1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #ifndef SC_VBA_FOUNDFILES_HXX 23 #define SC_VBA_FOUNDFILES_HXX 24 25 #include <cppuhelper/implbase2.hxx> 26 #include <com/sun/star/container/XIndexAccess.hpp> 27 #include <ooo/vba/XFoundFiles.hpp> 28 #include <vbahelper/vbacollectionimpl.hxx> 29 30 namespace css = ::com::sun::star; 31 32 typedef CollTestImplHelper< ooo::vba::XFoundFiles > VbaFoundFilesImpl_BASE; 33 34 class VbaFoundFilesEnum : public cppu::WeakImplHelper2< css::container::XIndexAccess, css::container::XEnumeration > 35 { 36 private: 37 css::uno::Sequence< rtl::OUString > m_sFileList; 38 sal_Int32 m_nIndex; 39 40 public: 41 VbaFoundFilesEnum(); 42 VbaFoundFilesEnum( css::uno::Sequence< rtl::OUString >& sFileList ); 43 ~VbaFoundFilesEnum(); 44 45 void SetFileList( css::uno::Sequence< rtl::OUString >& sFileList ); 46 47 // XIndexAccess 48 virtual sal_Int32 SAL_CALL getCount() throw ( css::uno::RuntimeException ); 49 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw ( css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException ); 50 51 // XElementAccess 52 virtual css::uno::Type SAL_CALL getElementType() throw ( css::uno::RuntimeException ); 53 virtual sal_Bool SAL_CALL hasElements() throw ( css::uno::RuntimeException ); 54 55 // XEnumeration 56 virtual sal_Bool SAL_CALL hasMoreElements() throw ( css::uno::RuntimeException ); 57 virtual css::uno::Any SAL_CALL nextElement() throw ( css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException ); 58 }; 59 60 // MS Excel VBA: Collection of file paths returned by FileSearch.Execute. 61 // Status: implemented - wraps a sequence of OUString file paths 62 class VbaFoundFiles : public VbaFoundFilesImpl_BASE 63 { 64 private: 65 66 public: 67 // MS Excel VBA: Constructs FoundFiles with parent, context, and file list. 68 // Status: implemented 69 VbaFoundFiles( const css::uno::Reference< ov::XHelperInterface >& xParent, 70 const css::uno::Reference< css::uno::XComponentContext >& xContext, 71 const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ); 72 // MS Excel VBA: Factory constructor for service instantiation. 73 // Status: implemented 74 VbaFoundFiles( const css::uno::Sequence< css::uno::Any >& args, 75 const css::uno::Reference< css::uno::XComponentContext >& xContext ); 76 // MS Excel VBA: Destructor. 77 // Status: implemented 78 virtual ~VbaFoundFiles(); 79 80 // MS Excel VBA: Creates a collection object from a source Any. 81 // Status: implemented 82 virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); 83 84 // XFoundFiles 85 // MS Excel VBA: Returns the file path at the specified index (1-based). 86 // Status: implemented - validates index and throws IndexOutOfBoundsException if out of range 87 virtual rtl::OUString SAL_CALL File( sal_Int32 nIndex ) throw ( css::uno::RuntimeException ); 88 89 // XEnumerationAccess 90 // MS Excel VBA: Returns the type of objects in this collection. 91 // Status: implemented - returns XFoundFiles 92 virtual css::uno::Type SAL_CALL getElementType() throw ( css::uno::RuntimeException ); 93 // MS Excel VBA: Creates an enumeration for iterating the collection. 94 // Status: implemented 95 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw ( css::uno::RuntimeException ); 96 97 // XHelperInterface 98 // MS Excel VBA: Returns the implementation name for UNO service identification. 99 // Status: implemented - returns "VbaFoundFiles" 100 virtual rtl::OUString& getServiceImplName(); 101 // MS Excel VBA: Returns the service names this implementation supports. 102 // Status: implemented - returns "ooo.vba.excel.FoundFiles" 103 virtual css::uno::Sequence< rtl::OUString > getServiceNames(); 104 }; 105 106 #endif 107