fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / ucb / source / ucp / tdoc / tdoc_docmgr.hxx
blob9d445ec12c556e16716620cd60e8d6111ee61101
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_DOCMGR_HXX
21 #define INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_DOCMGR_HXX
23 #include <map>
25 #include <rtl/ref.hxx>
26 #include "osl/mutex.hxx"
28 #include "cppuhelper/implbase1.hxx"
30 #include "com/sun/star/document/XDocumentEventListener.hpp"
31 #include "com/sun/star/embed/XStorage.hpp"
32 #include "com/sun/star/frame/XModel.hpp"
33 #include "com/sun/star/frame/XModuleManager2.hpp"
34 #include "com/sun/star/frame/XGlobalEventBroadcaster.hpp"
35 #include "com/sun/star/util/XCloseListener.hpp"
37 namespace tdoc_ucp {
39 class OfficeDocumentsEventListener
41 public:
42 virtual void notifyDocumentOpened( const OUString & rDocId ) = 0;
43 virtual void notifyDocumentClosed( const OUString & rDocId ) = 0;
45 protected:
46 ~OfficeDocumentsEventListener() {}
51 struct StorageInfo
53 OUString aTitle;
54 com::sun::star::uno::Reference<
55 com::sun::star::embed::XStorage > xStorage;
56 com::sun::star::uno::Reference<
57 com::sun::star::frame::XModel > xModel;
59 StorageInfo() {}; // needed for STL map only.
61 StorageInfo(
62 const OUString & rTitle,
63 const com::sun::star::uno::Reference<
64 com::sun::star::embed::XStorage > & rxStorage,
65 const com::sun::star::uno::Reference<
66 com::sun::star::frame::XModel > & rxModel )
67 : aTitle( rTitle ), xStorage( rxStorage ), xModel( rxModel ) {}
72 struct ltref
74 bool operator()(
75 const OUString & r1, const OUString & r2 ) const
77 return r1 < r2;
81 typedef std::map< OUString, StorageInfo, ltref > DocumentList;
85 class OfficeDocumentsManager :
86 public cppu::WeakImplHelper1< com::sun::star::document::XDocumentEventListener >
88 class OfficeDocumentsCloseListener :
89 public cppu::WeakImplHelper1< com::sun::star::util::XCloseListener >
92 public:
93 OfficeDocumentsCloseListener( OfficeDocumentsManager * pMgr )
94 : m_pManager( pMgr ) {}
96 // util::XCloseListener
97 virtual void SAL_CALL queryClosing(
98 const ::com::sun::star::lang::EventObject& Source,
99 sal_Bool GetsOwnership )
100 throw (::com::sun::star::util::CloseVetoException,
101 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 virtual void SAL_CALL notifyClosing(
104 const ::com::sun::star::lang::EventObject& Source )
105 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 // lang::XEventListener (base of util::XCloseListener)
108 virtual void SAL_CALL disposing(
109 const com::sun::star::lang::EventObject & Source )
110 throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
112 void Dispose() { m_pManager = 0; }
114 private:
115 OfficeDocumentsManager * m_pManager;
118 public:
119 OfficeDocumentsManager(
120 const com::sun::star::uno::Reference<
121 com::sun::star::uno::XComponentContext > & rxContext,
122 OfficeDocumentsEventListener * pDocEventListener );
123 virtual ~OfficeDocumentsManager();
125 void destroy();
127 // document::XDocumentEventListener
128 virtual void SAL_CALL documentEventOccured(
129 const com::sun::star::document::DocumentEvent & Event )
130 throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
132 // lang::XEventListener (base of document::XDocumentEventListener)
133 virtual void SAL_CALL disposing(
134 const com::sun::star::lang::EventObject & Source )
135 throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
137 // Non-interface
138 com::sun::star::uno::Reference< com::sun::star::embed::XStorage >
139 queryStorage( const OUString & rDocId );
141 static OUString queryDocumentId(
142 const com::sun::star::uno::Reference<
143 com::sun::star::frame::XModel > & xModel );
145 com::sun::star::uno::Reference< com::sun::star::frame::XModel >
146 queryDocumentModel( const OUString & rDocId );
148 com::sun::star::uno::Sequence< OUString >
149 queryDocuments();
151 OUString
152 queryStorageTitle( const OUString & rDocId );
154 private:
155 void buildDocumentsList();
157 bool isOfficeDocument(
158 const com::sun::star::uno::Reference<
159 com::sun::star::uno::XInterface > & xDoc );
161 static bool isDocumentPreview(
162 const com::sun::star::uno::Reference<
163 com::sun::star::frame::XModel > & xModel );
165 static bool isWithoutOrInTopLevelFrame(
166 const com::sun::star::uno::Reference<
167 com::sun::star::frame::XModel > & xModel );
169 bool
170 isBasicIDE(
171 const com::sun::star::uno::Reference<
172 com::sun::star::frame::XModel > & xModel );
174 static bool isHelpDocument(
175 const com::sun::star::uno::Reference<
176 com::sun::star::frame::XModel > & xModel );
178 osl::Mutex m_aMtx;
179 com::sun::star::uno::Reference<
180 com::sun::star::uno::XComponentContext > m_xContext;
181 com::sun::star::uno::Reference<
182 com::sun::star::frame::XGlobalEventBroadcaster > m_xDocEvtNotifier;
183 com::sun::star::uno::Reference<
184 com::sun::star::frame::XModuleManager2 > m_xModuleMgr;
185 DocumentList m_aDocs;
186 OfficeDocumentsEventListener * m_pDocEventListener;
187 ::rtl::Reference<OfficeDocumentsCloseListener> m_xDocCloseListener;
190 } // namespace tdoc_ucp
192 #endif // INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_DOCMGR_HXX
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */