Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(881)

Side by Side Diff: fpdfsdk/include/fsdk_mgr.h

Issue 1657663003: Merge to XFA: Remove CGW_ArrayTemplate and its O(n^2 log n) sort. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/include/fsdk_baseform.h ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef FPDFSDK_INCLUDE_FSDK_MGR_H_ 7 #ifndef FPDFSDK_INCLUDE_FSDK_MGR_H_
8 #define FPDFSDK_INCLUDE_FSDK_MGR_H_ 8 #define FPDFSDK_INCLUDE_FSDK_MGR_H_
9 9
10 #include <map> 10 #include <map>
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 private: 554 private:
555 std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap; 555 std::map<UnderlyingPageType*, CPDFSDK_PageView*> m_pageMap;
556 UnderlyingDocumentType* m_pDoc; 556 UnderlyingDocumentType* m_pDoc;
557 std::unique_ptr<CPDFSDK_InterForm> m_pInterForm; 557 std::unique_ptr<CPDFSDK_InterForm> m_pInterForm;
558 CPDFSDK_Annot* m_pFocusAnnot; 558 CPDFSDK_Annot* m_pFocusAnnot;
559 CPDFDoc_Environment* m_pEnv; 559 CPDFDoc_Environment* m_pEnv;
560 std::unique_ptr<CPDF_OCContext> m_pOccontent; 560 std::unique_ptr<CPDF_OCContext> m_pOccontent;
561 FX_BOOL m_bChangeMask; 561 FX_BOOL m_bChangeMask;
562 FX_BOOL m_bBeingDestroyed; 562 FX_BOOL m_bBeingDestroyed;
563 }; 563 };
564
564 class CPDFSDK_PageView final { 565 class CPDFSDK_PageView final {
565 public: 566 public:
566 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page); 567 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page);
567 ~CPDFSDK_PageView(); 568 ~CPDFSDK_PageView();
568 569
569 #ifdef PDF_ENABLE_XFA 570 #ifdef PDF_ENABLE_XFA
570 void PageView_OnDraw(CFX_RenderDevice* pDevice, 571 void PageView_OnDraw(CFX_RenderDevice* pDevice,
571 CFX_Matrix* pUser2Device, 572 CFX_Matrix* pUser2Device,
572 CPDF_RenderOptions* pOptions, 573 CPDF_RenderOptions* pOptions,
573 const FX_RECT& pClip); 574 const FX_RECT& pClip);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 CPDFSDK_Widget* m_CaptureWidget; 661 CPDFSDK_Widget* m_CaptureWidget;
661 FX_BOOL m_bTakeOverPage; 662 FX_BOOL m_bTakeOverPage;
662 #endif // PDF_ENABLE_XFA 663 #endif // PDF_ENABLE_XFA
663 FX_BOOL m_bEnterWidget; 664 FX_BOOL m_bEnterWidget;
664 FX_BOOL m_bExitWidget; 665 FX_BOOL m_bExitWidget;
665 FX_BOOL m_bOnWidget; 666 FX_BOOL m_bOnWidget;
666 FX_BOOL m_bValid; 667 FX_BOOL m_bValid;
667 FX_BOOL m_bLocked; 668 FX_BOOL m_bLocked;
668 }; 669 };
669 670
670 template <class TYPE>
671 class CGW_ArrayTemplate : public CFX_ArrayTemplate<TYPE> {
672 public:
673 CGW_ArrayTemplate() {}
674 ~CGW_ArrayTemplate() {}
675
676 typedef int (*LP_COMPARE)(TYPE p1, TYPE p2);
677
678 void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE) {
679 int nSize = this->GetSize();
680 QuickSort(0, nSize - 1, bAscent, pCompare);
681 }
682
683 private:
684 void QuickSort(FX_UINT nStartPos,
685 FX_UINT nStopPos,
686 FX_BOOL bAscend,
687 LP_COMPARE pCompare) {
688 if (nStartPos >= nStopPos)
689 return;
690
691 if ((nStopPos - nStartPos) == 1) {
692 TYPE Value1 = this->GetAt(nStartPos);
693 TYPE Value2 = this->GetAt(nStopPos);
694
695 int iGreate = (*pCompare)(Value1, Value2);
696 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) {
697 this->SetAt(nStartPos, Value2);
698 this->SetAt(nStopPos, Value1);
699 }
700 return;
701 }
702
703 FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2;
704 FX_UINT i = nStartPos;
705
706 TYPE Value = this->GetAt(m);
707
708 while (i < m) {
709 TYPE temp = this->GetAt(i);
710
711 int iGreate = (*pCompare)(temp, Value);
712 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) {
713 this->InsertAt(m + 1, temp);
714 this->RemoveAt(i);
715 m--;
716 } else {
717 i++;
718 }
719 }
720
721 FX_UINT j = nStopPos;
722
723 while (j > m) {
724 TYPE temp = this->GetAt(j);
725
726 int iGreate = (*pCompare)(temp, Value);
727 if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0)) {
728 this->RemoveAt(j);
729 this->InsertAt(m, temp);
730 m++;
731 } else {
732 j--;
733 }
734 }
735
736 if (nStartPos < m)
737 QuickSort(nStartPos, m, bAscend, pCompare);
738 if (nStopPos > m)
739 QuickSort(m, nStopPos, bAscend, pCompare);
740 }
741 };
742
743 #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_ 671 #endif // FPDFSDK_INCLUDE_FSDK_MGR_H_
OLDNEW
« no previous file with comments | « fpdfsdk/include/fsdk_baseform.h ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698