XUnoTunnel->dynamic_cast in SwXTextTable

Change-Id: I18c229f31738707e4a379c9379425141ba4dc690
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145787
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2023-01-19 17:56:25 +00:00
parent 0c25ccbd0e
commit 7d2bee35c4
7 changed files with 12 additions and 38 deletions
+3 -10
View File
@@ -246,7 +246,7 @@ struct SwRangeDescriptor
void Normalize();
};
class SAL_DLLPUBLIC_RTTI SwXTextTable final : public cppu::WeakImplHelper
class SW_DLLPUBLIC SwXTextTable final : public cppu::WeakImplHelper
<
css::text::XTextTable,
css::lang::XServiceInfo,
@@ -256,7 +256,6 @@ class SAL_DLLPUBLIC_RTTI SwXTextTable final : public cppu::WeakImplHelper
css::container::XNamed,
css::table::XAutoFormattable,
css::util::XSortable,
css::lang::XUnoTunnel,
css::sheet::XCellRangeData
>
{
@@ -272,15 +271,9 @@ public:
static rtl::Reference<SwXTextTable>
CreateXTextTable(SwFrameFormat * pFrameFormat);
SW_DLLPUBLIC static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
SW_DLLPUBLIC static void GetCellPosition(std::u16string_view aCellName, sal_Int32& o_rColumn, sal_Int32& o_rRow);
SW_DLLPUBLIC SwFrameFormat* GetFrameFormat();
//XUnoTunnel
virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
static void GetCellPosition(std::u16string_view aCellName, sal_Int32& o_rColumn, sal_Int32& o_rRow);
SwFrameFormat* GetFrameFormat();
//XTextTable
virtual void SAL_CALL initialize( sal_Int32 nRows, sal_Int32 nColumns ) override;
+1 -2
View File
@@ -202,8 +202,7 @@ void GetSelectableFromAny(uno::Reference<uno::XInterface> const& xIfc,
return;
}
SwXTextTable *const pTextTable(
comphelper::getFromUnoTunnel<SwXTextTable>(xTunnel));
SwXTextTable *const pTextTable = dynamic_cast<SwXTextTable*>(xIfc.get());
if (pTextTable)
{
SwFrameFormat *const pFrameFormat(pTextTable->GetFrameFormat());
+1 -13
View File
@@ -1947,18 +1947,6 @@ public:
};
const uno::Sequence< sal_Int8 > & SwXTextTable::getUnoTunnelId()
{
static const comphelper::UnoIdInit theSwXTextTableUnoTunnelId;
return theSwXTextTableUnoTunnelId.getSeq();
}
sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >& rId )
{
return comphelper::getSomethingImpl(rId, this);
}
SwXTextTable::SwXTextTable()
: m_pImpl(new Impl(nullptr))
{
@@ -2072,7 +2060,7 @@ SwXTextTable::attach(const uno::Reference<text::XTextRange> & xTextRange)
if (!m_pImpl->IsDescriptor()) /* already attached ? */
throw uno::RuntimeException("SwXTextTable: already attached to range.", static_cast<cppu::OWeakObject*>(this));
uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
uno::Reference<lang::XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
SwXTextRange* pRange(comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel));
OTextCursorHelper* pCursor(dynamic_cast<OTextCursorHelper*>(xTextRange.get()));
SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : nullptr;
+4 -8
View File
@@ -647,8 +647,7 @@ SwXText::insertTextContentBefore(
uno::UNO_QUERY);
SwXTextSection *const pXSection =
comphelper::getFromUnoTunnel<SwXTextSection>(xSuccTunnel);
SwXTextTable *const pXTable =
comphelper::getFromUnoTunnel<SwXTextTable>(xSuccTunnel);
SwXTextTable *const pXTable = dynamic_cast<SwXTextTable*>(xSuccessor.get());
SwFrameFormat *const pTableFormat = pXTable ? pXTable->GetFrameFormat() : nullptr;
SwTextNode * pTextNode = nullptr;
if(pTableFormat && pTableFormat->GetDoc() == GetDoc())
@@ -701,8 +700,7 @@ SwXText::insertTextContentAfter(
uno::UNO_QUERY);
SwXTextSection *const pXSection =
comphelper::getFromUnoTunnel<SwXTextSection>(xPredTunnel);
SwXTextTable *const pXTable =
comphelper::getFromUnoTunnel<SwXTextTable>(xPredTunnel);
SwXTextTable *const pXTable = dynamic_cast<SwXTextTable*>(xPredecessor.get());
SwFrameFormat *const pTableFormat = pXTable ? pXTable->GetFrameFormat() : nullptr;
bool bRet = false;
SwTextNode * pTextNode = nullptr;
@@ -751,8 +749,7 @@ SwXText::removeTextContentBefore(
uno::UNO_QUERY);
SwXTextSection *const pXSection =
comphelper::getFromUnoTunnel<SwXTextSection>(xSuccTunnel);
SwXTextTable *const pXTable =
comphelper::getFromUnoTunnel<SwXTextTable>(xSuccTunnel);
SwXTextTable *const pXTable = dynamic_cast<SwXTextTable*>(xSuccessor.get());
SwFrameFormat *const pTableFormat = pXTable ? pXTable->GetFrameFormat() : nullptr;
if(pTableFormat && pTableFormat->GetDoc() == GetDoc())
{
@@ -803,8 +800,7 @@ SwXText::removeTextContentAfter(
uno::UNO_QUERY);
SwXTextSection *const pXSection =
comphelper::getFromUnoTunnel<SwXTextSection>(xPredTunnel);
SwXTextTable *const pXTable =
comphelper::getFromUnoTunnel<SwXTextTable>(xPredTunnel);
SwXTextTable *const pXTable = dynamic_cast<SwXTextTable*>(xPredecessor.get());
SwFrameFormat *const pTableFormat = pXTable ? pXTable->GetFrameFormat() : nullptr;
if(pTableFormat && pTableFormat->GetDoc() == GetDoc())
{
+1 -2
View File
@@ -1208,8 +1208,7 @@ void SwXMLTextParagraphExport::exportTable(
OSL_ENSURE( xTextTable.is(), "text table missing" );
if( xTextTable.is() )
{
Reference<XUnoTunnel> xTableTunnel( rTextContent, UNO_QUERY);
SwXTextTable* pXTable = comphelper::getFromUnoTunnel<SwXTextTable>(xTableTunnel);
SwXTextTable* pXTable = dynamic_cast<SwXTextTable*>(rTextContent.get());
if( pXTable )
{
SwFrameFormat *const pFormat = pXTable->GetFrameFormat();
+1 -1
View File
@@ -1213,7 +1213,7 @@ SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
// xml:id for RDF metadata
GetImport().SetXmlId(xTable, sXmlId);
pXTable = comphelper::getFromUnoTunnel<SwXTextTable>(xTable);
pXTable = dynamic_cast<SwXTextTable*>(xTable.get());
Reference < XCellRange > xCellRange( xTable, UNO_QUERY );
Reference < XCell > xCell = xCellRange->getCellByPosition( 0, 0 );
+1 -2
View File
@@ -36,8 +36,7 @@ SwVbaTableHelper::SwVbaTableHelper( uno::Reference< text::XTextTable > xTextTabl
SwTable* SwVbaTableHelper::GetSwTable( const uno::Reference< text::XTextTable >& xTextTable )
{
uno::Reference< lang::XUnoTunnel > xTunnel( xTextTable, uno::UNO_QUERY_THROW );
SwXTextTable* pXTextTable = comphelper::getFromUnoTunnel<SwXTextTable>(xTunnel);
SwXTextTable* pXTextTable = dynamic_cast<SwXTextTable*>(xTextTable.get());
if( !pXTextTable )
throw uno::RuntimeException();