desktop/source/lib/init.cxx | 1 include/LibreOfficeKit/LibreOfficeKitEnums.h | 9 ++++ include/svx/svdmrkv.hxx | 2 libreofficekit/source/gtk/lokdocview.cxx | 1 svx/source/svdraw/svdedxv.cxx | 6 ++ svx/source/svdraw/svdmrkv.cxx | 55 ++++++++++++++++++--------- 6 files changed, 57 insertions(+), 17 deletions(-)
New commits: commit 12fd51017dc45ba032a9788825d305e4a3e2e131 Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Thu Mar 7 23:08:24 2024 +0530 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Fri Mar 8 10:54:39 2024 +0100 LOK: send inner text boundry information of shapes/textbox on change instroduced new callback for LOK LOK_CALLBACK_SHAPE_INNER_TEXT now if innert text is changed LOK is instantly updated about new textarea Change-Id: I0a88e1dd77556e47f14359ce0a98701a327aceda Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164547 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 586d9b4d84cc..bde805eedce5 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1876,6 +1876,7 @@ void CallbackFlushHandler::queue(const int type, CallbackData& aCallbackData) case LOK_CALLBACK_A11Y_FOCUSED_CELL_CHANGED: case LOK_CALLBACK_COLOR_PALETTES: case LOK_CALLBACK_TOOLTIP: + case LOK_CALLBACK_SHAPE_INNER_TEXT: { if (removeAll(type)) SAL_INFO("lok", "Removed dups of [" << type << "]: [" << aCallbackData.getPayload() << "]."); diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index 2b499b091105..9a6f34bbd846 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -1045,6 +1045,13 @@ typedef enum */ LOK_CALLBACK_TOOLTIP = 71, + /** + * Used for sending the rectangle for text inside a shape/textbox + * + * Payload contains the rectangle details + */ + LOK_CALLBACK_SHAPE_INNER_TEXT = 72, + } LibreOfficeKitCallbackType; @@ -1217,6 +1224,8 @@ static inline const char* lokCallbackTypeToString(int nType) return "LOK_CALLBACK_CORE_LOG"; case LOK_CALLBACK_TOOLTIP: return "LOK_CALLBACK_TOOLTIP"; + case LOK_CALLBACK_SHAPE_INNER_TEXT: + return "LOK_CALLBACK_SHAPE_INNER_TEXT"; } assert(!"Unknown LibreOfficeKitCallbackType type."); diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx index 162581fc5def..6421b51b0dba 100644 --- a/include/svx/svdmrkv.hxx +++ b/include/svx/svdmrkv.hxx @@ -150,6 +150,7 @@ private: void UndirtyMrkPnt() const; void SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const SfxViewShell* pOtherShell); + OString CreateInnerTextRectString() const; bool dumpGluePointsToJSON(boost::property_tree::ptree& rTree); protected: @@ -246,6 +247,7 @@ public: /// whether all x coordinates in use are negated or not void SetNegativeX(bool bOn) { mbNegativeX = bOn; } bool IsNegativeX() const { return mbNegativeX; } + void SetInnerTextAreaForLOKit() const; // migrate selections diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index f025cf99a140..60c3435ac28d 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -1498,6 +1498,7 @@ callback (gpointer pData) case LOK_CALLBACK_A11Y_SELECTION_CHANGED: case LOK_CALLBACK_CORE_LOG: case LOK_CALLBACK_TOOLTIP: + case LOK_CALLBACK_SHAPE_INNER_TEXT: { // TODO: Implement me break; diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index c2d35cc75b6b..0efdd449e00e 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -1964,7 +1964,10 @@ bool SdrObjEditView::KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin) if (mpTextEditOutlinerView->PostKeyEvent(rKEvt, pWin)) { if (mpTextEditOutliner && mpTextEditOutliner->IsModified()) + { GetModel().SetChanged(); + SetInnerTextAreaForLOKit(); + } /* Start chaining processing */ ImpChainingEventHdl(); @@ -2155,7 +2158,10 @@ bool SdrObjEditView::Command(const CommandEvent& rCEvt, vcl::Window* pWin) // It could execute CommandEventId::ExtTextInput, while SdrObjEditView::KeyInput // isn't called if (mpTextEditOutliner && mpTextEditOutliner->IsModified()) + { GetModel().SetChanged(); + SetInnerTextAreaForLOKit(); + } } return true; } diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index 8128de702dfd..477fb573d722 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -786,6 +786,41 @@ namespace }; } +OString SdrMarkView::CreateInnerTextRectString() const +{ + if (!mpMarkedObj) + return OString(); + + SdrPageView* pPageView = GetSdrPageView(); + const sdr::contact::ViewObjectContact& rVOC = mpMarkedObj->GetViewContact().GetViewObjectContact( + pPageView->GetPageWindow(0)->GetObjectContact()); + + sdr::contact::DisplayInfo aDisplayInfo; + TextBoundsExtractor aTextBoundsExtractor(rVOC.GetObjectContact().getViewInformation2D()); + basegfx::B2DRange aRange = aTextBoundsExtractor.getTextBounds(rVOC, aDisplayInfo); + if (!aRange.isEmpty()) { + tools::Rectangle rect(aRange.getMinX(), aRange.getMinY(), aRange.getMaxX(), aRange.getMaxY()); + tools::Rectangle aRangeTWIP = o3tl::convert(rect, o3tl::Length::mm100, o3tl::Length::twip); + OString innerTextInfo = "\"innerTextRect\":[" + + OString::number(aRangeTWIP.getX()) + "," + + OString::number(aRangeTWIP.getY()) + "," + + OString::number(aRangeTWIP.GetWidth()) + "," + + OString::number(aRangeTWIP.GetHeight()) + "]"; + return innerTextInfo; + } + + return OString(); +} + +void SdrMarkView::SetInnerTextAreaForLOKit() const +{ + if (!comphelper::LibreOfficeKit::isActive()) + return; + SfxViewShell* pViewShell = GetSfxViewShell(); + if (pViewShell) + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_SHAPE_INNER_TEXT, CreateInnerTextRectString()); +} + void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const SfxViewShell* pOtherShell) { SfxViewShell* pViewShell = GetSfxViewShell(); @@ -884,23 +919,9 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S if (mpMarkedObj && !pOtherShell) { - const sdr::contact::ViewObjectContact& rVOC = mpMarkedObj->GetViewContact().GetViewObjectContact( - pPageView->GetPageWindow(0)->GetObjectContact()); - - sdr::contact::DisplayInfo aDisplayInfo; - TextBoundsExtractor aTextBoundsExtractor(rVOC.GetObjectContact().getViewInformation2D()); - basegfx::B2DRange aRange = aTextBoundsExtractor.getTextBounds(rVOC, aDisplayInfo); - if (!aRange.isEmpty()) { - tools::Rectangle rect(aRange.getMinX(), aRange.getMinY(), aRange.getMaxX(), aRange.getMaxY()); - tools::Rectangle aRangeTWIP = o3tl::convert(rect, o3tl::Length::mm100, o3tl::Length::twip); - OString innerTextInfo = ",\"innerTextRect\":[" + - OString::number(aRangeTWIP.getX()) + "," + - OString::number(aRangeTWIP.getY()) + "," + - OString::number(aRangeTWIP.GetWidth()) + "," + - OString::number(aRangeTWIP.GetHeight()) + "]"; - - aExtraInfo.append(innerTextInfo); - } + OString innerTextInfo = CreateInnerTextRectString(); + if (!innerTextInfo.isEmpty()) + aExtraInfo.append("," + innerTextInfo); } // In core, the gridOffset is calculated based on the LogicRect's TopLeft coordinate