This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch symphony-vba
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 42535aff4b267a3fd4409eeb51922308a3a93d2c
Author: Pedro Giffuni <[email protected]>
AuthorDate: Sat Sep 26 23:54:43 2026 -0500

    Port Symphony VBA FileDialog, FileSearch, QueryTable, FormatCondition, 
Workbook.SaveAs, and Application enhancements
    
    Port IBM Lotus Symphony VBA compatibility features into Apache OpenOffice's
    Calc VBA compatibility layer:
    
    New IDL interfaces (main/oovbaapi/ooo/vba/):
    - XFileDialog: MsoFileDialogType, Title, AllowMultiSelect, Show()
    - XFileDialogSelectedItems: extends XCollection
    - XFileSearch: FileName, LookIn, SearchSubFolders, MatchTextExactly, 
Execute()
    - XFoundFiles: extends XCollection, File(Index)
    - XQueryTable: Refresh(any), Delete()
    
    New C++ implementations (main/sc/source/ui/vba/):
    - ScVbaFileDialog using com.sun.star.ui.dialogs.FilePicker
    - ScVbaFileSearch using com.sun.star.ucb.SimpleFileAccess
    - VbaFoundFiles collection with XIndexAccess/XEnumeration
    - ScVbaQueryTable using sfx2::LinkManager and ScAreaLink
    
    Modified XApplication.idl:
    - FileDialog() method + FileSearch attribute
    - CountA, MenuBars, International, Undo, InchesToPoints
    - setSheetsInNewWorkbook, getSheetsInNewWorkbook
    - Intersect, Union (already present)
    
    Modified XRange.idl:
    - Added FormatConditions and QueryTable attributes
    
    Modified XWorkbook.idl:
    - Added SaveAs method
    
    Implemented getFormatConditions() in vbarange.cxx:
    - Returns ScVbaFormatConditions using ConditionalFormat property
    
    Implemented Application methods in vbaapplication.cxx:
    - CountA delegates to WorksheetFunction::CountA
    - getSheetsInNewWorkbook/setSheetsInNewWorkbook use ScAppOptions
    - FileDialog() creates ScVbaFileDialog with model
    - getFileSearch() creates ScVbaFileSearch
    
    Added missing Formula1()/Formula2() to XFormatCondition:
    - Required by IDL interface, returns formula from XSheetCondition
    
    Registered services in service.cxx:
    - filedialog, filesearch, foundfiles, querytable
    - formatconditions, formatcondition
    
    Build configuration:
    - UnoApi_oovbaapi.mk: 5 new IDL files added
    - Library_vbaobj.mk: 5 new .cxx files added
---
 .gitignore                                         |   3 +
 main/oovbaapi/UnoApi_oovbaapi.mk                   |   5 +
 main/oovbaapi/ooo/vba/XFileDialog.idl              |  46 ++++
 main/oovbaapi/ooo/vba/XFileDialogSelectedItems.idl |  36 +++
 main/oovbaapi/ooo/vba/XFileSearch.idl              |  48 ++++
 main/oovbaapi/ooo/vba/XFoundFiles.idl              |  36 +++
 main/oovbaapi/ooo/vba/excel/XApplication.idl       |  14 ++
 main/oovbaapi/ooo/vba/excel/XQueryTable.idl        |  40 ++++
 main/oovbaapi/ooo/vba/excel/XRange.idl             |   4 +
 main/oovbaapi/ooo/vba/excel/XWorkbook.idl          |   1 +
 main/sc/Library_vbaobj.mk                          |   5 +
 main/sc/source/ui/vba/service.cxx                  |  28 ++-
 main/sc/source/ui/vba/vbaapplication.cxx           |  83 +++++++
 main/sc/source/ui/vba/vbaapplication.hxx           |  14 ++
 main/sc/source/ui/vba/vbafiledialog.cxx            | 230 +++++++++++++++++++
 main/sc/source/ui/vba/vbafiledialog.hxx            |  63 ++++++
 .../source/ui/vba/vbafiledialogselecteditems.cxx   | 145 ++++++++++++
 .../source/ui/vba/vbafiledialogselecteditems.hxx   |  81 +++++++
 main/sc/source/ui/vba/vbafilesearch.cxx            | 245 +++++++++++++++++++++
 main/sc/source/ui/vba/vbafilesearch.hxx            |  70 ++++++
 main/sc/source/ui/vba/vbaformatcondition.cxx       |  24 +-
 main/sc/source/ui/vba/vbaformatcondition.hxx       |   2 +
 main/sc/source/ui/vba/vbaformatconditions.cxx      |  12 +-
 main/sc/source/ui/vba/vbafoundfiles.cxx            | 152 +++++++++++++
 main/sc/source/ui/vba/vbafoundfiles.hxx            |  84 +++++++
 main/sc/source/ui/vba/vbaquerytable.cxx            | 116 ++++++++++
 main/sc/source/ui/vba/vbaquerytable.hxx            |  55 +++++
 main/sc/source/ui/vba/vbarange.cxx                 |  29 ++-
 main/sc/source/ui/vba/vbarange.hxx                 |   4 +
 main/sc/source/ui/vba/vbaworkbook.cxx              |  35 +++
 main/sc/source/ui/vba/vbaworkbook.hxx              |   1 +
 31 files changed, 1707 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 18754d0a0e..cc9b9284c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -104,6 +104,9 @@ main/winaccessibility/source/UAccCOMIDL/dlldata.c
 # claude
 .claude/
 
+# Visual Studio (not VS Code)
+.vs/
+
 # bazel
 bazel-*
 user.bazelrc
