desktop/source/lib/init.cxx | 1 officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu | 8 sd/Library_sd.mk | 1 sd/inc/app.hrc | 1 sd/inc/strings.hrc | 1 sd/sdi/SlideSorterController.sdi | 5 sd/sdi/_drvwsh.sdi | 5 sd/sdi/outlnvsh.sdi | 5 sd/sdi/sdraw.sdi | 18 + sd/source/ui/app/scalectrl.cxx | 108 ++++++++++ sd/source/ui/app/sddll.cxx | 2 sd/source/ui/dlg/tpoption.cxx | 4 sd/source/ui/func/fuoltext.cxx | 1 sd/source/ui/inc/scalectrl.hxx | 39 +++ sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx | 1 sd/source/ui/slidesorter/controller/SlsSlotManager.cxx | 5 sd/source/ui/view/drviewsa.cxx | 8 sd/uiconfig/sdraw/statusbar/statusbar.xml | 1 sfx2/source/control/unoctitm.cxx | 1 19 files changed, 213 insertions(+), 2 deletions(-)
New commits: commit 951b243f10a7c184e635ce1d84f69683d8e7abde Author: Heiko Tietze <tietze.he...@gmail.com> AuthorDate: Thu Mar 4 09:41:55 2021 +0100 Commit: Heiko Tietze <heiko.tie...@documentfoundation.org> CommitDate: Thu Mar 18 10:13:26 2021 +0100 Resolves tdf#66470 - Scaling value in statusbar Changes also the sort order at the options Change-Id: I61c231fb94d4b4c66358a17e7585609e31eb6a70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111947 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 6275bf691946..12eff83a4bc3 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2731,6 +2731,7 @@ static void doc_iniUnoCommands () OUString(".uno:SelectionMode"), OUString(".uno:PageStatus"), OUString(".uno:LayoutStatus"), + OUString(".uno:Scale"), OUString(".uno:Context"), OUString(".uno:WrapText"), OUString(".uno:ToggleMergeCells"), diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu index 97970ec450a9..deb4676df411 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu @@ -1180,6 +1180,14 @@ <value xml:lang="en-US">Layout</value> </prop> </node> + <node oor:name=".uno:Scale" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Scale</value> + </prop> + <prop oor:name="TooltipLabel" oor:type="xs:string"> + <value xml:lang="en-US">Scaling at the current document</value> + </prop> + </node> <node oor:name=".uno:CrookRotate" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Set in Circle (perspective)</value> diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index fe2dfc3d7617..092dc70da1ef 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -199,6 +199,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/ui/app/sdpopup \ sd/source/ui/app/sdxfer \ sd/source/ui/app/tmplctrl \ + sd/source/ui/app/scalectrl \ sd/source/ui/controller/slidelayoutcontroller \ sd/source/ui/controller/displaymodecontroller \ sd/source/ui/dlg/AnimationChildWindow \ diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc index 450bc35195fa..4a20807138b9 100644 --- a/sd/inc/app.hrc +++ b/sd/inc/app.hrc @@ -152,6 +152,7 @@ #define SID_DELETE_LAYER (SID_SD_START+81) #define SID_DISMANTLE (SID_SD_START+82) // FREE +#define SID_SCALE (SID_SD_START+85) #define SID_STATUS_PAGE (SID_SD_START+86) #define SID_STATUS_LAYOUT (SID_SD_START+87) #define SID_STATUS_SELMODE (SID_SD_START+88) diff --git a/sd/inc/strings.hrc b/sd/inc/strings.hrc index 183324d2679a..751b576ec0ec 100644 --- a/sd/inc/strings.hrc +++ b/sd/inc/strings.hrc @@ -104,6 +104,7 @@ #define STR_DLG_INSERT_PAGES_FROM_FILE NC_("STR_DLG_INSERT_PAGES_FROM_FILE", "Insert File") #define STR_READ_DATA_ERROR NC_("STR_READ_DATA_ERROR", "The file could not be loaded!") #define STR_SCALE_OBJECTS NC_("STR_SCALE_OBJECTS", "The page size of the target document is different than the source document.\n\nDo you want to scale the copied objects to fit the new page size?") +#define STR_SCALE_TOOLTIP NC_("STR_SCALE_TOOLTIP", "Scaling factor of the document; right-click to change.") #define STR_CREATE_PAGES NC_("STR_CREATE_PAGES", "Create Slides") #define STR_UNDO_CHANGE_PAGEFORMAT NC_("STR_UNDO_CHANGE_PAGEFORMAT", "Modify page format") #define STR_UNDO_CHANGE_PAGEBORDER NC_("STR_UNDO_CHANGE_PAGEBORDER", "Modify page margins") diff --git a/sd/sdi/SlideSorterController.sdi b/sd/sdi/SlideSorterController.sdi index 8b4f08c63e1f..22bc64214868 100644 --- a/sd/sdi/SlideSorterController.sdi +++ b/sd/sdi/SlideSorterController.sdi @@ -186,6 +186,11 @@ interface SlideSorterView ExecMethod = ExecStatusBar ; StateMethod = GetStatusBarState ; ] + SID_SCALE // ole : no, status : ? + [ + ExecMethod = ExecStatusBar ; + StateMethod = GetStatusBarState ; + ] SID_RELOAD // ole : no, status : ? [ GroupId = SfxGroupId::Document ; diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi index 2307906426da..bbbfdaabc332 100644 --- a/sd/sdi/_drvwsh.sdi +++ b/sd/sdi/_drvwsh.sdi @@ -1682,6 +1682,11 @@ interface DrawView ExecMethod = ExecStatusBar ; StateMethod = GetStatusBarState ; ] + SID_SCALE // ole : no, status : ? + [ + ExecMethod = ExecStatusBar ; + StateMethod = GetStatusBarState ; + ] SID_LINEEND_POLYGON // ole : no, status : ? [ ExecMethod = FuTemporary ; diff --git a/sd/sdi/outlnvsh.sdi b/sd/sdi/outlnvsh.sdi index 3b34d20f1c76..09957e8a0e39 100644 --- a/sd/sdi/outlnvsh.sdi +++ b/sd/sdi/outlnvsh.sdi @@ -261,6 +261,11 @@ interface OutlineView ExecMethod = ExecStatusBar ; StateMethod = GetStatusBarState ; ] + SID_SCALE // ole : no, status : ? + [ + ExecMethod = ExecStatusBar ; + StateMethod = GetStatusBarState ; + ] SID_THESAURUS // ole : no, status : ? [ ExecMethod = FuTemporaryModify ; diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi index 436a89cc30b4..c45a8bea5e68 100644 --- a/sd/sdi/sdraw.sdi +++ b/sd/sdi/sdraw.sdi @@ -2401,6 +2401,24 @@ SfxStringItem LayoutStatus SID_STATUS_LAYOUT GroupId = SfxGroupId::View; ] +SfxStringItem Scale SID_SCALE + +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::View; +] + SfxBoolItem LeaveAllGroups SID_LEAVE_ALL_GROUPS [ diff --git a/sd/source/ui/app/scalectrl.cxx b/sd/source/ui/app/scalectrl.cxx new file mode 100644 index 000000000000..e1826957b03e --- /dev/null +++ b/sd/source/ui/app/scalectrl.cxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <scalectrl.hxx> + +#include <vcl/commandevent.hxx> +#include <vcl/status.hxx> +#include <vcl/weldutils.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> +#include <svl/stritem.hxx> +#include <sfx2/sfxsids.hrc> + +#include <ViewShellBase.hxx> +#include <drawdoc.hxx> +#include <app.hrc> +#include <sdresid.hxx> +#include <strings.hrc> + +SFX_IMPL_STATUSBAR_CONTROL(SdScaleControl, SfxStringItem); + +// class SdScaleControl ------------------------------------------ +SdScaleControl::SdScaleControl(sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& rStb) + : SfxStatusBarControl(_nSlotId, _nId, rStb) +{ + GetStatusBar().SetQuickHelpText(GetId(), SdResId(STR_SCALE_TOOLTIP)); +} + +SdScaleControl::~SdScaleControl() {} + +void SdScaleControl::StateChanged(sal_uInt16 /*nSID*/, SfxItemState eState, + const SfxPoolItem* pState) +{ + if (eState != SfxItemState::DEFAULT || pState->IsVoidItem()) + return; + auto pStringItem = dynamic_cast<const SfxStringItem*>(pState); + GetStatusBar().SetItemText(GetId(), pStringItem->GetValue()); +} + +void SdScaleControl::Command(const CommandEvent& rCEvt) +{ + if (rCEvt.GetCommand() != CommandEventId::ContextMenu + || GetStatusBar().GetItemText(GetId()).isEmpty()) + return; + + SfxViewFrame* pViewFrame = SfxViewFrame::Current(); + + sd::ViewShellBase* pViewShellBase = sd::ViewShellBase::GetViewShellBase(pViewFrame); + if (!pViewShellBase) + return; + + SdDrawDocument* pDoc = pViewShellBase->GetDocument(); + if (!pDoc) + return; + + std::unique_ptr<weld::Builder> xBuilder( + Application::CreateBuilder(nullptr, "modules/simpress/ui/masterpagemenu.ui")); + std::unique_ptr<weld::Menu> xPopup(xBuilder->weld_menu("menu")); + + sal_uInt16 aTable[12] = { 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 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])); + + ::tools::Rectangle aRect(rCEvt.GetMousePosPixel(), Size(1, 1)); + weld::Window* pParent = weld::GetPopupParent(GetStatusBar(), aRect); + OString sResult = xPopup->popup_at_rect(pParent, aRect); + if (!sResult.isEmpty()) + { + sal_Int32 i = sResult.toUInt32(); + sal_Int32 nX; + sal_Int32 nY; + if (i > 11) + nX = 1; + else + nX = aTable[12 - i % 12]; + if (i > 11) + nY = aTable[i % 12]; + else + nY = 1; + pDoc->SetUIScale(Fraction(nX, nY)); + + SfxBindings& pBindings = pViewFrame->GetBindings(); + pBindings.Invalidate(SID_SCALE); //update statusbar + pBindings.Invalidate(SID_ATTR_METRIC); //update sidebar + pViewShellBase->UpdateBorder(true); // update ruler + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/app/sddll.cxx b/sd/source/ui/app/sddll.cxx index cbcd201095d3..4e20d0997fb8 100644 --- a/sd/source/ui/app/sddll.cxx +++ b/sd/source/ui/app/sddll.cxx @@ -54,6 +54,7 @@ #include <SdShapeTypes.hxx> #include <TextObjectBar.hxx> #include <tmplctrl.hxx> +#include <scalectrl.hxx> #include <svx/svxids.hrc> #include <svx/bmpmask.hxx> @@ -198,6 +199,7 @@ void SdDLL::RegisterControllers(SdModule* pMod) #endif XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod ); SdTemplateControl::RegisterControl( SID_STATUS_LAYOUT, pMod ); + SdScaleControl::RegisterControl( SID_SCALE, pMod ); SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod ); } diff --git a/sd/source/ui/dlg/tpoption.cxx b/sd/source/ui/dlg/tpoption.cxx index e2abc9565251..1da1974bedb7 100644 --- a/sd/source/ui/dlg/tpoption.cxx +++ b/sd/source/ui/dlg/tpoption.cxx @@ -253,9 +253,9 @@ SdTpOptionsMisc::SdTpOptionsMisc(weld::Container* pPage, weld::DialogController* sal_uInt16 aTable[ TABLE_COUNT ] = { 1, 2, 4, 5, 8, 10, 16, 20, 30, 40, 50, 100 }; - for( sal_uInt16 i = 0; i < TABLE_COUNT; i++ ) + for( sal_uInt16 i = TABLE_COUNT-1; i > 0 ; i-- ) m_xCbScale->append_text( GetScale( 1, aTable[i] ) ); - for( sal_uInt16 i = 1; i < TABLE_COUNT; i++ ) + for( sal_uInt16 i = 0; i < TABLE_COUNT; i++ ) m_xCbScale->append_text( GetScale( aTable[i], 1 ) ); } diff --git a/sd/source/ui/func/fuoltext.cxx b/sd/source/ui/func/fuoltext.cxx index 2314e3b75d33..07c3625ffe46 100644 --- a/sd/source/ui/func/fuoltext.cxx +++ b/sd/source/ui/func/fuoltext.cxx @@ -77,6 +77,7 @@ const sal_uInt16 SidArray[] = { SID_PARASPACE_DECREASE, SID_STATUS_PAGE, SID_STATUS_LAYOUT, + SID_SCALE, SID_EXPAND_PAGE, SID_SUMMARY_PAGE, 0 }; diff --git a/sd/source/ui/inc/scalectrl.hxx b/sd/source/ui/inc/scalectrl.hxx new file mode 100644 index 000000000000..85c93017172f --- /dev/null +++ b/sd/source/ui/inc/scalectrl.hxx @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <sfx2/stbitem.hxx> + +class SdScaleControl : public SfxStatusBarControl +{ +public: + SdScaleControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb); + virtual ~SdScaleControl() override; + + virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) override; + + SFX_DECL_STATUSBAR_CONTROL(); + +protected: + virtual void Command(const CommandEvent& rCEvt) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx index 1bda593e16be..e1f75b21c5cf 100644 --- a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx @@ -229,6 +229,7 @@ void SelectionManager::SelectionHasChanged () // StatusBar pViewShell->Invalidate (SID_STATUS_PAGE); pViewShell->Invalidate (SID_STATUS_LAYOUT); + pViewShell->Invalidate (SID_SCALE); OSL_ASSERT(mrController.GetCurrentSlideManager()); SharedPageDescriptor pDescriptor(mrController.GetCurrentSlideManager()->GetCurrentSlide()); diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx index bc65ac5be70c..215d5ae1682a 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -860,6 +860,11 @@ void SlotManager::GetStatusBarState (SfxItemSet& rSet) aLayoutStr = aLayoutStr.copy(0, nIndex); rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aLayoutStr ) ); } + //Scale value + const Fraction& aUIScale = mrSlideSorter.GetModel().GetDocument()->GetUIScale(); + OUString aString = OUString::number(aUIScale.GetNumerator()) + + ":" + OUString::number(aUIScale.GetDenominator()); + rSet.Put( SfxStringItem( SID_SCALE, aString ) ); } void SlotManager::RenameSlide(const SfxRequest& rRequest) diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx index c489745af601..92174788cfc6 100644 --- a/sd/source/ui/view/drviewsa.cxx +++ b/sd/source/ui/view/drviewsa.cxx @@ -714,6 +714,14 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet) aString = aString.copy(0, nPos); rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aString ) ); } + // Scale + if( SfxItemState::DEFAULT == rSet.GetItemState( SID_SCALE ) ) + { + const Fraction& aUIScale = GetDoc()->GetUIScale(); + OUString aString = OUString::number(aUIScale.GetNumerator()) + + ":" + OUString::number(aUIScale.GetDenominator()); + rSet.Put( SfxStringItem( SID_SCALE, aString ) ); + } } void DrawViewShell::Notify (SfxBroadcaster&, const SfxHint& rHint) diff --git a/sd/uiconfig/sdraw/statusbar/statusbar.xml b/sd/uiconfig/sdraw/statusbar/statusbar.xml index 6a975cb477de..e89d1abc1f2e 100644 --- a/sd/uiconfig/sdraw/statusbar/statusbar.xml +++ b/sd/uiconfig/sdraw/statusbar/statusbar.xml @@ -22,6 +22,7 @@ <statusbar:statusbaritem xlink:href=".uno:Context" statusbar:align="left" statusbar:autosize="true" statusbar:mandatory="false" statusbar:width="184"/> <statusbar:statusbaritem xlink:href=".uno:LayoutStatus" statusbar:align="left" statusbar:autosize="true" statusbar:mandatory="false" statusbar:width="54"/> <statusbar:statusbaritem xlink:href=".uno:Size" statusbar:align="center" statusbar:ownerdraw="true" statusbar:autosize="true" statusbar:width="200"/> + <statusbar:statusbaritem xlink:href=".uno:Scale" statusbar:align="left" statusbar:autosize="false" statusbar:width="30"/> <statusbar:statusbaritem xlink:href=".uno:ModifiedStatus" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="9"/> <statusbar:statusbaritem xlink:href=".uno:Signature" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="16"/> <statusbar:statusbaritem xlink:href=".uno:ZoomPage" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="9"/> diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 3b5a8e16de75..64f097503256 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1219,6 +1219,7 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra aEvent.FeatureURL.Path == "PageStyleName" || aEvent.FeatureURL.Path == "PageStatus" || aEvent.FeatureURL.Path == "LayoutStatus" || + aEvent.FeatureURL.Path == "Scale" || aEvent.FeatureURL.Path == "Context") { OUString aString; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits