include/svx/strings.hrc          |    1 +
 include/svx/zoomctrl.hxx         |    1 +
 svx/source/stbctrls/zoomctrl.cxx |   21 +++++++++++++++++++++
 3 files changed, 23 insertions(+)

New commits:
commit 91148ed5d5ef3428a39676bec672ccb5918ff19a
Author:     Baole Fang <baole.f...@gmail.com>
AuthorDate: Wed Apr 19 14:14:10 2023 -0400
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Apr 20 17:40:39 2023 +0200

    tdf#154732: Fix zoom bar in Draw
    
    Oringally, the zoom bar in both Draw and Impress show
    "Fit slide to current window."
    Now, the zoom bar in Draw is modified into
    "Fit page to current window.", while Impress still uses "slide".
    
    Change-Id: Iba25215d437b128f581bc5a8e6767f6b1f382be4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150650
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc
index b5b64bfd6304..7799a69bca11 100644
--- a/include/svx/strings.hrc
+++ b/include/svx/strings.hrc
@@ -1324,6 +1324,7 @@
 #define RID_SVXSTR_DOC_MODIFIED_NO                          
NC_("RID_SVXSTR_DOC_MODIFIED_NO", "The document has not been modified since the 
last save.")
 #define RID_SVXSTR_DOC_LOAD                                 
NC_("RID_SVXSTR_DOC_LOAD", "Loading document...")
 #define RID_SVXSTR_FIT_SLIDE                                
NC_("RID_SVXSTR_FIT_SLIDE", "Fit slide to current window.")
+#define RID_SVXSTR_FIT_PAGE                                 
NC_("RID_SVXSTR_FIT_PAGE", "Fit page to current window.")
 #define RID_SVXSTR_WARN_MISSING_SMARTART                    
NC_("RID_SVXSTR_WARN_MISSING_SMARTART", "Could not load all SmartArt objects. 
Saving in Microsoft Office 2010 or later would avoid this issue.")
 #define RID_SVXSTR_TABLECELL_HINT                           
NC_("RID_SVXSTR_TABLECELL_HINT", "Table cell address. Click to open Table 
Properties dialog.")
 #define RID_SVXSTR_SECTION_HINT                             
NC_("RID_SVXSTR_SECTION_HINT", "Section name. Click to open Edit Sections 
dialog.")
diff --git a/include/svx/zoomctrl.hxx b/include/svx/zoomctrl.hxx
index 0c64db1e5efa..15ccb03f5747 100644
--- a/include/svx/zoomctrl.hxx
+++ b/include/svx/zoomctrl.hxx
@@ -52,6 +52,7 @@ private:
 public:
     virtual void Paint(const UserDrawEvent& rEvt) override;
     virtual bool MouseButtonDown(const MouseEvent& rEvt) override;
+    virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& 
aArguments) override;
 
     SFX_DECL_STATUSBAR_CONTROL();
 
diff --git a/svx/source/stbctrls/zoomctrl.cxx b/svx/source/stbctrls/zoomctrl.cxx
index 001ba0ec1e3b..3faaa17073f2 100644
--- a/svx/source/stbctrls/zoomctrl.cxx
+++ b/svx/source/stbctrls/zoomctrl.cxx
@@ -39,6 +39,7 @@
 #include <bitmaps.hlst>
 
 #include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
 
 SFX_IMPL_STATUSBAR_CONTROL(SvxZoomStatusBarControl,SvxZoomItem);
 
@@ -203,6 +204,26 @@ 
SvxZoomPageStatusBarControl::SvxZoomPageStatusBarControl(sal_uInt16 _nSlotId,
     GetStatusBar().SetQuickHelpText(GetId(), SvxResId(RID_SVXSTR_FIT_SLIDE));
 }
 
+void SAL_CALL SvxZoomPageStatusBarControl::initialize( const 
css::uno::Sequence< css::uno::Any >& aArguments )
+{
+    // Call inherited initialize
+    StatusbarController::initialize(aArguments);
+
+    // Get document type
+    css::uno::Reference< css::frame::XModuleManager2 > xModuleManager = 
css::frame::ModuleManager::create( m_xContext );
+    OUString aModuleIdentifier = xModuleManager->identify( 
css::uno::Reference<XInterface>( m_xFrame, 
css::uno::UnoReference_Query::UNO_QUERY ) );
+
+    // Decide what to show in zoom bar
+    if ( aModuleIdentifier == "com.sun.star.drawing.DrawingDocument" )
+    {
+        GetStatusBar().SetQuickHelpText(GetId(), 
SvxResId(RID_SVXSTR_FIT_PAGE));
+    }
+    else if ( aModuleIdentifier == 
"com.sun.star.presentation.PresentationDocument" )
+    {
+        GetStatusBar().SetQuickHelpText(GetId(), 
SvxResId(RID_SVXSTR_FIT_SLIDE));
+    }
+}
+
 void SvxZoomPageStatusBarControl::Paint(const UserDrawEvent& rUsrEvt)
 {
     vcl::RenderContext* pDev = rUsrEvt.GetRenderContext();

Reply via email to