summaryrefslogtreecommitdiff
path: root/svx/source/svdraw
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-06-07 12:31:10 +0900
committerTomaž Vajngerl <quikee@gmail.com>2024-06-11 12:49:05 +0200
commit2dc9d587cb38145141a4821006a09606e6625c35 (patch)
treeecd0a29ff888bd25c70e15b9c7518b77e3ee0e54 /svx/source/svdraw
parentc89131d1c6dc4fe19f214ec800412c173c2420f0 (diff)
annot: update annotation position, size, text when those change
Change-Id: I345f4c714ed4ca0c8277e0aedf5ea4b5cd70ea70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168513 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Jenkins
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r--svx/source/svdraw/svdobj.cxx41
-rw-r--r--svx/source/svdraw/svdotxed.cxx9
2 files changed, 39 insertions, 11 deletions
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 9da8c5662f12..34101b755ea7 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1533,15 +1533,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*/)
@@ -1562,11 +1571,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 4ecca10951e9..adcdb6a578a1 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 */