summaryrefslogtreecommitdiff
path: root/sc/source/ui/vba
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-03-10 16:55:21 -0500
committerKohei Yoshida <kyoshida@novell.com>2011-03-10 20:21:13 -0500
commit43721d32e078d738495451e0060883274475158c (patch)
treeb339bf238c85e51ab2d991a506c806edfefb3b02 /sc/source/ui/vba
parent51bf6bf654860d564e3c5f82ab989b5912252996 (diff)
parent2851cc7baf8defb165e100f303b02e895a4e7fdf (diff)
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101
Diffstat (limited to 'sc/source/ui/vba')
-rw-r--r--sc/source/ui/vba/excelvbahelper.cxx82
-rw-r--r--sc/source/ui/vba/excelvbahelper.hxx32
-rw-r--r--sc/source/ui/vba/makefile.mk12
-rw-r--r--sc/source/ui/vba/testvba/makefile.mk5
-rw-r--r--sc/source/ui/vba/testvba/testvba.cxx6
-rw-r--r--sc/source/ui/vba/vbaapplication.cxx83
-rw-r--r--sc/source/ui/vba/vbaapplication.hxx10
-rw-r--r--sc/source/ui/vba/vbaassistant.cxx4
-rw-r--r--sc/source/ui/vba/vbaaxes.cxx2
-rw-r--r--sc/source/ui/vba/vbaaxis.cxx32
-rw-r--r--sc/source/ui/vba/vbacharacters.cxx4
-rw-r--r--sc/source/ui/vba/vbacharacters.hxx2
-rw-r--r--sc/source/ui/vba/vbachart.cxx34
-rw-r--r--sc/source/ui/vba/vbacomment.cxx6
-rw-r--r--sc/source/ui/vba/vbaeventshelper.cxx221
-rw-r--r--sc/source/ui/vba/vbaeventshelper.hxx9
-rw-r--r--sc/source/ui/vba/vbafiledialog.cxx2
-rw-r--r--sc/source/ui/vba/vbafiledialogselecteditems.cxx2
-rw-r--r--sc/source/ui/vba/vbafont.cxx28
-rw-r--r--sc/source/ui/vba/vbaformat.cxx14
-rw-r--r--sc/source/ui/vba/vbaformatcondition.cxx2
-rw-r--r--sc/source/ui/vba/vbafoundfiles.cxx2
-rw-r--r--sc/source/ui/vba/vbahelper.cxx24
-rw-r--r--sc/source/ui/vba/vbahyperlink.cxx2
-rw-r--r--sc/source/ui/vba/vbanames.cxx2
-rw-r--r--sc/source/ui/vba/vbapagebreak.cxx8
-rw-r--r--sc/source/ui/vba/vbapagebreaks.cxx2
-rw-r--r--sc/source/ui/vba/vbapagesetup.cxx26
-rw-r--r--sc/source/ui/vba/vbaquerytable.cxx4
-rw-r--r--sc/source/ui/vba/vbarange.cxx353
-rw-r--r--sc/source/ui/vba/vbarange.hxx23
-rw-r--r--sc/source/ui/vba/vbasheetobject.cxx43
-rw-r--r--sc/source/ui/vba/vbavalidation.cxx10
-rw-r--r--sc/source/ui/vba/vbawindow.cxx6
-rw-r--r--sc/source/ui/vba/vbaworkbook.cxx12
-rw-r--r--sc/source/ui/vba/vbaworkbooks.cxx82
-rw-r--r--sc/source/ui/vba/vbaworkbooks.hxx5
-rw-r--r--sc/source/ui/vba/vbaworksheet.cxx71
-rw-r--r--sc/source/ui/vba/vbaworksheet.hxx1
-rw-r--r--sc/source/ui/vba/vbaworksheets.cxx14
-rw-r--r--sc/source/ui/vba/vbawsfunction.cxx6
41 files changed, 783 insertions, 505 deletions
diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx
index 99fda2b57..5ec8fd16c 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"
@@ -40,12 +44,7 @@
using namespace ::com::sun::star;
using namespace ::ooo::vba;
-namespace ooo
-{
-namespace vba
-{
-namespace excel
-{
+// ============================================================================
uno::Reference< sheet::XDatabaseRanges >
GetDataBaseRanges( ScDocShell* pShell ) throw ( uno::RuntimeException )
@@ -79,7 +78,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 )
@@ -169,7 +168,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 +216,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 +231,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 +264,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 +277,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 +322,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< 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 +342,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 +359,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 +408,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,16 +430,33 @@ 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
diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx
index bdab4fd28..5d2b02cb2 100644
--- a/sc/source/ui/vba/excelvbahelper.hxx
+++ b/sc/source/ui/vba/excelvbahelper.hxx
@@ -34,12 +34,42 @@
#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);
+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 );
+
+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 );
+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
{
diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk
index a937849d3..67d600116 100644
--- a/sc/source/ui/vba/makefile.mk
+++ b/sc/source/ui/vba/makefile.mk
@@ -123,15 +123,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/testvba/makefile.mk b/sc/source/ui/vba/testvba/makefile.mk
index 20bdeca52..c75f6f632 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 06729c14b..0cb5a1aa3 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 65b7e1151..faa678637 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() )
{
}
@@ -301,7 +323,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 +479,7 @@ ScVbaApplication::getCutCopyMode() throw (uno::RuntimeException)
}
else
{
- result <<= sal_False;
+ result <<= false;
}
return result;
}
@@ -466,7 +488,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 +536,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 +564,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 +575,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 +601,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 +614,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 +679,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 +806,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 +820,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 +854,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 +1340,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 +1350,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 +1373,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 +1383,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 +1447,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 +1456,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 +1625,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 +1657,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 bc047b82c..848169020 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 b52a1651c..abe77778d 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 533791db3..e18ffc46b 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 fc9345893..7e3135c11 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())
@@ -572,7 +572,7 @@ ScVbaAxis::setScaleType( ::sal_Int32 _nScaleType ) throw (script::BasicErrorExce
switch (_nScaleType)
{
case xlScaleLinear:
- mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Logarithmic" ) ), uno::makeAny( sal_False ) );
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Logarithmic" ) ), uno::makeAny( false ) );
break;
case xlScaleLogarithmic:
mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Logarithmic" ) ), uno::makeAny( sal_True ) );
@@ -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 5d12facad..d81ceee4c 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 a0a6c3502..0fde0247b 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 e05278cdb..6ed1b5fe5 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;
@@ -331,7 +331,7 @@ try
case xlXYScatter:
case xlBubble: // not possible
case xlBubble3DEffect: // not possible
- mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( sal_False ));
+ mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( false ));
break;
case xlXYScatterLines:
case xlXYScatterLinesNoMarkers:
@@ -385,7 +385,7 @@ try
default:
if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DEEP))
{
- mxDiagramPropertySet->setPropertyValue(DEEP, uno::makeAny( sal_False));
+ mxDiagramPropertySet->setPropertyValue(DEEP, uno::makeAny( false));
}
break;
}
@@ -455,7 +455,7 @@ try
default:
if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(VERTICAL))
{
- mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny(sal_False));
+ mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny(false));
}
break;
}
@@ -476,7 +476,7 @@ try
case xlConeBarStacked:
case xlPyramidColStacked:
case xlPyramidBarStacked:
- mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False ));
+ mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( false ));
mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_True ));
break;
case xlPyramidColStacked100:
@@ -497,8 +497,8 @@ try
mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_True ));
break;
default:
- mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False));
- mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_False));
+ mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( false));
+ mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( false));
break;
}
switch (_nChartType)
@@ -542,7 +542,7 @@ try
default:
if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DIM3D))
{
- mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( sal_False));
+ mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( false));
}
break;
}
@@ -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 f707fad1e..402d9e9e1 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 712621a63..ad60039fd 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;
@@ -91,7 +137,6 @@ private:
uno::Reference< awt::XWindow > getContainerWindow();
bool isMouseReleased();
DECL_LINK( fireResizeMacro, void* );
- void processWindowResizeMacro();
private:
::osl::Mutex maMutex;
@@ -288,7 +333,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 +408,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;
}
@@ -392,7 +443,7 @@ ScVbaEventsHelper::ScVbaEventsHelper( const uno::Sequence< uno::Any >& rArgs, co
{
mpDocShell = dynamic_cast< ScDocShell* >( mpShell ); // mpShell from base class
mpDoc = mpDocShell ? mpDocShell->GetDocument() : 0;
-
+
if( !mxModel.is() || !mpDocShell || !mpDoc )
return;
@@ -450,43 +501,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();
-
- // 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;
+ // framework and Calc fire a few events before 'opened', ignore them
+ bool bExecuteEvent = mbOpened;
+
+ // 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 +526,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 +668,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,34 +682,31 @@ 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.Count() == 0;
+ bool bRightEmpty = rRight.Count() == 0;
+ 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.GetObject( 0 )->aStart.Tab() != rRight.GetObject( 0 )->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 > xOldSelection( maOldSelection, uno::UNO_QUERY );
uno::Reference< uno::XInterface > xNewSelection = getXSomethingFromArgs< uno::XInterface >( rArgs, nIndex, false );
if( ScCellRangesBase* pNewCellRanges = ScCellRangesBase::getImplementation( xNewSelection ) )
{
@@ -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 3bd965513..a3a28329d 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,11 +70,10 @@ private:
css::uno::Any createWindow() const throw (css::uno::RuntimeException);
private:
- mutable css::uno::WeakReference< ov::excel::XApplication > mxApplication;
::rtl::Reference< ScVbaEventsListener > mxListener;
+ css::uno::Any maOldSelection;
ScDocShell* mpDocShell;
ScDocument* mpDoc;
- ScRangeList maOldSelection;
bool mbOpened;
};
diff --git a/sc/source/ui/vba/vbafiledialog.cxx b/sc/source/ui/vba/vbafiledialog.cxx
index 04b27a8d4..c0d576366 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 d8ebc937b..547841a2c 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 1d3785178..48eb5e487 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 a38c7f3c8..a19e8de32 100644
--- a/sc/source/ui/vba/vbaformat.cxx
+++ b/sc/source/ui/vba/vbaformat.cxx
@@ -59,7 +59,7 @@ using namespace ::com::sun::star;
#define LOCALE "Locale"
template< typename Ifc1 >
-ScVbaFormat< Ifc1 >::ScVbaFormat( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, const uno::Reference< frame::XModel >& xModel, bool bCheckAmbiguoity ) throw ( script::BasicErrorException ) : ScVbaFormat_BASE( xParent, xContext ), m_aDefaultLocale( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("en") ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "US") ), rtl::OUString() ), mxPropertySet( _xPropertySet ), mxModel( xModel ), mbCheckAmbiguoity( bCheckAmbiguoity ), mbAddIndent( sal_False )
+ScVbaFormat< Ifc1 >::ScVbaFormat( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, const uno::Reference< frame::XModel >& xModel, bool bCheckAmbiguoity ) throw ( script::BasicErrorException ) : ScVbaFormat_BASE( xParent, xContext ), m_aDefaultLocale( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("en") ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "US") ), rtl::OUString() ), mxPropertySet( _xPropertySet ), mxModel( xModel ), mbCheckAmbiguoity( bCheckAmbiguoity ), mbAddIndent( false )
{
try
{
@@ -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 ce7ecfd52..dcd835763 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 9d3af947e..efbddd345 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 de2eca9b9..7546ebeb0 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 4499a1183..3897d9b78 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 8379ebafc..1e104e7ff 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 813a5954d..3369b726d 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 )
@@ -70,7 +70,7 @@ void ScVbaPageBreak<Ifc1>::setType(sal_Int32 type) throw (uno::RuntimeException)
if( type == excel::XlPageBreak::xlPageBreakNone )
{
- mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_False));
+ mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(false));
return;
}
@@ -78,13 +78,13 @@ 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 >
void ScVbaPageBreak<Ifc1>::Delete() throw ( script::BasicErrorException, uno::RuntimeException)
{
- mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_False));
+ mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(false));
}
template< typename Ifc1 >
diff --git a/sc/source/ui/vba/vbapagebreaks.cxx b/sc/source/ui/vba/vbapagebreaks.cxx
index d8a574d58..18d785924 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 f03ee70b9..f01e06a64 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 305c14262..159c7b75a 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 3dd34ca78..e13dc7358 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"
@@ -192,6 +197,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 +207,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 +287,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 +514,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,7 +537,7 @@ public:
return nType;
}
- bool setNumberFormat( const rtl::OUString& rFormat )
+ bool setNumberFormat( const rtl::OUString& rFormat )
{
lang::Locale aLocale;
uno::Reference< beans::XPropertySet > xNumProps = getNumberProps();
@@ -517,7 +545,12 @@ public:
sal_Int32 nNewIndex = mxFormats->queryKey(rFormat, aLocale, false );
if ( nNewIndex == -1 ) // format not defined
{
- 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 +714,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 +732,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 +811,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 +1127,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 +1135,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 )
{
@@ -1149,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;
@@ -1252,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)
@@ -1399,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 );
@@ -1533,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
@@ -1591,6 +1642,7 @@ ScVbaRange::setValue( const uno::Any &aValue, ValueSetter& valueSetter ) thro
{
visitArray( valueSetter );
}
+ if( bFireEvent ) fireChangeEvent();
}
void SAL_CALL
@@ -1611,7 +1663,7 @@ ScVbaRange::setValue( const uno::Any &aValue ) throw (uno::RuntimeException)
lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
}
-void
+void SAL_CALL
ScVbaRange::Clear() throw (uno::RuntimeException)
{
using namespace ::com::sun::star::sheet::CellFlags;
@@ -1624,7 +1676,7 @@ ScVbaRange::Clear() throw (uno::RuntimeException)
//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
@@ -1640,20 +1692,24 @@ ScVbaRange::ClearContents( sal_Int32 nFlags ) throw (uno::RuntimeException)
if ( pRange )
pRange->ClearContents( nFlags );
}
+ // 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 |
@@ -1665,7 +1721,7 @@ ScVbaRange::ClearContents() throw (uno::RuntimeException)
lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
}
-void
+void SAL_CALL
ScVbaRange::ClearFormats() throw (uno::RuntimeException)
{
//FIXME: need to check if we need to combine sheet::CellFlags::FORMATTED
@@ -1677,7 +1733,7 @@ ScVbaRange::ClearFormats() throw (uno::RuntimeException)
}
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 )
@@ -1727,7 +1783,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
@@ -1821,7 +1877,7 @@ ScVbaRange::HasFormula() throw (uno::RuntimeException)
ScCellRangesBase* pFormulaRanges = dynamic_cast< ScCellRangesBase * > ( xRanges.get() );
// check if there are no formula cell, return false
if ( pFormulaRanges->GetRangeList().empty() )
- return uno::makeAny(sal_False);
+ return uno::makeAny(false);
// chech if there are holes (where some cells are not formulas)
// or returned range is not equal to this range
@@ -2069,7 +2125,7 @@ ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolut
// force external to be false
// only first address should have the
// document and sheet specifications
- aExternalCopy = uno::makeAny(sal_False);
+ aExternalCopy = uno::makeAny(false);
}
sAddress += xRange->Address( RowAbsolute, ColumnAbsolute, ReferenceStyle, aExternalCopy, RelativeTo );
}
@@ -2084,7 +2140,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();
@@ -2092,8 +2148,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() )
@@ -2110,7 +2166,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;
@@ -2165,6 +2221,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();
@@ -2185,7 +2253,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
{
@@ -2205,7 +2273,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( mxRange ), dDetails );
if ( ( flags & 0x200 ) != 0x200 )
throw uno::RuntimeException();
nColumn = tmpRange.aStart.Col() + 1;
@@ -2238,12 +2306,12 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr
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 )
@@ -2305,7 +2373,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 );
}
}
@@ -2682,7 +2750,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();
@@ -2822,10 +2890,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;
@@ -2853,10 +2921,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:
@@ -2889,8 +2957,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;
@@ -2901,8 +2969,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);
}
@@ -3072,7 +3140,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() )
{
@@ -3086,9 +3154,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
@@ -3102,9 +3170,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
@@ -3222,9 +3290,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
@@ -3237,9 +3305,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
@@ -3255,9 +3323,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
@@ -3268,7 +3336,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
@@ -3375,7 +3443,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 >() );
@@ -3391,7 +3459,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();
@@ -3436,13 +3504,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;
@@ -3450,7 +3518,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() )
{
@@ -3498,26 +3566,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;
@@ -3696,7 +3764,7 @@ ScVbaRange::hasElements() throw (uno::RuntimeException)
if ( xColumnRowRange->getRows()->getCount() ||
xColumnRowRange->getColumns()->getCount() )
return sal_True;
- return sal_False;
+ return false;
}
// XEnumerationAccess
@@ -3740,7 +3808,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;
@@ -3750,7 +3818,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;
@@ -3779,7 +3847,7 @@ 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 );
}
uno::Any SAL_CALL
@@ -3797,24 +3865,24 @@ ScVbaRange::getColumnWidth() throw (uno::RuntimeException)
if ( pShell )
{
uno::Reference< frame::XModel > xModel = pShell->GetModel();
- double defaultCharWidth = getDefaultCharWidth( xModel );
+ double defaultCharWidth = getDefaultCharWidth( pShell );
RangeHelper thisRange( mxRange );
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 );
@@ -3846,17 +3914,16 @@ ScVbaRange::setColumnWidth( const uno::Any& _columnwidth ) throw (uno::RuntimeEx
nColWidth = ( nColWidth * getDefaultCharWidth( xModel ) );
RangeHelper thisRange( mxRange );
table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
- USHORT nTwips = lcl_pointsToTwips( nColWidth );
+ sal_uInt16 nTwips = lcl_pointsToTwips( nColWidth );
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 );
+ aFunc.SetWidthOrHeight( true, 1, nColArr, thisAddress.Sheet, SC_SIZE_ORIGINAL,
+ nTwips, true, true );
}
- }
}
uno::Any SAL_CALL
@@ -3946,7 +4013,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 );
@@ -3969,7 +4036,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
@@ -3980,7 +4047,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 )
@@ -4009,15 +4076,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
@@ -4029,10 +4096,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() )
@@ -4069,10 +4136,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();
@@ -4080,9 +4147,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);
}
}
}
@@ -4257,7 +4324,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];
}
@@ -4273,7 +4340,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 );
}
}
}
@@ -4413,7 +4480,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() )
@@ -4446,6 +4513,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 );
@@ -4467,10 +4548,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 ) );
}
@@ -4483,12 +4564,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 );
@@ -4608,7 +4689,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
@@ -4661,8 +4742,6 @@ 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)
{
- 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
@@ -4697,7 +4776,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 ) );
@@ -4735,15 +4818,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 );
}
}
@@ -4795,7 +4878,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 ) )
@@ -4804,7 +4887,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 ) )
@@ -4813,7 +4896,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 ) )
@@ -4821,7 +4904,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 ) )
@@ -4829,7 +4912,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 ) )
@@ -4837,7 +4920,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 )
{
@@ -4888,15 +4971,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++ )
{
@@ -4907,7 +4990,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& )
@@ -5107,7 +5190,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();
@@ -5120,7 +5203,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();
@@ -5239,7 +5322,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())
{
@@ -5478,7 +5561,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
@@ -5504,10 +5587,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;
}
@@ -5619,7 +5702,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 );
@@ -5629,7 +5712,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 ) );
}
}
}
@@ -5647,7 +5730,7 @@ ScVbaRange::UnMerge( ) throw (script::BasicErrorException, uno::RuntimeExceptio
}
return;
}
- lcl_mergeCellsOfRange( mxRange, sal_False);
+ lcl_mergeCellsOfRange( mxRange, false);
}
uno::Any SAL_CALL
@@ -5697,7 +5780,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 );
@@ -5907,9 +5990,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 );
@@ -6076,7 +6159,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
{
@@ -6171,7 +6254,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 );
@@ -6184,7 +6267,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 1b01329ac..bc2ba3dae 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 dc6c0e26a..d5f943e3a 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,38 @@ 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;
+ 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;
+ }
+ }
+ return nRet;
}
-void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 /*nPlacement*/ ) throw (uno::RuntimeException)
+void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 nPlacement ) throw (uno::RuntimeException)
{
- // TODO
+ 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);
+ }
+ }
}
sal_Bool SAL_CALL ScVbaSheetObjectBase::getPrintObject() throw (uno::RuntimeException)
@@ -351,14 +378,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 +405,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 5d15c2788..573d9fab5 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 819a299ad..af5763841 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 982ffa9d3..1b1a74062 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 361842c30..977c33475 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
@@ -130,7 +134,19 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >&
xLib->insertByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ) ) );
}
}
- }
+ }
+
+ /* 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,13 +260,13 @@ ScVbaWorkbooks::Add() throw (uno::RuntimeException)
return uno::Any();
}
-void
+void SAL_CALL
ScVbaWorkbooks::Close() throw (uno::RuntimeException)
{
- VbaDocumentsBase::Close();
+ closeDocuments();
}
-bool
+bool
ScVbaWorkbooks::isTextFile( const rtl::OUString& sType )
{
// will return true if the file is
@@ -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,13 +390,7 @@ 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&
+rtl::OUString&
ScVbaWorkbooks::getServiceImplName()
{
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWorkbooks") );
diff --git a/sc/source/ui/vba/vbaworkbooks.hxx b/sc/source/ui/vba/vbaworkbooks.hxx
index 6cd6d90fc..571ef6772 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 51a2292c2..7b889b460 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -52,6 +52,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 +63,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 +184,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 +195,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;
@@ -245,6 +247,25 @@ ScVbaWorksheet::getVisible() throw (uno::RuntimeException)
void
ScVbaWorksheet::setVisible( ::sal_Int32 _Visible ) throw (uno::RuntimeException)
{
+ using namespace ::ooo::vba::excel::XlSheetVisibility;
+ bool bVisible = true;
+ switch( nVisible )
+ {
+ case xlSheetVisible: case 1: // Excel accepts -1 and 1 for visible sheets
+ bVisible = true;
+ mbVeryHidden = false;
+ break;
+ case xlSheetHidden:
+ bVisible = false;
+ mbVeryHidden = false;
+ break;
+ case xlSheetVeryHidden:
+ bVisible = false;
+ mbVeryHidden = true;
+ break;
+ default:
+ throw uno::RuntimeException();
+ }
uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW );
sal_Bool bVisible = true;
@@ -279,8 +300,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 +339,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 +383,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 +457,7 @@ ScVbaWorksheet::getStandardHeight() throw (uno::RuntimeException)
sal_Bool
ScVbaWorksheet::getProtectionMode() throw (uno::RuntimeException)
{
- return sal_False;
+ return false;
}
sal_Bool
@@ -461,13 +482,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 +613,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 +750,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 +830,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 +993,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 +1024,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 +1112,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 d8fe20e4f..6ad6baf88 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 23e77a3c4..1bac9628c 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 b87ec852b..685377da4 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