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 .
24 #include <rtl/ref.hxx>
25 #include <osl/mutex.hxx>
27 #include <cppuhelper/implbase.hxx>
29 #include <com/sun/star/document/XDocumentEventListener.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/uno/XComponentContext.hpp>
35 #include <com/sun/star/util/XCloseListener.hpp>
39 class ContentProvider
;
44 css::uno::Reference
< css::embed::XStorage
> xStorage
;
45 css::uno::Reference
< css::frame::XModel
> xModel
;
47 StorageInfo() {}; // needed for STL map only.
50 const OUString
& rTitle
,
51 const css::uno::Reference
< css::embed::XStorage
> & rxStorage
,
52 const css::uno::Reference
< css::frame::XModel
> & rxModel
)
53 : aTitle( rTitle
), xStorage( rxStorage
), xModel( rxModel
) {}
57 typedef std::map
< OUString
, StorageInfo
> DocumentList
;
60 class OfficeDocumentsManager
:
61 public cppu::WeakImplHelper
< css::document::XDocumentEventListener
>
63 class OfficeDocumentsCloseListener
:
64 public cppu::WeakImplHelper
< css::util::XCloseListener
>
68 explicit OfficeDocumentsCloseListener( OfficeDocumentsManager
* pMgr
)
69 : m_pManager( pMgr
) {}
71 // util::XCloseListener
72 virtual void SAL_CALL
queryClosing(
73 const css::lang::EventObject
& Source
,
74 sal_Bool GetsOwnership
) override
;
76 virtual void SAL_CALL
notifyClosing(
77 const css::lang::EventObject
& Source
) override
;
79 // lang::XEventListener (base of util::XCloseListener)
80 virtual void SAL_CALL
disposing(
81 const css::lang::EventObject
& Source
) override
;
83 void Dispose() { m_pManager
= nullptr; }
86 OfficeDocumentsManager
* m_pManager
;
90 OfficeDocumentsManager(
91 const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
,
92 ContentProvider
* pDocEventListener
);
93 virtual ~OfficeDocumentsManager() override
;
97 // document::XDocumentEventListener
98 virtual void SAL_CALL
documentEventOccured(
99 const css::document::DocumentEvent
& Event
) override
;
101 // lang::XEventListener (base of document::XDocumentEventListener)
102 virtual void SAL_CALL
disposing(
103 const css::lang::EventObject
& Source
) override
;
106 css::uno::Reference
< css::embed::XStorage
>
107 queryStorage( const OUString
& rDocId
);
109 static OUString
queryDocumentId(
110 const css::uno::Reference
< css::frame::XModel
> & xModel
);
112 css::uno::Reference
< css::frame::XModel
>
113 queryDocumentModel( const OUString
& rDocId
);
115 css::uno::Sequence
< OUString
>
119 queryStorageTitle( const OUString
& rDocId
);
122 void buildDocumentsList();
124 bool isOfficeDocument(
125 const css::uno::Reference
< css::uno::XInterface
> & xDoc
);
127 static bool isDocumentPreview(
128 const css::uno::Reference
< css::frame::XModel
> & xModel
);
130 static bool isWithoutOrInTopLevelFrame(
131 const css::uno::Reference
< css::frame::XModel
> & xModel
);
135 const css::uno::Reference
< css::frame::XModel
> & xModel
);
137 static bool isHelpDocument(
138 const css::uno::Reference
< css::frame::XModel
> & xModel
);
141 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
142 css::uno::Reference
< css::frame::XGlobalEventBroadcaster
> m_xDocEvtNotifier
;
143 css::uno::Reference
< css::frame::XModuleManager2
> m_xModuleMgr
;
144 DocumentList m_aDocs
;
145 ContentProvider
* const m_pDocEventListener
;
146 ::rtl::Reference
<OfficeDocumentsCloseListener
> const m_xDocCloseListener
;
149 } // namespace tdoc_ucp
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */