1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef BASCTL_DOCUMENTENUMERATION_HXX 29 #define BASCTL_DOCUMENTENUMERATION_HXX 30 31 /** === begin UNO includes === **/ 32 #include <com/sun/star/frame/XModel.hpp> 33 #include <com/sun/star/frame/XController.hpp> 34 /** === end UNO includes === **/ 35 36 #include <comphelper/componentcontext.hxx> 37 38 #include <memory> 39 #include <vector> 40 41 //........................................................................ 42 namespace basctl { namespace docs { 43 //........................................................................ 44 45 typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > Model; 46 typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > > Controllers; 47 48 struct DocumentDescriptor 49 { 50 Model xModel; 51 Controllers aControllers; 52 }; 53 54 typedef ::std::vector< DocumentDescriptor > Documents; 55 56 //==================================================================== 57 //= IDocumentDescriptorFilter 58 //==================================================================== 59 /// allows pre-filtering when enumerating document descriptors 60 class SAL_NO_VTABLE IDocumentDescriptorFilter 61 { 62 public: 63 virtual bool includeDocument( const DocumentDescriptor& _rDocument ) const = 0; 64 }; 65 66 //==================================================================== 67 //= DocumentEnumeration 68 //==================================================================== 69 struct DocumentEnumeration_Data; 70 /** is a helper class for enumerating documents in OOo 71 72 If you need a list of all open documents in OOo, this is little bit of 73 a hassle: You need to iterate though all components at the desktop, which 74 might or might not be documents. 75 76 Additionally, you need to examine the existing documents' frames 77 for sub frames, which might contain sub documents (e.g. embedded objects 78 edited out-place). 79 80 DocumentEnumeration relieves you from this hassle. 81 */ 82 class DocumentEnumeration 83 { 84 public: 85 DocumentEnumeration( const ::comphelper::ComponentContext& _rContext, const IDocumentDescriptorFilter* _pFilter = NULL ); 86 ~DocumentEnumeration(); 87 88 /** retrieves a list of all currently known documents in the application 89 90 @param _out_rDocuments 91 output parameter taking the collected document information 92 @ 93 */ 94 void getDocuments( 95 Documents& _out_rDocuments 96 ) const; 97 98 private: 99 ::std::auto_ptr< DocumentEnumeration_Data > m_pData; 100 }; 101 102 //........................................................................ 103 } } // namespace basctl::docs 104 //........................................................................ 105 106 #endif // BASCTL_DOCUMENTENUMERATION_HXX 107