bump product version to 7.2.5.1
[LibreOffice.git] / ucb / source / ucp / tdoc / tdoc_docmgr.hxx
blob2304a9bef8532844d5b2b639ea4490fa970edc8e
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 #pragma once
22 #include <map>
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>
37 namespace tdoc_ucp {
39 class ContentProvider;
41 struct StorageInfo
43 OUString aTitle;
44 css::uno::Reference< css::embed::XStorage > xStorage;
45 css::uno::Reference< css::frame::XModel > xModel;
47 StorageInfo() {}; // needed for STL map only.
49 StorageInfo(
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 >
67 public:
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; }
85 private:
86 OfficeDocumentsManager * m_pManager;
89 public:
90 OfficeDocumentsManager(
91 const css::uno::Reference< css::uno::XComponentContext > & rxContext,
92 ContentProvider * pDocEventListener );
93 virtual ~OfficeDocumentsManager() override;
95 void destroy();
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;
105 // Non-interface
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 >
116 queryDocuments();
118 OUString
119 queryStorageTitle( const OUString & rDocId );
121 private:
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 );
133 bool
134 isBasicIDE(
135 const css::uno::Reference< css::frame::XModel > & xModel );
137 static bool isHelpDocument(
138 const css::uno::Reference< css::frame::XModel > & xModel );
140 osl::Mutex m_aMtx;
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: */