diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-06-07 12:31:10 +0900 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-06-18 11:18:28 +0200 |
commit | d65acecc180c437f4c564fb5b3c4ad985986801c (patch) | |
tree | a0649e91b539efccf95f8d3eb813c29de62a88b5 | |
parent | fec3f4bbf0606720d99bf92cbdaa1c18e1c0a570 (diff) |
annot: update annotation position, size, text when those change
Change-Id: I345f4c714ed4ca0c8277e0aedf5ea4b5cd70ea70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168604
Tested-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | include/svx/annotation/Annotation.hxx | 1 | ||||
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 41 | ||||
-rw-r--r-- | svx/source/svdraw/svdotxed.cxx | 9 |
3 files changed, 40 insertions, 11 deletions
diff --git a/include/svx/annotation/Annotation.hxx b/include/svx/annotation/Annotation.hxx index 09c6da0f7b83..0950335c8734 100644 --- a/include/svx/annotation/Annotation.hxx +++ b/include/svx/annotation/Annotation.hxx @@ -150,6 +150,7 @@ public: OUString GetText(); void SetText(OUString const& rText); + rtl::Reference<sdr::annotation::TextApiObject> getTextApiObject() { return m_TextRange; } SdrModel* GetModel() const; SdrPage const* getPage() const { return mpPage; } diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 1b180f19bdec..e1a4628a2fff 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -1539,15 +1539,24 @@ void SdrObject::NbcShear(const Point& rRef, Degree100 /*nAngle*/, double tn, boo SetGlueReallyAbsolute(false); } -void SdrObject::Move(const Size& rSiz) +void SdrObject::Move(const Size& rSize) { - if (rSiz.Width()!=0 || rSiz.Height()!=0) { - tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); - NbcMove(rSiz); - SetChanged(); - BroadcastObjectChange(); - SendUserCall(SdrUserCallType::MoveOnly,aBoundRect0); + if (rSize.Width() == 0 && rSize.Height() == 0) + return; + + tools::Rectangle aBoundRect0; + if (m_pUserCall != nullptr) + aBoundRect0 = GetLastBoundRect(); + NbcMove(rSize); + if (isAnnotationObject()) + { + auto& rRect = GetCurrentBoundRect(); + css::geometry::RealPoint2D aNewPosition(rRect.Left() / 100.0, rRect.Top() / 100.0); + getAnnotationData()->mxAnnotation->SetPosition(aNewPosition); } + SetChanged(); + BroadcastObjectChange(); + SendUserCall(SdrUserCallType::MoveOnly, aBoundRect0); } void SdrObject::NbcCrop(const basegfx::B2DPoint& /*aRef*/, double /*fxFact*/, double /*fyFact*/) @@ -1568,11 +1577,23 @@ void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction& mpImpl->meRelativeHeightRelation = text::RelOrientation::PAGE_FRAME; mpImpl->mnRelativeHeight.reset(); } - tools::Rectangle aBoundRect0; if (m_pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); - NbcResize(rRef,xFact,yFact); + tools::Rectangle aBoundRect0; + + if (m_pUserCall != nullptr) + aBoundRect0 = GetLastBoundRect(); + + NbcResize(rRef, xFact, yFact); + + if (isAnnotationObject()) + { + auto& rRect = GetCurrentBoundRect(); + css::geometry::RealSize2D aNewSize(rRect.GetWidth() / 100.0, rRect.GetHeight() / 100.0); + getAnnotationData()->mxAnnotation->SetSize(aNewSize); + } + SetChanged(); BroadcastObjectChange(); - SendUserCall(SdrUserCallType::Resize,aBoundRect0); + SendUserCall(SdrUserCallType::Resize, aBoundRect0); } void SdrObject::Crop(const basegfx::B2DPoint& rRef, double fxFact, double fyFact) diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx index 8666f262be92..3e54761325a1 100644 --- a/svx/source/svdraw/svdotxed.cxx +++ b/svx/source/svdraw/svdotxed.cxx @@ -29,7 +29,7 @@ #include <editeng/eeitem.hxx> #include <svx/sdtfchim.hxx> #include <textchain.hxx> - +#include <svx/annotation/ObjectAnnotationData.hxx> bool SdrTextObj::HasTextEdit() const { @@ -286,6 +286,13 @@ void SdrTextObj::EndTextEdit(SdrOutliner& rOutl) } else { // If we are not doing in-chaining switching just set the ParaObject SetOutlinerParaObject(std::move(pNewText)); } + + if (isAnnotationObject()) + { + auto xTextAPI(getAnnotationData()->mxAnnotation->getTextApiObject()); + std::optional<OutlinerParaObject> pAnnotationText = rOutl.CreateParaObject(0, rOutl.GetParagraphCount()); + xTextAPI->SetText(*pAnnotationText); + } } /* Chaining-related code */ |