[ooo-build-commit] .: 2 commits - sfx2/sdi sfx2/source svx/inc svx/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Wed Sep 29 14:21:09 PDT 2010
sfx2/sdi/sfx.sdi | 2
sfx2/source/doc/objserv.cxx | 2
svx/inc/modctrl.hxx | 12 ++--
svx/inc/svx/dialogs.hrc | 4 +
svx/source/stbctrls/makefile.mk | 1
svx/source/stbctrls/modctrl.cxx | 103 ++++++++++++++++++++++++++++++---------
svx/source/stbctrls/stbctrls.src | 26 +++++++++
7 files changed, 119 insertions(+), 31 deletions(-)
New commits:
commit e65dd6f7c4867a506cf3385aead25927034f9150
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Wed Sep 29 17:11:21 2010 -0400
Ported statusbar-fancy-modified-status-svx.diff from ooo-build.
diff --git a/svx/inc/modctrl.hxx b/svx/inc/modctrl.hxx
index c03617e..1b56689 100644
--- a/svx/inc/modctrl.hxx
+++ b/svx/inc/modctrl.hxx
@@ -32,6 +32,8 @@
#include <sfx2/stbitem.hxx>
#include "svx/svxdllapi.h"
+#include <boost/shared_ptr.hpp>
+
// class SvxModifyControl ------------------------------------------------
class SVX_DLLPUBLIC SvxModifyControl : public SfxStatusBarControl
@@ -39,7 +41,8 @@ class SVX_DLLPUBLIC SvxModifyControl : public SfxStatusBarControl
public:
virtual void StateChanged( USHORT nSID, SfxItemState eState,
const SfxPoolItem* pState );
- virtual void Paint( const UserDrawEvent& rEvt );
+ virtual void Paint( const UserDrawEvent& rUsrEvt );
+ virtual void DoubleClick();
SFX_DECL_STATUSBAR_CONTROL();
@@ -48,11 +51,8 @@ public:
static ULONG GetDefItemWidth(const StatusBar& rStb);
private:
- BOOL bState;
-
-#ifdef _SVX_MODCTRL_CXX
- SVX_DLLPRIVATE void DrawItemText_Impl();
-#endif
+ struct ImplData;
+ ::boost::shared_ptr<ImplData> mpImpl;
};
diff --git a/svx/inc/svx/dialogs.hrc b/svx/inc/svx/dialogs.hrc
index bc9aa17..5315ffb 100755
--- a/svx/inc/svx/dialogs.hrc
+++ b/svx/inc/svx/dialogs.hrc
@@ -1060,5 +1060,9 @@
#define SVX_OOO_BUILD_START (RID_SVX_START + 1200)
#define SID_SC_TP_FORMULA (SVX_OOO_BUILD_START + 1)
+#define RID_SVXBMP_DOC_MODIFIED_YES (SVX_OOO_BUILD_START + 2)
+#define RID_SVXBMP_DOC_MODIFIED_NO (SVX_OOO_BUILD_START + 3)
+#define RID_SVXSTR_DOC_MODIFIED_YES (SVX_OOO_BUILD_START + 4)
+#define RID_SVXSTR_DOC_MODIFIED_NO (SVX_OOO_BUILD_START + 5)
#endif
diff --git a/svx/source/stbctrls/makefile.mk b/svx/source/stbctrls/makefile.mk
index 4e125ad..0cd8594 100644
--- a/svx/source/stbctrls/makefile.mk
+++ b/svx/source/stbctrls/makefile.mk
@@ -55,6 +55,7 @@ SLOFILES= \
$(SLO)$/zoomsliderctrl.obj
EXCEPTIONSFILES= \
+ $(SLO)$/modctrl.obj \
$(SLO)$/zoomsliderctrl.obj
HXX1TARGET=stbctrls
diff --git a/svx/source/stbctrls/modctrl.cxx b/svx/source/stbctrls/modctrl.cxx
index 9b4fbd3..8054a32 100644
--- a/svx/source/stbctrls/modctrl.cxx
+++ b/svx/source/stbctrls/modctrl.cxx
@@ -30,29 +30,47 @@
// include ---------------------------------------------------------------
-#ifndef _STATUS_HXX //autogen
+#include "modctrl.hxx"
+
#include <vcl/status.hxx>
-#endif
+#include <vcl/image.hxx>
#include <svl/eitem.hxx>
#include <sfx2/app.hxx>
-#define _SVX_MODCTRL_CXX
-
#include <svx/dialogs.hrc>
-
-#include "modctrl.hxx"
#include <svx/dialmgr.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::PropertyValue;
+using ::rtl::OUString;
+
SFX_IMPL_STATUSBAR_CONTROL(SvxModifyControl, SfxBoolItem);
// class SvxModifyControl ------------------------------------------------
+struct SvxModifyControl::ImplData
+{
+ Image maModifiedButton;
+ Image maNonModifiedButton;
+
+ bool mbModified;
+
+ ImplData() :
+ maModifiedButton( SVX_RES(RID_SVXBMP_DOC_MODIFIED_YES) ),
+ maNonModifiedButton( SVX_RES(RID_SVXBMP_DOC_MODIFIED_NO) ),
+ mbModified(false)
+ {
+ }
+};
+
SvxModifyControl::SvxModifyControl( USHORT _nSlotId,
USHORT _nId,
StatusBar& rStb ) :
SfxStatusBarControl( _nSlotId, _nId, rStb ),
- bState( TRUE )
+ mpImpl(new ImplData)
{
}
@@ -62,32 +80,71 @@ void SvxModifyControl::StateChanged( USHORT, SfxItemState eState,
const SfxPoolItem* pState )
{
if ( SFX_ITEM_AVAILABLE != eState )
- GetStatusBar().SetItemText( GetId(), String() );
- else
- {
- DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
- SfxBoolItem* pItem = (SfxBoolItem*)pState;
- bState = pItem->GetValue();
- DrawItemText_Impl();
- }
+ return;
+
+ DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
+ SfxBoolItem* pItem = (SfxBoolItem*)pState;
+ mpImpl->mbModified = pItem->GetValue();
+
+ if ( GetStatusBar().AreItemsVisible() )
+ GetStatusBar().SetItemData( GetId(), 0 ); // force repaint
+
+ int nResId = mpImpl->mbModified ? RID_SVXSTR_DOC_MODIFIED_YES : RID_SVXSTR_DOC_MODIFIED_NO;
+ GetStatusBar().SetQuickHelpText(GetId(), SVX_RESSTR(nResId));
}
// -----------------------------------------------------------------------
-void SvxModifyControl::Paint( const UserDrawEvent& )
+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
+ * vertically.
+ *
+ * @param rBoundingRect bounding rectangle
+ * @param rImg image
+ *
+ * @return Point top-left corner of the centered image position
+ */
+Point centerImage(const Rectangle& rBoundingRect, const Image& rImg)
{
- DrawItemText_Impl();
+ Size aImgSize = rImg.GetSizePixel();
+ Size aRectSize = rBoundingRect.GetSize();
+ long nXOffset = (aRectSize.getWidth() - aImgSize.getWidth())/2;
+ long nYOffset = (aRectSize.getHeight() - aImgSize.getHeight())/2;
+ Point aPt = rBoundingRect.TopLeft();
+ aPt += Point(nXOffset, nYOffset);
+ return aPt;
}
-// -----------------------------------------------------------------------
+}
+void SvxModifyControl::Paint( const UserDrawEvent& rUsrEvt )
+{
+ const Rectangle aControlRect = getControlRect();
+ OutputDevice* pDev = rUsrEvt.GetDevice();
+ Rectangle aRect = rUsrEvt.GetRect();
+
+ if (mpImpl->mbModified)
+ {
+ Point aPt = centerImage(aRect, mpImpl->maModifiedButton);
+ pDev->DrawImage(aPt, mpImpl->maModifiedButton);
+ }
+ else
+ {
+ Point aPt = centerImage(aRect, mpImpl->maNonModifiedButton);
+ pDev->DrawImage(aPt, mpImpl->maNonModifiedButton);
+ }
+}
-void SvxModifyControl::DrawItemText_Impl()
+void SvxModifyControl::DoubleClick()
{
- String sMode;
+ if (!mpImpl->mbModified)
+ // document not modified. nothing to do here.
+ return;
- if ( bState )
- sMode = '*';
- GetStatusBar().SetItemText( GetId(), sMode );
+ Sequence<PropertyValue> aArgs;
+ execute(OUString::createFromAscii(".uno:Save"), aArgs);
}
ULONG SvxModifyControl::GetDefItemWidth(const StatusBar& rStb)
diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src
index 7520e4f..80f150a 100644
--- a/svx/source/stbctrls/stbctrls.src
+++ b/svx/source/stbctrls/stbctrls.src
@@ -89,6 +89,16 @@ String RID_SVXSTR_XMLSEC_SIG_CERT_OK_PARTIAL_SIG
Text [ en-US ] = "Digital Signature: The document signature and the certificate are OK, but not all parts of the document are signed.";
};
+String RID_SVXSTR_DOC_MODIFIED_YES
+{
+ Text [ en-US ] = "The document has been modified. Double-click to save the document.";
+};
+
+String RID_SVXSTR_DOC_MODIFIED_NO
+{
+ Text [ en-US ] = "The document has not been modified since the last save.";
+};
+
// PopupMenu -------------------------------------------------------------
Menu RID_SVXMNU_ZOOM
{
@@ -325,3 +335,19 @@ Image RID_SVXBMP_SLIDERINCREASE_HC
MaskColor = STD_MASKCOLOR;
};
+Image RID_SVXBMP_DOC_MODIFIED_YES
+{
+ ImageBitmap = Bitmap
+ {
+ File = "doc_modified_yes_14.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_DOC_MODIFIED_NO
+{
+ ImageBitmap = Bitmap
+ {
+ File = "doc_modified_no_14.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
commit 2d0138a3e7f1aa6055e38d500e472afa9cff3a15
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Wed Sep 29 17:09:42 2010 -0400
Ported statusbar-fancy-modified-status-sfx2.diff from ooo-build.
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 54e54cb..2569249 100755
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -3884,7 +3884,7 @@ SfxBoolItem Modified SID_MODIFIED
]
//--------------------------------------------------------------------------
-SfxStringItem ModifiedStatus SID_DOC_MODIFIED
+SfxBoolItem ModifiedStatus SID_DOC_MODIFIED
[
/* flags: */
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index ee8e57a..f4440b6 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1029,7 +1029,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
case SID_DOC_MODIFIED:
{
- rSet.Put( SfxStringItem( SID_DOC_MODIFIED, IsModified() ? '*' : ' ' ) );
+ rSet.Put( SfxBoolItem( SID_DOC_MODIFIED, IsModified() ) );
break;
}
More information about the ooo-build-commit
mailing list