sd/source/ui/app/scalectrl.cxx | 20 - sd/source/ui/dlg/tpoption.cxx | 572 ++++++++++++++++++++++------------------- 2 files changed, 326 insertions(+), 266 deletions(-)
New commits: commit 8e27423470dd808713514ee93c340a8061d560b5 Author: Manas Todi <manastodi1...@gmail.com> AuthorDate: Sun Aug 10 15:13:50 2025 +0530 Commit: Heiko Tietze <heiko.tie...@documentfoundation.org> CommitDate: Thu Aug 14 13:43:24 2025 +0200 tdf#162501: SD: Update list of drawing scale factors The predefined list of drawing scales in Draw/Impress was missing common factors used for imperial/English units, such as 1:12. As per the design team's recommendation in the bug report, this patch updates the hardcoded list to include these factors while maintaining a concise set of useful metric scales. The new list is: 1, 2, 5, 10, 12, 24, 48, 50, 100. Additionally, the array size in sd/source/ui/app/scalectrl.cxx was refactored from a magic number to use a TABLE_COUNT constant, matching the pattern in tpoption.cxx for improved maintainability. Change-Id: I1c2610fa218233f320207594ba1086a749c636be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189309 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org> diff --git a/sd/source/ui/app/scalectrl.cxx b/sd/source/ui/app/scalectrl.cxx index a12cbdd3d660..041e290f3a5f 100644 --- a/sd/source/ui/app/scalectrl.cxx +++ b/sd/source/ui/app/scalectrl.cxx @@ -33,6 +33,8 @@ #include <sdresid.hxx> #include <strings.hrc> +#define TABLE_COUNT 9 + SFX_IMPL_STATUSBAR_CONTROL(SdScaleControl, SfxStringItem); // class SdScaleControl ------------------------------------------ @@ -79,12 +81,12 @@ void SdScaleControl::Command(const CommandEvent& rCEvt) Application::CreateBuilder(nullptr, u"modules/simpress/ui/masterpagemenu.ui"_ustr)); std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu(u"menu"_ustr)); - sal_uInt16 aTable[12] = { 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 50, 100 }; + sal_uInt16 aTable[TABLE_COUNT] = { 1, 2, 5, 10, 12, 24, 48, 50, 100 }; - for (sal_uInt16 i = 11; i > 0; i--) - xPopup->append(OUString::number(12 - i), OUString::number(aTable[i]) + ":1"); - for (sal_uInt16 i = 0; i < 12; i++) - xPopup->append(OUString::number(12 + i), "1:" + OUString::number(aTable[i])); + for (sal_uInt16 i = TABLE_COUNT - 1; i > 0; i--) + xPopup->append(OUString::number(TABLE_COUNT - i), OUString::number(aTable[i]) + ":1"); + for (sal_uInt16 i = 0; i < TABLE_COUNT; i++) + xPopup->append(OUString::number(TABLE_COUNT + i), "1:" + OUString::number(aTable[i])); ::tools::Rectangle aRect(rCEvt.GetMousePosPixel(), Size(1, 1)); weld::Window* pParent = weld::GetPopupParent(GetStatusBar(), aRect); @@ -95,12 +97,12 @@ void SdScaleControl::Command(const CommandEvent& rCEvt) sal_Int32 i = sResult.toUInt32(); sal_Int32 nX; sal_Int32 nY; - if (i > 11) + if (i > TABLE_COUNT - 1) nX = 1; else - nX = aTable[(12 - i) % 12]; - if (i > 11) - nY = aTable[i % 12]; + nX = aTable[(TABLE_COUNT - i) % TABLE_COUNT]; + if (i > TABLE_COUNT - 1) + nY = aTable[i % TABLE_COUNT]; else nY = 1; pDoc->SetUIScale(Fraction(nX, nY)); diff --git a/sd/source/ui/dlg/tpoption.cxx b/sd/source/ui/dlg/tpoption.cxx index 48f004243733..f92c9435feea 100644 --- a/sd/source/ui/dlg/tpoption.cxx +++ b/sd/source/ui/dlg/tpoption.cxx @@ -44,17 +44,16 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; -SdTpOptionsSnap::SdTpOptionsSnap(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) +SdTpOptionsSnap::SdTpOptionsSnap(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rInAttrs) : SvxGridTabPage(pPage, pController, rInAttrs) { m_xSnapFrames->show(); } -SdTpOptionsSnap::~SdTpOptionsSnap() -{ -} +SdTpOptionsSnap::~SdTpOptionsSnap() {} -bool SdTpOptionsSnap::FillItemSet( SfxItemSet* rAttrs ) +bool SdTpOptionsSnap::FillItemSet(SfxItemSet* rAttrs) { SvxGridTabPage::FillItemSet(rAttrs); bool bDrawMode = SvxGridTabPage::IsDrawMode(); @@ -64,29 +63,50 @@ bool SdTpOptionsSnap::FillItemSet( SfxItemSet* rAttrs ) if (bDrawMode) { - officecfg::Office::Draw::Snap::Object::SnapLine::set( m_xCbxSnapHelplines->get_active(), batch ); - officecfg::Office::Draw::Snap::Object::PageMargin::set( m_xCbxSnapBorder->get_active(), batch ); - officecfg::Office::Draw::Snap::Object::ObjectFrame::set( m_xCbxSnapFrame->get_active(), batch ); - officecfg::Office::Draw::Snap::Object::ObjectPoint::set( m_xCbxSnapPoints->get_active(), batch ); - officecfg::Office::Draw::Snap::Position::CreatingMoving::set( m_xCbxOrtho->get_active(), batch ); - officecfg::Office::Draw::Snap::Position::ExtendEdges::set( m_xCbxBigOrtho->get_active(), batch ); - officecfg::Office::Draw::Snap::Position::Rotating::set( m_xCbxRotate->get_active(), batch ); - officecfg::Office::Draw::Snap::Object::Range::set( static_cast<sal_Int16>(m_xMtrFldSnapArea->get_value(FieldUnit::PIXEL)), batch ); - officecfg::Office::Draw::Snap::Position::RotatingValue::set( static_cast<sal_Int32>(Degree100(m_xMtrFldAngle->get_value(FieldUnit::DEGREE))), batch ); - officecfg::Office::Draw::Snap::Position::PointReduction::set ( static_cast<sal_Int32>(Degree100(m_xMtrFldBezAngle->get_value(FieldUnit::DEGREE))), batch ); + officecfg::Office::Draw::Snap::Object::SnapLine::set(m_xCbxSnapHelplines->get_active(), + batch); + officecfg::Office::Draw::Snap::Object::PageMargin::set(m_xCbxSnapBorder->get_active(), + batch); + officecfg::Office::Draw::Snap::Object::ObjectFrame::set(m_xCbxSnapFrame->get_active(), + batch); + officecfg::Office::Draw::Snap::Object::ObjectPoint::set(m_xCbxSnapPoints->get_active(), + batch); + officecfg::Office::Draw::Snap::Position::CreatingMoving::set(m_xCbxOrtho->get_active(), + batch); + officecfg::Office::Draw::Snap::Position::ExtendEdges::set(m_xCbxBigOrtho->get_active(), + batch); + officecfg::Office::Draw::Snap::Position::Rotating::set(m_xCbxRotate->get_active(), batch); + officecfg::Office::Draw::Snap::Object::Range::set( + static_cast<sal_Int16>(m_xMtrFldSnapArea->get_value(FieldUnit::PIXEL)), batch); + officecfg::Office::Draw::Snap::Position::RotatingValue::set( + static_cast<sal_Int32>(Degree100(m_xMtrFldAngle->get_value(FieldUnit::DEGREE))), batch); + officecfg::Office::Draw::Snap::Position::PointReduction::set( + static_cast<sal_Int32>(Degree100(m_xMtrFldBezAngle->get_value(FieldUnit::DEGREE))), + batch); } else { - officecfg::Office::Impress::Snap::Object::SnapLine::set( m_xCbxSnapHelplines->get_active(), batch ); - officecfg::Office::Impress::Snap::Object::PageMargin::set( m_xCbxSnapBorder->get_active(), batch ); - officecfg::Office::Impress::Snap::Object::ObjectFrame::set( m_xCbxSnapFrame->get_active(), batch ); - officecfg::Office::Impress::Snap::Object::ObjectPoint::set( m_xCbxSnapPoints->get_active(), batch ); - officecfg::Office::Impress::Snap::Position::CreatingMoving::set( m_xCbxOrtho->get_active(), batch ); - officecfg::Office::Impress::Snap::Position::ExtendEdges::set( m_xCbxBigOrtho->get_active(), batch ); - officecfg::Office::Impress::Snap::Position::Rotating::set( m_xCbxRotate->get_active(), batch ); - officecfg::Office::Impress::Snap::Object::Range::set( static_cast<sal_Int16>(m_xMtrFldSnapArea->get_value(FieldUnit::PIXEL)), batch ); - officecfg::Office::Impress::Snap::Position::RotatingValue::set( static_cast<sal_Int32>(Degree100(m_xMtrFldAngle->get_value(FieldUnit::DEGREE))), batch ); - officecfg::Office::Impress::Snap::Position::PointReduction::set ( static_cast<sal_Int32>(Degree100(m_xMtrFldBezAngle->get_value(FieldUnit::DEGREE))), batch ); + officecfg::Office::Impress::Snap::Object::SnapLine::set(m_xCbxSnapHelplines->get_active(), + batch); + officecfg::Office::Impress::Snap::Object::PageMargin::set(m_xCbxSnapBorder->get_active(), + batch); + officecfg::Office::Impress::Snap::Object::ObjectFrame::set(m_xCbxSnapFrame->get_active(), + batch); + officecfg::Office::Impress::Snap::Object::ObjectPoint::set(m_xCbxSnapPoints->get_active(), + batch); + officecfg::Office::Impress::Snap::Position::CreatingMoving::set(m_xCbxOrtho->get_active(), + batch); + officecfg::Office::Impress::Snap::Position::ExtendEdges::set(m_xCbxBigOrtho->get_active(), + batch); + officecfg::Office::Impress::Snap::Position::Rotating::set(m_xCbxRotate->get_active(), + batch); + officecfg::Office::Impress::Snap::Object::Range::set( + static_cast<sal_Int16>(m_xMtrFldSnapArea->get_value(FieldUnit::PIXEL)), batch); + officecfg::Office::Impress::Snap::Position::RotatingValue::set( + static_cast<sal_Int32>(Degree100(m_xMtrFldAngle->get_value(FieldUnit::DEGREE))), batch); + officecfg::Office::Impress::Snap::Position::PointReduction::set( + static_cast<sal_Int32>(Degree100(m_xMtrFldBezAngle->get_value(FieldUnit::DEGREE))), + batch); } batch->commit(); @@ -96,92 +116,101 @@ bool SdTpOptionsSnap::FillItemSet( SfxItemSet* rAttrs ) return true; } -void SdTpOptionsSnap::Reset( const SfxItemSet* rAttrs ) +void SdTpOptionsSnap::Reset(const SfxItemSet* rAttrs) { SvxGridTabPage::Reset(rAttrs); bool bDrawMode = SvxGridTabPage::IsDrawMode(); if (bDrawMode) { - m_xCbxSnapHelplines->set_active( officecfg::Office::Draw::Snap::Object::SnapLine::get() ); - m_xCbxSnapBorder->set_active( officecfg::Office::Draw::Snap::Object::PageMargin::get() ); - m_xCbxSnapFrame->set_active( officecfg::Office::Draw::Snap::Object::ObjectFrame::get() ); - m_xCbxSnapPoints->set_active( officecfg::Office::Draw::Snap::Object::ObjectPoint::get() ); - m_xCbxOrtho->set_active( officecfg::Office::Draw::Snap::Position::CreatingMoving::get() ); - m_xCbxBigOrtho->set_active( officecfg::Office::Draw::Snap::Position::ExtendEdges::get() ); - m_xCbxRotate->set_active( officecfg::Office::Draw::Snap::Position::Rotating::get() ); - m_xMtrFldSnapArea->set_value( officecfg::Office::Draw::Snap::Object::Range::get(), FieldUnit::PIXEL); - m_xMtrFldAngle->set_value( officecfg::Office::Draw::Snap::Position::RotatingValue::get(), FieldUnit::DEGREE); - m_xMtrFldBezAngle->set_value( officecfg::Office::Draw::Snap::Position::PointReduction::get(), FieldUnit::DEGREE); + m_xCbxSnapHelplines->set_active(officecfg::Office::Draw::Snap::Object::SnapLine::get()); + m_xCbxSnapBorder->set_active(officecfg::Office::Draw::Snap::Object::PageMargin::get()); + m_xCbxSnapFrame->set_active(officecfg::Office::Draw::Snap::Object::ObjectFrame::get()); + m_xCbxSnapPoints->set_active(officecfg::Office::Draw::Snap::Object::ObjectPoint::get()); + m_xCbxOrtho->set_active(officecfg::Office::Draw::Snap::Position::CreatingMoving::get()); + m_xCbxBigOrtho->set_active(officecfg::Office::Draw::Snap::Position::ExtendEdges::get()); + m_xCbxRotate->set_active(officecfg::Office::Draw::Snap::Position::Rotating::get()); + m_xMtrFldSnapArea->set_value(officecfg::Office::Draw::Snap::Object::Range::get(), + FieldUnit::PIXEL); + m_xMtrFldAngle->set_value(officecfg::Office::Draw::Snap::Position::RotatingValue::get(), + FieldUnit::DEGREE); + m_xMtrFldBezAngle->set_value(officecfg::Office::Draw::Snap::Position::PointReduction::get(), + FieldUnit::DEGREE); } else { - m_xCbxSnapHelplines->set_active( officecfg::Office::Impress::Snap::Object::SnapLine::get() ); - m_xCbxSnapBorder->set_active( officecfg::Office::Impress::Snap::Object::PageMargin::get() ); - m_xCbxSnapFrame->set_active( officecfg::Office::Impress::Snap::Object::ObjectFrame::get() ); - m_xCbxSnapPoints->set_active( officecfg::Office::Impress::Snap::Object::ObjectPoint::get() ); - m_xCbxOrtho->set_active( officecfg::Office::Impress::Snap::Position::CreatingMoving::get() ); - m_xCbxBigOrtho->set_active( officecfg::Office::Impress::Snap::Position::ExtendEdges::get() ); - m_xCbxRotate->set_active( officecfg::Office::Impress::Snap::Position::Rotating::get() ); - m_xMtrFldSnapArea->set_value( officecfg::Office::Impress::Snap::Object::Range::get(), FieldUnit::PIXEL); - m_xMtrFldAngle->set_value( officecfg::Office::Impress::Snap::Position::RotatingValue::get(), FieldUnit::DEGREE); - m_xMtrFldBezAngle->set_value( officecfg::Office::Impress::Snap::Position::PointReduction::get(), FieldUnit::DEGREE); + m_xCbxSnapHelplines->set_active(officecfg::Office::Impress::Snap::Object::SnapLine::get()); + m_xCbxSnapBorder->set_active(officecfg::Office::Impress::Snap::Object::PageMargin::get()); + m_xCbxSnapFrame->set_active(officecfg::Office::Impress::Snap::Object::ObjectFrame::get()); + m_xCbxSnapPoints->set_active(officecfg::Office::Impress::Snap::Object::ObjectPoint::get()); + m_xCbxOrtho->set_active(officecfg::Office::Impress::Snap::Position::CreatingMoving::get()); + m_xCbxBigOrtho->set_active(officecfg::Office::Impress::Snap::Position::ExtendEdges::get()); + m_xCbxRotate->set_active(officecfg::Office::Impress::Snap::Position::Rotating::get()); + m_xMtrFldSnapArea->set_value(officecfg::Office::Impress::Snap::Object::Range::get(), + FieldUnit::PIXEL); + m_xMtrFldAngle->set_value(officecfg::Office::Impress::Snap::Position::RotatingValue::get(), + FieldUnit::DEGREE); + m_xMtrFldBezAngle->set_value( + officecfg::Office::Impress::Snap::Position::PointReduction::get(), FieldUnit::DEGREE); } - bool bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Object::SnapLine::isReadOnly() : - officecfg::Office::Impress::Snap::Object::SnapLine::isReadOnly(); + bool bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Object::SnapLine::isReadOnly() + : officecfg::Office::Impress::Snap::Object::SnapLine::isReadOnly(); m_xCbxSnapHelplines->set_sensitive(!bReadOnly); m_xCbxSnapHelplinesImg->set_visible(bReadOnly); - bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Object::PageMargin::isReadOnly() : - officecfg::Office::Impress::Snap::Object::PageMargin::isReadOnly(); + bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Object::PageMargin::isReadOnly() + : officecfg::Office::Impress::Snap::Object::PageMargin::isReadOnly(); m_xCbxSnapBorder->set_sensitive(!bReadOnly); m_xCbxSnapBorderImg->set_visible(bReadOnly); - bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Object::ObjectFrame::isReadOnly() : - officecfg::Office::Impress::Snap::Object::ObjectFrame::isReadOnly(); + bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Object::ObjectFrame::isReadOnly() + : officecfg::Office::Impress::Snap::Object::ObjectFrame::isReadOnly(); m_xCbxSnapFrame->set_sensitive(!bReadOnly); m_xCbxSnapFrameImg->set_visible(bReadOnly); - bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Object::ObjectPoint::isReadOnly() : - officecfg::Office::Impress::Snap::Object::ObjectPoint::isReadOnly(); + bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Object::ObjectPoint::isReadOnly() + : officecfg::Office::Impress::Snap::Object::ObjectPoint::isReadOnly(); m_xCbxSnapPoints->set_sensitive(!bReadOnly); m_xCbxSnapPointsImg->set_visible(bReadOnly); - bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Position::CreatingMoving::isReadOnly() : - officecfg::Office::Impress::Snap::Position::CreatingMoving::isReadOnly(); + bReadOnly = bDrawMode + ? officecfg::Office::Draw::Snap::Position::CreatingMoving::isReadOnly() + : officecfg::Office::Impress::Snap::Position::CreatingMoving::isReadOnly(); m_xCbxOrtho->set_sensitive(!bReadOnly); m_xCbxOrthoImg->set_visible(bReadOnly); - bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Position::ExtendEdges::isReadOnly() : - officecfg::Office::Impress::Snap::Position::ExtendEdges::isReadOnly(); + bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Position::ExtendEdges::isReadOnly() + : officecfg::Office::Impress::Snap::Position::ExtendEdges::isReadOnly(); m_xCbxBigOrtho->set_sensitive(!bReadOnly); m_xCbxBigOrthoImg->set_visible(bReadOnly); - bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Position::Rotating::isReadOnly() : - officecfg::Office::Impress::Snap::Position::Rotating::isReadOnly(); + bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Position::Rotating::isReadOnly() + : officecfg::Office::Impress::Snap::Position::Rotating::isReadOnly(); m_xCbxRotate->set_sensitive(!bReadOnly); m_xCbxRotateImg->set_visible(bReadOnly); - bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Object::Range::isReadOnly() : - officecfg::Office::Impress::Snap::Object::Range::isReadOnly(); + bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Object::Range::isReadOnly() + : officecfg::Office::Impress::Snap::Object::Range::isReadOnly(); m_xMtrFldSnapArea->set_sensitive(!bReadOnly); m_xMtrFldSnapAreaImg->set_visible(bReadOnly); - bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Position::RotatingValue::isReadOnly() : - officecfg::Office::Impress::Snap::Position::RotatingValue::isReadOnly(); + bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Position::RotatingValue::isReadOnly() + : officecfg::Office::Impress::Snap::Position::RotatingValue::isReadOnly(); m_xMtrFldAngle->set_sensitive(!bReadOnly); - bReadOnly = bDrawMode ? officecfg::Office::Draw::Snap::Position::PointReduction::isReadOnly() : - officecfg::Office::Impress::Snap::Position::PointReduction::isReadOnly(); + bReadOnly = bDrawMode + ? officecfg::Office::Draw::Snap::Position::PointReduction::isReadOnly() + : officecfg::Office::Impress::Snap::Position::PointReduction::isReadOnly(); m_xMtrFldBezAngle->set_sensitive(!bReadOnly); m_xMtrFldBezAngleImg->set_visible(bReadOnly); ClickRotateHdl_Impl(*m_xCbxRotate); } -std::unique_ptr<SfxTabPage> SdTpOptionsSnap::Create( weld::Container* pPage, weld::DialogController* pController, - const SfxItemSet* rAttrs ) +std::unique_ptr<SfxTabPage> SdTpOptionsSnap::Create(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet* rAttrs) { return std::make_unique<SdTpOptionsSnap>(pPage, pController, *rAttrs); } @@ -191,8 +220,11 @@ std::unique_ptr<SfxTabPage> SdTpOptionsSnap::Create( weld::Container* pPage, wel |* TabPage to adjust the content options |* \************************************************************************/ -SdTpOptionsContents::SdTpOptionsContents(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, u"modules/simpress/ui/sdviewpage.ui"_ustr, u"SdViewPage"_ustr, &rInAttrs) +SdTpOptionsContents::SdTpOptionsContents(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet& rInAttrs) + : SfxTabPage(pPage, pController, u"modules/simpress/ui/sdviewpage.ui"_ustr, u"SdViewPage"_ustr, + &rInAttrs) , m_bDrawMode(false) , m_xCbxRuler(m_xBuilder->weld_check_button(u"ruler"_ustr)) , m_xCbxRulerImg(m_xBuilder->weld_widget(u"lockruler"_ustr)) @@ -205,9 +237,7 @@ SdTpOptionsContents::SdTpOptionsContents(weld::Container* pPage, weld::DialogCon { } -SdTpOptionsContents::~SdTpOptionsContents() -{ -} +SdTpOptionsContents::~SdTpOptionsContents() {} OUString SdTpOptionsContents::GetAllStrings() { @@ -220,7 +250,8 @@ OUString SdTpOptionsContents::GetAllStrings() sAllStrings += pString->get_label() + " "; } - OUString checkButton[] = { u"ruler"_ustr, u"dragstripes"_ustr, u"handlesbezier"_ustr, u"moveoutline"_ustr }; + OUString checkButton[] + = { u"ruler"_ustr, u"dragstripes"_ustr, u"handlesbezier"_ustr, u"moveoutline"_ustr }; for (const auto& check : checkButton) { @@ -231,14 +262,14 @@ OUString SdTpOptionsContents::GetAllStrings() return sAllStrings.replaceAll("_", ""); } -bool SdTpOptionsContents::FillItemSet( SfxItemSet* ) +bool SdTpOptionsContents::FillItemSet(SfxItemSet*) { bool bModified = false; - if( m_xCbxRuler->get_state_changed_from_saved() || - m_xCbxMoveOutline->get_state_changed_from_saved() || - m_xCbxDragStripes->get_state_changed_from_saved() || - m_xCbxHandlesBezier->get_state_changed_from_saved() ) + if (m_xCbxRuler->get_state_changed_from_saved() + || m_xCbxMoveOutline->get_state_changed_from_saved() + || m_xCbxDragStripes->get_state_changed_from_saved() + || m_xCbxHandlesBezier->get_state_changed_from_saved()) { std::shared_ptr<comphelper::ConfigurationChanges> batch( comphelper::ConfigurationChanges::create()); @@ -246,17 +277,24 @@ bool SdTpOptionsContents::FillItemSet( SfxItemSet* ) if (m_bDrawMode) { officecfg::Office::Draw::Layout::Display::Ruler::set(m_xCbxRuler->get_active(), batch); - officecfg::Office::Draw::Layout::Display::Contour::set(m_xCbxMoveOutline->get_active(), batch); - officecfg::Office::Draw::Layout::Display::Guide::set(m_xCbxDragStripes->get_active(), batch); - officecfg::Office::Draw::Layout::Display::Bezier::set(m_xCbxHandlesBezier->get_active(), batch); + officecfg::Office::Draw::Layout::Display::Contour::set(m_xCbxMoveOutline->get_active(), + batch); + officecfg::Office::Draw::Layout::Display::Guide::set(m_xCbxDragStripes->get_active(), + batch); + officecfg::Office::Draw::Layout::Display::Bezier::set(m_xCbxHandlesBezier->get_active(), + batch); batch->commit(); } else { - officecfg::Office::Impress::Layout::Display::Ruler::set(m_xCbxRuler->get_active(), batch); - officecfg::Office::Impress::Layout::Display::Contour::set(m_xCbxMoveOutline->get_active(), batch); - officecfg::Office::Impress::Layout::Display::Guide::set(m_xCbxDragStripes->get_active(), batch); - officecfg::Office::Impress::Layout::Display::Bezier::set(m_xCbxHandlesBezier->get_active(), batch); + officecfg::Office::Impress::Layout::Display::Ruler::set(m_xCbxRuler->get_active(), + batch); + officecfg::Office::Impress::Layout::Display::Contour::set( + m_xCbxMoveOutline->get_active(), batch); + officecfg::Office::Impress::Layout::Display::Guide::set(m_xCbxDragStripes->get_active(), + batch); + officecfg::Office::Impress::Layout::Display::Bezier::set( + m_xCbxHandlesBezier->get_active(), batch); batch->commit(); } bModified = true; @@ -264,7 +302,7 @@ bool SdTpOptionsContents::FillItemSet( SfxItemSet* ) return bModified; } -void SdTpOptionsContents::Reset( const SfxItemSet* ) +void SdTpOptionsContents::Reset(const SfxItemSet*) { if (m_bDrawMode) { @@ -281,23 +319,23 @@ void SdTpOptionsContents::Reset( const SfxItemSet* ) m_xCbxHandlesBezier->set_active(officecfg::Office::Impress::Layout::Display::Bezier::get()); } - bool bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Display::Ruler::isReadOnly() : - officecfg::Office::Impress::Layout::Display::Ruler::isReadOnly(); + bool bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Display::Ruler::isReadOnly() + : officecfg::Office::Impress::Layout::Display::Ruler::isReadOnly(); m_xCbxRuler->set_sensitive(!bReadOnly); m_xCbxRulerImg->set_visible(bReadOnly); - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Display::Contour::isReadOnly() : - officecfg::Office::Impress::Layout::Display::Contour::isReadOnly(); + bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Display::Contour::isReadOnly() + : officecfg::Office::Impress::Layout::Display::Contour::isReadOnly(); m_xCbxMoveOutline->set_sensitive(!bReadOnly); m_xCbxMoveOutlineImg->set_visible(bReadOnly); - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Display::Guide::isReadOnly() : - officecfg::Office::Impress::Layout::Display::Guide::isReadOnly(); + bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Display::Guide::isReadOnly() + : officecfg::Office::Impress::Layout::Display::Guide::isReadOnly(); m_xCbxDragStripes->set_sensitive(!bReadOnly); m_xCbxDragStripesImg->set_visible(bReadOnly); - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Display::Bezier::isReadOnly() : - officecfg::Office::Impress::Layout::Display::Bezier::isReadOnly(); + bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Display::Bezier::isReadOnly() + : officecfg::Office::Impress::Layout::Display::Bezier::isReadOnly(); m_xCbxHandlesBezier->set_sensitive(!bReadOnly); m_xCbxHandlesBezierImg->set_visible(bReadOnly); @@ -307,13 +345,14 @@ void SdTpOptionsContents::Reset( const SfxItemSet* ) m_xCbxHandlesBezier->save_state(); } -std::unique_ptr<SfxTabPage> SdTpOptionsContents::Create( weld::Container* pPage, weld::DialogController* pController, - const SfxItemSet* rAttrs ) +std::unique_ptr<SfxTabPage> SdTpOptionsContents::Create(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet* rAttrs) { return std::make_unique<SdTpOptionsContents>(pPage, pController, *rAttrs); } -void SdTpOptionsContents::PageCreated( const SfxAllItemSet& aSet ) +void SdTpOptionsContents::PageCreated(const SfxAllItemSet& aSet) { const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_SDMODE_FLAG, false); if (pFlagItem) @@ -329,11 +368,13 @@ void SdTpOptionsContents::PageCreated( const SfxAllItemSet& aSet ) |* TabPage to adjust the misc options |* \************************************************************************/ -#define TABLE_COUNT 12 +#define TABLE_COUNT 9 #define TOKEN ':' -SdTpOptionsMisc::SdTpOptionsMisc(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, u"modules/simpress/ui/optimpressgeneralpage.ui"_ustr, u"OptSavePage"_ustr, &rInAttrs) +SdTpOptionsMisc::SdTpOptionsMisc(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rInAttrs) + : SfxTabPage(pPage, pController, u"modules/simpress/ui/optimpressgeneralpage.ui"_ustr, + u"OptSavePage"_ustr, &rInAttrs) , nWidth(0) , nHeight(0) , m_bDrawMode(false) @@ -361,11 +402,13 @@ SdTpOptionsMisc::SdTpOptionsMisc(weld::Container* pPage, weld::DialogController* , m_xCbScaleImg(m_xBuilder->weld_widget(u"lockscaleBox"_ustr)) , m_xNewDocLb(m_xBuilder->weld_label(u"newdoclbl"_ustr)) , m_xFiInfo1(m_xBuilder->weld_label(u"info1"_ustr)) - , m_xMtrFldOriginalWidth(m_xBuilder->weld_metric_spin_button(u"metricWidthFields"_ustr, FieldUnit::MM)) + , m_xMtrFldOriginalWidth( + m_xBuilder->weld_metric_spin_button(u"metricWidthFields"_ustr, FieldUnit::MM)) , m_xWidthLb(m_xBuilder->weld_label(u"widthlbl"_ustr)) , m_xHeightLb(m_xBuilder->weld_label(u"heightlbl"_ustr)) , m_xFiInfo2(m_xBuilder->weld_label(u"info2"_ustr)) - , m_xMtrFldOriginalHeight(m_xBuilder->weld_metric_spin_button(u"metricHeightFields"_ustr, FieldUnit::MM)) + , m_xMtrFldOriginalHeight( + m_xBuilder->weld_metric_spin_button(u"metricHeightFields"_ustr, FieldUnit::MM)) , m_xCbxDistort(m_xBuilder->weld_check_button(u"distortcb"_ustr)) , m_xCbxDistortImg(m_xBuilder->weld_widget(u"lockdistortcb"_ustr)) , m_xMtrFldInfo1(m_xBuilder->weld_metric_spin_button(u"metricInfo1Fields"_ustr, FieldUnit::MM)) @@ -376,16 +419,16 @@ SdTpOptionsMisc::SdTpOptionsMisc(weld::Container* pPage, weld::DialogController* // set metric FieldUnit eFUnit; - sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC ); - if ( rInAttrs.GetItemState( nWhich ) >= SfxItemState::DEFAULT ) + sal_uInt16 nWhich = GetWhich(SID_ATTR_METRIC); + if (rInAttrs.GetItemState(nWhich) >= SfxItemState::DEFAULT) { - const SfxUInt16Item& rItem = static_cast<const SfxUInt16Item&>(rInAttrs.Get( nWhich )); + const SfxUInt16Item& rItem = static_cast<const SfxUInt16Item&>(rInAttrs.Get(nWhich)); eFUnit = static_cast<FieldUnit>(rItem.GetValue()); } else eFUnit = SfxModule::GetCurrentFieldUnit(); - SetFieldUnit( *m_xMtrFldTabstop , eFUnit ); + SetFieldUnit(*m_xMtrFldTabstop, eFUnit); // tdf#148292 - avoid right frame to change position depending on width of this control m_xMtrFldTabstop->set_size_request(150, -1); // Impress is default mode, let' hide the entire scale frame etc. @@ -399,99 +442,98 @@ SdTpOptionsMisc::SdTpOptionsMisc(weld::Container* pPage, weld::DialogController* sal_uInt32 nFieldUnit = sal_uInt32(SvxFieldUnitTable::GetValue(i)); m_xLbMetric->append(OUString::number(nFieldUnit), sMetric); } - m_xLbMetric->connect_changed( LINK( this, SdTpOptionsMisc, SelectMetricHdl_Impl ) ); + m_xLbMetric->connect_changed(LINK(this, SdTpOptionsMisc, SelectMetricHdl_Impl)); - SetFieldUnit( *m_xMtrFldOriginalWidth, eFUnit ); - SetFieldUnit( *m_xMtrFldOriginalHeight, eFUnit ); + SetFieldUnit(*m_xMtrFldOriginalWidth, eFUnit); + SetFieldUnit(*m_xMtrFldOriginalHeight, eFUnit); m_xMtrFldOriginalWidth->set_max(999999999, FieldUnit::NONE); m_xMtrFldOriginalHeight->set_max(999999999, FieldUnit::NONE); // temporary fields for info texts (for formatting/calculation) - m_xMtrFldInfo1->set_unit( eFUnit ); + m_xMtrFldInfo1->set_unit(eFUnit); m_xMtrFldInfo1->set_max(999999999, FieldUnit::NONE); - m_xMtrFldInfo1->set_digits( 2 ); - m_xMtrFldInfo2->set_unit( eFUnit ); + m_xMtrFldInfo1->set_digits(2); + m_xMtrFldInfo2->set_unit(eFUnit); m_xMtrFldInfo2->set_max(999999999, FieldUnit::NONE); - m_xMtrFldInfo2->set_digits( 2 ); + m_xMtrFldInfo2->set_digits(2); // determine PoolUnit SfxItemPool* pPool = rInAttrs.GetPool(); - assert(pPool && "Where is the Pool?"); - ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH ); + assert(pPool && "Where is the Pool?"); + ePoolUnit = pPool->GetMetric(SID_ATTR_FILL_HATCH); // Fill the CB - sal_uInt16 aTable[ TABLE_COUNT ] = - { 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 50, 100 }; + sal_uInt16 aTable[TABLE_COUNT] = { 1, 2, 5, 10, 12, 24, 48, 50, 100 }; - for( sal_uInt16 i = TABLE_COUNT-1; i > 0 ; i-- ) - m_xCbScale->append_text( GetScale( 1, aTable[i] ) ); - for( sal_uInt16 i = 0; i < TABLE_COUNT; i++ ) - m_xCbScale->append_text( GetScale( aTable[i], 1 ) ); + for (sal_uInt16 i = TABLE_COUNT - 1; i > 0; i--) + m_xCbScale->append_text(GetScale(1, aTable[i])); + for (sal_uInt16 i = 0; i < TABLE_COUNT; i++) + m_xCbScale->append_text(GetScale(aTable[i], 1)); } -SdTpOptionsMisc::~SdTpOptionsMisc() -{ -} +SdTpOptionsMisc::~SdTpOptionsMisc() {} -void SdTpOptionsMisc::ActivatePage( const SfxItemSet& rSet ) +void SdTpOptionsMisc::ActivatePage(const SfxItemSet& rSet) { // We have to call save_state again since it can happen that the value // has no effect on other TabPages m_xLbMetric->save_value(); // change metric if necessary (since TabPage is in the Dialog where // the metric is set) - const SfxUInt16Item* pAttr = rSet.GetItemIfSet( SID_ATTR_METRIC , false ); - if( !pAttr ) + const SfxUInt16Item* pAttr = rSet.GetItemIfSet(SID_ATTR_METRIC, false); + if (!pAttr) return; FieldUnit eFUnit = static_cast<FieldUnit>(static_cast<tools::Long>(pAttr->GetValue())); - if( eFUnit == m_xMtrFldOriginalWidth->get_unit() ) + if (eFUnit == m_xMtrFldOriginalWidth->get_unit()) return; // set metrics - sal_Int64 nVal = m_xMtrFldOriginalWidth->denormalize( m_xMtrFldOriginalWidth->get_value( FieldUnit::TWIP ) ); - SetFieldUnit( *m_xMtrFldOriginalWidth, eFUnit, true ); - m_xMtrFldOriginalWidth->set_value( m_xMtrFldOriginalWidth->normalize( nVal ), FieldUnit::TWIP ); + sal_Int64 nVal + = m_xMtrFldOriginalWidth->denormalize(m_xMtrFldOriginalWidth->get_value(FieldUnit::TWIP)); + SetFieldUnit(*m_xMtrFldOriginalWidth, eFUnit, true); + m_xMtrFldOriginalWidth->set_value(m_xMtrFldOriginalWidth->normalize(nVal), FieldUnit::TWIP); - nVal = m_xMtrFldOriginalHeight->denormalize( m_xMtrFldOriginalHeight->get_value( FieldUnit::TWIP ) ); - SetFieldUnit( *m_xMtrFldOriginalHeight, eFUnit, true ); - m_xMtrFldOriginalHeight->set_value( m_xMtrFldOriginalHeight->normalize( nVal ), FieldUnit::TWIP ); + nVal + = m_xMtrFldOriginalHeight->denormalize(m_xMtrFldOriginalHeight->get_value(FieldUnit::TWIP)); + SetFieldUnit(*m_xMtrFldOriginalHeight, eFUnit, true); + m_xMtrFldOriginalHeight->set_value(m_xMtrFldOriginalHeight->normalize(nVal), FieldUnit::TWIP); - if( nWidth == 0 || nHeight == 0 ) + if (nWidth == 0 || nHeight == 0) return; - m_xMtrFldInfo1->set_unit( eFUnit ); - m_xMtrFldInfo2->set_unit( eFUnit ); + m_xMtrFldInfo1->set_unit(eFUnit); + m_xMtrFldInfo2->set_unit(eFUnit); - SetMetricValue( *m_xMtrFldInfo1, nWidth, ePoolUnit ); + SetMetricValue(*m_xMtrFldInfo1, nWidth, ePoolUnit); aInfo1 = m_xMtrFldInfo1->get_text(); - m_xFiInfo1->set_label( aInfo1 ); + m_xFiInfo1->set_label(aInfo1); - SetMetricValue( *m_xMtrFldInfo2, nHeight, ePoolUnit ); + SetMetricValue(*m_xMtrFldInfo2, nHeight, ePoolUnit); aInfo2 = m_xMtrFldInfo2->get_text(); - m_xFiInfo2->set_label( aInfo2 ); + m_xFiInfo2->set_label(aInfo2); } -DeactivateRC SdTpOptionsMisc::DeactivatePage( SfxItemSet* pActiveSet ) +DeactivateRC SdTpOptionsMisc::DeactivatePage(SfxItemSet* pActiveSet) { // check parser sal_Int32 nX, nY; - if( SetScale( m_xCbScale->get_active_text(), nX, nY ) ) + if (SetScale(m_xCbScale->get_active_text(), nX, nY)) { - if( pActiveSet ) - FillItemSet( pActiveSet ); + if (pActiveSet) + FillItemSet(pActiveSet); return DeactivateRC::LeavePage; } - std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::YesNo, - SdResId(STR_WARN_SCALE_FAIL))); + std::unique_ptr<weld::MessageDialog> xWarn( + Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, + VclButtonsType::YesNo, SdResId(STR_WARN_SCALE_FAIL))); if (xWarn->run() == RET_YES) return DeactivateRC::KeepPage; - if( pActiveSet ) - FillItemSet( pActiveSet ); + if (pActiveSet) + FillItemSet(pActiveSet); return DeactivateRC::LeavePage; } @@ -499,9 +541,10 @@ DeactivateRC SdTpOptionsMisc::DeactivatePage( SfxItemSet* pActiveSet ) OUString SdTpOptionsMisc::GetAllStrings() { OUString sAllStrings; - OUString labels[] - = { u"newdoclbl"_ustr, u"label4"_ustr, u"label6"_ustr, u"tabstoplabel"_ustr, u"label1"_ustr, u"label7"_ustr, u"label2"_ustr, - u"label5"_ustr, u"label8"_ustr, u"widthlbl"_ustr, u"info1"_ustr, u"heightlbl"_ustr, u"info2"_ustr }; + OUString labels[] = { u"newdoclbl"_ustr, u"label4"_ustr, u"label6"_ustr, u"tabstoplabel"_ustr, + u"label1"_ustr, u"label7"_ustr, u"label2"_ustr, u"label5"_ustr, + u"label8"_ustr, u"widthlbl"_ustr, u"info1"_ustr, u"heightlbl"_ustr, + u"info2"_ustr }; for (const auto& label : labels) { @@ -509,9 +552,10 @@ OUString SdTpOptionsMisc::GetAllStrings() sAllStrings += pString->get_label() + " "; } - OUString checkButton[] = { u"startwithwizard"_ustr, u"copywhenmove"_ustr, u"backgroundback"_ustr, - u"objalwymov"_ustr, u"distortcb"_ustr, u"cbCompatibility"_ustr, - u"qickedit"_ustr, u"textselected"_ustr}; + OUString checkButton[] + = { u"startwithwizard"_ustr, u"copywhenmove"_ustr, u"backgroundback"_ustr, + u"objalwymov"_ustr, u"distortcb"_ustr, u"cbCompatibility"_ustr, + u"qickedit"_ustr, u"textselected"_ustr }; for (const auto& check : checkButton) { @@ -522,30 +566,31 @@ OUString SdTpOptionsMisc::GetAllStrings() return sAllStrings.replaceAll("_", ""); } -bool SdTpOptionsMisc::FillItemSet( SfxItemSet* rAttrs ) +bool SdTpOptionsMisc::FillItemSet(SfxItemSet* rAttrs) { bool bModified = false; - if( m_xCbxStartWithTemplate->get_state_changed_from_saved() || - m_xCbxMarkedHitMovesAlways->get_state_changed_from_saved() || - m_xCbxQuickEdit->get_state_changed_from_saved() || - m_xCbxPickThrough->get_state_changed_from_saved() || - m_xCbxMasterPageCache->get_state_changed_from_saved() || - m_xCbxCopy->get_state_changed_from_saved() || - m_xCbxCompatibility->get_state_changed_from_saved() || - m_xCbxDistort->get_state_changed_from_saved()) + if (m_xCbxStartWithTemplate->get_state_changed_from_saved() + || m_xCbxMarkedHitMovesAlways->get_state_changed_from_saved() + || m_xCbxQuickEdit->get_state_changed_from_saved() + || m_xCbxPickThrough->get_state_changed_from_saved() + || m_xCbxMasterPageCache->get_state_changed_from_saved() + || m_xCbxCopy->get_state_changed_from_saved() + || m_xCbxCompatibility->get_state_changed_from_saved() + || m_xCbxDistort->get_state_changed_from_saved()) { SdOptionsMiscItem aOptsItem; //all settings here need to be reflected in SdOptionsMiscItem::SetOptions() - aOptsItem.GetOptionsMisc().SetStartWithTemplate( m_xCbxStartWithTemplate->get_active() ); - aOptsItem.GetOptionsMisc().SetMarkedHitMovesAlways( m_xCbxMarkedHitMovesAlways->get_active() ); - aOptsItem.GetOptionsMisc().SetQuickEdit( m_xCbxQuickEdit->get_active() ); - aOptsItem.GetOptionsMisc().SetPickThrough( m_xCbxPickThrough->get_active() ); - aOptsItem.GetOptionsMisc().SetMasterPagePaintCaching( m_xCbxMasterPageCache->get_active() ); - aOptsItem.GetOptionsMisc().SetDragWithCopy( m_xCbxCopy->get_active() ); - aOptsItem.GetOptionsMisc().SetSummationOfParagraphs( m_xCbxCompatibility->get_active() ); - aOptsItem.GetOptionsMisc().SetCrookNoContortion( m_xCbxDistort->get_active() ); - rAttrs->Put( aOptsItem ); + aOptsItem.GetOptionsMisc().SetStartWithTemplate(m_xCbxStartWithTemplate->get_active()); + aOptsItem.GetOptionsMisc().SetMarkedHitMovesAlways( + m_xCbxMarkedHitMovesAlways->get_active()); + aOptsItem.GetOptionsMisc().SetQuickEdit(m_xCbxQuickEdit->get_active()); + aOptsItem.GetOptionsMisc().SetPickThrough(m_xCbxPickThrough->get_active()); + aOptsItem.GetOptionsMisc().SetMasterPagePaintCaching(m_xCbxMasterPageCache->get_active()); + aOptsItem.GetOptionsMisc().SetDragWithCopy(m_xCbxCopy->get_active()); + aOptsItem.GetOptionsMisc().SetSummationOfParagraphs(m_xCbxCompatibility->get_active()); + aOptsItem.GetOptionsMisc().SetCrookNoContortion(m_xCbxDistort->get_active()); + rAttrs->Put(aOptsItem); bModified = true; } @@ -555,24 +600,25 @@ bool SdTpOptionsMisc::FillItemSet( SfxItemSet* rAttrs ) { const sal_Int32 nMPos = m_xLbMetric->get_active(); sal_uInt16 nFieldUnit = m_xLbMetric->get_id(nMPos).toUInt32(); - rAttrs->Put( SfxUInt16Item( GetWhich( SID_ATTR_METRIC ), nFieldUnit ) ); + rAttrs->Put(SfxUInt16Item(GetWhich(SID_ATTR_METRIC), nFieldUnit)); bModified = true; } // tabulator space - if( m_xMtrFldTabstop->get_value_changed_from_saved() ) + if (m_xMtrFldTabstop->get_value_changed_from_saved()) { - MapUnit eUnit = rAttrs->GetPool()->GetMetric( SID_ATTR_DEFTABSTOP ); - SfxUInt16Item aDef( SID_ATTR_DEFTABSTOP, static_cast<sal_uInt16>(GetCoreValue( *m_xMtrFldTabstop, eUnit )) ); - rAttrs->Put( aDef ); + MapUnit eUnit = rAttrs->GetPool()->GetMetric(SID_ATTR_DEFTABSTOP); + SfxUInt16Item aDef(SID_ATTR_DEFTABSTOP, + static_cast<sal_uInt16>(GetCoreValue(*m_xMtrFldTabstop, eUnit))); + rAttrs->Put(aDef); bModified = true; } sal_Int32 nX, nY; - if( SetScale( m_xCbScale->get_active_text(), nX, nY ) ) + if (SetScale(m_xCbScale->get_active_text(), nX, nY)) { - rAttrs->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_X, nX ) ); - rAttrs->Put( SfxInt32Item( ATTR_OPTIONS_SCALE_Y, nY ) ); + rAttrs->Put(SfxInt32Item(ATTR_OPTIONS_SCALE_X, nX)); + rAttrs->Put(SfxInt32Item(ATTR_OPTIONS_SCALE_Y, nY)); bModified = true; } @@ -580,51 +626,56 @@ bool SdTpOptionsMisc::FillItemSet( SfxItemSet* rAttrs ) return bModified; } -void SdTpOptionsMisc::Reset( const SfxItemSet* rAttrs ) +void SdTpOptionsMisc::Reset(const SfxItemSet* rAttrs) { - SdOptionsMiscItem aOptsItem( rAttrs->Get( ATTR_OPTIONS_MISC ) ); + SdOptionsMiscItem aOptsItem(rAttrs->Get(ATTR_OPTIONS_MISC)); - bool bReadOnly = m_bDrawMode ? false : officecfg::Office::Impress::Misc::NewDoc::AutoPilot::isReadOnly(); - m_xCbxStartWithTemplate->set_active( aOptsItem.GetOptionsMisc().IsStartWithTemplate() ); + bool bReadOnly + = m_bDrawMode ? false : officecfg::Office::Impress::Misc::NewDoc::AutoPilot::isReadOnly(); + m_xCbxStartWithTemplate->set_active(aOptsItem.GetOptionsMisc().IsStartWithTemplate()); m_xCbxStartWithTemplate->set_sensitive(!bReadOnly); m_xCbxStartWithTemplateImg->set_visible(bReadOnly); - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Misc::ObjectMoveable::isReadOnly() : - officecfg::Office::Impress::Misc::ObjectMoveable::isReadOnly(); - m_xCbxMarkedHitMovesAlways->set_active( aOptsItem.GetOptionsMisc().IsMarkedHitMovesAlways() ); + bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Misc::ObjectMoveable::isReadOnly() + : officecfg::Office::Impress::Misc::ObjectMoveable::isReadOnly(); + m_xCbxMarkedHitMovesAlways->set_active(aOptsItem.GetOptionsMisc().IsMarkedHitMovesAlways()); m_xCbxMarkedHitMovesAlways->set_sensitive(!bReadOnly); m_xCbxMarkedHitMovesAlwaysImg->set_visible(bReadOnly); - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Misc::TextObject::QuickEditing::isReadOnly() : - officecfg::Office::Impress::Misc::TextObject::QuickEditing::isReadOnly(); - m_xCbxQuickEdit->set_active( aOptsItem.GetOptionsMisc().IsQuickEdit() ); + bReadOnly = m_bDrawMode + ? officecfg::Office::Draw::Misc::TextObject::QuickEditing::isReadOnly() + : officecfg::Office::Impress::Misc::TextObject::QuickEditing::isReadOnly(); + m_xCbxQuickEdit->set_active(aOptsItem.GetOptionsMisc().IsQuickEdit()); m_xCbxQuickEdit->set_sensitive(!bReadOnly); m_xCbxQuickEditImg->set_visible(bReadOnly); - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Misc::TextObject::Selectable::isReadOnly() : - officecfg::Office::Impress::Misc::TextObject::Selectable::isReadOnly(); - m_xCbxPickThrough->set_active( aOptsItem.GetOptionsMisc().IsPickThrough() ); + bReadOnly = m_bDrawMode + ? officecfg::Office::Draw::Misc::TextObject::Selectable::isReadOnly() + : officecfg::Office::Impress::Misc::TextObject::Selectable::isReadOnly(); + m_xCbxPickThrough->set_active(aOptsItem.GetOptionsMisc().IsPickThrough()); m_xCbxPickThrough->set_sensitive(!bReadOnly); m_xCbxPickThroughImg->set_visible(bReadOnly); - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Misc::BackgroundCache::isReadOnly() : - officecfg::Office::Impress::Misc::BackgroundCache::isReadOnly(); - m_xCbxMasterPageCache->set_active( aOptsItem.GetOptionsMisc().IsMasterPagePaintCaching() ); + bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Misc::BackgroundCache::isReadOnly() + : officecfg::Office::Impress::Misc::BackgroundCache::isReadOnly(); + m_xCbxMasterPageCache->set_active(aOptsItem.GetOptionsMisc().IsMasterPagePaintCaching()); m_xCbxMasterPageCache->set_sensitive(!bReadOnly); m_xCbxMasterPageCacheImg->set_visible(bReadOnly); - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Misc::CopyWhileMoving::isReadOnly() : - officecfg::Office::Impress::Misc::CopyWhileMoving::isReadOnly(); - m_xCbxCopy->set_active( aOptsItem.GetOptionsMisc().IsDragWithCopy() ); + bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Misc::CopyWhileMoving::isReadOnly() + : officecfg::Office::Impress::Misc::CopyWhileMoving::isReadOnly(); + m_xCbxCopy->set_active(aOptsItem.GetOptionsMisc().IsDragWithCopy()); m_xCbxCopy->set_sensitive(!bReadOnly); m_xCbxCopyImg->set_visible(bReadOnly); - bReadOnly = m_bDrawMode ? false : officecfg::Office::Impress::Misc::Compatibility::AddBetween::isReadOnly(); - m_xCbxCompatibility->set_active( aOptsItem.GetOptionsMisc().IsSummationOfParagraphs() ); + bReadOnly = m_bDrawMode + ? false + : officecfg::Office::Impress::Misc::Compatibility::AddBetween::isReadOnly(); + m_xCbxCompatibility->set_active(aOptsItem.GetOptionsMisc().IsSummationOfParagraphs()); m_xCbxCompatibility->set_sensitive(!bReadOnly); m_xCbxCompatibilityImg->set_visible(bReadOnly); - m_xCbxDistort->set_active( aOptsItem.GetOptionsMisc().IsCrookNoContortion() ); + m_xCbxDistort->set_active(aOptsItem.GetOptionsMisc().IsCrookNoContortion()); if (m_bDrawMode) { bReadOnly = officecfg::Office::Draw::Misc::NoDistort::isReadOnly(); @@ -643,19 +694,19 @@ void SdTpOptionsMisc::Reset( const SfxItemSet* rAttrs ) m_xCbxDistort->save_state(); // metric - sal_uInt16 nWhich = GetWhich( SID_ATTR_METRIC ); + sal_uInt16 nWhich = GetWhich(SID_ATTR_METRIC); m_xLbMetric->set_active(-1); - if ( rAttrs->GetItemState( nWhich ) >= SfxItemState::DEFAULT ) + if (rAttrs->GetItemState(nWhich) >= SfxItemState::DEFAULT) { - const SfxUInt16Item& rItem = static_cast<const SfxUInt16Item&>(rAttrs->Get( nWhich )); + const SfxUInt16Item& rItem = static_cast<const SfxUInt16Item&>(rAttrs->Get(nWhich)); sal_uInt32 nFieldUnit = static_cast<sal_uInt32>(rItem.GetValue()); for (sal_Int32 i = 0, nEntryCount = m_xLbMetric->get_count(); i < nEntryCount; ++i) { if (m_xLbMetric->get_id(i).toUInt32() == nFieldUnit) { - m_xLbMetric->set_active( i ); + m_xLbMetric->set_active(i); break; } } @@ -663,35 +714,42 @@ void SdTpOptionsMisc::Reset( const SfxItemSet* rAttrs ) // tabulator space constexpr auto nWhich2 = SID_ATTR_DEFTABSTOP; - if( rAttrs->GetItemState( nWhich2 ) >= SfxItemState::DEFAULT ) + if (rAttrs->GetItemState(nWhich2) >= SfxItemState::DEFAULT) { - MapUnit eUnit = rAttrs->GetPool()->GetMetric( nWhich2 ); - const SfxUInt16Item& rItem = rAttrs->Get( nWhich2 ); - SetMetricValue( *m_xMtrFldTabstop, rItem.GetValue(), eUnit ); + MapUnit eUnit = rAttrs->GetPool()->GetMetric(nWhich2); + const SfxUInt16Item& rItem = rAttrs->Get(nWhich2); + SetMetricValue(*m_xMtrFldTabstop, rItem.GetValue(), eUnit); } if (SdOptionsGeneric::isMetricSystem()) { - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Other::MeasureUnit::Metric::isReadOnly() : - officecfg::Office::Impress::Layout::Other::MeasureUnit::Metric::isReadOnly(); + bReadOnly + = m_bDrawMode + ? officecfg::Office::Draw::Layout::Other::MeasureUnit::Metric::isReadOnly() + : officecfg::Office::Impress::Layout::Other::MeasureUnit::Metric::isReadOnly(); } else { - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Other::MeasureUnit::NonMetric::isReadOnly() : - officecfg::Office::Impress::Layout::Other::MeasureUnit::NonMetric::isReadOnly(); + bReadOnly + = m_bDrawMode + ? officecfg::Office::Draw::Layout::Other::MeasureUnit::NonMetric::isReadOnly() + : officecfg::Office::Impress::Layout::Other::MeasureUnit::NonMetric::isReadOnly(); } m_xLbMetric->set_sensitive(!bReadOnly); m_xLbMetricImg->set_visible(bReadOnly); if (SdOptionsGeneric::isMetricSystem()) { - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Other::TabStop::Metric::isReadOnly() : - officecfg::Office::Impress::Layout::Other::TabStop::Metric::isReadOnly(); + bReadOnly = m_bDrawMode + ? officecfg::Office::Draw::Layout::Other::TabStop::Metric::isReadOnly() + : officecfg::Office::Impress::Layout::Other::TabStop::Metric::isReadOnly(); } else { - bReadOnly = m_bDrawMode ? officecfg::Office::Draw::Layout::Other::TabStop::NonMetric::isReadOnly() : - officecfg::Office::Impress::Layout::Other::TabStop::NonMetric::isReadOnly(); + bReadOnly + = m_bDrawMode + ? officecfg::Office::Draw::Layout::Other::TabStop::NonMetric::isReadOnly() + : officecfg::Office::Impress::Layout::Other::TabStop::NonMetric::isReadOnly(); } m_xMtrFldTabstop->set_sensitive(!bReadOnly); m_xMtrFldTabstopImg->set_visible(bReadOnly); @@ -699,34 +757,35 @@ void SdTpOptionsMisc::Reset( const SfxItemSet* rAttrs ) m_xLbMetric->save_value(); m_xMtrFldTabstop->save_value(); //Scale - sal_Int32 nX = rAttrs->Get( ATTR_OPTIONS_SCALE_X ).GetValue(); - sal_Int32 nY = rAttrs->Get( ATTR_OPTIONS_SCALE_Y ).GetValue(); - nWidth = rAttrs->Get( ATTR_OPTIONS_SCALE_WIDTH ).GetValue(); - nHeight = rAttrs->Get( ATTR_OPTIONS_SCALE_HEIGHT ).GetValue(); + sal_Int32 nX = rAttrs->Get(ATTR_OPTIONS_SCALE_X).GetValue(); + sal_Int32 nY = rAttrs->Get(ATTR_OPTIONS_SCALE_Y).GetValue(); + nWidth = rAttrs->Get(ATTR_OPTIONS_SCALE_WIDTH).GetValue(); + nHeight = rAttrs->Get(ATTR_OPTIONS_SCALE_HEIGHT).GetValue(); - m_xCbScale->set_entry_text( GetScale( nX, nY ) ); + m_xCbScale->set_entry_text(GetScale(nX, nY)); if (m_bDrawMode) { - bReadOnly = officecfg::Office::Draw::Zoom::ScaleX::isReadOnly() && - officecfg::Office::Draw::Zoom::ScaleY::isReadOnly(); + bReadOnly = officecfg::Office::Draw::Zoom::ScaleX::isReadOnly() + && officecfg::Office::Draw::Zoom::ScaleY::isReadOnly(); m_xCbScale->set_sensitive(!bReadOnly); m_xCbScaleImg->set_visible(bReadOnly); } m_xMtrFldOriginalWidth->hide(); - m_xMtrFldOriginalWidth->set_text( aInfo1 ); // empty + m_xMtrFldOriginalWidth->set_text(aInfo1); // empty m_xMtrFldOriginalHeight->hide(); - m_xMtrFldOriginalHeight->set_text( aInfo2 ); //empty + m_xMtrFldOriginalHeight->set_text(aInfo2); //empty m_xFiInfo1->hide(); m_xFiInfo2->hide(); - UpdateCompatibilityControls (); + UpdateCompatibilityControls(); } -std::unique_ptr<SfxTabPage> SdTpOptionsMisc::Create( weld::Container* pPage, weld::DialogController* pController, - const SfxItemSet* rAttrs ) +std::unique_ptr<SfxTabPage> SdTpOptionsMisc::Create(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet* rAttrs) { - return std::make_unique<SdTpOptionsMisc>( pPage, pController, *rAttrs ); + return std::make_unique<SdTpOptionsMisc>(pPage, pController, *rAttrs); } IMPL_LINK_NOARG(SdTpOptionsMisc, SelectMetricHdl_Impl, weld::ComboBox&, void) @@ -735,10 +794,10 @@ IMPL_LINK_NOARG(SdTpOptionsMisc, SelectMetricHdl_Impl, weld::ComboBox&, void) if (nPos != -1) { FieldUnit eUnit = static_cast<FieldUnit>(m_xLbMetric->get_id(nPos).toUInt32()); - sal_Int64 nVal = - m_xMtrFldTabstop->denormalize(m_xMtrFldTabstop->get_value(FieldUnit::TWIP)); - SetFieldUnit( *m_xMtrFldTabstop, eUnit ); - m_xMtrFldTabstop->set_value( m_xMtrFldTabstop->normalize( nVal ), FieldUnit::TWIP ); + sal_Int64 nVal + = m_xMtrFldTabstop->denormalize(m_xMtrFldTabstop->get_value(FieldUnit::TWIP)); + SetFieldUnit(*m_xMtrFldTabstop, eUnit); + m_xMtrFldTabstop->set_value(m_xMtrFldTabstop->normalize(nVal), FieldUnit::TWIP); } } @@ -763,31 +822,31 @@ void SdTpOptionsMisc::SetDrawMode() m_bDrawMode = true; } -OUString SdTpOptionsMisc::GetScale( sal_Int32 nX, sal_Int32 nY ) +OUString SdTpOptionsMisc::GetScale(sal_Int32 nX, sal_Int32 nY) { return OUString::number(nX) + OUStringChar(TOKEN) + OUString::number(nY); } -bool SdTpOptionsMisc::SetScale( std::u16string_view aScale, sal_Int32& rX, sal_Int32& rY ) +bool SdTpOptionsMisc::SetScale(std::u16string_view aScale, sal_Int32& rX, sal_Int32& rY) { if (aScale.empty()) return false; - sal_Int32 nIdx {0}; + sal_Int32 nIdx{ 0 }; std::u16string_view aTmp(o3tl::getToken(aScale, 0, TOKEN, nIdx)); - if (nIdx<0) + if (nIdx < 0) return false; // we expect another token! if (!comphelper::string::isdigitAsciiString(aTmp)) return false; rX = static_cast<tools::Long>(o3tl::toInt32(aTmp)); - if( rX == 0 ) + if (rX == 0) return false; aTmp = o3tl::getToken(aScale, 0, TOKEN, nIdx); - if (nIdx>=0) + if (nIdx >= 0) return false; // we require just 2 tokens! if (!comphelper::string::isdigitAsciiString(aTmp)) @@ -806,24 +865,23 @@ void SdTpOptionsMisc::UpdateCompatibilityControls() try { // Get a component enumeration from the desktop and search it for documents. - const Reference<uno::XComponentContext>& xContext( ::comphelper::getProcessComponentContext()); + const Reference<uno::XComponentContext>& xContext( + ::comphelper::getProcessComponentContext()); do { Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(xContext); - Reference<container::XEnumerationAccess> xComponents = - xDesktop->getComponents(); - if ( ! xComponents.is()) + Reference<container::XEnumerationAccess> xComponents = xDesktop->getComponents(); + if (!xComponents.is()) break; - Reference<container::XEnumeration> xEnumeration ( - xComponents->createEnumeration()); - if ( ! xEnumeration.is()) + Reference<container::XEnumeration> xEnumeration(xComponents->createEnumeration()); + if (!xEnumeration.is()) break; while (xEnumeration->hasMoreElements()) { - Reference<frame::XModel> xModel (xEnumeration->nextElement(), UNO_QUERY); + Reference<frame::XModel> xModel(xEnumeration->nextElement(), UNO_QUERY); if (xModel.is()) { // There is at least one model/document: Enable the compatibility controls. @@ -832,8 +890,7 @@ void SdTpOptionsMisc::UpdateCompatibilityControls() } } - } - while (false); // One 'loop'. + } while (false); // One 'loop'. } catch (const uno::Exception&) { @@ -841,7 +898,8 @@ void SdTpOptionsMisc::UpdateCompatibilityControls() // bIsEnabled and disable the controls. } - m_xCbxCompatibility->set_sensitive(bIsEnabled && !officecfg::Office::Impress::Misc::Compatibility::AddBetween::isReadOnly()); + m_xCbxCompatibility->set_sensitive( + bIsEnabled && !officecfg::Office::Impress::Misc::Compatibility::AddBetween::isReadOnly()); } void SdTpOptionsMisc::PageCreated(const SfxAllItemSet& aSet) @@ -849,8 +907,8 @@ void SdTpOptionsMisc::PageCreated(const SfxAllItemSet& aSet) const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_SDMODE_FLAG, false); if (pFlagItem) { - sal_uInt32 nFlags=pFlagItem->GetValue(); - if ( ( nFlags & SD_DRAW_MODE ) == SD_DRAW_MODE ) + sal_uInt32 nFlags = pFlagItem->GetValue(); + if ((nFlags & SD_DRAW_MODE) == SD_DRAW_MODE) SetDrawMode(); } }