diff --git a/main/oovbaapi/UnoApi_oovbaapi.mk b/main/oovbaapi/UnoApi_oovbaapi.mk
index 7f19395b6c..4ec8deabf7 100644
--- a/main/oovbaapi/UnoApi_oovbaapi.mk
+++ b/main/oovbaapi/UnoApi_oovbaapi.mk
@@ -74,6 +74,10 @@ $(eval $(call gb_UnoApiTarget_add_idlfiles,oovbaapi,\
        oovbaapi/ooo/vba/XDocumentsBase \
        oovbaapi/ooo/vba/XErrObject \
        oovbaapi/ooo/vba/XExecutableDialog \
+       oovbaapi/ooo/vba/XFileDialog \
+       oovbaapi/ooo/vba/XFileDialogSelectedItems \
+       oovbaapi/ooo/vba/XFileSearch \
+       oovbaapi/ooo/vba/XFoundFiles \
        oovbaapi/ooo/vba/XFontBase \
        oovbaapi/ooo/vba/XGlobalsBase \
        oovbaapi/ooo/vba/XHelperInterface \
@@ -120,6 +124,7 @@ $(eval $(call gb_UnoApiTarget_add_idlfiles,oovbaapi,\
        oovbaapi/ooo/vba/excel/XPivotCache \
        oovbaapi/ooo/vba/excel/XPivotTable \
        oovbaapi/ooo/vba/excel/XPivotTables \
+       oovbaapi/ooo/vba/excel/XQueryTable \
        oovbaapi/ooo/vba/excel/XRange \
        oovbaapi/ooo/vba/excel/XSeries \
        oovbaapi/ooo/vba/excel/XSeriesCollection \
diff --git a/main/oovbaapi/ooo/vba/XFileDialog.idl 
b/main/oovbaapi/ooo/vba/XFileDialog.idl
new file mode 100644
index 0000000000..ef4db5a1d1
--- /dev/null
+++ b/main/oovbaapi/ooo/vba/XFileDialog.idl
@@ -0,0 +1,46 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef __ooo_vba_XFileDialog_idl__
+#define __ooo_vba_XFileDialog_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <ooo/vba/XHelperInterface.idl>
+
+module ooo { module vba {
+
+interface XFileDialogSelectedItems;
+
+interface XFileDialog
+{
+    interface ::ooo::vba::XHelperInterface;
+
+    [attribute] long MsoFileDialogType;
+    [attribute] string Title;
+    [attribute] boolean AllowMultiSelect;
+    [attribute, readonly] XFileDialogSelectedItems SelectedItems;
+
+    long Show();
+};
+
+}; };
+
+#endif
\ No newline at end of file
diff --git a/main/oovbaapi/ooo/vba/XFileDialogSelectedItems.idl 
b/main/oovbaapi/ooo/vba/XFileDialogSelectedItems.idl
new file mode 100644
index 0000000000..2ed26139aa
--- /dev/null
+++ b/main/oovbaapi/ooo/vba/XFileDialogSelectedItems.idl
@@ -0,0 +1,36 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef __ooo_vba_XFileDialogSelectedItems_idl__
+#define __ooo_vba_XFileDialogSelectedItems_idl__
+
+#include <com/sun/star/container/XEnumerationAccess.idl>
+#include <ooo/vba/XCollection.idl>
+
+module ooo { module vba {
+
+interface XFileDialogSelectedItems : XCollection
+{
+};
+
+}; };
+
+#endif
\ No newline at end of file
diff --git a/main/oovbaapi/ooo/vba/XFileSearch.idl 
b/main/oovbaapi/ooo/vba/XFileSearch.idl
new file mode 100644
index 0000000000..81042cfc38
--- /dev/null
+++ b/main/oovbaapi/ooo/vba/XFileSearch.idl
@@ -0,0 +1,48 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef __ooo_vba_XFileSearch_idl__
+#define __ooo_vba_XFileSearch_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <ooo/vba/XHelperInterface.idl>
+
+module ooo { module vba {
+
+interface XFoundFiles;
+
+interface XFileSearch
+{
+    interface ::ooo::vba::XHelperInterface;
+
+    [attribute] string FileName;
+    [attribute] string LookIn;
+    [attribute] boolean SearchSubFolders;
+    [attribute] boolean MatchTextExactly;
+    [attribute, readonly] XFoundFiles FoundFiles;
+
+    long Execute();
+    void NewSearch();
+};
+
+}; };
+
+#endif
\ No newline at end of file
diff --git a/main/oovbaapi/ooo/vba/XFoundFiles.idl 
b/main/oovbaapi/ooo/vba/XFoundFiles.idl
new file mode 100644
index 0000000000..56c544d494
--- /dev/null
+++ b/main/oovbaapi/ooo/vba/XFoundFiles.idl
@@ -0,0 +1,36 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef __ooo_vba_XFoundFiles_idl__
+#define __ooo_vba_XFoundFiles_idl__
+
+#include <ooo/vba/XCollection.idl>
+
+module ooo { module vba {
+
+interface XFoundFiles : XCollection
+{
+    string File( [in] long Index );
+};
+
+}; };
+
+#endif
\ No newline at end of file
diff --git a/main/oovbaapi/ooo/vba/excel/XApplication.idl 
b/main/oovbaapi/ooo/vba/excel/XApplication.idl
index f5a288704b..85e926e25a 100644
--- a/main/oovbaapi/ooo/vba/excel/XApplication.idl
+++ b/main/oovbaapi/ooo/vba/excel/XApplication.idl
@@ -27,6 +27,8 @@
 #include <com/sun/star/script/XInvocation.idl>
 #include <ooo/vba/XHelperInterface.idl>
 #include <ooo/vba/XAssistant.idl>
+#include <ooo/vba/XFileDialog.idl>
+#include <ooo/vba/XFileSearch.idl>
 
 module ooo {  module vba {  module excel {
 
@@ -37,6 +39,8 @@ interface XWorksheets;
 interface XWorksheetFunction;
 interface XWindow;
 interface XWorksheet;
+interface ::ooo::vba::XFileDialog;
+interface ::ooo::vba::XFileSearch;
 
 interface XApplication
 {
@@ -66,6 +70,9 @@ interface XApplication
     [attribute, readonly] string TemplatesPath;
     [attribute, readonly] string PathSeparator;
 
+    ::ooo::vba::XFileDialog FileDialog( [in] long MsoFileDialogType );
+    [attribute, readonly] ::ooo::vba::XFileSearch FileSearch;
+
     //any CommandBars( [in] any Index );
        any Workbooks( [in] any Index );
        any Worksheets( [in] any Index );
@@ -88,6 +95,13 @@ interface XApplication
        any Caller( [in] any Index );
        any GetOpenFilename( [in] any FileFilter, [in] any FilterIndex, [in] 
any Title, [in] any ButtonText, [in] any MultiSelect );
        any GetSaveAsFilename( [in] any InitialFileName, [in] any FileFilter, 
[in] any FilterIndex, [in] any Title, [in] any ButtonText );
+       double CountA( [in] any arg1 );
+       any MenuBars( [in] any aIndex );
+       any International( [in] long Index );
+       void Undo();
+       double InchesToPoints( [in] double Inches );
+       void setSheetsInNewWorkbook( [in] long SheetsInNewWorkbook );
+       long getSheetsInNewWorkbook();
 };
 
 }; }; };
diff --git a/main/oovbaapi/ooo/vba/excel/XQueryTable.idl 
b/main/oovbaapi/ooo/vba/excel/XQueryTable.idl
new file mode 100644
index 0000000000..bfc4e2e5df
--- /dev/null
+++ b/main/oovbaapi/ooo/vba/excel/XQueryTable.idl
@@ -0,0 +1,40 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef __ooo_vba_excel_XQueryTable_idl__
+#define __ooo_vba_excel_XQueryTable_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <ooo/vba/XHelperInterface.idl>
+
+module ooo { module vba { module excel {
+
+interface XQueryTable
+{
+    interface ::ooo::vba::XHelperInterface;
+
+    boolean Refresh( [in] any BackgroundQuery );
+    void Delete();
+};
+
+}; }; };
+
+#endif
\ No newline at end of file
diff --git a/main/oovbaapi/ooo/vba/excel/XRange.idl 
b/main/oovbaapi/ooo/vba/excel/XRange.idl
index 7934d59407..261c3b9635 100644
--- a/main/oovbaapi/ooo/vba/excel/XRange.idl
+++ b/main/oovbaapi/ooo/vba/excel/XRange.idl
@@ -64,6 +64,8 @@ interface XCharacters;
 interface XBorders;
 interface XValidation;
 interface XWorksheet;
+interface XFormatConditions;
+interface XQueryTable;
 
 interface XRange
 {
@@ -98,6 +100,8 @@ interface XRange
        [attribute] any Style;
        [attribute] any AddIndent;
        [attribute] any ShowDetail;
+       [attribute, readonly] XFormatConditions FormatConditions;
+       [attribute, readonly] XQueryTable QueryTable;
 
        XComment AddComment( [in] any Text );
        void Clear();
diff --git a/main/oovbaapi/ooo/vba/excel/XWorkbook.idl 
b/main/oovbaapi/ooo/vba/excel/XWorkbook.idl
index 8533f77ee8..7e479c20e0 100644
--- a/main/oovbaapi/ooo/vba/excel/XWorkbook.idl
+++ b/main/oovbaapi/ooo/vba/excel/XWorkbook.idl
@@ -58,6 +58,7 @@ interface XWorkbook : com::sun::star::uno::XInterface
        any Colors( [in] any Index ) raises 
(com::sun::star::script::BasicErrorException);
        long FileFormat() raises (com::sun::star::script::BasicErrorException);
        void SaveCopyAs( [in] string Filename );
+       void SaveAs( [in] any FileName, [in] any FileFormat, [in] any Password, 
[in] any WriteResPassword, [in] any ReadOnlyRecommended, [in] any CreateBackup 
);
 };
 
 }; }; };
diff --git a/main/sc/Library_vbaobj.mk b/main/sc/Library_vbaobj.mk
index a4f61bd364..edb11b5e73 100644
--- a/main/sc/Library_vbaobj.mk
+++ b/main/sc/Library_vbaobj.mk
@@ -122,6 +122,11 @@ $(eval $(call gb_Library_add_exception_objects,vbaobj,\
        sc/source/ui/vba/vbaworksheet \
        sc/source/ui/vba/vbaworksheets \
        sc/source/ui/vba/vbawsfunction \
+       sc/source/ui/vba/vbafiledialog \
+       sc/source/ui/vba/vbafiledialogselecteditems \
+       sc/source/ui/vba/vbafilesearch \
+       sc/source/ui/vba/vbafoundfiles \
+       sc/source/ui/vba/vbaquerytable \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/main/sc/source/ui/vba/service.cxx 
b/main/sc/source/ui/vba/service.cxx
index d684f5a5aa..1140e5952d 100644
--- a/main/sc/source/ui/vba/service.cxx
+++ b/main/sc/source/ui/vba/service.cxx
@@ -70,6 +70,30 @@ namespace textframe
 {
 extern sdecl::ServiceDecl const serviceDecl;
 }
+namespace filedialog
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace filesearch
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace foundfiles
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace formatconditions
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace formatcondition
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace querytable
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
 
 extern "C"
 {
@@ -85,10 +109,12 @@ extern "C"
         registry::XRegistryKey * pRegistryKey )
     {
                OSL_TRACE("In component_getFactory for %s", pImplName );
-       void* pRet =  component_getFactoryHelper(
+    void* pRet =  component_getFactoryHelper(
                pImplName, pServiceManager, pRegistryKey, range::serviceDecl, 
workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, 
window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl );
     if( !pRet )
         pRet = component_getFactoryHelper( pImplName, pServiceManager, 
pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl );
+    if( !pRet )
+        pRet = component_getFactoryHelper( pImplName, pServiceManager, 
pRegistryKey, filedialog::serviceDecl, filesearch::serviceDecl, 
foundfiles::serviceDecl, querytable::serviceDecl, 
formatconditions::serviceDecl, formatcondition::serviceDecl );
        OSL_TRACE("Ret is 0x%x", pRet);
        return pRet;
     }
diff --git a/main/sc/source/ui/vba/vbaapplication.cxx 
b/main/sc/source/ui/vba/vbaapplication.cxx
index c93c53d22b..ed1da6a666 100644
--- a/main/sc/source/ui/vba/vbaapplication.cxx
+++ b/main/sc/source/ui/vba/vbaapplication.cxx
@@ -54,7 +54,13 @@
 #include <vbahelper/vbashape.hxx>
 #include "vbatextboxshape.hxx"
 #include "vbaassistant.hxx"
+#include "vbafiledialog.hxx"
+#include "vbafilesearch.hxx"
 #include "sc.hrc"
+#include "global.hxx"
+#include "scmod.hxx"
+#include "docoptio.hxx"
+#include "appoptio.hxx"
 
 #include <osl/file.hxx>
 #include <rtl/instance.hxx>
@@ -1154,12 +1160,89 @@ uno::Any SAL_CALL ScVbaApplication::GetSaveAsFilename(
     return xFilePicker->execute();
 }
 
+uno::Reference< ooo::vba::XFileDialog > SAL_CALL
+ScVbaApplication::FileDialog( sal_Int32 nFileDialogType )
+{
+    uno::Reference< frame::XModel > xModel( getThisExcelDoc( mxContext ), 
uno::UNO_SET_THROW );
+    uno::Reference< ooo::vba::XFileDialog > xFileDialog(
+        new ScVbaFileDialog( this, mxContext, xModel ) );
+    xFileDialog->setMsoFileDialogType( nFileDialogType );
+    return xFileDialog;
+}
+
+uno::Reference< ooo::vba::XFileSearch > SAL_CALL
+ScVbaApplication::getFileSearch()
+{
+    uno::Reference< ooo::vba::XFileSearch > xFileSearch(
+        new ScVbaFileSearch( this, this, mxContext ) );
+    return xFileSearch;
+}
+
 uno::Reference< frame::XModel >
 ScVbaApplication::getCurrentDocument()
 {
     return getCurrentExcelDoc(mxContext);
 }
 
+double SAL_CALL
+ScVbaApplication::CountA( const css::uno::Any& aArg1 )
+{
+    double result = 0;
+    uno::Reference< script::XInvocation > xInvoc( WorksheetFunction(), 
uno::UNO_QUERY_THROW );
+    if ( xInvoc.is() )
+    {
+        static rtl::OUString FunctionName( 
RTL_CONSTASCII_USTRINGPARAM("CountA") );
+        uno::Sequence< uno::Any > Params(1);
+        Params[0] = aArg1;
+        uno::Sequence< sal_Int16 > OutParamIndex;
+        uno::Sequence< uno::Any > OutParam;
+        xInvoc->invoke( FunctionName, Params, OutParamIndex, OutParam ) >>= 
result;
+    }
+    return result;
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::MenuBars( const css::uno::Any& aIndex )
+{
+    return uno::Any();
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::International( sal_Int32 nIndex )
+{
+    return uno::Any();
+}
+
+void SAL_CALL
+ScVbaApplication::Undo()
+{
+}
+
+double SAL_CALL
+ScVbaApplication::InchesToPoints( double nInches )
+{
+    return nInches * 72.0;
+}
+
+sal_Int32 SAL_CALL ScVbaApplication::getSheetsInNewWorkbook()
+{
+    const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
+    return rAppOpt.GetTabCountInNewSpreadsheet();
+}
+
+void SAL_CALL ScVbaApplication::setSheetsInNewWorkbook( sal_Int32 nSheets )
+{
+    if ( nSheets < 1 || nSheets > MAXTAB )
+    {
+        DebugHelper::exception( rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM("The number must be between 1 and 255") ), 
uno::Exception(), SbERR_METHOD_FAILED, rtl::OUString() );
+    }
+    else
+    {
+        ScAppOptions& rAppOpt = const_cast< ScAppOptions& 
>(SC_MOD()->GetAppOptions());
+        rAppOpt.SetTabCountInNewSpreadsheet( nSheets );
+    }
+}
+
 rtl::OUString&
 ScVbaApplication::getServiceImplName()
 {
diff --git a/main/sc/source/ui/vba/vbaapplication.hxx 
b/main/sc/source/ui/vba/vbaapplication.hxx
index a6b60ff25a..ecf71a0ee2 100644
--- a/main/sc/source/ui/vba/vbaapplication.hxx
+++ b/main/sc/source/ui/vba/vbaapplication.hxx
@@ -26,6 +26,8 @@
 
 #include <ooo/vba/excel/XWorksheetFunction.hpp>
 #include <ooo/vba/excel/XApplication.hpp>
+#include <ooo/vba/XFileDialog.hpp>
+#include <ooo/vba/XFileSearch.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 
 #include <vbahelper/vbahelperinterface.hxx>
@@ -118,6 +120,18 @@ public:
        virtual css::uno::Any SAL_CALL Caller( const css::uno::Any& aIndex );
        virtual css::uno::Any SAL_CALL GetOpenFilename( const css::uno::Any& 
rFileFilter, const css::uno::Any& rFilterIndex, const css::uno::Any& rTitle, 
const css::uno::Any& rButtonText, const css::uno::Any& rMultiSelect );
        virtual css::uno::Any SAL_CALL GetSaveAsFilename( const css::uno::Any& 
rInitialFileName, const css::uno::Any& rFileFilter, const css::uno::Any& 
rFilterIndex, const css::uno::Any& rTitle, const css::uno::Any& rButtonText );
+
+       virtual css::uno::Reference< ooo::vba::XFileDialog > SAL_CALL 
FileDialog( sal_Int32 nFileDialogType );
+       virtual css::uno::Reference< ooo::vba::XFileSearch > SAL_CALL 
getFileSearch();
+
+       virtual double SAL_CALL CountA( const css::uno::Any& aArg1 );
+       virtual css::uno::Any SAL_CALL MenuBars( const css::uno::Any& aIndex );
+       virtual css::uno::Any SAL_CALL International( sal_Int32 nIndex );
+       virtual void SAL_CALL Undo();
+       virtual double SAL_CALL InchesToPoints( double nInches );
+       virtual void SAL_CALL setSheetsInNewWorkbook( sal_Int32 nSheets );
+       virtual sal_Int32 SAL_CALL getSheetsInNewWorkbook();
+
        // XHelperInterface
        virtual rtl::OUString& getServiceImplName();
        virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/main/sc/source/ui/vba/vbafiledialog.cxx 
b/main/sc/source/ui/vba/vbafiledialog.cxx
new file mode 100644
index 0000000000..2b91b342c0
--- /dev/null
+++ b/main/sc/source/ui/vba/vbafiledialog.cxx
@@ -0,0 +1,230 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the 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/XFilterManager.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include "tools/urlobj.hxx"
+#include <sfx2/filedlghelper.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+ScVbaFileDialog::ScVbaFileDialog( const css::uno::Reference< 
ooo::vba::XHelperInterface >& xParent, const css::uno::Reference< 
css::uno::XComponentContext > &xContext, const css::uno::Reference< 
css::frame::XModel >& xModel )
+:      ScVbaFileDialog_BASE( xParent, xContext, xModel )
+{
+    m_nDialogType = 3;
+    m_bAllowMultiSelect = sal_True;
+       m_pSelectedItems = new VbaFileDialogSelectedItems(xParent, xContext, 
(com::sun::star::container::XIndexAccess *)&m_FileDialogSelectedObj);
+}
+
+ScVbaFileDialog::~ScVbaFileDialog()
+{
+    if (m_pSelectedItems != NULL)
+    {
+        delete m_pSelectedItems;
+    }
+}
+
+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;
+}
+
+sal_Int32 SAL_CALL
+ScVbaFileDialog::getMsoFileDialogType() throw ( css::uno::RuntimeException )
+{
+    return m_nDialogType;
+}
+
+void SAL_CALL
+ScVbaFileDialog::setMsoFileDialogType( sal_Int32 nType ) throw ( 
css::uno::RuntimeException )
+{
+    m_nDialogType = nType;
+}
+
+rtl::OUString SAL_CALL
+ScVbaFileDialog::getTitle() throw ( css::uno::RuntimeException )
+{
+    return m_sTitle;
+}
+
+void SAL_CALL
+ScVbaFileDialog::setTitle( const rtl::OUString& rTitle ) throw ( 
css::uno::RuntimeException )
+{
+    m_sTitle = rTitle;
+}
+
+sal_Bool SAL_CALL
+ScVbaFileDialog::getAllowMultiSelect() throw ( css::uno::RuntimeException )
+{
+    return m_bAllowMultiSelect;
+}
+
+void SAL_CALL
+ScVbaFileDialog::setAllowMultiSelect( sal_Bool bAllow ) throw ( 
css::uno::RuntimeException )
+{
+    m_bAllowMultiSelect = bAllow;
+}
+
+css::uno::Reference< ooo::vba::XFileDialogSelectedItems > SAL_CALL
+ScVbaFileDialog::getSelectedItems() throw ( css::uno::RuntimeException )
+{
+    css::uno::Reference< ooo::vba::XFileDialogSelectedItems > xFileDlgSlc = 
(ooo::vba::XFileDialogSelectedItems *)m_pSelectedItems;
+    return xFileDlgSlc;
+}
+
+sal_Int32 SAL_CALL
+ScVbaFileDialog::Show() throw ( css::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 );
+        Reference< ui::dialogs::XFilterManager > xFilterManager( xFilePicker, 
UNO_QUERY );
+        if ( xFilePicker.is() )
+        {
+            xFilePicker->setMultiSelectionMode( m_bAllowMultiSelect );
+            // Only when there is no any filter in the msoFileDialogFilePicker 
dialog, then we need to add the All File Filter.
+            if ( xFilterManager.is() && 
xFilterManager->getCurrentFilter().equalsAscii("") )
+            {
+                xFilterManager->appendFilter( 
sfx2::FileDialogHelper::GetAllFileFilterName(), rtl::OUString::createFromAscii( 
"*.*" ) );
+            }
+            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;
+}
+
+namespace filedialog
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaFileDialog, sdecl::with_args<true> > 
serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+    serviceImpl,
+    "ScVbaFileDialog",
+    "ooo.vba.excel.FileDialog" );
+}
diff --git a/main/sc/source/ui/vba/vbafiledialog.hxx 
b/main/sc/source/ui/vba/vbafiledialog.hxx
new file mode 100644
index 0000000000..8550ffcf35
--- /dev/null
+++ b/main/sc/source/ui/vba/vbafiledialog.hxx
@@ -0,0 +1,63 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef SC_VBA_FILEDIALOG_HXX
+#define SC_VBA_FILEDIALOG_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <vbahelper/vbadialogsbase.hxx>
+#include <ooo/vba/XFileDialog.hpp>
+#include "vbafiledialogselecteditems.hxx"
+
+typedef cppu::ImplInheritanceHelper1< VbaDialogsBase, ooo::vba::XFileDialog > 
ScVbaFileDialog_BASE;
+
+class ScVbaFileDialog : public ScVbaFileDialog_BASE
+{
+public:
+    ScVbaFileDialog( const css::uno::Reference< ooo::vba::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 sal_Int32 SAL_CALL getMsoFileDialogType() throw ( 
css::uno::RuntimeException );
+    virtual void SAL_CALL setMsoFileDialogType( sal_Int32 nType ) throw ( 
css::uno::RuntimeException );
+    virtual rtl::OUString SAL_CALL getTitle() throw ( 
css::uno::RuntimeException );
+    virtual void SAL_CALL setTitle( const rtl::OUString& rTitle ) throw ( 
css::uno::RuntimeException );
+    virtual sal_Bool SAL_CALL getAllowMultiSelect() throw ( 
css::uno::RuntimeException );
+    virtual void SAL_CALL setAllowMultiSelect( sal_Bool bAllow ) throw ( 
css::uno::RuntimeException );
+    virtual css::uno::Reference< ooo::vba::XFileDialogSelectedItems > SAL_CALL 
getSelectedItems() throw ( css::uno::RuntimeException );
+    virtual sal_Int32 SAL_CALL Show() throw ( css::uno::RuntimeException );
+
+private:
+    sal_Int32 m_nDialogType;
+    rtl::OUString m_sTitle;
+    sal_Bool m_bAllowMultiSelect;
+    css::uno::Sequence< rtl::OUString > m_sSelectedItems;
+    VbaFileDialogSelectedItems *m_pSelectedItems;
+    VbaFileDialogSelectedObj m_FileDialogSelectedObj;
+};
+
+#endif
\ No newline at end of file
diff --git a/main/sc/source/ui/vba/vbafiledialogselecteditems.cxx 
b/main/sc/source/ui/vba/vbafiledialogselecteditems.cxx
new file mode 100644
index 0000000000..0cb49fad2e
--- /dev/null
+++ b/main/sc/source/ui/vba/vbafiledialogselecteditems.cxx
@@ -0,0 +1,145 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "vbafiledialogselecteditems.hxx"
+
+using namespace ::com::sun::star;
+
+VbaFileDialogSelectedItems::VbaFileDialogSelectedItems(
+        const css::uno::Reference< ooo::vba::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 ( css::uno::RuntimeException )
+{
+    sal_Int32 nListCnt = m_sFileList.getLength();
+    return nListCnt;
+}
+
+css::uno::Any SAL_CALL VbaFileDialogSelectedObj::getByIndex( sal_Int32 nIndex )
+    throw ( css::lang::IndexOutOfBoundsException,
+            css::lang::WrappedTargetException,
+            css::uno::RuntimeException )
+{
+    if ( nIndex >= getCount() )
+    {
+        throw css::lang::IndexOutOfBoundsException();
+    }
+
+    return uno::makeAny( m_sFileList[nIndex] );
+}
+
+css::uno::Type SAL_CALL
+VbaFileDialogSelectedObj::getElementType()
+    throw ( css::uno::RuntimeException )
+{
+    return getCppuType( (uno::Reference< 
com::sun::star::container::XIndexAccess >*)0 );
+}
+
+sal_Bool SAL_CALL
+VbaFileDialogSelectedObj::hasElements()
+    throw ( css::uno::RuntimeException )
+{
+    return ( getCount() != 0 );
+}
+
+sal_Bool SAL_CALL
+VbaFileDialogSelectedObj::hasMoreElements()
+    throw ( css::uno::RuntimeException )
+{
+    if ( getCount() > m_nIndex )
+    {
+        return sal_True;
+    }
+    return sal_False;
+}
+
+css::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/main/sc/source/ui/vba/vbafiledialogselecteditems.hxx 
b/main/sc/source/ui/vba/vbafiledialogselecteditems.hxx
new file mode 100644
index 0000000000..913bab85d5
--- /dev/null
+++ b/main/sc/source/ui/vba/vbafiledialogselecteditems.hxx
@@ -0,0 +1,81 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef SC_VBA_FILEDIALOGSELECTEDITEMS_HXX
+#define SC_VBA_FILEDIALOGSELECTEDITEMS_HXX
+
+#include <ooo/vba/XFileDialogSelectedItems.hpp>
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/container/XIndexAccess.hpp>
+
+typedef CollTestImplHelper< ooo::vba::XFileDialogSelectedItems > 
FileDialogSelectedItems_BASE;
+
+class VbaFileDialogSelectedItems : public FileDialogSelectedItems_BASE
+{
+public:
+    VbaFileDialogSelectedItems( const css::uno::Reference< 
ooo::vba::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();
+};
+
+
+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 ( 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 );
+
+protected:
+private:
+    css::uno::Sequence< rtl::OUString > m_sFileList;
+    sal_Int32 m_nIndex;
+};
+
+#endif
\ No newline at end of file
diff --git a/main/sc/source/ui/vba/vbafilesearch.cxx 
b/main/sc/source/ui/vba/vbafilesearch.cxx
new file mode 100644
index 0000000000..e7ea5a4f5d
--- /dev/null
+++ b/main/sc/source/ui/vba/vbafilesearch.cxx
@@ -0,0 +1,245 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the 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 nLength = aSearchedFiles.getLength();
+                aSearchedFiles.realloc( nLength + 1 );
+                rtl::OUString sSystemPath;
+                ::osl::File::getSystemPathFromFileURL( aURLStr, sSystemPath );
+                aSearchedFiles[nLength] = 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();
+}
+
+// 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;
+}
+
+namespace filesearch
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaFileSearch, sdecl::with_args<true> > 
serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+    serviceImpl,
+    "ScVbaFileSearch",
+    "ooo.vba.FileSearch" );
+}
diff --git a/main/sc/source/ui/vba/vbafilesearch.hxx 
b/main/sc/source/ui/vba/vbafilesearch.hxx
new file mode 100644
index 0000000000..bebf389249
--- /dev/null
+++ b/main/sc/source/ui/vba/vbafilesearch.hxx
@@ -0,0 +1,70 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the 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();
+
+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
\ No newline at end of file
diff --git a/main/sc/source/ui/vba/vbaformatcondition.cxx 
b/main/sc/source/ui/vba/vbaformatcondition.cxx
index 1d619deda9..dcd552e45d 100644
--- a/main/sc/source/ui/vba/vbaformatcondition.cxx
+++ b/main/sc/source/ui/vba/vbaformatcondition.cxx
@@ -139,6 +139,18 @@ ScVbaFormatCondition::Operator(  )
        return ScVbaFormatCondition_BASE::Operator( sal_True );
 }
 
