LCOV - code coverage report
Current view: top level - libreoffice/embeddedobj/source/commonembedding - specialobject.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 74 0.0 %
Date: 2012-12-27 Functions: 0 9 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             : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      21             : #include <com/sun/star/embed/EmbedStates.hpp>
      22             : #include <com/sun/star/embed/EmbedVerbs.hpp>
      23             : #include <com/sun/star/embed/EmbedUpdateModes.hpp>
      24             : #include <com/sun/star/embed/XEmbeddedClient.hpp>
      25             : #include <com/sun/star/embed/XInplaceClient.hpp>
      26             : #include <com/sun/star/embed/XWindowSupplier.hpp>
      27             : #include <com/sun/star/embed/Aspects.hpp>
      28             : #include <com/sun/star/awt/XWindowPeer.hpp>
      29             : #include <com/sun/star/util/XCloseBroadcaster.hpp>
      30             : #include <com/sun/star/util/XCloseable.hpp>
      31             : #include <com/sun/star/util/XModifiable.hpp>
      32             : #include <com/sun/star/frame/XFrame.hpp>
      33             : #include <com/sun/star/frame/XComponentLoader.hpp>
      34             : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
      35             : #include <com/sun/star/lang/DisposedException.hpp>
      36             : #include <com/sun/star/embed/EmbedMapUnits.hpp>
      37             : 
      38             : #include <cppuhelper/typeprovider.hxx>
      39             : 
      40             : #include "specialobject.hxx"
      41             : #include "intercept.hxx"
      42             : 
      43             : using namespace ::com::sun::star;
      44             : 
      45             : 
      46           0 : OSpecialEmbeddedObject::OSpecialEmbeddedObject( const uno::Reference< lang::XMultiServiceFactory >& xFactory, const uno::Sequence< beans::NamedValue >& aObjectProps )
      47           0 : : OCommonEmbeddedObject( xFactory, aObjectProps )
      48             : {
      49           0 :     maSize.Width = maSize.Height = 10000;
      50           0 :     m_nObjectState = embed::EmbedStates::LOADED;
      51           0 : }
      52             : 
      53             : //------------------------------------------------------
      54           0 : uno::Any SAL_CALL OSpecialEmbeddedObject::queryInterface( const uno::Type& rType )
      55             :         throw( uno::RuntimeException )
      56             : {
      57           0 :     uno::Any aReturn;
      58             : 
      59             :     aReturn <<= ::cppu::queryInterface( rType,
      60             :                                         static_cast< embed::XEmbeddedObject* >( this ),
      61             :                                         static_cast< embed::XInplaceObject* >( this ),
      62             :                                         static_cast< embed::XVisualObject* >( this ),
      63             :                                         static_cast< embed::XClassifiedObject* >( this ),
      64             :                                         static_cast< embed::XComponentSupplier* >( this ),
      65             :                                         static_cast< util::XCloseable* >( this ),
      66           0 :                                         static_cast< document::XEventBroadcaster* >( this ) );
      67           0 :     if ( aReturn.hasValue() )
      68           0 :         return aReturn;
      69             :     else
      70           0 :         return ::cppu::OWeakObject::queryInterface( rType ) ;
      71             : 
      72             : }
      73             : 
      74             : //------------------------------------------------------
      75           0 : uno::Sequence< uno::Type > SAL_CALL OSpecialEmbeddedObject::getTypes()
      76             :         throw( uno::RuntimeException )
      77             : {
      78             :     static ::cppu::OTypeCollection* pTypeCollection = NULL;
      79             : 
      80           0 :     if ( !pTypeCollection )
      81             :     {
      82           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
      83           0 :         if ( !pTypeCollection )
      84             :         {
      85             :             static ::cppu::OTypeCollection aTypeCollection(
      86           0 :                                         ::getCppuType( (const uno::Reference< lang::XTypeProvider >*)NULL ),
      87           0 :                                         ::getCppuType( (const uno::Reference< embed::XEmbeddedObject >*)NULL ),
      88           0 :                                         ::getCppuType( (const uno::Reference< embed::XInplaceObject >*)NULL ) );
      89             : 
      90           0 :             pTypeCollection = &aTypeCollection ;
      91           0 :         }
      92             :     }
      93             : 
      94           0 :     return pTypeCollection->getTypes() ;
      95             : 
      96             : }
      97             : 
      98           0 : embed::VisualRepresentation SAL_CALL OSpecialEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 nAspect )
      99             :         throw ( lang::IllegalArgumentException,
     100             :                 embed::WrongStateException,
     101             :                 uno::Exception,
     102             :                 uno::RuntimeException )
     103             : {
     104           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     105           0 :     if ( m_bDisposed )
     106           0 :         throw lang::DisposedException(); // TODO
     107             : 
     108             :     // TODO: if object is in loaded state it should switch itself to the running state
     109           0 :     if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::LOADED )
     110             :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The own object has no model!\n" )),
     111           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     112             : 
     113             :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     114           0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     115             :         // no representation can be retrieved
     116             :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
     117           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     118             : 
     119             :     // TODO: return for the aspect of the document
     120           0 :     embed::VisualRepresentation aVisualRepresentation;
     121           0 :     return aVisualRepresentation;
     122             : }
     123             : 
     124           0 : void SAL_CALL OSpecialEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt::Size& aSize )
     125             :         throw ( lang::IllegalArgumentException,
     126             :                 embed::WrongStateException,
     127             :                 uno::Exception,
     128             :                 uno::RuntimeException )
     129             : {
     130           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     131           0 :     if ( m_bDisposed )
     132           0 :         throw lang::DisposedException(); // TODO
     133             : 
     134             :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     135           0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     136             :         // no representation can be retrieved
     137             :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
     138           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     139             : 
     140           0 :     maSize = aSize;
     141           0 : }
     142             : 
     143           0 : awt::Size SAL_CALL OSpecialEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
     144             :         throw ( lang::IllegalArgumentException,
     145             :                 embed::WrongStateException,
     146             :                 uno::Exception,
     147             :                 uno::RuntimeException )
     148             : {
     149           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     150           0 :     if ( m_bDisposed )
     151           0 :         throw lang::DisposedException(); // TODO
     152             : 
     153             :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     154           0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     155             :         // no representation can be retrieved
     156             :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
     157           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     158             : 
     159           0 :     if ( m_nObjectState == -1 )
     160             :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The own object has no model!\n" )),
     161           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     162             : 
     163           0 :     awt::Size aResult;
     164           0 :     return maSize;
     165             : }
     166             : 
     167           0 : sal_Int32 SAL_CALL OSpecialEmbeddedObject::getMapUnit( sal_Int64 nAspect )
     168             :         throw ( uno::Exception,
     169             :                 uno::RuntimeException)
     170             : {
     171           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     172           0 :     if ( m_bDisposed )
     173           0 :         throw lang::DisposedException(); // TODO
     174             : 
     175             :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     176           0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     177             :         // no representation can be retrieved
     178             :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Illegal call!\n" )),
     179           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     180             : 
     181           0 :     return embed::EmbedMapUnits::ONE_100TH_MM;
     182             : }
     183             : 
     184           0 : void SAL_CALL OSpecialEmbeddedObject::changeState( sal_Int32 nNewState )
     185             :         throw ( ::com::sun::star::embed::UnreachableStateException,
     186             :                 ::com::sun::star::embed::WrongStateException,
     187             :                 ::com::sun::star::uno::Exception,
     188             :                 ::com::sun::star::uno::RuntimeException )
     189             : {
     190           0 :     if ( nNewState == embed::EmbedStates::UI_ACTIVE )
     191           0 :         nNewState = embed::EmbedStates::INPLACE_ACTIVE;
     192           0 :     OCommonEmbeddedObject::changeState( nNewState );
     193           0 : }
     194             : 
     195           0 : void SAL_CALL OSpecialEmbeddedObject::doVerb( sal_Int32 nVerbID )
     196             :         throw ( lang::IllegalArgumentException,
     197             :                 embed::WrongStateException,
     198             :                 embed::UnreachableStateException,
     199             :                 uno::Exception,
     200             :                 uno::RuntimeException )
     201             : {
     202           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     203           0 :     if ( m_bDisposed )
     204           0 :         throw lang::DisposedException(); // TODO
     205             : 
     206           0 :     if ( m_nObjectState == -1 )
     207             :         throw embed::WrongStateException( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "The object has no persistence!\n" )),
     208           0 :                                         uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     209             : 
     210           0 :     if ( nVerbID == -7 )
     211             :     {
     212             : 
     213           0 :         uno::Reference < ui::dialogs::XExecutableDialog > xDlg( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
     214           0 :         if ( xDlg.is() )
     215           0 :             xDlg->execute();
     216             :         else
     217           0 :             throw embed::UnreachableStateException();
     218             :     }
     219             :     else
     220           0 :         OCommonEmbeddedObject::doVerb( nVerbID );
     221           0 : }
     222             : 
     223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10