1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef INCLUDED_TDOC_DOCMGR_HXX
30 #define INCLUDED_TDOC_DOCMGR_HXX
34 #include "osl/mutex.hxx"
36 #include "cppuhelper/implbase1.hxx"
38 #include "com/sun/star/document/XEventBroadcaster.hpp"
39 #include "com/sun/star/document/XEventListener.hpp"
40 #include "com/sun/star/embed/XStorage.hpp"
41 #include "com/sun/star/frame/XModel.hpp"
42 #include "com/sun/star/frame/XModuleManager.hpp"
43 #include "com/sun/star/util/XCloseListener.hpp"
47 class OfficeDocumentsEventListener
50 virtual void notifyDocumentOpened( const rtl::OUString
& rDocId
) = 0;
51 virtual void notifyDocumentClosed( const rtl::OUString
& rDocId
) = 0;
54 ~OfficeDocumentsEventListener() {}
57 //=======================================================================
62 com::sun::star::uno::Reference
<
63 com::sun::star::embed::XStorage
> xStorage
;
64 com::sun::star::uno::Reference
<
65 com::sun::star::frame::XModel
> xModel
;
67 StorageInfo() {}; // needed for STL map only.
70 const rtl::OUString
& rTitle
,
71 const com::sun::star::uno::Reference
<
72 com::sun::star::embed::XStorage
> & rxStorage
,
73 const com::sun::star::uno::Reference
<
74 com::sun::star::frame::XModel
> & rxModel
)
75 : aTitle( rTitle
), xStorage( rxStorage
), xModel( rxModel
) {}
78 //=======================================================================
83 const rtl::OUString
& r1
, const rtl::OUString
& r2
) const
89 typedef std::map
< rtl::OUString
, StorageInfo
, ltref
> DocumentList
;
91 //=======================================================================
93 class OfficeDocumentsManager
:
94 public cppu::WeakImplHelper1
< com::sun::star::document::XEventListener
>
96 class OfficeDocumentsCloseListener
:
97 public cppu::WeakImplHelper1
< com::sun::star::util::XCloseListener
>
101 OfficeDocumentsCloseListener( OfficeDocumentsManager
* pMgr
)
102 : m_pManager( pMgr
) {};
104 // util::XCloseListener
105 virtual void SAL_CALL
queryClosing(
106 const ::com::sun::star::lang::EventObject
& Source
,
107 ::sal_Bool GetsOwnership
)
108 throw (::com::sun::star::util::CloseVetoException
,
109 ::com::sun::star::uno::RuntimeException
);
111 virtual void SAL_CALL
notifyClosing(
112 const ::com::sun::star::lang::EventObject
& Source
)
113 throw (::com::sun::star::uno::RuntimeException
);
115 // lang::XEventListener (base of util::XCloseListener)
116 virtual void SAL_CALL
disposing(
117 const com::sun::star::lang::EventObject
& Source
)
118 throw ( com::sun::star::uno::RuntimeException
);
120 OfficeDocumentsManager
* m_pManager
;
124 OfficeDocumentsManager(
125 const com::sun::star::uno::Reference
<
126 com::sun::star::lang::XMultiServiceFactory
> & xSMgr
,
127 OfficeDocumentsEventListener
* pDocEventListener
);
128 virtual ~OfficeDocumentsManager();
132 // document::XEventListener
133 virtual void SAL_CALL
notifyEvent(
134 const com::sun::star::document::EventObject
& Event
)
135 throw ( com::sun::star::uno::RuntimeException
);
137 // lang::XEventListener (base of document::XEventListener)
138 virtual void SAL_CALL
disposing(
139 const com::sun::star::lang::EventObject
& Source
)
140 throw ( com::sun::star::uno::RuntimeException
);
143 com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>
144 queryStorage( const rtl::OUString
& rDocId
);
148 const com::sun::star::uno::Reference
<
149 com::sun::star::frame::XModel
> & xModel
);
151 com::sun::star::uno::Reference
< com::sun::star::frame::XModel
>
152 queryDocumentModel( const rtl::OUString
& rDocId
);
154 com::sun::star::uno::Sequence
< rtl::OUString
>
158 queryStorageTitle( const rtl::OUString
& rDocId
);
161 static com::sun::star::uno::Reference
<
162 com::sun::star::document::XEventBroadcaster
>
163 createDocumentEventNotifier(
164 const com::sun::star::uno::Reference
<
165 com::sun::star::lang::XMultiServiceFactory
>& rXSMgr
);
167 void buildDocumentsList();
171 const com::sun::star::uno::Reference
<
172 com::sun::star::uno::XInterface
> & xDoc
);
176 const com::sun::star::uno::Reference
<
177 com::sun::star::frame::XModel
> & xModel
);
180 isWithoutOrInTopLevelFrame(
181 const com::sun::star::uno::Reference
<
182 com::sun::star::frame::XModel
> & xModel
);
186 const com::sun::star::uno::Reference
<
187 com::sun::star::frame::XModel
> & xModel
);
191 const com::sun::star::uno::Reference
<
192 com::sun::star::frame::XModel
> & xModel
);
195 com::sun::star::uno::Reference
<
196 com::sun::star::lang::XMultiServiceFactory
> m_xSMgr
;
197 com::sun::star::uno::Reference
<
198 com::sun::star::document::XEventBroadcaster
> m_xDocEvtNotifier
;
199 com::sun::star::uno::Reference
<
200 com::sun::star::frame::XModuleManager
> m_xModuleMgr
;
201 DocumentList m_aDocs
;
202 OfficeDocumentsEventListener
* m_pDocEventListener
;
203 com::sun::star::uno::Reference
<
204 com::sun::star::util::XCloseListener
> m_xDocCloseListener
;
207 } // namespace tdoc_ucp
209 #endif /* !INCLUDED_TDOC_DOCMGR_HXX */
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */