// tdf#161899: Without the fix in place, this test would have crashed here const SfxStringItem aItem(SID_DELETEALLBYAUTHOR_POSTIT, u"A"_ustr);
pViewShell->GetDispatcher()->ExecuteList(SID_DELETEALLBYAUTHOR_POSTIT, SfxCallMode::ASYNCHRON,
{ &aItem });
Scheduler::ProcessEventsToIdle();
// 1 object in the page now
CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount()); // .. and is an annotation object
SdrObject* pObject = pPage->GetObj(0);
CPPUNIT_ASSERT_EQUAL(SdrObjKind::Annotation, pObject->GetObjIdentifier()); auto& pAnnotationData = pObject->getAnnotationData();
CPPUNIT_ASSERT(pAnnotationData);
// Remember the annotation ID
sal_uInt64 nID = pAnnotationData->mxAnnotation->GetId();
// Current annotation position
CPPUNIT_ASSERT_EQUAL(tools::Long(0), pObject->GetLogicRect().Left());
CPPUNIT_ASSERT_EQUAL(tools::Long(0), pObject->GetLogicRect().Top());
// Move the object
pObject->Move({ 200, 200 });
// Object at a new position
CPPUNIT_ASSERT_EQUAL(tools::Long(200),
pObject->GetLogicRect().Left()); // in 100th of an mm (hmm)
CPPUNIT_ASSERT_EQUAL(tools::Long(200), pObject->GetLogicRect().Top());
// Position of the annotation would be the same as the object (2.0 mm equals 200 hmm)
CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0, pAnnotationData->mxAnnotation->getPosition().X, 1E-4); // mm
CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0, pAnnotationData->mxAnnotation->getPosition().Y, 1E-4);
// Position of the annotation changed again
CPPUNIT_ASSERT_DOUBLES_EQUAL(25.4, pAnnotationData->mxAnnotation->getPosition().X, 1E-4); // in mm
CPPUNIT_ASSERT_DOUBLES_EQUAL(254.0, pAnnotationData->mxAnnotation->getPosition().Y, 1E-4);
// Position of the annotation object changed also to the same value
CPPUNIT_ASSERT_EQUAL(tools::Long(2540), pObject->GetLogicRect().Left()); // in hmm
CPPUNIT_ASSERT_EQUAL(tools::Long(25400), pObject->GetLogicRect().Top());
}
CPPUNIT_TEST_FIXTURE(AnnotationTest, testAnnotationDuplicatePage)
{ // Check the annotation object is properly cloned when duplicating the page.
// Check state
{ // 1 Annotation in the page
CPPUNIT_ASSERT_EQUAL(size_t(1), pPage1->getAnnotations().size());
// 1 Object in the page
CPPUNIT_ASSERT_EQUAL(size_t(1), pPage1->GetObjCount());
// And the object is an annotation
SdrObject* pObject = pPage1->GetObj(0);
CPPUNIT_ASSERT_EQUAL(SdrObjKind::Annotation, pObject->GetObjIdentifier());
CPPUNIT_ASSERT(pObject->isAnnotationObject()); auto& rAnnotationData = pObject->getAnnotationData();
// Get the annotation from the page 1 auto xAnnotation = pPage1->getAnnotations().at(0);
// Annotation in the object is the same as the one in the page
CPPUNIT_ASSERT_EQUAL(xAnnotation.get(), rAnnotationData->mxAnnotation.get());
// Check text of the annotation
CPPUNIT_ASSERT_EQUAL(u"Comment"_ustr, xAnnotation->GetText());
}
// Let's duplicate the page
dispatchCommand(mxComponent, u".uno:DuplicatePage"_ustr, {});
// Let's switch to the 2nd page
CPPUNIT_ASSERT_EQUAL(true, pDrawViewShell->SwitchPage(1));
// Check state
{ // Get the current page
SdrPage* pPage2 = pDrawViewShell->GetActualPage();
// Should not be the same page as previous page
CPPUNIT_ASSERT(pPage2 != pPage1);
// 1 Annotation in the page
CPPUNIT_ASSERT_EQUAL(size_t(1), pPage2->getAnnotations().size());
// 1 Object in the page
CPPUNIT_ASSERT_EQUAL(size_t(1), pPage2->GetObjCount());
// And the object is an annotation
SdrObject* pObject = pPage2->GetObj(0);
CPPUNIT_ASSERT_EQUAL(SdrObjKind::Annotation, pObject->GetObjIdentifier());
CPPUNIT_ASSERT(pObject->isAnnotationObject()); auto& rAnnotationData = pObject->getAnnotationData();
// Get the annotation from the page 2 auto xAnnotation = pPage2->getAnnotations().at(0);
// Annotation in the object is the same as the one in the page
CPPUNIT_ASSERT_EQUAL(xAnnotation.get(), rAnnotationData->mxAnnotation.get());
// Check text of the annotation
CPPUNIT_ASSERT_EQUAL(u"Comment"_ustr, xAnnotation->GetText());
// Annotation in page 1 is not the same instance as annotation in page 2 // We verify the annotation was copied
CPPUNIT_ASSERT(pPage1->getAnnotations().at(0).get()
!= pPage2->getAnnotations().at(0).get());
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.14Bemerkung:
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.