diff options
author | Jan Holesovsky <kendy@suse.cz> | 2011-03-18 15:33:40 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-03-18 15:33:40 +0100 |
commit | e6064484fae8aa2797f86c68e9a8d23d2e213367 (patch) | |
tree | db2f4d140efca43ab01dee4fc053fff0829d106b /sc/source/ui/vba | |
parent | 9e0a09e89c38774dd1af902387a8b25de158b634 (diff) | |
parent | 378c75a798c8baa34cb26e7f07fe28cb5ee2a85f (diff) |
Merge remote-tracking branch 'origin/integration/dev300_m101'
Conflicts:
chart2/source/controller/main/UndoManager.cxx
chart2/source/tools/RegressionCurveHelper.cxx
sc/inc/address.hxx
sc/inc/attrib.hxx
sc/inc/bigrange.hxx
sc/inc/callform.hxx
sc/inc/cell.hxx
sc/inc/chartarr.hxx
sc/inc/chartlis.hxx
sc/inc/chgtrack.hxx
sc/inc/collect.hxx
sc/inc/compiler.hxx
sc/inc/detdata.hxx
sc/inc/document.hxx
sc/inc/fillinfo.hxx
sc/inc/olinetab.hxx
sc/inc/prnsave.hxx
sc/inc/queryparam.hxx
sc/inc/sc.hrc
sc/inc/scabstdlg.hxx
sc/inc/table.hxx
sc/inc/validat.hxx
sc/inc/zforauto.hxx
sc/source/core/data/documen2.cxx
sc/source/core/data/document.cxx
sc/source/core/data/table1.cxx
sc/source/core/tool/address.cxx
sc/source/core/tool/token.cxx
sc/source/filter/excel/frmbase.cxx
sc/source/filter/excel/impop.cxx
sc/source/filter/excel/xename.cxx
sc/source/filter/inc/formel.hxx
sc/source/filter/inc/xename.hxx
sc/source/filter/xml/xmlexprt.cxx
sc/source/filter/xml/xmlnexpi.cxx
sc/source/filter/xml/xmlnexpi.hxx
sc/source/ui/dbgui/filtdlg.cxx
sc/source/ui/inc/docfunc.hxx
sc/source/ui/inc/namedlg.hxx
sc/source/ui/namedlg/namedlg.cxx
sc/source/ui/src/namedlg.src
Diffstat (limited to 'sc/source/ui/vba')
42 files changed, 858 insertions, 590 deletions
diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 99fda2b57a81..4f49aab539c4 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -25,8 +25,12 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include <docuno.hxx> + #include "excelvbahelper.hxx" + +#include <comphelper/processfactory.hxx> +#include <com/sun/star/sheet/XSheetCellRange.hpp> +#include "docuno.hxx" #include "tabvwsh.hxx" #include "transobj.hxx" #include "scmod.hxx" @@ -34,18 +38,15 @@ #include "compiler.hxx" #include "token.hxx" #include "tokenarray.hxx" -#include <comphelper/processfactory.hxx> -#include <com/sun/star/sheet/XSheetCellRange.hpp> using namespace ::com::sun::star; using namespace ::ooo::vba; -namespace ooo -{ -namespace vba -{ -namespace excel -{ +namespace ooo { +namespace vba { +namespace excel { + +// ============================================================================ uno::Reference< sheet::XDatabaseRanges > GetDataBaseRanges( ScDocShell* pShell ) throw ( uno::RuntimeException ) @@ -79,7 +80,7 @@ GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet, rtl::OUString& sName ) t dbAddress = xDBRange->getDataArea(); if ( dbAddress.Sheet == nSheet ) { - sal_Bool bHasAuto = sal_False; + sal_Bool bHasAuto = false; uno::Reference< beans::XPropertySet > xProps( xDBRange, uno::UNO_QUERY_THROW ); xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoFilter") ) ) >>= bHasAuto; if ( bHasAuto ) @@ -103,6 +104,14 @@ ScDocShell* GetDocShellFromRange( const uno::Reference< uno::XInterface >& xRang return pScCellRangesBase->GetDocShell(); } +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSheetCellRange > xSheetRange( xRange, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheet > xSheet( xSheetRange->getSpreadsheet(), uno::UNO_SET_THROW ); + return getUnoSheetModuleObj( xSheet ); +} + ScDocShell* GetDocShellFromRanges( const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges ) throw ( uno::RuntimeException ) { // need the ScCellRangesBase to get docshell @@ -169,7 +178,7 @@ private: bool getReplaceCellsWarning() throw ( uno::RuntimeException ) { - sal_Bool res = sal_False; + sal_Bool res = false; getGlobalSheetSettings()->getPropertyValue( REPLACE_CELLS_WARNING ) >>= res; return ( res == sal_True ); } @@ -217,7 +226,14 @@ implnCopy( const uno::Reference< frame::XModel>& xModel ) { ScTabViewShell* pViewShell = getBestViewShell( xModel ); if ( pViewShell ) + { pViewShell->CopyToClip(NULL,false,false,true); + + // mark the copied transfer object so it is used in ScVbaRange::Insert + ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard( NULL ); + if (pClipObj) + pClipObj->SetUseInApi( true ); + } } void @@ -225,13 +241,20 @@ implnCut( const uno::Reference< frame::XModel>& xModel ) { ScTabViewShell* pViewShell = getBestViewShell( xModel ); if ( pViewShell ) - pViewShell->CutToClip( NULL, TRUE ); + { + pViewShell->CutToClip( NULL, sal_True ); + + // mark the copied transfer object so it is used in ScVbaRange::Insert + ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard( NULL ); + if (pClipObj) + pClipObj->SetUseInApi( true ); + } } -void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) +void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) { PasteCellsWarningReseter resetWarningBox; - sal_Bool bAsLink(sal_False), bOtherDoc(sal_False); + sal_Bool bAsLink(false), bOtherDoc(false); InsCellCmd eMoveMode = INS_NONE; ScTabViewShell* pTabViewShell = getBestViewShell( xModel ); @@ -251,7 +274,7 @@ void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, USHORT nFl pDoc = pOwnClip->GetDocument(); pTabViewShell->PasteFromClip( nFlags, pDoc, nFunction, bSkipEmpty, bTranspose, bAsLink, - eMoveMode, IDF_NONE, TRUE ); + eMoveMode, IDF_NONE, sal_True ); pTabViewShell->CellContentChanged(); } } @@ -264,7 +287,7 @@ void implnCopyRange( const uno::Reference< frame::XModel>& xModel, const ScRange ScTabViewShell* pViewShell = getBestViewShell( xModel ); if ( pViewShell ) { - pViewShell->CopyToClip( NULL, rRange, FALSE, TRUE, TRUE ); + pViewShell->CopyToClip( NULL, rRange, false, true, true ); } } @@ -309,20 +332,19 @@ sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const rtl::OUString& sRangeStr ) { ScRangeList aCellRanges; String sAddress( sRangeStr ); - USHORT nMask = SCA_VALID; - USHORT rResFlags = aCellRanges.Parse( sAddress, pDoc, nMask, formula::FormulaGrammar::CONV_XL_R1C1 ); + sal_uInt16 nMask = SCA_VALID; + sal_uInt16 rResFlags = aCellRanges.Parse( sAddress, pDoc, nMask, formula::FormulaGrammar::CONV_XL_R1C1 ); if ( rResFlags & SCA_VALID ) { return sal_True; } - return sal_False; + return false; } -uno::Reference< XHelperInterface > -getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) +uno::Reference< vba::XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< sheet::XSpreadsheet >& xSheet ) throw ( uno::RuntimeException ) { - uno::Reference< sheet::XSheetCellRange > xSheetRange( xRange, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProps( xSheetRange->getSpreadsheet(), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps( xSheet, uno::UNO_QUERY_THROW ); rtl::OUString sCodeName; xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CodeName") ) ) >>= sCodeName; // #TODO #FIXME ideally we should 'throw' here if we don't get a valid parent, but... it is possible @@ -330,8 +352,7 @@ getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw // are *NO* special document module objects ( of course being able to switch between vba/non vba mode at // the document in the future could fix this, especially IF the switching of the vba mode takes care to // create the special document module objects if they don't exist. - uno::Reference< XHelperInterface > xParent( ov::getUnoDocModule( sCodeName, GetDocShellFromRange( xRange ) ), uno::UNO_QUERY ); - + uno::Reference< XHelperInterface > xParent( ov::getUnoDocModule( sCodeName, GetDocShellFromRange( xSheet ) ), uno::UNO_QUERY ); return xParent; } @@ -348,9 +369,9 @@ formula::FormulaGrammar::Grammar GetFormulaGrammar( ScDocument* pDoc, const ScAd ScTokenArray* pCode = aCompiler.CompileString( sFormula ); if ( pCode ) { - USHORT nLen = pCode->GetLen(); + sal_uInt16 nLen = pCode->GetLen(); formula::FormulaToken** pTokens = pCode->GetArray(); - for ( USHORT nPos = 0; nPos < nLen; nPos++ ) + for ( sal_uInt16 nPos = 0; nPos < nLen; nPos++ ) { const formula::FormulaToken& rToken = *pTokens[nPos]; switch ( rToken.GetType() ) @@ -397,13 +418,13 @@ void CompileODFFormulaToExcel( ScDocument* pDoc, const String& rOldFormula, Stri { return; } - USHORT nLen = pCode->GetLen(); + sal_uInt16 nLen = pCode->GetLen(); formula::FormulaToken** pTokens = pCode->GetArray(); - for ( USHORT nPos = 0; nPos < nLen && pTokens[nPos]; nPos++ ) + for ( sal_uInt16 nPos = 0; nPos < nLen && pTokens[nPos]; nPos++ ) { String rFormula; formula::FormulaToken* pToken = pTokens[nPos]; - aCompiler.CreateStringFromToken( rFormula, pToken, TRUE ); + aCompiler.CreateStringFromToken( rFormula, pToken, true ); if ( pToken->GetOpCode() == ocSep ) { // Excel formula separator is ",". @@ -419,19 +440,34 @@ getUnoSheetModuleObj( const uno::Reference< sheet::XSheetCellRangeContainer >& x uno::Reference< container::XEnumerationAccess > xEnumAccess( xRanges, uno::UNO_QUERY_THROW ); uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration(); uno::Reference< table::XCellRange > xRange( xEnum->nextElement(), uno::UNO_QUERY_THROW ); - return getUnoSheetModuleObj( xRange ); } +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< table::XCell >& xCell ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSheetCellRange > xSheetRange( xCell, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheet > xSheet( xSheetRange->getSpreadsheet(), uno::UNO_SET_THROW ); + return getUnoSheetModuleObj( xSheet ); +} + +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< frame::XModel >& xModel, SCTAB nTab ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSpreadsheetDocument > xDoc( xModel, uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexAccess > xSheets( xDoc->getSheets(), uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheet > xSheet( xSheets->getByIndex( nTab ), uno::UNO_QUERY_THROW ); + return getUnoSheetModuleObj( xSheet ); +} + SfxItemSet* ScVbaCellRangeAccess::GetDataSet( ScCellRangesBase* pRangeObj ) { return pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : 0; } +// ============================================================================ -} //excel -} //vba -} //ooo - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +} // namespace excel +} // namespace vba +} // namespace ooo diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx index 7eff6768aa96..4534cb1dd918 100644 --- a/sc/source/ui/vba/excelvbahelper.hxx +++ b/sc/source/ui/vba/excelvbahelper.hxx @@ -28,56 +28,68 @@ #ifndef SC_EXCEL_VBA_HELPER_HXX #define SC_EXCEL_VBA_HELPER_HXX -#include<vbahelper/vbahelper.hxx> -#include <docsh.hxx> +#include <vbahelper/vbahelper.hxx> +#include "docsh.hxx" #include <com/sun/star/sheet/XDatabaseRanges.hpp> #include <com/sun/star/sheet/XDatabaseRange.hpp> #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> #include <ooo/vba/XHelperInterface.hpp> #include <formula/grammar.hxx> class ScCellRangesBase; -namespace ooo +namespace ooo { +namespace vba { +namespace excel { + +// ============================================================================ + +// nTabs empty means apply zoom to all sheets +void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs ); +void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel ); +void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel ); +void implnCut( const css::uno::Reference< css::frame::XModel>& xModel ); +void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose); +void implnCopyRange( const css::uno::Reference< css::frame::XModel>& xModel, const ScRange& rRange ); +ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; +ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; +ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext ); +SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel ); + +sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const ::rtl::OUString& sRangeStr ); +formula::FormulaGrammar::Grammar GetFormulaGrammar( ScDocument* pDoc, const ScAddress& sAddress, const css::uno::Any& aFormula ); +void CompileExcelFormulaToODF( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula ); +void CompileODFFormulaToExcel( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula, const formula::FormulaGrammar::Grammar eGrammar ); +css::uno::Reference< css::sheet::XDatabaseRanges > GetDataBaseRanges( ScDocShell* pShell ) throw ( css::uno::RuntimeException ); + +css::uno::Reference< css::sheet::XDatabaseRange > GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet, rtl::OUString& sName ) throw ( css::uno::RuntimeException ); +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSpreadsheet >& xSheet ) throw ( css::uno::RuntimeException ); +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException ); +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCell >& xCell ) throw ( css::uno::RuntimeException ); +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::frame::XModel >& xModel, SCTAB nTab ) throw ( css::uno::RuntimeException ); + +ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); +ScDocShell* GetDocShellFromRanges( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); +ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); +css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); + +// ============================================================================ + +class ScVbaCellRangeAccess { - namespace vba - { - namespace excel - { - // nTabs empty means apply zoom to all sheets - void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs ); - void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnCut( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose); - void implnCopyRange( const css::uno::Reference< css::frame::XModel>& xModel, const ScRange& rRange ); - ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; - ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; - ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext ); - SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel ); - sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const ::rtl::OUString& sRangeStr ); - formula::FormulaGrammar::Grammar GetFormulaGrammar( ScDocument* pDoc, const ScAddress& sAddress, const css::uno::Any& aFormula ); - void CompileExcelFormulaToODF( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula ); - void CompileODFFormulaToExcel( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula, const formula::FormulaGrammar::Grammar eGrammar ); - css::uno::Reference< css::sheet::XDatabaseRanges > GetDataBaseRanges( ScDocShell* pShell ) throw ( css::uno::RuntimeException ); +public: + static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj ); +}; + +// ============================================================================ - css::uno::Reference< css::sheet::XDatabaseRange > GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet, rtl::OUString& sName ) throw ( css::uno::RuntimeException ); - css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); - css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException ); - ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); - ScDocShell* GetDocShellFromRanges( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); - ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); - css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); +} // namespace excel +} // namespace vba +} // namespace ooo - class ScVbaCellRangeAccess - { - public: - static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj ); - }; - } - } -} #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk index a937849d3ed4..bd355b184668 100644 --- a/sc/source/ui/vba/makefile.mk +++ b/sc/source/ui/vba/makefile.mk @@ -37,13 +37,6 @@ VISIBILITY_HIDDEN=TRUE .INCLUDE : settings.mk DLLPRE = -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vba..." -.ENDIF - -CDEFS+=-DVBA_OOBUILD_HACK - .IF "$(L10N_framework)"=="" INCPRE=$(INCCOM)$/$(TARGET) @@ -123,15 +116,3 @@ SLOFILES= \ .INCLUDE : target.mk -.IF "$(L10N_framework)"=="" - -ALLTAR : \ - $(MISC)$/$(TARGET).don \ - -$(SLOFILES) : $(MISC)$/$(TARGET).don - -$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb - +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@ - echo $@ - -.ENDIF diff --git a/sc/source/ui/vba/service.cxx b/sc/source/ui/vba/service.cxx index 05dc4ab91820..56ed8a38fc6f 100644 --- a/sc/source/ui/vba/service.cxx +++ b/sc/source/ui/vba/service.cxx @@ -85,16 +85,6 @@ extern "C" *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) - { - OSL_TRACE("In component_writeInfo"); - - // Component registration - return component_writeInfoHelper( pServiceManager, pRegistryKey, - range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl ); - } - SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) diff --git a/sc/source/ui/vba/testvba/makefile.mk b/sc/source/ui/vba/testvba/makefile.mk index 20bdeca5271c..c75f6f63296c 100644 --- a/sc/source/ui/vba/testvba/makefile.mk +++ b/sc/source/ui/vba/testvba/makefile.mk @@ -36,11 +36,6 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk DLLPRE = -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vba..." -.ENDIF - INCPRE=$(INCCOM)$/$(TARGET) CDEFS+=-DVBA_OOBUILD_HACK diff --git a/sc/source/ui/vba/testvba/testvba.cxx b/sc/source/ui/vba/testvba/testvba.cxx index d93f2515cc35..4a318098684e 100644 --- a/sc/source/ui/vba/testvba/testvba.cxx +++ b/sc/source/ui/vba/testvba/testvba.cxx @@ -132,7 +132,7 @@ mxCompLoader( _xCompLoader ), msOutDirPath( convertToURL( _outDirPath ) ) // Loading the wanted document Sequence< PropertyValue > propertyValues(1); propertyValues[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Hidden" )); - propertyValues[0].Value <<= sal_False; + propertyValues[0].Value <<= false; rtl::OUString sfileUrl = convertToURL( sUrl ); printf( "try to get xDoc %s\n", rtl::OUStringToOString( sfileUrl, RTL_TEXTENCODING_UTF8 ).getStr() ); @@ -208,7 +208,7 @@ mxCompLoader( _xCompLoader ), msOutDirPath( convertToURL( _outDirPath ) ) // if only one frame and model, click a button which related will colse. // will make a crash. It related with window listener. // so, for run all test cases, it should not close the document at this moment. - xCloseable->close(sal_False); + xCloseable->close(false); printf("closed\n"); } else @@ -237,7 +237,7 @@ mxCompLoader( _xCompLoader ), msOutDirPath( convertToURL( _outDirPath ) ) throw lang::IllegalArgumentException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "not a directory: ")).concat( sFileDirectoryURL ), Reference<uno::XInterface>(), 1 ); } // Getting all files and directories in the current directory - Sequence<OUString> entries = mxSFA->getFolderContents( sFileDirectoryURL, sal_False ); + Sequence<OUString> entries = mxSFA->getFolderContents( sFileDirectoryURL, false ); // Iterating for each file and directory printf( "Entries %d\n", (int)entries.getLength() ); diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index d54ea2bdff59..817ec1ecbf4a 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -82,6 +82,7 @@ #include "appoptio.hxx" #include <osl/file.hxx> +#include <rtl/instance.hxx> #include <map> @@ -149,11 +150,32 @@ public: ActiveWorkbook( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext) : ScVbaWorkbook( xParent, xContext ){} }; +// ============================================================================ + +/** Global application settings shared by all open workbooks. */ +struct ScVbaAppSettings +{ + sal_Int32 mnCalculation; + sal_Bool mbDisplayAlerts; + sal_Bool mbEnableEvents; + + explicit ScVbaAppSettings(); +}; + +ScVbaAppSettings::ScVbaAppSettings() : + mnCalculation( excel::XlCalculation::xlCalculationAutomatic ), + mbDisplayAlerts( sal_True ), + mbEnableEvents( sal_True ) +{ +} + +struct ScVbaStaticAppSettings : public ::rtl::Static< ScVbaAppSettings, ScVbaStaticAppSettings > {}; + +// ============================================================================ + ScVbaApplication::ScVbaApplication( const uno::Reference<uno::XComponentContext >& xContext ) : ScVbaApplication_BASE( xContext ), - m_xCalculation( excel::XlCalculation::xlCalculationAutomatic ), - m_bDisplayAlerts( sal_True ), - m_bEnableEvents( sal_True ) + mrAppSettings( ScVbaStaticAppSettings::get() ) { } @@ -161,6 +183,11 @@ ScVbaApplication::~ScVbaApplication() { } +/*static*/ bool ScVbaApplication::getDocumentEventsEnabled() +{ + return ScVbaStaticAppSettings::get().mbEnableEvents; +} + SfxObjectShell* ScVbaApplication::GetDocShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) { return static_cast< SfxObjectShell* >( excel::getDocShell( xModel ) ); @@ -301,7 +328,7 @@ ScVbaApplication::getSelection() throw (uno::RuntimeException) OUString aPropName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_FILTERED_RANGE_SELECTION ) ); uno::Any aOldVal = xPropSet->getPropertyValue( aPropName ); uno::Any any; - any <<= sal_False; + any <<= false; xPropSet->setPropertyValue( aPropName, any ); uno::Reference< uno::XInterface > aSelection = ScUnoHelpFunctions::AnyToInterface( xSelSupp->getSelection() ); @@ -457,7 +484,7 @@ ScVbaApplication::getCutCopyMode() throw (uno::RuntimeException) } else { - result <<= sal_False; + result <<= false; } return result; } @@ -466,7 +493,7 @@ void SAL_CALL ScVbaApplication::setCutCopyMode( const uno::Any& _cutcopymode ) throw (uno::RuntimeException) { // According to Excel's behavior, no matter what is the value of _cutcopymode, always releases the clip object. - sal_Bool bCutCopyMode = sal_False; + sal_Bool bCutCopyMode = false; if ( ( _cutcopymode >>= bCutCopyMode ) ) { ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( NULL ); @@ -514,19 +541,21 @@ void SAL_CALL ScVbaApplication::setStatusBar( const uno::Any& _statusbar ) throw (uno::RuntimeException) { rtl::OUString sText; - sal_Bool bDefault = sal_False; + sal_Bool bDefault = false; uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); uno::Reference< task::XStatusIndicatorSupplier > xStatusIndicatorSupplier( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); uno::Reference< task::XStatusIndicator > xStatusIndicator( xStatusIndicatorSupplier->getStatusIndicator(), uno::UNO_QUERY_THROW ); if( _statusbar >>= sText ) { setDisplayStatusBar( sal_True ); - xStatusIndicator->start( sText, 100 ); - //xStatusIndicator->setText( sText ); + if ( sText.getLength() ) + xStatusIndicator->start( sText, 100 ); + else + xStatusIndicator->end(); // restore normal state for empty text } else if( _statusbar >>= bDefault ) { - if( bDefault == sal_False ) + if( bDefault == false ) { xStatusIndicator->end(); setDisplayStatusBar( sal_True ); @@ -540,6 +569,7 @@ ScVbaApplication::setStatusBar( const uno::Any& _statusbar ) throw (uno::Runtime ::sal_Int32 SAL_CALL ScVbaApplication::getCalculation() throw (uno::RuntimeException) { + // TODO: in Excel, this is an application-wide setting uno::Reference<sheet::XCalculatable> xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW); if(xCalc->isAutomaticCalculationEnabled()) return excel::XlCalculation::xlCalculationAutomatic; @@ -550,11 +580,12 @@ ScVbaApplication::getCalculation() throw (uno::RuntimeException) void SAL_CALL ScVbaApplication::setCalculation( ::sal_Int32 _calculation ) throw (uno::RuntimeException) { + // TODO: in Excel, this is an application-wide setting uno::Reference< sheet::XCalculatable > xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW); switch(_calculation) { case excel::XlCalculation::xlCalculationManual: - xCalc->enableAutomaticCalculation(sal_False); + xCalc->enableAutomaticCalculation(false); break; case excel::XlCalculation::xlCalculationAutomatic: case excel::XlCalculation::xlCalculationSemiautomatic: @@ -575,7 +606,6 @@ void SAL_CALL ScVbaApplication::wait( double time ) throw (uno::RuntimeException) { StarBASIC* pBasic = SFX_APP()->GetBasic(); - SFX_APP()->EnterBasicCall(); SbxArrayRef aArgs = new SbxArray; SbxVariableRef aRef = new SbxVariable; aRef->PutDouble( time ); @@ -589,8 +619,6 @@ ScVbaApplication::wait( double time ) throw (uno::RuntimeException) // forces a broadcast SbxVariableRef pNew = new SbxMethod( *((SbxMethod*)pMeth)); } - SFX_APP()->LeaveBasicCall(); - } uno::Any SAL_CALL @@ -656,12 +684,12 @@ void SAL_CALL ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) throw (uno::RuntimeException) { //test Scroll is a boolean - sal_Bool bScroll = sal_False; + sal_Bool bScroll = false; //R1C1-style string or a string of procedure name. if( Scroll.hasValue() ) { - sal_Bool aScroll = sal_False; + sal_Bool aScroll = false; if( Scroll >>= aScroll ) { bScroll = aScroll; @@ -783,7 +811,7 @@ ScVbaApplication::setCursor( sal_Int32 _cursor ) throw (uno::RuntimeException) case excel::XlMousePointer::xlNorthwestArrow: { const Pointer& rPointer( POINTER_ARROW ); - setCursorHelper( xModel, rPointer, sal_False ); + setCursorHelper( xModel, rPointer, false ); break; } case excel::XlMousePointer::xlWait: @@ -797,7 +825,7 @@ ScVbaApplication::setCursor( sal_Int32 _cursor ) throw (uno::RuntimeException) case excel::XlMousePointer::xlDefault: { const Pointer& rPointer( POINTER_NULL ); - setCursorHelper( xModel, rPointer, sal_False ); + setCursorHelper( xModel, rPointer, false ); break; } default: @@ -831,25 +859,25 @@ ScVbaApplication::getName() throw (uno::RuntimeException) void SAL_CALL ScVbaApplication::setDisplayAlerts(sal_Bool displayAlerts) throw (uno::RuntimeException) { - m_bDisplayAlerts = displayAlerts; + mrAppSettings.mbDisplayAlerts = displayAlerts; } sal_Bool SAL_CALL ScVbaApplication::getDisplayAlerts() throw (uno::RuntimeException) { - return m_bDisplayAlerts; + return mrAppSettings.mbDisplayAlerts; } void SAL_CALL ScVbaApplication::setEnableEvents(sal_Bool bEnable) throw (uno::RuntimeException) { - m_bEnableEvents = bEnable; + mrAppSettings.mbEnableEvents = bEnable; } sal_Bool SAL_CALL ScVbaApplication::getEnableEvents() throw (uno::RuntimeException) { - return m_bEnableEvents; + return mrAppSettings.mbEnableEvents; } sal_Bool SAL_CALL @@ -1317,7 +1345,7 @@ ScVbaApplication::Volatile( const uno::Any& aVolatile ) throw ( uno::RuntimeExc ::sal_Bool SAL_CALL ScVbaApplication::getDisplayFormulaBar() throw ( css::uno::RuntimeException ) { - sal_Bool bRes = sal_False; + sal_Bool bRes = false; ScTabViewShell* pViewShell = excel::getCurrentBestViewShell( mxContext ); if ( pViewShell ) { @@ -1327,7 +1355,7 @@ ScVbaApplication::getDisplayFormulaBar() throw ( css::uno::RuntimeException ) pViewShell->GetState( reqList ); const SfxPoolItem *pItem=0; - if ( reqList.GetItemState( FID_TOGGLEINPUTLINE, sal_False, &pItem ) == SFX_ITEM_SET ) + if ( reqList.GetItemState( FID_TOGGLEINPUTLINE, false, &pItem ) == SFX_ITEM_SET ) bRes = ((SfxBoolItem*)pItem)->GetValue(); } return bRes; @@ -1350,7 +1378,6 @@ uno::Any SAL_CALL ScVbaApplication::Caller( const uno::Any& /*aIndex*/ ) throw ( uno::RuntimeException ) { StarBASIC* pBasic = SFX_APP()->GetBasic(); - SFX_APP()->EnterBasicCall(); SbMethod* pMeth = (SbMethod*)pBasic->GetRtl()->Find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FuncCaller") ), SbxCLASS_METHOD ); uno::Any aRet; if ( pMeth ) @@ -1361,14 +1388,13 @@ ScVbaApplication::Caller( const uno::Any& /*aIndex*/ ) throw ( uno::RuntimeExcep OSL_TRACE("pNew has type %d and string value %s", pNew->GetType(), rtl::OUStringToOString( pNew->GetString(), RTL_TEXTENCODING_UTF8 ).getStr() ); aRet = sbxToUnoValue( pNew ); } - SFX_APP()->LeaveBasicCall(); return aRet; } uno::Any SAL_CALL ScVbaApplication::GetOpenFilename(const uno::Any& FileFilter, const uno::Any& FilterIndex, const uno::Any& Title, const uno::Any& ButtonText, const uno::Any& MultiSelect) throw (uno::RuntimeException) { - uno::Any aRet = uno::makeAny( sal_False ); + uno::Any aRet = uno::makeAny( false ); try { const rtl::OUString sServiceName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" )); @@ -1426,7 +1452,7 @@ ScVbaApplication::GetOpenFilename(const uno::Any& FileFilter, const uno::Any& Fi ButtonText >>= sButtonText; xPickerControlAccess->setLabel( ui::dialogs::CommonFilePickerElementIds::PUSHBUTTON_OK, sButtonText ); } - sal_Bool bMultiSelect = sal_False; + sal_Bool bMultiSelect = false; if ( xFilePicker.is() && MultiSelect.hasValue() ) { MultiSelect >>= bMultiSelect; @@ -1435,7 +1461,7 @@ ScVbaApplication::GetOpenFilename(const uno::Any& FileFilter, const uno::Any& Fi if ( xFilePicker.is() && xFilePicker->execute() ) { - sal_Bool bUseXFilePicker2 = sal_False; + sal_Bool bUseXFilePicker2 = false; uno::Reference< lang::XServiceInfo > xServiceInfo( xFilePicker, UNO_QUERY ); if ( xServiceInfo.is() ) { @@ -1604,7 +1630,7 @@ ScVbaApplication::GetSaveAsFilename( const ::com::sun::star::uno::Any& InitialFi sal_Int16 nRet = xFilePicker->execute(); if (nRet == 0) { - strRet <<= sal_False; + strRet <<= false; } else { @@ -1636,7 +1662,7 @@ ScVbaApplication::GetSaveAsFilename( const ::com::sun::star::uno::Any& InitialFi } else { - sal_Bool bValidFilter = sal_False; + sal_Bool bValidFilter = false; FileFilterMap::const_iterator aIt = mFilterNameMap.begin(); while ( aIt != mFilterNameMap.end() ) { diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx index bc047b82c7b9..84816902088d 100644 --- a/sc/source/ui/vba/vbaapplication.hxx +++ b/sc/source/ui/vba/vbaapplication.hxx @@ -39,12 +39,13 @@ typedef cppu::ImplInheritanceHelper1< VbaApplicationBase, ov::excel::XApplication > ScVbaApplication_BASE; +struct ScVbaAppSettings; + class ScVbaApplication : public ScVbaApplication_BASE { private: - sal_Int32 m_xCalculation; - sal_Bool m_bDisplayAlerts; - sal_Bool m_bEnableEvents; + // note: member variables moved to struct "ScVbaAppSettings", see cxx file, to be shared by all application instances + ScVbaAppSettings& mrAppSettings; rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException ); css::uno::Reference< ov::XFileSearch > m_xFileSearch; @@ -56,6 +57,9 @@ public: ScVbaApplication( const css::uno::Reference< css::uno::XComponentContext >& m_xContext ); virtual ~ScVbaApplication(); + /** Returns true, if VBA document events are enabled. */ + static bool getDocumentEventsEnabled(); + virtual SfxObjectShell* GetDocShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException); // XExactName diff --git a/sc/source/ui/vba/vbaassistant.cxx b/sc/source/ui/vba/vbaassistant.cxx index 126719c6fd56..3c91b9cde00b 100644 --- a/sc/source/ui/vba/vbaassistant.cxx +++ b/sc/source/ui/vba/vbaassistant.cxx @@ -41,7 +41,7 @@ using namespace ooo::vba::office::MsoAnimationType; ScVbaAssistant::ScVbaAssistant( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext ): ScVbaAssistantImpl_BASE( xParent, xContext ), m_sName( RTL_CONSTASCII_USTRINGPARAM( "Clippit" ) ) { - m_bIsVisible = sal_False; + m_bIsVisible = false; m_nPointsLeft = 795; m_nPointsTop = 248; m_nAnimation = msoAnimationIdle; @@ -66,7 +66,7 @@ sal_Bool SAL_CALL ScVbaAssistant::getOn() throw (uno::RuntimeException) if( SvtHelpOptions().IsHelpAgentAutoStartMode() ) return sal_True; else - return sal_False; + return false; } void SAL_CALL ScVbaAssistant::setOn( sal_Bool bOn ) throw (uno::RuntimeException) diff --git a/sc/source/ui/vba/vbaaxes.cxx b/sc/source/ui/vba/vbaaxes.cxx index 9005ffdf6069..ae182c8a795e 100644 --- a/sc/source/ui/vba/vbaaxes.cxx +++ b/sc/source/ui/vba/vbaaxes.cxx @@ -168,7 +168,7 @@ ScVbaAxes::Item( const css::uno::Any& _nType, const css::uno::Any& _oAxisGroup) // bodgy helperapi port bits sal_Int32 nAxisGroup = xlPrimary; sal_Int32 nType = -1; - if ( !_nType.hasValue() || ( ( _nType >>= nType ) == sal_False ) ) + if ( !_nType.hasValue() || ( ( _nType >>= nType ) == false ) ) throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Axes::Item Failed to extract type" )), uno::Reference< uno::XInterface >() ); if ( _oAxisGroup.hasValue() ) diff --git a/sc/source/ui/vba/vbaaxis.cxx b/sc/source/ui/vba/vbaaxis.cxx index 3cab8e7cea53..843b278fcbfc 100644 --- a/sc/source/ui/vba/vbaaxis.cxx +++ b/sc/source/ui/vba/vbaaxis.cxx @@ -61,7 +61,7 @@ ScVbaAxis::isValueAxis() throw( script::BasicErrorException ) return sal_True; } -ScVbaAxis::ScVbaAxis( const uno::Reference< XHelperInterface >& xParent,const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, sal_Int32 _nType, sal_Int32 _nGroup ) : ScVbaAxis_BASE( xParent, xContext ), mxPropertySet( _xPropertySet ), mnType( _nType ), mnGroup( _nGroup ), bCrossesAreCustomized( sal_False ) +ScVbaAxis::ScVbaAxis( const uno::Reference< XHelperInterface >& xParent,const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, sal_Int32 _nType, sal_Int32 _nGroup ) : ScVbaAxis_BASE( xParent, xContext ), mxPropertySet( _xPropertySet ), mnType( _nType ), mnGroup( _nGroup ), bCrossesAreCustomized( false ) { oShapeHelper.reset( new ShapeHelper( uno::Reference< drawing::XShape >( mxPropertySet, uno::UNO_QUERY ) ) ); moChartParent.set( xParent, uno::UNO_QUERY_THROW ); @@ -132,23 +132,23 @@ ScVbaAxis::setCrosses( ::sal_Int32 _nCrosses ) throw (script::BasicErrorExceptio { case xlAxisCrossesAutomatic: //Microsoft Excel sets the axis crossing point. mxPropertySet->setPropertyValue(AUTOORIGIN, uno::makeAny( sal_True ) ); - bCrossesAreCustomized = sal_False; + bCrossesAreCustomized = false; return; case xlAxisCrossesMinimum: // The axis crosses at the minimum value. mxPropertySet->getPropertyValue(VBA_MIN) >>= fNum; setCrossesAt( fNum ); - bCrossesAreCustomized = sal_False; + bCrossesAreCustomized = false; break; case xlAxisCrossesMaximum: // The axis crosses at the maximum value. mxPropertySet->getPropertyValue(VBA_MAX) >>= fNum; setCrossesAt(fNum); - bCrossesAreCustomized = sal_False; + bCrossesAreCustomized = false; break; default: //xlAxisCrossesCustom bCrossesAreCustomized = sal_True; break; } - mxPropertySet->setPropertyValue(AUTOORIGIN, uno::makeAny(sal_False) ); + mxPropertySet->setPropertyValue(AUTOORIGIN, uno::makeAny(false) ); } catch (uno::Exception& ) { @@ -161,7 +161,7 @@ ScVbaAxis::getCrosses( ) throw (script::BasicErrorException, uno::RuntimeExcept sal_Int32 nCrosses = xlAxisCrossesCustom; try { - sal_Bool bisAutoOrigin = sal_False; + sal_Bool bisAutoOrigin = false; mxPropertySet->getPropertyValue(AUTOORIGIN) >>= bisAutoOrigin; if (bisAutoOrigin) nCrosses = xlAxisCrossesAutomatic; @@ -194,8 +194,8 @@ ScVbaAxis::setCrossesAt( double _fCrossesAt ) throw (script::BasicErrorException { try { - setMaximumScaleIsAuto( sal_False ); - setMinimumScaleIsAuto( sal_False ); + setMaximumScaleIsAuto( false ); + setMinimumScaleIsAuto( false ); mxPropertySet->setPropertyValue(ORIGIN, uno::makeAny(_fCrossesAt)); } catch (uno::Exception& e) @@ -260,7 +260,7 @@ ScVbaAxis::setHasTitle( ::sal_Bool _bHasTitle ) throw (script::BasicErrorExcepti ::sal_Bool SAL_CALL ScVbaAxis::getHasTitle( ) throw (script::BasicErrorException, uno::RuntimeException) { - sal_Bool bHasTitle = sal_False; + sal_Bool bHasTitle = false; try { ScVbaChart* pChart = getChartPtr(); @@ -331,7 +331,7 @@ ScVbaAxis::setMinorUnitIsAuto( ::sal_Bool _bMinorUnitIsAuto ) throw (script::Bas ::sal_Bool SAL_CALL ScVbaAxis::getMinorUnitIsAuto( ) throw (script::BasicErrorException, uno::RuntimeException) { - sal_Bool bIsAuto = sal_False; + sal_Bool bIsAuto = false; try { if (isValueAxis()) @@ -356,7 +356,7 @@ ScVbaAxis::setReversePlotOrder( ::sal_Bool /*ReversePlotOrder*/ ) throw (script: ScVbaAxis::getReversePlotOrder( ) throw (script::BasicErrorException, uno::RuntimeException) { DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString()); - return sal_False; + return false; } void SAL_CALL @@ -410,7 +410,7 @@ ScVbaAxis::setMajorUnitIsAuto( ::sal_Bool _bMajorUnitIsAuto ) throw (script::Bas ::sal_Bool SAL_CALL ScVbaAxis::getMajorUnitIsAuto( ) throw (script::BasicErrorException, uno::RuntimeException) { - sal_Bool bIsAuto = sal_False; + sal_Bool bIsAuto = false; try { if (isValueAxis()) @@ -479,7 +479,7 @@ ScVbaAxis::setMaximumScaleIsAuto( ::sal_Bool _bMaximumScaleIsAuto ) throw (scrip ::sal_Bool SAL_CALL ScVbaAxis::getMaximumScaleIsAuto( ) throw (script::BasicErrorException, uno::RuntimeException) { - sal_Bool bIsAuto = sal_False; + sal_Bool bIsAuto = false; try { if (isValueAxis()) @@ -541,7 +541,7 @@ ScVbaAxis::setMinimumScaleIsAuto( ::sal_Bool _bMinimumScaleIsAuto ) throw (scrip ::sal_Bool SAL_CALL ScVbaAxis::getMinimumScaleIsAuto( ) throw (script::BasicErrorException, uno::RuntimeException) { - sal_Bool bIsAuto = sal_False; + sal_Bool bIsAuto = false; try { if (isValueAxis()) @@ -597,7 +597,7 @@ ScVbaAxis::getScaleType( ) throw (script::BasicErrorException, uno::RuntimeExce { if (isValueAxis()) { - sal_Bool bisLogarithmic = sal_False; + sal_Bool bisLogarithmic = false; mxPropertySet->getPropertyValue( rtl::OUString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Logarithmic"))) ) >>= bisLogarithmic; if (bisLogarithmic) nScaleType = xlScaleLogarithmic; diff --git a/sc/source/ui/vba/vbacharacters.cxx b/sc/source/ui/vba/vbacharacters.cxx index 011b0a4a72e1..2b163afc2a74 100644 --- a/sc/source/ui/vba/vbacharacters.cxx +++ b/sc/source/ui/vba/vbacharacters.cxx @@ -47,8 +47,8 @@ ScVbaCharacters::ScVbaCharacters( const uno::Reference< XHelperInterface >& xPar { if ( ( nStart + 1 ) > m_xSimpleText->getString().getLength() ) //nStart = m_xSimpleText->getString().getLength(); - xTextCursor->gotoEnd( sal_False ); - xTextCursor->goRight( nStart, sal_False ); + xTextCursor->gotoEnd( false ); + xTextCursor->goRight( nStart, false ); } if ( nLength < 0 ) // expand to end xTextCursor->gotoEnd( sal_True ); diff --git a/sc/source/ui/vba/vbacharacters.hxx b/sc/source/ui/vba/vbacharacters.hxx index df2fcf348619..b9711fcb86df 100644 --- a/sc/source/ui/vba/vbacharacters.hxx +++ b/sc/source/ui/vba/vbacharacters.hxx @@ -49,7 +49,7 @@ private: // Add becuase of MSO has diferent behavior. sal_Bool bReplace; public: - ScVbaCharacters( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const ScVbaPalette& dPalette, const css::uno::Reference< css::text::XSimpleText >& xRange, const css::uno::Any& Start, const css::uno::Any& Length, sal_Bool bReplace = sal_False ) throw ( css::lang::IllegalArgumentException ); + ScVbaCharacters( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const ScVbaPalette& dPalette, const css::uno::Reference< css::text::XSimpleText >& xRange, const css::uno::Any& Start, const css::uno::Any& Length, sal_Bool bReplace = false ) throw ( css::lang::IllegalArgumentException ); virtual ~ScVbaCharacters() {} // Attributes diff --git a/sc/source/ui/vba/vbachart.cxx b/sc/source/ui/vba/vbachart.cxx index c46569a8c44d..1377291fcb24 100644 --- a/sc/source/ui/vba/vbachart.cxx +++ b/sc/source/ui/vba/vbachart.cxx @@ -166,7 +166,7 @@ ScVbaChart::getChartType() throw ( uno::RuntimeException, script::BasicErrorExce } else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.StockDiagram")))) { - sal_Bool bVolume = sal_False; + sal_Bool bVolume = false; mxDiagramPropertySet->getPropertyValue(VOLUME) >>= bVolume; if (bVolume) { @@ -179,7 +179,7 @@ ScVbaChart::getChartType() throw ( uno::RuntimeException, script::BasicErrorExce } else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.XYDiagram")))) { - sal_Bool bHasLines = sal_False; + sal_Bool bHasLines = false; mxDiagramPropertySet->getPropertyValue(LINES) >>= bHasLines; sal_Int32 nSplineType = 0; mxDiagramPropertySet->getPropertyValue(SPLINETYPE) >>= nSplineType; @@ -583,8 +583,8 @@ ScVbaChart::setSourceData( const css::uno::Reference< ::ooo::vba::excel::XRange mxTableChart->setRanges(mRangeAddresses); - sal_Bool bsetRowHeaders = sal_False; - sal_Bool bsetColumnHeaders = sal_False; + sal_Bool bsetRowHeaders = false; + sal_Bool bsetColumnHeaders = false; ScVbaRange* pRange = static_cast< ScVbaRange* >( _xCalcRange.get() ); if ( pRange ) @@ -822,7 +822,7 @@ ScVbaChart::setLocation( ::sal_Int32 /*where*/, const css::uno::Any& /*Name*/ ) sal_Bool SAL_CALL ScVbaChart::getHasTitle( ) throw (script::BasicErrorException, uno::RuntimeException) { - sal_Bool bHasTitle = sal_False; + sal_Bool bHasTitle = false; try { mxChartPropertySet->getPropertyValue(HASMAINTITLE) >>= bHasTitle; @@ -851,7 +851,7 @@ ScVbaChart::setHasTitle( ::sal_Bool bTitle ) throw (script::BasicErrorException, ::sal_Bool SAL_CALL ScVbaChart::getHasLegend( ) throw (script::BasicErrorException, uno::RuntimeException) { - sal_Bool bHasLegend = sal_False; + sal_Bool bHasLegend = false; try { mxChartPropertySet->getPropertyValue(HASLEGEND) >>= bHasLegend; @@ -897,7 +897,7 @@ bool ScVbaChart::is3D() throw ( uno::RuntimeException ) { // #TODO perhaps provide limited Debughelper functionality - sal_Bool is3d = sal_False; + sal_Bool is3d = false; mxDiagramPropertySet->getPropertyValue(DIM3D) >>= is3d; return is3d; } @@ -921,7 +921,7 @@ bool ScVbaChart::isStacked() throw ( uno::RuntimeException ) { // #TODO perhaps provide limited Debughelper functionality - sal_Bool bStacked = sal_False; + sal_Bool bStacked = false; mxDiagramPropertySet->getPropertyValue(STACKED) >>= bStacked; return bStacked; } @@ -930,7 +930,7 @@ bool ScVbaChart::is100PercentStacked() throw ( uno::RuntimeException ) { // #TODO perhaps provide limited Debughelper functionality - sal_Bool b100Percent = sal_False; + sal_Bool b100Percent = false; mxDiagramPropertySet->getPropertyValue(PERCENT) >>= b100Percent; return b100Percent; } @@ -971,7 +971,7 @@ ScVbaChart::getSolidType(sal_Int32 _nDeep, sal_Int32 _nVertiStacked, sal_Int32 _ sal_Int32 ScVbaChart::getStockUpDownValue(sal_Int32 _nUpDown, sal_Int32 _nNotUpDown) throw (script::BasicErrorException) { - sal_Bool bUpDown = sal_False; + sal_Bool bUpDown = false; try { mxDiagramPropertySet->getPropertyValue(UPDOWN) >>= bUpDown; diff --git a/sc/source/ui/vba/vbacomment.cxx b/sc/source/ui/vba/vbacomment.cxx index f707fad1eb13..402d9e9e1667 100644 --- a/sc/source/ui/vba/vbacomment.cxx +++ b/sc/source/ui/vba/vbacomment.cxx @@ -202,14 +202,14 @@ ScVbaComment::Text( const uno::Any& aText, const uno::Any& aStart, const uno::An if ( bOverwrite ) { xTextCursor->collapseToStart(); - xTextCursor->gotoStart( sal_False ); - xTextCursor->goRight( nStart - 1, sal_False ); + xTextCursor->gotoStart( false ); + xTextCursor->goRight( nStart - 1, false ); xTextCursor->gotoEnd( sal_True ); } else { xTextCursor->collapseToStart(); - xTextCursor->gotoStart( sal_False ); + xTextCursor->gotoStart( false ); xTextCursor->goRight( nStart - 1 , sal_True ); } diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index 7cbcc8592721..e22632529617 100644 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -49,6 +49,7 @@ #include "cellsuno.hxx" #include "convuno.hxx" +#include "vbaapplication.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::script::vba::VBAEventId; @@ -56,6 +57,51 @@ using namespace ::ooo::vba; // ============================================================================ +namespace { + +/** Extracts a sheet index from the specified element of the passed sequence. + The element may be an integer, a Calc range or ranges object, or a VBA Range object. */ +SCTAB lclGetTabFromArgs( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException) +{ + VbaEventsHelperBase::checkArgument( rArgs, nIndex ); + + // first try to extract a sheet index + SCTAB nTab = -1; + if( rArgs[ nIndex ] >>= nTab ) + return nTab; + + // try VBA Range object + uno::Reference< excel::XRange > xVbaRange = getXSomethingFromArgs< excel::XRange >( rArgs, nIndex ); + if( xVbaRange.is() ) + { + uno::Reference< XHelperInterface > xVbaHelper( xVbaRange, uno::UNO_QUERY_THROW ); + // TODO: in the future, the parent may be an excel::XChart (chart sheet) -> will there be a common base interface? + uno::Reference< excel::XWorksheet > xVbaSheet( xVbaHelper->getParent(), uno::UNO_QUERY_THROW ); + // VBA sheet index is 1-based + return static_cast< SCTAB >( xVbaSheet->getIndex() - 1 ); + } + + // try single UNO range object + uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable = getXSomethingFromArgs< sheet::XCellRangeAddressable >( rArgs, nIndex ); + if( xCellRangeAddressable.is() ) + return xCellRangeAddressable->getRangeAddress().Sheet; + + // at last, try UNO range list + uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); + if( xRanges.is() ) + { + uno::Sequence< table::CellRangeAddress > aRangeAddresses = xRanges->getRangeAddresses(); + if( aRangeAddresses.getLength() > 0 ) + return aRangeAddresses[ 0 ].Sheet; + } + + throw lang::IllegalArgumentException(); +} + +} // namespace + +// ============================================================================ + typedef ::cppu::WeakImplHelper4< awt::XWindowListener, util::XCloseListener, frame::XBorderResizeListener, util::XChangesListener > ScVbaEventsListener_BASE; @@ -288,7 +334,7 @@ void SAL_CALL ScVbaEventsListener::changesOccurred( const util::ChangesEvent& aE aChange.ReplacedElement >>= xRangeObj; if( xRangeObj.is() ) { - uno::Sequence< uno::Any > aArgs(1); + uno::Sequence< uno::Any > aArgs( 1 ); aArgs[0] <<= xRangeObj; mrVbaEvents.processVbaEvent( WORKSHEET_CHANGE, aArgs ); } @@ -363,8 +409,14 @@ bool ScVbaEventsListener::isMouseReleased() IMPL_LINK( ScVbaEventsListener, fireResizeMacro, void*, EMPTYARG ) { - if( !mbDisposed && isMouseReleased() ) - processWindowResizeMacro(); + if( !mbDisposed && isMouseReleased() ) try + { + mrVbaEvents.processVbaEvent( WORKBOOK_WINDOWRESIZE, uno::Sequence< uno::Any >() ); + } + catch( uno::Exception& ) + { + // #163419# do not throw exceptions into application core + } release(); return 0; } @@ -450,43 +502,19 @@ void SAL_CALL ScVbaEventsHelper::disposing( const lang::EventObject& rSource ) t // protected ------------------------------------------------------------------ -bool ScVbaEventsHelper::implEventsEnabled() throw (uno::RuntimeException) +bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& rArgs ) throw (uno::RuntimeException) { // document and document shell are needed during event processing - if( !mpDocShell || !mpDoc ) + if( !mpShell || !mpDoc ) throw uno::RuntimeException(); - // get Application object and check if events are enabled (this is an Excel-only attribute) - uno::Reference< excel::XApplication > xApplication( mxApplication.get(), uno::UNO_QUERY ); - if( !xApplication.is() && mpShell ) - { - uno::Any aVBAGlobals; - mpShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aVBAGlobals ); - uno::Reference< XHelperInterface > xHelperInterface( aVBAGlobals, uno::UNO_QUERY ); - if( xHelperInterface.is() ) - { - xApplication.set( xHelperInterface->Application(), uno::UNO_QUERY ); - mxApplication = xApplication; - } - } - if( !xApplication.is() ) - throw uno::RuntimeException(); + // framework and Calc fire a few events before 'opened', ignore them + bool bExecuteEvent = mbOpened; - // return whether event processing is enabled - return xApplication->getEnableEvents(); -} - -bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, - const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& rArgs ) throw (uno::RuntimeException) -{ - // check preconditions for some events, add more events if needed - bool bExecuteEvent = true; + // special handling for some events switch( rInfo.mnEventId ) { - case WORKBOOK_ACTIVATE: - // while loading, framework fires this before 'opened' event, delay it - bExecuteEvent = mbOpened; - break; case WORKBOOK_OPEN: bExecuteEvent = !mbOpened; if( bExecuteEvent ) @@ -499,15 +527,25 @@ bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, break; case WORKSHEET_SELECTIONCHANGE: // if selection is not changed, then do not fire the event - bExecuteEvent = mbOpened && isSelectionChanged( rArgs, 0 ); + bExecuteEvent = bExecuteEvent && isSelectionChanged( rArgs, 0 ); break; } - // add workbook event associated to a sheet event - bool bSheetEvent = false; - rInfo.maUserData >>= bSheetEvent; - if( bSheetEvent && bExecuteEvent ) - rEventQueue.push_back( EventQueueEntry( rInfo.mnEventId + USERDEFINED_START, rArgs ) ); + if( bExecuteEvent ) + { + // add workbook event associated to a sheet event + bool bSheetEvent = false; + if( (rInfo.maUserData >>= bSheetEvent) && bSheetEvent ) + rEventQueue.push_back( EventQueueEntry( rInfo.mnEventId + USERDEFINED_START, rArgs ) ); + + /* For document events: check if events are enabled via the + Application.EnableEvents symbol (this is an Excel-only attribute). + Check this again for every event, as the event handler may change + the state of the EnableEvents symbol. Global events such as + AUTO_OPEN and AUTO_CLOSE are always enabled. */ + if( rInfo.meType == EVENTHANDLER_DOCUMENT ) + bExecuteEvent = ScVbaApplication::getDocumentEventsEnabled(); + } return bExecuteEvent; } @@ -631,7 +669,7 @@ void ScVbaEventsHelper::implPostProcessEvent( EventQueue& rEventQueue, { bool bSheetEvent = false; rInfo.maUserData >>= bSheetEvent; - SCTAB nTab = bSheetEvent ? getTabFromArgs( rArgs, 0 ) : -1; + SCTAB nTab = bSheetEvent ? lclGetTabFromArgs( rArgs, 0 ) : -1; if( bSheetEvent && (nTab < 0) ) throw lang::IllegalArgumentException(); @@ -645,32 +683,28 @@ void ScVbaEventsHelper::implPostProcessEvent( EventQueue& rEventQueue, // private -------------------------------------------------------------------- -SCTAB ScVbaEventsHelper::getTabFromArgs( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException) -{ - checkArgument( rArgs, nIndex ); +namespace { - // first try to extract a sheet index - SCTAB nTab = -1; - if( rArgs[ nIndex ] >>= nTab ) - return nTab; +/** Compares the passed range lists representing sheet selections. Ignores + selections that refer to different sheets (returns false in this case). */ +bool lclSelectionChanged( const ScRangeList& rLeft, const ScRangeList& rRight ) +{ + // one of the range lists empty? -> return false, if both lists empty + bool bLeftEmpty = rLeft.empty(); + bool bRightEmpty = rRight.empty(); + if( bLeftEmpty || bRightEmpty ) + return !(bLeftEmpty && bRightEmpty); - // next, try single range object - uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable = getXSomethingFromArgs< sheet::XCellRangeAddressable >( rArgs, nIndex ); - if( xCellRangeAddressable.is() ) - return xCellRangeAddressable->getRangeAddress().Sheet; + // check sheet indexes of the range lists (assuming that all ranges in a list are on the same sheet) + if( rLeft.front()->aStart.Tab() != rRight.front()->aStart.Tab() ) + return false; - // at last, try range list - uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); - if( xRanges.is() ) - { - uno::Sequence< table::CellRangeAddress > aRangeAddresses = xRanges->getRangeAddresses(); - if( aRangeAddresses.getLength() > 0 ) - return aRangeAddresses[ 0 ].Sheet; - } - - throw lang::IllegalArgumentException(); + // compare all ranges + return rLeft != rRight; } +} // namespace + bool ScVbaEventsHelper::isSelectionChanged( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException, uno::RuntimeException) { uno::Reference< uno::XInterface > xNewSelection = getXSomethingFromArgs< uno::XInterface >( rArgs, nIndex, false ); @@ -687,53 +721,46 @@ bool ScVbaEventsHelper::isSelectionChanged( const uno::Sequence< uno::Any >& rAr uno::Any ScVbaEventsHelper::createWorksheet( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const throw (lang::IllegalArgumentException, uno::RuntimeException) { - // Eventually we will be able to pull the Workbook/Worksheet objects - // directly from basic and register them as listeners - // extract sheet index, will throw, if parameter is invalid - SCTAB nTab = getTabFromArgs( rArgs, nIndex ); - - // create Workbook - uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); - aArgs[ 1 ] <<= mxModel; - uno::Reference< uno::XInterface > xWorkbook( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Workbook", aArgs ), uno::UNO_SET_THROW ); - - // create WorkSheet - String aSheetName; - mpDoc->GetName( nTab, aSheetName ); - aArgs = uno::Sequence< uno::Any >( 3 ); - aArgs[ 0 ] <<= xWorkbook; - aArgs[ 1 ] <<= mxModel; - aArgs[ 2 ] <<= ::rtl::OUString( aSheetName ); - uno::Reference< uno::XInterface > xWorksheet( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Worksheet", aArgs ), uno::UNO_SET_THROW ); - return uno::Any( xWorksheet ); + SCTAB nTab = lclGetTabFromArgs( rArgs, nIndex ); + return uno::Any( excel::getUnoSheetModuleObj( mxModel, nTab ) ); } uno::Any ScVbaEventsHelper::createRange( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const throw (lang::IllegalArgumentException, uno::RuntimeException) { - uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); - uno::Reference< table::XCellRange > xRange = getXSomethingFromArgs< table::XCellRange >( rArgs, nIndex ); - if ( !xRanges.is() && !xRange.is() ) - throw lang::IllegalArgumentException(); + // it is possible to pass an existing VBA Range object + uno::Reference< excel::XRange > xVbaRange = getXSomethingFromArgs< excel::XRange >( rArgs, nIndex ); + if( !xVbaRange.is() ) + { + uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); + uno::Reference< table::XCellRange > xRange = getXSomethingFromArgs< table::XCellRange >( rArgs, nIndex ); + if ( !xRanges.is() && !xRange.is() ) + throw lang::IllegalArgumentException(); - uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); // dummy parent - if ( xRanges.is() ) - aArgs[ 1 ] <<= xRanges; - else - aArgs[ 1 ] <<= xRange; - uno::Reference< uno::XInterface > xVbaRange( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Range", aArgs ), uno::UNO_SET_THROW ); + uno::Sequence< uno::Any > aArgs( 2 ); + if ( xRanges.is() ) + { + aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xRanges ); + aArgs[ 1 ] <<= xRanges; + } + else + { + aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xRange ); + aArgs[ 1 ] <<= xRange; + } + xVbaRange.set( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Range", aArgs ), uno::UNO_QUERY_THROW ); + } return uno::Any( xVbaRange ); } uno::Any ScVbaEventsHelper::createHyperlink( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const throw (lang::IllegalArgumentException, uno::RuntimeException) { + uno::Reference< table::XCell > xCell = getXSomethingFromArgs< table::XCell >( rArgs, nIndex, false ); uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); // dummy parent - aArgs[ 1 ] <<= getXSomethingFromArgs< table::XCell >( rArgs, nIndex, false ); + aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xCell ); + aArgs[ 1 ] <<= xCell; uno::Reference< uno::XInterface > xHyperlink( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Hyperlink", aArgs ), uno::UNO_SET_THROW ); return uno::Any( xHyperlink ); } diff --git a/sc/source/ui/vba/vbaeventshelper.hxx b/sc/source/ui/vba/vbaeventshelper.hxx index f0c73dd88d7f..fccbe2873f84 100644 --- a/sc/source/ui/vba/vbaeventshelper.hxx +++ b/sc/source/ui/vba/vbaeventshelper.hxx @@ -34,8 +34,6 @@ #include "excelvbahelper.hxx" #include "rangelst.hxx" -namespace ooo { namespace vba { namespace excel { class XApplication; } } } - class ScVbaEventsListener; // ============================================================================ @@ -52,16 +50,12 @@ public: virtual void SAL_CALL disposing( const css::lang::EventObject& rSource ) throw (css::uno::RuntimeException); protected: - virtual bool implEventsEnabled() throw (css::uno::RuntimeException); virtual bool implPrepareEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException); virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException); virtual void implPostProcessEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, bool bSuccess, bool bCancel ) throw (css::uno::RuntimeException); virtual ::rtl::OUString implGetDocumentModuleName( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException); private: - /** Extracts a sheet index from the first element of the passed sequence. The - element may be an integer, or a Calc range or ranges object. */ - static SCTAB getTabFromArgs( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException); /** Checks if selection has been changed compared to selection of last call. @return true, if the selection has been changed. */ bool isSelectionChanged( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); @@ -76,7 +70,6 @@ private: css::uno::Any createWindow() const throw (css::uno::RuntimeException); private: - mutable css::uno::WeakReference< ov::excel::XApplication > mxApplication; ::rtl::Reference< ScVbaEventsListener > mxListener; ScDocShell* mpDocShell; ScDocument* mpDoc; diff --git a/sc/source/ui/vba/vbafiledialog.cxx b/sc/source/ui/vba/vbafiledialog.cxx index fcb561e2d414..1c5e7382c926 100644 --- a/sc/source/ui/vba/vbafiledialog.cxx +++ b/sc/source/ui/vba/vbafiledialog.cxx @@ -103,7 +103,7 @@ ScVbaFileDialog::Show( ) throw (::com::sun::star::uno::RuntimeException) xFilePicker->setMultiSelectionMode(sal_True); if ( xFilePicker->execute() ) { - sal_Bool bUseXFilePicker2 = sal_False; + sal_Bool bUseXFilePicker2 = false; Reference< lang::XServiceInfo > xServiceInfo( xFilePicker, UNO_QUERY ); if (xServiceInfo.is()) { diff --git a/sc/source/ui/vba/vbafiledialogselecteditems.cxx b/sc/source/ui/vba/vbafiledialogselecteditems.cxx index d8ebc937b489..547841a2c987 100644 --- a/sc/source/ui/vba/vbafiledialogselecteditems.cxx +++ b/sc/source/ui/vba/vbafiledialogselecteditems.cxx @@ -139,7 +139,7 @@ throw (uno::RuntimeException) { return sal_True; } - return sal_False; + return false; } uno::Any SAL_CALL diff --git a/sc/source/ui/vba/vbafont.cxx b/sc/source/ui/vba/vbafont.cxx index 68ade5207674..216b0b7232c4 100644 --- a/sc/source/ui/vba/vbafont.cxx +++ b/sc/source/ui/vba/vbafont.cxx @@ -104,7 +104,7 @@ ScVbaFont::setSuperscript( const uno::Any& aValue ) throw ( uno::RuntimeExceptio xCell.set( xCellRange->getCellByPosition( 0,0 ) ); uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell ); - sal_Bool bValue = sal_False; + sal_Bool bValue = false; aValue >>= bValue; sal_Int16 nValue = NORMAL; sal_Int8 nValue2 = NORMALHEIGHT; @@ -176,7 +176,7 @@ ScVbaFont::setSubscript( const uno::Any& aValue ) throw ( uno::RuntimeException xCell.set( xCellRange->getCellByPosition( 0,0 ) ); uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell ); - sal_Bool bValue = sal_False; + sal_Bool bValue = false; aValue >>= bValue; sal_Int16 nValue = NORMAL; sal_Int8 nValue2 = NORMALHEIGHT; @@ -230,7 +230,7 @@ uno::Any SAL_CALL ScVbaFont::getSize() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_HEIGHT, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_HEIGHT, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getSize(); } @@ -257,7 +257,7 @@ uno::Any SAL_CALL ScVbaFont::getColorIndex() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_COLOR, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_COLOR, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getColorIndex(); } @@ -304,8 +304,8 @@ ScVbaFont::getStandardFont() throw ( uno::RuntimeException ) void SAL_CALL ScVbaFont::setFontStyle( const uno::Any& aValue ) throw( uno::RuntimeException ) { - sal_Bool bBold = sal_False; - sal_Bool bItalic = sal_False; + sal_Bool bBold = false; + sal_Bool bItalic = false; rtl::OUString aStyles; aValue >>= aStyles; @@ -337,7 +337,7 @@ uno::Any SAL_CALL ScVbaFont::getFontStyle() throw ( uno::RuntimeException ) { rtl::OUStringBuffer aStyles; - sal_Bool bValue = sal_False; + sal_Bool bValue = false; getBold() >>= bValue; if( bValue ) aStyles.appendAscii("Bold"); @@ -356,7 +356,7 @@ uno::Any SAL_CALL ScVbaFont::getBold() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_WEIGHT, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_WEIGHT, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getBold(); } @@ -399,7 +399,7 @@ uno::Any SAL_CALL ScVbaFont::getUnderline() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_UNDERLINE, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_UNDERLINE, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); sal_Int32 nValue = awt::FontUnderline::NONE; @@ -426,7 +426,7 @@ uno::Any SAL_CALL ScVbaFont::getStrikethrough() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_CROSSEDOUT, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_CROSSEDOUT, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getStrikethrough(); } @@ -435,7 +435,7 @@ uno::Any SAL_CALL ScVbaFont::getShadow() throw (uno::RuntimeException) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_SHADOWED, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_SHADOWED, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getShadow(); } @@ -444,7 +444,7 @@ uno::Any SAL_CALL ScVbaFont::getItalic() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_POSTURE, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_POSTURE, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getItalic(); @@ -454,7 +454,7 @@ uno::Any SAL_CALL ScVbaFont::getName() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getName(); } @@ -477,7 +477,7 @@ uno::Any SAL_CALL ScVbaFont::getOutlineFont() throw (uno::RuntimeException) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_CONTOUR, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_CONTOUR, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharContoured" ) ) ); } diff --git a/sc/source/ui/vba/vbaformat.cxx b/sc/source/ui/vba/vbaformat.cxx index a493bac28e05..83563e05ea02 100644 --- a/sc/source/ui/vba/vbaformat.cxx +++ b/sc/source/ui/vba/vbaformat.cxx @@ -534,7 +534,7 @@ ScVbaFormat<Ifc1>::setLocked( const uno::Any& _aLocked ) throw (script::BasicErr { try { - sal_Bool bIsLocked = sal_False; + sal_Bool bIsLocked = false; if ( !( _aLocked >>= bIsLocked ) ) throw uno::RuntimeException(); util::CellProtection aCellProtection; @@ -555,7 +555,7 @@ ScVbaFormat<Ifc1>::setFormulaHidden( const uno::Any& FormulaHidden ) throw (scri { try { - sal_Bool bIsFormulaHidden = sal_False; + sal_Bool bIsFormulaHidden = false; FormulaHidden >>= bIsFormulaHidden; util::CellProtection aCellProtection; rtl::OUString sCellProt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLPRO ) ); @@ -583,8 +583,8 @@ ScVbaFormat<Ifc1>::getLocked( ) throw (script::BasicErrorException, uno::Runtim SfxItemSet* pDataSet = getCurrentDataSet(); if ( pDataSet ) { - const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, TRUE); - SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL); + const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, sal_True); + SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, sal_True, NULL); if(eState != SFX_ITEM_DONTCARE) aCellProtection = uno::makeAny(rProtAttr.GetProtection()); } @@ -616,8 +616,8 @@ ScVbaFormat<Ifc1>::getFormulaHidden( ) throw (script::BasicErrorException, uno: SfxItemSet* pDataSet = getCurrentDataSet(); if ( pDataSet ) { - const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, TRUE); - SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL); + const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, sal_True); + SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, sal_True, NULL); if(eState != SFX_ITEM_DONTCARE) aBoolRet = uno::makeAny(rProtAttr.GetHideFormula()); } diff --git a/sc/source/ui/vba/vbaformatcondition.cxx b/sc/source/ui/vba/vbaformatcondition.cxx index deed22ab287e..9874a44c2618 100644 --- a/sc/source/ui/vba/vbaformatcondition.cxx +++ b/sc/source/ui/vba/vbaformatcondition.cxx @@ -63,7 +63,7 @@ ScVbaFormatCondition::Modify( ::sal_Int32 _nType, const uno::Any& _aOperator, co try { ScVbaFormatConditions* pFormatConditions = lcl_getScVbaFormatConditionsPtr( moFormatConditions ); - pFormatConditions->removeFormatCondition(msStyleName, sal_False); + pFormatConditions->removeFormatCondition(msStyleName, false); pFormatConditions->Add(_nType, _aOperator, _aFormula1, _aFormula2, mxStyle); } catch (uno::Exception& ) diff --git a/sc/source/ui/vba/vbafoundfiles.cxx b/sc/source/ui/vba/vbafoundfiles.cxx index 9d3af947e1dd..efbddd3451b1 100644 --- a/sc/source/ui/vba/vbafoundfiles.cxx +++ b/sc/source/ui/vba/vbafoundfiles.cxx @@ -83,7 +83,7 @@ sal_Bool SAL_CALL VbaFoundFilesEnum::hasMoreElements() throw (css::uno::RuntimeE { return sal_True; } - return sal_False; + return false; } css::uno::Any SAL_CALL VbaFoundFilesEnum::nextElement() throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException) diff --git a/sc/source/ui/vba/vbahelper.cxx b/sc/source/ui/vba/vbahelper.cxx index 8178608eb3af..adc7b2493b88 100644 --- a/sc/source/ui/vba/vbahelper.cxx +++ b/sc/source/ui/vba/vbahelper.cxx @@ -131,7 +131,7 @@ private: bool getReplaceCellsWarning() throw ( uno::RuntimeException ) { - sal_Bool res = sal_False; + sal_Bool res = false; getGlobalSheetSettings()->getPropertyValue( REPLACE_CELLS_WARNING ) >>= res; return ( res == sal_True ); } @@ -161,7 +161,7 @@ public: } }; -void dispatchExecute(css::uno::Reference< css::frame::XModel>& xModel, USHORT nSlot, SfxCallMode nCall) +void dispatchExecute(css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nSlot, SfxCallMode nCall) { ScTabViewShell* pViewShell = getBestViewShell( xModel ); SfxViewFrame* pViewFrame = NULL; @@ -203,13 +203,13 @@ implnCut() { ScTabViewShell* pViewShell = getCurrentBestViewShell(); if ( pViewShell ) - pViewShell->CutToClip( NULL, TRUE ); + pViewShell->CutToClip( NULL, sal_True ); } -void implnPasteSpecial(USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) +void implnPasteSpecial(sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) { PasteCellsWarningReseter resetWarningBox; - sal_Bool bAsLink(sal_False), bOtherDoc(sal_False); + sal_Bool bAsLink(false), bOtherDoc(false); InsCellCmd eMoveMode = INS_NONE; ScTabViewShell* pTabViewShell = ScTabViewShell::GetActiveViewShell(); @@ -232,7 +232,7 @@ void implnPasteSpecial(USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_B pDoc = pOwnClip->GetDocument(); pTabViewShell->PasteFromClip( nFlags, pDoc, nFunction, bSkipEmpty, bTranspose, bAsLink, - eMoveMode, IDF_NONE, TRUE ); + eMoveMode, IDF_NONE, sal_True ); pTabViewShell->CellContentChanged(); } } @@ -271,7 +271,7 @@ getCurrentDocument() throw (uno::RuntimeException) if ( pCompVar ) { aModel = sbxToUnoValue( pCompVar ); - if ( sal_False == ( aModel >>= xModel ) || + if ( false == ( aModel >>= xModel ) || !xModel.is() ) { // trying last gasp try the current component @@ -394,8 +394,8 @@ void PrintOutHelper( const uno::Any& From, const uno::Any& To, const uno::Any& C sal_Int32 nTo = 0; sal_Int32 nFrom = 0; sal_Int16 nCopies = 1; - sal_Bool bPreview = sal_False; - sal_Bool bCollate = sal_False; + sal_Bool bPreview = false; + sal_Bool bCollate = false; sal_Bool bSelection = bUseSelection; From >>= nFrom; To >>= nTo; @@ -444,7 +444,7 @@ void PrintOutHelper( const uno::Any& From, const uno::Any& To, const uno::Any& C } SfxBoolItem sfxSelection( SID_SELECTION, bSelection ); aArgs.Put( sfxSelection, sfxSelection.Which() ); - SfxBoolItem sfxAsync( SID_ASYNCHRON, sal_False ); + SfxBoolItem sfxAsync( SID_ASYNCHRON, false ); aArgs.Put( sfxAsync, sfxAsync.Which() ); SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); @@ -461,7 +461,7 @@ void PrintOutHelper( const uno::Any& From, const uno::Any& To, const uno::Any& C } } else - pDispatcher->Execute( (USHORT)SID_PRINTDOC, (SfxCallMode)SFX_CALLMODE_SYNCHRON, aArgs ); + pDispatcher->Execute( (sal_uInt16)SID_PRINTDOC, (SfxCallMode)SFX_CALLMODE_SYNCHRON, aArgs ); } } @@ -491,7 +491,7 @@ rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeEx { case uno::TypeClass_BOOLEAN: { - sal_Bool bBool = sal_False; + sal_Bool bBool = false; pvargItem >>= bBool; sString = rtl::OUString::valueOf( bBool ); break; diff --git a/sc/source/ui/vba/vbahyperlink.cxx b/sc/source/ui/vba/vbahyperlink.cxx index 2f3c5703203f..0a8f8463e390 100644 --- a/sc/source/ui/vba/vbahyperlink.cxx +++ b/sc/source/ui/vba/vbahyperlink.cxx @@ -100,7 +100,7 @@ ScVbaHyperlink::ScVbaHyperlink( const uno::Reference< XHelperInterface >& rxAnch // insert the text field into the document xText->setString( OUString() ); uno::Reference< text::XTextRange > xRange( xText->createTextCursor(), uno::UNO_QUERY_THROW ); - xText->insertTextContent( xRange, xUrlField, sal_False ); + xText->insertTextContent( xRange, xUrlField, false ); } else { diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx index 8379ebafcbc4..1e104e7ff5f4 100644 --- a/sc/source/ui/vba/vbanames.cxx +++ b/sc/source/ui/vba/vbanames.cxx @@ -229,7 +229,7 @@ uno::Reference< container::XEnumeration > ScVbaNames::createEnumeration() throw (uno::RuntimeException) { uno::Reference< container::XEnumerationAccess > xEnumAccess( mxNames, uno::UNO_QUERY_THROW ); - return new NamesEnumeration( this, mxContext, xEnumAccess->createEnumeration(), mxModel , mxNames ); + return new NamesEnumeration( getParent(), mxContext, xEnumAccess->createEnumeration(), mxModel , mxNames ); } uno::Any diff --git a/sc/source/ui/vba/vbapagebreak.cxx b/sc/source/ui/vba/vbapagebreak.cxx index 8c28aada76f4..3939c33128cc 100644 --- a/sc/source/ui/vba/vbapagebreak.cxx +++ b/sc/source/ui/vba/vbapagebreak.cxx @@ -46,7 +46,7 @@ template< typename Ifc1 > sal_Int32 ScVbaPageBreak<Ifc1>::getType() throw (uno::RuntimeException) { uno::Any aValue = mxRowColPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" ))); - sal_Bool hasPageBreak = sal_False; + sal_Bool hasPageBreak = false; aValue >>= hasPageBreak; if( !hasPageBreak ) @@ -78,7 +78,7 @@ void ScVbaPageBreak<Ifc1>::setType(sal_Int32 type) throw (uno::RuntimeException) if( type == excel::XlPageBreak::xlPageBreakManual ) maTablePageBreakData.ManualBreak = sal_True; else - maTablePageBreakData.ManualBreak = sal_False; + maTablePageBreakData.ManualBreak = false; } template< typename Ifc1 > diff --git a/sc/source/ui/vba/vbapagebreaks.cxx b/sc/source/ui/vba/vbapagebreaks.cxx index d8a574d5837d..18d785924c8c 100644 --- a/sc/source/ui/vba/vbapagebreaks.cxx +++ b/sc/source/ui/vba/vbapagebreaks.cxx @@ -205,7 +205,7 @@ public: ScVbaHPageBreaks::ScVbaHPageBreaks( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< sheet::XSheetPageBreak >& xSheetPageBreak) throw (uno::RuntimeException): - ScVbaHPageBreaks_BASE( xParent,xContext, new RangePageBreaks( xParent, xContext, xSheetPageBreak, sal_False )), + ScVbaHPageBreaks_BASE( xParent,xContext, new RangePageBreaks( xParent, xContext, xSheetPageBreak, false )), mxSheetPageBreak( xSheetPageBreak ) { } diff --git a/sc/source/ui/vba/vbapagesetup.cxx b/sc/source/ui/vba/vbapagesetup.cxx index f03ee70b9231..f01e06a64a50 100644 --- a/sc/source/ui/vba/vbapagesetup.cxx +++ b/sc/source/ui/vba/vbapagesetup.cxx @@ -81,7 +81,7 @@ rtl::OUString SAL_CALL ScVbaPageSetup::getPrintArea() throw (css::uno::RuntimeEx if( nCount ) { ScAddress::Details aDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); - USHORT nFlags = SCA_VALID; + sal_uInt16 nFlags = SCA_VALID; nFlags |= ( SCA_TAB_ABSOLUTE | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB2_ABSOLUTE | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE ); ScRangeList aRangeList; for( sal_Int32 i=0; i<nCount; i++ ) @@ -153,7 +153,7 @@ uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesTall() throw (css::uno::RuntimeEx void SAL_CALL ScVbaPageSetup::setFitToPagesTall( const uno::Any& fitToPagesTall) throw (css::uno::RuntimeException) { - USHORT scaleToPageY = 0; + sal_uInt16 scaleToPageY = 0; try { sal_Bool aValue; @@ -176,10 +176,10 @@ uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesWide() throw (css::uno::RuntimeEx void SAL_CALL ScVbaPageSetup::setFitToPagesWide( const uno::Any& fitToPagesWide) throw (css::uno::RuntimeException) { - USHORT scaleToPageX = 0; + sal_uInt16 scaleToPageX = 0; try { - sal_Bool aValue = sal_False; + sal_Bool aValue = false; if( fitToPagesWide.getValueTypeClass() != uno::TypeClass_BOOLEAN || (fitToPagesWide >>= aValue)) { fitToPagesWide >>= scaleToPageX; @@ -199,12 +199,12 @@ uno::Any SAL_CALL ScVbaPageSetup::getZoom() throw (css::uno::RuntimeException) void SAL_CALL ScVbaPageSetup::setZoom( const uno::Any& zoom) throw (css::uno::RuntimeException) { - USHORT pageScale = 0; + sal_uInt16 pageScale = 0; try { if( zoom.getValueTypeClass() == uno::TypeClass_BOOLEAN ) { - sal_Bool aValue = sal_False; + sal_Bool aValue = false; zoom >>= aValue; if( aValue ) { @@ -221,7 +221,7 @@ void SAL_CALL ScVbaPageSetup::setZoom( const uno::Any& zoom) throw (css::uno::Ru } // these only exist in S08 - USHORT nScale = 0; + sal_uInt16 nScale = 0; mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPages")), uno::makeAny( nScale )); mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesX")), uno::makeAny( nScale )); mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesY")), uno::makeAny( nScale )); @@ -463,7 +463,7 @@ sal_Int32 SAL_CALL ScVbaPageSetup::getOrder() throw (css::uno::RuntimeException) try { uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrintDownFirst"))); - sal_Bool bPrintDownFirst = sal_False; + sal_Bool bPrintDownFirst = false; aValue >>= bPrintDownFirst; if( !bPrintDownFirst ) order = excel::XlOrder::xlOverThenDown; @@ -483,7 +483,7 @@ void SAL_CALL ScVbaPageSetup::setOrder( sal_Int32 order) throw (css::uno::Runtim case excel::XlOrder::xlDownThenOver: break; case excel::XlOrder::xlOverThenDown: - bOrder = sal_False; + bOrder = false; break; default: DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() ); @@ -538,7 +538,7 @@ void SAL_CALL ScVbaPageSetup::setFirstPageNumber( sal_Int32 firstPageNumber) thr sal_Bool SAL_CALL ScVbaPageSetup::getCenterVertically() throw (css::uno::RuntimeException) { - sal_Bool centerVertically = sal_False; + sal_Bool centerVertically = false; try { uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CenterVertically"))); @@ -563,7 +563,7 @@ void SAL_CALL ScVbaPageSetup::setCenterVertically( sal_Bool centerVertically) th sal_Bool SAL_CALL ScVbaPageSetup::getCenterHorizontally() throw (css::uno::RuntimeException) { - sal_Bool centerHorizontally = sal_False; + sal_Bool centerHorizontally = false; try { uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CenterHorizontally"))); @@ -588,7 +588,7 @@ void SAL_CALL ScVbaPageSetup::setCenterHorizontally( sal_Bool centerHorizontally sal_Bool SAL_CALL ScVbaPageSetup::getPrintHeadings() throw (css::uno::RuntimeException) { - sal_Bool printHeadings = sal_False; + sal_Bool printHeadings = false; try { uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrintHeaders"))); @@ -691,7 +691,7 @@ sal_Int32 SAL_CALL ScVbaPageSetup::getPaperSize() throw (css::uno::RuntimeExcept { uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Size"))); aValue >>= size; - ePaper = SvxPaperInfo::GetSvxPaper( Size(size.Width, size.Height), MAP_100TH_MM, TRUE); + ePaper = SvxPaperInfo::GetSvxPaper( Size(size.Width, size.Height), MAP_100TH_MM, true); } catch( uno::Exception& ) { diff --git a/sc/source/ui/vba/vbaquerytable.cxx b/sc/source/ui/vba/vbaquerytable.cxx index 305c14262d3a..159c7b75adf2 100644 --- a/sc/source/ui/vba/vbaquerytable.cxx +++ b/sc/source/ui/vba/vbaquerytable.cxx @@ -67,9 +67,9 @@ ScVbaQueryTable::Refresh( const ::com::sun::star::uno::Any& /*aBackgroundQuery*/ //Get link info sfx2::LinkManager *pLinkMng = m_pDocument->GetLinkManager(); const ::sfx2::SvBaseLinks &rLinks = pLinkMng->GetLinks(); - USHORT nCount = rLinks.Count(); + sal_uInt16 nCount = rLinks.Count(); - for (USHORT i=0; i<nCount; i++) + for (sal_uInt16 i=0; i<nCount; i++) { ::sfx2::SvBaseLink* pBase = *rLinks[i]; if (pBase->ISA(ScAreaLink)) diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 6ab4dafb015c..1505f210bf91 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -25,6 +25,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + +#include "vbarange.hxx" + #include <vbahelper/helperdecl.hxx> #include <comphelper/unwrapargs.hxx> @@ -32,6 +35,8 @@ #include <sfx2/objsh.hxx> #include <com/sun/star/script/ArrayWrapper.hpp> +#include <com/sun/star/script/vba/VBAEventId.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> #include <com/sun/star/sheet/XDatabaseRange.hpp> #include <com/sun/star/sheet/XDatabaseRanges.hpp> #include <com/sun/star/sheet/XGoalSeek.hpp> @@ -147,7 +152,7 @@ #include <unonames.hxx> #include <tools/stream.hxx> -#include "vbarange.hxx" +#include "vbaapplication.hxx" #include "vbafont.hxx" #include "vbacomment.hxx" #include "vbainterior.hxx" @@ -171,6 +176,7 @@ #include "dbdocfun.hxx" #include "patattr.hxx" #include "olinetab.hxx" +#include "transobj.hxx" #include <comphelper/anytostring.hxx> #include <global.hxx> @@ -192,6 +198,9 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; using ::std::vector; +// difference between VBA and file format width, in character units +const double fExtraWidth = 182.0 / 256.0; + // * 1 point = 1/72 inch = 20 twips // * 1 inch = 72 points = 1440 twips // * 1 cm = 567 twips @@ -199,13 +208,13 @@ double lcl_hmmToPoints( double nVal ) { return ( (double)((nVal /1000 ) * 567 ) static const sal_Int16 supportedIndexTable[] = { excel::XlBordersIndex::xlEdgeLeft, excel::XlBordersIndex::xlEdgeTop, excel::XlBordersIndex::xlEdgeBottom, excel::XlBordersIndex::xlEdgeRight, excel::XlBordersIndex::xlDiagonalDown, excel::XlBordersIndex::xlDiagonalUp, excel::XlBordersIndex::xlInsideVertical, excel::XlBordersIndex::xlInsideHorizontal }; -USHORT lcl_pointsToTwips( double nVal ) +sal_uInt16 lcl_pointsToTwips( double nVal ) { nVal = nVal * static_cast<double>(20); short nTwips = static_cast<short>(nVal); return nTwips; } -double lcl_TwipsToPoints( USHORT nVal ) +double lcl_TwipsToPoints( sal_uInt16 nVal ) { double nPoints = nVal; return nPoints / 20; @@ -279,6 +288,26 @@ SfxItemSet* ScVbaRange::getCurrentDataSet( ) throw ( uno::RuntimeException ) return pDataSet; } +void ScVbaRange::fireChangeEvent() +{ + if( ScVbaApplication::getDocumentEventsEnabled() ) + { + if( ScDocument* pDoc = getScDocument() ) + { + uno::Reference< script::vba::XVBAEventProcessor > xVBAEvents = pDoc->GetVbaEventProcessor(); + if( xVBAEvents.is() ) try + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= uno::Reference< excel::XRange >( this ); + xVBAEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_CHANGE, aArgs ); + } + catch( uno::Exception& ) + { + } + } + } +} + class SingleRangeEnumeration : public EnumerationHelper_BASE { uno::Reference< XHelperInterface > m_xParent; @@ -486,7 +515,7 @@ public: { SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( pUnoCellRange ); - SfxItemState eState = pDataSet->GetItemState( ATTR_VALUE_FORMAT, TRUE, NULL); + SfxItemState eState = pDataSet->GetItemState( ATTR_VALUE_FORMAT, true, NULL); // one of the cells in the range is not like the other ;-) // so return a zero length format to indicate that if ( eState == SFX_ITEM_DONTCARE ) @@ -509,15 +538,18 @@ public: return nType; } - bool setNumberFormat( const rtl::OUString& rFormat ) + bool setNumberFormat( const rtl::OUString& rFormat ) { - lang::Locale aLocale; - uno::Reference< beans::XPropertySet > xNumProps = getNumberProps(); - xNumProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Locale" )) ) >>= aLocale; - sal_Int32 nNewIndex = mxFormats->queryKey(rFormat, aLocale, false ); - if ( nNewIndex == -1 ) // format not defined + // #163288# treat "General" as "Standard" format + sal_Int32 nNewIndex = 0; + if( !rFormat.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "General" ) ) ) { - nNewIndex = mxFormats->addNew( rFormat, aLocale ); + lang::Locale aLocale; + uno::Reference< beans::XPropertySet > xNumProps = getNumberProps(); + xNumProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Locale" ) ) ) >>= aLocale; + nNewIndex = mxFormats->queryKey( rFormat, aLocale, false ); + if ( nNewIndex == -1 ) // format not defined + nNewIndex = mxFormats->addNew( rFormat, aLocale ); } mxRangeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberFormat") ), uno::makeAny( nNewIndex ) ); return true; @@ -681,7 +713,7 @@ CellValueSetter::processValue( const uno::Any& aValue, const uno::Reference< tab { case uno::TypeClass_BOOLEAN: { - sal_Bool bState = sal_False; + sal_Bool bState = false; if ( aValue >>= bState ) { uno::Reference< table::XCellRange > xRange( xCell, uno::UNO_QUERY_THROW ); @@ -699,8 +731,26 @@ CellValueSetter::processValue( const uno::Any& aValue, const uno::Reference< tab rtl::OUString aString; if ( aValue >>= aString ) { - uno::Reference< text::XTextRange > xTextRange( xCell, uno::UNO_QUERY_THROW ); - xTextRange->setString( aString ); + // The required behavior for a string value is: + // 1. If the first character is a single quote, use the rest as a string cell, regardless of the cell's number format. + // 2. Otherwise, if the cell's number format is "text", use the string value as a string cell. + // 3. Otherwise, parse the string value in English locale, and apply a corresponding number format with the cell's locale + // if the cell's number format was "General". + // Case 1 is handled here, the rest in ScCellObj::InputEnglishString + + if ( aString.toChar() == '\'' ) // case 1 - handle with XTextRange + { + rtl::OUString aRemainder( aString.copy(1) ); // strip the quote + uno::Reference< text::XTextRange > xTextRange( xCell, uno::UNO_QUERY_THROW ); + xTextRange->setString( aRemainder ); + } + else + { + // call implementation method InputEnglishString + ScCellObj* pCellObj = dynamic_cast< ScCellObj* >( xCell.get() ); + if ( pCellObj ) + pCellObj->InputEnglishString( aString ); + } } else isExtracted = false; @@ -760,7 +810,7 @@ void CellValueGetter::visitNode( sal_Int32 x, sal_Int32 y, const uno::Reference< if ( sFormula.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("=TRUE()") ) ) ) aValue <<= sal_True; else if ( sFormula.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("=FALSE()") ) ) ) - aValue <<= sal_False; + aValue <<= false; else { uno::Reference< beans::XPropertySet > xProp( xCell, uno::UNO_QUERY_THROW ); @@ -1076,7 +1126,7 @@ public: }; bool -getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv, char cDelimiter = 0 ) +getCellRangesForAddress( sal_uInt16& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv, char cDelimiter = 0 ) { ScDocument* pDoc = NULL; @@ -1084,7 +1134,7 @@ getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDoc { pDoc = pDocSh->GetDocument(); String aString(sAddress); - USHORT nMask = SCA_VALID; + sal_uInt16 nMask = SCA_VALID; rResFlags = rCellRanges.Parse( sAddress, pDoc, nMask, eConv, cDelimiter ); if ( rResFlags & SCA_VALID ) { @@ -1150,7 +1200,7 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S aChar = ';'; } - USHORT nFlags = 0; + sal_uInt16 nFlags = 0; if ( !getCellRangesForAddress( nFlags, sAddress, pDocSh, aCellRanges, eConv, aChar ) ) return false; @@ -1253,7 +1303,7 @@ void lclExpandAndMerge( const uno::Reference< table::XCellRange >& rxCellRange, { uno::Reference< util::XMergeable > xMerge( lclExpandToMerged( rxCellRange, true ), uno::UNO_QUERY_THROW ); // Calc cannot merge over merged ranges, always unmerge first - xMerge->merge( sal_False ); + xMerge->merge( false ); if( bMerge ) { // clear all contents of the covered cells (not the top-left cell) @@ -1400,7 +1450,7 @@ void lcl_NotifyRangeChanges( const uno::Reference< frame::XModel >& xModel, ScCe } ScVbaRange::ScVbaRange( uno::Sequence< uno::Any> const & args, - uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : ScVbaRange_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext, getXSomethingFromArgs< beans::XPropertySet >( args, 1, false ), excel::GetModelFromRange( getXSomethingFromArgs< uno::XInterface >( args, 1 ) ), true ), mbIsRows( sal_False ), mbIsColumns( sal_False ) + uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : ScVbaRange_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext, getXSomethingFromArgs< beans::XPropertySet >( args, 1, false ), excel::GetModelFromRange( getXSomethingFromArgs< uno::XInterface >( args, 1 ) ), true ), mbIsRows( false ), mbIsColumns( false ) { mxRange.set( mxPropertySet, uno::UNO_QUERY ); mxRanges.set( mxPropertySet, uno::UNO_QUERY ); @@ -1534,7 +1584,7 @@ ScVbaRange::getValue( ValueGetter& valueGetter) throw (uno::RuntimeException) // multi cell range ( return array ) Dim2ArrayValueGetter arrayGetter( nRowCount, nColCount, valueGetter ); visitArray( arrayGetter ); - return uno::makeAny( script::ArrayWrapper( sal_False, arrayGetter.getValue() ) ); + return uno::makeAny( script::ArrayWrapper( false, arrayGetter.getValue() ) ); } uno::Any SAL_CALL @@ -1557,7 +1607,7 @@ ScVbaRange::getValue() throw (uno::RuntimeException) void -ScVbaRange::setValue( const uno::Any &aValue, ValueSetter& valueSetter ) throw (uno::RuntimeException) +ScVbaRange::setValue( const uno::Any& aValue, ValueSetter& valueSetter, bool bFireEvent ) throw (uno::RuntimeException) { uno::TypeClass aClass = aValue.getValueTypeClass(); if ( aClass == uno::TypeClass_SEQUENCE ) @@ -1592,6 +1642,7 @@ ScVbaRange::setValue( const uno::Any &aValue, ValueSetter& valueSetter ) thro { visitArray( valueSetter ); } + if( bFireEvent ) fireChangeEvent(); } void SAL_CALL @@ -1606,26 +1657,30 @@ ScVbaRange::setValue( const uno::Any &aValue ) throw (uno::RuntimeException) return; } CellValueSetter valueSetter( aValue ); - setValue( aValue, valueSetter ); + setValue( aValue, valueSetter, true ); +#if 0 // TODO: Noel, do we still need this? // Fires the range change event. lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); +#endif } -void +void SAL_CALL ScVbaRange::Clear() throw (uno::RuntimeException) { using namespace ::com::sun::star::sheet::CellFlags; sal_Int32 nFlags = VALUE | DATETIME | STRING | FORMULA | HARDATTR | EDITATTR | FORMATTED; - ClearContents( nFlags ); + ClearContents( nFlags, true ); +#if 0 // TODO: do we still need this? // Fires the range change event. lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); +#endif } //helper ClearContent void -ScVbaRange::ClearContents( sal_Int32 nFlags ) throw (uno::RuntimeException) +ScVbaRange::ClearContents( sal_Int32 nFlags, bool bFireEvent ) throw (uno::RuntimeException) { // #TODO code within the test below "if ( m_Areas.... " can be removed // Test is performed only because m_xRange is NOT set to be @@ -1639,46 +1694,54 @@ ScVbaRange::ClearContents( sal_Int32 nFlags ) throw (uno::RuntimeException) uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW ); ScVbaRange* pRange = getImplementation( xRange ); if ( pRange ) - pRange->ClearContents( nFlags ); + pRange->ClearContents( nFlags, false ); // do not fire for single ranges } + // fire change event for the entire range list + if( bFireEvent ) fireChangeEvent(); return; } uno::Reference< sheet::XSheetOperation > xSheetOperation(mxRange, uno::UNO_QUERY_THROW); xSheetOperation->clearContents( nFlags ); + if( bFireEvent ) fireChangeEvent(); } -void + +void SAL_CALL ScVbaRange::ClearComments() throw (uno::RuntimeException) { - ClearContents( sheet::CellFlags::ANNOTATION ); + ClearContents( sheet::CellFlags::ANNOTATION, false ); } -void +void SAL_CALL ScVbaRange::ClearContents() throw (uno::RuntimeException) { sal_Int32 nClearFlags = ( sheet::CellFlags::VALUE | sheet::CellFlags::STRING | sheet::CellFlags::DATETIME | sheet::CellFlags::FORMULA ); - ClearContents( nClearFlags ); + ClearContents( nClearFlags, true ); +#if 0 // TODO: do we still need this? // Fires the range change event. lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); +#endif } -void +void SAL_CALL ScVbaRange::ClearFormats() throw (uno::RuntimeException) { //FIXME: need to check if we need to combine sheet::CellFlags::FORMATTED sal_Int32 nClearFlags = sheet::CellFlags::HARDATTR | sheet::CellFlags::FORMATTED | sheet::CellFlags::EDITATTR; - ClearContents( nClearFlags ); + ClearContents( nClearFlags, false ); +#if 0 // TODO: do we still need this? // Fires the range change event. lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); +#endif } void -ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar::Grammar eGram ) throw (uno::RuntimeException) +ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar::Grammar eGram, bool bFireEvent ) throw (uno::RuntimeException) { // If this is a multiple selection apply setFormula over all areas if ( m_Areas->getCount() > 1 ) @@ -1689,10 +1752,12 @@ ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar:: return; } CellFormulaValueSetter formulaValueSetter( rFormula, getScDocument(), eGram ); - setValue( rFormula, formulaValueSetter ); + setValue( rFormula, formulaValueSetter, bFireEvent ); +#if 0 // TODO: ditto // Fires the range change event. lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); +#endif } uno::Any @@ -1716,7 +1781,7 @@ void ScVbaRange::setFormula(const uno::Any &rFormula ) throw (uno::RuntimeException) { // #FIXME converting "=$a$1" e.g. CONV_XL_A1 -> CONV_OOO // results in "=$a$1:a1", temporalily disable conversion - setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );; + setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1, true ); } uno::Any @@ -1728,7 +1793,7 @@ ScVbaRange::getFormulaR1C1() throw (::com::sun::star::uno::RuntimeException) void ScVbaRange::setFormulaR1C1(const uno::Any& rFormula ) throw (uno::RuntimeException) { - setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 ); + setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1, true ); } uno::Any @@ -2085,7 +2150,7 @@ ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolut if ( refStyle == excel::XlReferenceStyle::xlR1C1 ) dDetails = ScAddress::Details( formula::FormulaGrammar::CONV_XL_R1C1, 0, 0 ); } - USHORT nFlags = SCA_VALID; + sal_uInt16 nFlags = SCA_VALID; ScDocShell* pDocShell = getScDocShell(); ScDocument* pDoc = pDocShell->GetDocument(); @@ -2093,8 +2158,8 @@ ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolut table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); ScRange aRange( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCROW >( thisAddress.StartRow ), static_cast< SCTAB >( thisAddress.Sheet ), static_cast< SCCOL >( thisAddress.EndColumn ), static_cast< SCROW >( thisAddress.EndRow ), static_cast< SCTAB >( thisAddress.Sheet ) ); String sRange; - USHORT ROW_ABSOLUTE = ( SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE ); - USHORT COL_ABSOLUTE = ( SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE ); + sal_uInt16 ROW_ABSOLUTE = ( SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE ); + sal_uInt16 COL_ABSOLUTE = ( SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE ); // default nFlags |= ( SCA_TAB_ABSOLUTE | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB2_ABSOLUTE | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE ); if ( RowAbsolute.hasValue() ) @@ -2111,7 +2176,7 @@ ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolut if ( !bVal ) nFlags &= ~COL_ABSOLUTE; } - sal_Bool bLocal = sal_False; + sal_Bool bLocal = false; if ( External.hasValue() ) { External >>= bLocal; @@ -2166,6 +2231,18 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr return xRange->Cells( nRowIndex, nColumnIndex ); } + // Performance: Use a common helper method for ScVbaRange::Cells and ScVbaWorksheet::Cells, + // instead of creating a new ScVbaRange object in often-called ScVbaWorksheet::Cells + return CellsHelper( mxParent, mxContext, mxRange, nRowIndex, nColumnIndex ); +} + +// static +uno::Reference< excel::XRange > +ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< css::table::XCellRange >& xRange, + const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) throw(uno::RuntimeException) +{ sal_Int32 nRow = 0, nColumn = 0; sal_Bool bIsIndex = nRowIndex.hasValue(); @@ -2186,7 +2263,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr } else if ( aRowIndexAny.hasValue() && !( aRowIndexAny >>= nRow ) ) { - uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext ); + uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext ); uno::Any aConverted; try { @@ -2206,7 +2283,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr { ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); ScRange tmpRange; - USHORT flags = tmpRange.ParseCols( sCol, excel::GetDocumentFromRange( mxRange ), dDetails ); + sal_uInt16 flags = tmpRange.ParseCols( sCol, excel::GetDocumentFromRange( xRange ), dDetails ); if ( ( flags & 0x200 ) != 0x200 ) throw uno::RuntimeException(); nColumn = tmpRange.aStart.Col() + 1; @@ -2223,7 +2300,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr } if ( !( aColumnAny >>= nColumn ) ) { - uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext ); + uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext ); uno::Any aConverted; try { @@ -2234,17 +2311,17 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr } } } - RangeHelper thisRange( mxRange ); + RangeHelper thisRange( xRange ); table::CellRangeAddress thisRangeAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); uno::Reference< table::XCellRange > xSheetRange = thisRange.getCellRangeFromSheet(); if( !bIsIndex && !bIsColumnIndex ) // .Cells // #FIXE needs proper parent ( Worksheet ) - return uno::Reference< excel::XRange >( new ScVbaRange( mxParent, mxContext, mxRange ) ); + return uno::Reference< excel::XRange >( new ScVbaRange( xParent, xContext, xRange ) ); sal_Int32 nIndex = --nRow; if( bIsIndex && !bIsColumnIndex ) // .Cells(n) { - uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, ::uno::UNO_QUERY_THROW); + uno::Reference< table::XColumnRowRange > xColumnRowRange(xRange, ::uno::UNO_QUERY_THROW); sal_Int32 nColCount = xColumnRowRange->getColumns()->getCount(); if ( !nIndex || nIndex < 0 ) @@ -2257,7 +2334,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr --nColumn; nRow = nRow + thisRangeAddress.StartRow; nColumn = nColumn + thisRangeAddress.StartColumn; - return new ScVbaRange( mxParent, mxContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); + return new ScVbaRange( xParent, xContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); } void @@ -2306,7 +2383,7 @@ void setCursor( const SCCOL& nCol, const SCROW& nRow, const uno::Reference< fra if ( bInSel ) pShell->SetCursor( nCol, nRow ); else - pShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_NONE, FALSE, FALSE, TRUE, FALSE ); + pShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_NONE, false, false, sal_True, false ); } } @@ -2683,7 +2760,7 @@ ScVbaRange::getWrapText() throw (script::BasicErrorException, uno::RuntimeExcept SfxItemSet* pDataSet = getCurrentDataSet(); - SfxItemState eState = pDataSet->GetItemState( ATTR_LINEBREAK, TRUE, NULL); + SfxItemState eState = pDataSet->GetItemState( ATTR_LINEBREAK, true, NULL); if ( eState == SFX_ITEM_DONTCARE ) return aNULL(); @@ -2823,10 +2900,10 @@ uno::Any ScVbaRange::getCellRange( const uno::Reference< excel::XRange >& rxRang throw uno::RuntimeException(); } -static USHORT +static sal_uInt16 getPasteFlags (sal_Int32 Paste) { - USHORT nFlags = IDF_NONE; + sal_uInt16 nFlags = IDF_NONE; switch (Paste) { case excel::XlPasteType::xlPasteComments: nFlags = IDF_NOTE;break; @@ -2854,10 +2931,10 @@ getPasteFlags (sal_Int32 Paste) return nFlags; } -static USHORT +static sal_uInt16 getPasteFormulaBits( sal_Int32 Operation) { - USHORT nFormulaBits = PASTE_NOFUNC ; + sal_uInt16 nFormulaBits = PASTE_NOFUNC ; switch (Operation) { case excel::XlPasteSpecialOperation::xlPasteSpecialOperationAdd: @@ -2890,8 +2967,8 @@ ScVbaRange::PasteSpecial( const uno::Any& Paste, const uno::Any& Operation, cons // set up defaults sal_Int32 nPaste = excel::XlPasteType::xlPasteAll; sal_Int32 nOperation = excel::XlPasteSpecialOperation::xlPasteSpecialOperationNone; - sal_Bool bTranspose = sal_False; - sal_Bool bSkipBlanks = sal_False; + sal_Bool bTranspose = false; + sal_Bool bSkipBlanks = false; if ( Paste.hasValue() ) Paste >>= nPaste; @@ -2902,8 +2979,8 @@ ScVbaRange::PasteSpecial( const uno::Any& Paste, const uno::Any& Operation, cons if ( Transpose.hasValue() ) Transpose >>= bTranspose; - USHORT nFlags = getPasteFlags(nPaste); - USHORT nFormulaBits = getPasteFormulaBits(nOperation); + sal_uInt16 nFlags = getPasteFlags(nPaste); + sal_uInt16 nFormulaBits = getPasteFormulaBits(nOperation); excel::implnPasteSpecial(pShell->GetModel(), nFlags,nFormulaBits,bSkipBlanks,bTranspose); } @@ -3073,7 +3150,7 @@ ScVbaRange::Replace( const ::rtl::OUString& What, const ::rtl::OUString& Replace sal_Int16 nLook = globalSearchOptions.GetWordOnly() ? excel::XlLookAt::xlPart : excel::XlLookAt::xlWhole; sal_Int16 nSearchOrder = globalSearchOptions.GetRowDirection() ? excel::XlSearchOrder::xlByRows : excel::XlSearchOrder::xlByColumns; - sal_Bool bMatchCase = sal_False; + sal_Bool bMatchCase = false; uno::Reference< util::XReplaceable > xReplace( mxRange, uno::UNO_QUERY ); if ( xReplace.is() ) { @@ -3087,9 +3164,9 @@ ScVbaRange::Replace( const ::rtl::OUString& What, const ::rtl::OUString& Replace { // sets SearchWords ( true is Cell match ) nLook = ::comphelper::getINT16( LookAt ); - sal_Bool bSearchWords = sal_False; + sal_Bool bSearchWords = false; if ( nLook == excel::XlLookAt::xlPart ) - bSearchWords = sal_False; + bSearchWords = false; else if ( nLook == excel::XlLookAt::xlWhole ) bSearchWords = sal_True; else @@ -3103,9 +3180,9 @@ ScVbaRange::Replace( const ::rtl::OUString& What, const ::rtl::OUString& Replace if ( SearchOrder.hasValue() ) { nSearchOrder = ::comphelper::getINT16( SearchOrder ); - sal_Bool bSearchByRow = sal_False; + sal_Bool bSearchByRow = false; if ( nSearchOrder == excel::XlSearchOrder::xlByColumns ) - bSearchByRow = sal_False; + bSearchByRow = false; else if ( nSearchOrder == excel::XlSearchOrder::xlByRows ) bSearchByRow = sal_True; else @@ -3223,9 +3300,9 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L if ( LookAt.hasValue() ) { nLookAt = ::comphelper::getINT16( LookAt ); - sal_Bool bSearchWords = sal_False; + sal_Bool bSearchWords = false; if ( nLookAt == excel::XlLookAt::xlPart ) - bSearchWords = sal_False; + bSearchWords = false; else if ( nLookAt == excel::XlLookAt::xlWhole ) bSearchWords = sal_True; else @@ -3238,9 +3315,9 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L if ( SearchOrder.hasValue() ) { nSearchOrder = ::comphelper::getINT16( SearchOrder ); - sal_Bool bSearchByRow = sal_False; + sal_Bool bSearchByRow = false; if ( nSearchOrder == excel::XlSearchOrder::xlByColumns ) - bSearchByRow = sal_False; + bSearchByRow = false; else if ( nSearchOrder == excel::XlSearchOrder::xlByRows ) bSearchByRow = sal_True; else @@ -3256,9 +3333,9 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L sal_Int32 nSearchDirection = 0; if( SearchDirection >>= nSearchDirection ) { - sal_Bool bSearchBackwards = sal_False; + sal_Bool bSearchBackwards = false; if ( nSearchDirection == excel::XlSearchDirection::xlNext ) - bSearchBackwards = sal_False; + bSearchBackwards = false; else if( nSearchDirection == excel::XlSearchDirection::xlPrevious ) bSearchBackwards = sal_True; else @@ -3269,7 +3346,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L } // MatchCase - sal_Bool bMatchCase = sal_False; + sal_Bool bMatchCase = false; if ( MatchCase.hasValue() ) { // SearchCaseSensitive @@ -3376,7 +3453,7 @@ void updateTableSortField( const uno::Reference< table::XCellRange >& xParentRan if ( nOrder == excel::XlSortOrder::xlAscending ) aTableField.IsAscending = sal_True; else - aTableField.IsAscending = sal_False; + aTableField.IsAscending = false; } else throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Illegal Key param" ) ), uno::Reference< uno::XInterface >() ); @@ -3392,7 +3469,7 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("That command cannot be used on multiple selections" ) ), uno::Reference< uno::XInterface >() ); sal_Int16 nDataOption1 = excel::XlSortDataOption::xlSortNormal; - sal_Int16 nDataOption2 = excel::XlSortDataOption::xlSortNormal;; + sal_Int16 nDataOption2 = excel::XlSortDataOption::xlSortNormal; sal_Int16 nDataOption3 = excel::XlSortDataOption::xlSortNormal; ScDocument* pDoc = getScDocument(); @@ -3437,13 +3514,13 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& nOrientation = ::comphelper::getINT16( Orientation ); // persist new option to be next calls default if ( nOrientation == excel::XlSortOrientation::xlSortRows ) - aSortParam.bByRow = FALSE; + aSortParam.bByRow = false; else - aSortParam.bByRow = TRUE; + aSortParam.bByRow = sal_True; } - sal_Bool bIsSortColumns=sal_False; // sort by row + sal_Bool bIsSortColumns=false; // sort by row if ( nOrientation == excel::XlSortOrientation::xlSortRows ) bIsSortColumns = sal_True; @@ -3451,7 +3528,7 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& #ifdef VBA_OOBUILD_HACK nHeader = aSortParam.nCompatHeader; #endif - sal_Bool bContainsHeader = sal_False; + sal_Bool bContainsHeader = false; if ( Header.hasValue() ) { @@ -3499,26 +3576,26 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& { nOrder1 = ::comphelper::getINT16(Order1); if ( nOrder1 == excel::XlSortOrder::xlAscending ) - aSortParam.bAscending[0] = TRUE; + aSortParam.bAscending[0] = true; else - aSortParam.bAscending[0] = FALSE; + aSortParam.bAscending[0] = false; } if ( Order2.hasValue() ) { nOrder2 = ::comphelper::getINT16(Order2); if ( nOrder2 == excel::XlSortOrder::xlAscending ) - aSortParam.bAscending[1] = TRUE; + aSortParam.bAscending[1] = true; else - aSortParam.bAscending[1] = FALSE; + aSortParam.bAscending[1] = false; } if ( Order3.hasValue() ) { nOrder3 = ::comphelper::getINT16(Order3); if ( nOrder3 == excel::XlSortOrder::xlAscending ) - aSortParam.bAscending[2] = TRUE; + aSortParam.bAscending[2] = true; else - aSortParam.bAscending[2] = FALSE; + aSortParam.bAscending[2] = false; } uno::Reference< table::XCellRange > xKey1; @@ -3697,7 +3774,7 @@ ScVbaRange::hasElements() throw (uno::RuntimeException) if ( xColumnRowRange->getRows()->getCount() || xColumnRowRange->getColumns()->getCount() ) return sal_True; - return sal_False; + return false; } // XEnumerationAccess @@ -3741,7 +3818,7 @@ double ScVbaRange::getCalcColWidth( const table::CellRangeAddress& rAddress) throw (uno::RuntimeException) { ScDocument* pDoc = getScDocument(); - USHORT nWidth = pDoc->GetOriginalWidth( static_cast< SCCOL >( rAddress.StartColumn ), static_cast< SCTAB >( rAddress.Sheet ) ); + sal_uInt16 nWidth = pDoc->GetOriginalWidth( static_cast< SCCOL >( rAddress.StartColumn ), static_cast< SCTAB >( rAddress.Sheet ) ); double nPoints = lcl_TwipsToPoints( nWidth ); nPoints = lcl_Round2DecPlaces( nPoints ); return nPoints; @@ -3751,7 +3828,7 @@ double ScVbaRange::getCalcRowHeight( const table::CellRangeAddress& rAddress ) throw (uno::RuntimeException) { ScDocument* pDoc = excel::GetDocumentFromRange( mxRange ); - USHORT nWidth = pDoc->GetOriginalHeight( rAddress.StartRow, rAddress.Sheet ); + sal_uInt16 nWidth = pDoc->GetOriginalHeight( rAddress.StartRow, rAddress.Sheet ); double nPoints = lcl_TwipsToPoints( nWidth ); nPoints = lcl_Round2DecPlaces( nPoints ); return nPoints; @@ -3780,7 +3857,19 @@ double getDefaultCharWidth( const uno::Reference< frame::XModel >& xModel ) thro double nPixelsPerMeter = xDevice->getInfo().PixelPerMeterX; double nCharWidth = nCharPixelWidth / nPixelsPerMeter; nCharWidth = nCharWidth * (double)56700;// in twips - return lcl_TwipsToPoints( (USHORT)nCharWidth ); + return lcl_TwipsToPoints( (sal_uInt16)nCharWidth ); +} + +double getDefaultCharWidth( ScDocShell* pDocShell ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + OutputDevice* pRefDevice = pDoc->GetRefDevice(); + ScPatternAttr* pAttr = pDoc->GetDefPattern(); + ::Font aDefFont; + pAttr->GetFont( aDefFont, SC_AUTOCOL_BLACK, pRefDevice ); + pRefDevice->SetFont( aDefFont ); + long nCharWidth = pRefDevice->GetTextWidth( String( '0' ) ); // 1/100th mm + return lcl_hmmToPoints( nCharWidth ); } uno::Any SAL_CALL @@ -3803,19 +3892,19 @@ ScVbaRange::getColumnWidth() throw (uno::RuntimeException) table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); sal_Int32 nStartCol = thisAddress.StartColumn; sal_Int32 nEndCol = thisAddress.EndColumn; - USHORT nColTwips = 0; + sal_uInt16 nColTwips = 0; for( sal_Int32 nCol = nStartCol ; nCol <= nEndCol; ++nCol ) { thisAddress.StartColumn = nCol; - USHORT nCurTwips = pShell->GetDocument()->GetOriginalWidth( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCTAB >( thisAddress.Sheet ) ); + sal_uInt16 nCurTwips = pShell->GetDocument()->GetOriginalWidth( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCTAB >( thisAddress.Sheet ) ); if ( nCol == nStartCol ) nColTwips = nCurTwips; if ( nColTwips != nCurTwips ) return aNULL(); } - nColWidth = lcl_Round2DecPlaces( lcl_TwipsToPoints( nColTwips ) ); - if ( xModel.is() ) - nColWidth = nColWidth / defaultCharWidth; + nColWidth = lcl_TwipsToPoints( nColTwips ); + if ( nColWidth != 0.0 ) + nColWidth = ( nColWidth / defaultCharWidth ) - fExtraWidth; } nColWidth = lcl_Round2DecPlaces( nColWidth ); return uno::makeAny( nColWidth ); @@ -3837,26 +3926,23 @@ ScVbaRange::setColumnWidth( const uno::Any& _columnwidth ) throw (uno::RuntimeEx double nColWidth = 0; _columnwidth >>= nColWidth; nColWidth = lcl_Round2DecPlaces( nColWidth ); - ScDocShell* pDocShell = getScDocShell(); - if ( pDocShell ) - { - uno::Reference< frame::XModel > xModel = pDocShell->GetModel(); - if ( xModel.is() ) - { + ScDocShell* pDocShell = getScDocShell(); + if ( pDocShell ) + { + if ( nColWidth != 0.0 ) + nColWidth = ( nColWidth + fExtraWidth ) * getDefaultCharWidth( pDocShell ); + RangeHelper thisRange( mxRange ); + table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); + sal_uInt16 nTwips = lcl_pointsToTwips( nColWidth ); - nColWidth = ( nColWidth * getDefaultCharWidth( xModel ) ); - RangeHelper thisRange( mxRange ); - table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); - USHORT nTwips = lcl_pointsToTwips( nColWidth ); + ScDocFunc aFunc(*pDocShell); + SCCOLROW nColArr[2]; + nColArr[0] = thisAddress.StartColumn; + nColArr[1] = thisAddress.EndColumn; + // #163561# use mode SC_SIZE_DIRECT: hide for width 0, show for other values + aFunc.SetWidthOrHeight( true, 1, nColArr, thisAddress.Sheet, + SC_SIZE_DIRECT, nTwips, true, true ); - ScDocFunc aFunc(*pDocShell); - SCCOLROW nColArr[2]; - nColArr[0] = thisAddress.StartColumn; - nColArr[1] = thisAddress.EndColumn; - aFunc.SetWidthOrHeight( TRUE, 1, nColArr, thisAddress.Sheet, SC_SIZE_ORIGINAL, - nTwips, TRUE, TRUE ); - - } } } @@ -3947,7 +4033,7 @@ ScVbaRange::BorderAround( const css::uno::Any& LineStyle, const css::uno::Any& W case excel::XlBordersIndex::xlDiagonalUp: break; default: - return uno::makeAny( sal_False ); + return uno::makeAny( false ); } } return uno::makeAny( sal_True ); @@ -3970,7 +4056,7 @@ ScVbaRange::getRowHeight() throw (uno::RuntimeException) sal_Int32 nStartRow = thisAddress.StartRow; sal_Int32 nEndRow = thisAddress.EndRow; - USHORT nRowTwips = 0; + sal_uInt16 nRowTwips = 0; // #TODO probably possible to use the SfxItemSet ( and see if // SFX_ITEM_DONTCARE is set ) to improve performance // #CHECKME looks like this is general behaviour not just row Range specific @@ -3981,7 +4067,7 @@ ScVbaRange::getRowHeight() throw (uno::RuntimeException) for ( sal_Int32 nRow = nStartRow ; nRow <= nEndRow; ++nRow ) { thisAddress.StartRow = nRow; - USHORT nCurTwips = pShell->GetDocument()->GetOriginalHeight( thisAddress.StartRow, thisAddress.Sheet ); + sal_uInt16 nCurTwips = pShell->GetDocument()->GetOriginalHeight( thisAddress.StartRow, thisAddress.Sheet ); if ( nRow == nStartRow ) nRowTwips = nCurTwips; if ( nRowTwips != nCurTwips ) @@ -4010,15 +4096,15 @@ ScVbaRange::setRowHeight( const uno::Any& _rowheight) throw (uno::RuntimeExcepti nHeight = lcl_Round2DecPlaces( nHeight ); RangeHelper thisRange( mxRange ); table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); - USHORT nTwips = lcl_pointsToTwips( nHeight ); + sal_uInt16 nTwips = lcl_pointsToTwips( nHeight ); ScDocShell* pDocShell = excel::GetDocShellFromRange( mxRange ); ScDocFunc aFunc(*pDocShell); SCCOLROW nRowArr[2]; nRowArr[0] = thisAddress.StartRow; nRowArr[1] = thisAddress.EndRow; - aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, thisAddress.Sheet, SC_SIZE_ORIGINAL, - nTwips, TRUE, TRUE ); + aFunc.SetWidthOrHeight( false, 1, nRowArr, thisAddress.Sheet, SC_SIZE_ORIGINAL, + nTwips, true, true ); } uno::Any SAL_CALL @@ -4030,10 +4116,10 @@ ScVbaRange::getPageBreak() throw (uno::RuntimeException) { RangeHelper thisRange( mxRange ); table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); - BOOL bColumn = FALSE; + sal_Bool bColumn = false; if (thisAddress.StartRow==0) - bColumn = TRUE; + bColumn = true; uno::Reference< frame::XModel > xModel = pShell->GetModel(); if ( xModel.is() ) @@ -4070,10 +4156,10 @@ ScVbaRange::setPageBreak( const uno::Any& _pagebreak) throw (uno::RuntimeExcepti table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); if ((thisAddress.StartColumn==0) && (thisAddress.StartRow==0)) return; - BOOL bColumn = FALSE; + sal_Bool bColumn = false; if (thisAddress.StartRow==0) - bColumn = TRUE; + bColumn = true; ScAddress aAddr( static_cast<SCCOL>(thisAddress.StartColumn), thisAddress.StartRow, thisAddress.Sheet ); uno::Reference< frame::XModel > xModel = pShell->GetModel(); @@ -4081,9 +4167,9 @@ ScVbaRange::setPageBreak( const uno::Any& _pagebreak) throw (uno::RuntimeExcepti { ScTabViewShell* pViewShell = excel::getBestViewShell( xModel ); if ( nPageBreak == excel::XlPageBreak::xlPageBreakManual ) - pViewShell->InsertPageBreak( bColumn, TRUE, &aAddr); + pViewShell->InsertPageBreak( bColumn, sal_True, &aAddr); else if ( nPageBreak == excel::XlPageBreak::xlPageBreakNone ) - pViewShell->DeletePageBreak( bColumn, TRUE, &aAddr); + pViewShell->DeletePageBreak( bColumn, sal_True, &aAddr); } } } @@ -4258,7 +4344,7 @@ ScDBData* lcl_GetDBData_Impl( ScDocShell* pDocShell, sal_Int16 nSheet ) ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); if (pNames) { - USHORT nPos = 0; + sal_uInt16 nPos = 0; if (pNames->SearchName( sName , nPos )) pRet = (*pNames)[nPos]; } @@ -4274,7 +4360,7 @@ void lcl_SelectAll( ScDocShell* pDocShell, ScQueryParam& aParam ) if ( pViewData ) { OSL_TRACE("Pushing out SelectAll query"); - pViewData->GetView()->Query( aParam, NULL, TRUE ); + pViewData->GetView()->Query( aParam, NULL, sal_True ); } } } @@ -4414,7 +4500,7 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); sal_Int16 nSheet = thisAddress.Sheet; ScDocShell* pShell = getScDocShell(); - sal_Bool bHasAuto = sal_False; + sal_Bool bHasAuto = false; rtl::OUString sAutofiltRangeName; uno::Reference< sheet::XDatabaseRange > xDataBaseRange = excel::GetAutoFiltRange( pShell, nSheet, sAutofiltRangeName ); if ( xDataBaseRange.is() ) @@ -4447,6 +4533,20 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const { RangeHelper multiCellRange( mxRange ); autoFiltAddress = multiCellRange.getCellRangeAddressable()->getRangeAddress(); + // #163530# Filter box shows only entry of first row + ScDocument* pDocument = ( pShell ? pShell->GetDocument() : NULL ); + if ( pDocument ) + { + SCCOL nStartCol = autoFiltAddress.StartColumn; + SCROW nStartRow = autoFiltAddress.StartRow; + SCCOL nEndCol = autoFiltAddress.EndColumn; + SCROW nEndRow = autoFiltAddress.EndRow; + pDocument->GetDataArea( autoFiltAddress.Sheet, nStartCol, nStartRow, nEndCol, nEndRow, sal_True, true ); + autoFiltAddress.StartColumn = nStartCol; + autoFiltAddress.StartRow = nStartRow; + autoFiltAddress.EndColumn = nEndCol; + autoFiltAddress.EndRow = nEndRow; + } } uno::Reference< sheet::XDatabaseRanges > xDBRanges = excel::GetDataBaseRanges( pShell ); @@ -4468,10 +4568,10 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const xDBRangeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoFilter") ), uno::Any(sal_True) ); // set header uno::Reference< beans::XPropertySet > xFiltProps( xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY_THROW ); - sal_Bool bHasColHeader = sal_False; + sal_Bool bHasColHeader = false; ScDocument* pDoc = pShell ? pShell->GetDocument() : NULL; - bHasColHeader = pDoc->HasColHeader( static_cast< SCCOL >( autoFiltAddress.StartColumn ), static_cast< SCROW >( autoFiltAddress.StartRow ), static_cast< SCCOL >( autoFiltAddress.EndColumn ), static_cast< SCROW >( autoFiltAddress.EndRow ), static_cast< SCTAB >( autoFiltAddress.Sheet ) ) ? sal_True : sal_False; + bHasColHeader = pDoc->HasColHeader( static_cast< SCCOL >( autoFiltAddress.StartColumn ), static_cast< SCROW >( autoFiltAddress.StartRow ), static_cast< SCCOL >( autoFiltAddress.EndColumn ), static_cast< SCROW >( autoFiltAddress.EndRow ), static_cast< SCTAB >( autoFiltAddress.Sheet ) ) ? sal_True : false; xFiltProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ContainsHeader") ), uno::Any( bHasColHeader ) ); } @@ -4484,12 +4584,12 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const VisibleDropDown >>= bVisible; if ( bVisible == bHasAuto ) // dropdown is displayed/notdisplayed as required - bVisible = sal_False; + bVisible = false; sheet::FilterConnection nConn = sheet::FilterConnection_AND; double nCriteria1 = 0; bool bHasCritValue = Criteria1.hasValue(); - bool bCritHasNumericValue = sal_False; // not sure if a numeric criteria is possible + bool bCritHasNumericValue = false; // not sure if a numeric criteria is possible if ( bHasCritValue ) bCritHasNumericValue = ( Criteria1 >>= nCriteria1 ); @@ -4609,7 +4709,7 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const { uno::Reference< beans::XPropertySet > xProps; lcl_setTableFieldsFromCriteria( sCriteria2, xProps, sTabFilts[1] ); - sTabFilts[1].IsNumeric = sal_False; + sTabFilts[1].IsNumeric = false; } } else // numeric @@ -4660,10 +4760,8 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const } void SAL_CALL -ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (uno::RuntimeException) +ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& /*CopyOrigin*/ ) throw (uno::RuntimeException) { - sal_Bool bCopyOrigin = sal_True; - CopyOrigin >>= bCopyOrigin; // It appears ( from the web ) that the undocumented CopyOrigin // param should contain member of enum XlInsertFormatOrigin // which can have values xlFormatFromLeftOrAbove or xlFormatFromRightOrBelow @@ -4698,7 +4796,11 @@ ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (u table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); uno::Reference< sheet::XCellRangeMovement > xCellRangeMove( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW ); xCellRangeMove->insertCells( thisAddress, mode ); - if ( bCopyOrigin ) + + // Paste from clipboard only if the clipboard content was copied via VBA, and not already pasted via VBA again. + // "Insert" behavior should not depend on random clipboard content previously copied by the user. + ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard( NULL ); + if ( pClipObj && pClipObj->GetUseInApi() ) { // After the insert ( this range ) actually has moved ScRange aRange( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCROW >( thisAddress.StartRow ), static_cast< SCTAB >( thisAddress.Sheet ), static_cast< SCCOL >( thisAddress.EndColumn ), static_cast< SCROW >( thisAddress.EndRow ), static_cast< SCTAB >( thisAddress.Sheet ) ); @@ -4736,15 +4838,15 @@ ScVbaRange::Autofit() throw (uno::RuntimeException) SCCOLROW nColArr[2]; nColArr[0] = thisAddress.StartColumn; nColArr[1] = thisAddress.EndColumn; - BOOL bDirection = TRUE; + sal_Bool bDirection = sal_True; if ( mbIsRows ) { - bDirection = FALSE; + bDirection = false; nColArr[0] = thisAddress.StartRow; nColArr[1] = thisAddress.EndRow; } aFunc.SetWidthOrHeight( bDirection, 1, nColArr, thisAddress.Sheet, SC_SIZE_OPTIMAL, - 0, TRUE, TRUE ); + 0, true, true ); } } @@ -4796,7 +4898,7 @@ ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any OSL_TRACE("set TextQualifier\n"); } - sal_Bool bConsecutiveDelimiter = sal_False; + sal_Bool bConsecutiveDelimiter = false; if( ConsecutiveDelimiter.hasValue() ) { if( !( ConsecutiveDelimiter >>= bConsecutiveDelimiter ) ) @@ -4805,7 +4907,7 @@ ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any OSL_TRACE("set ConsecutiveDelimiter\n"); } - sal_Bool bTab = sal_False; + sal_Bool bTab = false; if( Tab.hasValue() && bDilimited ) { if( !( Tab >>= bTab ) ) @@ -4814,7 +4916,7 @@ ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any OSL_TRACE("set Tab\n"); } - sal_Bool bSemicolon = sal_False; + sal_Bool bSemicolon = false; if( Semicolon.hasValue() && bDilimited ) { if( !( Semicolon >>= bSemicolon ) ) @@ -4822,7 +4924,7 @@ ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any uno::Reference< uno::XInterface >() ); OSL_TRACE("set Semicolon\n"); } - sal_Bool bComma = sal_False; + sal_Bool bComma = false; if( Comma.hasValue() && bDilimited ) { if( !( Comma >>= bComma ) ) @@ -4830,7 +4932,7 @@ ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any uno::Reference< uno::XInterface >() ); OSL_TRACE("set Comma\n"); } - sal_Bool bSpace = sal_False; + sal_Bool bSpace = false; if( Space.hasValue() && bDilimited ) { if( !( Space >>= bSpace ) ) @@ -4838,7 +4940,7 @@ ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any uno::Reference< uno::XInterface >() ); OSL_TRACE("set Space\n"); } - sal_Bool bOther = sal_False; + sal_Bool bOther = false; rtl::OUString sOtherChar; if( Other.hasValue() && bDilimited ) { @@ -4889,15 +4991,15 @@ ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any } // Parse the value of parameter FieldInfo. - USHORT nRealCount = 0; + sal_uInt16 nRealCount = 0; xub_StrLen* pColumns = NULL; - BYTE* pFormats = NULL; + sal_uInt8* pFormats = NULL; if ( sFieldInfo.getLength() > 0 ) { - USHORT nCount = sFieldInfo.getLength(); + sal_uInt16 nCount = sFieldInfo.getLength(); pColumns = new xub_StrLen[nCount]; - pFormats = new BYTE[nCount]; - USHORT nFormat = 1; + pFormats = new sal_uInt8[nCount]; + sal_uInt16 nFormat = 1; uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext ); for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) { @@ -4908,7 +5010,7 @@ ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any { uno::Any aConverted = xConverter->convertTo( sFieldInfo[nIndex][0], getCppuType((xub_StrLen*)0) ); aConverted >>= pColumns[nRealCount]; - aConverted = xConverter->convertTo( sFieldInfo[nIndex][1], getCppuType((USHORT*)0) ); + aConverted = xConverter->convertTo( sFieldInfo[nIndex][1], getCppuType((sal_uInt16*)0) ); aConverted >>= nFormat; } catch( const uno::Exception& ) @@ -5108,7 +5210,7 @@ uno::Any ScVbaRange::getShowDetail() throw ( css::uno::RuntimeException) if( m_Areas->getCount() > 1 ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can not get Range.ShowDetail attribute ")), uno::Reference< uno::XInterface >() ); - sal_Bool bShowDetail = sal_False; + sal_Bool bShowDetail = false; RangeHelper helper( mxRange ); uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = helper.getSheetCellCursor(); @@ -5121,7 +5223,7 @@ uno::Any ScVbaRange::getShowDetail() throw ( css::uno::RuntimeException) if( (thisAddress.StartRow == thisAddress.EndRow && thisAddress.EndRow == aOutlineAddress.EndRow ) || (thisAddress.StartColumn == thisAddress.EndColumn && thisAddress.EndColumn == aOutlineAddress.EndColumn )) { - sal_Bool bColumn =thisAddress.StartRow == thisAddress.EndRow ? sal_False:sal_True; + sal_Bool bColumn =thisAddress.StartRow == thisAddress.EndRow ? false:sal_True; ScDocument* pDoc = excel::GetDocumentFromRange( mxRange ); ScOutlineTable* pOutlineTable = pDoc->GetOutlineTable(static_cast<SCTAB>(thisAddress.Sheet), sal_True); const ScOutlineArray* pOutlineArray = bColumn ? pOutlineTable->GetColArray(): pOutlineTable->GetRowArray(); @@ -5240,7 +5342,7 @@ throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::Run sal_Int32 nCol; sal_Int32 nMaxRows = 0; sal_Int32 nMaxColumns = 0; - sal_Bool bEof = sal_False; + sal_Bool bEof = false; long lColCnt = 0; if (MaxColumns.hasValue()) { @@ -5479,7 +5581,7 @@ ScVbaRange::AutoFill( const uno::Reference< excel::XRange >& Destination, const } ScDocFunc aFunc(*pDocSh); #ifdef VBA_OOBUILD_HACK - aFunc.FillAuto( aSourceRange, NULL, eDir, eCmd, eDateCmd, nCount, fStep, fEndValue, TRUE, TRUE ); + aFunc.FillAuto( aSourceRange, NULL, eDir, eCmd, eDateCmd, nCount, fStep, fEndValue, sal_True, sal_True ); #endif } sal_Bool SAL_CALL @@ -5505,10 +5607,10 @@ ScVbaRange::GoalSeek( const uno::Any& Goal, const uno::Reference< excel::XRange // but... if it detects 0 is the value it requires then it will use that // e.g. divergence & result both = 0.0 does NOT mean there is an error if ( ( res.Divergence != 0.0 ) && ( res.Result == 0.0 ) ) - bRes = sal_False; + bRes = false; } else - bRes = sal_False; + bRes = false; return bRes; } @@ -5620,7 +5722,7 @@ ScVbaRange::Merge( const uno::Any& Across ) throw (script::BasicErrorException, return; } uno::Reference< table::XCellRange > oCellRange; - sal_Bool bAcross = sal_False; + sal_Bool bAcross = false; Across >>= bAcross; if ( !bAcross ) lcl_mergeCellsOfRange( mxRange ); @@ -5630,7 +5732,7 @@ ScVbaRange::Merge( const uno::Any& Across ) throw (script::BasicErrorException, // #TODO #FIXME this seems incredibly lame, this can't be right for (sal_Int32 i=1; i <= oRangeRowsImpl->getCount();i++) { - oRangeRowsImpl->Cells( uno::makeAny( i ), uno::Any() )->Merge( uno::makeAny( sal_False ) ); + oRangeRowsImpl->Cells( uno::makeAny( i ), uno::Any() )->Merge( uno::makeAny( false ) ); } } } @@ -5648,7 +5750,7 @@ ScVbaRange::UnMerge( ) throw (script::BasicErrorException, uno::RuntimeExceptio } return; } - lcl_mergeCellsOfRange( mxRange, sal_False); + lcl_mergeCellsOfRange( mxRange, false); } uno::Any SAL_CALL @@ -5698,7 +5800,7 @@ ScVbaRange::PreviousNext( bool bIsPrevious ) SCTAB nTab = refRange.aStart.Tab(); ScDocument* pDoc = getScDocument(); - pDoc->GetNextPos( nNewX,nNewY, nTab, nMove,0, TRUE,TRUE, markedRange ); + pDoc->GetNextPos( nNewX,nNewY, nTab, nMove,0, true,true, markedRange ); refRange.aStart.SetCol( nNewX ); refRange.aStart.SetRow( nNewY ); refRange.aStart.SetTab( nTab ); @@ -5908,9 +6010,9 @@ ScVbaRange::Subtotal( ::sal_Int32 _nGroupBy, ::sal_Int32 _nFunction, const uno:: { try { - sal_Bool bDoReplace = sal_False; + sal_Bool bDoReplace = false; aReplace >>= bDoReplace; - sal_Bool bAddPageBreaks = sal_False; + sal_Bool bAddPageBreaks = false; PageBreaks >>= bAddPageBreaks; uno::Reference< sheet::XSubTotalCalculatable> xSub(mxRange, uno::UNO_QUERY_THROW ); @@ -6077,7 +6179,7 @@ uno::Any SAL_CALL ScVbaRange::AdvancedFilter( sal_Int32 Action, const uno::Any& // Unique if ( xPropertySet.is() ) { - sal_Bool bUnique = sal_False; + sal_Bool bUnique = false; uno::Any aUnique; try { @@ -6172,7 +6274,7 @@ ScVbaRange::getServiceNames() sal_Bool SAL_CALL ScVbaRange::hasError() throw (uno::RuntimeException) { - double dResult = sal_False; + double dResult = false; uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW ); uno::Reference< script::XInvocation > xInvoc( xApplication->WorksheetFunction(), uno::UNO_QUERY_THROW ); @@ -6185,7 +6287,7 @@ ScVbaRange::hasError() throw (uno::RuntimeException) xInvoc->invoke( FunctionName, Params, OutParamIndex, OutParam ) >>= dResult; if ( dResult > 0.0 ) return sal_True; - return sal_False; + return false; } namespace range diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index 3bec144fe57f..687128b98757 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -110,11 +110,14 @@ class ScVbaRange : public ScVbaRange_BASE void fillSeries( css::sheet::FillDirection nFillDirection, css::sheet::FillMode nFillMode, css::sheet::FillDateMode nFillDateMode, double fStep, double fEndValue ) throw( css::uno::RuntimeException ); - void ClearContents( sal_Int32 nFlags ) throw (css::uno::RuntimeException); - virtual void setValue( const css::uno::Any& aValue, ValueSetter& setter) throw ( css::uno::RuntimeException); - virtual css::uno::Any getValue( ValueGetter& rValueGetter ) throw (css::uno::RuntimeException); - virtual css::uno::Any getFormulaValue( formula::FormulaGrammar::Grammar ) throw (css::uno::RuntimeException); - virtual void setFormulaValue( const css::uno::Any& aValue, formula::FormulaGrammar::Grammar ) throw ( css::uno::RuntimeException); + void ClearContents( sal_Int32 nFlags, bool bFireEvent ) throw (css::uno::RuntimeException); + + css::uno::Any getValue( ValueGetter& rValueGetter ) throw (css::uno::RuntimeException); + void setValue( const css::uno::Any& aValue, ValueSetter& setter, bool bFireEvent ) throw ( css::uno::RuntimeException); + + css::uno::Any getFormulaValue( formula::FormulaGrammar::Grammar ) throw (css::uno::RuntimeException); + void setFormulaValue( const css::uno::Any& aValue, formula::FormulaGrammar::Grammar, bool bFireEvent ) throw ( css::uno::RuntimeException); + css::uno::Reference< ov::excel::XRange > getArea( sal_Int32 nIndex ) throw( css::uno::RuntimeException ); ScCellRangeObj* getCellRangeObj( ) throw ( css::uno::RuntimeException ); css::uno::Reference< ov::XCollection >& getBorders(); @@ -122,6 +125,10 @@ class ScVbaRange : public ScVbaRange_BASE css::uno::Reference< ov::excel::XRange > PreviousNext( bool bIsPrevious ); css::uno::Reference< ov::excel::XRange > SpecialCellsImpl( sal_Int32 nType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException ); css::awt::Point getPosition() throw ( css::uno::RuntimeException ); + + /** Fires a Worksheet_Change event for this range or range list. */ + void fireChangeEvent(); + protected: virtual ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException ); virtual SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException ); @@ -152,6 +159,12 @@ public: formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( css::uno::RuntimeException ); css::table::CellAddress getLeftUpperCellAddress(); + static css::uno::Reference< ov::excel::XRange > CellsHelper( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::table::XCellRange >& xRange, + const css::uno::Any &nRowIndex, const css::uno::Any &nColumnIndex ) throw(css::uno::RuntimeException); + // Attributes virtual css::uno::Any SAL_CALL getName() throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx index 652c8e4f87b1..9c8b5e2e501b 100644 --- a/sc/source/ui/vba/vbasheetobject.cxx +++ b/sc/source/ui/vba/vbasheetobject.cxx @@ -39,7 +39,9 @@ #include <rtl/ustrbuf.hxx> #include <filter/msfilter/msvbahelper.hxx> #include <oox/helper/helper.hxx> +#include <svx/unoshape.hxx> #include "vbafont.hxx" +#include "drwlayer.hxx" using ::rtl::OUString; using namespace ::com::sun::star; @@ -238,13 +240,42 @@ void SAL_CALL ScVbaSheetObjectBase::setName( const OUString& rName ) throw (uno: sal_Int32 SAL_CALL ScVbaSheetObjectBase::getPlacement() throw (uno::RuntimeException) { - // TODO - return excel::XlPlacement::xlMoveAndSize; + sal_Int32 nRet = excel::XlPlacement::xlMoveAndSize; +#if 0 // TODO: not working at the moment. + SvxShape* pShape = SvxShape::getImplementation( mxShape ); + if(pShape) + { + SdrObject* pObj = pShape->GetSdrObject(); + if (pObj) + { + ScAnchorType eType = ScDrawLayer::GetAnchor(pObj); + if (eType == SCA_PAGE) + nRet = excel::XlPlacement::xlFreeFloating; + } + } +#endif + return nRet; } void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 /*nPlacement*/ ) throw (uno::RuntimeException) { - // TODO +#if 0 // TODO: not working at the moment. + SvxShape* pShape = SvxShape::getImplementation( mxShape ); + if(pShape) + { + SdrObject* pObj = pShape->GetSdrObject(); + if (pObj) + { + ScAnchorType eType = SCA_CELL; + if ( nPlacement == excel::XlPlacement::xlFreeFloating ) + eType = SCA_PAGE; + + // xlMove is not supported, treated as SCA_CELL (xlMoveAndSize) + + ScDrawLayer::SetAnchor(pObj, eType); + } + } +#endif } sal_Bool SAL_CALL ScVbaSheetObjectBase::getPrintObject() throw (uno::RuntimeException) @@ -351,14 +382,14 @@ void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName ) // if a macro name has been passed, try to attach it to the event if( rMacroName.getLength() > 0 ) { - VBAMacroResolvedInfo aResolvedMacro = resolveVBAMacro( getSfxObjShell( mxModel ), rMacroName ); - if( !aResolvedMacro.IsResolved() ) + MacroResolvedInfo aResolvedMacro = resolveVBAMacro( getSfxObjShell( mxModel ), rMacroName ); + if( !aResolvedMacro.mbFound ) throw uno::RuntimeException(); script::ScriptEventDescriptor aDescriptor; aDescriptor.ListenerType = maListenerType; aDescriptor.EventMethod = maEventMethod; aDescriptor.ScriptType = CREATE_OUSTRING( "Script" ); - aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.ResolvedMacro() ); + aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.msResolvedMacro ); xEventMgr->registerScriptEvent( nIndex, aDescriptor ); } } @@ -378,7 +409,7 @@ void SAL_CALL ScVbaControlObjectBase::setPrintObject( sal_Bool bPrintObject ) th sal_Bool SAL_CALL ScVbaControlObjectBase::getAutoSize() throw (uno::RuntimeException) { // not supported - return sal_False; + return false; } void SAL_CALL ScVbaControlObjectBase::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException) diff --git a/sc/source/ui/vba/vbavalidation.cxx b/sc/source/ui/vba/vbavalidation.cxx index 126b03577887..2c52556b23a9 100644 --- a/sc/source/ui/vba/vbavalidation.cxx +++ b/sc/source/ui/vba/vbavalidation.cxx @@ -72,7 +72,7 @@ lcl_getValidationProps( const uno::Reference< table::XCellRange >& xRange ) ScVbaValidation::getIgnoreBlank() throw (uno::RuntimeException) { uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) ); - sal_Bool bBlank = sal_False; + sal_Bool bBlank = false; xProps->getPropertyValue( IGNOREBLANK ) >>= bBlank; return bBlank; } @@ -91,13 +91,13 @@ ScVbaValidation::getInCellDropdown() throw (uno::RuntimeException) uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange ); sal_Int32 nShowList = 0; xProps->getPropertyValue( SHOWLIST ) >>= nShowList; - return ( nShowList ? sal_True : sal_False ); + return ( nShowList ? sal_True : false ); } void SAL_CALL ScVbaValidation::setInCellDropdown( ::sal_Bool _incelldropdown ) throw (uno::RuntimeException) { - sal_Int32 nDropDown = sal_False; + sal_Int32 nDropDown = false; if ( _incelldropdown ) nDropDown = 1; uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps(m_xRange) ); @@ -109,7 +109,7 @@ ScVbaValidation::setInCellDropdown( ::sal_Bool _incelldropdown ) throw (uno::R ScVbaValidation::getShowInput() throw (uno::RuntimeException) { uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange ); - sal_Bool bShowInput = sal_False; + sal_Bool bShowInput = false; xProps->getPropertyValue( SHOWINPUT ) >>= bShowInput; return bShowInput; } @@ -126,7 +126,7 @@ ScVbaValidation:: setShowInput( ::sal_Bool _showinput ) throw (uno::RuntimeExcep ScVbaValidation::getShowError() throw (uno::RuntimeException) { uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange ); - sal_Bool bShowError = sal_False; + sal_Bool bShowError = false; xProps->getPropertyValue( SHOWERROR ) >>= bShowError; return bShowError; } diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx index e79985db92a6..761671727e9c 100644 --- a/sc/source/ui/vba/vbawindow.cxx +++ b/sc/source/ui/vba/vbawindow.cxx @@ -683,14 +683,14 @@ double SAL_CALL ScVbaWindow::getSplitVertical() throw (uno::RuntimeException) { double fSplitVertical = m_xViewSplitable->getSplitVertical(); - double fVertiPoints = PixelsToPoints( m_xDevice, fSplitVertical, sal_False ); + double fVertiPoints = PixelsToPoints( m_xDevice, fSplitVertical, false ); return fVertiPoints; } void SAL_CALL ScVbaWindow::setSplitVertical(double _splitvertical ) throw (uno::RuntimeException) { - double fVertiPixels = PointsToPixels( m_xDevice, _splitvertical, sal_False ); + double fVertiPixels = PointsToPixels( m_xDevice, _splitvertical, false ); m_xViewSplitable->splitAtPosition( 0, static_cast<sal_Int32>( fVertiPixels ) ); } @@ -761,7 +761,7 @@ ScVbaWindow::setView( const uno::Any& _view) throw (uno::RuntimeException) { sal_Int32 nWindowView = excel::XlWindowView::xlNormalView; _view >>= nWindowView; - USHORT nSlot = FID_NORMALVIEWMODE; + sal_uInt16 nSlot = FID_NORMALVIEWMODE; switch ( nWindowView ) { case excel::XlWindowView::xlNormalView: diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx index 53063bd0e4fc..bf880e473af3 100644 --- a/sc/source/ui/vba/vbaworkbook.cxx +++ b/sc/source/ui/vba/vbaworkbook.cxx @@ -382,18 +382,16 @@ ScVbaWorkbook::Styles( const::uno::Any& Item ) throw (uno::RuntimeException) } uno::Any SAL_CALL -ScVbaWorkbook::Names( const css::uno::Any& aIndex ) throw (uno::RuntimeException) +ScVbaWorkbook::Names( const uno::Any& aIndex ) throw (uno::RuntimeException) { - uno::Reference< frame::XModel > xModel( getModel() ); + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW ); uno::Reference< beans::XPropertySet > xProps( xModel, uno::UNO_QUERY_THROW ); uno::Reference< sheet::XNamedRanges > xNamedRanges( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NamedRanges") ) ), uno::UNO_QUERY_THROW ); - uno::Reference< XCollection > xNames( new ScVbaNames( this , mxContext , xNamedRanges , xModel )); - if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID ) - { + uno::Reference< XCollection > xNames( new ScVbaNames( this, mxContext, xNamedRanges, xModel ) ); + if ( aIndex.hasValue() ) + return uno::Any( xNames->Item( aIndex, uno::Any() ) ); return uno::Any( xNames ); } - return uno::Any( xNames->Item( aIndex, uno::Any() ) ); -} rtl::OUString& ScVbaWorkbook::getServiceImplName() diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index ee947f1a757e..86b24c3dec92 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -47,7 +47,9 @@ #include <com/sun/star/document/XTypeDetection.hpp> #include <com/sun/star/uri/XUriReference.hpp> #include <com/sun/star/uri/XUriReferenceFactory.hpp> +#include <com/sun/star/script/vba/VBAEventId.hpp> #include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> #include <com/sun/star/script/vba/XVBAModuleInfo.hpp> #include <com/sun/star/script/ModuleInfo.hpp> #include <com/sun/star/script/ModuleType.hpp> @@ -74,15 +76,19 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& ScDocShell* pShell = excel::getDocShell( xModel ); if ( pShell ) { + String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + pShell->GetBasicManager()->SetName( aPrjName ); + + /* Set library container to VBA compatibility mode. This will create + the VBA Globals object and store it in the Basic manager of the + document. */ uno::Reference<script::XLibraryContainer> xLibContainer = pShell->GetBasicContainer(); uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY_THROW ); xVBACompat->setVBACompatibilityMode( sal_True ); - String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - pShell->GetBasicManager()->SetName( aPrjName ); if( xLibContainer.is() ) { - if( !xLibContainer->hasByName( aPrjName ) ) + if( !xLibContainer->hasByName( aPrjName ) ) xLibContainer->createLibrary( aPrjName ); uno::Any aLibAny = xLibContainer->getByName( aPrjName ); uno::Reference< container::XNameContainer > xLib; @@ -91,8 +97,6 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& { uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY_THROW ); 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 @@ -131,6 +135,18 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& } } } + + /* Trigger the Workbook_Open event, event processor will register + itself as listener for specific events. */ + try + { + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pShell->GetDocument()->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_OPEN, aArgs ); + } + catch( uno::Exception& ) + { + } } } @@ -201,9 +217,41 @@ ScVbaWorkbooks::createCollectionObject( const css::uno::Any& aSource ) uno::Any SAL_CALL -ScVbaWorkbooks::Add() throw (uno::RuntimeException) +ScVbaWorkbooks::Add( const uno::Any& Template ) throw (uno::RuntimeException) { - uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( VbaDocumentsBase::Add() , uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheetDocument > xSpreadDoc; + sal_Int32 nWorkbookType = 0; + ::rtl::OUString aTemplateFileName; + if( Template >>= nWorkbookType ) + { + // nWorkbookType is a constant from XlWBATemplate (added in Excel 2007) + // TODO: create chart-sheet if supported by Calc + + xSpreadDoc.set( createDocument(), uno::UNO_QUERY_THROW ); + // create a document with one sheet only + uno::Reference< sheet::XSpreadsheets > xSheets( xSpreadDoc->getSheets(), uno::UNO_SET_THROW ); + uno::Reference< container::XIndexAccess > xSheetsIA( xSheets, uno::UNO_QUERY_THROW ); + while( xSheetsIA->getCount() > 1 ) + { + uno::Reference< container::XNamed > xSheetName( xSheetsIA->getByIndex( xSheetsIA->getCount() - 1 ), uno::UNO_QUERY_THROW ); + xSheets->removeByName( xSheetName->getName() ); + } + } + else if( Template >>= aTemplateFileName ) + { + // TODO: create document from template + xSpreadDoc.set( createDocument(), uno::UNO_QUERY_THROW ); + } + else if( !Template.hasValue() ) + { + // regular spreadsheet document with configured number of sheets + xSpreadDoc.set( createDocument(), uno::UNO_QUERY_THROW ); + } + else + { + // illegal argument + throw uno::RuntimeException(); + } // need to set up the document modules ( and vba mode ) here setUpDocumentModules( xSpreadDoc ); @@ -212,10 +260,10 @@ ScVbaWorkbooks::Add() throw (uno::RuntimeException) return uno::Any(); } -void +void SAL_CALL ScVbaWorkbooks::Close() throw (uno::RuntimeException) { - VbaDocumentsBase::Close(); + closeDocuments(); } bool @@ -255,7 +303,7 @@ ScVbaWorkbooks::getFileFilterType( const rtl::OUString& rFileName ) } // #TODO# #FIXME# can any of the unused params below be used? -uno::Any +uno::Any SAL_CALL 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) { // we need to detect if this is a URL, if not then assume its a file path @@ -334,7 +382,7 @@ ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLi else if ( !isSpreadSheetFile( sType ) ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Bad Format")), uno::Reference< uno::XInterface >() ); - uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( VbaDocumentsBase::Open( rFileName, ReadOnly, sProps ), uno::UNO_QUERY_THROW ); + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( openDocument( rFileName, ReadOnly, sProps ), uno::UNO_QUERY_THROW ); uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, mxParent ); uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY ); if ( xWBook.is() ) @@ -342,12 +390,6 @@ ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLi return aRet; } -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 ); -} - rtl::OUString& ScVbaWorkbooks::getServiceImplName() { diff --git a/sc/source/ui/vba/vbaworkbooks.hxx b/sc/source/ui/vba/vbaworkbooks.hxx index a195bb8d3cd0..51273b180cf1 100644 --- a/sc/source/ui/vba/vbaworkbooks.hxx +++ b/sc/source/ui/vba/vbaworkbooks.hxx @@ -61,12 +61,9 @@ public: virtual css::uno::Sequence<rtl::OUString> getServiceNames(); // XWorkbooks - virtual css::uno::Any SAL_CALL Add() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Template ) throw (css::uno::RuntimeException); virtual void SAL_CALL Close( ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Open( const ::rtl::OUString& Filename, const css::uno::Any& UpdateLinks, const css::uno::Any& ReadOnly, const css::uno::Any& Format, const css::uno::Any& Password, const css::uno::Any& WriteResPassword, const css::uno::Any& IgnoreReadOnlyRecommended, const css::uno::Any& Origin, const css::uno::Any& Delimiter, const css::uno::Any& Editable, const css::uno::Any& Notify, const css::uno::Any& Converter, const css::uno::Any& AddToMru ) throw (css::uno::RuntimeException); - - // VbaDocumentsBase / XDocumentsBase (to avoid warning C4266 for hiding function on wntmsci) - virtual css::uno::Any SAL_CALL Open( const ::rtl::OUString& Filename, const css::uno::Any& ReadOnly, const css::uno::Sequence< css::beans::PropertyValue >& rProps ) throw (css::uno::RuntimeException); }; #endif /* SC_VBA_WORKBOOKS_HXX */ diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 51a2292c2bf2..94f197d32de5 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -30,6 +30,7 @@ #include <cppuhelper/queryinterface.hxx> #include "vbaworksheet.hxx" +#include "vbanames.hxx" #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XIntrospectionAccess.hpp> @@ -52,6 +53,7 @@ #include <com/sun/star/sheet/XSheetOutline.hpp> #include <com/sun/star/sheet/XSheetPageBreak.hpp> #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp> +#include <com/sun/star/sheet/XNamedRanges.hpp> #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> @@ -62,6 +64,7 @@ #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/form/XFormsSupplier.hpp> #include <ooo/vba/excel/XlEnableSelection.hpp> +#include <ooo/vba/excel/XlSheetVisibility.hpp> #include <ooo/vba/excel/XWorkbook.hpp> #include <ooo/vba/XControlProvider.hpp> #include <ooo/vba/excel/XlSheetVisibility.hpp> @@ -182,7 +185,7 @@ openNewDoc(rtl::OUString aSheetName ) return xModel; } -ScVbaWorksheet::ScVbaWorksheet( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : WorksheetImpl_BASE( xParent, xContext ) +ScVbaWorksheet::ScVbaWorksheet( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : WorksheetImpl_BASE( xParent, xContext ), mbVeryHidden( false ) { } @@ -193,9 +196,9 @@ ScVbaWorksheet::ScVbaWorksheet(const uno::Reference< XHelperInterface >& xParent } ScVbaWorksheet::ScVbaWorksheet( uno::Sequence< uno::Any> const & args, - uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : WorksheetImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ) + uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : WorksheetImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ), mbVeryHidden( false ) { - if ( args.getLength() < 2 ) + if ( args.getLength() < 3 ) throw lang::IllegalArgumentException(); rtl::OUString sSheetName; @@ -243,24 +246,31 @@ ScVbaWorksheet::getVisible() throw (uno::RuntimeException) } void -ScVbaWorksheet::setVisible( ::sal_Int32 _Visible ) throw (uno::RuntimeException) +ScVbaWorksheet::setVisible( ::sal_Int32 nVisible ) throw (uno::RuntimeException) { - uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW ); - - sal_Bool bVisible = true; - switch( _Visible ) + using namespace ::ooo::vba::excel::XlSheetVisibility; + bool bVisible = true; + switch( nVisible ) { - case excel::XlSheetVisibility::xlSheetHidden: - case excel::XlSheetVisibility::xlSheetVeryHidden: - bVisible = false; - break; - case excel::XlSheetVisibility::xlSheetVisible: + case xlSheetVisible: case 1: // Excel accepts -1 and 1 for visible sheets bVisible = true; - break; + mbVeryHidden = false; + break; + case xlSheetHidden: + bVisible = false; + mbVeryHidden = false; + break; + case xlSheetVeryHidden: + bVisible = false; + mbVeryHidden = true; + break; + default: + throw uno::RuntimeException(); } - uno::Any aValue( bVisible ); + uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW ); xProps->setPropertyValue - (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ), aValue); + ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ), + uno::Any( bVisible ) ); } sal_Int16 @@ -279,8 +289,8 @@ ScVbaWorksheet::getEnableSelection() throw (uno::RuntimeException) uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); - sal_Bool bLockedCells = sal_False; - sal_Bool bUnlockedCells = sal_False; + sal_Bool bLockedCells = false; + sal_Bool bUnlockedCells = false; if( pProtect ) { bLockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); @@ -318,8 +328,8 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeEx ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument(); ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); // default is xlNoSelection - sal_Bool bLockedCells = sal_False; - sal_Bool bUnlockedCells = sal_False; + sal_Bool bLockedCells = false; + sal_Bool bUnlockedCells = false; if( nSelection == excel::XlEnableSelection::xlNoRestrictions ) { bLockedCells = sal_True; @@ -362,7 +372,7 @@ uno::Reference< beans::XPropertySet > ScVbaWorksheet::getFirstDBRangeProperties( sal_Bool SAL_CALL ScVbaWorksheet::getAutoFilterMode() throw (uno::RuntimeException) { uno::Reference< beans::XPropertySet > xDBRangeProps = getFirstDBRangeProperties(); - sal_Bool bAutoFilterMode = sal_False; + sal_Bool bAutoFilterMode = false; return xDBRangeProps.is() && (xDBRangeProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoFilter" ) ) ) >>= bAutoFilterMode) && @@ -436,7 +446,7 @@ ScVbaWorksheet::getStandardHeight() throw (uno::RuntimeException) sal_Bool ScVbaWorksheet::getProtectionMode() throw (uno::RuntimeException) { - return sal_False; + return false; } sal_Bool @@ -461,13 +471,13 @@ ScVbaWorksheet::getProtectDrawingObjects() throw (uno::RuntimeException) if ( pProtect ) return pProtect->isOptionEnabled( ScTableProtection::OBJECTS ); } - return sal_False; + return false; } sal_Bool ScVbaWorksheet::getProtectScenarios() throw (uno::RuntimeException) { - return sal_False; + return false; } void @@ -592,7 +602,7 @@ ScVbaWorksheet::Copy( const uno::Any& Before, const uno::Any& After ) throw (uno ScDocShell* pDestDocShell = excel::getDocShell( pDestSheet->getModel() ); ScDocShell* pSrcDocShell = excel::getDocShell( getModel() ); if ( pDestDocShell && pSrcDocShell ) - pDestDocShell->TransferTab( *pSrcDocShell, static_cast<SCTAB>(nSrc), static_cast<SCTAB>(nDest), TRUE, TRUE ); + pDestDocShell->TransferTab( *pSrcDocShell, static_cast<SCTAB>(nSrc), static_cast<SCTAB>(nDest), true, true ); } } // active the new sheet @@ -729,7 +739,10 @@ uno::Reference< excel::XRange > ScVbaWorksheet::Cells( const ::uno::Any &nRow, const ::uno::Any &nCol ) throw (uno::RuntimeException) { - return getSheetRange()->Cells( nRow, nCol ); + // Performance optimization for often-called Cells method: + // Use a common helper method instead of creating a new ScVbaRange object + uno::Reference< table::XCellRange > xRange( getSheet(), uno::UNO_QUERY_THROW ); + return ScVbaRange::CellsHelper( this, mxContext, xRange, nRow, nCol ); } uno::Reference< excel::XRange > @@ -806,8 +819,15 @@ ScVbaWorksheet::Hyperlinks( const uno::Any& aIndex ) throw (uno::RuntimeExceptio uno::Any SAL_CALL ScVbaWorksheet::Names( const css::uno::Any& aIndex ) throw (uno::RuntimeException) { - uno::Reference< excel::XWorkbook > xWorkbook( getParent(), uno::UNO_QUERY_THROW ); - return xWorkbook->Names( aIndex ); + // fake sheet-local names by returning all global names + // #163498# initialize Names object with correct parent (this worksheet) + // TODO: real sheet-local names... + uno::Reference< beans::XPropertySet > xProps( mxModel, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XNamedRanges > xNamedRanges( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NamedRanges") ) ), uno::UNO_QUERY_THROW ); + uno::Reference< XCollection > xNames( new ScVbaNames( this, mxContext, xNamedRanges, mxModel ) ); + if ( aIndex.hasValue() ) + return uno::Any( xNames->Item( aIndex, uno::Any() ) ); + return uno::Any( xNames ); } uno::Any SAL_CALL @@ -962,7 +982,7 @@ ScVbaWorksheet::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::U ::sal_Bool SAL_CALL ScVbaWorksheet::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::RuntimeException) { - return sal_False; + return false; } uno::Reference< container::XNameAccess > @@ -993,7 +1013,7 @@ ScVbaWorksheet::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeE uno::Reference< container::XNameAccess > xFormControls( getFormControls() ); if ( xFormControls.is() ) return xFormControls->hasByName( aName ); - return sal_False; + return false; } uno::Any @@ -1081,9 +1101,9 @@ ScVbaWorksheet::PrintOut( const uno::Any& From, const uno::Any& To, const uno::A sal_Int32 nTo = 0; sal_Int32 nFrom = 0; sal_Int16 nCopies = 1; - sal_Bool bCollate = sal_False; - sal_Bool bSelection = sal_False; - sal_Bool bIgnorePrintAreas = sal_False; + sal_Bool bCollate = false; + sal_Bool bSelection = false; + sal_Bool bIgnorePrintAreas = false; From >>= nFrom; To >>= nTo; Copies >>= nCopies; diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx index 3328c3c5b807..df490655d9ba 100644 --- a/sc/source/ui/vba/vbaworksheet.hxx +++ b/sc/source/ui/vba/vbaworksheet.hxx @@ -64,6 +64,7 @@ class ScVbaWorksheet : public WorksheetImpl_BASE css::uno::Reference< ov::excel::XChartObjects > mxCharts; css::uno::Reference< ov::excel::XHyperlinks > mxHlinks; ::rtl::Reference< ScVbaSheetObjectsBase > mxButtons; + bool mbVeryHidden; css::uno::Reference< ov::excel::XWorksheet > getSheetAtOffset(SCTAB offset) throw (css::uno::RuntimeException); css::uno::Reference< ov::excel::XRange > getSheetRange() throw (css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index ed0cc73171cb..680b5ae6b600 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -267,7 +267,7 @@ ScVbaWorksheets::Add( const uno::Any& Before, const uno::Any& After, aStringSheet = xBeforeAfterSheet->getName(); else After >>= aStringSheet; - bBefore = sal_False; + bBefore = false; } if (!aStringSheet.getLength()) { @@ -339,8 +339,8 @@ ScVbaWorksheets::PrintOut( const uno::Any& From, const uno::Any& To, const uno:: sal_Int32 nTo = 0; sal_Int32 nFrom = 0; sal_Int16 nCopies = 1; - sal_Bool bCollate = sal_False; - sal_Bool bSelection = sal_False; + sal_Bool bCollate = false; + sal_Bool bSelection = false; From >>= nFrom; To >>= nTo; Copies >>= nCopies; @@ -362,9 +362,9 @@ ScVbaWorksheets::getVisible() throw (uno::RuntimeException) while ( xEnum->hasMoreElements() ) { uno::Reference< excel::XWorksheet > xSheet( xEnum->nextElement(), uno::UNO_QUERY_THROW ); - if ( xSheet->getVisible() == sal_False ) + if ( xSheet->getVisible() == false ) { - bVisible = sal_False; + bVisible = false; break; } } @@ -374,7 +374,7 @@ ScVbaWorksheets::getVisible() throw (uno::RuntimeException) void SAL_CALL ScVbaWorksheets::setVisible( const uno::Any& _visible ) throw (uno::RuntimeException) { - sal_Bool bState = sal_False; + sal_Bool bState = false; if ( _visible >>= bState ) { uno::Reference< container::XEnumeration > xEnum( createEnumeration(), uno::UNO_QUERY_THROW ); @@ -416,7 +416,7 @@ ScVbaWorksheets::Select( const uno::Any& Replace ) throw (uno::RuntimeException) bSelectSingle = false; } else - rMarkData.SelectTable( static_cast< SCTAB >( pSheet->getSheetID() ), TRUE ); + rMarkData.SelectTable( static_cast< SCTAB >( pSheet->getSheetID() ), sal_True ); } } diff --git a/sc/source/ui/vba/vbawsfunction.cxx b/sc/source/ui/vba/vbawsfunction.cxx index b87ec852b9a5..685377da4324 100644 --- a/sc/source/ui/vba/vbawsfunction.cxx +++ b/sc/source/ui/vba/vbawsfunction.cxx @@ -63,7 +63,7 @@ void lclConvertDoubleToBoolean( uno::Any& rAny ) void lclConvertBooleanToDouble( uno::Any& rAny ) { - sal_Bool bValue( sal_False ); + sal_Bool bValue( false ); if ( rAny >>= bValue ) { if ( bValue ) @@ -268,7 +268,7 @@ ScVbaWSFunction::getValue(const rtl::OUString& /*PropertyName*/) throw(beans::Un sal_Bool SAL_CALL ScVbaWSFunction::hasMethod(const rtl::OUString& Name) throw(uno::RuntimeException) { - sal_Bool bIsFound = sal_False; + sal_Bool bIsFound = false; try { // the function name contained in the com.sun.star.sheet.FunctionDescription service is alwayse localized. @@ -288,7 +288,7 @@ ScVbaWSFunction::hasMethod(const rtl::OUString& Name) throw(uno::RuntimeExcepti sal_Bool SAL_CALL ScVbaWSFunction::hasProperty(const rtl::OUString& /*Name*/) throw(uno::RuntimeException) { - return sal_False; + return false; } ::rtl::OUString SAL_CALL |