LCOV - code coverage report
Current view: top level - embeddedobj/source/commonembedding - visobj.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 85 0.0 %
Date: 2014-04-14 Functions: 0 4 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/embed/Aspects.hpp>
      21             : #include <com/sun/star/embed/EmbedStates.hpp>
      22             : #include <com/sun/star/datatransfer/XTransferable.hpp>
      23             : #include <com/sun/star/uno/Sequence.hxx>
      24             : #include <com/sun/star/lang/DisposedException.hpp>
      25             : 
      26             : 
      27             : #include <commonembobj.hxx>
      28             : 
      29             : 
      30             : using namespace ::com::sun::star;
      31             : 
      32           0 : void SAL_CALL OCommonEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt::Size& aSize )
      33             :         throw ( lang::IllegalArgumentException,
      34             :                 embed::WrongStateException,
      35             :                 uno::Exception,
      36             :                 uno::RuntimeException, std::exception )
      37             : {
      38           0 :     ::osl::MutexGuard aGuard( m_aMutex );
      39           0 :     if ( m_bDisposed )
      40           0 :         throw lang::DisposedException(); // TODO
      41             : 
      42             :     SAL_WARN_IF( nAspect == embed::Aspects::MSOLE_ICON, "embeddedobj.common", "For iconified objects no graphical replacement is required!" );
      43           0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
      44             :         // no representation can be retrieved
      45             :         throw embed::WrongStateException( OUString( "Illegal call!\n" ),
      46           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
      47             : 
      48           0 :     if ( m_nObjectState == -1 )
      49             :         throw embed::WrongStateException( OUString( "The own object has no persistence!\n" ),
      50           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
      51             : 
      52           0 :     m_bHasClonedSize = sal_False;
      53             : 
      54           0 :     sal_Bool bBackToLoaded = sal_False;
      55           0 :     if ( m_nObjectState == embed::EmbedStates::LOADED )
      56             :     {
      57           0 :         changeState( embed::EmbedStates::RUNNING );
      58             : 
      59             :         // the links should be switched back to loaded state for now to avoid locking problems
      60           0 :         bBackToLoaded = m_bIsLink;
      61             :     }
      62             : 
      63           0 :     sal_Bool bSuccess = m_pDocHolder->SetExtent( nAspect, aSize );
      64             : 
      65           0 :     if ( bBackToLoaded )
      66           0 :         changeState( embed::EmbedStates::LOADED );
      67             : 
      68           0 :     if ( !bSuccess )
      69           0 :         throw uno::Exception(); // TODO:
      70           0 : }
      71             : 
      72           0 : awt::Size SAL_CALL OCommonEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
      73             :         throw ( lang::IllegalArgumentException,
      74             :                 embed::WrongStateException,
      75             :                 uno::Exception,
      76             :                 uno::RuntimeException, std::exception )
      77             : {
      78           0 :     ::osl::MutexGuard aGuard( m_aMutex );
      79           0 :     if ( m_bDisposed )
      80           0 :         throw lang::DisposedException(); // TODO
      81             : 
      82           0 :     if ( m_nObjectState == -1 )
      83             :         throw embed::WrongStateException( OUString( "The own object has no persistence!\n" ),
      84           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
      85             : 
      86             :     SAL_WARN_IF( nAspect == embed::Aspects::MSOLE_ICON, "embeddedobj.common", "For iconified objects no graphical replacement is required!" );
      87             : 
      88           0 :     if ( m_bHasClonedSize )
      89           0 :         return m_aClonedSize;
      90             : 
      91           0 :     sal_Bool bBackToLoaded = sal_False;
      92           0 :     if ( m_nObjectState == embed::EmbedStates::LOADED )
      93             :     {
      94           0 :         changeState( embed::EmbedStates::RUNNING );
      95             : 
      96             :         // the links should be switched back to loaded state for now to avoid locking problems
      97           0 :         bBackToLoaded = m_bIsLink;
      98             :     }
      99             : 
     100           0 :     awt::Size aResult;
     101           0 :     sal_Bool bSuccess = m_pDocHolder->GetExtent( nAspect, &aResult );
     102             : 
     103           0 :     if ( bBackToLoaded )
     104           0 :         changeState( embed::EmbedStates::LOADED );
     105             : 
     106           0 :     if ( !bSuccess )
     107           0 :         throw uno::Exception(); // TODO:
     108             : 
     109           0 :     return aResult;
     110             : }
     111             : 
     112           0 : sal_Int32 SAL_CALL OCommonEmbeddedObject::getMapUnit( sal_Int64 nAspect )
     113             :         throw ( uno::Exception,
     114             :                 uno::RuntimeException, std::exception)
     115             : {
     116           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     117           0 :     if ( m_bDisposed )
     118           0 :         throw lang::DisposedException(); // TODO
     119             : 
     120             :     SAL_WARN_IF( nAspect == embed::Aspects::MSOLE_ICON, "embeddedobj.common", "For iconified objects no graphical replacement is required!" );
     121           0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     122             :         // no representation can be retrieved
     123             :         throw embed::WrongStateException( OUString( "Illegal call!\n" ),
     124           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     125             : 
     126           0 :     if ( m_nObjectState == -1 )
     127             :         throw embed::WrongStateException( OUString( "The own object has no persistence!\n" ),
     128           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     129             : 
     130           0 :     if ( m_bHasClonedSize )
     131           0 :         return m_nClonedMapUnit;
     132             : 
     133           0 :     sal_Bool bBackToLoaded = sal_False;
     134           0 :     if ( m_nObjectState == embed::EmbedStates::LOADED )
     135             :     {
     136           0 :         changeState( embed::EmbedStates::RUNNING );
     137             : 
     138             :         // the links should be switched back to loaded state for now to avoid locking problems
     139           0 :         bBackToLoaded = m_bIsLink;
     140             :     }
     141             : 
     142           0 :     sal_Int32 nResult = m_pDocHolder->GetMapUnit( nAspect );
     143             : 
     144           0 :     if ( bBackToLoaded )
     145           0 :         changeState( embed::EmbedStates::LOADED );
     146             : 
     147           0 :     if ( nResult < 0  )
     148           0 :         throw uno::Exception(); // TODO:
     149             : 
     150           0 :     return nResult;
     151             : }
     152             : 
     153           0 : embed::VisualRepresentation SAL_CALL OCommonEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 nAspect )
     154             :         throw ( lang::IllegalArgumentException,
     155             :                 embed::WrongStateException,
     156             :                 uno::Exception,
     157             :                 uno::RuntimeException, std::exception )
     158             : {
     159           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     160           0 :     if ( m_bDisposed )
     161           0 :         throw lang::DisposedException(); // TODO
     162             : 
     163           0 :     if ( m_nObjectState == -1 )
     164             :         throw embed::WrongStateException( OUString( "The own object has no persistence!\n" ),
     165           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     166             : 
     167             : 
     168             :     SAL_WARN_IF( nAspect == embed::Aspects::MSOLE_ICON, "embeddedobj.common", "For iconified objects no graphical replacement is required!" );
     169           0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     170             :         // no representation can be retrieved
     171             :         throw embed::WrongStateException( OUString( "Illegal call!\n" ),
     172           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     173             : 
     174           0 :     sal_Bool bBackToLoaded = sal_False;
     175           0 :     if ( m_nObjectState == embed::EmbedStates::LOADED )
     176             :     {
     177           0 :         changeState( embed::EmbedStates::RUNNING );
     178             : 
     179             :         // the links should be switched back to loaded state for now to avoid locking problems
     180           0 :         bBackToLoaded = m_bIsLink;
     181             :     }
     182             : 
     183             :     SAL_WARN_IF( !m_pDocHolder->GetComponent().is(), "embeddedobj.common", "Running or Active object has no component!" );
     184             : 
     185             :     // TODO: return for the aspect of the document
     186           0 :     embed::VisualRepresentation aVisualRepresentation;
     187             : 
     188           0 :     uno::Reference< embed::XVisualObject > xVisualObject( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
     189           0 :     if( xVisualObject.is())
     190             :     {
     191           0 :         aVisualRepresentation = xVisualObject->getPreferredVisualRepresentation( nAspect );
     192             :     }
     193             :     else
     194             :     {
     195           0 :         uno::Reference< datatransfer::XTransferable > xTransferable( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
     196           0 :         if (!xTransferable.is() )
     197           0 :             throw uno::RuntimeException();
     198             : 
     199             :         datatransfer::DataFlavor aDataFlavor(
     200             :                 OUString( "application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"" ),
     201             :                 OUString( "GDIMetaFile" ),
     202           0 :                 ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) );
     203             : 
     204           0 :         if( xTransferable->isDataFlavorSupported( aDataFlavor ))
     205             :         {
     206           0 :             aVisualRepresentation.Data = xTransferable->getTransferData( aDataFlavor );
     207           0 :             aVisualRepresentation.Flavor = aDataFlavor;
     208             :         }
     209             :         else
     210           0 :             throw uno::RuntimeException();
     211             :     }
     212             : 
     213           0 :     if ( bBackToLoaded )
     214           0 :         changeState( embed::EmbedStates::LOADED );
     215             : 
     216           0 :     return aVisualRepresentation;
     217             : }
     218             : 
     219             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10