summaryrefslogtreecommitdiff
path: root/comphelper/source/misc/storagehelper.cxx
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@gmail.com>2012-08-16 21:47:01 +0200
committerMatúš Kukan <matus.kukan@gmail.com>2012-08-16 21:54:18 +0200
commite3648d4ebc7378cc31b6ce73716328f48b8903e5 (patch)
treec8cd2fc0fce09d92910728ed8f9949d4e54f975c /comphelper/source/misc/storagehelper.cxx
parent72777a66bb8d9e71c4786c282c7971d7ededa729 (diff)
Revert "Cleanup comphelper::storagehelper"
This reverts commit 72777a66bb8d9e71c4786c282c7971d7ededa729. +using namespace com::sun::star::uno; in header is not a good idea Fails to compile and is hard to parse and figure out what was the point, so just reverting. Also +using rtl::OUString; is automatic nowadays whenever possible and RTL_CONSTASCII_USTRINGPARAM is obsoleted. Change-Id: I24cb24b7f1a6007734d26cbba41d46323cb55b18
Diffstat (limited to 'comphelper/source/misc/storagehelper.cxx')
-rw-r--r--comphelper/source/misc/storagehelper.cxx511
1 files changed, 265 insertions, 246 deletions
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index a339589aa02e..d43e68943855 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -40,177 +40,177 @@
#include <comphelper/storagehelper.hxx>
-using namespace com::sun::star::io;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::embed;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::ucb;
-using namespace com::sun::star::xml::crypto;
-using rtl::OUString;
-using rtl::OString;
+using namespace ::com::sun::star;
namespace comphelper {
-Reference< XSingleServiceFactory >
- OStorageHelper::GetStorageFactory(const Reference< XMultiServiceFactory >& xSF )
- throw ( Exception )
+// ----------------------------------------------------------------------
+uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetStorageFactory(
+ const uno::Reference< lang::XMultiServiceFactory >& xSF )
+ throw ( uno::Exception )
{
- Reference< XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
+ uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
if ( !xFactory.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
- OUString sService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory"));
+ rtl::OUString sService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory"));
- Reference < XSingleServiceFactory > xStorageFactory(
- xFactory->createInstance(sService), UNO_QUERY);
+ uno::Reference < lang::XSingleServiceFactory > xStorageFactory(
+ xFactory->createInstance(sService), uno::UNO_QUERY);
if ( !xStorageFactory.is() )
{
- throw RuntimeException(OUString(
+ throw uno::RuntimeException(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("Could not load: ")) + sService,
- Reference< XInterface >());
+ uno::Reference< uno::XInterface >());
}
return xStorageFactory;
}
-Reference< XSingleServiceFactory > OStorageHelper::GetFileSystemStorageFactory(
- const Reference< XMultiServiceFactory >& xSF )
- throw ( Exception )
+// ----------------------------------------------------------------------
+uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetFileSystemStorageFactory(
+ const uno::Reference< lang::XMultiServiceFactory >& xSF )
+ throw ( uno::Exception )
{
- Reference< XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
+ uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
if ( !xFactory.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
- OUString sService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.FileSystemStorageFactory"));
+ rtl::OUString sService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.FileSystemStorageFactory"));
- Reference < XSingleServiceFactory > xStorageFactory(
- xFactory->createInstance(sService), UNO_QUERY);
+ uno::Reference < lang::XSingleServiceFactory > xStorageFactory(
+ xFactory->createInstance(sService), uno::UNO_QUERY);
if ( !xStorageFactory.is() )
{
- throw RuntimeException(OUString(
+ throw uno::RuntimeException(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("Could not load: ")) + sService,
- Reference< XInterface >());
+ uno::Reference< uno::XInterface >());
}
return xStorageFactory;
}
-Reference< XStorage > OStorageHelper::GetTemporaryStorage(
- const Reference< XMultiServiceFactory >& xFactory )
- throw ( Exception )
+// ----------------------------------------------------------------------
+uno::Reference< embed::XStorage > OStorageHelper::GetTemporaryStorage(
+ const uno::Reference< lang::XMultiServiceFactory >& xFactory )
+ throw ( uno::Exception )
{
- Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstance(),
- UNO_QUERY );
+ uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstance(),
+ uno::UNO_QUERY );
if ( !xTempStorage.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
return xTempStorage;
}
-Reference< XStorage > OStorageHelper::GetStorageFromURL(
- const OUString& aURL,
+// ----------------------------------------------------------------------
+uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL(
+ const ::rtl::OUString& aURL,
sal_Int32 nStorageMode,
- const Reference< XMultiServiceFactory >& xFactory )
- throw ( Exception )
+ const uno::Reference< lang::XMultiServiceFactory >& xFactory )
+ throw ( uno::Exception )
{
- Sequence< Any > aArgs( 2 );
+ uno::Sequence< uno::Any > aArgs( 2 );
aArgs[0] <<= aURL;
aArgs[1] <<= nStorageMode;
- Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
- UNO_QUERY );
+ uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
+ uno::UNO_QUERY );
if ( !xTempStorage.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
return xTempStorage;
}
-Reference< XStorage > OStorageHelper::GetStorageFromURL2(
- const OUString& aURL,
+// ----------------------------------------------------------------------
+uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2(
+ const ::rtl::OUString& aURL,
sal_Int32 nStorageMode,
- const Reference< XMultiServiceFactory >& xFactory )
- throw ( Exception )
+ const uno::Reference< lang::XMultiServiceFactory >& xFactory )
+ throw ( uno::Exception )
{
- Sequence< Any > aArgs( 2 );
+ uno::Sequence< uno::Any > aArgs( 2 );
aArgs[0] <<= aURL;
aArgs[1] <<= nStorageMode;
- Reference< XSingleServiceFactory > xFact;
+ uno::Reference< lang::XSingleServiceFactory > xFact;
try {
- ::ucbhelper::Content aCntnt( aURL, Reference< XCommandEnvironment > () );
- if (aCntnt.isDocument())
- {
+ ::ucbhelper::Content aCntnt( aURL,
+ uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
+ if (aCntnt.isDocument()) {
xFact = GetStorageFactory( xFactory );
- }
- else
- {
+ } else {
xFact = GetFileSystemStorageFactory( xFactory );
}
- } catch (Exception &)
- { }
+ } catch (uno::Exception &) { }
- if (!xFact.is()) throw RuntimeException();
+ if (!xFact.is()) throw uno::RuntimeException();
- Reference< XStorage > xTempStorage( xFact->createInstanceWithArguments( aArgs ), UNO_QUERY );
+ uno::Reference< embed::XStorage > xTempStorage(
+ xFact->createInstanceWithArguments( aArgs ), uno::UNO_QUERY );
if ( !xTempStorage.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
return xTempStorage;
}
-Reference< XStorage > OStorageHelper::GetStorageFromInputStream(
- const Reference < XInputStream >& xStream,
- const Reference< XMultiServiceFactory >& xFactory )
- throw ( Exception )
+// ----------------------------------------------------------------------
+uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromInputStream(
+ const uno::Reference < io::XInputStream >& xStream,
+ const uno::Reference< lang::XMultiServiceFactory >& xFactory )
+ throw ( uno::Exception )
{
- Sequence< Any > aArgs( 2 );
+ uno::Sequence< uno::Any > aArgs( 2 );
aArgs[0] <<= xStream;
- aArgs[1] <<= ElementModes::READ;
+ aArgs[1] <<= embed::ElementModes::READ;
- Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), UNO_QUERY );
+ uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
+ uno::UNO_QUERY );
if ( !xTempStorage.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
return xTempStorage;
}
-Reference< XStorage > OStorageHelper::GetStorageFromStream(
- const Reference < XStream >& xStream,
+// ----------------------------------------------------------------------
+uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromStream(
+ const uno::Reference < io::XStream >& xStream,
sal_Int32 nStorageMode,
- const Reference< XMultiServiceFactory >& xFactory )
- throw ( Exception )
+ const uno::Reference< lang::XMultiServiceFactory >& xFactory )
+ throw ( uno::Exception )
{
- Sequence< Any > aArgs( 2 );
+ uno::Sequence< uno::Any > aArgs( 2 );
aArgs[0] <<= xStream;
aArgs[1] <<= nStorageMode;
- Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), UNO_QUERY );
+ uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
+ uno::UNO_QUERY );
if ( !xTempStorage.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
return xTempStorage;
}
+// ----------------------------------------------------------------------
void OStorageHelper::CopyInputToOutput(
- const Reference< XInputStream >& xInput,
- const Reference< XOutputStream >& xOutput )
- throw ( Exception )
+ const uno::Reference< io::XInputStream >& xInput,
+ const uno::Reference< io::XOutputStream >& xOutput )
+ throw ( uno::Exception )
{
static const sal_Int32 nConstBufferSize = 32000;
sal_Int32 nRead;
- Sequence < sal_Int8 > aSequence ( nConstBufferSize );
+ uno::Sequence < sal_Int8 > aSequence ( nConstBufferSize );
do
{
nRead = xInput->readBytes ( aSequence, nConstBufferSize );
if ( nRead < nConstBufferSize )
{
- Sequence < sal_Int8 > aTempBuf ( aSequence.getConstArray(), nRead );
+ uno::Sequence < sal_Int8 > aTempBuf ( aSequence.getConstArray(), nRead );
xOutput->writeBytes ( aTempBuf );
}
else
@@ -219,211 +219,223 @@ void OStorageHelper::CopyInputToOutput(
while ( nRead == nConstBufferSize );
}
-Reference< XInputStream > OStorageHelper::GetInputStreamFromURL(
- const OUString& aURL,
- const Reference< XMultiServiceFactory >& xSF )
- throw ( Exception )
+// ----------------------------------------------------------------------
+uno::Reference< io::XInputStream > OStorageHelper::GetInputStreamFromURL(
+ const ::rtl::OUString& aURL,
+ const uno::Reference< lang::XMultiServiceFactory >& xSF )
+ throw ( uno::Exception )
{
- Reference< XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
+ uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
if ( !xFactory.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
- Reference < XSimpleFileAccess > xTempAccess(
- xFactory->createInstance ( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" )) ),
- UNO_QUERY );
+ uno::Reference < ::com::sun::star::ucb::XSimpleFileAccess > xTempAccess(
+ xFactory->createInstance ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" )) ),
+ uno::UNO_QUERY );
if ( !xTempAccess.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
- Reference< XInputStream > xInputStream = xTempAccess->openFileRead( aURL );
+ uno::Reference< io::XInputStream > xInputStream = xTempAccess->openFileRead( aURL );
if ( !xInputStream.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
return xInputStream;
}
+// ----------------------------------------------------------------------
void OStorageHelper::SetCommonStorageEncryptionData(
- const Reference< XStorage >& xStorage,
- const Sequence< NamedValue >& aEncryptionData )
- throw ( Exception )
+ const uno::Reference< embed::XStorage >& xStorage,
+ const uno::Sequence< beans::NamedValue >& aEncryptionData )
+ throw ( uno::Exception )
{
- Reference< XEncryptionProtectedSource2 > xEncrSet( xStorage, UNO_QUERY );
+ uno::Reference< embed::XEncryptionProtectedSource2 > xEncrSet( xStorage, uno::UNO_QUERY );
if ( !xEncrSet.is() )
- throw IOException(); // TODO
+ throw io::IOException(); // TODO
xEncrSet->setEncryptionData( aEncryptionData );
}
+// ----------------------------------------------------------------------
sal_Int32 OStorageHelper::GetXStorageFormat(
- const Reference< XStorage >& xStorage )
- throw ( Exception )
+ const uno::Reference< embed::XStorage >& xStorage )
+ throw ( uno::Exception )
{
- Reference< XPropertySet > xStorProps( xStorage, UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xStorProps( xStorage, uno::UNO_QUERY_THROW );
- OUString aMediaType;
- xStorProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" )) ) >>= aMediaType;
+ ::rtl::OUString aMediaType;
+ xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" )) ) >>= aMediaType;
sal_Int32 nResult = 0;
// TODO/LATER: the filter configuration could be used to detect it later, or batter a special service
- if ( aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_WRITER_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_WRITER_WEB_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_WRITER_GLOBAL_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_DRAW_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_IMPRESS_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_CALC_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_CHART_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_MATH_ASCII ) )
+ if (
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_WRITER_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_WRITER_WEB_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_WRITER_GLOBAL_ASCII) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_DRAW_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_IMPRESS_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_CALC_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_CHART_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_VND_SUN_XML_MATH_ASCII )
+ )
{
nResult = SOFFICE_FILEFORMAT_60;
}
- else if ( aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_TEXT_WEB_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_TEXT_GLOBAL_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_REPORT_CHART_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_TEXT_TEMPLATE_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_TEMPLATE_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_TEMPLATE_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_TEMPLATE_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_CHART_TEMPLATE_ASCII )
- || aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_TEMPLATE_ASCII ) )
+ else
+ if (
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_TEXT_WEB_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_TEXT_GLOBAL_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_ASCII) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_REPORT_CHART_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_TEXT_TEMPLATE_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_TEMPLATE_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_TEMPLATE_ASCII) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_TEMPLATE_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_CHART_TEMPLATE_ASCII ) ||
+ aMediaType.equalsIgnoreAsciiCaseAscii(MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_TEMPLATE_ASCII )
+ )
{
nResult = SOFFICE_FILEFORMAT_8;
}
else
{
// the mediatype is not known
- throw IllegalTypeException();
+ throw beans::IllegalTypeException();
}
return nResult;
}
-Reference< XStorage > OStorageHelper::GetStorageOfFormatFromURL(
- const OUString& aFormat,
- const OUString& aURL,
+// ----------------------------------------------------------------------
+uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromURL(
+ const ::rtl::OUString& aFormat,
+ const ::rtl::OUString& aURL,
sal_Int32 nStorageMode,
- const Reference< XMultiServiceFactory >& xFactory,
+ const uno::Reference< lang::XMultiServiceFactory >& xFactory,
sal_Bool bRepairStorage )
- throw ( Exception )
+ throw ( uno::Exception )
{
- Sequence< PropertyValue > aProps( 1 );
- aProps[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
+ uno::Sequence< beans::PropertyValue > aProps( 1 );
+ aProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
aProps[0].Value <<= aFormat;
-
if ( bRepairStorage )
{
aProps.realloc( 2 );
- aProps[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
+ aProps[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
aProps[1].Value <<= bRepairStorage;
}
- Sequence< Any > aArgs( 3 );
+ uno::Sequence< uno::Any > aArgs( 3 );
aArgs[0] <<= aURL;
aArgs[1] <<= nStorageMode;
aArgs[2] <<= aProps;
- Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), UNO_QUERY );
+ uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
+ uno::UNO_QUERY );
if ( !xTempStorage.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
return xTempStorage;
}
-Reference< XStorage > OStorageHelper::GetStorageOfFormatFromInputStream(
- const OUString& aFormat,
- const Reference < XInputStream >& xStream,
- const Reference< XMultiServiceFactory >& xFactory,
+// ----------------------------------------------------------------------
+uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromInputStream(
+ const ::rtl::OUString& aFormat,
+ const uno::Reference < io::XInputStream >& xStream,
+ const uno::Reference< lang::XMultiServiceFactory >& xFactory,
sal_Bool bRepairStorage )
- throw ( Exception )
+ throw ( uno::Exception )
{
- Sequence< PropertyValue > aProps( 1 );
- aProps[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
+ uno::Sequence< beans::PropertyValue > aProps( 1 );
+ aProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
aProps[0].Value <<= aFormat;
-
if ( bRepairStorage )
{
aProps.realloc( 2 );
- aProps[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
+ aProps[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
aProps[1].Value <<= bRepairStorage;
}
- Sequence< Any > aArgs( 3 );
+ uno::Sequence< uno::Any > aArgs( 3 );
aArgs[0] <<= xStream;
- aArgs[1] <<= ElementModes::READ;
+ aArgs[1] <<= embed::ElementModes::READ;
aArgs[2] <<= aProps;
- Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), UNO_QUERY );
+ uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
+ uno::UNO_QUERY );
if ( !xTempStorage.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
return xTempStorage;
}
-Reference< XStorage > OStorageHelper::GetStorageOfFormatFromStream(
- const OUString& aFormat,
- const Reference < XStream >& xStream,
+// ----------------------------------------------------------------------
+uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromStream(
+ const ::rtl::OUString& aFormat,
+ const uno::Reference < io::XStream >& xStream,
sal_Int32 nStorageMode,
- const Reference< XMultiServiceFactory >& xFactory,
+ const uno::Reference< lang::XMultiServiceFactory >& xFactory,
sal_Bool bRepairStorage )
- throw ( Exception )
+ throw ( uno::Exception )
{
- Sequence< PropertyValue > aProps( 1 );
- aProps[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
+ uno::Sequence< beans::PropertyValue > aProps( 1 );
+ aProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
aProps[0].Value <<= aFormat;
-
if ( bRepairStorage )
{
aProps.realloc( 2 );
- aProps[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
+ aProps[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
aProps[1].Value <<= bRepairStorage;
}
- Sequence< Any > aArgs( 3 );
+ uno::Sequence< uno::Any > aArgs( 3 );
aArgs[0] <<= xStream;
aArgs[1] <<= nStorageMode;
aArgs[2] <<= aProps;
- Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), UNO_QUERY );
+ uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
+ uno::UNO_QUERY );
if ( !xTempStorage.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
return xTempStorage;
}
-Sequence< NamedValue > OStorageHelper::CreatePackageEncryptionData( const OUString& aPassword, const Reference< XMultiServiceFactory >& xSF )
+// ----------------------------------------------------------------------
+uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData( const ::rtl::OUString& aPassword, const uno::Reference< lang::XMultiServiceFactory >& xSF )
{
// TODO/LATER: Should not the method be part of DocPasswordHelper?
- Sequence< NamedValue > aEncryptionData;
+ uno::Sequence< beans::NamedValue > aEncryptionData;
if ( !aPassword.isEmpty() )
{
sal_Int32 nSha1Ind = 0;
// generate SHA256 start key
try
{
- Reference< XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
+ uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
if ( !xFactory.is() )
- throw RuntimeException();
+ throw uno::RuntimeException();
- Reference< XDigestContextSupplier > xDigestContextSupplier( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.crypto.NSSInitializer" ) ) ), UNO_QUERY_THROW );
- Reference< XDigestContext > xDigestContext( xDigestContextSupplier->getDigestContext( DigestID::SHA256, Sequence< NamedValue >() ), UNO_SET_THROW );
+ uno::Reference< xml::crypto::XDigestContextSupplier > xDigestContextSupplier( xFactory->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.crypto.NSSInitializer" ) ) ), uno::UNO_QUERY_THROW );
+ uno::Reference< xml::crypto::XDigestContext > xDigestContext( xDigestContextSupplier->getDigestContext( xml::crypto::DigestID::SHA256, uno::Sequence< beans::NamedValue >() ), uno::UNO_SET_THROW );
- OString aUTF8Password( OUStringToOString( aPassword, RTL_TEXTENCODING_UTF8 ) );
- xDigestContext->updateDigest( Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aUTF8Password.getStr() ), aUTF8Password.getLength() ) );
- Sequence< sal_Int8 > aDigest = xDigestContext->finalizeDigestAndDispose();
+ ::rtl::OString aUTF8Password( ::rtl::OUStringToOString( aPassword, RTL_TEXTENCODING_UTF8 ) );
+ xDigestContext->updateDigest( uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aUTF8Password.getStr() ), aUTF8Password.getLength() ) );
+ uno::Sequence< sal_Int8 > aDigest = xDigestContext->finalizeDigestAndDispose();
aEncryptionData.realloc( ++nSha1Ind );
aEncryptionData[0].Name = PACKAGE_ENCRYPTIONDATA_SHA256UTF8;
aEncryptionData[0].Value <<= aDigest;
}
- catch ( Exception& )
+ catch ( uno::Exception& )
{
OSL_ENSURE( false, "Can not create SHA256 digest!" );
}
@@ -439,7 +451,7 @@ Sequence< NamedValue > OStorageHelper::CreatePackageEncryptionData( const OUStri
for ( sal_Int32 nInd = 0; nInd < 2; nInd++ )
{
- OString aByteStrPass = OUStringToOString( aPassword, pEncoding[nInd] );
+ ::rtl::OString aByteStrPass = ::rtl::OUStringToOString( aPassword, pEncoding[nInd] );
sal_uInt8 pBuffer[RTL_DIGEST_LENGTH_SHA1];
rtlDigestError nError = rtl_digest_SHA1( aByteStrPass.getStr(),
@@ -453,18 +465,20 @@ Sequence< NamedValue > OStorageHelper::CreatePackageEncryptionData( const OUStri
break;
}
- aEncryptionData[nSha1Ind+nInd].Value <<= Sequence< sal_Int8 >( (sal_Int8*)pBuffer, RTL_DIGEST_LENGTH_SHA1 );
+ aEncryptionData[nSha1Ind+nInd].Value <<= uno::Sequence< sal_Int8 >( (sal_Int8*)pBuffer, RTL_DIGEST_LENGTH_SHA1 );
}
}
return aEncryptionData;
}
-sal_Bool OStorageHelper::IsValidZipEntryFileName( const OUString& aName, sal_Bool bSlashAllowed )
+// ----------------------------------------------------------------------
+sal_Bool OStorageHelper::IsValidZipEntryFileName( const ::rtl::OUString& aName, sal_Bool bSlashAllowed )
{
return IsValidZipEntryFileName( aName.getStr(), aName.getLength(), bSlashAllowed );
}
+// ----------------------------------------------------------------------
sal_Bool OStorageHelper::IsValidZipEntryFileName(
const sal_Unicode *pChar, sal_Int32 nLength, sal_Bool bSlashAllowed )
{
@@ -492,7 +506,8 @@ sal_Bool OStorageHelper::IsValidZipEntryFileName(
return sal_True;
}
-sal_Bool OStorageHelper::PathHasSegment( const OUString& aPath, const OUString& aSegment )
+// ----------------------------------------------------------------------
+sal_Bool OStorageHelper::PathHasSegment( const ::rtl::OUString& aPath, const ::rtl::OUString& aSegment )
{
sal_Bool bResult = sal_False;
const sal_Int32 nPathLen = aPath.getLength();
@@ -500,11 +515,11 @@ sal_Bool OStorageHelper::PathHasSegment( const OUString& aPath, const OUString&
if ( !aSegment.isEmpty() && nPathLen >= nSegLen )
{
- OUString aEndSegment( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+ ::rtl::OUString aEndSegment( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
aEndSegment += aSegment;
- OUString aInternalSegment( aEndSegment );
- aInternalSegment += OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+ ::rtl::OUString aInternalSegment( aEndSegment );
+ aInternalSegment += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
if ( aPath.indexOf( aInternalSegment ) >= 0 )
bResult = sal_True;
@@ -522,85 +537,89 @@ sal_Bool OStorageHelper::PathHasSegment( const OUString& aPath, const OUString&
return bResult;
}
-class LifecycleProxy::Impl : public std::vector< Reference< XStorage > > {};
+class LifecycleProxy::Impl
+ : public std::vector< uno::Reference< embed::XStorage > > {};
+LifecycleProxy::LifecycleProxy()
+ : m_pBadness( new Impl() ) { }
+LifecycleProxy::~LifecycleProxy() { }
- LifecycleProxy::LifecycleProxy() : m_pBadness( new Impl() ) { }
- LifecycleProxy::~LifecycleProxy() { }
-
- void LifecycleProxy::commitStorages()
+void LifecycleProxy::commitStorages()
+{
+ for (Impl::reverse_iterator iter = m_pBadness->rbegin();
+ iter != m_pBadness->rend(); ++iter) // reverse order (outwards)
{
- for (Impl::reverse_iterator iter = m_pBadness->rbegin();
- iter != m_pBadness->rend(); ++iter) // reverse order (outwards)
+ uno::Reference<embed::XTransactedObject> const xTransaction(*iter,
+ uno::UNO_QUERY);
+ if (xTransaction.is())
{
- Reference<XTransactedObject> const xTransaction(*iter, UNO_QUERY);
- if (xTransaction.is())
- xTransaction->commit();
+ xTransaction->commit();
}
}
+}
- static void splitPath( std::vector<OUString> &rElems,
- const OUString& rPath )
- {
- for (sal_Int32 i = 0; i >= 0;)
- rElems.push_back( rPath.getToken( 0, '/', i ) );
- }
+static void splitPath( std::vector<rtl::OUString> &rElems,
+ const ::rtl::OUString& rPath )
+{
+ for (sal_Int32 i = 0; i >= 0;)
+ rElems.push_back( rPath.getToken( 0, '/', i ) );
+}
- static Reference< XStorage > LookupStorageAtPath(
- const Reference< XStorage > &xParentStorage,
- std::vector<OUString> &rElems, sal_uInt32 nOpenMode,
- LifecycleProxy &rNastiness )
+static uno::Reference< embed::XStorage > LookupStorageAtPath(
+ const uno::Reference< embed::XStorage > &xParentStorage,
+ std::vector<rtl::OUString> &rElems, sal_uInt32 nOpenMode,
+ LifecycleProxy &rNastiness )
+{
+ uno::Reference< embed::XStorage > xStorage( xParentStorage );
+ rNastiness.m_pBadness->push_back( xStorage );
+ for( size_t i = 0; i < rElems.size() && xStorage.is(); i++ )
{
- Reference< XStorage > xStorage( xParentStorage );
+ xStorage = xStorage->openStorageElement( rElems[i], nOpenMode );
rNastiness.m_pBadness->push_back( xStorage );
- for( size_t i = 0; i < rElems.size() && xStorage.is(); i++ )
- {
- xStorage = xStorage->openStorageElement( rElems[i], nOpenMode );
- rNastiness.m_pBadness->push_back( xStorage );
- }
- return xStorage;
}
+ return xStorage;
+}
- Reference< XStorage > OStorageHelper::GetStorageAtPath(
- const Reference< XStorage > &xStorage,
- const OUString& rPath, sal_uInt32 nOpenMode,
- LifecycleProxy &rNastiness )
- {
- std::vector<OUString> aElems;
- splitPath( aElems, rPath );
- return LookupStorageAtPath( xStorage, aElems, nOpenMode, rNastiness );
- }
+uno::Reference< embed::XStorage > OStorageHelper::GetStorageAtPath(
+ const uno::Reference< embed::XStorage > &xStorage,
+ const ::rtl::OUString& rPath, sal_uInt32 nOpenMode,
+ LifecycleProxy &rNastiness )
+{
+ std::vector<rtl::OUString> aElems;
+ splitPath( aElems, rPath );
+ return LookupStorageAtPath( xStorage, aElems, nOpenMode, rNastiness );
+}
- Reference< XStream > OStorageHelper::GetStreamAtPath(
- const Reference< XStorage > &xParentStorage,
- const OUString& rPath, sal_uInt32 nOpenMode,
- LifecycleProxy &rNastiness )
- {
- std::vector<OUString> aElems;
- splitPath( aElems, rPath );
- OUString aName( aElems.back() );
- aElems.pop_back();
- sal_uInt32 nStorageMode = nOpenMode & ~ElementModes::TRUNCATE;
- Reference< XStorage > xStorage(
- LookupStorageAtPath( xParentStorage, aElems, nStorageMode, rNastiness ),
- UNO_QUERY_THROW );
- return xStorage->openStreamElement( aName, nOpenMode );
- }
+uno::Reference< io::XStream > OStorageHelper::GetStreamAtPath(
+ const uno::Reference< embed::XStorage > &xParentStorage,
+ const ::rtl::OUString& rPath, sal_uInt32 nOpenMode,
+ LifecycleProxy &rNastiness )
+{
+ std::vector<rtl::OUString> aElems;
+ splitPath( aElems, rPath );
+ rtl::OUString aName( aElems.back() );
+ aElems.pop_back();
+ sal_uInt32 nStorageMode = nOpenMode & ~embed::ElementModes::TRUNCATE;
+ uno::Reference< embed::XStorage > xStorage(
+ LookupStorageAtPath( xParentStorage, aElems, nStorageMode, rNastiness ),
+ uno::UNO_QUERY_THROW );
+ return xStorage->openStreamElement( aName, nOpenMode );
+}
- Reference< XStream > OStorageHelper::GetStreamAtPackageURL(
- Reference< XStorage > const& xParentStorage,
- const OUString& rURL, sal_uInt32 const nOpenMode,
- LifecycleProxy & rNastiness)
+uno::Reference< io::XStream > OStorageHelper::GetStreamAtPackageURL(
+ uno::Reference< embed::XStorage > const& xParentStorage,
+ const ::rtl::OUString& rURL, sal_uInt32 const nOpenMode,
+ LifecycleProxy & rNastiness)
+{
+ static char const s_PkgScheme[] = "vnd.sun.star.Package:";
+ if (0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
+ rURL.getStr(), rURL.getLength(),
+ s_PkgScheme, SAL_N_ELEMENTS(s_PkgScheme) - 1))
{
- static char const s_PkgScheme[] = "vnd.sun.star.Package:";
- if (0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
- rURL.getStr(), rURL.getLength(),
- s_PkgScheme, SAL_N_ELEMENTS(s_PkgScheme) - 1))
- {
- OUString const path(rURL.copy(SAL_N_ELEMENTS(s_PkgScheme)-1));
- return GetStreamAtPath(xParentStorage, path, nOpenMode, rNastiness);
- }
- return 0;
+ ::rtl::OUString const path(rURL.copy(SAL_N_ELEMENTS(s_PkgScheme)-1));
+ return GetStreamAtPath(xParentStorage, path, nOpenMode, rNastiness);
}
+ return 0;
+}
}