summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2012-09-11 08:48:02 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-09-12 12:49:49 +0100
commit4597483e00bffcc4e30d379dcf6fad42bc565e56 (patch)
treeb590428b0e3ae3c7056e6c18f008d7179dc5ba38 /sc
parentc414499bbd456389ac6cacf677327bff9e6b43f9 (diff)
targetted VBA re-work.
Diffstat (limited to 'sc')
-rw-r--r--sc/Library_vbaobj.mk4
-rw-r--r--sc/inc/document.hxx6
-rw-r--r--sc/inc/scmod.hxx4
-rw-r--r--sc/inc/viewuno.hxx5
-rw-r--r--sc/source/core/data/document.cxx34
-rw-r--r--sc/source/ui/inc/asciiopt.hxx2
-rw-r--r--sc/source/ui/inc/impex.hxx2
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx2
-rw-r--r--sc/source/ui/unoobj/viewuno.cxx116
-rw-r--r--sc/source/ui/vba/excelvbahelper.cxx125
-rw-r--r--sc/source/ui/vba/excelvbahelper.hxx9
-rw-r--r--sc/source/ui/vba/vbaapplication.cxx559
-rw-r--r--sc/source/ui/vba/vbaapplication.hxx19
-rw-r--r--sc/source/ui/vba/vbacomment.cxx10
-rw-r--r--sc/source/ui/vba/vbadialog.cxx77
-rw-r--r--sc/source/ui/vba/vbadialog.hxx1
-rw-r--r--sc/source/ui/vba/vbadialogs.cxx9
-rw-r--r--sc/source/ui/vba/vbadialogs.hxx1
-rw-r--r--sc/source/ui/vba/vbafiledialog.cxx174
-rw-r--r--sc/source/ui/vba/vbafiledialog.hxx63
-rw-r--r--sc/source/ui/vba/vbafiledialogselecteditems.cxx156
-rw-r--r--sc/source/ui/vba/vbafiledialogselecteditems.hxx90
-rw-r--r--sc/source/ui/vba/vbafilesearch.cxx244
-rw-r--r--sc/source/ui/vba/vbafilesearch.hxx80
-rw-r--r--sc/source/ui/vba/vbaname.cxx87
-rw-r--r--sc/source/ui/vba/vbaname.hxx4
-rw-r--r--sc/source/ui/vba/vbanames.cxx85
-rw-r--r--sc/source/ui/vba/vbaoleobject.cxx2
-rw-r--r--sc/source/ui/vba/vbapagebreaks.cxx26
-rw-r--r--sc/source/ui/vba/vbapagesetup.cxx101
-rw-r--r--sc/source/ui/vba/vbapagesetup.hxx2
-rw-r--r--sc/source/ui/vba/vbapivotcache.cxx11
-rw-r--r--sc/source/ui/vba/vbapivotcache.hxx3
-rw-r--r--sc/source/ui/vba/vbaquerytable.cxx90
-rw-r--r--sc/source/ui/vba/vbaquerytable.hxx62
-rw-r--r--sc/source/ui/vba/vbarange.cxx1030
-rw-r--r--sc/source/ui/vba/vbarange.hxx16
-rw-r--r--sc/source/ui/vba/vbaworkbook.cxx63
-rw-r--r--sc/source/ui/vba/vbaworkbook.hxx3
-rw-r--r--sc/source/ui/vba/vbaworksheet.cxx69
-rw-r--r--sc/source/ui/vba/vbaworksheet.hxx6
-rw-r--r--sc/source/ui/view/viewfun3.cxx10
42 files changed, 332 insertions, 3130 deletions
diff --git a/sc/Library_vbaobj.mk b/sc/Library_vbaobj.mk
index e8a667a7bb39..fb7e1c34d98c 100644
--- a/sc/Library_vbaobj.mk
+++ b/sc/Library_vbaobj.mk
@@ -81,9 +81,6 @@ $(eval $(call gb_Library_add_exception_objects,vbaobj,\
sc/source/ui/vba/vbadialog \
sc/source/ui/vba/vbadialogs \
sc/source/ui/vba/vbaeventshelper \
- sc/source/ui/vba/vbafiledialog \
- sc/source/ui/vba/vbafiledialogselecteditems \
- sc/source/ui/vba/vbafilesearch \
sc/source/ui/vba/vbafont \
sc/source/ui/vba/vbaformat \
sc/source/ui/vba/vbaformatcondition \
@@ -112,7 +109,6 @@ $(eval $(call gb_Library_add_exception_objects,vbaobj,\
sc/source/ui/vba/vbapivotcache \
sc/source/ui/vba/vbapivottable \
sc/source/ui/vba/vbapivottables \
- sc/source/ui/vba/vbaquerytable \
sc/source/ui/vba/vbarange \
sc/source/ui/vba/vbasheetobject \
sc/source/ui/vba/vbastyle \
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index efe8814ea67c..b12ce261964f 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -564,7 +564,6 @@ public:
bool HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRow,
SCCOL nEndCol, SCROW nEndRow,
const ScMarkData& rMark ) const;
- bool HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTAB ) const;
bool GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix );
@@ -956,7 +955,7 @@ public:
SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab,
ScDirection eDir );
- SC_DLLPUBLIC void FindAreaPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, ScMoveDirection eDirection ) const;
+ void FindAreaPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, ScMoveDirection eDirection ) const;
SC_DLLPUBLIC void GetNextPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCsCOL nMovX, SCsROW nMovY,
bool bMarked, bool bUnprotected, const ScMarkData& rMark ) const;
@@ -1015,7 +1014,7 @@ public:
SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks );
SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, SCTAB nTab );
void SetCutMode( bool bCut );
- SC_DLLPUBLIC bool IsCutMode();
+ bool IsCutMode();
void SetClipArea( const ScRange& rArea, bool bCut = false );
SC_DLLPUBLIC bool IsDocVisible() const { return bIsVisible; }
@@ -1865,7 +1864,6 @@ private: // CLOOK-Impl-methods
const ScRange& r, SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
void CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks, bool bAllTabs);
- void CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, SCTAB nTab);
bool HasPartOfMerged( const ScRange& rRange );
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index bc0ebd9726da..521d8219412a 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -176,14 +176,14 @@ public:
// Options:
const ScViewOptions& GetViewOptions ();
-SC_DLLPUBLIC const ScDocOptions& GetDocOptions ();
+ const ScDocOptions& GetDocOptions ();
SC_DLLPUBLIC const ScAppOptions& GetAppOptions ();
SC_DLLPUBLIC const ScDefaultsOptions& GetDefaultsOptions ();
const ScFormulaOptions& GetFormulaOptions ();
const ScInputOptions& GetInputOptions ();
SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions ();
void SetViewOptions ( const ScViewOptions& rOpt );
-SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt );
+ void SetDocOptions ( const ScDocOptions& rOpt );
SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt );
void SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
void SetFormulaOptions ( const ScFormulaOptions& rOpt );
diff --git a/sc/inc/viewuno.hxx b/sc/inc/viewuno.hxx
index 2aeb6f51d072..135b54016597 100644
--- a/sc/inc/viewuno.hxx
+++ b/sc/inc/viewuno.hxx
@@ -317,11 +317,6 @@ public:
::com::sun::star::sheet::XSpreadsheet >& xActiveSheet )
throw(::com::sun::star::uno::RuntimeException);
- // support expand (but not replace) the active sheet
- virtual void SAL_CALL selectSheet( const ::com::sun::star::uno::Reference<
- ::com::sun::star::sheet::XSpreadsheet >& xActiveSheet,
- sal_Bool bExpand)
- throw(::com::sun::star::uno::RuntimeException);
//XEnhancedMouseClickBroadcaster
virtual void SAL_CALL addEnhancedMouseClickHandler( const ::com::sun::star::uno::Reference<
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index d660686dbaab..ade6c8e9b051 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1926,9 +1926,9 @@ void ScDocument::CopyToClip(const ScClipParam& rClipParam,
else
pClipDoc->ResetClip(this, pMarks);
- if ( bUseRangeForVBA )
- CopyRangeNamesToClip(pClipDoc, aClipRange, nTab );
- else
+// if ( bUseRangeForVBA )
+// CopyRangeNamesToClip(pClipDoc, aClipRange, nTab );
+// else
CopyRangeNamesToClip(pClipDoc, aClipRange, pMarks, bAllTabs);
for ( ; i < nEndTab; ++i)
@@ -2114,24 +2114,6 @@ void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClip
copyUsedNamesToClip(pClipDoc->GetRangeName(), pRangeName, aUsedNames);
}
-void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, SCTAB nTab)
-{
- if (!pRangeName || pRangeName->empty())
- return;
-
- // Indexes of named ranges that are used in the copied cells
- std::set<sal_uInt16> aUsedNames;
- if ( nTab < static_cast<SCTAB>(maTabs.size()) && nTab < static_cast<SCTAB>(pClipDoc->maTabs.size()) )
- if ( maTabs[nTab] && pClipDoc->maTabs[nTab] )
- {
- maTabs[nTab]->FindRangeNamesInUse(
- rClipRange.aStart.Col(), rClipRange.aStart.Row(),
- rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames );
- }
-
- copyUsedNamesToClip(pClipDoc->GetRangeName(), pRangeName, aUsedNames);
-}
-
ScDocument::NumFmtMergeHandler::NumFmtMergeHandler(ScDocument* pDoc, ScDocument* pSrcDoc) :
mpDoc(pDoc)
{
@@ -4817,16 +4799,6 @@ bool ScDocument::HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRo
return !bOk;
}
-bool ScDocument::HasSelectedBlockMatrixFragment( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab ) const
-{
- bool bOk = true;
- if ( nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] && maTabs[nTab]->HasBlockMatrixFragment( nStartCol, nStartRow, nEndCol, nEndRow ) )
- {
- bOk = false;
- }
- return !bOk;
-}
-
bool ScDocument::GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix )
{
// if rCell is part of a matrix formula, return its complete range
diff --git a/sc/source/ui/inc/asciiopt.hxx b/sc/source/ui/inc/asciiopt.hxx
index 45107c19ad22..868533035ea6 100644
--- a/sc/source/ui/inc/asciiopt.hxx
+++ b/sc/source/ui/inc/asciiopt.hxx
@@ -45,7 +45,7 @@
// ============================================================================
-class SC_DLLPUBLIC ScAsciiOptions
+class ScAsciiOptions
{
private:
sal_Bool bFixedLen;
diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx
index 6bad36293396..84a52229a1b7 100644
--- a/sc/source/ui/inc/impex.hxx
+++ b/sc/source/ui/inc/impex.hxx
@@ -54,7 +54,7 @@ struct ScExportTextOptions
bool mbAddQuotes;
};
-class SC_DLLPUBLIC ScImportExport
+class ScImportExport
{
ScDocShell* pDocSh;
ScDocument* pDoc;
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 36bdab18c955..10b2b9c1b293 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -295,7 +295,7 @@ public:
void GetSaveState( SfxItemSet& rSet );
void ExecSearch( SfxRequest& rReq );
- SC_DLLPUBLIC void ExecuteUndo(SfxRequest& rReq);
+ void ExecuteUndo(SfxRequest& rReq);
void GetUndoState(SfxItemSet &rSet);
void ExecuteSbx( SfxRequest& rReq );
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index 4d7a92786802..4ecc009653a8 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -461,91 +461,6 @@ void SAL_CALL ScViewPaneObj::release() throw()
OWeakObject::release();
}
-// To process sheet compatibile event
-typedef ::cppu::WeakImplHelper2< awt::XEnhancedMouseClickHandler, view::XSelectionChangeListener > TabViewEventListener_BASE;
-class ScTabViewEventListener: public TabViewEventListener_BASE
-{
-private:
- ScTabViewObj* pViewObj;
- uno::Reference< script::vba::XVBAEventProcessor > xVbaEventsHelper;
- sal_Bool bDelaySelectionEvent;
- sal_Bool bSelectionChangeOccurred;
-
- void fireSelectionChangeEvent();
-
-public:
- ScTabViewEventListener( ScTabViewObj* pObj, uno::Reference< script::vba::XVBAEventProcessor >& rVbaEventsHelper);
- ~ScTabViewEventListener();
- // XEnhancedMouseClickHandler
- virtual sal_Bool SAL_CALL mousePressed( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException);
- virtual sal_Bool SAL_CALL mouseReleased( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException);
-
- // XSelectionChangeListener
- virtual void SAL_CALL selectionChanged( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
- // XEventListener
- virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
-};
-
-ScTabViewEventListener::ScTabViewEventListener(ScTabViewObj* pObj, uno::Reference< script::vba::XVBAEventProcessor >& rVbaEventsHelper):
- pViewObj( pObj ),xVbaEventsHelper( rVbaEventsHelper ), bDelaySelectionEvent( false ), bSelectionChangeOccurred( false )
-{
-}
-
-ScTabViewEventListener::~ScTabViewEventListener()
-{
-}
-
-void SAL_CALL ScTabViewEventListener::disposing( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
-{
-}
-
-void ScTabViewEventListener::fireSelectionChangeEvent()
-{
- if ( xVbaEventsHelper.is() && pViewObj )
- {
- uno::Sequence< uno::Any > aArgs(1);
- aArgs[0] = pViewObj->getSelection();
- try
- {
- xVbaEventsHelper->processVbaEvent( script::vba::VBAEventId::WORKSHEET_SELECTIONCHANGE, aArgs );
- }
- catch( uno::Exception& )
- {
- }
- }
- bDelaySelectionEvent = false;
- bSelectionChangeOccurred = false;
-}
-
-sal_Bool SAL_CALL ScTabViewEventListener::mousePressed( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException)
-{
- // Delay to fire the selection change event if clicking the left mouse button to do selection.
- bDelaySelectionEvent = ( e.Buttons == ::com::sun::star::awt::MouseButton::RIGHT ) ? false : sal_True;
- bSelectionChangeOccurred = false;
-
- // ScTabViewObj::MousePressed should handle process BeforeDoubleClick and BeforeRightClick events
- return sal_True;
-}
-
-sal_Bool SAL_CALL ScTabViewEventListener::mouseReleased( const awt::EnhancedMouseEvent&/*e*/) throw (uno::RuntimeException)
-{
- if ( bSelectionChangeOccurred )
- fireSelectionChangeEvent();
- return sal_True;
-}
-
-void SAL_CALL ScTabViewEventListener::selectionChanged( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
-{
- if ( !bDelaySelectionEvent )
- {
- fireSelectionChangeEvent();
- }
- else
- {
- bSelectionChangeOccurred = sal_True;
- }
-}
-
//------------------------------------------------------------------------
// Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht
@@ -559,24 +474,8 @@ ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) :
nPreviousTab( 0 ),
bDrawSelModeSet(false)
{
- if (!pViewSh)
- return;
-
- nPreviousTab = pViewSh->GetViewData()->GetTabNo();
- ScViewData* pViewData = pViewSh->GetViewData();
- if (!pViewData)
- return;
-
- uno::Reference< script::vba::XVBAEventProcessor > xVbaEventsHelper(
- pViewData->GetDocument()->GetVbaEventProcessor(), uno::UNO_QUERY );
- if (!xVbaEventsHelper.is())
- return;
-
- ScTabViewEventListener* pEventListener = new ScTabViewEventListener( this, xVbaEventsHelper );
- uno::Reference< awt::XEnhancedMouseClickHandler > aMouseClickHandler( *pEventListener, uno::UNO_QUERY );
- addEnhancedMouseClickHandler( aMouseClickHandler );
- uno::Reference< view::XSelectionChangeListener > aSelectionChangeListener( *pEventListener, uno::UNO_QUERY );
- addSelectionChangeListener( aSelectionChangeListener );
+ if (pViewSh)
+ nPreviousTab = pViewSh->GetViewData()->GetTabNo();
}
ScTabViewObj::~ScTabViewObj()
@@ -1208,16 +1107,7 @@ uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTabViewObj::getActiveSheet()
void SAL_CALL ScTabViewObj::setActiveSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveSheet )
throw(uno::RuntimeException)
{
- selectSheet(xActiveSheet, false);
-}
-
-void SAL_CALL
-ScTabViewObj::selectSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveSheet,
- sal_Bool bExpand)
- throw(uno::RuntimeException)
-{
SolarMutexGuard aGuard;
- sal_Bool bNew = bExpand;
ScTabViewShell* pViewSh = GetViewShell();
if ( pViewSh && xActiveSheet.is() )
@@ -1232,7 +1122,7 @@ ScTabViewObj::selectSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveShe
{
SCTAB nNewTab = rRanges[ 0 ]->aStart.Tab();
if ( pViewSh->GetViewData()->GetDocument()->HasTable(nNewTab) )
- pViewSh->SetTabNo( nNewTab, bNew, bExpand );
+ pViewSh->SetTabNo( nNewTab );
}
}
}
diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx
index 90848f49a858..2da0df5c1a32 100644
--- a/sc/source/ui/vba/excelvbahelper.cxx
+++ b/sc/source/ui/vba/excelvbahelper.cxx
@@ -35,9 +35,6 @@
#include "transobj.hxx"
#include "scmod.hxx"
#include "cellsuno.hxx"
-#include "compiler.hxx"
-#include "token.hxx"
-#include "tokenarray.hxx"
#include <com/sun/star/script/vba/VBAEventId.hpp>
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
@@ -122,16 +119,6 @@ ScDocument* GetDocumentFromRange( const uno::Reference< uno::XInterface >& xRang
return pDocShell->GetDocument();
}
-uno::Reference< frame::XModel > GetModelFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException )
-{
- ScDocShell* pDocShell = GetDocShellFromRange( xRange );
- if ( !pDocShell )
- {
- throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access underlying model uno range object" ) ), uno::Reference< uno::XInterface >() );
- }
- return pDocShell->GetModel();
-}
-
void implSetZoom( const uno::Reference< frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs )
{
ScTabViewShell* pViewSh = excel::getBestViewShell( xModel );
@@ -262,24 +249,6 @@ void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, sal_uInt16
}
-bool implnCopyRanges( const uno::Reference< frame::XModel>& xModel, ScRangeList& rRangeList )
-{
- bool bResult = false;
- ScTabViewShell* pViewShell = getBestViewShell( xModel );
- if ( pViewShell )
- {
- bResult = pViewShell->CopyToClip( NULL, rRangeList, false, true, true );
- }
- return bResult;
-}
-
-bool implnCopyRange( const uno::Reference< frame::XModel>& xModel, const ScRange& rRange )
-{
- ScRangeList aRanges;
- aRanges.Append( rRange );
- return implnCopyRanges( xModel, aRanges );
-}
-
ScDocShell*
getDocShell( const css::uno::Reference< css::frame::XModel>& xModel )
{
@@ -308,17 +277,13 @@ getCurrentBestViewShell( const uno::Reference< uno::XComponentContext >& xConte
return getBestViewShell( xModel );
}
-sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const rtl::OUString& sRangeStr )
+SfxViewFrame*
+getViewFrame( const uno::Reference< frame::XModel >& xModel )
{
- ScRangeList aCellRanges;
- String sAddress( sRangeStr );
- 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 false;
+ ScTabViewShell* pViewShell = getBestViewShell( xModel );
+ if ( pViewShell )
+ return pViewShell->GetViewFrame();
+ return NULL;
}
uno::Reference< vba::XHelperInterface >
@@ -336,84 +301,6 @@ getUnoSheetModuleObj( const uno::Reference< sheet::XSpreadsheet >& xSheet ) thro
return xParent;
}
-formula::FormulaGrammar::Grammar GetFormulaGrammar( ScDocument* pDoc, const ScAddress& sAddress, const css::uno::Any& aFormula )
-{
- formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_NATIVE_XL_A1;
- if ( pDoc && aFormula.hasValue() && aFormula.getValueTypeClass() == uno::TypeClass_STRING )
- {
- rtl::OUString sFormula;
- aFormula >>= sFormula;
-
- ScCompiler aCompiler( pDoc, sAddress );
- aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
- ScTokenArray* pCode = aCompiler.CompileString( sFormula );
- if ( pCode )
- {
- sal_uInt16 nLen = pCode->GetLen();
- formula::FormulaToken** pTokens = pCode->GetArray();
- for ( sal_uInt16 nPos = 0; nPos < nLen; nPos++ )
- {
- const formula::FormulaToken& rToken = *pTokens[nPos];
- switch ( rToken.GetType() )
- {
- case formula::svSingleRef:
- case formula::svDoubleRef:
- {
- return formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
- }
- break;
- default: break;
- }
- }
- }
- }
- return eGrammar;
-}
-
-void CompileExcelFormulaToODF( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula )
-{
- if ( !pDoc )
- {
- return;
- }
- ScCompiler aCompiler( pDoc, ScAddress() );
- aCompiler.SetGrammar( excel::GetFormulaGrammar( pDoc, ScAddress(), uno::Any( rtl::OUString( rOldFormula ) ) ) );
- aCompiler.CompileString( rOldFormula );
- aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_PODF_A1 );
- aCompiler.CreateStringFromTokenArray( rNewFormula );
-}
-
-void CompileODFFormulaToExcel( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula, const formula::FormulaGrammar::Grammar eGrammar )
-{
- // eGrammar can be formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 and formula::FormulaGrammar::GRAM_NATIVE_XL_A1
- if ( !pDoc )
- {
- return;
- }
- ScCompiler aCompiler( pDoc, ScAddress() );
- aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_PODF_A1 );
- ScTokenArray* pCode = aCompiler.CompileString( rOldFormula );
- aCompiler.SetGrammar( eGrammar );
- if ( !pCode )
- {
- return;
- }
- sal_uInt16 nLen = pCode->GetLen();
- formula::FormulaToken** pTokens = pCode->GetArray();
- for ( sal_uInt16 nPos = 0; nPos < nLen && pTokens[nPos]; nPos++ )
- {
- String rFormula;
- formula::FormulaToken* pToken = pTokens[nPos];
- aCompiler.CreateStringFromToken( rFormula, pToken, true );
- if ( pToken->GetOpCode() == ocSep )
- {
- // Excel formula separator is ",".
- rFormula = rtl::OUString(",");
- }
- rNewFormula += rFormula;
- }
-}
-
uno::Reference< XHelperInterface >
getUnoSheetModuleObj( const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges ) throw ( uno::RuntimeException )
{
diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx
index 53f44c997f13..2009cc39a128 100644
--- a/sc/source/ui/vba/excelvbahelper.hxx
+++ b/sc/source/ui/vba/excelvbahelper.hxx
@@ -38,7 +38,6 @@
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <ooo/vba/XHelperInterface.hpp>
-#include <formula/grammar.hxx>
class ScCellRangesBase;
@@ -54,16 +53,11 @@ 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);
-bool implnCopyRanges( const css::uno::Reference< css::frame::XModel>& xModel, ScRangeList& rRange );
-bool implnCopyRange( const css::uno::Reference< css::frame::XModel>& xModel, const ScRange& rRange );
ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel );
-sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const ::rtl::OUString& sRangeStr );
-formula::FormulaGrammar::Grammar GetFormulaGrammar( ScDocument* pDoc, const ScAddress& sAddress, const css::uno::Any& aFormula );
-void CompileExcelFormulaToODF( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula );
-void CompileODFFormulaToExcel( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula, const formula::FormulaGrammar::Grammar eGrammar );
css::uno::Reference< css::sheet::XUnnamedDatabaseRanges > GetUnnamedDataBaseRanges( ScDocShell* pShell ) throw ( css::uno::RuntimeException );
css::uno::Reference< css::sheet::XDatabaseRange > GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet ) throw ( css::uno::RuntimeException );
@@ -76,7 +70,6 @@ css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const cs
ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
ScDocShell* GetDocShellFromRanges( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException );
ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
-css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
void setUpDocumentModules( const css::uno::Reference< css::sheet::XSpreadsheetDocument >& xDoc );
// ============================================================================
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index d962395b6dd2..b7b53f956392 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -28,14 +28,11 @@
#include <stdio.h>
-#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
-#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
#include <com/sun/star/sheet/XSpreadsheetView.hpp>
#include <com/sun/star/sheet/XSpreadsheets.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <ooo/vba/excel/XlCalculation.hpp>
-#include <ooo/vba/excel/XlCutCopyMode.hpp>
#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
#include <com/sun/star/sheet/XCalculatable.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
@@ -44,17 +41,10 @@
#include <ooo/vba/excel/XlMousePointer.hpp>
#include <com/sun/star/sheet/XNamedRanges.hpp>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
-#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
+#include <ooo/vba/XExecutableDialog.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
-#include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
-#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
-#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
-#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include<ooo/vba/XCommandBars.hpp>
-#include <ooo/vba/excel/XlEnableCancelKey.hpp>
-#include <ooo/vba/excel/XlApplicationInternational.hpp>
-#include <unotools/localedatawrapper.hxx>
#include "vbaapplication.hxx"
#include "vbaworkbooks.hxx"
@@ -73,19 +63,13 @@
#include <vbahelper/vbashape.hxx>
#include "vbatextboxshape.hxx"
#include "vbaassistant.hxx"
-#include "vbafilesearch.hxx" // add the support of VBA Application.FileSearch
#include "sc.hrc"
#include "macromgr.hxx"
-#include "global.hxx"
-#include "scmod.hxx"
-#include "docoptio.hxx"
#include "defaultsoptions.hxx"
#include <osl/file.hxx>
#include <rtl/instance.hxx>
-#include <map>
-
#include <sfx2/request.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/viewfrm.hxx>
@@ -106,7 +90,6 @@
#include <basic/sbuno.hxx>
#include <basic/sbmeth.hxx>
-#include "transobj.hxx"
#include "convuno.hxx"
#include "cellsuno.hxx"
#include "miscuno.hxx"
@@ -118,7 +101,6 @@
#include <basic/sbmod.hxx>
#include <basic/sbxobj.hxx>
-#include "vbafiledialog.hxx"
#include "viewutil.hxx"
using namespace ::ooo::vba;
@@ -306,18 +288,6 @@ ScVbaApplication::getAssistant() throw (uno::RuntimeException)
return uno::Reference< XAssistant >( new ScVbaAssistant( this, mxContext ) );
}
-// add support of VBA Application.FileSearch
-uno::Reference< XFileSearch > SAL_CALL
-ScVbaApplication::getFileSearch() throw (uno::RuntimeException)
-{
- if (! m_xFileSearch.get() )
- {
- m_xFileSearch = uno::Reference< XFileSearch >( new ScVbaFileSearch( this, uno::Reference< XHelperInterface >( this ), mxContext ) );
- }
-
- return m_xFileSearch;
-}
-
uno::Any SAL_CALL
ScVbaApplication::getSelection() throw (uno::RuntimeException)
{
@@ -469,67 +439,16 @@ ScVbaApplication::getActiveWindow() throw (uno::RuntimeException)
uno::Any SAL_CALL
ScVbaApplication::getCutCopyMode() throw (uno::RuntimeException)
{
+ //# FIXME TODO, implementation
uno::Any result;
- ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( NULL );
- ScDocument* pDoc = pOwnClip ? pOwnClip->GetDocument() : NULL;
- if ( pDoc )
- {
- if ( pDoc->IsCutMode() )
- {
- result <<= excel::XlCutCopyMode::xlCut;
- }
- else
- {
- result <<= excel::XlCutCopyMode::xlCopy;
- }
- }
- else
- {
- result <<= false;
- }
+ result <<= sal_False;
return result;
}
void SAL_CALL
-ScVbaApplication::setCutCopyMode( const uno::Any& _cutcopymode ) throw (uno::RuntimeException)
+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 = false;
- if ( ( _cutcopymode >>= bCutCopyMode ) )
- {
- ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( NULL );
- if ( pOwnClip )
- {
- pOwnClip->ObjectReleased();
- ScTabViewShell* pTabViewShell = excel::getBestViewShell( getCurrentDocument() );
- if ( pTabViewShell )
- {
- ScViewData* pView = pTabViewShell->GetViewData();
- Window* pWindow = pView ? pView->GetActiveWin() : NULL;
- if ( pWindow )
- {
- Reference< datatransfer::clipboard::XClipboard > xClipboard = pWindow->GetClipboard();
- Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
- if ( xClipboard.is() )
- {
- xClipboard->setContents( NULL, NULL );
- if ( xFlushableClipboard.is() )
- {
- const sal_uInt32 nRef = Application::ReleaseSolarMutex();
- try
- {
- xFlushableClipboard->flushClipboard();
- }
- catch (const uno::Exception&)
- {
- }
- Application::AcquireSolarMutex( nRef );
- }
- }
- }
- }
- }
- }
+ //# FIXME TODO, implementation
}
uno::Any SAL_CALL
@@ -956,90 +875,6 @@ ScVbaApplication::setShowWindowsInTaskbar( sal_Bool bSet ) throw (css::uno::Runt
mrAppSettings.mbShowWindowsInTaskbar = bSet;
}
-sal_Bool SAL_CALL
-ScVbaApplication::getVisible() throw (uno::RuntimeException)
-{
- sal_Bool bVisible = sal_True;
- return bVisible;
-}
-
-void SAL_CALL
-ScVbaApplication::setVisible(sal_Bool /*bVisible*/) throw (uno::RuntimeException)
-{
-}
-
-//add the support of Excel VBA Application.Iteration
-//The Excel Iteration option is global and unique, but in Symphony there is an Iteration property in ScModule and one in every ScDocument,
-//so the set method will set all the Iteration properties
-sal_Bool SAL_CALL
-ScVbaApplication::getIteration() throw (uno::RuntimeException)
-{
- ScModule* pScMod = SC_MOD();
- ScDocOptions aDocOpt = pScMod->GetDocOptions();
-
- return aDocOpt.IsIter();
-}
-
-void SAL_CALL
-ScVbaApplication::setIteration(sal_Bool bIteration) throw (uno::RuntimeException)
-{
- ScModule* pScMod = SC_MOD();
- ScDocOptions& aDocOpt = const_cast< ScDocOptions& > (pScMod->GetDocOptions());
- aDocOpt.SetIter( bIteration );
-
- uno::Any aIteration;
- aIteration <<= bIteration;
-
- OUString aPropName(RTL_CONSTASCII_USTRINGPARAM( "IsIterationEnabled" ));
-
- uno::Reference< XCollection > xWorkbooks( new ScVbaWorkbooks( this, mxContext ) );
- sal_Int32 nCount = xWorkbooks->getCount();
-
- for (sal_Int32 i = 1; i <= nCount; i++)
- {
- uno::Reference< ooo::vba::excel::XWorkbook > xWorkbook;
- uno::Any aWorkbook = xWorkbooks->Item(uno::makeAny(i), uno::Any());
- aWorkbook >>= xWorkbook;
- ScVbaWorkbook* pWorkbook = excel::getImplFromDocModuleWrapper<ScVbaWorkbook>( xWorkbook );
- uno::Reference< frame::XModel > xModel( pWorkbook->getDocModel(), uno::UNO_QUERY_THROW );
- uno::Reference< beans::XPropertySet > xPropertySet( xModel, uno::UNO_QUERY_THROW );
- xPropertySet->setPropertyValue( aPropName, aIteration );
- }
-}
-
-//add the support of Excel VBA Application.EnableCancelKey
-sal_Int32 SAL_CALL
-ScVbaApplication::getEnableCancelKey() throw (uno::RuntimeException)
-{
- return ooo::vba::excel::XlEnableCancelKey::xlDisabled;
-}
-
-void SAL_CALL
-ScVbaApplication::setEnableCancelKey(sal_Int32 /*lEnableCancelKey*/) throw (uno::RuntimeException)
-{
-}
-
-sal_Int32 SAL_CALL ScVbaApplication::getSheetsInNewWorkbook() throw (uno::RuntimeException)
-{
- const ScDefaultsOptions& rOpt = SC_MOD()->GetDefaultsOptions();
- return rOpt.GetInitTabCount();
-}
-
-void SAL_CALL ScVbaApplication::setSheetsInNewWorkbook( sal_Int32 SheetsInNewWorkbook ) throw (script::BasicErrorException, uno::RuntimeException)
-{
- if ( SheetsInNewWorkbook < MININITTAB
- || SheetsInNewWorkbook > MAXINITTAB )
- {
- DebugHelper::exception( OUString(RTL_CONSTASCII_USTRINGPARAM("The number must be between 1 and 1024")),
- uno::Exception(), SbERR_METHOD_FAILED, OUString() );
- }
- else
- {
- ScDefaultsOptions& rOpt = const_cast< ScDefaultsOptions& >(SC_MOD()->GetDefaultsOptions());
- rOpt.SetInitTabCount( SheetsInNewWorkbook );
- }
-}
-
void SAL_CALL
ScVbaApplication::Calculate() throw( script::BasicErrorException , uno::RuntimeException )
{
@@ -1467,310 +1302,6 @@ ScVbaApplication::Caller( const uno::Any& /*aIndex*/ ) throw ( uno::RuntimeExcep
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( false );
- try
- {
- const rtl::OUString sServiceName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ));
- uno::Reference< lang::XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
- // Set the type of File Picker Dialog: TemplateDescription::FILEOPEN_SIMPLE.
- uno::Sequence< uno::Any > aDialogType( 1 );
- aDialogType[0] <<= ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
- uno::Reference< ui::dialogs::XFilePicker > xFilePicker( xMSF->createInstanceWithArguments( sServiceName, aDialogType ), UNO_QUERY );
- uno::Reference< ui::dialogs::XFilePicker2 > xFilePicker2( xFilePicker, UNO_QUERY );
- uno::Reference< ui::dialogs::XFilterManager > xFilterManager( xFilePicker, UNO_QUERY );
- uno::Reference< ui::dialogs::XExecutableDialog > xExecutableDialog( xFilePicker, UNO_QUERY );
- uno::Reference< ui::dialogs::XFilePickerControlAccess > xPickerControlAccess( xFilePicker, UNO_QUERY );
-
- if ( xFilterManager.is() && FileFilter.hasValue() )
- {
- sal_Int32 nFilterIndex = 1;
- if ( FilterIndex.hasValue() )
- {
- FilterIndex >>= nFilterIndex;
- }
- ::rtl::OUString strFilter;
- FileFilter >>= strFilter;
- sal_Int32 nCommaID = 0;
- sal_Int32 nIndex = 1;
- do
- {
- ::rtl::OUString aFilterTitleToken = strFilter.getToken( 0, ',' , nCommaID );
- ::rtl::OUString aFilterToken;
- if ( nCommaID >= 0 )
- {
- aFilterToken = strFilter.getToken( 0, ',' , nCommaID );
- }
- else if ( nCommaID < 0 && nIndex == 1 )
- {
- throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Invalid FileFilter format!" )),
- uno::Reference< uno::XInterface >() );
- }
- xFilterManager->appendFilter( aFilterTitleToken, aFilterToken );
- if ( nFilterIndex == nIndex )
- {
- xFilterManager->setCurrentFilter( aFilterTitleToken );
- }
- nIndex++;
- } while ( nCommaID >= 0 );
- }
- if ( xExecutableDialog.is() && Title.hasValue() )
- {
- ::rtl::OUString sTitle;
- Title >>= sTitle;
- xExecutableDialog->setTitle( sTitle );
- }
- if ( xPickerControlAccess.is() && ButtonText.hasValue() )
- {
- ::rtl::OUString sButtonText;
- ButtonText >>= sButtonText;
- xPickerControlAccess->setLabel( ui::dialogs::CommonFilePickerElementIds::PUSHBUTTON_OK, sButtonText );
- }
- sal_Bool bMultiSelect = false;
- if ( xFilePicker.is() && MultiSelect.hasValue() )
- {
- MultiSelect >>= bMultiSelect;
- xFilePicker->setMultiSelectionMode( bMultiSelect );
- }
-
- if ( xFilePicker.is() && xFilePicker->execute() )
- {
- uno::Sequence< rtl::OUString > aSelectedFiles;
- if ( xFilePicker2.is() )
- {
- // On Linux, XFilePicker->getFiles() always return one selected file although we select more than one file, also on Vista
- // XFilePicker->getFiles() does not work well too, so we call XFilePicker2->getSelectedFiles() to get selected files.
- aSelectedFiles = xFilePicker2->getSelectedFiles();
- }
- else
- {
- // If only one file is selected, the first entry of the sequence contains the complete path/filename in URL format. If multiple files are selected,
- // the first entry of the sequence contains the path in URL format, and the other entries contains the names of the selected files without path information.
- uno::Sequence< rtl::OUString > aTmpFiles = xFilePicker->getFiles();
- aSelectedFiles = aTmpFiles;
- sal_Int32 iFileCount = aTmpFiles.getLength();
- if ( iFileCount > 1 )
- {
- aSelectedFiles.realloc( iFileCount - 1 );
- INetURLObject aPath( aTmpFiles[0] );
- aPath.setFinalSlash();
- for ( sal_Int32 i = 1; i < iFileCount; i++ )
- {
- if ( aTmpFiles[i].indexOf ('/') > 0 || aTmpFiles[i].indexOf ('\\') > 0 )
- {
- aSelectedFiles[i - 1] = aTmpFiles[i];
- }
- else
- {
- if ( i == 1 )
- aPath.Append( aTmpFiles[i] );
- else
- aPath.setName( aTmpFiles[i] );
- aSelectedFiles[i - 1] = aPath.GetMainURL( INetURLObject::NO_DECODE );
- }
- }
- }
- }
-
- sal_Int32 iFileCount = aSelectedFiles.getLength();
- for ( sal_Int32 i = 0; i < iFileCount; i++ )
- {
- INetURLObject aObj( aSelectedFiles[i] );
- if ( aObj.GetProtocol() == INET_PROT_FILE )
- {
- rtl::OUString aTemp = aObj.PathToFileName();
- aSelectedFiles[i] = aTemp.isEmpty() ? aSelectedFiles[i] : aTemp ;
- }
- }
- if ( bMultiSelect )
- {
- aRet = uno::makeAny( aSelectedFiles );
- }
- else if ( aSelectedFiles.getLength() > 0 && !bMultiSelect )
- {
- aRet = uno::makeAny( aSelectedFiles[0] );
- }
- }
- }
- catch (const uno::Exception&)
- {
- DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
- }
-
- return aRet;
-}
-
-::com::sun::star::uno::Reference< ::ooo::vba::XFileDialog > SAL_CALL
-ScVbaApplication::getFileDialog() throw (::com::sun::star::uno::RuntimeException)
-{
- uno::Reference< XFileDialog > xFileDialogs( new ScVbaFileDialog( uno::Reference< XHelperInterface >( this ), mxContext, getCurrentDocument() ) );
- return xFileDialogs;
-}
-
-typedef std::map< ::rtl::OUString, ::rtl::OUString > FileFilterMap;
-
-uno::Any SAL_CALL
-ScVbaApplication::GetSaveAsFilename( const ::com::sun::star::uno::Any& InitialFilename, const ::com::sun::star::uno::Any& FileFilter, const ::com::sun::star::uno::Any& FilterIndex, const ::com::sun::star::uno::Any& Title, const ::com::sun::star::uno::Any& ButtonText ) throw (::com::sun::star::uno::RuntimeException)
-{
- uno::Any strRet;
- try
- {
- const rtl::OUString sServiceName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ));
- uno::Reference< lang::XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
-
- uno::Sequence< uno::Any > aDialogType( 1 );
- aDialogType[0] <<= ui::dialogs::TemplateDescription::FILESAVE_SIMPLE;
- uno::Reference< ui::dialogs::XFilePicker > xFilePicker( xMSF->createInstanceWithArguments( sServiceName, aDialogType ), UNO_QUERY );
-
- if (InitialFilename.hasValue())
- {
- ::rtl::OUString strInitFileName;
- InitialFilename >>= strInitFileName;
- xFilePicker->setDefaultName(strInitFileName);
- }
-
- // Begin from 1.
- sal_Int32 nFilterIndex = 1;
- if (FilterIndex.hasValue())
- {
- FilterIndex >>= nFilterIndex;
- }
-
- uno::Reference< ui::dialogs::XFilterManager > xFilter( xFilePicker, UNO_QUERY );
- FileFilterMap mFilterNameMap;
- if (FileFilter.hasValue())
- {
- ::rtl::OUString strFilter;
- sal_Int32 nCommaID = 0;
- FileFilter >>= strFilter;
-
- sal_Int32 nIndex = 1;
- do
- {
- ::rtl::OUString aFilterTitleToken = strFilter.getToken( 0, ',' , nCommaID );
- ::rtl::OUString aFilterToken;
- if ( nCommaID >= 0 )
- {
- aFilterToken = strFilter.getToken( 0, ',' , nCommaID );
- }
- else if ( nCommaID < 0 && nIndex == 1 )
- {
- throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Invalid FileFilter format!" )),
- uno::Reference< uno::XInterface >() );
- }
-
- FileFilterMap::const_iterator aIt = mFilterNameMap.find( aFilterTitleToken );
- if ( aIt == mFilterNameMap.end() )
- {
- xFilter->appendFilter( aFilterTitleToken, aFilterToken );
- if ( nFilterIndex == nIndex )
- {
- xFilter->setCurrentFilter( aFilterTitleToken );
- }
- nIndex++;
- mFilterNameMap[aFilterTitleToken] = aFilterToken;
- }
- } while ( nCommaID >= 0 );
- }
-
- if (Title.hasValue())
- {
- ::rtl::OUString strTitle;
- Title >>= strTitle;
- uno::Reference< ::com::sun::star::ui::dialogs::XExecutableDialog> xExcTblDlg(xFilePicker, UNO_QUERY );
- xExcTblDlg->setTitle(strTitle);
- }
-
- if (ButtonText.hasValue())
- {
- ::rtl::OUString strBttTxt;
- ButtonText >>= strBttTxt;
- }
-
-
- if ( xFilePicker.is() )
- {
- sal_Int16 nRet = xFilePicker->execute();
- if (nRet == 0)
- {
- strRet <<= false;
- }
- else
- {
- uno::Sequence < rtl::OUString > aPathSeq = xFilePicker->getFiles();
-
- if ( aPathSeq.getLength() )
- {
- ::rtl::OUString sSelectedFilters;
- if ( xFilter.is() )
- {
- ::rtl::OUString sSelectedFilterName = xFilter->getCurrentFilter();
- FileFilterMap::const_iterator aIt = mFilterNameMap.find( sSelectedFilterName );
- if ( aIt != mFilterNameMap.end() )
- {
- sSelectedFilters = aIt->second;
- }
- }
- INetURLObject aURLObj( aPathSeq[0] );
- ::rtl::OUString aPathStr = aURLObj.PathToFileName();
- if ( aURLObj.GetProtocol() == INET_PROT_FILE )
- {
- sal_Int32 nSemicolonID = 0;
- ::rtl::OUString sFirstFilter = sSelectedFilters.getToken( 0, ';' , nSemicolonID );
- ::rtl::OUString sFileExtension = aURLObj.GetExtension();
- if ( sFileExtension.isEmpty() )
- {
- sFileExtension = sFirstFilter == "*.*" ? sFileExtension : sFirstFilter.copy( sFirstFilter.indexOfAsciiL("*.", 2) + 2 );
- aPathStr = sFileExtension.isEmpty() ? aPathStr : aPathStr + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")) + sFileExtension;
- }
- else
- {
- sal_Bool bValidFilter = false;
- FileFilterMap::const_iterator aIt = mFilterNameMap.begin();
- while ( aIt != mFilterNameMap.end() )
- {
- sSelectedFilters = aIt->second;
- nSemicolonID = 0;
- do
- {
- ::rtl::OUString aFilterToken = sSelectedFilters.getToken( 0, ';' , nSemicolonID );
- if ( aFilterToken.trim().equalsIgnoreAsciiCase( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*.")) + sFileExtension) )
- {
- bValidFilter = sal_True;
- break;
- }
- } while ( nSemicolonID >= 0 );
- if ( bValidFilter )
- {
- break;
- }
- ++aIt;
- }
- if ( !bValidFilter )
- {
- sFileExtension = sFirstFilter == "*.*" ? rtl::OUString()
- : sFirstFilter.copy( sFirstFilter.indexOfAsciiL("*.", 2) + 2 );
- aPathStr = sFileExtension.isEmpty() ? aPathStr
- : aPathStr + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")) + sFileExtension;
- }
- }
- }
- strRet <<= aPathStr;
- }
- }
- }
- }
- catch (const uno::Exception&)
- {
- DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
- }
- return strRet;
-}
-
-//end add
-
uno::Reference< frame::XModel >
ScVbaApplication::getCurrentDocument() throw (css::uno::RuntimeException)
{
@@ -1790,86 +1321,6 @@ ScVbaApplication::MenuBars( const uno::Any& aIndex ) throw (uno::RuntimeExceptio
return uno::Any( xMenuBars );
}
-//add the support of Application.International
-sal_Int32 SAL_CALL
-ConvertCountryCode(const OUString& language)
-{
- sal_Int32 nCode = 0;
-
- if( language == "ar" ) nCode = 966; // Arabic
- else if ( language == "cs" ) nCode = 42; // Czech
- else if ( language == "da" ) nCode = 45; // Danish
- else if ( language == "de" ) nCode = 49; // German
- else if ( language == "en" ) nCode = 1; // English
- else if ( language == "es" ) nCode = 34; // Spanish
- else if ( language == "el" ) nCode = 30; // Greek
- else if ( language == "fa" ) nCode = 98; // Persian = Farsi
- else if ( language == "fi" ) nCode = 358; // Finnish
- else if ( language == "fr" ) nCode = 33; // French
- else if ( language == "he" ) nCode = 972; // Hebrew
- else if ( language == "hi" ) nCode = 91; // Indian = Hindi
- else if ( language == "hu" ) nCode = 36; // Hungarian
- else if ( language == "it" ) nCode = 39; // Italian
- else if ( language == "ja" ) nCode = 81; // Japanese
- else if ( language == "ko" ) nCode = 82; // Korean
- else if ( language == "nl" ) nCode = 31; // Dutch
- else if ( language == "no" ) nCode = 47; // Norwegian
- else if ( language == "pl" ) nCode = 48; // Polish
- else if ( language == "pt" ) nCode = 351; // Portuguese
- else if ( language == "ru" ) nCode = 7; // Russian
- else if ( language == "sv" ) nCode = 46; // Swedish
- else if ( language == "th" ) nCode = 66; // Thai
- else if ( language == "tk" ) nCode = 90; // Turkish
- else if ( language == "ur" ) nCode = 92; // Urdu
- else if ( language == "vi" ) nCode = 84; // Vietnamese
- else if ( language == "zh" ) nCode = 86; // Simplified Chinese
-
- return nCode;
-}
-
-uno::Any SAL_CALL
-ScVbaApplication::International( sal_Int32 Index ) throw (uno::RuntimeException)
-{
- uno::Any aRet;
- OUString str;
- const LocaleDataWrapper* pLocaleData = ScGlobal::GetpLocaleData();
- switch ( Index )
- {
- case excel::XlApplicationInternational::xlCountryCode:
- aRet <<= ConvertCountryCode( pLocaleData->getLanguageCountryInfo().Language );
- break;
- case excel::XlApplicationInternational::xlDecimalSeparator:
- str = pLocaleData->getNumDecimalSep();
- aRet <<= str;
- break;
- case excel::XlApplicationInternational::xlDateSeparator:
- str = pLocaleData->getDateSep();
- aRet <<= str;
- break;
- default:
- break;
- }
- return aRet;
-}
-
-void SAL_CALL ScVbaApplication::Undo( ) throw (::com::sun::star::uno::RuntimeException)
-{
- SfxAllItemSet reqList( SFX_APP()->GetPool() );
- SfxRequest rReq(SID_UNDO, 0, reqList);
- ScTabViewShell* pViewShell = excel::getCurrentBestViewShell( mxContext );
-
- if (pViewShell != NULL)
- {
- pViewShell->ExecuteUndo(rReq);
- }
-}
-
-double SAL_CALL ScVbaApplication::InchesToPoints( double Inches ) throw (uno::RuntimeException)
-{
- // Convert a measurement from Inch to Point (1 inch = 72 points).
- return MetricField::ConvertDoubleValue( Inches, 0, 0, FUNIT_INCH, FUNIT_POINT );
-}
-
rtl::OUString
ScVbaApplication::getServiceImplName()
{
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
index 0f72d7bfaef5..751175c68220 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -48,7 +48,6 @@ private:
ScVbaAppSettings& mrAppSettings;
rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException );
- css::uno::Reference< ov::XFileSearch > m_xFileSearch;
protected:
virtual css::uno::Reference< css::frame::XModel > getCurrentDocument() throw (css::uno::RuntimeException);
@@ -94,7 +93,6 @@ public:
virtual void SAL_CALL setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( css::uno::RuntimeException );
virtual css::uno::Reference< ov::XAssistant > SAL_CALL getAssistant() throw (css::uno::RuntimeException);
- virtual css::uno::Reference< ov::XFileSearch > SAL_CALL getFileSearch() throw (css::uno::RuntimeException); // add the support of Application.FileSearch
virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getThisWorkbook() throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Workbooks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Worksheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
@@ -108,17 +106,6 @@ public:
virtual ::sal_Int32 SAL_CALL getCursor() throw (css::uno::RuntimeException);
virtual void SAL_CALL setCursor( ::sal_Int32 _cursor ) throw (css::uno::RuntimeException);
- virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw (css::uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL getIteration() throw (css::uno::RuntimeException); // add the support of Iteration
- virtual void SAL_CALL setIteration( sal_Bool bIteration ) throw (css::uno::RuntimeException); // add the support of Iteration
- virtual sal_Int32 SAL_CALL getEnableCancelKey() throw (css::uno::RuntimeException); // add the support of EnableCancelKey
- virtual void SAL_CALL setEnableCancelKey( sal_Int32 lEnableCancelKey ) throw (css::uno::RuntimeException); // add the support of EnableCancelKey
-
- virtual sal_Int32 SAL_CALL getSheetsInNewWorkbook() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setSheetsInNewWorkbook( sal_Int32 SheetsInNewWorkbook ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
-
virtual sal_Bool SAL_CALL getEnableEvents() throw (css::uno::RuntimeException);
virtual void SAL_CALL setEnableEvents( sal_Bool bEnable ) throw (css::uno::RuntimeException);
@@ -144,12 +131,6 @@ public:
virtual void SAL_CALL Volatile( const css::uno::Any& Volatile ) throw (css::uno::RuntimeException );
virtual css::uno::Any SAL_CALL Caller( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL MenuBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL GetOpenFilename( const css::uno::Any& FileFilter, const css::uno::Any& FilterIndex, const css::uno::Any& Title, const css::uno::Any& ButtonText, const css::uno::Any& MultiSelect ) throw (css::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::ooo::vba::XFileDialog > SAL_CALL getFileDialog() throw (::com::sun::star::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL International( sal_Int32 Index ) throw (css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL GetSaveAsFilename( const ::com::sun::star::uno::Any& InitialFilename, const ::com::sun::star::uno::Any& FileFilter, const ::com::sun::star::uno::Any& FilterIndex, const ::com::sun::star::uno::Any& Title, const ::com::sun::star::uno::Any& ButtonText ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL Undo( ) throw (::com::sun::star::uno::RuntimeException);
- virtual double SAL_CALL InchesToPoints( double Inches ) throw (css::uno::RuntimeException);
// XHelperInterface
virtual rtl::OUString getServiceImplName();
diff --git a/sc/source/ui/vba/vbacomment.cxx b/sc/source/ui/vba/vbacomment.cxx
index bce3c19673f5..e30fd5e29a90 100644
--- a/sc/source/ui/vba/vbacomment.cxx
+++ b/sc/source/ui/vba/vbacomment.cxx
@@ -39,14 +39,6 @@
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/text/XText.hpp>
-#include <cellsuno.hxx>
-#include <postit.hxx>
-#include <svx/svdobj.hxx>
-#include <svx/svdocapt.hxx>
-#include <ooo/vba/msforms/XShape.hpp>
-#include <com/sun/star/drawing/XShape.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-
#include <vbahelper/vbashape.hxx>
#include "vbaglobals.hxx"
#include "vbacomments.hxx"
@@ -187,6 +179,7 @@ ScVbaComment::Text( const uno::Any& aText, const uno::Any& aStart, const uno::An
aText >>= sText;
uno::Reference< text::XSimpleText > xAnnoText( getAnnotation(), uno::UNO_QUERY_THROW );
+ rtl::OUString sAnnoText = xAnnoText->getString();
if ( aStart.hasValue() )
{
@@ -225,7 +218,6 @@ ScVbaComment::Text( const uno::Any& aText, const uno::Any& aStart, const uno::An
getAnnotations()->insertNew( aAddress, sText );
}
- rtl::OUString sAnnoText = xAnnoText->getString();
return sAnnoText;
}
diff --git a/sc/source/ui/vba/vbadialog.cxx b/sc/source/ui/vba/vbadialog.cxx
index d7cbb7446b1d..9bb4e4c91293 100644
--- a/sc/source/ui/vba/vbadialog.cxx
+++ b/sc/source/ui/vba/vbadialog.cxx
@@ -32,56 +32,42 @@
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-//solve the problem that "Application.Dialogs.Item(***).Show" and "Application.Dialogs.Count" cannot get the correct result
-struct DialogMatch
+static const rtl::OUString aStringList[]=
{
- sal_Int32 nVbaDlgIndex;
- rtl::OUString aOODlgName;
+ rtl::OUString( ".uno:Open" ),
+ rtl::OUString( ".uno:FormatCellDialog" ),
+ rtl::OUString( ".uno:InsertCell" ),
+ rtl::OUString( ".uno:Print" ),
+ rtl::OUString( ".uno:PasteSpecial" ),
+ rtl::OUString( ".uno:ToolProtectionDocument" ),
+ rtl::OUString( ".uno:ColumnWidth" ),
+ rtl::OUString( ".uno:DefineName" ),
+ rtl::OUString( ".uno:ConfigureDialog" ),
+ rtl::OUString( ".uno:HyperlinkDialog" ),
+ rtl::OUString( ".uno:InsertGraphic" ),
+ rtl::OUString( ".uno:InsertObject" ),
+ rtl::OUString( ".uno:PageFormatDialog" ),
+ rtl::OUString( ".uno:DataSort" ),
+ rtl::OUString( ".uno:RowHeight" ),
+ rtl::OUString( ".uno:AutoCorrectDlg" ),
+ rtl::OUString( ".uno:ConditionalFormatDialog" ),
+ rtl::OUString( ".uno:DataConsolidate" ),
+ rtl::OUString( ".uno:CreateNames" ),
+ rtl::OUString( ".uno:FillSeries" ),
+ rtl::OUString( ".uno:Validation"),
+ rtl::OUString( ".uno:DefineLabelRange" ),
+ rtl::OUString( ".uno:DataFilterAutoFilter" ),
+ rtl::OUString( ".uno:DataFilterSpecialFilter" ),
+ rtl::OUString( ".uno:AutoFormat" )
};
-static const DialogMatch aDialogMatchList[] =
-{
- { 1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Open" ) ) }, // xlDialogOpen -> .uno:Open
- { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormatCellDialog" ) ) }, // ??? -> .uno:FormatCellDialog
- { 55, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertCell" ) ) }, // xlDialogInsert -> .uno:InsertCell
- { 8, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Print" ) ) }, // xlDialogPrint -> .uno:Print
- { 9, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PrinterSetup" ) ) }, // xlDialogPrinterSetup -> .uno:PrinterSetup
- { 53, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PasteSpecial" ) ) }, // xlDialogPasteSpecial -> .uno:PasteSpecial
- { 28, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ToolProtectionDocument" ) ) }, // xlDialogProtectDocument -> uno:ToolProtectionDocument
- { 47, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColumnWidth" ) ) }, // xlDialogColumnWidth -> .uno:ColumnWidth
- { 61, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DefineName" ) ) }, // xlDialogDefineName -> .uno:DefineName
- { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConfigureDialog" ) ) }, // ??? -> .uno:ConfigureDialog
- { 596, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:HyperlinkDialog" ) ) }, // xlDialogInsertHyperlink -> .uno:HyperlinkDialog
- { 342, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertGraphic" ) ) }, // xlDialogInsertPicture -> .uno:InsertGraphic
- { 259, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertObject" ) ) }, // xlDialogInsertObject -> .uno:InsertObject
- { 7, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PageFormatDialog" ) ) }, // xlDialogPageSetup -> .uno:PageFormatDialog
- { 39, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataSort" ) ) }, // xlDialogSort -> .uno:DataSort
- { 127, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:RowHeight" ) ) }, // xlDialogRowHeight -> .uno:RowHeight
- { 485, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoCorrectDlg" ) ) }, // xlDialogAutoCorrect -> .uno:AutoCorrectDlg
- { 583, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConditionalFormatDialog" ) ) }, // xlDialogCondiationalFormatting -> .uno:ConditionalFormatDialog
- { 191, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataConsolidate" ) ) }, // xlDialogConsolidate -> .uno:DataConsolidate
- { 62, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CreateNames" ) ) }, // xlDialogCreateNames -> .uno:CreateNames
- { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillSeries" ) ) }, // ??? -> .uno:FillSeries
- { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Validation" ) ) }, // ??? -> .uno:Validation"
- { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DefineLabelRange" ) ) }, // ??? -> .uno:DefineLabelRange
- { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataFilterAutoFilter" ) ) }, // ??? -> .uno:DataFilterAutoFilter
- { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataFilterSpecialFilter" ) ) }, // ??? -> .uno:DataFilterSpecialFilter
- { 269, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoFormat" ) ) } // xlDialogFormatAuto -> .uno:AutoFormat
-};
-
-const sal_Int32 nDialogSize = sizeof (aDialogMatchList) / sizeof (aDialogMatchList[0]);
+const sal_Int32 nDialogSize = sizeof (aStringList) / sizeof (aStringList[0]);
rtl::OUString
ScVbaDialog::mapIndexToName( sal_Int32 nIndex )
{
- for (int i = 0; i < nDialogSize; i++)
- {
- if ( aDialogMatchList[i].nVbaDlgIndex == nIndex )
- {
- return aDialogMatchList[i].aOODlgName;
- }
- }
-
+ if( nIndex < nDialogSize )
+ return aStringList[ nIndex ];
return rtl::OUString();
}
@@ -102,9 +88,4 @@ ScVbaDialog::getServiceNames()
}
return aServiceNames;
}
-
-sal_Int32 ScVbaDialog::GetSupportedDialogCount()
-{
- return nDialogSize;
-}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbadialog.hxx b/sc/source/ui/vba/vbadialog.hxx
index 3bde7a7ff987..1ff2f651dfa9 100644
--- a/sc/source/ui/vba/vbadialog.hxx
+++ b/sc/source/ui/vba/vbadialog.hxx
@@ -47,7 +47,6 @@ public:
virtual rtl::OUString getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
- static sal_Int32 GetSupportedDialogCount();
};
#endif /* SC_VBA_DIALOG_HXX */
diff --git a/sc/source/ui/vba/vbadialogs.cxx b/sc/source/ui/vba/vbadialogs.cxx
index f196ee2fa90c..15a06b5ff183 100644
--- a/sc/source/ui/vba/vbadialogs.cxx
+++ b/sc/source/ui/vba/vbadialogs.cxx
@@ -64,13 +64,4 @@ ScVbaDialogs::getServiceNames()
return aServiceNames;
}
-::sal_Int32
-ScVbaDialogs::getCount() throw (uno::RuntimeException)
-{
- return ScVbaDialog::GetSupportedDialogCount();
-}
-
-
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbadialogs.hxx b/sc/source/ui/vba/vbadialogs.hxx
index cda36dd18424..a0be27676405 100644
--- a/sc/source/ui/vba/vbadialogs.hxx
+++ b/sc/source/ui/vba/vbadialogs.hxx
@@ -45,7 +45,6 @@ public:
// XCollection
virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index ) throw (css::uno::RuntimeException);
- virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
// XDialogs
virtual void SAL_CALL Dummy() throw (css::uno::RuntimeException);
diff --git a/sc/source/ui/vba/vbafiledialog.cxx b/sc/source/ui/vba/vbafiledialog.cxx
deleted file mode 100644
index 7ae0a9eafb7a..000000000000
--- a/sc/source/ui/vba/vbafiledialog.cxx
+++ /dev/null
@@ -1,174 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright IBM Corporation 2009, 2010.
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "vbafiledialog.hxx"
-#include "comphelper/processfactory.hxx"
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
-#include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
-#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
-#include "tools/urlobj.hxx"
-
-
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-
-
-ScVbaFileDialog::ScVbaFileDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel >& xModel )
-: ScVbaFileDialog_BASE( xParent, xContext, xModel )
-{
- m_pFileDialogSelectedItems = new VbaFileDialogSelectedItems(xParent, xContext, (com::sun::star::container::XIndexAccess *)&m_FileDialogSelectedObj);
-}
-
-ScVbaFileDialog::~ScVbaFileDialog()
-{
- if (m_pFileDialogSelectedItems != NULL)
- {
- delete m_pFileDialogSelectedItems;
- }
-}
-
-rtl::OUString
-ScVbaFileDialog::getServiceImplName()
-{
- return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaFileDialog"));
-}
-
-css::uno::Sequence<rtl::OUString>
-ScVbaFileDialog::getServiceNames()
-{
- static Sequence< rtl::OUString > aServiceNames;
- if ( aServiceNames.getLength() == 0 )
- {
- aServiceNames.realloc( 1 );
- aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.FileDialog" ) );
- }
- return aServiceNames;
-
-}
-
-css::uno::Reference< ov::XFileDialogSelectedItems > SAL_CALL
-ScVbaFileDialog::getSelectedItems() throw (css::uno::RuntimeException)
-{
- css::uno::Reference< ov::XFileDialogSelectedItems > xFileDlgSlc = (ov::XFileDialogSelectedItems *)m_pFileDialogSelectedItems;
- return xFileDlgSlc;
-}
-
-::sal_Int32 SAL_CALL
-ScVbaFileDialog::Show( ) throw (::com::sun::star::uno::RuntimeException)
-{
- // Returns an Integer indicating if user pressed "Open" button(-1) or "Cancel" button(0).
- sal_Int32 nResult = -1;
- try
- {
- m_sSelectedItems.realloc(0);
-
- const ::rtl::OUString sServiceName(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ));
-
- Reference< lang::XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
- // Set the type of File Picker Dialog: TemplateDescription::FILEOPEN_SIMPLE.
- Sequence< uno::Any > aDialogType( 1 );
- aDialogType[0] <<= ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
- Reference < ui::dialogs::XFilePicker > xFilePicker( xMSF->createInstanceWithArguments( sServiceName, aDialogType ), UNO_QUERY );
- Reference < ui::dialogs::XFilePicker2 > xFilePicker2( xFilePicker, UNO_QUERY );
- if ( xFilePicker.is() )
- {
- xFilePicker->setMultiSelectionMode(sal_True);
- if ( xFilePicker->execute() )
- {
- if ( xFilePicker2.is() )
- {
- // On Linux, XFilePicker->getFiles() always return one selected file although we select
- // more than one file, also on Vista XFilePicker->getFiles() does not work well too,
- // so we call XFilePicker2->getSelectedFiles() to get selected files.
- m_sSelectedItems = xFilePicker2->getSelectedFiles();
- }
- else
- {
- // If only one file is selected, the first entry of the sequence contains the complete path/filename in
- // URL format. If multiple files are selected, the first entry of the sequence contains the path in URL
- // format, and the other entries contains the names of the selected files without path information.
- Sequence< rtl::OUString > aSelectedFiles = xFilePicker->getFiles();
- sal_Int32 iFileCount = aSelectedFiles.getLength();
- if ( iFileCount > 1 )
- {
- m_sSelectedItems.realloc( iFileCount - 1 );
- INetURLObject aPath( aSelectedFiles[0] );
- aPath.setFinalSlash();
- for ( sal_Int32 i = 1; i < iFileCount; i++ )
- {
- if ( aSelectedFiles[i].indexOf ('/') > 0 || aSelectedFiles[i].indexOf ('\\') > 0 )
- {
- m_sSelectedItems[i - 1] = aSelectedFiles[i];
- }
- else
- {
- if ( i == 1 )
- aPath.Append( aSelectedFiles[i] );
- else
- aPath.setName( aSelectedFiles[i] );
- m_sSelectedItems[i - 1] = aPath.GetMainURL(INetURLObject::NO_DECODE);
- }
- }
- }
- else if ( iFileCount == 1 )
- {
- m_sSelectedItems = aSelectedFiles;
- }
- }
-
- sal_Int32 iFileCount = m_sSelectedItems.getLength();
- rtl::OUString aTemp;
- for ( sal_Int32 i = 0; i < iFileCount; i++ )
- {
- INetURLObject aObj( m_sSelectedItems[i] );
- if ( aObj.GetProtocol() == INET_PROT_FILE )
- {
- aTemp = aObj.PathToFileName();
- m_sSelectedItems[i] = aTemp.isEmpty() ? m_sSelectedItems[i] : aTemp;
- }
- }
- }
- else
- {
- nResult = 0;
- }
- }
-
- m_FileDialogSelectedObj.SetSelectedFile(m_sSelectedItems);
- }
- catch( const uno::Exception& )
- {
- return 0;
- }
-
- return nResult;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafiledialog.hxx b/sc/source/ui/vba/vbafiledialog.hxx
deleted file mode 100644
index 16ed4de39a01..000000000000
--- a/sc/source/ui/vba/vbafiledialog.hxx
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright IBM Corporation 2009, 2010.
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _vbafiledialog_hxx_
-#define _vbafiledialog_hxx_
-
-#include <cppuhelper/implbase1.hxx>
-#include <vbahelper/vbadialogsbase.hxx>
-#include <ooo/vba/XFileDialog.hpp>
-#include "vbafiledialogselecteditems.hxx"
-
-
-typedef cppu::ImplInheritanceHelper1< VbaDialogsBase, ov::XFileDialog > ScVbaFileDialog_BASE;
-
-class ScVbaFileDialog : public ScVbaFileDialog_BASE
-{
-public:
-
- ScVbaFileDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel >& xModel ) ;
- virtual ~ScVbaFileDialog() ;
-
- // XHelperInterface
- virtual rtl::OUString getServiceImplName();
- virtual css::uno::Sequence<rtl::OUString> getServiceNames();
- //XFileDialog
- virtual css::uno::Reference< ov::XFileDialogSelectedItems > SAL_CALL getSelectedItems() throw (css::uno::RuntimeException);
- virtual ::sal_Int32 SAL_CALL Show( ) throw (::com::sun::star::uno::RuntimeException) ;
-
-private:
- css::uno::Sequence < rtl::OUString > m_sSelectedItems;
- VbaFileDialogSelectedItems *m_pFileDialogSelectedItems;
- VbaFileDialogSelectedObj m_FileDialogSelectedObj;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafiledialogselecteditems.cxx b/sc/source/ui/vba/vbafiledialogselecteditems.cxx
deleted file mode 100644
index 21fa2e75d88c..000000000000
--- a/sc/source/ui/vba/vbafiledialogselecteditems.cxx
+++ /dev/null
@@ -1,156 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright IBM Corporation 2009, 2010.
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "vbafiledialogselecteditems.hxx"
-
-using namespace ::com::sun::star;
-
-VbaFileDialogSelectedItems::VbaFileDialogSelectedItems( const css::uno::Reference< ov::XHelperInterface >& xParent,
- const css::uno::Reference< css::uno::XComponentContext >& xContext,
- const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess
- )
- : FileDialogSelectedItems_BASE( xParent, xContext, xIndexAccess )
-{
-}
-
-
-rtl::OUString VbaFileDialogSelectedItems::getServiceImplName()
-{
- return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VbaFileDialogSelectedItems"));
-}
-
-css::uno::Sequence<rtl::OUString> VbaFileDialogSelectedItems::getServiceNames()
-{
- static uno::Sequence< rtl::OUString > aServiceNames;
- if ( aServiceNames.getLength() == 0 )
- {
- aServiceNames.realloc( 1 );
- aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.FileDialogSelectedItems" ) );
- }
- return aServiceNames;
-
-}
-
-css::uno::Any VbaFileDialogSelectedItems::createCollectionObject( const css::uno::Any& aSource )
-{
- css::uno::Any aRet;
- aRet = aSource;
- return aRet;
-}
-
-
-css::uno::Type SAL_CALL
-VbaFileDialogSelectedItems::getElementType() throw (css::uno::RuntimeException)
-{
- return ooo::vba::XFileDialogSelectedItems::static_type(0);
-}
-
-css::uno::Reference< css::container::XEnumeration > SAL_CALL
-VbaFileDialogSelectedItems::createEnumeration() throw (css::uno::RuntimeException)
-{
- css::uno::Reference< css::container::XEnumeration > xEnumRet(m_xIndexAccess, css::uno::UNO_QUERY);
- return xEnumRet;
-}
-
-
-//VbaFileDialogSelectedObj
-//////////////////////////////////////////////////////////////////////////
-
-VbaFileDialogSelectedObj::VbaFileDialogSelectedObj()
-{
- m_nIndex = 0;
-}
-
-
-sal_Bool
-VbaFileDialogSelectedObj::SetSelectedFile(css::uno::Sequence<rtl::OUString> &sFList)
-{
- m_sFileList = sFList;
- return sal_True;
-}
-
-sal_Int32 SAL_CALL
-VbaFileDialogSelectedObj::getCount() throw(::com::sun::star::uno::RuntimeException)
-{
- sal_Int32 nListCnt = m_sFileList.getLength();
- return nListCnt;
-}
-
-::com::sun::star::uno::Any SAL_CALL VbaFileDialogSelectedObj::getByIndex( sal_Int32 nIndex )
-throw(::com::sun::star::lang::IndexOutOfBoundsException,
- ::com::sun::star::lang::WrappedTargetException,
- ::com::sun::star::uno::RuntimeException)
-{
- css::uno::Any aRet;
-
- if ( nIndex >= getCount() )
- {
- throw css::lang::IndexOutOfBoundsException();
- }
-
- return uno::makeAny(m_sFileList[nIndex]);
-}
-
-::com::sun::star::uno::Type SAL_CALL
-VbaFileDialogSelectedObj::getElementType()
-throw(::com::sun::star::uno::RuntimeException)
-{
- return getCppuType((uno::Reference<com::sun::star::container::XIndexAccess>*)0);
-}
-
-sal_Bool SAL_CALL VbaFileDialogSelectedObj::hasElements()
-throw(::com::sun::star::uno::RuntimeException)
-{
- return ( getCount() != 0 );
-}
-
-::sal_Bool SAL_CALL
-VbaFileDialogSelectedObj::hasMoreElements( )
-throw (uno::RuntimeException)
-{
- if (getCount() > m_nIndex)
- {
- return sal_True;
- }
- return false;
-}
-
-uno::Any SAL_CALL
-VbaFileDialogSelectedObj::nextElement( )
-throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
-{
- if (!hasMoreElements())
- {
- throw container::NoSuchElementException();
- }
-
- return uno::makeAny(m_sFileList[m_nIndex++]);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafiledialogselecteditems.hxx b/sc/source/ui/vba/vbafiledialogselecteditems.hxx
deleted file mode 100644
index 030242a9e867..000000000000
--- a/sc/source/ui/vba/vbafiledialogselecteditems.hxx
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright IBM Corporation 2009, 2010.
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _vbafiledialogselecteditems_hxx_
-#define _vbafiledialogselecteditems_hxx_
-
-#include <ooo/vba/XFileDialogSelectedItems.hpp>
-#include <vbahelper/vbacollectionimpl.hxx>
-#include <cppuhelper/implbase1.hxx>
-#include <com/sun/star/container/XIndexAccess.hpp>
-
-typedef CollTestImplHelper< ov::XFileDialogSelectedItems > FileDialogSelectedItems_BASE;
-
-
-class VbaFileDialogSelectedItems : public FileDialogSelectedItems_BASE
-{
-public:
- VbaFileDialogSelectedItems( const css::uno::Reference< ov::XHelperInterface >& xParent,
- const css::uno::Reference< css::uno::XComponentContext >& xContext,
- const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
-
- virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
- virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
- virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
-
-protected:
- virtual rtl::OUString getServiceImplName();
- virtual css::uno::Sequence<rtl::OUString> getServiceNames();
-private:
-};
-
-
-class VbaFileDialogSelectedObj : public cppu::WeakImplHelper2<css::container::XIndexAccess, css::container::XEnumeration>
-{
-public:
- VbaFileDialogSelectedObj();
- sal_Bool SetSelectedFile(css::uno::Sequence<rtl::OUString> &sFList);
- //XIndexAccess
- virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
-
- virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex )
- throw(::com::sun::star::lang::IndexOutOfBoundsException,
- ::com::sun::star::lang::WrappedTargetException,
- ::com::sun::star::uno::RuntimeException);
-
- // XElementAccess
- virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
- throw(::com::sun::star::uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
-
- //XEnumeration
- virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL nextElement( ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException);
-
-protected:
-private:
- css::uno::Sequence<rtl::OUString> m_sFileList;
- sal_Int32 m_nIndex;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafilesearch.cxx b/sc/source/ui/vba/vbafilesearch.cxx
deleted file mode 100644
index c0c6f9761541..000000000000
--- a/sc/source/ui/vba/vbafilesearch.cxx
+++ /dev/null
@@ -1,244 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright IBM Corporation 2009, 2010.
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "vbafilesearch.hxx"
-#include "vbaapplication.hxx"
-#include "vbafoundfiles.hxx"
-#include <comphelper/processfactory.hxx>
-#include <tools/urlobj.hxx>
-#include <tools/wldcrd.hxx>
-#include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <vector>
-#include "unotools/viewoptions.hxx"
-#include <osl/file.hxx>
-
-using namespace ::ooo::vba;
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::ucb;
-using namespace ::com::sun::star::lang;
-using namespace comphelper;
-
-static Reference< XSimpleFileAccess3 > getFileAccess( void )
-{
- static Reference< XSimpleFileAccess3 > xSFI;
- if( !xSFI.is() )
- {
- Reference< XMultiServiceFactory > xSMgr = getProcessServiceFactory();
- if( xSMgr.is() )
- {
- xSFI = Reference< XSimpleFileAccess3 >( xSMgr->createInstance
- ( ::rtl::OUString( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY );
- }
- }
- return xSFI;
-}
-
-ScVbaFileSearch::ScVbaFileSearch( ScVbaApplication* pApp, const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext )
- : ScVbaFileSearchImpl_BASE( xParent, xContext ), m_pApplication( pApp )
-{
- NewSearch();
-}
-
-ScVbaFileSearch::~ScVbaFileSearch()
-{
-}
-
-::rtl::OUString SAL_CALL ScVbaFileSearch::getFileName() throw (css::uno::RuntimeException)
-{
- return m_sFileName;
-}
-
-void SAL_CALL ScVbaFileSearch::setFileName(const ::rtl::OUString& _fileName ) throw (css::uno::RuntimeException)
-{
- m_sFileName = _fileName;
-}
-
-::rtl::OUString SAL_CALL ScVbaFileSearch::getLookIn() throw (css::uno::RuntimeException)
-{
- return m_sLookIn;
-}
-
-void SAL_CALL ScVbaFileSearch::setLookIn( const ::rtl::OUString& _lookIn ) throw (css::uno::RuntimeException)
-{
- m_sLookIn = _lookIn;
-}
-
-sal_Bool SAL_CALL ScVbaFileSearch::getSearchSubFolders() throw (css::uno::RuntimeException)
-{
- return m_bSearchSubFolders;
-}
-
-void SAL_CALL ScVbaFileSearch::setSearchSubFolders( sal_Bool _searchSubFolders ) throw (css::uno::RuntimeException)
-{
- m_bSearchSubFolders = _searchSubFolders;
-}
-
-sal_Bool SAL_CALL ScVbaFileSearch::getMatchTextExactly() throw (css::uno::RuntimeException)
-{
- return m_bMatchTextExactly;
-}
-
-void SAL_CALL ScVbaFileSearch::setMatchTextExactly( sal_Bool _matchTextExactly ) throw (css::uno::RuntimeException)
-{
- m_bMatchTextExactly = _matchTextExactly;
-}
-
-static bool IsWildCard( const ::rtl::OUString& fileName )
-{
- static sal_Char cWild1 = '*';
- static sal_Char cWild2 = '?';
-
- return ( ( fileName.indexOf( cWild1 ) >= 0 )
- || ( fileName.indexOf( cWild2 ) >= 0 ) );
-}
-
-static void SearchWildCard(const WildCard& wildCard, const ::rtl::OUString& aDir, bool bSearchSubFolders, css::uno::Sequence< rtl::OUString >& aSearchedFiles)
-{
- Reference< XSimpleFileAccess3 > xSFI = getFileAccess();
- Sequence< rtl::OUString > aDirSeq;
- try
- {
- if ( xSFI.is() )
- {
- aDirSeq = xSFI->getFolderContents( aDir, bSearchSubFolders );
- }
- }
- catch( css::uno::Exception& )
- {
- }
- sal_Int32 nLength = aDirSeq.getLength();
- for ( sal_Int32 i = 0; i < nLength; i++ )
- {
- rtl::OUString aURLStr = aDirSeq[i];
- if ( xSFI->isFolder( aURLStr ) )
- {
- if ( bSearchSubFolders )
- {
- SearchWildCard( wildCard, aURLStr, true, aSearchedFiles );
- }
- }
- else
- {
- INetURLObject aFileURL( aURLStr );
- rtl::OUString aFileName = aFileURL.GetLastName( INetURLObject::DECODE_UNAMBIGUOUS );
- if ( wildCard.Matches( aFileName.toAsciiLowerCase() ) )
- {
- sal_Int32 nFilesLength = aSearchedFiles.getLength();
- aSearchedFiles.realloc( nFilesLength + 1 );
- rtl::OUString sSystemPath;
- ::osl::File::getSystemPathFromFileURL( aURLStr, sSystemPath );
- aSearchedFiles[nFilesLength] = sSystemPath;
- }
- }
- }
-}
-
-sal_Int32 SAL_CALL ScVbaFileSearch::Execute( ) throw (css::uno::RuntimeException)
-{
- m_aSearchedFiles.realloc(0);
- Reference< XSimpleFileAccess3 > xSFI = getFileAccess();
- if ( !xSFI.is() || !xSFI->isFolder( m_sLookIn ) )
- {
- return 0;
- }
-
- if ( m_sFileName.isEmpty() )
- {
- return 1;
- }
-
- ::rtl::OUString aTempFileName = m_sFileName.toAsciiLowerCase();
- if ( IsWildCard( aTempFileName ) )
- {
- bool bEndWithAsterisk = aTempFileName.endsWithAsciiL("*", 1);
- bool bStartWithAsterisk = (aTempFileName.indexOf('*') == 0);
- if ( !bEndWithAsterisk && !bStartWithAsterisk )
- {
- aTempFileName = ::rtl::OUString("*") + aTempFileName + ::rtl::OUString("*");
- }
- }
- else
- {
- aTempFileName = ::rtl::OUString("*") + aTempFileName + ::rtl::OUString("*");
- }
- WildCard wildCard( aTempFileName );
- SearchWildCard( wildCard, m_sLookIn, m_bSearchSubFolders, m_aSearchedFiles );
-
- return m_aSearchedFiles.getLength();
-}
-
-// set ScVbaApplication::getDefaultFilePath( ) as the InitPath for FileSearch
- ::rtl::OUString ScVbaFileSearch::getInitPath() throw (css::uno::RuntimeException)
-{
- String aPath;
-
- if (m_pApplication != NULL)
- {
- aPath = m_pApplication->getDefaultFilePath();
- }
-
- return aPath;
-}
-
-void SAL_CALL ScVbaFileSearch::NewSearch( ) throw (css::uno::RuntimeException)
-{
- m_sFileName = ::rtl::OUString();
- m_sLookIn = getInitPath();
- m_bSearchSubFolders = false;
- m_bMatchTextExactly = false;
- m_aSearchedFiles.realloc(0);
-}
-
-Reference< XFoundFiles > SAL_CALL ScVbaFileSearch::getFoundFiles() throw (css::uno::RuntimeException)
-{
- css::uno::Reference< ov::XFoundFiles > xFoundFiles = new VbaFoundFiles(
- mxParent, mxContext, (css::container::XIndexAccess *) new VbaFoundFilesEnum(m_aSearchedFiles) );
- return xFoundFiles;
-}
-
-rtl::OUString ScVbaFileSearch::getServiceImplName()
-{
- return rtl::OUString("VbaFileSearch");
-}
-
-css::uno::Sequence< rtl::OUString > ScVbaFileSearch::getServiceNames()
-{
- static css::uno::Sequence< rtl::OUString > aServiceNames;
- if ( aServiceNames.getLength() == 0 )
- {
- aServiceNames.realloc( 1 );
- aServiceNames[ 0 ] = rtl::OUString( "ooo.vba.FileSearch" );
- }
- return aServiceNames;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafilesearch.hxx b/sc/source/ui/vba/vbafilesearch.hxx
deleted file mode 100644
index f89fd11577e4..000000000000
--- a/sc/source/ui/vba/vbafilesearch.hxx
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright IBM Corporation 2009, 2010.
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef SC_VBA_FILESEARCH_HXX
-#define SC_VBA_FILESEARCH_HXX
-
-#include <ooo/vba/XFileSearch.hpp>
-#include <cppuhelper/implbase1.hxx>
-#include <vbahelper/vbahelperinterface.hxx>
-
-namespace css = ::com::sun::star;
-
-typedef InheritedHelperInterfaceImpl1< ooo::vba::XFileSearch > ScVbaFileSearchImpl_BASE;
-
-class ScVbaApplication;
-
-class ScVbaFileSearch : public ScVbaFileSearchImpl_BASE
-{
-private:
- rtl::OUString m_sFileName;
- rtl::OUString m_sLookIn;
- sal_Bool m_bSearchSubFolders;
- sal_Bool m_bMatchTextExactly;
- ScVbaApplication* m_pApplication;
- css::uno::Sequence< rtl::OUString > m_aSearchedFiles;
-
- ::rtl::OUString getInitPath() throw (css::uno::RuntimeException);
-
-public:
- ScVbaFileSearch( ScVbaApplication* pApp, const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext );
- virtual ~ScVbaFileSearch();
-
- // Attributes
- virtual ::rtl::OUString SAL_CALL getFileName() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setFileName(const ::rtl::OUString& _fileName ) throw (css::uno::RuntimeException);
- virtual ::rtl::OUString SAL_CALL getLookIn() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setLookIn(const ::rtl::OUString& _lookIn ) throw (css::uno::RuntimeException);
- virtual sal_Bool SAL_CALL getSearchSubFolders() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setSearchSubFolders( sal_Bool _searchSubFolders ) throw (css::uno::RuntimeException);
- virtual sal_Bool SAL_CALL getMatchTextExactly() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setMatchTextExactly( sal_Bool _matchTextExactly ) throw (css::uno::RuntimeException);
- virtual css::uno::Reference< ::ooo::vba::XFoundFiles > SAL_CALL getFoundFiles() throw (css::uno::RuntimeException);
-
- virtual sal_Int32 SAL_CALL Execute( ) throw (css::uno::RuntimeException);
- virtual void SAL_CALL NewSearch( ) throw (css::uno::RuntimeException);
-
- // XHelperInterface
- virtual rtl::OUString getServiceImplName();
- virtual css::uno::Sequence< rtl::OUString > getServiceNames();
-};
-
-#endif /* SC_VBA_FILESEARCH_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx
index 6509f628edc0..4c5f5f5f5044 100644
--- a/sc/source/ui/vba/vbaname.cxx
+++ b/sc/source/ui/vba/vbaname.cxx
@@ -106,41 +106,78 @@ ScVbaName::setVisible( sal_Bool /*bVisible*/ ) throw (css::uno::RuntimeException
::rtl::OUString
ScVbaName::getValue() throw (css::uno::RuntimeException)
{
- return getValue( formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );
-}
-
-::rtl::OUString
-ScVbaName::getValue(const formula::FormulaGrammar::Grammar eGrammar) throw (css::uno::RuntimeException)
-{
- rtl::OUString sValue = mxNamedRange->getContent();
- ScDocShell* pDocShell = excel::getDocShell( mxModel );
- ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
- String aContent;
- excel::CompileODFFormulaToExcel( pDoc, sValue, aContent, eGrammar );
- if ( aContent.Len() > 0 )
+ ::rtl::OUString sValue = mxNamedRange->getContent();
+ ::rtl::OUString sSheetName = getWorkSheet()->getName();
+ ::rtl::OUString sSegmentation = ::rtl::OUString::createFromAscii( ";" );
+ ::rtl::OUString sNewSegmentation = ::rtl::OUString::createFromAscii( "," );
+ ::rtl::OUString sResult;
+ sal_Int32 nFrom = 0;
+ sal_Int32 nTo = 0;
+ nTo = sValue.indexOf( sSegmentation, nFrom );
+ while ( nTo != -1 )
{
- sValue = aContent;
+ ::rtl::OUString sTmpValue = sValue.copy( nFrom, nTo - nFrom );
+ if ( sTmpValue.toChar() == '$' )
+ {
+ ::rtl::OUString sTmp = sTmpValue.copy( 1 );
+ sTmp = sTmp.replaceAt(0, (sSheetName + ::rtl::OUString::createFromAscii(".")).getLength(), sSheetName + ::rtl::OUString::createFromAscii("!"));
+ sResult += sTmp;
+ sResult += sNewSegmentation;
+ }
+ nFrom = nTo + 1;
+ nTo = sValue.indexOf( sSegmentation, nFrom );
}
- if ( sValue.indexOf('=') != 0 )
+ ::rtl::OUString sTmpValue = sValue.copy( nFrom );
+ if ( sTmpValue.toChar() == '$' )
{
- sValue = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=")) + sValue;
+ ::rtl::OUString sTmp = sTmpValue.copy(1);
+ sTmp = sTmp.replaceAt(0, (sSheetName + ::rtl::OUString::createFromAscii(".")).getLength(), sSheetName + ::rtl::OUString::createFromAscii("!"));
+ sResult += sTmp;
}
- return sValue;
+ if (sResult.indexOf('=') != 0)
+ {
+ sResult = ::rtl::OUString::createFromAscii("=") + sResult;
+ }
+ return sResult;
}
void
ScVbaName::setValue( const ::rtl::OUString & rValue ) throw (css::uno::RuntimeException)
{
+ ::rtl::OUString sSheetName = getWorkSheet()->getName();
::rtl::OUString sValue = rValue;
- ScDocShell* pDocShell = excel::getDocShell( mxModel );
- ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
- String aContent;
- excel::CompileExcelFormulaToODF( pDoc, sValue, aContent );
- if ( aContent.Len() > 0 )
+ ::rtl::OUString sSegmentation = ::rtl::OUString::createFromAscii( "," );
+ ::rtl::OUString sNewSegmentation = ::rtl::OUString::createFromAscii( ";" );
+ ::rtl::OUString sResult;
+ sal_Int32 nFrom = 0;
+ sal_Int32 nTo = 0;
+ if (sValue.indexOf('=') == 0)
{
- sValue = aContent;
+ ::rtl::OUString sTmp = sValue.copy(1);
+ sValue = sTmp;
}
- mxNamedRange->setContent( sValue );
+ nTo = sValue.indexOf( sSegmentation, nFrom );
+ while ( nTo != -1 )
+ {
+ ::rtl::OUString sTmpValue = sValue.copy( nFrom, nTo - nFrom );
+ sTmpValue = sTmpValue.replaceAt(0, (sSheetName + ::rtl::OUString::createFromAscii("!")).getLength(), sSheetName + ::rtl::OUString::createFromAscii("."));
+ if (sTmpValue.copy(0, sSheetName.getLength()).equals(sSheetName))
+ {
+ sTmpValue = ::rtl::OUString::createFromAscii("$") + sTmpValue;
+ }
+ sTmpValue += sNewSegmentation;
+ sResult += sTmpValue;
+ nFrom = nTo + 1;
+ nTo = sValue.indexOf( sSegmentation, nFrom );
+ }
+ ::rtl::OUString sTmpValue = sValue.copy( nFrom );
+ sTmpValue = sTmpValue.replaceAt(0, (sSheetName + ::rtl::OUString::createFromAscii("!")).getLength(), sSheetName + ::rtl::OUString::createFromAscii("."));
+ if (sTmpValue.copy(0, sSheetName.getLength()).equals(sSheetName))
+ {
+ sTmpValue = ::rtl::OUString::createFromAscii("$") + sTmpValue;
+ }
+ sResult += sTmpValue;
+ mxNamedRange->setContent(sResult);
}
::rtl::OUString
@@ -170,7 +207,7 @@ ScVbaName::setRefersToLocal( const ::rtl::OUString & rRefersTo ) throw (css::uno
::rtl::OUString
ScVbaName::getRefersToR1C1() throw (css::uno::RuntimeException)
{
- return getValue( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
+ return getRefersTo();
}
void
@@ -182,7 +219,7 @@ ScVbaName::setRefersToR1C1( const ::rtl::OUString & rRefersTo ) throw (css::uno:
::rtl::OUString
ScVbaName::getRefersToR1C1Local() throw (css::uno::RuntimeException)
{
- return getValue( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
+ return getRefersTo();
}
void
diff --git a/sc/source/ui/vba/vbaname.hxx b/sc/source/ui/vba/vbaname.hxx
index 2159b9ad63d0..c75ea3fbcab9 100644
--- a/sc/source/ui/vba/vbaname.hxx
+++ b/sc/source/ui/vba/vbaname.hxx
@@ -34,7 +34,7 @@
#include <vbahelper/vbahelperinterface.hxx>
-#include <formula/grammar.hxx>
+class ScDocument;
typedef InheritedHelperInterfaceImpl1< ov::excel::XName > NameImpl_BASE;
@@ -47,8 +47,6 @@ class ScVbaName : public NameImpl_BASE
protected:
virtual css::uno::Reference< css::frame::XModel > getModel() { return mxModel; }
virtual css::uno::Reference< ov::excel::XWorksheet > getWorkSheet() throw (css::uno::RuntimeException);
- // Get value by FormulaGrammar, such as FormulaGrammar::GRAM_NATIVE_XL_R1C1
- virtual ::rtl::OUString SAL_CALL getValue(const formula::FormulaGrammar::Grammar eGrammar) throw (css::uno::RuntimeException);
public:
ScVbaName( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XNamedRange >& xName , const css::uno::Reference< css::sheet::XNamedRanges >& xNames , const css::uno::Reference< css::frame::XModel >& xModel );
diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx
index b6cd0a57e126..f704a8da0c4a 100644
--- a/sc/source/ui/vba/vbanames.cxx
+++ b/sc/source/ui/vba/vbanames.cxx
@@ -88,32 +88,6 @@ ScVbaNames::getScDocument()
return pViewData->GetDocument();
}
-void GetRangeOrRefersTo( const css::uno::Any& RefersTo, const uno::Reference< uno::XComponentContext >& xContext, css::uno::Reference< excel::XRange >& xRange, rtl::OUString& sRefersTo )
-{
- if ( RefersTo.getValueTypeClass() == uno::TypeClass_STRING )
- {
- RefersTo >>= sRefersTo;
- }
- else if ( RefersTo.getValueTypeClass() == uno::TypeClass_INTERFACE )
- {
- RefersTo >>= xRange;
- }
- else if ( RefersTo.hasValue() )
- {
- uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext );
- try
- {
- if ( xConverter.is() )
- {
- uno::Any aConverted = xConverter->convertTo( RefersTo, getCppuType((rtl::OUString*)0) );
- aConverted >>= sRefersTo;
- }
- }
- catch( uno::Exception& )
- {
- }
- }
-}
css::uno::Any
ScVbaNames::Add( const css::uno::Any& Name ,
@@ -128,9 +102,7 @@ ScVbaNames::Add( const css::uno::Any& Name ,
const css::uno::Any& RefersToR1C1,
const css::uno::Any& RefersToR1C1Local ) throw (css::uno::RuntimeException)
{
- rtl::OUString sSheetName;
rtl::OUString sName;
- rtl::OUString sRefersTo;
uno::Reference< excel::XRange > xRange;
if ( Name.hasValue() )
Name >>= sName;
@@ -138,12 +110,6 @@ ScVbaNames::Add( const css::uno::Any& Name ,
NameLocal >>= sName;
if ( !sName.isEmpty() )
{
- sal_Int32 nTokenIndex = sName.indexOf('!');
- if ( nTokenIndex >= 0 )
- {
- sSheetName = sName.copy( 0, nTokenIndex );
- sName = sName.copy( nTokenIndex + 1 );
- }
if ( !ScRangeData::IsNameValid( sName , getScDocument() ) )
{
::rtl::OUString sResult ;
@@ -156,22 +122,20 @@ ScVbaNames::Add( const css::uno::Any& Name ,
sResult = sName.copy( nIndex );
sName = sResult ;
if ( !ScRangeData::IsNameValid( sName , getScDocument() ) )
- throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This Name is a invalid .")), uno::Reference< uno::XInterface >() );
+ throw uno::RuntimeException( "This Name is not valid .",
+ uno::Reference< uno::XInterface >() );
}
}
if ( RefersTo.hasValue() || RefersToR1C1.hasValue() || RefersToR1C1Local.hasValue() )
{
if ( RefersTo.hasValue() )
- GetRangeOrRefersTo( RefersTo, mxContext, xRange, sRefersTo );
+ RefersTo >>= xRange;
if ( RefersToR1C1.hasValue() )
- GetRangeOrRefersTo( RefersToR1C1, mxContext, xRange, sRefersTo );
+ RefersToR1C1 >>= xRange;
if ( RefersToR1C1Local.hasValue() )
- GetRangeOrRefersTo( RefersToR1C1Local, mxContext, xRange, sRefersTo );
+ RefersToR1C1Local >>= xRange;
}
- String aContent;
- table::CellAddress aPosition;
- RangeType nType = RT_NAME;
if ( xRange.is() )
{
ScVbaRange* pRange = dynamic_cast< ScVbaRange* >( xRange.get() );
@@ -184,37 +148,20 @@ ScVbaNames::Add( const css::uno::Any& Name ,
ScAddress aPos( static_cast< SCCOL >( aAddr.StartColumn ) , static_cast< SCROW >( aAddr.StartRow ) , static_cast< SCTAB >(aAddr.Sheet ) );
uno::Any xAny2 ;
String sRangeAdd = xRange->Address( xAny2, xAny2 , xAny2 , xAny2, xAny2 );
- aContent += rtl::OUString("$");
- aContent += UniString(xRange->getWorksheet()->getName());
- aContent += rtl::OUString(".");
- aContent += sRangeAdd;
- aPosition = table::CellAddress( aAddr.Sheet , aAddr.StartColumn , aAddr.StartRow );
- }
- else
- {
- ScDocShell* pDocShell = excel::getDocShell( mxModel );
- ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
- excel::CompileExcelFormulaToODF( pDoc, sRefersTo, aContent );
- if ( aContent.Len() == 0 )
+ String sTmp;
+ sTmp += "$";
+ sTmp += UniString(xRange->getWorksheet()->getName());
+ sTmp += ".";
+ sTmp += sRangeAdd;
+ if ( mxNames.is() )
{
- aContent = sRefersTo;
+ RangeType nType = RT_NAME;
+ table::CellAddress aCellAddr( aAddr.Sheet , aAddr.StartColumn , aAddr.StartRow );
+ if ( mxNames->hasByName( sName ) )
+ mxNames->removeByName(sName);
+ mxNames->addNewByName( sName , rtl::OUString(sTmp) , aCellAddr , (sal_Int32)nType);
}
}
-
- uno::Reference< sheet::XNamedRange > xNewNamedRange;
- if ( mxNames.is() )
- {
- if ( mxNames->hasByName( sName ) )
- {
- mxNames->removeByName( sName );
- }
- mxNames->addNewByName( sName, rtl::OUString( aContent ), aPosition, (sal_Int32) nType );
- xNewNamedRange = uno::Reference< sheet::XNamedRange >( mxNames->getByName( sName ), uno::UNO_QUERY );
- }
- if ( xNewNamedRange.is() )
- {
- return uno::makeAny( uno::Reference< excel::XName >( new ScVbaName( mxParent, mxContext, xNewNamedRange ,mxNames , mxModel ) ) );
- }
return css::uno::Any();
}
diff --git a/sc/source/ui/vba/vbaoleobject.cxx b/sc/source/ui/vba/vbaoleobject.cxx
index 1f26ccf986a3..1a6055103d1a 100644
--- a/sc/source/ui/vba/vbaoleobject.cxx
+++ b/sc/source/ui/vba/vbaoleobject.cxx
@@ -56,7 +56,7 @@ ScVbaOLEObject::ScVbaOLEObject( const uno::Reference< XHelperInterface >& xParen
uno::Reference< uno::XInterface > SAL_CALL
ScVbaOLEObject::getObject() throw (uno::RuntimeException)
{
- return uno::Reference< uno::XInterface >( m_xControl, uno::UNO_QUERY_THROW );
+ return uno::Reference< uno::XInterface >( m_xControlShape, uno::UNO_QUERY_THROW );
}
sal_Bool SAL_CALL
diff --git a/sc/source/ui/vba/vbapagebreaks.cxx b/sc/source/ui/vba/vbapagebreaks.cxx
index b4f2d4eeac6e..6ac97b443f82 100644
--- a/sc/source/ui/vba/vbapagebreaks.cxx
+++ b/sc/source/ui/vba/vbapagebreaks.cxx
@@ -116,13 +116,10 @@ sal_Int32 SAL_CALL RangePageBreaks::getCount( ) throw (uno::RuntimeException)
for( sal_Int32 i=0; i<nLength; i++ )
{
sal_Int32 nPos = aTablePageBreakData[i].Position;
-
- // All page breaks before the used range should be counted.
- // And the page break at the end of the used range also should be counted.
- if( nPos <= nUsedEnd + 1 )
- nCount++;
- else
+ if( nPos > nUsedEnd )
return nCount;
+ if( nPos >= nUsedStart )
+ nCount++;
}
return nCount;
@@ -148,15 +145,26 @@ uno::Any SAL_CALL RangePageBreaks::getByIndex( sal_Int32 Index ) throw (lang::In
sheet::TablePageBreakData RangePageBreaks::getTablePageBreakData( sal_Int32 nAPIItemIndex ) throw ( script::BasicErrorException, uno::RuntimeException)
{
+ sal_Int32 index = -1;
sheet::TablePageBreakData aTablePageBreakData;
uno::Reference< excel::XWorksheet > xWorksheet( mxParent, uno::UNO_QUERY_THROW );
uno::Reference< excel::XRange > xRange = xWorksheet->getUsedRange();
+ sal_Int32 nUsedStart = getAPIStartofRange( xRange );
+ sal_Int32 nUsedEnd = getAPIEndIndexofRange( xRange, nUsedStart );
uno::Sequence<sheet::TablePageBreakData> aTablePageBreakDataList = getAllPageBreaks();
sal_Int32 nLength = aTablePageBreakDataList.getLength();
- // No need to filter the page break. All page breaks before the used range are counted.
- if ( nAPIItemIndex < nLength && nAPIItemIndex>=0 )
- aTablePageBreakData = aTablePageBreakDataList[nAPIItemIndex];
+ for( sal_Int32 i=0; i<nLength; i++ )
+ {
+ aTablePageBreakData = aTablePageBreakDataList[i];
+ sal_Int32 nPos = aTablePageBreakData.Position;
+ if( nPos >= nUsedStart )
+ index++;
+ if( nPos > nUsedEnd )
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ if( index == nAPIItemIndex )
+ return aTablePageBreakData;
+ }
return aTablePageBreakData;
}
diff --git a/sc/source/ui/vba/vbapagesetup.cxx b/sc/source/ui/vba/vbapagesetup.cxx
index fe0403c056b9..b726d54aa035 100644
--- a/sc/source/ui/vba/vbapagesetup.cxx
+++ b/sc/source/ui/vba/vbapagesetup.cxx
@@ -39,8 +39,6 @@
#include <ooo/vba/excel/XlOrder.hpp>
#include <ooo/vba/excel/Constants.hpp>
#include <i18nutil/paper.hxx>
-#include <editeng/paperinf.hxx>
-#include <ooo/vba/excel/XlPaperSize.hpp>
#include <sal/macros.h>
using namespace ::com::sun::star;
@@ -629,103 +627,4 @@ ScVbaPageSetup::getServiceNames()
return aServiceNames;
}
-struct PaperSizeMap
-{
- Paper ePaper;
- sal_Int32 xlPaper;
-};
-
-static PaperSizeMap paperSizeMappings[] =
-{
- { PAPER_A3, ooo::vba::excel::XlPaperSize::xlPaperA3 },
- { PAPER_A4, ooo::vba::excel::XlPaperSize::xlPaperA4 },
- { PAPER_A5, ooo::vba::excel::XlPaperSize::xlPaperA5 },
- { PAPER_B4_ISO, ooo::vba::excel::XlPaperSize::xlPaperB4 },
- { PAPER_B5_ISO, ooo::vba::excel::XlPaperSize::xlPaperB5 },
- { PAPER_LETTER, ooo::vba::excel::XlPaperSize::xlPaperLetter },
- { PAPER_LEGAL, ooo::vba::excel::XlPaperSize::xlPaperLegal },
- { PAPER_TABLOID, ooo::vba::excel::XlPaperSize::xlPaperTabloid },
- { PAPER_USER, ooo::vba::excel::XlPaperSize::xlPaperUser },
- { PAPER_B6_ISO, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeB6 },
- { PAPER_ENV_C4, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC4 },
- { PAPER_ENV_C5, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC5 },
- { PAPER_ENV_C6, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC6 },
- { PAPER_ENV_C65, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC65 },
- { PAPER_ENV_DL, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeDL },
- { PAPER_C, ooo::vba::excel::XlPaperSize::xlPaperCsheet },
- { PAPER_D, ooo::vba::excel::XlPaperSize::xlPaperDsheet },
- { PAPER_E, ooo::vba::excel::XlPaperSize::xlPaperEsheet },
- { PAPER_ENV_MONARCH, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeMonarch },
- { PAPER_ENV_PERSONAL, ooo::vba::excel::XlPaperSize::xlPaperEnvelopePersonal },
- { PAPER_ENV_9, ooo::vba::excel::XlPaperSize::xlPaperEnvelope9 },
- { PAPER_ENV_10, ooo::vba::excel::XlPaperSize::xlPaperEnvelope10 },
- { PAPER_ENV_11, ooo::vba::excel::XlPaperSize::xlPaperEnvelope11 },
- { PAPER_ENV_12, ooo::vba::excel::XlPaperSize::xlPaperEnvelope12 }
-};
-
-static const int nMapSize = SAL_N_ELEMENTS(paperSizeMappings);
-
-sal_Int32 PaperSizeOOoToExcel(Paper ePaper)
-{
- sal_Int32 nPaperSize = ooo::vba::excel::XlPaperSize::xlPaperUser;
-
- for (int i = 0; i < nMapSize; i++)
- {
- if (ePaper == paperSizeMappings[i].ePaper)
- {
- nPaperSize = paperSizeMappings[i].xlPaper;
- break;
- }
- }
-
- return nPaperSize;
-}
-
-sal_Int32 SAL_CALL ScVbaPageSetup::getPaperSize() throw (css::uno::RuntimeException)
-{
- com::sun::star::awt::Size size;
- Paper ePaper = PAPER_USER;
-
- try
- {
- uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( "Size"));
- aValue >>= size;
- ePaper = SvxPaperInfo::GetSvxPaper( Size(size.Width, size.Height), MAP_100TH_MM, true);
- }
- catch( uno::Exception& )
- {
- }
-
- return PaperSizeOOoToExcel(ePaper);
-}
-
-Paper PaperSizeExcelToOOo( sal_Int32 xlPaper)
-{
- Paper ePaper = PAPER_USER;
-
- for (int i = 0; i < nMapSize; i++)
- {
- if (xlPaper == paperSizeMappings[i].xlPaper)
- {
- ePaper = paperSizeMappings[i].ePaper;
- break;
- }
- }
-
- return ePaper;
-}
-void SAL_CALL ScVbaPageSetup::setPaperSize( sal_Int32 paperSize) throw (css::uno::RuntimeException)
-{
- Paper ePaper = PaperSizeExcelToOOo( paperSize );
-
- try
- {
- Size size1 = SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM );
- com::sun::star::awt::Size size(size1.Width(), size1.Height());
- mxPageProps->setPropertyValue( rtl::OUString( "Size"), uno::makeAny( size ));
- }
- catch( uno::Exception& )
- {
- }
-}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapagesetup.hxx b/sc/source/ui/vba/vbapagesetup.hxx
index fb234200aec1..16542c1fe74c 100644
--- a/sc/source/ui/vba/vbapagesetup.hxx
+++ b/sc/source/ui/vba/vbapagesetup.hxx
@@ -83,8 +83,6 @@ public:
virtual void SAL_CALL setCenterHorizontally( sal_Bool centerHorizontally ) throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL getPrintHeadings() throw (css::uno::RuntimeException);
virtual void SAL_CALL setPrintHeadings( sal_Bool printHeadings ) throw (css::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getPaperSize() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setPaperSize( sal_Int32 paperSize ) throw (css::uno::RuntimeException);
// XHelperInterface
virtual rtl::OUString getServiceImplName();
diff --git a/sc/source/ui/vba/vbapivotcache.cxx b/sc/source/ui/vba/vbapivotcache.cxx
index ff50c7a8aeb1..fc83d6a3a2dd 100644
--- a/sc/source/ui/vba/vbapivotcache.cxx
+++ b/sc/source/ui/vba/vbapivotcache.cxx
@@ -35,17 +35,6 @@ ScVbaPivotCache::ScVbaPivotCache( const uno::Reference< XHelperInterface >& xPar
{
}
-sal_Int32
-ScVbaPivotCache::getMissingItemsLimit() throw (css::uno::RuntimeException)
-{
- return -1;
-}
-
-void
-ScVbaPivotCache::setMissingItemsLimit( sal_Int32 /*aValue*/ ) throw ( css::uno::RuntimeException)
-{
-}
-
void SAL_CALL
ScVbaPivotCache::Refresh() throw (css::uno::RuntimeException)
{
diff --git a/sc/source/ui/vba/vbapivotcache.hxx b/sc/source/ui/vba/vbapivotcache.hxx
index 44f10459a158..937d58ceb445 100644
--- a/sc/source/ui/vba/vbapivotcache.hxx
+++ b/sc/source/ui/vba/vbapivotcache.hxx
@@ -42,9 +42,6 @@ class ScVbaPivotCache : public PivotCacheImpl_BASE
public:
ScVbaPivotCache( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XDataPilotTable >& xTable );
- virtual ::sal_Int32 SAL_CALL getMissingItemsLimit() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setMissingItemsLimit( ::sal_Int32 aValue ) throw ( css::uno::RuntimeException);
-
virtual void SAL_CALL Refresh() throw (css::uno::RuntimeException);
// XHelperInterface
virtual rtl::OUString getServiceImplName();
diff --git a/sc/source/ui/vba/vbaquerytable.cxx b/sc/source/ui/vba/vbaquerytable.cxx
deleted file mode 100644
index aa4f8d01e62a..000000000000
--- a/sc/source/ui/vba/vbaquerytable.cxx
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright IBM Corporation 2009, 2010.
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "vbaquerytable.hxx"
-#include "document.hxx"
-#include "docsh.hxx"
-#include "sfx2/lnkbase.hxx"
-#include "sfx2/linkmgr.hxx"
-#include "arealink.hxx"
-#include "vbarange.hxx"
-
-using namespace com::sun::star;
-
-
-ScVbaQueryTable::ScVbaQueryTable(const css::uno::Reference< ov::XHelperInterface >& /*xParent*/,
- const css::uno::Reference< css::uno::XComponentContext > & /*xContext*/,
- ScDocument *pDocument ,
- ScVbaRange *pParent
- )
-//:QueryTable_Base(xParent, xContext)
-{
- m_pDocument = pDocument;
- m_pParent = pParent;
-}
-
-ScVbaQueryTable::~ScVbaQueryTable()
-{
-
-}
-
-::sal_Bool SAL_CALL
-ScVbaQueryTable::Refresh( const ::com::sun::star::uno::Any& /*aBackgroundQuery*/ ) throw (::com::sun::star::uno::RuntimeException)
-{
-
- //Get parent Info
- SCROW nRow = m_pParent->getRow();
- SCCOL nClm = m_pParent->getColumn();
- SCTAB nTab = m_pParent->getWorksheet()->getIndex() - 1; //The vba index begin from 1.
- ScAddress crrRngAddr(nClm, nRow, nTab);
-
- //Get link info
- sfx2::LinkManager *pLinkMng = m_pDocument->GetLinkManager();
- const ::sfx2::SvBaseLinks &rLinks = pLinkMng->GetLinks();
- sal_uInt16 nCount = rLinks.size();
-
- for (sal_uInt16 i=0; i<nCount; i++)
- {
- ::sfx2::SvBaseLink* pBase = *rLinks[i];
- if (pBase->ISA(ScAreaLink))
- {
-
- ScAreaLink *pAreaLink = (ScAreaLink *)pBase;
- const ScRange &destRange = pAreaLink->GetDestArea();
- if (destRange.In(crrRngAddr))
- {
- pBase->Update();
- }
- }
- }
-
- return sal_True;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaquerytable.hxx b/sc/source/ui/vba/vbaquerytable.hxx
deleted file mode 100644
index f7deea7014cb..000000000000
--- a/sc/source/ui/vba/vbaquerytable.hxx
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright IBM Corporation 2009, 2010.
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef SC_VBA_QUERYTABLE_HXX
-#define SC_VBA_QUERYTABLE_HXX
-
-
-#include <ooo/vba/excel/XQueryTable.hpp>
-#include "vbahelper/vbahelperinterface.hxx"
-
-using namespace ::ooo::vba;
-typedef ::cppu::WeakImplHelper1<excel::XQueryTable> QueryTable_Base;
-
-class ScDocument;
-class ScVbaRange;
-
-class ScVbaQueryTable : public QueryTable_Base
-{
-private:
- ScDocument *m_pDocument;
- ScVbaRange *m_pParent;
-public:
- ScVbaQueryTable(const css::uno::Reference< ov::XHelperInterface >& xParent,
- const css::uno::Reference< css::uno::XComponentContext > & xContext,
- ScDocument *pDocument = NULL,
- ScVbaRange *pParent = NULL
- );
- ~ScVbaQueryTable();
- virtual ::sal_Bool SAL_CALL Refresh( const ::com::sun::star::uno::Any& aBackgroundQuery )
- throw (::com::sun::star::uno::RuntimeException);
-
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 34578e3c6f6f..62b450486b1b 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -48,6 +48,7 @@
#include <com/sun/star/sheet/XCellSeries.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <com/sun/star/sheet/XSpreadsheetView.hpp>
#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
@@ -56,7 +57,6 @@
#include <com/sun/star/sheet/XSheetCellCursor.hpp>
#include <com/sun/star/sheet/XArrayFormulaRange.hpp>
#include <com/sun/star/sheet/XNamedRange.hpp>
-#include <com/sun/star/sheet/XNamedRanges.hpp>
#include <com/sun/star/sheet/XPrintAreas.hpp>
#include <com/sun/star/sheet/XCellRangesQuery.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -99,12 +99,6 @@
#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
#include <com/sun/star/sheet/XSheetAnnotations.hpp>
-#include <com/sun/star/sheet/XDataPilotTable.hpp>
-#include <com/sun/star/sheet/XDataPilotTable2.hpp>
-#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
-#include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
-#include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
-
#include <ooo/vba/excel/XlPasteSpecialOperation.hpp>
#include <ooo/vba/excel/XlPasteType.hpp>
#include <ooo/vba/excel/Constants.hpp>
@@ -130,8 +124,6 @@
#include <ooo/vba/excel/XlSpecialCellsValue.hpp>
#include <ooo/vba/excel/XlConsolidationFunction.hpp>
#include <ooo/vba/excel/XlSearchDirection.hpp>
-#include <ooo/vba/excel/XlColumnDataType.hpp>
-#include <ooo/vba/excel/XlFilterAction.hpp>
#include <scitems.hxx>
#include <svl/srchitem.hxx>
@@ -149,7 +141,6 @@
#include <sc.hrc>
#include <globstr.hrc>
#include <unonames.hxx>
-#include <tools/stream.hxx>
#include "vbaapplication.hxx"
#include "vbafont.hxx"
@@ -161,13 +152,8 @@
#include "vbavalidation.hxx"
#include "vbahyperlinks.hxx"
-#include "vbapivottable.hxx"
-
-#include "asciiopt.hxx"
-#include "impex.hxx"
#include "tabvwsh.hxx"
#include "rangelst.hxx"
-#include "rangenam.hxx"
#include "convuno.hxx"
#include "compiler.hxx"
#include "attrib.hxx"
@@ -184,8 +170,6 @@
#include "vbaglobals.hxx"
#include "vbastyle.hxx"
-#include "vbaname.hxx"
-#include "vbanames.hxx"
#include <vector>
#include <vbahelper/vbacollectionimpl.hxx>
// begin test includes
@@ -408,6 +392,55 @@ ScVbaRangeAreas::createCollectionObject( const uno::Any& aSource )
return lcl_makeRange( mxParent, mxContext, aSource, mbIsRows, mbIsColumns );
}
+// assume that xIf is infact a ScCellRangesBase
+ScDocShell*
+getDocShellFromIf( const uno::Reference< uno::XInterface >& xIf ) throw ( uno::RuntimeException )
+{
+ ScCellRangesBase* pUno = ScCellRangesBase::getImplementation( xIf );
+ if ( !pUno )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access underlying uno range object" ) ), uno::Reference< uno::XInterface >() );
+ return pUno->GetDocShell();
+}
+
+ScDocShell*
+getDocShellFromRange( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException )
+{
+ // need the ScCellRangesBase to get docshell
+ uno::Reference< uno::XInterface > xIf( xRange );
+ return getDocShellFromIf(xIf );
+}
+
+ScDocShell*
+getDocShellFromRanges( const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges ) throw ( uno::RuntimeException )
+{
+ // need the ScCellRangesBase to get docshell
+ uno::Reference< uno::XInterface > xIf( xRanges );
+ return getDocShellFromIf(xIf );
+}
+
+uno::Reference< frame::XModel > getModelFromXIf( const uno::Reference< uno::XInterface >& xIf ) throw ( uno::RuntimeException )
+{
+ ScDocShell* pDocShell = getDocShellFromIf(xIf );
+ return pDocShell->GetModel();
+}
+
+uno::Reference< frame::XModel > getModelFromRange( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException )
+{
+ // the XInterface for getImplementation can be any derived interface, no need for queryInterface
+ uno::Reference< uno::XInterface > xIf( xRange );
+ return getModelFromXIf( xIf );
+}
+
+ScDocument*
+getDocumentFromRange( const uno::Reference< table::XCellRange >& xRange )
+{
+ ScDocShell* pDocShell = getDocShellFromRange( xRange );
+ if ( !pDocShell )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access underlying docshell from uno range object" ) ), uno::Reference< uno::XInterface >() );
+ ScDocument* pDoc = pDocShell->GetDocument();
+ return pDoc;
+}
+
ScDocument*
ScVbaRange::getScDocument() throw (uno::RuntimeException)
{
@@ -415,9 +448,9 @@ ScVbaRange::getScDocument() throw (uno::RuntimeException)
{
uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
uno::Reference< table::XCellRange > xRange( xIndex->getByIndex( 0 ), uno::UNO_QUERY_THROW );
- return excel::GetDocumentFromRange( xRange );
+ return getDocumentFromRange( xRange );
}
- return excel::GetDocumentFromRange( mxRange );
+ return getDocumentFromRange( mxRange );
}
ScDocShell*
@@ -427,9 +460,9 @@ ScVbaRange::getScDocShell() throw (uno::RuntimeException)
{
uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
uno::Reference< table::XCellRange > xRange( xIndex->getByIndex( 0 ), uno::UNO_QUERY_THROW );
- return excel::GetDocShellFromRange( xRange );
+ return getDocShellFromRange( xRange );
}
- return excel::GetDocShellFromRange( mxRange );
+ return getDocShellFromRange( mxRange );
}
ScVbaRange* ScVbaRange::getImplementation( const uno::Reference< excel::XRange >& rxRange )
@@ -475,7 +508,7 @@ class NumFormatHelper
public:
NumFormatHelper( const uno::Reference< table::XCellRange >& xRange )
{
- mxSupplier.set( excel::GetModelFromRange( xRange ), uno::UNO_QUERY_THROW );
+ mxSupplier.set( getModelFromRange( xRange ), uno::UNO_QUERY_THROW );
mxRangeProps.set( xRange, uno::UNO_QUERY_THROW);
mxFormats = mxSupplier->getNumberFormats();
}
@@ -758,15 +791,7 @@ CellValueSetter::processValue( const uno::Any& aValue, const uno::Reference< tab
{
double nDouble = 0.0;
if ( aValue >>= nDouble )
- {
xCell->setValue( nDouble );
- uno::Reference< table::XCellRange > xRange( xCell, uno::UNO_QUERY_THROW );
- NumFormatHelper cellNumFormat( xRange );
- if ( cellNumFormat.isBooleanType() )
- {
- cellNumFormat.setNumberFormat( util::NumberFormat::NUMBER );
- }
- }
else
isExtracted = false;
break;
@@ -1300,7 +1325,7 @@ uno::Reference< sheet::XSheetCellRangeContainer > lclExpandToMerged( const uno::
ScUnoConversion::FillScRange( aScRange, aRangeAddr );
aScRanges.Append( aScRange );
}
- return new ScCellRangesObj( excel::GetDocShellFromRanges( rxCellRanges ), aScRanges );
+ return new ScCellRangesObj( getDocShellFromRanges( rxCellRanges ), aScRanges );
}
void lclExpandAndMerge( const uno::Reference< table::XCellRange >& rxCellRange, bool bMerge ) throw (uno::RuntimeException)
@@ -1346,7 +1371,7 @@ util::TriState lclGetMergedState( const uno::Reference< table::XCellRange >& rxC
of a merged range is part of this range are not covered. */
ScRange aScRange;
ScUnoConversion::FillScRange( aScRange, aRangeAddr );
- bool bHasMerged = excel::GetDocumentFromRange( rxCellRange )->HasAttrib( aScRange, HASATTR_MERGED | HASATTR_OVERLAPPED );
+ bool bHasMerged = getDocumentFromRange( rxCellRange )->HasAttrib( aScRange, HASATTR_MERGED | HASATTR_OVERLAPPED );
return bHasMerged ? util::TriState_INDETERMINATE : util::TriState_NO;
}
@@ -1363,29 +1388,6 @@ ScVbaRange::getRangeObjectForName(
return getRangeForName( xContext, sRangeName, pDocSh, refAddr, eConv );
}
-table::CellAddress ScVbaRange::getLeftUpperCellAddress()
-{
- table::CellAddress aCellAddress;
- uno::Reference< table::XCellRange > xCellRange = mxRange;
- if ( mxRanges.is() && m_Areas.is() && m_Areas->getCount() > 1 )
- {
- uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY );
- if ( xIndex.is() && xIndex->getCount() > 0 )
- {
- xCellRange.set( xIndex->getByIndex( 0 ), uno::UNO_QUERY );
- }
- }
- if ( xCellRange.is() )
- {
- uno::Reference< sheet::XCellAddressable > xCellAddr( xCellRange->getCellByPosition( 0, 0 ), uno::UNO_QUERY );
- if ( xCellAddr.is() )
- {
- aCellAddress = xCellAddr->getCellAddress();
- }
- }
- return aCellAddress;
-}
-
table::CellRangeAddress getCellRangeAddressForVBARange( const uno::Any& aParam, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1) throw ( uno::RuntimeException )
{
uno::Reference< table::XCellRange > xRangeParam;
@@ -1412,14 +1414,7 @@ table::CellRangeAddress getCellRangeAddressForVBARange( const uno::Any& aParam,
uno::Reference< excel::XRange > xRange;
aParam >>= xRange;
if ( xRange.is() )
- {
- ScVbaRange* pRange = dynamic_cast< ScVbaRange* >( xRange.get() );
- if ( pRange && pDocSh && pRange->getScDocument() != pDocSh->GetDocument() )
- {
- throw uno::RuntimeException( rtl::OUString( "Invalid range" ), uno::Reference< uno::XInterface >() );
- }
xRange->getCellRange() >>= xRangeParam;
- }
break;
}
default:
@@ -1432,7 +1427,7 @@ uno::Reference< XCollection >
lcl_setupBorders( const uno::Reference< excel::XRange >& xParentRange, const uno::Reference<uno::XComponentContext>& xContext, const uno::Reference< table::XCellRange >& xRange ) throw( uno::RuntimeException )
{
uno::Reference< XHelperInterface > xParent( xParentRange, uno::UNO_QUERY_THROW );
- ScDocument* pDoc = excel::GetDocumentFromRange(xRange);
+ ScDocument* pDoc = getDocumentFromRange(xRange);
if ( !pDoc )
throw uno::RuntimeException( rtl::OUString( "Failed to access document from shell" ), uno::Reference< uno::XInterface >() );
ScVbaPalette aPalette( pDoc->GetDocumentShell() );
@@ -1440,21 +1435,8 @@ lcl_setupBorders( const uno::Reference< excel::XRange >& xParentRange, const uno
return borders;
}
-void lcl_NotifyRangeChanges( const uno::Reference< frame::XModel >& xModel, ScCellRangesBase* pUnoRangesBase )
-{
- if ( xModel.is() && pUnoRangesBase )
- {
- ScModelObj* pModelObj = ScModelObj::getImplementation( xModel );
- const ScRangeList& aCellRanges = pUnoRangesBase->GetRangeList();
- if ( pModelObj && pModelObj->HasChangesListeners() )
- {
- pModelObj->NotifyChanges( ::rtl::OUString( "cell-change" ), aCellRanges );
- }
- }
-}
-
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( false ), mbIsColumns( false )
+ uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : ScVbaRange_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext, getXSomethingFromArgs< beans::XPropertySet >( args, 1, false ), getModelFromXIf( getXSomethingFromArgs< uno::XInterface >( args, 1 ) ), true ), mbIsRows( false ), mbIsColumns( false )
{
mxRange.set( mxPropertySet, uno::UNO_QUERY );
mxRanges.set( mxPropertySet, uno::UNO_QUERY );
@@ -1471,7 +1453,7 @@ ScVbaRange::ScVbaRange( uno::Sequence< uno::Any> const & args,
}
ScVbaRange::ScVbaRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange, sal_Bool bIsRows, sal_Bool bIsColumns ) throw( lang::IllegalArgumentException )
-: ScVbaRange_BASE( xParent, xContext, uno::Reference< beans::XPropertySet >( xRange, uno::UNO_QUERY_THROW ), excel::GetModelFromRange( xRange), true ), mxRange( xRange ),
+: ScVbaRange_BASE( xParent, xContext, uno::Reference< beans::XPropertySet >( xRange, uno::UNO_QUERY_THROW ), getModelFromRange( xRange), true ), mxRange( xRange ),
mbIsRows( bIsRows ),
mbIsColumns( bIsColumns )
{
@@ -1486,7 +1468,7 @@ ScVbaRange::ScVbaRange( const uno::Reference< XHelperInterface >& xParent, const
}
ScVbaRange::ScVbaRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges, sal_Bool bIsRows, sal_Bool bIsColumns ) throw ( lang::IllegalArgumentException )
-: ScVbaRange_BASE( xParent, xContext, uno::Reference< beans::XPropertySet >( xRanges, uno::UNO_QUERY_THROW ), excel::GetModelFromRange( uno::Reference< uno::XInterface >( xRanges, uno::UNO_QUERY_THROW ) ), true ), mxRanges( xRanges ),mbIsRows( bIsRows ), mbIsColumns( bIsColumns )
+: ScVbaRange_BASE( xParent, xContext, uno::Reference< beans::XPropertySet >( xRanges, uno::UNO_QUERY_THROW ), getModelFromXIf( uno::Reference< uno::XInterface >( xRanges, uno::UNO_QUERY_THROW ) ), true ), mxRanges( xRanges ),mbIsRows( bIsRows ), mbIsColumns( bIsColumns )
{
uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
@@ -1525,77 +1507,6 @@ ScVbaRange::visitArray( ArrayVisitor& visitor )
}
}
-uno::Any SAL_CALL ScVbaRange::getName() throw (uno::RuntimeException)
-{
- uno::Reference< excel::XName > xName;
-
- ScDocShell* pDocShell = getScDocShell();
- uno::Reference< frame::XModel > xModel = pDocShell ? pDocShell->GetModel() : NULL;
- if ( !xModel.is() )
- {
- throw uno::RuntimeException( rtl::OUString( "Invalid document" ), uno::Reference< uno::XInterface >() );
- }
- uno::Reference< beans::XPropertySet > xPropertySet( xModel, uno::UNO_QUERY_THROW );
- uno::Reference< sheet::XNamedRanges > xNamedRanges( xPropertySet->getPropertyValue( rtl::OUString("NamedRanges")) , uno::UNO_QUERY_THROW );
-
- uno::Reference< excel::XNames > xNames( new ScVbaNames( uno::Reference< XHelperInterface >(), mxContext , xNamedRanges , xModel ) );
- sal_Int32 nCount = xNames->getCount();
- ScCellRangesBase* pUnoRangesBase = getCellRangesBase();
- if ( pUnoRangesBase && nCount > 0 )
- {
- ScRangeList aRangeList = pUnoRangesBase->GetRangeList();
- for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
- {
- uno::Reference< excel::XName > xTmpName( xNames->Item( uno::makeAny( nIndex + 1 ), uno::Any() ), uno::UNO_QUERY );
- if ( xTmpName.is() )
- {
- try
- {
- uno::Reference< excel::XRange > xRange = xTmpName->getRefersToRange();
- if ( xRange.is() )
- {
- ScVbaRange* pRange = dynamic_cast< ScVbaRange* >( xRange.get() );
- ScCellRangesBase* pCurRangesBase = pRange ? pRange->getCellRangesBase() : NULL;
- if ( pCurRangesBase && aRangeList == pCurRangesBase->GetRangeList() )
- {
- xName = xTmpName;
- break;
- }
- }
- }
- catch (const uno::Exception&)
- {
- }
- }
- }
- }
-
- return uno::makeAny( xName );
-}
-
-void
-ScVbaRange::setName( const uno::Any& aName ) throw (uno::RuntimeException)
-{
- uno::Reference< excel::XName > xName;
-
- ScDocShell* pDocShell = getScDocShell();
- uno::Reference< frame::XModel > xModel = pDocShell ? pDocShell->GetModel() : NULL;
- if ( !xModel.is() )
- {
- throw uno::RuntimeException( rtl::OUString( "Invalid document" ), uno::Reference< uno::XInterface >() );
- }
- uno::Reference< beans::XPropertySet > xPropertySet( xModel, uno::UNO_QUERY_THROW );
- uno::Reference< sheet::XNamedRanges > xNamedRanges( xPropertySet->getPropertyValue( rtl::OUString("NamedRanges")) , uno::UNO_QUERY_THROW );
-
- uno::Reference< excel::XNames > xNames( new ScVbaNames( uno::Reference< XHelperInterface >(), mxContext , xNamedRanges , xModel ) );
-
- uno::Any aDummy;
- //uno::Any aRefersTo;
- // aRefersTo <<= uno::Reference< excel::XRange >(this, uno::UNO_QUERY);
- xNames->Add(aName, getCellRange(), aDummy, aDummy, aDummy, aDummy,
- aDummy, aDummy, aDummy, aDummy, aDummy);
-}
-
uno::Any
ScVbaRange::getValue( ValueGetter& valueGetter) throw (uno::RuntimeException)
{
@@ -1685,11 +1596,6 @@ ScVbaRange::setValue( const uno::Any &aValue ) throw (uno::RuntimeException)
}
CellValueSetter valueSetter( aValue );
setValue( aValue, valueSetter, true );
-
-#if 0 // TODO: Noel, do we still need this?
- // Fires the range change event.
- lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
-#endif
}
void SAL_CALL
@@ -1698,11 +1604,6 @@ ScVbaRange::Clear() throw (uno::RuntimeException)
using namespace ::com::sun::star::sheet::CellFlags;
sal_Int32 nFlags = VALUE | DATETIME | STRING | FORMULA | HARDATTR | EDITATTR | FORMATTED;
ClearContents( nFlags, true );
-
-#if 0 // TODO: do we still need this?
- // Fires the range change event.
- lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
-#endif
}
//helper ClearContent
@@ -1747,11 +1648,6 @@ ScVbaRange::ClearContents() throw (uno::RuntimeException)
sheet::CellFlags::STRING | sheet::CellFlags::DATETIME |
sheet::CellFlags::FORMULA );
ClearContents( nClearFlags, true );
-
-#if 0 // TODO: do we still need this?
- // Fires the range change event.
- lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
-#endif
}
void SAL_CALL
@@ -1760,11 +1656,6 @@ ScVbaRange::ClearFormats() throw (uno::RuntimeException)
//FIXME: need to check if we need to combine sheet::CellFlags::FORMATTED
sal_Int32 nClearFlags = sheet::CellFlags::HARDATTR | sheet::CellFlags::FORMATTED | sheet::CellFlags::EDITATTR;
ClearContents( nClearFlags, false );
-
-#if 0 // TODO: do we still need this?
- // Fires the range change event.
- lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
-#endif
}
void
@@ -1780,11 +1671,6 @@ ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar::
}
CellFormulaValueSetter formulaValueSetter( rFormula, getScDocument(), eGram );
setValue( rFormula, formulaValueSetter, bFireEvent );
-
-#if 0 // TODO: ditto
- // Fires the range change event.
- lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
-#endif
}
uno::Any
@@ -1945,9 +1831,6 @@ ScVbaRange::fillSeries( sheet::FillDirection nFillDirection, sheet::FillMode nFi
uno::Reference< sheet::XCellSeries > xCellSeries(mxRange, uno::UNO_QUERY_THROW );
xCellSeries->fillSeries( nFillDirection, nFillMode, nFillDateMode, fStep, fEndValue );
-
- // Fires the range change event.
- lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
}
void
@@ -2088,15 +1971,7 @@ ScVbaRange::getFormulaArray() throw (uno::RuntimeException)
uno::Reference< sheet::XCellRangeFormula> xCellRangeFormula( mxRange, uno::UNO_QUERY_THROW );
uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
uno::Any aMatrix;
-
- uno::Sequence< uno::Sequence<rtl::OUString> > aFmArray = xCellRangeFormula->getFormulaArray();
- if( aFmArray.getLength() )
- {
- if( aFmArray.getLength() == 1 && aFmArray[0].getLength() == 1 )
- aMatrix <<= aFmArray[0][0];
- else
- aMatrix = xConverter->convertTo( uno::makeAny( xCellRangeFormula->getFormulaArray() ) , getCppuType((uno::Sequence< uno::Sequence< uno::Any > >*)0) ) ;
- }
+ aMatrix = xConverter->convertTo( uno::makeAny( xCellRangeFormula->getFormulaArray() ) , getCppuType((uno::Sequence< uno::Sequence< uno::Any > >*)0) ) ;
return aMatrix;
}
@@ -2280,15 +2155,7 @@ ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent,
// #FIXME - perhaps worth turning this into some sort of
// convertion routine e.g. bSuccess = getValueFromAny( nRow, nRowIndex, getCppuType((sal_Int32*)0) )
uno::Any aRowIndexAny = nRowIndex;
- if ( aRowIndexAny.getValueTypeClass() == uno::TypeClass_INTERFACE )
- {
- try
- {
- aRowIndexAny = getDefaultPropByIntrospection( aRowIndexAny );
- }
- catch( uno::Exception& ) {}
- }
- else if ( aRowIndexAny.hasValue() && !( aRowIndexAny >>= nRow ) )
+ if ( aRowIndexAny.hasValue() && !( aRowIndexAny >>= nRow ) )
{
uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext );
uno::Any aConverted;
@@ -2310,21 +2177,13 @@ ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent,
{
ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
ScRange tmpRange;
- sal_uInt16 flags = tmpRange.ParseCols( sCol, excel::GetDocumentFromRange( xRange ), dDetails );
+ sal_uInt16 flags = tmpRange.ParseCols( sCol, getDocumentFromRange( xRange ), dDetails );
if ( ( flags & 0x200 ) != 0x200 )
throw uno::RuntimeException();
nColumn = tmpRange.aStart.Col() + 1;
}
else
{
- if ( aColumnAny.getValueTypeClass() == uno::TypeClass_INTERFACE )
- {
- try
- {
- aColumnAny = getDefaultPropByIntrospection( aColumnAny );
- }
- catch( uno::Exception& ) {}
- }
if ( !( aColumnAny >>= nColumn ) )
{
uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext );
@@ -2495,7 +2354,7 @@ ScVbaRange::Rows(const uno::Any& aIndex ) throw (uno::RuntimeException)
{
ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
ScRange tmpRange;
- tmpRange.ParseRows( sAddress, excel::GetDocumentFromRange( mxRange ), dDetails );
+ tmpRange.ParseRows( sAddress, getDocumentFromRange( mxRange ), dDetails );
SCROW nStartRow = tmpRange.aStart.Row();
SCROW nEndRow = tmpRange.aEnd.Row();
@@ -2539,7 +2398,7 @@ ScVbaRange::Columns(const uno::Any& aIndex ) throw (uno::RuntimeException)
{
ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
ScRange tmpRange;
- tmpRange.ParseCols( sAddress, excel::GetDocumentFromRange( mxRange ), dDetails );
+ tmpRange.ParseCols( sAddress, getDocumentFromRange( mxRange ), dDetails );
SCCOL nStartCol = tmpRange.aStart.Col();
SCCOL nEndCol = tmpRange.aEnd.Col();
@@ -2623,11 +2482,10 @@ ScVbaRange::getMergeCells() throw (script::BasicErrorException, uno::RuntimeExce
void
ScVbaRange::Copy(const ::uno::Any& Destination) throw (uno::RuntimeException)
{
+ if ( m_Areas->getCount() > 1 )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("That command cannot be used on multiple selections" ) ), uno::Reference< uno::XInterface >() );
if ( Destination.hasValue() )
{
- // #TODO support ( if necessary ) multi-area range in this scenario
- if ( m_Areas->getCount() > 1 )
- throw uno::RuntimeException( rtl::OUString( "!!! That command cannot be used on multiple selections" ), uno::Reference< uno::XInterface >() );
uno::Reference< excel::XRange > xRange( Destination, uno::UNO_QUERY_THROW );
uno::Any aRange = xRange->getCellRange();
uno::Reference< table::XCellRange > xCellRange;
@@ -2643,24 +2501,9 @@ ScVbaRange::Copy(const ::uno::Any& Destination) throw (uno::RuntimeException)
}
else
{
- if ( m_Areas->getCount() > 1 )
- {
- uno::Reference< frame::XModel > xModel = excel::GetModelFromRange( mxRanges );
- ScCellRangesBase* pUnoRangesBase = getCellRangesBase();
- ScRangeList aList = pUnoRangesBase->GetRangeList();
- if ( !excel::implnCopyRanges( xModel, aList ) )
- {
- throw uno::RuntimeException( rtl::OUString( "That command cannot be used on multiple selections" ), uno::Reference< uno::XInterface >() );
- }
- }
- else
- {
- ScRange aRange;
- RangeHelper thisRange( mxRange );
- uno::Reference< frame::XModel > xModel = excel::GetModelFromRange( mxRange );
- ScUnoConversion::FillScRange( aRange, thisRange.getCellRangeAddressable()->getRangeAddress() );
- excel::implnCopyRange( xModel, aRange );
- }
+ uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange );
+ Select();
+ excel::implnCopy( xModel );
}
}
@@ -2682,8 +2525,8 @@ ScVbaRange::Cut(const ::uno::Any& Destination) throw (uno::RuntimeException)
uno::Reference< sheet::XCellRangeAddressable > xSource( mxRange, uno::UNO_QUERY);
xMover->moveRange( xDestination->getCellAddress(), xSource->getRangeAddress() );
}
- else {
- uno::Reference< frame::XModel > xModel = excel::GetModelFromRange( mxRange );
+ {
+ uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange );
Select();
excel::implnCut( xModel );
}
@@ -3240,16 +3083,7 @@ ScVbaRange::Replace( const ::rtl::OUString& What, const ::rtl::OUString& Replace
// OOo.org afaik
uno::Reference< util::XSearchDescriptor > xSearch( xDescriptor, uno::UNO_QUERY );
- // Find all cells that being replaced, used to fire the range changed event.
- uno::Reference< container::XIndexAccess > xIndexAccess = xReplace->findAll( xSearch );
xReplace->replaceAll( xSearch );
-
- if ( xIndexAccess.is() && xIndexAccess->getCount() > 0 )
- {
- // Fires the range change event.
- ScCellRangesBase* pScCellRangesBase = ScCellRangesBase::getImplementation( xIndexAccess );
- lcl_NotifyRangeChanges( getScDocShell()->GetModel(), pScCellRangesBase ); // the original convert method will fail in SUSE
- }
}
return sal_True; // always
}
@@ -3685,44 +3519,73 @@ ScVbaRange::End( ::sal_Int32 Direction ) throw (uno::RuntimeException)
return xRange->End( Direction );
}
- table::CellAddress aAddress = getLeftUpperCellAddress();
- SCTAB nTab = aAddress.Sheet;
- SCCOL nCurX = aAddress.Column;
- SCROW nCurY = aAddress.Row;
- SCCOL nNewX = nCurX;
- SCROW nNewY = nCurY;
+ // #FIXME #TODO
+ // euch! found my orig implementation sucked, so
+ // trying this even suckier one ( really need to use/expose code in
+ // around ScTabView::MoveCursorArea(), thats the bit that calcutes
+ // where the cursor should go )
+ // Main problem with this method is the ultra hacky attempt to preserve
+ // the ActiveCell, there should be no need to go to these extreems
+
+ // Save ActiveCell pos ( to restore later )
+ uno::Any aDft;
+ uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+ rtl::OUString sActiveCell = xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft );
- ScDocShell* pDocShell = getScDocShell();
- ScDocument* pDoc = pDocShell->GetDocument();
+ // position current cell upper left of this range
+ Cells( uno::makeAny( (sal_Int32) 1 ), uno::makeAny( (sal_Int32) 1 ) )->Select();
- ScMoveDirection eDirection;
- switch ( Direction )
- {
- case excel::XlDirection::xlDown:
- eDirection = SC_MOVE_DOWN;
- break;
- case excel::XlDirection::xlUp:
- eDirection = SC_MOVE_UP;
- break;
- case excel::XlDirection::xlToLeft:
- eDirection = SC_MOVE_LEFT;
- break;
- case excel::XlDirection::xlToRight:
- eDirection = SC_MOVE_RIGHT;
- break;
- default:
- throw uno::RuntimeException( ::rtl::OUString( "Invalid Direction" ), uno::Reference< uno::XInterface >() );
- }
+ uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange );
- if ( pDoc )
+ SfxViewFrame* pViewFrame = excel::getViewFrame( xModel );
+ if ( pViewFrame )
{
- pDoc->FindAreaPos( nNewX, nNewY, nTab, eDirection );
+ SfxAllItemSet aArgs( SFX_APP()->GetPool() );
+ // Hoping this will make sure this slot is called
+ // synchronously
+ SfxBoolItem sfxAsync( SID_ASYNCHRON, sal_False );
+ aArgs.Put( sfxAsync, sfxAsync.Which() );
+ SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
+
+ sal_uInt16 nSID = 0;
+
+ switch( Direction )
+ {
+ case excel::XlDirection::xlDown:
+ nSID = SID_CURSORBLKDOWN;
+ break;
+ case excel::XlDirection::xlUp:
+ nSID = SID_CURSORBLKUP;
+ break;
+ case excel::XlDirection::xlToLeft:
+ nSID = SID_CURSORBLKLEFT;
+ break;
+ case excel::XlDirection::xlToRight:
+ nSID = SID_CURSORBLKRIGHT;
+ break;
+ default:
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": Invalid ColumnIndex" ) ), uno::Reference< uno::XInterface >() );
+ }
+ if ( pDispatcher )
+ {
+ pDispatcher->Execute( nSID, (SfxCallMode)SFX_CALLMODE_SYNCHRON, aArgs );
+ }
}
- ScRange aNewRange( (SCCOL)nNewX, (SCROW)nNewY, nTab, (SCCOL)nNewX, (SCROW)nNewY, nTab );
- uno::Reference< table::XCellRange > xCellRange( new ScCellRangeObj( getScDocShell(), aNewRange ) );
- uno::Reference< excel::XRange > xResultRange = new ScVbaRange( mxParent, mxContext, xCellRange );
- return xResultRange;
+ // result is the ActiveCell
+ rtl::OUString sMoved = xApplication->getActiveCell()->Address(aDft, aDft, aDft, aDft, aDft );
+
+ // restore old ActiveCell
+ uno::Any aVoid;
+
+ uno::Reference< excel::XRange > xOldActiveCell( xApplication->getActiveSheet()->Range( uno::makeAny( sActiveCell ), aVoid ), uno::UNO_QUERY_THROW );
+ xOldActiveCell->Select();
+
+ uno::Reference< excel::XRange > resultCell;
+ resultCell.set( xApplication->getActiveSheet()->Range( uno::makeAny( sMoved ), aVoid ), uno::UNO_QUERY_THROW );
+
+ // return result
+ return resultCell;
}
bool
@@ -3740,7 +3603,7 @@ ScVbaRange::characters( const uno::Any& Start, const uno::Any& Length ) throw (u
if ( !isSingleCellRange() )
throw uno::RuntimeException( rtl::OUString( "Can't create Characters property for multicell range " ), uno::Reference< uno::XInterface >() );
uno::Reference< text::XSimpleText > xSimple(mxRange->getCellByPosition(0,0) , uno::UNO_QUERY_THROW );
- ScDocument* pDoc = excel::GetDocumentFromRange(mxRange);
+ ScDocument* pDoc = getDocumentFromRange(mxRange);
if ( !pDoc )
throw uno::RuntimeException( rtl::OUString( "Failed to access document from shell" ), uno::Reference< uno::XInterface >() );
@@ -3857,7 +3720,7 @@ ScVbaRange::getCalcColWidth( const table::CellRangeAddress& rAddress) throw (uno
double
ScVbaRange::getCalcRowHeight( const table::CellRangeAddress& rAddress ) throw (uno::RuntimeException)
{
- ScDocument* pDoc = excel::GetDocumentFromRange( mxRange );
+ ScDocument* pDoc = getDocumentFromRange( mxRange );
sal_uInt16 nWidth = pDoc->GetOriginalHeight( rAddress.StartRow, rAddress.Sheet );
double nPoints = lcl_TwipsToPoints( nWidth );
nPoints = lcl_Round2DecPlaces( nPoints );
@@ -4127,7 +3990,7 @@ ScVbaRange::setRowHeight( const uno::Any& _rowheight) throw (uno::RuntimeExcepti
table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
sal_uInt16 nTwips = lcl_pointsToTwips( nHeight );
- ScDocShell* pDocShell = excel::GetDocShellFromRange( mxRange );
+ ScDocShell* pDocShell = getDocShellFromRange( mxRange );
SCCOLROW nRowArr[2];
nRowArr[0] = thisAddress.StartRow;
nRowArr[1] = thisAddress.EndRow;
@@ -4139,7 +4002,7 @@ uno::Any SAL_CALL
ScVbaRange::getPageBreak() throw (uno::RuntimeException)
{
sal_Int32 nPageBreak = excel::XlPageBreak::xlPageBreakNone;
- ScDocShell* pShell = excel::GetDocShellFromRange( mxRange );
+ ScDocShell* pShell = getDocShellFromRange( mxRange );
if ( pShell )
{
RangeHelper thisRange( mxRange );
@@ -4152,7 +4015,7 @@ ScVbaRange::getPageBreak() throw (uno::RuntimeException)
uno::Reference< frame::XModel > xModel = pShell->GetModel();
if ( xModel.is() )
{
- ScDocument* pDoc = excel::GetDocumentFromRange( mxRange );
+ ScDocument* pDoc = getDocumentFromRange( mxRange );
ScBreakType nBreak = BREAK_NONE;
if ( !bColumn )
@@ -4177,7 +4040,7 @@ ScVbaRange::setPageBreak( const uno::Any& _pagebreak) throw (uno::RuntimeExcepti
sal_Int32 nPageBreak = 0;
_pagebreak >>= nPageBreak;
- ScDocShell* pShell = excel::GetDocShellFromRange( mxRange );
+ ScDocShell* pShell = getDocShellFromRange( mxRange );
if ( pShell )
{
RangeHelper thisRange( mxRange );
@@ -4271,7 +4134,7 @@ ScVbaRange::getWorksheet() throw (uno::RuntimeException)
uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
xRange.set( xIndex->getByIndex( 0 ), uno::UNO_QUERY_THROW );
}
- ScDocShell* pDocShell = excel::GetDocShellFromRange(xRange);
+ ScDocShell* pDocShell = getDocShellFromRange(xRange);
RangeHelper rHelper(xRange);
// parent should be Thisworkbook
xSheet.set( new ScVbaWorksheet( uno::Reference< XHelperInterface >(), mxContext,rHelper.getSpreadSheet(),pDocShell->GetModel()) );
@@ -4327,34 +4190,9 @@ ScVbaRange::ApplicationRange( const uno::Reference< uno::XComponentContext >& xC
}
}
- // Add these codes for supporting shortcut: Application.Range(Range1, Range2), Range1 or Range2 is not the range of current active sheet.
- // If Range1 and Range2 are not in current active sheet, we should not use the active sheet, but use the sheet of Range1 and Range2.
- // If Range1 and Range2 are not in the same sheet, we throw an exception.
- uno::Reference< sheet::XSpreadsheet > xSpreadsheet;
- uno::Reference< excel::XRange > xRange1( Cell1, uno::UNO_QUERY ), xRange2( Cell2, uno::UNO_QUERY );
- if ( xRange1.is() )
- {
- RangeHelper thisRange( xRange1->getCellRange() );
- xSpreadsheet = thisRange.getSpreadSheet();
- }
- else if ( xRange2.is() )
- {
- RangeHelper thisRange( xRange2->getCellRange() );
- xSpreadsheet = thisRange.getSpreadSheet();
- }
- if ( !xSpreadsheet.is() )
- {
- uno::Reference< frame::XModel > xModel = getCurrentExcelDoc( xContext );
- if ( xModel.is() )
- {
- uno::Reference< sheet::XSpreadsheetView > xView( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
- xSpreadsheet = xView->getActiveSheet();
- }
- }
-
- uno::Reference< table::XCellRange > xSheetRange( xSpreadsheet, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSpreadsheetView > xView( getCurrentExcelDoc(xContext)->getCurrentController(), uno::UNO_QUERY );
+ uno::Reference< table::XCellRange > xSheetRange( xView->getActiveSheet(), uno::UNO_QUERY_THROW );
ScVbaRange* pRange = new ScVbaRange( excel::getUnoSheetModuleObj( xSheetRange ), xContext, xSheetRange );
-
uno::Reference< excel::XRange > xVbSheetRange( pRange );
return pRange->Range( Cell1, Cell2, true );
}
@@ -4592,20 +4430,7 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const
// we can't use refresh as the uno interface doesn't have a concept of ALL
// in this case we just call the core calc functionality -
bool bAll = false;
- uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
- bool bIsValidFieldValue = ( Field >>= nField );
- if ( !bIsValidFieldValue && xConverter.is() )
- {
- try
- {
- uno::Any aConverted = xConverter->convertTo( Field, getCppuType( (sal_Int32*)0 ) );
- bIsValidFieldValue = ( aConverted >>= nField );
- }
- catch( const uno::Exception& )
- {
- }
- }
- if ( bIsValidFieldValue )
+ if ( ( Field >>= nField ) )
{
uno::Reference< sheet::XSheetFilterDescriptor2 > xDesc(
xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY );
@@ -4636,19 +4461,7 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const
bAll = true;
// not sure what the relationship between Criteria1 and Operator is,
// e.g. can you have a Operator without a Criteria ? in openoffice it
- bool bIsValidOpValue = ( Operator.hasValue() && ( Operator >>= nOperator ) );
- if ( Operator.hasValue() && !bIsValidOpValue && xConverter.is() )
- {
- try
- {
- uno::Any aConverted = xConverter->convertTo( Operator, getCppuType( (sal_Int32*)0 ) );
- bIsValidOpValue = ( aConverted >>= nOperator );
- }
- catch( const uno::Exception& )
- {
- }
- }
- if ( bIsValidOpValue )
+ if ( Operator.hasValue() && ( Operator >>= nOperator ) )
{
// if its a bottom/top Ten(Percent/Value) and there
// is no value specified for critera1 set it to 10
@@ -4796,7 +4609,7 @@ ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& /*CopyOrigin*/ ) thro
{
// 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 ) );
- uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( excel::GetDocShellFromRange( mxRange ) , aRange ) );
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getDocShellFromRange( mxRange ) , aRange ) );
uno::Reference< excel::XRange > xVbaRange( new ScVbaRange( mxParent, mxContext, xRange, mbIsRows, mbIsColumns ) );
xVbaRange->PasteSpecial( uno::Any(), uno::Any(), uno::Any(), uno::Any() );
}
@@ -4820,7 +4633,7 @@ ScVbaRange::Autofit() throw (uno::RuntimeException)
if ( !( mbIsColumns || mbIsRows ) )
DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
- ScDocShell* pDocShell = excel::GetDocShellFromRange( mxRange );
+ ScDocShell* pDocShell = getDocShellFromRange( mxRange );
if ( pDocShell )
{
RangeHelper thisRange( mxRange );
@@ -4841,237 +4654,6 @@ ScVbaRange::Autofit() throw (uno::RuntimeException)
}
}
-/***************************************************************************************
- * interface for text:
- * com.sun.star.text.XText, com.sun.star.table.XCell, com.sun.star.container.XEnumerationAccess
- * com.sun.star.text.XTextRange,
- * the main problem is to recognize the numeric and date, which assosiate with DecimalSeparator, ThousandsSeparator,
- * TrailingMinusNumbers and FieldInfo.
-***************************************************************************************/
-void SAL_CALL
-ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any& DataType, const css::uno::Any& TextQualifier,
- const css::uno::Any& ConsecutiveDelimiter, const css::uno::Any& Tab, const css::uno::Any& Semicolon, const css::uno::Any& Comma,
- const css::uno::Any& Space, const css::uno::Any& Other, const css::uno::Any& OtherChar, const css::uno::Any& FieldInfo,
- const css::uno::Any& DecimalSeparator, const css::uno::Any& ThousandsSeparator, const css::uno::Any& /*TrailingMinusNumbers*/ ) throw (css::uno::RuntimeException)
-{
- uno::Reference< excel::XRange > xRange;
- if( Destination.hasValue() )
- {
- if( !( Destination >>= xRange ) )
- throw uno::RuntimeException( rtl::OUString( "Destination parameter should be a range" ),
- uno::Reference< uno::XInterface >() );
- OSL_TRACE("set range");
- }
- else
- {
- //set as current
- xRange = this;
- OSL_TRACE("set range as himself");
- }
-
- sal_Int16 xlTextParsingType = excel::XlTextParsingType::xlDelimited;
- if ( DataType.hasValue() )
- {
- if( !( DataType >>= xlTextParsingType ) )
- throw uno::RuntimeException( rtl::OUString( "DataType parameter should be a short" ),
- uno::Reference< uno::XInterface >() );
- OSL_TRACE("set Datatype" );
- }
- sal_Bool bDilimited = ( xlTextParsingType == excel::XlTextParsingType::xlDelimited );
-
- sal_Int16 xlTextQualifier = excel::XlTextQualifier::xlTextQualifierDoubleQuote;
- if( TextQualifier.hasValue() )
- {
- if( !( TextQualifier >>= xlTextQualifier ))
- throw uno::RuntimeException( rtl::OUString( "TextQualifier parameter should be a short" ),
- uno::Reference< uno::XInterface >() );
- OSL_TRACE("set TextQualifier");
- }
-
- sal_Bool bConsecutiveDelimiter = false;
- if( ConsecutiveDelimiter.hasValue() )
- {
- if( !( ConsecutiveDelimiter >>= bConsecutiveDelimiter ) )
- throw uno::RuntimeException( rtl::OUString( "ConsecutiveDelimiter parameter should be a boolean" ),
- uno::Reference< uno::XInterface >() );
- OSL_TRACE("set ConsecutiveDelimiter");
- }
-
- sal_Bool bTab = false;
- if( Tab.hasValue() && bDilimited )
- {
- if( !( Tab >>= bTab ) )
- throw uno::RuntimeException( rtl::OUString( "Tab parameter should be a boolean" ),
- uno::Reference< uno::XInterface >() );
- OSL_TRACE("set Tab");
- }
-
- sal_Bool bSemicolon = false;
- if( Semicolon.hasValue() && bDilimited )
- {
- if( !( Semicolon >>= bSemicolon ) )
- throw uno::RuntimeException( rtl::OUString( "Semicolon parameter should be a boolean" ),
- uno::Reference< uno::XInterface >() );
- OSL_TRACE("set Semicolon");
- }
- sal_Bool bComma = false;
- if( Comma.hasValue() && bDilimited )
- {
- if( !( Comma >>= bComma ) )
- throw uno::RuntimeException( rtl::OUString( "Comma parameter should be a boolean" ),
- uno::Reference< uno::XInterface >() );
- OSL_TRACE("set Comma");
- }
- sal_Bool bSpace = false;
- if( Space.hasValue() && bDilimited )
- {
- if( !( Space >>= bSpace ) )
- throw uno::RuntimeException( rtl::OUString( "Space parameter should be a boolean" ),
- uno::Reference< uno::XInterface >() );
- OSL_TRACE("set Space");
- }
- sal_Bool bOther = false;
- rtl::OUString sOtherChar;
- if( Other.hasValue() && bDilimited )
- {
- if( Other >>= bOther )
- {
- if( OtherChar.hasValue() )
- if( !( OtherChar >>= sOtherChar ) )
- throw uno::RuntimeException( rtl::OUString( "OtherChar parameter should be a String" ),
- uno::Reference< uno::XInterface >() );
- OSL_TRACE("set OtherChar" );
- }
- else if( bOther )
- throw uno::RuntimeException( rtl::OUString( "Other parameter should be a True" ),
- uno::Reference< uno::XInterface >() );
- }
- // FieldInfo, Optional Variant. An array containing parse information for the individual columns of data.
- // The interpretation depends on the value of DataType. When the data is delimited, this argument is an array
- // of two-element arrays, with each two-element array specifying the conversion options for a particular column.
- // The first element is the column number (1-based), and the second element is one of the xlColumnDataType
- // constants specifying how the column is parsed.
- uno::Sequence< uno::Sequence< uno::Any > > sFieldInfo;
- FieldInfo >>= sFieldInfo;
-
- rtl::OUString sDecimalSeparator;
- if( DecimalSeparator.hasValue() )
- {
- if( !( DecimalSeparator >>= sDecimalSeparator ) )
- throw uno::RuntimeException( rtl::OUString( "DecimalSeparator parameter should be a String" ),
- uno::Reference< uno::XInterface >() );
- OSL_TRACE("set DecimalSeparator" );
- }
- rtl::OUString sThousandsSeparator;
- if( ThousandsSeparator.hasValue() )
- {
- if( !( ThousandsSeparator >>= sThousandsSeparator ) )
- throw uno::RuntimeException( rtl::OUString( "ThousandsSeparator parameter should be a String" ),
- uno::Reference< uno::XInterface >() );
- OSL_TRACE("set ThousandsSpeparator" );
- }
- //TODO* TrailingMinusNumbers Optional Variant. Numbers that begin with a minus character.
-
- // Get the destination range's left-upper cell address.
- ScVbaRange* pDestVbaRange = dynamic_cast< ScVbaRange* >( xRange.get() );
- ScAddress aScDestAddress;
- if ( pDestVbaRange )
- {
- ScUnoConversion::FillScAddress( aScDestAddress, pDestVbaRange->getLeftUpperCellAddress() );
- }
-
- // Parse the value of parameter FieldInfo.
- sal_uInt16 nRealCount = 0;
- sal_Int32* pColumns = NULL;
- sal_uInt8* pFormats = NULL;
- if ( sFieldInfo.getLength() > 0 )
- {
- sal_uInt16 nCount = sFieldInfo.getLength();
- pColumns = new sal_Int32[nCount];
- pFormats = new sal_uInt8[nCount];
- sal_uInt16 nFormat = 1;
- uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
- for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
- {
- if ( sFieldInfo[nIndex].getLength() >= 2 )
- {
- nFormat = 1;
- try
- {
- uno::Any aConverted = xConverter->convertTo( sFieldInfo[nIndex][0], getCppuType((sal_Int32*)0) );
- aConverted >>= pColumns[nRealCount];
- aConverted = xConverter->convertTo( sFieldInfo[nIndex][1], getCppuType((sal_uInt16*)0) );
- aConverted >>= nFormat;
- }
- catch( const uno::Exception& )
- {
- }
- pFormats[nRealCount++] = nFormat;
- }
- }
- }
-
- sal_Unicode cTextQualifier = '"';
- cTextQualifier = xlTextQualifier == excel::XlTextQualifier::xlTextQualifierNone ? '\0' : cTextQualifier;
- cTextQualifier = xlTextQualifier == excel::XlTextQualifier::xlTextQualifierSingleQuote ? '\'' : cTextQualifier;
-
- // Get field delimiters.
- String rFieldDelimiters;
- if ( bTab ) rFieldDelimiters += '\t';
- if ( bSemicolon ) rFieldDelimiters += ';';
- if ( bComma ) rFieldDelimiters += ',';
- if ( bSpace ) rFieldDelimiters += ' ';
- if ( bOther ) rFieldDelimiters += *sOtherChar.getStr();
-
- // Get the text in current range to SvMemoryStream.
- ScRange aSrcScRange;
- ScCellRangesBase* pSrcCellRangesBase = getCellRangesBase();
- if ( pSrcCellRangesBase )
- {
- ScRangeList aRangeList = pSrcCellRangesBase->GetRangeList();
- if ( !aRangeList.empty() )
- {
- aSrcScRange = *aRangeList.front();
- }
- }
- ScImportExport aExport( getScDocument(), aSrcScRange );
- aExport.SetDelimiter( static_cast< sal_Unicode >( 0 ) );
- SvMemoryStream aStream;
- aStream.SetStreamCharSet( RTL_TEXTENCODING_UNICODE );
- ScImportExport::SetNoEndianSwap( aStream );
- aExport.ExportStream( aStream, String(), FORMAT_STRING );
- aStream.Seek( 0 );
-
- // Set ScAsciiOptions according to the input parameters.
- ScAsciiOptions aOptions;
- aOptions.SetFixedLen( !bDilimited );
- aOptions.SetStartRow( 0 );
- aOptions.SetColInfo( nRealCount, pColumns, pFormats );
- if ( bDilimited )
- {
- aOptions.SetFieldSeps( rFieldDelimiters );
- aOptions.SetMergeSeps( bConsecutiveDelimiter );
- aOptions.SetTextSep( cTextQualifier );
- }
-
- // Split the String in to columns.
- if ( pDestVbaRange && pDestVbaRange->getScDocument() )
- {
- ScImportExport aImport( pDestVbaRange->getScDocument(), aScDestAddress );
- aImport.SetExtOptions( aOptions );
- aImport.SetApi( false );
- aImport.ImportStream( aStream, String(), FORMAT_STRING );
- }
- if ( pColumns )
- {
- DELETEZ( pColumns );
- }
- if ( pFormats )
- {
- DELETEZ( pFormats );
- }
-}
-
uno::Any SAL_CALL
ScVbaRange::Hyperlinks( const uno::Any& aIndex ) throw (uno::RuntimeException)
{
@@ -5214,7 +4796,7 @@ uno::Any ScVbaRange::getShowDetail() throw ( css::uno::RuntimeException)
(thisAddress.StartColumn == thisAddress.EndColumn && thisAddress.EndColumn == aOutlineAddress.EndColumn ))
{
sal_Bool bColumn =thisAddress.StartRow == thisAddress.EndRow ? false:sal_True;
- ScDocument* pDoc = excel::GetDocumentFromRange( mxRange );
+ ScDocument* pDoc = getDocumentFromRange( mxRange );
ScOutlineTable* pOutlineTable = pDoc->GetOutlineTable(static_cast<SCTAB>(thisAddress.Sheet), sal_True);
const ScOutlineArray* pOutlineArray = bColumn ? pOutlineTable->GetColArray(): pOutlineTable->GetRowArray();
if( pOutlineArray )
@@ -5270,17 +4852,6 @@ void ScVbaRange::setShowDetail(const uno::Any& aShowDetail) throw ( css::uno::Ru
}
}
-::com::sun::star::uno::Reference< ::ooo::vba::excel::XQueryTable > SAL_CALL
-ScVbaRange::getQueryTable() throw (::com::sun::star::uno::RuntimeException)
-{
- if (!m_xQueryTable.is())
- {
- m_xQueryTable = new ScVbaQueryTable(mxParent ,mxContext, getScDocument(), this);
- }
-
- return m_xQueryTable;
-}
-
uno::Reference< excel::XRange > SAL_CALL
ScVbaRange::MergeArea() throw (script::BasicErrorException, uno::RuntimeException)
{
@@ -5310,116 +4881,6 @@ ScVbaRange::MergeArea() throw (script::BasicErrorException, uno::RuntimeExceptio
return new ScVbaRange( mxParent, mxContext, mxRange );
}
-//The recordset's member: Recordset.Fields.Item will get a Field obj.
-//Field.value is the column value.
-::sal_Int32 SAL_CALL
-ScVbaRange::CopyFromRecordset( const ::com::sun::star::uno::Any& Data, const ::com::sun::star::uno::Any& MaxRows, const ::com::sun::star::uno::Any& MaxColumns )
-throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException)
-{
- uno::Sequence< uno::Any > aParams;
- uno::Sequence< uno::Any > aFieldsParams(1);
- uno::Sequence< sal_Int16 > aOutParamIndex;
- uno::Sequence< uno::Any > aOutParam;
- uno::Reference< uno::XInterface > xIntRes;
- uno::Reference< uno::XInterface > xIntFields;
- uno::Reference< uno::XInterface > xIntFld;
- uno::Any aRet;
- uno::Any aPar;
- uno::Any aCrrCol;
- uno::Any aCrrRow;
- sal_Int16 nCrrCol = 0;
- sal_Int32 nCrrRow = 0;
- sal_Int32 nCol;
- sal_Int32 nMaxRows = 0;
- sal_Int32 nMaxColumns = 0;
- sal_Bool bEof = false;
- long lColCnt = 0;
- if (MaxColumns.hasValue())
- {
- MaxColumns >>= nMaxColumns;
- }
-
- long lMaxCol = nMaxColumns;
-
- if (MaxRows.hasValue())
- {
- MaxRows >>= nMaxRows;
- }
-
-
- Data >>= xIntRes;
- uno::Reference< script::XInvocation > xInvRes(xIntRes, uno::UNO_QUERY_THROW);
- rtl::OUString oMoveNext("MoveNext") ;
- rtl::OUString oEof("EOF") ;
- rtl::OUString oFields("Fields") ;
-
- if( !xInvRes->hasMethod(oMoveNext))
- {
- return -1;
- }
-
- //Get columns count
- aRet = xInvRes->getValue(oFields);
- aRet >>= xIntFields;
- uno::Reference< script::XInvocation > xInvFields(xIntFields, uno::UNO_QUERY_THROW);
- aRet = xInvFields->getValue( rtl::OUString("Count")) ;
- aRet >>= lColCnt;
-
- //Set the assign column number
- if (lMaxCol != 0)
- {
- if (lColCnt > lMaxCol)
- {
- lColCnt = lMaxCol;
- }
- }
-
- aCrrRow <<= nCrrRow;
- aCrrCol <<= nCrrCol;
-
-
- //Get start position
- uno::Reference< excel::XRange > xRngStartRow = Rows(uno::Any(sal_Int32(1)) );
- uno::Reference< excel::XRange > xRngPos = xRngStartRow->Columns( uno::Any(sal_Int32(1)) );
-
- while(1)
- {//travel recordset
- //get every column
- for (long l = 0; l < lColCnt ; l++)
- {
- nCol = l;
- aPar <<= nCol;
- //get every field
- aRet = xInvFields->invoke( rtl::OUString("Item"), uno::Sequence< uno::Any >(&aPar,1) , aOutParamIndex,aOutParam);
- aRet >>= xIntFld;
- uno::Reference< script::XInvocation > xInvFld(xIntFld, uno::UNO_QUERY_THROW); //Get the Field obj
-
- //set the field value
- aRet = xInvFld->getValue( rtl::OUString("Value") );
- uno::Reference< excel::XRange > xRngToFill = xRngPos->Offset(aCrrRow,aCrrCol );
-
- xRngToFill->setValue(aRet);
- nCrrCol++;
- aCrrCol <<= nCrrCol;
- }
-
- aRet = xInvRes->invoke(oMoveNext, aParams,aOutParamIndex,aOutParam );
- aRet = xInvRes->getValue(oEof);
- aRet >>= bEof;
- if (bEof || ( nCrrRow >= nMaxRows && nMaxRows != 0) )
- {//Arrive the end of recordset
- break;
- }
-
- nCrrRow++;
- aCrrRow <<= nCrrRow;
- nCrrCol = 0;
- aCrrCol <<= nCrrCol;
- }
-
- return 0;
-}
-
void SAL_CALL
ScVbaRange::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any& Copies, const uno::Any& Preview, const uno::Any& ActivePrinter, const uno::Any& PrintToFile, const uno::Any& Collate, const uno::Any& PrToFileName ) throw (uno::RuntimeException)
{
@@ -5438,7 +4899,7 @@ ScVbaRange::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any&
{
ScVbaRange* pRange = getImplementation( xRange );
// initialise the doc shell and the printareas
- pShell = excel::GetDocShellFromRange( pRange->mxRange );
+ pShell = getDocShellFromRange( pRange->mxRange );
xPrintAreas.set( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
}
printAreas[ index - 1 ] = rangeAddress;
@@ -5565,7 +5026,7 @@ ScVbaRange::AutoFill( const uno::Reference< excel::XRange >& Destination, const
}
}
double fEndValue = MAXDOUBLE;
- ScDocShell* pDocSh = excel::GetDocShellFromRange( mxRange );
+ ScDocShell* pDocSh = getDocShellFromRange( mxRange );
pDocSh->GetDocFunc().FillAuto( aSourceRange, NULL, eDir, eCmd, eDateCmd,
nCount, fStep, fEndValue, sal_True, sal_True );
}
@@ -5637,8 +5098,13 @@ ScVbaRange::AutoOutline( ) throw (script::BasicErrorException, uno::RuntimeExce
RangeHelper thisRange( mxRange );
table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
- uno::Reference< sheet::XSheetOutline > xSheetOutline( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
- xSheetOutline->autoOutline( thisAddress );
+ if ( isSingleCellRange() || mbIsRows )
+ {
+ uno::Reference< sheet::XSheetOutline > xSheetOutline( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
+ xSheetOutline->autoOutline( thisAddress );
+ }
+ else
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
}
void SAL_CALL
@@ -5664,9 +5130,9 @@ ScVbaRange::groupUnGroup( bool bUnGroup ) throw ( script::BasicErrorException, u
{
if ( m_Areas->getCount() > 1 )
DebugHelper::exception(SbERR_METHOD_FAILED, STR_ERRORMESSAGE_APPLIESTOSINGLERANGEONLY);
- table::TableOrientation nOrient = table::TableOrientation_COLUMNS;
- if ( mbIsRows )
- nOrient = table::TableOrientation_ROWS;
+ table::TableOrientation nOrient = table::TableOrientation_ROWS;
+ if ( mbIsColumns )
+ nOrient = table::TableOrientation_COLUMNS;
RangeHelper thisRange( mxRange );
table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
uno::Reference< sheet::XSheetOutline > xSheetOutline( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
@@ -6060,182 +5526,6 @@ ScVbaRange::Subtotal( ::sal_Int32 _nGroupBy, ::sal_Int32 _nFunction, const uno::
}
}
-uno::Any SAL_CALL ScVbaRange::AdvancedFilter( sal_Int32 Action, const uno::Any& CriteriaRange,
- const uno::Any& CopyToRange, const uno::Any& Unique ) throw (script::BasicErrorException, uno::RuntimeException)
-{
- uno::Any aRet;
- aRet <<= sal_True;
-
- uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
- ScDocument* pDoc = getScDocument();
- if ( !pDoc )
- {
- throw uno::RuntimeException( rtl::OUString( "Failed to access document from range" ), uno::Reference< uno::XInterface >() );
- }
-
- // Action
- if ( Action != excel::XlFilterAction::xlFilterInPlace && Action != excel::XlFilterAction::xlFilterCopy )
- {
- throw uno::RuntimeException( rtl::OUString( "Invalid input parameter" ), uno::Reference< uno::XInterface >() );
- }
- if ( m_Areas->getCount() > 1 )
- {
- throw uno::RuntimeException( rtl::OUString( "Invalid range" ), uno::Reference< uno::XInterface >() );
- }
-
- sal_Bool bCopyOut = ( Action != excel::XlFilterAction::xlFilterInPlace );
- uno::Reference< sheet::XSheetFilterDescriptor > xFilterDesc;
- uno::Reference< sheet::XSheetFilterable > xSheetFilter( mxRange, uno::UNO_QUERY_THROW );
-
- // CriteriaRange
- String aBuiltInCriteria; // Excel Built-In Filter Criteria.
- table::CellRangeAddress refParentAddr;
- uno::Any aCriteriaRange = CriteriaRange;
- formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1;
- if ( aCriteriaRange.hasValue() && aCriteriaRange.getValueTypeClass() == uno::TypeClass_STRING )
- {
- rtl::OUString rRangeString;
- aCriteriaRange >>= rRangeString;
- aConv = excel::IsR1C1ReferFormat( pDoc, rRangeString ) ? formula::FormulaGrammar::CONV_XL_R1C1 : aConv;
- }
- else
- {
- // Get Excel BuiltIn Filter Criteria.
- ScRangeName* pRangeNames = pDoc->GetRangeName();
- if (pRangeNames)
- {
- ScRangeName::const_iterator itr = pRangeNames->begin(), itrEnd = pRangeNames->end();
- for (; itr != itrEnd; ++itr)
- {
- if (itr->second->HasType(RT_CRITERIA))
- {
- itr->second->GetSymbol( aBuiltInCriteria, formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );
- break;
- }
- }
- }
- aCriteriaRange = aBuiltInCriteria.Len() > 0 ? uno::makeAny( rtl::OUString( aBuiltInCriteria ) ) : aCriteriaRange;
- }
- if ( aCriteriaRange.hasValue() )
- {
- table::CellRangeAddress criteriaRangeAddress = getCellRangeAddressForVBARange( aCriteriaRange, getScDocShell(), aConv );
- ScRange refRange;
- ScUnoConversion::FillScRange( refRange, criteriaRangeAddress );
- uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell(), refRange ) );
- uno::Reference< sheet::XSheetFilterableEx > xCriteria( xRange, uno::UNO_QUERY );
- if ( xCriteria.is() )
- {
- xFilterDesc = xCriteria->createFilterDescriptorByObject( xSheetFilter );
- }
- }
- else if ( mxRange.is() )
- {
- uno::Reference< sheet::XSheetFilterableEx > xCriteria( mxRange, uno::UNO_QUERY );
- if ( xCriteria.is() )
- {
- xFilterDesc = xCriteria->createFilterDescriptorByObject( xSheetFilter );
- }
- }
-
- uno::Reference< beans::XPropertySet > xPropertySet( xFilterDesc, uno::UNO_QUERY );
- if ( xPropertySet.is() )
- {
- xPropertySet->setPropertyValue( rtl::OUString( SC_UNONAME_COPYOUT ), uno::makeAny( bCopyOut ) );
- }
-
- // CopyToRange
- if ( bCopyOut && CopyToRange.hasValue() && xPropertySet.is() )
- {
- formula::FormulaGrammar::AddressConvention aTmpConv = formula::FormulaGrammar::CONV_XL_A1;
- if ( CopyToRange.getValueTypeClass() == uno::TypeClass_STRING )
- {
- rtl::OUString rRangeString;
- CopyToRange >>= rRangeString;
- aTmpConv = excel::IsR1C1ReferFormat( pDoc, rRangeString ) ? formula::FormulaGrammar::CONV_XL_R1C1 : aConv;
- }
- ScRange refRange;
- ScUnoConversion::FillScRange( refRange, getCellRangeAddressForVBARange( CopyToRange, getScDocShell(), aTmpConv ) );
- uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell(), refRange ) );
- uno::Reference< sheet::XCellAddressable > xCellAddr( xRange->getCellByPosition( 0, 0 ), uno::UNO_QUERY_THROW );
- xPropertySet->setPropertyValue( rtl::OUString( SC_UNONAME_OUTPOS ), uno::makeAny( xCellAddr->getCellAddress() ) );
- }
-
- // Unique
- if ( xPropertySet.is() )
- {
- sal_Bool bUnique = false;
- uno::Any aUnique;
- try
- {
- aUnique <<= bUnique;
- aUnique = ( xConverter.is() && Unique.hasValue() ) ? xConverter->convertTo( Unique, getCppuType( ( sal_Bool* ) 0 ) ) : aUnique;
- }
- catch( const uno::Exception& )
- {
- }
- xPropertySet->setPropertyValue( rtl::OUString( SC_UNONAME_SKIPDUP ), aUnique );
- }
-
- // Do filter.
- if ( xFilterDesc.is() )
- {
- xSheetFilter->filter( xFilterDesc );
- }
-
- return aRet;
-}
-
-//Range.PivotTable.
-//Returns a PivotTable object that represents the PivotTable report containing the upper-left corner of the specified range.
-uno::Reference< excel::XPivotTable >
-ScVbaRange::PivotTable() throw (uno::RuntimeException)
-{
- uno::Reference< excel::XPivotTable > xDestPVTable;
-
- uno::Reference< sheet::XSpreadsheet > xSheet;
- if ( mxRange.is() )
- {
- RangeHelper thisRange( mxRange );
- xSheet = thisRange.getSpreadSheet();
- }
- else if ( mxRanges.is() )
- {
- uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
- uno::Reference< table::XCellRange > xRange( xIndex->getByIndex( 0 ), uno::UNO_QUERY_THROW );
- RangeHelper thisRange( xRange );
- xSheet = thisRange.getSpreadSheet();
- }
-
- uno::Reference< sheet::XDataPilotTablesSupplier > xTables(xSheet, uno::UNO_QUERY_THROW ) ;
- uno::Reference< container::XIndexAccess > xIndexAccess( xTables->getDataPilotTables(), uno::UNO_QUERY_THROW );
- if ( xIndexAccess.is() )
- {
- //get the upper-left cell address
- table::CellAddress aAddress = getLeftUpperCellAddress();
-
- sal_Int32 nCount = xIndexAccess->getCount();
- for (sal_Int32 i=0; i < nCount; i++)
- {
- uno::Reference< sheet::XDataPilotTable > xDPTable(xIndexAccess->getByIndex(i), uno::UNO_QUERY);
- uno::Reference< sheet::XDataPilotTable2 > xDPTable2(xDPTable, uno::UNO_QUERY);
-
- //check if the cell is in the pivot table
- sheet::DataPilotTablePositionData posData = xDPTable2->getPositionData(aAddress);
- table::CellRangeAddress aCellRangeAddress = xDPTable->getOutputRange();
- ScRange aScRange( aCellRangeAddress.StartColumn, aCellRangeAddress.StartRow, aCellRangeAddress.Sheet,
- aCellRangeAddress.EndColumn, aCellRangeAddress.EndRow, aCellRangeAddress.Sheet );
- ScAddress aPos( aAddress.Column, aAddress.Row, aAddress.Sheet );
- if( !(posData.PositionType == sheet::DataPilotTablePositionType::NOT_IN_TABLE) || aScRange.In( aPos ) )
- {
- xDestPVTable = new ScVbaPivotTable( mxContext, xDPTable );
- break;
- }
- }
- }
- return xDestPVTable;
-}
-
-
rtl::OUString
ScVbaRange::getServiceImplName()
{
diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx
index b395445bf459..e39f8bb9ed5e 100644
--- a/sc/source/ui/vba/vbarange.hxx
+++ b/sc/source/ui/vba/vbarange.hxx
@@ -36,7 +36,6 @@
#include <ooo/vba/excel/XFont.hpp>
#include <ooo/vba/excel/XComment.hpp>
#include <ooo/vba/XCollection.hpp>
-#include <ooo/vba/excel/XPivotTable.hpp>
#include <ooo/vba/excel/XlPasteType.hpp>
#include <ooo/vba/excel/XlPasteSpecialOperation.hpp>
@@ -51,8 +50,6 @@
#include <com/sun/star/sheet/FillDirection.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
-#include <com/sun/star/table/CellAddress.hpp>
-#include "vbaquerytable.hxx"
#include "vbaformat.hxx"
#include <formula/grammar.hxx>
@@ -99,7 +96,6 @@ class ScVbaRange : public ScVbaRange_BASE
sal_Bool mbIsRows;
sal_Bool mbIsColumns;
css::uno::Reference< ov::excel::XValidation > m_xValidation;
- css::uno::Reference<excel::XQueryTable> m_xQueryTable;
double getCalcColWidth( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException);
double getCalcRowHeight( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException);
void visitArray( ArrayVisitor& vistor );
@@ -155,7 +151,6 @@ public:
const css::uno::Reference< css::uno::XComponentContext >& xContext,
const rtl::OUString& sRangeName, ScDocShell* pDocSh,
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,
@@ -164,8 +159,6 @@ public:
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 void SAL_CALL setName( const css::uno::Any& aName ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
virtual void SAL_CALL setValue( const css::uno::Any& aValue ) throw ( css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getFormula() throw (css::uno::RuntimeException);
@@ -206,7 +199,6 @@ public:
virtual css::uno::Any SAL_CALL getPrefixCharacter() throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getShowDetail() throw (css::uno::RuntimeException);
virtual void SAL_CALL setShowDetail(const css::uno::Any& aShowDetail) throw (css::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::ooo::vba::excel::XQueryTable > SAL_CALL getQueryTable() throw (::com::sun::star::uno::RuntimeException);
// Methods
sal_Bool IsRows() const { return mbIsRows; }
sal_Bool IsColumns() const { return mbIsColumns; }
@@ -256,10 +248,6 @@ public:
virtual css::uno::Any SAL_CALL Borders( const css::uno::Any& ) throw ( css::script::BasicErrorException, css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL BorderAround( const css::uno::Any& LineStyle,
const css::uno::Any& Weight, const css::uno::Any& ColorIndex, const css::uno::Any& Color ) throw (css::uno::RuntimeException);
- virtual void SAL_CALL TextToColumns( const css::uno::Any& Destination, const css::uno::Any& DataType, const css::uno::Any& TextQualifier,
- const css::uno::Any& ConsecutiveDelimiter, const css::uno::Any& Tab, const css::uno::Any& Semicolon, const css::uno::Any& Comma,
- const css::uno::Any& Space, const css::uno::Any& Other, const css::uno::Any& OtherChar, const css::uno::Any& FieldInfo,
- const css::uno::Any& DecimalSeparator, const css::uno::Any& ThousandsSeparator, const css::uno::Any& TrailingMinusNumbers ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Hyperlinks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual void SAL_CALL AutoFilter( const css::uno::Any& Field, const css::uno::Any& Criteria1, const css::uno::Any& Operator, const css::uno::Any& Criteria2, const css::uno::Any& VisibleDropDown ) throw (css::uno::RuntimeException);
@@ -282,11 +270,7 @@ public:
virtual void SAL_CALL RemoveSubtotal( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
virtual css::uno::Reference< ov::excel::XRange > SAL_CALL MergeArea() throw (css::script::BasicErrorException, css::uno::RuntimeException);
virtual void SAL_CALL Subtotal( ::sal_Int32 GroupBy, ::sal_Int32 Function, const css::uno::Sequence< ::sal_Int32 >& TotalList, const css::uno::Any& Replace, const css::uno::Any& PageBreaks, const css::uno::Any& SummaryBelowData ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL AdvancedFilter( ::sal_Int32 Action, const css::uno::Any& CriteriaRange, const css::uno::Any& CopyToRange, const css::uno::Any& Unique ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
- virtual css::uno::Reference< ov::excel::XPivotTable > SAL_CALL PivotTable( ) throw (css::uno::RuntimeException);
-
- virtual ::sal_Int32 SAL_CALL CopyFromRecordset( const ::com::sun::star::uno::Any& Data, const ::com::sun::star::uno::Any& MaxRows, const ::com::sun::star::uno::Any& MaxColumns ) throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException);
// XEnumerationAccess
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
// XElementAccess
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index 8e5b38f6049a..209facdef2b4 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -38,7 +38,6 @@
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <ooo/vba/excel/XlFileFormat.hpp>
-#include <ooo/vba/excel/XApplication.hpp>
#include "scextopt.hxx"
#include "vbaworksheet.hxx"
@@ -163,24 +162,6 @@ ScVbaWorkbook::getFileFormat( ) throw (::uno::RuntimeException)
return aFileFormat;
}
-// Convert Excel fileformat to OO file filter
-::rtl::OUString ScVbaWorkbook::convertFileFormat(sal_Int32 aFileFormat)
-{
- rtl::OUString aFilterName;
-
- switch(aFileFormat)
- {
- case excel::XlFileFormat::xlCSV:
- aFilterName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text - txt - csv (StarCalc)" ) );
- break;
- case excel::XlFileFormat::xlExcel9795:
- aFilterName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MS Excel 97" ) );
- break;
- }
-
- return aFilterName;
-}
-
void
ScVbaWorkbook::init()
{
@@ -312,50 +293,6 @@ ScVbaWorkbook::SaveCopyAs( const rtl::OUString& sFileName ) throw ( uno::Runtime
xStor->storeToURL( aURL, storeProps );
}
-// Add Workbook.SaveAs.
-void
-ScVbaWorkbook::SaveAs( const rtl::OUString& FileName, const uno::Any& FileFormat, const uno::Any& /*CreateBackup*/ ) throw ( uno::RuntimeException)
-{
- rtl::OUString aURL;
- osl::FileBase::getFileURLFromSystemPath( FileName, aURL );
- //if the input parameter "FileName" takes the form as "MyFile", we need to get the current directory and combine the current directory and the file name
- INetURLObject aFileNameURL( aURL );
- aURL = aFileNameURL.GetMainURL( INetURLObject::NO_DECODE );
- if ( aURL.isEmpty() )
- {
- uno::Reference< excel::XApplication > xApplication ( Application(),uno::UNO_QUERY_THROW );
- rtl::OUString aPathStr = xApplication->getDefaultFilePath();
- rtl::OUString aPathURLStr;
- osl::FileBase::getFileURLFromSystemPath( aPathStr, aPathURLStr );
- INetURLObject aPathURL( aPathURLStr );
- aPathURL.Append( FileName );
- aURL = aPathURL.GetMainURL( INetURLObject::NO_DECODE );
- }
-
- uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
-
- sal_Int32 aFileFormat = excel::XlFileFormat::xlExcel9795;
- FileFormat >>= aFileFormat;
-
- if ( FileName.indexOf('.') == -1 )
- {
- if ( aFileFormat == excel::XlFileFormat::xlExcel9795 )
- {
- aURL = aURL + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".xls" ) );
- }
- else if ( aFileFormat == excel::XlFileFormat::xlCSV )
- {
- aURL = aURL + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".csv" ) );
- }
- }
-
- uno::Sequence< beans::PropertyValue > storeProps(1);
- storeProps[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" ) );
- storeProps[0].Value <<= convertFileFormat(aFileFormat);
-
- xStor->storeAsURL( aURL, storeProps );
-}
-
css::uno::Any SAL_CALL
ScVbaWorkbook::Styles( const::uno::Any& Item ) throw (uno::RuntimeException)
{
diff --git a/sc/source/ui/vba/vbaworkbook.hxx b/sc/source/ui/vba/vbaworkbook.hxx
index 0164eb75a900..063d7c3e139d 100644
--- a/sc/source/ui/vba/vbaworkbook.hxx
+++ b/sc/source/ui/vba/vbaworkbook.hxx
@@ -41,7 +41,6 @@ class ScVbaWorkbook : public ScVbaWorkbook_BASE
void initColorData( const css::uno::Sequence< sal_Int32 >& sColors );
void init();
- ::rtl::OUString convertFileFormat(sal_Int32 aFileFormat);
protected:
ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext);
@@ -72,7 +71,6 @@ public:
virtual css::uno::Any SAL_CALL Colors( const css::uno::Any& Index ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getFileFormat( ) throw (css::uno::RuntimeException);
virtual void SAL_CALL SaveCopyAs( const rtl::OUString& Filename ) throw ( css::uno::RuntimeException);
- virtual void SAL_CALL SaveAs( const rtl::OUString& FileName, const css::uno::Any& FileFormat, const css::uno::Any& CreateBackup ) throw (css::uno::RuntimeException);
// code name
virtual ::rtl::OUString SAL_CALL getCodeName() throw ( css::uno::RuntimeException);
@@ -81,7 +79,6 @@ public:
virtual rtl::OUString getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
- virtual css::uno::Reference< css::frame::XModel > getDocModel() { return mxModel; }
// XUnoTunnel
virtual ::sal_Int64 SAL_CALL getSomething(const css::uno::Sequence<sal_Int8 >& rId ) throw(css::uno::RuntimeException);
};
diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index a2e738475743..528941b090d7 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -106,7 +106,6 @@
#include "vbaworksheets.hxx"
#include "vbahyperlinks.hxx"
#include "vbasheetobjects.hxx"
-#include "viewuno.hxx"
#include "markdata.hxx"
#include "dbdata.hxx"
@@ -312,26 +311,18 @@ ScVbaWorksheet::setName(const ::rtl::OUString &rName ) throw (uno::RuntimeExcept
xNamed->setName( rName );
}
-::sal_Int32
+sal_Int32
ScVbaWorksheet::getVisible() throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW );
- uno::Any aValue = xProps->getPropertyValue
- (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ) );
- sal_Bool bRet = false;
- aValue >>= bRet;
- if ( bRet )
- {
- return excel::XlSheetVisibility::xlSheetVisible;
- }
- else
- {
- return excel::XlSheetVisibility::xlSheetHidden;
- }
+ bool bVisible = false;
+ xProps->getPropertyValue( "IsVisible" ) >>= bVisible;
+ using namespace ::ooo::vba::excel::XlSheetVisibility;
+ return bVisible ? xlSheetVisible : (mbVeryHidden ? xlSheetVeryHidden : xlSheetHidden);
}
void
-ScVbaWorksheet::setVisible( ::sal_Int32 nVisible ) throw (uno::RuntimeException)
+ScVbaWorksheet::setVisible( sal_Int32 nVisible ) throw (uno::RuntimeException)
{
using namespace ::ooo::vba::excel::XlSheetVisibility;
bool bVisible = true;
@@ -353,9 +344,7 @@ ScVbaWorksheet::setVisible( ::sal_Int32 nVisible ) throw (uno::RuntimeException)
throw uno::RuntimeException();
}
uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW );
- xProps->setPropertyValue
- ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ),
- uno::Any( bVisible ) );
+ xProps->setPropertyValue( "IsVisible", uno::Any( bVisible ) );
}
sal_Int16
@@ -573,30 +562,10 @@ ScVbaWorksheet::Activate() throw (uno::RuntimeException)
xSpreadsheet->setActiveSheet(getSheet());
}
-// support expand (but not replace) the active sheet
void
-ScVbaWorksheet::Select(const css::uno::Any& aReplace) throw (uno::RuntimeException)
+ScVbaWorksheet::Select() throw (uno::RuntimeException)
{
- sal_Bool bReplace = true;
- if (aReplace.hasValue() && aReplace.getValueTypeClass() == uno::TypeClass_BOOLEAN)
- {
- aReplace >>= bReplace;
- }
-
- uno::Reference< sheet::XSpreadsheetView > xSpreadsheet(
- getModel()->getCurrentController(), uno::UNO_QUERY_THROW );
- ScTabViewObj* pTabView = static_cast< ScTabViewObj* >( xSpreadsheet.get() );
-
- if (bReplace)
- {
- pTabView->selectSheet(getSheet(), false);
- }
- else
- {
- uno::Reference< sheet::XSpreadsheet > xOldActiveSheet = pTabView->getActiveSheet();
- pTabView->selectSheet(getSheet(), true);
- pTabView->selectSheet(xOldActiveSheet, true);
- }
+ Activate();
}
void
@@ -699,25 +668,13 @@ ScVbaWorksheet::getSheetAtOffset(SCTAB offset) throw (uno::RuntimeException)
uno::Reference< excel::XWorksheet >
ScVbaWorksheet::getNext() throw (uno::RuntimeException)
{
- // catch the exception for index out of bound
- try{
- return getSheetAtOffset(static_cast<SCTAB>(1));
- }catch( lang::IndexOutOfBoundsException& /*e*/ )
- {
- return NULL;
- }
+ return getSheetAtOffset(static_cast<SCTAB>(1));
}
uno::Reference< excel::XWorksheet >
ScVbaWorksheet::getPrevious() throw (uno::RuntimeException)
{
- // catch the exception for index out of bound
- try{
- return getSheetAtOffset(-1);
- }catch( lang::IndexOutOfBoundsException& /*e*/ )
- {
- return NULL;
- }
+ return getSheetAtOffset(-1);
}
@@ -804,7 +761,7 @@ ScVbaWorksheet::ChartObjects( const uno::Any& Index ) throw (uno::RuntimeExcepti
uno::Reference< table::XTableChartsSupplier > xChartSupplier( getSheet(), uno::UNO_QUERY_THROW );
uno::Reference< table::XTableCharts > xTableCharts = xChartSupplier->getCharts();
- uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( getSheet(), uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxSheet, uno::UNO_QUERY_THROW );
mxCharts = new ScVbaChartObjects( this, mxContext, xTableCharts, xDrawPageSupplier );
}
if ( Index.hasValue() )
@@ -1126,7 +1083,7 @@ ScVbaWorksheet::getCodeName() throw (css::uno::RuntimeException)
sal_Int16
ScVbaWorksheet::getSheetID() throw (uno::RuntimeException)
{
- uno::Reference< sheet::XCellRangeAddressable > xAddressable( getSheet(), uno::UNO_QUERY_THROW ); // if ActiveSheet, mxSheet is null.
+ uno::Reference< sheet::XCellRangeAddressable > xAddressable( mxSheet, uno::UNO_QUERY_THROW ); // if ActiveSheet, mxSheet is null.
return xAddressable->getRangeAddress().Sheet;
}
diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx
index a3771a24601a..f9b801152b3c 100644
--- a/sc/source/ui/vba/vbaworksheet.hxx
+++ b/sc/source/ui/vba/vbaworksheet.hxx
@@ -92,8 +92,8 @@ public:
// Attributes
virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
virtual void SAL_CALL setName( const ::rtl::OUString &rName ) throw (css::uno::RuntimeException);
- virtual ::sal_Int32 SAL_CALL getVisible() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setVisible( ::sal_Int32 _Visible ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getVisible() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setVisible( sal_Int32 nVisible ) throw (css::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getStandardWidth() throw (css::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getStandardHeight() throw (css::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL getProtectionMode() throw (css::uno::RuntimeException);
@@ -116,7 +116,7 @@ public:
// Methods
virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
- virtual void SAL_CALL Select(const css::uno::Any& aReplace) throw (css::uno::RuntimeException); // add the input parameter to support expand selection
+ virtual void SAL_CALL Select() throw (css::uno::RuntimeException);
virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Range( const css::uno::Any& Cell1, const css::uno::Any& Cell2 ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Move( const css::uno::Any& Before, const css::uno::Any& After ) throw (css::uno::RuntimeException) ;
virtual void SAL_CALL Copy( const css::uno::Any& Before, const css::uno::Any& After ) throw (css::uno::RuntimeException);
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 86371930c279..5def6996cc0c 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -237,8 +237,7 @@ sal_Bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, sal_Bool bCut, sal_Bool b
return bDone;
}
-// Copy the content of the Range into clipboard. Adding this method for VBA API: Range.Copy().
-// also combine the old content of CopyToClip method to share this implementation
+// Copy the content of the Range into clipboard.
sal_Bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, sal_Bool bCut, sal_Bool bApi, sal_Bool bIncludeObjects, sal_Bool bStopEdit, sal_Bool bUseRangeForVBA )
{
if ( rRanges.empty() )
@@ -256,7 +255,7 @@ sal_Bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRange
if ( !aClipParam.isMultiRange() )
{
- if ( pDoc && ( ( bUseRangeForVBA && !pDoc->HasSelectedBlockMatrixFragment( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ) ) || ( !bUseRangeForVBA && !pDoc->HasSelectedBlockMatrixFragment( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), rMark ) ) ) )
+ if ( pDoc && ( !pDoc->HasSelectedBlockMatrixFragment( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), rMark ) ) )
{
sal_Bool bSysClip = false;
if ( !pClipDoc ) // no clip doc specified
@@ -366,9 +365,8 @@ sal_Bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRange
for ( size_t i = 1; i < aClipParam.maRanges.size(); ++i )
{
p = aClipParam.maRanges[i];
- if ( ( bUseRangeForVBA && pDoc->HasSelectedBlockMatrixFragment(
- p->aStart.Col(), p->aStart.Row(), p->aEnd.Col(), p->aEnd.Row(), p->aStart.Tab() ) ) || ( !bUseRangeForVBA && pDoc->HasSelectedBlockMatrixFragment(
- p->aStart.Col(), p->aStart.Row(), p->aEnd.Col(), p->aEnd.Row(), rMark) ) )
+ if ( pDoc->HasSelectedBlockMatrixFragment(
+ p->aStart.Col(), p->aStart.Row(), p->aEnd.Col(), p->aEnd.Row(), rMark) )
{
if (!bApi)
ErrorMessage(STR_MATRIXFRAGMENTERR);