[Libreoffice-commits] core.git: compilerplugins/clang dbaccess/source lotuswordpro/source sc/source xmloff/inc xmloff/source

Noel Grandin noel at peralex.com
Wed Aug 5 04:26:25 PDT 2015


 compilerplugins/clang/refcounting.cxx                 |  120 +++++++++++++++++-
 dbaccess/source/core/api/KeySet.cxx                   |   18 +-
 dbaccess/source/core/api/KeySet.hxx                   |    4 
 dbaccess/source/core/api/RowSet.cxx                   |   28 ++--
 dbaccess/source/core/api/RowSet.hxx                   |    4 
 dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx |    2 
 dbaccess/source/ui/querydesign/querycontroller.cxx    |    2 
 lotuswordpro/source/filter/xfilter/xfdrawgroup.hxx    |    6 
 lotuswordpro/source/filter/xfilter/xfdrawobj.hxx      |    2 
 lotuswordpro/source/filter/xfilter/xfendnote.hxx      |    2 
 lotuswordpro/source/filter/xfilter/xfheader.hxx       |    2 
 lotuswordpro/source/filter/xfilter/xftable.cxx        |    6 
 lotuswordpro/source/filter/xfilter/xftable.hxx        |    2 
 sc/source/filter/xml/xmlexprt.cxx                     |    6 
 xmloff/inc/SchXMLExport.hxx                           |    4 
 xmloff/inc/SchXMLImport.hxx                           |    2 
 xmloff/source/chart/SchXMLExport.cxx                  |   22 +--
 xmloff/source/chart/SchXMLImport.cxx                  |   11 -
 xmloff/source/draw/sdxmlexp.cxx                       |    4 
 xmloff/source/draw/shapeexport.cxx                    |    6 
 xmloff/source/table/XMLTableExport.cxx                |    4 
 21 files changed, 189 insertions(+), 68 deletions(-)

New commits:
commit 9c1f700aff5f7e375d3570231e6d68fe2e2c0334
Author: Noel Grandin <noel at peralex.com>
Date:   Wed Aug 5 10:48:40 2015 +0200

    improve refcounting loplugin to check SvRef-based classes
    
    Change-Id: I2b3c8eedabeaecd8dcae9fe69c951353a5686883
    Reviewed-on: https://gerrit.libreoffice.org/17521
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx
index 7b859ff..3a6c715 100644
--- a/compilerplugins/clang/refcounting.cxx
+++ b/compilerplugins/clang/refcounting.cxx
@@ -215,7 +215,81 @@ bool containsXInterfaceSubclass(const Type* pType0) {
     }
 }
 
+bool containsSvRefBaseSubclass(const Type* pType0) {
+    if (!pType0)
+        return false;
+    const Type* pType = pType0->getUnqualifiedDesugaredType();
+    if (!pType)
+        return false;
+    const CXXRecordDecl* pRecordDecl = pType->getAsCXXRecordDecl();
+    if (pRecordDecl) {
+        pRecordDecl = pRecordDecl->getCanonicalDecl();
+    }
+    if (pRecordDecl) {
+        const ClassTemplateSpecializationDecl* pTemplate = dyn_cast<ClassTemplateSpecializationDecl>(pRecordDecl);
+        if (pTemplate) {
+            std::string aName = pTemplate->getQualifiedNameAsString();
+            if (aName == "tools::SvRef")
+                return false;
+            for(unsigned i=0; i<pTemplate->getTemplateArgs().size(); ++i) {
+                const TemplateArgument& rArg = pTemplate->getTemplateArgs()[i];
+                if (rArg.getKind() == TemplateArgument::ArgKind::Type &&
+                    containsSvRefBaseSubclass(rArg.getAsType().getTypePtr()))
+                {
+                    return true;
+                }
+            }
+        }
+    }
+    if (pType->isPointerType()) {
+        // ignore
+        return false;
+    } else if (pType->isArrayType()) {
+        const ArrayType* pArrayType = dyn_cast<ArrayType>(pType);
+        QualType elementType = pArrayType->getElementType();
+        return containsSvRefBaseSubclass(elementType.getTypePtr());
+    } else {
+        return isDerivedFrom(pRecordDecl, "tools::SvRefBase");
+    }
+}
 
+bool containsSalhelperReferenceObjectSubclass(const Type* pType0) {
+    if (!pType0)
+        return false;
+    const Type* pType = pType0->getUnqualifiedDesugaredType();
+    if (!pType)
+        return false;
+    const CXXRecordDecl* pRecordDecl = pType->getAsCXXRecordDecl();
+    if (pRecordDecl) {
+        pRecordDecl = pRecordDecl->getCanonicalDecl();
+    }
+    if (pRecordDecl) {
+        const ClassTemplateSpecializationDecl* pTemplate = dyn_cast<ClassTemplateSpecializationDecl>(pRecordDecl);
+        if (pTemplate) {
+            std::string aName = pTemplate->getQualifiedNameAsString();
+            if (aName == "rtl::Reference" || aName == "store::OStoreHandle")
+                return false;
+            for(unsigned i=0; i<pTemplate->getTemplateArgs().size(); ++i) {
+                const TemplateArgument& rArg = pTemplate->getTemplateArgs()[i];
+                if (rArg.getKind() == TemplateArgument::ArgKind::Type &&
+                    containsSalhelperReferenceObjectSubclass(rArg.getAsType().getTypePtr()))
+                {
+                    return true;
+                }
+            }
+        }
+    }
+    if (pType->isPointerType()) {
+        // ignore
+        return false;
+    } else if (pType->isArrayType()) {
+        const ArrayType* pArrayType = dyn_cast<ArrayType>(pType);
+        QualType elementType = pArrayType->getElementType();
+        return containsSalhelperReferenceObjectSubclass(elementType.getTypePtr());
+    } else {
+        return isDerivedFrom(pRecordDecl, "salhelper::SimpleReferenceObject");
+    }
+}
 
 bool RefCounting::VisitFieldDecl(const FieldDecl * fieldDecl) {
     if (ignoreLocation(fieldDecl)) {
@@ -224,7 +298,29 @@ bool RefCounting::VisitFieldDecl(const FieldDecl * fieldDecl) {
     if (fieldDecl->isBitField()) {
         return true;
     }
+
     std::string aParentName = fieldDecl->getParent()->getQualifiedNameAsString();
+
+    if (containsSvRefBaseSubclass(fieldDecl->getType().getTypePtr())) {
+        report(
+            DiagnosticsEngine::Warning,
+            "SvRefBase subclass being directly heap managed, should be managed via tools::SvRef, "
+            + fieldDecl->getType().getAsString()
+            + ", parent is " + aParentName,
+            fieldDecl->getLocation())
+          << fieldDecl->getSourceRange();
+    }
+
+    if (containsSalhelperReferenceObjectSubclass(fieldDecl->getType().getTypePtr())) {
+        report(
+            DiagnosticsEngine::Warning,
+            "salhelper::SimpleReferenceObject subclass being directly heap managed, should be managed via rtl::Reference, "
+            + fieldDecl->getType().getAsString()
+            + ", parent is " + aParentName,
+            fieldDecl->getLocation())
+          << fieldDecl->getSourceRange();
+    }
+
     if ( aParentName == "com::sun::star::uno::BaseReference"
          || aParentName == "cppu::detail::element_alias"
          // this is playing some kind of game to avoid circular references
@@ -241,7 +337,6 @@ bool RefCounting::VisitFieldDecl(const FieldDecl * fieldDecl) {
             + ", parent is " + aParentName,
             fieldDecl->getLocation())
           << fieldDecl->getSourceRange();
-        return true;
     }
     return true;
 }
@@ -251,6 +346,29 @@ bool RefCounting::VisitVarDecl(const VarDecl * varDecl) {
     if (ignoreLocation(varDecl)) {
         return true;
     }
+    if (isa<ParmVarDecl>(varDecl)) {
+        return true;
+    }
+    if (containsSvRefBaseSubclass(varDecl->getType().getTypePtr())) {
+        report(
+            DiagnosticsEngine::Warning,
+            "SvRefBase subclass being directly stack managed, should be managed via tools::SvRef, "
+            + varDecl->getType().getAsString(),
+            varDecl->getLocation())
+          << varDecl->getSourceRange();
+    }
+    if (containsSalhelperReferenceObjectSubclass(varDecl->getType().getTypePtr())) {
+        StringRef name { compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(varDecl->getLocation())) };
+        // this is playing games that it believes is safe
+        if (name == SRCDIR "/stoc/source/security/permissions.cxx")
+            return true;
+        report(
+            DiagnosticsEngine::Warning,
+            "salhelper::SimpleReferenceObject subclass being directly stack managed, should be managed via rtl::Reference, "
+            + varDecl->getType().getAsString(),
+            varDecl->getLocation())
+          << varDecl->getSourceRange();
+    }
     if (containsXInterfaceSubclass(varDecl->getType())) {
         report(
             DiagnosticsEngine::Warning,
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 404e016..060f028 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -111,7 +111,7 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable,
                  sal_Int32 i_nMaxRows,
                  sal_Int32& o_nRowCount)
             :OCacheSet(i_nMaxRows)
-            ,m_aParameterValueForCache(_aParameterValueForCache)
+            ,m_aParameterValueForCache(new ORowSetValueVector(_aParameterValueForCache))
             ,m_xTable(_xTable)
             ,m_xTableKeys(_xTableKeys)
             ,m_xComposer(_xComposer)
@@ -824,8 +824,8 @@ void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sa
     connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = _rKeyRow->get().begin();
 
     // check the if the parameter values have been changed
-    OSL_ENSURE((m_aParameterValueForCache.get().size()-1) == m_pParameterNames->size(),"OKeySet::copyRowValue: Parameter values and names differ!");
-    connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache.get().begin() +1;
+    OSL_ENSURE((m_aParameterValueForCache->get().size()-1) == m_pParameterNames->size(),"OKeySet::copyRowValue: Parameter values and names differ!");
+    connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache->get().begin() +1;
 
     bool bChanged = false;
     SelectColumnsMetaData::const_iterator aParaIter = (*m_pParameterNames).begin();
@@ -836,8 +836,8 @@ void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sa
         aValue.setSigned(m_aSignedFlags[aParaIter->second.nPosition]);
         if ( (_rInsertRow->get())[aParaIter->second.nPosition] != aValue )
         {
-            ORowSetValueVector aCopy(m_aParameterValueForCache);
-            (aCopy.get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition];
+            rtl::Reference<ORowSetValueVector> aCopy(new ORowSetValueVector(*m_aParameterValueForCache.get()));
+            (aCopy->get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition];
             m_aUpdatedParameter[i_nBookmark] = aCopy;
             bChanged = true;
         }
@@ -1192,13 +1192,13 @@ bool OKeySet::doTryRefetch_throw()  throw(SQLException, RuntimeException)
     OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first);
     if ( aUpdateFind == m_aUpdatedParameter.end() )
     {
-        aParaIter = m_aParameterValueForCache.get().begin();
-        aParaEnd = m_aParameterValueForCache.get().end();
+        aParaIter = m_aParameterValueForCache->get().begin();
+        aParaEnd = m_aParameterValueForCache->get().end();
     }
     else
     {
-        aParaIter = aUpdateFind->second.get().begin();
-        aParaEnd = aUpdateFind->second.get().end();
+        aParaIter = aUpdateFind->second->get().begin();
+        aParaEnd = aUpdateFind->second->get().end();
     }
 
     for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos)
diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx
index 6ce838e..945684f 100644
--- a/dbaccess/source/core/api/KeySet.hxx
+++ b/dbaccess/source/core/api/KeySet.hxx
@@ -72,7 +72,7 @@ namespace dbaccess
 
     typedef ::std::pair<ORowSetRow,::std::pair<sal_Int32,css::uno::Reference< css::sdbc::XRow> > > OKeySetValue;
     typedef ::std::map<sal_Int32,OKeySetValue > OKeySetMatrix;
-    typedef ::std::map<sal_Int32,ORowSetValueVector > OUpdatedParameter;
+    typedef ::std::map<sal_Int32, rtl::Reference<ORowSetValueVector> > OUpdatedParameter;
     // is used when the source supports keys
     class OKeySet : public OCacheSet
     {
@@ -83,7 +83,7 @@ namespace dbaccess
         ::std::vector< OUString >                               m_aAutoColumns;  // contains all columns which are autoincrement ones
 
         OUpdatedParameter                                       m_aUpdatedParameter;    // contains all parameter which have been updated and are needed for refetching
-        ORowSetValueVector                                      m_aParameterValueForCache;
+        rtl::Reference<ORowSetValueVector>                      m_aParameterValueForCache;
         ::std::unique_ptr<SelectColumnsMetaData>                m_pKeyColumnNames;      // contains all key column names
         ::std::unique_ptr<SelectColumnsMetaData>                m_pColumnNames;         // contains all column names
         ::std::unique_ptr<SelectColumnsMetaData>                m_pParameterNames;      // contains all parameter names
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 9e03c14..70a419a 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -134,6 +134,8 @@ ORowSet::ORowSet( const Reference< css::uno::XComponentContext >& _rxContext )
     :ORowSet_BASE1(m_aMutex)
     ,ORowSetBase( _rxContext, ORowSet_BASE1::rBHelper, &m_aMutex )
     ,m_pParameters( NULL )
+    ,m_aPrematureParamValues(new ORowSetValueVector)
+    ,m_aParameterValueForCache(new ORowSetValueVector)
     ,m_aRowsetListeners(*m_pMutex)
     ,m_aApproveListeners(*m_pMutex)
     ,m_aRowsChangeListener(*m_pMutex)
@@ -170,7 +172,7 @@ ORowSet::ORowSet( const Reference< css::uno::XComponentContext >& _rxContext )
     sal_Int32 nRT   = PropertyAttribute::READONLY   | PropertyAttribute::TRANSIENT;
     sal_Int32 nBT   = PropertyAttribute::BOUND      | PropertyAttribute::TRANSIENT;
 
-    m_aPrematureParamValues.get().resize( 0 );
+    m_aPrematureParamValues->get().resize( 0 );
 
     // sdb.RowSet Properties
     registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT|PropertyAttribute::BOUND, &m_aActiveConnection,   cppu::UnoType<XConnection>::get());
@@ -1681,14 +1683,14 @@ Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw()
 {
     impl_ensureStatement_throw();
 
-    m_aParameterValueForCache.get().resize(1);
+    m_aParameterValueForCache->get().resize(1);
     Reference< XParameters > xParam( m_xStatement, UNO_QUERY_THROW );
-    size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
+    size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues->get().size() );
     for ( size_t i=1; i<=nParamCount; ++i )
     {
         ORowSetValue& rParamValue( getParameterStorage( (sal_Int32)i ) );
         ::dbtools::setObjectWithInfo( xParam, i, rParamValue.makeAny(), rParamValue.getTypeKind() );
-        m_aParameterValueForCache.get().push_back(rParamValue);
+        m_aParameterValueForCache->get().push_back(rParamValue);
     }
     m_bParametersDirty = false;
 
@@ -1703,7 +1705,7 @@ Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw()
     {
         DELETEZ(m_pCache);
     }
-    m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache,m_aFilter,m_nMaxRows );
+    m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew, *m_aParameterValueForCache.get(),m_aFilter,m_nMaxRows );
     if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
     {
         m_nPrivileges = Privilege::SELECT;
@@ -2432,10 +2434,10 @@ void ORowSet::impl_initParametersContainer_nothrow()
 
     m_pParameters = new param::ParameterWrapperContainer( m_xComposer.get() );
     // copy the premature parameters into the final ones
-    size_t nParamCount( ::std::min( m_pParameters->size(), m_aPrematureParamValues.get().size() ) );
+    size_t nParamCount( ::std::min( m_pParameters->size(), m_aPrematureParamValues->get().size() ) );
     for ( size_t i=0; i<nParamCount; ++i )
     {
-        (*m_pParameters)[i] = m_aPrematureParamValues.get()[i];
+        (*m_pParameters)[i] = m_aPrematureParamValues->get()[i];
     }
 }
 
@@ -2446,10 +2448,10 @@ void ORowSet::impl_disposeParametersContainer_nothrow()
 
     // copy the actual values to our "premature" ones, to preserve them for later use
     size_t nParamCount( m_pParameters->size() );
-    m_aPrematureParamValues.get().resize( nParamCount );
+    m_aPrematureParamValues->get().resize( nParamCount );
     for ( size_t i=0; i<nParamCount; ++i )
     {
-        m_aPrematureParamValues.get()[i] = (*m_pParameters)[i];
+        m_aPrematureParamValues->get()[i] = (*m_pParameters)[i];
     }
 
     m_pParameters->dispose();
@@ -2480,9 +2482,9 @@ ORowSetValue& ORowSet::getParameterStorage(sal_Int32 parameterIndex)
         }
     }
 
-    if ( m_aPrematureParamValues.get().size() < (size_t)parameterIndex )
-        m_aPrematureParamValues.get().resize( parameterIndex );
-    return m_aPrematureParamValues.get()[ parameterIndex - 1 ];
+    if ( m_aPrematureParamValues->get().size() < (size_t)parameterIndex )
+        m_aPrematureParamValues->get().resize( parameterIndex );
+    return m_aPrematureParamValues->get()[ parameterIndex - 1 ];
 }
 
 // XParameters
@@ -2655,7 +2657,7 @@ void SAL_CALL ORowSet::clearParameters(  ) throw(SQLException, RuntimeException,
 
     ::osl::MutexGuard aGuard( m_aColumnsMutex );
 
-    size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
+    size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues->get().size() );
     for ( size_t i=1; i<=nParamCount; ++i )
         getParameterStorage( (sal_Int32)i ).setNull();
     m_aParametersSet.clear();
diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx
index 845df9a..44e0d56 100644
--- a/dbaccess/source/core/api/RowSet.hxx
+++ b/dbaccess/source/core/api/RowSet.hxx
@@ -86,8 +86,8 @@ namespace dbaccess
         /** our parameters values, used when we do not yet have a parameters container
             (since we have not been executed, yet)
         */
-        ORowSetValueVector                          m_aPrematureParamValues;
-        ORowSetValueVector                          m_aParameterValueForCache;
+        rtl::Reference<ORowSetValueVector>          m_aPrematureParamValues;
+        rtl::Reference<ORowSetValueVector>          m_aParameterValueForCache;
         ::std::vector<bool>                         m_aParametersSet;
         ::std::vector<bool>                         m_aReadOnlyDataColumns;
 
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index 86fb9f7..f02dfa4 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -1391,7 +1391,7 @@ sal_Int8 OSelectionBrowseBox::ExecuteDrop( const BrowserExecuteDropEvent& _rEvt
         return DND_ACTION_NONE;
     }
 
-    OTableFieldDesc aInfo;
+    rtl::Reference<OTableFieldDesc> aInfo;
     // insert the field at the selected position
     OJoinExchangeData jxdSource = OJoinExchObj::GetSourceDescription(_rEvt.maDropEvent.Transferable);
     InsertField(jxdSource);
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
index 76bd6c1..37976f0 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -1252,7 +1252,7 @@ sal_Int32 OQueryController::getColWidth(sal_uInt16 _nColPos)  const
 {
     if ( _nColPos < m_aFieldInformation.getLength() )
     {
-        ::std::unique_ptr<OTableFieldDesc> pField( new OTableFieldDesc());
+        rtl::Reference<OTableFieldDesc> pField( new OTableFieldDesc());
         pField->Load( m_aFieldInformation[ _nColPos ], false );
         return pField->GetColWidth();
     }
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawgroup.hxx b/lotuswordpro/source/filter/xfilter/xfdrawgroup.hxx
index d97ae14..722fce1 100644
--- a/lotuswordpro/source/filter/xfilter/xfdrawgroup.hxx
+++ b/lotuswordpro/source/filter/xfilter/xfdrawgroup.hxx
@@ -87,13 +87,13 @@ public:
     virtual void ToXml(IXFStream *pStrm) SAL_OVERRIDE;
 
 private:
-    XFContentContainer  m_aChildren;
+    rtl::Reference<XFContentContainer>  m_aChildren;
 };
 
 inline void XFDrawGroup::Add(XFFrame *pFrame)
 {
     if( pFrame )
-        m_aChildren.Add(pFrame);
+        m_aChildren->Add(pFrame);
 }
 
 inline void XFDrawGroup::ToXml(IXFStream *pStrm)
@@ -105,7 +105,7 @@ inline void XFDrawGroup::ToXml(IXFStream *pStrm)
 
     pStrm->StartElement( "draw:g" );
 
-    m_aChildren.ToXml(pStrm);
+    m_aChildren->ToXml(pStrm);
 
     pStrm->EndElement( "draw:g" );
 
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawobj.hxx b/lotuswordpro/source/filter/xfilter/xfdrawobj.hxx
index 32e32c6..d273a53 100644
--- a/lotuswordpro/source/filter/xfilter/xfdrawobj.hxx
+++ b/lotuswordpro/source/filter/xfilter/xfdrawobj.hxx
@@ -98,7 +98,7 @@ public:
     virtual void    ToXml(IXFStream *pStrm) SAL_OVERRIDE;
 
 protected:
-    XFContentContainer  m_aContents;
+    rtl::Reference<XFContentContainer>  m_aContents;
     OUString        m_strTextStyle;
     double          m_fRotate;
     XFPoint         m_aRotatePoint;
diff --git a/lotuswordpro/source/filter/xfilter/xfendnote.hxx b/lotuswordpro/source/filter/xfilter/xfendnote.hxx
index 78243ec..1626d2b 100644
--- a/lotuswordpro/source/filter/xfilter/xfendnote.hxx
+++ b/lotuswordpro/source/filter/xfilter/xfendnote.hxx
@@ -79,7 +79,7 @@ public:
 private:
     OUString   m_strID;
     OUString   m_strLabel;
-    XFContentContainer  m_aContents;
+    rtl::Reference<XFContentContainer>  m_aContents;
 };
 
 inline XFEndNote::XFEndNote()
diff --git a/lotuswordpro/source/filter/xfilter/xfheader.hxx b/lotuswordpro/source/filter/xfilter/xfheader.hxx
index 9a4773a..5fc150c 100644
--- a/lotuswordpro/source/filter/xfilter/xfheader.hxx
+++ b/lotuswordpro/source/filter/xfilter/xfheader.hxx
@@ -81,7 +81,7 @@ public:
         pStrm->EndElement( "style:header" );
     }
 private:
-    XFContentContainer  m_aContents;
+    rtl::Reference<XFContentContainer>  m_aContents;
 };
 
 #endif
diff --git a/lotuswordpro/source/filter/xfilter/xftable.cxx b/lotuswordpro/source/filter/xfilter/xftable.cxx
index f9576f0..13d5193 100644
--- a/lotuswordpro/source/filter/xfilter/xftable.cxx
+++ b/lotuswordpro/source/filter/xfilter/xftable.cxx
@@ -108,7 +108,7 @@ void    XFTable::AddHeaderRow(XFRow *pRow)
 {
     if( !pRow )
         return;
-    m_aHeaderRows.Add(pRow);
+    m_aHeaderRows->Add(pRow);
 }
 
 OUString XFTable::GetTableName()
@@ -207,10 +207,10 @@ void    XFTable::ToXml(IXFStream *pStrm)
         }
     }
 
