summaryrefslogtreecommitdiff
path: root/sfx2/source/control
diff options
context:
space:
mode:
authorSiqi Liu <me@siqi.fr>2015-04-13 16:23:32 +0200
committerSiqi Liu <me@siqi.fr>2015-04-13 16:23:32 +0200
commit0632f77ee8059f2d65ad72bf148da88901732dc2 (patch)
tree8717d2ebfc7af6b91499ec2c94792661122317bc /sfx2/source/control
parentcc54da22377feef44e1aa48a92d9b4c86eda7577 (diff)
LOK_STATE_CHANGED callback implemented with sfx events interception.
Diffstat (limited to 'sfx2/source/control')
-rw-r--r--sfx2/source/control/unoctitm.cxx55
1 files changed, 44 insertions, 11 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 0d98a2584b15..41a20fe38a8e 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -68,6 +68,9 @@
#include <iostream>
#include <map>
+#include <sal/log.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::util;
@@ -973,8 +976,7 @@ void SfxDispatchController_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eSt
pLastState = pState;
}
- ::cppu::OInterfaceContainerHelper* pContnr = pDispatch->GetListeners().getContainer ( aDispatchURL.Complete );
- if ( bNotify && pContnr )
+ if (bNotify)
{
::com::sun::star::uno::Any aState;
if ( ( eState >= SfxItemState::DEFAULT ) && pState && !IsInvalidItem( pState ) && !pState->ISA(SfxVoidItem) )
@@ -1015,16 +1017,24 @@ void SfxDispatchController_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eSt
aEvent.Requery = sal_False;
aEvent.State = aState;
- ::cppu::OInterfaceIteratorHelper aIt( *pContnr );
- while( aIt.hasMoreElements() )
- {
- try
- {
- static_cast< ::com::sun::star::frame::XStatusListener *>(aIt.next())->statusChanged( aEvent );
- }
- catch (const ::com::sun::star::uno::RuntimeException&)
+ if (pDispatcher && pDispatcher->GetFrame()) {
+ InterceptLOKStateChangeEvent(
+ pDispatcher->GetFrame()->GetObjectShell(), aEvent);
+ }
+
+ ::cppu::OInterfaceContainerHelper* pContnr = pDispatch->GetListeners().getContainer ( aDispatchURL.Complete );
+ if (pContnr) {
+ ::cppu::OInterfaceIteratorHelper aIt( *pContnr );
+ while( aIt.hasMoreElements() )
{
- aIt.remove();
+ try
+ {
+ static_cast< ::com::sun::star::frame::XStatusListener *>(aIt.next())->statusChanged( aEvent );
+ }
+ catch (const ::com::sun::star::uno::RuntimeException&)
+ {
+ aIt.remove();
+ }
}
}
}
@@ -1035,4 +1045,27 @@ void SfxDispatchController_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eSt
StateChanged( nSID, eState, pState, 0 );
}
+void SfxDispatchController_Impl::InterceptLOKStateChangeEvent(const SfxObjectShell* objSh, const ::com::sun::star::frame::FeatureStateEvent& aEvent) const
+{
+ if (!objSh || !objSh->isTiledRendering()) {
+ return;
+ }
+
+ if (aEvent.FeatureURL.Path == "Bold" ||
+ aEvent.FeatureURL.Path == "Italic" ||
+ aEvent.FeatureURL.Path == "Underline" ||
+ aEvent.FeatureURL.Path == "StrikeOut") {
+
+ OUStringBuffer aBuffer;
+ aBuffer.append(aEvent.FeatureURL.Complete);
+ aBuffer.append("=");
+ bool bTemp = false;
+ aEvent.State >>= bTemp;
+ aBuffer.append(bTemp);
+
+ OUString payload = aBuffer.makeStringAndClear();
+ objSh->libreOfficeKitCallback(LOK_CALLBACK_STATE_CHANGED, payload.toUtf8().getStr());
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */