use rtl::Reference in SvXMLExport

instead of storing both a raw pointer and an uno::Reference

Change-Id: I83774937d3556b9fed550a7f3e757dc975b4098a
This commit is contained in:
Noel Grandin
2017-01-16 14:56:48 +02:00
parent 2796150fdc
commit 034cb09f56
2 changed files with 17 additions and 20 deletions

View File

@@ -131,8 +131,7 @@ class XMLOFF_DLLPUBLIC SvXMLExport : public cppu::WeakImplHelper<
css::uno::Reference< css::beans::XPropertySet > mxExportInfo; css::uno::Reference< css::beans::XPropertySet > mxExportInfo;
css::uno::Reference< css::lang::XEventListener > mxEventListener; css::uno::Reference< css::lang::XEventListener > mxEventListener;
SvXMLAttributeList *mpAttrList; // a common attribute list rtl::Reference<SvXMLAttributeList> mxAttrList; // a common attribute list
css::uno::Reference< css::xml::sax::XAttributeList > mxAttrList; // and an interface of it
OUString msOrigFileName; // the original URL OUString msOrigFileName; // the original URL
OUString msGraphicObjectProtocol; OUString msGraphicObjectProtocol;
@@ -377,8 +376,8 @@ public:
css::xml::sax::XAttributeList >& xAttrList ); css::xml::sax::XAttributeList >& xAttrList );
// Get common attribute list as implementation or interface. // Get common attribute list as implementation or interface.
SvXMLAttributeList &GetAttrList() { return *mpAttrList; } SvXMLAttributeList &GetAttrList() { return *mxAttrList.get(); }
const css::uno::Reference< css::xml::sax::XAttributeList > & GetXAttrList() { return mxAttrList; } css::uno::Reference< css::xml::sax::XAttributeList > GetXAttrList() { return mxAttrList.get(); }
// Get document handler. This methods are not const, because the // Get document handler. This methods are not const, because the
// reference allowes modifications through the handler. // reference allowes modifications through the handler.

View File

@@ -393,8 +393,6 @@ void SvXMLExport::InitCtor_()
GetXMLToken(XML_NP_CSS3TEXT), GetXMLToken(XML_N_CSS3TEXT), XML_NAMESPACE_CSS3TEXT ); GetXMLToken(XML_NP_CSS3TEXT), GetXMLToken(XML_N_CSS3TEXT), XML_NAMESPACE_CSS3TEXT );
} }
mxAttrList = static_cast<xml::sax::XAttributeList*>(mpAttrList);
msGraphicObjectProtocol = "vnd.sun.star.GraphicObject:"; msGraphicObjectProtocol = "vnd.sun.star.GraphicObject:";
msEmbeddedObjectProtocol = "vnd.sun.star.EmbeddedObject:"; msEmbeddedObjectProtocol = "vnd.sun.star.EmbeddedObject:";
@@ -434,7 +432,7 @@ SvXMLExport::SvXMLExport(
const enum XMLTokenEnum eClass, SvXMLExportFlags nExportFlags ) const enum XMLTokenEnum eClass, SvXMLExportFlags nExportFlags )
: mpImpl( new SvXMLExport_Impl ), : mpImpl( new SvXMLExport_Impl ),
m_xContext(xContext), m_implementationName(implementationName), m_xContext(xContext), m_implementationName(implementationName),
mpAttrList( new SvXMLAttributeList ), mxAttrList( new SvXMLAttributeList ),
mpNamespaceMap( new SvXMLNamespaceMap ), mpNamespaceMap( new SvXMLNamespaceMap ),
mpUnitConv( new SvXMLUnitConverter( xContext, mpUnitConv( new SvXMLUnitConverter( xContext,
util::MeasureUnit::MM_100TH, eDefaultMeasureUnit) ), util::MeasureUnit::MM_100TH, eDefaultMeasureUnit) ),
@@ -463,7 +461,7 @@ SvXMLExport::SvXMLExport(
m_xContext(xContext), m_implementationName(implementationName), m_xContext(xContext), m_implementationName(implementationName),
mxHandler( rHandler ), mxHandler( rHandler ),
mxExtHandler( rHandler, uno::UNO_QUERY ), mxExtHandler( rHandler, uno::UNO_QUERY ),
mpAttrList( new SvXMLAttributeList ), mxAttrList( new SvXMLAttributeList ),
msOrigFileName( rFileName ), msOrigFileName( rFileName ),
mpNamespaceMap( new SvXMLNamespaceMap ), mpNamespaceMap( new SvXMLNamespaceMap ),
mpUnitConv( new SvXMLUnitConverter( xContext, mpUnitConv( new SvXMLUnitConverter( xContext,
@@ -500,7 +498,7 @@ SvXMLExport::SvXMLExport(
mxHandler( rHandler ), mxHandler( rHandler ),
mxExtHandler( rHandler, uno::UNO_QUERY ), mxExtHandler( rHandler, uno::UNO_QUERY ),
mxNumberFormatsSupplier (rModel, uno::UNO_QUERY), mxNumberFormatsSupplier (rModel, uno::UNO_QUERY),
mpAttrList( new SvXMLAttributeList ), mxAttrList( new SvXMLAttributeList ),
msOrigFileName( rFileName ), msOrigFileName( rFileName ),
mpNamespaceMap( new SvXMLNamespaceMap ), mpNamespaceMap( new SvXMLNamespaceMap ),
mpUnitConv( new SvXMLUnitConverter( xContext, mpUnitConv( new SvXMLUnitConverter( xContext,
@@ -945,7 +943,7 @@ void SvXMLExport::AddAttributeASCII( sal_uInt16 nPrefixKey,
OUString sName( OUString::createFromAscii( pName ) ); OUString sName( OUString::createFromAscii( pName ) );
OUString sValue( OUString::createFromAscii( pValue ) ); OUString sValue( OUString::createFromAscii( pValue ) );
mpAttrList->AddAttribute( mxAttrList->AddAttribute(
GetNamespaceMap_().GetQNameByKey( nPrefixKey, sName ), sValue ); GetNamespaceMap_().GetQNameByKey( nPrefixKey, sName ), sValue );
} }
@@ -954,14 +952,14 @@ void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const sal_Char *pName,
{ {
OUString sName( OUString::createFromAscii( pName ) ); OUString sName( OUString::createFromAscii( pName ) );
mpAttrList->AddAttribute( mxAttrList->AddAttribute(
GetNamespaceMap_().GetQNameByKey( nPrefixKey, sName ), rValue ); GetNamespaceMap_().GetQNameByKey( nPrefixKey, sName ), rValue );
} }
void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName, void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey, const OUString& rName,
const OUString& rValue ) const OUString& rValue )
{ {
mpAttrList->AddAttribute( mxAttrList->AddAttribute(
GetNamespaceMap_().GetQNameByKey( nPrefixKey, rName ), rValue ); GetNamespaceMap_().GetQNameByKey( nPrefixKey, rName ), rValue );
} }
@@ -969,7 +967,7 @@ void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
enum XMLTokenEnum eName, enum XMLTokenEnum eName,
const OUString& rValue ) const OUString& rValue )
{ {
mpAttrList->AddAttribute( mxAttrList->AddAttribute(
GetNamespaceMap_().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ), GetNamespaceMap_().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
rValue ); rValue );
} }
@@ -978,7 +976,7 @@ void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
enum XMLTokenEnum eName, enum XMLTokenEnum eName,
enum XMLTokenEnum eValue) enum XMLTokenEnum eValue)
{ {
mpAttrList->AddAttribute( mxAttrList->AddAttribute(
GetNamespaceMap_().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ), GetNamespaceMap_().GetQNameByKey( nPrefixKey, GetXMLToken(eName) ),
GetXMLToken(eValue) ); GetXMLToken(eValue) );
} }
@@ -986,7 +984,7 @@ void SvXMLExport::AddAttribute( sal_uInt16 nPrefixKey,
void SvXMLExport::AddAttribute( const OUString& rQName, void SvXMLExport::AddAttribute( const OUString& rQName,
const OUString& rValue ) const OUString& rValue )
{ {
mpAttrList->AddAttribute( mxAttrList->AddAttribute(
rQName, rQName,
rValue ); rValue );
} }
@@ -994,7 +992,7 @@ void SvXMLExport::AddAttribute( const OUString& rQName,
void SvXMLExport::AddAttribute( const OUString& rQName, void SvXMLExport::AddAttribute( const OUString& rQName,
enum ::xmloff::token::XMLTokenEnum eValue ) enum ::xmloff::token::XMLTokenEnum eValue )
{ {
mpAttrList->AddAttribute( mxAttrList->AddAttribute(
rQName, rQName,
GetXMLToken(eValue) ); GetXMLToken(eValue) );
} }
@@ -1061,18 +1059,18 @@ void SvXMLExport::AddLanguageTagAttributes( sal_uInt16 nPrefix, sal_uInt16 nPref
void SvXMLExport::AddAttributeList( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) void SvXMLExport::AddAttributeList( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
{ {
if( xAttrList.is()) if( xAttrList.is())
mpAttrList->AppendAttributeList( xAttrList ); mxAttrList->AppendAttributeList( xAttrList );
} }
void SvXMLExport::ClearAttrList() void SvXMLExport::ClearAttrList()
{ {
mpAttrList->Clear(); mxAttrList->Clear();
} }
#ifdef DBG_UTIL #ifdef DBG_UTIL
void SvXMLExport::CheckAttrList() void SvXMLExport::CheckAttrList()
{ {
SAL_WARN_IF( mpAttrList->getLength(), "xmloff.core", "XMLExport::CheckAttrList: list is not empty" ); SAL_WARN_IF( mxAttrList->getLength(), "xmloff.core", "XMLExport::CheckAttrList: list is not empty" );
} }
#endif #endif
@@ -1350,7 +1348,7 @@ sal_uInt32 SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass )
sal_uInt16 nPos = mpNamespaceMap->GetFirstKey(); sal_uInt16 nPos = mpNamespaceMap->GetFirstKey();
while( USHRT_MAX != nPos ) while( USHRT_MAX != nPos )
{ {
mpAttrList->AddAttribute( mpNamespaceMap->GetAttrNameByKey( nPos ), mxAttrList->AddAttribute( mpNamespaceMap->GetAttrNameByKey( nPos ),
mpNamespaceMap->GetNameByKey( nPos ) ); mpNamespaceMap->GetNameByKey( nPos ) );
nPos = mpNamespaceMap->GetNextKey( nPos ); nPos = mpNamespaceMap->GetNextKey( nPos );
} }