summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-05-29 08:33:42 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-07-30 14:53:07 +0200
commit2f3ef47e64384c03e908ae56b7da97a13b78858c (patch)
treeec4632b271f661e28ff3f1c37a6280274457cded
parente17d264a2bf73bf3a0ce125e9d373d2a08023f0e (diff)
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 <quikee@gmail.com> (cherry picked from commit 06ddbd4a7a15b80b0286b359bd0a05812fd7ee75) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95924 Tested-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 42cfe2309bd9731d0e5b497356af5834757521bb)
-rw-r--r--sd/source/ui/view/Outliner.cxx36
1 files changed, 23 insertions, 13 deletions
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 7d8ba3eb9e13..6dff606cbf26 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -721,11 +721,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()));
@@ -733,24 +738,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
@@ -879,7 +884,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);
}
}
@@ -1280,7 +1287,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 );