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 
23 
24 #ifndef BASCTL_DOCUMENTENUMERATION_HXX
25 #define BASCTL_DOCUMENTENUMERATION_HXX
26 
27 /** === begin UNO includes === **/
28 #include <com/sun/star/frame/XModel.hpp>
29 #include <com/sun/star/frame/XController.hpp>
30 /** === end UNO includes === **/
31 
32 #include <comphelper/componentcontext.hxx>
33 
34 #include <memory>
35 #include <vector>
36 
37 //........................................................................
38 namespace basctl { namespace docs {
39 //........................................................................
40 
41     typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >                         Model;
42     typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > >   Controllers;
43 
44     struct DocumentDescriptor
45     {
46         Model       xModel;
47         Controllers aControllers;
48     };
49 
50     typedef ::std::vector< DocumentDescriptor > Documents;
51 
52 	//====================================================================
53 	//= IDocumentDescriptorFilter
54 	//====================================================================
55     /// allows pre-filtering when enumerating document descriptors
56     class SAL_NO_VTABLE IDocumentDescriptorFilter
57     {
58     public:
59         virtual bool    includeDocument( const DocumentDescriptor& _rDocument ) const = 0;
60     };
61 
62 	//====================================================================
63 	//= DocumentEnumeration
64 	//====================================================================
65     struct DocumentEnumeration_Data;
66     /** is a helper class for enumerating documents in OOo
67 
68         If you need a list of all open documents in OOo, this is little bit of
69         a hassle: You need to iterate though all components at the desktop, which
70         might or might not be documents.
71 
72         Additionally, you need to examine the existing documents' frames
73         for sub frames, which might contain sub documents (e.g. embedded objects
74         edited out-place).
75 
76         DocumentEnumeration relieves you from this hassle.
77     */
78 	class DocumentEnumeration
79 	{
80     public:
81         DocumentEnumeration( const ::comphelper::ComponentContext& _rContext, const IDocumentDescriptorFilter* _pFilter = NULL );
82         ~DocumentEnumeration();
83 
84         /** retrieves a list of all currently known documents in the application
85 
86             @param _out_rDocuments
87                 output parameter taking the collected document information
88             @
89         */
90         void    getDocuments(
91             Documents& _out_rDocuments
92         ) const;
93 
94     private:
95         ::std::auto_ptr< DocumentEnumeration_Data > m_pData;
96 	};
97 
98 //........................................................................
99 } } // namespace basctl::docs
100 //........................................................................
101 
102 #endif // BASCTL_DOCUMENTENUMERATION_HXX
103