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_FILESEARCH_HXX 23 #define SC_VBA_FILESEARCH_HXX 24 25 #include <ooo/vba/XFileSearch.hpp> 26 #include <cppuhelper/implbase1.hxx> 27 #include <vbahelper/vbahelperinterface.hxx> 28 #include <com/sun/star/uno/Sequence.hxx> 29 30 namespace css = ::com::sun::star; 31 32 typedef InheritedHelperInterfaceImpl1< ooo::vba::XFileSearch > ScVbaFileSearchImpl_BASE; 33 34 class ScVbaApplication; 35 36 // MS Excel VBA: Object used to search for files on the filesystem. 37 // Status: implemented - wraps sc/search results into FoundFiles collection 38 class ScVbaFileSearch : public ScVbaFileSearchImpl_BASE 39 { 40 private: 41 rtl::OUString m_sFileName; 42 rtl::OUString m_sLookIn; 43 sal_Bool m_bSearchSubFolders; 44 sal_Bool m_bMatchTextExactly; 45 ScVbaApplication* m_pApplication; 46 css::uno::Sequence< rtl::OUString > m_aSearchedFiles; 47 48 // MS Excel VBA: Returns the default search directory path. 49 // Status: implemented - falls back to Application.DefaultFilePath 50 ::rtl::OUString getInitPath() throw (css::uno::RuntimeException); 51 52 public: 53 // MS Excel VBA: Constructs FileSearch with application, parent, and context. 54 // Status: implemented 55 ScVbaFileSearch( ScVbaApplication* pApp, const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ); 56 // MS Excel VBA: Factory constructor for service instantiation. 57 // Status: implemented 58 ScVbaFileSearch( const css::uno::Sequence< css::uno::Any >& /*args*/, const css::uno::Reference< css::uno::XComponentContext >& xContext ); 59 // MS Excel VBA: Destructor. 60 // Status: implemented 61 virtual ~ScVbaFileSearch(); 62 63 // Attributes 64 // MS Excel VBA: Gets/sets the file name criteria for the search. 65 // Status: implemented 66 virtual ::rtl::OUString SAL_CALL getFileName() throw (css::uno::RuntimeException); 67 virtual void SAL_CALL setFileName( const ::rtl::OUString& _fileName ) throw (css::uno::RuntimeException); 68 // MS Excel VBA: Gets/sets the folder path to search in. 69 // Status: implemented 70 virtual ::rtl::OUString SAL_CALL getLookIn() throw (css::uno::RuntimeException); 71 virtual void SAL_CALL setLookIn( const ::rtl::OUString& _lookIn ) throw (css::uno::RuntimeException); 72 // MS Excel VBA: Gets/sets whether to search subfolders. 73 // Status: implemented 74 virtual sal_Bool SAL_CALL getSearchSubFolders() throw (css::uno::RuntimeException); 75 virtual void SAL_CALL setSearchSubFolders( sal_Bool _searchSubFolders ) throw (css::uno::RuntimeException); 76 // MS Excel VBA: Gets/sets whether to match file text exactly. 77 // Status: implemented 78 virtual sal_Bool SAL_CALL getMatchTextExactly() throw (css::uno::RuntimeException); 79 virtual void SAL_CALL setMatchTextExactly( sal_Bool _matchTextExactly ) throw (css::uno::RuntimeException); 80 // MS Excel VBA: Returns FoundFiles collection with all matching files. 81 // Status: implemented - returns VbaFoundFiles enum 82 virtual css::uno::Reference< ::ooo::vba::XFoundFiles > SAL_CALL getFoundFiles() throw (css::uno::RuntimeException); 83 84 // MS Excel VBA: Executes the file search and returns the number of results. 85 // Status: implemented - delegates to SearchFiles BASIC function 86 virtual sal_Int32 SAL_CALL Execute() throw (css::uno::RuntimeException); 87 // MS Excel VBA: Clears all search criteria and results. 88 // Status: implemented 89 virtual void SAL_CALL NewSearch() throw (css::uno::RuntimeException); 90 91 // XHelperInterface 92 // MS Excel VBA: Returns the implementation name for UNO service identification. 93 // Status: implemented - returns "ScVbaFileSearch" 94 virtual rtl::OUString& getServiceImplName(); 95 // MS Excel VBA: Returns the service names this implementation supports. 96 // Status: implemented - returns "ooo.vba.excel.FileSearch" 97 virtual css::uno::Sequence< rtl::OUString > getServiceNames(); 98 }; 99 100 #endif 101