-    if( m_aHeaderRows.GetCount()>0 )
+    if( m_aHeaderRows->GetCount()>0 )
     {
         pStrm->StartElement( "table:table-header-rows" );
-        m_aHeaderRows.ToXml(pStrm);
+        m_aHeaderRows->ToXml(pStrm);
         pStrm->EndElement( "table:table-header-rows" );
     }
     //output rows:
diff --git a/lotuswordpro/source/filter/xfilter/xftable.hxx b/lotuswordpro/source/filter/xfilter/xftable.hxx
index 844d685..e5caaa3 100644
--- a/lotuswordpro/source/filter/xfilter/xftable.hxx
+++ b/lotuswordpro/source/filter/xfilter/xftable.hxx
@@ -109,7 +109,7 @@ private:
     OUString   m_strName;
     bool    m_bSubTable;
     XFCell      *m_pOwnerCell;
-    XFContentContainer  m_aHeaderRows;
+    rtl::Reference<XFContentContainer>  m_aHeaderRows;
     std::map<sal_uInt16, XFRow*>  m_aRows;
     std::map<sal_Int32,OUString>   m_aColumns;
     OUString   m_strDefCellStyle;
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 6abf4be..a208c38 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1893,7 +1893,7 @@ void ScXMLExport::_ExportStyles( bool bUsed )
         sal_Int32 nShapesCount(0);
         CollectSharedData(nTableCount, nShapesCount);
     }
-    ScXMLStyleExport aStylesExp(*this, OUString(), GetAutoStylePool().get());
+    rtl::Reference<ScXMLStyleExport> aStylesExp(new ScXMLStyleExport(*this, OUString(), GetAutoStylePool().get()));
     if (GetModel().is())
     {
         uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
@@ -1901,7 +1901,7 @@ void ScXMLExport::_ExportStyles( bool bUsed )
         {
             uno::Reference <beans::XPropertySet> xProperties(xMultiServiceFactory->createInstance("com.sun.star.sheet.Defaults"), uno::UNO_QUERY);
             if (xProperties.is())
-                aStylesExp.exportDefaultStyle(xProperties, OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME), xCellStylesExportPropertySetMapper);
+                aStylesExp->exportDefaultStyle(xProperties, OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME), xCellStylesExportPropertySetMapper);
             if (pSharedData->HasShapes())
             {
                 GetShapeExport()->ExportGraphicDefaults();
@@ -1934,7 +1934,7 @@ void ScXMLExport::_ExportStyles( bool bUsed )
     }
     exportDataStyles();
 
-    aStylesExp.exportStyleFamily(OUString("CellStyles"),
+    aStylesExp->exportStyleFamily(OUString("CellStyles"),
         OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME), xCellStylesExportPropertySetMapper, false, XML_STYLE_FAMILY_TABLE_CELL);
 
     SvXMLExport::_ExportStyles(bUsed);
diff --git a/xmloff/inc/SchXMLExport.hxx b/xmloff/inc/SchXMLExport.hxx
index e9e2159..41e179d 100644
--- a/xmloff/inc/SchXMLExport.hxx
+++ b/xmloff/inc/SchXMLExport.hxx
@@ -37,9 +37,9 @@ class SchXMLExport : public SvXMLExport
 {
 private:
     com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > mxStatusIndicator;
-    SchXMLAutoStylePoolP maAutoStylePool;
+    rtl::Reference<SchXMLAutoStylePoolP> maAutoStylePool;
 
-    SchXMLExportHelper maExportHelper;
+    rtl::Reference<SchXMLExportHelper> maExportHelper;
 
 protected:
     virtual sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_TOKEN_INVALID ) SAL_OVERRIDE;
diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx
index 6535faa..01e6e1d 100644
--- a/xmloff/inc/SchXMLImport.hxx
+++ b/xmloff/inc/SchXMLImport.hxx
@@ -160,7 +160,7 @@ class SchXMLImport : public SvXMLImport
 private:
     com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > mxStatusIndicator;
 
-    SchXMLImportHelper maImportHelper;
+    rtl::Reference<SchXMLImportHelper> maImportHelper;
 
 protected:
     virtual SvXMLImportContext *CreateContext(
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 08f1c53..e50c783 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -3560,8 +3560,8 @@ SchXMLExport::SchXMLExport(
     OUString const & implementationName, SvXMLExportFlags nExportFlags )
 :   SvXMLExport( util::MeasureUnit::CM, xContext, implementationName,
         ::xmloff::token::XML_CHART, nExportFlags ),
-    maAutoStylePool( *this ),
-    maExportHelper( *this, maAutoStylePool )
+    maAutoStylePool( new SchXMLAutoStylePoolP(*this) ),
+    maExportHelper( new SchXMLExportHelper(*this, *maAutoStylePool.get()) )
 {
     if( getDefaultVersion() > SvtSaveOptions::ODFVER_012 )
         _GetNamespaceMap().Add( GetXMLToken(XML_NP_CHART_EXT), GetXMLToken(XML_N_CHART_EXT), XML_NAMESPACE_CHART_EXT);
@@ -3579,11 +3579,11 @@ SchXMLExport::~SchXMLExport()
 
 sal_uInt32 SchXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass )
 {
-    maExportHelper.SetSourceShellID(GetSourceShellID());
-    maExportHelper.SetDestinationShellID(GetDestinationShellID());
+    maExportHelper->SetSourceShellID(GetSourceShellID());
+    maExportHelper->SetDestinationShellID(GetDestinationShellID());
 
     Reference< chart2::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
-    maExportHelper.m_pImpl->InitRangeSegmentationProperties( xChartDoc );
+    maExportHelper->m_pImpl->InitRangeSegmentationProperties( xChartDoc );
     return SvXMLExport::exportDoc( eClass );
 }
 
@@ -3606,8 +3606,8 @@ void SchXMLExport::_ExportAutoStyles()
         Reference< chart::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY );
         if( xChartDoc.is())
         {
-            maExportHelper.m_pImpl->collectAutoStyles( xChartDoc );
-            maExportHelper.m_pImpl->exportAutoStyles();
+            maExportHelper->m_pImpl->collectAutoStyles( xChartDoc );
+            maExportHelper->m_pImpl->exportAutoStyles();
         }
         else
         {
@@ -3654,13 +3654,13 @@ void SchXMLExport::_ExportContent()
                             aAny = xProp->getPropertyValue(
                                 OUString( "ChartRangeAddress" ));
                             aAny >>= sChartAddress;
-                            maExportHelper.m_pImpl->SetChartRangeAddress( sChartAddress );
+                            maExportHelper->m_pImpl->SetChartRangeAddress( sChartAddress );
 
                             OUString sTableNumberList;
                             aAny = xProp->getPropertyValue(
                                 OUString( "TableNumberList" ));
                             aAny >>= sTableNumberList;
-                            maExportHelper.m_pImpl->SetTableNumberList( sTableNumberList );
+                            maExportHelper->m_pImpl->SetTableNumberList( sTableNumberList );
 
                             // do not include own table if there are external addresses
                             bIncludeTable = sChartAddress.isEmpty();
@@ -3673,7 +3673,7 @@ void SchXMLExport::_ExportContent()
                 }
             }
         }
