summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-05-16 19:52:32 +0900
committerMiklos Vajna <vmiklos@collabora.com>2024-05-17 08:45:01 +0200
commit9f26e04c8f97af9139e2f4be335fe6999d26a387 (patch)
tree33d2dd30a4cba558f1018a21be5e5868e434ddeb /svx/source
parent2a040bfe3e9f58db5c9f6503796778f07e2beba9 (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>
Diffstat (limited to 'svx/source')
-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 17c4edaa930d..14b7ce6d79d6 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