LCOV - code coverage report
Current view: top level - sd/source/filter/cgm - sdcgmfilter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 38 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 68 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <osl/module.hxx>
      31                 :            : #include <tools/urlobj.hxx>
      32                 :            : #include <svl/itemset.hxx>
      33                 :            : #include <sfx2/docfile.hxx>
      34                 :            : #include <sfx2/docfilt.hxx>
      35                 :            : #include <svx/xflclit.hxx>
      36                 :            : #include <svx/xfillit0.hxx>
      37                 :            : 
      38                 :            : #include "sdpage.hxx"
      39                 :            : #include "drawdoc.hxx"
      40                 :            : #include "sdcgmfilter.hxx"
      41                 :            : 
      42                 :            : // -----------
      43                 :            : // - Defines -
      44                 :            : // -----------
      45                 :            : 
      46                 :            : #define CGM_IMPORT_CGM      0x00000001
      47                 :            : #define CGM_IMPORT_IM       0x00000002
      48                 :            : 
      49                 :            : #define CGM_EXPORT_IMPRESS  0x00000100
      50                 :            : #define CGM_EXPORT_META     0x00000200
      51                 :            : #define CGM_EXPORT_COMMENT  0x00000400
      52                 :            : 
      53                 :            : #define CGM_NO_PAD_BYTE     0x00010000
      54                 :            : #define CGM_BIG_ENDIAN      0x00020000
      55                 :            : #define CGM_LITTLE_ENDIAN   0x00040000
      56                 :            : 
      57                 :            : // --------------
      58                 :            : // - Namespaces -
      59                 :            : // --------------
      60                 :            : 
      61                 :            : using namespace ::com::sun::star::uno;
      62                 :            : using namespace ::com::sun::star::task;
      63                 :            : using namespace ::com::sun::star::frame;
      64                 :            : 
      65                 :            : // ------------
      66                 :            : // - Typedefs -
      67                 :            : // ------------
      68                 :            : 
      69                 :            : typedef sal_uInt32 ( __LOADONCALLAPI *ImportCGM )( ::rtl::OUString&, Reference< XModel >&, sal_uInt32, Reference< XStatusIndicator >& );
      70                 :            : typedef sal_Bool ( __LOADONCALLAPI *ExportCGM )( ::rtl::OUString&, Reference< XModel >&, Reference< XStatusIndicator >&, void* );
      71                 :            : 
      72                 :            : // ---------------
      73                 :            : // - SdPPTFilter -
      74                 :            : // ---------------
      75                 :            : 
      76                 :          0 : SdCGMFilter::SdCGMFilter( SfxMedium& rMedium, ::sd::DrawDocShell& rDocShell, sal_Bool bShowProgress ) :
      77                 :          0 :     SdFilter( rMedium, rDocShell, bShowProgress )
      78                 :            : {
      79                 :          0 : }
      80                 :            : 
      81                 :            : // -----------------------------------------------------------------------------
      82                 :            : 
      83                 :          0 : SdCGMFilter::~SdCGMFilter()
      84                 :            : {
      85         [ #  # ]:          0 : }
      86                 :            : 
      87                 :            : // -----------------------------------------------------------------------------
      88                 :            : 
      89                 :          0 : sal_Bool SdCGMFilter::Import()
      90                 :            : {
      91                 :          0 :     ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
      92                 :          0 :     sal_Bool        bRet = sal_False;
      93                 :            : 
      94 [ #  # ][ #  # ]:          0 :     if( pLibrary && mxModel.is() )
                 [ #  # ]
      95                 :            :     {
      96         [ #  # ]:          0 :         ImportCGM       FncImportCGM = reinterpret_cast< ImportCGM >( pLibrary->getFunctionSymbol(  "ImportCGM" ) );
      97 [ #  # ][ #  # ]:          0 :         ::rtl::OUString aFileURL( mrMedium.GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) );
      98                 :            :         sal_uInt32          nRetValue;
      99                 :            : 
     100 [ #  # ][ #  # ]:          0 :         if( mrDocument.GetPageCount() == 0L )
     101         [ #  # ]:          0 :             mrDocument.CreateFirstPages();
     102                 :            : 
     103         [ #  # ]:          0 :         CreateStatusIndicator();
     104         [ #  # ]:          0 :         nRetValue = FncImportCGM( aFileURL, mxModel, CGM_IMPORT_CGM | CGM_BIG_ENDIAN | CGM_EXPORT_IMPRESS, mxStatusIndicator );
     105                 :            : 
     106         [ #  # ]:          0 :         if( nRetValue )
     107                 :            :         {
     108                 :          0 :             bRet = sal_True;
     109                 :            : 
     110         [ #  # ]:          0 :             if( ( nRetValue &~0xff000000 ) != 0xffffff )    // maybe the backgroundcolor is already white
     111                 :            :             {                                               // so we must not set a master page
     112         [ #  # ]:          0 :                 mrDocument.StopWorkStartupDelay();
     113         [ #  # ]:          0 :                 SdPage* pSdPage = mrDocument.GetMasterSdPage(0, PK_STANDARD);
     114                 :            : 
     115         [ #  # ]:          0 :                 if(pSdPage)
     116                 :            :                 {
     117                 :            :                     // set PageFill to given color
     118                 :          0 :                     const Color aColor((sal_uInt8)(nRetValue >> 16), (sal_uInt8)(nRetValue >> 8), (sal_uInt8)(nRetValue >> 16));
     119 [ #  # ][ #  # ]:          0 :                     pSdPage->getSdrPageProperties().PutItem(XFillColorItem(String(), aColor));
         [ #  # ][ #  # ]
                 [ #  # ]
     120 [ #  # ][ #  # ]:          0 :                     pSdPage->getSdrPageProperties().PutItem(XFillStyleItem(XFILL_SOLID));
                 [ #  # ]
     121                 :            :                 }
     122                 :            :             }
     123                 :          0 :         }
     124                 :            :     }
     125                 :            : 
     126         [ #  # ]:          0 :     delete pLibrary;
     127                 :            : 
     128                 :          0 :     return bRet;
     129                 :            : }
     130                 :            : 
     131                 :            : // -----------------------------------------------------------------------------
     132                 :            : 
     133                 :          0 : sal_Bool SdCGMFilter::Export()
     134                 :            : {
     135                 :          0 :     ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
     136                 :          0 :     sal_Bool        bRet = sal_False;
     137                 :            : 
     138 [ #  # ][ #  # ]:          0 :     if( pLibrary && mxModel.is() )
                 [ #  # ]
     139                 :            :     {
     140                 :          0 :         ExportCGM FncCGMExport = reinterpret_cast< ExportCGM >( pLibrary->getFunctionSymbol( "ExportCGM" ) );
     141                 :            : 
     142         [ #  # ]:          0 :         if( FncCGMExport )
     143                 :            :         {
     144         [ #  # ]:          0 :             ::rtl::OUString aPhysicalName( mrMedium.GetPhysicalName() );
     145                 :            : 
     146         [ #  # ]:          0 :             CreateStatusIndicator();
     147         [ #  # ]:          0 :             bRet = FncCGMExport( aPhysicalName, mxModel, mxStatusIndicator, NULL );
     148                 :            :         }
     149                 :            :     }
     150                 :            : 
     151         [ #  # ]:          0 :     delete pLibrary;
     152                 :            : 
     153                 :          0 :     return bRet;
     154                 :            : }
     155                 :            : 
     156                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10