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

Generated by: LCOV version 1.11