sd/qa/unit/tiledrendering/tiledrendering.cxx | 8 ++++---- sd/source/ui/annotations/annotationmanager.cxx | 3 +++ svx/source/annotation/AnnotationObject.cxx | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-)
New commits: commit b547e9f19de339531709c14931998125b9a41649 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Jul 10 14:22:53 2024 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Thu Jul 11 08:34:21 2024 +0200 tdf#161911 annot: fix for annotation with 0 size We need to set the size to something non-zero or it will stay zero even if we try to adapt the frame to the text content. Additionally when we adapt the frame to text, we need to update the annotation with the new size. Change-Id: I4125f95fe6d0e55ab3b00a6a457cd2c9e04ec7c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170260 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Jenkins diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 2b2bdb7a9c56..d6e041519974 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -1808,7 +1808,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCommentChangeImpress) CPPUNIT_ASSERT(!aView1.m_aCommentCallbackResult.get<std::string>("parthash").empty()); CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); - CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 282, 282"), aView1.m_aCommentCallbackResult.get<std::string>("rectangle")); + CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 705, 365"), aView1.m_aCommentCallbackResult.get<std::string>("rectangle")); // Edit this annotation now aArgs = comphelper::InitPropertySequence( @@ -1821,7 +1821,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCommentChangeImpress) CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView1.m_aCommentCallbackResult.get<std::string>("action")); CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); - CPPUNIT_ASSERT_EQUAL(std::string("10, 20, 282, 282"), aView1.m_aCommentCallbackResult.get<std::string>("rectangle")); + CPPUNIT_ASSERT_EQUAL(std::string("10, 20, 705, 365"), aView1.m_aCommentCallbackResult.get<std::string>("rectangle")); comphelper::LibreOfficeKit::setTiledAnnotations(true); } @@ -1854,7 +1854,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCommentChangeDraw) CPPUNIT_ASSERT(!aView1.m_aCommentCallbackResult.get<std::string>("parthash").empty()); CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); - CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 282, 282"), aView1.m_aCommentCallbackResult.get<std::string>("rectangle")); + CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 705, 365"), aView1.m_aCommentCallbackResult.get<std::string>("rectangle")); // Edit this annotation now aArgs = comphelper::InitPropertySequence( @@ -1867,7 +1867,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testCommentChangeDraw) CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView1.m_aCommentCallbackResult.get<std::string>("action")); CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); - CPPUNIT_ASSERT_EQUAL(std::string("10, 20, 282, 282"), aView1.m_aCommentCallbackResult.get<std::string>("rectangle")); + CPPUNIT_ASSERT_EQUAL(std::string("10, 20, 705, 365"), aView1.m_aCommentCallbackResult.get<std::string>("rectangle")); comphelper::LibreOfficeKit::setTiledAnnotations(true); } diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index c55cb5ae7567..000ef254b23e 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -1022,6 +1022,9 @@ void AnnotationManagerImpl::SyncAnnotationObjects() auto aRealSize2D = xAnnotation->getSize(); Size aSize(::tools::Long(aRealSize2D.Width * 100.0), ::tools::Long(aRealSize2D.Height * 100.0)); + // If the size is not set, set it to a default value so it is non-zero + if (aSize.getWidth() == 0 || aSize.getHeight() == 0) + aSize = Size(500, 500); ::tools::Rectangle aRectangle(aPosition, aSize); diff --git a/svx/source/annotation/AnnotationObject.cxx b/svx/source/annotation/AnnotationObject.cxx index d69f9be6e9fa..193a3438c277 100644 --- a/svx/source/annotation/AnnotationObject.cxx +++ b/svx/source/annotation/AnnotationObject.cxx @@ -168,6 +168,12 @@ void AnnotationObject::ApplyAnnotationName() aItemSet.Put(makeSdrTextAutoGrowHeightItem(true)); SetMergedItemSet(aItemSet); + + // Update the annotation size after the auto-sizing the frame to content does its magic + auto& xAnnotationData = getAnnotationData(); + css::geometry::RealSize2D aRealSize2D{ GetLogicRect().GetWidth() / 100.0, + GetLogicRect().GetHeight() / 100.0 }; + xAnnotationData->mxAnnotation->SetSize(aRealSize2D); } AnnotationObject::~AnnotationObject() {}