summaryrefslogtreecommitdiff
path: root/sfx2
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
parentcc54da22377feef44e1aa48a92d9b4c86eda7577 (diff)
LOK_STATE_CHANGED callback implemented with sfx events interception.
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/unoctitm.cxx55
-rw-r--r--sfx2/source/doc/objcont.cxx12
2 files changed, 56 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: */
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index 95fd6b83e1dc..40d1e195e0a5 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -76,6 +76,10 @@
#include "querytemplate.hxx"
#include <boost/scoped_array.hpp>
+#include <LibreOfficeKit/LibreOfficeKitTypes.h>
+
+#include <typeinfo>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -639,4 +643,12 @@ bool SfxObjectShell::IsModifyPasswordEntered()
return pImp->m_bModifyPasswordEntered;
}
+void SfxObjectShell::libreOfficeKitCallback(SAL_UNUSED_PARAMETER int nType, SAL_UNUSED_PARAMETER const char* pPayload) const {
+ SAL_WARN("tiled-rendering", "LOK callback interface not overridden for SfxObjectShell subclass typeId: " << typeid(*this).name());
+}
+bool SfxObjectShell::isTiledRendering() const {
+ SAL_WARN("tiled-rendering", "LOK callback interface not overridden for SfxObjectShell subclass typeId: " << typeid(*this).name());
+ return false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */