diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-01-16 10:36:59 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-01-17 19:09:51 +0000 |
commit | a04bf69bccfbc266643b418ef57030a42bbb5c05 (patch) | |
tree | 785dc34a97856679630d5ba677939a6845ab5207 /package/source/zippackage | |
parent | c4341c95a2be2e0210d5f8f15d4dd80d9077c4af (diff) |
XUnoTunnel->dynamic_cast in ZipPackageEntry
Change-Id: I0c49ebcb0ed16ab5b90c0cfa1417f002b5dad7b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145632
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package/source/zippackage')
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 44 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageEntry.cxx | 2 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageFolder.cxx | 24 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageFolderEnumeration.cxx | 3 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageStream.cxx | 27 |
5 files changed, 37 insertions, 63 deletions
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 9bf6f5e9b24c..e03a17e8016a 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -171,15 +171,14 @@ void ZipPackage::parseManifest() { try { static const OUStringLiteral sManifest (u"manifest.xml"); - uno::Reference< XUnoTunnel > xTunnel; Any aAny = m_xRootFolder->getByName( sMeta ); - aAny >>= xTunnel; - uno::Reference< XNameContainer > xMetaInfFolder( xTunnel, UNO_QUERY ); + uno::Reference< XNameContainer > xMetaInfFolder; + aAny >>= xMetaInfFolder; if ( xMetaInfFolder.is() && xMetaInfFolder->hasByName( sManifest ) ) { + uno::Reference < XActiveDataSink > xSink; aAny = xMetaInfFolder->getByName( sManifest ); - aAny >>= xTunnel; - uno::Reference < XActiveDataSink > xSink ( xTunnel, UNO_QUERY ); + aAny >>= xSink; if ( xSink.is() ) { uno::Reference < XManifestReader > xReader = ManifestReader::create( m_xContext ); @@ -238,14 +237,14 @@ void ZipPackage::parseManifest() if ( !sPath.isEmpty() && hasByHierarchicalName ( sPath ) ) { aAny = getByHierarchicalName( sPath ); - uno::Reference < XUnoTunnel > xUnoTunnel; - aAny >>= xUnoTunnel; - if (auto pFolder = comphelper::getFromUnoTunnel<ZipPackageFolder>(xUnoTunnel)) + uno::Reference < XInterface > xTmp; + aAny >>= xTmp; + if (auto pFolder = dynamic_cast<ZipPackageFolder*>(xTmp.get())) { pFolder->SetMediaType ( sMediaType ); pFolder->SetVersion ( sVersion ); } - else if (auto pStream = comphelper::getFromUnoTunnel<ZipPackageStream>(xUnoTunnel)) + else if (auto pStream = dynamic_cast<ZipPackageStream*>(xTmp.get())) { pStream->SetMediaType ( sMediaType ); pStream->SetFromManifest( true ); @@ -374,9 +373,8 @@ void ZipPackage::parseManifest() { // get mediatype from the "mimetype" stream OUString aPackageMediatype; - uno::Reference< lang::XUnoTunnel > xMimeTypeTunnel; - m_xRootFolder->getByName( sMimetype ) >>= xMimeTypeTunnel; - uno::Reference < io::XActiveDataSink > xMimeSink( xMimeTypeTunnel, UNO_QUERY ); + uno::Reference < io::XActiveDataSink > xMimeSink; + m_xRootFolder->getByName( sMimetype ) >>= xMimeSink; if ( xMimeSink.is() ) { uno::Reference< io::XInputStream > xMimeInStream = xMimeSink->getInputStream(); @@ -452,10 +450,9 @@ void ZipPackage::parseContentType() if ( !m_xRootFolder->hasByName( aContentTypes ) ) throw io::IOException(THROW_WHERE "Wrong format!" ); - uno::Reference< lang::XUnoTunnel > xTunnel; + uno::Reference < io::XActiveDataSink > xSink; uno::Any aAny = m_xRootFolder->getByName( aContentTypes ); - aAny >>= xTunnel; - uno::Reference < io::XActiveDataSink > xSink( xTunnel, UNO_QUERY ); + aAny >>= xSink; if ( xSink.is() ) { uno::Reference< io::XInputStream > xInStream = xSink->getInputStream(); @@ -484,9 +481,9 @@ void ZipPackage::parseContentType() if ( !aPath.isEmpty() && hasByHierarchicalName( aPath ) ) { uno::Any aIterAny = getByHierarchicalName( aPath ); - uno::Reference < lang::XUnoTunnel > xIterTunnel; - aIterAny >>= xIterTunnel; - if (auto pStream = comphelper::getFromUnoTunnel<ZipPackageStream>(xIterTunnel)) + uno::Reference < XInterface > xIterTmp; + aIterAny >>= xIterTmp; + if (auto pStream = dynamic_cast<ZipPackageStream*>(xIterTmp.get())) { // this is a package stream, in OFOPXML format only streams can have mediatype pStream->SetMediaType( rPair.Second ); @@ -800,7 +797,7 @@ Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName ) if (aName == "/") // root directory. - return Any ( uno::Reference < XUnoTunnel > ( m_xRootFolder ) ); + return Any ( uno::Reference < XInterface > ( static_cast<cppu::OWeakObject*>(m_xRootFolder.get()) ) ); nStreamIndex = aName.lastIndexOf ( '/' ); bool bFolder = nStreamIndex == nIndex-1; // last character is '/'. @@ -823,7 +820,7 @@ Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName ) sTemp = aName.copy ( nDirIndex == -1 ? 0 : nDirIndex+1, nStreamIndex-nDirIndex-1 ); if (pFolder && sTemp == pFolder->getName()) - return Any(uno::Reference<XUnoTunnel>(pFolder)); + return Any(uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(pFolder))); } else { @@ -869,7 +866,7 @@ Any SAL_CALL ZipPackage::getByHierarchicalName( const OUString& aName ) { if ( nStreamIndex != -1 ) m_aRecent[sDirName] = pPrevious; // cache it. - return Any ( uno::Reference < XUnoTunnel > ( pCurrent ) ); + return Any ( uno::Reference < XInterface > ( static_cast<cppu::OWeakObject*>(pCurrent) ) ); } sTemp = aName.copy( nOldIndex ); @@ -1217,10 +1214,9 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile() { static const OUStringLiteral sManifest (u"manifest.xml"); - uno::Reference< XUnoTunnel > xTunnel; + uno::Reference< XNameContainer > xMetaInfFolder; Any aAny = m_xRootFolder->getByName( sMeta ); - aAny >>= xTunnel; - uno::Reference< XNameContainer > xMetaInfFolder( xTunnel, UNO_QUERY ); + aAny >>= xMetaInfFolder; if ( xMetaInfFolder.is() && xMetaInfFolder->hasByName( sManifest ) ) xMetaInfFolder->removeByName( sManifest ); } diff --git a/package/source/zippackage/ZipPackageEntry.cxx b/package/source/zippackage/ZipPackageEntry.cxx index df18f0874f25..cbbcf5e9a468 100644 --- a/package/source/zippackage/ZipPackageEntry.cxx +++ b/package/source/zippackage/ZipPackageEntry.cxx @@ -93,7 +93,7 @@ void SAL_CALL ZipPackageEntry::setParent( const uno::Reference< XInterface >& xN { if ( !xNewParent.is() ) throw NoSupportException(THROW_WHERE ); - ZipPackageFolder* pNewParent = comphelper::getFromUnoTunnel<ZipPackageFolder>(xNewParent); + ZipPackageFolder* pNewParent = dynamic_cast<ZipPackageFolder*>(xNewParent.get()); if (!pNewParent) throw NoSupportException(THROW_WHERE ); diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx index 7e7168805f72..175536415a48 100644 --- a/package/source/zippackage/ZipPackageFolder.cxx +++ b/package/source/zippackage/ZipPackageFolder.cxx @@ -143,26 +143,20 @@ void ZipPackageFolder::setChildStreamsTypeByExtension( const beans::StringPair& } } -const css::uno::Sequence < sal_Int8 > & ZipPackageFolder::getUnoTunnelId() -{ - static const comphelper::UnoIdInit lcl_CachedImplId; - return lcl_CachedImplId.getSeq(); -} - // XNameContainer void SAL_CALL ZipPackageFolder::insertByName( const OUString& aName, const uno::Any& aElement ) { if (hasByName(aName)) throw ElementExistException(THROW_WHERE ); - uno::Reference < XUnoTunnel > xRef; + uno::Reference < XInterface > xRef; aElement >>= xRef; if ( !(aElement >>= xRef) ) throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 0 ); - ZipPackageEntry* pEntry = comphelper::getFromUnoTunnel<ZipPackageFolder>(xRef); + ZipPackageEntry* pEntry = dynamic_cast<ZipPackageFolder*>(xRef.get()); if (!pEntry) - pEntry = comphelper::getFromUnoTunnel<ZipPackageStream>(xRef); + pEntry = dynamic_cast<ZipPackageStream*>(xRef.get()); if (!pEntry) throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 0 ); @@ -186,7 +180,7 @@ uno::Reference< XEnumeration > SAL_CALL ZipPackageFolder::createEnumeration( ) // XElementAccess uno::Type SAL_CALL ZipPackageFolder::getElementType( ) { - return cppu::UnoType<XUnoTunnel>::get(); + return cppu::UnoType<XInterface>::get(); } sal_Bool SAL_CALL ZipPackageFolder::hasElements( ) { @@ -203,7 +197,7 @@ ZipContentInfo& ZipPackageFolder::doGetByName( const OUString& aName ) uno::Any SAL_CALL ZipPackageFolder::getByName( const OUString& aName ) { - return uno::Any ( doGetByName ( aName ).xTunnel ); + return uno::Any ( uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(doGetByName ( aName ).xPackageEntry.get())) ); } uno::Sequence< OUString > SAL_CALL ZipPackageFolder::getElementNames( ) { @@ -329,10 +323,6 @@ void ZipPackageFolder::saveContents( } } -sal_Int64 SAL_CALL ZipPackageFolder::getSomething( const uno::Sequence< sal_Int8 >& aIdentifier ) -{ - return comphelper::getSomethingImpl(aIdentifier, this); -} void SAL_CALL ZipPackageFolder::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) { if ( aPropertyName == "MediaType" ) @@ -395,14 +385,14 @@ sal_Bool SAL_CALL ZipPackageFolder::supportsService( OUString const & rServiceNa ZipContentInfo::ZipContentInfo ( ZipPackageStream * pNewStream ) -: xTunnel ( pNewStream ) +: xPackageEntry ( pNewStream ) , bFolder ( false ) , pStream ( pNewStream ) { } ZipContentInfo::ZipContentInfo ( ZipPackageFolder * pNewFolder ) -: xTunnel ( pNewFolder ) +: xPackageEntry ( pNewFolder ) , bFolder ( true ) , pFolder ( pNewFolder ) { diff --git a/package/source/zippackage/ZipPackageFolderEnumeration.cxx b/package/source/zippackage/ZipPackageFolderEnumeration.cxx index 7b08e18909ce..5d091de0e1e4 100644 --- a/package/source/zippackage/ZipPackageFolderEnumeration.cxx +++ b/package/source/zippackage/ZipPackageFolderEnumeration.cxx @@ -46,7 +46,8 @@ uno::Any SAL_CALL ZipPackageFolderEnumeration::nextElement() uno::Any aAny; if (aIterator == rContents.end()) throw container::NoSuchElementException(THROW_WHERE); - aAny <<= (*aIterator).second.xTunnel; + aAny <<= uno::Reference<XInterface>( + static_cast<cppu::OWeakObject*>((*aIterator).second.xPackageEntry.get())); ++aIterator; return aAny; } diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index a63683c771cd..353216694f8a 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -73,12 +73,6 @@ using namespace cppu; #define THROW_WHERE "" #endif -const css::uno::Sequence < sal_Int8 > & ZipPackageStream::getUnoTunnelId() -{ - static const comphelper::UnoIdInit lcl_CachedImplId; - return lcl_CachedImplId.getSeq(); -} - ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage, const uno::Reference< XComponentContext >& xContext, sal_Int32 nFormat, @@ -300,13 +294,13 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream( } // insert a new stream in the package - uno::Reference< XUnoTunnel > xTunnel; + uno::Reference< XInterface > xTmp; Any aRoot = pPackage->getByHierarchicalName("/"); - aRoot >>= xTunnel; - uno::Reference< container::XNameContainer > xRootNameContainer( xTunnel, UNO_QUERY_THROW ); + aRoot >>= xTmp; + uno::Reference< container::XNameContainer > xRootNameContainer( xTmp, UNO_QUERY_THROW ); - uno::Reference< XUnoTunnel > xNPSTunnel( xNewPackStream, UNO_QUERY ); - xRootNameContainer->insertByName("dummy", Any( xNPSTunnel ) ); + uno::Reference< XInterface > xNPSDummy( xNewPackStream, UNO_QUERY ); + xRootNameContainer->insertByName("dummy", Any( xNPSDummy ) ); // commit the temporary package pPackage->commitChanges(); @@ -330,9 +324,9 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream( // close raw stream, package stream and folder xInRaw.clear(); xNewPSProps.clear(); - xNPSTunnel.clear(); + xNPSDummy.clear(); xNewPackStream.clear(); - xTunnel.clear(); + xTmp.clear(); xRootNameContainer.clear(); // return the stream representing the first temporary file @@ -1095,13 +1089,6 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getPlainRawStream( return uno::Reference< io::XInputStream >(); } -// XUnoTunnel - -sal_Int64 SAL_CALL ZipPackageStream::getSomething( const Sequence< sal_Int8 >& aIdentifier ) -{ - return comphelper::getSomethingImpl(aIdentifier, this); -} - // XPropertySet void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) { |