Kaydet (Commit) 8aa5946a authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Stephan Bergmann

fdo#46808, Adapt packages::manifest::ManifestWriter UNO service to new style

The service already existed, it just did not have an IDL file

Change-Id: I04c617a97262e9cc96af17fcae9cc084245c0149
üst 468acb7f
......@@ -56,7 +56,7 @@
#include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
#include "com/sun/star/ucb/XCommandEnvironment.hpp"
#include <com/sun/star/ucb/NameClash.hpp>
#include "com/sun/star/packages/manifest/XManifestWriter.hpp"
#include "com/sun/star/packages/manifest/ManifestWriter.hpp"
#include <unotools/pathoptions.hxx>
#include <comphelper/processfactory.hxx>
......@@ -1355,9 +1355,8 @@ void LibPage::ExportAsPackage( const String& aLibName )
manifest.push_back( attribs );
// write into pipe:
Reference<packages::manifest::XManifestWriter> xManifestWriter( xMSF->createInstance
( DEFINE_CONST_UNICODE("com.sun.star.packages.manifest.ManifestWriter") ), UNO_QUERY );
Reference<io::XOutputStream> xPipe( io::Pipe::create(comphelper::getComponentContext(xMSF)), UNO_QUERY_THROW );
Reference<packages::manifest::XManifestWriter> xManifestWriter = packages::manifest::ManifestWriter::create( xContext );
Reference<io::XOutputStream> xPipe( io::Pipe::create( xContext ), UNO_QUERY_THROW );
xManifestWriter->writeManifestSequence(
xPipe, Sequence< Sequence<beans::PropertyValue> >(
&manifest[ 0 ], manifest.size() ) );
......@@ -1384,7 +1383,6 @@ void LibPage::ExportAsPackage( const String& aLibName )
void LibPage::ExportAsBasic( const String& aLibName )
{
// Folder picker
Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
Reference< XFolderPicker2 > xFolderPicker = FolderPicker::create(xContext);
Reference< task::XInteractionHandler2 > xHandler( task::InteractionHandler::createWithParent(xContext, 0) );
......
......@@ -62,7 +62,7 @@
#include "com/sun/star/sdbc/XResultSet.hpp"
#include "com/sun/star/sdbc/XRow.hpp"
#include "com/sun/star/packages/manifest/ManifestReader.hpp"
#include "com/sun/star/packages/manifest/XManifestWriter.hpp"
#include "com/sun/star/packages/manifest/ManifestWriter.hpp"
#include "com/sun/star/deployment/DependencyException.hpp"
#include "com/sun/star/deployment/LicenseException.hpp"
#include "com/sun/star/deployment/PlatformException.hpp"
......@@ -1185,10 +1185,8 @@ void BackendImpl::PackageImpl::exportTo(
// write into pipe:
Reference<XComponentContext> xContext(
getMyBackend()->getComponentContext() );
Reference<packages::manifest::XManifestWriter> xManifestWriter(
xContext->getServiceManager()->createInstanceWithContext(
OUSTR("com.sun.star.packages.manifest.ManifestWriter"),
xContext ), UNO_QUERY_THROW );
Reference<packages::manifest::XManifestWriter> xManifestWriter =
packages::manifest::ManifestWriter::create( xContext );
Reference<io::XOutputStream> xPipe( io::Pipe::create(xContext), UNO_QUERY_THROW );
xManifestWriter->writeManifestSequence(
xPipe, comphelper::containerToSequence(manifest) );
......
......@@ -179,6 +179,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/mozilla,\
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/packages/manifest,\
ManifestReader \
ManifestWriter \
))
$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/plugin,\
PluginManager \
......
/* -*- 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_ManifestWriter_idl__
#define __com_sun_star_packages_manifest_ManifestWriter_idl__
#include <com/sun/star/packages/manifest/XManifestWriter.idl>
module com { module sun { module star { module packages { module manifest {
published service ManifestWriter : XManifestWriter;
}; }; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -30,7 +30,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/packages/zip/ZipConstants.hpp>
#include <com/sun/star/packages/manifest/ManifestReader.hpp>
#include <com/sun/star/packages/manifest/XManifestWriter.hpp>
#include <com/sun/star/packages/manifest/ManifestWriter.hpp>
#include <com/sun/star/io/TempFile.hpp>
#include <com/sun/star/io/XStream.hpp>
#include <com/sun/star/io/XInputStream.hpp>
......@@ -1012,48 +1012,35 @@ void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut )
void ZipPackage::WriteManifest( ZipOutputStream& aZipOut, const vector< uno::Sequence < PropertyValue > >& aManList )
{
// Write the manifest
uno::Reference < XOutputStream > xManOutStream;
uno::Reference < XManifestWriter > xWriter ( m_xFactory->createInstance("com.sun.star.packages.manifest.ManifestWriter"), UNO_QUERY );
if ( xWriter.is() )
{
ZipEntry * pEntry = new ZipEntry;
ZipPackageBuffer *pBuffer = new ZipPackageBuffer( n_ConstBufferSize );
xManOutStream = uno::Reference < XOutputStream > ( *pBuffer, UNO_QUERY );
pEntry->sPath = "META-INF/manifest.xml";
pEntry->nMethod = DEFLATED;
pEntry->nCrc = -1;
pEntry->nSize = pEntry->nCompressedSize = -1;
pEntry->nTime = ZipOutputStream::getCurrentDosTime();
// Convert vector into a uno::Sequence
uno::Sequence < uno::Sequence < PropertyValue > > aManifestSequence ( aManList.size() );
sal_Int32 nInd = 0;
for ( vector < uno::Sequence < PropertyValue > >::const_iterator aIter = aManList.begin(), aEnd = aManList.end();
aIter != aEnd;
++aIter, ++nInd )
{
aManifestSequence[nInd] = ( *aIter );
}
xWriter->writeManifestSequence ( xManOutStream, aManifestSequence );
uno::Reference < XManifestWriter > xWriter = ManifestWriter::create( comphelper::getComponentContext(m_xFactory) );
ZipEntry * pEntry = new ZipEntry;
ZipPackageBuffer *pBuffer = new ZipPackageBuffer( n_ConstBufferSize );
uno::Reference < XOutputStream > xManOutStream( *pBuffer, UNO_QUERY );
sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
pBuffer->realloc( nBufferLength );
pEntry->sPath = "META-INF/manifest.xml";
pEntry->nMethod = DEFLATED;
pEntry->nCrc = -1;
pEntry->nSize = pEntry->nCompressedSize = -1;
pEntry->nTime = ZipOutputStream::getCurrentDosTime();
// the manifest.xml is never encrypted - so pass an empty reference
aZipOut.putNextEntry( *pEntry, NULL );
aZipOut.write( pBuffer->getSequence(), 0, nBufferLength );
aZipOut.closeEntry();
}
else
// Convert vector into a uno::Sequence
uno::Sequence < uno::Sequence < PropertyValue > > aManifestSequence ( aManList.size() );
sal_Int32 nInd = 0;
for ( vector < uno::Sequence < PropertyValue > >::const_iterator aIter = aManList.begin(), aEnd = aManList.end();
aIter != aEnd;
++aIter, ++nInd )
{
OSL_FAIL( "Couldn't get a ManifestWriter!" );
IOException aException;
throw WrappedTargetException(
OSL_LOG_PREFIX "Couldn't get a ManifestWriter!",
static_cast < OWeakObject * > ( this ),
makeAny( aException ) );
aManifestSequence[nInd] = ( *aIter );
}
xWriter->writeManifestSequence ( xManOutStream, aManifestSequence );
sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
pBuffer->realloc( nBufferLength );
// the manifest.xml is never encrypted - so pass an empty reference
aZipOut.putNextEntry( *pEntry, NULL );
aZipOut.write( pBuffer->getSequence(), 0, nBufferLength );
aZipOut.closeEntry();
}
//--------------------------------------------------------
......
......@@ -39,7 +39,7 @@
#include <com/sun/star/ucb/ContentInfo.hpp>
#include <com/sun/star/ucb/ContentInfoAttribute.hpp>
#include <com/sun/star/beans/Property.hpp>
#include <com/sun/star/packages/manifest/XManifestWriter.hpp>
#include <com/sun/star/packages/manifest/ManifestWriter.hpp>
#include <com/sun/star/packages/manifest/ManifestReader.hpp>
#include <com/sun/star/ucb/InteractiveIOException.hpp>
......@@ -2366,9 +2366,8 @@ sal_Int16 UCBStorage_Impl::Commit()
// create a manifest writer object that will fill the stream
Reference < ::com::sun::star::packages::manifest::XManifestWriter > xWriter =
Reference< ::com::sun::star::packages::manifest::XManifestWriter >
( ::comphelper::getProcessServiceFactory()->createInstance(
::rtl::OUString("com.sun.star.packages.manifest.ManifestWriter")), UNO_QUERY) ;
::com::sun::star::packages::manifest::ManifestWriter::create(
::comphelper::getProcessComponentContext() );
sal_Int32 nCount = GetObjectCount() + 1;
Sequence < Sequence < PropertyValue > > aProps( nCount );
sal_Int32 nProps = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment