LCOV - code coverage report
Current view: top level - embeddedobj/source/commonembedding - specialobject.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 74 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 152 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      30                 :            : #include <com/sun/star/embed/EmbedStates.hpp>
      31                 :            : #include <com/sun/star/embed/EmbedVerbs.hpp>
      32                 :            : #include <com/sun/star/embed/EmbedUpdateModes.hpp>
      33                 :            : #include <com/sun/star/embed/XEmbeddedClient.hpp>
      34                 :            : #include <com/sun/star/embed/XInplaceClient.hpp>
      35                 :            : #include <com/sun/star/embed/XWindowSupplier.hpp>
      36                 :            : #include <com/sun/star/embed/Aspects.hpp>
      37                 :            : #include <com/sun/star/awt/XWindowPeer.hpp>
      38                 :            : #include <com/sun/star/util/XCloseBroadcaster.hpp>
      39                 :            : #include <com/sun/star/util/XCloseable.hpp>
      40                 :            : #include <com/sun/star/util/XModifiable.hpp>
      41                 :            : #include <com/sun/star/frame/XFrame.hpp>
      42                 :            : #include <com/sun/star/frame/XComponentLoader.hpp>
      43                 :            : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
      44                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      45                 :            : #include <com/sun/star/embed/EmbedMapUnits.hpp>
      46                 :            : 
      47                 :            : #include <cppuhelper/typeprovider.hxx>
      48                 :            : 
      49                 :            : #include "specialobject.hxx"
      50                 :            : #include "intercept.hxx"
      51                 :            : 
      52                 :            : using namespace ::com::sun::star;
      53                 :            : 
      54                 :            : 
      55                 :          0 : OSpecialEmbeddedObject::OSpecialEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory, const uno::Sequence< beans::NamedValue >& aObjectProps )
      56                 :          0 : : OCommonEmbeddedObject( xFactory, aObjectProps )
      57                 :            : {
      58                 :          0 :     maSize.Width = maSize.Height = 10000;
      59                 :          0 :     m_nObjectState = embed::EmbedStates::LOADED;
      60                 :          0 : }
      61                 :            : 
      62                 :            : //------------------------------------------------------
      63                 :          0 : uno::Any SAL_CALL OSpecialEmbeddedObject::queryInterface( const uno::Type& rType )
      64                 :            :         throw( uno::RuntimeException )
      65                 :            : {
      66                 :          0 :     uno::Any aReturn;
      67                 :            : 
      68                 :            :     aReturn <<= ::cppu::queryInterface( rType,
      69                 :            :                                         static_cast< embed::XEmbeddedObject* >( this ),
      70                 :            :                                         static_cast< embed::XInplaceObject* >( this ),
      71                 :            :                                         static_cast< embed::XVisualObject* >( this ),
      72                 :            :                                         static_cast< embed::XClassifiedObject* >( this ),
      73                 :            :                                         static_cast< embed::XComponentSupplier* >( this ),
      74                 :            :                                         static_cast< util::XCloseable* >( this ),
      75 [ #  # ][ #  # ]:          0 :                                         static_cast< document::XEventBroadcaster* >( this ) );
      76         [ #  # ]:          0 :     if ( aReturn.hasValue() )
      77                 :          0 :         return aReturn;
      78                 :            :     else
      79         [ #  # ]:          0 :         return ::cppu::OWeakObject::queryInterface( rType ) ;
      80                 :            : 
      81                 :            : }
      82                 :            : 
      83                 :            : //------------------------------------------------------
      84                 :          0 : uno::Sequence< uno::Type > SAL_CALL OSpecialEmbeddedObject::getTypes()
      85                 :            :         throw( uno::RuntimeException )
      86                 :            : {
      87                 :            :     static ::cppu::OTypeCollection* pTypeCollection = NULL;
      88                 :            : 
      89         [ #  # ]:          0 :     if ( !pTypeCollection )
      90                 :            :     {
      91 [ #  # ][ #  # ]:          0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
      92         [ #  # ]:          0 :         if ( !pTypeCollection )
      93                 :            :         {
      94                 :            :             static ::cppu::OTypeCollection aTypeCollection(
      95         [ #  # ]:          0 :                                         ::getCppuType( (const uno::Reference< lang::XTypeProvider >*)NULL ),
      96         [ #  # ]:          0 :                                         ::getCppuType( (const uno::Reference< embed::XEmbeddedObject >*)NULL ),
      97 [ #  # ][ #  # ]:          0 :                                         ::getCppuType( (const uno::Reference< embed::XInplaceObject >*)NULL ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      98                 :            : 
      99                 :          0 :             pTypeCollection = &aTypeCollection ;
     100         [ #  # ]:          0 :         }
     101                 :            :     }
     102                 :            : 
     103                 :          0 :     return pTypeCollection->getTypes() ;
     104                 :            : 
     105                 :            : }
     106                 :            : 
     107                 :          0 : embed::VisualRepresentation SAL_CALL OSpecialEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 nAspect )
     108                 :            :         throw ( lang::IllegalArgumentException,
     109                 :            :                 embed::WrongStateException,
     110                 :            :                 uno::Exception,
     111                 :            :                 uno::RuntimeException )
     112                 :            : {
     113         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
     114         [ #  # ]:          0 :     if ( m_bDisposed )
     115         [ #  # ]:          0 :         throw lang::DisposedException(); // TODO
     116                 :            : 
     117                 :            :     // TODO: if object is in loaded state it should switch itself to the running state
     118 [ #  # ][ #  # ]:          0 :     if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::LOADED )
     119                 :            :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The own object has no model!\n" )),
     120 [ #  # ][ #  # ]:          0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
                 [ #  # ]
     121                 :            : 
     122                 :            :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     123         [ #  # ]:          0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     124                 :            :         // no representation can be retrieved
     125                 :            :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
     126 [ #  # ][ #  # ]:          0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
                 [ #  # ]
     127                 :            : 
     128                 :            :     // TODO: return for the aspect of the document
     129                 :          0 :     embed::VisualRepresentation aVisualRepresentation;
     130         [ #  # ]:          0 :     return aVisualRepresentation;
     131                 :            : }
     132                 :            : 
     133                 :          0 : void SAL_CALL OSpecialEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt::Size& aSize )
     134                 :            :         throw ( lang::IllegalArgumentException,
     135                 :            :                 embed::WrongStateException,
     136                 :            :                 uno::Exception,
     137                 :            :                 uno::RuntimeException )
     138                 :            : {
     139         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
     140         [ #  # ]:          0 :     if ( m_bDisposed )
     141         [ #  # ]:          0 :         throw lang::DisposedException(); // TODO
     142                 :            : 
     143                 :            :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     144         [ #  # ]:          0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     145                 :            :         // no representation can be retrieved
     146                 :            :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
     147 [ #  # ][ #  # ]:          0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
                 [ #  # ]
     148                 :            : 
     149         [ #  # ]:          0 :     maSize = aSize;
     150                 :          0 : }
     151                 :            : 
     152                 :          0 : awt::Size SAL_CALL OSpecialEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
     153                 :            :         throw ( lang::IllegalArgumentException,
     154                 :            :                 embed::WrongStateException,
     155                 :            :                 uno::Exception,
     156                 :            :                 uno::RuntimeException )
     157                 :            : {
     158         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
     159         [ #  # ]:          0 :     if ( m_bDisposed )
     160         [ #  # ]:          0 :         throw lang::DisposedException(); // TODO
     161                 :            : 
     162                 :            :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     163         [ #  # ]:          0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     164                 :            :         // no representation can be retrieved
     165                 :            :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
     166 [ #  # ][ #  # ]:          0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
                 [ #  # ]
     167                 :            : 
     168         [ #  # ]:          0 :     if ( m_nObjectState == -1 )
     169                 :            :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The own object has no model!\n" )),
     170 [ #  # ][ #  # ]:          0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
                 [ #  # ]
     171                 :            : 
     172                 :          0 :     awt::Size aResult;
     173         [ #  # ]:          0 :     return maSize;
     174                 :            : }
     175                 :            : 
     176                 :          0 : sal_Int32 SAL_CALL OSpecialEmbeddedObject::getMapUnit( sal_Int64 nAspect )
     177                 :            :         throw ( uno::Exception,
     178                 :            :                 uno::RuntimeException)
     179                 :            : {
     180         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
     181         [ #  # ]:          0 :     if ( m_bDisposed )
     182         [ #  # ]:          0 :         throw lang::DisposedException(); // TODO
     183                 :            : 
     184                 :            :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     185         [ #  # ]:          0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     186                 :            :         // no representation can be retrieved
     187                 :            :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
     188 [ #  # ][ #  # ]:          0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
                 [ #  # ]
     189                 :            : 
     190         [ #  # ]:          0 :     return embed::EmbedMapUnits::ONE_100TH_MM;
     191                 :            : }
     192                 :            : 
     193                 :          0 : void SAL_CALL OSpecialEmbeddedObject::changeState( sal_Int32 nNewState )
     194                 :            :         throw ( ::com::sun::star::embed::UnreachableStateException,
     195                 :            :                 ::com::sun::star::embed::WrongStateException,
     196                 :            :                 ::com::sun::star::uno::Exception,
     197                 :            :                 ::com::sun::star::uno::RuntimeException )
     198                 :            : {
     199         [ #  # ]:          0 :     if ( nNewState == embed::EmbedStates::UI_ACTIVE )
     200                 :          0 :         nNewState = embed::EmbedStates::INPLACE_ACTIVE;
     201                 :          0 :     OCommonEmbeddedObject::changeState( nNewState );
     202                 :          0 : }
     203                 :            : 
     204                 :          0 : void SAL_CALL OSpecialEmbeddedObject::doVerb( sal_Int32 nVerbID )
     205                 :            :         throw ( lang::IllegalArgumentException,
     206                 :            :                 embed::WrongStateException,
     207                 :            :                 embed::UnreachableStateException,
     208                 :            :                 uno::Exception,
     209                 :            :                 uno::RuntimeException )
     210                 :            : {
     211         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
     212         [ #  # ]:          0 :     if ( m_bDisposed )
     213         [ #  # ]:          0 :         throw lang::DisposedException(); // TODO
     214                 :            : 
     215         [ #  # ]:          0 :     if ( m_nObjectState == -1 )
     216                 :            :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object has no persistence!\n" )),
     217 [ #  # ][ #  # ]:          0 :                                         uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
                 [ #  # ]
     218                 :            : 
     219         [ #  # ]:          0 :     if ( nVerbID == -7 )
     220                 :            :     {
     221                 :            : 
     222 [ #  # ][ #  # ]:          0 :         uno::Reference < ui::dialogs::XExecutableDialog > xDlg( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
     223         [ #  # ]:          0 :         if ( xDlg.is() )
     224 [ #  # ][ #  # ]:          0 :             xDlg->execute();
     225                 :            :         else
     226         [ #  # ]:          0 :             throw embed::UnreachableStateException();
     227                 :            :     }
     228                 :            :     else
     229 [ #  # ][ #  # ]:          0 :         OCommonEmbeddedObject::doVerb( nVerbID );
     230                 :          0 : }
     231                 :            : 
     232                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10