desktop/source/lib/init.cxx                  |    2 ++
 include/LibreOfficeKit/LibreOfficeKitEnums.h |   21 ++++++++++++++++++++-
 libreofficekit/source/gtk/lokdocview.cxx     |    3 +++
 sw/source/uibase/inc/swruler.hxx             |    2 ++
 sw/source/uibase/misc/swruler.cxx            |   14 +++++++++++---
 sw/source/uibase/uiview/view.cxx             |   14 +++++++++-----
 6 files changed, 47 insertions(+), 9 deletions(-)

New commits:
commit 40ddb619cfc88d161cb74a1f516dd39196658d50
Author:     Darshan-upadhyay1110 <darshan.upadh...@collabora.com>
AuthorDate: Fri May 10 20:04:01 2024 +0530
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Mon Jun 17 10:23:27 2024 +0200

    Add new LOK CALLBACK for vertical ruler
    
    - We're adding a new LOK callback LOK_CALLBACK_VERTICAL_RULER_UPDATE.
    - The reason is that we currently override the existing callback.
    - Using the same callback for both vertical and horizontal rulers causes an 
issue.
    - override will create problem like it will only send any one of the ruler 
orientation update.
    - It results in online updates being limited to just one ruler orientation.
    - By introducing a new callback, we ensure updates for both vertical and 
horizontal rulers both are captured correctly in online.
    
    Change-Id: I02d0e3e7e4ac8a07a83644460aa0ba36e0f3c013
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167481
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 11b936629dd4ef9308d63b312900b8b7c8ff19b4)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167464
    Tested-by: Jenkins

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c8af7f847ee5..2519f2d985c6 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1526,6 +1526,7 @@ 
CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, Li
     m_states.emplace(LOK_CALLBACK_TABLE_SELECTED, "NIL"_ostr);
     m_states.emplace(LOK_CALLBACK_TAB_STOP_LIST, "NIL"_ostr);
     m_states.emplace(LOK_CALLBACK_RULER_UPDATE, "NIL"_ostr);
+    m_states.emplace(LOK_CALLBACK_VERTICAL_RULER_UPDATE, "NIL"_ostr);
     m_states.emplace(LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE, "NIL"_ostr);
 }
 
@@ -1834,6 +1835,7 @@ void CallbackFlushHandler::queue(const int type, 
CallbackData& aCallbackData)
             case LOK_CALLBACK_SET_PART:
             case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
             case LOK_CALLBACK_RULER_UPDATE:
+            case LOK_CALLBACK_VERTICAL_RULER_UPDATE:
             case LOK_CALLBACK_A11Y_FOCUS_CHANGED:
             case LOK_CALLBACK_A11Y_CARET_CHANGED:
             case LOK_CALLBACK_A11Y_TEXT_SELECTION_CHANGED:
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h 
b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 9a6f34bbd846..516622722bb9 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -581,7 +581,7 @@ typedef enum
      */
     LOK_CALLBACK_CELL_ADDRESS = 34,
     /**
-     * The key ruler related properties on change are reported by this.
+     * The key horizontal ruler related properties on change are reported by 
this.
      *
      * The payload format is:
      *
@@ -1051,6 +1051,23 @@ typedef enum
      *  Payload contains the rectangle details
      */
     LOK_CALLBACK_SHAPE_INNER_TEXT = 72,
+        /**
+     * The key vertical ruler related properties on change are reported by 
this.
+     *
+     * The payload format is:
+     *
+     * {
+     *      "margin1": "...",
+     *      "margin2": "...",
+     *      "leftOffset": "...",
+     *      "pageOffset": "...",
+     *      "pageWidth": "...",
+     *      "unit": "..."
+     *  }
+     *
+     * Here all aproperties are same as described in svxruler.
+     */
+    LOK_CALLBACK_VERTICAL_RULER_UPDATE = 73
 
 }
 LibreOfficeKitCallbackType;
@@ -1152,6 +1169,8 @@ static inline const char* lokCallbackTypeToString(int 
nType)
         return "LOK_CALLBACK_COMMENT";
     case LOK_CALLBACK_RULER_UPDATE:
         return "LOK_CALLBACK_RULER_UPDATE";
+    case LOK_CALLBACK_VERTICAL_RULER_UPDATE:
+        return "LOK_CALLBACK_VERTICAL_RULER_UPDATE";
     case LOK_CALLBACK_WINDOW:
         return "LOK_CALLBACK_WINDOW";
     case LOK_CALLBACK_VALIDITY_LIST_BUTTON:
diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 60c3435ac28d..5dddaa2d0e37 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1376,6 +1376,9 @@ callback (gpointer pData)
     case LOK_CALLBACK_RULER_UPDATE:
         g_signal_emit(pCallback->m_pDocView, doc_view_signals[RULER], 0, 
pCallback->m_aPayload.c_str());
         break;
+    case LOK_CALLBACK_VERTICAL_RULER_UPDATE:
+        g_signal_emit(pCallback->m_pDocView, doc_view_signals[RULER], 0, 
pCallback->m_aPayload.c_str());
+        break;
     case LOK_CALLBACK_WINDOW:
         g_signal_emit(pCallback->m_pDocView, doc_view_signals[WINDOW], 0, 
pCallback->m_aPayload.c_str());
         break;
