summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorAditya Dewan <iit2015097@iiita.ac.in>2017-07-15 21:47:14 +0530
committerpranavk <pranavk@collabora.co.uk>2017-08-17 13:10:30 +0200
commitd64a7f4ba80fa2a0a0ad2bddc6906ab6b78a23c8 (patch)
tree8269f9ab235c5a4b31ede606bc64b0b474591102 /sw
parentea43e0e3ceec30336273da0fb3d47c24073cffd2 (diff)
implementing callback for ruler invalidation
adding commands to fetch and changee ruler state '.uno:RulerState' and '.uno:RulerStateChange' Change-Id: I66107039a7ae5893691feb45c8ab2e4aa476ea76 Reviewed-on: https://gerrit.libreoffice.org/40727 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: pranavk <pranavk@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/unotxdoc.hxx3
-rw-r--r--sw/sdi/_viewsh.sdi4
-rw-r--r--sw/source/uibase/inc/swruler.hxx2
-rw-r--r--sw/source/uibase/misc/swruler.cxx33
-rw-r--r--sw/source/uibase/uiview/viewtab.cxx19
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx8
6 files changed, 68 insertions, 1 deletions
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 9316b919137e..797aec9512fa 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -64,6 +64,7 @@
#include <rtl/ref.hxx>
#include <svl/itemprop.hxx>
#include <svx/fmdmod.hxx>
+#include <svx/ruler.hxx>
#include <editeng/UnoForbiddenCharsTable.hxx>
#include <cppuhelper/weak.hxx>
#include <cppuhelper/implbase.hxx>
@@ -423,6 +424,8 @@ public:
OUString getTrackedChanges() override;
/// @see vcl::ITiledRenderable::getTrackedChangeAuthors().
OUString getTrackedChangeAuthors() override;
+
+ OUString getRulerState() override;
/// @see vcl::ITiledRenderable::getPostIts().
OUString getPostIts() override;
// css::tiledrendering::XTiledRenderable
diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi
index 62e67f6b0d5c..d6ba21022c0e 100644
--- a/sw/sdi/_viewsh.sdi
+++ b/sw/sdi/_viewsh.sdi
@@ -235,6 +235,10 @@ interface BaseTextEditView
StateMethod = StateTabWin ;
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
+ SID_RULER_CHANGE_STATE
+ [
+ ExecMethod = ExecTabWin ;
+ ]
SID_RULER_BORDERS // status()
[
ExecMethod = ExecTabWin ;
diff --git a/sw/source/uibase/inc/swruler.hxx b/sw/source/uibase/inc/swruler.hxx
index c8f1deb12842..7821d3f89281 100644
--- a/sw/source/uibase/inc/swruler.hxx
+++ b/sw/source/uibase/inc/swruler.hxx
@@ -41,6 +41,7 @@ public:
* \param rRect ignored
*/
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
+ const std::string CreateJsonNotification();
protected:
SwViewShell * mpViewShell; //< Shell to check if there is any comments on doc and their visibility
@@ -50,6 +51,7 @@ protected:
int mnFadeRate; //< From 0 to 100. 0 means not highlighted.
ScopedVclPtr<VirtualDevice> maVirDev; //< VirtualDevice of this window. Just for convenience.
+ void NotifyKit();
/**
* Callback function to handle a mouse button down event.
*
diff --git a/sw/source/uibase/misc/swruler.cxx b/sw/source/uibase/misc/swruler.cxx
index c1c28dd50d9f..5c33febef4bc 100644
--- a/sw/source/uibase/misc/swruler.cxx
+++ b/sw/source/uibase/misc/swruler.cxx
@@ -24,9 +24,11 @@
#include <vcl/window.hxx>
#include <vcl/settings.hxx>
#include "strings.hrc"
+#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <boost/property_tree/json_parser.hpp>
#define CONTROL_BORDER_WIDTH 1
-
#define CONTROL_LEFT_OFFSET 6
#define CONTROL_RIGHT_OFFSET 3
#define CONTROL_TOP_OFFSET 4
@@ -246,12 +248,41 @@ void SwCommentRuler::MouseButtonDown( const MouseEvent& rMEvt )
Invalidate();
}
+const std::string SwCommentRuler::CreateJsonNotification()
+{
+ boost::property_tree::ptree jsonNotif;
+
+ jsonNotif.put("margin1", convertTwipToMm100(GetMargin1()));
+ jsonNotif.put("margin2", convertTwipToMm100(GetMargin2()));
+ jsonNotif.put("leftOffset", convertTwipToMm100(GetNullOffset()));
+ jsonNotif.put("pageOffset", convertTwipToMm100(GetPageOffset()));
+ jsonNotif.put("pageWidth", convertTwipToMm100(GetPageWidth()));
+
+ RulerUnitData aUnitData = GetCurrentRulerUnit();
+ jsonNotif.put("unit", aUnitData.aUnitStr);
+
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, jsonNotif);
+ std::string aPayload = aStream.str();
+ return aPayload;
+}
+
+void SwCommentRuler::NotifyKit()
+{
+ if (!comphelper::LibreOfficeKit::isActive())
+ return;
+
+ const std::string test = CreateJsonNotification();
+ mpViewShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_RULER_UPDATE, test.c_str());
+}
+
void SwCommentRuler::Update()
{
tools::Rectangle aPreviousControlRect = GetCommentControlRegion();
SvxRuler::Update();
if (aPreviousControlRect != GetCommentControlRegion())
Invalidate();
+ NotifyKit();
}
void SwCommentRuler::UpdateCommentHelpText()
diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx
index 84b1af29a751..ad92a7ae6e21 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -52,6 +52,7 @@
#include "wview.hxx"
#include "fmtcol.hxx"
#include "section.hxx"
+#include "swruler.hxx"
#include "ndtxt.hxx"
#include "pam.hxx"
@@ -801,6 +802,24 @@ void SwView::ExecTabWin( SfxRequest const & rReq )
rSh.SetAttrItem( aULSpace );
}
break;
+
+ case SID_RULER_CHANGE_STATE:
+ {
+ const SfxPoolItem *pMargin1, *pMargin2;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState(SID_RULER_MARGIN1,true,&pMargin1) == SfxItemState::SET )
+ {
+ const OUString ratio = static_cast<const SfxStringItem*>(pMargin1)->GetValue();
+ GetHRuler().SetValues(RulerChangeType::MARGIN1, GetHRuler().GetPageWidth() * ratio.toFloat());
+ }
+ else if ( pReqArgs &&
+ pReqArgs->GetItemState(SID_RULER_MARGIN2,true,&pMargin2) == SfxItemState::SET )
+ {
+ const OUString ratio = static_cast<const SfxStringItem*>(pMargin2)->GetValue();
+ GetHRuler().SetValues(RulerChangeType::MARGIN2, GetHRuler().GetPageWidth() * ratio.toFloat());
+ }
+ }
+ break;
case SID_RULER_BORDERS_VERTICAL:
case SID_RULER_BORDERS:
if ( pReqArgs )
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index c3afd987974f..cc765f88feab 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -130,6 +130,8 @@
#include <comphelper/storagehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <unotools/saveopt.hxx>
+#include "swruler.hxx"
+
#include <EnhancedPDFExportHelper.hxx>
#include <numrule.hxx>
@@ -3255,6 +3257,12 @@ OUString SwXTextDocument::getTrackedChangeAuthors()
return SW_MOD()->GetRedlineAuthorInfo();
}
+OUString SwXTextDocument::getRulerState()
+{
+ SwView* pView = pDocShell->GetView();
+ return OUString::fromUtf8((dynamic_cast<SwCommentRuler&>(pView->GetHRuler())).CreateJsonNotification().c_str());
+}
+
OUString SwXTextDocument::getPostIts()
{
SolarMutexGuard aGuard;