+rtl::OUString SAL_CALL
+ScVbaFormatCondition::Formula1()
+{
+    return mxSheetCondition->getFormula1();
+}
+
+rtl::OUString SAL_CALL
+ScVbaFormatCondition::Formula2()
+{
+    return mxSheetCondition->getFormula2();
+}
+
 void
 ScVbaFormatCondition::notifyRange()
 {
@@ -168,5 +180,15 @@ ScVbaFormatCondition::getServiceNames()
                aServiceNames.realloc( 1 );
                aServiceNames[ 0 ] = rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.FormatCondition" ) );
        }
-       return aServiceNames;
+               return aServiceNames;
+}
+
+namespace formatcondition
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaFormatCondition, sdecl::with_args<true> > 
serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+    serviceImpl,
+    "ScVbaFormatCondition",
+    "ooo.vba.excel.FormatCondition" );
 }
diff --git a/main/sc/source/ui/vba/vbaformatcondition.hxx 
b/main/sc/source/ui/vba/vbaformatcondition.hxx
index 2ea2f63650..4d18c4617f 100644
--- a/main/sc/source/ui/vba/vbaformatcondition.hxx
+++ b/main/sc/source/ui/vba/vbaformatcondition.hxx
@@ -54,6 +54,8 @@ public:
        virtual ::sal_Int32 SAL_CALL Type(  );
        virtual ::sal_Int32 Operator( sal_Bool  );
        virtual ::sal_Int32 SAL_CALL Operator(  );
+       virtual rtl::OUString SAL_CALL Formula1(  );
+       virtual rtl::OUString SAL_CALL Formula2(  );
        virtual void setFormula1( const css::uno::Any& _aFormula1);
        virtual void setFormula2( const css::uno::Any& _aFormula2);
        virtual css::uno::Reference< ::ooo::vba::excel::XInterior > SAL_CALL 
Interior(  );
diff --git a/main/sc/source/ui/vba/vbaformatconditions.cxx 
b/main/sc/source/ui/vba/vbaformatconditions.cxx
index 135bf72fca..4a9ea499a9 100644
--- a/main/sc/source/ui/vba/vbaformatconditions.cxx
+++ b/main/sc/source/ui/vba/vbaformatconditions.cxx
@@ -292,5 +292,15 @@ ScVbaFormatConditions::getServiceNames()
                aServiceNames.realloc( 1 );
                aServiceNames[ 0 ] = rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.FormatConditions" ) );
        }
-       return aServiceNames;
+               return aServiceNames;
+}
+
+namespace formatconditions
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaFormatConditions, sdecl::with_args<true> > 
serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+    serviceImpl,
+    "ScVbaFormatConditions",
+    "ooo.vba.excel.FormatConditions" );
 }
diff --git a/main/sc/source/ui/vba/vbafoundfiles.cxx 
b/main/sc/source/ui/vba/vbafoundfiles.cxx
new file mode 100644
index 0000000000..9060aa1ceb
--- /dev/null
+++ b/main/sc/source/ui/vba/vbafoundfiles.cxx
@@ -0,0 +1,152 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the 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;
+}
+
+rtl::OUString SAL_CALL VbaFoundFiles::File( sal_Int32 nIndex )
+    throw ( css::uno::RuntimeException )
+{
+    return m_xIndexAccess->getByIndex( nIndex - 1 ).get< rtl::OUString >();
+}
+
+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;
+}
+
+namespace foundfiles
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<VbaFoundFiles, sdecl::with_args<true> > serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+    serviceImpl,
+    "VbaFoundFiles",
+    "ooo.vba.FoundFiles" );
+}
diff --git a/main/sc/source/ui/vba/vbafoundfiles.hxx 
b/main/sc/source/ui/vba/vbafoundfiles.hxx
new file mode 100644
index 0000000000..dc6c48560c
--- /dev/null
+++ b/main/sc/source/ui/vba/vbafoundfiles.hxx
@@ -0,0 +1,84 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the 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:
+    css::uno::Sequence< rtl::OUString > m_sFileList;
+    sal_Int32 m_nIndex;
+
+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 
);
+
+    // XFoundFiles
+    virtual rtl::OUString SAL_CALL File( sal_Int32 nIndex ) 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 );
+
+    // XHelperInterface
+    virtual rtl::OUString& getServiceImplName();
+    virtual css::uno::Sequence< rtl::OUString > getServiceNames();
+};
+
+#endif
\ No newline at end of file
diff --git a/main/sc/source/ui/vba/vbaquerytable.cxx 
b/main/sc/source/ui/vba/vbaquerytable.cxx
new file mode 100644
index 0000000000..cdf43a65a3
--- /dev/null
+++ b/main/sc/source/ui/vba/vbaquerytable.cxx
@@ -0,0 +1,116 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "vbaquerytable.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "scaddress.hxx"
+#include "scrange.hxx"
+#include <tools/rtti.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <sfx2/lnkbase.hxx>
+#include "arealink.hxx"
+#include "vbarange.hxx"
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+ScVbaQueryTable::ScVbaQueryTable( const css::uno::Reference< 
ov::XHelperInterface >& xParent,
+            const css::uno::Reference< css::uno::XComponentContext >& xContext,
+            ScDocument* pDocument,
+            ScVbaRange* pParent
+            )
+:      ScVbaQueryTableImpl_BASE( xParent, xContext ),
+    m_pDocument( pDocument ),
+    m_pParent( pParent )
+{
+}
+
+ScVbaQueryTable::~ScVbaQueryTable()
+{
+}
+
+sal_Bool SAL_CALL
+ScVbaQueryTable::Refresh( const css::uno::Any& aBackgroundQuery ) throw ( 
css::uno::RuntimeException )
+{
+    if ( !m_pParent || !m_pDocument )
+        return sal_False;
+
+    // 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 begins from 1.
+    ScAddress crrRngAddr( nClm, nRow, nTab );
+
+    // Get link info
+    sfx2::LinkManager* pLinkMng = m_pDocument->GetLinkManager();
+    const SvBaseLinks& rLinks = pLinkMng->GetLinks();
+    sal_uInt16 nCount = rLinks.Count();
+
+    for ( sal_uInt16 i = 0; i < nCount; ++i )
+    {
+        SvBaseLink* pBase = *rLinks[i];
+        if ( pBase->ISA( ScAreaLink ) )
+        {
+            ScAreaLink* pAreaLink = static_cast< ScAreaLink* >( pBase );
+            const ScRange& destRange = pAreaLink->GetDestArea();
+            if ( destRange.In( crrRngAddr ) )
+            {
+                pBase->Update();
+            }
+        }
+    }
+
+    return sal_True;
+}
+
+void SAL_CALL
+ScVbaQueryTable::Delete() throw ( css::uno::RuntimeException )
+{
+    // TODO: Implement Delete method
+}
+
+rtl::OUString& ScVbaQueryTable::getServiceImplName()
+{
+    static rtl::OUString sImplName( 
RTL_CONSTASCII_USTRINGPARAM("ScVbaQueryTable") );
+    return sImplName;
+}
+
+css::uno::Sequence< rtl::OUString > ScVbaQueryTable::getServiceNames()
+{
+    static css::uno::Sequence< rtl::OUString > aServiceNames;
+    if ( aServiceNames.getLength() == 0 )
+    {
+        aServiceNames.realloc( 1 );
+        aServiceNames[ 0 ] = rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.QueryTable") );
+    }
+    return aServiceNames;
+}
+
+namespace querytable
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaQueryTable, sdecl::with_args<true> > 
serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+    serviceImpl,
+    "ScVbaQueryTable",
+    "ooo.vba.excel.QueryTable" );
+}
diff --git a/main/sc/source/ui/vba/vbaquerytable.hxx 
b/main/sc/source/ui/vba/vbaquerytable.hxx
new file mode 100644
index 0000000000..5d7ab7ddce
--- /dev/null
+++ b/main/sc/source/ui/vba/vbaquerytable.hxx
@@ -0,0 +1,55 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef SC_VBA_QUERYTABLE_HXX
+#define SC_VBA_QUERYTABLE_HXX
+
+#include <ooo/vba/excel/XQueryTable.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+namespace css = ::com::sun::star;
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::excel::XQueryTable > 
ScVbaQueryTableImpl_BASE;
+
+class ScDocument;
+class ScVbaRange;
+
+class ScVbaQueryTable : public ScVbaQueryTableImpl_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 );
+    virtual ~ScVbaQueryTable();
+
+    virtual sal_Bool SAL_CALL Refresh( const css::uno::Any& aBackgroundQuery )
+        throw ( css::uno::RuntimeException );
+    virtual void SAL_CALL Delete() throw ( css::uno::RuntimeException );
+
+    virtual rtl::OUString& getServiceImplName();
+    virtual css::uno::Sequence< rtl::OUString > getServiceNames();
+};
+
+#endif
\ No newline at end of file
diff --git a/main/sc/source/ui/vba/vbarange.cxx 
b/main/sc/source/ui/vba/vbarange.cxx
index 33726b2cb5..93a4d59b83 100644
--- a/main/sc/source/ui/vba/vbarange.cxx
+++ b/main/sc/source/ui/vba/vbarange.cxx
@@ -146,6 +146,8 @@
 #include "vbaworksheet.hxx"
 #include "vbavalidation.hxx"
 #include "vbahyperlinks.hxx"
