diff options
author | Darshan-upadhyay1110 <darshan.upadhyay@collabora.com> | 2024-05-10 20:04:01 +0530 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-05-14 11:59:58 +0200 |
commit | 11b936629dd4ef9308d63b312900b8b7c8ff19b4 (patch) | |
tree | dd124f693b68f1cae8bdac4a8847bdea63fb61a9 | |
parent | 48ee8fb96540e68a17599b5db505f9b056dc09f3 (diff) |
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 <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | desktop/source/lib/init.cxx | 2 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitEnums.h | 21 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/inc/swruler.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/misc/swruler.cxx | 14 | ||||
-rw-r--r-- | sw/source/uibase/uiview/view.cxx | 14 |
6 files changed, 47 insertions, 9 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 962d676694ac..3ae89cf84ba1 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1547,6 +1547,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); } @@ -1878,6 +1879,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 6c903f9ca9a5..430c089abfe0 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 @@ -52,6 +53,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 0ccdec2f46a5..bce0e27489ca 100644 --- a/sw/source/uibase/misc/swruler.cxx +++ b/sw/source/uibase/misc/swruler.cxx @@ -96,6 +96,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(); } @@ -259,7 +260,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"); @@ -285,8 +285,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 8583fc004a5a..25d3f101ddb9 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -767,11 +767,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()), @@ -943,6 +938,15 @@ SwView::SwView(SfxViewFrame& _rFrame, SfxViewShell* pOldSh) GetViewFrame().GetBindings(), WB_STDRULER | WB_EXTRAFIELD | WB_BORDER); + m_pVRuler = VclPtr<SwCommentRuler>::Create(m_pWrtShell.get(), &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(); |