-        maExportHelper.m_pImpl->exportChart( xChartDoc, bIncludeTable );
+        maExportHelper->m_pImpl->exportChart( xChartDoc, bIncludeTable );
     }
     else
     {
@@ -3683,7 +3683,7 @@ void SchXMLExport::_ExportContent()
 
 rtl::Reference< XMLPropertySetMapper > SchXMLExport::GetPropertySetMapper() const
 {
-    return maExportHelper.m_pImpl->GetPropertySetMapper();
+    return maExportHelper->m_pImpl->GetPropertySetMapper();
 }
 
 void SchXMLExportHelper_Impl::InitRangeSegmentationProperties( const Reference< chart2::XChartDocument > & xChartDoc )
diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx
index 46083c4..a8e1ea4 100644
--- a/xmloff/source/chart/SchXMLImport.cxx
+++ b/xmloff/source/chart/SchXMLImport.cxx
@@ -506,7 +506,8 @@ Reference< chart2::XDataSeries > SchXMLImportHelper::GetNewDataSeries(
 SchXMLImport::SchXMLImport(
     const Reference< uno::XComponentContext >& xContext,
     OUString const & implementationName, SvXMLImportFlags nImportFlags ) :
-    SvXMLImport( xContext, implementationName, nImportFlags )
+    SvXMLImport( xContext, implementationName, nImportFlags ),
+    maImportHelper(new SchXMLImportHelper)
 {
     GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
     GetNamespaceMap().Add( GetXMLToken(XML_NP_CHART_EXT), GetXMLToken(XML_N_CHART_EXT), XML_NAMESPACE_CHART_EXT);
@@ -540,7 +541,7 @@ SvXMLImportContext *SchXMLImport::CreateContext( sal_uInt16 nPrefix, const OUStr
         ( IsXMLToken( rLocalName, XML_DOCUMENT_STYLES) ||
           IsXMLToken( rLocalName, XML_DOCUMENT_CONTENT) ))
     {
-        pContext = new SchXMLDocContext( maImportHelper, *this, nPrefix, rLocalName );
+        pContext = new SchXMLDocContext( *maImportHelper.get(), *this, nPrefix, rLocalName );
     } else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
                 ( IsXMLToken(rLocalName, XML_DOCUMENT) ||
                   (IsXMLToken(rLocalName, XML_DOCUMENT_META)
@@ -556,12 +557,12 @@ SvXMLImportContext *SchXMLImport::CreateContext( sal_uInt16 nPrefix, const OUStr
                             xDPS->getDocumentProperties())
                 // flat OpenDocument file format
                 : new SchXMLFlatDocContext_Impl(
-                            maImportHelper, *this, nPrefix, rLocalName,
+                            *maImportHelper.get(), *this, nPrefix, rLocalName,
                             xDPS->getDocumentProperties());
         } else {
             pContext = (IsXMLToken(rLocalName, XML_DOCUMENT_META))
                 ? SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList )
-                : new SchXMLDocContext( maImportHelper, *this,
+                : new SchXMLDocContext( *maImportHelper.get(), *this,
                                         nPrefix, rLocalName );
         }
     } else {
@@ -583,7 +584,7 @@ SvXMLImportContext* SchXMLImport::CreateStylesContext(
 
     // set context at base class, so that all auto-style classes are imported
     SetAutoStyles( pStylesCtxt );
-    maImportHelper.SetAutoStylesContext( pStylesCtxt );
+    maImportHelper->SetAutoStylesContext( pStylesCtxt );
 
     return pStylesCtxt;
 }
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index 8945815..fa86baf 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -1717,13 +1717,13 @@ void SdXMLExport::ImpWritePresentationStyles()
                 // write presentation styles (ONLY if presentation)
                 if(IsImpress() && mxDocStyleFamilies.is() && xNamed.is())
                 {
-                    XMLStyleExport aStEx(*this, OUString(), GetAutoStylePool().get());
+                    rtl::Reference<XMLStyleExport> aStEx(new XMLStyleExport(*this, OUString(), GetAutoStylePool().get()));
                     const rtl::Reference< SvXMLExportPropertyMapper > aMapperRef( GetPropertySetMapper() );
 
                     OUString aPrefix( xNamed->getName() );
 
                     aPrefix += "-";
-                    aStEx.exportStyleFamily(xNamed->getName(),
+                    aStEx->exportStyleFamily(xNamed->getName(),
                         OUString(XML_STYLE_FAMILY_SD_PRESENTATION_NAME),
                         aMapperRef, false,
                         XML_STYLE_FAMILY_SD_PRESENTATION_ID, &aPrefix);
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index be6b76d..2852245 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -1247,7 +1247,7 @@ void XMLShapeExport::ImpExportGluePoints( const uno::Reference< drawing::XShape
 
 void XMLShapeExport::ExportGraphicDefaults()
 {
-    XMLStyleExport aStEx(mrExport, OUString(), mrExport.GetAutoStylePool().get());
+    rtl::Reference<XMLStyleExport> aStEx(new XMLStyleExport(mrExport, OUString(), mrExport.GetAutoStylePool().get()));
 
     // construct PropertySetMapper
     rtl::Reference< SvXMLExportPropertyMapper > xPropertySetMapper( CreateShapePropMapper( mrExport ) );
@@ -1268,10 +1268,10 @@ void XMLShapeExport::ExportGraphicDefaults()
             uno::Reference< beans::XPropertySet > xDefaults( xFact->createInstance("com.sun.star.drawing.Defaults"), uno::UNO_QUERY );
             if( xDefaults.is() )
             {
-                aStEx.exportDefaultStyle( xDefaults, OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper );
+                aStEx->exportDefaultStyle( xDefaults, OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper );
 
                 // write graphic family styles
-                aStEx.exportStyleFamily("graphics", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper, false, XML_STYLE_FAMILY_SD_GRAPHICS_ID);
+                aStEx->exportStyleFamily("graphics", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper, false, XML_STYLE_FAMILY_SD_GRAPHICS_ID);
             }
         }
         catch(const lang::ServiceNotRegisteredException&)
diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx
index ab86020..38824f8 100644
--- a/xmloff/source/table/XMLTableExport.cxx
+++ b/xmloff/source/table/XMLTableExport.cxx
@@ -456,10 +456,10 @@ void XMLTableExport::exportTableStyles()
      if( !mbExportTables )
          return;
 
-    XMLStyleExport aStEx(mrExport, OUString(), mrExport.GetAutoStylePool().get());
+    rtl::Reference<XMLStyleExport> aStEx(new XMLStyleExport(mrExport, OUString(), mrExport.GetAutoStylePool().get()));
 
     // write graphic family styles
-    aStEx.exportStyleFamily("cell", OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME), mxCellExportPropertySetMapper.get(), true, XML_STYLE_FAMILY_TABLE_CELL);
+    aStEx->exportStyleFamily("cell", OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME), mxCellExportPropertySetMapper.get(), true, XML_STYLE_FAMILY_TABLE_CELL);
 
     exportTableTemplates();
 }


More information about the Libreoffice-commits mailing list