LCOV - code coverage report
Current view: top level - chart2/source/controller/main - ChartTransferable.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 59 0.0 %
Date: 2012-08-25 Functions: 0 6 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 104 0.0 %

           Branch data     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                 :            : 
      21                 :            : #include "ChartTransferable.hxx"
      22                 :            : 
      23                 :            : #include <unotools/streamwrap.hxx>
      24                 :            : #include <vcl/graph.hxx>
      25                 :            : #include <svl/itempool.hxx>
      26                 :            : #include <editeng/eeitem.hxx>
      27                 :            : #include <editeng/fhgtitem.hxx>
      28                 :            : #include <svx/svditer.hxx>
      29                 :            : #include <svx/svdmodel.hxx>
      30                 :            : #include <svx/svdpage.hxx>
      31                 :            : #include <svx/unomodel.hxx>
      32                 :            : 
      33                 :            : // header for class SdrView
      34                 :            : #include <svx/svdview.hxx>
      35                 :            : 
      36                 :            : #define CHARTTRANSFER_OBJECTTYPE_DRAWMODEL      1
      37                 :            : 
      38                 :            : using namespace ::com::sun::star;
      39                 :            : 
      40                 :            : using ::com::sun::star::uno::Reference;
      41                 :            : using ::com::sun::star::uno::Sequence;
      42                 :            : using ::rtl::OUString;
      43                 :            : 
      44                 :            : namespace chart
      45                 :            : {
      46                 :            : 
      47                 :          0 : ChartTransferable::ChartTransferable( SdrModel* pDrawModel, SdrObject* pSelectedObj, bool bDrawing )
      48                 :            :     :m_pMarkedObjModel( NULL )
      49                 :          0 :     ,m_bDrawing( bDrawing )
      50                 :            : {
      51 [ #  # ][ #  # ]:          0 :     SdrExchangeView * pExchgView( new SdrView( pDrawModel ));
      52 [ #  # ][ #  # ]:          0 :     SdrPageView* pPv = pExchgView->ShowSdrPage( pDrawModel->GetPage( 0 ));
      53         [ #  # ]:          0 :     if( pSelectedObj )
      54         [ #  # ]:          0 :         pExchgView->MarkObj( pSelectedObj, pPv );
      55                 :            :     else
      56         [ #  # ]:          0 :         pExchgView->MarkAllObj( pPv );
      57 [ #  # ][ #  # ]:          0 :     Graphic aGraphic( pExchgView->GetMarkedObjMetaFile(true));
                 [ #  # ]
      58 [ #  # ][ #  # ]:          0 :     m_xMetaFileGraphic.set( aGraphic.GetXGraphic());
      59         [ #  # ]:          0 :     if ( m_bDrawing )
      60                 :            :     {
      61 [ #  # ][ #  # ]:          0 :         m_pMarkedObjModel = ( pExchgView ? pExchgView->GetAllMarkedModel() : NULL );
      62                 :            :     }
      63 [ #  # ][ #  # ]:          0 :     delete pExchgView;
                 [ #  # ]
      64                 :          0 : }
      65                 :            : 
      66                 :          0 : ChartTransferable::~ChartTransferable()
      67         [ #  # ]:          0 : {}
      68                 :            : 
      69                 :          0 : void ChartTransferable::AddSupportedFormats()
      70                 :            : {
      71         [ #  # ]:          0 :     if ( m_bDrawing )
      72                 :            :     {
      73                 :          0 :         AddFormat( SOT_FORMATSTR_ID_DRAWING );
      74                 :            :     }
      75                 :          0 :     AddFormat( SOT_FORMAT_GDIMETAFILE );
      76                 :          0 :     AddFormat( SOT_FORMAT_BITMAP );
      77                 :          0 : }
      78                 :            : 
      79                 :          0 : sal_Bool ChartTransferable::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
      80                 :            : {
      81                 :          0 :     sal_uInt32  nFormat = SotExchange::GetFormat( rFlavor );
      82                 :          0 :     sal_Bool    bResult = sal_False;
      83                 :            : 
      84         [ #  # ]:          0 :     if( HasFormat( nFormat ))
      85                 :            :     {
      86         [ #  # ]:          0 :         if ( nFormat == SOT_FORMATSTR_ID_DRAWING )
      87                 :            :         {
      88                 :          0 :             bResult = SetObject( m_pMarkedObjModel, CHARTTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor );
      89                 :            :         }
      90         [ #  # ]:          0 :         else if ( nFormat == FORMAT_GDIMETAFILE )
      91                 :            :         {
      92         [ #  # ]:          0 :             Graphic aGraphic( m_xMetaFileGraphic );
      93 [ #  # ][ #  # ]:          0 :             bResult = SetGDIMetaFile( aGraphic.GetGDIMetaFile(), rFlavor );
                 [ #  # ]
      94                 :            :         }
      95         [ #  # ]:          0 :         else if( nFormat == FORMAT_BITMAP )
      96                 :            :         {
      97         [ #  # ]:          0 :             Graphic aGraphic( m_xMetaFileGraphic );
      98 [ #  # ][ #  # ]:          0 :             bResult = SetBitmap( aGraphic.GetBitmap(), rFlavor );
         [ #  # ][ #  # ]
      99                 :            :         }
     100                 :            :     }
     101                 :            : 
     102                 :          0 :     return bResult;
     103                 :            : }
     104                 :            : 
     105                 :          0 : sal_Bool ChartTransferable::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
     106                 :            :     const datatransfer::DataFlavor& /* rFlavor */ )
     107                 :            : {
     108                 :            :     // called from SetObject, put data into stream
     109                 :            : 
     110                 :          0 :     sal_Bool bRet = sal_False;
     111         [ #  # ]:          0 :     switch ( nUserObjectId )
     112                 :            :     {
     113                 :            :         case CHARTTRANSFER_OBJECTTYPE_DRAWMODEL:
     114                 :            :             {
     115                 :          0 :                 SdrModel* pMarkedObjModel = reinterpret_cast< SdrModel* >( pUserObject );
     116         [ #  # ]:          0 :                 if ( pMarkedObjModel )
     117                 :            :                 {
     118         [ #  # ]:          0 :                     rxOStm->SetBufferSize( 0xff00 );
     119                 :            : 
     120                 :            :                     // for the changed pool defaults from drawing layer pool set those
     121                 :            :                     // attributes as hard attributes to preserve them for saving
     122                 :          0 :                     const SfxItemPool& rItemPool = pMarkedObjModel->GetItemPool();
     123                 :            :                     const SvxFontHeightItem& rDefaultFontHeight = static_cast< const SvxFontHeightItem& >(
     124         [ #  # ]:          0 :                         rItemPool.GetDefaultItem( EE_CHAR_FONTHEIGHT ) );
     125         [ #  # ]:          0 :                     sal_uInt16 nCount = pMarkedObjModel->GetPageCount();
     126         [ #  # ]:          0 :                     for ( sal_uInt16 i = 0; i < nCount; ++i )
     127                 :            :                     {
     128         [ #  # ]:          0 :                         const SdrPage* pPage = pMarkedObjModel->GetPage( i );
     129         [ #  # ]:          0 :                         SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
     130         [ #  # ]:          0 :                         while ( aIter.IsMore() )
     131                 :            :                         {
     132         [ #  # ]:          0 :                             SdrObject* pObj = aIter.Next();
     133                 :            :                             const SvxFontHeightItem& rItem = static_cast< const SvxFontHeightItem& >(
     134         [ #  # ]:          0 :                                 pObj->GetMergedItem( EE_CHAR_FONTHEIGHT ) );
     135         [ #  # ]:          0 :                             if ( rItem.GetHeight() == rDefaultFontHeight.GetHeight() )
     136                 :            :                             {
     137         [ #  # ]:          0 :                                 pObj->SetMergedItem( rDefaultFontHeight );
     138                 :            :                             }
     139                 :            :                         }
     140                 :          0 :                     }
     141                 :            : 
     142 [ #  # ][ #  # ]:          0 :                     Reference< io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) );
                 [ #  # ]
     143 [ #  # ][ #  # ]:          0 :                     if ( SvxDrawingLayerExport( pMarkedObjModel, xDocOut ) )
     144                 :            :                     {
     145         [ #  # ]:          0 :                         rxOStm->Commit();
     146                 :            :                     }
     147                 :            : 
     148                 :          0 :                     bRet = ( rxOStm->GetError() == ERRCODE_NONE );
     149                 :            :                 }
     150                 :            :             }
     151                 :          0 :             break;
     152                 :            :         default:
     153                 :            :             {
     154                 :            :                 OSL_FAIL( "ChartTransferable::WriteObject: unknown object id" );
     155                 :            :             }
     156                 :          0 :             break;
     157                 :            :     }
     158                 :          0 :     return bRet;
     159                 :            : }
     160                 :            : 
     161                 :            : } //  namespace chart
     162                 :            : 
     163                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10