summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorChristoph Lutz <christoph.lutz@cib.de>2013-11-05 23:34:37 +0100
committerMichael Meeks <michael.meeks@collabora.com>2013-11-07 11:50:00 +0000
commit49112ec909ef465ecb1aa2786a283b57034e6af4 (patch)
tree87940088328b4ad1e96d74f9996972a82e926c4c /desktop
parent67311738157bced7b49e94b24845091995edb142 (diff)
liblibo: fixes and improvements for liblibreoffice
fixes for liblibreoffice-Impl (init.cxx): determine outputfilter from file suffix if no filter is provided; ensure that url provided to XStorable.storeToUrl is really an url; improved error handling small improvements in somektest/libtest.cxx: output times required for init, load and save. Change-Id: Ic8b2c0d34cbeae3250c43cac02690e6ec1954ed7
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx48
1 files changed, 35 insertions, 13 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5d7e8c0b38a0..6c6b9f51ad27 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -166,19 +166,23 @@ LibLibreOffice_Impl::documentLoad( const char *docUrl )
bool LibLODocument_Impl::saveAs (const char *url, const char *format)
{
- OUString sURL = getUString( url );
OUString sFormat = getUString( format );
+ OUString sUrl = getUString( url );
+ OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl;
+
+ osl_getProcessWorkingDir(&sWorkingDir.pData);
+ osl::FileBase::getFileURLFromSystemPath( sUrl, sDocPathUrl );
+ osl::FileBase::getAbsoluteFileURL(sWorkingDir, sDocPathUrl, sAbsoluteDocUrl);
+
try {
uno::Reference< frame::XModel > xDocument( mxComponent, uno::UNO_QUERY_THROW );
uno::Sequence< beans::PropertyValue > aSeq = xDocument->getArgs();
- OUString aFilterName, aDocumentService;
+ OUString aDocumentService;
for( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
{
- if( aSeq[i].Name == "FilterName" )
- aSeq[i].Value >>= aFilterName;
- else if( aSeq[i].Name == "DocumentService" )
+ if( aSeq[i].Name == "DocumentService" )
aSeq[i].Value >>= aDocumentService;
OUString aValue;
aSeq[i].Value >>= aValue;
@@ -198,17 +202,35 @@ bool LibLODocument_Impl::saveAs (const char *url, const char *format)
else // for the sake of argument only writer documents ...
pMap = (const ExtensionMap *)aWriterExtensionMap;
- if( format )
+ if( ! format )
+ {
+ // sniff from the extension
+ sal_Int32 idx = sUrl.lastIndexOf( "." );
+ if( idx > 0 )
+ {
+ sFormat = sUrl.copy( idx + 1 );
+ }
+ else
+ {
+ gImpl->maLastExceptionMsg = "input filename without a suffix";
+ return false;
+ }
+ }
+
+ OUString aFilterName;
+ for( sal_Int32 i = 0; pMap[i].extn; i++ )
{
- for( sal_Int32 i = 0; pMap[i].extn; i++ )
+ if( sFormat.equalsIgnoreAsciiCaseAscii( pMap[i].extn ) )
{
- if( sFormat.equalsIgnoreAsciiCaseAscii( pMap[i].extn ) )
- {
- aFilterName = getUString( pMap[i].filterName );
- break;
- }
+ aFilterName = getUString( pMap[i].filterName );
+ break;
}
}
+ if( ! aFilterName.getLength() )
+ {
+ gImpl->maLastExceptionMsg = "no output filter found for provided suffix";
+ return false;
+ }
aSeq.realloc(2);
aSeq[0].Name = "Overwrite";
@@ -217,7 +239,7 @@ bool LibLODocument_Impl::saveAs (const char *url, const char *format)
aSeq[1].Value <<= aFilterName;
uno::Reference< frame::XStorable > xStorable( mxComponent, uno::UNO_QUERY_THROW );
- xStorable->storeToURL( sURL, aSeq );
+ xStorable->storeToURL( sAbsoluteDocUrl, aSeq );
return true;
} catch (const uno::Exception &ex) {