LCOV - code coverage report
Current view: top level - libreoffice/sd/source/filter/cgm - sdcgmfilter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 39 0.0 %
Date: 2012-12-17 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             : 
      21             : #include <osl/module.hxx>
      22             : #include <tools/urlobj.hxx>
      23             : #include <svl/itemset.hxx>
      24             : #include <sfx2/docfile.hxx>
      25             : #include <sfx2/docfilt.hxx>
      26             : #include <svx/xflclit.hxx>
      27             : #include <svx/xfillit0.hxx>
      28             : 
      29             : #include "sdpage.hxx"
      30             : #include "drawdoc.hxx"
      31             : #include "sdcgmfilter.hxx"
      32             : 
      33             : // -----------
      34             : // - Defines -
      35             : // -----------
      36             : 
      37             : #define CGM_IMPORT_CGM      0x00000001
      38             : #define CGM_IMPORT_IM       0x00000002
      39             : 
      40             : #define CGM_EXPORT_IMPRESS  0x00000100
      41             : #define CGM_EXPORT_META     0x00000200
      42             : #define CGM_EXPORT_COMMENT  0x00000400
      43             : 
      44             : #define CGM_NO_PAD_BYTE     0x00010000
      45             : #define CGM_BIG_ENDIAN      0x00020000
      46             : #define CGM_LITTLE_ENDIAN   0x00040000
      47             : 
      48             : // --------------
      49             : // - Namespaces -
      50             : // --------------
      51             : 
      52             : using namespace ::com::sun::star::uno;
      53             : using namespace ::com::sun::star::task;
      54             : using namespace ::com::sun::star::frame;
      55             : 
      56             : // ------------
      57             : // - Typedefs -
      58             : // ------------
      59             : 
      60             : 
      61             : typedef sal_uInt32 ( SAL_CALL *ImportCGMPointer )( ::rtl::OUString&, Reference< XModel >&, sal_uInt32, Reference< XStatusIndicator >& );
      62             : typedef sal_Bool ( SAL_CALL *ExportCGMPointer )( ::rtl::OUString&, Reference< XModel >&, Reference< XStatusIndicator >&, void* );
      63             : 
      64             : #ifdef DISABLE_DYNLOADING
      65             : 
      66             : extern "C" sal_uInt32 ImportCGM( ::rtl::OUString&, Reference< XModel >&, sal_uInt32, Reference< XStatusIndicator >& );
      67             : 
      68             : #endif
      69             : 
      70             : // ---------------
      71             : // - SdPPTFilter -
      72             : // ---------------
      73             : 
      74           0 : SdCGMFilter::SdCGMFilter( SfxMedium& rMedium, ::sd::DrawDocShell& rDocShell, sal_Bool bShowProgress ) :
      75           0 :     SdFilter( rMedium, rDocShell, bShowProgress )
      76             : {
      77           0 : }
      78             : 
      79             : // -----------------------------------------------------------------------------
      80             : 
      81           0 : SdCGMFilter::~SdCGMFilter()
      82             : {
      83           0 : }
      84             : 
      85             : // -----------------------------------------------------------------------------
      86             : 
      87           0 : sal_Bool SdCGMFilter::Import()
      88             : {
      89             : #ifndef DISABLE_DYNLOADING
      90           0 :     ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
      91             : #endif
      92           0 :     sal_Bool        bRet = sal_False;
      93             : 
      94           0 :     if(
      95             : #ifndef DISABLE_DYNLOADING
      96             :        pLibrary &&
      97             : #endif
      98           0 :        mxModel.is() )
      99             :     {
     100             : #ifndef DISABLE_DYNLOADING
     101           0 :         ImportCGMPointer FncImportCGM = reinterpret_cast< ImportCGMPointer >( pLibrary->getFunctionSymbol(  "ImportCGM" ) );
     102             : #else
     103             :         ImportCGMPointer FncImportCGM = ImportCGM;
     104             : #endif
     105           0 :         ::rtl::OUString aFileURL( mrMedium.GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) );
     106             :         sal_uInt32          nRetValue;
     107             : 
     108           0 :         if( mrDocument.GetPageCount() == 0L )
     109           0 :             mrDocument.CreateFirstPages();
     110             : 
     111           0 :         CreateStatusIndicator();
     112           0 :         nRetValue = FncImportCGM( aFileURL, mxModel, CGM_IMPORT_CGM | CGM_BIG_ENDIAN | CGM_EXPORT_IMPRESS, mxStatusIndicator );
     113             : 
     114           0 :         if( nRetValue )
     115             :         {
     116           0 :             bRet = sal_True;
     117             : 
     118           0 :             if( ( nRetValue &~0xff000000 ) != 0xffffff )    // maybe the backgroundcolor is already white
     119             :             {                                               // so we must not set a master page
     120           0 :                 mrDocument.StopWorkStartupDelay();
     121           0 :                 SdPage* pSdPage = mrDocument.GetMasterSdPage(0, PK_STANDARD);
     122             : 
     123           0 :                 if(pSdPage)
     124             :                 {
     125             :                     // set PageFill to given color
     126           0 :                     const Color aColor((sal_uInt8)(nRetValue >> 16), (sal_uInt8)(nRetValue >> 8), (sal_uInt8)(nRetValue >> 16));
     127           0 :                     pSdPage->getSdrPageProperties().PutItem(XFillColorItem(String(), aColor));
     128           0 :                     pSdPage->getSdrPageProperties().PutItem(XFillStyleItem(XFILL_SOLID));
     129             :                 }
     130             :             }
     131           0 :         }
     132             :     }
     133             : #ifndef DISABLE_DYNLOADING
     134           0 :     delete pLibrary;
     135             : #endif
     136           0 :     return bRet;
     137             : }
     138             : 
     139             : // -----------------------------------------------------------------------------
     140             : 
     141           0 : sal_Bool SdCGMFilter::Export()
     142             : {
     143             : #ifdef DISABLE_DYNLOADING
     144             :     // No ExportCGM function exists(!)
     145             :     return sal_False;
     146             : #else
     147           0 :     ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
     148           0 :     sal_Bool        bRet = sal_False;
     149             : 
     150           0 :     if( pLibrary && mxModel.is() )
     151             :     {
     152           0 :         ExportCGMPointer FncCGMExport = reinterpret_cast< ExportCGMPointer >( pLibrary->getFunctionSymbol( "ExportCGM" ) );
     153             : 
     154           0 :         if( FncCGMExport )
     155             :         {
     156           0 :             ::rtl::OUString aPhysicalName( mrMedium.GetPhysicalName() );
     157             : 
     158           0 :             CreateStatusIndicator();
     159           0 :             bRet = FncCGMExport( aPhysicalName, mxModel, mxStatusIndicator, NULL );
     160             :         }
     161             :     }
     162             : 
     163           0 :     delete pLibrary;
     164           0 :     return bRet;
     165             : #endif
     166             : }
     167             : 
     168             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10