sd/source/ui/view/Outliner.cxx | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)
New commits: commit 06ddbd4a7a15b80b0286b359bd0a05812fd7ee75 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri May 29 08:33:42 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Jun 2 19:00:16 2020 +0200 sd: remove code dupl. when getting PDF text selection for LOK Change-Id: I61d0a9851e9cfe60e9672acec38946b0b25f310f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95349 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index 97792e5cd3b8..9e81a826bfb9 100644 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -693,11 +693,16 @@ basegfx::B2DRange b2DRectangleFromRectangle( const ::tools::Rectangle& rRect ) rRect.IsHeightEmpty() ? rRect.Top() : rRect.Bottom()); } -void getPDFSelections(std::vector<basegfx::B2DRectangle> & rSubSelections, - std::unique_ptr<VectorGraphicSearch> & rVectorGraphicSearch, - SdrObject* pObject) +basegfx::B2DRectangle getPDFSelection(std::unique_ptr<VectorGraphicSearch> & rVectorGraphicSearch, + SdrObject* pObject) { - basegfx::B2DSize aPdfPageSize = rVectorGraphicSearch->pageSize(); + basegfx::B2DRectangle aSelection; + + auto const & rTextRectangles = rVectorGraphicSearch->getTextRectangles(); + if (rTextRectangles.empty()) + return aSelection; + + basegfx::B2DSize aPdfPageSizeHMM = rVectorGraphicSearch->pageSize(); basegfx::B2DRectangle aObjectB2DRectHMM(b2DRectangleFromRectangle(pObject->GetLogicRect())); @@ -705,24 +710,24 @@ void getPDFSelections(std::vector<basegfx::B2DRectangle> & rSubSelections, // coordinates to the page relative coordinates basegfx::B2DHomMatrix aB2DMatrix; - aB2DMatrix.scale(aObjectB2DRectHMM.getWidth() / aPdfPageSize.getX(), - aObjectB2DRectHMM.getHeight() / aPdfPageSize.getY()); + aB2DMatrix.scale(aObjectB2DRectHMM.getWidth() / aPdfPageSizeHMM.getX(), + aObjectB2DRectHMM.getHeight() / aPdfPageSizeHMM.getY()); aB2DMatrix.translate(aObjectB2DRectHMM.getMinX(), aObjectB2DRectHMM.getMinY()); - basegfx::B2DRectangle aCombined; for (auto const & rRectangle : rVectorGraphicSearch->getTextRectangles()) { basegfx::B2DRectangle aRectangle(rRectangle); aRectangle *= aB2DMatrix; - if (aCombined.isEmpty()) - aCombined = aRectangle; + + if (aSelection.isEmpty()) + aSelection = aRectangle; else - aCombined.expand(aRectangle); + aSelection.expand(aRectangle); } - rSubSelections.push_back(aCombined); + return aSelection; } } // end namespace @@ -851,7 +856,9 @@ bool SdOutliner::SearchAndReplaceOnce(std::vector<sd::SearchSelection>* pSelecti mpView->UnmarkAllObj(pPageView); std::vector<basegfx::B2DRectangle> aSubSelections; - getPDFSelections(aSubSelections, mpImpl->mpVectorGraphicSearch, mpObj); + basegfx::B2DRectangle aSubSelection = getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj); + if (!aSubSelection.isEmpty()) + aSubSelections.push_back(aSubSelection); mpView->MarkObj(mpObj, pPageView, false, false, aSubSelections); } } @@ -1252,7 +1259,10 @@ void SdOutliner::ProvideNextTextObject() mpView->UnmarkAllObj(pPageView); std::vector<basegfx::B2DRectangle> aSubSelections; - getPDFSelections(aSubSelections, mpImpl->mpVectorGraphicSearch, mpObj); + basegfx::B2DRectangle aSubSelection = getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj); + if (!aSubSelection.isEmpty()) + aSubSelections.push_back(aSubSelection); + mpView->MarkObj(mpObj, pPageView, false, false, aSubSelections); mpDrawDocument->GetDocSh()->SetWaitCursor( false ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits