summaryrefslogtreecommitdiffstats
path: root/comphelper
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2012-08-16 19:05:36 +0200
committerTomaž Vajngerl <quikee@gmail.com>2012-08-16 20:47:15 +0200
commit72777a66bb8d9e71c4786c282c7971d7ededa729 (patch)
tree8a69a5cc936a7e215a1ea9699ab26916b5da1b2c /comphelper
parentmake buttons wider (diff)
downloadcore-72777a66bb8d9e71c4786c282c7971d7ededa729.tar.gz
core-72777a66bb8d9e71c4786c282c7971d7ededa729.zip
Cleanup comphelper::storagehelper
Change-Id: I04313cf4235ce3db20ff340474691435e9b440b6
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/inc/comphelper/storagehelper.hxx177
-rw-r--r--comphelper/source/misc/storagehelper.cxx511
2 files changed, 332 insertions, 356 deletions
diff --git a/comphelper/inc/comphelper/storagehelper.hxx b/comphelper/inc/comphelper/storagehelper.hxx
index f255dc842fb5..5e4916ef4e2b 100644
--- a/comphelper/inc/comphelper/storagehelper.hxx
+++ b/comphelper/inc/comphelper/storagehelper.hxx
@@ -33,14 +33,20 @@
#include <com/sun/star/io/XStream.hpp>
#include "comphelper/comphelperdllapi.h"
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::embed;
+using namespace com::sun::star::io;
+using namespace com::sun::star::beans;
+using rtl::OUString;
-#define PACKAGE_STORAGE_FORMAT_STRING ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageFormat" ) )
-#define ZIP_STORAGE_FORMAT_STRING ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ZipFormat" ) )
-#define OFOPXML_STORAGE_FORMAT_STRING ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OFOPXMLFormat" ) )
+#define PACKAGE_STORAGE_FORMAT_STRING OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageFormat" ) )
+#define ZIP_STORAGE_FORMAT_STRING OUString( RTL_CONSTASCII_USTRINGPARAM( "ZipFormat" ) )
+#define OFOPXML_STORAGE_FORMAT_STRING OUString( RTL_CONSTASCII_USTRINGPARAM( "OFOPXMLFormat" ) )
-#define PACKAGE_ENCRYPTIONDATA_SHA256UTF8 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA256UTF8EncryptionKey" ) )
-#define PACKAGE_ENCRYPTIONDATA_SHA1UTF8 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA1UTF8EncryptionKey" ) )
-#define PACKAGE_ENCRYPTIONDATA_SHA1MS1252 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA1MS1252EncryptionKey" ) )
+#define PACKAGE_ENCRYPTIONDATA_SHA256UTF8 OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA256UTF8EncryptionKey" ) )
+#define PACKAGE_ENCRYPTIONDATA_SHA1UTF8 OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA1UTF8EncryptionKey" ) )
+#define PACKAGE_ENCRYPTIONDATA_SHA1MS1252 OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA1MS1252EncryptionKey" ) )
namespace comphelper {
@@ -63,131 +69,120 @@ public:
class COMPHELPER_DLLPUBLIC OStorageHelper
{
public:
- static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >
+ static Reference< XSingleServiceFactory >
GetStorageFactory(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSF
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
- throw ( ::com::sun::star::uno::Exception );
+ const Reference< XMultiServiceFactory >& xSF = Reference< XMultiServiceFactory >() )
+ throw ( Exception );
- static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >
+ static Reference< XSingleServiceFactory >
GetFileSystemStorageFactory(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSF
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
- throw ( ::com::sun::star::uno::Exception );
+ const Reference< XMultiServiceFactory >& xSF = Reference< XMultiServiceFactory >() )
+ throw ( Exception );
- static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ static Reference< XStorage >
GetTemporaryStorage(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
- throw ( ::com::sun::star::uno::Exception );
+ const Reference< XMultiServiceFactory >& xFactory = Reference< XMultiServiceFactory >() )
+ throw ( Exception );
- /// this one will only return Storage
- static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ // this one will only return Storage
+ static Reference< XStorage >
GetStorageFromURL(
- const ::rtl::OUString& aURL,
- sal_Int32 nStorageMode,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
- throw ( ::com::sun::star::uno::Exception );
+ const OUString& aURL, sal_Int32 nStorageMode,
+ const Reference< XMultiServiceFactory >& xFactory = Reference< XMultiServiceFactory >() )
+ throw ( Exception );
- /// this one will return either Storage or FileSystemStorage
- static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ // this one will return either Storage or FileSystemStorage
+ static Reference< XStorage >
GetStorageFromURL2(
- const ::rtl::OUString& aURL,
- sal_Int32 nStorageMode,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
-
- throw ( ::com::sun::star::uno::Exception );
+ const OUString& aURL, sal_Int32 nStorageMode,
+ const Reference< XMultiServiceFactory >& xFactory = Reference< XMultiServiceFactory >() )
+ throw ( Exception );
- static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ static Reference< XStorage >
GetStorageFromInputStream(
- const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xStream,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
- throw ( ::com::sun::star::uno::Exception );
+ const Reference < XInputStream >& xStream,
+ const Reference< XMultiServiceFactory >& xFactory = Reference< XMultiServiceFactory >() )
+ throw ( Exception );
- static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ static Reference< XStorage >
GetStorageFromStream(
- const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xStream,
- sal_Int32 nStorageMode = ::com::sun::star::embed::ElementModes::READWRITE,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
- throw ( ::com::sun::star::uno::Exception );
+ const Reference < XStream >& xStream,
+ sal_Int32 nStorageMode = ElementModes::READWRITE,
+ const Reference< XMultiServiceFactory >& xFactory = Reference< XMultiServiceFactory >() )
+ throw ( Exception );
static void CopyInputToOutput(
- const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput,
- const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput )
- throw ( ::com::sun::star::uno::Exception );
+ const Reference< XInputStream >& xInput,
+ const Reference< XOutputStream >& xOutput )
+ throw ( Exception );
- static ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
+ static Reference< XInputStream >
GetInputStreamFromURL(
- const ::rtl::OUString& aURL,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
- throw ( ::com::sun::star::uno::Exception );
+ const OUString& aURL,
+ const Reference< XMultiServiceFactory >& xFactory = Reference< XMultiServiceFactory >() )
+ throw ( Exception );
static void SetCommonStorageEncryptionData(
- const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aEncryptionData )
- throw ( ::com::sun::star::uno::Exception );
+ const Reference< XStorage >& xStorage,
+ const Sequence< NamedValue >& aEncryptionData )
+ throw ( Exception );
// the following method supports only storages of OOo formats
static sal_Int32 GetXStorageFormat(
- const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
- throw ( ::com::sun::star::uno::Exception );
+ const Reference< XStorage >& xStorage )
+ throw ( Exception );
- static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ static Reference< XStorage >
GetStorageOfFormatFromURL(
- const ::rtl::OUString& aFormat,
- const ::rtl::OUString& aURL,
+ const OUString& aFormat,
+ const OUString& aURL,
sal_Int32 nStorageMode,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >(),
+ const Reference< XMultiServiceFactory >& xFactory
+ = Reference< XMultiServiceFactory >(),
sal_Bool bRepairStorage = sal_False )
- throw ( ::com::sun::star::uno::Exception );
+ throw ( Exception );
- static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ static Reference< XStorage >
GetStorageOfFormatFromInputStream(
- const ::rtl::OUString& aFormat,
- const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xStream,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >(),
+ const OUString& aFormat,
+ const Reference < XInputStream >& xStream,
+ const Reference< XMultiServiceFactory >& xFactory
+ = Reference< XMultiServiceFactory >(),
sal_Bool bRepairStorage = sal_False )
- throw ( ::com::sun::star::uno::Exception );
+ throw ( Exception );
- static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ static Reference< XStorage >
GetStorageOfFormatFromStream(
- const ::rtl::OUString& aFormat,
- const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xStream,
- sal_Int32 nStorageMode = ::com::sun::star::embed::ElementModes::READWRITE,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >(),
+ const OUString& aFormat,
+ const Reference < XStream >& xStream,
+ sal_Int32 nStorageMode = ElementModes::READWRITE,
+ const Reference< XMultiServiceFactory >& xFactory = Reference< XMultiServiceFactory >(),
sal_Bool bRepairStorage = sal_False )
- throw ( ::com::sun::star::uno::Exception );
+ throw ( Exception );
- static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >
+ static Sequence< NamedValue >
CreatePackageEncryptionData(
- const ::rtl::OUString& aPassword,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSF
- = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() );
+ const OUString& aPassword,
+ const Reference< XMultiServiceFactory >& xSF = Reference< XMultiServiceFactory >() );
- static sal_Bool IsValidZipEntryFileName( const ::rtl::OUString& aName, sal_Bool bSlashAllowed );
+ static sal_Bool IsValidZipEntryFileName( const OUString& aName, sal_Bool bSlashAllowed );
static sal_Bool IsValidZipEntryFileName( const sal_Unicode *pChar, sal_Int32 nLength, sal_Bool bSlashAllowed );
- static sal_Bool PathHasSegment( const ::rtl::OUString& aPath, const ::rtl::OUString& aSegment );
+ static sal_Bool PathHasSegment( const OUString& aPath, const OUString& aSegment );
// Methods to allow easy use of hierachical names inside storages
- static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetStorageAtPath(
- const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > &xStorage,
- const ::rtl::OUString& aPath, sal_uInt32 nOpenMode, LifecycleProxy &rNastiness );
- static ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetStreamAtPath(
- const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > &xStorage,
- const ::rtl::OUString& aPath, sal_uInt32 nOpenMode, LifecycleProxy &rNastiness );
- static ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetStreamAtPackageURL(
- const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > &xStorage,
- const ::rtl::OUString& rURL, sal_uInt32 const nOpenMode,
+ static Reference< XStorage > GetStorageAtPath(
+ const Reference< XStorage > &xStorage,
+ const OUString& aPath, sal_uInt32 nOpenMode, LifecycleProxy &rNastiness );
+
+ static Reference< XStream > GetStreamAtPath(
+ const Reference< XStorage > &xStorage,
+ const OUString& aPath, sal_uInt32 nOpenMode, LifecycleProxy &rNastiness );
+
+ static Reference< XStream > GetStreamAtPackageURL(
+ const Reference< XStorage > &xStorage,
+ const OUString& rURL, sal_uInt32 const nOpenMode,
LifecycleProxy & rNastiness );
};
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index d43e68943855..a339589aa02e 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 namespace ::com::sun::star;
+using rtl::OUString;
+using rtl::OString;
namespace comphelper {
-// ----------------------------------------------------------------------
-uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetStorageFactory(
- const uno::Reference< lang::XMultiServiceFactory >& xSF )
- throw ( uno::Exception )
+Reference< XSingleServiceFactory >
+ OStorageHelper::GetStorageFactory(const Reference< XMultiServiceFactory >& xSF )
+ throw ( Exception )
{
- uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
+ Reference< XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
if ( !xFactory.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
- rtl::OUString sService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory"));
+ OUString sService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory"));
- uno::Reference < lang::XSingleServiceFactory > xStorageFactory(
- xFactory->createInstance(sService), uno::UNO_QUERY);
+ Reference < XSingleServiceFactory > xStorageFactory(
+ xFactory->createInstance(sService), UNO_QUERY);
if ( !xStorageFactory.is() )
{
- throw uno::RuntimeException(rtl::OUString(
+ throw RuntimeException(OUString(
RTL_CONSTASCII_USTRINGPARAM("Could not load: ")) + sService,
- uno::Reference< uno::XInterface >());
+ Reference< XInterface >());
}
return xStorageFactory;
}
-// ----------------------------------------------------------------------
-uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetFileSystemStorageFactory(
- const uno::Reference< lang::XMultiServiceFactory >& xSF )
- throw ( uno::Exception )
+Reference< XSingleServiceFactory > OStorageHelper::GetFileSystemStorageFactory(
+ const Reference< XMultiServiceFactory >& xSF )
+ throw ( Exception )
{
- uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
+ Reference< XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
if ( !xFactory.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
- rtl::OUString sService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.FileSystemStorageFactory"));
+ OUString sService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.FileSystemStorageFactory"));
- uno::Reference < lang::XSingleServiceFactory > xStorageFactory(
- xFactory->createInstance(sService), uno::UNO_QUERY);
+ Reference < XSingleServiceFactory > xStorageFactory(
+ xFactory->createInstance(sService), UNO_QUERY);
if ( !xStorageFactory.is() )
{
- throw uno::RuntimeException(rtl::OUString(
+ throw RuntimeException(OUString(
RTL_CONSTASCII_USTRINGPARAM("Could not load: ")) + sService,
- uno::Reference< uno::XInterface >());
+ Reference< XInterface >());
}
return xStorageFactory;
}
-// ----------------------------------------------------------------------
-uno::Reference< embed::XStorage > OStorageHelper::GetTemporaryStorage(
- const uno::Reference< lang::XMultiServiceFactory >& xFactory )
- throw ( uno::Exception )
+Reference< XStorage > OStorageHelper::GetTemporaryStorage(
+ const Reference< XMultiServiceFactory >& xFactory )
+ throw ( Exception )
{
- uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstance(),
- uno::UNO_QUERY );
+ Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstance(),
+ UNO_QUERY );
if ( !xTempStorage.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
return xTempStorage;
}
-// ----------------------------------------------------------------------
-uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL(
- const ::rtl::OUString& aURL,
+Reference< XStorage > OStorageHelper::GetStorageFromURL(
+ const OUString& aURL,
sal_Int32 nStorageMode,
- const uno::Reference< lang::XMultiServiceFactory >& xFactory )
- throw ( uno::Exception )
+ const Reference< XMultiServiceFactory >& xFactory )
+ throw ( Exception )
{
- uno::Sequence< uno::Any > aArgs( 2 );
+ Sequence< Any > aArgs( 2 );
aArgs[0] <<= aURL;
aArgs[1] <<= nStorageMode;
- uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
- uno::UNO_QUERY );
+ Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
+ UNO_QUERY );
if ( !xTempStorage.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
return xTempStorage;
}
-// ----------------------------------------------------------------------
-uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2(
- const ::rtl::OUString& aURL,
+Reference< XStorage > OStorageHelper::GetStorageFromURL2(
+ const OUString& aURL,
sal_Int32 nStorageMode,
- const uno::Reference< lang::XMultiServiceFactory >& xFactory )
- throw ( uno::Exception )
+ const Reference< XMultiServiceFactory >& xFactory )
+ throw ( Exception )
{
- uno::Sequence< uno::Any > aArgs( 2 );
+ Sequence< Any > aArgs( 2 );
aArgs[0] <<= aURL;
aArgs[1] <<= nStorageMode;
- uno::Reference< lang::XSingleServiceFactory > xFact;
+ Reference< XSingleServiceFactory > xFact;
try {
- ::ucbhelper::Content aCntnt( aURL,
- uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
- if (aCntnt.isDocument()) {
+ ::ucbhelper::Content aCntnt( aURL, Reference< XCommandEnvironment > () );
+ if (aCntnt.isDocument())
+ {
xFact = GetStorageFactory( xFactory );
- } else {
+ }
+ else
+ {
xFact = GetFileSystemStorageFactory( xFactory );
}
- } catch (uno::Exception &) { }
+ } catch (Exception &)
+ { }
- if (!xFact.is()) throw uno::RuntimeException();
+ if (!xFact.is()) throw RuntimeException();
- uno::Reference< embed::XStorage > xTempStorage(
- xFact->createInstanceWithArguments( aArgs ), uno::UNO_QUERY );
+ Reference< XStorage > xTempStorage( xFact->createInstanceWithArguments( aArgs ), UNO_QUERY );
if ( !xTempStorage.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
return xTempStorage;
}
-// ----------------------------------------------------------------------
-uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromInputStream(
- const uno::Reference < io::XInputStream >& xStream,
- const uno::Reference< lang::XMultiServiceFactory >& xFactory )
- throw ( uno::Exception )
+Reference< XStorage > OStorageHelper::GetStorageFromInputStream(
+ const Reference < XInputStream >& xStream,
+ const Reference< XMultiServiceFactory >& xFactory )
+ throw ( Exception )
{
- uno::Sequence< uno::Any > aArgs( 2 );
+ Sequence< Any > aArgs( 2 );
aArgs[0] <<= xStream;
- aArgs[1] <<= embed::ElementModes::READ;
+ aArgs[1] <<= ElementModes::READ;
- uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
- uno::UNO_QUERY );
+ Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), UNO_QUERY );
if ( !xTempStorage.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
return xTempStorage;
}
-// ----------------------------------------------------------------------
-uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromStream(
- const uno::Reference < io::XStream >& xStream,
+Reference< XStorage > OStorageHelper::GetStorageFromStream(
+ const Reference < XStream >& xStream,
sal_Int32 nStorageMode,
- const uno::Reference< lang::XMultiServiceFactory >& xFactory )
- throw ( uno::Exception )
+ const Reference< XMultiServiceFactory >& xFactory )
+ throw ( Exception )
{
- uno::Sequence< uno::Any > aArgs( 2 );
+ Sequence< Any > aArgs( 2 );
aArgs[0] <<= xStream;
aArgs[1] <<= nStorageMode;
- uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
- uno::UNO_QUERY );
+ Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), UNO_QUERY );
if ( !xTempStorage.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
return xTempStorage;
}
-// ----------------------------------------------------------------------
void OStorageHelper::CopyInputToOutput(
- const uno::Reference< io::XInputStream >& xInput,
- const uno::Reference< io::XOutputStream >& xOutput )
- throw ( uno::Exception )
+ const Reference< XInputStream >& xInput,
+ const Reference< XOutputStream >& xOutput )
+ throw ( Exception )
{
static const sal_Int32 nConstBufferSize = 32000;
sal_Int32 nRead;
- uno::Sequence < sal_Int8 > aSequence ( nConstBufferSize );
+ Sequence < sal_Int8 > aSequence ( nConstBufferSize );
do
{
nRead = xInput->readBytes ( aSequence, nConstBufferSize );
if ( nRead < nConstBufferSize )
{
- uno::Sequence < sal_Int8 > aTempBuf ( aSequence.getConstArray(), nRead );
+ Sequence < sal_Int8 > aTempBuf ( aSequence.getConstArray(), nRead );
xOutput->writeBytes ( aTempBuf );
}
else
@@ -219,223 +219,211 @@ void OStorageHelper::CopyInputToOutput(
while ( nRead == nConstBufferSize );
}
-// ----------------------------------------------------------------------
-uno::Reference< io::XInputStream > OStorageHelper::GetInputStreamFromURL(
- const ::rtl::OUString& aURL,
- const uno::Reference< lang::XMultiServiceFactory >& xSF )
- throw ( uno::Exception )
+Reference< XInputStream > OStorageHelper::GetInputStreamFromURL(
+ const OUString& aURL,
+ const Reference< XMultiServiceFactory >& xSF )
+ throw ( Exception )
{
- uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
+ Reference< XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
if ( !xFactory.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
- uno::Reference < ::com::sun::star::ucb::XSimpleFileAccess > xTempAccess(
- xFactory->createInstance ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" )) ),
- uno::UNO_QUERY );
+ Reference < XSimpleFileAccess > xTempAccess(
+ xFactory->createInstance ( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" )) ),
+ UNO_QUERY );
if ( !xTempAccess.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
- uno::Reference< io::XInputStream > xInputStream = xTempAccess->openFileRead( aURL );
+ Reference< XInputStream > xInputStream = xTempAccess->openFileRead( aURL );
if ( !xInputStream.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
return xInputStream;
}
-// ----------------------------------------------------------------------
void OStorageHelper::SetCommonStorageEncryptionData(
- const uno::Reference< embed::XStorage >& xStorage,
- const uno::Sequence< beans::NamedValue >& aEncryptionData )
- throw ( uno::Exception )
+ const Reference< XStorage >& xStorage,
+ const Sequence< NamedValue >& aEncryptionData )
+ throw ( Exception )
{
- uno::Reference< embed::XEncryptionProtectedSource2 > xEncrSet( xStorage, uno::UNO_QUERY );
+ Reference< XEncryptionProtectedSource2 > xEncrSet( xStorage, UNO_QUERY );
if ( !xEncrSet.is() )
- throw io::IOException(); // TODO
+ throw IOException(); // TODO
xEncrSet->setEncryptionData( aEncryptionData );
}
-// ----------------------------------------------------------------------
sal_Int32 OStorageHelper::GetXStorageFormat(
- const uno::Reference< embed::XStorage >& xStorage )
- throw ( uno::Exception )
+ const Reference< XStorage >& xStorage )
+ throw ( Exception )
{
- uno::Reference< beans::XPropertySet > xStorProps( xStorage, uno::UNO_QUERY_THROW );
+ Reference< XPropertySet > xStorProps( xStorage, UNO_QUERY_THROW );
- ::rtl::OUString aMediaType;
- xStorProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" )) ) >>= aMediaType;
+ OUString aMediaType;
+ xStorProps->getPropertyValue( 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 beans::IllegalTypeException();
+ throw IllegalTypeException();
}
return nResult;
}
-// ----------------------------------------------------------------------
-uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromURL(
- const ::rtl::OUString& aFormat,
- const ::rtl::OUString& aURL,
+Reference< XStorage > OStorageHelper::GetStorageOfFormatFromURL(
+ const OUString& aFormat,
+ const OUString& aURL,
sal_Int32 nStorageMode,
- const uno::Reference< lang::XMultiServiceFactory >& xFactory,
+ const Reference< XMultiServiceFactory >& xFactory,
sal_Bool bRepairStorage )
- throw ( uno::Exception )
+ throw ( Exception )
{
- uno::Sequence< beans::PropertyValue > aProps( 1 );
- aProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
+ Sequence< PropertyValue > aProps( 1 );
+ aProps[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
aProps[0].Value <<= aFormat;
+
if ( bRepairStorage )
{
aProps.realloc( 2 );
- aProps[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
+ aProps[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
aProps[1].Value <<= bRepairStorage;
}
- uno::Sequence< uno::Any > aArgs( 3 );
+ Sequence< Any > aArgs( 3 );
aArgs[0] <<= aURL;
aArgs[1] <<= nStorageMode;
aArgs[2] <<= aProps;
- uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
- uno::UNO_QUERY );
+ Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), UNO_QUERY );
if ( !xTempStorage.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
return xTempStorage;
}
-// ----------------------------------------------------------------------
-uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromInputStream(
- const ::rtl::OUString& aFormat,
- const uno::Reference < io::XInputStream >& xStream,
- const uno::Reference< lang::XMultiServiceFactory >& xFactory,
+Reference< XStorage > OStorageHelper::GetStorageOfFormatFromInputStream(
+ const OUString& aFormat,
+ const Reference < XInputStream >& xStream,
+ const Reference< XMultiServiceFactory >& xFactory,
sal_Bool bRepairStorage )
- throw ( uno::Exception )
+ throw ( Exception )
{
- uno::Sequence< beans::PropertyValue > aProps( 1 );
- aProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
+ Sequence< PropertyValue > aProps( 1 );
+ aProps[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
aProps[0].Value <<= aFormat;
+
if ( bRepairStorage )
{
aProps.realloc( 2 );
- aProps[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
+ aProps[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
aProps[1].Value <<= bRepairStorage;
}
- uno::Sequence< uno::Any > aArgs( 3 );
+ Sequence< Any > aArgs( 3 );
aArgs[0] <<= xStream;
- aArgs[1] <<= embed::ElementModes::READ;
+ aArgs[1] <<= ElementModes::READ;
aArgs[2] <<= aProps;
- uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
- uno::UNO_QUERY );
+ Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), UNO_QUERY );
if ( !xTempStorage.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
return xTempStorage;
}
-// ----------------------------------------------------------------------
-uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromStream(
- const ::rtl::OUString& aFormat,
- const uno::Reference < io::XStream >& xStream,
+Reference< XStorage > OStorageHelper::GetStorageOfFormatFromStream(
+ const OUString& aFormat,
+ const Reference < XStream >& xStream,
sal_Int32 nStorageMode,
- const uno::Reference< lang::XMultiServiceFactory >& xFactory,
+ const Reference< XMultiServiceFactory >& xFactory,
sal_Bool bRepairStorage )
- throw ( uno::Exception )
+ throw ( Exception )
{
- uno::Sequence< beans::PropertyValue > aProps( 1 );
- aProps[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
+ Sequence< PropertyValue > aProps( 1 );
+ aProps[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "StorageFormat" ) );
aProps[0].Value <<= aFormat;
+
if ( bRepairStorage )
{
aProps.realloc( 2 );
- aProps[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
+ aProps[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "RepairPackage" ) );
aProps[1].Value <<= bRepairStorage;
}
- uno::Sequence< uno::Any > aArgs( 3 );
+ Sequence< Any > aArgs( 3 );
aArgs[0] <<= xStream;
aArgs[1] <<= nStorageMode;
aArgs[2] <<= aProps;
- uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ),
- uno::UNO_QUERY );
+ Reference< XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), UNO_QUERY );
if ( !xTempStorage.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
return xTempStorage;
}
-// ----------------------------------------------------------------------
-uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData( const ::rtl::OUString& aPassword, const uno::Reference< lang::XMultiServiceFactory >& xSF )
+Sequence< NamedValue > OStorageHelper::CreatePackageEncryptionData( const OUString& aPassword, const Reference< XMultiServiceFactory >& xSF )
{
// TODO/LATER: Should not the method be part of DocPasswordHelper?
- uno::Sequence< beans::NamedValue > aEncryptionData;
+ Sequence< NamedValue > aEncryptionData;
if ( !aPassword.isEmpty() )
{
sal_Int32 nSha1Ind = 0;
// generate SHA256 start key
try
{
- uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
+ Reference< XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory();
if ( !xFactory.is() )
- throw uno::RuntimeException();
+ throw RuntimeException();
- 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 );
+ 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 );
- ::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();
+ 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();
aEncryptionData.realloc( ++nSha1Ind );
aEncryptionData[0].Name = PACKAGE_ENCRYPTIONDATA_SHA256UTF8;
aEncryptionData[0].Value <<= aDigest;
}
- catch ( uno::Exception& )
+ catch ( Exception& )
{
OSL_ENSURE( false, "Can not create SHA256 digest!" );
}
@@ -451,7 +439,7 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData(
for ( sal_Int32 nInd = 0; nInd < 2; nInd++ )
{
- ::rtl::OString aByteStrPass = ::rtl::OUStringToOString( aPassword, pEncoding[nInd] );
+ OString aByteStrPass = OUStringToOString( aPassword, pEncoding[nInd] );
sal_uInt8 pBuffer[RTL_DIGEST_LENGTH_SHA1];
rtlDigestError nError = rtl_digest_SHA1( aByteStrPass.getStr(),
@@ -465,20 +453,18 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData(
break;
}
- aEncryptionData[nSha1Ind+nInd].Value <<= uno::Sequence< sal_Int8 >( (sal_Int8*)pBuffer, RTL_DIGEST_LENGTH_SHA1 );
+ aEncryptionData[nSha1Ind+nInd].Value <<= Sequence< sal_Int8 >( (sal_Int8*)pBuffer, RTL_DIGEST_LENGTH_SHA1 );
}
}
return aEncryptionData;
}
-// ----------------------------------------------------------------------
-sal_Bool OStorageHelper::IsValidZipEntryFileName( const ::rtl::OUString& aName, sal_Bool bSlashAllowed )
+sal_Bool OStorageHelper::IsValidZipEntryFileName( const 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 )
{
@@ -506,8 +492,7 @@ sal_Bool OStorageHelper::IsValidZipEntryFileName(
return sal_True;
}
-// ----------------------------------------------------------------------
-sal_Bool OStorageHelper::PathHasSegment( const ::rtl::OUString& aPath, const ::rtl::OUString& aSegment )
+sal_Bool OStorageHelper::PathHasSegment( const OUString& aPath, const OUString& aSegment )
{
sal_Bool bResult = sal_False;
const sal_Int32 nPathLen = aPath.getLength();
@@ -515,11 +500,11 @@ sal_Bool OStorageHelper::PathHasSegment( const ::rtl::OUString& aPath, const ::r
if ( !aSegment.isEmpty() && nPathLen >= nSegLen )
{
- ::rtl::OUString aEndSegment( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+ OUString aEndSegment( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
aEndSegment += aSegment;
- ::rtl::OUString aInternalSegment( aEndSegment );
- aInternalSegment += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+ OUString aInternalSegment( aEndSegment );
+ aInternalSegment += OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
if ( aPath.indexOf( aInternalSegment ) >= 0 )
bResult = sal_True;
@@ -537,89 +522,85 @@ sal_Bool OStorageHelper::PathHasSegment( const ::rtl::OUString& aPath, const ::r
return bResult;
}
-class LifecycleProxy::Impl
- : public std::vector< uno::Reference< embed::XStorage > > {};
-LifecycleProxy::LifecycleProxy()
- : m_pBadness( new Impl() ) { }
-LifecycleProxy::~LifecycleProxy() { }
+class LifecycleProxy::Impl : public std::vector< Reference< XStorage > > {};
-void LifecycleProxy::commitStorages()
-{
- for (Impl::reverse_iterator iter = m_pBadness->rbegin();
- iter != m_pBadness->rend(); ++iter) // reverse order (outwards)
+ LifecycleProxy::LifecycleProxy() : m_pBadness( new Impl() ) { }
+ LifecycleProxy::~LifecycleProxy() { }
+
+ void LifecycleProxy::commitStorages()
{
- uno::Reference<embed::XTransactedObject> const xTransaction(*iter,
- uno::UNO_QUERY);
- if (xTransaction.is())
+ for (Impl::reverse_iterator iter = m_pBadness->rbegin();
+ iter != m_pBadness->rend(); ++iter) // reverse order (outwards)
{
- xTransaction->commit();
+ Reference<XTransactedObject> const xTransaction(*iter, UNO_QUERY);
+ if (xTransaction.is())
+ xTransaction->commit();
}
}
-}
-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 void splitPath( std::vector<OUString> &rElems,
+ const OUString& rPath )
+ {
+ for (sal_Int32 i = 0; i >= 0;)
+ rElems.push_back( rPath.getToken( 0, '/', i ) );
+ }
-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++ )
+ static Reference< XStorage > LookupStorageAtPath(
+ const Reference< XStorage > &xParentStorage,
+ std::vector<OUString> &rElems, sal_uInt32 nOpenMode,
+ LifecycleProxy &rNastiness )
{
- xStorage = xStorage->openStorageElement( rElems[i], nOpenMode );
+ Reference< XStorage > xStorage( xParentStorage );
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;
-}
-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< 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< 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::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::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))
+ Reference< XStream > OStorageHelper::GetStreamAtPackageURL(
+ Reference< XStorage > const& xParentStorage,
+ const OUString& rURL, sal_uInt32 const nOpenMode,
+ LifecycleProxy & rNastiness)
{
- ::rtl::OUString const path(rURL.copy(SAL_N_ELEMENTS(s_PkgScheme)-1));
- return GetStreamAtPath(xParentStorage, path, nOpenMode, 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))
+ {
+ OUString const path(rURL.copy(SAL_N_ELEMENTS(s_PkgScheme)-1));
+ return GetStreamAtPath(xParentStorage, path, nOpenMode, rNastiness);
+ }
+ return 0;
}
- return 0;
-}
}