Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef BASCTL_DOCUMENTENUMERATION_HXX
21 : #define BASCTL_DOCUMENTENUMERATION_HXX
22 :
23 : #include <boost/scoped_ptr.hpp>
24 : #include <com/sun/star/frame/XModel.hpp>
25 : #include <com/sun/star/frame/XController.hpp>
26 : #include <com/sun/star/uno/Reference.hxx>
27 :
28 : #include <vector>
29 :
30 : namespace com { namespace sun { namespace star { namespace uno {
31 : class XComponentContext;
32 : } } } }
33 :
34 :
35 : namespace basctl { namespace docs {
36 :
37 :
38 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > Model;
39 : typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > > Controllers;
40 :
41 0 : struct DocumentDescriptor
42 : {
43 : Model xModel;
44 : Controllers aControllers;
45 : };
46 :
47 : typedef ::std::vector< DocumentDescriptor > Documents;
48 :
49 :
50 : //= IDocumentDescriptorFilter
51 :
52 : /// allows pre-filtering when enumerating document descriptors
53 0 : class SAL_NO_VTABLE IDocumentDescriptorFilter
54 : {
55 : public:
56 : virtual bool includeDocument( const DocumentDescriptor& _rDocument ) const = 0;
57 :
58 : protected:
59 0 : ~IDocumentDescriptorFilter() {}
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( com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & _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 : boost::scoped_ptr< DocumentEnumeration_Data > m_pData;
96 : };
97 :
98 :
99 : } } // namespace basctl::docs
100 :
101 :
102 : #endif // BASCTL_DOCUMENTENUMERATION_HXX
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|