From d6f5d4ee2cd0654497f1af37421d788411db762c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 8 May 2014 14:27:53 +0100 Subject: [PATCH] add a status bar icon to fit slide to window Change-Id: I2c1d1fc7425b0aaad2a2445e0ac71ddc38410fdb --- icon-themes/galaxy/svx/res/zoom_page_statusbar.png | Bin 0 -> 418 bytes include/svx/dialogs.hrc | 6 ++- include/svx/zoomctrl.hxx | 15 ++++++- sd/source/ui/app/sddll.cxx | 1 + sd/uiconfig/simpress/statusbar/statusbar.xml | 1 + svx/source/stbctrls/modctrl.cxx | 7 ---- svx/source/stbctrls/stbctrls.src | 13 ++++++ svx/source/stbctrls/zoomctrl.cxx | 46 +++++++++++++++++---- 8 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 icon-themes/galaxy/svx/res/zoom_page_statusbar.png diff --git a/icon-themes/galaxy/svx/res/zoom_page_statusbar.png b/icon-themes/galaxy/svx/res/zoom_page_statusbar.png new file mode 100644 index 0000000000000000000000000000000000000000..5fb2d59cf7549dbb665e9efc81f7a94c0f4e4980 GIT binary patch literal 418 zcmeAS@N?(olHy`uVBq!ia0vp^d>}Rl8<3oNC%zs?aTa()76ZkPfH31!Z9ZwBAbW|Y zuPggKRt_Em37r=8g+L+M%#er@=ltB<)VvZPmw~~#C^fMpHASI3vm`^o-P1Q9MK6_| zfq_xN)5S4F<9zQVMQ;~Jf#dbYn_qus^<|gZlVlLhn=WYb!{o$M=H~ea)HIsH)+Pzs zA7O3wTb1UD040>XycHdeXZiA&sHNY`QYup??3pE~^|b;>byRP|ES8VP<`l z`Gp^To!vF}*zE59-5A<;>sii #include - -// class SvxZoomToolBoxControl ------------------------------------------- +#include class SVX_DLLPUBLIC SvxZoomStatusBarControl : public SfxStatusBarControl { @@ -42,6 +41,18 @@ public: }; +class SVX_DLLPUBLIC SvxZoomPageStatusBarControl : public SfxStatusBarControl +{ +private: + Image maImage; +public: + virtual void Paint( const UserDrawEvent& rEvt ) SAL_OVERRIDE; + virtual bool MouseButtonDown( const MouseEvent & rEvt ) SAL_OVERRIDE; + + SFX_DECL_STATUSBAR_CONTROL(); + + SvxZoomPageStatusBarControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb); +}; #endif diff --git a/sd/source/ui/app/sddll.cxx b/sd/source/ui/app/sddll.cxx index f7a27c0..b37d934 100644 --- a/sd/source/ui/app/sddll.cxx +++ b/sd/source/ui/app/sddll.cxx @@ -242,6 +242,7 @@ void SdDLL::RegisterControllers() SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_RIGHT_TO_LEFT, pMod); // register StatusBarControls + SvxZoomPageStatusBarControl::RegisterControl( SID_ZOOM_ENTIRE_PAGE, pMod ); SvxZoomStatusBarControl::RegisterControl( SID_ATTR_ZOOM, pMod ); SvxPosSizeStatusBarControl::RegisterControl( SID_ATTR_SIZE, pMod ); SvxModifyControl::RegisterControl( SID_DOC_MODIFIED, pMod ); diff --git a/sd/uiconfig/simpress/statusbar/statusbar.xml b/sd/uiconfig/simpress/statusbar/statusbar.xml index 24224fe..78042ef 100644 --- a/sd/uiconfig/simpress/statusbar/statusbar.xml +++ b/sd/uiconfig/simpress/statusbar/statusbar.xml @@ -24,6 +24,7 @@ + diff --git a/svx/source/stbctrls/modctrl.cxx b/svx/source/stbctrls/modctrl.cxx index db94f49..aff7e75 100644 --- a/svx/source/stbctrls/modctrl.cxx +++ b/svx/source/stbctrls/modctrl.cxx @@ -137,8 +137,6 @@ void SvxModifyControl::_repaint() // ----------------------------------------------------------------------- -namespace { - /** * Given a bounding rectangle and an image, determine the top-left position * of the image so that the image would look centered both horizontally and @@ -160,9 +158,6 @@ Point centerImage(const Rectangle& rBoundingRect, const Image& rImg) return aPt; } -} - - void SvxModifyControl::Paint( const UserDrawEvent& rUsrEvt ) { OutputDevice* pDev = rUsrEvt.GetDevice(); diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src index 8d5beeb..5987d7a 100644 --- a/svx/source/stbctrls/stbctrls.src +++ b/svx/source/stbctrls/stbctrls.src @@ -120,6 +120,11 @@ String RID_SVXSTR_DOC_LOAD Text [ en-US ] = "Loading document..."; }; +String RID_SVXSTR_FIT_SLIDE +{ + Text [ en-US ] = "Fit slide to current window."; +}; + // PopupMenu ------------------------------------------------------------- Menu RID_SVXMNU_ZOOM { @@ -337,5 +342,13 @@ Image RID_SVXBMP_DOC_MODIFIED_FEEDBACK }; MaskColor = STD_MASKCOLOR; }; +Image RID_SVXBMP_ZOOM_PAGE +{ + ImageBitmap = Bitmap + { + File = "zoom_page_statusbar.png" ; + }; + MaskColor = STD_MASKCOLOR; +}; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/stbctrls/zoomctrl.cxx b/svx/source/stbctrls/zoomctrl.cxx index b5be076..229f98d 100644 --- a/svx/source/stbctrls/zoomctrl.cxx +++ b/svx/source/stbctrls/zoomctrl.cxx @@ -25,7 +25,8 @@ #include -#include "svx/zoomctrl.hxx" +#include +#include #include #include "stbctrls.h" #include @@ -95,7 +96,6 @@ void ZoomPopup_Impl::Select() } // class SvxZoomStatusBarControl ------------------------------------------ - SvxZoomStatusBarControl::SvxZoomStatusBarControl( sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar& rStb ) : @@ -183,5 +183,41 @@ void SvxZoomStatusBarControl::Command( const CommandEvent& rCEvt ) SfxStatusBarControl::Command( rCEvt ); } +SFX_IMPL_STATUSBAR_CONTROL(SvxZoomPageStatusBarControl,SfxVoidItem); + +SvxZoomPageStatusBarControl::SvxZoomPageStatusBarControl(sal_uInt16 _nSlotId, + sal_uInt16 _nId, StatusBar& rStb) + : SfxStatusBarControl(_nSlotId, _nId, rStb) + , maImage(SVX_RES(RID_SVXBMP_ZOOM_PAGE)) +{ + GetStatusBar().SetQuickHelpText(GetId(), SVX_RESSTR(RID_SVXSTR_FIT_SLIDE)); +} + +extern Point centerImage(const Rectangle& rBoundingRect, const Image& rImg); + +void SvxZoomPageStatusBarControl::Paint(const UserDrawEvent& rUsrEvt) +{ + OutputDevice* pDev = rUsrEvt.GetDevice(); + Rectangle aRect = rUsrEvt.GetRect(); + Point aPt = centerImage(aRect, maImage); + pDev->DrawImage(aPt, maImage); +} + +bool SvxZoomPageStatusBarControl::MouseButtonDown(const MouseEvent&) +{ + SvxZoomItem aZoom( SVX_ZOOM_WHOLEPAGE, 0, GetId() ); + + ::com::sun::star::uno::Any a; + INetURLObject aObj( m_aCommandURL ); + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 ); + aArgs[0].Name = aObj.GetURLPath(); + aZoom.QueryValue( a ); + aArgs[0].Value = a; + + execute( aArgs ); + + return true; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */