1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_TDOC_DOCMGR_HXX
21 #define INCLUDED_TDOC_DOCMGR_HXX
25 #include "osl/mutex.hxx"
27 #include "cppuhelper/implbase1.hxx"
29 #include "com/sun/star/document/XEventListener.hpp"
30 #include "com/sun/star/embed/XStorage.hpp"
31 #include "com/sun/star/frame/XModel.hpp"
32 #include "com/sun/star/frame/XModuleManager2.hpp"
33 #include "com/sun/star/frame/XGlobalEventBroadcaster.hpp"
34 #include "com/sun/star/util/XCloseListener.hpp"
38 class OfficeDocumentsEventListener
41 virtual void notifyDocumentOpened( const rtl::OUString
& rDocId
) = 0;
42 virtual void notifyDocumentClosed( const rtl::OUString
& rDocId
) = 0;
45 ~OfficeDocumentsEventListener() {}
48 //=======================================================================
53 com::sun::star::uno::Reference
<
54 com::sun::star::embed::XStorage
> xStorage
;
55 com::sun::star::uno::Reference
<
56 com::sun::star::frame::XModel
> xModel
;
58 StorageInfo() {}; // needed for STL map only.
61 const rtl::OUString
& rTitle
,
62 const com::sun::star::uno::Reference
<
63 com::sun::star::embed::XStorage
> & rxStorage
,
64 const com::sun::star::uno::Reference
<
65 com::sun::star::frame::XModel
> & rxModel
)
66 : aTitle( rTitle
), xStorage( rxStorage
), xModel( rxModel
) {}
69 //=======================================================================
74 const rtl::OUString
& r1
, const rtl::OUString
& r2
) const
80 typedef std::map
< rtl::OUString
, StorageInfo
, ltref
> DocumentList
;
82 //=======================================================================
84 class OfficeDocumentsManager
:
85 public cppu::WeakImplHelper1
< com::sun::star::document::XEventListener
>
87 class OfficeDocumentsCloseListener
:
88 public cppu::WeakImplHelper1
< com::sun::star::util::XCloseListener
>
92 OfficeDocumentsCloseListener( OfficeDocumentsManager
* pMgr
)
93 : m_pManager( pMgr
) {};
95 // util::XCloseListener
96 virtual void SAL_CALL
queryClosing(
97 const ::com::sun::star::lang::EventObject
& Source
,
98 ::sal_Bool GetsOwnership
)
99 throw (::com::sun::star::util::CloseVetoException
,
100 ::com::sun::star::uno::RuntimeException
);
102 virtual void SAL_CALL
notifyClosing(
103 const ::com::sun::star::lang::EventObject
& Source
)
104 throw (::com::sun::star::uno::RuntimeException
);
106 // lang::XEventListener (base of util::XCloseListener)
107 virtual void SAL_CALL
disposing(
108 const com::sun::star::lang::EventObject
& Source
)
109 throw ( com::sun::star::uno::RuntimeException
);
111 OfficeDocumentsManager
* m_pManager
;
115 OfficeDocumentsManager(
116 const com::sun::star::uno::Reference
<
117 com::sun::star::uno::XComponentContext
> & rxContext
,
118 OfficeDocumentsEventListener
* pDocEventListener
);
119 virtual ~OfficeDocumentsManager();
123 // document::XEventListener
124 virtual void SAL_CALL
notifyEvent(
125 const com::sun::star::document::EventObject
& Event
)
126 throw ( com::sun::star::uno::RuntimeException
);
128 // lang::XEventListener (base of document::XEventListener)
129 virtual void SAL_CALL
disposing(
130 const com::sun::star::lang::EventObject
& Source
)
131 throw ( com::sun::star::uno::RuntimeException
);
134 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>
135 queryStorage( const rtl::OUString
& rDocId
);
139 const com::sun::star::uno::Reference
<
140 com::sun::star::frame::XModel
> & xModel
);
142 com::sun::star::uno::Reference
< com::sun::star::frame::XModel
>
143 queryDocumentModel( const rtl::OUString
& rDocId
);
145 com::sun::star::uno::Sequence
< rtl::OUString
>
149 queryStorageTitle( const rtl::OUString
& rDocId
);
152 void buildDocumentsList();
156 const com::sun::star::uno::Reference
<
157 com::sun::star::uno::XInterface
> & xDoc
);
161 const com::sun::star::uno::Reference
<
162 com::sun::star::frame::XModel
> & xModel
);
165 isWithoutOrInTopLevelFrame(
166 const com::sun::star::uno::Reference
<
167 com::sun::star::frame::XModel
> & xModel
);
171 const com::sun::star::uno::Reference
<
172 com::sun::star::frame::XModel
> & xModel
);
176 const com::sun::star::uno::Reference
<
177 com::sun::star::frame::XModel
> & xModel
);
180 com::sun::star::uno::Reference
<
181 com::sun::star::uno::XComponentContext
> m_xContext
;
182 com::sun::star::uno::Reference
<
183 com::sun::star::frame::XGlobalEventBroadcaster
> m_xDocEvtNotifier
;
184 com::sun::star::uno::Reference
<
185 com::sun::star::frame::XModuleManager2
> m_xModuleMgr
;
186 DocumentList m_aDocs
;
187 OfficeDocumentsEventListener
* m_pDocEventListener
;
188 com::sun::star::uno::Reference
<
189 com::sun::star::util::XCloseListener
> m_xDocCloseListener
;
192 } // namespace tdoc_ucp
194 #endif /* !INCLUDED_TDOC_DOCMGR_HXX */
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */