diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-08-10 08:10:19 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-08-11 06:41:17 +0200 |
commit | fa339b3adb53300ae68913bed87e18caf9f2e262 (patch) | |
tree | e3aed1bb38664cfe343a6d7f0803d2312c86c76a /sd | |
parent | e89404f00b25cfddd4098b4b2cf900d190617221 (diff) |
convert some LogicToLogic calls to use o3tl::convert instead
If a LogicToLogic uses fixed units, we can use o3tl::convert
instead. We can also do the same for all other cases where
LogicToLogic is used, but that needs additional investigation to
determine if it is safe to do so.
Note:
MapUnit::Pixel is converted to o3tl::Length::pt because it assumed
72 PPI for a logical pixel, which corresponds with the conversion
rate of a point (72 PPI).
Today, 96 PPI is standard, which is also used for o3tl::Length:px.
Change-Id: I29126df38bfcfda74b5d83d4cb880a378aecd18b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120230
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/tiledrendering/LOKitSearchTest.cxx | 28 | ||||
-rw-r--r-- | sd/source/core/annotations/Annotation.cxx | 2 | ||||
-rw-r--r-- | sd/source/core/drawdoc.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/view/Outliner.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/sdview.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/sdwindow.cxx | 4 |
6 files changed, 24 insertions, 20 deletions
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx index 762faaac1b56..dd661553b425 100644 --- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx +++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx @@ -347,9 +347,9 @@ void LOKitSearchTest::testSearchInPDF() CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount); CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); - CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 483"), + CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 482"), mpCallbackRecorder->m_aSearchResultSelection[0]); - CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)), + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 483)), mpCallbackRecorder->m_aSelection[0]); // Search again - same result @@ -359,9 +359,9 @@ void LOKitSearchTest::testSearchInPDF() CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount); CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); - CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 483"), + CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 482"), mpCallbackRecorder->m_aSearchResultSelection[0]); - CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)), + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 483)), mpCallbackRecorder->m_aSelection[0]); } @@ -444,7 +444,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]); - CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"), + CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 498"), mpCallbackRecorder->m_aSearchResultSelection[0]); // Search for "him" @@ -457,7 +457,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]); - CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"), + CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1099, 498"), mpCallbackRecorder->m_aSearchResultSelection[0]); // Search for "him" @@ -470,7 +470,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]); - CPPUNIT_ASSERT_EQUAL(OString("9463, 1308, 1099, 499"), + CPPUNIT_ASSERT_EQUAL(OString("9463, 1308, 1099, 498"), mpCallbackRecorder->m_aSearchResultSelection[0]); // Search for "him" @@ -483,7 +483,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]); - CPPUNIT_ASSERT_EQUAL(OString("5592, 2964, 1100, 499"), + CPPUNIT_ASSERT_EQUAL(OString("5592, 2964, 1099, 498"), mpCallbackRecorder->m_aSearchResultSelection[0]); // Search for "him" - back to start @@ -496,7 +496,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]); - CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"), + CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 498"), mpCallbackRecorder->m_aSearchResultSelection[0]); } @@ -547,7 +547,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]); - CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"), + CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1099, 498"), mpCallbackRecorder->m_aSearchResultSelection[0]); // Search for "him" @@ -560,7 +560,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]); - CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"), + CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 498"), mpCallbackRecorder->m_aSearchResultSelection[0]); // Search for "him" @@ -573,7 +573,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]); - CPPUNIT_ASSERT_EQUAL(OString("5592, 2964, 1100, 499"), + CPPUNIT_ASSERT_EQUAL(OString("5592, 2964, 1099, 498"), mpCallbackRecorder->m_aSearchResultSelection[0]); // Search for "him" @@ -586,7 +586,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]); - CPPUNIT_ASSERT_EQUAL(OString("9463, 1308, 1099, 499"), + CPPUNIT_ASSERT_EQUAL(OString("9463, 1308, 1099, 498"), mpCallbackRecorder->m_aSearchResultSelection[0]); // Search for "him" - back to start @@ -599,7 +599,7 @@ void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]); - CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"), + CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1099, 498"), mpCallbackRecorder->m_aSearchResultSelection[0]); } diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx index 7e9d4aff275a..1d1ca39fc9dd 100644 --- a/sd/source/core/annotations/Annotation.cxx +++ b/sd/source/core/annotations/Annotation.cxx @@ -359,7 +359,7 @@ std::string lcl_LOKGetCommentPayload(CommentNotificationType nType, uno::Referen geometry::RealPoint2D const & rPoint = rxAnnotation->getPosition(); geometry::RealSize2D const & rSize = rxAnnotation->getSize(); ::tools::Rectangle aRectangle(Point(rPoint.X * 100.0, rPoint.Y * 100.0), Size(rSize.Width * 100.0, rSize.Height * 100.0)); - aRectangle = OutputDevice::LogicToLogic(aRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + aRectangle = o3tl::convert(aRectangle, o3tl::Length::mm100, o3tl::Length::twip); OString sRectangle = aRectangle.toString(); aAnnotation.put("rectangle", sRectangle.getStr()); } diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index baf1d57fea18..3734d4aa70ea 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -163,7 +163,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) SetScaleUnit(MapUnit::Map100thMM); SetScaleFraction(Fraction(1, 1)); - SetDefaultFontHeight(847); // 24p + SetDefaultFontHeight(o3tl::convert(24, o3tl::Length::pt, o3tl::Length::mm100)); m_pItemPool->SetDefaultMetric(MapUnit::Map100thMM); m_pItemPool->FreezeIdRanges(); diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index dd823204ced1..316e330a7bed 100644 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -743,7 +743,7 @@ void SdOutliner::sendLOKSearchResultCallback(const std::shared_ptr<sd::ViewShell tools::Rectangle aSelection(Point(aSelectionHMM.getMinX(), aSelectionHMM.getMinY()), Size(aSelectionHMM.getWidth(), aSelectionHMM.getHeight())); - aSelection = OutputDevice::LogicToLogic(aSelection, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + aSelection = o3tl::convert(aSelection, o3tl::Length::mm100, o3tl::Length::twip); aLogicRects.push_back(aSelection); } else @@ -757,7 +757,7 @@ void SdOutliner::sendLOKSearchResultCallback(const std::shared_ptr<sd::ViewShell { for (tools::Rectangle& rRectangle : aLogicRects) { - rRectangle = OutputDevice::LogicToLogic(rRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + rRectangle = o3tl::convert(rRectangle, o3tl::Length::mm100, o3tl::Length::twip); } } } diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index d2b9816f40e9..49b384b98e7b 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -689,7 +689,9 @@ bool View::SdrBeginTextEdit( { ::tools::Rectangle aRectangle = pView->GetOutputArea(); if (pWin && pWin->GetMapMode().GetMapUnit() == MapUnit::Map100thMM) - aRectangle = OutputDevice::LogicToLogic(aRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + { + aRectangle = o3tl::convert(aRectangle, o3tl::Length::mm100, o3tl::Length::twip); + } OString sRectangle = aRectangle.toString(); SfxLokHelper::notifyOtherViews(&mpViewSh->GetViewShellBase(), LOK_CALLBACK_VIEW_LOCK, "rectangle", sRectangle); } diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx index bb29151b4b1e..f639b463e124 100644 --- a/sd/source/ui/view/sdwindow.cxx +++ b/sd/source/ui/view/sdwindow.cxx @@ -1036,7 +1036,9 @@ void Window::LogicInvalidate(const ::tools::Rectangle* pRectangle) { aRectangle = *pRectangle; if (GetMapMode().GetMapUnit() == MapUnit::Map100thMM) - aRectangle = OutputDevice::LogicToLogic(aRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + { + aRectangle = o3tl::convert(aRectangle, o3tl::Length::mm100, o3tl::Length::twip); + } pResultRectangle = &aRectangle; } SfxViewShell& rSfxViewShell = pDrawViewShell->GetViewShellBase(); |