diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-03-10 16:55:21 -0500 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-03-10 20:21:13 -0500 |
commit | 43721d32e078d738495451e0060883274475158c (patch) | |
tree | b339bf238c85e51ab2d991a506c806edfefb3b02 /sc/source/ui/vba/excelvbahelper.cxx | |
parent | 51bf6bf654860d564e3c5f82ab989b5912252996 (diff) | |
parent | 2851cc7baf8defb165e100f303b02e895a4e7fdf (diff) |
Merge commit 'ooo/DEV300_m101' into integration/dev300_m101
Diffstat (limited to 'sc/source/ui/vba/excelvbahelper.cxx')
-rw-r--r-- | sc/source/ui/vba/excelvbahelper.cxx | 82 |
1 files changed, 55 insertions, 27 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 |