summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2010-10-13 09:48:44 +0100
committerNoel Power <noel.power@novell.com>2010-10-13 10:01:42 +0100
commitbe3ca836cb9a7f189759571d15ec8762cfb130fd (patch)
treeedd9751cdedea19453796cba3e5fbe38bc82b6ea /sc
parent4b33c0d44fe85064d73ebe39eba4ea2d8ed018b9 (diff)
parent6196c60c78c0a66e79d283450830e3df92f10bde (diff)
Merge branch 'vba' fix conflics, trailing ws & tab issues
additionally the following iz patches are rolled up with this commit i#113356, i#112998 i#113955 i#113358 i#113515 i#112531 i#112596 i#112530
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/address.hxx3
-rw-r--r--sc/inc/addruno.hxx2
-rw-r--r--sc/inc/appoptio.hxx5
-rw-r--r--sc/inc/cell.hxx2
-rw-r--r--sc/inc/document.hxx17
-rw-r--r--sc/inc/global.hxx1
-rw-r--r--sc/inc/globstr.hrc19
-rw-r--r--sc/inc/macromgr.hxx69
-rw-r--r--sc/inc/rangenam.hxx2
-rw-r--r--sc/inc/sc.hrc6
-rw-r--r--sc/inc/scabstdlg.hxx13
-rw-r--r--sc/inc/scmod.hxx4
-rw-r--r--sc/inc/shapeuno.hxx2
-rw-r--r--sc/inc/table.hxx3
-rw-r--r--sc/inc/unonames.hxx4
-rw-r--r--sc/inc/userdat.hxx4
-rw-r--r--sc/inc/viewuno.hxx8
-rw-r--r--sc/sdi/cellsh.sdi1
-rw-r--r--sc/sdi/drawsh.sdi6
-rw-r--r--sc/sdi/scalc.sdi115
-rw-r--r--sc/source/core/data/cell.cxx46
-rw-r--r--sc/source/core/data/column3.cxx15
-rw-r--r--sc/source/core/data/documen2.cxx2
-rw-r--r--sc/source/core/data/documen8.cxx8
-rw-r--r--sc/source/core/data/document.cxx78
-rw-r--r--sc/source/core/inc/interpre.hxx11
-rw-r--r--sc/source/core/tool/address.cxx2
-rw-r--r--sc/source/core/tool/appoptio.cxx4
-rw-r--r--sc/source/core/tool/interpr1.cxx13
-rw-r--r--sc/source/core/tool/interpr4.cxx134
-rw-r--r--sc/source/core/tool/interpr5.cxx5
-rw-r--r--sc/source/core/tool/rangelst.cxx19
-rw-r--r--sc/source/filter/excel/excimp8.cxx28
-rw-r--r--sc/source/filter/excel/makefile.mk4
-rw-r--r--sc/source/filter/excel/read.cxx65
-rw-r--r--sc/source/filter/excel/xecontent.cxx11
-rw-r--r--sc/source/filter/excel/xeescher.cxx86
-rw-r--r--sc/source/filter/excel/xiescher.cxx145
-rw-r--r--sc/source/filter/excel/xiname.cxx23
-rw-r--r--sc/source/filter/excel/xistyle.cxx63
-rw-r--r--sc/source/filter/excel/xlescher.cxx2
-rw-r--r--sc/source/filter/excel/xltoolbar.cxx431
-rw-r--r--sc/source/filter/excel/xltoolbar.hxx95
-rw-r--r--sc/source/filter/excel/xltools.cxx7
-rw-r--r--sc/source/filter/inc/excimp8.hxx3
-rw-r--r--sc/source/filter/inc/xcl97esc.hxx9
-rw-r--r--sc/source/filter/inc/xcl97rec.hxx2
-rw-r--r--sc/source/filter/inc/xecontent.hxx2
-rw-r--r--sc/source/filter/inc/xeescher.hxx33
-rw-r--r--sc/source/filter/inc/xiescher.hxx51
-rw-r--r--sc/source/filter/inc/xistyle.hxx2
-rw-r--r--sc/source/filter/inc/xlescher.hxx2
-rw-r--r--sc/source/filter/xcl97/xcl97esc.cxx44
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx27
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.cxx24
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.hxx10
-rw-r--r--sc/source/ui/docshell/docfunc.cxx12
-rw-r--r--sc/source/ui/docshell/docsh5.cxx41
-rw-r--r--sc/source/ui/docshell/macromgr.cxx216
-rw-r--r--sc/source/ui/docshell/makefile.mk9
-rw-r--r--sc/source/ui/drawfunc/drawsh.cxx4
-rw-r--r--sc/source/ui/drawfunc/drawsh2.cxx4
-rw-r--r--sc/source/ui/drawfunc/drawsh5.cxx4
-rw-r--r--sc/source/ui/drawfunc/fudraw.cxx4
-rw-r--r--sc/source/ui/drawfunc/fusel.cxx16
-rw-r--r--sc/source/ui/drawfunc/makefile.mk1
-rw-r--r--sc/source/ui/drawfunc/objdraw.src6
-rw-r--r--sc/source/ui/inc/asciiopt.hxx2
-rw-r--r--sc/source/ui/inc/datafdlg.hrc15
-rw-r--r--sc/source/ui/inc/datafdlg.hxx85
-rw-r--r--sc/source/ui/inc/docfunc.hxx2
-rw-r--r--sc/source/ui/inc/docsh.hxx5
-rw-r--r--sc/source/ui/inc/drawsh.hxx2
-rw-r--r--sc/source/ui/inc/impex.hxx2
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx4
-rw-r--r--sc/source/ui/inc/undodat.hxx36
-rw-r--r--sc/source/ui/inc/viewfunc.hxx9
-rw-r--r--sc/source/ui/miscdlgs/datafdlg.cxx388
-rw-r--r--sc/source/ui/miscdlgs/makefile.mk1
-rw-r--r--sc/source/ui/src/datafdlg.src70
-rw-r--r--sc/source/ui/src/globstr.src71
-rw-r--r--sc/source/ui/src/makefile.mk1
-rw-r--r--sc/source/ui/undo/undodat.cxx205
-rw-r--r--sc/source/ui/unoobj/addruno.cxx28
-rw-r--r--sc/source/ui/unoobj/docuno.cxx14
-rw-r--r--sc/source/ui/unoobj/servuno.cxx25
-rw-r--r--sc/source/ui/unoobj/shapeuno.cxx64
-rw-r--r--sc/source/ui/unoobj/viewuno.cxx138
-rw-r--r--sc/source/ui/vba/excelvbahelper.cxx166
-rw-r--r--sc/source/ui/vba/excelvbahelper.hxx39
-rw-r--r--sc/source/ui/vba/makefile.mk14
-rw-r--r--sc/source/ui/vba/testvba/testvba.cxx6
-rw-r--r--sc/source/ui/vba/vbaapplication.cxx658
-rw-r--r--sc/source/ui/vba/vbaapplication.hxx23
-rw-r--r--sc/source/ui/vba/vbacomment.cxx18
-rw-r--r--sc/source/ui/vba/vbacommentshape.cxx46
-rw-r--r--sc/source/ui/vba/vbacommentshape.hxx46
-rw-r--r--sc/source/ui/vba/vbadialog.cxx80
-rw-r--r--sc/source/ui/vba/vbadialog.hxx3
-rw-r--r--sc/source/ui/vba/vbadialogs.cxx8
-rw-r--r--sc/source/ui/vba/vbadialogs.hxx1
-rw-r--r--sc/source/ui/vba/vbaeventshelper.cxx10
-rw-r--r--sc/source/ui/vba/vbafiledialog.cxx183
-rw-r--r--sc/source/ui/vba/vbafiledialog.hxx60
-rw-r--r--sc/source/ui/vba/vbafiledialogselecteditems.cxx154
-rw-r--r--sc/source/ui/vba/vbafiledialogselecteditems.hxx87
-rw-r--r--sc/source/ui/vba/vbafilesearch.cxx242
-rw-r--r--sc/source/ui/vba/vbafilesearch.hxx77
-rw-r--r--sc/source/ui/vba/vbafoundfiles.cxx143
-rw-r--r--sc/source/ui/vba/vbafoundfiles.hxx88
-rw-r--r--sc/source/ui/vba/vbaglobals.cxx6
-rw-r--r--sc/source/ui/vba/vbaglobals.hxx1
-rw-r--r--sc/source/ui/vba/vbahelper.cxx758
-rw-r--r--sc/source/ui/vba/vbamenu.cxx57
-rw-r--r--sc/source/ui/vba/vbamenu.hxx28
-rw-r--r--sc/source/ui/vba/vbamenubar.cxx40
-rw-r--r--sc/source/ui/vba/vbamenubar.hxx24
-rw-r--r--sc/source/ui/vba/vbamenubars.cxx111
-rw-r--r--sc/source/ui/vba/vbamenubars.hxx35
-rw-r--r--sc/source/ui/vba/vbamenuitem.cxx56
-rw-r--r--sc/source/ui/vba/vbamenuitem.hxx29
-rw-r--r--sc/source/ui/vba/vbamenuitems.cxx124
-rw-r--r--sc/source/ui/vba/vbamenuitems.hxx34
-rw-r--r--sc/source/ui/vba/vbamenus.cxx110
-rw-r--r--sc/source/ui/vba/vbamenus.hxx34
-rw-r--r--sc/source/ui/vba/vbaname.cxx91
-rw-r--r--sc/source/ui/vba/vbaname.hxx4
-rw-r--r--sc/source/ui/vba/vbanames.cxx86
-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.cxx105
-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.hxx4
-rw-r--r--sc/source/ui/vba/vbaquerytable.cxx87
-rw-r--r--sc/source/ui/vba/vbaquerytable.hxx59
-rw-r--r--sc/source/ui/vba/vbarange.cxx1041
-rw-r--r--sc/source/ui/vba/vbarange.hxx16
-rw-r--r--sc/source/ui/vba/vbavalidation.cxx12
-rw-r--r--sc/source/ui/vba/vbaworkbook.cxx71
-rw-r--r--sc/source/ui/vba/vbaworkbook.hxx9
-rw-r--r--sc/source/ui/vba/vbaworksheet.cxx120
-rw-r--r--sc/source/ui/vba/vbaworksheet.hxx7
-rw-r--r--sc/source/ui/vba/vbawsfunction.cxx66
-rw-r--r--sc/source/ui/view/cellsh2.cxx14
-rw-r--r--sc/source/ui/view/gridwin5.cxx2
-rw-r--r--sc/source/ui/view/tabview3.cxx7
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx7
-rw-r--r--sc/source/ui/view/viewfun2.cxx59
-rw-r--r--sc/source/ui/view/viewfun3.cxx150
-rw-r--r--sc/uiconfig/scalc/menubar/menubar.xml1
-rw-r--r--sc/util/makefile.mk10
152 files changed, 7441 insertions, 1503 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 15084565dfe0..bb4e97d45cf8 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -232,6 +232,9 @@ inline SCTAB SanitizeTab( SCTAB nTab, SCTAB nMaxTab )
#define SCA_VALID_ROW 0x0100
#define SCA_VALID_COL 0x0200
#define SCA_VALID_TAB 0x0400
+// SCA_BITS is a convience for
+// (SCA_VALID_TAB | SCA_VALID_COL | SCA_VALID_ROW | SCA_TAB_3D | SCA_TAB_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_COL_ABSOLUTE)
+#define SCA_BITS 0x070F
// somewhat cheesy kludge to force the display of the document name even for
// local references. Requires TAB_3D to be valid
#define SCA_FORCE_DOC 0x0800
diff --git a/sc/inc/addruno.hxx b/sc/inc/addruno.hxx
index d6df571a29aa..6e71230b21d4 100644
--- a/sc/inc/addruno.hxx
+++ b/sc/inc/addruno.hxx
@@ -47,7 +47,7 @@ private:
sal_Int32 nRefSheet;
sal_Bool bIsRange;
- sal_Bool ParseUIString( const String& rUIString );
+ sal_Bool ParseUIString( const String& rUIString, ::formula::FormulaGrammar::AddressConvention eConv = ::formula::FormulaGrammar::CONV_OOO );
public:
diff --git a/sc/inc/appoptio.hxx b/sc/inc/appoptio.hxx
index 91fc43fc249a..bbff1dfd6ad4 100644
--- a/sc/inc/appoptio.hxx
+++ b/sc/inc/appoptio.hxx
@@ -44,6 +44,10 @@ public:
void SetDefaults();
+ // Set or get the initial tab count for new spreadsheet, it is used by VBA API currently.
+ void SetTabCountInNewSpreadsheet( sal_Int16 nCount ) { nTabCountInNewSpreadsheet = nCount; }
+ sal_Int16 GetTabCountInNewSpreadsheet() const { return nTabCountInNewSpreadsheet; }
+
void SetAppMetric( FieldUnit eUnit ) { eMetric = eUnit; }
FieldUnit GetAppMetric() const { return eMetric; }
void SetZoom( USHORT nNew ) { nZoom = nNew; }
@@ -87,6 +91,7 @@ public:
const ScAppOptions& operator= ( const ScAppOptions& rOpt );
private:
+ sal_Int16 nTabCountInNewSpreadsheet;
FieldUnit eMetric;
USHORT nLRUFuncCount;
USHORT* pLRUList;
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index f9cce9e94ed2..4e2c0395ab9d 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -406,7 +406,7 @@ public:
const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
void SetDirty();
- inline void SetDirtyVar() { bDirty = TRUE; }
+ void SetDirtyVar();
// If setting entire document dirty after load, no broadcasts but still append to FormulaTree.
void SetDirtyAfterLoad();
inline void ResetTableOpDirtyVar() { bTableOpDirty = FALSE; }
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 8964f756f07e..1c2e20e55d32 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -104,6 +104,7 @@ class ScDrawLayer;
class ScExtDocOptions;
class ScExternalRefManager;
class ScFormulaCell;
+class ScMacroManager;
class ScMarkData;
class ScOutlineTable;
class ScPatternAttr;
@@ -309,6 +310,8 @@ private:
::std::auto_ptr<ScClipParam> mpClipParam;
::std::auto_ptr<ScExternalRefManager> pExternalRefMgr;
+ ::std::auto_ptr<ScMacroManager> mpMacroMgr;
+
// mutable for lazy construction
mutable ::std::auto_ptr< ScFormulaParserPool >
@@ -467,6 +470,8 @@ public:
const String& GetCodeName() const { return aDocCodeName; }
void SetCodeName( const String& r ) { aDocCodeName = r; }
+ SC_DLLPUBLIC NameToNameMap* GetLocalNameMap( SCTAB& rTab );
+
void GetDocStat( ScDocStat& rDocStat );
SC_DLLPUBLIC void InitDrawLayer( SfxObjectShell* pDocShell = NULL );
@@ -586,6 +591,7 @@ 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 );
@@ -958,7 +964,7 @@ public:
SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab,
ScDirection eDir );
- void FindAreaPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCsCOL nMovX, SCsROW nMovY );
+ SC_DLLPUBLIC void FindAreaPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCsCOL nMovX, SCsROW nMovY );
SC_DLLPUBLIC void GetNextPos( SCCOL& rCol, SCROW& rRow, SCTAB nTab, SCsCOL nMovX, SCsROW nMovY,
BOOL bMarked, BOOL bUnprotected, const ScMarkData& rMark );
@@ -979,7 +985,7 @@ public:
SCROW nStartRow, SCSIZE nSize,
ScDocument* pRefUndoDoc = NULL, BOOL* pUndoOutline = NULL,
const ScMarkData* pTabMark = NULL );
- void DeleteRow( const ScRange& rRange,
+ SC_DLLPUBLIC void DeleteRow( const ScRange& rRange,
ScDocument* pRefUndoDoc = NULL, BOOL* pUndoOutline = NULL );
BOOL InsertCol( SCROW nStartRow, SCTAB nStartTab,
SCROW nEndRow, SCTAB nEndTab,
@@ -1017,7 +1023,7 @@ public:
SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks );
SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, SCTAB nTab );
void SetCutMode( BOOL bCut );
- BOOL IsCutMode();
+ SC_DLLPUBLIC BOOL IsCutMode();
void SetClipArea( const ScRange& rArea, BOOL bCut = FALSE );
SC_DLLPUBLIC BOOL IsDocVisible() const { return bIsVisible; }
@@ -1039,6 +1045,9 @@ public:
const ScMarkData* pMarks = NULL, bool bAllTabs = false, bool bKeepScenarioFlags = false,
bool bIncludeObjects = false, bool bCloneNoteCaptions = true);
+ void CopyToClip4VBA(const ScClipParam& rClipParam, ScDocument* pClipDoc, bool bKeepScenarioFlags = false,
+ bool bIncludeObjects = false, bool bCloneNoteCaptions = true);
+
void CopyTabToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
SCTAB nTab, ScDocument* pClipDoc = NULL);
void CopyBlockFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
@@ -1594,6 +1603,7 @@ public:
SC_DLLPUBLIC ScLkUpdMode GetLinkMode() const { return eLinkMode ;}
void SetLinkMode( ScLkUpdMode nSet ) { eLinkMode = nSet;}
+ SC_DLLPUBLIC ScMacroManager* GetMacroManager();
private:
ScDocument(const ScDocument& r); // disabled with no definition
@@ -1861,6 +1871,7 @@ private: // CLOOK-Impl-Methoden
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);
void CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameData& rRangeNames);
void UpdateRangeNamesInFormulas(
ScClipRangeNameData& rRangeNames, const ScRangeList& rDestRanges, const ScMarkData& rMark,
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index db87877df738..1f31acd8349b 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -225,6 +225,7 @@ const USHORT IDF_HARDATTR = 0x0020; /// Hard cell attributes.
const USHORT IDF_STYLES = 0x0040; /// Cell styles.
const USHORT IDF_OBJECTS = 0x0080; /// Drawing objects.
const USHORT IDF_EDITATTR = 0x0100; /// Rich-text attributes.
+const USHORT IDF_SPECIAL_BOOLEAN = 0x1000;
const USHORT IDF_ATTRIB = IDF_HARDATTR | IDF_STYLES;
const USHORT IDF_CONTENTS = IDF_VALUE | IDF_DATETIME | IDF_STRING | IDF_NOTE | IDF_FORMULA;
const USHORT IDF_ALL = IDF_CONTENTS | IDF_ATTRIB | IDF_OBJECTS;
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index bc3094424d69..67f2da962258 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -579,8 +579,23 @@
#define STR_UNDO_INSERT_CURRENT_TIME 441
#define STR_OPTIONS_WARN_SEPARATORS 442
-
-#define STR_COUNT 443
+#define STR_SHAPE_AUTOSHAPE 443
+#define STR_SHAPE_RECTANGLE 444
+#define STR_SHAPE_LINE 445
+#define STR_SHAPE_OVAL 446
+#define STR_SHAPE_TEXTBOX 447
+
+#define STR_FORM_BUTTON 448
+#define STR_FORM_CHECKBOX 449
+#define STR_FORM_OPTIONBUTTON 450
+#define STR_FORM_LABEL 451
+#define STR_FORM_LISTBOX 452
+#define STR_FORM_GROUPBOX 453
+#define STR_FORM_DROPDOWN 454
+#define STR_FORM_SPINNER 455
+#define STR_FORM_SCROLLBAR 456
+
+#define STR_COUNT 456
#endif
diff --git a/sc/inc/macromgr.hxx b/sc/inc/macromgr.hxx
new file mode 100644
index 000000000000..ae99f8188189
--- /dev/null
+++ b/sc/inc/macromgr.hxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: document.hxx,v $
+ * $Revision: 1.115.36.9 $
+ *
+ * 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_MACROMGR_HXX
+#define SC_MACROMGR_HXX
+
+#include <com/sun/star/container/XContainerListener.hpp>
+
+#include "rtl/ustring.hxx"
+#include "scdllapi.h"
+
+#include <hash_map>
+#include <memory>
+
+class ScDocument;
+class ScFormulaCell;
+class ScUserMacroDepTracker;
+
+class ScMacroManager
+{
+public:
+ explicit ScMacroManager(ScDocument* pDoc);
+ ~ScMacroManager();
+
+ SC_DLLPUBLIC void InitUserFuncData();
+ SC_DLLPUBLIC void SetUserFuncVolatile( const rtl::OUString& sName, bool isVolatile );
+ SC_DLLPUBLIC bool GetUserFuncVolatile( const rtl::OUString& sName );
+
+ void AddDependentCell(const ::rtl::OUString& aModuleName, ScFormulaCell* pCell);
+ void RemoveDependentCell(ScFormulaCell* pCell);
+ void BroadcastModuleUpdate(const ::rtl::OUString& aModuleName);
+
+private:
+ typedef std::hash_map< ::rtl::OUString, bool, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > NameBoolMap;
+ NameBoolMap mhFuncToVolatile;
+ com::sun::star::uno::Reference< com::sun::star::container::XContainerListener > mxContainerListener;
+
+ ::std::auto_ptr<ScUserMacroDepTracker> mpDepTracker;
+ ScDocument* mpDoc;
+};
+
+#endif
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 889efcf164d7..37b70554b708 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -142,7 +142,7 @@ public:
SC_DLLPUBLIC BOOL IsReference( ScRange& rRef ) const;
BOOL IsReference( ScRange& rRef, const ScAddress& rPos ) const;
- BOOL IsValidReference( ScRange& rRef ) const;
+ SC_DLLPUBLIC BOOL IsValidReference( ScRange& rRef ) const;
BOOL IsRangeAtBlock( const ScRange& ) const;
void UpdateTabRef(SCTAB nOldTable, USHORT nFlag, SCTAB nNewTable);
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 5264651b3859..6d20ee3d9fb5 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -592,11 +592,9 @@
// #i59082# assign macro to shape
#define SID_ASSIGNMACRO (SC_VIEW_START + 95)
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
// #i66550# hyperlinks in shapes
#define SID_DRAW_HLINK_EDIT (SC_VIEW_START + 96)
#define SID_DRAW_HLINK_DELETE (SC_VIEW_START + 97)
-#endif
// "Zoom / Synchronize sheets" in options dialog
#define SID_SC_OPT_SYNCZOOM (SC_VIEW_START + 98)
@@ -1672,6 +1670,10 @@
// Insert current date and time to cell via command
#define SID_INSERT_CURRENT_DATE (SC_OOO_BUILD_START + 4)
#define SID_INSERT_CURRENT_TIME (SC_OOO_BUILD_START + 5)
+// Data Form
+#define SID_DATAFORM_NEW (SC_OOO_BUILD_START + 6) // message
+#define SID_DATA_FORM (SC_OOO_BUILD_START + 7) // menu (in Data menu)
+#define RID_SCDLG_DATAFORM (SC_OOO_BUILD_START + 8) // dialog
#endif
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 442e62bdd9cb..d075785c56d6 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -40,6 +40,8 @@
#include "pivot.hxx"
#include "i18npool/lang.h"
+#include <tabvwsh.hxx>
+
class ScAsciiOptions;
class ScAutoFormat;
class ScAutoFormatData;
@@ -113,6 +115,12 @@ public:
virtual DelCellCmd GetDelCellCmd() const = 0;
};
+//for dataform
+class AbstractScDataFormDlg : public VclAbstractDialog //add for ScDeleteCellDlg
+{
+
+};
+
class AbstractScDeleteContentsDlg: public VclAbstractDialog //add for ScDeleteContentsDlg
{
public:
@@ -309,7 +317,7 @@ public:
class ScAbstractDialogFactory
{
public:
- static ScAbstractDialogFactory* Create();
+ SC_DLLPUBLIC static ScAbstractDialogFactory* Create();
virtual AbstractScImportAsciiDlg * CreateScImportAsciiDlg( Window* pParent, String aDatName, //add for ScImportAsciiDlg
SvStream* pInStream, int nId,
@@ -343,6 +351,9 @@ public:
virtual AbstractScDeleteCellDlg * CreateScDeleteCellDlg( Window* pParent, int nId, BOOL bDisallowCellMove = FALSE ) = 0 ; //add for ScDeleteCellDlg
+ //for dataform
+ virtual AbstractScDataFormDlg * CreateScDataFormDlg( Window* pParent, int nId, ScTabViewShell* pTabViewShell ) = 0 ; //add for ScDataFormDlg
+
virtual AbstractScDeleteContentsDlg * CreateScDeleteContentsDlg(Window* pParent,int nId, //add for ScDeleteContentsDlg
USHORT nCheckDefaults = 0 ) = 0;
virtual AbstractScFillSeriesDlg * CreateScFillSeriesDlg( Window* pParent, //add for ScFillSeriesDlg
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index bd5d40709cd4..1cbc3065c613 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -201,12 +201,12 @@ public:
// Options:
const ScViewOptions& GetViewOptions ();
- const ScDocOptions& GetDocOptions ();
+SC_DLLPUBLIC const ScDocOptions& GetDocOptions ();
SC_DLLPUBLIC const ScAppOptions& GetAppOptions ();
const ScInputOptions& GetInputOptions ();
SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions ();
void SetViewOptions ( const ScViewOptions& rOpt );
- void SetDocOptions ( const ScDocOptions& rOpt );
+SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt );
SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt );
void SetInputOptions ( const ScInputOptions& rOpt );
void SetPrintOptions ( const ScPrintOptions& rOpt );
diff --git a/sc/inc/shapeuno.hxx b/sc/inc/shapeuno.hxx
index ddbbf3108daf..880ab42357a5 100644
--- a/sc/inc/shapeuno.hxx
+++ b/sc/inc/shapeuno.hxx
@@ -52,6 +52,7 @@ namespace com { namespace sun { namespace star {
class SdrObject;
struct SvEventDescription;
class ShapeUnoEventAccessImpl;
+class ScMacroInfo;
//------------------------------------------------------------------------
@@ -70,6 +71,7 @@ class ScShapeObj :public ScShapeObj_Base
,public ScShapeObj_TextBase
{
private:
+friend ScMacroInfo* lcl_getShapeHyperMacroInfo( ScShapeObj* pShape, BOOL bCreate );
::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > mxShapeAgg;
// cached pointers to avoid repeated queryAggregation calls:
::com::sun::star::beans::XPropertySet* pShapePropertySet;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 21b6107bd535..dd3e05699ed4 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -89,6 +89,8 @@ struct ScSetStringParam;
struct ScColWidthParam;
struct ScColWidthParam;
+typedef std::hash_map< ::rtl::OUString, rtl::OUString, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > NameToNameMap;
+
class ScTable
{
private:
@@ -183,6 +185,7 @@ private:
Color aTabBgColor;
USHORT nScenarioFlags;
BOOL bActiveScenario;
+ NameToNameMap localNameToGlobalName;
bool mbPageBreaksValid;
friend class ScDocument; // fuer FillInfo
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index f66f6c8cf6eb..d1accadbbbf6 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -186,6 +186,8 @@
#define SC_UNONAME_ANCHOR "Anchor"
#define SC_UNONAME_HORIPOS "HoriOrientPosition"
#define SC_UNONAME_VERTPOS "VertOrientPosition"
+// #i66550 HLINK_FOR_SHAPES
+#define SC_UNONAME_HYPERLINK "Hyperlink"
// other cell properties
#define SC_UNONAME_CHCOLHDR "ChartColumnAsLabel"
@@ -531,6 +533,7 @@
#define SC_UNO_ZOOMTYPE "ZoomType"
#define SC_UNO_ZOOMVALUE "ZoomValue"
#define SC_UNO_UPDTEMPL "UpdateFromTemplate"
+#define SC_UNO_FILTERED_RANGE_SELECTION "FilteredRangeSelection"
/*Stampit enable/disable print cancel */
#define SC_UNO_ALLOWPRINTJOBCANCEL "AllowPrintJobCancel"
@@ -613,6 +616,7 @@
#define SC_UNONAME_ADDRESS "Address"
#define SC_UNONAME_UIREPR "UserInterfaceRepresentation"
#define SC_UNONAME_PERSREPR "PersistentRepresentation"
+#define SC_UNONAME_XL_A1_REPR "XL_A1_Representation"
#define SC_UNONAME_REFSHEET "ReferenceSheet"
// --> PB 2004-08-23 #i33095# Security Options
diff --git a/sc/inc/userdat.hxx b/sc/inc/userdat.hxx
index 88dea98ec22a..f457ca33e22a 100644
--- a/sc/inc/userdat.hxx
+++ b/sc/inc/userdat.hxx
@@ -99,16 +99,12 @@ public:
void SetMacro( const rtl::OUString& rMacro ) { maMacro = rMacro; }
const rtl::OUString& GetMacro() const { return maMacro; }
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
void SetHlink( const rtl::OUString& rHlink ) { maHlink = rHlink; }
const rtl::OUString& GetHlink() const { return maHlink; }
-#endif
private:
rtl::OUString maMacro;
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
rtl::OUString maHlink;
-#endif
};
//-------------------------------------------------------------------------
diff --git a/sc/inc/viewuno.hxx b/sc/inc/viewuno.hxx
index 19b5c60fd070..26c4cf93d817 100644
--- a/sc/inc/viewuno.hxx
+++ b/sc/inc/viewuno.hxx
@@ -199,6 +199,7 @@ private:
XActivationEventListenerArr_Impl aActivationListeners;
SCTAB nPreviousTab;
sal_Bool bDrawSelModeSet;
+ sal_Bool bFilteredRangeSelection;
ScViewPaneObj* GetObjectByIndex_Impl(USHORT nIndex) const;
INT16 GetZoom(void) const;
@@ -313,6 +314,13 @@ public:
::com::sun::star::sheet::XSpreadsheet >& xActiveSheet )
throw(::com::sun::star::uno::RuntimeException);
+ //liuchen 2009-9-2 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);
+ //liuchen 2009-9-2
+
//XEnhancedMouseClickBroadcaster
virtual void SAL_CALL addEnhancedMouseClickHandler( const ::com::sun::star::uno::Reference<
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index 3e35a77d9723..a50f2e963713 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -60,6 +60,7 @@ interface CellSelection
SID_SBA_BRW_INSERT [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ]
SID_SELECT_DB [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ]
SID_SORT [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ]
+ SID_DATA_FORM [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ]
FID_FILTER_OK [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ]
SID_AUTO_FILTER [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ]
SID_AUTOFILTER_HIDE [ ExecMethod = ExecuteDB; StateMethod = GetDBState; ]
diff --git a/sc/sdi/drawsh.sdi b/sc/sdi/drawsh.sdi
index 98c7bf3a009d..8ba2a6759b15 100644
--- a/sc/sdi/drawsh.sdi
+++ b/sc/sdi/drawsh.sdi
@@ -226,9 +226,9 @@ interface TableDraw
SID_FONTWORK_CHARACTER_SPACING_DIALOG [ ExecMethod = ExecDrawFunc ; StateMethod = GetDrawFuncState ; ]
// ISSUE66550_HLINK_FOR_SHAPES
-// SID_DRAW_HLINK_EDIT [ ExecMethod = ExecDrawAttr; StateMethod = GetDrawFuncState; Export = FALSE; ]
-// SID_DRAW_HLINK_DELETE [ ExecMethod = ExecDrawAttr; StateMethod = GetDrawFuncState; Export = FALSE; ]
-// SID_OPEN_HYPERLINK [ ExecMethod = ExecDrawAttr; StateMethod = GetDrawFuncState; Export = FALSE; ]
+ SID_DRAW_HLINK_EDIT [ ExecMethod = ExecDrawAttr; StateMethod = GetDrawFuncState; Export = FALSE; ]
+ SID_DRAW_HLINK_DELETE [ ExecMethod = ExecDrawAttr; StateMethod = GetDrawFuncState; Export = FALSE; ]
+ SID_OPEN_HYPERLINK [ ExecMethod = ExecDrawAttr; StateMethod = GetDrawFuncState; Export = FALSE; ]
}
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index d2d425c7b646..a1ea25518037 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -1598,6 +1598,31 @@ SfxVoidItem DataSort SID_SORT
]
//--------------------------------------------------------------------------
+SfxVoidItem DataForm SID_DATA_FORM
+()
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = FALSE,
+ HasCoreId = FALSE,
+ HasDialog = TRUE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Synchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = FALSE,
+ GroupId = GID_DATA;
+]
+
+//--------------------------------------------------------------------------
SfxVoidItem DataSubTotals SID_SUBTOTALS
()
[
@@ -6271,55 +6296,55 @@ SfxVoidItem StandardFonts SID_STANDARD_FONTS
//--------------------------------------------------------------------------
// ISSUE66550_HLINK_FOR_SHAPES
-//SfxVoidItem EditShapeHyperlink SID_DRAW_HLINK_EDIT
-//()
-//[
-// /* flags: */
-// AutoUpdate = FALSE,
-// Cachable = Cachable,
-// FastCall = TRUE,
-// HasCoreId = FALSE,
-// HasDialog = TRUE,
-// ReadOnlyDoc = TRUE,
-// Toggle = FALSE,
-// Container = FALSE,
-// RecordAbsolute = FALSE,
-// RecordPerSet;
-// Synchron;
-//
+SfxVoidItem EditShapeHyperlink SID_DRAW_HLINK_EDIT
+()
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = TRUE,
+ HasCoreId = FALSE,
+ HasDialog = TRUE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Synchron;
+
// /* config: */
-// AccelConfig = TRUE,
-// MenuConfig = FALSE,
-// StatusBarConfig = FALSE,
-// ToolBoxConfig = FALSE,
-// GroupId = GID_DRAWING;
-//]
+ AccelConfig = TRUE,
+ MenuConfig = FALSE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = FALSE,
+ GroupId = GID_DRAWING;
+]
//--------------------------------------------------------------------------
// ISSUE66550_HLINK_FOR_SHAPES
-//SfxVoidItem DeleteShapeHyperlink SID_DRAW_HLINK_DELETE
-//()
-//[
-// /* flags: */
-// AutoUpdate = TRUE,
-// Cachable = Cachable,
-// FastCall = TRUE,
-// HasCoreId = FALSE,
-// HasDialog = FALSE,
-// ReadOnlyDoc = TRUE,
-// Toggle = FALSE,
-// Container = FALSE,
-// RecordAbsolute = FALSE,
-// RecordPerSet;
-// Synchron;
-//
-// /* config: */
-// AccelConfig = TRUE,
-// MenuConfig = FALSE,
-// StatusBarConfig = FALSE,
-// ToolBoxConfig = FALSE,
-// GroupId = GID_DRAWING;
-//]
+SfxVoidItem DeleteShapeHyperlink SID_DRAW_HLINK_DELETE
+()
+[
+ /* flags: */
+ AutoUpdate = TRUE,
+ Cachable = Cachable,
+ FastCall = TRUE,
+ HasCoreId = FALSE,
+ HasDialog = FALSE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Synchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = FALSE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = FALSE,
+ GroupId = GID_DRAWING;
+]
//--------------------------------------------------------------------------
SfxVoidItem StandardTextAttributes SID_TEXT_STANDARD
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 8b1e66de6c55..f842a2c79da0 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -51,6 +51,7 @@
#include "recursionhelper.hxx"
#include "postit.hxx"
#include "externalrefmgr.hxx"
+#include "macromgr.hxx"
#include <editeng/editobj.hxx>
#include <svl/intitem.hxx>
#include <editeng/flditem.hxx>
@@ -826,6 +827,8 @@ ScFormulaCell::~ScFormulaCell()
{
pDocument->RemoveFromFormulaTree( this );
pDocument->RemoveSubTotalCell(this);
+ if (pCode->HasOpCode(ocMacro))
+ pDocument->GetMacroManager()->RemoveDependentCell(this);
if (pDocument->HasExternalRefManager())
pDocument->GetExternalRefManager()->removeRefCell(this);
@@ -1757,6 +1760,36 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
// Reschedule verlangsamt das ganze erheblich, nur bei Prozentaenderung ausfuehren
ScProgress::GetInterpretProgress()->SetStateCountDownOnPercent(
pDocument->GetFormulaCodeInTree()/MIN_NO_CODES_PER_PROGRESS_UPDATE );
+
+ switch (p->GetVolatileType())
+ {
+ case ScInterpreter::VOLATILE:
+ // Volatile via built-in volatile functions. No actions needed.
+ break;
+ case ScInterpreter::VOLATILE_MACRO:
+ // The formula contains a volatile macro.
+ pCode->SetRecalcModeAlways();
+ pDocument->PutInFormulaTree(this);
+ StartListeningTo(pDocument);
+ break;
+ case ScInterpreter::NOT_VOLATILE:
+ if (pCode->IsRecalcModeAlways())
+ {
+ // The formula was previously volatile, but no more.
+ EndListeningTo(pDocument);
+ pCode->SetRecalcModeNormal();
+ }
+ else
+ {
+ // non-volatile formula. End listening to the area in case
+ // it's listening due to macro module change.
+ pDocument->EndListeningArea(BCA_LISTEN_ALWAYS, this);
+ }
+ pDocument->RemoveFromFormulaTree(this);
+ break;
+ default:
+ ;
+ }
}
else
{
@@ -1824,7 +1857,7 @@ void __EXPORT ScFormulaCell::Notify( SvtBroadcaster&, const SfxHint& rHint)
else
{
bForceTrack = !bDirty;
- bDirty = TRUE;
+ SetDirtyVar();
}
// #35962# Don't remove from FormulaTree to put in FormulaTrack to
// put in FormulaTree again and again, only if necessary.
@@ -1847,7 +1880,7 @@ void ScFormulaCell::SetDirty()
if ( !IsInChangeTrack() )
{
if ( pDocument->GetHardRecalcState() )
- bDirty = TRUE;
+ SetDirtyVar();
else
{
// Mehrfach-FormulaTracking in Load und in CompileAll
@@ -1856,7 +1889,7 @@ void ScFormulaCell::SetDirty()
// setzen, z.B. in CompileTokenArray
if ( !bDirty || !pDocument->IsInFormulaTree( this ) )
{
- bDirty = TRUE;
+ SetDirtyVar();
pDocument->AppendToFormulaTrack( this );
pDocument->TrackFormulas();
}
@@ -1867,6 +1900,13 @@ void ScFormulaCell::SetDirty()
}
}
+void ScFormulaCell::SetDirtyVar()
+{
+ bDirty = TRUE;
+ // mark the sheet of this cell to be calculated
+ //#FIXME do we need to revert this remnant of old fake vba events? pDocument->AddCalculateTable( aPos.Tab() );
+}
+
void ScFormulaCell::SetDirtyAfterLoad()
{
bDirty = TRUE;
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 642d5bdcf3f0..2535a0c0bf9d 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -829,8 +829,10 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, USHORT nFlags, ScDocument& rDestD
bool bCloneValue = (nFlags & IDF_VALUE) != 0;
bool bCloneDateTime = (nFlags & IDF_DATETIME) != 0;
bool bCloneString = (nFlags & IDF_STRING) != 0;
+ bool bCloneSpecialBoolean = (nFlags & IDF_SPECIAL_BOOLEAN) != 0;
bool bCloneFormula = (nFlags & IDF_FORMULA) != 0;
bool bCloneNote = (nFlags & IDF_NOTE) != 0;
+ bool bForceFormula = false;
ScBaseCell* pNew = 0;
ScBaseCell& rSource = *pItems[nIndex].pCell;
@@ -854,7 +856,18 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, USHORT nFlags, ScDocument& rDestD
break;
case CELLTYPE_FORMULA:
- if (bCloneFormula)
+ if ( bCloneSpecialBoolean )
+ {
+ ScFormulaCell& rForm = (ScFormulaCell&)rSource;
+ rtl::OUStringBuffer aBuf;
+ // #TODO #FIXME do we have a localisation issue here?
+ rForm.GetFormula( aBuf );
+ rtl::OUString aVal( aBuf.makeStringAndClear() );
+ if ( aVal.equalsAscii( "=TRUE()" )
+ || aVal.equalsAscii( "=FALSE()" ) )
+ bForceFormula = true;
+ }
+ if (bForceFormula || bCloneFormula)
{
// note will be cloned below
pNew = rSource.CloneWithoutNote( rDestDoc, rDestPos );
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 8c695c7ee467..55e7173a6d3d 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -94,6 +94,7 @@
#include "tabprotection.hxx"
#include "formulaparserpool.hxx"
#include "clipparam.hxx"
+#include "macromgr.hxx"
using namespace com::sun::star;
@@ -156,6 +157,7 @@ ScDocument::ScDocument( ScDocumentMode eMode,
pCacheFieldEditEngine( NULL ),
pDocProtection( NULL ),
mpClipParam( NULL),
+ mpMacroMgr( NULL ),
pExternalRefMgr( NULL ),
pViewOptions( NULL ),
pDocOptions( NULL ),
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index f2c2f4925859..e3e872cc7ec8 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -93,6 +93,7 @@
#include "globstr.hrc"
#include "sc.hrc"
#include "charthelper.hxx"
+#include "macromgr.hxx"
#include "dpobject.hxx"
#define GET_SCALEVALUE(set,id) ((const SfxUInt16Item&)(set.Get( id ))).GetValue()
@@ -412,6 +413,13 @@ BYTE ScDocument::GetEditTextDirection(SCTAB nTab) const
return sal::static_int_cast<BYTE>(eRet);
}
+ScMacroManager* ScDocument::GetMacroManager()
+{
+ if (!mpMacroMgr.get())
+ mpMacroMgr.reset(new ScMacroManager(this));
+ return mpMacroMgr.get();
+}
+
//------------------------------------------------------------------------
void ScDocument::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 0bd50b75f04d..c59f6f8da1bb 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -97,6 +97,8 @@
#include <map>
#include <limits>
+using namespace ::com::sun::star;
+
namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::sheet::TablePageBreakData;
@@ -184,6 +186,13 @@ BOOL ScDocument::GetCodeName( SCTAB nTab, String& rName ) const
return FALSE;
}
+NameToNameMap*
+ScDocument::GetLocalNameMap( SCTAB& rTab )
+{
+ if ( !HasTable( rTab ) )
+ return NULL;
+ return &pTab[rTab]->localNameToGlobalName;
+}
BOOL ScDocument::GetTable( const String& rName, SCTAB& rTab ) const
{
@@ -448,6 +457,7 @@ BOOL ScDocument::DeleteTab( SCTAB nTab, ScDocument* pRefUndoDoc )
delete pTab[nTab];
for (i=nTab + 1; i < nTabCount; i++)
pTab[i - 1] = pTab[i];
+
pTab[nTabCount - 1] = NULL;
--nMaxTableNumber;
// UpdateBroadcastAreas must be called between UpdateDeleteTab,
@@ -1608,6 +1618,40 @@ void ScDocument::CopyToClip(const ScClipParam& rClipParam,
pClipDoc->ExtendMerge(aClipRange, true);
}
+// Copy the content of the Range into clipboard. Adding this method for VBA API: Range.Copy().
+void ScDocument::CopyToClip4VBA(const ScClipParam& rClipParam, ScDocument* pClipDoc, bool bKeepScenarioFlags, bool bIncludeObjects, bool bCloneNoteCaptions)
+{
+ if ( !bIsClip )
+ {
+ pClipDoc = pClipDoc ? pClipDoc : SC_MOD()->GetClipDoc();
+ if ( !pClipDoc )
+ {
+ return;
+ }
+ ScRange aClipRange = rClipParam.getWholeRange();
+ SCTAB nTab = aClipRange.aStart.Tab();
+ pClipDoc->aDocName = aDocName;
+ pClipDoc->SetClipParam( rClipParam );
+ pClipDoc->ResetClip( this, nTab );
+
+ CopyRangeNamesToClip( pClipDoc, aClipRange, nTab );
+
+ if ( pTab[nTab] && pClipDoc->pTab[nTab] )
+ {
+ pTab[nTab]->CopyToClip( rClipParam.maRanges, pClipDoc->pTab[nTab], bKeepScenarioFlags, bCloneNoteCaptions );
+ if ( pDrawLayer && bIncludeObjects )
+ {
+ // Also copy drawing objects.
+ Rectangle aObjRect = GetMMRect( aClipRange.aStart.Col(), aClipRange.aStart.Row(), aClipRange.aEnd.Col(), aClipRange.aEnd.Row(), nTab );
+ pDrawLayer->CopyToClip( pClipDoc, nTab, aObjRect );
+ }
+ }
+
+ // Make sure to mark overlapped cells.
+ pClipDoc->ExtendMerge( aClipRange, true );
+ }
+}
+
void ScDocument::CopyTabToClip(SCCOL nCol1, SCROW nRow1,
SCCOL nCol2, SCROW nRow2,
SCTAB nTab, ScDocument* pClipDoc)
@@ -1729,6 +1773,31 @@ void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClip
}
}
+void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, SCTAB nTab)
+{
+ // Indexes of named ranges that are used in the copied cells
+ std::set<USHORT> aUsedNames;
+ if ( pTab[nTab] && pClipDoc->pTab[nTab] )
+ {
+ pTab[nTab]->FindRangeNamesInUse( rClipRange.aStart.Col(), rClipRange.aStart.Row(), rClipRange.aEnd.Col(), rClipRange.aEnd.Row(), aUsedNames );
+ }
+
+ pClipDoc->pRangeName->FreeAll();
+ for ( USHORT i = 0; i < pRangeName->GetCount(); i++ )
+ {
+ USHORT nIndex = ((ScRangeData*)((*pRangeName)[i]))->GetIndex();
+ bool bInUse = ( aUsedNames.find(nIndex) != aUsedNames.end() );
+ if ( bInUse )
+ {
+ ScRangeData* pData = new ScRangeData(*((*pRangeName)[i]));
+ if ( !pClipDoc->pRangeName->Insert(pData) )
+ delete pData;
+ else
+ pData->SetIndex(nIndex);
+ }
+ }
+}
+
ScDocument::NumFmtMergeHandler::NumFmtMergeHandler(ScDocument* pDoc, ScDocument* pSrcDoc) :
mpDoc(pDoc)
{
@@ -4502,6 +4571,15 @@ 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 ( pTab[nTab] && pTab[nTab]->HasBlockMatrixFragment( nStartCol, nStartRow, nEndCol, nEndRow ) )
+ {
+ bOk = FALSE;
+ }
+ return !bOk;
+}
BOOL ScDocument::GetMatrixFormulaRange( const ScAddress& rCellPos, ScRange& rMatrix )
{
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 98c6afbe466c..138d1bec9b66 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -135,6 +135,15 @@ public:
static inline double div( const double& fNumerator, const double& fDenominator );
ScMatrixRef GetNewMat(SCSIZE nC, SCSIZE nR);
+
+ enum VolatileType {
+ VOLATILE,
+ VOLATILE_MACRO,
+ NOT_VOLATILE
+ };
+
+ VolatileType GetVolatileType() const;
+
private:
static ScTokenStack* pGlobalStack;
static BOOL bGlobalStackInUse;
@@ -169,6 +178,8 @@ private:
BOOL bCalcAsShown; // precision as shown
BOOL bMatrixFormula; // formula cell is a matrix formula
+ VolatileType meVolaileType;
+
//---------------------------------Funktionen in interpre.cxx---------
// nMust <= nAct <= nMax ? ok : PushError
inline BOOL MustHaveParamCount( short nAct, short nMust );
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 5e0327e06c91..a86436458f8f 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -1378,7 +1378,7 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const String& r, ScDocument* pDoc, ScAdd
}
nRes1 = ( ( nRes1 | nRes2 ) & SCA_VALID )
| nRes1
- | ( ( nRes2 & 0x070F ) << 4 );
+ | ( ( nRes2 & SCA_BITS ) << 4 );
return nRes1;
}
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index 857efd972886..958db9806b13 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -82,6 +82,9 @@ ScAppOptions::~ScAppOptions()
void ScAppOptions::SetDefaults()
{
+ // Set default tab count for new spreadsheet.
+ nTabCountInNewSpreadsheet = 3;
+
if ( ScOptionsUtil::IsMetricSystem() )
eMetric = FUNIT_CM; // default for countries with metric system
else
@@ -119,6 +122,7 @@ void ScAppOptions::SetDefaults()
const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
{
+ nTabCountInNewSpreadsheet = rCpy.nTabCountInNewSpreadsheet;
eMetric = rCpy.eMetric;
eZoomType = rCpy.eZoomType;
bSynchronizeZoom = rCpy.bSynchronizeZoom;
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index fec208671760..cbffdf10499a 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -70,6 +70,7 @@
#include "rangenam.hxx"
#include "compiler.hxx"
#include "externalrefmgr.hxx"
+#include <basic/sbstar.hxx>
#include "doubleref.hxx"
#include "queryparam.hxx"
@@ -4297,7 +4298,17 @@ void ScInterpreter::ScMatch()
}
}
if ( rEntry.bQueryByString )
- rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+ {
+ BOOL bIsVBAMode = FALSE;
+ if ( pDok )
+ bIsVBAMode = pDok->IsInVBAMode();
+
+ // #TODO handle MSO wildcards
+ if ( bIsVBAMode )
+ rParam.bRegExp = FALSE;
+ else
+ rParam.bRegExp = MayBeRegExp( *rEntry.pStr, pDok );
+ }
if (pMatSrc) // The source data is matrix array.
{
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 2edd18a369f0..71e879cc6c21 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -33,10 +33,14 @@
#include <sfx2/app.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/objsh.hxx>
+#include <sfx2/docfilt.hxx>
#include <basic/sbmeth.hxx>
#include <basic/sbmod.hxx>
#include <basic/sbstar.hxx>
#include <basic/sbx.hxx>
+#include <basic/sbxobj.hxx>
+#include <basic/sbuno.hxx>
+#include <svl/zforlist.hxx>
#include <svl/zforlist.hxx>
#include <tools/urlobj.hxx>
#include <rtl/logfile.hxx>
@@ -45,6 +49,8 @@
#include <signal.h>
#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XSheetCellRange.hpp>
+#include <comphelper/processfactory.hxx>
#include "interpre.hxx"
#include "global.hxx"
@@ -65,6 +71,8 @@
#include "jumpmatrix.hxx"
#include "parclass.hxx"
#include "externalrefmgr.hxx"
+#include "formula/FormulaCompiler.hxx"
+#include "macromgr.hxx"
#include "doubleref.hxx"
#include <math.h>
@@ -72,6 +80,8 @@
#include <map>
#include <algorithm>
#include <functional>
+#include <basic/basmgr.hxx>
+#include <vbahelper/vbaaccesshelper.hxx>
#include <memory>
using namespace com::sun::star;
@@ -2925,6 +2935,61 @@ void ScInterpreter::ScMissing()
PushTempToken( new FormulaMissingToken );
}
+uno::Any lcl_getSheetModule( const uno::Reference<table::XCellRange>& xCellRange, ScDocument* pDok )
+{
+ uno::Reference< sheet::XSheetCellRange > xSheetRange( xCellRange, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xSheetRange->getSpreadsheet(), uno::UNO_QUERY_THROW );
+ rtl::OUString sCodeName;
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CodeName") ) ) >>= sCodeName;
+ // #TODO #FIXME ideally we should 'throw' here if we don't get a valid parent, but... it is possible
+ // to create a module ( and use 'Option VBASupport 1' ) for a calc document, in this scenario there
+ // are *NO* special document module objects ( of course being able to switch between vba/non vba mode at
+ // the document in the future could fix this, especially IF the switching of the vba mode takes care to
+ // create the special document module objects if they don't exist.
+ BasicManager* pBasMgr = pDok->GetDocumentShell()->GetBasicManager();
+
+ uno::Reference< uno::XInterface > xIf;
+ if ( pBasMgr && pBasMgr->GetName().Len() )
+ {
+ String sProj = String( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+ if ( pDok->GetDocumentShell()->GetBasicManager()->GetName().Len() )
+ sProj = pDok->GetDocumentShell()->GetBasicManager()->GetName();
+ StarBASIC* pBasic = pDok->GetDocumentShell()->GetBasicManager()->GetLib( sProj );
+ if ( pBasic )
+ {
+ SbModule* pMod = pBasic->FindModule( sCodeName );
+ if ( pMod )
+ xIf = pMod->GetUnoModule();
+ }
+ }
+ return uno::makeAny( xIf );
+}
+
+bool
+lcl_setVBARange( ScRange& aRange, ScDocument* pDok, SbxVariable* pPar )
+{
+ bool bOk = false;
+ try
+ {
+ uno::Reference< uno::XInterface > xVBARange;
+ uno::Reference<table::XCellRange> xCellRange = ScCellRangeObj::CreateRangeFromDoc( pDok, aRange );
+ uno::Sequence< uno::Any > aArgs(2);
+ aArgs[0] = lcl_getSheetModule( xCellRange, pDok );
+ aArgs[1] = uno::Any( xCellRange );
+ xVBARange = ooo::vba::createVBAUnoAPIServiceWithArgs( pDok->GetDocumentShell(), "ooo.vba.excel.Range", aArgs );
+ if ( xVBARange.is() )
+ {
+ String sDummy(RTL_CONSTASCII_USTRINGPARAM("A-Range") );
+ SbxObjectRef aObj = GetSbUnoObject( sDummy, uno::Any( xVBARange ) );
+ SetSbUnoObjectDfltPropName( aObj );
+ bOk = pPar->PutObject( aObj );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return bOk;
+}
void ScInterpreter::ScMacro()
{
@@ -2962,8 +3027,11 @@ void ScInterpreter::ScMacro()
return;
}
+ bool bVolatileMacro = false;
SbMethod* pMethod = (SbMethod*)pVar;
+
SbModule* pModule = pMethod->GetModule();
+ bool bUseVBAObjects = pModule->IsVBACompat();
SbxObject* pObject = pModule->GetParent();
DBG_ASSERT(pObject->IsA(TYPE(StarBASIC)), "Kein Basic gefunden!");
String aMacroStr = pObject->GetName();
@@ -2973,7 +3041,13 @@ void ScInterpreter::ScMacro()
aMacroStr += pMethod->GetName();
String aBasicStr;
if (pObject->GetParent())
+ {
aBasicStr = pObject->GetParent()->GetName(); // Dokumentenbasic
+ const SfxFilter* pFilter = NULL;
+ SfxMedium* pMedium = pDok->GetDocumentShell()->GetMedium();
+ if ( pMedium )
+ pFilter = pMedium->GetFilter();
+ }
else
aBasicStr = SFX_APP()->GetName(); // Applikationsbasic
@@ -2997,7 +3071,13 @@ void ScInterpreter::ScMacro()
{
ScAddress aAdr;
PopSingleRef( aAdr );
- bOk = SetSbxVariable( pPar, aAdr );
+ if ( bUseVBAObjects )
+ {
+ ScRange aRange( aAdr );
+ bOk = lcl_setVBARange( aRange, pDok, pPar );
+ }
+ else
+ bOk = SetSbxVariable( pPar, aAdr );
}
break;
case svDoubleRef:
@@ -3016,24 +3096,32 @@ void ScInterpreter::ScMacro()
}
else
{
- SbxDimArrayRef refArray = new SbxDimArray;
- refArray->AddDim32( 1, nRow2 - nRow1 + 1 );
- refArray->AddDim32( 1, nCol2 - nCol1 + 1 );
- ScAddress aAdr( nCol1, nRow1, nTab1 );
- for( SCROW nRow = nRow1; bOk && nRow <= nRow2; nRow++ )
+ if ( bUseVBAObjects )
{
- aAdr.SetRow( nRow );
- INT32 nIdx[ 2 ];
- nIdx[ 0 ] = nRow-nRow1+1;
- for( SCCOL nCol = nCol1; bOk && nCol <= nCol2; nCol++ )
+ ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
+ bOk = lcl_setVBARange( aRange, pDok, pPar );
+ }
+ else
+ {
+ SbxDimArrayRef refArray = new SbxDimArray;
+ refArray->AddDim32( 1, nRow2 - nRow1 + 1 );
+ refArray->AddDim32( 1, nCol2 - nCol1 + 1 );
+ ScAddress aAdr( nCol1, nRow1, nTab1 );
+ for( SCROW nRow = nRow1; bOk && nRow <= nRow2; nRow++ )
{
- aAdr.SetCol( nCol );
- nIdx[ 1 ] = nCol-nCol1+1;
- SbxVariable* p = refArray->Get32( nIdx );
- bOk = SetSbxVariable( p, aAdr );
+ aAdr.SetRow( nRow );
+ INT32 nIdx[ 2 ];
+ nIdx[ 0 ] = nRow-nRow1+1;
+ for( SCCOL nCol = nCol1; bOk && nCol <= nCol2; nCol++ )
+ {
+ aAdr.SetCol( nCol );
+ nIdx[ 1 ] = nCol-nCol1+1;
+ SbxVariable* p = refArray->Get32( nIdx );
+ bOk = SetSbxVariable( p, aAdr );
+ }
}
+ pPar->PutObject( refArray );
}
- pPar->PutObject( refArray );
}
}
break;
@@ -3081,6 +3169,13 @@ void ScInterpreter::ScMacro()
pDok->DecMacroInterpretLevel();
pDok->UnlockTable( aPos.Tab() );
+ ScMacroManager* pMacroMgr = pDok->GetMacroManager();
+ if (pMacroMgr)
+ {
+ bVolatileMacro = pMacroMgr->GetUserFuncVolatile( pMethod->GetName() );
+ pMacroMgr->AddDependentCell(pModule->GetName(), pMyFormulaCell);
+ }
+
SbxDataType eResType = refRes->GetType();
if( pVar->GetError() )
SetError( errNoValue);
@@ -3152,6 +3247,9 @@ void ScInterpreter::ScMacro()
}
pSfxApp->LeaveBasicCall();
+
+ if (bVolatileMacro && meVolaileType == NOT_VOLATILE)
+ meVolaileType = VOLATILE_MACRO;
}
@@ -3448,7 +3546,8 @@ ScInterpreter::ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc,
pMyFormulaCell( pCell ),
pFormatter( pDoc->GetFormatTable() ),
mnStringNoValueError( errNoValue),
- bCalcAsShown( pDoc->GetDocOptions().IsCalcAsShown() )
+ bCalcAsShown( pDoc->GetDocOptions().IsCalcAsShown() ),
+ meVolaileType(NOT_VOLATILE)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScTTT" );
// pStack = new ScToken*[ MAXSTACK ];
@@ -3895,6 +3994,9 @@ StackVar ScInterpreter::Interpret()
continue; // while( ( pCur = aCode.Next() ) != NULL ...
}
+ if (FormulaCompiler::IsOpCodeVolatile(eOp))
+ meVolaileType = VOLATILE;
+
// Remember result matrix in case it could be reused.
if (pTokenMatrixMap && sp && GetStackType() == svMatrix)
pTokenMatrixMap->insert( ScTokenMatrixMap::value_type( pCur,
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 82830796ec09..b3c8e5b0f907 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -322,6 +322,11 @@ ScMatrixRef ScInterpreter::GetNewMat(SCSIZE nC, SCSIZE nR)
return pMat;
}
+ScInterpreter::VolatileType ScInterpreter::GetVolatileType() const
+{
+ return meVolaileType;
+}
+
ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken,
SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2 )
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 1ab978866c67..11935a6e7d00 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -83,15 +83,18 @@ USHORT ScRangeList::Parse( const String& rStr, ScDocument* pDoc, USHORT nMask,
for ( USHORT i=0; i<nTCount; i++ )
{
aOne = rStr.GetToken( i, cDelimiter );
- // FIXME : broken for Lotus
- if ( aOne.Search( ':' ) == STRING_NOTFOUND )
- { // Range muss es sein
- String aStrTmp( aOne );
- aOne += ':';
- aOne += aStrTmp;
- }
aRange.aStart.SetTab( nTab ); // Default Tab wenn nicht angegeben
- USHORT nRes = aRange.Parse( aOne, pDoc, eConv );
+ USHORT nRes = aRange.ParseAny( aOne, pDoc, eConv );
+ USHORT nEndRangeBits = SCA_VALID_COL2 | SCA_VALID_ROW2 |
+SCA_VALID_TAB2;
+ USHORT nTmp1 = ( nRes & SCA_BITS );
+ USHORT nTmp2 = ( nRes & nEndRangeBits );
+ // If we have a valid single range with
+ // any of the address bits we are interested in
+ // set - set the equiv end range bits
+ if ( (nRes & SCA_VALID ) && nTmp1 && ( nTmp2 != nEndRangeBits ) )
+ nRes |= ( nTmp1 << 4 );
+
if ( (nRes & nMask) == nMask )
Append( aRange );
nResult &= nRes; // alle gemeinsamen Bits bleiben erhalten
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index f9d1b5b34f99..fb24e48b7fe6 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -99,15 +99,20 @@
#include "stlpool.hxx"
#include "stlsheet.hxx"
#include "detfunc.hxx"
+#include "macromgr.hxx"
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/script/ModuleInfo.hpp>
#include <cppuhelper/component_context.hxx>
#include <sfx2/app.hxx>
+#include "xltoolbar.hxx"
using namespace com::sun::star;
using ::rtl::OUString;
+// defined in docfunc.cxx ( really this needs a new name )
+script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule );
ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) :
ImportExcel( rImpData, rStrm )
@@ -242,7 +247,30 @@ void ImportExcel8::ReadBasic( void )
{
SvxImportMSVBasic aBasicImport( *pShell, *xRootStrg, bLoadCode, bLoadStrg );
bool bAsComment = !bLoadExecutable;
+
+ if ( !bAsComment )
+ {
+ ScDocument& rDoc = GetDoc();
+#if 1
+ // see if we have the XCB stream
+ SvStorageStreamRef xXCB = xRootStrg->OpenSotStream( String( RTL_CONSTASCII_USTRINGPARAM( "XCB" ) ), STREAM_STD_READ | STREAM_NOCREATE );
+ if ( xXCB.Is()|| SVSTREAM_OK == xXCB->GetError() )
+ {
+ CTBWrapper wrapper;
+ if ( wrapper.Read( xXCB ) )
+ {
+#if DEBUG
+ wrapper.Print( stderr );
+#endif
+ wrapper.ImportCustomToolBar( *pShell );
+ }
+ }
+#endif
+
+ }
aBasicImport.Import( EXC_STORAGE_VBA_PROJECT, EXC_STORAGE_VBA, bAsComment );
+ if ( !bAsComment )
+ GetObjectManager().SetOleNameOverrideInfo( aBasicImport.ControlNameForObjectId() );
}
}
}
diff --git a/sc/source/filter/excel/makefile.mk b/sc/source/filter/excel/makefile.mk
index 04ba76d4a68a..d5b90abad556 100644
--- a/sc/source/filter/excel/makefile.mk
+++ b/sc/source/filter/excel/makefile.mk
@@ -102,7 +102,8 @@ SLOFILES = \
$(SLO)$/xlstyle.obj \
$(SLO)$/xltools.obj \
$(SLO)$/xltracer.obj \
- $(SLO)$/xlview.obj
+ $(SLO)$/xlview.obj \
+ $(SLO)$/xltoolbar.obj \
.IF "$(OS)$(COM)$(CPUNAME)"=="LINUXGCCSPARC"
NOOPTFILES = \
@@ -151,6 +152,7 @@ EXCEPTIONSFILES = \
$(SLO)$/xlpivot.obj \
$(SLO)$/xlroot.obj \
$(SLO)$/xlstyle.obj \
+ $(SLO)$/xltoolbar.obj \
$(SLO)$/xltools.obj \
$(SLO)$/xlview.obj
diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index e3e46add1c73..1e30cbb1e7de 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -832,6 +832,12 @@ FltError ImportExcel8::Read( void )
sal_Size nProgressBasePos = 0;
sal_Size nProgressBaseSize = 0;
+ bool bSheetHasCodeName = false;
+
+ std::vector< String > CodeNames;
+
+ std::vector < SCTAB > nTabsWithNoCodeName;
+
while( eAkt != EXC_STATE_END )
{
if( eAkt == EXC_STATE_BEFORE_SHEET )
@@ -913,6 +919,7 @@ FltError ImportExcel8::Read( void )
// #i62752# possible to have BIFF8 sheet without globals
NeueTabelle();
eAkt = EXC_STATE_SHEET_PRE; // Shrfmla Prefetch, Row-Prefetch
+ bSheetHasCodeName = false; // reset
aIn.StoreGlobalPosition();
}
}
@@ -1083,12 +1090,32 @@ FltError ImportExcel8::Read( void )
case EXC_ID2_DIMENSIONS:
case EXC_ID3_DIMENSIONS: ReadDimensions(); break;
- case EXC_ID_CODENAME: ReadCodeName( aIn, false ); break;
+ case EXC_ID_CODENAME: ReadCodeName( aIn, false ); bSheetHasCodeName = true; break;
case 0x0A: // EOF [ 2345 ]
+ {
eAkt = EXC_STATE_SHEET;
+ String sName;
+ GetDoc().GetName( GetCurrScTab(), sName );
+ if ( !bSheetHasCodeName )
+ {
+ nTabsWithNoCodeName.push_back( GetCurrScTab() );
+ OSL_TRACE("No Codename for %d", GetCurrScTab() );
+ }
+ else
+ {
+ String sCodeName;
+ GetDoc().GetCodeName( GetCurrScTab(), sCodeName );
+ OSL_TRACE("Have CodeName %s for SheetName %s",
+ rtl::OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ CodeNames.push_back( sCodeName );
+ }
+
+ bSheetHasCodeName = false; // reset
+
aIn.SeekGlobalPosition(); // und zurueck an alte Position
break;
+ }
case 0x12: SheetProtect(); break;
case 0x13: SheetPassword(); break;
case 0x42: Codepage(); break; // CODEPAGE [ 2345 ]
@@ -1207,6 +1234,42 @@ FltError ImportExcel8::Read( void )
if( eLastErr == eERR_OK )
{
+ // In some strange circumstances a the codename might be missing
+ // # Create any missing Sheet CodeNames
+ std::vector < SCTAB >::iterator it_end = nTabsWithNoCodeName.end();
+ for ( std::vector < SCTAB >::iterator it = nTabsWithNoCodeName.begin(); it != it_end; ++it )
+ {
+ bool bGotCodeName = false;
+ SCTAB nTab = 1;
+ OSL_TRACE("Trying to find suitable codename for %d", *it );
+ while ( true )
+ {
+ String sTmpName( RTL_CONSTASCII_USTRINGPARAM("Sheet" ) );
+ sTmpName += String::CreateFromInt32( sal_Int32(nTab++) );
+ std::vector< String >::iterator codeName_It = CodeNames.begin();
+ std::vector< String >::iterator codeName_It_end = CodeNames.end();
+ // search for codename
+ for ( ; codeName_It != codeName_It_end; ++codeName_It )
+ {
+ if ( *codeName_It == sTmpName )
+ break;
+ }
+
+ if ( codeName_It == codeName_It_end ) // generated codename not found
+ {
+ OSL_TRACE("Using generated codename %s", rtl::OUStringToOString( sTmpName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ // Set new codename
+ GetDoc().SetCodeName( *it, sTmpName );
+ // Record newly used codename
+ CodeNames.push_back( sTmpName );
+ // Record those we have created so they can be created in
+ // basic
+ AutoGeneratedCodeNames.push_back( sTmpName );
+ break;
+ }
+ }
+
+ }
// #i45843# Convert pivot tables before calculation, so they are available
// for the GETPIVOTDATA function.
if( GetBiff() == EXC_BIFF8 )
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 7bfd57be7290..0ac140fd124e 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -516,12 +516,17 @@ void XclExpHyperlink::WriteBody( XclExpStream& rStrm )
{
sal_uInt16 nXclCol = static_cast< sal_uInt16 >( maScPos.Col() );
sal_uInt16 nXclRow = static_cast< sal_uInt16 >( maScPos.Row() );
- mxVarData->Seek( STREAM_SEEK_TO_BEGIN );
+ rStrm << nXclRow << nXclRow << nXclCol << nXclCol;
+ WriteEmbeddedData( rStrm );
+}
- rStrm << nXclRow << nXclRow << nXclCol << nXclCol
- << XclTools::maGuidStdLink
+void XclExpHyperlink::WriteEmbeddedData( XclExpStream& rStrm )
+{
+ rStrm << XclTools::maGuidStdLink
<< sal_uInt32( 2 )
<< mnFlags;
+
+ mxVarData->Seek( STREAM_SEEK_TO_BEGIN );
rStrm.CopyFromStream( *mxVarData );
}
diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index 0509f2afa5fa..5edc3e3e823a 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -63,6 +63,9 @@
#include "xelink.hxx"
#include "xename.hxx"
#include "xestyle.hxx"
+#include "userdat.hxx"
+#include "drwlayer.hxx"
+#include "svx/unoapi.hxx"
#include <oox/core/tokens.hxx>
@@ -484,9 +487,9 @@ void XclExpOcxControlObj::WriteSubRecs( XclExpStream& rStrm )
#else
-XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape, const Rectangle* pChildAnchor ) :
- XclObj( rObjMgr, EXC_OBJTYPE_UNKNOWN, true ),
- XclExpControlHelper( rObjMgr.GetRoot() ),
+XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rRoot, Reference< XShape > xShape , const Rectangle* pChildAnchor ) :
+ XclObj( rRoot, EXC_OBJTYPE_UNKNOWN, true ),
+ XclMacroHelper( rRoot ),
mnHeight( 0 ),
mnState( 0 ),
mnLineCount( 0 ),
@@ -735,6 +738,8 @@ XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rObjMgr, Referenc
bool XclExpTbxControlObj::SetMacroLink( const ScriptEventDescriptor& rEvent )
{
+ return XclMacroHelper::SetMacroLink( rEvent, meEventType );
+/*
String aMacroName = XclControlHelper::ExtractFromMacroDescriptor( rEvent, meEventType );
if( aMacroName.Len() )
{
@@ -744,6 +749,7 @@ bool XclExpTbxControlObj::SetMacroLink( const ScriptEventDescriptor& rEvent )
return true;
}
return false;
+*/
}
void XclExpTbxControlObj::WriteSubRecs( XclExpStream& rStrm )
@@ -882,12 +888,6 @@ void XclExpTbxControlObj::WriteSubRecs( XclExpStream& rStrm )
}
}
-void XclExpTbxControlObj::WriteMacroSubRec( XclExpStream& rStrm )
-{
- if( mxMacroLink.is() )
- WriteFormulaSubRec( rStrm, EXC_ID_OBJMACRO, *mxMacroLink );
-}
-
void XclExpTbxControlObj::WriteCellLinkSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId )
{
if( const XclTokenArray* pCellLink = GetCellLinkTokArr() )
@@ -916,6 +916,7 @@ void XclExpTbxControlObj::WriteSbs( XclExpStream& rStrm )
#endif
+
// ----------------------------------------------------------------------------
XclExpChartObj::XclExpChartObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape, const Rectangle* pChildAnchor ) :
@@ -1059,6 +1060,7 @@ void XclExpNote::Save( XclExpStream& rStrm )
}
}
+
void XclExpNote::WriteBody( XclExpStream& rStrm )
{
// BIFF5/BIFF7 is written separately
@@ -1095,6 +1097,72 @@ void XclExpNote::WriteXml( sal_Int32 nAuthorId, XclExpXmlStream& rStrm )
// ============================================================================
+XclMacroHelper::XclMacroHelper( const XclExpRoot& rRoot ) :
+ XclExpControlHelper( rRoot )
+{
+}
+
+XclMacroHelper::~XclMacroHelper()
+{
+}
+
+void XclMacroHelper::WriteMacroSubRec( XclExpStream& rStrm )
+{
+ if( mxMacroLink.is() )
+ WriteFormulaSubRec( rStrm, EXC_ID_OBJMACRO, *mxMacroLink );
+}
+
+bool
+XclMacroHelper::SetMacroLink( const ScriptEventDescriptor& rEvent, const XclTbxEventType& nEventType )
+{
+ String aMacroName = XclControlHelper::ExtractFromMacroDescriptor( rEvent, nEventType, GetDocShell() );
+ if( aMacroName.Len() )
+ {
+ return SetMacroLink( aMacroName );
+ }
+ return false;
+}
+
+bool
+XclMacroHelper::SetMacroLink( const String& rMacroName )
+{
+ OSL_TRACE("SetMacroLink( macroname:=%s )", rtl::OUStringToOString( rMacroName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ if( rMacroName.Len() )
+ {
+ sal_uInt16 nExtSheet = GetLocalLinkManager().FindExtSheet( EXC_EXTSH_OWNDOC );
+ sal_uInt16 nNameIdx = GetNameManager().InsertMacroCall( rMacroName, true, false );
+ mxMacroLink = GetFormulaCompiler().CreateNameXFormula( nExtSheet, nNameIdx );
+ return true;
+ }
+ return false;
+}
+
+XclExpShapeObj::XclExpShapeObj( XclExpObjectManager& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape ) :
+ XclObjAny( rRoot ),
+ XclMacroHelper( rRoot )
+{
+ if( SdrObject* pSdrObj = ::GetSdrObjectFromXShape( xShape ) )
+ {
+ ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pSdrObj );
+ if ( pInfo && pInfo->GetMacro().getLength() )
+// FIXME ooo330-m2: XclControlHelper::GetXclMacroName was removed in upstream sources; they started to call XclTools::GetXclMacroName instead; is this enough? it has only one parameter
+// SetMacroLink( XclControlHelper::GetXclMacroName( pInfo->GetMacro(), rRoot.GetDocShell() ) );
+ SetMacroLink( XclTools::GetXclMacroName( pInfo->GetMacro() ) );
+ }
+}
+
+XclExpShapeObj::~XclExpShapeObj()
+{
+}
+
+void XclExpShapeObj::WriteSubRecs( XclExpStream& rStrm )
+{
+ XclObjAny::WriteSubRecs( rStrm );
+ WriteMacroSubRec( rStrm );
+}
+
+// ============================================================================
+
XclExpComments::XclExpComments( SCTAB nTab, XclExpRecordList< XclExpNote >& rNotes )
: mnTab( nTab ), mrNotes( rNotes )
{
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index dc2508fe74fe..9710b539dfad 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -109,6 +109,8 @@
#include "xipage.hxx"
#include "xichart.hxx"
#include "xicontent.hxx"
+#include "scextopt.hxx"
+
#include "namebuff.hxx"
using ::rtl::OUString;
@@ -236,6 +238,7 @@ XclImpDrawObjBase::~XclImpDrawObjBase()
}
}
+ xDrawObj->mnTab = rRoot.GetCurrScTab();
xDrawObj->ImplReadObj3( rStrm );
return xDrawObj;
}
@@ -268,6 +271,7 @@ XclImpDrawObjBase::~XclImpDrawObjBase()
}
}
+ xDrawObj->mnTab = rRoot.GetCurrScTab();
xDrawObj->ImplReadObj4( rStrm );
return xDrawObj;
}
@@ -310,6 +314,7 @@ XclImpDrawObjBase::~XclImpDrawObjBase()
}
}
+ xDrawObj->mnTab = rRoot.GetCurrScTab();
xDrawObj->ImplReadObj5( rStrm );
return xDrawObj;
}
@@ -368,6 +373,7 @@ XclImpDrawObjBase::~XclImpDrawObjBase()
}
}
+ xDrawObj->mnTab = rRoot.GetCurrScTab();
xDrawObj->ImplReadObj8( rStrm );
return xDrawObj;
}
@@ -468,8 +474,9 @@ void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrOb
}
// macro and hyperlink
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
- if( mbSimpleMacro && ((maMacroName.Len() > 0) || (maHyperlink.getLength() > 0)) )
+ // removed oracle/sun check for mbSimpleMacro ( no idea what its for )
+ if( (maMacroName.Len() > 0 ) ||
+ (maHyperlink.Len() > 0) )
{
if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, TRUE ) )
{
@@ -477,11 +484,6 @@ void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrOb
pInfo->SetHlink( maHyperlink );
}
}
-#else
- if( mbSimpleMacro && (maMacroName.Len() > 0) )
- if( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( &rSdrObj, TRUE ) )
- pInfo->SetMacro( XclTools::GetSbMacroUrl( maMacroName, GetDocShell() ) );
-#endif
// call virtual function for object type specific processing
DoPreProcessSdrObj( rDffConv, rSdrObj );
@@ -1761,22 +1763,15 @@ SdrObject* XclImpControlHelper::CreateSdrObjectFromShape(
return xSdrObj.release();
}
-void XclImpControlHelper::ProcessControl( const XclImpDrawObjBase& rDrawObj ) const
+void XclImpControlHelper::ApplySheetLinkProps() const
{
+
Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( mxShape );
if( !xCtrlModel.is() )
return;
-
ScfPropertySet aPropSet( xCtrlModel );
- // #118053# #i51348# set object name at control model
- aPropSet.SetStringProperty( CREATE_OUSTRING( "Name" ), rDrawObj.GetObjName() );
-
- // control visible and printable?
- aPropSet.SetBoolProperty( CREATE_OUSTRING( "EnableVisible" ), rDrawObj.IsVisible() );
- aPropSet.SetBoolProperty( CREATE_OUSTRING( "Printable" ), rDrawObj.IsPrintable() );
-
- // sheet links
+ // sheet links
if( SfxObjectShell* pDocShell = mrRoot.GetDocShell() )
{
Reference< XMultiServiceFactory > xFactory( pDocShell->GetModel(), UNO_QUERY );
@@ -1839,6 +1834,25 @@ void XclImpControlHelper::ProcessControl( const XclImpDrawObjBase& rDrawObj ) co
}
}
}
+}
+
+void XclImpControlHelper::ProcessControl( const XclImpDrawObjBase& rDrawObj ) const
+{
+ Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( mxShape );
+ if( !xCtrlModel.is() )
+ return;
+
+ ApplySheetLinkProps();
+
+ ScfPropertySet aPropSet( xCtrlModel );
+
+ // #118053# #i51348# set object name at control model
+ aPropSet.SetStringProperty( CREATE_OUSTRING( "Name" ), rDrawObj.GetObjName() );
+
+ // control visible and printable?
+ aPropSet.SetBoolProperty( CREATE_OUSTRING( "EnableVisible" ), rDrawObj.IsVisible() );
+ aPropSet.SetBoolProperty( CREATE_OUSTRING( "Printable" ), rDrawObj.IsPrintable() );
+
// virtual call for type specific processing
DoProcessControl( aPropSet );
@@ -2170,6 +2184,45 @@ void XclImpOptionButtonObj::DoProcessControl( ScfPropertySet& rPropSet ) const
{
XclImpCheckBoxObj::DoProcessControl( rPropSet );
// TODO: grouping
+ XclImpOptionButtonObj* pTbxObj = dynamic_cast< XclImpOptionButtonObj* >( GetObjectManager().GetSheetDrawing( GetTab() ).FindDrawObj( mnNextInGroup ).get() );
+ if ( ( pTbxObj && pTbxObj->mnFirstInGroup ) )
+ {
+ // Group has terminated
+ // traverse each RadioButton in group and
+ // a) apply the groupname
+ // b) propagate the linked cell from the lead radiobutton
+ // c) apply the correct Ref value
+ XclImpOptionButtonObj* pLeader = pTbxObj;
+ ;
+ sal_Int32 nRefVal = 1;
+ OSL_TRACE( "0x%x start group ", pLeader->GetObjId()/*.mnObjId */);
+ do
+ {
+
+ Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( pTbxObj->mxShape );
+ if ( xCtrlModel.is() )
+ {
+ ScfPropertySet aProps( xCtrlModel );
+ rtl::OUString sGroupName = rtl::OUString::valueOf( static_cast< sal_Int32 >( pLeader->GetDffShapeId() ) );
+
+ aProps.SetStringProperty( CREATE_OUSTRING( "GroupName" ), sGroupName );
+ aProps.SetStringProperty( CREATE_OUSTRING( "RefValue" ), rtl::OUString::valueOf( nRefVal++ ) );
+ if ( pLeader->HasCellLink() && !pTbxObj->HasCellLink() )
+ {
+ // propagate cell link info
+ pTbxObj->mxCellLink.reset( new ScAddress( *pLeader->mxCellLink.get() ) );
+ pTbxObj->ApplySheetLinkProps();
+ }
+ pTbxObj = dynamic_cast< XclImpOptionButtonObj* >( GetObjectManager().GetSheetDrawing( GetTab() ).FindDrawObj( pTbxObj->mnNextInGroup ).get() );
+ }
+ else
+ pTbxObj = NULL;
+ } while ( pTbxObj && !( pTbxObj->mnFirstInGroup == 1 ) );
+ }
+ else
+ {
+ // not the leader? try and find it
+ }
}
OUString XclImpOptionButtonObj::DoGetServiceName() const
@@ -2806,6 +2859,17 @@ SdrObject* XclImpPictureObj::DoCreateSdrObj( XclImpDffConverter& rDffConv, const
return xSdrObj.release();
}
+String XclImpPictureObj::GetObjName() const
+{
+ if( IsOcxControl() )
+ {
+ String sName( GetObjectManager().GetOleNameOverride( GetTab(), GetObjId() ) );
+ if ( sName.Len() > 0 )
+ return sName;
+ }
+ return XclImpDrawObjBase::GetObjName();
+}
+
void XclImpPictureObj::DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const
{
if( IsOcxControl() )
@@ -3115,6 +3179,27 @@ XclImpDffConverter::~XclImpDffConverter()
{
}
+String XclImpObjectManager::GetOleNameOverride( SCTAB nTab, sal_uInt16 nObjId )
+{
+ String sOleName;
+ String sCodeName = GetExtDocOptions().GetCodeName( nTab );
+
+ CodeNameToCntrlObjIdInfo::iterator it = maOleCtrlNameOverride.find( sCodeName );
+ if ( it != maOleCtrlNameOverride.end() )
+ {
+ CntrlObjIdToName::iterator it_id = it->second.find( nObjId );
+ if ( it_id != it->second.end() )
+ {
+ sOleName = it_id->second;
+ }
+ }
+ OSL_TRACE("XclImpObjectManager::GetOleNameOverride tab %d, ( module %s ) object id ( %d ) is %s", nTab,
+ rtl::OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), nObjId,
+ rtl::OUStringToOString( sOleName, RTL_TEXTENCODING_UTF8 ).getStr() );
+
+ return sOleName;
+}
+
void XclImpDffConverter::StartProgressBar( sal_Size nProgressSize )
{
mxProgress.reset( new ScfProgressBar( GetDocShell(), STR_PROGRESS_CALCULATING ) );
@@ -3985,27 +4070,27 @@ XclImpObjectManager::XclImpObjectManager( const XclImpRoot& rRoot ) :
XclImpRoot( rRoot )
{
maDefObjNames[ EXC_OBJTYPE_GROUP ] = CREATE_STRING( "Group" );
- maDefObjNames[ EXC_OBJTYPE_LINE ] = CREATE_STRING( "Line" );
- maDefObjNames[ EXC_OBJTYPE_RECTANGLE ] = CREATE_STRING( "Rectangle" );
- maDefObjNames[ EXC_OBJTYPE_OVAL ] = CREATE_STRING( "Oval" );
+ maDefObjNames[ EXC_OBJTYPE_LINE ] = ScGlobal::GetRscString( STR_SHAPE_LINE );
+ maDefObjNames[ EXC_OBJTYPE_RECTANGLE ] = ScGlobal::GetRscString( STR_SHAPE_RECTANGLE );
+ maDefObjNames[ EXC_OBJTYPE_OVAL ] = ScGlobal::GetRscString( STR_SHAPE_OVAL );
maDefObjNames[ EXC_OBJTYPE_ARC ] = CREATE_STRING( "Arc" );
maDefObjNames[ EXC_OBJTYPE_CHART ] = CREATE_STRING( "Chart" );
maDefObjNames[ EXC_OBJTYPE_TEXT ] = CREATE_STRING( "Text" );
- maDefObjNames[ EXC_OBJTYPE_BUTTON ] = CREATE_STRING( "Button" );
+ maDefObjNames[ EXC_OBJTYPE_BUTTON ] = ScGlobal::GetRscString( STR_FORM_BUTTON );
maDefObjNames[ EXC_OBJTYPE_PICTURE ] = CREATE_STRING( "Picture" );
maDefObjNames[ EXC_OBJTYPE_POLYGON ] = CREATE_STRING( "Freeform" );
- maDefObjNames[ EXC_OBJTYPE_CHECKBOX ] = CREATE_STRING( "Check Box" );
- maDefObjNames[ EXC_OBJTYPE_OPTIONBUTTON ] = CREATE_STRING( "Option Button" );
+ maDefObjNames[ EXC_OBJTYPE_CHECKBOX ] = ScGlobal::GetRscString( STR_FORM_CHECKBOX );
+ maDefObjNames[ EXC_OBJTYPE_OPTIONBUTTON ] = ScGlobal::GetRscString( STR_FORM_OPTIONBUTTON );
maDefObjNames[ EXC_OBJTYPE_EDIT ] = CREATE_STRING( "Edit Box" );
- maDefObjNames[ EXC_OBJTYPE_LABEL ] = CREATE_STRING( "Label" );
+ maDefObjNames[ EXC_OBJTYPE_LABEL ] = ScGlobal::GetRscString( STR_FORM_LABEL );
maDefObjNames[ EXC_OBJTYPE_DIALOG ] = CREATE_STRING( "Dialog Frame" );
- maDefObjNames[ EXC_OBJTYPE_SPIN ] = CREATE_STRING( "Spinner" );
- maDefObjNames[ EXC_OBJTYPE_SCROLLBAR ] = CREATE_STRING( "Scroll Bar" );
- maDefObjNames[ EXC_OBJTYPE_LISTBOX ] = CREATE_STRING( "List Box" );
- maDefObjNames[ EXC_OBJTYPE_GROUPBOX ] = CREATE_STRING( "Group Box" );
- maDefObjNames[ EXC_OBJTYPE_DROPDOWN ] = CREATE_STRING( "Drop Down" );
+ maDefObjNames[ EXC_OBJTYPE_SPIN ] = ScGlobal::GetRscString( STR_FORM_SPINNER );
+ maDefObjNames[ EXC_OBJTYPE_SCROLLBAR ] = ScGlobal::GetRscString( STR_FORM_SCROLLBAR );
+ maDefObjNames[ EXC_OBJTYPE_LISTBOX ] = ScGlobal::GetRscString( STR_FORM_LISTBOX );
+ maDefObjNames[ EXC_OBJTYPE_GROUPBOX ] = ScGlobal::GetRscString( STR_FORM_GROUPBOX );
+ maDefObjNames[ EXC_OBJTYPE_DROPDOWN ] = ScGlobal::GetRscString( STR_FORM_DROPDOWN );
maDefObjNames[ EXC_OBJTYPE_NOTE ] = CREATE_STRING( "Comment" );
- maDefObjNames[ EXC_OBJTYPE_DRAWING ] = CREATE_STRING( "AutoShape" );
+ maDefObjNames[ EXC_OBJTYPE_DRAWING ] = ScGlobal::GetRscString( STR_SHAPE_AUTOSHAPE );
}
XclImpObjectManager::~XclImpObjectManager()
diff --git a/sc/source/filter/excel/xiname.cxx b/sc/source/filter/excel/xiname.cxx
index 5c0eac63de92..779edc5c990a 100644
--- a/sc/source/filter/excel/xiname.cxx
+++ b/sc/source/filter/excel/xiname.cxx
@@ -35,7 +35,8 @@
#include "excform.hxx"
// for filter manager
#include "excimp8.hxx"
-
+#include "scextopt.hxx"
+#include "document.hxx"
// ============================================================================
// *** Implementation ***
// ============================================================================
@@ -127,6 +128,7 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) :
maScName = maXclName;
ScfTools::ConvertToScDefinedName( maScName );
}
+ rtl::OUString aRealOrigName = maScName;
// add index for local names
if( nXclTab != EXC_NAME_GLOBAL )
@@ -219,6 +221,25 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) :
pData->GuessPosition(); // calculate base position for relative refs
pData->SetIndex( nXclNameIdx ); // used as unique identifier in formulas
rRangeNames.Insert( pData ); // takes ownership of pData
+ if( nXclTab != EXC_NAME_GLOBAL )
+ {
+ if (GetBiff() == EXC_BIFF8)
+ {
+ ScRange aRange;
+ // discard deleted ranges ( for the moment at least )
+ if ( pData->IsValidReference( aRange ) )
+ {
+ ScExtTabSettings& rTabSett = GetExtDocOptions().GetOrCreateTabSettings( nXclTab );
+ // create a mapping between the unmodified localname to
+ // the name in the global name container for named ranges
+ OSL_TRACE(" mapping local name to global name for tab %d which exists? %s", nXclTab, GetDoc().HasTable( mnScTab ) ? "true" : "false" );
+ SCTAB nTab( static_cast< SCTAB >( mnScTab ) );
+ NameToNameMap* pMap = GetDoc().GetLocalNameMap( nTab );
+ if ( pMap )
+ (*pMap)[ aRealOrigName ] = maScName;
+ }
+ }
+ }
mpScData = pData; // cache for later use
}
}
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index b9b68a91d05f..180c1d588dde 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -72,10 +72,70 @@
using ::std::list;
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+using namespace ::com::sun::star;
+
+typedef ::cppu::WeakImplHelper1< container::XIndexAccess > XIndexAccess_BASE;
+typedef ::std::vector< ColorData > ColorDataVec;
+
+class PaletteIndex : public XIndexAccess_BASE
+{
+public:
+ PaletteIndex( const ColorDataVec& rColorDataTable ) : maColorData( rColorDataTable ) {}
+
+ // Methods XIndexAccess
+ virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException)
+ {
+ return maColorData.size();
+ }
+
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ //--Index; // apparently the palette is already 1 based
+ return uno::makeAny( sal_Int32( maColorData[ Index ] ) );
+ }
+
+ // Methods XElementAcess
+ virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException)
+ {
+ return ::getCppuType( (sal_Int32*)0 );
+ }
+ virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException)
+ {
+ return (maColorData.size() > 0);
+ }
+
+private:
+ ColorDataVec maColorData;
+};
+
+void
+XclImpPalette::ExportPalette()
+{
+ if( SfxObjectShell* pDocShell = mrRoot.GetDocShell() )
+ {
+ // copy values in color palette
+ sal_Int16 nColors = maColorTable.size();
+ ColorDataVec aColors;
+ aColors.resize( nColors );
+ for( sal_uInt16 nIndex = 0; nIndex < nColors; ++nIndex )
+ aColors[ nIndex ] = GetColorData( nIndex );
+
+ uno::Reference< beans::XPropertySet > xProps( pDocShell->GetModel(), uno::UNO_QUERY );
+ if ( xProps.is() )
+ {
+ uno::Reference< container::XIndexAccess > xIndex( new PaletteIndex( aColors ) );
+ xProps->setPropertyValue( CREATE_OUSTRING("ColorPalette"), uno::makeAny( xIndex ) );
+ }
+ }
+
+}
// PALETTE record - color information =========================================
XclImpPalette::XclImpPalette( const XclImpRoot& rRoot ) :
- XclDefaultPalette( rRoot )
+ XclDefaultPalette( rRoot ), mrRoot( rRoot )
{
}
@@ -109,6 +169,7 @@ void XclImpPalette::ReadPalette( XclImpStream& rStrm )
rStrm >> aColor;
maColorTable[ nIndex ] = aColor.GetColor();
}
+ ExportPalette();
}
// FONT record - font information =============================================
diff --git a/sc/source/filter/excel/xlescher.cxx b/sc/source/filter/excel/xlescher.cxx
index 153a5d5ed3cc..0f8c363074b4 100644
--- a/sc/source/filter/excel/xlescher.cxx
+++ b/sc/source/filter/excel/xlescher.cxx
@@ -366,7 +366,7 @@ bool XclControlHelper::FillMacroDescriptor( ScriptEventDescriptor& rDescriptor,
}
String XclControlHelper::ExtractFromMacroDescriptor(
- const ScriptEventDescriptor& rDescriptor, XclTbxEventType eEventType )
+ const ScriptEventDescriptor& rDescriptor, XclTbxEventType eEventType, SfxObjectShell* pShell )
{
if( (rDescriptor.ScriptCode.getLength() > 0) &&
rDescriptor.ScriptType.equalsIgnoreAsciiCaseAscii( "Script" ) &&
diff --git a/sc/source/filter/excel/xltoolbar.cxx b/sc/source/filter/excel/xltoolbar.cxx
new file mode 100644
index 000000000000..5ca4440d73db
--- /dev/null
+++ b/sc/source/filter/excel/xltoolbar.cxx
@@ -0,0 +1,431 @@
+#include "xltoolbar.hxx"
+#include <rtl/ustrbuf.hxx>
+#include <stdarg.h>
+#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
+#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/ui/XImageManager.hpp>
+#include <com/sun/star/ui/ItemType.hpp>
+#include <fstream>
+#include <comphelper/processfactory.hxx>
+#include <vcl/graph.hxx>
+#include <map>
+using namespace com::sun::star;
+
+typedef std::map< sal_Int16, rtl::OUString > IdToString;
+
+class MSOExcelCommandConvertor : public MSOCommandConvertor
+{
+ IdToString msoToOOcmd;
+ IdToString tcidToOOcmd;
+public:
+ MSOExcelCommandConvertor();
+ virtual rtl::OUString MSOCommandToOOCommand( sal_Int16 msoCmd );
+ virtual rtl::OUString MSOTCIDToOOCommand( sal_Int16 key );
+};
+
+MSOExcelCommandConvertor::MSOExcelCommandConvertor()
+{
+/*
+ // mso command id to ooo command string
+ // #FIXME and *HUNDREDS* of id's to added here
+ msoToOOcmd[ 0x20b ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:CloseDoc") );
+ msoToOOcmd[ 0x50 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:Open") );
+
+ // mso tcid to ooo command string
+ // #FIXME and *HUNDREDS* of id's to added here
+ tcidToOOcmd[ 0x9d9 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:Print") );
+*/
+}
+
+rtl::OUString MSOExcelCommandConvertor::MSOCommandToOOCommand( sal_Int16 key )
+{
+ rtl::OUString sResult;
+ IdToString::iterator it = msoToOOcmd.find( key );
+ if ( it != msoToOOcmd.end() )
+ sResult = it->second;
+ return sResult;
+}
+
+rtl::OUString MSOExcelCommandConvertor::MSOTCIDToOOCommand( sal_Int16 key )
+{
+ rtl::OUString sResult;
+ IdToString::iterator it = tcidToOOcmd.find( key );
+ if ( it != tcidToOOcmd.end() )
+ sResult = it->second;
+ return sResult;
+}
+
+
+
+CTBS::CTBS() : bSignature(0), bVersion(0), reserved1(0), reserved2(0), reserved3(0), ctb(0), ctbViews(0), ictbView(0)
+{
+}
+
+CTB::CTB() : nViews( 0 ), ectbid(0)
+{
+}
+
+CTB::CTB(sal_uInt16 nNum ) : nViews( nNum ), ectbid(0)
+{
+}
+
+bool CTB::Read( SvStream *pS )
+{
+ OSL_TRACE("CTB::Read() stream pos 0x%x", pS->Tell() );
+ nOffSet = pS->Tell();
+ tb.Read( pS );
+ for ( sal_uInt16 index = 0; index < nViews; ++index )
+ {
+ TBVisualData aVisData;
+ aVisData.Read( pS );
+ rVisualData.push_back( aVisData );
+ }
+ *pS >> ectbid;
+
+ for ( sal_Int16 index = 0; index < tb.getcCL(); ++index )
+ {
+ TBC aTBC;
+ aTBC.Read( pS );
+ rTBC.push_back( aTBC );
+ }
+ return true;
+}
+
+void CTB::Print( FILE* fp )
+{
+ Indent a;
+ indent_printf( fp, "[ 0x%x ] CTB -- dump\n", nOffSet );
+ indent_printf( fp, " nViews 0x%x\n", nViews);
+ tb.Print( fp );
+
+ std::vector<TBVisualData>::iterator visData_end = rVisualData.end();
+ sal_Int32 counter = 0;
+ for ( std::vector<TBVisualData>::iterator it = rVisualData.begin(); it != visData_end; ++it )
+ {
+
+ indent_printf( fp, " TBVisualData [%d]\n", counter++ );
+ Indent b;
+ it->Print( fp );
+ }
+ indent_printf( fp, " ectbid 0x%x\n", ectbid);
+ std::vector<TBC>::iterator it_end = rTBC.end();
+ counter = 0;
+ for ( std::vector<TBC>::iterator it = rTBC.begin(); it != it_end; ++it )
+ {
+ indent_printf( fp, " TBC [%d]\n", counter++);
+ Indent c;
+ it->Print( fp );
+ }
+}
+
+bool CTB::IsMenuToolbar()
+{
+ return tb.IsMenuToolbar();
+}
+
+bool CTB::ImportMenuTB( CTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& xMenuDesc, CustomToolBarImportHelper& helper )
+{
+ sal_Int32 index = 0;
+ for ( std::vector< TBC >::iterator it = rTBC.begin(); it != rTBC.end(); ++it, ++index )
+ {
+ if ( !it->ImportToolBarControl( rWrapper, xMenuDesc, helper, IsMenuToolbar() ) )
+ return false;
+ }
+ return true;
+}
+
+bool CTB::ImportCustomToolBar( CTBWrapper& rWrapper, CustomToolBarImportHelper& helper )
+{
+
+ static rtl::OUString sToolbarPrefix( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/custom_" ) );
+ bool bRes = false;
+ try
+ {
+ if ( !tb.IsEnabled() )
+ return true; // didn't fail, just ignoring
+
+ // Create default setting
+ uno::Reference< container::XIndexContainer > xIndexContainer( helper.getCfgManager()->createSettings(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xIndexContainer, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xIndexContainer, uno::UNO_QUERY_THROW );
+ WString& name = tb.getName();
+ // set UI name for toolbar
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UIName") ), uno::makeAny( name.getString() ) );
+
+ rtl::OUString sToolBarName = sToolbarPrefix.concat( name.getString() );
+ for ( std::vector< TBC >::iterator it = rTBC.begin(); it != rTBC.end(); ++it )
+ {
+ if ( !it->ImportToolBarControl( rWrapper, xIndexContainer, helper, IsMenuToolbar() ) )
+ return false;
+ }
+
+ OSL_TRACE("Name of toolbar :-/ %s", rtl::OUStringToOString( sToolBarName, RTL_TEXTENCODING_UTF8 ).getStr() );
+
+ helper.getCfgManager()->insertSettings( sToolBarName, xIndexAccess );
+ helper.applyIcons();
+#if 1
+ uno::Reference< ui::XUIConfigurationPersistence > xPersistence( helper.getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
+ xPersistence->store();
+
+ xPersistence.set( helper.getCfgManager(), uno::UNO_QUERY_THROW );
+ xPersistence->store();
+#endif
+
+ bRes = true;
+ }
+ catch( uno::Exception& )
+ {
+ bRes = false;
+ }
+ return bRes;
+}
+bool CTBS::Read( SvStream *pS )
+{
+ OSL_TRACE("CTBS::Read() stream pos 0x%x", pS->Tell() );
+ nOffSet = pS->Tell();
+ *pS >> bSignature >> bVersion >> reserved1 >> reserved2 >> reserved3 >> ctb >> ctbViews >> ictbView;
+ return true;
+}
+
+void CTBS::Print( FILE* fp )
+{
+ Indent a;
+ indent_printf( fp, "[ 0x%x ] CTBS -- dump\n", nOffSet );
+
+ indent_printf( fp, " bSignature 0x%x\n", bSignature);
+ indent_printf( fp, " bVersion 0x%x\n", bVersion);
+
+ indent_printf( fp, " reserved1 0x%x\n", reserved1 );
+ indent_printf( fp, " reserved2 0x%x\n", reserved2 );
+ indent_printf( fp, " reserved3 0x%x\n", reserved3 );
+
+ indent_printf( fp, " ctb 0x%x\n", ctb );
+ indent_printf( fp, " ctbViews 0x%x\n", ctbViews );
+ indent_printf( fp, " ictbView 0x%x\n", ictbView );
+}
+
+TBC::TBC()
+{
+}
+
+bool
+TBC::Read(SvStream *pS)
+{
+ OSL_TRACE("TBC::Read() stream pos 0x%x", pS->Tell() );
+ nOffSet = pS->Tell();
+ if ( !tbch.Read( pS ) )
+ return false;
+ sal_uInt16 tcid = tbch.getTcID();
+ sal_uInt8 tct = tbch.getTct();
+ if ( ( tcid != 0x0001 && tcid != 0x06CC && tcid != 0x03D8 && tcid != 0x03EC && tcid != 0x1051 ) && ( ( tct > 0 && tct < 0x0B ) || ( ( tct > 0x0B && tct < 0x10 ) || tct == 0x15 ) ) )
+ {
+ tbcCmd.reset( new TBCCmd );
+ if ( ! tbcCmd->Read( pS ) )
+ return false;
+ }
+ if ( tct != 0x16 )
+ {
+ tbcd.reset( new TBCData( tbch ) );
+ if ( !tbcd->Read( pS ) )
+ return false;
+ }
+ return true;
+}
+
+
+void
+TBC::Print(FILE* fp)
+{
+ Indent a;
+ indent_printf( fp, "[ 0x%x ] TBC -- dump\n", nOffSet );
+ tbch.Print( fp );
+ if ( tbcCmd.get() )
+ tbcCmd->Print( fp );
+ if ( tbcd.get() )
+ tbcd->Print( fp );
+}
+
+bool TBC::ImportToolBarControl( CTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper, bool bIsMenuToolbar )
+{
+ // how to identify built-in-command ?
+// bool bBuiltin = false;
+ if ( tbcd.get() )
+ {
+ std::vector< css::beans::PropertyValue > props;
+/*
+ if ( bBuiltin )
+ {
+ rtl::OUString sCommand = helper.MSOCommandToOOCommand( cmdId );
+ if ( sCommand.getLength() > 0 )
+ {
+ beans::PropertyValue aProp;
+
+ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CommandURL") );
+ aProp.Value <<= sCommand;
+ props.push_back( aProp );
+ }
+
+ }
+*/
+ bool bBeginGroup = false;
+ if ( ! tbcd->ImportToolBarControl( helper, props, bBeginGroup, bIsMenuToolbar ) )
+ return false;
+ TBCMenuSpecific* pMenu = tbcd->getMenuSpecific();
+ if ( pMenu )
+ {
+ // search for CTB with the appropriate name ( it contains the
+ // menu items, although we cannot import ( or create ) a menu on
+ // a custom toolbar we can import the menu items in a separate
+ // toolbar ( better than nothing )
+ CTB* pCustTB = rWrapper.GetCustomizationData( pMenu->Name() );
+ if ( pCustTB )
+ {
+ uno::Reference< container::XIndexContainer > xMenuDesc;
+ uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+ xMenuDesc.set( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.IndexedPropertyValues" ) ) ), uno::UNO_QUERY_THROW );
+ if ( !pCustTB->ImportMenuTB( rWrapper, xMenuDesc, helper ) )
+ return false;
+ if ( !bIsMenuToolbar )
+ {
+ if ( !helper.createMenu( pMenu->Name(), uno::Reference< container::XIndexAccess >( xMenuDesc, uno::UNO_QUERY ), true ) )
+ return false;
+ }
+ else
+ {
+ beans::PropertyValue aProp;
+ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ItemDescriptorContainer") );
+ aProp.Value <<= xMenuDesc;
+ props.push_back( aProp );
+ }
+ }
+ }
+
+ if ( bBeginGroup )
+ {
+ // insert spacer
+ uno::Sequence< beans::PropertyValue > sProps( 1 );
+ sProps[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Type") );
+ sProps[ 0 ].Value = uno::makeAny( ui::ItemType::SEPARATOR_LINE );
+ toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( sProps ) );
+ }
+ uno::Sequence< beans::PropertyValue > sProps( props.size() );
+ beans::PropertyValue* pProp = sProps.getArray();
+
+ for ( std::vector< css::beans::PropertyValue >::iterator it = props.begin(); it != props.end(); ++it, ++pProp )
+ *pProp = *it;
+
+ toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( sProps ) );
+ }
+ return true;
+}
+
+void
+TBCCmd::Print(FILE* fp)
+{
+ Indent a;
+ indent_printf( fp, " TBCCmd -- dump\n" );
+ indent_printf( fp, " cmdID 0x%x\n", cmdID );
+ indent_printf( fp, " A ( fHideDrawing ) %s\n", A ? "true" : "false" );
+ indent_printf( fp, " B ( reserved - ignored ) %s\n", A ? "true" : "false" );
+ indent_printf( fp, " cmdType 0x%x\n", cmdType );
+ indent_printf( fp, " C ( reserved - ignored ) %s\n", A ? "true" : "false" );
+ indent_printf( fp, " reserved3 0x%x\n", reserved3 );
+}
+
+bool TBCCmd::Read( SvStream *pS )
+{
+ OSL_TRACE("TBCCmd::Read() stream pos 0x%x", pS->Tell() );
+ nOffSet = pS->Tell();
+ *pS >> cmdID;
+ sal_uInt16 temp;
+ *pS >> temp;
+ OSL_TRACE("TBCmd temp = 0x%x", temp );
+ A = (temp & 0x8000 ) == 0x8000;
+ B = (temp & 0x4000) == 0x4000;
+ cmdType = ( temp & 0x3E00 ) >> 9;
+ C = ( temp & 0x100 ) == 0x100;
+ reserved3 = ( temp & 0xFF );
+ return true;
+}
+
+CTBWrapper::CTBWrapper()
+{
+}
+
+CTBWrapper::~CTBWrapper()
+{
+}
+
+bool
+CTBWrapper::Read( SvStream *pS)
+{
+ OSL_TRACE("CTBWrapper::Read() stream pos 0x%x", pS->Tell() );
+ nOffSet = pS->Tell();
+ if ( !ctbSet.Read( pS ) )
+ return false;
+ for ( sal_uInt16 index = 0; index < ctbSet.ctb; ++index )
+ {
+ CTB aCTB( ctbSet.ctbViews );
+ if ( !aCTB.Read( pS ) )
+ return false;
+ rCTB.push_back( aCTB );
+ }
+ return true;
+}
+
+void
+CTBWrapper::Print( FILE* fp )
+{
+ Indent a;
+ indent_printf( fp, "[ 0x%x ] CTBWrapper -- dump\n", nOffSet );
+ ctbSet.Print( fp );
+ std::vector<CTB>::iterator it_end = rCTB.end();
+ for ( std::vector<CTB>::iterator it = rCTB.begin(); it != it_end; ++it )
+ {
+ Indent b;
+ it->Print( fp );
+ }
+}
+
+CTB* CTBWrapper::GetCustomizationData( const rtl::OUString& sTBName )
+{
+ CTB* pCTB = NULL;
+ for ( std::vector< CTB >::iterator it = rCTB.begin(); it != rCTB.end(); ++it )
+ {
+ if ( it->GetName().equals( sTBName ) )
+ {
+ pCTB = &(*it);
+ break;
+ }
+ }
+ return pCTB;
+}
+
+bool CTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
+{
+ std::vector<CTB>::iterator it_end = rCTB.end();
+ for ( std::vector<CTB>::iterator it = rCTB.begin(); it != it_end; ++it )
+ {
+ // for each customtoolbar
+ uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+ uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xAppCfgSupp( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ) ) ), uno::UNO_QUERY_THROW );
+ CustomToolBarImportHelper helper( rDocSh, xAppCfgSupp->getUIConfigurationManager( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument" ) ) ) );
+ helper.setMSOCommandMap( new MSOExcelCommandConvertor() );
+ // Ignore menu toolbars, excel doesn't ( afaics ) store
+ // menu customizations ( but you can have menus in a customtoolbar
+ // such menus will be dealt with when they are encountered
+ // as part of importing the appropriate MenuSpecific toolbar control )
+
+
+ if ( !(*it).IsMenuToolbar() )
+ {
+ if ( !(*it).ImportCustomToolBar( *this, helper ) )
+ return false;
+ }
+ }
+ return true;
+}
diff --git a/sc/source/filter/excel/xltoolbar.hxx b/sc/source/filter/excel/xltoolbar.hxx
new file mode 100644
index 000000000000..5152b6b398c4
--- /dev/null
+++ b/sc/source/filter/excel/xltoolbar.hxx
@@ -0,0 +1,95 @@
+#ifndef _XLTOOLBAR_HXX
+#define _XLTOOLBAR_HXX
+
+#include <filter/msfilter/mstoolbar.hxx>
+
+namespace css = ::com::sun::star;
+
+class CTBWrapper;
+// hmm I don't normally use these packed structures
+// but.. hey always good to do something different
+class TBCCmd : public TBBase
+{
+public:
+ TBCCmd() : cmdID(0), A(0), B(0), cmdType(0), C(0), reserved3(0) {}
+ sal_uInt16 cmdID;
+ sal_uInt16 A:1;
+ sal_uInt16 B:1;
+ sal_uInt16 cmdType:5;
+ sal_uInt16 C:1;
+ sal_uInt16 reserved3:8;
+ bool Read( SvStream* pS );
+ void Print(FILE* fp);
+};
+
+class TBC : public TBBase
+{
+ TBCHeader tbch;
+ boost::shared_ptr<TBCCmd> tbcCmd; // optional
+ boost::shared_ptr<TBCData> tbcd;
+public:
+ TBC();
+ ~TBC(){}
+ void Print( FILE* );
+ bool Read(SvStream *pS);
+ bool ImportToolBarControl( CTBWrapper&, const com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper, bool bIsMenuBar );
+};
+
+class CTB : public TBBase
+{
+ sal_uInt16 nViews;
+ TB tb;
+ std::vector<TBVisualData> rVisualData;
+ sal_uInt32 ectbid;
+ std::vector< TBC > rTBC;
+ bool ImportCustomToolBar_Impl( CTBWrapper&, CustomToolBarImportHelper& );
+public:
+ CTB();
+ CTB(sal_uInt16);
+ ~CTB(){}
+ void Print( FILE* );
+ bool Read(SvStream *pS);
+ bool IsMenuToolbar();
+ bool ImportCustomToolBar( CTBWrapper&, CustomToolBarImportHelper& );
+ bool ImportMenuTB( CTBWrapper&, const css::uno::Reference< css::container::XIndexContainer >&, CustomToolBarImportHelper& );
+ rtl::OUString GetName() { return tb.getName().getString(); }
+
+
+};
+
+class CTBS : public TBBase
+{
+public:
+ sal_uInt8 bSignature;
+ sal_uInt8 bVersion;
+ sal_uInt16 reserved1;
+ sal_uInt16 reserved2;
+ sal_uInt16 reserved3;
+ sal_uInt16 ctb;
+ sal_uInt16 ctbViews;
+ sal_uInt16 ictbView;
+ CTBS(const CTBS&);
+ CTBS& operator = ( const CTBS&);
+ CTBS();
+ ~CTBS(){}
+ void Print( FILE* );
+ bool Read(SvStream *pS);
+};
+
+class CTBWrapper : public TBBase
+{
+ CTBS ctbSet;
+
+ std::vector< CTB > rCTB;
+
+public:
+ CTBWrapper();
+ ~CTBWrapper();
+ bool Read(SvStream *pS);
+ void Print( FILE* );
+ bool ImportCustomToolBar( SfxObjectShell& rDocSh );
+ CTB* GetCustomizationData( const rtl::OUString& name );
+};
+
+
+#endif //_XLTOOLBAR_HXX
diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx
index 0dd988d67586..5fbcdc4db855 100644
--- a/sc/source/filter/excel/xltools.cxx
+++ b/sc/source/filter/excel/xltools.cxx
@@ -689,7 +689,7 @@ void XclTools::SkipSubStream( XclImpStream& rStrm )
// Basic macro names ----------------------------------------------------------
-const OUString XclTools::maSbMacroPrefix( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:Standard." ) );
+const OUString XclTools::maSbMacroPrefix( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:" ) );
const OUString XclTools::maSbMacroSuffix( RTL_CONSTASCII_USTRINGPARAM( "?language=Basic&location=document" ) );
OUString XclTools::GetSbMacroUrl( const String& rMacroName, SfxObjectShell* pDocShell )
@@ -714,7 +714,10 @@ String XclTools::GetXclMacroName( const OUString& rSbMacroUrl )
sal_Int32 nMacroNameLen = nSbMacroUrlLen - maSbMacroPrefix.getLength() - maSbMacroSuffix.getLength();
if( (nMacroNameLen > 0) && rSbMacroUrl.matchIgnoreAsciiCase( maSbMacroPrefix, 0 ) &&
rSbMacroUrl.matchIgnoreAsciiCase( maSbMacroSuffix, nSbMacroUrlLen - maSbMacroSuffix.getLength() ) )
- return rSbMacroUrl.copy( maSbMacroPrefix.getLength(), nMacroNameLen );
+ {
+ sal_Int32 nPrjDot = rSbMacroUrl.indexOf( '.', maSbMacroPrefix.getLength() ) + 1;
+ return rSbMacroUrl.copy( nPrjDot, nSbMacroUrlLen - nPrjDot - maSbMacroSuffix.getLength() );
+ }
return String::EmptyString();
}
diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx
index 7e4cca15dfe1..0f46a125b12c 100644
--- a/sc/source/filter/inc/excimp8.hxx
+++ b/sc/source/filter/inc/excimp8.hxx
@@ -57,6 +57,9 @@ public:
virtual FltError Read( void );
protected:
+ // represents codename ( and associated modules )
+ // not speficied directly in the binary format
+ std::vector< String > AutoGeneratedCodeNames;
ExcScenarioList aScenList;
void Calccount( void ); // 0x0C
diff --git a/sc/source/filter/inc/xcl97esc.hxx b/sc/source/filter/inc/xcl97esc.hxx
index fde03337cc0f..d590e44b15ed 100644
--- a/sc/source/filter/inc/xcl97esc.hxx
+++ b/sc/source/filter/inc/xcl97esc.hxx
@@ -70,6 +70,15 @@ class XclExpOcxControlObj;
#else
class XclExpTbxControlObj;
#endif
+class XclExpShapeObj;
+class EscherExHostAppData;
+class ShapeInteractionHelper
+{
+public:
+ static XclExpShapeObj* CreateShapeObj( XclExpObjectManager& rObjMgr, const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape >& xShape );
+ static void PopulateShapeInteractionInfo( XclExpObjectManager& rObjMgr, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, EscherExHostAppData& rHostAppData );
+};
class XclEscherEx : public EscherEx, protected XclExpRoot
{
diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx
index 201562fa752c..0c35433760d0 100644
--- a/sc/source/filter/inc/xcl97rec.hxx
+++ b/sc/source/filter/inc/xcl97rec.hxx
@@ -220,7 +220,7 @@ public:
class XclObjAny : public XclObj
{
-private:
+protected:
virtual void WriteSubRecs( XclExpStream& rStrm );
public:
diff --git a/sc/source/filter/inc/xecontent.hxx b/sc/source/filter/inc/xecontent.hxx
index 50c9466d2801..a999d97cb1f2 100644
--- a/sc/source/filter/inc/xecontent.hxx
+++ b/sc/source/filter/inc/xecontent.hxx
@@ -113,6 +113,8 @@ public:
inline const String* GetRepr() const { return mxRepr.get(); }
virtual void SaveXml( XclExpXmlStream& rStrm );
+
+ virtual void WriteEmbeddedData( XclExpStream& rStrm );
private:
/** Builds file name from the passed file URL. Tries to convert to relative file name.
@param rnLevel (out-param) The parent directory level.
diff --git a/sc/source/filter/inc/xeescher.hxx b/sc/source/filter/inc/xeescher.hxx
index d227db184f1a..51f1c8a12311 100644
--- a/sc/source/filter/inc/xeescher.hxx
+++ b/sc/source/filter/inc/xeescher.hxx
@@ -207,6 +207,34 @@ private:
sal_uInt16 mnEntryCount; /// Number of entries in source range.
};
+class XclMacroHelper : public XclExpControlHelper
+{
+protected:
+ XclTokenArrayRef mxMacroLink; /// Token array containing a link to an attached macro.
+
+public:
+ explicit XclMacroHelper( const XclExpRoot& rRoot );
+ virtual ~XclMacroHelper();
+ /** Writes an ftMacro subrecord containing a macro link, or nothing, if no macro present. */
+ void WriteMacroSubRec( XclExpStream& rStrm );
+ /** Sets the name of a macro for object of passed type
+ @return true = The passed event descriptor was valid, macro name has been found. */
+ bool SetMacroLink( const ::com::sun::star::script::ScriptEventDescriptor& rEvent, const XclTbxEventType& nEventType );
+
+ /** Sets the name of a macro
+ @return true = The passed macro name has been found. */
+ bool SetMacroLink( const String& rMacro );
+};
+
+class XclExpShapeObj : public XclObjAny, public XclMacroHelper
+{
+public:
+ explicit XclExpShapeObj( XclExpObjectManager& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
+ virtual ~XclExpShapeObj();
+private:
+ virtual void WriteSubRecs( XclExpStream& rStrm );
+};
+
// ----------------------------------------------------------------------------
#if EXC_EXP_OCX_CTRL
@@ -234,7 +262,7 @@ private:
#else
/** Represents an OBJ record for an TBX form control. */
-class XclExpTbxControlObj : public XclObj, public XclExpControlHelper
+class XclExpTbxControlObj : public XclObj, public XclMacroHelper
{
public:
explicit XclExpTbxControlObj(
@@ -249,8 +277,6 @@ public:
private:
virtual void WriteSubRecs( XclExpStream& rStrm );
- /** Writes an ftMacro subrecord containing a macro link, or nothing, if no macro present. */
- void WriteMacroSubRec( XclExpStream& rStrm );
/** Writes a subrecord containing a cell link, or nothing, if no link present. */
void WriteCellLinkSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId );
/** Writes the ftSbs sub structure containing scrollbar data. */
@@ -258,7 +284,6 @@ private:
private:
ScfInt16Vec maMultiSel; /// Indexes of all selected entries in a multi selection.
- XclTokenArrayRef mxMacroLink; /// Token array containing a link to an attached macro.
XclTbxEventType meEventType; /// Type of supported macro event.
sal_Int32 mnHeight; /// Height of the control.
sal_uInt16 mnState; /// Checked/unchecked state.
diff --git a/sc/source/filter/inc/xiescher.hxx b/sc/source/filter/inc/xiescher.hxx
index fc93af420667..f465753c4cc1 100644
--- a/sc/source/filter/inc/xiescher.hxx
+++ b/sc/source/filter/inc/xiescher.hxx
@@ -30,6 +30,7 @@
#include <vector>
#include <map>
+#include <hash_map>
#include <filter/msfilter/msdffimp.hxx>
#include <filter/msfilter/msocximex.hxx>
#include <vcl/graph.hxx>
@@ -92,7 +93,7 @@ public:
/** Returns the Excel object type from OBJ record. */
inline sal_uInt16 GetObjType() const { return mnObjType; }
/** Returns the name of this object, may generate a default name. */
- String GetObjName() const;
+ virtual String GetObjName() const;
/** Returns associated macro name, if set, otherwise zero length string. */
inline const String& GetMacroName() const { return maMacroName; }
@@ -172,7 +173,7 @@ protected:
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
/** Derived classes may perform additional processing for the passed SdrObject after insertion. */
virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
-
+ SCTAB GetTab() const { return mnTab; }
private:
/** Reads the contents of a BIFF3 OBJ record. */
void ImplReadObj3( XclImpStream& rStrm );
@@ -186,6 +187,7 @@ private:
private:
XclObjAnchor maAnchor; /// The position of the object in its parent.
sal_uInt16 mnObjId; /// The object identifier (unique per drawing).
+ SCTAB mnTab; /// Location of object
sal_uInt16 mnObjType; /// The Excel object type from OBJ record.
sal_uInt32 mnDffShapeId; /// Shape ID from DFF stream.
sal_uInt32 mnDffFlags; /// Shape flags from DFF stream.
@@ -502,6 +504,10 @@ protected:
/** Derived classes will set additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
+ void ApplySheetLinkProps() const;
+ mutable ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+ mxShape; /// The UNO wrapper of the control shape.
+ ScfRef< ScAddress > mxCellLink; /// Linked cell in the Calc document.
private:
/** Reads a list of cell ranges from a formula at the current stream position. */
void ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm );
@@ -510,9 +516,6 @@ private:
private:
const XclImpRoot& mrRoot; /// Not derived from XclImpRoot to allow multiple inheritance.
- mutable ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
- mxShape; /// The UNO wrapper of the control shape.
- ScfRef< ScAddress > mxCellLink; /// Linked cell in the Calc document.
ScfRef< ScRange > mxSrcRange; /// Source data range in the Calc document.
XclCtrlBindMode meBindMode; /// Value binding mode.
};
@@ -614,6 +617,7 @@ protected:
virtual XclTbxEventType DoGetEventType() const;
protected:
+ void ApplyGrouping( XclImpOptionButtonObj& rLeader, sal_Int32 nRefVal );
sal_uInt16 mnNextInGroup; /// Next option button in a group.
sal_uInt16 mnFirstInGroup; /// 1 = Button is the first in a group.
};
@@ -862,7 +866,8 @@ class XclImpPictureObj : public XclImpRectObj, public XclImpControlHelper
{
public:
explicit XclImpPictureObj( const XclImpRoot& rRoot );
-
+ /** Returns the ObjectName - can use non-obvious lookup for override in the associated vba document module stream**/
+ virtual String GetObjName() const;
/** Returns the graphic imported from the IMGDATA record. */
inline const Graphic& GetGraphic() const { return maGraphic; }
/** Returns the visible area of the imported graphic. */
@@ -1207,6 +1212,8 @@ private:
/** Stores all drawing and OLE objects and additional data related to these objects. */
class XclImpObjectManager : protected XclImpRoot
{
+typedef std::hash_map< sal_Int32, String > CntrlObjIdToName;
+typedef std::map< String, CntrlObjIdToName > CodeNameToCntrlObjIdInfo;
public:
explicit XclImpObjectManager( const XclImpRoot& rRoot );
virtual ~XclImpObjectManager();
@@ -1223,9 +1230,41 @@ public:
String GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const;
/** Returns the used area in the sheet with the passed index. */
ScRange GetUsedArea( SCTAB nScTab ) const;
+ void SetOleNameOverrideInfo( const CodeNameToCntrlObjIdInfo& rOverrideInfo ) { maOleCtrlNameOverride = rOverrideInfo; }
+ String GetOleNameOverride( SCTAB nTab, sal_uInt16 nObjId );
+ // ------------------------------------------------------------------------
+private:
+
+ CodeNameToCntrlObjIdInfo maOleCtrlNameOverride;
+
+ /** Reads and returns a bitmap from WMF/PICT format. */
+ static void ReadWmf( Graphic& rGraphic, XclImpStream& rStrm );
+ /** Reads and returns a bitmap from BMP format. */
+ static void ReadBmp( Graphic& rGraphic, XclImpStream& rStrm );
+
+ /** Reads contents of an DFF record and append data to internal DFF stream. */
+ void ReadDffRecord( XclImpStream& rStrm );
+ /** Reads a BIFF8 OBJ record following an MSODRAWING record. */
+ void ReadObj8( XclImpStream& rStrm );
+ /** Reads the TXO record and following CONTINUE records containing string and formatting. */
+ void ReadTxo( XclImpStream& rStrm );
+
+ /** Reads a BIFF3-BIFF5 NOTE record. */
+ void ReadNote3( XclImpStream& rStrm );
+ /** Reads a BIFF8 NOTE record. */
+ void ReadNote8( XclImpStream& rStrm );
+
+ /** Returns the size of the progress bar shown while processing all objects. */
+ sal_Size GetProgressSize() const;
// ------------------------------------------------------------------------
private:
+ typedef ::std::map< sal_Size, XclImpDrawObjRef > XclImpObjMap;
+ typedef ::std::map< XclObjId, XclImpDrawObjRef > XclImpObjMapById;
+ typedef ScfRef< XclImpObjTextData > XclImpObjTextRef;
+ typedef ::std::map< sal_Size, XclImpObjTextRef > XclImpObjTextMap;
+ typedef ::std::vector< XclObjId > XclObjIdVec;
+
typedef ::std::map< sal_uInt16, String > DefObjNameMap;
typedef ScfRef< XclImpSheetDrawing > XclImpSheetDrawingRef;
typedef ::std::map< SCTAB, XclImpSheetDrawingRef > XclImpSheetDrawingMap;
diff --git a/sc/source/filter/inc/xistyle.hxx b/sc/source/filter/inc/xistyle.hxx
index a89122a7618a..d38fe6478512 100644
--- a/sc/source/filter/inc/xistyle.hxx
+++ b/sc/source/filter/inc/xistyle.hxx
@@ -70,8 +70,10 @@ public:
void ReadPalette( XclImpStream& rStrm );
private:
+ void ExportPalette();
typedef ::std::vector< ColorData > ColorDataVec;
ColorDataVec maColorTable; /// Colors read from file.
+ const XclImpRoot& mrRoot;
};
// FONT record - font information =============================================
diff --git a/sc/source/filter/inc/xlescher.hxx b/sc/source/filter/inc/xlescher.hxx
index 921da6b8741b..b1fe7410ecea 100644
--- a/sc/source/filter/inc/xlescher.hxx
+++ b/sc/source/filter/inc/xlescher.hxx
@@ -441,7 +441,7 @@ public:
/** Tries to extract an Excel macro name from the passed macro descriptor. */
static String ExtractFromMacroDescriptor(
const ::com::sun::star::script::ScriptEventDescriptor& rDescriptor,
- XclTbxEventType eEventType );
+ XclTbxEventType eEventType, SfxObjectShell* pShell = NULL );
};
// ============================================================================
diff --git a/sc/source/filter/xcl97/xcl97esc.cxx b/sc/source/filter/xcl97/xcl97esc.cxx
index a7c6dee67dc5..2f1e65297bfa 100644
--- a/sc/source/filter/xcl97/xcl97esc.cxx
+++ b/sc/source/filter/xcl97/xcl97esc.cxx
@@ -54,6 +54,9 @@
#include "global.hxx"
#include "document.hxx"
#include "drwlayer.hxx"
+#include "xecontent.hxx"
+#include <editeng/flditem.hxx>
+#include "userdat.hxx"
#include "xcl97rec.hxx"
#include "xehelper.hxx"
#include "xechart.hxx"
@@ -256,7 +259,8 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape
{
// #107540# ignore permanent note shapes
// #i12190# do not ignore callouts (do not filter by object type ID)
- pCurrXclObj = new XclObjAny( mrObjMgr ); // just a metafile
+ pCurrXclObj = ShapeInteractionHelper::CreateShapeObj( mrObjMgr, rxShape );
+ ShapeInteractionHelper::PopulateShapeInteractionInfo( mrObjMgr, rxShape, *pCurrAppData );
}
}
if ( pCurrXclObj )
@@ -359,7 +363,6 @@ EscherExHostAppData* XclEscherEx::EnterAdditionalTextGroup()
return pCurrAppData;
}
-
void XclEscherEx::EndDocument()
{
if( mbIsRootDff )
@@ -478,6 +481,7 @@ void XclEscherEx::DeleteCurrAppData()
delete pCurrAppData->GetClientAnchor();
// delete pCurrAppData->GetClientData();
delete pCurrAppData->GetClientTextbox();
+ delete pCurrAppData->GetInteractionInfo();
delete pCurrAppData;
}
}
@@ -509,4 +513,40 @@ void XclEscherClientTextbox::WriteData( EscherEx& /*rEx*/ ) const
pXclObj->SetText( GetRoot(), rTextObj );
}
+XclExpShapeObj*
+ShapeInteractionHelper::CreateShapeObj( XclExpObjectManager& rObjMgr, const Reference< XShape >& xShape )
+{
+ return new XclExpShapeObj( rObjMgr, xShape );
+}
+
+void
+ShapeInteractionHelper::PopulateShapeInteractionInfo( XclExpObjectManager& rObjMgr, const Reference< XShape >& xShape, EscherExHostAppData& rHostAppData )
+{
+ try
+ {
+ SvMemoryStream* pMemStrm = NULL;
+ rtl::OUString sHyperLink;
+ rtl::OUString sMacro;
+ if ( ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( ::GetSdrObjectFromXShape( xShape ) ) )
+ {
+ sHyperLink = pInfo->GetHlink();
+ sMacro = pInfo->GetMacro();
+ }
+ if ( sHyperLink.getLength() > 0 )
+ {
+ pMemStrm = new SvMemoryStream();
+ XclExpStream tmpStream( *pMemStrm, rObjMgr.GetRoot() );
+ ScAddress dummyAddress;
+ SvxURLField aUrlField;
+ aUrlField.SetURL( sHyperLink );
+ XclExpHyperlink hExpHlink( rObjMgr.GetRoot(), aUrlField, dummyAddress );
+ hExpHlink.WriteEmbeddedData( tmpStream );
+ }
+ if ( ( sHyperLink.getLength() > 0 ) || ( sMacro.getLength() > 0 ) )
+ rHostAppData.SetInteractionInfo( new InteractionInfo( pMemStrm, true ) );
+ }
+ catch( Exception& )
+ {
+ }
+}
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 6a72dfbc60fb..b7bd7876413d 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3204,7 +3204,34 @@ void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape,
}
}
if (!bIsChart)
+ {
+ // #i66550 HLINK_FOR_SHAPES
+ rtl::OUString sHlink;
+ uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );
+ if ( xProps.is() )
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_HYPERLINK ) ) ) >>= sHlink;
+
+ std::auto_ptr< SvXMLElementExport > pDrawA;
+ // enlose shapes with <draw:a> element only if sHlink contains something
+ if ( sHlink.getLength() > 0 )
+ {
+ // need to get delete the attributes that are pre-loaded
+ // for the shape export ( otherwise they will become
+ // attributes of the draw:a element ) This *shouldn't*
+ // affect performance adversely as there are only a
+ // couple of attributes involved
+ uno::Reference< xml::sax::XAttributeList > xSaveAttribs( new SvXMLAttributeList( GetAttrList() ) );
+ ClearAttrList();
+ // Add Hlink
+ AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
+ AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sHlink);
+ pDrawA.reset( new SvXMLElementExport( *this, XML_NAMESPACE_DRAW, XML_A, sal_False, sal_False ) );
+ // Attribute list has been cleared by previous operation
+ // re-add pre-loaded attributes
+ AddAttributeList( xSaveAttribs );
+ }
GetShapeExport()->exportShape(xShape, SEF_DEFAULT, pPoint);
+ }
IncrementProgressBar(sal_False);
}
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index e9141f40a871..cc1f1107790f 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -80,6 +80,8 @@
#include "tpusrlst.hxx" //add for ScTpUserLists
#include "tpview.hxx" //add for ScTpContentOptions
#include "tpformula.hxx"
+//for dataform
+#include "datafdlg.hxx" //add for ScDataFormDlg
// ause
#include "editutil.hxx"
@@ -93,6 +95,8 @@ IMPL_ABSTDLG_BASE(AbstractScDataPilotDatabaseDlg_Impl); //add for ScDataPilotDat
IMPL_ABSTDLG_BASE(AbstractScDataPilotSourceTypeDlg_Impl); //add for ScDataPilotSourceTypeDlg
IMPL_ABSTDLG_BASE(AbstractScDataPilotServiceDlg_Impl); //add for ScDataPilotServiceDlg
IMPL_ABSTDLG_BASE(AbstractScDeleteCellDlg_Impl); //add for ScDeleteCellDlg
+//for dataform
+IMPL_ABSTDLG_BASE(AbstractScDataFormDlg_Impl); //add for ScDataFormDlg
IMPL_ABSTDLG_BASE(AbstractScDeleteContentsDlg_Impl); //add for ScDeleteContentsDlg
IMPL_ABSTDLG_BASE(AbstractScFillSeriesDlg_Impl); //add for ScFillSeriesDlg
IMPL_ABSTDLG_BASE(AbstractScGroupDlg_Impl); //add for ScGroupDlg
@@ -864,6 +868,26 @@ AbstractScDeleteCellDlg* ScAbstractDialogFactory_Impl::CreateScDeleteCellDlg( Wi
//add for ScDeleteCellDlg end
+//add for ScDataFormDlg begin
+AbstractScDataFormDlg* ScAbstractDialogFactory_Impl::CreateScDataFormDlg( Window* pParent, int nId, ScTabViewShell* pTabViewShell )
+{
+ ScDataFormDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_DATAFORM :
+ pDlg = new ScDataFormDlg( pParent, pTabViewShell);
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScDataFormDlg_Impl( pDlg );
+ return 0;
+}
+
+//add for ScDataFormDlg end
+
//add for ScDeleteContentsDlg begin
AbstractScDeleteContentsDlg* ScAbstractDialogFactory_Impl::CreateScDeleteContentsDlg(Window* pParent,int nId, //add for ScDeleteContentsDlg
USHORT nCheckDefaults )
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index d0d3d0879e5f..4770923ea6d1 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -37,6 +37,7 @@ class ScDataPilotDatabaseDlg;
class ScDataPilotSourceTypeDlg;
class ScDataPilotServiceDlg;
class ScDeleteCellDlg;
+class ScDataFormDlg;
class ScDeleteContentsDlg;
class ScFillSeriesDlg;
class ScGroupDlg;
@@ -163,6 +164,12 @@ class AbstractScDeleteCellDlg_Impl : public AbstractScDeleteCellDlg //add for S
virtual DelCellCmd GetDelCellCmd() const;
};
+//for dataform
+class AbstractScDataFormDlg_Impl : public AbstractScDataFormDlg //add for ScDataFormDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScDataFormDlg_Impl,ScDataFormDlg);
+};
+
class AbstractScDeleteContentsDlg_Impl : public AbstractScDeleteContentsDlg //add for ScDeleteContentsDlg
{
DECL_ABSTDLG_BASE( AbstractScDeleteContentsDlg_Impl,ScDeleteContentsDlg)
@@ -424,6 +431,9 @@ public:
virtual AbstractScDeleteCellDlg * CreateScDeleteCellDlg( Window* pParent, int nId,
BOOL bDisallowCellMove = FALSE ); //add for ScDeleteCellDlg
+ //for dataform
+ virtual AbstractScDataFormDlg * CreateScDataFormDlg( Window* pParent, int nId, ScTabViewShell* pTabViewShell); //add for ScDeleteCellDlg
+
virtual AbstractScDeleteContentsDlg * CreateScDeleteContentsDlg(Window* pParent,int nId, //add for ScDeleteContentsDlg
USHORT nCheckDefaults = 0 );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 57b2245ad9ce..6e084c490209 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -109,6 +109,7 @@ using namespace com::sun::star;
using ::com::sun::star::uno::Sequence;
using ::std::vector;
+
// STATIC DATA -----------------------------------------------------------
//========================================================================
@@ -4188,6 +4189,13 @@ BOOL ScDocFunc::FillSeries( const ScRange& rRange, const ScMarkData* pTabMark,
BOOL ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark,
FillDir eDir, ULONG nCount, BOOL bRecord, BOOL bApi )
{
+ double fStep = 1.0;
+ double fMax = MAXDOUBLE;
+ return FillAuto( rRange, pTabMark, eDir, FILL_AUTO, FILL_DAY, nCount, fStep, fMax, bRecord, bApi );
+}
+
+BOOL ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, ULONG nCount, double fStep, double fMax, BOOL bRecord, BOOL bApi )
+{
ScDocShellModificator aModificator( rDocShell );
ScDocument* pDoc = rDocShell.GetDocument();
@@ -4213,10 +4221,6 @@ BOOL ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark,
ScRange aSourceArea = rRange;
ScRange aDestArea = rRange;
- FillCmd eCmd = FILL_AUTO;
- FillDateCmd eDateCmd = FILL_DAY;
- double fStep = 1.0;
- double fMax = MAXDOUBLE;
switch (eDir)
{
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index 9510c91e3290..bccbe303a00f 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -853,6 +853,47 @@ SCTAB ScDocShell::MakeScenario( SCTAB nTab, const String& rName, const String& r
return nTab;
}
+ULONG ScDocShell::TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
+ SCTAB nDestPos, BOOL bInsertNew,
+ BOOL bNotifyAndPaint )
+{
+ ScDocument* pSrcDoc = rSrcDocShell.GetDocument();
+
+ ULONG nErrVal = aDocument.TransferTab( pSrcDoc, nSrcPos, nDestPos,
+ bInsertNew ); // no insert
+
+ // TransferTab doesn't copy drawing objects with bInsertNew=FALSE
+ if ( nErrVal > 0 && !bInsertNew)
+ aDocument.TransferDrawPage( pSrcDoc, nSrcPos, nDestPos );
+
+ if(nErrVal>0 && pSrcDoc->IsScenario( nSrcPos ))
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+
+ pSrcDoc->GetScenarioData( nSrcPos, aComment,aColor, nFlags);
+ aDocument.SetScenario(nDestPos,TRUE);
+ aDocument.SetScenarioData(nDestPos,aComment,aColor,nFlags);
+ BOOL bActive = pSrcDoc->IsActiveScenario(nSrcPos);
+ aDocument.SetActiveScenario(nDestPos, bActive );
+
+ BOOL bVisible=pSrcDoc->IsVisible(nSrcPos);
+ aDocument.SetVisible(nDestPos,bVisible );
+
+ }
+
+ if ( nErrVal > 0 && pSrcDoc->IsTabProtected( nSrcPos ) )
+ aDocument.SetTabProtection(nDestPos, pSrcDoc->GetTabProtection(nSrcPos));
+ if ( bNotifyAndPaint )
+ {
+ Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestPos ) );
+ PostPaintExtras();
+ PostPaintGridAll();
+ }
+ return nErrVal;
+}
+
BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRecord )
{
ScDocShellModificator aModificator( *this );
diff --git a/sc/source/ui/docshell/macromgr.cxx b/sc/source/ui/docshell/macromgr.cxx
new file mode 100644
index 000000000000..3adb03ddb42c
--- /dev/null
+++ b/sc/source/ui/docshell/macromgr.cxx
@@ -0,0 +1,216 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: document.hxx,v $
+ * $Revision: 1.115.36.9 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "macromgr.hxx"
+#include "document.hxx"
+
+#include "basic/basmgr.hxx"
+#include "cppuhelper/implbase1.hxx"
+#include "sfx2/objsh.hxx"
+#include "cell.hxx"
+#include <com/sun/star/container/XContainer.hpp>
+
+#include <list>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::Reference;
+using ::rtl::OUString;
+using ::rtl::OUStringHash;
+using ::std::hash_map;
+using ::std::list;
+using ::std::for_each;
+using ::std::pair;
+
+// ============================================================================
+
+/**
+ * A simple container to keep track of cells that depend on basic modules
+ * changes. We don't check for duplicates at insertion time; instead, we
+ * remove duplicates at query time.
+ */
+class ScUserMacroDepTracker
+{
+public:
+ void addCell(const OUString& rModuleName, ScFormulaCell* pCell)
+ {
+ ModuleCellMap::iterator itr = maCells.find(rModuleName);
+ if (itr == maCells.end())
+ {
+ pair<ModuleCellMap::iterator, bool> r = maCells.insert(
+ ModuleCellMap::value_type(rModuleName, list<ScFormulaCell*>()));
+
+ if (!r.second)
+ // insertion failed.
+ return;
+
+ itr = r.first;
+ }
+ itr->second.push_back(pCell);
+ }
+
+ void removeCell(ScFormulaCell* pCell)
+ {
+ ModuleCellMap::iterator itr = maCells.begin(), itrEnd = maCells.end();
+ for (; itr != itrEnd; ++itr)
+ itr->second.remove(pCell);
+ }
+
+ void getCellsByModule(const OUString& rModuleName, list<ScFormulaCell*>& rCells)
+ {
+ ModuleCellMap::iterator itr = maCells.find(rModuleName);
+ if (itr == maCells.end())
+ return;
+
+ list<ScFormulaCell*>& rCellList = itr->second;
+
+ // Remove duplicates.
+ rCellList.sort();
+ rCellList.unique();
+ // exception safe copy
+ list<ScFormulaCell*> temp(rCellList);
+ rCells.swap(temp);
+ }
+
+private:
+ typedef hash_map<OUString, list<ScFormulaCell*>, OUStringHash> ModuleCellMap;
+ ModuleCellMap maCells;
+};
+
+
+// ============================================================================
+
+ScMacroManager::ScMacroManager(ScDocument* pDoc) :
+ mpDepTracker(new ScUserMacroDepTracker),
+ mpDoc(pDoc)
+{
+}
+
+ScMacroManager::~ScMacroManager()
+{
+}
+
+typedef ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener > ContainerListenerHelper;
+
+class VBAProjectListener : public ContainerListenerHelper
+{
+ ScMacroManager* mpMacroMgr;
+public:
+ VBAProjectListener( ScMacroManager* pMacroMgr ) : mpMacroMgr( pMacroMgr ) {}
+ // XEventListener
+ virtual void SAL_CALL disposing( const lang::EventObject& /*Source*/ ) throw(RuntimeException) {}
+
+ // XContainerListener
+ virtual void SAL_CALL elementInserted( const container::ContainerEvent& /*Event*/ ) throw(RuntimeException){}
+ virtual void SAL_CALL elementReplaced( const container::ContainerEvent& Event ) throw(RuntimeException)
+ {
+ rtl::OUString sModuleName;
+ Event.Accessor >>= sModuleName;
+ OSL_TRACE("VBAProjectListener::elementReplaced(%s)", rtl::OUStringToOString( sModuleName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ mpMacroMgr->InitUserFuncData();
+ mpMacroMgr->BroadcastModuleUpdate(sModuleName);
+ }
+ virtual void SAL_CALL elementRemoved( const container::ContainerEvent& /*Event*/ ) throw(RuntimeException){}
+
+};
+
+void ScMacroManager::InitUserFuncData()
+{
+ // Clear hash_map
+ mhFuncToVolatile.clear();
+ String sProjectName( RTL_CONSTASCII_USTRINGPARAM("Standard") );
+
+ Reference< container::XContainer > xModuleContainer;
+ SfxObjectShell* pShell = mpDoc->GetDocumentShell();
+ if ( pShell && pShell->GetBasicManager()->GetName().Len() > 0 )
+ sProjectName = pShell->GetBasicManager()->GetName();
+ try
+ {
+ Reference< script::XLibraryContainer > xLibraries( pShell->GetBasicContainer(), uno::UNO_QUERY_THROW );
+ xModuleContainer.set( xLibraries->getByName( sProjectName ), uno::UNO_QUERY_THROW );
+
+ if ( xModuleContainer.is() )
+ {
+ // remove old listener ( if there was one )
+ if ( mxContainerListener.is() )
+ xModuleContainer->removeContainerListener( mxContainerListener );
+ // Create listener
+ mxContainerListener = new VBAProjectListener( this );
+ xModuleContainer->addContainerListener( mxContainerListener );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+void ScMacroManager::SetUserFuncVolatile( const OUString& sName, bool isVolatile )
+{
+ mhFuncToVolatile[ sName ] = isVolatile;
+}
+
+bool ScMacroManager::GetUserFuncVolatile( const OUString& sName )
+{
+ NameBoolMap::iterator it = mhFuncToVolatile.find( sName );
+ if ( it == mhFuncToVolatile.end() )
+ return false;
+ return it->second;
+}
+
+void ScMacroManager::AddDependentCell(const OUString& aModuleName, ScFormulaCell* pCell)
+{
+ mpDepTracker->addCell(aModuleName, pCell);
+}
+
+void ScMacroManager::RemoveDependentCell(ScFormulaCell* pCell)
+{
+ mpDepTracker->removeCell(pCell);
+}
+
+void ScMacroManager::BroadcastModuleUpdate(const OUString& aModuleName)
+{
+ list<ScFormulaCell*> aCells;
+ mpDepTracker->getCellsByModule(aModuleName, aCells);
+ list<ScFormulaCell*>::iterator itr = aCells.begin(), itrEnd = aCells.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ ScFormulaCell* pCell = *itr;
+ mpDoc->PutInFormulaTree(pCell); // for F9 recalc
+
+ // for recalc on cell value change. If the cell is not volatile, the
+ // cell stops listening right away after it gets re-interpreted.
+ mpDoc->StartListeningArea(BCA_LISTEN_ALWAYS, pCell);
+ }
+}
diff --git a/sc/source/ui/docshell/makefile.mk b/sc/source/ui/docshell/makefile.mk
index dcfd0429bd50..df8d4c9b37f2 100644
--- a/sc/source/ui/docshell/makefile.mk
+++ b/sc/source/ui/docshell/makefile.mk
@@ -91,7 +91,8 @@ SLOFILES = \
$(SLO)$/hiranges.obj \
$(SLO)$/pntlock.obj \
$(SLO)$/sizedev.obj \
- $(SLO)$/editable.obj
+ $(SLO)$/editable.obj \
+ $(SLO)$/macromgr.obj
EXCEPTIONSFILES= \
@@ -102,7 +103,8 @@ EXCEPTIONSFILES= \
$(SLO)$/docsh8.obj \
$(SLO)$/externalrefmgr.obj \
$(SLO)$/dbdocimp.obj \
- $(SLO)$/docfunc.obj
+ $(SLO)$/docfunc.obj \
+ $(SLO)$/macromgr.obj
SRS1NAME=$(TARGET)
SRC1FILES = tpstat.src
@@ -132,7 +134,8 @@ LIB1OBJFILES = \
$(SLO)$/hiranges.obj \
$(SLO)$/pntlock.obj \
$(SLO)$/sizedev.obj \
- $(SLO)$/editable.obj
+ $(SLO)$/editable.obj \
+ $(SLO)$/macromgr.obj
# --- Tagets -------------------------------------------------------
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index 5199b721352a..cb44b695469a 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -205,7 +205,6 @@ void ScDrawShell::ExecDrawAttr( SfxRequest& rReq )
ExecuteTextAttrDlg( rReq );
break;
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
case SID_DRAW_HLINK_EDIT:
if ( pSingleSelectedObj )
pViewData->GetDispatcher().Execute( SID_HYPERLINK_DIALOG );
@@ -233,7 +232,6 @@ void ScDrawShell::ExecDrawAttr( SfxRequest& rReq )
ScGlobal::OpenURL( pInfo->GetHlink(), String::EmptyString() );
}
break;
-#endif
case SID_ATTR_TRANSFORM:
{
@@ -473,7 +471,6 @@ void ScDrawShell::ExecuteTextAttrDlg( SfxRequest& rReq, USHORT /* nTabPage */ )
delete( pDlg );
}
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
void ScDrawShell::SetHlinkForObject( SdrObject* pObj, const rtl::OUString& rHlnk )
{
if ( pObj )
@@ -483,5 +480,4 @@ void ScDrawShell::SetHlinkForObject( SdrObject* pObj, const rtl::OUString& rHlnk
lcl_setModified( GetObjectShell() );
}
}
-#endif
diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx
index 7da571fc05a7..67e3114976c1 100644
--- a/sc/source/ui/drawfunc/drawsh2.cxx
+++ b/sc/source/ui/drawfunc/drawsh2.cxx
@@ -197,24 +197,20 @@ void ScDrawShell::GetDrawFuncState( SfxItemSet& rSet ) // Funktionen disabl
BOOL bCanRename = FALSE;
if ( nMarkCount > 1 )
{
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
// no hypelink options for a selected group
rSet.DisableItem( SID_DRAW_HLINK_EDIT );
rSet.DisableItem( SID_DRAW_HLINK_DELETE );
rSet.DisableItem( SID_OPEN_HYPERLINK );
-#endif
}
else if ( nMarkCount == 1 )
{
SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
if ( !pInfo || (pInfo->GetHlink().getLength() == 0) )
{
rSet.DisableItem( SID_DRAW_HLINK_DELETE );
rSet.DisableItem( SID_OPEN_HYPERLINK );
}
-#endif
SdrLayerID nLayerID = pObj->GetLayer();
if ( nLayerID != SC_LAYER_INTERN )
bCanRename = TRUE; // #i51351# anything except internal objects can be renamed
diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx
index a05083eeadcc..21c9dc39526f 100644
--- a/sc/source/ui/drawfunc/drawsh5.cxx
+++ b/sc/source/ui/drawfunc/drawsh5.cxx
@@ -90,14 +90,12 @@ void ScDrawShell::GetHLinkState( SfxItemSet& rSet ) // Hyperlink
if ( nMarkCount == 1 ) // URL-Button markiert ?
{
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
if ( pInfo && (pInfo->GetHlink().getLength() > 0) )
{
aHLinkItem.SetURL( pInfo->GetHlink() );
aHLinkItem.SetInsertMode(HLINK_FIELD);
}
-#endif
SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj);
if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
{
@@ -240,13 +238,11 @@ void ScDrawShell::ExecuteHLink( SfxRequest& rReq )
bDone = TRUE;
}
}
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
else
{
SetHlinkForObject( pObj, rURL );
bDone = TRUE;
}
-#endif
}
}
diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx
index 1142e34b780d..07c0aa213b27 100644
--- a/sc/source/ui/drawfunc/fudraw.cxx
+++ b/sc/source/ui/drawfunc/fudraw.cxx
@@ -828,11 +828,7 @@ void FuDraw::ForcePointer(const MouseEvent* pMEvt)
SdrObjMacroHitRec aHitRec; //! muss da noch irgendwas gesetzt werden ????
pViewShell->SetActivePointer( pObj->GetMacroPointer(aHitRec) );
}
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
else if ( !bAlt && pInfo && ((pInfo->GetMacro().getLength() > 0) || (pInfo->GetHlink().getLength() > 0)) )
-#else
- else if ( !bAlt && pInfo && (pInfo->GetMacro().getLength() > 0) )
-#endif
pWindow->SetPointer( Pointer( POINTER_REFHAND ) );
else if ( IsDetectiveHit( aPnt ) )
pViewShell->SetActivePointer( Pointer( POINTER_DETECTIVE ) );
diff --git a/sc/source/ui/drawfunc/fusel.cxx b/sc/source/ui/drawfunc/fusel.cxx
index 4a456522003c..6972834ced02 100644
--- a/sc/source/ui/drawfunc/fusel.cxx
+++ b/sc/source/ui/drawfunc/fusel.cxx
@@ -202,7 +202,6 @@ BOOL __EXPORT FuSelection::MouseButtonDown(const MouseEvent& rMEvt)
}
ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, TRUE );
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
// For interoperability favour links over macros if both are defined
if ( pInfo->GetHlink().getLength() > 0 )
{
@@ -210,20 +209,27 @@ BOOL __EXPORT FuSelection::MouseButtonDown(const MouseEvent& rMEvt)
sURL = pInfo->GetHlink();
}
else if ( pInfo->GetMacro().getLength() > 0 )
-#else
- if ( pInfo->GetMacro().getLength() > 0 )
-#endif
{
SfxObjectShell* pObjSh = SfxObjectShell::Current();
if ( pObjSh && SfxApplication::IsXScriptURL( pInfo->GetMacro() ) )
{
+ uno::Reference< beans::XPropertySet > xProps( pObj->getUnoShape(), uno::UNO_QUERY );
+ uno::Any aCaller;
+ if ( xProps.is() )
+ {
+ try
+ {
+ aCaller = xProps->getPropertyValue( rtl::OUString::createFromAscii("Name") );
+ }
+ catch( uno::Exception& ) {}
+ }
uno::Any aRet;
uno::Sequence< sal_Int16 > aOutArgsIndex;
uno::Sequence< uno::Any > aOutArgs;
uno::Sequence< uno::Any >* pInArgs =
new uno::Sequence< uno::Any >(0);
pObjSh->CallXScript( pInfo->GetMacro(),
- *pInArgs, aRet, aOutArgsIndex, aOutArgs);
+ *pInArgs, aRet, aOutArgsIndex, aOutArgs, true, &aCaller );
pViewShell->FakeButtonUp( pViewShell->GetViewData()->GetActivePart() );
return TRUE; // kein CaptureMouse etc.
}
diff --git a/sc/source/ui/drawfunc/makefile.mk b/sc/source/ui/drawfunc/makefile.mk
index a50c450ab373..f82008e4cdeb 100644
--- a/sc/source/ui/drawfunc/makefile.mk
+++ b/sc/source/ui/drawfunc/makefile.mk
@@ -75,6 +75,7 @@ SLOFILES = \
$(SLO)$/mediash.obj
EXCEPTIONSFILES= \
+ $(SLO)$/fusel.obj \
$(SLO)$/fuins2.obj \
$(SLO)$/graphsh.obj \
$(SLO)$/mediash.obj
diff --git a/sc/source/ui/drawfunc/objdraw.src b/sc/source/ui/drawfunc/objdraw.src
index 82649044b38c..c221567f3671 100644
--- a/sc/source/ui/drawfunc/objdraw.src
+++ b/sc/source/ui/drawfunc/objdraw.src
@@ -186,7 +186,6 @@
ITEM_FORMAT_PARA_DLG\
};
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
#define MN_EDITLNK \
MenuItem\
{\
@@ -202,7 +201,6 @@
HelpID = SID_DRAW_HLINK_DELETE ; \
Text [ en-US ] = "~Remove Hyperlink" ; \
};
-#endif
#define MN_DRWTXTATTR \
MenuItem\
@@ -1297,14 +1295,12 @@ Menu RID_POPUP_DRAW
MenuItem { Separator = TRUE ; };
//------------------------------
ITEM_GROUP_MENU
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
//------------------------------
MenuItem { Separator = TRUE ; };
//------------------------------
MN_EDITLNK
MN_DELLNK
MenuItem { ITEM_OPEN_HYPERLINK };
-#endif
};
};
@@ -1374,14 +1370,12 @@ Menu RID_POPUP_GRAPHIC
MenuItem { Separator = TRUE ; };
//------------------------------
ITEM_GROUP_MENU
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
//------------------------------
MenuItem { Separator = TRUE ; };
//------------------------------
MN_EDITLNK
MN_DELLNK
MenuItem { ITEM_OPEN_HYPERLINK };
-#endif
};
};
diff --git a/sc/source/ui/inc/asciiopt.hxx b/sc/source/ui/inc/asciiopt.hxx
index 9d798083a155..469a8f2da0f2 100644
--- a/sc/source/ui/inc/asciiopt.hxx
+++ b/sc/source/ui/inc/asciiopt.hxx
@@ -44,7 +44,7 @@
// ============================================================================
-class ScAsciiOptions
+class SC_DLLPUBLIC ScAsciiOptions
{
private:
BOOL bFixedLen;
diff --git a/sc/source/ui/inc/datafdlg.hrc b/sc/source/ui/inc/datafdlg.hrc
new file mode 100644
index 000000000000..952f5fd31f6c
--- /dev/null
+++ b/sc/source/ui/inc/datafdlg.hrc
@@ -0,0 +1,15 @@
+
+#include "sc.hrc" // -> RID_SCDLG_DATAFORM
+
+//dataform
+#define BTN_DATAFORM_NEW 1001
+#define BTN_DATAFORM_DELETE 1002
+#define BTN_DATAFORM_RESTORE 1003
+#define BTN_DATAFORM_LAST 1004
+#define BTN_DATAFORM_NEXT 1005
+#define BTN_DATAFORM_CLOSE 1007
+#define WND_DATAFORM_SCROLLBAR 1008
+#define LAB_DATAFORM_RECORDNO 1009
+
+#define FT_DATAFORM_FIXEDTEXT1 2001
+#define ED_DATAFORM_EDIT1 2002
diff --git a/sc/source/ui/inc/datafdlg.hxx b/sc/source/ui/inc/datafdlg.hxx
new file mode 100644
index 000000000000..bb094957c20e
--- /dev/null
+++ b/sc/source/ui/inc/datafdlg.hxx
@@ -0,0 +1,85 @@
+
+#ifndef SC_DATAFDLG_HXX
+#define SC_DATAFDLG_HXX
+
+
+#ifndef _SV_DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+
+#ifndef _SV_BUTTON_HXX //autogen
+#include <vcl/imagebtn.hxx>
+#endif
+
+#ifndef _SV_FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+
+
+#include "global.hxx"
+
+#include <tabvwsh.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+
+#define MAX_DATAFORM_COLS 256
+#define MAX_DATAFORM_ROWS 32000
+#define CTRL_HEIGHT 22
+#define FIXED_WIDTH 60
+#define EDIT_WIDTH 140
+#define FIXED_LEFT 12
+#define EDIT_LEFT 78
+#define LINE_HEIGHT 30
+
+//zhangyun
+class ScDataFormDlg : public ModalDialog
+{
+private:
+
+ PushButton aBtnNew;
+ PushButton aBtnDelete;
+ PushButton aBtnRestore;
+ PushButton aBtnLast;
+ PushButton aBtnNext;
+ PushButton aBtnClose;
+ ScrollBar aSlider;
+ FixedText aFixedText;
+ //FixedText aFixedText1;
+ //Edit aEdit1;
+
+ ScTabViewShell* pTabViewShell;
+ ScDocument* pDoc;
+ sal_uInt16 aColLength;
+ SCROW aCurrentRow;
+ SCCOL nStartCol;
+ SCCOL nEndCol;
+ SCROW nStartRow;
+ SCROW nEndRow;
+ SCTAB nTab;
+ BOOL bNoSelection;
+
+ FixedText** pFixedTexts;
+ Edit** pEdits;
+
+public:
+ ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShell);
+ ~ScDataFormDlg();
+
+ void FillCtrls(SCROW nCurrentRow);
+private:
+
+ void SetButtonState();
+
+ // Handler:
+ DECL_LINK( Impl_NewHdl, PushButton* );
+ DECL_LINK( Impl_LastHdl, PushButton* );
+ DECL_LINK( Impl_NextHdl, PushButton* );
+
+ DECL_LINK( Impl_RestoreHdl, PushButton* );
+ DECL_LINK( Impl_DeleteHdl, PushButton* );
+ DECL_LINK( Impl_CloseHdl, PushButton* );
+
+ DECL_LINK( Impl_ScrollHdl, ScrollBar* );
+ DECL_LINK( Impl_DataModifyHdl, Edit* );
+};
+#endif // SC_DATAFDLG_HXX
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 6c61364c5228..a28692350421 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -167,6 +167,8 @@ public:
double fStart, double fStep, double fMax,
BOOL bRecord, BOOL bApi );
// FillAuto: rRange wird von Source-Range auf Dest-Range angepasst
+ SC_DLLPUBLIC BOOL FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, ULONG nCount, double fStep, double fMax, BOOL bRecord, BOOL bApi );
+
BOOL FillAuto( ScRange& rRange, const ScMarkData* pTabMark,
FillDir eDir, ULONG nCount, BOOL bRecord, BOOL bApi );
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 057e2af4d676..b8f88d6254a4 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -42,6 +42,7 @@
#include "refreshtimer.hxx"
#include <hash_map>
+#include <cppuhelper/implbase1.hxx>
class ScEditEngineDefaulter;
class FontList;
@@ -300,6 +301,10 @@ public:
ScMarkData& rMark, BOOL bRecord = TRUE );
void ModifyScenario( SCTAB nTab, const String& rName, const String& rComment,
const Color& rColor, USHORT nFlags );
+ ULONG TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
+ SCTAB nDestPos, BOOL bInsertNew,
+ BOOL bNotifyAndPaint );
+
BOOL MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRecord );
void DoRecalc( BOOL bApi );
diff --git a/sc/source/ui/inc/drawsh.hxx b/sc/source/ui/inc/drawsh.hxx
index e633ab00e277..8d2e7238f759 100644
--- a/sc/source/ui/inc/drawsh.hxx
+++ b/sc/source/ui/inc/drawsh.hxx
@@ -44,9 +44,7 @@ class ScDrawShell : public SfxShell
DECL_LINK( NameObjectHdl, AbstractSvxNameDialog* );
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
void SetHlinkForObject( SdrObject* pObj, const rtl::OUString& rHlnk );
-#endif
protected:
ScViewData* GetViewData() { return pViewData; }
diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx
index 86a91216edcc..164c4edb187c 100644
--- a/sc/source/ui/inc/impex.hxx
+++ b/sc/source/ui/inc/impex.hxx
@@ -50,7 +50,7 @@ struct ScExportTextOptions
bool mbAddQuotes;
};
-class ScImportExport
+class SC_DLLPUBLIC ScImportExport
{
ScDocShell* pDocSh;
ScDocument* pDoc;
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 7bfd0201cbb8..5109c99cb223 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -246,7 +246,7 @@ public:
virtual ~ScTabViewShell();
- Window* GetDialogParent();
+ SC_DLLPUBLIC Window* GetDialogParent();
bool IsRefInputMode() const;
void ExecuteInputDirect();
@@ -289,7 +289,7 @@ public:
void GetSaveState( SfxItemSet& rSet );
void ExecSearch( SfxRequest& rReq );
- void ExecuteUndo(SfxRequest& rReq);
+ SC_DLLPUBLIC void ExecuteUndo(SfxRequest& rReq);
void GetUndoState(SfxItemSet &rSet);
void ExecuteSbx( SfxRequest& rReq );
diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx
index 76f3d42a8475..fafc71511f03 100644
--- a/sc/source/ui/inc/undodat.hxx
+++ b/sc/source/ui/inc/undodat.hxx
@@ -495,7 +495,43 @@ private:
void Init();
};
+// amelia
+class ScUndoDataForm: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoDataForm( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
+ USHORT nNewFlags,
+ ScRefUndoData* pRefData, void* pFill1, void* pFill2, void* pFill3,
+ BOOL bRedoIsFilled = TRUE
+ );
+ virtual ~ScUndoDataForm();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+ virtual String GetComment() const;
+
+private:
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc;
+ ScDocument* pRedoDoc;
+ USHORT nFlags;
+ ScRefUndoData* pRefUndoData;
+ ScRefUndoData* pRefRedoData;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+ BOOL bRedoFilled;
+
+ void DoChange( const BOOL bUndo );
+ void SetChangeTrack();
+};
#endif
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 301c3e5663f7..4f7e9e01771a 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -110,6 +110,8 @@ public:
SC_DLLPUBLIC void CutToClip( ScDocument* pClipDoc = NULL, BOOL bIncludeObjects = FALSE );
SC_DLLPUBLIC BOOL CopyToClip( ScDocument* pClipDoc = NULL, BOOL bCut = FALSE, BOOL bApi = FALSE,
BOOL bIncludeObjects = FALSE, BOOL bStopEdit = TRUE );
+ SC_DLLPUBLIC BOOL CopyToClip( ScDocument* pClipDoc, const ScRange& rRange, BOOL bCut = FALSE,
+ BOOL bApi = FALSE, BOOL bIncludeObjects = FALSE, BOOL bStopEdit = TRUE );
ScTransferObj* CopyToTransferable();
SC_DLLPUBLIC BOOL PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
USHORT nFunction = PASTE_NOFUNC, BOOL bSkipEmpty = FALSE,
@@ -337,6 +339,13 @@ public:
void ForgetFormatArea() { bFormatValid = FALSE; }
BOOL SelectionEditable( BOOL* pOnlyNotBecauseOfMatrix = NULL );
+ // Amelia Wang
+ SC_DLLPUBLIC void DataFormPutData( SCROW nCurrentRow ,
+ SCROW nStartRow , SCCOL nStartCol ,
+ SCROW nEndRow , SCCOL nEndCol ,
+ Edit** pEdits ,
+ sal_uInt16 aColLength );
+
// interne Hilfsfunktionen
protected:
void UpdateLineAttrs( SvxBorderLine& rLine,
diff --git a/sc/source/ui/miscdlgs/datafdlg.cxx b/sc/source/ui/miscdlgs/datafdlg.cxx
new file mode 100644
index 000000000000..8911fd92fb09
--- /dev/null
+++ b/sc/source/ui/miscdlgs/datafdlg.cxx
@@ -0,0 +1,388 @@
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+//------------------------------------------------------------------
+
+#include "datafdlg.hxx"
+#include "scresid.hxx"
+#include "datafdlg.hrc"
+#include "viewdata.hxx"
+//#include "document.hxx"
+#include "docsh.hxx"
+#include "refundo.hxx"
+#include "undodat.hxx"
+
+#define HDL(hdl) LINK( this, ScDataFormDlg, hdl )
+
+//zhangyun
+ScDataFormDlg::ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShellOri) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DATAFORM ) ),
+ //
+ aBtnNew ( this, ScResId( BTN_DATAFORM_NEW ) ),
+ aBtnDelete ( this, ScResId( BTN_DATAFORM_DELETE ) ),
+ aBtnRestore ( this, ScResId( BTN_DATAFORM_RESTORE ) ),
+ aBtnLast ( this, ScResId( BTN_DATAFORM_LAST ) ),
+ aBtnNext ( this, ScResId( BTN_DATAFORM_NEXT ) ),
+ aBtnClose ( this, ScResId( BTN_DATAFORM_CLOSE ) ),
+ aSlider ( this, ScResId( WND_DATAFORM_SCROLLBAR ) ),
+ aFixedText ( this, ScResId( LAB_DATAFORM_RECORDNO ) )
+{
+ pTabViewShell = pTabViewShellOri;
+ FreeResource();
+ //read header form current document, and add new controls
+ DBG_ASSERT( pTabViewShell, "pTabViewShell is NULL! :-/" );
+ ScViewData* pViewData = pTabViewShell->GetViewData();
+
+ pDoc = pViewData->GetDocument();
+ if (pDoc)
+ {
+ ScRange aRange;
+ pViewData->GetSimpleArea( aRange );
+ ScAddress aStart = aRange.aStart;
+ ScAddress aEnd = aRange.aEnd;
+
+ nStartCol = aStart.Col();
+ nEndCol = aEnd.Col();
+ nStartRow = aStart.Row();
+ nEndRow = aEnd.Row();
+
+ nTab = pViewData->GetTabNo();
+ //if there is no selection
+ if ((nStartCol == nEndCol) && (nStartRow == nEndRow))
+ bNoSelection = TRUE;
+
+ if (bNoSelection)
+ {
+ //find last not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_COLS;i++)
+ {
+ String aColName;
+ nEndCol++;
+ pDoc->GetString( nEndCol, nStartRow, nTab, aColName );
+ int nColWidth = pDoc->GetColWidth( nEndCol, nTab );
+ if ( aColName.Len() == 0 && nColWidth)
+ {
+ nEndCol--;
+ break;
+ }
+ }
+
+ //find first not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_COLS;i++)
+ {
+ String aColName;
+ if (nStartCol <= 0)
+ break;
+ nStartCol--;
+
+ pDoc->GetString( nStartCol, nStartRow, nTab, aColName );
+ int nColWidth = pDoc->GetColWidth( nEndCol, nTab );
+ if ( aColName.Len() == 0 && nColWidth)
+ {
+ nStartCol++;
+ break;
+ }
+ }
+
+ //skip leading hide column
+ for (int i=1;i<=MAX_DATAFORM_COLS;i++)
+ {
+ String aColName;
+ int nColWidth = pDoc->GetColWidth( nStartCol, nTab );
+ if (nColWidth)
+ break;
+ nStartCol++;
+ }
+
+ if (nEndCol < nStartCol)
+ nEndCol = nStartCol;
+
+ //find last not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_ROWS;i++)
+ {
+ String aColName;
+ nEndRow++;
+ pDoc->GetString( nStartCol, nEndRow, nTab, aColName );
+ if ( aColName.Len() == 0 )
+ {
+ nEndRow--;
+ break;
+ }
+ }
+
+ //find first not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_ROWS;i++)
+ {
+ String aColName;
+ if (nStartRow <= 0)
+ break;
+ nStartRow--;
+
+ pDoc->GetString( nStartCol, nStartRow, nTab, aColName );
+ if ( aColName.Len() == 0 )
+ {
+ nStartRow++;
+ break;
+ }
+ }
+
+ if (nEndRow < nStartRow)
+ nEndRow = nStartRow;
+ }
+
+ aCurrentRow = nStartRow + 1;
+
+ String aFieldName;
+
+ int nTop = 12;
+
+ Size nFixedSize(FIXED_WIDTH, CTRL_HEIGHT );
+ Size nEditSize(EDIT_WIDTH, CTRL_HEIGHT );
+
+ //pFtArray = new FixedText(this);
+ aColLength = nEndCol - nStartCol + 1;
+
+ //new the controls
+ pFixedTexts = new FixedText*[aColLength];
+ pEdits = new Edit*[aColLength];
+
+ for(sal_uInt16 nIndex = 0; nIndex < aColLength; nIndex++)
+ {
+ pDoc->GetString( nIndex + nStartCol, nStartRow, nTab, aFieldName );
+ int nColWidth = pDoc->GetColWidth( nIndex + nStartCol, nTab );
+ if (nColWidth)
+ {
+ pFixedTexts[nIndex] = new FixedText(this);
+ pEdits[nIndex] = new Edit(this, WB_BORDER);
+
+ pFixedTexts[nIndex]->SetSizePixel(nFixedSize);
+ pEdits[nIndex]->SetSizePixel(nEditSize);
+ pFixedTexts[nIndex]->SetPosPixel(Point(FIXED_LEFT, nTop));
+ pEdits[nIndex]->SetPosPixel(Point(EDIT_LEFT, nTop));
+ //pFixedTexts[nIndex]->SetText(String::CreateFromAscii("W4W-Filter Nr. "));
+ pFixedTexts[nIndex]->SetText(aFieldName);
+ pFixedTexts[nIndex]->Show();
+ pEdits[nIndex]->Show();
+
+ nTop += LINE_HEIGHT;
+ }
+ else
+ {
+ pFixedTexts[nIndex] = NULL;
+ pEdits[nIndex] = NULL;
+ }
+ pEdits[nIndex]->SetModifyHdl( HDL(Impl_DataModifyHdl) );
+ }
+
+ Size nDialogSize = this->GetSizePixel();
+ if (nTop > nDialogSize.Height())
+ {
+ nDialogSize.setHeight(nTop);
+ this->SetSizePixel(nDialogSize);
+ }
+ Size nScrollSize = aSlider.GetSizePixel();
+ nScrollSize.setHeight(nDialogSize.Height()-20);
+ aSlider.SetSizePixel(nScrollSize);
+ }
+
+ FillCtrls(aCurrentRow);
+
+ aSlider.SetPageSize( 10 );
+ aSlider.SetVisibleSize( 1 );
+ aSlider.SetLineSize( 1 );
+ aSlider.SetRange( Range( 0, nEndRow - nStartRow + 1) );
+ aSlider.Show();
+
+ aBtnNew.SetClickHdl ( HDL(Impl_NewHdl) );
+ aBtnLast.SetClickHdl ( HDL(Impl_LastHdl) );
+ aBtnNext.SetClickHdl ( HDL(Impl_NextHdl) );
+
+ aBtnRestore.SetClickHdl ( HDL(Impl_RestoreHdl) );
+ aBtnDelete.SetClickHdl ( HDL(Impl_DeleteHdl) );
+ aBtnClose.SetClickHdl ( HDL(Impl_CloseHdl) );
+
+ aSlider.SetEndScrollHdl( HDL( Impl_ScrollHdl ) );
+
+ SetButtonState();
+
+ //end
+ //FreeResource();
+}
+
+ScDataFormDlg::~ScDataFormDlg()
+{
+ for(sal_uInt16 i = 0; i < aColLength; i++)
+ {
+ if (pEdits[i])
+ delete pEdits[i];
+ if (pFixedTexts[i])
+ delete pFixedTexts[i];
+ }
+ if (pEdits)
+ delete pEdits;
+ if (pFixedTexts)
+ delete pFixedTexts;
+}
+
+void ScDataFormDlg::FillCtrls(SCROW /*nCurrentRow*/)
+{
+ //ScViewData* pViewData = pTabViewShell->GetViewData();
+
+ //pDoc = pViewData->GetDocument();
+ String aFieldName;
+ int nRecordNum = nEndRow - nStartRow;
+ for(sal_uInt16 i = 0; i < aColLength; i++)
+ {
+ if (pEdits[i])
+ {
+ if (aCurrentRow<=nEndRow)
+ {
+ pDoc->GetString( i + nStartCol, aCurrentRow, nTab, aFieldName );
+ pEdits[i]->SetText(aFieldName);
+ }
+ else
+ pEdits[i]->SetText(String());
+ }
+ }
+ char sRecordStr[256];
+ if (aCurrentRow<=nEndRow)
+ aFixedText.SetText(String::CreateFromAscii(sRecordStr));
+ else
+ aFixedText.SetText(String::CreateFromAscii("New Record"));
+
+ aSlider.SetThumbPos(aCurrentRow-nStartRow-1);
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_DataModifyHdl, Edit*, pEdit)
+{
+ if ( pEdit->IsModified() )
+ aBtnRestore.Enable( TRUE );
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_NewHdl, PushButton*, EMPTYARG )
+{
+ ScViewData* pViewData = pTabViewShell->GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ if ( pDoc )
+ {
+ sal_Bool bHasData = sal_False;
+ for(sal_uInt16 i = 0; i < aColLength; i++)
+ if (pEdits[i])
+ if ( pEdits[i]->GetText().Len() != 0 )
+ {
+ bHasData = sal_True;
+ break;
+ }
+
+ if ( bHasData )
+ {
+ pTabViewShell->DataFormPutData( aCurrentRow , nStartRow , nStartCol , nEndRow , nEndCol , pEdits , aColLength );
+ aCurrentRow++;
+ if (aCurrentRow >= nEndRow + 2)
+ {
+ nEndRow ++ ;
+ aSlider.SetRange( Range( 0, nEndRow - nStartRow + 1) );
+ }
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ pDocSh->SetDocumentModified();
+ pDocSh->PostPaintGridAll();
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_LastHdl, PushButton*, EMPTYARG )
+{
+ if (pDoc)
+ {
+ if ( aCurrentRow > nStartRow +1 )
+ aCurrentRow--;
+
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_NextHdl, PushButton*, EMPTYARG )
+{
+ if (pDoc)
+ {
+ if ( aCurrentRow <= nEndRow)
+ aCurrentRow++;
+
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_RestoreHdl, PushButton*, EMPTYARG )
+{
+ if (pDoc)
+ {
+ FillCtrls(aCurrentRow);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_DeleteHdl, PushButton*, EMPTYARG )
+{
+ ScViewData* pViewData = pTabViewShell->GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ if (pDoc)
+ {
+ ScRange aRange(nStartCol, aCurrentRow, nTab, nEndCol, aCurrentRow, nTab);
+ pDoc->DeleteRow(aRange);
+ nEndRow--;
+
+ SetButtonState();
+ pDocSh->GetUndoManager()->Clear();
+
+ FillCtrls(aCurrentRow);
+ pDocSh->SetDocumentModified();
+ pDocSh->PostPaintGridAll();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_CloseHdl, PushButton*, EMPTYARG )
+{
+ EndDialog( );
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ long nOffset = aSlider.GetThumbPos();
+ aCurrentRow = nStartRow + nOffset + 1;
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ return 0;
+}
+
+void ScDataFormDlg::SetButtonState()
+{
+ if ( aCurrentRow > nEndRow )
+ {
+ aBtnDelete.Enable( FALSE );
+ aBtnLast.Enable( TRUE );
+ aBtnNext.Enable( FALSE );
+ }
+ else
+ {
+ aBtnDelete.Enable( TRUE );
+ aBtnNext.Enable( TRUE );
+ }
+ if ( 1 == aCurrentRow )
+ aBtnLast.Enable( FALSE );
+
+ aBtnRestore.Enable( FALSE );
+ if ( pEdits )
+ pEdits[0]->GrabFocus();
+}
diff --git a/sc/source/ui/miscdlgs/makefile.mk b/sc/source/ui/miscdlgs/makefile.mk
index d34994341ade..d3c6853d6875 100644
--- a/sc/source/ui/miscdlgs/makefile.mk
+++ b/sc/source/ui/miscdlgs/makefile.mk
@@ -41,6 +41,7 @@ LIBTARGET=no
# --- Files --------------------------------------------------------
SLOFILES = \
+ $(SLO)$/datafdlg.obj \
$(SLO)$/delcldlg.obj \
$(SLO)$/inscldlg.obj \
$(SLO)$/delcodlg.obj \
diff --git a/sc/source/ui/src/datafdlg.src b/sc/source/ui/src/datafdlg.src
new file mode 100644
index 000000000000..99812af2a6ad
--- /dev/null
+++ b/sc/source/ui/src/datafdlg.src
@@ -0,0 +1,70 @@
+
+#include "datafdlg.hrc"
+
+//zhangyun, dataform
+ModalDialog RID_SCDLG_DATAFORM
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 191 , 180 ) ;
+ Text [ en-US ] = "Data Form" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ FixedText LAB_DATAFORM_RECORDNO
+ {
+ Pos = MAP_APPFONT ( 136 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ Text [ en-US ] = "/" ;
+ };
+ PushButton BTN_DATAFORM_NEW
+ {
+ Pos = MAP_APPFONT ( 135 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ Text [ en-US ] = "New" ;
+ };
+ PushButton BTN_DATAFORM_DELETE
+ {
+ Pos = MAP_APPFONT ( 135 , 40 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Delete" ;
+ };
+ PushButton BTN_DATAFORM_RESTORE
+ {
+ Pos = MAP_APPFONT ( 135 , 57 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Restore" ;
+ };
+ PushButton BTN_DATAFORM_LAST
+ {
+ Pos = MAP_APPFONT ( 135 , 82 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Last Record" ;
+ };
+ PushButton BTN_DATAFORM_NEXT
+ {
+ Pos = MAP_APPFONT ( 135 , 99 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Next Record" ;
+ };
+ PushButton BTN_DATAFORM_CLOSE
+ {
+ Pos = MAP_APPFONT ( 135 , 116 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Close" ;
+ };
+ ScrollBar WND_DATAFORM_SCROLLBAR
+ {
+ Pos = MAP_APPFONT ( 124 , 6 ) ;
+ Size = MAP_APPFONT ( 8 , 135 ) ;
+ HScroll = FALSE ;
+ TabStop = FALSE ;
+ };
+};
+//end
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 6f0b1f1fd789..c18dd724014b 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1718,6 +1718,77 @@ Resource RID_GLOBSTR
{
Text [ en-US ] = "Unknown User";
};
+
+ String STR_SHAPE_AUTOSHAPE
+ {
+ Text [ en-US ] = "AutoShape";
+ };
+
+ String STR_SHAPE_RECTANGLE
+ {
+ Text [ en-US ] = "Rectangle";
+ };
+
+ String STR_SHAPE_LINE
+ {
+ Text [ en-US ] = "Line";
+ };
+
+ String STR_SHAPE_OVAL
+ {
+ Text [ en-US ] = "Oval";
+ };
+
+ String STR_SHAPE_TEXTBOX
+ {
+ Text [ en-US ] = "Text Box";
+ };
+
+ String STR_FORM_BUTTON
+ {
+ Text [ en-US ] = "Button";
+ };
+
+ String STR_FORM_CHECKBOX
+ {
+ Text [ en-US ] = "Check Box";
+ };
+
+ String STR_FORM_OPTIONBUTTON
+ {
+ Text [ en-US ] = "Option Button";
+ };
+
+ String STR_FORM_LABEL
+ {
+ Text [ en-US ] = "Label";
+ };
+
+ String STR_FORM_LISTBOX
+ {
+ Text [ en-US ] = "List Box";
+ };
+
+ String STR_FORM_GROUPBOX
+ {
+ Text [ en-US ] = "Group Box";
+ };
+
+ String STR_FORM_DROPDOWN
+ {
+ Text [ en-US ] = "Drop Down";
+ };
+
+ String STR_FORM_SPINNER
+ {
+ Text [ en-US ] = "Spinner";
+ };
+
+ String STR_FORM_SCROLLBAR
+ {
+ Text [ en-US ] = "Scroll Bar";
+ };
+
String STR_STYLE_FAMILY_CELL
{
Text [ en-US ] = "Cell Styles";
diff --git a/sc/source/ui/src/makefile.mk b/sc/source/ui/src/makefile.mk
index 96bb78e2902c..7036ad8bde27 100644
--- a/sc/source/ui/src/makefile.mk
+++ b/sc/source/ui/src/makefile.mk
@@ -53,6 +53,7 @@ SRC1FILES = \
dbnamdlg.src \
subtdlg.src \
miscdlgs.src \
+ datafdlg.src \
autofmt.src \
solvrdlg.src \
optsolver.src \
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index 36b192abce24..b7014fa86422 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -52,6 +52,8 @@
#include "attrib.hxx"
#include "hints.hxx"
#include "sc.hrc"
+#include "chgtrack.hxx" // Amelia Wang
+#include "refundo.hxx" // Amelia Wang
// -----------------------------------------------------------------------
@@ -71,6 +73,7 @@ TYPEINIT1(ScUndoRepeatDB, ScSimpleUndo);
TYPEINIT1(ScUndoDataPilot, ScSimpleUndo);
TYPEINIT1(ScUndoConsolidate, ScSimpleUndo);
TYPEINIT1(ScUndoChartData, ScSimpleUndo);
+TYPEINIT1(ScUndoDataForm, SfxUndoAction); // amelia
// -----------------------------------------------------------------------
@@ -2027,8 +2030,210 @@ BOOL __EXPORT ScUndoChartData::CanRepeat(SfxRepeatTarget& /* rTarget */) const
return FALSE;
}
+// Amelia Wang
+ScUndoDataForm::ScUndoDataForm( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
+ USHORT nNewFlags,
+ ScRefUndoData* pRefData,
+ void* /*pFill1*/, void* /*pFill2*/, void* /*pFill3*/,
+ BOOL bRedoIsFilled ) :
+ ScBlockUndo( pNewDocShell, ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), SC_UNDO_SIMPLE ),
+ aMarkData( rMark ),
+ pUndoDoc( pNewUndoDoc ),
+ pRedoDoc( pNewRedoDoc ),
+ nFlags( nNewFlags ),
+ pRefUndoData( pRefData ),
+ pRefRedoData( NULL ),
+ bRedoFilled( bRedoIsFilled )
+{
+ // pFill1,pFill2,pFill3 are there so the ctor calls for simple paste (without cutting)
+ // don't have to be changed and branched for 641.
+ // They can be removed later.
+
+ if ( !aMarkData.IsMarked() ) // no cell marked:
+ aMarkData.SetMarkArea( aBlockRange ); // mark paste block
+
+ if ( pRefUndoData )
+ pRefUndoData->DeleteUnchanged( pDocShell->GetDocument() );
+
+ SetChangeTrack();
+}
+
+ScUndoDataForm::~ScUndoDataForm()
+{
+ delete pUndoDoc;
+ delete pRedoDoc;
+ delete pRefUndoData;
+ delete pRefRedoData;
+}
+
+String ScUndoDataForm::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_PASTE );
+}
+
+void ScUndoDataForm::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack && (nFlags & IDF_CONTENTS) )
+ pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc,
+ nStartChangeAction, nEndChangeAction, SC_CACM_PASTE );
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+
+void ScUndoDataForm::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE );
+ ShowTable( aBlockRange );
+ EndUndo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+}
+
+void ScUndoDataForm::Redo()
+{
+ BeginRedo();
+ ScDocument* pDoc = pDocShell->GetDocument();
+ EnableDrawAdjust( pDoc, FALSE ); //! include in ScBlockUndo?
+ DoChange( FALSE );
+ EnableDrawAdjust( pDoc, TRUE ); //! include in ScBlockUndo?
+ EndRedo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+}
+
+void ScUndoDataForm::Repeat(SfxRepeatTarget& /*rTarget*/)
+{
+}
+
+BOOL ScUndoDataForm::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+void ScUndoDataForm::DoChange( const BOOL bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ // RefUndoData for redo is created before first undo
+ // (with DeleteUnchanged after the DoUndo call)
+ BOOL bCreateRedoData = ( bUndo && pRefUndoData && !pRefRedoData );
+ if ( bCreateRedoData )
+ pRefRedoData = new ScRefUndoData( pDoc );
+
+ ScRefUndoData* pWorkRefData = bUndo ? pRefUndoData : pRefRedoData;
+
+ // fuer Undo immer alle oder keine Inhalte sichern
+ USHORT nUndoFlags = IDF_NONE;
+ if (nFlags & IDF_CONTENTS)
+ nUndoFlags |= IDF_CONTENTS;
+ if (nFlags & IDF_ATTRIB)
+ nUndoFlags |= IDF_ATTRIB;
+ BOOL bPaintAll = FALSE;
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ // marking is in ScBlockUndo...
+ //ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockRange );
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ if ( bUndo && !bRedoFilled )
+ {
+ if (!pRedoDoc)
+ {
+ BOOL bColInfo = ( aBlockRange.aStart.Row()==0 && aBlockRange.aEnd.Row()==MAXROW );
+ BOOL bRowInfo = ( aBlockRange.aStart.Col()==0 && aBlockRange.aEnd.Col()==MAXCOL );
+
+ pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRedoDoc->InitUndoSelected( pDoc, aMarkData, bColInfo, bRowInfo );
+ }
+ // read "redo" data from the document in the first undo
+ // all sheets - CopyToDocument skips those that don't exist in pRedoDoc
+ ScRange aCopyRange = aBlockRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, 1, FALSE, pRedoDoc );
+ bRedoFilled = TRUE;
+ }
+
+ USHORT nExtFlags = 0;
+ pDocShell->UpdatePaintExt( nExtFlags, aBlockRange );
+
+ for ( sal_uInt16 i=0; i <= ( aBlockRange.aEnd.Col() - aBlockRange.aStart.Col() ); i++ )
+ {
+ String aOldString;
+ pUndoDoc->GetString( aBlockRange.aStart.Col()+i , aBlockRange.aStart.Row() , aBlockRange.aStart.Tab() , aOldString );
+ pDoc->SetString( aBlockRange.aStart.Col()+i , aBlockRange.aStart.Row() , aBlockRange.aStart.Tab() , aOldString );
+ }
+
+ //ScRange aTabSelectRange = aBlockRange;
+
+ if (pWorkRefData)
+ {
+ pWorkRefData->DoUndo( pDoc, TRUE ); // TRUE = bSetChartRangeLists for SetChartListenerCollection
+ if ( pDoc->RefreshAutoFilter( 0,0, MAXCOL,MAXROW, aBlockRange.aStart.Tab() ) )
+ bPaintAll = TRUE;
+ }
+
+ if ( bCreateRedoData && pRefRedoData )
+ pRefRedoData->DeleteUnchanged( pDoc );
+
+ if ( bUndo )
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+ }
+ else
+ SetChangeTrack();
+
+ ScRange aDrawRange( aBlockRange );
+ pDoc->ExtendMerge( aDrawRange, TRUE ); // only needed for single sheet (text/rtf etc.)
+ USHORT nPaint = PAINT_GRID;
+ if (bPaintAll)
+ {
+ aDrawRange.aStart.SetCol(0);
+ aDrawRange.aStart.SetRow(0);
+ aDrawRange.aEnd.SetCol(MAXCOL);
+ aDrawRange.aEnd.SetRow(MAXROW);
+ nPaint |= PAINT_TOP | PAINT_LEFT;
+/*A*/ if (pViewShell)
+ pViewShell->AdjustBlockHeight(FALSE);
+ }
+ else
+ {
+ if ( aBlockRange.aStart.Row() == 0 && aBlockRange.aEnd.Row() == MAXROW ) // ganze Spalte
+ {
+ nPaint |= PAINT_TOP;
+ aDrawRange.aEnd.SetCol(MAXCOL);
+ }
+ if ( aBlockRange.aStart.Col() == 0 && aBlockRange.aEnd.Col() == MAXCOL ) // ganze Zeile
+ {
+ nPaint |= PAINT_LEFT;
+ aDrawRange.aEnd.SetRow(MAXROW);
+ }
+/*A*/ if ((pViewShell) && pViewShell->AdjustBlockHeight(FALSE))
+ {
+ aDrawRange.aStart.SetCol(0);
+ aDrawRange.aStart.SetRow(0);
+ aDrawRange.aEnd.SetCol(MAXCOL);
+ aDrawRange.aEnd.SetRow(MAXROW);
+ nPaint |= PAINT_LEFT;
+ }
+ pDocShell->UpdatePaintExt( nExtFlags, aDrawRange );
+ }
+ if ( !bUndo ) // draw redo after updating row heights
+ RedoSdrUndoAction( pDrawUndo ); //! include in ScBlockUndo?
+ pDocShell->PostPaint( aDrawRange, nPaint, nExtFlags );
+ pDocShell->PostDataChanged();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+}
diff --git a/sc/source/ui/unoobj/addruno.cxx b/sc/source/ui/unoobj/addruno.cxx
index 10627222be80..6d38383b9ee3 100644
--- a/sc/source/ui/unoobj/addruno.cxx
+++ b/sc/source/ui/unoobj/addruno.cxx
@@ -69,7 +69,7 @@ void ScAddressConversionObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
}
}
-sal_Bool ScAddressConversionObj::ParseUIString( const String& rUIString )
+sal_Bool ScAddressConversionObj::ParseUIString( const String& rUIString, ::formula::FormulaGrammar::AddressConvention eConv )
{
if (!pDocShell)
return sal_False;
@@ -78,7 +78,7 @@ sal_Bool ScAddressConversionObj::ParseUIString( const String& rUIString )
sal_Bool bSuccess = sal_False;
if ( bIsRange )
{
- USHORT nResult = aRange.ParseAny( rUIString, pDoc );
+ USHORT nResult = aRange.ParseAny( rUIString, pDoc, eConv );
if ( nResult & SCA_VALID )
{
if ( ( nResult & SCA_TAB_3D ) == 0 )
@@ -92,7 +92,7 @@ sal_Bool ScAddressConversionObj::ParseUIString( const String& rUIString )
}
else
{
- USHORT nResult = aRange.aStart.Parse( rUIString, pDoc );
+ USHORT nResult = aRange.aStart.Parse( rUIString, pDoc, eConv );
if ( nResult & SCA_VALID )
{
if ( ( nResult & SCA_TAB_3D ) == 0 )
@@ -116,6 +116,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScAddressConversionObj::getProp
{
{MAP_CHAR_LEN(SC_UNONAME_ADDRESS), 0, &getCppuType((table::CellRangeAddress*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNONAME_PERSREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_XL_A1_REPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNONAME_REFSHEET), 0, &getCppuType((sal_Int32*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNONAME_UIREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
{0,0,0,0,0,0}
@@ -129,6 +130,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScAddressConversionObj::getProp
{
{MAP_CHAR_LEN(SC_UNONAME_ADDRESS), 0, &getCppuType((table::CellAddress*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNONAME_PERSREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_XL_A1_REPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNONAME_REFSHEET), 0, &getCppuType((sal_Int32*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNONAME_UIREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
{0,0,0,0,0,0}
@@ -190,8 +192,11 @@ void SAL_CALL ScAddressConversionObj::setPropertyValue( const rtl::OUString& aPr
bSuccess = ParseUIString( aUIString );
}
}
- else if ( aNameStr.EqualsAscii( SC_UNONAME_PERSREPR ) )
+ else if ( aNameStr.EqualsAscii( SC_UNONAME_PERSREPR ) || aNameStr.EqualsAscii( SC_UNONAME_XL_A1_REPR ) )
{
+ ::formula::FormulaGrammar::AddressConvention aConv = ::formula::FormulaGrammar::CONV_OOO;
+ if ( aNameStr.EqualsAscii( SC_UNONAME_XL_A1_REPR ) )
+ aConv = ::formula::FormulaGrammar::CONV_XL_A1;
// parse the file format string
rtl::OUString sRepresentation;
if (aValue >>= sRepresentation)
@@ -212,7 +217,7 @@ void SAL_CALL ScAddressConversionObj::setPropertyValue( const rtl::OUString& aPr
}
// parse the rest like a UI string
- bSuccess = ParseUIString( aUIString );
+ bSuccess = ParseUIString( aUIString, aConv );
}
}
else
@@ -265,17 +270,24 @@ uno::Any SAL_CALL ScAddressConversionObj::getPropertyValue( const rtl::OUString&
aRange.aStart.Format( aFormatStr, nFlags, pDoc );
aRet <<= rtl::OUString( aFormatStr );
}
- else if ( aNameStr.EqualsAscii( SC_UNONAME_PERSREPR ) )
+ else if ( aNameStr.EqualsAscii( SC_UNONAME_PERSREPR ) || aNameStr.EqualsAscii( SC_UNONAME_XL_A1_REPR ) )
{
+ ::formula::FormulaGrammar::AddressConvention aConv = ::formula::FormulaGrammar::CONV_OOO;
+ if ( aNameStr.EqualsAscii( SC_UNONAME_XL_A1_REPR ) )
+ aConv = ::formula::FormulaGrammar::CONV_XL_A1;
+
// generate file format string - always include sheet
String aFormatStr;
- aRange.aStart.Format( aFormatStr, SCA_VALID | SCA_TAB_3D, pDoc );
+ aRange.aStart.Format( aFormatStr, SCA_VALID | SCA_TAB_3D, pDoc, aConv );
if ( bIsRange )
{
// manually concatenate range so both parts always have the sheet name
aFormatStr.Append( (sal_Unicode) ':' );
String aSecond;
- aRange.aEnd.Format( aSecond, SCA_VALID | SCA_TAB_3D, pDoc );
+ USHORT nFlags = SCA_VALID;
+ if( aConv != ::formula::FormulaGrammar::CONV_XL_A1 )
+ nFlags |= SCA_TAB_3D;
+ aRange.aEnd.Format( aSecond, SCA_VALID | SCA_TAB_3D, pDoc, aConv );
aFormatStr.Append( aSecond );
}
aRet <<= rtl::OUString( aFormatStr );
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 83c9441d8fc7..dd29f0eb2339 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -102,6 +102,7 @@
#include "scresid.hxx"
using namespace com::sun::star;
+#define SC_UNO_VBADOCOBJ "ThisVBADocObj" // perhaps we want to actually make this ThisWorkbook ?
//------------------------------------------------------------------------
@@ -117,6 +118,7 @@ const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap()
{MAP_CHAR_LEN(SC_UNO_AUTOCONTFOC), 0, &getBooleanCppuType(), 0, 0},
{MAP_CHAR_LEN(SC_UNO_BASICLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0},
{MAP_CHAR_LEN(SC_UNO_DIALOGLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(SC_UNO_VBADOCOBJ), 0, &getCppuType((beans::PropertyValue*)0), beans::PropertyAttribute::READONLY, 0},
{MAP_CHAR_LEN(SC_UNO_CALCASSHOWN), PROP_UNO_CALCASSHOWN, &getBooleanCppuType(), 0, 0},
{MAP_CHAR_LEN(SC_UNONAME_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0},
{MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0},
@@ -1873,6 +1875,18 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const rtl::OUString& aPropertyNa
{
aRet <<= pDocShell->GetDialogContainer();
}
+ else if ( aString.EqualsAscii( SC_UNO_VBADOCOBJ ) )
+ {
+ // PropertyValue seems extreme because we store
+ // the model ( as the value member ) of the PropertyValue that is
+ // itself a property of the model ( the intention however is to
+ // store something like a Workbook object... but we don't do that )
+ // yet
+ beans::PropertyValue aProp;
+ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisExcelDoc") );
+ aProp.Value <<= pDocShell->GetModel();
+ aRet <<= aProp;
+ }
else if ( aString.EqualsAscii( SC_UNO_RUNTIMEUID ) )
{
aRet <<= getRuntimeUID();
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index 45f55b03df2c..274ca792f8ac 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -36,6 +36,7 @@
#include <svx/unofill.hxx>
#include <editeng/unonrule.hxx>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
#include "servuno.hxx"
#include "unoguard.hxx"
@@ -72,8 +73,27 @@
#include <basic/basmgr.hxx>
#include <sfx2/app.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/document/XCodeNameQuery.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#include <comphelper/componentcontext.hxx>
+#include <cppuhelper/component_context.hxx>
+#include <vbahelper/vbaaccesshelper.hxx>
+#include <com/sun/star/script/vba/XVBACompatibility.hpp>
+
using namespace ::com::sun::star;
+bool isInVBAMode( ScDocShell& rDocSh )
+{
+ uno::Reference<script::XLibraryContainer> xLibContainer = rDocSh.GetBasicContainer();
+ uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY );
+ if ( xVBACompat.is() )
+ return xVBACompat->getVBACompatibilityMode();
+ return false;
+}
+
class ScVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess >
{
uno::Any maWorkbook;
@@ -286,7 +306,8 @@ static const ProvNamesId_Type __FAR_DATA aProvNamesId[] =
{ "com.sun.star.text.textfield.Time", SC_SERVICE_TIMEFIELD },
{ "com.sun.star.text.textfield.DocumentTitle", SC_SERVICE_TITLEFIELD },
{ "com.sun.star.text.textfield.FileName", SC_SERVICE_FILEFIELD },
- { "com.sun.star.text.textfield.SheetName", SC_SERVICE_SHEETFIELD }
+ { "com.sun.star.text.textfield.SheetName", SC_SERVICE_SHEETFIELD },
+ { "ooo.vba.VBAGlobals", SC_SERVICE_VBAGLOBALS },
};
//
@@ -548,7 +569,7 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
}
break;
case SC_SERVICE_VBACODENAMEPROVIDER:
- if (pDocShell && pDocShell->GetDocument()->IsInVBAMode())
+ if ( pDocShell && ooo::vba::isAlienExcelDoc( *pDocShell ) && isInVBAMode( *pDocShell ) )
{
OSL_TRACE("**** creating VBA Object provider");
xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider( pDocShell )));
diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx
index 1ed384ed2ebd..e94faa42ed83 100644
--- a/sc/source/ui/unoobj/shapeuno.cxx
+++ b/sc/source/ui/unoobj/shapeuno.cxx
@@ -70,6 +70,8 @@ const SfxItemPropertyMapEntry* lcl_GetShapeMap()
{MAP_CHAR_LEN(SC_UNONAME_HORIPOS), 0, &getCppuType((sal_Int32*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNONAME_IMAGEMAP), 0, &getCppuType((uno::Reference<container::XIndexContainer>*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNONAME_VERTPOS), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+ // #i66550 HLINK_FOR_SHAPES
+ {MAP_CHAR_LEN(SC_UNONAME_HYPERLINK), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
{0,0,0,0,0,0}
};
return aShapeMap_Impl;
@@ -84,6 +86,14 @@ const SvEventDescription* ScShapeObj::GetSupportedMacroItems()
};
return aMacroDescriptionsImpl;
}
+// #i66550 HLINK_FOR_SHAPES
+ScMacroInfo* lcl_getShapeHyperMacroInfo( ScShapeObj* pShape, BOOL bCreate = FALSE )
+{
+ if( pShape )
+ if( SdrObject* pObj = pShape->GetSdrObject() )
+ return ScDrawLayer::GetMacroInfo( pObj, bCreate );
+ return 0;
+}
//------------------------------------------------------------------------
@@ -635,6 +645,13 @@ void SAL_CALL ScShapeObj::setPropertyValue(
}
}
}
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HYPERLINK ) )
+ {
+ rtl::OUString sHlink;
+ ScMacroInfo* pInfo = lcl_getShapeHyperMacroInfo(this, TRUE);
+ if ( ( aValue >>= sHlink ) && pInfo )
+ pInfo->SetHlink( sHlink );
+ }
else
{
GetShapePropertySet();
@@ -816,6 +833,13 @@ uno::Any SAL_CALL ScShapeObj::getPropertyValue( const rtl::OUString& aPropertyNa
}
}
}
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HYPERLINK ) )
+ {
+ rtl::OUString sHlink;
+ if ( ScMacroInfo* pInfo = lcl_getShapeHyperMacroInfo(this) )
+ sHlink = pInfo->GetHlink();
+ aAny <<= sHlink;
+ }
else
{
GetShapePropertySet();
@@ -1339,11 +1363,6 @@ SdrObject* ScShapeObj::GetSdrObject() const throw()
}
#define SC_EVENTACC_ONCLICK ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) )
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
-#define SC_EVENTACC_ONACTION ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnAction" ) )
-#define SC_EVENTACC_URL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) )
-#define SC_EVENTACC_ACTION ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Action" ) )
-#endif
#define SC_EVENTACC_SCRIPT ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Script" ) )
#define SC_EVENTACC_EVENTTYPE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) )
@@ -1355,10 +1374,7 @@ private:
ScMacroInfo* getInfo( BOOL bCreate = FALSE )
{
- if( mpShape )
- if( SdrObject* pObj = mpShape->GetSdrObject() )
- return ScDrawLayer::GetMacroInfo( pObj, bCreate );
- return 0;
+ return lcl_getShapeHyperMacroInfo( mpShape, bCreate );
}
public:
@@ -1384,11 +1400,7 @@ public:
isEventType = true;
continue;
}
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
- if ( isEventType && ((pProperties->Name == SC_EVENTACC_SCRIPT) || (pProperties->Name == SC_EVENTACC_URL)) )
-#else
if ( isEventType && (pProperties->Name == SC_EVENTACC_SCRIPT) )
-#endif
{
rtl::OUString sValue;
if ( pProperties->Value >>= sValue )
@@ -1399,10 +1411,8 @@ public:
break;
if ( pProperties->Name == SC_EVENTACC_SCRIPT )
pInfo->SetMacro( sValue );
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
else
pInfo->SetHlink( sValue );
-#endif
}
}
}
@@ -1425,19 +1435,6 @@ public:
aProperties[ 1 ].Value <<= pInfo->GetMacro();
}
}
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
- else if( aName == SC_EVENTACC_ONACTION )
- {
- if ( pInfo && (pInfo->GetHlink().getLength() > 0) )
- {
- aProperties.realloc( 2 );
- aProperties[ 0 ].Name = SC_EVENTACC_EVENTTYPE;
- aProperties[ 0 ].Value <<= SC_EVENTACC_ACTION;
- aProperties[ 1 ].Name = SC_EVENTACC_URL;
- aProperties[ 1 ].Value <<= pInfo->GetHlink();
- }
- }
-#endif
else
{
throw container::NoSuchElementException();
@@ -1448,25 +1445,14 @@ public:
virtual uno::Sequence< rtl::OUString > SAL_CALL getElementNames() throw(uno::RuntimeException)
{
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
- uno::Sequence< rtl::OUString > aSeq( 2 );
-#else
uno::Sequence< rtl::OUString > aSeq( 1 );
-#endif
aSeq[ 0 ] = SC_EVENTACC_ONCLICK;
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
- aSeq[ 1 ] = SC_EVENTACC_ONACTION;
-#endif
return aSeq;
}
virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw(uno::RuntimeException)
{
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
- return (aName == SC_EVENTACC_ONCLICK) || (aName == SC_EVENTACC_ONACTION);
-#else
return aName == SC_EVENTACC_ONCLICK;
-#endif
}
// XElementAccess
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index 86ebf066a52d..cdb79a1d5975 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -460,6 +460,91 @@ 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 bSelectionChangeOccured;
+
+ 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( sal_False ), bSelectionChangeOccured( sal_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 = sal_False;
+ bSelectionChangeOccured = sal_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 ) ? sal_False : sal_True;
+ bSelectionChangeOccured = sal_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 ( bSelectionChangeOccured )
+ fireSelectionChangeEvent();
+ return sal_True;
+}
+
+void SAL_CALL ScTabViewEventListener::selectionChanged( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
+{
+ if ( !bDelaySelectionEvent )
+ {
+ fireSelectionChangeEvent();
+ }
+ else
+ {
+ bSelectionChangeOccured = sal_True;
+ }
+}
+
//------------------------------------------------------------------------
// Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht
@@ -474,7 +559,22 @@ ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) :
bDrawSelModeSet(sal_False)
{
if (pViewSh)
+ {
nPreviousTab = pViewSh->GetViewData()->GetTabNo();
+ ScViewData* pViewData = pViewSh->GetViewData();
+ if( pViewData )
+ {
+ uno::Reference< script::vba::XVBAEventProcessor > xVbaEventsHelper (pViewData->GetDocument()->GetVbaEventProcessor(), uno::UNO_QUERY );
+ if ( xVbaEventsHelper.is() )
+ {
+ 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 );
+ }
+ }
+ }
}
ScTabViewObj::~ScTabViewObj()
@@ -1162,10 +1262,20 @@ uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTabViewObj::getActiveSheet()
return NULL;
}
+//liuchen 2009-9-2 support expand (but not replace) the active sheet
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)
+{
ScUnoGuard aGuard;
+ sal_Bool bNew = bExpand;
ScTabViewShell* pViewSh = GetViewShell();
if ( pViewSh && xActiveSheet.is() )
@@ -1180,7 +1290,7 @@ void SAL_CALL ScTabViewObj::setActiveSheet( const uno::Reference<sheet::XSpreads
{
SCTAB nNewTab = rRanges.GetObject(0)->aStart.Tab();
if ( pViewSh->GetViewData()->GetDocument()->HasTable(nNewTab) )
- pViewSh->SetTabNo( nNewTab );
+ pViewSh->SetTabNo( nNewTab, bNew, bExpand );
}
}
}
@@ -1837,19 +1947,7 @@ void ScTabViewObj::SelectionChanged()
/*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
}
}
-
- // execute VBA event handler
- try
- {
- uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
- // the parameter is the clicked object, as in the mousePressed call above
- uno::Sequence< uno::Any > aArgs( 1 );
- aArgs[ 0 ] <<= getSelection();
- xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_SELECT ), aArgs );
- }
- catch( uno::Exception& )
- {
- }
+ // Removed Sun/Oracle code intentionally, it doesn't work properly ( selection should be fired after mouse release )
}
@@ -1874,6 +1972,12 @@ void SAL_CALL ScTabViewObj::setPropertyValue(
ScUnoGuard aGuard;
String aString(aPropertyName);
+ if ( aString.EqualsAscii(SC_UNO_FILTERED_RANGE_SELECTION) )
+ {
+ bFilteredRangeSelection = ScUnoHelpFunctions::GetBoolFromAny(aValue);
+ return;
+ }
+
ScTabViewShell* pViewSh = GetViewShell();
if (pViewSh)
{
@@ -1994,6 +2098,12 @@ uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const rtl::OUString& aProperty
String aString(aPropertyName);
uno::Any aRet;
+ if ( aString.EqualsAscii(SC_UNO_FILTERED_RANGE_SELECTION) )
+ {
+ ScUnoHelpFunctions::SetBoolInAny(aRet, bFilteredRangeSelection);
+ return aRet;
+ }
+
ScTabViewShell* pViewSh = GetViewShell();
if (pViewSh)
{
diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx
index 2c39d7154b4b..7d1dcd2e6dc7 100644
--- a/sc/source/ui/vba/excelvbahelper.cxx
+++ b/sc/source/ui/vba/excelvbahelper.cxx
@@ -30,6 +30,9 @@
#include "transobj.hxx"
#include "scmod.hxx"
#include "cellsuno.hxx"
+#include "compiler.hxx"
+#include "token.hxx"
+#include "tokenarray.hxx"
#include <comphelper/processfactory.hxx>
#include <com/sun/star/sheet/XSheetCellRange.hpp>
@@ -43,6 +46,52 @@ namespace vba
namespace excel
{
+uno::Reference< sheet::XDatabaseRanges >
+GetDataBaseRanges( ScDocShell* pShell ) throw ( uno::RuntimeException )
+{
+ uno::Reference< frame::XModel > xModel;
+ if ( pShell )
+ xModel.set( pShell->GetModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xModelProps( xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XDatabaseRanges > xDBRanges( xModelProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DatabaseRanges") ) ), uno::UNO_QUERY_THROW );
+ return xDBRanges;
+}
+
+// returns the XDatabaseRange for the autofilter on sheet (nSheet)
+// also populates sName with the name of range
+uno::Reference< sheet::XDatabaseRange >
+GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet, rtl::OUString& sName ) throw ( uno::RuntimeException )
+{
+ uno::Reference< container::XIndexAccess > xIndexAccess( GetDataBaseRanges( pShell ), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XDatabaseRange > xDataBaseRange;
+ table::CellRangeAddress dbAddress;
+ for ( sal_Int32 index=0; index < xIndexAccess->getCount(); ++index )
+ {
+ uno::Reference< sheet::XDatabaseRange > xDBRange( xIndexAccess->getByIndex( index ), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNamed > xNamed( xDBRange, uno::UNO_QUERY_THROW );
+ // autofilters work weirdly with openoffice, unnamed is the default
+ // named range which is used to create an autofilter, but
+ // its also possible that another name could be used
+ // this also causes problems when an autofilter is created on
+ // another sheet
+ // ( but.. you can use any named range )
+ dbAddress = xDBRange->getDataArea();
+ if ( dbAddress.Sheet == nSheet )
+ {
+ sal_Bool bHasAuto = sal_False;
+ uno::Reference< beans::XPropertySet > xProps( xDBRange, uno::UNO_QUERY_THROW );
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoFilter") ) ) >>= bHasAuto;
+ if ( bHasAuto )
+ {
+ sName = xNamed->getName();
+ xDataBaseRange=xDBRange;
+ break;
+ }
+ }
+ }
+ return xDataBaseRange;
+}
+
ScDocShell* GetDocShellFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException )
{
ScCellRangesBase* pScCellRangesBase = ScCellRangesBase::getImplementation( xRange );
@@ -53,6 +102,13 @@ ScDocShell* GetDocShellFromRange( const uno::Reference< uno::XInterface >& xRang
return pScCellRangesBase->GetDocShell();
}
+ScDocShell* GetDocShellFromRanges( const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges ) throw ( uno::RuntimeException )
+{
+ // need the ScCellRangesBase to get docshell
+ uno::Reference< uno::XInterface > xIf( xRanges, uno::UNO_QUERY_THROW );
+ return GetDocShellFromRange( xIf );
+}
+
ScDocument* GetDocumentFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException )
{
ScDocShell* pDocShell = GetDocShellFromRange( xRange );
@@ -63,6 +119,16 @@ 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 );
@@ -192,6 +258,15 @@ void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, USHORT nFl
}
+void implnCopyRange( const uno::Reference< frame::XModel>& xModel, const ScRange& rRange )
+{
+ ScTabViewShell* pViewShell = getBestViewShell( xModel );
+ if ( pViewShell )
+ {
+ pViewShell->CopyToClip( NULL, rRange, FALSE, TRUE, TRUE );
+ }
+}
+
ScDocShell*
getDocShell( const css::uno::Reference< css::frame::XModel>& xModel )
{
@@ -229,6 +304,19 @@ getViewFrame( const uno::Reference< frame::XModel >& xModel )
return NULL;
}
+sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const rtl::OUString& sRangeStr )
+{
+ ScRangeList aCellRanges;
+ String sAddress( sRangeStr );
+ USHORT nMask = SCA_VALID;
+ USHORT rResFlags = aCellRanges.Parse( sAddress, pDoc, nMask, formula::FormulaGrammar::CONV_XL_R1C1 );
+ if ( rResFlags & SCA_VALID )
+ {
+ return sal_True;
+ }
+ return sal_False;
+}
+
uno::Reference< XHelperInterface >
getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException )
{
@@ -246,6 +334,84 @@ getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw
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 )
+ {
+ USHORT nLen = pCode->GetLen();
+ formula::FormulaToken** pTokens = pCode->GetArray();
+ for ( USHORT 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 ) ) ) );
+ ScTokenArray* pCode = 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;
+ }
+ USHORT nLen = pCode->GetLen();
+ formula::FormulaToken** pTokens = pCode->GetArray();
+ for ( USHORT 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 = String::CreateFromAscii(",");
+ }
+ 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 da0474e6ceb0..fca3d11958fc 100644
--- a/sc/source/ui/vba/excelvbahelper.hxx
+++ b/sc/source/ui/vba/excelvbahelper.hxx
@@ -29,9 +29,12 @@
#include<vbahelper/vbahelper.hxx>
#include <docsh.hxx>
+#include <com/sun/star/sheet/XDatabaseRanges.hpp>
+#include <com/sun/star/sheet/XDatabaseRange.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
#include <ooo/vba/XHelperInterface.hpp>
+#include <formula/grammar.hxx>
class ScCellRangesBase;
@@ -39,29 +42,39 @@ namespace ooo
{
namespace vba
{
- namespace excel
+ namespace excel
{
- // nTabs empty means apply zoom to all sheets
- void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs );
- void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel );
- void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel );
- void implnCut( const css::uno::Reference< css::frame::XModel>& xModel );
- void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose);
- ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
- ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
- ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext );
- SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel );
+ // nTabs empty means apply zoom to all sheets
+ void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs );
+ void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel );
+ void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel );
+ void implnCut( const css::uno::Reference< css::frame::XModel>& xModel );
+ void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose);
+ void implnCopyRange( const css::uno::Reference< css::frame::XModel>& xModel, const ScRange& rRange );
+ ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
+ ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
+ ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+ SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel );
+ sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const ::rtl::OUString& sRangeStr );
+ formula::FormulaGrammar::Grammar GetFormulaGrammar( ScDocument* pDoc, const ScAddress& sAddress, const css::uno::Any& aFormula );
+ void CompileExcelFormulaToODF( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula );
+ void CompileODFFormulaToExcel( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula, const formula::FormulaGrammar::Grammar eGrammar );
+ css::uno::Reference< css::sheet::XDatabaseRanges > GetDataBaseRanges( ScDocShell* pShell ) throw ( css::uno::RuntimeException );
+
+ css::uno::Reference< css::sheet::XDatabaseRange > GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet, rtl::OUString& sName ) throw ( css::uno::RuntimeException );
css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException );
css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException );
ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
+ ScDocShell* GetDocShellFromRanges( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException );
ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
+
class ScVbaCellRangeAccess
{
public:
static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj );
};
-}
-}
+ }
+ }
}
#endif
diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk
index 92bb3fd39db0..ba50cbad9abd 100644
--- a/sc/source/ui/vba/makefile.mk
+++ b/sc/source/ui/vba/makefile.mk
@@ -31,7 +31,7 @@ PRJNAME=sc
TARGET=vbaobj
ENABLE_EXCEPTIONS=TRUE
VISIBILITY_HIDDEN=TRUE
-
+CDEFS+=-DVBA_OOBUILD_HACK
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
@@ -63,18 +63,29 @@ SLOFILES= \
$(SLO)$/vbacharttitle.obj \
$(SLO)$/vbacomment.obj \
$(SLO)$/vbacomments.obj \
+ $(SLO)$/vbacommentshape.obj \
$(SLO)$/vbacondition.obj \
$(SLO)$/vbadialog.obj \
$(SLO)$/vbadialogs.obj \
$(SLO)$/vbaeventshelper.obj \
+ $(SLO)$/vbafiledialog.obj \
+ $(SLO)$/vbafiledialogselecteditems.obj \
+ $(SLO)$/vbafilesearch.obj \
$(SLO)$/vbafont.obj \
$(SLO)$/vbaformat.obj \
$(SLO)$/vbaformatcondition.obj \
$(SLO)$/vbaformatconditions.obj \
+ $(SLO)$/vbafoundfiles.obj \
$(SLO)$/vbaglobals.obj \
$(SLO)$/vbahyperlink.obj \
$(SLO)$/vbahyperlinks.obj \
$(SLO)$/vbainterior.obj \
+ $(SLO)$/vbamenubar.obj \
+ $(SLO)$/vbamenubars.obj \
+ $(SLO)$/vbamenu.obj \
+ $(SLO)$/vbamenus.obj \
+ $(SLO)$/vbamenuitem.obj \
+ $(SLO)$/vbamenuitems.obj \
$(SLO)$/vbaname.obj \
$(SLO)$/vbanames.obj \
$(SLO)$/vbaoleobject.obj \
@@ -88,6 +99,7 @@ SLOFILES= \
$(SLO)$/vbapivotcache.obj \
$(SLO)$/vbapivottable.obj \
$(SLO)$/vbapivottables.obj \
+ $(SLO)$/vbaquerytable.obj \
$(SLO)$/vbarange.obj \
$(SLO)$/vbaseriescollection.obj \
$(SLO)$/vbasheetobject.obj \
diff --git a/sc/source/ui/vba/testvba/testvba.cxx b/sc/source/ui/vba/testvba/testvba.cxx
index 686b3e47eaa9..6ae1fb9e1cfc 100644
--- a/sc/source/ui/vba/testvba/testvba.cxx
+++ b/sc/source/ui/vba/testvba/testvba.cxx
@@ -159,15 +159,15 @@ mxCompLoader( _xCompLoader ), msOutDirPath( convertToURL( _outDirPath ) )
Reference< script::provider::XScript > xScript;
try
{
- xScript = xProv->getScript( rtl::OUString::createFromAscii( "vnd.sun.star.script:Standard.TestMacros.Main?language=Basic&location=document" ));
+ xScript = xProv->getScript( rtl::OUString::createFromAscii( "vnd.sun.star.script:VBAProject.TestMacros.Main?language=Basic&location=document" ));
} catch ( uno::Exception& e )
{
try
{
- xScript = xProv->getScript( rtl::OUString::createFromAscii( "vnd.sun.star.script:Standard.testMacro.Main?language=Basic&location=document" ));
+ xScript = xProv->getScript( rtl::OUString::createFromAscii( "vnd.sun.star.script:VBAProject.testMacro.Main?language=Basic&location=document" ));
} catch ( uno::Exception& e2 )
{
- xScript = xProv->getScript( rtl::OUString::createFromAscii( "vnd.sun.star.script:Standard.testMain.Main?language=Basic&location=document" ));
+ xScript = xProv->getScript( rtl::OUString::createFromAscii( "vnd.sun.star.script:VBAProject.testMain.Main?language=Basic&location=document" ));
}
}
OSL_TRACE("Got script for doc %s", rtl::OUStringToOString( sUrl, RTL_TEXTENCODING_UTF8 ).getStr() );
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index f3965393e919..de2bf4964055 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -27,11 +27,14 @@
#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>
@@ -40,6 +43,19 @@
#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 <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>
+//2009-11-06 add by limingl
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+//end
+#include<ooo/vba/XCommandBars.hpp>
+#include <ooo/vba/excel/XlEnableCancelKey.hpp> //liuchen 2009-11-26
+#include <ooo/vba/excel/XlApplicationInternational.hpp> //liuchen 2009-11-26
+#include <unotools/localedatawrapper.hxx> //liuchen 2009-11-26
#include "vbaapplication.hxx"
#include "vbaworkbooks.hxx"
@@ -51,25 +67,37 @@
#include "vbawindow.hxx"
#include "vbawindows.hxx"
#include "vbaglobals.hxx"
+#include "vbamenubars.hxx"
#include "tabvwsh.hxx"
#include "gridwin.hxx"
#include "vbanames.hxx"
#include <vbahelper/vbashape.hxx>
#include "vbatextboxshape.hxx"
#include "vbaassistant.hxx"
+#include "vbafilesearch.hxx" //liuchen 2009-8-18, add the support of VBA Application.FileSearch
#include "sc.hrc"
+#include "macromgr.hxx"
+#include "global.hxx" //liuchen 2009-11-26
+#include "scmod.hxx" //liuchen 2009-11-26
+#include "docoptio.hxx" //liuchen 2009-11-26
+#include "appoptio.hxx"
#include <osl/file.hxx>
+#include <map>
+
#include <sfx2/request.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/app.hxx>
+#include <comphelper/processfactory.hxx>
+
#include <toolkit/awt/vclxwindow.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
#include <docuno.hxx>
@@ -78,15 +106,29 @@
#include <basic/sbuno.hxx>
#include <basic/sbmeth.hxx>
+#include "transobj.hxx"
#include "convuno.hxx"
#include "cellsuno.hxx"
+#include "miscuno.hxx"
+#include "unonames.hxx"
#include "docsh.hxx"
#include <vbahelper/helperdecl.hxx>
#include "excelvbahelper.hxx"
-
+#include <basic/sbmeth.hxx>
+#include <basic/sbmod.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/sbx.hxx>
+#include <basic/sbxobj.hxx>
+#include <basic/sbuno.hxx>
+//limingl 2009-07-20
+#include "vbafiledialog.hxx"
using namespace ::ooo::vba;
using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::rtl::OUString;
// #TODO is this defined somewhere else?
#if ( defined UNX ) || ( defined OS2 ) //unix
@@ -237,16 +279,49 @@ ScVbaApplication::getAssistant() throw (uno::RuntimeException)
return uno::Reference< XAssistant >( new ScVbaAssistant( this, mxContext ) );
}
+//liuchen 2009-8-18, 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;
+}
+//liuchen
+
uno::Any SAL_CALL
ScVbaApplication::getSelection() throw (uno::RuntimeException)
{
OSL_TRACE("** ScVbaApplication::getSelection() ** ");
uno::Reference< frame::XModel > xModel( getCurrentDocument() );
- uno::Reference< lang::XServiceInfo > xServiceInfo( xModel->getCurrentSelection(), uno::UNO_QUERY_THROW );
- rtl::OUString sImpementaionName = xServiceInfo->getImplementationName();
- if( sImpementaionName.equalsIgnoreAsciiCaseAscii("com.sun.star.drawing.SvxShapeCollection") )
+
+ Reference< view::XSelectionSupplier > xSelSupp( xModel->getCurrentController(), UNO_QUERY_THROW );
+ Reference< beans::XPropertySet > xPropSet( xSelSupp, UNO_QUERY_THROW );
+ OUString aPropName = OUString::createFromAscii( SC_UNO_FILTERED_RANGE_SELECTION );
+ uno::Any aOldVal = xPropSet->getPropertyValue( aPropName );
+ uno::Any any;
+ any <<= sal_False;
+ xPropSet->setPropertyValue( aPropName, any );
+ uno::Reference< uno::XInterface > aSelection = ScUnoHelpFunctions::AnyToInterface(
+ xSelSupp->getSelection() );
+ xPropSet->setPropertyValue( aPropName, aOldVal );
+
+ if (!aSelection.is())
{
- uno::Reference< drawing::XShapes > xShapes( xModel->getCurrentSelection(), uno::UNO_QUERY_THROW );
+ throw uno::RuntimeException(
+ rtl::OUString::createFromAscii("failed to obtain current selection"),
+ uno::Reference< uno::XInterface >() );
+ }
+
+ uno::Reference< lang::XServiceInfo > xServiceInfo( aSelection, uno::UNO_QUERY_THROW );
+ rtl::OUString sImplementationName = xServiceInfo->getImplementationName();
+
+ if( sImplementationName.equalsIgnoreAsciiCaseAscii("com.sun.star.drawing.SvxShapeCollection") )
+ {
+ uno::Reference< drawing::XShapes > xShapes( aSelection, uno::UNO_QUERY_THROW );
uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY_THROW );
uno::Reference< drawing::XShape > xShape( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW );
// if ScVbaShape::getType( xShape ) == office::MsoShapeType::msoAutoShape
@@ -265,10 +340,10 @@ ScVbaApplication::getSelection() throw (uno::RuntimeException)
else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRange")) ||
xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRanges")))
{
- uno::Reference< table::XCellRange > xRange( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY);
+ uno::Reference< table::XCellRange > xRange( aSelection, ::uno::UNO_QUERY);
if ( !xRange.is() )
{
- uno::Reference< sheet::XSheetCellRangeContainer > xRanges( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY);
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges( aSelection, ::uno::UNO_QUERY);
if ( xRanges.is() )
return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ), mxContext, xRanges ) ) );
@@ -277,7 +352,7 @@ ScVbaApplication::getSelection() throw (uno::RuntimeException)
}
else
{
- throw uno::RuntimeException( sImpementaionName + rtl::OUString::createFromAscii(" not suported"), uno::Reference< uno::XInterface >() );
+ throw uno::RuntimeException( sImplementationName + rtl::OUString::createFromAscii(" not supported"), uno::Reference< uno::XInterface >() );
}
}
@@ -367,16 +442,67 @@ ScVbaApplication::getActiveWindow() throw (uno::RuntimeException)
uno::Any SAL_CALL
ScVbaApplication::getCutCopyMode() throw (uno::RuntimeException)
{
- //# FIXME TODO, implementation
uno::Any result;
- result <<= sal_False;
+ 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 <<= 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)
{
- //# FIXME TODO, implementation
+ // According to Excel's behavior, no matter what is the value of _cutcopymode, always releases the clip object.
+ sal_Bool bCutCopyMode = sal_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 );
+ }
+ }
+ }
+ }
+ }
+ }
}
uno::Any SAL_CALL
@@ -725,6 +851,91 @@ ScVbaApplication::getEnableEvents() throw (uno::RuntimeException)
return m_bEnableEvents;
}
+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)
+{
+}
+
+//liuchen 2009-11-25 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 = OUString::createFromAscii( "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 = static_cast< ScVbaWorkbook* > ( xWorkbook.get() );
+
+ 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 );
+ }
+}
+//liuchen 2009-11-25 end
+
+//liuchen 2009-11-26 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)
+{
+}
+//liuchen 2009-11-26 end
+
+sal_Int32 SAL_CALL ScVbaApplication::getSheetsInNewWorkbook() throw (uno::RuntimeException)
+{
+ const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
+ return rAppOpt.GetTabCountInNewSpreadsheet();
+}
+
+void SAL_CALL ScVbaApplication::setSheetsInNewWorkbook( sal_Int32 SheetsInNewWorkbook ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if ( SheetsInNewWorkbook < 1 || SheetsInNewWorkbook > MAXTAB )
+ {
+ DebugHelper::exception( OUString::createFromAscii("The number must be between 1 and 255"), uno::Exception(), SbERR_METHOD_FAILED, OUString() );
+ }
+ else
+ {
+ ScAppOptions& rAppOpt = const_cast< ScAppOptions& >(SC_MOD()->GetAppOptions());
+ rAppOpt.SetTabCountInNewSpreadsheet( SheetsInNewWorkbook );
+ }
+}
+
void SAL_CALL
ScVbaApplication::Calculate() throw( script::BasicErrorException , uno::RuntimeException )
{
@@ -1090,13 +1301,19 @@ ScVbaApplication::Volatile( const uno::Any& aVolatile ) throw ( uno::RuntimeExc
{
sal_Bool bVolatile = sal_True;
aVolatile >>= bVolatile;
+ SbMethod* pMeth = StarBASIC::GetActiveMethod();
+ if ( pMeth )
+ {
+ OSL_TRACE("ScVbaApplication::Volatile() In method ->%s<-", rtl::OUStringToOString( pMeth->GetName(), RTL_TEXTENCODING_UTF8 ).getStr() );
+ uno::Reference< frame::XModel > xModel( getCurrentDocument() );
+ ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+ pDoc->GetMacroManager()->SetUserFuncVolatile( pMeth->GetName(), bVolatile);
+ }
+
+// this is bound to break when loading the document
return;
}
-void SAL_CALL
-ScVbaApplication::DoEvents() throw ( uno::RuntimeException )
-{
-}
::sal_Bool SAL_CALL
ScVbaApplication::getDisplayFormulaBar() throw ( css::uno::RuntimeException )
{
@@ -1148,12 +1365,421 @@ ScVbaApplication::Caller( const uno::Any& /*aIndex*/ ) throw ( uno::RuntimeExcep
return aRet;
}
+//Add by minz@cn.ibm.com. 2009-07-08.
+uno::Any SAL_CALL
+ScVbaApplication::GetOpenFilename(const uno::Any& FileFilter, const uno::Any& FilterIndex, const uno::Any& Title, const uno::Any& ButtonText, const uno::Any& MultiSelect) throw (uno::RuntimeException)
+{
+ uno::Any aRet = uno::makeAny( sal_False );
+ try
+ {
+ const ::rtl::OUString sServiceName = ::rtl::OUString::createFromAscii( "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::createFromAscii( "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 = sal_False;
+ if ( xFilePicker.is() && MultiSelect.hasValue() )
+ {
+ MultiSelect >>= bMultiSelect;
+ xFilePicker->setMultiSelectionMode( bMultiSelect );
+ }
+
+ if ( xFilePicker.is() && xFilePicker->execute() )
+ {
+ sal_Bool bUseXFilePicker2 = sal_False;
+ uno::Reference< lang::XServiceInfo > xServiceInfo( xFilePicker, UNO_QUERY );
+ if ( xServiceInfo.is() )
+ {
+ rtl::OUString sImplName = xServiceInfo->getImplementationName();
+ if ( sImplName.equalsAscii("com.sun.star.comp.fpicker.VistaFileDialog") || sImplName.equalsAscii("com.sun.star.ui.dialogs.SalGtkFilePicker") )
+ {
+ bUseXFilePicker2 = sal_True;
+ }
+ }
+ uno::Sequence< rtl::OUString > aSelectedFiles;
+ if ( bUseXFilePicker2 && 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.getLength() > 0 ? aTemp : aSelectedFiles[i];
+ }
+ }
+ 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;
+}
+
+//liming 2009-7-17
+::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;
+
+//2009-11-06 add by limingl
+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::createFromAscii( "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::createFromAscii( "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 <<= sal_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.equalsAscii("") )
+ {
+ sFileExtension = sFirstFilter.equalsAscii("*.*") ? sFileExtension : sFirstFilter.copy( sFirstFilter.indexOfAsciiL("*.", 2) + 2 );
+ aPathStr = sFileExtension.equalsAscii("") ? aPathStr : aPathStr + ::rtl::OUString::createFromAscii(".") + sFileExtension;
+ }
+ else
+ {
+ sal_Bool bValidFilter = sal_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::createFromAscii("*.") + sFileExtension) )
+ {
+ bValidFilter = sal_True;
+ break;
+ }
+ } while ( nSemicolonID >= 0 );
+ if ( bValidFilter )
+ {
+ break;
+ }
+ aIt++;
+ }
+ if ( !bValidFilter )
+ {
+ sFileExtension = sFirstFilter.equalsAscii("*.*") ? ::rtl::OUString::createFromAscii("") : sFirstFilter.copy( sFirstFilter.indexOfAsciiL("*.", 2) + 2 );
+ aPathStr = sFileExtension.equalsAscii("") ? aPathStr : aPathStr + ::rtl::OUString::createFromAscii(".") + 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)
{
return getCurrentExcelDoc(mxContext);
}
+uno::Any SAL_CALL
+ScVbaApplication::MenuBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< XCommandBars > xCommandBars( CommandBars( uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xMenuBars( new ScVbaMenuBars( this, mxContext, xCommandBars ) );
+ if ( aIndex.hasValue() )
+ {
+ return uno::Any ( xMenuBars->Item( aIndex, uno::Any() ) );
+ }
+
+ return uno::Any( xMenuBars );
+}
+
+//liuchen 2009-11-26 add the support of Application.International
+sal_Int32 SAL_CALL
+ConvertCountryCode(const OUString& language)
+{
+ sal_Int32 nCode = 0;
+
+ if( language == OUString::createFromAscii("ar") ) nCode = 966; // Arabic
+ else if ( language == OUString::createFromAscii("cs") ) nCode = 42; // Czech
+ else if ( language == OUString::createFromAscii("da") ) nCode = 45; // Danish
+ else if ( language == OUString::createFromAscii("de") ) nCode = 49; // German
+ else if ( language == OUString::createFromAscii("en") ) nCode = 1; // English
+ else if ( language == OUString::createFromAscii("es") ) nCode = 34; // Spanish
+ else if ( language == OUString::createFromAscii("el") ) nCode = 30; // Greek
+ else if ( language == OUString::createFromAscii("fa") ) nCode = 98; // Persian = Farsi
+ else if ( language == OUString::createFromAscii("fi") ) nCode = 358; // Finnish
+ else if ( language == OUString::createFromAscii("fr") ) nCode = 33; // French
+ else if ( language == OUString::createFromAscii("he") ) nCode = 972; // Hebrew
+ else if ( language == OUString::createFromAscii("hi") ) nCode = 91; // Indian = Hindi
+ else if ( language == OUString::createFromAscii("hu") ) nCode = 36; // Hungarian
+ else if ( language == OUString::createFromAscii("it") ) nCode = 39; // Italian
+ else if ( language == OUString::createFromAscii("ja") ) nCode = 81; // Japanese
+ else if ( language == OUString::createFromAscii("ko") ) nCode = 82; // Korean
+ else if ( language == OUString::createFromAscii("nl") ) nCode = 31; // Dutch
+ else if ( language == OUString::createFromAscii("no") ) nCode = 47; // Norwegian
+ else if ( language == OUString::createFromAscii("pl") ) nCode = 48; // Polish
+ else if ( language == OUString::createFromAscii("pt") ) nCode = 351; // Portuguese
+ else if ( language == OUString::createFromAscii("ru") ) nCode = 7; // Russian
+ else if ( language == OUString::createFromAscii("sv") ) nCode = 46; // Swedish
+ else if ( language == OUString::createFromAscii("th") ) nCode = 66; // Thai
+ else if ( language == OUString::createFromAscii("tk") ) nCode = 90; // Turkish
+ else if ( language == OUString::createFromAscii("ur") ) nCode = 92; // Urdu
+ else if ( language == OUString::createFromAscii("vi") ) nCode = 84; // Vietnamese
+ else if ( language == OUString::createFromAscii("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;
+}
+//liuchen 2009-11-26 end
+
+//2009-12-11 add by limingl
+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);
+ }
+}
+//end
+
+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 a7be5feb1d27..9d865a513547 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -47,6 +47,7 @@ private:
sal_Bool m_bEnableEvents;
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);
@@ -89,6 +90,7 @@ 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); //liuchen 2009-8-18 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);
@@ -102,6 +104,17 @@ 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); //liuchen 2009-11-25 add the support of Iteration
+ virtual void SAL_CALL setIteration( sal_Bool bIteration ) throw (css::uno::RuntimeException); //liuchen 2009-11-25 add the support of Iteration
+ virtual sal_Int32 SAL_CALL getEnableCancelKey() throw (css::uno::RuntimeException); //liuchen 2009-11-26 add the support of EnableCancelKey
+ virtual void SAL_CALL setEnableCancelKey( sal_Int32 lEnableCancelKey ) throw (css::uno::RuntimeException); //liuchen 2009-11-26 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);
@@ -114,8 +127,16 @@ public:
virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
virtual void SAL_CALL Volatile( const css::uno::Any& Volatile ) throw (css::uno::RuntimeException );
- virtual void SAL_CALL DoEvents() 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); //liminl 2009-08-12 add
+ virtual css::uno::Any SAL_CALL International( sal_Int32 Index ) throw (css::uno::RuntimeException); //liuchen 2009-11-26
+ //2009-12-04 add by limingl
+ 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();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/sc/source/ui/vba/vbacomment.cxx b/sc/source/ui/vba/vbacomment.cxx
index 9c50a25b8b7c..31ea50c0dff4 100644
--- a/sc/source/ui/vba/vbacomment.cxx
+++ b/sc/source/ui/vba/vbacomment.cxx
@@ -33,14 +33,23 @@
#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
#include <com/sun/star/sheet/XSheetAnnotationShapeSupplier.hpp>
#include <com/sun/star/sheet/XSheetCellRange.hpp>
+#include <com/sun/star/sheet/XCellAddressable.hpp>
#include <com/sun/star/table/CellAddress.hpp>
#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"
-
+#include "vbacommentshape.hxx"
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -178,7 +187,6 @@ 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() )
{
@@ -212,10 +220,12 @@ ScVbaComment::Text( const uno::Any& aText, const uno::Any& aStart, const uno::An
}
else if ( aText.hasValue() )
{
- xAnnoText->setString( sText );
- return sText;
+ uno::Reference< sheet::XCellAddressable > xCellAddr(mxRange->getCellByPosition(0, 0), uno::UNO_QUERY_THROW );
+ table::CellAddress aAddress = xCellAddr->getCellAddress();
+ getAnnotations()->insertNew( aAddress, sText );
}
+ rtl::OUString sAnnoText = xAnnoText->getString();
return sAnnoText;
}
diff --git a/sc/source/ui/vba/vbacommentshape.cxx b/sc/source/ui/vba/vbacommentshape.cxx
new file mode 100644
index 000000000000..4c0d15597ce7
--- /dev/null
+++ b/sc/source/ui/vba/vbacommentshape.cxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * 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 "vbacommentshape.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+ScVbaCommentShape::ScVbaCommentShape( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< drawing::XShape >& xShape, const uno::Reference< excel::XComment >& xComment,
+ const uno::Reference< drawing::XShapes >& xShapes, const uno::Reference< frame::XModel >& xModel, sal_Int32 nType ) : ScVbaShape( xParent, xContext, xShape, xShapes, xModel, nType )
+{
+ m_xComment.set( xComment, uno::UNO_QUERY );
+}
+
+void SAL_CALL ScVbaCommentShape::Delete() throw (uno::RuntimeException)
+{
+ if ( m_xComment.is() )
+ {
+ m_xComment->Delete();
+ }
+}
diff --git a/sc/source/ui/vba/vbacommentshape.hxx b/sc/source/ui/vba/vbacommentshape.hxx
new file mode 100644
index 000000000000..d55de4b07c18
--- /dev/null
+++ b/sc/source/ui/vba/vbacommentshape.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * 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_COMMENTSHAPE_HXX
+#define SC_VBA_COMMENTSHAPE_HXX
+
+#include <ooo/vba/excel/XComment.hpp>
+#include <vbahelper/vbashape.hxx>
+
+class ScVbaCommentShape : public ScVbaShape
+{
+ css::uno::Reference< ooo::vba::excel::XComment > m_xComment;
+
+public:
+ ScVbaCommentShape( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape,
+ const css::uno::Reference< ooo::vba::excel::XComment >& xComment, const css::uno::Reference< css::drawing::XShapes >& xShapes, const css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nType );
+
+ // Methods
+ virtual void SAL_CALL Delete() throw (css::uno::RuntimeException);
+};
+#endif //SC_VBA_COMMENTSHAPE_HXX
diff --git a/sc/source/ui/vba/vbadialog.cxx b/sc/source/ui/vba/vbadialog.cxx
index 88a4c4ae67fd..c43c3f7b0cd3 100644
--- a/sc/source/ui/vba/vbadialog.cxx
+++ b/sc/source/ui/vba/vbadialog.cxx
@@ -31,42 +31,58 @@
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-static const rtl::OUString aStringList[]=
+//liuchen 2009-7-27
+//solve the problem that "Application.Dialogs.Item(***).Show" and "Application.Dialogs.Count" cannot get the correct result
+struct DialogMatch
{
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Open" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormatCellDialog" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertCell" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Print" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PasteSpecial" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ToolProtectionDocument" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColumnWidth" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DefineName" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConfigureDialog" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:HyperlinkDialog" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertGraphic" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertObject" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PageFormatDialog" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataSort" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:RowHeight" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoCorrectDlg" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConditionalFormatDialog" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataConsolidate" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CreateNames" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillSeries" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Validation") ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DefineLabelRange" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataFilterAutoFilter" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataFilterSpecialFilter" ) ),
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoFormat" ) )
+ sal_Int32 nVbaDlgIndex;
+ rtl::OUString aOODlgName;
};
-const sal_Int32 nDialogSize = SAL_N_ELEMENTS( aStringList ) ;
+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 = SAL_N_ELEMENTS( aDialogMatchList ) ;
+//liuchen modified 2009-2-27
rtl::OUString
ScVbaDialog::mapIndexToName( sal_Int32 nIndex )
{
- if( nIndex < nDialogSize )
- return aStringList[ nIndex ];
+ for (int i = 0; i < nDialogSize; i++)
+ {
+ if ( aDialogMatchList[i].nVbaDlgIndex == nIndex )
+ {
+ return aDialogMatchList[i].aOODlgName;
+ }
+ }
+
return rtl::OUString();
}
@@ -88,3 +104,9 @@ ScVbaDialog::getServiceNames()
}
return aServiceNames;
}
+
+//liuchen add 2009-7-27
+sal_Int32 ScVbaDialog::GetSupportedDialogCount()
+{
+ return nDialogSize;
+}
diff --git a/sc/source/ui/vba/vbadialog.hxx b/sc/source/ui/vba/vbadialog.hxx
index 40f4a4a83a11..086770f19357 100644
--- a/sc/source/ui/vba/vbadialog.hxx
+++ b/sc/source/ui/vba/vbadialog.hxx
@@ -45,6 +45,9 @@ public:
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+ //liuchen 2009-7-27
+ 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 67070879535b..6aa4a65cf7d1 100644
--- a/sc/source/ui/vba/vbadialogs.cxx
+++ b/sc/source/ui/vba/vbadialogs.cxx
@@ -64,5 +64,13 @@ ScVbaDialogs::getServiceNames()
return aServiceNames;
}
+//liuchen 2009-7-27
+::sal_Int32
+ScVbaDialogs::getCount() throw (uno::RuntimeException)
+{
+ return ScVbaDialog::GetSupportedDialogCount();
+}
+
+
diff --git a/sc/source/ui/vba/vbadialogs.hxx b/sc/source/ui/vba/vbadialogs.hxx
index 9aab5daf11fe..6b5e1f9a8d90 100644
--- a/sc/source/ui/vba/vbadialogs.hxx
+++ b/sc/source/ui/vba/vbadialogs.hxx
@@ -44,6 +44,7 @@ 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); //liuchen 2009-7-27
// XDialogs
virtual void SAL_CALL Dummy() throw (css::uno::RuntimeException);
diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx
index 45667adf2f2c..7b06c5995fbe 100644
--- a/sc/source/ui/vba/vbaeventshelper.cxx
+++ b/sc/source/ui/vba/vbaeventshelper.cxx
@@ -372,7 +372,15 @@ void ScVbaEventsListener::processWindowResizeMacro()
{
OSL_TRACE( "**** Attempt to FIRE MACRO **** " );
if( !mbDisposed )
- mrVbaEvents.processVbaEvent( WORKBOOK_WINDOWRESIZE, uno::Sequence< uno::Any >() );
+ {
+ try
+ {
+ mrVbaEvents.processVbaEvent( WORKBOOK_WINDOWRESIZE, uno::Sequence< uno::Any >() );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
}
// ============================================================================
diff --git a/sc/source/ui/vba/vbafiledialog.cxx b/sc/source/ui/vba/vbafiledialog.cxx
new file mode 100644
index 000000000000..af85f5d8aee7
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialog.cxx
@@ -0,0 +1,183 @@
+/*************************************************************************
+ *
+ * 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()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFileDialog") );
+ return sImplName;
+}
+
+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::OUString::createFromAscii( "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() )
+ {
+ sal_Bool bUseXFilePicker2 = sal_False;
+ Reference< lang::XServiceInfo > xServiceInfo( xFilePicker, UNO_QUERY );
+ if (xServiceInfo.is())
+ {
+ rtl::OUString sImplName = xServiceInfo->getImplementationName();
+ if (sImplName.equalsAscii("com.sun.star.comp.fpicker.VistaFileDialog") ||
+ sImplName.equalsAscii("com.sun.star.ui.dialogs.SalGtkFilePicker"))
+ {
+ bUseXFilePicker2 = sal_True;
+ }
+ }
+ if ( bUseXFilePicker2 && 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.getLength() > 0 ? aTemp : m_sSelectedItems[i];
+ }
+ }
+ }
+ else
+ {
+ nResult = 0;
+ }
+ }
+
+ m_FileDialogSelectedObj.SetSelectedFile(m_sSelectedItems);
+ }
+ catch( const uno::Exception& )
+ {
+ return 0;
+ }
+
+ return nResult;
+}
diff --git a/sc/source/ui/vba/vbafiledialog.hxx b/sc/source/ui/vba/vbafiledialog.hxx
new file mode 100644
index 000000000000..b38fc16e0c28
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialog.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * 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
diff --git a/sc/source/ui/vba/vbafiledialogselecteditems.cxx b/sc/source/ui/vba/vbafiledialogselecteditems.cxx
new file mode 100644
index 000000000000..ee3adb03342f
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialogselecteditems.cxx
@@ -0,0 +1,154 @@
+/*************************************************************************
+ *
+ * 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()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaFileDialogSelectedItems") );
+ return sImplName;
+
+}
+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 sal_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++]);
+}
diff --git a/sc/source/ui/vba/vbafiledialogselecteditems.hxx b/sc/source/ui/vba/vbafiledialogselecteditems.hxx
new file mode 100644
index 000000000000..272e00ef2d30
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialogselecteditems.hxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * 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
diff --git a/sc/source/ui/vba/vbafilesearch.cxx b/sc/source/ui/vba/vbafilesearch.cxx
new file mode 100644
index 000000000000..9711a5316e4a
--- /dev/null
+++ b/sc/source/ui/vba/vbafilesearch.cxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * 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::createFromAscii( "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 == ::rtl::OUString::createFromAscii( "" ) )
+ {
+ return 1;
+ }
+
+ ::rtl::OUString aTempFileName = m_sFileName.toAsciiLowerCase();
+ if ( IsWildCard( aTempFileName ) )
+ {
+ bool bEndWithAsterisk = aTempFileName.endsWithAsciiL("*", 1);
+ bool bStartWithAsterisk = (aTempFileName.indexOf(::rtl::OUString::createFromAscii("*")) == 0);
+ if ( !bEndWithAsterisk && !bStartWithAsterisk )
+ {
+ aTempFileName = ::rtl::OUString::createFromAscii("*") + aTempFileName + ::rtl::OUString::createFromAscii("*");
+ }
+ }
+ else
+ {
+ aTempFileName = ::rtl::OUString::createFromAscii("*") + aTempFileName + ::rtl::OUString::createFromAscii("*");
+ }
+ WildCard wildCard( aTempFileName );
+ SearchWildCard( wildCard, m_sLookIn, m_bSearchSubFolders, m_aSearchedFiles );
+
+ return m_aSearchedFiles.getLength();
+}
+
+//liuchen 2009-11-5 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::createFromAscii( "" );
+ 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()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaFileSearch") );
+ return sImplName;
+}
+
+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( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.FileSearch") );
+ }
+ return aServiceNames;
+}
diff --git a/sc/source/ui/vba/vbafilesearch.hxx b/sc/source/ui/vba/vbafilesearch.hxx
new file mode 100644
index 000000000000..e82f14a94699
--- /dev/null
+++ b/sc/source/ui/vba/vbafilesearch.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * 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 */
diff --git a/sc/source/ui/vba/vbafoundfiles.cxx b/sc/source/ui/vba/vbafoundfiles.cxx
new file mode 100644
index 000000000000..78e61e8b8601
--- /dev/null
+++ b/sc/source/ui/vba/vbafoundfiles.cxx
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * 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 "vbafoundfiles.hxx"
+
+////////////////////////////////VbaFoundFilesEnum//////////////////////////////////////////
+VbaFoundFilesEnum::VbaFoundFilesEnum() : m_nIndex(0)
+{
+
+}
+
+VbaFoundFilesEnum::VbaFoundFilesEnum( css::uno::Sequence<rtl::OUString>& sFileList ) : m_nIndex(0), m_sFileList(sFileList)
+{
+
+}
+
+VbaFoundFilesEnum::~VbaFoundFilesEnum()
+{
+
+}
+
+void VbaFoundFilesEnum::SetFileList( css::uno::Sequence<rtl::OUString>& sFileList )
+{
+ m_nIndex = 0;
+ m_sFileList = sFileList;
+}
+
+sal_Int32 SAL_CALL VbaFoundFilesEnum::getCount() throw (css::uno::RuntimeException)
+{
+ return m_sFileList.getLength();
+}
+
+css::uno::Any SAL_CALL VbaFoundFilesEnum::getByIndex( sal_Int32 nIndex )
+ throw (css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException)
+{
+ if ( nIndex >= getCount() )
+ {
+ throw css::lang::IndexOutOfBoundsException();
+ }
+
+ return css::uno::makeAny( m_sFileList[nIndex] );
+}
+
+css::uno::Type SAL_CALL VbaFoundFilesEnum::getElementType() throw (css::uno::RuntimeException)
+{
+ return getCppuType((css::uno::Reference< css::container::XIndexAccess >*)0);
+}
+
+sal_Bool SAL_CALL VbaFoundFilesEnum::hasElements() throw (css::uno::RuntimeException)
+{
+ return ( getCount() != 0 );
+}
+
+sal_Bool SAL_CALL VbaFoundFilesEnum::hasMoreElements() throw (css::uno::RuntimeException)
+{
+ if ( getCount() > m_nIndex )
+ {
+ return sal_True;
+ }
+ return sal_False;
+}
+
+css::uno::Any SAL_CALL VbaFoundFilesEnum::nextElement() throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException)
+{
+ if ( !hasMoreElements() )
+ {
+ throw css::container::NoSuchElementException();
+ }
+
+ return css::uno::makeAny( m_sFileList[m_nIndex++] );
+}
+
+////////////////////////////////VbaFoundFiles//////////////////////////////////////////
+VbaFoundFiles::VbaFoundFiles( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess
+ ) : VbaFoundFilesImpl_BASE( xParent, xContext, xIndexAccess )
+{
+
+}
+
+VbaFoundFiles::~VbaFoundFiles()
+{
+
+}
+
+css::uno::Reference< css::container::XEnumeration > VbaFoundFiles::createEnumeration() throw (css::uno::RuntimeException)
+{
+ css::uno::Reference< css::container::XEnumeration > xEnumRet( m_xIndexAccess, css::uno::UNO_QUERY );
+ return xEnumRet;
+}
+
+css::uno::Any VbaFoundFiles::createCollectionObject( const css::uno::Any& aSource )
+{
+ return aSource;
+}
+
+css::uno::Type VbaFoundFiles::getElementType() throw (css::uno::RuntimeException)
+{
+ return ov::XFoundFiles::static_type(0);
+}
+
+rtl::OUString& VbaFoundFiles::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaFoundFiles") );
+ return sImplName;
+}
+
+css::uno::Sequence< rtl::OUString > VbaFoundFiles::getServiceNames()
+{
+ static css::uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.FoundFiles") );
+ }
+ return aServiceNames;
+}
diff --git a/sc/source/ui/vba/vbafoundfiles.hxx b/sc/source/ui/vba/vbafoundfiles.hxx
new file mode 100644
index 000000000000..b02d3bb91526
--- /dev/null
+++ b/sc/source/ui/vba/vbafoundfiles.hxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * 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_FOUNDFILES_HXX
+#define SC_VBA_FOUNDFILES_HXX
+
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <ooo/vba/XFoundFiles.hpp>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+namespace css = ::com::sun::star;
+
+typedef CollTestImplHelper< ooo::vba::XFoundFiles > VbaFoundFilesImpl_BASE;
+
+class VbaFoundFilesEnum : public cppu::WeakImplHelper2< css::container::XIndexAccess, css::container::XEnumeration >
+{
+private:
+ sal_Int32 m_nIndex;
+ css::uno::Sequence< rtl::OUString > m_sFileList;
+
+public:
+ VbaFoundFilesEnum();
+ VbaFoundFilesEnum( css::uno::Sequence< rtl::OUString >& sFileList );
+ ~VbaFoundFilesEnum();
+
+ void SetFileList( css::uno::Sequence< rtl::OUString >& sFileList );
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw (css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ // XElementAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw (css::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);
+};
+
+class VbaFoundFiles : public VbaFoundFilesImpl_BASE
+{
+private:
+
+public:
+ VbaFoundFiles( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
+ virtual ~VbaFoundFiles();
+
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ // XEnumerationAccess
+ 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);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence< rtl::OUString > getServiceNames();
+};
+
+#endif /* SC_VBA_FOUNDFILES_HXX */
diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx
index 2f9f002d427d..91f7afb04638 100644
--- a/sc/source/ui/vba/vbaglobals.cxx
+++ b/sc/source/ui/vba/vbaglobals.cxx
@@ -248,6 +248,12 @@ ScVbaGlobals::getDebug() throw (uno::RuntimeException)
return uno::Any();
}
+uno::Any SAL_CALL
+ScVbaGlobals::MenuBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ return uno::Any( getApplication()->MenuBars(aIndex) );
+}
+
uno::Sequence< ::rtl::OUString > SAL_CALL
ScVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException)
{
diff --git a/sc/source/ui/vba/vbaglobals.hxx b/sc/source/ui/vba/vbaglobals.hxx
index f22e5b19faa4..3108f5ab871c 100644
--- a/sc/source/ui/vba/vbaglobals.hxx
+++ b/sc/source/ui/vba/vbaglobals.hxx
@@ -84,6 +84,7 @@ typedef ::cppu::ImplInheritanceHelper1< VbaGlobalsBase, ov::excel::XGlobals > Sc
virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
virtual css::uno::Reference< ov::excel::XApplication > SAL_CALL getExcel() throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL getDebug() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL MenuBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
// XMultiServiceFactory
diff --git a/sc/source/ui/vba/vbahelper.cxx b/sc/source/ui/vba/vbahelper.cxx
deleted file mode 100644
index cc76b1e60125..000000000000
--- a/sc/source/ui/vba/vbahelper.cxx
+++ /dev/null
@@ -1,758 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * 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 <cppuhelper/bootstrap.hxx>
-#include <com/sun/star/util/XURLTransformer.hpp>
-#include <com/sun/star/frame/XDispatchProvider.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/frame/XDesktop.hpp>
-#include <com/sun/star/frame/XController.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiComponentFactory.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/beans/XIntrospection.hpp>
-
-#include <comphelper/processfactory.hxx>
-
-#include <sfx2/objsh.hxx>
-#include <sfx2/viewfrm.hxx>
-#include <sfx2/dispatch.hxx>
-#include <sfx2/app.hxx>
-#include <svl/stritem.hxx>
-
-#include <docuno.hxx>
-
-#include <basic/sbx.hxx>
-#include <basic/sbstar.hxx>
-#include <rtl/math.hxx>
-
-#include <math.h>
-#include "vbahelper.hxx"
-#include "tabvwsh.hxx"
-#include "transobj.hxx"
-#include "scmod.hxx"
-#include "vbashape.hxx"
-#include "unonames.hxx"
-#include "cellsuno.hxx"
-using namespace ::com::sun::star;
-using namespace ::ooo::vba;
-
-#define POINTTO100THMILLIMETERFACTOR 35.27778
-void unoToSbxValue( SbxVariable* pVar, const uno::Any& aValue );
-
-uno::Any sbxToUnoValue( SbxVariable* pVar );
-
-
-namespace ooo
-{
-namespace vba
-{
-
-const double Millimeter::factor = 35.27778;
-
-uno::Reference< beans::XIntrospectionAccess >
-getIntrospectionAccess( const uno::Any& aObject ) throw (uno::RuntimeException)
-{
- static uno::Reference< beans::XIntrospection > xIntrospection;
- if( !xIntrospection.is() )
- {
- uno::Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
- xIntrospection.set( xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.beans.Introspection") ), uno::UNO_QUERY_THROW );
- }
- return xIntrospection->inspect( aObject );
-}
-
-uno::Reference< script::XTypeConverter >
-getTypeConverter( const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException)
-{
- static uno::Reference< script::XTypeConverter > xTypeConv( xContext->getServiceManager()->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.Converter") ), xContext ), uno::UNO_QUERY_THROW );
- return xTypeConv;
-}
-// helper method to determine if the view ( calc ) is in print-preview mode
-bool isInPrintPreview( SfxViewFrame* pView )
-{
- sal_uInt16 nViewNo = SID_VIEWSHELL1 - SID_VIEWSHELL0;
- if ( pView->GetObjectShell()->GetFactory().GetViewFactoryCount() >
-nViewNo && !pView->GetObjectShell()->IsInPlaceActive() )
- {
- SfxViewFactory &rViewFactory =
- pView->GetObjectShell()->GetFactory().GetViewFactory(nViewNo);
- if ( pView->GetCurViewId() == rViewFactory.GetOrdinal() )
- return true;
- }
- return false;
-}
-const ::rtl::OUString REPLACE_CELLS_WARNING( RTL_CONSTASCII_USTRINGPARAM( "ReplaceCellsWarning"));
-const uno::Any&
-aNULL()
-{
- static uno::Any aNULLL = uno::makeAny( uno::Reference< uno::XInterface >() );
- return aNULLL;
-}
-
-class PasteCellsWarningReseter
-{
-private:
- bool bInitialWarningState;
- static uno::Reference< beans::XPropertySet > getGlobalSheetSettings() throw ( uno::RuntimeException )
- {
- static uno::Reference< beans::XPropertySet > xTmpProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
- static uno::Reference<uno::XComponentContext > xContext( xTmpProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
- static uno::Reference<lang::XMultiComponentFactory > xServiceManager(
- xContext->getServiceManager(), uno::UNO_QUERY_THROW );
- static uno::Reference< beans::XPropertySet > xProps( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.GlobalSheetSettings" ) ) ,xContext ), uno::UNO_QUERY_THROW );
- return xProps;
- }
-
- bool getReplaceCellsWarning() throw ( uno::RuntimeException )
- {
- sal_Bool res = sal_False;
- getGlobalSheetSettings()->getPropertyValue( REPLACE_CELLS_WARNING ) >>= res;
- return ( res == sal_True );
- }
-
- void setReplaceCellsWarning( bool bState ) throw ( uno::RuntimeException )
- {
- getGlobalSheetSettings()->setPropertyValue( REPLACE_CELLS_WARNING, uno::makeAny( bState ) );
- }
-public:
- PasteCellsWarningReseter() throw ( uno::RuntimeException )
- {
- bInitialWarningState = getReplaceCellsWarning();
- if ( bInitialWarningState )
- setReplaceCellsWarning( false );
- }
- ~PasteCellsWarningReseter()
- {
- if ( bInitialWarningState )
- {
- // don't allow dtor to throw
- try
- {
- setReplaceCellsWarning( true );
- }
- catch ( uno::Exception& /*e*/ ){}
- }
- }
-};
-
-void dispatchExecute(css::uno::Reference< css::frame::XModel>& xModel, USHORT nSlot, SfxCallMode nCall)
-{
- ScTabViewShell* pViewShell = getBestViewShell( xModel );
- SfxViewFrame* pViewFrame = NULL;
- if ( pViewShell )
- pViewFrame = pViewShell->GetViewFrame();
- if ( pViewFrame )
- {
- SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
- if( pDispatcher )
- {
- pDispatcher->Execute( nSlot , nCall );
- }
- }
-}
-
-void
-implnPaste()
-{
- PasteCellsWarningReseter resetWarningBox;
- ScTabViewShell* pViewShell = getCurrentBestViewShell();
- if ( pViewShell )
- {
- pViewShell->PasteFromSystem();
- pViewShell->CellContentChanged();
- }
-}
-
-
-void
-implnCopy()
-{
- ScTabViewShell* pViewShell = getCurrentBestViewShell();
- if ( pViewShell )
- pViewShell->CopyToClip(NULL,false,false,true);
-}
-
-void
-implnCut()
-{
- ScTabViewShell* pViewShell = getCurrentBestViewShell();
- if ( pViewShell )
- pViewShell->CutToClip( NULL, TRUE );
-}
-
-void implnPasteSpecial(USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose)
-{
- PasteCellsWarningReseter resetWarningBox;
- sal_Bool bAsLink(sal_False), bOtherDoc(sal_False);
- InsCellCmd eMoveMode = INS_NONE;
-
- ScTabViewShell* pTabViewShell = ScTabViewShell::GetActiveViewShell();
- if ( !pTabViewShell )
- // none active, try next best
- pTabViewShell = getCurrentBestViewShell();
- if ( pTabViewShell )
- {
- ScViewData* pView = pTabViewShell->GetViewData();
- Window* pWin = ( pView != NULL ) ? pView->GetActiveWin() : NULL;
- if ( pView && pWin )
- {
- if ( bAsLink && bOtherDoc )
- pTabViewShell->PasteFromSystem(0);//SOT_FORMATSTR_ID_LINK
- else
- {
- ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
- ScDocument* pDoc = NULL;
- if ( pOwnClip )
- pDoc = pOwnClip->GetDocument();
- pTabViewShell->PasteFromClip( nFlags, pDoc,
- nFunction, bSkipEmpty, bTranspose, bAsLink,
- eMoveMode, IDF_NONE, TRUE );
- pTabViewShell->CellContentChanged();
- }
- }
- }
-
-}
-
- uno::Reference< frame::XModel >
-getCurrentDocument() throw (uno::RuntimeException)
-{
- uno::Reference< frame::XModel > xModel;
- SbxObject* pBasic = dynamic_cast< SbxObject* > ( SFX_APP()->GetBasic() );
- SbxObject* basicChosen = pBasic ;
- if ( basicChosen == NULL)
- {
- OSL_TRACE("getModelFromBasic() StarBASIC* is NULL" );
- return xModel;
- }
- SbxObject* p = pBasic;
- SbxObject* pParent = p->GetParent();
- SbxObject* pParentParent = pParent ? pParent->GetParent() : NULL;
-
- if( pParentParent )
- {
- basicChosen = pParentParent;
- }
- else if( pParent )
- {
- basicChosen = pParent;
- }
-
-
- uno::Any aModel;
- SbxVariable *pCompVar = basicChosen->Find( UniString(RTL_CONSTASCII_USTRINGPARAM("ThisComponent")), SbxCLASS_OBJECT );
-
- if ( pCompVar )
- {
- aModel = sbxToUnoValue( pCompVar );
- if ( sal_False == ( aModel >>= xModel ) ||
- !xModel.is() )
- {
- // trying last gasp try the current component
- uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
- // test if vba service is present
- uno::Reference< uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
- uno::Reference<lang::XMultiComponentFactory > xSMgr( xCtx->getServiceManager(), uno::UNO_QUERY_THROW );
- uno::Reference< frame::XDesktop > xDesktop (xSMgr->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop"), xCtx), uno::UNO_QUERY_THROW );
- xModel.set( xDesktop->getCurrentComponent(), uno::UNO_QUERY );
- if ( !xModel.is() )
- {
- throw uno::RuntimeException(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't extract model from basic ( its obviously not set yet ) therefore don't know the currently selected document") ), uno::Reference< uno::XInterface >() );
- }
- return xModel;
- }
- else
- {
- OSL_TRACE("Have model ThisComponent points to url %s",
- ::rtl::OUStringToOString( xModel->getURL(),
- RTL_TEXTENCODING_ASCII_US ).pData->buffer );
- }
- }
- else
- {
- OSL_TRACE("Failed to get ThisComponent");
- throw uno::RuntimeException(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM(
- "Can't determine the currently selected document") ),
- uno::Reference< uno::XInterface >() );
- }
- return xModel;
-}
-
-ScDocShell*
-getDocShell( css::uno::Reference< css::frame::XModel>& xModel )
-{
- uno::Reference< uno::XInterface > xIf( xModel, uno::UNO_QUERY_THROW );
- ScModelObj* pModel = dynamic_cast< ScModelObj* >( xIf.get() );
- ScDocShell* pDocShell = NULL;
- if ( pModel )
- pDocShell = (ScDocShell*)pModel->GetEmbeddedObject();
- return pDocShell;
-
-}
-
-ScTabViewShell*
-getBestViewShell( css::uno::Reference< css::frame::XModel>& xModel )
-{
- ScDocShell* pDocShell = getDocShell( xModel );
- if ( pDocShell )
- return pDocShell->GetBestViewShell();
- return NULL;
-}
-
-ScTabViewShell*
-getCurrentBestViewShell()
-{
- uno::Reference< frame::XModel > xModel = getCurrentDocument();
- return getBestViewShell( xModel );
-}
-
-SfxViewFrame*
-getCurrentViewFrame()
-{
- ScTabViewShell* pViewShell = getCurrentBestViewShell();
- if ( pViewShell )
- return pViewShell->GetViewFrame();
- return NULL;
-}
-
-sal_Int32
-OORGBToXLRGB( sal_Int32 nCol )
-{
- sal_Int32 nRed = nCol;
- nRed &= 0x00FF0000;
- nRed >>= 16;
- sal_Int32 nGreen = nCol;
- nGreen &= 0x0000FF00;
- nGreen >>= 8;
- sal_Int32 nBlue = nCol;
- nBlue &= 0x000000FF;
- sal_Int32 nRGB = ( (nBlue << 16) | (nGreen << 8) | nRed );
- return nRGB;
-}
-sal_Int32
-XLRGBToOORGB( sal_Int32 nCol )
-{
- sal_Int32 nBlue = nCol;
- nBlue &= 0x00FF0000;
- nBlue >>= 16;
- sal_Int32 nGreen = nCol;
- nGreen &= 0x0000FF00;
- nGreen >>= 8;
- sal_Int32 nRed = nCol;
- nRed &= 0x000000FF;
- sal_Int32 nRGB = ( (nRed << 16) | (nGreen << 8) | nBlue );
- return nRGB;
-}
-uno::Any
-OORGBToXLRGB( const uno::Any& aCol )
-{
- sal_Int32 nCol=0;
- aCol >>= nCol;
- nCol = OORGBToXLRGB( nCol );
- return uno::makeAny( nCol );
-}
-uno::Any
-XLRGBToOORGB( const uno::Any& aCol )
-{
- sal_Int32 nCol=0;
- aCol >>= nCol;
- nCol = XLRGBToOORGB( nCol );
- return uno::makeAny( nCol );
-}
-
-void PrintOutHelper( 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, css::uno::Reference< frame::XModel >& xModel, sal_Bool bUseSelection )
-{
- sal_Int32 nTo = 0;
- sal_Int32 nFrom = 0;
- sal_Int16 nCopies = 1;
- sal_Bool bPreview = sal_False;
- sal_Bool bCollate = sal_False;
- sal_Bool bSelection = bUseSelection;
- From >>= nFrom;
- To >>= nTo;
- Copies >>= nCopies;
- Preview >>= bPreview;
- if ( nCopies > 1 ) // Collate only useful when more that 1 copy
- Collate >>= bCollate;
-
- rtl::OUString sRange( RTL_CONSTASCII_USTRINGPARAM( "-" ) );
- rtl::OUString sFileName;
-
- if (( nFrom || nTo ) )
- {
- if ( nFrom )
- sRange = ( ::rtl::OUString::valueOf( nFrom ) + sRange );
- if ( nTo )
- sRange += ::rtl::OUString::valueOf( nTo );
- }
-
- if ( PrToFileName.getValue() )
- {
- PrToFileName >>= sFileName;
- }
- ScTabViewShell* pViewShell = getBestViewShell( xModel );
- SfxViewFrame* pViewFrame = NULL;
- if ( pViewShell )
- pViewFrame = pViewShell->GetViewFrame();
- if ( pViewFrame )
- {
- SfxAllItemSet aArgs( SFX_APP()->GetPool() );
-
- SfxBoolItem sfxCollate( SID_PRINT_COLLATE, bCollate );
- aArgs.Put( sfxCollate, sfxCollate.Which() );
- SfxInt16Item sfxCopies( SID_PRINT_COPIES, nCopies );
- aArgs.Put( sfxCopies, sfxCopies.Which() );
- if ( sFileName.getLength() )
- {
- SfxStringItem sfxFileName( SID_FILE_NAME, sFileName);
- aArgs.Put( sfxFileName, sfxFileName.Which() );
-
- }
- if ( sRange.getLength() )
- {
- SfxStringItem sfxRange( SID_PRINT_PAGES, sRange );
- aArgs.Put( sfxRange, sfxRange.Which() );
- }
- SfxBoolItem sfxSelection( SID_SELECTION, bSelection );
- aArgs.Put( sfxSelection, sfxSelection.Which() );
- SfxBoolItem sfxAsync( SID_ASYNCHRON, sal_False );
- aArgs.Put( sfxAsync, sfxAsync.Which() );
- SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
-
- if ( pDispatcher )
- {
- if ( bPreview )
- {
- if ( !pViewFrame->GetFrame().IsInPlace() )
- {
- SC_MOD()->InputEnterHandler();
- pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SFX_CALLMODE_SYNCHRON );
- while ( isInPrintPreview( pViewFrame ) )
- Application::Yield();
- }
- }
- else
- pDispatcher->Execute( (USHORT)SID_PRINTDOC, (SfxCallMode)SFX_CALLMODE_SYNCHRON, aArgs );
- }
-
- }
-
- // #FIXME #TODO
- // 1 ActivePrinter ( how/can we switch a printer via API? )
- // 2 PrintToFile ( ms behaviour if this option is specified but no
- // filename supplied 'PrToFileName' then the user will be prompted )
- // 3 Need to check behaviour of Selected sheets with range ( e.g. From & To
- // values ) in oOO these options are mutually exclusive
- // 4 There is a pop up to do with transparent objects in the print source
- // should be able to disable that via configuration for the duration
- // of this method
-}
-
- void PrintPreviewHelper( const css::uno::Any& /*EnableChanges*/, css::uno::Reference< css::frame::XModel >& xModel )
-{
- dispatchExecute( xModel, SID_VIEWSHELL1 );
-}
-
-rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException )
-{
- uno::Type aType = pvargItem.getValueType();
- uno::TypeClass eTypeClass = aType.getTypeClass();
- rtl::OUString sString;
- switch ( eTypeClass )
- {
- case uno::TypeClass_BOOLEAN:
- {
- sal_Bool bBool = sal_False;
- pvargItem >>= bBool;
- sString = rtl::OUString::valueOf( bBool );
- break;
- }
- case uno::TypeClass_STRING:
- pvargItem >>= sString;
- break;
- case uno::TypeClass_FLOAT:
- {
- float aFloat = 0;
- pvargItem >>= aFloat;
- sString = rtl::OUString::valueOf( aFloat );
- break;
- }
- case uno::TypeClass_DOUBLE:
- {
- double aDouble = 0;
- pvargItem >>= aDouble;
- sString = rtl::OUString::valueOf( aDouble );
- break;
- }
- case uno::TypeClass_SHORT:
- case uno::TypeClass_LONG:
- case uno::TypeClass_BYTE:
- {
- sal_Int32 aNum = 0;
- pvargItem >>= aNum;
- sString = rtl::OUString::valueOf( aNum );
- break;
- }
-
- case uno::TypeClass_HYPER:
- {
- sal_Int64 aHyper = 0;
- pvargItem >>= aHyper;
- sString = rtl::OUString::valueOf( aHyper );
- break;
- }
- default:
- throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid type, can't convert" ), uno::Reference< uno::XInterface >() );
- }
- return sString;
-}
-
-
-rtl::OUString
-ContainerUtilities::getUniqueName( const uno::Sequence< ::rtl::OUString >& _slist, const rtl::OUString& _sElementName, const ::rtl::OUString& _sSuffixSeparator)
-{
- return getUniqueName(_slist, _sElementName, _sSuffixSeparator, sal_Int32(2));
-}
-
-rtl::OUString
-ContainerUtilities::getUniqueName( const uno::Sequence< rtl::OUString >& _slist, const rtl::OUString _sElementName, const rtl::OUString& _sSuffixSeparator, sal_Int32 _nStartSuffix)
-{
- sal_Int32 a = _nStartSuffix;
- rtl::OUString scompname = _sElementName;
- bool bElementexists = true;
- sal_Int32 nLen = _slist.getLength();
- if ( nLen == 0 )
- return _sElementName;
-
- while (bElementexists == true)
- {
- for (sal_Int32 i = 0; i < nLen; i++)
- {
- if (FieldInList(_slist, scompname) == -1)
- {
- return scompname;
- }
- }
- scompname = _sElementName + _sSuffixSeparator + rtl::OUString::valueOf( a++ );
- }
- return rtl::OUString();
-}
-
-sal_Int32
-ContainerUtilities::FieldInList( const uno::Sequence< rtl::OUString >& SearchList, const rtl::OUString& SearchString )
-{
- sal_Int32 FieldLen = SearchList.getLength();
- sal_Int32 retvalue = -1;
- for (sal_Int32 i = 0; i < FieldLen; i++)
- {
- // I wonder why comparing lexicographically is done
- // when its a match is whats interesting?
- //if (SearchList[i].compareTo(SearchString) == 0)
- if ( SearchList[i].equals( SearchString ) )
- {
- retvalue = i;
- break;
- }
- }
- return retvalue;
-
-}
-bool NeedEsc(sal_Unicode cCode)
-{
- String sEsc(RTL_CONSTASCII_USTRINGPARAM(".^$+\\|{}()"));
- return (STRING_NOTFOUND != sEsc.Search(cCode));
-}
-
-rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike )
-{
- rtl::OUStringBuffer sResult;
- const sal_Unicode *start = rIn.getStr();
- const sal_Unicode *end = start + rIn.getLength();
-
- int seenright = 0;
- if ( bForLike )
- sResult.append(static_cast<sal_Unicode>('^'));
-
- while (start < end)
- {
- switch (*start)
- {
- case '?':
- sResult.append(static_cast<sal_Unicode>('.'));
- start++;
- break;
- case '*':
- sResult.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".*")));
- start++;
- break;
- case '#':
- sResult.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[0-9]")));
- start++;
- break;
- case '~':
- sResult.append(static_cast<sal_Unicode>('\\'));
- sResult.append(*(++start));
- start++;
- break;
- // dump the ~ and escape the next characture
- case ']':
- sResult.append(static_cast<sal_Unicode>('\\'));
- sResult.append(*start++);
- break;
- case '[':
- sResult.append(*start++);
- seenright = 0;
- while (start < end && !seenright)
- {
- switch (*start)
- {
- case '[':
- case '?':
- case '*':
- sResult.append(static_cast<sal_Unicode>('\\'));
- sResult.append(*start);
- break;
- case ']':
- sResult.append(*start);
- seenright = 1;
- break;
- case '!':
- sResult.append(static_cast<sal_Unicode>('^'));
- break;
- default:
- if (NeedEsc(*start))
- sResult.append(static_cast<sal_Unicode>('\\'));
- sResult.append(*start);
- break;
- }
- start++;
- }
- break;
- default:
- if (NeedEsc(*start))
- sResult.append(static_cast<sal_Unicode>('\\'));
- sResult.append(*start++);
- }
- }
-
- if ( bForLike )
- sResult.append(static_cast<sal_Unicode>('$'));
-
- return sResult.makeStringAndClear( );
-}
-
-double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical)
-{
- double fConvertFactor = 1.0;
- if( bVertical )
- {
- fConvertFactor = xDevice->getInfo().PixelPerMeterY/100000;
- }
- else
- {
- fConvertFactor = xDevice->getInfo().PixelPerMeterX/100000;
- }
- return fConvertFactor;
-}
-
-double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical)
-{
- double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
- return fPoints * POINTTO100THMILLIMETERFACTOR * fConvertFactor;
-}
-double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical)
-{
- double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
- return (fPixels/fConvertFactor)/POINTTO100THMILLIMETERFACTOR;
-}
-
-ConcreteXShapeGeometryAttributes::ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape )
-{
- m_xShape = new ScVbaShape( xContext, xShape );
-}
-
-#define VBA_LEFT "PositionX"
-#define VBA_TOP "PositionY"
-UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl )
-{
- mxModel.set( xControl->getModel(), uno::UNO_QUERY_THROW );
-}
- double UserFormGeometryHelper::getLeft()
- {
- sal_Int32 nLeft = 0;
- mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ) ) >>= nLeft;
- return Millimeter::getInPoints( nLeft );
- }
- void UserFormGeometryHelper::setLeft( double nLeft )
- {
- mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nLeft ) ) );
- }
- double UserFormGeometryHelper::getTop()
- {
- sal_Int32 nTop = 0;
- mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ) ) >>= nTop;
- return Millimeter::getInPoints( nTop );
- }
- void UserFormGeometryHelper::setTop( double nTop )
- {
- mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nTop ) ) );
- }
- double UserFormGeometryHelper::getHeight()
- {
- sal_Int32 nHeight = 0;
- mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHGT ) ) ) >>= nHeight;
- return Millimeter::getInPoints( nHeight );
- }
- void UserFormGeometryHelper::setHeight( double nHeight )
- {
- mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHGT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nHeight ) ) );
- }
- double UserFormGeometryHelper::getWidth()
- {
- sal_Int32 nWidth = 0;
- mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLWID ) ) ) >>= nWidth;
- return Millimeter::getInPoints( nWidth );
- }
- void UserFormGeometryHelper::setWidth( double nWidth)
- {
- mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLWID ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nWidth ) ) );
- }
-
-SfxItemSet*
-ScVbaCellRangeAccess::GetDataSet( ScCellRangeObj* pRangeObj )
-{
- SfxItemSet* pDataSet = pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : NULL ;
- return pDataSet;
-
-}
-
-} // vba
-} // ooo
diff --git a/sc/source/ui/vba/vbamenu.cxx b/sc/source/ui/vba/vbamenu.cxx
new file mode 100644
index 000000000000..fa3dc1779ef3
--- /dev/null
+++ b/sc/source/ui/vba/vbamenu.cxx
@@ -0,0 +1,57 @@
+#include "vbamenu.hxx"
+#include "vbamenuitems.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+ScVbaMenu::ScVbaMenu( const uno::Reference< ov::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< XCommandBarControl >& xCommandBarControl ) throw( uno::RuntimeException ) : Menu_BASE( xParent, xContext ), m_xCommandBarControl( xCommandBarControl )
+{
+}
+
+::rtl::OUString SAL_CALL
+ScVbaMenu::getCaption() throw ( uno::RuntimeException )
+{
+ return m_xCommandBarControl->getCaption();
+}
+
+void SAL_CALL
+ScVbaMenu::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException)
+{
+ m_xCommandBarControl->setCaption( _caption );
+}
+
+void SAL_CALL
+ScVbaMenu::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ m_xCommandBarControl->Delete();
+}
+
+uno::Any SAL_CALL
+ScVbaMenu::MenuItems( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< XCommandBarControls > xCommandBarControls( m_xCommandBarControl->Controls( uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XMenuItems > xMenuItems( new ScVbaMenuItems( this, mxContext, xCommandBarControls ) );
+ if( aIndex.hasValue() )
+ {
+ return xMenuItems->Item( aIndex, uno::Any() );
+ }
+ return uno::makeAny( xMenuItems );
+}
+
+rtl::OUString&
+ScVbaMenu::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenu") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenu::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Menu" ) );
+ }
+ return aServiceNames;
+}
diff --git a/sc/source/ui/vba/vbamenu.hxx b/sc/source/ui/vba/vbamenu.hxx
new file mode 100644
index 000000000000..bc4c5e39a9aa
--- /dev/null
+++ b/sc/source/ui/vba/vbamenu.hxx
@@ -0,0 +1,28 @@
+#ifndef SC_VBA_MENU_HXX
+#define SC_VBA_MENU_HXX
+
+#include <ooo/vba/excel/XMenu.hpp>
+#include <ooo/vba/XCommandBarControl.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XMenu > Menu_BASE;
+
+class ScVbaMenu : public Menu_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBarControl > m_xCommandBarControl;
+
+public:
+ ScVbaMenu( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< ov::XCommandBarControl >& xCommandBarControl ) throw( css::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL MenuItems( const css::uno::Any& aIndex ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif//SC_VBA_MENU_HXX
diff --git a/sc/source/ui/vba/vbamenubar.cxx b/sc/source/ui/vba/vbamenubar.cxx
new file mode 100644
index 000000000000..254d8fd47922
--- /dev/null
+++ b/sc/source/ui/vba/vbamenubar.cxx
@@ -0,0 +1,40 @@
+#include "vbamenubar.hxx"
+#include "vbamenus.hxx"
+#include <ooo/vba/XCommandBarControls.hpp>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+ScVbaMenuBar::ScVbaMenuBar( const uno::Reference< ov::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< XCommandBar >& xCommandBar ) throw( uno::RuntimeException ) : MenuBar_BASE( xParent, xContext ), m_xCommandBar( xCommandBar )
+{
+}
+
+uno::Any SAL_CALL
+ScVbaMenuBar::Menus( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< XCommandBarControls > xCommandBarControls( m_xCommandBar->Controls( uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XMenus > xMenus( new ScVbaMenus( this, mxContext, xCommandBarControls ) );
+ if( aIndex.hasValue() )
+ {
+ return xMenus->Item( aIndex, uno::Any() );
+ }
+ return uno::makeAny( xMenus );
+}
+
+rtl::OUString&
+ScVbaMenuBar::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenuBar") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenuBar::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.MenuBar" ) );
+ }
+ return aServiceNames;
+}
diff --git a/sc/source/ui/vba/vbamenubar.hxx b/sc/source/ui/vba/vbamenubar.hxx
new file mode 100644
index 000000000000..daadd622f427
--- /dev/null
+++ b/sc/source/ui/vba/vbamenubar.hxx
@@ -0,0 +1,24 @@
+#ifndef SC_VBA_MENUBAR_HXX
+#define SC_VBA_MENUBAR_HXX
+
+#include <ooo/vba/excel/XMenuBar.hpp>
+#include <ooo/vba/XCommandBar.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XMenuBar > MenuBar_BASE;
+
+class ScVbaMenuBar : public MenuBar_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBar > m_xCommandBar;
+
+public:
+ ScVbaMenuBar( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< ov::XCommandBar >& xCommandBar ) throw( css::uno::RuntimeException );
+
+ virtual css::uno::Any SAL_CALL Menus( const css::uno::Any& aIndex ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif//SC_VBA_MENUBAR_HXX
diff --git a/sc/source/ui/vba/vbamenubars.cxx b/sc/source/ui/vba/vbamenubars.cxx
new file mode 100644
index 000000000000..00fe9cc73955
--- /dev/null
+++ b/sc/source/ui/vba/vbamenubars.cxx
@@ -0,0 +1,111 @@
+#include "vbamenubars.hxx"
+#include "vbamenubar.hxx"
+#include <ooo/vba/excel/XlSheetType.hpp>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+
+typedef ::cppu::WeakImplHelper1< container::XEnumeration > MenuBarEnumeration_BASE;
+
+class MenuBarEnumeration : public MenuBarEnumeration_BASE
+{
+ uno::Reference< XHelperInterface > m_xParent;
+ uno::Reference< uno::XComponentContext > m_xContext;
+ uno::Reference< container::XEnumeration > m_xEnumeration;
+public:
+ MenuBarEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration )
+ {
+ }
+ virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
+ {
+ return m_xEnumeration->hasMoreElements();
+ }
+ virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+ {
+ // FIXME: should be add menubar
+ if( hasMoreElements() )
+ {
+ uno::Reference< XCommandBar > xCommandBar( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( m_xParent, m_xContext, xCommandBar ) );
+ return uno::makeAny( xMenuBar );
+ }
+ else
+ throw container::NoSuchElementException();
+ return uno::Any();
+ }
+};
+
+ScVbaMenuBars::ScVbaMenuBars( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCommandBars >& xCommandBars ) throw ( uno::RuntimeException ) : MenuBars_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() ), m_xCommandBars( xCommandBars )
+{
+}
+
+ScVbaMenuBars::~ScVbaMenuBars()
+{
+}
+
+// XEnumerationAccess
+uno::Type SAL_CALL
+ScVbaMenuBars::getElementType() throw ( uno::RuntimeException )
+{
+ return excel::XMenuBar::static_type( 0 );
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaMenuBars::createEnumeration() throw ( uno::RuntimeException )
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xCommandBars, uno::UNO_QUERY_THROW );
+ return uno::Reference< container::XEnumeration >( new MenuBarEnumeration( this, mxContext, xEnumAccess->createEnumeration() ) );
+}
+
+uno::Any
+ScVbaMenuBars::createCollectionObject( const uno::Any& aSource )
+{
+ // make no sense
+ return aSource;
+}
+
+sal_Int32 SAL_CALL
+ScVbaMenuBars::getCount() throw(css::uno::RuntimeException)
+{
+ return m_xCommandBars->getCount();
+}
+
+// ScVbaCollectionBaseImpl
+uno::Any SAL_CALL
+ScVbaMenuBars::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
+{
+ sal_Int16 nIndex = 0;
+ aIndex >>= nIndex;
+ if( nIndex == excel::XlSheetType::xlWorksheet )
+ {
+ uno::Any aSource;
+ aSource <<= rtl::OUString::createFromAscii( "Worksheet Menu Bar" );
+ uno::Reference< XCommandBar > xCommandBar( m_xCommandBars->Item( aSource, uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( this, mxContext, xCommandBar ) );
+ return uno::makeAny( xMenuBar );
+ }
+
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+
+ return uno::Any();
+}
+
+// XHelperInterface
+rtl::OUString&
+ScVbaMenuBars::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenuBars") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenuBars::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.MenuBars" ) );
+ }
+ return aServiceNames;
+}
diff --git a/sc/source/ui/vba/vbamenubars.hxx b/sc/source/ui/vba/vbamenubars.hxx
new file mode 100644
index 000000000000..1a2f228cc28d
--- /dev/null
+++ b/sc/source/ui/vba/vbamenubars.hxx
@@ -0,0 +1,35 @@
+#ifndef SC_VBA_MENUBARS_HXX
+#define SC_VBA_MENUBARS_HXX
+
+#include <ooo/vba/excel/XMenuBars.hpp>
+#include <ooo/vba/excel/XMenuBar.hpp>
+#include <ooo/vba/XCommandBars.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+typedef CollTestImplHelper< ov::excel::XMenuBars > MenuBars_BASE;
+
+class ScVbaMenuBars : public MenuBars_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBars > m_xCommandBars;
+
+public:
+ ScVbaMenuBars( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< ov::XCommandBars >& xCommandBars ) throw (css::uno::RuntimeException);
+ virtual ~ScVbaMenuBars();
+
+ // XEnumerationAccess
+ 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);
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ virtual sal_Int32 SAL_CALL getCount() throw(css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& aIndex, const css::uno::Any& /*aIndex2*/ ) throw( css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif//SC_VBA_MENUBARS_HXX
diff --git a/sc/source/ui/vba/vbamenuitem.cxx b/sc/source/ui/vba/vbamenuitem.cxx
new file mode 100644
index 000000000000..d6abde4a33a2
--- /dev/null
+++ b/sc/source/ui/vba/vbamenuitem.cxx
@@ -0,0 +1,56 @@
+#include "vbamenuitem.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+ScVbaMenuItem::ScVbaMenuItem( const uno::Reference< ov::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< XCommandBarControl >& xCommandBarControl ) throw( uno::RuntimeException ) : MenuItem_BASE( xParent, xContext ), m_xCommandBarControl( xCommandBarControl )
+{
+}
+
+::rtl::OUString SAL_CALL
+ScVbaMenuItem::getCaption() throw ( uno::RuntimeException )
+{
+ return m_xCommandBarControl->getCaption();
+}
+
+void SAL_CALL
+ScVbaMenuItem::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException)
+{
+ m_xCommandBarControl->setCaption( _caption );
+}
+
+::rtl::OUString SAL_CALL
+ScVbaMenuItem::getOnAction() throw ( uno::RuntimeException )
+{
+ return m_xCommandBarControl->getOnAction();
+}
+
+void SAL_CALL
+ScVbaMenuItem::setOnAction( const ::rtl::OUString& _onaction ) throw (uno::RuntimeException)
+{
+ m_xCommandBarControl->setOnAction( _onaction );
+}
+
+void SAL_CALL
+ScVbaMenuItem::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ m_xCommandBarControl->Delete();
+}
+
+rtl::OUString&
+ScVbaMenuItem::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenuItem") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenuItem::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.MenuItem" ) );
+ }
+ return aServiceNames;
+}
diff --git a/sc/source/ui/vba/vbamenuitem.hxx b/sc/source/ui/vba/vbamenuitem.hxx
new file mode 100644
index 000000000000..71feec07cd11
--- /dev/null
+++ b/sc/source/ui/vba/vbamenuitem.hxx
@@ -0,0 +1,29 @@
+#ifndef SC_VBA_MENUITEM_HXX
+#define SC_VBA_MENUITEM_HXX
+
+#include <ooo/vba/excel/XMenuItem.hpp>
+#include <ooo/vba/XCommandBarControl.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XMenuItem > MenuItem_BASE;
+
+class ScVbaMenuItem : public MenuItem_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBarControl > m_xCommandBarControl;
+
+public:
+ ScVbaMenuItem( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< ov::XCommandBarControl >& xCommandBarControl ) throw( css::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getOnAction() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setOnAction( const ::rtl::OUString& _onaction ) throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif//SC_VBA_MENUITEM_HXX
diff --git a/sc/source/ui/vba/vbamenuitems.cxx b/sc/source/ui/vba/vbamenuitems.cxx
new file mode 100644
index 000000000000..4cbc98a23b2f
--- /dev/null
+++ b/sc/source/ui/vba/vbamenuitems.cxx
@@ -0,0 +1,124 @@
+#include "vbamenuitems.hxx"
+#include "vbamenuitem.hxx"
+#include "vbamenu.hxx"
+#include <ooo/vba/office/MsoControlType.hpp>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+
+typedef ::cppu::WeakImplHelper1< container::XEnumeration > MenuEnumeration_BASE;
+
+class MenuEnumeration : public MenuEnumeration_BASE
+{
+ uno::Reference< XHelperInterface > m_xParent;
+ uno::Reference< uno::XComponentContext > m_xContext;
+ uno::Reference< container::XEnumeration > m_xEnumeration;
+public:
+ MenuEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration )
+ {
+ }
+ virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
+ {
+ return m_xEnumeration->hasMoreElements();
+ }
+ virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+ {
+ // FIXME: should be add menu
+ if( hasMoreElements() )
+ {
+ uno::Reference< XCommandBarControl > xCommandBarControl( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ if( xCommandBarControl->getType() == office::MsoControlType::msoControlPopup )
+ {
+ uno::Reference< excel::XMenu > xMenu( new ScVbaMenu( m_xParent, m_xContext, xCommandBarControl ) );
+ return uno::makeAny( xMenu );
+ }
+ else if( xCommandBarControl->getType() == office::MsoControlType::msoControlButton )
+ {
+ uno::Reference< excel::XMenuItem > xMenuItem( new ScVbaMenuItem( m_xParent, m_xContext, xCommandBarControl ) );
+ return uno::makeAny( xMenuItem );
+ }
+ nextElement();
+ }
+ else
+ throw container::NoSuchElementException();
+ return uno::Any();
+ }
+};
+
+ScVbaMenuItems::ScVbaMenuItems( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCommandBarControls >& xCommandBarControls ) throw ( uno::RuntimeException ) : MenuItems_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() ), m_xCommandBarControls( xCommandBarControls )
+{
+}
+
+// XEnumerationAccess
+uno::Type SAL_CALL
+ScVbaMenuItems::getElementType() throw ( uno::RuntimeException )
+{
+ return excel::XMenuItem::static_type( 0 );
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaMenuItems::createEnumeration() throw ( uno::RuntimeException )
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xCommandBarControls, uno::UNO_QUERY_THROW );
+ return uno::Reference< container::XEnumeration >( new MenuEnumeration( this, mxContext, xEnumAccess->createEnumeration() ) );
+}
+
+uno::Any
+ScVbaMenuItems::createCollectionObject( const uno::Any& aSource )
+{
+ // make no sense
+ return aSource;
+}
+
+sal_Int32 SAL_CALL
+ScVbaMenuItems::getCount() throw(css::uno::RuntimeException)
+{
+ // FIXME: should check if it is a popup menu
+ return m_xCommandBarControls->getCount();
+}
+
+// ScVbaCollectionBaseImpl
+uno::Any SAL_CALL
+ScVbaMenuItems::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
+{
+ uno::Reference< XCommandBarControl > xCommandBarControl( m_xCommandBarControls->Item( aIndex, uno::Any() ), uno::UNO_QUERY_THROW );
+ if( xCommandBarControl->getType() == office::MsoControlType::msoControlPopup )
+ return uno::makeAny( uno::Reference< excel::XMenu > ( new ScVbaMenu( this, mxContext, xCommandBarControl ) ) );
+ else if( xCommandBarControl->getType() == office::MsoControlType::msoControlButton )
+ return uno::makeAny( uno::Reference< excel::XMenuItem > ( new ScVbaMenuItem( this, mxContext, xCommandBarControl ) ) );
+ throw uno::RuntimeException();
+}
+
+uno::Reference< excel::XMenuItem > SAL_CALL ScVbaMenuItems::Add( const rtl::OUString& Caption, const css::uno::Any& OnAction, const css::uno::Any& /*ShortcutKey*/, const css::uno::Any& Before, const css::uno::Any& Restore, const css::uno::Any& /*StatusBar*/, const css::uno::Any& /*HelpFile*/, const css::uno::Any& /*HelpContextID*/ ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ sal_Int32 nType = office::MsoControlType::msoControlButton;
+ uno::Reference< XCommandBarControl > xCommandBarControl = m_xCommandBarControls->Add( uno::makeAny( nType ), uno::Any(), uno::Any(), Before, Restore );
+ xCommandBarControl->setCaption( Caption );
+ if( OnAction.hasValue() )
+ {
+ rtl::OUString sAction;
+ OnAction >>= sAction;
+ xCommandBarControl->setOnAction( sAction );
+ }
+ return uno::Reference< excel::XMenuItem >( new ScVbaMenuItem( this, mxContext, xCommandBarControl ) );
+}
+
+// XHelperInterface
+rtl::OUString&
+ScVbaMenuItems::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenuItems") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenuItems::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.MenuItems" ) );
+ }
+ return aServiceNames;
+}
diff --git a/sc/source/ui/vba/vbamenuitems.hxx b/sc/source/ui/vba/vbamenuitems.hxx
new file mode 100644
index 000000000000..6b0d5f5d5322
--- /dev/null
+++ b/sc/source/ui/vba/vbamenuitems.hxx
@@ -0,0 +1,34 @@
+#ifndef SC_VBA_MENUITEMS_HXX
+#define SC_VBA_MENUITEMS_HXX
+
+#include <ooo/vba/excel/XMenuItems.hpp>
+#include <ooo/vba/excel/XMenuItem.hpp>
+#include <ooo/vba/XCommandBarControls.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+typedef CollTestImplHelper< ov::excel::XMenuItems > MenuItems_BASE;
+
+class ScVbaMenuItems : public MenuItems_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBarControls > m_xCommandBarControls;
+
+public:
+ ScVbaMenuItems( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< ov::XCommandBarControls >& xCommandBarControls ) throw( css::uno::RuntimeException );
+
+ // XEnumerationAccess
+ 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);
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ // Methods
+ virtual sal_Int32 SAL_CALL getCount() throw(css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index, const css::uno::Any& /*Index2*/ ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XMenuItem > SAL_CALL Add( const rtl::OUString& Caption, const css::uno::Any& OnAction, const css::uno::Any& ShortcutKey, const css::uno::Any& Before, const css::uno::Any& Restore, const css::uno::Any& StatusBar, const css::uno::Any& HelpFile, const css::uno::Any& HelpContextID ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif//SC_VBA_MENUITEMS_HXX
diff --git a/sc/source/ui/vba/vbamenus.cxx b/sc/source/ui/vba/vbamenus.cxx
new file mode 100644
index 000000000000..7644e51034b0
--- /dev/null
+++ b/sc/source/ui/vba/vbamenus.cxx
@@ -0,0 +1,110 @@
+#include "vbamenus.hxx"
+#include "vbamenu.hxx"
+#include <ooo/vba/office/MsoControlType.hpp>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+
+typedef ::cppu::WeakImplHelper1< container::XEnumeration > MenuEnumeration_BASE;
+
+class MenuEnumeration : public MenuEnumeration_BASE
+{
+ uno::Reference< XHelperInterface > m_xParent;
+ uno::Reference< uno::XComponentContext > m_xContext;
+ uno::Reference< container::XEnumeration > m_xEnumeration;
+public:
+ MenuEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration )
+ {
+ }
+ virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
+ {
+ return m_xEnumeration->hasMoreElements();
+ }
+ virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+ {
+ // FIXME: should be add menu
+ if( hasMoreElements() )
+ {
+ uno::Reference< XCommandBarControl > xCommandBarControl( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ if( xCommandBarControl->getType() == office::MsoControlType::msoControlPopup )
+ {
+ uno::Reference< excel::XMenu > xMenu( new ScVbaMenu( m_xParent, m_xContext, xCommandBarControl ) );
+ return uno::makeAny( xMenu );
+ }
+ nextElement();
+ }
+ else
+ throw container::NoSuchElementException();
+ return uno::Any();
+ }
+};
+
+ScVbaMenus::ScVbaMenus( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCommandBarControls >& xCommandBarControls ) throw ( uno::RuntimeException ) : Menus_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() ), m_xCommandBarControls( xCommandBarControls )
+{
+}
+
+// XEnumerationAccess
+uno::Type SAL_CALL
+ScVbaMenus::getElementType() throw ( uno::RuntimeException )
+{
+ return excel::XMenu::static_type( 0 );
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaMenus::createEnumeration() throw ( uno::RuntimeException )
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xCommandBarControls, uno::UNO_QUERY_THROW );
+ return uno::Reference< container::XEnumeration >( new MenuEnumeration( this, mxContext, xEnumAccess->createEnumeration() ) );
+}
+
+uno::Any
+ScVbaMenus::createCollectionObject( const uno::Any& aSource )
+{
+ // make no sense
+ return aSource;
+}
+
+sal_Int32 SAL_CALL
+ScVbaMenus::getCount() throw(css::uno::RuntimeException)
+{
+ // FIXME: should check if it is a popup menu
+ return m_xCommandBarControls->getCount();
+}
+
+// ScVbaCollectionBaseImpl
+uno::Any SAL_CALL
+ScVbaMenus::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
+{
+ uno::Reference< XCommandBarControl > xCommandBarControl( m_xCommandBarControls->Item( aIndex, uno::Any() ), uno::UNO_QUERY_THROW );
+ if( xCommandBarControl->getType() != office::MsoControlType::msoControlPopup )
+ throw uno::RuntimeException();
+ return uno::makeAny( uno::Reference< excel::XMenu > ( new ScVbaMenu( this, mxContext, xCommandBarControl ) ) );
+}
+
+uno::Reference< excel::XMenu > SAL_CALL ScVbaMenus::Add( const rtl::OUString& Caption, const css::uno::Any& Before, const css::uno::Any& Restore ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ sal_Int32 nType = office::MsoControlType::msoControlPopup;
+ uno::Reference< XCommandBarControl > xCommandBarControl = m_xCommandBarControls->Add( uno::makeAny( nType ), uno::Any(), uno::Any(), Before, Restore );
+ xCommandBarControl->setCaption( Caption );
+ return uno::Reference< excel::XMenu >( new ScVbaMenu( this, mxContext, xCommandBarControl ) );
+}
+
+// XHelperInterface
+rtl::OUString&
+ScVbaMenus::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenus") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenus::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Menus" ) );
+ }
+ return aServiceNames;
+}
diff --git a/sc/source/ui/vba/vbamenus.hxx b/sc/source/ui/vba/vbamenus.hxx
new file mode 100644
index 000000000000..19e26a78f8fb
--- /dev/null
+++ b/sc/source/ui/vba/vbamenus.hxx
@@ -0,0 +1,34 @@
+#ifndef SC_VBA_MENUS_HXX
+#define SC_VBA_MENUS_HXX
+
+#include <ooo/vba/excel/XMenus.hpp>
+#include <ooo/vba/excel/XMenu.hpp>
+#include <ooo/vba/XCommandBarControls.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+typedef CollTestImplHelper< ov::excel::XMenus > Menus_BASE;
+
+class ScVbaMenus : public Menus_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBarControls > m_xCommandBarControls;
+
+public:
+ ScVbaMenus( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< ov::XCommandBarControls >& xCommandBarControls ) throw( css::uno::RuntimeException );
+
+ // XEnumerationAccess
+ 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);
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ // Methods
+ virtual sal_Int32 SAL_CALL getCount() throw(css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index, const css::uno::Any& /*Index2*/ ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XMenu > SAL_CALL Add( const rtl::OUString& Caption, const css::uno::Any& Before, const css::uno::Any& Restore ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif//SC_VBA_MENUS_HXX
diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx
index 464b167df250..cd99430acb15 100644
--- a/sc/source/ui/vba/vbaname.cxx
+++ b/sc/source/ui/vba/vbaname.cxx
@@ -69,8 +69,8 @@ ScVbaName::getWorkSheet() throw (css::uno::RuntimeException)
ScVbaName::getName() throw (css::uno::RuntimeException)
{
String sName;
- sName += UniString( getWorkSheet()->getName());
- sName += String::CreateFromAscii("!");
+ //sName += UniString( getWorkSheet()->getName()); //liuchen 2009-9-9 resolve the defect that the name get by macro code are not the same with that in UI (for example, if a name of "AA" is found in the UI "Define Names" dialog box, the result of get that name through macro code will be "Sheet1!AA")
+ //sName += String::CreateFromAscii("!");
sName += UniString ( mxNamedRange->getName() );
return ::rtl::OUString( sName );
}
@@ -107,78 +107,41 @@ ScVbaName::setVisible( sal_Bool /*bVisible*/ ) throw (css::uno::RuntimeException
::rtl::OUString
ScVbaName::getValue() throw (css::uno::RuntimeException)
{
- ::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 )
- {
- ::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 );
- }
- ::rtl::OUString sTmpValue = sValue.copy( nFrom );
- if ( sTmpValue.toChar() == '$' )
+ 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 sTmp = sTmpValue.copy(1);
- sTmp = sTmp.replaceAt(0, (sSheetName + ::rtl::OUString::createFromAscii(".")).getLength(), sSheetName + ::rtl::OUString::createFromAscii("!"));
- sResult += sTmp;
+ sValue = aContent;
}
- if (sResult.indexOf('=') != 0)
+ if ( sValue.indexOf('=') != 0 )
{
- sResult = ::rtl::OUString::createFromAscii("=") + sResult;
+ sValue = rtl::OUString::createFromAscii("=") + sValue;
}
- return sResult;
+ return sValue;
}
void
ScVbaName::setValue( const ::rtl::OUString & rValue ) throw (css::uno::RuntimeException)
{
- ::rtl::OUString sSheetName = getWorkSheet()->getName();
::rtl::OUString sValue = rValue;
- ::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)
+ ScDocShell* pDocShell = excel::getDocShell( mxModel );
+ ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
+ String aContent;
+ excel::CompileExcelFormulaToODF( pDoc, sValue, aContent );
+ if ( aContent.Len() > 0 )
{
- ::rtl::OUString sTmp = sValue.copy(1);
- sValue = sTmp;
+ sValue = aContent;
}
- 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);
+ mxNamedRange->setContent( sValue );
}
::rtl::OUString
@@ -208,7 +171,7 @@ ScVbaName::setRefersToLocal( const ::rtl::OUString & rRefersTo ) throw (css::uno
::rtl::OUString
ScVbaName::getRefersToR1C1() throw (css::uno::RuntimeException)
{
- return getRefersTo();
+ return getValue( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
}
void
@@ -220,7 +183,7 @@ ScVbaName::setRefersToR1C1( const ::rtl::OUString & rRefersTo ) throw (css::uno:
::rtl::OUString
ScVbaName::getRefersToR1C1Local() throw (css::uno::RuntimeException)
{
- return getRefersTo();
+ return getValue( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
}
void
diff --git a/sc/source/ui/vba/vbaname.hxx b/sc/source/ui/vba/vbaname.hxx
index 81b2555a4ce1..8e0aa3973aae 100644
--- a/sc/source/ui/vba/vbaname.hxx
+++ b/sc/source/ui/vba/vbaname.hxx
@@ -33,6 +33,8 @@
#include <vbahelper/vbahelperinterface.hxx>
+#include <formula/grammar.hxx>
+
class ScDocument;
typedef InheritedHelperInterfaceImpl1< ov::excel::XName > NameImpl_BASE;
@@ -48,6 +50,8 @@ 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 9fd22bf89f7a..f79dc5023d28 100644
--- a/sc/source/ui/vba/vbanames.cxx
+++ b/sc/source/ui/vba/vbanames.cxx
@@ -87,6 +87,33 @@ 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 ,
const css::uno::Any& RefersTo,
@@ -100,8 +127,9 @@ 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;
@@ -109,6 +137,12 @@ ScVbaNames::Add( const css::uno::Any& Name ,
NameLocal >>= sName;
if ( sName.getLength() != 0 )
{
+ 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 ;
@@ -121,19 +155,22 @@ ScVbaNames::Add( const css::uno::Any& Name ,
sResult = sName.copy( nIndex );
sName = sResult ;
if ( !ScRangeData::IsNameValid( sName , getScDocument() ) )
- throw uno::RuntimeException( rtl::OUString::createFromAscii("This Name is a valid ."), uno::Reference< uno::XInterface >() );
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("This Name is a invalid ."), uno::Reference< uno::XInterface >() );
}
}
if ( RefersTo.hasValue() || RefersToR1C1.hasValue() || RefersToR1C1Local.hasValue() )
{
if ( RefersTo.hasValue() )
- RefersTo >>= xRange;
+ GetRangeOrRefersTo( RefersTo, mxContext, xRange, sRefersTo );
if ( RefersToR1C1.hasValue() )
- RefersToR1C1 >>= xRange;
+ GetRangeOrRefersTo( RefersToR1C1, mxContext, xRange, sRefersTo );
if ( RefersToR1C1Local.hasValue() )
- RefersToR1C1Local >>= xRange;
+ GetRangeOrRefersTo( RefersToR1C1Local, mxContext, xRange, sRefersTo );
}
+ String aContent;
+ table::CellAddress aPosition;
+ RangeType nType = RT_NAME;
if ( xRange.is() )
{
ScVbaRange* pRange = dynamic_cast< ScVbaRange* >( xRange.get() );
@@ -146,19 +183,36 @@ 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 );
- String sTmp;
- sTmp += String::CreateFromAscii("$");
- sTmp += UniString(xRange->getWorksheet()->getName());
- sTmp += String::CreateFromAscii(".");
- sTmp += sRangeAdd;
- if ( mxNames.is() )
+ aContent += String::CreateFromAscii("$");
+ aContent += UniString(xRange->getWorksheet()->getName());
+ aContent += String::CreateFromAscii(".");
+ 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 )
+ {
+ aContent = sRefersTo;
+ }
+ }
+
+ uno::Reference< sheet::XNamedRange > xNewNamedRange;
+ if ( mxNames.is() )
+ {
+ if ( mxNames->hasByName( sName ) )
{
- 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);
+ 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 a35ce4b3120f..e74fa48f1755 100644
--- a/sc/source/ui/vba/vbaoleobject.cxx
+++ b/sc/source/ui/vba/vbaoleobject.cxx
@@ -67,7 +67,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_xControlShape, uno::UNO_QUERY_THROW );
+ return uno::Reference< uno::XInterface >( m_xControl, 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 25ccbb0f4cdc..89ea1533921f 100644
--- a/sc/source/ui/vba/vbapagebreaks.cxx
+++ b/sc/source/ui/vba/vbapagebreaks.cxx
@@ -115,10 +115,13 @@ sal_Int32 SAL_CALL RangePageBreaks::getCount( ) throw (uno::RuntimeException)
for( sal_Int32 i=0; i<nLength; i++ )
{
sal_Int32 nPos = aTablePageBreakData[i].Position;
- if( nPos > nUsedEnd )
- return nCount;
- if( nPos >= nUsedStart )
+
+ // VBA. minz@cn.ibm.com. 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
+ return nCount;
}
return nCount;
@@ -144,26 +147,15 @@ 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();
- 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;
- }
+ //VBA. minz@cn.ibm.com. No need to filter the page break. All page breaks before the used range are counted.
+ if ( nAPIItemIndex < nLength && nAPIItemIndex>=0 )
+ aTablePageBreakData = aTablePageBreakDataList[nAPIItemIndex];
return aTablePageBreakData;
}
diff --git a/sc/source/ui/vba/vbapagesetup.cxx b/sc/source/ui/vba/vbapagesetup.cxx
index d660ddbbfd77..f72b32477179 100644
--- a/sc/source/ui/vba/vbapagesetup.cxx
+++ b/sc/source/ui/vba/vbapagesetup.cxx
@@ -37,6 +37,9 @@
#include <ooo/vba/excel/XlPageOrientation.hpp>
#include <ooo/vba/excel/XlOrder.hpp>
#include <ooo/vba/excel/Constants.hpp>
+#include <i18npool/paper.hxx>
+#include <editeng/paperinf.hxx>
+#include <ooo/vba/excel/XlPaperSize.hpp>
using namespace ::com::sun::star;
using namespace ::ooo::vba;
@@ -624,3 +627,105 @@ ScVbaPageSetup::getServiceNames()
}
return aServiceNames;
}
+
+//liuchen 2009-12-11
+
+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 = sizeof(paperSizeMappings) / sizeof(paperSizeMappings[0]);
+
+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( RTL_CONSTASCII_USTRINGPARAM("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( RTL_CONSTASCII_USTRINGPARAM("Size")), uno::makeAny( size ));
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
diff --git a/sc/source/ui/vba/vbapagesetup.hxx b/sc/source/ui/vba/vbapagesetup.hxx
index d2c001b225cf..f81ad5a7a29a 100644
--- a/sc/source/ui/vba/vbapagesetup.hxx
+++ b/sc/source/ui/vba/vbapagesetup.hxx
@@ -82,6 +82,8 @@ 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); //liuchen 2009-12-11
+ virtual void SAL_CALL setPaperSize( sal_Int32 paperSize ) throw (css::uno::RuntimeException); //liuchen 2009-12-11
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
diff --git a/sc/source/ui/vba/vbapivotcache.cxx b/sc/source/ui/vba/vbapivotcache.cxx
index 322b42368b48..01fe65e8111a 100644
--- a/sc/source/ui/vba/vbapivotcache.cxx
+++ b/sc/source/ui/vba/vbapivotcache.cxx
@@ -34,6 +34,17 @@ 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 dea3e35d18bd..3b88fe311f33 100644
--- a/sc/source/ui/vba/vbapivotcache.hxx
+++ b/sc/source/ui/vba/vbapivotcache.hxx
@@ -40,6 +40,10 @@ class ScVbaPivotCache : public PivotCacheImpl_BASE
css::uno::Reference< css::sheet::XDataPilotTable > m_xTable;
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
new file mode 100644
index 000000000000..d08fd302b2a8
--- /dev/null
+++ b/sc/source/ui/vba/vbaquerytable.cxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * 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
+ sal_Int32 nRow = m_pParent->getRow();
+ sal_Int32 nClm = m_pParent->getColumn();
+ sal_Int16 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();
+ USHORT nCount = rLinks.Count();
+
+ for (USHORT 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;
+}
diff --git a/sc/source/ui/vba/vbaquerytable.hxx b/sc/source/ui/vba/vbaquerytable.hxx
new file mode 100644
index 000000000000..bf3ef4da4aa7
--- /dev/null
+++ b/sc/source/ui/vba/vbaquerytable.hxx
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * 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
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 0724541278fa..1041f020127b 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -43,7 +43,6 @@
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
-#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/sheet/XSpreadsheetView.hpp>
#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
#include <com/sun/star/sheet/XSheetCellRange.hpp>
@@ -51,6 +50,7 @@
#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>
@@ -91,6 +91,15 @@
#include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
#include <com/sun/star/sheet/GeneralFunction.hdl>
+#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>
@@ -116,12 +125,15 @@
#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>
#include <cellsuno.hxx>
#include <dbcolect.hxx>
#include "docfunc.hxx"
+#include <docuno.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/app.hxx>
@@ -132,6 +144,7 @@
#include <sc.hrc>
#include <globstr.hrc>
#include <unonames.hxx>
+#include <tools/stream.hxx>
#include "vbarange.hxx"
#include "vbafont.hxx"
@@ -143,8 +156,13 @@
#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"
@@ -158,6 +176,8 @@
#include "vbaglobals.hxx"
#include "vbastyle.hxx"
+#include "vbaname.hxx"
+#include "vbanames.hxx"
#include <vector>
#include <vbahelper/vbacollectionimpl.hxx>
// begin test includes
@@ -362,55 +382,6 @@ 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, uno::UNO_QUERY_THROW );
- 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, uno::UNO_QUERY_THROW );
- 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 )
-{
- uno::Reference< uno::XInterface > xIf( xRange, uno::UNO_QUERY_THROW );
- 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)
{
@@ -418,9 +389,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 getDocumentFromRange( xRange );
+ return excel::GetDocumentFromRange( xRange );
}
- return getDocumentFromRange( mxRange );
+ return excel::GetDocumentFromRange( mxRange );
}
ScDocShell*
@@ -430,9 +401,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 getDocShellFromRange( xRange );
+ return excel::GetDocShellFromRange( xRange );
}
- return getDocShellFromRange( mxRange );
+ return excel::GetDocShellFromRange( mxRange );
}
/*static*/ ScVbaRange* ScVbaRange::getImplementation( const uno::Reference< excel::XRange >& rxRange )
@@ -478,7 +449,7 @@ class NumFormatHelper
public:
NumFormatHelper( const uno::Reference< table::XCellRange >& xRange )
{
- mxSupplier.set( getModelFromRange( xRange ), uno::UNO_QUERY_THROW );
+ mxSupplier.set( excel::GetModelFromRange( xRange ), uno::UNO_QUERY_THROW );
mxRangeProps.set( xRange, uno::UNO_QUERY_THROW);
mxFormats = mxSupplier->getNumberFormats();
}
@@ -743,7 +714,15 @@ 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;
@@ -837,9 +816,10 @@ protected:
double aDblValue = 0.0;
if ( aValue >>= sFormula )
{
- // convert to CONV_OOO style formula string because XCell::setFormula
- // always compile it in CONV_OOO style. Perhaps css.sheet.FormulaParser
- // should be used in future to directly pass formula tokens.
+ // convert to GRAM_PODF_A1 style grammar because XCell::setFormula
+ // always compile it in that grammar. Perhaps
+ // css.sheet.FormulaParser should be used in future to directly
+ // pass formula tokens when that API stabilizes.
if ( m_eGrammar != formula::FormulaGrammar::GRAM_PODF_A1 && ( sFormula.trim().indexOf('=') == 0 ) )
{
uno::Reference< uno::XInterface > xIf( xCell, uno::UNO_QUERY_THROW );
@@ -1100,7 +1080,7 @@ public:
};
bool
-getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv )
+getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv, char cDelimiter = 0 )
{
ScDocument* pDoc = NULL;
@@ -1109,7 +1089,7 @@ getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDoc
pDoc = pDocSh->GetDocument();
String aString(sAddress);
USHORT nMask = SCA_VALID;
- rResFlags = rCellRanges.Parse( sAddress, pDoc, nMask, eConv, 0 );
+ rResFlags = rCellRanges.Parse( sAddress, pDoc, nMask, eConv, cDelimiter );
if ( rResFlags & SCA_VALID )
{
return true;
@@ -1144,6 +1124,25 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S
formula::FormulaGrammar::AddressConvention eConv = aConv;
// spaces are illegal ( but the user of course can enter them )
rtl::OUString sAddress = (*it).trim();
+ // if a local name ( on the active sheet ) exists this will
+ // take precedence over a global with the same name
+ if ( !xNameAccess->hasByName( sAddress ) && pDocSh )
+ {
+ // try a local name
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nCurTab = pDocSh->GetCurTab();
+ if ( pDoc )
+ {
+ NameToNameMap* pMap = pDoc->GetLocalNameMap( nCurTab );
+ if ( pMap )
+ {
+ NameToNameMap::iterator itTmp = pMap->find( sAddress );
+ if ( itTmp != pMap->end() ) // found a mapping
+ sAddress = itTmp->second;
+ }
+ }
+ }
+ char aChar = 0;
if ( xNameAccess->hasByName( sAddress ) )
{
uno::Reference< sheet::XNamedRange > xNamed( xNameAccess->getByName( sAddress ), uno::UNO_QUERY_THROW );
@@ -1151,10 +1150,11 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S
// As the address comes from OOO, the addressing
// style is may not be XL_A1
eConv = pDocSh->GetDocument()->GetAddressConvention();
+ aChar = ';';
}
USHORT nFlags = 0;
- if ( !getCellRangesForAddress( nFlags, sAddress, pDocSh, aCellRanges, eConv ) )
+ if ( !getCellRangesForAddress( nFlags, sAddress, pDocSh, aCellRanges, eConv, aChar ) )
return false;
bool bTabFromReferrer = !( nFlags & SCA_TAB_3D );
@@ -1248,7 +1248,7 @@ uno::Reference< sheet::XSheetCellRangeContainer > lclExpandToMerged( const uno::
ScUnoConversion::FillScRange( aScRange, aRangeAddr );
aScRanges.Append( aScRange );
}
- return new ScCellRangesObj( getDocShellFromRanges( rxCellRanges ), aScRanges );
+ return new ScCellRangesObj( excel::GetDocShellFromRanges( rxCellRanges ), aScRanges );
}
void lclExpandAndMerge( const uno::Reference< table::XCellRange >& rxCellRange, bool bMerge ) throw (uno::RuntimeException)
@@ -1294,7 +1294,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 = getDocumentFromRange( rxCellRange )->HasAttrib( aScRange, HASATTR_MERGED | HASATTR_OVERLAPPED );
+ bool bHasMerged = excel::GetDocumentFromRange( rxCellRange )->HasAttrib( aScRange, HASATTR_MERGED | HASATTR_OVERLAPPED );
return bHasMerged ? util::TriState_INDETERMINATE : util::TriState_NO;
}
@@ -1311,6 +1311,28 @@ 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 )
{
@@ -1338,7 +1360,14 @@ 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( RTL_CONSTASCII_USTRINGPARAM("Invalid range" ) ), uno::Reference< uno::XInterface >() );
+ }
xRange->getCellRange() >>= xRangeParam;
+ }
break;
}
default:
@@ -1351,7 +1380,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 = getDocumentFromRange(xRange);
+ ScDocument* pDoc = excel::GetDocumentFromRange(xRange);
if ( !pDoc )
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from shell" ) ), uno::Reference< uno::XInterface >() );
ScVbaPalette aPalette( pDoc->GetDocumentShell() );
@@ -1359,8 +1388,21 @@ 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( RTL_CONSTASCII_USTRINGPARAM( "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 ), getModelFromXIf( getXSomethingFromArgs< uno::XInterface >( args, 1 ) ), true ), mbIsRows( sal_False ), mbIsColumns( sal_False )
+ uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : ScVbaRange_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext, getXSomethingFromArgs< beans::XPropertySet >( args, 1, false ), excel::GetModelFromRange( getXSomethingFromArgs< uno::XInterface >( args, 1 ) ), true ), mbIsRows( sal_False ), mbIsColumns( sal_False )
{
mxRange.set( mxPropertySet, uno::UNO_QUERY );
mxRanges.set( mxPropertySet, uno::UNO_QUERY );
@@ -1377,7 +1419,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 ), getModelFromRange( xRange), true ), mxRange( xRange ),
+: ScVbaRange_BASE( xParent, xContext, uno::Reference< beans::XPropertySet >( xRange, uno::UNO_QUERY_THROW ), excel::GetModelFromRange( xRange), true ), mxRange( xRange ),
mbIsRows( bIsRows ),
mbIsColumns( bIsColumns )
{
@@ -1392,7 +1434,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 ), getModelFromXIf( 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 ), excel::GetModelFromRange( 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 );
@@ -1431,7 +1473,53 @@ 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::createFromAscii( "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::createFromAscii("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 );
+}
uno::Any
ScVbaRange::getValue( ValueGetter& valueGetter) throw (uno::RuntimeException)
@@ -1521,6 +1609,9 @@ ScVbaRange::setValue( const uno::Any &aValue ) throw (uno::RuntimeException)
}
CellValueSetter valueSetter( aValue );
setValue( aValue, valueSetter );
+
+ // Fires the range change event.
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
}
void
@@ -1529,6 +1620,9 @@ ScVbaRange::Clear() throw (uno::RuntimeException)
using namespace ::com::sun::star::sheet::CellFlags;
sal_Int32 nFlags = VALUE | DATETIME | STRING | FORMULA | HARDATTR | EDITATTR | FORMATTED;
ClearContents( nFlags );
+
+ // Fires the range change event.
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
}
//helper ClearContent
@@ -1569,6 +1663,9 @@ ScVbaRange::ClearContents() throw (uno::RuntimeException)
sheet::CellFlags::STRING | sheet::CellFlags::DATETIME |
sheet::CellFlags::FORMULA );
ClearContents( nClearFlags );
+
+ // Fires the range change event.
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
}
void
@@ -1577,6 +1674,9 @@ 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 );
+
+ // Fires the range change event.
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
}
void
@@ -1592,6 +1692,9 @@ ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar::
}
CellFormulaValueSetter formulaValueSetter( rFormula, getScDocument(), eGram );
setValue( rFormula, formulaValueSetter );
+
+ // Fires the range change event.
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
}
uno::Any
@@ -1751,6 +1854,9 @@ 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
@@ -1890,7 +1996,16 @@ 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;
- aMatrix = xConverter->convertTo( uno::makeAny( xCellRangeFormula->getFormulaArray() ) , getCppuType((uno::Sequence< uno::Sequence< uno::Any > >*)0) ) ;
+
+ //VBA, minz@cn.ibm.com
+ 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) ) ;
+ }
return aMatrix;
}
@@ -2061,29 +2176,65 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr
// set in the Any, we should convert as appropriate
// #FIXME - perhaps worth turning this into some sort of
// convertion routine e.g. bSuccess = getValueFromAny( nRow, nRowIndex, getCppuType((sal_Int32*)0) )
- if ( nRowIndex.hasValue() && !( nRowIndex >>= nRow ) )
+ uno::Any aRowIndexAny = nRowIndex;
+ if ( aRowIndexAny.getValueTypeClass() == uno::TypeClass_INTERFACE )
{
- uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
- uno::Any aConverted;
try
{
- aConverted = xConverter->convertTo( nRowIndex, getCppuType((sal_Int32*)0) );
- bIsIndex = ( aConverted >>= nRow );
+ aRowIndexAny = getDefaultPropByIntrospection( aRowIndexAny );
}
- catch( uno::Exception& ) {} // silence any errors
+ catch( uno::Exception& ) {}
}
- if ( bIsColumnIndex && !( nColumnIndex >>= nColumn ) )
+ else if ( aRowIndexAny.hasValue() && !( aRowIndexAny >>= nRow ) )
{
uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
uno::Any aConverted;
try
{
- aConverted = xConverter->convertTo( nColumnIndex, getCppuType((sal_Int32*)0) );
- bIsColumnIndex = ( aConverted >>= nColumn );
+ aConverted = xConverter->convertTo( aRowIndexAny, getCppuType((sal_Int32*)0) );
+ bIsIndex = ( aConverted >>= nRow );
}
catch( uno::Exception& ) {} // silence any errors
}
+ uno::Any aColumnAny = nColumnIndex;
+
+ if ( bIsColumnIndex )
+ {
+ // Column index can be a col address e.g Cells( 1, "B" ) etc.
+ rtl::OUString sCol;
+ if ( nColumnIndex >>= sCol )
+ {
+ ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
+ ScRange tmpRange;
+ USHORT flags = tmpRange.ParseCols( sCol, excel::GetDocumentFromRange( mxRange ), 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( mxContext );
+ uno::Any aConverted;
+ try
+ {
+ aConverted = xConverter->convertTo( aColumnAny, getCppuType((sal_Int32*)0) );
+ bIsColumnIndex = ( aConverted >>= nColumn );
+ }
+ catch( uno::Exception& ) {} // silence any errors
+ }
+ }
+ }
RangeHelper thisRange( mxRange );
table::CellRangeAddress thisRangeAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
uno::Reference< table::XCellRange > xSheetRange = thisRange.getCellRangeFromSheet();
@@ -2245,7 +2396,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, getDocumentFromRange( mxRange ), dDetails );
+ tmpRange.ParseRows( sAddress, excel::GetDocumentFromRange( mxRange ), dDetails );
nStartRow = tmpRange.aStart.Row();
nEndRow = tmpRange.aEnd.Row();
@@ -2292,7 +2443,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, getDocumentFromRange( mxRange ), dDetails );
+ tmpRange.ParseCols( sAddress, excel::GetDocumentFromRange( mxRange ), dDetails );
nStartCol = tmpRange.aStart.Col();
nEndCol = tmpRange.aEnd.Col();
@@ -2395,9 +2546,11 @@ ScVbaRange::Copy(const ::uno::Any& Destination) throw (uno::RuntimeException)
}
else
{
- uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange );
- Select();
- excel::implnCopy( xModel );
+ ScRange aRange;
+ RangeHelper thisRange( mxRange );
+ ScUnoConversion::FillScRange( aRange, thisRange.getCellRangeAddressable()->getRangeAddress() );
+ uno::Reference< frame::XModel > xModel = excel::GetModelFromRange( mxRange );
+ excel::implnCopyRange( xModel, aRange );
}
}
@@ -2419,8 +2572,9 @@ ScVbaRange::Cut(const ::uno::Any& Destination) throw (uno::RuntimeException)
uno::Reference< sheet::XCellRangeAddressable > xSource( mxRange, uno::UNO_QUERY);
xMover->moveRange( xDestination->getCellAddress(), xSource->getRangeAddress() );
}
- {
- uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange );
+ //VBA, minz@cn.ibm.com.
+ else {
+ uno::Reference< frame::XModel > xModel = excel::GetModelFromRange( mxRange );
Select();
excel::implnCut( xModel );
}
@@ -2740,8 +2894,6 @@ ScVbaRange::PasteSpecial( const uno::Any& Paste, const uno::Any& Operation, cons
uno::Reference< frame::XModel > xModel( ( pShell ? pShell->GetModel() : NULL ), uno::UNO_QUERY_THROW );
uno::Reference< view::XSelectionSupplier > xSelection( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
- // save old selection
- uno::Reference< uno::XInterface > xSel( xModel->getCurrentSelection() );
// select this range
xSelection->select( uno::makeAny( mxRange ) );
// set up defaults
@@ -2762,8 +2914,6 @@ ScVbaRange::PasteSpecial( const uno::Any& Paste, const uno::Any& Operation, cons
USHORT nFlags = getPasteFlags(nPaste);
USHORT nFormulaBits = getPasteFormulaBits(nOperation);
excel::implnPasteSpecial(pShell->GetModel(), nFlags,nFormulaBits,bSkipBlanks,bTranspose);
- // restore selection
- xSelection->select( uno::makeAny( xSel ) );
}
uno::Reference< excel::XRange >
@@ -2984,7 +3134,16 @@ 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 ); //liuchen 2010-01-05
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), pScCellRangesBase ); //liuchen 2010-01-05 the original convert method will fail in SUSE
+ }
}
return sal_True; // always
}
@@ -3135,6 +3294,13 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L
uno::Reference< uno::XInterface > xInterface = xStartCell.is() ? xSearch->findNext( xStartCell, xDescriptor) : xSearch->findFirst( xDescriptor );
uno::Reference< table::XCellRange > xCellRange( xInterface, uno::UNO_QUERY );
+ // if we are searching from a starting cell and failed to find a match
+ // then try from the begining
+ if ( !xCellRange.is() && xStartCell.is() )
+ {
+ xInterface = xSearch->findFirst( xDescriptor );
+ xCellRange.set( xInterface, uno::UNO_QUERY );
+ }
if ( xCellRange.is() )
{
uno::Reference< excel::XRange > xResultRange = new ScVbaRange( mxParent, mxContext, xCellRange );
@@ -3428,76 +3594,45 @@ 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 );
-
- // position current cell upper left of this range
- Cells( uno::makeAny( (sal_Int32) 1 ), uno::makeAny( (sal_Int32) 1 ) )->Select();
+ ScDocShell* pDocShell = getScDocShell();
+ ScDocument* pDoc = pDocShell->GetDocument();
- uno::Reference< frame::XModel > xModel = getModelFromRange( mxRange );
+ SCsCOL nMoveX = 0;
+ SCsROW nMoveY = 0;
+ switch ( Direction )
+ {
+ case excel::XlDirection::xlDown:
+ nMoveY = 1;
+ break;
+ case excel::XlDirection::xlUp:
+ nMoveY = -1;
+ break;
+ case excel::XlDirection::xlToLeft:
+ nMoveX = -1;
+ break;
+ case excel::XlDirection::xlToRight:
+ nMoveX = 1;
+ break;
+ default:
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid Direction" ) ), uno::Reference< uno::XInterface >() );
+ }
- SfxViewFrame* pViewFrame = excel::getViewFrame( xModel );
- if ( pViewFrame )
+ if ( pDoc )
{
- 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();
-
- USHORT 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 );
- }
+ pDoc->FindAreaPos( nNewX, nNewY, nTab, nMoveX, nMoveY );
}
- // 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;
+ 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;
}
bool
@@ -3515,7 +3650,7 @@ ScVbaRange::characters( const uno::Any& Start, const uno::Any& Length ) throw (u
if ( !isSingleCellRange() )
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("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 = getDocumentFromRange(mxRange);
+ ScDocument* pDoc = excel::GetDocumentFromRange(mxRange);
if ( !pDoc )
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from shell" ) ), uno::Reference< uno::XInterface >() );
@@ -3632,7 +3767,7 @@ ScVbaRange::getCalcColWidth( const table::CellRangeAddress& rAddress) throw (uno
double
ScVbaRange::getCalcRowHeight( const table::CellRangeAddress& rAddress ) throw (uno::RuntimeException)
{
- ScDocument* pDoc = getDocumentFromRange( mxRange );
+ ScDocument* pDoc = excel::GetDocumentFromRange( mxRange );
USHORT nWidth = pDoc->GetOriginalHeight( rAddress.StartRow, rAddress.Sheet );
double nPoints = lcl_TwipsToPoints( nWidth );
nPoints = lcl_Round2DecPlaces( nPoints );
@@ -3894,7 +4029,7 @@ ScVbaRange::setRowHeight( const uno::Any& _rowheight) throw (uno::RuntimeExcepti
table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
USHORT nTwips = lcl_pointsToTwips( nHeight );
- ScDocShell* pDocShell = getDocShellFromRange( mxRange );
+ ScDocShell* pDocShell = excel::GetDocShellFromRange( mxRange );
ScDocFunc aFunc(*pDocShell);
SCCOLROW nRowArr[2];
nRowArr[0] = thisAddress.StartRow;
@@ -3907,7 +4042,7 @@ uno::Any SAL_CALL
ScVbaRange::getPageBreak() throw (uno::RuntimeException)
{
sal_Int32 nPageBreak = excel::XlPageBreak::xlPageBreakNone;
- ScDocShell* pShell = getDocShellFromRange( mxRange );
+ ScDocShell* pShell = excel::GetDocShellFromRange( mxRange );
if ( pShell )
{
RangeHelper thisRange( mxRange );
@@ -3920,7 +4055,7 @@ ScVbaRange::getPageBreak() throw (uno::RuntimeException)
uno::Reference< frame::XModel > xModel = pShell->GetModel();
if ( xModel.is() )
{
- ScDocument* pDoc = getDocumentFromRange( mxRange );
+ ScDocument* pDoc = excel::GetDocumentFromRange( mxRange );
ScBreakType nBreak = BREAK_NONE;
if ( !bColumn )
@@ -3945,7 +4080,7 @@ ScVbaRange::setPageBreak( const uno::Any& _pagebreak) throw (uno::RuntimeExcepti
sal_Int32 nPageBreak = 0;
_pagebreak >>= nPageBreak;
- ScDocShell* pShell = getDocShellFromRange( mxRange );
+ ScDocShell* pShell = excel::GetDocShellFromRange( mxRange );
if ( pShell )
{
RangeHelper thisRange( mxRange );
@@ -4039,7 +4174,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 = getDocShellFromRange(xRange);
+ ScDocShell* pDocShell = excel::GetDocShellFromRange(xRange);
RangeHelper rHelper(xRange);
// parent should be Thisworkbook
xSheet.set( new ScVbaWorksheet( uno::Reference< XHelperInterface >(), mxContext,rHelper.getSpreadSheet(),pDocShell->GetModel()) );
@@ -4094,63 +4229,44 @@ ScVbaRange::ApplicationRange( const uno::Reference< uno::XComponentContext >& xC
}
}
}
- 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 );
-}
-uno::Reference< sheet::XDatabaseRanges >
-lcl_GetDataBaseRanges( ScDocShell* pShell ) throw ( uno::RuntimeException )
-{
- uno::Reference< frame::XModel > xModel;
- if ( pShell )
- xModel.set( pShell->GetModel(), uno::UNO_QUERY_THROW );
- uno::Reference< beans::XPropertySet > xModelProps( xModel, uno::UNO_QUERY_THROW );
- uno::Reference< sheet::XDatabaseRanges > xDBRanges( xModelProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DatabaseRanges") ) ), uno::UNO_QUERY_THROW );
- return xDBRanges;
-}
-// returns the XDatabaseRange for the autofilter on sheet (nSheet)
-// also populates sName with the name of range
-uno::Reference< sheet::XDatabaseRange >
-lcl_GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet, rtl::OUString& sName )
-{
- uno::Reference< container::XIndexAccess > xIndexAccess( lcl_GetDataBaseRanges( pShell ), uno::UNO_QUERY_THROW );
- uno::Reference< sheet::XDatabaseRange > xDataBaseRange;
- table::CellRangeAddress dbAddress;
- for ( sal_Int32 index=0; index < xIndexAccess->getCount(); ++index )
- {
- uno::Reference< sheet::XDatabaseRange > xDBRange( xIndexAccess->getByIndex( index ), uno::UNO_QUERY_THROW );
- uno::Reference< container::XNamed > xNamed( xDBRange, uno::UNO_QUERY_THROW );
- // autofilters work weirdly with openoffice, unnamed is the default
- // named range which is used to create an autofilter, but
- // its also possible that another name could be used
- // this also causes problems when an autofilter is created on
- // another sheet
- // ( but.. you can use any named range )
- dbAddress = xDBRange->getDataArea();
- if ( dbAddress.Sheet == nSheet )
- {
- sal_Bool bHasAuto = sal_False;
- uno::Reference< beans::XPropertySet > xProps( xDBRange, uno::UNO_QUERY_THROW );
- xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoFilter") ) ) >>= bHasAuto;
- if ( bHasAuto )
- {
- sName = xNamed->getName();
- xDataBaseRange=xDBRange;
- break;
- }
+ // 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();
}
}
- return xDataBaseRange;
+
+ uno::Reference< table::XCellRange > xSheetRange( xSpreadsheet, 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 );
}
// Helper functions for AutoFilter
ScDBData* lcl_GetDBData_Impl( ScDocShell* pDocShell, sal_Int16 nSheet )
{
rtl::OUString sName;
- lcl_GetAutoFiltRange( pDocShell, nSheet, sName );
+ excel::GetAutoFiltRange( pDocShell, nSheet, sName );
OSL_TRACE("lcl_GetDBData_Impl got autofilter range %s for sheet %d",
rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() , nSheet );
ScDBData* pRet = NULL;
@@ -4317,7 +4433,7 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const
ScDocShell* pShell = getScDocShell();
sal_Bool bHasAuto = sal_False;
rtl::OUString sAutofiltRangeName;
- uno::Reference< sheet::XDatabaseRange > xDataBaseRange = lcl_GetAutoFiltRange( pShell, nSheet, sAutofiltRangeName );
+ uno::Reference< sheet::XDatabaseRange > xDataBaseRange = excel::GetAutoFiltRange( pShell, nSheet, sAutofiltRangeName );
if ( xDataBaseRange.is() )
bHasAuto = true;
@@ -4350,7 +4466,7 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const
autoFiltAddress = multiCellRange.getCellRangeAddressable()->getRangeAddress();
}
- uno::Reference< sheet::XDatabaseRanges > xDBRanges = lcl_GetDataBaseRanges( pShell );
+ uno::Reference< sheet::XDatabaseRanges > xDBRanges = excel::GetDataBaseRanges( pShell );
if ( xDBRanges.is() )
{
rtl::OUString sGenName( RTL_CONSTASCII_USTRINGPARAM("VBA_Autofilter_") );
@@ -4403,8 +4519,21 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const
// Use the normal uno api, sometimes e.g. when you want to use ALL as the filter
// 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;;
- if ( ( Field >>= nField ) )
+ 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& ex )
+ {
+ }
+ }
+ if ( bIsValidFieldValue )
{
uno::Reference< sheet::XSheetFilterDescriptor2 > xDesc(
xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY );
@@ -4435,7 +4564,19 @@ 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
- if ( Operator.hasValue() && ( Operator >>= nOperator ) )
+ 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& ex )
+ {
+ }
+ }
+ if ( bIsValidOpValue )
{
// if its a bottom/top Ten(Percent/Value) and there
// is no value specified for critera1 set it to 10
@@ -4583,7 +4724,7 @@ ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (u
{
// 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( getDocShellFromRange( mxRange ) , aRange ) );
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( excel::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() );
}
@@ -4607,7 +4748,7 @@ ScVbaRange::Autofit() throw (uno::RuntimeException)
if ( !( mbIsColumns || mbIsRows ) )
DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
- ScDocShell* pDocShell = getDocShellFromRange( mxRange );
+ ScDocShell* pDocShell = excel::GetDocShellFromRange( mxRange );
if ( pDocShell )
{
RangeHelper thisRange( mxRange );
@@ -4639,8 +4780,8 @@ ScVbaRange::Autofit() throw (uno::RuntimeException)
***************************************************************************************/
void SAL_CALL
ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any& DataType, const css::uno::Any& TextQualifier,
- const css::uno::Any& ConsecutinveDelimiter, 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& 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;
@@ -4677,13 +4818,13 @@ ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any
OSL_TRACE("set TextQualifier\n");
}
- sal_Bool bConsecutinveDelimiter = sal_False;
- if( ConsecutinveDelimiter.hasValue() )
+ sal_Bool bConsecutiveDelimiter = sal_False;
+ if( ConsecutiveDelimiter.hasValue() )
{
- if( !( ConsecutinveDelimiter >>= bConsecutinveDelimiter ) )
- throw uno::RuntimeException( rtl::OUString::createFromAscii( "ConsecutinveDelimiter parameter should be a boolean" ),
+ if( !( ConsecutiveDelimiter >>= bConsecutiveDelimiter ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "ConsecutiveDelimiter parameter should be a boolean" ),
uno::Reference< uno::XInterface >() );
- OSL_TRACE("set ConsecutinveDelimiter\n");
+ OSL_TRACE("set ConsecutiveDelimiter\n");
}
sal_Bool bTab = sal_False;
@@ -4735,7 +4876,13 @@ ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any
throw uno::RuntimeException( rtl::OUString::createFromAscii( "Other parameter should be a True" ),
uno::Reference< uno::XInterface >() );
}
- //TODO* 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.
+ // 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() )
@@ -4753,7 +4900,106 @@ ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any
uno::Reference< uno::XInterface >() );
OSL_TRACE("set ThousandsSpeparator\n" );
}
- //TODO* TrailingMinusNumbers Optional Variant. Numbers that begin with a minus character.
+ //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.
+ USHORT nCount = 0, nRealCount = 0;
+ xub_StrLen* pColumns = NULL;
+ BYTE* pFormats = NULL;
+ if ( sFieldInfo.getLength() > 0 )
+ {
+ nCount = sFieldInfo.getLength();
+ pColumns = new xub_StrLen[nCount];
+ pFormats = new BYTE[nCount];
+ USHORT 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((xub_StrLen*)0) );
+ aConverted >>= pColumns[nRealCount];
+ aConverted = xConverter->convertTo( sFieldInfo[nIndex][1], getCppuType((USHORT*)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.First() )
+ {
+ aSrcScRange = *aRangeList.First();
+ }
+ }
+ 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
@@ -4898,7 +5144,7 @@ uno::Any ScVbaRange::getShowDetail() throw ( css::uno::RuntimeException)
(thisAddress.StartColumn == thisAddress.EndColumn && thisAddress.EndColumn == aOutlineAddress.EndColumn ))
{
sal_Bool bColumn =thisAddress.StartRow == thisAddress.EndRow ? sal_False:sal_True;
- ScDocument* pDoc = getDocumentFromRange( mxRange );
+ ScDocument* pDoc = excel::GetDocumentFromRange( mxRange );
ScOutlineTable* pOutlineTable = pDoc->GetOutlineTable(static_cast<SCTAB>(thisAddress.Sheet), sal_True);
const ScOutlineArray* pOutlineArray = bColumn ? pOutlineTable->GetColArray(): pOutlineTable->GetRowArray();
if( pOutlineArray )
@@ -4954,6 +5200,24 @@ void ScVbaRange::setShowDetail(const uno::Any& aShowDetail) throw ( css::uno::Ru
}
}
+//09-09-16 add by limingl
+::com::sun::star::uno::Reference< ::ooo::vba::excel::XQueryTable > SAL_CALL
+ScVbaRange::getQueryTable() throw (::com::sun::star::uno::RuntimeException)
+{
+ /*
+ if (m_pQueryTable == NULL)
+ {
+ m_pQueryTable = new ScVbaQueryTable(mxParent ,mxContext, getScDocument(), this); //add by limingl
+ }
+ //*/
+ if (!m_xQueryTable.is())
+ {
+ m_xQueryTable = new ScVbaQueryTable(mxParent ,mxContext, getScDocument(), this); //add by limingl
+ }
+
+ return m_xQueryTable;
+}
+//end add
uno::Reference< excel::XRange > SAL_CALL
ScVbaRange::MergeArea() throw (script::BasicErrorException, uno::RuntimeException)
{
@@ -4983,6 +5247,118 @@ ScVbaRange::MergeArea() throw (script::BasicErrorException, uno::RuntimeExceptio
return new ScVbaRange( mxParent, mxContext, mxRange );
}
+//2008-08-25 add by limingl
+//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;
+// sal_Bool bColName = sal_True;
+ 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 = rtl::OUString::createFromAscii("MoveNext") ;
+ rtl::OUString oEof = rtl::OUString::createFromAscii("EOF") ;
+ rtl::OUString oFields = rtl::OUString::createFromAscii("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::createFromAscii("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::createFromAscii("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::createFromAscii("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;
+}
+//end add
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)
{
@@ -5001,7 +5377,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 = getDocShellFromRange( pRange->mxRange );
+ pShell = excel::GetDocShellFromRange( pRange->mxRange );
xPrintAreas.set( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
}
printAreas[ index - 1 ] = rangeAddress;
@@ -5087,7 +5463,7 @@ ScVbaRange::AutoFill( const uno::Reference< excel::XRange >& Destination, const
}
}
}
- ScDocShell* pDocSh= getDocShellFromRange( mxRange );
+ ScDocShell* pDocSh= excel::GetDocShellFromRange( mxRange );
FillCmd eCmd = FILL_AUTO;
FillDateCmd eDateCmd = FILL_DAY;
@@ -5210,13 +5586,8 @@ ScVbaRange::AutoOutline( ) throw (script::BasicErrorException, uno::RuntimeExce
RangeHelper thisRange( mxRange );
table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
- 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());
+ uno::Reference< sheet::XSheetOutline > xSheetOutline( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
+ xSheetOutline->autoOutline( thisAddress );
}
void SAL_CALL
@@ -5243,9 +5614,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_ROWS;
- if ( mbIsColumns )
- nOrient = table::TableOrientation_COLUMNS;
+ table::TableOrientation nOrient = table::TableOrientation_COLUMNS;
+ if ( mbIsRows )
+ nOrient = table::TableOrientation_ROWS;
RangeHelper thisRange( mxRange );
table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
uno::Reference< sheet::XSheetOutline > xSheetOutline( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
@@ -5404,6 +5775,7 @@ ScVbaRange::SpecialCells( const uno::Any& _oType, const uno::Any& _oValue) throw
bool bIsSingleCell = isSingleCellRange();
bool bIsMultiArea = ( m_Areas->getCount() > 1 );
ScVbaRange* pRangeToUse = this;
+ uno::Reference< excel::XRange > xUsedRange( getWorksheet()->getUsedRange() );
sal_Int32 nType = 0;
if ( !( _oType >>= nType ) )
DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
@@ -5464,7 +5836,6 @@ ScVbaRange::SpecialCells( const uno::Any& _oType, const uno::Any& _oValue) throw
}
else if ( bIsSingleCell )
{
- uno::Reference< excel::XRange > xUsedRange = getWorksheet()->getUsedRange();
pRangeToUse = static_cast< ScVbaRange* >( xUsedRange.get() );
}
@@ -5639,6 +6010,183 @@ 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( RTL_CONSTASCII_USTRINGPARAM( "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( RTL_CONSTASCII_USTRINGPARAM("Invalid input parameter" ) ), uno::Reference< uno::XInterface >() );
+ }
+ if ( m_Areas->getCount() > 1 )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("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.
+ ScRangeData* pData = NULL;
+ 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();
+ const USHORT nCount = pRangeNames ? pRangeNames->GetCount() : 0;
+ for ( USHORT index = 0; index < nCount; index++ )
+ {
+ pData = ( ScRangeData* )( pRangeNames->At( index ) );
+ if ( pData && pData->HasType( RT_CRITERIA ) )
+ {
+ pData->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( RTL_CONSTASCII_USTRINGPARAM( 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( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_OUTPOS ) ), uno::makeAny( xCellAddr->getCellAddress() ) );
+ }
+
+ // Unique
+ if ( xPropertySet.is() )
+ {
+ sal_Bool bUnique = sal_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( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SKIPDUP ) ), aUnique );
+ }
+
+ // Do filter.
+ if ( xFilterDesc.is() )
+ {
+ xSheetFilter->filter( xFilterDesc );
+ }
+
+ return aRet;
+}
+
+//Add by minz@cn.ibm.com. 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();
+ }
+
+// RangeHelper thisRange( mxRange );
+// uno::Reference< sheet::XSpreadsheet > 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()
{
@@ -5658,6 +6206,25 @@ ScVbaRange::getServiceNames()
return aServiceNames;
}
+sal_Bool SAL_CALL
+ScVbaRange::hasError() throw (uno::RuntimeException)
+{
+ double dResult = sal_False;
+ uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+ uno::Reference< script::XInvocation > xInvoc( xApplication->WorksheetFunction(), uno::UNO_QUERY_THROW );
+
+ static rtl::OUString FunctionName( RTL_CONSTASCII_USTRINGPARAM("IsError" ) );
+ uno::Sequence< uno::Any > Params(1);
+ uno::Reference< excel::XRange > aRange( this );
+ Params[0] = uno::makeAny( aRange );
+ uno::Sequence< sal_Int16 > OutParamIndex;
+ uno::Sequence< uno::Any > OutParam;
+ xInvoc->invoke( FunctionName, Params, OutParamIndex, OutParam ) >>= dResult;
+ if ( dResult > 0.0 )
+ return sal_True;
+ return sal_False;
+}
+
namespace range
{
namespace sdecl = comphelper::service_decl;
diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx
index 84a65e7e2af5..ac745ef42279 100644
--- a/sc/source/ui/vba/vbarange.hxx
+++ b/sc/source/ui/vba/vbarange.hxx
@@ -35,6 +35,7 @@
#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.hdl>
#include <ooo/vba/excel/XlPasteSpecialOperation.hdl>
@@ -49,6 +50,8 @@
#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" //09-09-18 add by limingl
#include "vbaformat.hxx"
#include <formula/grammar.hxx>
@@ -97,6 +100,7 @@ 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; //09-09-16 add by limingl
double getCalcColWidth( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException);
double getCalcRowHeight( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException);
void visitArray( ArrayVisitor& vistor );
@@ -146,8 +150,10 @@ 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();
// Attributes
+ virtual css::uno::Any SAL_CALL getName() 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);
@@ -188,6 +194,7 @@ 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); //09-09-16 add by limingl
// Methods
sal_Bool IsRows() { return mbIsRows; }
sal_Bool IsColumns() { return mbIsColumns; }
@@ -238,7 +245,7 @@ public:
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& ConsecutinveDelimiter, const css::uno::Any& Tab, const css::uno::Any& Semicolon, const css::uno::Any& Comma,
+ 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);
@@ -263,6 +270,11 @@ 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); //2008-08-25 add by limingl
// XEnumerationAccess
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
// XElementAccess
@@ -288,6 +300,8 @@ public:
static css::uno::Reference< ov::excel::XRange > ApplicationRange( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Any &Cell1, const css::uno::Any &Cell2 ) throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL GoalSeek( const css::uno::Any& Goal, const css::uno::Reference< ov::excel::XRange >& ChangingCell ) throw (css::uno::RuntimeException);
virtual css::uno::Reference< ov::excel::XRange > SAL_CALL SpecialCells( const css::uno::Any& _oType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException );
+ // XErrorQuery
+ virtual ::sal_Bool SAL_CALL hasError( ) throw (css::uno::RuntimeException);
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/sc/source/ui/vba/vbavalidation.cxx b/sc/source/ui/vba/vbavalidation.cxx
index e2a768549e11..07c61e788310 100644
--- a/sc/source/ui/vba/vbavalidation.cxx
+++ b/sc/source/ui/vba/vbavalidation.cxx
@@ -25,6 +25,7 @@
*
************************************************************************/
#include "vbavalidation.hxx"
+#include "vbaformatcondition.hxx"
#include <com/sun/star/sheet/XSheetCondition.hpp>
#include <com/sun/star/sheet/ValidationType.hpp>
#include <com/sun/star/sheet/ValidationAlertStyle.hpp>
@@ -225,8 +226,10 @@ ScVbaValidation::Delete( ) throw (uno::RuntimeException)
lcl_setValidationProps( m_xRange, xProps );
}
+
+// Fix the defect that validatation cannot work when the input should be limited between a lower bound and an upper bound
void SAL_CALL
-ScVbaValidation::Add( const uno::Any& Type, const uno::Any& AlertStyle, const uno::Any& /*Operator*/, const uno::Any& Formula1, const uno::Any& Formula2 ) throw (uno::RuntimeException)
+ScVbaValidation::Add( const uno::Any& Type, const uno::Any& AlertStyle, const uno::Any& Operator, const uno::Any& Formula1, const uno::Any& Formula2 ) throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
uno::Reference< sheet::XSheetCondition > xCond( xProps, uno::UNO_QUERY_THROW );
@@ -291,6 +294,13 @@ ScVbaValidation::Add( const uno::Any& Type, const uno::Any& AlertStyle, const un
xProps->setPropertyValue( ALERTSTYLE, uno::makeAny( eStyle ) );
+ //2009-11-11 fix the defect that validatation cannot work when the input should be limited between a lower bound and an upper bound
+ if ( Operator.hasValue() )
+ {
+ css::sheet::ConditionOperator conOperator = ScVbaFormatCondition::retrieveAPIOperator( Operator );
+ xCond->setOperator( conOperator );
+ }
+ //2009-11-11
if ( sFormula1.getLength() )
xCond->setFormula1( sFormula1 );
if ( sFormula2.getLength() )
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index 28469c4685a2..445e5641c89c 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -36,6 +36,7 @@
#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> //liuchen 2009-12-16
#include "scextopt.hxx"
#include "vbaworksheet.hxx"
@@ -125,7 +126,7 @@ ScVbaWorkbook::Colors( const ::uno::Any& Index ) throw (::script::BasicErrorExce
}
::sal_Int32 SAL_CALL
-ScVbaWorkbook::FileFormat( ) throw (::script::BasicErrorException, ::uno::RuntimeException)
+ScVbaWorkbook::getFileFormat( ) throw (::uno::RuntimeException)
{
sal_Int32 aFileFormat = 0;
rtl::OUString aFilterName;
@@ -185,6 +186,24 @@ ScVbaWorkbook::FileFormat( ) throw (::script::BasicErrorException, ::uno::Runti
return aFileFormat;
}
+//VBA by minz@cn.ibm.com. 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()
{
@@ -264,6 +283,12 @@ ScVbaWorkbook::Activate() throw (uno::RuntimeException)
VbaDocumentBase::Activate();
}
+void
+ScVbaWorkbook::Protect( const uno::Any &aPassword ) throw (uno::RuntimeException)
+{
+ VbaDocumentBase::Protect( aPassword );
+}
+
::sal_Bool
ScVbaWorkbook::getProtectStructure() throw (uno::RuntimeException)
{
@@ -299,6 +324,50 @@ ScVbaWorkbook::SaveCopyAs( const rtl::OUString& sFileName ) throw ( uno::Runtime
xStor->storeToURL( aURL, storeProps );
}
+//VBA by minz@cn.ibm.com. 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 );
+ //liuchen 2009-12-16 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.getLength() == 0 )
+ {
+ 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 );
+ }
+ //liuchen 2009-12-16
+ 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 4aff58078403..a5ccea180dd3 100644
--- a/sc/source/ui/vba/vbaworkbook.hxx
+++ b/sc/source/ui/vba/vbaworkbook.hxx
@@ -41,6 +41,8 @@ class ScVbaWorkbook : public ScVbaWorkbook_BASE
static css::uno::Sequence< sal_Int32 > ColorData;
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);
@@ -61,20 +63,25 @@ public:
virtual css::uno::Any SAL_CALL Sheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Protect( const css::uno::Any & aPassword ) throw (css::uno::RuntimeException);
// Amelia Wang
virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Styles( const css::uno::Any& Item ) throw (css::uno::RuntimeException);
virtual void SAL_CALL ResetColors( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Colors( const css::uno::Any& Index ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
- virtual ::sal_Int32 SAL_CALL FileFormat( ) 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);
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+ virtual css::uno::Reference< css::frame::XModel > getDocModel() { return mxModel; }
};
#endif /* SC_VBA_WORKBOOK_HXX */
diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index d76aa7bd612e..187f719d2b7f 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -63,6 +63,7 @@
#include <ooo/vba/excel/XlEnableSelection.hpp>
#include <ooo/vba/excel/XWorkbook.hpp>
#include <ooo/vba/XControlProvider.hpp>
+#include <ooo/vba/excel/XlSheetVisibility.hpp>
#include <comphelper/processfactory.hxx>
#include <vbahelper/vbashapes.hxx>
@@ -80,7 +81,7 @@
#include "cellsuno.hxx"
#include "drwlayer.hxx"
-
+#include "tabprotection.hxx"
#include "scextopt.hxx"
#include "vbaoutline.hxx"
#include "vbarange.hxx"
@@ -94,6 +95,7 @@
#include "vbaworksheets.hxx"
#include "vbahyperlinks.hxx"
#include "vbasheetobjects.hxx"
+#include "viewuno.hxx" //liuchen 2009-9-2
#define STANDARDWIDTH 2267
#define STANDARDHEIGHT 427
@@ -221,7 +223,7 @@ ScVbaWorksheet::setName(const ::rtl::OUString &rName ) throw (uno::RuntimeExcept
xNamed->setName( rName );
}
-sal_Bool
+::sal_Int32
ScVbaWorksheet::getVisible() throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW );
@@ -229,13 +231,33 @@ ScVbaWorksheet::getVisible() throw (uno::RuntimeException)
(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ) );
sal_Bool bRet = false;
aValue >>= bRet;
- return bRet;
+ if ( bRet )
+ {
+ return excel::XlSheetVisibility::xlSheetVisible;
+ }
+ else
+ {
+ return excel::XlSheetVisibility::xlSheetHidden;
+ }
}
void
-ScVbaWorksheet::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException)
+ScVbaWorksheet::setVisible( ::sal_Int32 _Visible ) throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW );
+
+ //VBA by minz@cn.ibm.com.
+ sal_Bool bVisible = true;
+ switch( _Visible )
+ {
+ case excel::XlSheetVisibility::xlSheetHidden:
+ case excel::XlSheetVisibility::xlSheetVeryHidden:
+ bVisible = false;
+ break;
+ case excel::XlSheetVisibility::xlSheetVisible:
+ bVisible = true;
+ break;
+ }
uno::Any aValue( bVisible );
xProps->setPropertyValue
(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ), aValue);
@@ -427,6 +449,18 @@ ScVbaWorksheet::getProtectContents()throw (uno::RuntimeException)
sal_Bool
ScVbaWorksheet::getProtectDrawingObjects() throw (uno::RuntimeException)
{
+ SCTAB nTab = 0;
+ rtl::OUString aSheetName = getName();
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
+ bool bSheetExists = ScVbaWorksheets::nameExists (xSpreadDoc, aSheetName, nTab);
+ if ( bSheetExists )
+ {
+ uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+ ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ if ( pProtect )
+ return pProtect->isOptionEnabled( ScTableProtection::OBJECTS );
+ }
return sal_False;
}
@@ -444,10 +478,30 @@ ScVbaWorksheet::Activate() throw (uno::RuntimeException)
xSpreadsheet->setActiveSheet(getSheet());
}
+//liuchen 2009-9-2, support expand (but not replace) the active sheet
void
-ScVbaWorksheet::Select() throw (uno::RuntimeException)
+ScVbaWorksheet::Select(const css::uno::Any& aReplace) throw (uno::RuntimeException)
{
- Activate();
+ 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);
+ }
}
void
@@ -509,18 +563,42 @@ ScVbaWorksheet::Copy( const uno::Any& Before, const uno::Any& After ) throw (uno
return;
}
- uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY );
+ ScVbaWorksheet* pDestSheet = static_cast< ScVbaWorksheet* >(xSheet.get());
+ uno::Reference <sheet::XSpreadsheetDocument> xDestDoc( pDestSheet->getModel(), uno::UNO_QUERY );
+ uno::Reference <sheet::XSpreadsheetDocument> xSrcDoc( getModel(), uno::UNO_QUERY );
+
SCTAB nDest = 0;
+ SCTAB nSrc = 0;
rtl::OUString aSheetName = xSheet->getName();
- if ( ScVbaWorksheets::nameExists (xSpreadDoc, aSheetName, nDest ) )
+ bool bSameDoc = ( pDestSheet->getModel() == getModel() );
+ bool bDestSheetExists = ScVbaWorksheets::nameExists (xDestDoc, aSheetName, nDest );
+ bool bSheetExists = ScVbaWorksheets::nameExists (xSrcDoc, aCurrSheetName, nSrc );
+
+ // set sheet name to be newSheet name
+ aSheetName = aCurrSheetName;
+ SCTAB nDummy=0;
+ if ( bSheetExists && bDestSheetExists )
{
sal_Bool bAfter = After.hasValue();
if(bAfter)
nDest++;
- uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
- getNewSpreadsheetName(aSheetName,aCurrSheetName,xSpreadDoc);
- xSheets->copyByName(aCurrSheetName,aSheetName,nDest);
+ uno::Reference<sheet::XSpreadsheets> xSheets = xDestDoc->getSheets();
+ if ( bSameDoc || ScVbaWorksheets::nameExists( xDestDoc, aCurrSheetName, nDummy ) )
+ getNewSpreadsheetName(aSheetName,aCurrSheetName,xDestDoc);
+ if ( bSameDoc )
+ xSheets->copyByName(aCurrSheetName,aSheetName,nDest);
+ else
+ {
+ ScDocShell* pDestDocShell = excel::getDocShell( pDestSheet->getModel() );
+ ScDocShell* pSrcDocShell = excel::getDocShell( getModel() );
+ if ( pDestDocShell && pSrcDocShell )
+ pDestDocShell->TransferTab( *pSrcDocShell, static_cast<SCTAB>(nSrc), static_cast<SCTAB>(nDest), TRUE, TRUE );
+ }
}
+ // active the new sheet
+ uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XWorksheet > xNewSheet( xApplication->Worksheets( uno::makeAny( aSheetName ) ), uno::UNO_QUERY_THROW );
+ xNewSheet->Activate();
}
@@ -572,13 +650,25 @@ ScVbaWorksheet::getSheetAtOffset(SCTAB offset) throw (uno::RuntimeException)
uno::Reference< excel::XWorksheet >
ScVbaWorksheet::getNext() throw (uno::RuntimeException)
{
- return getSheetAtOffset(static_cast<SCTAB>(1));
+ //VBA, minz@cn.ibm.com. catch the exception for index out of bound
+ try{
+ return getSheetAtOffset(static_cast<SCTAB>(1));
+ }catch( lang::IndexOutOfBoundsException& /*e*/ )
+ {
+ return NULL;
+ }
}
uno::Reference< excel::XWorksheet >
ScVbaWorksheet::getPrevious() throw (uno::RuntimeException)
{
- return getSheetAtOffset(-1);
+ //VBA, minz@cn.ibm.com. catch the exception for index out of bound
+ try{
+ return getSheetAtOffset(-1);
+ }catch( lang::IndexOutOfBoundsException& /*e*/ )
+ {
+ return NULL;
+ }
}
@@ -662,7 +752,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( mxSheet, uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( getSheet(), uno::UNO_QUERY_THROW ); //VBA, minz@cn.ibm.com.
mxCharts = new ScVbaChartObjects( this, mxContext, xTableCharts, xDrawPageSupplier );
}
if ( Index.hasValue() )
@@ -981,7 +1071,7 @@ ScVbaWorksheet::getCodeName() throw (css::uno::RuntimeException)
sal_Int16
ScVbaWorksheet::getSheetID() throw (uno::RuntimeException)
{
- uno::Reference< sheet::XCellRangeAddressable > xAddressable( mxSheet, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XCellRangeAddressable > xAddressable( getSheet(), uno::UNO_QUERY_THROW ); //VBA. minz@cn.ibm.com. 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 78bcc2503a49..adcfd4af16fa 100644
--- a/sc/source/ui/vba/vbaworksheet.hxx
+++ b/sc/source/ui/vba/vbaworksheet.hxx
@@ -42,6 +42,7 @@
#include <ooo/vba/excel/XPageSetup.hpp>
#include <ooo/vba/excel/XHPageBreaks.hpp>
#include <ooo/vba/excel/XVPageBreaks.hpp>
+#include <com/sun/star/container/XNamed.hpp>
#include <vbahelper/vbahelperinterface.hxx>
#include "address.hxx"
@@ -91,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_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setVisible( sal_Bool bVisible ) 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 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);
@@ -115,7 +116,7 @@ public:
// Methods
virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
- virtual void SAL_CALL Select() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Select(const css::uno::Any& aReplace) throw (css::uno::RuntimeException); //liuchen 2009-9-2, add the input parameter to support expand selection
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/vba/vbawsfunction.cxx b/sc/source/ui/vba/vbawsfunction.cxx
index 60daa7303f2e..6155c1bda5f0 100644
--- a/sc/source/ui/vba/vbawsfunction.cxx
+++ b/sc/source/ui/vba/vbawsfunction.cxx
@@ -60,6 +60,18 @@ void lclConvertDoubleToBoolean( uno::Any& rAny )
}
}
+void lclConvertBooleanToDouble( uno::Any& rAny )
+{
+ sal_Bool bValue( sal_False );
+ if ( rAny >>= bValue )
+ {
+ if ( bValue )
+ rAny <<= double( 1.0 );
+ else
+ rAny <<= double( 0.0 );
+ }
+}
+
} // namespace
ScVbaWSFunction::ScVbaWSFunction( const uno::Reference< XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) :
@@ -84,9 +96,57 @@ ScVbaWSFunction::invoke(const rtl::OUString& FunctionName, const uno::Sequence<
uno::Any* pArrayEnd = pArray + aParamTemp.getLength();
for( ; pArray < pArrayEnd; ++pArray )
{
- uno::Reference< excel::XRange > myRange( *pArray, uno::UNO_QUERY );
- if( myRange.is() )
- *pArray = myRange->getCellRange();
+ switch( pArray->getValueType().getTypeClass() )
+ {
+ case uno::TypeClass_BOOLEAN:
+ lclConvertBooleanToDouble( *pArray );
+ break;
+ case uno::TypeClass_INTERFACE:
+ {
+ uno::Reference< excel::XRange > myRange( *pArray, uno::UNO_QUERY );
+ if( myRange.is() )
+ *pArray = myRange->getCellRange();
+ }
+ break;
+ case uno::TypeClass_SEQUENCE:
+ {
+ // the sheet.FunctionAccess service doesn't deal with Sequences, only Sequences of Sequence
+ uno::Type aType = pArray->getValueType();
+ if ( aType.equals( getCppuType( (uno::Sequence<sal_Int16>*)0 ) ) )
+ {
+ uno::Sequence< uno::Sequence< sal_Int16 > > aTmp(1);
+ (*pArray) >>= aTmp[ 0 ];
+ (*pArray) <<= aTmp;
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence<sal_Int32>*)0 ) ) )
+ {
+ uno::Sequence< uno::Sequence< sal_Int32 > > aTmp(1);
+ (*pArray) >>= aTmp[ 0 ];
+ (*pArray) <<= aTmp;
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence<double>*)0 ) ) )
+ {
+ uno::Sequence< uno::Sequence< double > > aTmp(1);
+ (*pArray) >>= aTmp[ 0 ];
+ (*pArray) <<= aTmp;
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence<rtl::OUString>*)0 ) ) )
+ {
+ uno::Sequence< uno::Sequence< rtl::OUString > > aTmp(1);
+ (*pArray) >>= aTmp[ 0 ];
+ (*pArray) <<= aTmp;
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence<uno::Any>*)0 ) ) )
+ {
+ uno::Sequence< uno::Sequence<uno::Any > > aTmp(1);
+ (*pArray) >>= aTmp[ 0 ];
+ (*pArray) <<= aTmp;
+ }
+ }
+ break;
+ default:
+ break;
+ }
OSL_TRACE("Param[%d] is %s", (int)(pArray - aParamTemp.getConstArray()), rtl::OUStringToOString( comphelper::anyToString( *pArray ), RTL_TEXTENCODING_UTF8 ).getStr() );
}
}
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 2e318a920898..38794bdca38e 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -334,6 +334,20 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
}
break;
+ case SID_DATA_FORM:
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
+
+ AbstractScDataFormDlg* pDlg = pFact->CreateScDataFormDlg( pTabViewShell->GetDialogParent(),RID_SCDLG_DATAFORM, pTabViewShell);
+ DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
+
+ pDlg->Execute();
+
+ rReq.Done();
+ }
+ break;
+
case SID_SUBTOTALS:
{
const SfxItemSet* pArgs = rReq.GetArgs();
diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx
index 4a9dbbaf98b6..592a5392ba20 100644
--- a/sc/source/ui/view/gridwin5.cxx
+++ b/sc/source/ui/view/gridwin5.cxx
@@ -343,14 +343,12 @@ void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
if ( pDrView->PickObj(aMDPos, pDrView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) )
pObj = pHit;
}
-#ifdef ISSUE66550_HLINK_FOR_SHAPES
ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
if ( pInfo && (pInfo->GetHlink().getLength() > 0) )
{
aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect());
aHelpText = pInfo->GetHlink();
}
-#endif
}
}
}
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 983113760bb9..cf9a8dc84cd6 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1419,9 +1419,11 @@ void ScTabView::MarkRange( const ScRange& rRange, BOOL bSetCursor, BOOL bContinu
{
SCCOL nAlignX = rRange.aStart.Col();
SCROW nAlignY = rRange.aStart.Row();
- if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL )
+ bool bCol = ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL ) && !aViewData.GetDocument()->IsInVBAMode();
+ bool bRow = ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW );
+ if ( bCol )
nAlignX = aViewData.GetPosX(WhichH(aViewData.GetActivePart()));
- if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW )
+ if ( bRow )
nAlignY = aViewData.GetPosY(WhichV(aViewData.GetActivePart()));
AlignToCursor( nAlignX, nAlignY, SC_FOLLOW_JUMP );
}
@@ -1535,6 +1537,7 @@ void ScTabView::SetTabNo( SCTAB nTab, BOOL bNew, BOOL bExtendSelection )
// nicht InputEnterHandler wegen Referenzeingabe !
ScDocument* pDoc = aViewData.GetDocument();
+
pDoc->MakeTable( nTab );
// Update pending row heights before switching the sheet, so Reschedule from the progress bar
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 7b944a32efe0..2ac65de9ec98 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1762,6 +1762,13 @@ void ScTabViewShell::Construct( BYTE nForceDesignMode )
if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
{
SCTAB nInitTabCount = 3; //! konfigurierbar !!!
+ // Get the customized initial tab count, we only can set the count by VBA API currently.
+ const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
+ SCTAB nNewTabCount = rAppOpt.GetTabCountInNewSpreadsheet();
+ if ( nNewTabCount >= 1 && nNewTabCount <= MAXTAB )
+ {
+ nInitTabCount = nNewTabCount;
+ }
for (SCTAB i=1; i<nInitTabCount; i++)
pDoc->MakeTable(i,false);
}
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index c2b8cf77a420..4f9a2b1ae200 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -52,6 +52,11 @@
#include <vcl/sound.hxx>
#include <vcl/waitobj.hxx>
+#include <basic/sbstar.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+using namespace com::sun::star;
+
#include "viewfunc.hxx"
#include "sc.hrc"
@@ -2200,6 +2205,8 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord )
WaitObject aWait( GetFrameWin() );
if (bRecord && !pDoc->IsUndoEnabled())
bRecord = FALSE;
+ if ( bVbaEnabled )
+ bRecord = FALSE;
while ( nNewTab > 0 && !pDoc->IsVisible( nNewTab ) )
--nNewTab;
@@ -2307,6 +2314,7 @@ BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord )
pDocSh->PostPaintExtras();
pDocSh->SetDocumentModified();
+
SfxApplication* pSfxApp = SFX_APP(); // Navigator
pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
@@ -2451,8 +2459,8 @@ void ScViewFunc::ImportTables( ScDocShell* pSrcShell,
{
SCTAB nSrcTab = pSrcTabs[i];
SCTAB nDestTab1=nTab+i;
- ULONG nErrVal = pDoc->TransferTab( pSrcDoc, nSrcTab, nDestTab1,
- FALSE ); // no insert
+ ULONG nErrVal = pDocSh->TransferTab( *pSrcShell, nSrcTab, nDestTab1,
+ FALSE, FALSE ); // no insert
switch (nErrVal)
{
@@ -2470,25 +2478,6 @@ void ScViewFunc::ImportTables( ScDocShell* pSrcShell,
break;
}
- // TransferTab doesn't copy drawing objects with bInsertNew=FALSE
- if ( !bError )
- pDoc->TransferDrawPage( pSrcDoc, nSrcTab, nDestTab1 );
-
- if(!bError &&pSrcDoc->IsScenario(nSrcTab))
- {
- String aComment;
- Color aColor;
- USHORT nFlags;
-
- pSrcDoc->GetScenarioData(nSrcTab, aComment,aColor, nFlags);
- pDoc->SetScenario( nDestTab1,TRUE);
- pDoc->SetScenarioData( nTab+i,aComment,aColor,nFlags);
- BOOL bActive = pSrcDoc->IsActiveScenario(nSrcTab );
- pDoc->SetActiveScenario( nDestTab1, bActive );
- BOOL bVisible=pSrcDoc->IsVisible(nSrcTab);
- pDoc->SetVisible(nDestTab1,bVisible );
-
- }
}
if (bLink)
@@ -2672,33 +2661,7 @@ void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy )
nDestTab1 = nDestTab;
for(USHORT i=0;i<TheTabs.Count();i++)
{
- nErrVal = pDestDoc->TransferTab( pDoc, TheTabs[i], nDestTab1,
- FALSE ); // no insert
-
- // TransferTab doesn't copy drawing objects with bInsertNew=FALSE
- if ( nErrVal > 0 )
- pDestDoc->TransferDrawPage( pDoc, TheTabs[i], nDestTab1 );
-
- if(nErrVal>0 && pDoc->IsScenario(TheTabs[i]))
- {
- String aComment;
- Color aColor;
- USHORT nFlags;
-
- pDoc->GetScenarioData(TheTabs[i], aComment,aColor, nFlags);
- pDestDoc->SetScenario(nDestTab1,TRUE);
- pDestDoc->SetScenarioData(nDestTab1,aComment,aColor,nFlags);
- BOOL bActive = pDoc->IsActiveScenario(TheTabs[i]);
- pDestDoc->SetActiveScenario(nDestTab1, bActive );
-
- BOOL bVisible=pDoc->IsVisible(TheTabs[i]);
- pDestDoc->SetVisible(nDestTab1,bVisible );
-
- }
-
- if ( nErrVal > 0 && pDoc->IsTabProtected( TheTabs[i] ) )
- pDestDoc->SetTabProtection(nDestTab1, pDoc->GetTabProtection(TheTabs[i]));
-
+ nErrVal = pDestShell->TransferTab( *pDocShell, static_cast<SCTAB>(TheTabs[i]), static_cast<SCTAB>(nDestTab1), FALSE, FALSE );
nDestTab1++;
}
}
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 24fab9ac2eba..773dc85d63f3 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -210,6 +210,7 @@
#include "drwtrans.hxx"
#include "docuno.hxx"
#include "clipparam.hxx"
+#include "undodat.hxx" // Amelia Wang
using namespace com::sun::star;
@@ -506,6 +507,76 @@ BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, BOOL bCut, BOOL bApi, BOOL bI
return bDone;
}
+// Copy the content of the Range into clipboard. Adding this method for VBA API: Range.Copy().
+BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRange& rRange, BOOL bCut, BOOL bApi, BOOL bIncludeObjects, BOOL bStopEdit )
+{
+ BOOL bDone = FALSE;
+ if ( bStopEdit )
+ UpdateInputLine();
+
+ ScRange aRange = rRange;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if ( pDoc && !pDoc->HasSelectedBlockMatrixFragment( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ) )
+ {
+ BOOL bSysClip = FALSE;
+ if ( !pClipDoc )
+ {
+ // Create one (deleted by ScTransferObj).
+ pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ bSysClip = TRUE;
+ }
+ if ( !bCut )
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->ResetLastCut();
+ }
+
+ if ( bSysClip && bIncludeObjects )
+ {
+ BOOL bAnyOle = pDoc->HasOLEObjectsInArea( aRange );
+ // Update ScGlobal::pDrawClipDocShellRef.
+ ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
+ }
+
+ ScClipParam aClipParam( aRange, bCut );
+ pDoc->CopyToClip4VBA( aClipParam, pClipDoc, false, bIncludeObjects );
+ if ( bSysClip )
+ {
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+ ScGlobal::SetClipDocName( pDoc->GetDocumentShell()->GetTitle( SFX_TITLE_FULLNAME ) );
+ }
+ pClipDoc->ExtendMerge( aRange, TRUE );
+
+ if ( bSysClip )
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+
+ ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+ if ( ScGlobal::pDrawClipDocShellRef )
+ {
+ SfxObjectShellRef aPersistRef( &(*ScGlobal::pDrawClipDocShellRef) );
+ pTransferObj->SetDrawPersist( aPersistRef );
+ }
+ pTransferObj->CopyToClipboard( GetActiveWin() );
+ SC_MOD()->SetClipObject( pTransferObj, NULL );
+ }
+
+ bDone = TRUE;
+ }
+ else
+ {
+ if ( !bApi )
+ ErrorMessage(STR_MATRIXFRAGMENTERR);
+ }
+
+ return bDone;
+}
+
ScTransferObj* ScViewFunc::CopyToTransferable()
{
ScRange aRange;
@@ -1784,6 +1855,85 @@ BOOL ScViewFunc::LinkBlock( const ScRange& rSource, const ScAddress& rDestPos, B
return TRUE;
}
+void ScViewFunc::DataFormPutData( SCROW nCurrentRow ,
+ SCROW nStartRow , SCCOL nStartCol ,
+ SCROW nEndRow , SCCOL nEndCol ,
+ Edit** pEdits ,
+ sal_uInt16 aColLength )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ ScDocShellModificator aModificator( *pDocSh );
+ SfxUndoManager* pUndoMgr = pDocSh->GetUndoManager();
+ if ( pDoc )
+ {
+ const BOOL bRecord( pDoc->IsUndoEnabled());
+ ScDocument* pUndoDoc = NULL;
+ ScDocument* pRedoDoc = NULL;
+ ScDocument* pRefUndoDoc = NULL;
+ ScRefUndoData* pUndoData = NULL;
+ SCTAB nTab = GetViewData()->GetTabNo();
+ SCTAB nStartTab = nTab;
+ SCTAB nEndTab = nTab;
+
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->ResetLastCut(); // kein CutMode mehr
+ }
+ ScRange aUserRange( nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab );
+ BOOL bColInfo = ( nStartRow==0 && nEndRow==MAXROW );
+ BOOL bRowInfo = ( nStartCol==0 && nEndCol==MAXCOL );
+ SCCOL nUndoEndCol = nStartCol+aColLength-1;
+ SCROW nUndoEndRow = nCurrentRow;
+ USHORT nUndoFlags = IDF_NONE;
+
+ if ( bRecord )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndoSelected( pDoc , rMark , bColInfo , bRowInfo );
+ pDoc->CopyToDocument( aUserRange , 1 , FALSE , pUndoDoc );
+ }
+ USHORT nExtFlags = 0;
+ pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab , nEndCol, nEndRow, nEndTab ); // content before the change
+ //rMark.SetMarkArea( aUserRange );
+ pDoc->BeginDrawUndo();
+
+ for(sal_uInt16 i = 0; i < aColLength; i++)
+ {
+ if (pEdits[i])
+ {
+ String aFieldName=pEdits[i]->GetText();
+ pDoc->SetString( nStartCol + i, nCurrentRow, nTab, aFieldName );
+ }
+ }
+ //pDoc->ExtendMergeSel( nStartCol, nStartRow, nEndCol, nEndRow, rMark, TRUE ); // Refresh
+ pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab ); // content after the change
+ SfxUndoAction* pUndo = new ScUndoDataForm( pDocSh,
+ nStartCol, nCurrentRow, nStartTab,
+ nUndoEndCol, nUndoEndRow, nEndTab, rMark,
+ pUndoDoc, pRedoDoc, nUndoFlags,
+ pUndoData, NULL, NULL, NULL,
+ FALSE ); // FALSE = Redo data not yet copied
+ pUndoMgr->AddUndoAction( new ScUndoWrapper( pUndo ), TRUE );
+
+ USHORT nPaint = PAINT_GRID;
+ if (bColInfo)
+ {
+ nPaint |= PAINT_TOP;
+ nUndoEndCol = MAXCOL; // nur zum Zeichnen !
+ }
+ if (bRowInfo)
+ {
+ nPaint |= PAINT_LEFT;
+ nUndoEndRow = MAXROW; // nur zum Zeichnen !
+ }
+ pDocSh->PostPaint( nStartCol, nCurrentRow, nStartTab,
+ nUndoEndCol, nUndoEndRow, nEndTab, nPaint, nExtFlags );
+ pDocSh->UpdateOle(GetViewData());
+ }
+}
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index ed16e94b9552..539bee7d0d1c 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -404,6 +404,7 @@
<menu:menuitem menu:id=".uno:DataFilterHideAutoFilter"/>
</menu:menupopup>
</menu:menu>
+ <menu:menuitem menu:id=".uno:DataForm"/>
<menu:menuitem menu:id=".uno:DataSubTotals"/>
<menu:menuitem menu:id=".uno:Validation"/>
<menu:menuseparator/>
diff --git a/sc/util/makefile.mk b/sc/util/makefile.mk
index 980d271ae7c0..71c05abaaf34 100644
--- a/sc/util/makefile.mk
+++ b/sc/util/makefile.mk
@@ -1,7 +1,7 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
+#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
@@ -96,7 +96,7 @@ SHL1STDLIBS= \
$(AVMEDIALIB) \
$(FORLIB) \
$(FORUILIB)
-
+
SHL1LIBS=$(LIB3TARGET) $(LIB4TARGET)
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
@@ -273,6 +273,7 @@ LIB8OBJFILES = \
$(SLO)$/filldlg.obj \
$(SLO)$/delcodlg.obj \
$(SLO)$/delcldlg.obj \
+ $(SLO)$/datafdlg.obj \
$(SLO)$/dapitype.obj \
$(SLO)$/dapidata.obj \
$(SLO)$/crdlg.obj \
@@ -316,7 +317,8 @@ SHL9STDLIBS= \
$(VCLLIB) \
$(TKLIB) \
$(MSFILTERLIB) \
- $(FORLIB)
+ $(FORLIB) \
+ $(UNOTOOLSLIB)
SHL9DEPN=$(SHL1TARGETN) $(SHL8TARGETN)
SHL9LIBS=$(SLB)$/$(TARGET_VBA).lib
@@ -328,7 +330,7 @@ SHL9LIBS=$(SLB)$/$(TARGET_VBA).lib
.ENDIF
.ENDIF
-
+
# --- Targets -------------------------------------------------------------