From b83beb8481b645b4db04112d63837a372cba6e57 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 3 Aug 2020 11:15:12 +0200 Subject: use more explicit types in xmloff instead of declaring them as a base-type, and then static-casting everwhere Change-Id: I53b901c5353bb39ca9a0357aa442f50d2f475e7d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99995 Tested-by: Jenkins Reviewed-by: Noel Grandin --- xmloff/inc/txtfldi.hxx | 2 +- xmloff/source/core/xmlimp.cxx | 36 +++++++++++------------ xmloff/source/style/XMLFontStylesContext_impl.hxx | 4 +-- xmloff/source/style/prstylei.cxx | 14 ++++----- xmloff/source/text/XMLIndexTOCContext.cxx | 11 ++++--- xmloff/source/text/XMLIndexTOCContext.hxx | 4 +-- xmloff/source/text/XMLTextListBlockContext.cxx | 6 ++-- xmloff/source/text/XMLTextListBlockContext.hxx | 2 +- xmloff/source/text/XMLTextShapeStyleContext.cxx | 6 ++-- xmloff/source/text/txtfldi.cxx | 7 ++--- xmloff/source/text/txtimp.cxx | 32 ++++++++------------ 11 files changed, 54 insertions(+), 70 deletions(-) (limited to 'xmloff') diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx index d5aee115d4d9..bea6df8bb853 100644 --- a/xmloff/inc/txtfldi.hxx +++ b/xmloff/inc/txtfldi.hxx @@ -879,7 +879,7 @@ private: class XMLMacroFieldImportContext final : public XMLTextFieldImportContext { OUString sDescription; - SvXMLImportContextRef xEventContext; + rtl::Reference xEventContext; OUString sMacro; // macro for old documents (pre 638i) diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 387b4a8de19a..479faef73416 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -627,13 +627,13 @@ void SAL_CALL SvXMLImport::endDocument() } if( mxFontDecls.is() ) - static_cast(mxFontDecls.get())->dispose(); + mxFontDecls->dispose(); if( mxStyles.is() ) - static_cast(mxStyles.get())->dispose(); + mxStyles->dispose(); if( mxAutoStyles.is() ) - static_cast(mxAutoStyles.get())->dispose(); + mxAutoStyles->dispose(); if( mxMasterStyles.is() ) - static_cast(mxMasterStyles.get())->dispose(); + mxMasterStyles->dispose(); // possible form-layer related knittings which can only be done when // the whole document exists @@ -1622,14 +1622,14 @@ XMLEventImportHelper& SvXMLImport::GetEventImport() void SvXMLImport::SetFontDecls( XMLFontStylesContext *pFontDecls ) { if (mxFontDecls.is()) - static_cast(mxFontDecls.get())->dispose(); + mxFontDecls->dispose(); mxFontDecls = pFontDecls; } void SvXMLImport::SetStyles( SvXMLStylesContext *pStyles ) { if (mxStyles.is()) - static_cast(mxStyles.get())->dispose(); + mxStyles->dispose(); mxStyles = pStyles; } @@ -1653,7 +1653,7 @@ void SvXMLImport::SetAutoStyles( SvXMLStylesContext *pAutoStyles ) } } if (mxAutoStyles.is()) - static_cast(mxAutoStyles.get())->dispose(); + mxAutoStyles->dispose(); mxAutoStyles = pAutoStyles; GetTextImport()->SetAutoStyles( pAutoStyles ); GetShapeImport()->SetAutoStylesContext( pAutoStyles ); @@ -1664,38 +1664,38 @@ void SvXMLImport::SetAutoStyles( SvXMLStylesContext *pAutoStyles ) void SvXMLImport::SetMasterStyles( SvXMLStylesContext *pMasterStyles ) { if (mxMasterStyles.is()) - static_cast(mxMasterStyles.get())->dispose(); + mxMasterStyles->dispose(); mxMasterStyles = pMasterStyles; } XMLFontStylesContext *SvXMLImport::GetFontDecls() { - return static_cast(mxFontDecls.get()); + return mxFontDecls.get(); } SvXMLStylesContext *SvXMLImport::GetStyles() { - return static_cast(mxStyles.get()); + return mxStyles.get(); } SvXMLStylesContext *SvXMLImport::GetAutoStyles() { - return static_cast(mxAutoStyles.get()); + return mxAutoStyles.get(); } const XMLFontStylesContext *SvXMLImport::GetFontDecls() const { - return static_cast(mxFontDecls.get()); + return mxFontDecls.get(); } const SvXMLStylesContext *SvXMLImport::GetStyles() const { - return static_cast(mxStyles.get()); + return mxStyles.get(); } const SvXMLStylesContext *SvXMLImport::GetAutoStyles() const { - return static_cast(mxAutoStyles.get()); + return mxAutoStyles.get(); } OUString SvXMLImport::GetAbsoluteReference(const OUString& rValue) const @@ -1873,13 +1873,13 @@ void SvXMLImport::SetError( void SvXMLImport::DisposingModel() { if( mxFontDecls.is() ) - static_cast(mxFontDecls.get())->dispose(); + mxFontDecls->dispose(); if( mxStyles.is() ) - static_cast(mxStyles.get())->dispose(); + mxStyles->dispose(); if( mxAutoStyles.is() ) - static_cast(mxAutoStyles.get())->dispose(); + mxAutoStyles->dispose(); if( mxMasterStyles.is() ) - static_cast(mxMasterStyles.get())->dispose(); + mxMasterStyles->dispose(); mxModel.set(nullptr); mxEventListener.set(nullptr); diff --git a/xmloff/source/style/XMLFontStylesContext_impl.hxx b/xmloff/source/style/XMLFontStylesContext_impl.hxx index 2d7880389391..854523e9a15b 100644 --- a/xmloff/source/style/XMLFontStylesContext_impl.hxx +++ b/xmloff/source/style/XMLFontStylesContext_impl.hxx @@ -35,11 +35,11 @@ class XMLFontStyleContextFontFace : public SvXMLStyleContext css::uno::Any aPitch; css::uno::Any aEnc; - SvXMLImportContextRef xStyles; + rtl::Reference xStyles; XMLFontStylesContext *GetStyles() { - return static_cast(xStyles.get()); + return xStyles.get(); } public: diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx index 4712bf4e5bb7..708ae6675e57 100644 --- a/xmloff/source/style/prstylei.cxx +++ b/xmloff/source/style/prstylei.cxx @@ -211,8 +211,7 @@ SvXMLImportContextRef XMLPropStyleContext::CreateChildContext( if( nFamily ) { rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap = - static_cast(mxStyles.get())->GetImportPropertyMapper( - GetFamily() ); + mxStyles->GetImportPropertyMapper( GetFamily() ); if( xImpPrMap.is() ) xContext = new SvXMLPropertySetContext( GetImport(), nPrefix, rLocalName, xAttrList, @@ -232,8 +231,7 @@ void XMLPropStyleContext::FillPropertySet( const Reference< XPropertySet > & rPropSet ) { rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap = - static_cast(mxStyles.get())->GetImportPropertyMapper( - GetFamily() ); + mxStyles->GetImportPropertyMapper( GetFamily() ); SAL_WARN_IF( !xImpPrMap.is(), "xmloff", "There is the import prop mapper" ); if( xImpPrMap.is() ) xImpPrMap->FillPropertySet( maProperties, rPropSet ); @@ -247,8 +245,7 @@ Reference < XStyle > XMLPropStyleContext::Create() { Reference < XStyle > xNewStyle; - OUString sServiceName( - static_cast(mxStyles.get())->GetServiceName( GetFamily() ) ); + OUString sServiceName = mxStyles->GetServiceName( GetFamily() ); if( !sServiceName.isEmpty() ) { Reference< XMultiServiceFactory > xFactory( GetImport().GetModel(), @@ -267,7 +264,7 @@ Reference < XStyle > XMLPropStyleContext::Create() void XMLPropStyleContext::CreateAndInsert( bool bOverwrite ) { - SvXMLStylesContext* pSvXMLStylesContext = static_cast< SvXMLStylesContext* >(mxStyles.get()); + SvXMLStylesContext* pSvXMLStylesContext = mxStyles.get(); rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap = pSvXMLStylesContext->GetImportPropertyMapper(GetFamily()); OSL_ENSURE(xImpPrMap.is(), "There is no import prop mapper"); @@ -460,8 +457,7 @@ void XMLPropStyleContext::Finish( bool bOverwrite ) return; // The families container must exist - Reference < XNameContainer > xFamilies = - static_cast(mxStyles.get())->GetStylesContainer( GetFamily() ); + Reference < XNameContainer > xFamilies = mxStyles->GetStylesContainer( GetFamily() ); SAL_WARN_IF( !xFamilies.is(), "xmloff", "Families lost" ); if( !xFamilies.is() ) return; diff --git a/xmloff/source/text/XMLIndexTOCContext.cxx b/xmloff/source/text/XMLIndexTOCContext.cxx index 6024b1188fd6..2077ac562c7f 100644 --- a/xmloff/source/text/XMLIndexTOCContext.cxx +++ b/xmloff/source/text/XMLIndexTOCContext.cxx @@ -256,8 +256,7 @@ void XMLIndexTOCContext::EndElement() // get rid of last paragraph (unless it's the only paragraph) rHelper->GetCursor()->goRight(1, false); - if( xBodyContextRef.is() && - static_cast(xBodyContextRef.get())->HasContent() ) + if( xBodyContextRef.is() && xBodyContextRef->HasContent() ) { rHelper->GetCursor()->goLeft(1, true); rHelper->GetText()->insertString(rHelper->GetCursorAsRange(), @@ -287,12 +286,12 @@ SvXMLImportContextRef XMLIndexTOCContext::CreateChildContext( { if ( IsXMLToken( rLocalName, XML_INDEX_BODY ) ) { - xContext = new XMLIndexBodyContext(GetImport(), nPrefix, + rtl::Reference xNewBodyContext = new XMLIndexBodyContext(GetImport(), nPrefix, rLocalName); - if ( !xBodyContextRef.is() || - !static_cast(xBodyContextRef.get())->HasContent() ) + xContext = xNewBodyContext; + if ( !xBodyContextRef.is() || !xBodyContextRef->HasContent() ) { - xBodyContextRef = xContext; + xBodyContextRef = xNewBodyContext; } } else if (IsXMLToken(rLocalName, aIndexSourceElementMap[eIndexType])) diff --git a/xmloff/source/text/XMLIndexTOCContext.hxx b/xmloff/source/text/XMLIndexTOCContext.hxx index c24d283b98ef..8e3566c8cf1d 100644 --- a/xmloff/source/text/XMLIndexTOCContext.hxx +++ b/xmloff/source/text/XMLIndexTOCContext.hxx @@ -43,7 +43,7 @@ enum IndexTypeEnum TEXT_INDEX_UNKNOWN }; - +class XMLIndexBodyContext; /** * Import all indices. * @@ -61,7 +61,7 @@ class XMLIndexTOCContext : public SvXMLImportContext bool bValid; - SvXMLImportContextRef xBodyContextRef; + rtl::Reference xBodyContextRef; public: diff --git a/xmloff/source/text/XMLTextListBlockContext.cxx b/xmloff/source/text/XMLTextListBlockContext.cxx index 0ed4fb91d1be..6265bcf48a9f 100644 --- a/xmloff/source/text/XMLTextListBlockContext.cxx +++ b/xmloff/source/text/XMLTextListBlockContext.cxx @@ -70,8 +70,7 @@ XMLTextListBlockContext::XMLTextListBlockContext( OUString sParentListStyleName; if( mxParentListBlock.is() ) { - XMLTextListBlockContext *pParent = - static_cast(mxParentListBlock.get()); + XMLTextListBlockContext *pParent = mxParentListBlock.get(); msListStyleName = pParent->msListStyleName; sParentListStyleName = msListStyleName; mxNumRules = pParent->GetNumRules(); @@ -234,8 +233,7 @@ void XMLTextListBlockContext::EndElement() { // Numbering has not to be restarted if it has been restarted within // a child list. - XMLTextListBlockContext *pParent = - static_cast(mxParentListBlock.get()); + XMLTextListBlockContext *pParent = mxParentListBlock.get(); if( pParent ) { pParent->mbRestartNumbering = mbRestartNumbering; diff --git a/xmloff/source/text/XMLTextListBlockContext.hxx b/xmloff/source/text/XMLTextListBlockContext.hxx index d60e5f52589f..f77a2d4ebdfd 100644 --- a/xmloff/source/text/XMLTextListBlockContext.hxx +++ b/xmloff/source/text/XMLTextListBlockContext.hxx @@ -34,7 +34,7 @@ class XMLTextListBlockContext : public SvXMLImportContext // text:style-name property of element OUString msListStyleName; - SvXMLImportContextRef mxParentListBlock; + rtl::Reference mxParentListBlock; sal_Int16 mnLevel; bool mbRestartNumbering; diff --git a/xmloff/source/text/XMLTextShapeStyleContext.cxx b/xmloff/source/text/XMLTextShapeStyleContext.cxx index 78c18282ec50..746dc2f443da 100644 --- a/xmloff/source/text/XMLTextShapeStyleContext.cxx +++ b/xmloff/source/text/XMLTextShapeStyleContext.cxx @@ -189,9 +189,9 @@ SvXMLImportContextRef XMLTextShapeStyleContext::CreateChildContext( { // create and remember events import context // (for delayed processing of events) - xContext = new XMLEventsImportContext( GetImport(), nPrefix, + xEventContext = new XMLEventsImportContext( GetImport(), nPrefix, rLocalName); - xEventContext = xContext; + xContext = xEventContext; } if (!xContext) @@ -222,7 +222,7 @@ void XMLTextShapeStyleContext::CreateAndInsert( bool bOverwrite ) { // set event supplier and release reference to context Reference xEventsSupplier(xStyle, UNO_QUERY); - static_cast(xEventContext.get())->SetEvents(xEventsSupplier); + xEventContext->SetEvents(xEventsSupplier); xEventContext = nullptr; } } diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index 02898ad629dc..2d9c33812700 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -2436,10 +2436,10 @@ SvXMLImportContextRef XMLMacroFieldImportContext::CreateChildContext( IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) { // create events context and remember it! - xContext = new XMLEventsImportContext( + xEventContext = new XMLEventsImportContext( GetImport(), nPrefix, rLocalName ); - xEventContext = xContext; bValid = true; + return xEventContext; } return xContext; @@ -2479,8 +2479,7 @@ void XMLMacroFieldImportContext::PrepareField( if ( xEventContext.is() ) { // get event sequence - XMLEventsImportContext* pEvents = - static_cast(xEventContext.get()); + XMLEventsImportContext* pEvents = xEventContext.get(); Sequence aValues; pEvents->GetEventSequence( "OnClick", aValues ); diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 6e4fefaa0cd2..bf1be258be99 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -522,7 +522,7 @@ struct XMLTextImportHelper::Impl std::unique_ptr< std::vector > m_xNextFrmNames; std::unique_ptr m_xTextListsHelper; - SvXMLImportContextRef m_xAutoStyles; + rtl::Reference m_xAutoStyles; rtl::Reference< SvXMLImportPropertyMapper > m_xParaImpPrMap; rtl::Reference< SvXMLImportPropertyMapper > m_xTextImpPrMap; @@ -1051,7 +1051,7 @@ XMLTextImportHelper::~XMLTextImportHelper() void XMLTextImportHelper::dispose() { if (m_xImpl->m_xAutoStyles) - static_cast(m_xImpl->m_xAutoStyles.get())->dispose(); + m_xImpl->m_xAutoStyles->dispose(); } SvXMLImportPropertyMapper *XMLTextImportHelper::CreateShapeExtPropMapper(SvXMLImport& rImport) @@ -1327,7 +1327,7 @@ OUString XMLTextImportHelper::ConvertStarFonts( const OUString& rChars, if (!rStyleName.isEmpty() && m_xImpl->m_xAutoStyles.is()) { const SvXMLStyleContext* pTempStyle = - static_cast(m_xImpl->m_xAutoStyles.get())-> + m_xImpl->m_xAutoStyles-> FindStyleChildContext( nFamily, rStyleName, true ); pStyle = const_cast( dynamic_cast< const XMLTextStyleContext* >(pTempStyle)); @@ -1339,8 +1339,7 @@ OUString XMLTextImportHelper::ConvertStarFonts( const OUString& rChars, if( nCount ) { rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap = - static_cast(m_xImpl->m_xAutoStyles.get()) - ->GetImportPropertyMapper(nFamily); + m_xImpl->m_xAutoStyles->GetImportPropertyMapper(nFamily); if( xImpPrMap.is() ) { rtl::Reference rPropMapper = @@ -1536,8 +1535,7 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( if (!sStyleName.isEmpty() && m_xImpl->m_xAutoStyles.is()) { const SvXMLStyleContext* pTempStyle = - static_cast(m_xImpl->m_xAutoStyles.get())-> - FindStyleChildContext( nFamily, sStyleName, true ); + m_xImpl->m_xAutoStyles->FindStyleChildContext( nFamily, sStyleName, true ); pStyle = const_cast(dynamic_cast< const XMLTextStyleContext* >(pTempStyle)); } if( pStyle ) @@ -2220,8 +2218,7 @@ void XMLTextImportHelper::SetRuby( if (!rStyleName.isEmpty() && m_xImpl->m_xAutoStyles.is()) { const SvXMLStyleContext* pTempStyle = - static_cast(m_xImpl->m_xAutoStyles.get())-> - FindStyleChildContext( XmlStyleFamily::TEXT_RUBY, + m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_RUBY, rStyleName, true ); XMLPropStyleContext *pStyle = const_cast(dynamic_cast< const XMLPropStyleContext* >(pTempStyle)); @@ -2463,8 +2460,7 @@ sal_Int32 XMLTextImportHelper::GetDataStyleKey(const OUString& sStyleName, return -1; const SvXMLStyleContext* pStyle = - static_cast(m_xImpl->m_xAutoStyles.get())-> - FindStyleChildContext( XmlStyleFamily::DATA_STYLE, + m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::DATA_STYLE, sStyleName, true ); // get appropriate context @@ -2499,8 +2495,7 @@ const SvxXMLListStyleContext *XMLTextImportHelper::FindAutoListStyle( const OUSt if (m_xImpl->m_xAutoStyles.is()) { const SvXMLStyleContext* pTempStyle = - static_cast(m_xImpl->m_xAutoStyles.get())-> - FindStyleChildContext( XmlStyleFamily::TEXT_LIST, rName, + m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_LIST, rName, true ); pStyle = dynamic_cast< const SvxXMLListStyleContext* >(pTempStyle); } @@ -2514,8 +2509,7 @@ XMLPropStyleContext *XMLTextImportHelper::FindAutoFrameStyle( const OUString& rN if (m_xImpl->m_xAutoStyles.is()) { const SvXMLStyleContext* pTempStyle = - static_cast(m_xImpl->m_xAutoStyles.get())-> - FindStyleChildContext( XmlStyleFamily::SD_GRAPHICS_ID, rName, + m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::SD_GRAPHICS_ID, rName, true ); pStyle = const_cast(dynamic_cast< const XMLPropStyleContext* >(pTempStyle)); } @@ -2530,8 +2524,7 @@ XMLPropStyleContext* XMLTextImportHelper::FindSectionStyle( if (m_xImpl->m_xAutoStyles.is()) { const SvXMLStyleContext* pTempStyle = - static_cast(m_xImpl->m_xAutoStyles.get())-> - FindStyleChildContext( + m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_SECTION, rName, true ); pStyle = const_cast(dynamic_cast< const XMLPropStyleContext* >(pTempStyle)); @@ -2547,8 +2540,7 @@ XMLPropStyleContext* XMLTextImportHelper::FindPageMaster( if (m_xImpl->m_xAutoStyles.is()) { const SvXMLStyleContext* pTempStyle = - static_cast(m_xImpl->m_xAutoStyles.get())-> - FindStyleChildContext( + m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::PAGE_MASTER, rName, true ); pStyle = const_cast(dynamic_cast< const XMLPropStyleContext* >(pTempStyle)); @@ -2564,7 +2556,7 @@ XMLPropStyleContext * XMLTextImportHelper::FindDrawingPage(OUString const& rName return nullptr; } SvXMLStyleContext const* pStyle( - static_cast(m_xImpl->m_xAutoStyles.get())->FindStyleChildContext( + m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::SD_DRAWINGPAGE_ID, rName, true)); assert(pStyle == nullptr || dynamic_cast(pStyle) != nullptr); return const_cast(static_cast(pStyle)); -- cgit