From 694562874b5b439cbace1b1f0ccb07c574f676a3 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 12 Oct 2012 13:47:05 +0200 Subject: fdo#46808, Adapt packages::manifest::ManifestReader UNO service to new style The service already existed, it just did not have an IDL file. Change-Id: Idad85ab23f6650c89ba3095d10568a302503613b --- .../deployment/registry/package/dp_package.cxx | 8 +- offapi/UnoApi_offapi.mk | 3 + .../sun/star/packages/manifest/ManifestReader.idl | 33 ++++ package/source/zippackage/ZipPackage.cxx | 219 ++++++++++----------- sot/source/sdstor/ucbstorage.cxx | 7 +- .../source/dialogs/digitalsignaturesdialog.cxx | 7 +- 6 files changed, 152 insertions(+), 125 deletions(-) create mode 100644 offapi/com/sun/star/packages/manifest/ManifestReader.idl diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index cd1fd3066c42..943029790b93 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -61,7 +61,7 @@ #include "com/sun/star/ucb/UnsupportedCommandException.hpp" #include "com/sun/star/sdbc/XResultSet.hpp" #include "com/sun/star/sdbc/XRow.hpp" -#include "com/sun/star/packages/manifest/XManifestReader.hpp" +#include "com/sun/star/packages/manifest/ManifestReader.hpp" #include "com/sun/star/packages/manifest/XManifestWriter.hpp" #include "com/sun/star/deployment/DependencyException.hpp" #include "com/sun/star/deployment/LicenseException.hpp" @@ -1445,10 +1445,8 @@ void BackendImpl::PackageImpl::scanBundle( const Reference xContext( getMyBackend()->getComponentContext() ); - Reference xManifestReader( - xContext->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.packages.manifest.ManifestReader"), - xContext ), UNO_QUERY_THROW ); + Reference xManifestReader = + packages::manifest::ManifestReader::create( xContext ); const Sequence< Sequence > manifestSeq( xManifestReader->readManifestSequence( manifestContent.openStream() ) ); const OUString packageRootURL( getURL() ); diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 8f63748f5b59..18ad25214f72 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -177,6 +177,9 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/media,\ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/mozilla,\ MozillaBootstrap \ )) +$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/packages/manifest,\ + ManifestReader \ +)) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/plugin,\ PluginManager \ )) diff --git a/offapi/com/sun/star/packages/manifest/ManifestReader.idl b/offapi/com/sun/star/packages/manifest/ManifestReader.idl new file mode 100644 index 000000000000..262234947bee --- /dev/null +++ b/offapi/com/sun/star/packages/manifest/ManifestReader.idl @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef __com_sun_star_packages_manifest_ManifestReader_idl__ +#define __com_sun_star_packages_manifest_ManifestReader_idl__ + +#include + +module com { module sun { module star { module packages { module manifest { + +published service ManifestReader : XManifestReader; + + +}; }; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 822f8399ea35..dd2cf380e027 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -212,139 +212,134 @@ void ZipPackage::parseManifest() uno::Reference < XActiveDataSink > xSink ( xTunnel, UNO_QUERY ); if ( xSink.is() ) { - OUString sManifestReader ("com.sun.star.packages.manifest.ManifestReader"); - uno::Reference < XManifestReader > xReader ( m_xFactory->createInstance( sManifestReader ), UNO_QUERY ); - if ( xReader.is() ) + uno::Reference < XManifestReader > xReader = ManifestReader::create( comphelper::getComponentContext( m_xFactory ) ); + + const OUString sPropFullPath ("FullPath"); + const OUString sPropVersion ("Version"); + const OUString sPropMediaType ("MediaType"); + const OUString sPropInitialisationVector ("InitialisationVector"); + const OUString sPropSalt ("Salt"); + const OUString sPropIterationCount ("IterationCount"); + const OUString sPropSize ("Size"); + const OUString sPropDigest ("Digest"); + const OUString sPropDerivedKeySize ("DerivedKeySize"); + const OUString sPropDigestAlgorithm ("DigestAlgorithm"); + const OUString sPropEncryptionAlgorithm ("EncryptionAlgorithm"); + const OUString sPropStartKeyAlgorithm ("StartKeyAlgorithm"); + + uno::Sequence < uno::Sequence < PropertyValue > > aManifestSequence = xReader->readManifestSequence ( xSink->getInputStream() ); + sal_Int32 nLength = aManifestSequence.getLength(); + const uno::Sequence < PropertyValue > *pSequence = aManifestSequence.getConstArray(); + ZipPackageStream *pStream = NULL; + ZipPackageFolder *pFolder = NULL; + + for ( sal_Int32 i = 0; i < nLength ; i++, pSequence++ ) { - const OUString sPropFullPath ("FullPath"); - const OUString sPropVersion ("Version"); - const OUString sPropMediaType ("MediaType"); - const OUString sPropInitialisationVector ("InitialisationVector"); - const OUString sPropSalt ("Salt"); - const OUString sPropIterationCount ("IterationCount"); - const OUString sPropSize ("Size"); - const OUString sPropDigest ("Digest"); - const OUString sPropDerivedKeySize ("DerivedKeySize"); - const OUString sPropDigestAlgorithm ("DigestAlgorithm"); - const OUString sPropEncryptionAlgorithm ("EncryptionAlgorithm"); - const OUString sPropStartKeyAlgorithm ("StartKeyAlgorithm"); - - uno::Sequence < uno::Sequence < PropertyValue > > aManifestSequence = xReader->readManifestSequence ( xSink->getInputStream() ); - sal_Int32 nLength = aManifestSequence.getLength(); - const uno::Sequence < PropertyValue > *pSequence = aManifestSequence.getConstArray(); - ZipPackageStream *pStream = NULL; - ZipPackageFolder *pFolder = NULL; - - for ( sal_Int32 i = 0; i < nLength ; i++, pSequence++ ) + OUString sPath, sMediaType, sVersion; + const PropertyValue *pValue = pSequence->getConstArray(); + const Any *pSalt = NULL, *pVector = NULL, *pCount = NULL, *pSize = NULL, *pDigest = NULL, *pDigestAlg = NULL, *pEncryptionAlg = NULL, *pStartKeyAlg = NULL, *pDerivedKeySize = NULL; + for ( sal_Int32 j = 0, nNum = pSequence->getLength(); j < nNum; j++ ) { - OUString sPath, sMediaType, sVersion; - const PropertyValue *pValue = pSequence->getConstArray(); - const Any *pSalt = NULL, *pVector = NULL, *pCount = NULL, *pSize = NULL, *pDigest = NULL, *pDigestAlg = NULL, *pEncryptionAlg = NULL, *pStartKeyAlg = NULL, *pDerivedKeySize = NULL; - for ( sal_Int32 j = 0, nNum = pSequence->getLength(); j < nNum; j++ ) + if ( pValue[j].Name.equals( sPropFullPath ) ) + pValue[j].Value >>= sPath; + else if ( pValue[j].Name.equals( sPropVersion ) ) + pValue[j].Value >>= sVersion; + else if ( pValue[j].Name.equals( sPropMediaType ) ) + pValue[j].Value >>= sMediaType; + else if ( pValue[j].Name.equals( sPropSalt ) ) + pSalt = &( pValue[j].Value ); + else if ( pValue[j].Name.equals( sPropInitialisationVector ) ) + pVector = &( pValue[j].Value ); + else if ( pValue[j].Name.equals( sPropIterationCount ) ) + pCount = &( pValue[j].Value ); + else if ( pValue[j].Name.equals( sPropSize ) ) + pSize = &( pValue[j].Value ); + else if ( pValue[j].Name.equals( sPropDigest ) ) + pDigest = &( pValue[j].Value ); + else if ( pValue[j].Name.equals( sPropDigestAlgorithm ) ) + pDigestAlg = &( pValue[j].Value ); + else if ( pValue[j].Name.equals( sPropEncryptionAlgorithm ) ) + pEncryptionAlg = &( pValue[j].Value ); + else if ( pValue[j].Name.equals( sPropStartKeyAlgorithm ) ) + pStartKeyAlg = &( pValue[j].Value ); + else if ( pValue[j].Name.equals( sPropDerivedKeySize ) ) + pDerivedKeySize = &( pValue[j].Value ); + } + + if ( !sPath.isEmpty() && hasByHierarchicalName ( sPath ) ) + { + aAny = getByHierarchicalName( sPath ); + uno::Reference < XUnoTunnel > xUnoTunnel; + aAny >>= xUnoTunnel; + sal_Int64 nTest=0; + if ( (nTest = xUnoTunnel->getSomething( ZipPackageFolder::static_getImplementationId() )) != 0 ) { - if ( pValue[j].Name.equals( sPropFullPath ) ) - pValue[j].Value >>= sPath; - else if ( pValue[j].Name.equals( sPropVersion ) ) - pValue[j].Value >>= sVersion; - else if ( pValue[j].Name.equals( sPropMediaType ) ) - pValue[j].Value >>= sMediaType; - else if ( pValue[j].Name.equals( sPropSalt ) ) - pSalt = &( pValue[j].Value ); - else if ( pValue[j].Name.equals( sPropInitialisationVector ) ) - pVector = &( pValue[j].Value ); - else if ( pValue[j].Name.equals( sPropIterationCount ) ) - pCount = &( pValue[j].Value ); - else if ( pValue[j].Name.equals( sPropSize ) ) - pSize = &( pValue[j].Value ); - else if ( pValue[j].Name.equals( sPropDigest ) ) - pDigest = &( pValue[j].Value ); - else if ( pValue[j].Name.equals( sPropDigestAlgorithm ) ) - pDigestAlg = &( pValue[j].Value ); - else if ( pValue[j].Name.equals( sPropEncryptionAlgorithm ) ) - pEncryptionAlg = &( pValue[j].Value ); - else if ( pValue[j].Name.equals( sPropStartKeyAlgorithm ) ) - pStartKeyAlg = &( pValue[j].Value ); - else if ( pValue[j].Name.equals( sPropDerivedKeySize ) ) - pDerivedKeySize = &( pValue[j].Value ); + pFolder = reinterpret_cast < ZipPackageFolder* > ( nTest ); + pFolder->SetMediaType ( sMediaType ); + pFolder->SetVersion ( sVersion ); } - - if ( !sPath.isEmpty() && hasByHierarchicalName ( sPath ) ) + else { - aAny = getByHierarchicalName( sPath ); - uno::Reference < XUnoTunnel > xUnoTunnel; - aAny >>= xUnoTunnel; - sal_Int64 nTest=0; - if ( (nTest = xUnoTunnel->getSomething( ZipPackageFolder::static_getImplementationId() )) != 0 ) - { - pFolder = reinterpret_cast < ZipPackageFolder* > ( nTest ); - pFolder->SetMediaType ( sMediaType ); - pFolder->SetVersion ( sVersion ); - } - else - { - pStream = reinterpret_cast < ZipPackageStream* > ( xUnoTunnel->getSomething( ZipPackageStream::static_getImplementationId() )); - pStream->SetMediaType ( sMediaType ); - pStream->SetFromManifest( sal_True ); + pStream = reinterpret_cast < ZipPackageStream* > ( xUnoTunnel->getSomething( ZipPackageStream::static_getImplementationId() )); + pStream->SetMediaType ( sMediaType ); + pStream->SetFromManifest( sal_True ); - if ( pSalt && pVector && pCount && pSize && pDigest && pDigestAlg && pEncryptionAlg ) - { - uno::Sequence < sal_Int8 > aSequence; - sal_Int64 nSize = 0; - sal_Int32 nCount = 0, nDigestAlg = 0, nEncryptionAlg = 0; - sal_Int32 nDerivedKeySize = 16, nStartKeyAlg = xml::crypto::DigestID::SHA1; + if ( pSalt && pVector && pCount && pSize && pDigest && pDigestAlg && pEncryptionAlg ) + { + uno::Sequence < sal_Int8 > aSequence; + sal_Int64 nSize = 0; + sal_Int32 nCount = 0, nDigestAlg = 0, nEncryptionAlg = 0; + sal_Int32 nDerivedKeySize = 16, nStartKeyAlg = xml::crypto::DigestID::SHA1; - pStream->SetToBeEncrypted ( sal_True ); + pStream->SetToBeEncrypted ( sal_True ); - *pSalt >>= aSequence; - pStream->setSalt ( aSequence ); + *pSalt >>= aSequence; + pStream->setSalt ( aSequence ); - *pVector >>= aSequence; - pStream->setInitialisationVector ( aSequence ); + *pVector >>= aSequence; + pStream->setInitialisationVector ( aSequence ); - *pCount >>= nCount; - pStream->setIterationCount ( nCount ); + *pCount >>= nCount; + pStream->setIterationCount ( nCount ); - *pSize >>= nSize; - pStream->setSize ( nSize ); + *pSize >>= nSize; + pStream->setSize ( nSize ); - *pDigest >>= aSequence; - pStream->setDigest ( aSequence ); + *pDigest >>= aSequence; + pStream->setDigest ( aSequence ); - *pDigestAlg >>= nDigestAlg; - pStream->SetImportedChecksumAlgorithm( nDigestAlg ); + *pDigestAlg >>= nDigestAlg; + pStream->SetImportedChecksumAlgorithm( nDigestAlg ); - *pEncryptionAlg >>= nEncryptionAlg; - pStream->SetImportedEncryptionAlgorithm( nEncryptionAlg ); + *pEncryptionAlg >>= nEncryptionAlg; + pStream->SetImportedEncryptionAlgorithm( nEncryptionAlg ); - if ( pDerivedKeySize ) - *pDerivedKeySize >>= nDerivedKeySize; - pStream->SetImportedDerivedKeySize( nDerivedKeySize ); + if ( pDerivedKeySize ) + *pDerivedKeySize >>= nDerivedKeySize; + pStream->SetImportedDerivedKeySize( nDerivedKeySize ); - if ( pStartKeyAlg ) - *pStartKeyAlg >>= nStartKeyAlg; - pStream->SetImportedStartKeyAlgorithm( nStartKeyAlg ); + if ( pStartKeyAlg ) + *pStartKeyAlg >>= nStartKeyAlg; + pStream->SetImportedStartKeyAlgorithm( nStartKeyAlg ); - pStream->SetToBeCompressed ( sal_True ); - pStream->SetToBeEncrypted ( sal_True ); - pStream->SetIsEncrypted ( sal_True ); - if ( !m_bHasEncryptedEntries && pStream->getName() == "content.xml" ) - { - m_bHasEncryptedEntries = sal_True; - m_nStartKeyGenerationID = nStartKeyAlg; - m_nChecksumDigestID = nDigestAlg; - m_nCommonEncryptionID = nEncryptionAlg; - } + pStream->SetToBeCompressed ( sal_True ); + pStream->SetToBeEncrypted ( sal_True ); + pStream->SetIsEncrypted ( sal_True ); + if ( !m_bHasEncryptedEntries && pStream->getName() == "content.xml" ) + { + m_bHasEncryptedEntries = sal_True; + m_nStartKeyGenerationID = nStartKeyAlg; + m_nChecksumDigestID = nDigestAlg; + m_nCommonEncryptionID = nEncryptionAlg; } - else - m_bHasNonEncryptedEntries = sal_True; } + else + m_bHasNonEncryptedEntries = sal_True; } } - - bManifestParsed = sal_True; } - else - throw uno::RuntimeException(OSL_LOG_PREFIX "No manifes parser!", uno::Reference< uno::XInterface >() ); + + bManifestParsed = sal_True; } // now hide the manifest.xml file from user diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx index d1ff3c13285b..d314aae4023f 100644 --- a/sot/source/sdstor/ucbstorage.cxx +++ b/sot/source/sdstor/ucbstorage.cxx @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include @@ -1780,9 +1780,8 @@ void UCBStorage_Impl::Init() // create a manifest reader object that will read in the manifest from the stream Reference < ::com::sun::star::packages::manifest::XManifestReader > xReader = - Reference< ::com::sun::star::packages::manifest::XManifestReader > - ( ::comphelper::getProcessServiceFactory()->createInstance( - ::rtl::OUString("com.sun.star.packages.manifest.ManifestReader")), UNO_QUERY) ; + ::com::sun::star::packages::manifest::ManifestReader::create( + ::comphelper::getProcessComponentContext() ) ; Sequence < Sequence < PropertyValue > > aProps = xReader->readManifestSequence( xInputStream ); // cleanup diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index aa58d93ddb7b..eb67af93f76d 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include @@ -268,9 +268,8 @@ void DigitalSignaturesDialog::SetStorage( const com::sun::star::uno::Reference < mxStore = rxStore; maSignatureHelper.SetStorage( mxStore, m_sODFVersion); - Reference < css::packages::manifest::XManifestReader > xReader( - mxCtx->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.packages.manifest.ManifestReader"), mxCtx), UNO_QUERY_THROW); + Reference < css::packages::manifest::XManifestReader > xReader = + css::packages::manifest::ManifestReader::create(mxCtx); //Get the manifest.xml Reference < css::embed::XStorage > xSubStore(rxStore->openStorageElement( -- cgit v1.2.3