LibreOffice Module ucb (master)  1
tdoc_docmgr.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include <map>
23 
24 #include <rtl/ref.hxx>
25 #include <osl/mutex.hxx>
26 
27 #include <cppuhelper/implbase.hxx>
28 
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>
36 
37 namespace tdoc_ucp {
38 
39  class ContentProvider;
40 
41  struct StorageInfo
42  {
43  OUString aTitle;
44  css::uno::Reference< css::embed::XStorage > xStorage;
45  css::uno::Reference< css::frame::XModel > xModel;
46 
47  StorageInfo() {}; // needed for STL map only.
48 
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 ) {}
54  };
55 
56 
57  typedef std::map< OUString, StorageInfo > DocumentList;
58 
59 
61  public cppu::WeakImplHelper< css::document::XDocumentEventListener >
62  {
64  public cppu::WeakImplHelper< css::util::XCloseListener >
65 
66  {
67  public:
69  : m_pManager( pMgr ) {}
70 
71  // util::XCloseListener
72  virtual void SAL_CALL queryClosing(
73  const css::lang::EventObject& Source,
74  sal_Bool GetsOwnership ) override;
75 
76  virtual void SAL_CALL notifyClosing(
77  const css::lang::EventObject& Source ) override;
78 
79  // lang::XEventListener (base of util::XCloseListener)
80  virtual void SAL_CALL disposing(
81  const css::lang::EventObject & Source ) override;
82 
83  void Dispose() { m_pManager = nullptr; }
84 
85  private:
87  };
88 
89  public:
91  const css::uno::Reference< css::uno::XComponentContext > & rxContext,
92  ContentProvider * pDocEventListener );
93  virtual ~OfficeDocumentsManager() override;
94 
95  void destroy();
96 
97  // document::XDocumentEventListener
98  virtual void SAL_CALL documentEventOccured(
99  const css::document::DocumentEvent & Event ) override;
100 
101  // lang::XEventListener (base of document::XDocumentEventListener)
102  virtual void SAL_CALL disposing(
103  const css::lang::EventObject & Source ) override;
104 
105  // Non-interface
106  css::uno::Reference< css::embed::XStorage >
107  queryStorage( const OUString & rDocId );
108 
109  static OUString queryDocumentId(
110  const css::uno::Reference< css::frame::XModel > & xModel );
111 
112  css::uno::Reference< css::frame::XModel >
113  queryDocumentModel( const OUString & rDocId );
114 
115  css::uno::Sequence< OUString >
116  queryDocuments();
117 
118  OUString
119  queryStorageTitle( const OUString & rDocId );
120 
121  private:
122  void buildDocumentsList();
123 
124  bool isOfficeDocument(
125  const css::uno::Reference< css::uno::XInterface > & xDoc );
126 
127  static bool isDocumentPreview(
128  const css::uno::Reference< css::frame::XModel > & xModel );
129 
130  static bool isWithoutOrInTopLevelFrame(
131  const css::uno::Reference< css::frame::XModel > & xModel );
132 
133  bool
134  isBasicIDE(
135  const css::uno::Reference< css::frame::XModel > & xModel );
136 
137  static bool isHelpDocument(
138  const css::uno::Reference< css::frame::XModel > & xModel );
139 
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;
147  };
148 
149 } // namespace tdoc_ucp
150 
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL queryClosing(const css::lang::EventObject &Source, sal_Bool GetsOwnership) override
Definition: tdoc_docmgr.cxx:52
css::uno::Reference< css::frame::XModel > xModel
Definition: tdoc_docmgr.hxx:45
css::uno::Reference< css::uno::XComponentContext > m_xContext
::rtl::Reference< OfficeDocumentsCloseListener > const m_xDocCloseListener
static bool isDocumentPreview(const css::uno::Reference< css::frame::XModel > &xModel)
css::uno::Reference< css::embed::XStorage > xStorage
Definition: tdoc_docmgr.hxx:44
css::uno::Reference< css::embed::XStorage > queryStorage(const OUString &rDocId)
static bool isWithoutOrInTopLevelFrame(const css::uno::Reference< css::frame::XModel > &xModel)
OfficeDocumentsManager(const css::uno::Reference< css::uno::XComponentContext > &rxContext, ContentProvider *pDocEventListener)
Definition: tdoc_docmgr.cxx:83
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: tdoc_docmgr.cxx:74
css::uno::Reference< css::frame::XGlobalEventBroadcaster > m_xDocEvtNotifier
StorageInfo(const OUString &rTitle, const css::uno::Reference< css::embed::XStorage > &rxStorage, const css::uno::Reference< css::frame::XModel > &rxModel)
Definition: tdoc_docmgr.hxx:49
css::uno::Sequence< OUString > queryDocuments()
ContentProvider *const m_pDocEventListener
std::map< OUString, StorageInfo > DocumentList
Definition: tdoc_docmgr.hxx:57
css::uno::Reference< css::frame::XModel > queryDocumentModel(const OUString &rDocId)
unsigned char sal_Bool
bool isBasicIDE(const css::uno::Reference< css::frame::XModel > &xModel)
static OUString queryDocumentId(const css::uno::Reference< css::frame::XModel > &xModel)
css::uno::Reference< css::frame::XModuleManager2 > m_xModuleMgr
bool isOfficeDocument(const css::uno::Reference< css::uno::XInterface > &xDoc)
static bool isHelpDocument(const css::uno::Reference< css::frame::XModel > &xModel)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL notifyClosing(const css::lang::EventObject &Source) override
Definition: tdoc_docmgr.cxx:58
virtual ~OfficeDocumentsManager() override
Definition: tdoc_docmgr.cxx:99
virtual void SAL_CALL documentEventOccured(const css::document::DocumentEvent &Event) override
friend ContentProvider
Definition: pkgprovider.cxx:53
OUString queryStorageTitle(const OUString &rDocId)