Update ooo320-m1
[ooovba.git] / ucb / source / ucp / tdoc / tdoc_docmgr.hxx
blobddf990fb4c3afe47892ba920ba00194bdf45f477
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tdoc_docmgr.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_TDOC_DOCMGR_HXX
32 #define INCLUDED_TDOC_DOCMGR_HXX
34 #include <map>
36 #include "osl/mutex.hxx"
38 #include "cppuhelper/implbase1.hxx"
40 #include "com/sun/star/document/XEventBroadcaster.hpp"
41 #include "com/sun/star/document/XEventListener.hpp"
42 #include "com/sun/star/embed/XStorage.hpp"
43 #include "com/sun/star/frame/XModel.hpp"
44 #include "com/sun/star/frame/XModuleManager.hpp"
46 namespace tdoc_ucp {
48 class OfficeDocumentsEventListener
50 public:
51 virtual void notifyDocumentOpened( const rtl::OUString & rDocId ) = 0;
52 virtual void notifyDocumentClosed( const rtl::OUString & rDocId ) = 0;
55 //=======================================================================
57 struct StorageInfo
59 rtl::OUString aTitle;
60 com::sun::star::uno::Reference<
61 com::sun::star::embed::XStorage > xStorage;
62 com::sun::star::uno::Reference<
63 com::sun::star::frame::XModel > xModel;
65 StorageInfo() {}; // needed for STL map only.
67 StorageInfo(
68 const rtl::OUString & rTitle,
69 const com::sun::star::uno::Reference<
70 com::sun::star::embed::XStorage > & rxStorage,
71 const com::sun::star::uno::Reference<
72 com::sun::star::frame::XModel > & rxModel )
73 : aTitle( rTitle ), xStorage( rxStorage ), xModel( rxModel ) {}
76 //=======================================================================
78 struct ltref
80 bool operator()(
81 const rtl::OUString & r1, const rtl::OUString & r2 ) const
83 return r1 < r2;
87 typedef std::map< rtl::OUString, StorageInfo, ltref > DocumentList;
89 //=======================================================================
91 class OfficeDocumentsManager :
92 public cppu::WeakImplHelper1< com::sun::star::document::XEventListener >
94 public:
95 OfficeDocumentsManager(
96 const com::sun::star::uno::Reference<
97 com::sun::star::lang::XMultiServiceFactory > & xSMgr,
98 OfficeDocumentsEventListener * pDocEventListener );
99 virtual ~OfficeDocumentsManager();
101 void destroy();
103 // document::XEventListener
104 virtual void SAL_CALL notifyEvent(
105 const com::sun::star::document::EventObject & Event )
106 throw ( com::sun::star::uno::RuntimeException );
108 // lang::XEventListener (base of document::XEventListener)
109 virtual void SAL_CALL disposing(
110 const com::sun::star::lang::EventObject & Source )
111 throw ( com::sun::star::uno::RuntimeException );
113 // Non-interface
114 com::sun::star::uno::Reference< com::sun::star::embed::XStorage >
115 queryStorage( const rtl::OUString & rDocId );
117 rtl::OUString
118 queryDocumentId(
119 const com::sun::star::uno::Reference<
120 com::sun::star::frame::XModel > & xModel );
122 com::sun::star::uno::Reference< com::sun::star::frame::XModel >
123 queryDocumentModel( const rtl::OUString & rDocId );
125 com::sun::star::uno::Sequence< rtl::OUString >
126 queryDocuments();
128 rtl::OUString
129 queryStorageTitle( const rtl::OUString & rDocId );
131 private:
132 static com::sun::star::uno::Reference<
133 com::sun::star::document::XEventBroadcaster >
134 createDocumentEventNotifier(
135 const com::sun::star::uno::Reference<
136 com::sun::star::lang::XMultiServiceFactory >& rXSMgr );
137 void buildDocumentsList();
138 bool
139 isOfficeDocument(
140 const com::sun::star::uno::Reference<
141 com::sun::star::uno::XInterface > & xDoc );
143 bool
144 isDocumentPreview(
145 const com::sun::star::uno::Reference<
146 com::sun::star::frame::XModel > & xModel );
148 bool
149 isWithoutOrInTopLevelFrame(
150 const com::sun::star::uno::Reference<
151 com::sun::star::frame::XModel > & xModel );
153 bool
154 isBasicIDE(
155 const com::sun::star::uno::Reference<
156 com::sun::star::frame::XModel > & xModel );
158 bool
159 isHelpDocument(
160 const com::sun::star::uno::Reference<
161 com::sun::star::frame::XModel > & xModel );
163 osl::Mutex m_aMtx;
164 com::sun::star::uno::Reference<
165 com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
166 com::sun::star::uno::Reference<
167 com::sun::star::document::XEventBroadcaster > m_xDocEvtNotifier;
168 com::sun::star::uno::Reference<
169 com::sun::star::frame::XModuleManager > m_xModuleMgr;
170 DocumentList m_aDocs;
171 OfficeDocumentsEventListener * m_pDocEventListener;
174 } // namespace tdoc_ucp
176 #endif /* !INCLUDED_TDOC_DOCMGR_HXX */