LCOV - code coverage report
Current view: top level - ucb/source/ucp/tdoc - tdoc_docmgr.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 11 0.0 %
Date: 2014-04-14 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef INCLUDED_TDOC_DOCMGR_HXX
      21             : #define INCLUDED_TDOC_DOCMGR_HXX
      22             : 
      23             : #include <map>
      24             : 
      25             : #include "osl/mutex.hxx"
      26             : 
      27             : #include "cppuhelper/implbase1.hxx"
      28             : 
      29             : #include "com/sun/star/document/XEventListener.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/util/XCloseListener.hpp"
      35             : 
      36             : namespace tdoc_ucp {
      37             : 
      38           0 :     class OfficeDocumentsEventListener
      39             :     {
      40             :     public:
      41             :         virtual void notifyDocumentOpened( const OUString & rDocId ) = 0;
      42             :         virtual void notifyDocumentClosed( const OUString & rDocId ) = 0;
      43             : 
      44             :     protected:
      45           0 :         ~OfficeDocumentsEventListener() {}
      46             :     };
      47             : 
      48             : 
      49             : 
      50           0 :     struct StorageInfo
      51             :     {
      52             :         OUString aTitle;
      53             :         com::sun::star::uno::Reference<
      54             :             com::sun::star::embed::XStorage > xStorage;
      55             :         com::sun::star::uno::Reference<
      56             :             com::sun::star::frame::XModel >   xModel;
      57             : 
      58           0 :         StorageInfo() {}; // needed for STL map only.
      59             : 
      60           0 :         StorageInfo(
      61             :             const OUString & rTitle,
      62             :             const com::sun::star::uno::Reference<
      63             :                 com::sun::star::embed::XStorage > & rxStorage,
      64             :             const com::sun::star::uno::Reference<
      65             :                 com::sun::star::frame::XModel > & rxModel )
      66           0 :         : aTitle( rTitle ), xStorage( rxStorage ), xModel( rxModel ) {}
      67             :     };
      68             : 
      69             : 
      70             : 
      71             :     struct ltref
      72             :     {
      73           0 :         bool operator()(
      74             :             const OUString & r1, const OUString & r2 ) const
      75             :         {
      76           0 :             return r1 < r2;
      77             :         }
      78             :     };
      79             : 
      80             :     typedef std::map< OUString, StorageInfo, ltref > DocumentList;
      81             : 
      82             : 
      83             : 
      84             :     class OfficeDocumentsManager :
      85             :         public cppu::WeakImplHelper1< com::sun::star::document::XEventListener >
      86             :     {
      87           0 :         class OfficeDocumentsCloseListener :
      88             :            public cppu::WeakImplHelper1< com::sun::star::util::XCloseListener >
      89             : 
      90             :         {
      91             :         public:
      92           0 :             OfficeDocumentsCloseListener( OfficeDocumentsManager * pMgr )
      93           0 :             : m_pManager( pMgr ) {};
      94             : 
      95             :             // util::XCloseListener
      96             :             virtual void SAL_CALL queryClosing(
      97             :                     const ::com::sun::star::lang::EventObject& Source,
      98             :                     sal_Bool GetsOwnership )
      99             :                 throw (::com::sun::star::util::CloseVetoException,
     100             :                        ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     101             : 
     102             :             virtual void SAL_CALL notifyClosing(
     103             :                     const ::com::sun::star::lang::EventObject& Source )
     104             :                 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     105             : 
     106             :             // lang::XEventListener (base of util::XCloseListener)
     107             :             virtual void SAL_CALL disposing(
     108             :                     const com::sun::star::lang::EventObject & Source )
     109             :                 throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     110             :         private:
     111             :             OfficeDocumentsManager * m_pManager;
     112             :         };
     113             : 
     114             :     public:
     115             :         OfficeDocumentsManager(
     116             :             const com::sun::star::uno::Reference<
     117             :                 com::sun::star::uno::XComponentContext > & rxContext,
     118             :             OfficeDocumentsEventListener * pDocEventListener );
     119             :         virtual ~OfficeDocumentsManager();
     120             : 
     121             :         void destroy();
     122             : 
     123             :         // document::XEventListener
     124             :         virtual void SAL_CALL notifyEvent(
     125             :                 const com::sun::star::document::EventObject & Event )
     126             :             throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     127             : 
     128             :         // lang::XEventListener (base of document::XEventListener)
     129             :         virtual void SAL_CALL disposing(
     130             :                 const com::sun::star::lang::EventObject & Source )
     131             :             throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     132             : 
     133             :         // Non-interface
     134             :         com::sun::star::uno::Reference< com::sun::star::embed::XStorage >
     135             :         queryStorage( const OUString & rDocId );
     136             : 
     137             :         OUString
     138             :         queryDocumentId(
     139             :             const com::sun::star::uno::Reference<
     140             :                 com::sun::star::frame::XModel > & xModel );
     141             : 
     142             :         com::sun::star::uno::Reference< com::sun::star::frame::XModel >
     143             :         queryDocumentModel( const OUString & rDocId );
     144             : 
     145             :         com::sun::star::uno::Sequence< OUString >
     146             :         queryDocuments();
     147             : 
     148             :         OUString
     149             :         queryStorageTitle( const OUString & rDocId );
     150             : 
     151             :     private:
     152             :         void buildDocumentsList();
     153             : 
     154             :         bool
     155             :         isOfficeDocument(
     156             :             const com::sun::star::uno::Reference<
     157             :                 com::sun::star::uno::XInterface > & xDoc );
     158             : 
     159             :         bool
     160             :         isDocumentPreview(
     161             :             const com::sun::star::uno::Reference<
     162             :                 com::sun::star::frame::XModel > & xModel );
     163             : 
     164             :         bool
     165             :         isWithoutOrInTopLevelFrame(
     166             :             const com::sun::star::uno::Reference<
     167             :                 com::sun::star::frame::XModel > & xModel );
     168             : 
     169             :         bool
     170             :         isBasicIDE(
     171             :             const com::sun::star::uno::Reference<
     172             :                 com::sun::star::frame::XModel > & xModel );
     173             : 
     174             :         bool
     175             :         isHelpDocument(
     176             :             const com::sun::star::uno::Reference<
     177             :                 com::sun::star::frame::XModel > & xModel );
     178             : 
     179             :         osl::Mutex                                          m_aMtx;
     180             :         com::sun::star::uno::Reference<
     181             :             com::sun::star::uno::XComponentContext >        m_xContext;
     182             :         com::sun::star::uno::Reference<
     183             :             com::sun::star::frame::XGlobalEventBroadcaster > m_xDocEvtNotifier;
     184             :         com::sun::star::uno::Reference<
     185             :             com::sun::star::frame::XModuleManager2 >        m_xModuleMgr;
     186             :         DocumentList                                        m_aDocs;
     187             :         OfficeDocumentsEventListener *                      m_pDocEventListener;
     188             :         com::sun::star::uno::Reference<
     189             :             com::sun::star::util::XCloseListener >          m_xDocCloseListener;
     190             :     };
     191             : 
     192             : } // namespace tdoc_ucp
     193             : 
     194             : #endif /* !INCLUDED_TDOC_DOCMGR_HXX */
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10