diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-02 11:16:30 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-03 16:41:59 +0200 |
commit | a3daf52dd21ae03a8b04e1f9132a6713c9cc414f (patch) | |
tree | 3da8eac339f92e9a22feb1449db9115e6bf02413 /sd | |
parent | 387a9c445793e8377f85e508d935dc070fd8ab74 (diff) |
Base scale on 1.0, not on 100.0
Simplifies things by avoiding many repeated multiplications / divisions
by 100 during calculations.
Change-Id: Ib063d343549139c8d83e5b06570dc61f39ea0df6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165666
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/TextFittingTest.cxx | 22 | ||||
-rw-r--r-- | sd/source/ui/dlg/NotesChildWindow.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/view/drtxtob.cxx | 4 |
3 files changed, 14 insertions, 14 deletions
diff --git a/sd/qa/unit/TextFittingTest.cxx b/sd/qa/unit/TextFittingTest.cxx index 13f41ff793db..9fe7946f2289 100644 --- a/sd/qa/unit/TextFittingTest.cxx +++ b/sd/qa/unit/TextFittingTest.cxx @@ -44,8 +44,8 @@ CPPUNIT_TEST_FIXTURE(TextFittingTest, testTest) auto pTextObject = DynCastSdrTextObj(pPage->GetObj(0)); CPPUNIT_ASSERT(pTextObject); - CPPUNIT_ASSERT_DOUBLES_EQUAL(100.0, pTextObject->GetFontScale(), 1E-2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(100.0, pTextObject->GetSpacingScale(), 1E-2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, pTextObject->GetFontScale(), 1E-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, pTextObject->GetSpacingScale(), 1E-4); { OutlinerParaObject* pOutlinerParagraphObject = pTextObject->GetOutlinerParaObject(); @@ -73,16 +73,16 @@ CPPUNIT_TEST_FIXTURE(TextFittingTest, testTest) Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(sal_Int32(4), rEditEngine.GetParagraphCount()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(92.5, rEditEngine.getScalingParameters().fFontY, 1E-2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(80.0, rEditEngine.getScalingParameters().fSpacingY, 1E-2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.925, rEditEngine.getScalingParameters().fFontY, 1E-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.8, rEditEngine.getScalingParameters().fSpacingY, 1E-4); // Add paragraph 5 rEditView.SetSelection(ESelection(4, 0, 4, 0)); rEditView.InsertText(u"\nD5"_ustr); CPPUNIT_ASSERT_EQUAL(sal_Int32(5), rEditEngine.GetParagraphCount()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(70.0, rEditEngine.getScalingParameters().fFontY, 1E-2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(80.0, rEditEngine.getScalingParameters().fSpacingY, 1E-2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.7, rEditEngine.getScalingParameters().fFontY, 1E-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.8, rEditEngine.getScalingParameters().fSpacingY, 1E-4); // Add paragraph 6 rEditView.SetSelection(ESelection(5, 0, 5, 0)); @@ -104,17 +104,17 @@ CPPUNIT_TEST_FIXTURE(TextFittingTest, testTest) rEditView.DeleteSelected(); CPPUNIT_ASSERT_EQUAL(sal_Int32(3), rEditEngine.GetParagraphCount()); - // We are back to 100% - CPPUNIT_ASSERT_DOUBLES_EQUAL(100.0, rEditEngine.getScalingParameters().fFontY, 1E-2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(100.0, rEditEngine.getScalingParameters().fSpacingY, 1E-2); + // not ideal - scaling should be 100%, but close enough + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, rEditEngine.getScalingParameters().fFontY, 1E-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, rEditEngine.getScalingParameters().fSpacingY, 1E-4); // are we still in text edit mode? CPPUNIT_ASSERT_EQUAL(true, pView1->IsTextEdit()); pView1->SdrEndTextEdit(); CPPUNIT_ASSERT_EQUAL(false, pView1->IsTextEdit()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(100.0, pTextObject->GetFontScale(), 1E-2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(100.0, pTextObject->GetSpacingScale(), 1E-2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, pTextObject->GetFontScale(), 1E-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, pTextObject->GetSpacingScale(), 1E-4); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/source/ui/dlg/NotesChildWindow.cxx b/sd/source/ui/dlg/NotesChildWindow.cxx index 79c0bdaaa95b..d74b5339e3b9 100644 --- a/sd/source/ui/dlg/NotesChildWindow.cxx +++ b/sd/source/ui/dlg/NotesChildWindow.cxx @@ -180,7 +180,7 @@ void NotesEditWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea) // For setGlobalScale to work correctly EEControlBits::STRETCHING must be set. mrParentWindow.GetOutliner()->SetControlWord(mrParentWindow.GetOutliner()->GetControlWord() | EEControlBits::STRETCHING); - mrParentWindow.GetOutliner()->setScalingParameters({ 30.0, 30.0 }); + mrParentWindow.GetOutliner()->setScalingParameters({ 0.30, 0.30 }); provideNoteText(); diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx index 3b15ceaef650..0a75f4dd5cef 100644 --- a/sd/source/ui/view/drtxtob.cxx +++ b/sd/source/ui/view/drtxtob.cxx @@ -169,7 +169,7 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) case SID_ATTR_CHAR_STRIKEOUT: case SID_ATTR_CHAR_CASEMAP: { - double stretchY = 100.0; + double stretchY = 1.0; SvxScriptSetItem aSetItem( nSlotId, GetPool() ); aSetItem.GetItemSet().Put( aAttrSet, false ); @@ -207,7 +207,7 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) if( nSlotId == SID_ATTR_CHAR_FONTHEIGHT ) { SvxFontHeightItem aFontItem = dynamic_cast<const SvxFontHeightItem&>(*pI); - aFontItem.SetHeight(aFontItem.GetHeight() * (stretchY / 100.0), 100, aFontItem.GetPropUnit()); + aFontItem.SetHeight(aFontItem.GetHeight() * stretchY, 100, aFontItem.GetPropUnit()); aFontItem.SetWhich(nWhich); aAttrSet.Put( aFontItem ); } |