LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/core/dataaccess - documentdefinition.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 7 0.0 %
Date: 2012-12-27 Functions: 0 5 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 _DBA_COREDATAACCESS_DOCUMENTDEFINITION_HXX_
      21             : #define _DBA_COREDATAACCESS_DOCUMENTDEFINITION_HXX_
      22             : 
      23             : #include <cppuhelper/propshlp.hxx>
      24             : #include <cppuhelper/implbase4.hxx>
      25             : #include "ContentHelper.hxx"
      26             : #include <comphelper/propertystatecontainer.hxx>
      27             : #include <comphelper/proparrhlp.hxx>
      28             : #include "apitools.hxx"
      29             : #include <comphelper/uno3.hxx>
      30             : #include <com/sun/star/sdbc/XConnection.hpp>
      31             : #include <com/sun/star/frame/XComponentLoader.hpp>
      32             : #include <com/sun/star/frame/XController.hpp>
      33             : #include <com/sun/star/embed/XStateChangeListener.hpp>
      34             : #include <com/sun/star/sdb/XSubDocument.hpp>
      35             : #include <com/sun/star/util/XCloseListener.hpp>
      36             : #include <com/sun/star/container/XHierarchicalName.hpp>
      37             : 
      38             : namespace comphelper
      39             : {
      40             :     class NamedValueCollection;
      41             : }
      42             : 
      43             : //........................................................................
      44             : namespace dbaccess
      45             : {
      46             : //........................................................................
      47             : 
      48             :     class OInterceptor;
      49             :     class OEmbeddedClientHelper;
      50             : //==========================================================================
      51             : //= ODocumentDefinition - a database "document" which is simply a link to a real
      52             : //=                   document
      53             : //==========================================================================
      54             : 
      55             : typedef ::cppu::ImplHelper4 <   ::com::sun::star::embed::XComponentSupplier
      56             :                             ,   ::com::sun::star::sdb::XSubDocument
      57             :                             ,   ::com::sun::star::util::XCloseListener
      58             :                             ,   ::com::sun::star::container::XHierarchicalName
      59             :                             >   ODocumentDefinition_Base;
      60             : 
      61             : class ODocumentDefinition
      62             :         :public OContentHelper
      63             :         ,public ::comphelper::OPropertyStateContainer
      64             :         ,public ::comphelper::OPropertyArrayUsageHelper< ODocumentDefinition >
      65             :         ,public ODocumentDefinition_Base
      66             : {
      67             :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject>         m_xEmbeddedObject;
      68             :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStateChangeListener >   m_xListener;
      69             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >             m_xLastKnownConnection;
      70             : 
      71             :     OInterceptor*                                                                       m_pInterceptor;
      72             :     sal_Bool                                                                            m_bForm; // <TRUE/> if it is a form
      73             :     sal_Bool                                                                            m_bOpenInDesign;
      74             :     sal_Bool                                                                            m_bInExecute;
      75             :     sal_Bool                                                                            m_bRemoveListener;
      76             :     OEmbeddedClientHelper*                                                              m_pClientHelper;
      77             : 
      78             : protected:
      79             :     virtual ~ODocumentDefinition();
      80             : 
      81             : public:
      82             : 
      83             :     ODocumentDefinition(
      84             :             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContainer,
      85             :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&,
      86             :             const TContentPtr& _pImpl,
      87             :             sal_Bool _bForm
      88             :         );
      89             : 
      90             :     void    initialLoad(
      91             :                 const ::com::sun::star::uno::Sequence< sal_Int8 >& i_rClassID,
      92             :                 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rCreationArgs,
      93             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& i_rConnection
      94             :             );
      95             : 
      96             : // com::sun::star::lang::XTypeProvider
      97             :     DECLARE_TYPEPROVIDER( );
      98             : 
      99             : // ::com::sun::star::uno::XInterface
     100             :     DECLARE_XINTERFACE( )
     101             : 
     102             : // ::com::sun::star::lang::XServiceInfo
     103             :     DECLARE_SERVICE_INFO_STATIC();
     104             : 
     105             : // ::com::sun::star::beans::XPropertySet
     106             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
     107             : 
     108             :     // OPropertySetHelper
     109             :     virtual void SAL_CALL getFastPropertyValue(
     110             :                                 ::com::sun::star::uno::Any& o_rValue,
     111             :                                 sal_Int32 i_nHandle
     112             :                             ) const;
     113             : 
     114             :     // XComponentSupplier
     115             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > SAL_CALL getComponent(  ) throw (::com::sun::star::uno::RuntimeException);
     116             : 
     117             :     // XSubDocument
     118             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL open(  ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     119             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL openDesign(  ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     120             :     virtual void SAL_CALL store(  ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     121             :     virtual ::sal_Bool SAL_CALL close(  ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
     122             : 
     123             :     // XHierarchicalName
     124             :     virtual ::rtl::OUString SAL_CALL getHierarchicalName(  ) throw (::com::sun::star::uno::RuntimeException);
     125             :     virtual ::rtl::OUString SAL_CALL composeHierarchicalName( const ::rtl::OUString& aRelativeName ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
     126             : 
     127             : // OPropertySetHelper
     128             :     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
     129             : 
     130             :     // XCommandProcessor
     131             :     virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::ucb::Command& aCommand, sal_Int32 CommandId, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw (::com::sun::star::uno::Exception, ::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::RuntimeException) ;
     132             : 
     133             :     // XRename
     134             :     virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
     135             : 
     136             :     // XCloseListener
     137             :     virtual void SAL_CALL queryClosing( const ::com::sun::star::lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException);
     138             :     virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
     139             : 
     140             :     // XEventListener
     141             :     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
     142             : 
     143             :     /** returns the forms/reports container storage, depending on m_bForm. Our own storage
     144             :         inside this container storage is the one with the name as indicated by m_pImpl->m_aProps.sPersistentName.
     145             :     */
     146             :     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
     147             :         getContainerStorage() const;
     148             : 
     149             :     sal_Bool save(sal_Bool _bApprove);
     150             :     sal_Bool saveAs();
     151             :     void closeObject();
     152             :     sal_Bool isModified();
     153           0 :     inline sal_Bool isNewReport() const { return !m_bForm && !m_pImpl->m_aProps.bAsTemplate; }
     154             : 
     155             :     static void fillReportData(
     156             :                     const ::comphelper::ComponentContext& _rContext,
     157             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >& _rxComponent,
     158             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActiveConnection
     159             :                 );
     160             : 
     161             :     const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >&
     162           0 :         getConnection() const { return m_xLastKnownConnection; }
     163             : 
     164             :     /** prepares closing the document component
     165             : 
     166             :         The method suspends the controller associated with the document, and saves the document
     167             :         if necessary.
     168             : 
     169             :         @return
     170             :             <TRUE/> if and only if the document component can be closed
     171             :     */
     172             :     bool prepareClose();
     173             : 
     174             :     static ::com::sun::star::uno::Sequence< sal_Int8 > getDefaultDocumentTypeClassId();
     175             : 
     176             :     static ::rtl::OUString GetDocumentServiceFromMediaType(
     177             :         const ::rtl::OUString& _rMediaType,
     178             :         const ::comphelper::ComponentContext& _rContext,
     179             :         ::com::sun::star::uno::Sequence< sal_Int8 >& _rClassId
     180             :     );
     181             :     static ::rtl::OUString GetDocumentServiceFromMediaType(
     182             :         const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxContainerStorage,
     183             :         const ::rtl::OUString& _rEntityName,
     184             :         const ::comphelper::ComponentContext& _rContext,
     185             :         ::com::sun::star::uno::Sequence< sal_Int8 >& _rClassId
     186             :     );
     187             : 
     188           0 :     struct NotifierAccess { friend class NameChangeNotifier; private: NotifierAccess() { } };
     189           0 :     const ::rtl::OUString& getCurrentName() const { return m_pImpl->m_aProps.aTitle; }
     190             :     void firePropertyChange(
     191             :                   sal_Int32 i_nHandle,
     192             :             const ::com::sun::star::uno::Any& i_rNewValue,
     193             :             const ::com::sun::star::uno::Any& i_rOldValue,
     194             :                   sal_Bool i_bVetoable,
     195             :             const NotifierAccess
     196             :         );
     197             : 
     198             : private:
     199             :     /** does necessary initializations after our embedded object has been switched to ACTIVE
     200             :     */
     201             :     void    impl_onActivateEmbeddedObject_nothrow( const bool i_bReactivated );
     202             : 
     203             :     /** initializes a newly created view/controller of a form which is displaying our embedded object
     204             : 
     205             :         Has only to be called if the respective embedded object has been loaded for design (and
     206             :         not for data entry)
     207             : 
     208             :         @param  _rxController
     209             :             the controller which belongs to the XModel of our (active) embedded object
     210             :     */
     211             :     static void impl_initFormEditView( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& _rxController );
     212             : 
     213             :     /** removes the given frame from the desktop's frame collection
     214             :         @raises ::com::sun::star::uno::RuntimeException
     215             :     */
     216             :     static void impl_removeFrameFromDesktop_throw(
     217             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rContxt,
     218             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame
     219             :                 );
     220             : 
     221             :     /** opens the UI for this sub document
     222             :     */
     223             :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
     224             :             impl_openUI_nolck_throw( bool _bForEditing );
     225             : 
     226             :     /** stores our document, if it's already loaded
     227             :     */
     228             :     void    impl_store_throw();
     229             : 
     230             :     /** closes our document, if it's open
     231             :     */
     232             :     bool    impl_close_throw();
     233             : 
     234             :     /** returns our component, creates it if necessary
     235             :     */
     236             :     ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >
     237             :             impl_getComponent_throw( const bool i_ForceCreate = true );
     238             : 
     239             :     /** shows or hides our component
     240             : 
     241             :         The embedded object must exist, and be in state LOADED, at least.
     242             :     */
     243             :     void    impl_showOrHideComponent_throw( const bool i_bShow );
     244             : 
     245             :     // OPropertyArrayUsageHelper
     246             :     virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
     247             : 
     248             :     virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const;
     249             : 
     250             :     // helper
     251             :     virtual void SAL_CALL disposing();
     252             : 
     253             :     // OContentHelper overridables
     254             :     virtual ::rtl::OUString determineContentType() const;
     255             : 
     256             :     /** fills the load arguments
     257             :     */
     258             :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
     259             :         fillLoadArgs(
     260             :             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
     261             :             const bool _bSuppressMacros,
     262             :             const bool _bReadOnly,
     263             :             const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rOpenCommandArguments,
     264             :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _out_rEmbeddedObjectDescriptor
     265             :         );
     266             : 
     267             :     /** splits the given arguments to an "open*" command into arguments for loading the document, and arguments to be
     268             :         put into the EmbeddedObjectDescriptor
     269             : 
     270             :         Any values already present in <code>o_rDocumentLoadArgs</code> and <code>o_rEmbeddedObjectDescriptor</code>
     271             :         will be overwritten by values from <code>i_rOpenCommandArguments</code>, if applicable, otherwise they will
     272             :         be preserved.
     273             : 
     274             :         @param i_rOpenCommandArguments
     275             :             the arguments passed to the "open*" command at the content
     276             :         @param o_rDocumentLoadArgs
     277             :             the arguments to be passed when actually loading the embedded document.
     278             :         @param o_rEmbeddedObjectDescriptor
     279             :             the EmbeddedObjectDescriptor to be passed when initializing the embedded object
     280             :     */
     281             :     void separateOpenCommandArguments(
     282             :             const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&    i_rOpenCommandArguments,
     283             :             ::comphelper::NamedValueCollection&                                                 o_rDocumentLoadArgs,
     284             :             ::comphelper::NamedValueCollection&                                                 o_rEmbeddedObjectDescriptor
     285             :         );
     286             : 
     287             :     /** loads the EmbeddedObject if not already loaded
     288             :         @param  _aClassID
     289             :             If set, it will be used to create the embedded object.
     290             :     */
     291             :     void loadEmbeddedObject(
     292             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
     293             :                 const ::com::sun::star::uno::Sequence< sal_Int8 >& _aClassID,
     294             :                 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rAdditionalArgs,
     295             :                 const bool _bSuppressMacros,
     296             :                 const bool _bReadOnly
     297             :             );
     298             : 
     299             :     /** loads the embedded object, if not already loaded. No new object can be created with this method.
     300             :     */
     301             :     void    loadEmbeddedObject( bool _bSuppressMacros = false )
     302             :     {
     303             :         loadEmbeddedObject(
     304             :             NULL,
     305             :             ::com::sun::star::uno::Sequence< sal_Int8 >(),
     306             :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >(),
     307             :             _bSuppressMacros,
     308             :             false
     309             :         );
     310             :     }
     311             : 
     312             :     /** loads the embedded object for preview. Macros will be suppressed, and the document will
     313             :         be read-only.
     314             :     */
     315           0 :     void    loadEmbeddedObjectForPreview()
     316             :     {
     317             :         loadEmbeddedObject(
     318             :             NULL,
     319             :             ::com::sun::star::uno::Sequence< sal_Int8 >(),
     320             :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >(),
     321             :             true,
     322             :             true
     323           0 :         );
     324           0 :     }
     325             : 
     326             :     /** searches for read-only flag in the args of the model and sets it to the given value,
     327             :         if the value was not found, it will be appended.
     328             :         @param  _bReadOnly
     329             :             If <TRUE/> the document will be switched to readonly mode
     330             :     */
     331             :     void updateDocumentTitle();
     332             : 
     333             :     void registerProperties();
     334             : 
     335             :     /** determines whether the document we represent supports embedded scripts and macros
     336             :     */
     337             :     sal_Bool objectSupportsEmbeddedScripts() const;
     338             : 
     339             :     //- commands
     340             : 
     341             :     void onCommandGetDocumentProperties( ::com::sun::star::uno::Any& _rProps );
     342             :     void onCommandInsert( const ::rtl::OUString& _sURL, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& Environment ) throw( ::com::sun::star::uno::Exception );
     343             :     void onCommandPreview( ::com::sun::star::uno::Any& _rImage );
     344             :     ::com::sun::star::uno::Any
     345             :         onCommandOpenSomething(
     346             :             const ::com::sun::star::uno::Any& _rArgument,
     347             :             const bool _bActivate,
     348             :             const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& _rxEnvironment
     349             :         );
     350             : private:
     351             :     using ::cppu::OPropertySetHelper::getFastPropertyValue;
     352             : };
     353             : 
     354             : class NameChangeNotifier
     355             : {
     356             : public:
     357             :     NameChangeNotifier(
     358             :         ODocumentDefinition& i_rDocumentDefinition,
     359             :         const ::rtl::OUString& i_rNewName,
     360             :         ::osl::ResettableMutexGuard& i_rClearForNotify
     361             :     );
     362             :     ~NameChangeNotifier();
     363             : 
     364             : private:
     365             :             ODocumentDefinition&            m_rDocumentDefinition;
     366             :     const   ::com::sun::star::uno::Any      m_aOldValue;
     367             :     const   ::com::sun::star::uno::Any      m_aNewValue;
     368             :     ::osl::ResettableMutexGuard&    m_rClearForNotify;
     369             : 
     370             :     void    impl_fireEvent_throw( const sal_Bool i_bVetoable );
     371             : };
     372             : 
     373             : }   // namespace dbaccess
     374             : 
     375             : #endif // _DBA_COREDATAACCESS_DOCUMENTDEFINITION_HXX_
     376             : 
     377             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10