Update ooo320-m1
[ooovba.git] / applied_patches / 0420-statusbar-fancy-modified-status-svx.diff
blob306febbd1e1c054b8eabca5428b07c0add7f5e6f
1 diff --git svx/inc/modctrl.hxx svx/inc/modctrl.hxx
2 index e1f41a8..94de89b 100644
3 --- svx/inc/modctrl.hxx
4 +++ svx/inc/modctrl.hxx
5 @@ -35,6 +35,8 @@
6 #include <sfx2/stbitem.hxx>
7 #include "svx/svxdllapi.h"
9 +#include <boost/shared_ptr.hpp>
11 // class SvxModifyControl ------------------------------------------------
13 class SVX_DLLPUBLIC SvxModifyControl : public SfxStatusBarControl
14 @@ -42,7 +44,8 @@ class SVX_DLLPUBLIC SvxModifyControl : public SfxStatusBarControl
15 public:
16 virtual void StateChanged( USHORT nSID, SfxItemState eState,
17 const SfxPoolItem* pState );
18 - virtual void Paint( const UserDrawEvent& rEvt );
19 + virtual void Paint( const UserDrawEvent& rUsrEvt );
20 + virtual void DoubleClick();
22 SFX_DECL_STATUSBAR_CONTROL();
24 @@ -51,11 +54,8 @@ public:
25 static ULONG GetDefItemWidth(const StatusBar& rStb);
27 private:
28 - BOOL bState;
30 -#ifdef _SVX_MODCTRL_CXX
31 - SVX_DLLPRIVATE void DrawItemText_Impl();
32 -#endif
33 + struct ImplData;
34 + ::boost::shared_ptr<ImplData> mpImpl;
38 diff --git svx/inc/svx/dialogs.hrc svx/inc/svx/dialogs.hrc
39 index 57e4e9f..53d5aae 100644
40 --- svx/inc/svx/dialogs.hrc
41 +++ svx/inc/svx/dialogs.hrc
42 @@ -1568,3 +1568,7 @@
43 #endif
45 #define SID_SC_TP_FORMULA (SVX_OOO_BUILD_START + 1)
46 +#define RID_SVXBMP_DOC_MODIFIED_YES (SVX_OOO_BUILD_START + 2)
47 +#define RID_SVXBMP_DOC_MODIFIED_NO (SVX_OOO_BUILD_START + 3)
48 +#define RID_SVXSTR_DOC_MODIFIED_YES (SVX_OOO_BUILD_START + 4)
49 +#define RID_SVXSTR_DOC_MODIFIED_NO (SVX_OOO_BUILD_START + 5)
50 diff --git svx/source/stbctrls/makefile.mk svx/source/stbctrls/makefile.mk
51 index 7a6fad6..e5bff5a 100644
52 --- svx/source/stbctrls/makefile.mk
53 +++ svx/source/stbctrls/makefile.mk
54 @@ -59,6 +59,7 @@ SLOFILES= \
55 $(SLO)$/zoomsliderctrl.obj
57 EXCEPTIONSFILES= \
58 + $(SLO)$/modctrl.obj \
59 $(SLO)$/zoomsliderctrl.obj
61 HXX1TARGET=stbctrls
62 diff --git svx/source/stbctrls/modctrl.cxx svx/source/stbctrls/modctrl.cxx
63 index 843c845..42f1d7c 100644
64 --- svx/source/stbctrls/modctrl.cxx
65 +++ svx/source/stbctrls/modctrl.cxx
66 @@ -33,29 +33,48 @@
68 // include ---------------------------------------------------------------
70 -#ifndef _STATUS_HXX //autogen
71 +#include "modctrl.hxx"
73 #include <vcl/status.hxx>
74 -#endif
75 +#include <vcl/image.hxx>
76 #include <svtools/eitem.hxx>
77 #include <sfx2/app.hxx>
79 -#define _SVX_MODCTRL_CXX
81 #include <svx/dialogs.hrc>
83 -#include "modctrl.hxx"
84 #include <svx/dialmgr.hxx>
86 +#include <com/sun/star/beans/PropertyValue.hpp>
88 +using ::com::sun::star::uno::Sequence;
89 +using ::com::sun::star::beans::PropertyValue;
90 +using ::rtl::OUString;
92 SFX_IMPL_STATUSBAR_CONTROL(SvxModifyControl, SfxBoolItem);
94 // class SvxModifyControl ------------------------------------------------
96 +struct SvxModifyControl::ImplData
98 + Image maModifiedButton;
99 + Image maNonModifiedButton;
101 + bool mbModified;
103 + ImplData() :
104 + maModifiedButton( SVX_RES(RID_SVXBMP_DOC_MODIFIED_YES) ),
105 + maNonModifiedButton( SVX_RES(RID_SVXBMP_DOC_MODIFIED_NO) ),
106 + mbModified(false)
111 SvxModifyControl::SvxModifyControl( USHORT _nSlotId,
112 USHORT _nId,
113 StatusBar& rStb ) :
115 SfxStatusBarControl( _nSlotId, _nId, rStb ),
116 - bState( TRUE )
117 + mpImpl(new ImplData)
121 @@ -65,32 +84,71 @@ void SvxModifyControl::StateChanged( USHORT, SfxItemState eState,
122 const SfxPoolItem* pState )
124 if ( SFX_ITEM_AVAILABLE != eState )
125 - GetStatusBar().SetItemText( GetId(), String() );
126 - else
128 - DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
129 - SfxBoolItem* pItem = (SfxBoolItem*)pState;
130 - bState = pItem->GetValue();
131 - DrawItemText_Impl();
133 + return;
135 + DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
136 + SfxBoolItem* pItem = (SfxBoolItem*)pState;
137 + mpImpl->mbModified = pItem->GetValue();
139 + if ( GetStatusBar().AreItemsVisible() )
140 + GetStatusBar().SetItemData( GetId(), 0 ); // force repaint
142 + int nResId = mpImpl->mbModified ? RID_SVXSTR_DOC_MODIFIED_YES : RID_SVXSTR_DOC_MODIFIED_NO;
143 + GetStatusBar().SetQuickHelpText(GetId(), SVX_RESSTR(nResId));
146 // -----------------------------------------------------------------------
148 -void SvxModifyControl::Paint( const UserDrawEvent& )
149 +namespace {
151 +/**
152 + * Given a bounding rectangle and an image, determine the top-left position
153 + * of the image so that the image would look centered both horizontally and
154 + * vertically.
156 + * @param rBoundingRect bounding rectangle
157 + * @param rImg image
158 + *
159 + * @return Point top-left corner of the centered image position
160 + */
161 +Point centerImage(const Rectangle& rBoundingRect, const Image& rImg)
163 - DrawItemText_Impl();
164 + Size aImgSize = rImg.GetSizePixel();
165 + Size aRectSize = rBoundingRect.GetSize();
166 + long nXOffset = (aRectSize.getWidth() - aImgSize.getWidth())/2;
167 + long nYOffset = (aRectSize.getHeight() - aImgSize.getHeight())/2;
168 + Point aPt = rBoundingRect.TopLeft();
169 + aPt += Point(nXOffset, nYOffset);
170 + return aPt;
173 -// -----------------------------------------------------------------------
175 +void SvxModifyControl::Paint( const UserDrawEvent& rUsrEvt )
177 + const Rectangle aControlRect = getControlRect();
178 + OutputDevice* pDev = rUsrEvt.GetDevice();
179 + Rectangle aRect = rUsrEvt.GetRect();
181 + if (mpImpl->mbModified)
182 + {
183 + Point aPt = centerImage(aRect, mpImpl->maModifiedButton);
184 + pDev->DrawImage(aPt, mpImpl->maModifiedButton);
186 + else
188 + Point aPt = centerImage(aRect, mpImpl->maNonModifiedButton);
189 + pDev->DrawImage(aPt, mpImpl->maNonModifiedButton);
193 -void SvxModifyControl::DrawItemText_Impl()
194 +void SvxModifyControl::DoubleClick()
196 - String sMode;
197 + if (!mpImpl->mbModified)
198 + // document not modified. nothing to do here.
199 + return;
201 - if ( bState )
202 - sMode = '*';
203 - GetStatusBar().SetItemText( GetId(), sMode );
204 + Sequence<PropertyValue> aArgs;
205 + execute(OUString::createFromAscii(".uno:Save"), aArgs);
208 ULONG SvxModifyControl::GetDefItemWidth(const StatusBar& rStb)
209 diff --git svx/source/stbctrls/stbctrls.src svx/source/stbctrls/stbctrls.src
210 index b4dac87..72b7d1a 100644
211 --- svx/source/stbctrls/stbctrls.src
212 +++ svx/source/stbctrls/stbctrls.src
213 @@ -87,6 +87,16 @@ String RID_SVXSTR_XMLSEC_NO_SIG
214 Text [ en-US ] = "Digital Signature: The document is not signed.";
217 +String RID_SVXSTR_DOC_MODIFIED_YES
219 + Text [ en-US ] = "The document has been modified. Double-click to save the document.";
222 +String RID_SVXSTR_DOC_MODIFIED_NO
224 + Text [ en-US ] = "The document has not been modified since the last save.";
227 // PopupMenu -------------------------------------------------------------
228 Menu RID_SVXMNU_ZOOM
230 @@ -323,3 +333,19 @@ Image RID_SVXBMP_SLIDERINCREASE_HC
231 MaskColor = STD_MASKCOLOR;
234 +Image RID_SVXBMP_DOC_MODIFIED_YES
236 + ImageBitmap = Bitmap
238 + File = "doc_modified_yes_14.png" ;
239 + };
240 + MaskColor = STD_MASKCOLOR;
242 +Image RID_SVXBMP_DOC_MODIFIED_NO
244 + ImageBitmap = Bitmap
246 + File = "doc_modified_no_14.png" ;
247 + };
248 + MaskColor = STD_MASKCOLOR;