[Libreoffice-commits] core.git: oovbaapi/ooo oovbaapi/UnoApi_oovbaapi.mk sc/Library_vbaobj.mk sc/source

Tamas Bunth tamas.bunth at collabora.co.uk
Fri Jul 14 21:25:17 UTC 2017


 oovbaapi/UnoApi_oovbaapi.mk                         |    2 
 oovbaapi/ooo/vba/excel/XApplication.idl             |    2 
 oovbaapi/ooo/vba/excel/XFileDialog.idl              |   49 ++++++
 oovbaapi/ooo/vba/excel/XFileDialogSelectedItems.idl |   42 +++++
 sc/Library_vbaobj.mk                                |    2 
 sc/source/ui/vba/vbaapplication.cxx                 |   16 ++
 sc/source/ui/vba/vbaapplication.hxx                 |    6 
 sc/source/ui/vba/vbafiledialog.cxx                  |  141 ++++++++++++++++++++
 sc/source/ui/vba/vbafiledialog.hxx                  |   56 +++++++
 sc/source/ui/vba/vbafiledialogitems.cxx             |  119 ++++++++++++++++
 sc/source/ui/vba/vbafiledialogitems.hxx             |   42 +++++
 11 files changed, 476 insertions(+), 1 deletion(-)

New commits:
commit 07fb14be7f79cbbf65f47458b7b2337c8ffcc4f7
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
Date:   Tue Jul 11 12:22:06 2017 +0200

    implement Application.FileDialog attribute
    
    Documentation:
    https://msdn.microsoft.com/en-us/vba/excel-vba/articles/application-filedialog-property-excel
    https://msdn.microsoft.com/VBA/Office-Shared-VBA/articles/filedialog-object-office
    
    Using FilePicker and FolderPicker uno services.
    
    Change-Id: Ifd3b3fc9c135efb0663d2ef36ecbe2b2fbe6132f
    Reviewed-on: https://gerrit.libreoffice.org/39806
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Bunth <btomi96 at gmail.com>

diff --git a/oovbaapi/UnoApi_oovbaapi.mk b/oovbaapi/UnoApi_oovbaapi.mk
index bd883f05797a..d99d7c3772d9 100644
--- a/oovbaapi/UnoApi_oovbaapi.mk
+++ b/oovbaapi/UnoApi_oovbaapi.mk
@@ -233,6 +233,8 @@ $(eval $(call gb_UnoApi_add_idlfiles,oovbaapi,ooo/vba/excel,\
 	XDialog \
 	XDialogs \
 	XDrawings \
+	XFileDialog \
+	XFileDialogSelectedItems \
 	XFont \
 	XFormat \
 	XFormatCondition \
diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl
index 153ed8bfc952..e08627651507 100644
--- a/oovbaapi/ooo/vba/excel/XApplication.idl
+++ b/oovbaapi/ooo/vba/excel/XApplication.idl
@@ -23,6 +23,7 @@
 #include <com/sun/star/script/XInvocation.idl>
 #include <ooo/vba/XHelperInterface.idl>
 #include <ooo/vba/XAssistant.idl>
+#include <ooo/vba/XFileDialog.idl>
 
 module ooo {  module vba {  module excel {
 
@@ -83,6 +84,7 @@ interface XApplication
     any Range( [in] any Cell1, [in] any Cell2 );
     any Names( [in] any Index );
     void GoTo( [in] any Reference, [in] any Scroll );
+    any FileDialog( [in] any DialogType );
 
     void wait( [in] double time );
     void Calculate() raises(com::sun::star::script::BasicErrorException);
diff --git a/oovbaapi/ooo/vba/excel/XFileDialog.idl b/oovbaapi/ooo/vba/excel/XFileDialog.idl
new file mode 100644
index 000000000000..e73813e53807
--- /dev/null
+++ b/oovbaapi/ooo/vba/excel/XFileDialog.idl
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   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 .
+ */
+#ifndef __ooo_vba_excel_XFileDialog_idl__
+#define __ooo_vba_excel_XFileDialog_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+
+#include <ooo/vba/XFileDialogSelectedItems.idl>
+
+
+module ooo {  module vba {  module excel  {
+
+
+
+interface XFileDialog
+{
+    interface ::ooo::vba::XHelperInterface;
+
+    [attribute]  any  InitialFileName;
+    [attribute]  any  Title;
+    [attribute, readonly]  XFileDialogSelectedItems  SelectedItems;
+
+    long Show();
+};
+
+
+
+}; }; };
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oovbaapi/ooo/vba/excel/XFileDialogSelectedItems.idl b/oovbaapi/ooo/vba/excel/XFileDialogSelectedItems.idl
new file mode 100644
index 000000000000..59370cbf89d2
--- /dev/null
+++ b/oovbaapi/ooo/vba/excel/XFileDialogSelectedItems.idl
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   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 .
+ */
+#ifndef __ooo_vba_excel_XFileDialogSelectedItems_idl__
+#define __ooo_vba_excel_XFileDialogSelectedItems_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <ooo/vba/XCollection.idl>
+
+
+module ooo {  module vba {  module excel  {
+
+
+
+interface XFileDialogSelectedItems
+{
+    interface XCollection;
+};
+
+
+
+}; }; };
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/Library_vbaobj.mk b/sc/Library_vbaobj.mk
index 36b4d7e39d91..2d04d28d5bb5 100644
--- a/sc/Library_vbaobj.mk
+++ b/sc/Library_vbaobj.mk
@@ -74,6 +74,8 @@ $(eval $(call gb_Library_add_exception_objects,vbaobj,\
 	sc/source/ui/vba/vbadialog \
 	sc/source/ui/vba/vbadialogs \
 	sc/source/ui/vba/vbaeventshelper \
+	sc/source/ui/vba/vbafiledialog \
+	sc/source/ui/vba/vbafiledialogitems \
 	sc/source/ui/vba/vbafont \
 	sc/source/ui/vba/vbaformat \
 	sc/source/ui/vba/vbaformatcondition \
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index f751ccff7f65..1805a3f950b1 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -55,6 +55,7 @@
 #include "sc.hrc"
 #include "macromgr.hxx"
 #include "defaultsoptions.hxx"
+#include "vbafiledialog.hxx"
 
 #include <osl/file.hxx>
 #include <rtl/instance.hxx>
@@ -126,7 +127,8 @@ struct ScVbaStaticAppSettings : public ::rtl::Static< ScVbaAppSettings, ScVbaSta
 
 ScVbaApplication::ScVbaApplication( const uno::Reference<uno::XComponentContext >& xContext ) :
     ScVbaApplication_BASE( xContext ),
-    mrAppSettings( ScVbaStaticAppSettings::get() )
+    mrAppSettings( ScVbaStaticAppSettings::get() ),
+    m_nDialogType(0)
 {
 }
 
@@ -313,6 +315,18 @@ ScVbaApplication::International( sal_Int32 /*Index*/ )
 }
 
 uno::Any SAL_CALL
+ScVbaApplication::FileDialog( const uno::Any& DialogType )
+{
+    sal_Int32 nType = 0;
+    DialogType >>= nType;
+
+    m_nDialogType = nType;
+    if( !m_xFileDialog || nType != m_nDialogType )
+        m_xFileDialog = uno::Reference<excel::XFileDialog> ( new ScVbaFileDialog( this, mxContext, nType ));
+    return uno::Any( m_xFileDialog );
+}
+
+uno::Any SAL_CALL
 ScVbaApplication::Workbooks( const uno::Any& aIndex )
 {
     uno::Reference< XCollection > xWorkBooks( new ScVbaWorkbooks( this, mxContext ) );
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
index 49180d214055..34d62b7b1f87 100644
--- a/sc/source/ui/vba/vbaapplication.hxx
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -21,6 +21,7 @@
 
 #include <ooo/vba/excel/XWorksheetFunction.hpp>
 #include <ooo/vba/excel/XApplication.hpp>
+#include <ooo/vba/excel/XFileDialog.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
 
 #include <vbahelper/vbahelperinterface.hxx>
@@ -37,6 +38,10 @@ private:
     // note: member variables moved to struct "ScVbaAppSettings", see cxx file, to be shared by all application instances
     ScVbaAppSettings& mrAppSettings;
 
+    // must be stored in order to get result paths from the same instance
+    css::uno::Reference< ov::excel::XFileDialog > m_xFileDialog;
+    sal_Int32 m_nDialogType;
+
     /// @throws css::uno::RuntimeException
     OUString getOfficePath( const OUString& sPath );
 
@@ -85,6 +90,7 @@ public:
     virtual css::uno::Reference< ov::XAssistant > SAL_CALL getAssistant() override;
     virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getThisWorkbook() override;
     virtual css::uno::Any SAL_CALL International( sal_Int32 Index ) override;
+    virtual css::uno::Any SAL_CALL FileDialog( const css::uno::Any& DialogType ) override;
     virtual css::uno::Any SAL_CALL Workbooks( const css::uno::Any& aIndex ) override;
     virtual css::uno::Any SAL_CALL Worksheets( const css::uno::Any& aIndex ) override;
     virtual css::uno::Any SAL_CALL WorksheetFunction( ) override;
diff --git a/sc/source/ui/vba/vbafiledialog.cxx b/sc/source/ui/vba/vbafiledialog.cxx
new file mode 100644
index 000000000000..1129953dff02
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialog.cxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   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 .
+ */
+
+#include "vbafiledialog.hxx"
+
+#include <ooo/vba/office/MsoFileDialogType.hpp>
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/ui/dialogs/FilePicker.hpp>
+#include <com/sun/star/ui/dialogs/FolderPicker.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+ScVbaFileDialog::ScVbaFileDialog( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const sal_Int32 nType )
+    : ScVbaFileDialog_BASE( xParent, xContext)
+    , m_nType(nType)
+    , m_sTitle("FileDialog")
+{}
+
+uno::Any
+ScVbaFileDialog::getInitialFileName() { return uno::makeAny( m_sInitialFileName ); }
+
+void ScVbaFileDialog::setInitialFileName( const css::uno::Any& rName )
+{
+    rName >>= m_sInitialFileName;
+}
+
+css::uno::Any ScVbaFileDialog::getTitle() { return uno::makeAny( m_sTitle ); }
+
+void ScVbaFileDialog::setTitle( const css::uno::Any& rTitle )
+{
+    rTitle >>= m_sTitle;
+}
+
+uno::Reference< excel::XFileDialogSelectedItems > SAL_CALL ScVbaFileDialog::getSelectedItems()
+{
+    // TODO use InitialFileName when m_xItems is empty
+    return m_xItems;
+}
+
+sal_Int32 ScVbaFileDialog::Show()
+{
+    std::vector<OUString> sSelectedPaths;
+    sal_Int32 nRet = -1;
+
+    switch (m_nType)
+    {
+        case office::MsoFileDialogType::msoFileDialogOpen:
+            // TODO implement
+            break;
+        case office::MsoFileDialogType::msoFileDialogSaveAs:
+            // TODO implement
+            break;
+        case office::MsoFileDialogType::msoFileDialogFilePicker:
+            {
+                uno::Reference<ui::dialogs::XFilePicker3> xFilePicker =
+                        ui::dialogs::FilePicker::createWithMode(
+                                mxContext, ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE );
+
+                // TODO set initial directory
+
+                if( xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
+                {
+                    nRet = 0; // cancel pressed
+                    break;
+                }
+
+                for( auto& sPath : xFilePicker->getSelectedFiles() )
+                {
+                    sSelectedPaths.push_back(sPath);
+                }
+            }
+            break;
+        case office::MsoFileDialogType::msoFileDialogFolderPicker:
+            {
+                uno::Reference< ui::dialogs::XFolderPicker2 > xFolderPicker =
+                        ui::dialogs::FolderPicker::create(mxContext);
+
+                // TODO set initial directory
+
+                if( xFolderPicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
+                {
+                    nRet = 0; // cancel pressed
+                    break;
+                }
+
+                OUString sPath = xFolderPicker->getDirectory();
+
+                if(!sPath.isEmpty())
+                    sSelectedPaths.push_back(sPath);
+
+            }
+            break;
+        default:
+            throw uno::RuntimeException();
+    }
+
+    m_xItems = css::uno::Reference< ov::excel::XFileDialogSelectedItems >(
+            new ScVbaFileDialogSelectedItems(this, mxContext, sSelectedPaths) );
+    return nRet;
+}
+
+// XHelperInterface
+OUString
+ScVbaFileDialog::getServiceImplName()
+{
+    return OUString("ScVbaFileDialog");
+}
+
+uno::Sequence<OUString>
+ScVbaFileDialog::getServiceNames()
+{
+    static uno::Sequence< OUString > aServiceNames;
+    if ( aServiceNames.getLength() == 0 )
+    {
+        aServiceNames.realloc( 1 );
+        aServiceNames[ 0 ] = "ooo.vba.FileDialog";
+    }
+    return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafiledialog.hxx b/sc/source/ui/vba/vbafiledialog.hxx
new file mode 100644
index 000000000000..202eefa020e0
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialog.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   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 .
+ */
+#ifndef INCLUDED_SC_SOURCE_UI_VBA_VBAFILEDIALOG_HXX
+#define INCLUDED_SC_SOURCE_UI_VBA_VBAFILEDIALOG_HXX
+
+#include <ooo/vba/excel/XFileDialog.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+#include "vbafiledialogitems.hxx"
+
+typedef InheritedHelperInterfaceWeakImpl< ov::excel::XFileDialog > ScVbaFileDialog_BASE;
+
+class ScVbaFileDialog : public ScVbaFileDialog_BASE
+{
+private:
+    sal_Int32 m_nType;
+    OUString m_sTitle;
+    OUString m_sInitialFileName;
+    css::uno::Reference< ov::excel::XFileDialogSelectedItems> m_xItems;
+public:
+    ScVbaFileDialog( const css::uno::Reference< ov::XHelperInterface >& xParent,  const css::uno::Reference< css::uno::XComponentContext >& xContext, const sal_Int32 nType);
+
+    virtual css::uno::Any SAL_CALL getInitialFileName() override;
+    virtual void SAL_CALL setInitialFileName( const css::uno::Any& rName ) override;
+    virtual css::uno::Any SAL_CALL getTitle() override;
+    virtual void SAL_CALL setTitle( const css::uno::Any& rTitle ) override;
+    virtual css::uno::Reference< ov::excel::XFileDialogSelectedItems > SAL_CALL getSelectedItems() override;
+
+    virtual sal_Int32 SAL_CALL Show() override;
+
+    //XHelperInterface
+    virtual OUString getServiceImplName() override;
+    virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafiledialogitems.cxx b/sc/source/ui/vba/vbafiledialogitems.cxx
new file mode 100644
index 000000000000..4e57a2e0d10a
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialogitems.cxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   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 .
+ */
+#include "vbafiledialogitems.hxx"
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+typedef std::vector< OUString > StringVector;
+
+class FileDialogItemEnumeration : public ::cppu::WeakImplHelper< container::XEnumeration >
+{
+    StringVector m_sItems;
+    StringVector::iterator mIt;
+public:
+    explicit FileDialogItemEnumeration( const StringVector& rVector ) : m_sItems( rVector ), mIt( m_sItems.begin() ) {}
+    virtual sal_Bool SAL_CALL hasMoreElements() override
+    {
+        return ( mIt != m_sItems.end() );
+    }
+    virtual uno::Any SAL_CALL nextElement() override
+    {
+        if( !hasMoreElements() )
+            throw container::NoSuchElementException();
+        OUString sPath = *mIt++;
+        return uno::makeAny( sPath );
+    }
+};
+
+ScVbaFileDialogSelectedItems::ScVbaFileDialogSelectedItems(
+        const css::uno::Reference< ov::XHelperInterface >& xParent
+       ,const css::uno::Reference< css::uno::XComponentContext >& xContext
+       ,const StringVector& rItems)
+    : FileDialogSelectedItems_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() )
+    , m_sItems(rItems) {}
+
+
+// XEnumerationAccess
+uno::Type SAL_CALL
+ScVbaFileDialogSelectedItems::getElementType()
+{
+    return cppu::UnoType<OUString>::get();
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaFileDialogSelectedItems::createEnumeration()
+{
+    return uno::Reference< container::XEnumeration >( new FileDialogItemEnumeration( m_sItems ) );
+}
+
+uno::Any
+ScVbaFileDialogSelectedItems::createCollectionObject( const uno::Any& aSource )
+{
+    sal_Int32 nPosition = -1;
+    aSource >>= nPosition;
+
+    OUString sPath = m_sItems[nPosition];
+    return uno::makeAny( sPath );
+}
+
+// Methods
+uno::Any SAL_CALL
+ScVbaFileDialogSelectedItems::Item( const uno::Any& aIndex, const uno::Any& /*aIndex*/ )
+{
+    sal_Int32 nPosition = -1;
+    aIndex >>= nPosition;
+
+    --nPosition; // vba indexing starts with 1
+
+    if( nPosition < 0 || nPosition >= getCount() )
+    {
+        throw uno::RuntimeException();
+    }
+
+    return createCollectionObject( uno::makeAny( nPosition ) );
+}
+
+sal_Int32 ScVbaFileDialogSelectedItems::getCount()
+{
+    return m_sItems.size();
+}
+
+// XHelperInterface
+OUString
+ScVbaFileDialogSelectedItems::getServiceImplName()
+{
+    return OUString("ScVbaFileDialogSelectedItems");
+}
+
+uno::Sequence<OUString>
+ScVbaFileDialogSelectedItems::getServiceNames()
+{
+    static uno::Sequence< OUString > aServiceNames;
+    if ( aServiceNames.getLength() == 0 )
+    {
+        aServiceNames.realloc( 1 );
+        aServiceNames[ 0 ] = "ooo.vba.FileDialogSelectedItems";
+    }
+    return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafiledialogitems.hxx b/sc/source/ui/vba/vbafiledialogitems.hxx
new file mode 100644
index 000000000000..3a789f886eb5
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialogitems.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#ifndef INCLUDED_SC_SOURCE_UI_VBA_VBAFILEDIALOGSELECTEDITEMS
+#define INCLUDED_SC_SOURCE_UI_VBA_VBAFILEDIALOGSELECTEDITEMS
+
+#include <ooo/vba//excel/XFileDialogSelectedItems.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <com/sun/star/container/XIndexAccess.hpp>
+
+typedef CollTestImplHelper< ov::excel::XFileDialogSelectedItems > FileDialogSelectedItems_BASE;
+
+class ScVbaFileDialogSelectedItems : public FileDialogSelectedItems_BASE
+{
+protected:
+    const std::vector<OUString> m_sItems;
+public:
+    ScVbaFileDialogSelectedItems( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const std::vector<OUString>& sItems);
+
+    // XEnumerationAccess
+    virtual css::uno::Type SAL_CALL getElementType() override;
+    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
+    virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) override;
+
+    // Methods
+    virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index, const css::uno::Any& /*Index2*/ ) override;
+    virtual sal_Int32 SAL_CALL getCount() override;
+
+    // XHelperInterface
+    virtual OUString getServiceImplName() override;
+    virtual css::uno::Sequence<OUString> getServiceNames() override;
+};
+
+#endif // INCLUDED_SC_SOURCE_UI_VBA_VBAFILEDIALOGSELECTEDITEMS
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list