2007-04-25 15:13:13 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 00:24:23 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2007-04-25 15:13:13 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2007-04-25 15:13:13 +00:00
|
|
|
*
|
2008-04-11 00:24:23 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2007-04-25 15:13:13 +00:00
|
|
|
*
|
2008-04-11 00:24:23 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2007-04-25 15:13:13 +00:00
|
|
|
*
|
2008-04-11 00:24:23 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2007-04-25 15:13:13 +00:00
|
|
|
*
|
2008-04-11 00:24:23 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2007-04-25 15:13:13 +00:00
|
|
|
*
|
2008-04-11 00:24:23 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2007-04-25 15:13:13 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
|
|
|
|
#include <cppuhelper/implbase1.hxx>
|
|
|
|
#include <cppuhelper/implbase3.hxx>
|
|
|
|
|
|
|
|
#include <com/sun/star/frame/XDesktop.hpp>
|
|
|
|
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
|
|
|
|
#include <com/sun/star/container/XEnumerationAccess.hpp>
|
|
|
|
#include <com/sun/star/frame/XComponentLoader.hpp>
|
|
|
|
#include <com/sun/star/lang/XComponent.hpp>
|
|
|
|
#include <com/sun/star/frame/XModel.hpp>
|
|
|
|
#include <com/sun/star/frame/XFrame.hpp>
|
|
|
|
#include <com/sun/star/frame/FrameSearchFlag.hpp>
|
|
|
|
#include <com/sun/star/util/XModifiable.hpp>
|
|
|
|
#include <com/sun/star/frame/XStorable.hpp>
|
|
|
|
#include <com/sun/star/lang/DisposedException.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyVetoException.hpp>
|
|
|
|
#include <com/sun/star/util/XCloseable.hpp>
|
|
|
|
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
|
|
|
|
#include <com/sun/star/document/XTypeDetection.hpp>
|
2007-12-07 10:06:29 +00:00
|
|
|
#include <com/sun/star/uri/XUriReference.hpp>
|
|
|
|
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
|
2010-07-27 14:43:33 +02:00
|
|
|
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
|
|
|
|
#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
|
2010-07-01 16:23:26 +02:00
|
|
|
#include <com/sun/star/script/ModuleInfo.hpp>
|
|
|
|
#include <com/sun/star/script/ModuleType.hpp>
|
2007-04-25 15:13:13 +00:00
|
|
|
|
|
|
|
#include <sfx2/objsh.hxx>
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
|
|
|
|
#include "vbaglobals.hxx"
|
|
|
|
#include "vbaworkbook.hxx"
|
|
|
|
#include "vbaworkbooks.hxx"
|
2009-09-18 15:24:22 +00:00
|
|
|
#include <vbahelper/vbahelper.hxx>
|
2007-04-25 15:13:13 +00:00
|
|
|
|
|
|
|
#include <hash_map>
|
2010-07-01 16:23:26 +02:00
|
|
|
#include <vector>
|
2007-04-25 15:13:13 +00:00
|
|
|
#include <osl/file.hxx>
|
2009-02-13 13:03:24 +00:00
|
|
|
using namespace ::ooo::vba;
|
2007-04-25 15:13:13 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
const sal_Int16 CUSTOM_CHAR = 5;
|
|
|
|
|
2010-07-01 16:23:26 +02:00
|
|
|
void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& xDoc )
|
|
|
|
{
|
|
|
|
uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY );
|
|
|
|
ScDocShell* pShell = excel::getDocShell( xModel );
|
|
|
|
if ( pShell )
|
|
|
|
{
|
|
|
|
uno::Reference<script::XLibraryContainer> xLibContainer = pShell->GetBasicContainer();
|
2010-07-27 14:43:33 +02:00
|
|
|
uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY_THROW );
|
|
|
|
xVBACompat->setVBACompatibilityMode( sal_True );
|
2010-08-10 06:57:53 +02:00
|
|
|
String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
|
2010-07-01 16:23:26 +02:00
|
|
|
pShell->GetBasicManager()->SetName( aPrjName );
|
|
|
|
|
|
|
|
if( xLibContainer.is() )
|
|
|
|
{
|
|
|
|
if( !xLibContainer->hasByName( aPrjName ) )
|
|
|
|
xLibContainer->createLibrary( aPrjName );
|
|
|
|
uno::Any aLibAny = xLibContainer->getByName( aPrjName );
|
|
|
|
uno::Reference< container::XNameContainer > xLib;
|
2010-07-27 14:43:33 +02:00
|
|
|
aLibAny >>= xLib;
|
2010-07-01 16:23:26 +02:00
|
|
|
if( xLib.is() )
|
|
|
|
{
|
2010-07-27 14:43:33 +02:00
|
|
|
uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY_THROW );
|
2010-07-01 16:23:26 +02:00
|
|
|
uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY_THROW);
|
|
|
|
// bootstrap vbaglobals
|
|
|
|
xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals")));
|
|
|
|
uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY_THROW );
|
|
|
|
// set up the module info for the workbook and sheets in the nealy created
|
|
|
|
// spreadsheet
|
|
|
|
ScDocument* pDoc = pShell->GetDocument();
|
|
|
|
String sCodeName = pDoc->GetCodeName();
|
|
|
|
if ( sCodeName.Len() == 0 )
|
|
|
|
{
|
|
|
|
sCodeName = String( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook") );
|
|
|
|
pDoc->SetCodeName( sCodeName );
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector< rtl::OUString > sDocModuleNames;
|
|
|
|
sDocModuleNames.push_back( sCodeName );
|
|
|
|
|
|
|
|
uno::Reference<container::XNameAccess > xSheets( xDoc->getSheets(), uno::UNO_QUERY_THROW );
|
|
|
|
uno::Sequence< rtl::OUString > sSheets( xSheets->getElementNames() );
|
|
|
|
|
|
|
|
for ( sal_Int32 index=0; index < sSheets.getLength() ; ++index )
|
|
|
|
{
|
|
|
|
sDocModuleNames.push_back( sSheets[ index ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<rtl::OUString>::iterator it_end = sDocModuleNames.end();
|
|
|
|
|
|
|
|
for ( std::vector<rtl::OUString>::iterator it = sDocModuleNames.begin(); it != it_end; ++it )
|
|
|
|
{
|
|
|
|
script::ModuleInfo sModuleInfo;
|
|
|
|
|
|
|
|
sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( *it ), uno::UNO_QUERY );
|
|
|
|
sModuleInfo.ModuleType = script::ModuleType::DOCUMENT;
|
|
|
|
xVBAModuleInfo->insertModuleInfo( *it, sModuleInfo );
|
|
|
|
if( xLib->hasByName( *it ) )
|
|
|
|
xLib->replaceByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n") ) ) );
|
|
|
|
else
|
|
|
|
xLib->insertByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ) ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-25 15:13:13 +00:00
|
|
|
static uno::Any
|
2010-07-01 16:23:26 +02:00
|
|
|
getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc, const uno::Reference< XHelperInterface >& xParent )
|
2007-04-25 15:13:13 +00:00
|
|
|
{
|
|
|
|
// FIXME: fine as long as ScVbaWorkbook is stateless ...
|
|
|
|
uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY );
|
|
|
|
if( !xModel.is() )
|
|
|
|
return uno::Any();
|
|
|
|
|
2010-07-01 16:23:26 +02:00
|
|
|
ScDocShell* pShell = excel::getDocShell( xModel );
|
|
|
|
if ( pShell )
|
|
|
|
{
|
|
|
|
String sCodeName = pShell->GetDocument()->GetCodeName();
|
|
|
|
uno::Reference< uno::XInterface > xIf = getUnoDocModule( sCodeName, pShell );
|
|
|
|
if ( xIf.is() )
|
|
|
|
{
|
|
|
|
OSL_TRACE(" *** Returning Module uno Object *** ");
|
|
|
|
return uno::makeAny( xIf );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ScVbaWorkbook *pWb = new ScVbaWorkbook( xParent, xContext, xModel );
|
2007-04-25 15:13:13 +00:00
|
|
|
return uno::Any( uno::Reference< excel::XWorkbook > (pWb) );
|
|
|
|
}
|
|
|
|
|
|
|
|
class WorkBookEnumImpl : public EnumerationHelperImpl
|
|
|
|
{
|
2009-09-18 15:24:22 +00:00
|
|
|
uno::Any m_aApplication;
|
2007-04-25 15:13:13 +00:00
|
|
|
public:
|
2010-07-01 16:23:26 +02:00
|
|
|
WorkBookEnumImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_aApplication( aApplication ) {}
|
2007-04-25 15:13:13 +00:00
|
|
|
|
|
|
|
virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
|
|
|
|
{
|
|
|
|
uno::Reference< sheet::XSpreadsheetDocument > xDoc( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
|
2010-07-01 16:23:26 +02:00
|
|
|
return getWorkbook( m_xContext, xDoc, m_xParent );
|
2007-04-25 15:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2009-09-18 15:24:22 +00:00
|
|
|
ScVbaWorkbooks::ScVbaWorkbooks( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext >& xContext ) : ScVbaWorkbooks_BASE( xParent, xContext, VbaDocumentsBase::EXCEL_DOCUMENT )
|
2007-04-25 15:13:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
// XEnumerationAccess
|
|
|
|
uno::Type
|
|
|
|
ScVbaWorkbooks::getElementType() throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return excel::XWorkbook::static_type(0);
|
|
|
|
}
|
|
|
|
uno::Reference< container::XEnumeration >
|
|
|
|
ScVbaWorkbooks::createEnumeration() throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
// #FIXME its possible the WorkBookEnumImpl here doens't reflect
|
|
|
|
// the state of this object ( although it should ) would be
|
|
|
|
// safer to create an enumeration based on this objects state
|
|
|
|
// rather than one effectively based of the desktop component
|
2009-09-18 15:24:22 +00:00
|
|
|
uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
|
2010-07-01 16:23:26 +02:00
|
|
|
return new WorkBookEnumImpl( mxParent, mxContext, xEnumerationAccess->createEnumeration(), Application() );
|
2007-04-25 15:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uno::Any
|
|
|
|
ScVbaWorkbooks::createCollectionObject( const css::uno::Any& aSource )
|
|
|
|
{
|
2009-09-18 15:24:22 +00:00
|
|
|
uno::Reference< sheet::XSpreadsheetDocument > xDoc( aSource, uno::UNO_QUERY_THROW );
|
2010-07-01 16:23:26 +02:00
|
|
|
return getWorkbook( mxContext, xDoc, mxParent );
|
2007-04-25 15:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uno::Any SAL_CALL
|
|
|
|
ScVbaWorkbooks::Add() throw (uno::RuntimeException)
|
|
|
|
{
|
2009-09-18 15:24:22 +00:00
|
|
|
uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( VbaDocumentsBase::Add() , uno::UNO_QUERY_THROW );
|
2007-04-25 15:13:13 +00:00
|
|
|
|
2010-07-01 16:23:26 +02:00
|
|
|
// need to set up the document modules ( and vba mode ) here
|
|
|
|
setUpDocumentModules( xSpreadDoc );
|
2007-04-25 15:13:13 +00:00
|
|
|
if( xSpreadDoc.is() )
|
2010-07-01 16:23:26 +02:00
|
|
|
return getWorkbook( mxContext, xSpreadDoc, mxParent );
|
2007-04-25 15:13:13 +00:00
|
|
|
return uno::Any();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ScVbaWorkbooks::Close() throw (uno::RuntimeException)
|
|
|
|
{
|
2009-09-18 15:24:22 +00:00
|
|
|
VbaDocumentsBase::Close();
|
2007-04-25 15:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2007-12-07 10:06:29 +00:00
|
|
|
ScVbaWorkbooks::isTextFile( const rtl::OUString& sType )
|
2007-04-25 15:13:13 +00:00
|
|
|
{
|
2007-12-07 10:06:29 +00:00
|
|
|
// will return true if the file is
|
|
|
|
// a) a variant of a text file
|
|
|
|
// b) a csv file
|
|
|
|
// c) unknown
|
|
|
|
// returning true basically means treat this like a csv file
|
|
|
|
const static rtl::OUString txtType( RTL_CONSTASCII_USTRINGPARAM("writer_Text" ) );
|
|
|
|
const static rtl::OUString csvType( RTL_CONSTASCII_USTRINGPARAM("calc_Text_txt_csv_StarCalc" ) );
|
|
|
|
const static rtl::OUString encodedTxtType( RTL_CONSTASCII_USTRINGPARAM("writer_Text_encoded" ) );
|
|
|
|
return sType.equals( txtType ) || sType.equals( csvType ) || ( sType.getLength() == 0 ) || sType.equals( encodedTxtType );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ScVbaWorkbooks::isSpreadSheetFile( const rtl::OUString& sType )
|
|
|
|
{
|
|
|
|
// include calc_QPro etc. ? ( not for the moment anyway )
|
|
|
|
if ( sType.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("calc_MS"))) == 0
|
|
|
|
|| sType.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("calc8"))) == 0
|
|
|
|
|| sType.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("calc_StarOffice"))) == 0 )
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::OUString
|
|
|
|
ScVbaWorkbooks::getFileFilterType( const rtl::OUString& rFileName )
|
|
|
|
{
|
|
|
|
uno::Reference< document::XTypeDetection > xTypeDetect( mxContext->getServiceManager()->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.document.TypeDetection"), mxContext), uno::UNO_QUERY_THROW );
|
2007-04-25 15:13:13 +00:00
|
|
|
uno::Sequence< beans::PropertyValue > aMediaDesc(1);
|
|
|
|
aMediaDesc[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ("URL" ) );
|
|
|
|
aMediaDesc[ 0 ].Value <<= rFileName;
|
|
|
|
rtl::OUString sType = xTypeDetect->queryTypeByDescriptor( aMediaDesc, sal_True );
|
2007-12-07 10:06:29 +00:00
|
|
|
return sType;
|
2007-04-25 15:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// #TODO# #FIXME# can any of the unused params below be used?
|
|
|
|
uno::Any
|
|
|
|
ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLinks*/, const uno::Any& ReadOnly, const uno::Any& Format, const uno::Any& /*Password*/, const uno::Any& /*WriteResPassword*/, const uno::Any& /*IgnoreReadOnlyRecommended*/, const uno::Any& /*Origin*/, const uno::Any& Delimiter, const uno::Any& /*Editable*/, const uno::Any& /*Notify*/, const uno::Any& /*Converter*/, const uno::Any& /*AddToMru*/ ) throw (uno::RuntimeException)
|
|
|
|
{
|
2007-12-07 10:06:29 +00:00
|
|
|
// we need to detect if this is a URL, if not then assume its a file path
|
2009-09-18 15:24:22 +00:00
|
|
|
rtl::OUString aURL;
|
|
|
|
INetURLObject aObj;
|
2007-12-07 10:06:29 +00:00
|
|
|
aObj.SetURL( rFileName );
|
|
|
|
bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID;
|
|
|
|
if ( bIsURL )
|
|
|
|
aURL = rFileName;
|
|
|
|
else
|
2007-04-25 15:13:13 +00:00
|
|
|
osl::FileBase::getFileURLFromSystemPath( rFileName, aURL );
|
2009-09-18 15:24:22 +00:00
|
|
|
|
2007-04-25 15:13:13 +00:00
|
|
|
uno::Sequence< beans::PropertyValue > sProps(0);
|
|
|
|
sal_Int32 nIndex = 0;
|
|
|
|
|
2007-12-07 10:06:29 +00:00
|
|
|
rtl::OUString sType = getFileFilterType( aURL );
|
2007-04-25 15:13:13 +00:00
|
|
|
// A text file means it needs to be processed as a csv file
|
2007-12-07 10:06:29 +00:00
|
|
|
if ( isTextFile( sType ) )
|
2007-04-25 15:13:13 +00:00
|
|
|
{
|
|
|
|
// Values for format
|
|
|
|
// 1 Tabs
|
|
|
|
// 2 Commas
|
|
|
|
// 3 Spaces
|
|
|
|
// 4 Semicolons
|
|
|
|
// 5 Nothing
|
|
|
|
// 6 Custom character (see the Delimiter argument
|
|
|
|
// no format means use the current delimiter
|
2007-12-07 10:06:29 +00:00
|
|
|
sProps.realloc( 3 );
|
2007-04-25 15:13:13 +00:00
|
|
|
sProps[ nIndex ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FilterOptions" ) );
|
|
|
|
sal_Int16 delims[] = { 0 /*default not used*/, 9/*tab*/, 44/*comma*/, 32/*space*/, 59/*semicolon*/ };
|
|
|
|
static rtl::OUString sRestOfFormat( RTL_CONSTASCII_USTRINGPARAM(",34,0,1" ) );
|
|
|
|
|
|
|
|
rtl::OUString sFormat;
|
|
|
|
sal_Int16 nFormat = 0; // default indicator
|
|
|
|
|
|
|
|
|
|
|
|
if ( Format.hasValue() )
|
|
|
|
{
|
|
|
|
Format >>= nFormat; // val of nFormat overwritten if extracted
|
|
|
|
// validate param
|
|
|
|
if ( nFormat < 1 || nFormat > 6 )
|
|
|
|
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Illegal value for Format" ) ), uno::Reference< uno::XInterface >() );
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int16 nDelim = getCurrentDelim();
|
|
|
|
|
|
|
|
if ( nFormat > 0 && nFormat < CUSTOM_CHAR )
|
|
|
|
{
|
|
|
|
nDelim = delims[ nFormat ];
|
|
|
|
}
|
|
|
|
else if ( nFormat > CUSTOM_CHAR )
|
|
|
|
{
|
|
|
|
// Need to check Delimiter param
|
|
|
|
if ( !Delimiter.hasValue() )
|
|
|
|
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Expected value for Delimiter" ) ), uno::Reference< uno::XInterface >() );
|
|
|
|
rtl::OUString sStr;
|
|
|
|
Delimiter >>= sStr;
|
|
|
|
String aUniStr( sStr );
|
|
|
|
if ( aUniStr.Len() )
|
|
|
|
nDelim = aUniStr.GetChar(0);
|
|
|
|
else
|
|
|
|
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Incorrect value for Delimiter" ) ), uno::Reference< uno::XInterface >() );
|
|
|
|
}
|
|
|
|
|
|
|
|
getCurrentDelim() = nDelim; //set new current
|
|
|
|
|
|
|
|
sFormat = rtl::OUString::valueOf( (sal_Int32)nDelim ) + sRestOfFormat;
|
|
|
|
sProps[ nIndex++ ].Value <<= sFormat;
|
2007-12-07 10:06:29 +00:00
|
|
|
sProps[ nIndex ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FilterName") );
|
|
|
|
sProps[ nIndex++ ].Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Text - txt - csv (StarCalc)") );
|
|
|
|
// Ensure WORKAROUND_CSV_TXT_BUG_i60158 gets called in typedetection.cxx so
|
|
|
|
// csv is forced for deep detected 'writerxxx' types
|
|
|
|
sProps[ nIndex ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentService") );
|
|
|
|
sProps[ nIndex ].Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument") );
|
2007-04-25 15:13:13 +00:00
|
|
|
}
|
2007-12-07 10:06:29 +00:00
|
|
|
else if ( !isSpreadSheetFile( sType ) )
|
|
|
|
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Bad Format")), uno::Reference< uno::XInterface >() );
|
|
|
|
|
2009-09-18 15:24:22 +00:00
|
|
|
uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( VbaDocumentsBase::Open( rFileName, ReadOnly, sProps ), uno::UNO_QUERY_THROW );
|
2010-07-01 16:23:26 +02:00
|
|
|
uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, mxParent );
|
2007-12-07 10:06:29 +00:00
|
|
|
uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY );
|
|
|
|
if ( xWBook.is() )
|
|
|
|
xWBook->Activate();
|
|
|
|
return aRet;
|
2007-04-25 15:13:13 +00:00
|
|
|
}
|
|
|
|
|
2009-10-07 14:45:16 +00:00
|
|
|
uno::Any
|
|
|
|
ScVbaWorkbooks::Open( const rtl::OUString& Filename, const uno::Any& ReadOnly, const uno::Sequence< beans::PropertyValue >& rProps ) throw (css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return VbaDocumentsBase::Open( Filename, ReadOnly, rProps );
|
|
|
|
}
|
|
|
|
|
2007-12-07 10:06:29 +00:00
|
|
|
rtl::OUString&
|
|
|
|
ScVbaWorkbooks::getServiceImplName()
|
|
|
|
{
|
|
|
|
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWorkbooks") );
|
|
|
|
return sImplName;
|
|
|
|
}
|
2007-04-25 15:13:13 +00:00
|
|
|
|
2007-12-07 10:06:29 +00:00
|
|
|
css::uno::Sequence<rtl::OUString>
|
|
|
|
ScVbaWorkbooks::getServiceNames()
|
|
|
|
{
|
|
|
|
static uno::Sequence< rtl::OUString > sNames;
|
|
|
|
if ( sNames.getLength() == 0 )
|
|
|
|
{
|
|
|
|
sNames.realloc( 1 );
|
2009-02-13 13:03:24 +00:00
|
|
|
sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Workbooks") );
|
2007-12-07 10:06:29 +00:00
|
|
|
}
|
|
|
|
return sNames;
|
|
|
|
}
|