1*96821c26SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96821c26SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96821c26SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96821c26SAndrew Rist  * distributed with this work for additional information
6*96821c26SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96821c26SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96821c26SAndrew Rist  * "License"); you may not use this file except in compliance
9*96821c26SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96821c26SAndrew Rist  *
11*96821c26SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96821c26SAndrew Rist  *
13*96821c26SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96821c26SAndrew Rist  * software distributed under the License is distributed on an
15*96821c26SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96821c26SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96821c26SAndrew Rist  * specific language governing permissions and limitations
18*96821c26SAndrew Rist  * under the License.
19*96821c26SAndrew Rist  *
20*96821c26SAndrew Rist  *************************************************************/
21*96821c26SAndrew Rist 
22*96821c26SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef BASCTL_DOCUMENTENUMERATION_HXX
25cdf0e10cSrcweir #define BASCTL_DOCUMENTENUMERATION_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir /** === begin UNO includes === **/
28cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
29cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
30cdf0e10cSrcweir /** === end UNO includes === **/
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <comphelper/componentcontext.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <memory>
35cdf0e10cSrcweir #include <vector>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //........................................................................
38cdf0e10cSrcweir namespace basctl { namespace docs {
39cdf0e10cSrcweir //........................................................................
40cdf0e10cSrcweir 
41cdf0e10cSrcweir     typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >                         Model;
42cdf0e10cSrcweir     typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > >   Controllers;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir     struct DocumentDescriptor
45cdf0e10cSrcweir     {
46cdf0e10cSrcweir         Model       xModel;
47cdf0e10cSrcweir         Controllers aControllers;
48cdf0e10cSrcweir     };
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     typedef ::std::vector< DocumentDescriptor > Documents;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 	//====================================================================
53cdf0e10cSrcweir 	//= IDocumentDescriptorFilter
54cdf0e10cSrcweir 	//====================================================================
55cdf0e10cSrcweir     /// allows pre-filtering when enumerating document descriptors
56cdf0e10cSrcweir     class SAL_NO_VTABLE IDocumentDescriptorFilter
57cdf0e10cSrcweir     {
58cdf0e10cSrcweir     public:
59cdf0e10cSrcweir         virtual bool    includeDocument( const DocumentDescriptor& _rDocument ) const = 0;
60cdf0e10cSrcweir     };
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	//====================================================================
63cdf0e10cSrcweir 	//= DocumentEnumeration
64cdf0e10cSrcweir 	//====================================================================
65cdf0e10cSrcweir     struct DocumentEnumeration_Data;
66cdf0e10cSrcweir     /** is a helper class for enumerating documents in OOo
67cdf0e10cSrcweir 
68cdf0e10cSrcweir         If you need a list of all open documents in OOo, this is little bit of
69cdf0e10cSrcweir         a hassle: You need to iterate though all components at the desktop, which
70cdf0e10cSrcweir         might or might not be documents.
71cdf0e10cSrcweir 
72cdf0e10cSrcweir         Additionally, you need to examine the existing documents' frames
73cdf0e10cSrcweir         for sub frames, which might contain sub documents (e.g. embedded objects
74cdf0e10cSrcweir         edited out-place).
75cdf0e10cSrcweir 
76cdf0e10cSrcweir         DocumentEnumeration relieves you from this hassle.
77cdf0e10cSrcweir     */
78cdf0e10cSrcweir 	class DocumentEnumeration
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir     public:
81cdf0e10cSrcweir         DocumentEnumeration( const ::comphelper::ComponentContext& _rContext, const IDocumentDescriptorFilter* _pFilter = NULL );
82cdf0e10cSrcweir         ~DocumentEnumeration();
83cdf0e10cSrcweir 
84cdf0e10cSrcweir         /** retrieves a list of all currently known documents in the application
85cdf0e10cSrcweir 
86cdf0e10cSrcweir             @param _out_rDocuments
87cdf0e10cSrcweir                 output parameter taking the collected document information
88cdf0e10cSrcweir             @
89cdf0e10cSrcweir         */
90cdf0e10cSrcweir         void    getDocuments(
91cdf0e10cSrcweir             Documents& _out_rDocuments
92cdf0e10cSrcweir         ) const;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     private:
95cdf0e10cSrcweir         ::std::auto_ptr< DocumentEnumeration_Data > m_pData;
96cdf0e10cSrcweir 	};
97cdf0e10cSrcweir 
98cdf0e10cSrcweir //........................................................................
99cdf0e10cSrcweir } } // namespace basctl::docs
100cdf0e10cSrcweir //........................................................................
101cdf0e10cSrcweir 
102cdf0e10cSrcweir #endif // BASCTL_DOCUMENTENUMERATION_HXX
103