diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2025-03-12 18:26:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2025-03-12 19:05:30 +0100 |
commit | 477138a0570589e8dcecdbfe104a055f432638ce (patch) | |
tree | 6c68bfa9eab7173f5d8c71aa3888f6c2570318b4 /sw/source | |
parent | 3fef5a0d2bcc1bea859de7cc62a42cf99b7f98c8 (diff) |
use more concrete UNO class in sw
Change-Id: If5839135eba9e82516c29441d28938e73570d7f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182837
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index bf3a9bbd5341..8da46acd2ba0 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -90,9 +90,8 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, SdrObject* pObject, bool bCo } // Create the associated TextFrame and insert it into the document. - uno::Reference<text::XTextContent> xTextFrame( - SwXServiceProvider::MakeInstance(SwServiceType::TypeTextFrame, *pShape->GetDoc()), - uno::UNO_QUERY); + rtl::Reference<SwXTextFrame> xTextFrame + = SwXTextFrame::CreateXTextFrame(*pShape->GetDoc(), nullptr); uno::Reference<text::XTextRange> xAnchor; uno::Reference<text::XTextContent> xAnchorProvider(pObject->getWeakUnoShape().get(), @@ -118,18 +117,19 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, SdrObject* pObject, bool bCo { // insertTextContentWithProperties would fail if xAnchor is in a different XText assert(xAnchor->getText() == xTextContentAppend); - xTextContentAppend->insertTextContentWithProperties(xTextFrame, {}, xAnchor); + xTextContentAppend->insertTextContentWithProperties( + uno::Reference<text::XTextContent>(cppu::getXWeak(xTextFrame.get()), uno::UNO_QUERY), + {}, xAnchor); } else { - xTextContentAppend->appendTextContent(xTextFrame, uno::Sequence<beans::PropertyValue>()); + xTextContentAppend->appendTextContent( + uno::Reference<text::XTextContent>(cppu::getXWeak(xTextFrame.get()), uno::UNO_QUERY), + uno::Sequence<beans::PropertyValue>()); } // Link FLY and DRAW formats, so it becomes a text box (needed for syncProperty calls). - uno::Reference<text::XTextFrame> xRealTextFrame(xTextFrame, uno::UNO_QUERY); - auto pTextFrame = dynamic_cast<SwXTextFrame*>(xRealTextFrame.get()); - assert(nullptr != pTextFrame); - SwFrameFormat* pFormat = pTextFrame->GetFrameFormat(); + SwFrameFormat* pFormat = xTextFrame->GetFrameFormat(); assert(nullptr != dynamic_cast<SwDrawFrameFormat*>(pShape)); assert(nullptr != dynamic_cast<SwFlyFrameFormat*>(pFormat)); @@ -148,27 +148,23 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, SdrObject* pObject, bool bCo pFormat->SetOtherTextBoxFormats(pTextBox); } // Initialize properties. - uno::Reference<beans::XPropertySet> xPropertySet(xTextFrame, uno::UNO_QUERY); uno::Any aEmptyBorder{ table::BorderLine2() }; - xPropertySet->setPropertyValue(UNO_NAME_TOP_BORDER, aEmptyBorder); - xPropertySet->setPropertyValue(UNO_NAME_BOTTOM_BORDER, aEmptyBorder); - xPropertySet->setPropertyValue(UNO_NAME_LEFT_BORDER, aEmptyBorder); - xPropertySet->setPropertyValue(UNO_NAME_RIGHT_BORDER, aEmptyBorder); + xTextFrame->setPropertyValue(UNO_NAME_TOP_BORDER, aEmptyBorder); + xTextFrame->setPropertyValue(UNO_NAME_BOTTOM_BORDER, aEmptyBorder); + xTextFrame->setPropertyValue(UNO_NAME_LEFT_BORDER, aEmptyBorder); + xTextFrame->setPropertyValue(UNO_NAME_RIGHT_BORDER, aEmptyBorder); - xPropertySet->setPropertyValue(UNO_NAME_FILL_TRANSPARENCE, uno::Any(sal_Int32(100))); + xTextFrame->setPropertyValue(UNO_NAME_FILL_TRANSPARENCE, uno::Any(sal_Int32(100))); - xPropertySet->setPropertyValue(UNO_NAME_SIZE_TYPE, uno::Any(text::SizeType::FIX)); + xTextFrame->setPropertyValue(UNO_NAME_SIZE_TYPE, uno::Any(text::SizeType::FIX)); - xPropertySet->setPropertyValue(UNO_NAME_SURROUND, uno::Any(text::WrapTextMode_THROUGH)); + xTextFrame->setPropertyValue(UNO_NAME_SURROUND, uno::Any(text::WrapTextMode_THROUGH)); - uno::Reference<container::XNamed> xNamed(xTextFrame, uno::UNO_QUERY); - assert(!xNamed->getName().isEmpty()); - (void)xNamed; + assert(!xTextFrame->getName().isEmpty()); // Link its text range to the original shape. - uno::Reference<text::XTextRange> xTextBox(xTextFrame, uno::UNO_QUERY_THROW); SwUnoInternalPaM aInternalPaM(*pShape->GetDoc()); - if (sw::XTextRangeToSwPaM(aInternalPaM, xTextBox)) + if (sw::XTextRangeToSwPaM(aInternalPaM, xTextFrame)) { SwAttrSet aSet(pShape->GetAttrSet()); SwFormatContent aContent(aInternalPaM.GetPointNode().StartOfSectionNode()); @@ -221,9 +217,8 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape, SdrObject* pObject, bool bCo if (pObject) { auto pSourceText = DynCastSdrTextObj(pObject); - uno::Reference<text::XTextRange> xDestText(xRealTextFrame, uno::UNO_QUERY); - xDestText->setString(sCopyableText); + xTextFrame->setString(sCopyableText); if (pSourceText) pSourceText->SetText(OUString()); |