Kaydet (Commit) b2d15262 authored tarafından Noel Power's avatar Noel Power

Parse workbook name correctly, don't fall over spaces etc.

Change-Id: I26213e4202ea2f2d15014ca722ab7878aa09cbf1
üst 4d1e0ea9
...@@ -58,6 +58,8 @@ public: ...@@ -58,6 +58,8 @@ public:
// XHelperInterface // XHelperInterface
virtual OUString getServiceImplName(); virtual OUString getServiceImplName();
virtual css::uno::Sequence<OUString> getServiceNames(); virtual css::uno::Sequence<OUString> getServiceNames();
static OUString getNameFromModel( const css::uno::Reference< css::frame::XModel >& xModel );
}; };
#endif /* VBA_DOCUMENTBASE_HXX */ #endif /* VBA_DOCUMENTBASE_HXX */
......
...@@ -54,16 +54,21 @@ VbaDocumentBase::VbaDocumentBase( uno::Sequence< uno::Any> const & args, ...@@ -54,16 +54,21 @@ VbaDocumentBase::VbaDocumentBase( uno::Sequence< uno::Any> const & args,
OUString OUString
VbaDocumentBase::getName() throw (uno::RuntimeException) VbaDocumentBase::getName() throw (uno::RuntimeException)
{ {
OUString sName = getModel()->getURL(); return VbaDocumentBase::getNameFromModel( getModel() );
}
OUString VbaDocumentBase::getNameFromModel( const uno::Reference< frame::XModel >& xModel )
{
OUString sName = xModel.is() ? xModel->getURL() : OUString();
if ( !sName.isEmpty() ) if ( !sName.isEmpty() )
{ {
INetURLObject aURL( getModel()->getURL() ); INetURLObject aURL( xModel->getURL() );
::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName ); ::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName );
} }
else else
{ {
uno::Reference< frame::XTitle > xTitle( getModel(), uno::UNO_QUERY_THROW ); uno::Reference< frame::XTitle > xTitle( xModel, uno::UNO_QUERY_THROW );
sName = xTitle->getTitle(); sName = xTitle->getTitle();
sName = sName.trim(); sName = sName.trim();
} }
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "vbahelper/vbahelper.hxx" #include "vbahelper/vbahelper.hxx"
#include "vbahelper/vbaapplicationbase.hxx" #include "vbahelper/vbaapplicationbase.hxx"
#include "vbahelper/vbadocumentbase.hxx"
using namespace ::ooo::vba; using namespace ::ooo::vba;
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -138,8 +139,8 @@ public: ...@@ -138,8 +139,8 @@ public:
{ {
uno::Reference< frame::XModel > xModel( xServiceInfo, uno::UNO_QUERY_THROW ); // that the spreadsheetdocument is a xmodel is a given uno::Reference< frame::XModel > xModel( xServiceInfo, uno::UNO_QUERY_THROW ); // that the spreadsheetdocument is a xmodel is a given
m_documents.push_back( xModel ); m_documents.push_back( xModel );
INetURLObject aURL( xModel->getURL() ); OUString sName = VbaDocumentBase::getNameFromModel( xModel );
namesToIndices[ aURL.GetLastName() ] = nIndex++; namesToIndices[ sName ] = nIndex++;
} }
} }
......
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