From 41c04ceb3b1b14c3c99ede86524df8f3de4f5daa Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 20 May 2024 12:55:15 +0200 Subject: [PATCH] use more concrete UNO types in sw Change-Id: I3cf017e74e7cc9902486d6dba1d89f70c47c978a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167864 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/inc/unocoll.hxx | 3 ++- sw/source/core/unocore/unocoll.cxx | 2 +- sw/source/core/unocore/unoredline.cxx | 3 ++- sw/source/core/unocore/unotext.cxx | 11 ++++------- sw/source/filter/ww8/docxtableexport.cxx | 4 ++-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx index 6254801bf8a7..0ecca6fb45c2 100644 --- a/sw/inc/unocoll.hxx +++ b/sw/inc/unocoll.hxx @@ -40,6 +40,7 @@ class SwSectionFormat; struct SvEventDescription; class SwXFootnote; class SwXTextSection; +class SwXTextTable; const SvEventDescription* sw_GetSupportedMacroItems(); @@ -287,7 +288,7 @@ public: virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - SW_DLLPUBLIC static css::uno::Reference GetObject(SwFrameFormat& rFormat); + SW_DLLPUBLIC static rtl::Reference GetObject(SwFrameFormat& rFormat); }; typedef diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 24016c53350f..e00fa835f16a 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -973,7 +973,7 @@ uno::Sequence< OUString > SwXTextTables::getSupportedServiceNames() return { u"com.sun.star.text.TextTables"_ustr }; } -uno::Reference SwXTextTables::GetObject(SwFrameFormat& rFormat) +rtl::Reference SwXTextTables::GetObject(SwFrameFormat& rFormat) { return SwXTextTable::CreateXTextTable(& rFormat); } diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 27fd9aa7f555..b97cc20028b2 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -42,6 +42,7 @@ #include #include #include +#include using namespace ::com::sun::star; @@ -422,7 +423,7 @@ uno::Any SwXRedline::getPropertyValue( const OUString& rPropertyName ) OSL_ENSURE(pTableNode, "No table node!"); SwTable& rTable = pTableNode->GetTable(); SwFrameFormat* pTableFormat = rTable.GetFrameFormat(); - xRet = SwXTextTables::GetObject( *pTableFormat ); + xRet = cppu::getXWeak(SwXTextTables::GetObject( *pTableFormat ).get()); } break; case SwNodeType::Text : diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 730e24ca6718..50d9f75db63f 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2214,9 +2214,8 @@ SwXText::convertToTable( if (!pTable) return uno::Reference< text::XTextTable >(); - uno::Reference const xRet = + rtl::Reference const xRet = SwXTextTable::CreateXTextTable(pTable->GetFrameFormat()); - uno::Reference const xPrSet(xRet, uno::UNO_QUERY); // set properties to the table // catch lang::WrappedTargetException and lang::IndexOutOfBoundsException try @@ -2254,7 +2253,7 @@ SwXText::convertToTable( }; if (std::find(vDenylist.begin(), vDenylist.end(), rTableProperty.Name) == vDenylist.end()) { - xPrSet->setPropertyValue(rTableProperty.Name, rTableProperty.Value); + xRet->setPropertyValue(rTableProperty.Name, rTableProperty.Value); } } catch (const uno::Exception&) @@ -2270,7 +2269,6 @@ SwXText::convertToTable( for(sal_Int32 nCnt = 0; nCnt < nLast; ++nCnt) lcl_ApplyRowProperties(rRowProperties[nCnt], xRows->getByIndex(nCnt), aRowSeparators[nCnt]); - uno::Reference const xCR(xRet, uno::UNO_QUERY_THROW); //apply cell properties sal_Int32 nRow = 0; for(const auto& rCellPropertiesForRow : rCellProperties) @@ -2280,7 +2278,7 @@ SwXText::convertToTable( { lcl_ApplyCellProperties(lcl_GetLeftPos(nCell, aRowSeparators[nRow]), rCellProps, - xCR->getCellByPosition(nCell, nRow), + xRet->getCellByPosition(nCell, nRow), aMergedCells); ++nCell; } @@ -2299,8 +2297,7 @@ SwXText::convertToTable( } assert(SwTable::FindTable(pTable->GetFrameFormat()) == pTable); - assert(pTable->GetFrameFormat() == - dynamic_cast(*xRet).GetFrameFormat()); + assert(pTable->GetFrameFormat() == xRet->GetFrameFormat()); return xRet; } diff --git a/sw/source/filter/ww8/docxtableexport.cxx b/sw/source/filter/ww8/docxtableexport.cxx index f6bbef34dddc..ba89f5695d04 100644 --- a/sw/source/filter/ww8/docxtableexport.cxx +++ b/sw/source/filter/ww8/docxtableexport.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include "docxexportfilter.hxx" #include "docxhelper.hxx" @@ -218,8 +219,7 @@ void DocxAttributeOutput::TableDefinition( nWidthPercent = rFrameSize.GetWidthPercent(); } - uno::Reference xPropertySet( - SwXTextTables::GetObject(*pTable->GetFrameFormat()), uno::UNO_QUERY); + rtl::Reference xPropertySet = SwXTextTables::GetObject(*pTable->GetFrameFormat()); bool isWidthRelative = false; xPropertySet->getPropertyValue("IsWidthRelative") >>= isWidthRelative; if (!isWidthRelative && !nWidthPercent)