summaryrefslogtreecommitdiff
path: root/svx/source/dialog/svxruler.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-05-16 19:52:32 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-06-20 04:53:18 +0200
commit66247fe7bdb089a897f9a02b96c888b92b67154d (patch)
tree54662eb237aa1d8a4094f82a221663fb20858777 /svx/source/dialog/svxruler.cxx
parentd7aeaeafc32f78ca38942868f965bae0e6c376b1 (diff)
svx: move lok's NotifyKit in the ruler to the SvxRuler super-class
We want to make the ruler work in other components and also not only for horizontal orientation. For this we want the NotifyKit already in the SvxRuler, which is used by all rulers. This change moves the functionality to the from SwCommentRuler to SvxRuler and partially reverts the previous attempt as changing the ruler instance for vertical ruelr to SwCommentRuler caused test failures. Change-Id: Ie618b5dc5b936f9dc53d09b624eefdbc506d98f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167740 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit 9f26e04c8f97af9139e2f4be335fe6999d26a387) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168985 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx/source/dialog/svxruler.cxx')
-rw-r--r--svx/source/dialog/svxruler.cxx48
1 files changed, 47 insertions, 1 deletions
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index d1824a25d469..e0b84b9ad1ba 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -36,6 +36,7 @@
#include <svx/dialmgr.hxx>
#include <svx/ruler.hxx>
#include <svx/rulritem.hxx>
+#include <sfx2/viewsh.hxx>
#include <editeng/editids.hrc>
#include <editeng/tstpitem.hxx>
#include <editeng/lrspitem.hxx>
@@ -44,7 +45,10 @@
#include <rtl/math.hxx>
#include <o3tl/string_view.hxx>
#include <svl/itemset.hxx>
-
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <tools/json_writer.hxx>
+#include <tools/UnitConversion.hxx>
+#include <comphelper/lok.hxx>
#include "rlrcitem.hxx"
#include <memory>
@@ -1141,6 +1145,46 @@ void SvxRuler::SetNullOffsetLogic(tools::Long lVal) // Setting of the logic Null
Update();
}
+void SvxRuler::CreateJsonNotification(tools::JsonWriter& rJsonWriter)
+{
+ rJsonWriter.put("margin1", convertTwipToMm100(GetMargin1()));
+ rJsonWriter.put("margin2", convertTwipToMm100(GetMargin2()));
+ rJsonWriter.put("leftOffset", convertTwipToMm100(GetNullOffset()));
+ rJsonWriter.put("pageOffset", convertTwipToMm100(GetPageOffset()));
+
+ rJsonWriter.put("pageWidth", convertTwipToMm100(GetPageWidth()));
+ {
+ auto tabsNode = rJsonWriter.startNode("tabs");
+
+ // The RulerTab array elements that GetTabs() returns have their nPos field in twips. So these
+ // too are actual mm100.
+ for (auto const& tab : GetTabs())
+ {
+ auto tabNode = rJsonWriter.startNode("");
+ rJsonWriter.put("position", convertTwipToMm100(tab.nPos));
+ rJsonWriter.put("style", tab.nStyle);
+ }
+ }
+
+ RulerUnitData aUnitData = GetCurrentRulerUnit();
+ rJsonWriter.put("unit", aUnitData.aUnitStr);
+}
+
+void SvxRuler::NotifyKit()
+{
+ if (!comphelper::LibreOfficeKit::isActive())
+ return;
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (!pViewShell)
+ return;
+
+ tools::JsonWriter aJsonWriter;
+ CreateJsonNotification(aJsonWriter);
+ OString pJsonData = aJsonWriter.finishAndGetAsOString();
+ LibreOfficeKitCallbackType eType = isHorizontal() ? LOK_CALLBACK_RULER_UPDATE : LOK_CALLBACK_VERTICAL_RULER_UPDATE;
+ pViewShell->libreOfficeKitViewCallback(eType, pJsonData);
+}
+
void SvxRuler::Update()
{
/* Perform update of view */
@@ -1159,6 +1203,8 @@ void SvxRuler::Update()
if(nFlags & SvxRulerSupportFlags::TABS)
UpdateTabs();
+
+ NotifyKit();
}
tools::Long SvxRuler::GetPageWidth() const