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 /svx | |
parent | 980ca3953084560806cd980d2ec16951d9e30c2b (diff) |
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>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 6 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 55 |
2 files changed, 44 insertions, 17 deletions
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 |