diff options
author | Noel Grandin <noel@peralex.com> | 2016-05-24 11:02:42 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-05-24 11:02:42 +0200 |
commit | 95d20a3799998b9816bd2e8aebdbc96c61cead3e (patch) | |
tree | 8206ecc848631432cb8b027d5e780483734f808a /xmlscript | |
parent | 3caf31b05d7bbf3d50a1bbda6c8b95982cb5c2b5 (diff) |
Revert "remove some manual ref-counting"
until I have a better understanding of the UNO reference
counting.
This reverts commit 111de438ea3e512a541281dc0716cc728ea8d152.
Diffstat (limited to 'xmlscript')
-rw-r--r-- | xmlscript/source/xmlflat_imexp/xmlbas_import.cxx | 44 | ||||
-rw-r--r-- | xmlscript/source/xmlflat_imexp/xmlbas_import.hxx | 4 | ||||
-rw-r--r-- | xmlscript/source/xmllib_imexp/imp_share.hxx | 4 | ||||
-rw-r--r-- | xmlscript/source/xmllib_imexp/xmllib_import.cxx | 51 | ||||
-rw-r--r-- | xmlscript/source/xmlmod_imexp/imp_share.hxx | 4 | ||||
-rw-r--r-- | xmlscript/source/xmlmod_imexp/xmlmod_import.cxx | 23 |
6 files changed, 82 insertions, 48 deletions
diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx index 3c99d74a870d..736afd5a6829 100644 --- a/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx +++ b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx @@ -43,15 +43,23 @@ namespace xmlscript BasicElementBase::BasicElementBase( const OUString& rLocalName, const Reference< xml::input::XAttributes >& xAttributes, BasicElementBase* pParent, BasicImport* pImport ) - :m_xImport( pImport ) - ,m_xParent( pParent ) + :m_pImport( pImport ) + ,m_pParent( pParent ) ,m_aLocalName( rLocalName ) ,m_xAttributes( xAttributes ) { + if ( m_pImport ) + m_pImport->acquire(); + if ( m_pParent ) + m_pParent->acquire(); } BasicElementBase::~BasicElementBase() { + if ( m_pImport ) + m_pImport->release(); + if ( m_pParent ) + m_pParent->release(); } bool BasicElementBase::getBoolAttr( bool* pRet, const OUString& rAttrName, @@ -87,7 +95,7 @@ namespace xmlscript Reference< xml::input::XElement > BasicElementBase::getParent() throw (RuntimeException, std::exception) { - return m_xParent; + return static_cast< xml::input::XElement* >( m_pParent ); } OUString BasicElementBase::getLocalName() @@ -100,8 +108,8 @@ namespace xmlscript throw (RuntimeException, std::exception) { sal_Int32 nId = -1; - if ( m_xImport.is() ) - nId = m_xImport->XMLNS_UID; + if ( m_pImport ) + nId = m_pImport->XMLNS_UID; return nId; } @@ -160,7 +168,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const { Reference< xml::input::XElement > xElement; - if ( nUid != m_xImport->XMLNS_UID ) + if ( nUid != m_pImport->XMLNS_UID ) { throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() ); } @@ -168,12 +176,12 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const { if ( xAttributes.is() ) { - OUString aName = xAttributes->getValueByUidName( m_xImport->XMLNS_UID, "name" ); + OUString aName = xAttributes->getValueByUidName( m_pImport->XMLNS_UID, "name" ); - OUString aStorageURL = xAttributes->getValueByUidName(m_xImport->XMLNS_XLINK_UID, "href" ); + OUString aStorageURL = xAttributes->getValueByUidName(m_pImport->XMLNS_XLINK_UID, "href" ); bool bReadOnly = false; - getBoolAttr( &bReadOnly,"readonly", xAttributes, m_xImport->XMLNS_UID ); + getBoolAttr( &bReadOnly,"readonly", xAttributes, m_pImport->XMLNS_UID ); if ( m_xLibContainer.is() ) { @@ -182,7 +190,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const Reference< container::XNameAccess > xLib( m_xLibContainer->createLibraryLink( aName, aStorageURL, bReadOnly ) ); if ( xLib.is() ) - xElement.set( new BasicElementBase( rLocalName, xAttributes, this, m_xImport.get() ) ); + xElement.set( new BasicElementBase( rLocalName, xAttributes, this, m_pImport ) ); } catch ( const container::ElementExistException& e ) { @@ -201,10 +209,10 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const if ( xAttributes.is() ) { - OUString aName = xAttributes->getValueByUidName( m_xImport->XMLNS_UID, "name" ); + OUString aName = xAttributes->getValueByUidName( m_pImport->XMLNS_UID, "name" ); bool bReadOnly = false; - getBoolAttr( &bReadOnly, "readonly", xAttributes, m_xImport->XMLNS_UID ); + getBoolAttr( &bReadOnly, "readonly", xAttributes, m_pImport->XMLNS_UID ); if ( m_xLibContainer.is() ) { @@ -222,7 +230,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const } if ( xLib.is() ) - xElement.set( new BasicEmbeddedLibraryElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLibContainer, aName, bReadOnly ) ); + xElement.set( new BasicEmbeddedLibraryElement( rLocalName, xAttributes, this, m_pImport, m_xLibContainer, aName, bReadOnly ) ); } catch ( const lang::IllegalArgumentException& e ) { @@ -276,7 +284,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const { Reference< xml::input::XElement > xElement; - if ( nUid != m_xImport->XMLNS_UID ) + if ( nUid != m_pImport->XMLNS_UID ) { throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() ); } @@ -284,10 +292,10 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const { if ( xAttributes.is() ) { - OUString aName = xAttributes->getValueByUidName(m_xImport->XMLNS_UID, "name" ); + OUString aName = xAttributes->getValueByUidName(m_pImport->XMLNS_UID, "name" ); if ( m_xLib.is() && !aName.isEmpty() ) - xElement.set( new BasicModuleElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLib, aName ) ); + xElement.set( new BasicModuleElement( rLocalName, xAttributes, this, m_pImport, m_xLib, aName ) ); } } else @@ -328,7 +336,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const Reference< xml::input::XElement > xElement; - if ( nUid != m_xImport->XMLNS_UID ) + if ( nUid != m_pImport->XMLNS_UID ) { throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() ); } @@ -339,7 +347,7 @@ void BasicElementBase::processingInstruction( const OUString& /*rTarget*/, const if ( xAttributes.is() ) { if ( m_xLib.is() && !m_aName.isEmpty() ) - xElement.set( new BasicSourceCodeElement( rLocalName, xAttributes, this, m_xImport.get(), m_xLib, m_aName ) ); + xElement.set( new BasicSourceCodeElement( rLocalName, xAttributes, this, m_pImport, m_xLib, m_aName ) ); } } else diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx b/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx index d38fa73f0ed3..0eecb0dd1cd3 100644 --- a/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx +++ b/xmlscript/source/xmlflat_imexp/xmlbas_import.hxx @@ -43,8 +43,8 @@ namespace xmlscript class BasicElementBase : public BasicElementBase_BASE { protected: - css::uno::Reference<BasicImport> m_xImport; - css::uno::Reference<BasicElementBase> m_xParent; + BasicImport* m_pImport; + BasicElementBase* m_pParent; OUString m_aLocalName; css::uno::Reference< css::xml::input::XAttributes > m_xAttributes; diff --git a/xmlscript/source/xmllib_imexp/imp_share.hxx b/xmlscript/source/xmllib_imexp/imp_share.hxx index a1ce3561cc6c..a28fb2f7cd33 100644 --- a/xmlscript/source/xmllib_imexp/imp_share.hxx +++ b/xmlscript/source/xmllib_imexp/imp_share.hxx @@ -155,8 +155,8 @@ class LibElementBase : public ::cppu::WeakImplHelper< css::xml::input::XElement > { protected: - css::uno::Reference<LibraryImport> mxImport; - css::uno::Reference<LibElementBase> mxParent; + LibraryImport * _pImport; + LibElementBase * _pParent; OUString _aLocalName; css::uno::Reference< css::xml::input::XAttributes > _xAttributes; diff --git a/xmlscript/source/xmllib_imexp/xmllib_import.cxx b/xmlscript/source/xmllib_imexp/xmllib_import.cxx index cc54d84cb4c7..891919228d08 100644 --- a/xmlscript/source/xmllib_imexp/xmllib_import.cxx +++ b/xmlscript/source/xmllib_imexp/xmllib_import.cxx @@ -33,7 +33,7 @@ namespace xmlscript Reference< xml::input::XElement > LibElementBase::getParent() throw (RuntimeException, std::exception) { - return mxParent; + return static_cast< xml::input::XElement * >( _pParent ); } OUString LibElementBase::getLocalName() @@ -45,7 +45,7 @@ OUString LibElementBase::getLocalName() sal_Int32 LibElementBase::getUid() throw (RuntimeException, std::exception) { - return mxImport->XMLNS_LIBRARY_UID; + return _pImport->XMLNS_LIBRARY_UID; } Reference< xml::input::XAttributes > LibElementBase::getAttributes() @@ -88,15 +88,28 @@ LibElementBase::LibElementBase( OUString const & rLocalName, Reference< xml::input::XAttributes > const & xAttributes, LibElementBase * pParent, LibraryImport * pImport ) - : mxImport( pImport ) - , mxParent( pParent ) + : _pImport( pImport ) + , _pParent( pParent ) , _aLocalName( rLocalName ) , _xAttributes( xAttributes ) { + _pImport->acquire(); + + if (_pParent) + { + _pParent->acquire(); + } } LibElementBase::~LibElementBase() { + _pImport->release(); + + if (_pParent) + { + _pParent->release(); + } + SAL_INFO("xmlscript.xmllib", "LibElementBase::~LibElementBase(): " << _aLocalName ); } @@ -169,7 +182,7 @@ Reference< xml::input::XElement > LibrariesElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException, std::exception) { - if (mxImport->XMLNS_LIBRARY_UID != nUid) + if (_pImport->XMLNS_LIBRARY_UID != nUid) { throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() ); } @@ -179,14 +192,14 @@ Reference< xml::input::XElement > LibrariesElement::startChildElement( LibDescriptor aDesc; aDesc.bLink = aDesc.bReadOnly = aDesc.bPasswordProtected = aDesc.bPreload = false; - aDesc.aName = xAttributes->getValueByUidName(mxImport->XMLNS_LIBRARY_UID, "name" ); - aDesc.aStorageURL = xAttributes->getValueByUidName( mxImport->XMLNS_XLINK_UID, "href" ); - getBoolAttr(&aDesc.bLink, "link", xAttributes, mxImport->XMLNS_LIBRARY_UID ); - getBoolAttr(&aDesc.bReadOnly, "readonly", xAttributes, mxImport->XMLNS_LIBRARY_UID ); - getBoolAttr(&aDesc.bPasswordProtected, "passwordprotected", xAttributes, mxImport->XMLNS_LIBRARY_UID ); + aDesc.aName = xAttributes->getValueByUidName(_pImport->XMLNS_LIBRARY_UID, "name" ); + aDesc.aStorageURL = xAttributes->getValueByUidName( _pImport->XMLNS_XLINK_UID, "href" ); + getBoolAttr(&aDesc.bLink, "link", xAttributes, _pImport->XMLNS_LIBRARY_UID ); + getBoolAttr(&aDesc.bReadOnly, "readonly", xAttributes, _pImport->XMLNS_LIBRARY_UID ); + getBoolAttr(&aDesc.bPasswordProtected, "passwordprotected", xAttributes, _pImport->XMLNS_LIBRARY_UID ); mLibDescriptors.push_back( aDesc ); - return new LibraryElement( rLocalName, xAttributes, this, mxImport.get() ); + return new LibraryElement( rLocalName, xAttributes, this, _pImport ); } else { @@ -197,13 +210,13 @@ Reference< xml::input::XElement > LibrariesElement::startChildElement( void LibrariesElement::endElement() throw (xml::sax::SAXException, RuntimeException, std::exception) { - sal_Int32 nLibCount = mxImport->mpLibArray->mnLibCount = (sal_Int32)mLibDescriptors.size(); - mxImport->mpLibArray->mpLibs = new LibDescriptor[ nLibCount ]; + sal_Int32 nLibCount = _pImport->mpLibArray->mnLibCount = (sal_Int32)mLibDescriptors.size(); + _pImport->mpLibArray->mpLibs = new LibDescriptor[ nLibCount ]; for( sal_Int32 i = 0 ; i < nLibCount ; i++ ) { const LibDescriptor& rLib = mLibDescriptors[i]; - mxImport->mpLibArray->mpLibs[i] = rLib; + _pImport->mpLibArray->mpLibs[i] = rLib; } } @@ -213,18 +226,18 @@ Reference< xml::input::XElement > LibraryElement::startChildElement( Reference< xml::input::XAttributes > const & xAttributes ) throw (xml::sax::SAXException, RuntimeException, std::exception) { - if (mxImport->XMLNS_LIBRARY_UID != nUid) + if (_pImport->XMLNS_LIBRARY_UID != nUid) { throw xml::sax::SAXException( "illegal namespace!", Reference< XInterface >(), Any() ); } // library else if ( rLocalName == "element" ) { - OUString aValue( xAttributes->getValueByUidName(mxImport->XMLNS_LIBRARY_UID, "name" ) ); + OUString aValue( xAttributes->getValueByUidName(_pImport->XMLNS_LIBRARY_UID, "name" ) ); if (!aValue.isEmpty()) mElements.push_back( aValue ); - return new LibElementBase( rLocalName, xAttributes, this, mxImport.get() ); + return new LibElementBase( rLocalName, xAttributes, this, _pImport ); } else { @@ -241,9 +254,9 @@ void LibraryElement::endElement() for( sal_Int32 i = 0 ; i < nElementCount ; i++ ) pElementNames[i] = mElements[i]; - LibDescriptor* pLib = mxImport->mpLibDesc; + LibDescriptor* pLib = _pImport->mpLibDesc; if( !pLib ) - pLib = &static_cast< LibrariesElement* >( mxParent.get() )->mLibDescriptors.back(); + pLib = &static_cast< LibrariesElement* >( _pParent )->mLibDescriptors.back(); pLib->aElementNames = aElementNames; } diff --git a/xmlscript/source/xmlmod_imexp/imp_share.hxx b/xmlscript/source/xmlmod_imexp/imp_share.hxx index b37b865971d5..05ca0944ce04 100644 --- a/xmlscript/source/xmlmod_imexp/imp_share.hxx +++ b/xmlscript/source/xmlmod_imexp/imp_share.hxx @@ -85,8 +85,8 @@ class ModuleElement : public ::cppu::WeakImplHelper< css::xml::input::XElement > { protected: - css::uno::Reference<ModuleImport> mxImport; - css::uno::Reference<ModuleElement> mxParent; + ModuleImport * _pImport; + ModuleElement * _pParent; OUString _aLocalName; css::uno::Reference< css::xml::input::XAttributes > _xAttributes; diff --git a/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx index 0fdc1174c5b7..f724ff7593ba 100644 --- a/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx +++ b/xmlscript/source/xmlmod_imexp/xmlmod_import.cxx @@ -33,7 +33,7 @@ namespace xmlscript Reference< xml::input::XElement > ModuleElement::getParent() throw (RuntimeException, std::exception) { - return mxParent; + return static_cast< xml::input::XElement * >( _pParent ); } OUString ModuleElement::getLocalName() throw (RuntimeException, std::exception) @@ -43,7 +43,7 @@ OUString ModuleElement::getLocalName() sal_Int32 ModuleElement::getUid() throw (RuntimeException, std::exception) { - return mxImport->XMLNS_SCRIPT_UID; + return _pImport->XMLNS_SCRIPT_UID; } Reference< xml::input::XAttributes > ModuleElement::getAttributes() throw (RuntimeException, std::exception) @@ -73,7 +73,7 @@ void ModuleElement::processingInstruction( void ModuleElement::endElement() throw (xml::sax::SAXException, RuntimeException, std::exception) { - mxImport->mrModuleDesc.aCode = _strBuffer.makeStringAndClear(); + _pImport->mrModuleDesc.aCode = _strBuffer.makeStringAndClear(); } Reference< xml::input::XElement > ModuleElement::startChildElement( @@ -88,15 +88,28 @@ ModuleElement::ModuleElement( OUString const & rLocalName, Reference< xml::input::XAttributes > const & xAttributes, ModuleElement * pParent, ModuleImport * pImport ) - : mxImport( pImport ) - , mxParent( pParent ) + : _pImport( pImport ) + , _pParent( pParent ) , _aLocalName( rLocalName ) , _xAttributes( xAttributes ) { + _pImport->acquire(); + + if (_pParent) + { + _pParent->acquire(); + } } ModuleElement::~ModuleElement() { + _pImport->release(); + + if (_pParent) + { + _pParent->release(); + } + SAL_INFO("xmlscript.xmlmod", "ModuleElement::~ModuleElement(): " << _aLocalName ); } |