diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2024-03-07 23:08:24 +0530 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-03-08 10:55:26 +0100 |
commit | 34daf30c7a02208408b83a8ff872736b98a732e0 (patch) | |
tree | 80b88a4cfa5704e1981c2ba0ede3a15b5e13a899 | |
parent | ucb: webdav-curl: don't set CURLOPT_NOBODY for OPTIONS (diff) | |
download | core-34daf30c7a02208408b83a8ff872736b98a732e0.tar.gz core-34daf30c7a02208408b83a8ff872736b98a732e0.zip |
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/+/164497
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r-- | desktop/source/lib/init.cxx | 1 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitEnums.h | 9 | ||||
-rw-r--r-- | include/svx/svdmrkv.hxx | 2 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 1 | ||||
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 6 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 55 |
6 files changed, 57 insertions, 17 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 6d221ec84418..d2525bcddcb3 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1871,6 +1871,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 c0e1b715ea31..f60baf1b64fe 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -2051,7 +2051,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(); @@ -2242,7 +2245,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 b9a492aa35ad..ccb873811143 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 |