LCOV - code coverage report
Current view: top level - sd/source/filter/cgm - sdcgmfilter.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 29 32 90.6 %
Date: 2015-06-13 12:38:46 Functions: 5 7 71.4 %
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 <osl/module.hxx>
      21             : #include <tools/urlobj.hxx>
      22             : #include <svl/itemset.hxx>
      23             : #include <sfx2/docfile.hxx>
      24             : #include <sfx2/docfilt.hxx>
      25             : #include <svx/xflclit.hxx>
      26             : #include <svx/xfillit0.hxx>
      27             : 
      28             : #include "sdpage.hxx"
      29             : #include "drawdoc.hxx"
      30             : #include "sdcgmfilter.hxx"
      31             : 
      32             : #define CGM_IMPORT_CGM      0x00000001
      33             : 
      34             : #define CGM_EXPORT_IMPRESS  0x00000100
      35             : 
      36             : #define CGM_BIG_ENDIAN      0x00020000
      37             : 
      38             : using namespace ::com::sun::star;
      39             : using namespace ::com::sun::star::uno;
      40             : using namespace ::com::sun::star::task;
      41             : using namespace ::com::sun::star::frame;
      42             : 
      43             : typedef sal_uInt32 ( SAL_CALL *ImportCGMPointer )( OUString const &, Reference< XModel > const &, sal_uInt32, Reference< XStatusIndicator > const & );
      44             : 
      45             : #ifdef DISABLE_DYNLOADING
      46             : 
      47             : extern "C" sal_uInt32 ImportCGM( OUString const &, Reference< XModel > const &, sal_uInt32, Reference< XStatusIndicator > const & );
      48             : 
      49             : #endif
      50             : 
      51           2 : SdCGMFilter::SdCGMFilter( SfxMedium& rMedium, ::sd::DrawDocShell& rDocShell, bool bShowProgress ) :
      52           2 :     SdFilter( rMedium, rDocShell, bShowProgress )
      53             : {
      54           2 : }
      55             : 
      56           2 : SdCGMFilter::~SdCGMFilter()
      57             : {
      58           2 : }
      59             : 
      60           2 : bool SdCGMFilter::Import()
      61             : {
      62             : #ifndef DISABLE_DYNLOADING
      63           2 :     ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
      64             : #endif
      65           2 :     bool        bRet = false;
      66             : 
      67           2 :     if(
      68             : #ifndef DISABLE_DYNLOADING
      69           4 :        pLibrary &&
      70             : #endif
      71           2 :        mxModel.is() )
      72             :     {
      73             : #ifndef DISABLE_DYNLOADING
      74           2 :         ImportCGMPointer FncImportCGM = reinterpret_cast< ImportCGMPointer >( pLibrary->getFunctionSymbol(  "ImportCGM" ) );
      75             : #else
      76             :         ImportCGMPointer FncImportCGM = ImportCGM;
      77             : #endif
      78           2 :         OUString aFileURL( mrMedium.GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) );
      79             :         sal_uInt32          nRetValue;
      80             : 
      81           2 :         if( mrDocument.GetPageCount() == 0L )
      82           0 :             mrDocument.CreateFirstPages();
      83             : 
      84           2 :         CreateStatusIndicator();
      85           2 :         nRetValue = FncImportCGM( aFileURL, mxModel, CGM_IMPORT_CGM | CGM_BIG_ENDIAN | CGM_EXPORT_IMPRESS, mxStatusIndicator );
      86             : 
      87           2 :         if( nRetValue )
      88             :         {
      89           1 :             bRet = true;
      90             : 
      91           1 :             if( ( nRetValue &~0xff000000 ) != 0xffffff )    // maybe the backgroundcolor is already white
      92             :             {                                               // so we must not set a master page
      93           1 :                 mrDocument.StopWorkStartupDelay();
      94           1 :                 SdPage* pSdPage = mrDocument.GetMasterSdPage(0, PK_STANDARD);
      95             : 
      96           1 :                 if(pSdPage)
      97             :                 {
      98             :                     // set PageFill to given color
      99           1 :                     const Color aColor((sal_uInt8)(nRetValue >> 16), (sal_uInt8)(nRetValue >> 8), (sal_uInt8)(nRetValue >> 16));
     100           1 :                     pSdPage->getSdrPageProperties().PutItem(XFillColorItem(OUString(), aColor));
     101           1 :                     pSdPage->getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_SOLID));
     102             :                 }
     103             :             }
     104           2 :         }
     105             :     }
     106             : #ifndef DISABLE_DYNLOADING
     107           2 :     delete pLibrary;
     108             : #endif
     109           2 :     return bRet;
     110             : }
     111             : 
     112           0 : bool SdCGMFilter::Export()
     113             : {
     114             :     // No ExportCGM function exists(!)
     115           0 :     return false;
     116          66 : }
     117             : 
     118             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11