+#include "vbaquerytable.hxx"
+#include "vbaformatconditions.hxx"
 
 #include "tabvwsh.hxx"
 #include "rangelst.hxx"
@@ -2133,7 +2135,32 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const 
uno::Any &nColumnIndex )
 
     // Performance: Use a common helper method for ScVbaRange::Cells and 
ScVbaWorksheet::Cells,
     // instead of creating a new ScVbaRange object in often-called 
ScVbaWorksheet::Cells
-    return CellsHelper( mxParent, mxContext, mxRange, nRowIndex, nColumnIndex 
);
+        return CellsHelper( mxParent, mxContext, mxRange, nRowIndex, 
nColumnIndex );
+}
+
+uno::Reference< ooo::vba::excel::XQueryTable >
+ScVbaRange::getQueryTable()
+{
+    // Return an instance of the QueryTable associated with this range
+    // The ScVbaQueryTable constructor takes parent, context, document, and 
range pointer
+    ScDocument* pDocument = getScDocument();
+    uno::Reference< ooo::vba::excel::XQueryTable > xQueryTable(
+        new ScVbaQueryTable( mxParent, mxContext, pDocument, this ) );
+    return xQueryTable;
+}
+
+uno::Reference< ooo::vba::excel::XFormatConditions >
+ScVbaRange::getFormatConditions()
+{
+    uno::Reference< beans::XPropertySet > xProps( mxRange, 
uno::UNO_QUERY_THROW );
+    uno::Reference< css::sheet::XSheetConditionalEntries > xEntries(
+        xProps->getPropertyValue(
+            rtl::OUString::createFromAscii( "ConditionalFormat" ) ),
+        uno::UNO_QUERY );
+    uno::Reference< frame::XModel > xModel( getUnoModel() );
+    uno::Reference< ooo::vba::excel::XFormatConditions > xFormatConditions(
+        new ScVbaFormatConditions( mxParent, mxContext, xEntries, xModel ) );
+    return xFormatConditions;
 }
 
 // static
