OLD | NEW |
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 #include "fpdfsdk/include/fsdk_baseform.h" | 7 #include "fpdfsdk/include/fsdk_baseform.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2793 fTop = rcAnnot.top; | 2793 fTop = rcAnnot.top; |
2794 } | 2794 } |
2795 } | 2795 } |
2796 if (nLeftTopIndex >= 0) { | 2796 if (nLeftTopIndex >= 0) { |
2797 CPDFSDK_Annot* pLeftTopAnnot = sa[nLeftTopIndex]; | 2797 CPDFSDK_Annot* pLeftTopAnnot = sa[nLeftTopIndex]; |
2798 CFX_FloatRect rcLeftTop = GetAnnotRect(pLeftTopAnnot); | 2798 CFX_FloatRect rcLeftTop = GetAnnotRect(pLeftTopAnnot); |
2799 m_Annots.push_back(pLeftTopAnnot); | 2799 m_Annots.push_back(pLeftTopAnnot); |
2800 sa.erase(sa.begin() + nLeftTopIndex); | 2800 sa.erase(sa.begin() + nLeftTopIndex); |
2801 | 2801 |
2802 std::vector<int> aSelect; | 2802 std::vector<int> aSelect; |
2803 for (int i = 0; i < sa.size(); ++i) { | 2803 for (size_t i = 0; i < sa.size(); ++i) { |
2804 CFX_FloatRect rcAnnot = GetAnnotRect(sa[i]); | 2804 CFX_FloatRect rcAnnot = GetAnnotRect(sa[i]); |
2805 FX_FLOAT fCenterY = (rcAnnot.top + rcAnnot.bottom) / 2.0f; | 2805 FX_FLOAT fCenterY = (rcAnnot.top + rcAnnot.bottom) / 2.0f; |
2806 if (fCenterY > rcLeftTop.bottom && fCenterY < rcLeftTop.top) | 2806 if (fCenterY > rcLeftTop.bottom && fCenterY < rcLeftTop.top) |
2807 aSelect.push_back(i); | 2807 aSelect.push_back(i); |
2808 } | 2808 } |
2809 for (int i = 0; i < aSelect.size(); ++i) | 2809 for (size_t i = 0; i < aSelect.size(); ++i) |
2810 m_Annots.push_back(sa[aSelect[i]]); | 2810 m_Annots.push_back(sa[aSelect[i]]); |
2811 | 2811 |
2812 for (int i = aSelect.size() - 1; i >= 0; --i) | 2812 for (int i = aSelect.size() - 1; i >= 0; --i) |
2813 sa.erase(sa.begin() + aSelect[i]); | 2813 sa.erase(sa.begin() + aSelect[i]); |
2814 } | 2814 } |
2815 } | 2815 } |
2816 } break; | 2816 } break; |
2817 case COLUMN: { | 2817 case COLUMN: { |
2818 std::vector<CPDFSDK_Annot*> sa; | 2818 std::vector<CPDFSDK_Annot*> sa; |
2819 for (size_t i = 0; i < m_pPageView->CountAnnots(); ++i) { | 2819 for (size_t i = 0; i < m_pPageView->CountAnnots(); ++i) { |
(...skipping 17 matching lines...) Expand all Loading... |
2837 } | 2837 } |
2838 } | 2838 } |
2839 | 2839 |
2840 if (nLeftTopIndex >= 0) { | 2840 if (nLeftTopIndex >= 0) { |
2841 CPDFSDK_Annot* pLeftTopAnnot = sa[nLeftTopIndex]; | 2841 CPDFSDK_Annot* pLeftTopAnnot = sa[nLeftTopIndex]; |
2842 CFX_FloatRect rcLeftTop = GetAnnotRect(pLeftTopAnnot); | 2842 CFX_FloatRect rcLeftTop = GetAnnotRect(pLeftTopAnnot); |
2843 m_Annots.push_back(pLeftTopAnnot); | 2843 m_Annots.push_back(pLeftTopAnnot); |
2844 sa.erase(sa.begin() + nLeftTopIndex); | 2844 sa.erase(sa.begin() + nLeftTopIndex); |
2845 | 2845 |
2846 std::vector<int> aSelect; | 2846 std::vector<int> aSelect; |
2847 for (int i = 0; i < sa.size(); ++i) { | 2847 for (size_t i = 0; i < sa.size(); ++i) { |
2848 CFX_FloatRect rcAnnot = GetAnnotRect(sa[i]); | 2848 CFX_FloatRect rcAnnot = GetAnnotRect(sa[i]); |
2849 FX_FLOAT fCenterX = (rcAnnot.left + rcAnnot.right) / 2.0f; | 2849 FX_FLOAT fCenterX = (rcAnnot.left + rcAnnot.right) / 2.0f; |
2850 if (fCenterX > rcLeftTop.left && fCenterX < rcLeftTop.right) | 2850 if (fCenterX > rcLeftTop.left && fCenterX < rcLeftTop.right) |
2851 aSelect.push_back(i); | 2851 aSelect.push_back(i); |
2852 } | 2852 } |
2853 for (int i = 0; i < aSelect.size(); ++i) | 2853 for (size_t i = 0; i < aSelect.size(); ++i) |
2854 m_Annots.push_back(sa[aSelect[i]]); | 2854 m_Annots.push_back(sa[aSelect[i]]); |
2855 | 2855 |
2856 for (int i = aSelect.size() - 1; i >= 0; --i) | 2856 for (int i = aSelect.size() - 1; i >= 0; --i) |
2857 sa.erase(sa.begin() + aSelect[i]); | 2857 sa.erase(sa.begin() + aSelect[i]); |
2858 } | 2858 } |
2859 } | 2859 } |
2860 break; | 2860 break; |
2861 } | 2861 } |
2862 } | 2862 } |
2863 } | 2863 } |
2864 | 2864 |
2865 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { | 2865 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { |
2866 CFX_FloatRect rcAnnot; | 2866 CFX_FloatRect rcAnnot; |
2867 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); | 2867 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); |
2868 return rcAnnot; | 2868 return rcAnnot; |
2869 } | 2869 } |
OLD | NEW |