diff --git a/sw/source/uibase/inc/swruler.hxx b/sw/source/uibase/inc/swruler.hxx
index f18f8721fc8a..058cf4bcf62c 100644
--- a/sw/source/uibase/inc/swruler.hxx
+++ b/sw/source/uibase/inc/swruler.hxx
@@ -44,6 +44,7 @@ public:
      */
     virtual void Paint( vcl::RenderContext& rRenderContext, const 
tools::Rectangle& rRect ) override;
     void CreateJsonNotification(tools::JsonWriter& rJsonWriter);
+    bool IsHorizontal() const { return mbHorizontal; }
 
 private:
     SwViewShell * mpViewShell;     //< Shell to check if there is any comments 
on doc and their visibility
@@ -54,6 +55,7 @@ private:
     Timer       maFadeTimer;     //< Timer for high/'low'light fading
     int         mnFadeRate;      //< From 0 to 100. 0 means not highlighted.
     ScopedVclPtr<VirtualDevice> maVirDev;      //< VirtualDevice of this 
window. Just for convenience.
+    bool mbHorizontal;     // Check if ruler is horizontal or not
 
     void NotifyKit();
     /**
diff --git a/sw/source/uibase/misc/swruler.cxx 
b/sw/source/uibase/misc/swruler.cxx
index 7f74f4afd6d7..da9f6f501748 100644
--- a/sw/source/uibase/misc/swruler.cxx
+++ b/sw/source/uibase/misc/swruler.cxx
@@ -99,6 +99,7 @@ SwCommentRuler::SwCommentRuler(SwViewShell* pViewSh, 
vcl::Window* pParent, SwEdi
     vcl::Font aFont(maVirDev->GetFont());
     aFont.SetFontHeight(aFont.GetFontHeight() + 1);
     maVirDev->SetFont(aFont);
+    mbHorizontal = nWinStyle & WB_HSCROLL;
 }
 
 SwCommentRuler::~SwCommentRuler() { disposeOnce(); }
@@ -288,7 +289,6 @@ void 
SwCommentRuler::CreateJsonNotification(tools::JsonWriter& rJsonWriter)
     // GetPageWidth() on the other hand does return a value in twips.
     // So here convertTwipToMm100() really does produce actual mm100. Fun.
     rJsonWriter.put("pageWidth", convertTwipToMm100(GetPageWidth()));
-
     {
         auto tabsNode = rJsonWriter.startNode("tabs");
 
@@ -314,8 +314,16 @@ void SwCommentRuler::NotifyKit()
     tools::JsonWriter aJsonWriter;
     CreateJsonNotification(aJsonWriter);
     OString pJsonData = aJsonWriter.finishAndGetAsOString();
-    
mpViewShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_RULER_UPDATE,
-                                                               pJsonData);
+    if (mbHorizontal)
+    {
+        
mpViewShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_RULER_UPDATE,
+                                                                   pJsonData);
+    }
+    else
+    {
+        mpViewShell->GetSfxViewShell()->libreOfficeKitViewCallback(
+            LOK_CALLBACK_VERTICAL_RULER_UPDATE, pJsonData);
+    }
 }
 
 void SwCommentRuler::Update()
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 4cace8a3d729..1bd82e27f0dd 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -766,11 +766,6 @@ SwView::SwView(SfxViewFrame& _rFrame, SfxViewShell* pOldSh)
     m_pFormShell(nullptr),
     m_pHScrollbar(nullptr),
     m_pVScrollbar(nullptr),
-    m_pVRuler(VclPtr<SvxRuler>::Create(&GetViewFrame().GetWindow(), m_pEditWin,
-                            SvxRulerSupportFlags::TABS | 
SvxRulerSupportFlags::PARAGRAPH_MARGINS_VERTICAL|
-                                SvxRulerSupportFlags::BORDERS | 
SvxRulerSupportFlags::REDUCED_METRIC,
-                            GetViewFrame().GetBindings(),
-                            WB_VSCROLL |  WB_EXTRAFIELD | WB_BORDER )),
     m_pLastTableFormat(nullptr),
     m_pLastFlyFormat(nullptr),
     m_pFormatClipboard(new SwFormatClipboard()),
@@ -942,6 +937,15 @@ SwView::SwView(SfxViewFrame& _rFrame, SfxViewShell* pOldSh)
                 GetViewFrame().GetBindings(),
                 WB_STDRULER | WB_EXTRAFIELD | WB_BORDER);
 
+    m_pVRuler = VclPtr<SvxRuler>::Create(&GetViewFrame().GetWindow(), 
m_pEditWin,
+                SvxRulerSupportFlags::TABS |
+                SvxRulerSupportFlags::PARAGRAPH_MARGINS_VERTICAL |
+                SvxRulerSupportFlags::BORDERS |
+                SvxRulerSupportFlags::NEGATIVE_MARGINS|
+                SvxRulerSupportFlags::REDUCED_METRIC,
+                GetViewFrame().GetBindings(),
+                WB_VSCROLL | WB_EXTRAFIELD | WB_BORDER);
+
     // assure that modified state of document
     // isn't reset, if document is already modified.
     const bool bIsDocModified = 
m_pWrtShell->GetDoc()->getIDocumentState().IsModified();

Reply via email to