diff --git a/main/sc/source/ui/vba/vbarange.hxx 
b/main/sc/source/ui/vba/vbarange.hxx
index d6590bc386..1a1dc71b90 100644
--- a/main/sc/source/ui/vba/vbarange.hxx
+++ b/main/sc/source/ui/vba/vbarange.hxx
@@ -27,6 +27,8 @@
 #include <com/sun/star/container/XEnumerationAccess.hpp>
 
 #include <ooo/vba/excel/XRange.hpp>
+#include <ooo/vba/excel/XQueryTable.hpp>
+#include <ooo/vba/excel/XFormatConditions.hpp>
 #include <com/sun/star/table/XCellRange.hpp>
 #include <ooo/vba/excel/XFont.hpp>
 #include <ooo/vba/excel/XComment.hpp>
@@ -266,6 +268,8 @@ public:
        virtual void SAL_CALL UnMerge(  );
        virtual css::uno::Any SAL_CALL getStyle();
        virtual void SAL_CALL setStyle( const css::uno::Any& _style );
+       virtual css::uno::Reference< ooo::vba::excel::XFormatConditions > 
SAL_CALL getFormatConditions();
+       virtual css::uno::Reference< ooo::vba::excel::XQueryTable > SAL_CALL 
getQueryTable();
        virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Next();
        virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Previous();
        virtual void SAL_CALL RemoveSubtotal(  );
diff --git a/main/sc/source/ui/vba/vbaworkbook.cxx 
b/main/sc/source/ui/vba/vbaworkbook.cxx
index 45177f2a77..fb606bef8b 100644
--- a/main/sc/source/ui/vba/vbaworkbook.cxx
+++ b/main/sc/source/ui/vba/vbaworkbook.cxx
@@ -293,6 +293,41 @@ ScVbaWorkbook::SaveCopyAs( const rtl::OUString& sFileName )
        xStor->storeToURL( aURL, storeProps );
 }
 
+void SAL_CALL
+ScVbaWorkbook::SaveAs( const css::uno::Any& FileName, const css::uno::Any& 
FileFormat, const css::uno::Any& Password, const css::uno::Any& 
WriteResPassword, const css::uno::Any& ReadOnlyRecommended, const 
css::uno::Any& /*CreateBackup*/ )
+{
+    rtl::OUString aFileName;
+    sal_Bool bHasFileName = ( FileName >>= aFileName );
+    if ( !bHasFileName )
+    {
+        aFileName = getName();
+    }
+    rtl::OUString aURL;
+    osl::FileBase::getFileURLFromSystemPath( aFileName, aURL );
+    uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW 
);
+
+    sal_Int32 aFileFormat = excel::XlFileFormat::xlExcel9795;
+    if ( FileFormat.hasValue() )
+        FileFormat >>= aFileFormat;
+
+    if ( aFileName.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 <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MS 
Excel 97" ) );
+    xStor->storeAsURL( aURL, storeProps );
+}
+
 css::uno::Any SAL_CALL
 ScVbaWorkbook::Styles( const uno::Any& Item )
 {
diff --git a/main/sc/source/ui/vba/vbaworkbook.hxx 
b/main/sc/source/ui/vba/vbaworkbook.hxx
index e72b518f53..12d7de3c61 100644
--- a/main/sc/source/ui/vba/vbaworkbook.hxx
+++ b/main/sc/source/ui/vba/vbaworkbook.hxx
@@ -65,6 +65,7 @@ public:
        virtual css::uno::Any SAL_CALL Colors( const css::uno::Any& Index );
        virtual ::sal_Int32 SAL_CALL FileFormat(  );
        virtual void SAL_CALL SaveCopyAs( const rtl::OUString& Filename );
+       virtual void SAL_CALL SaveAs( const css::uno::Any& FileName, const 
css::uno::Any& FileFormat, const css::uno::Any& Password, const css::uno::Any& 
WriteResPassword, const css::uno::Any& ReadOnlyRecommended, const 
css::uno::Any& CreateBackup );
     // code name
     virtual ::rtl::OUString SAL_CALL getCodeName();
 

Reply via email to