LCOV - code coverage report
Current view: top level - libreoffice/reportdesign/source/filter/xml - xmlImage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 33 0.0 %
Date: 2012-12-27 Functions: 0 3 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             : #include "xmlImage.hxx"
      20             : #include "xmlfilter.hxx"
      21             : #include <xmloff/xmltoken.hxx>
      22             : #include <xmloff/xmlnmspe.hxx>
      23             : #include <xmloff/nmspmap.hxx>
      24             : #include <xmloff/xmluconv.hxx>
      25             : #include "xmlEnums.hxx"
      26             : #include "xmlComponent.hxx"
      27             : #include "xmlReportElement.hxx"
      28             : #include "xmlControlProperty.hxx"
      29             : #include "xmlHelper.hxx"
      30             : #include <tools/debug.hxx>
      31             : #include <unotools/pathoptions.hxx>
      32             : 
      33             : #include <comphelper/componentcontext.hxx>
      34             : #include <com/sun/star/awt/ImageScaleMode.hpp>
      35             : 
      36             : namespace rptxml
      37             : {
      38             :     using namespace ::com::sun::star;
      39             :     using namespace ::com::sun::star::uno;
      40             :     using namespace ::com::sun::star::xml::sax;
      41             : DBG_NAME( rpt_OXMLImage )
      42             : 
      43             : 
      44             : // -----------------------------------------------------------------------------
      45           0 : OXMLImage::OXMLImage( ORptFilter& rImport,
      46             :                 sal_uInt16 nPrfx, const ::rtl::OUString& rLName,
      47             :                 const Reference< XAttributeList > & _xAttrList
      48             :                 ,const Reference< XImageControl > & _xComponent
      49             :                 ,OXMLTable* _pContainer) :
      50           0 :     OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer)
      51             : {
      52             :     DBG_CTOR( rpt_OXMLImage,NULL);
      53             : 
      54             :     OSL_ENSURE(m_xComponent.is(),"Component is NULL!");
      55           0 :     const SvXMLNamespaceMap& rMap = m_rImport.GetNamespaceMap();
      56           0 :     const SvXMLTokenMap& rTokenMap = m_rImport.GetControlElemTokenMap();
      57           0 :     static const ::rtl::OUString s_sTRUE = ::xmloff::token::GetXMLToken(XML_TRUE);
      58             : 
      59           0 :     const sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
      60             :     try
      61             :     {
      62           0 :         for(sal_Int16 i = 0; i < nLength; ++i)
      63             :         {
      64           0 :          ::rtl::OUString sLocalName;
      65           0 :             const rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
      66           0 :             const sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
      67           0 :             /* const */ rtl::OUString sValue = _xAttrList->getValueByIndex( i );
      68             : 
      69           0 :             switch( rTokenMap.Get( nPrefix, sLocalName ) )
      70             :             {
      71             :                 case XML_TOK_IMAGE_DATA:
      72             :                     {
      73           0 :                         SvtPathOptions aPathOptions;
      74           0 :                         sValue = aPathOptions.SubstituteVariable(sValue);
      75           0 :                         _xComponent->setImageURL(rImport.GetAbsoluteReference( sValue ));
      76             :                     }
      77             : 
      78           0 :                     break;
      79             :                 case XML_TOK_PRESERVE_IRI:
      80           0 :                     _xComponent->setPreserveIRI(s_sTRUE == sValue);
      81           0 :                     break;
      82             :                 case XML_TOK_SCALE:
      83             :                     {
      84           0 :                         sal_uInt16 nRet = awt::ImageScaleMode::None;
      85           0 :                         if ( s_sTRUE == sValue )
      86             :                         {
      87           0 :                             nRet = awt::ImageScaleMode::Anisotropic;
      88             :                         }
      89             :                         else
      90             :                         {
      91           0 :                                    const SvXMLEnumMapEntry* aXML_EnumMap = OXMLHelper::GetImageScaleOptions();
      92           0 :                                    SvXMLUnitConverter::convertEnum( nRet, sValue, aXML_EnumMap );
      93             :                         }
      94           0 :                         _xComponent->setScaleMode( nRet );
      95             :                     }
      96           0 :                     break;
      97             :                 case XML_TOK_DATA_FORMULA:
      98           0 :                     _xComponent->setDataField(ORptFilter::convertFormula(sValue));
      99           0 :                     break;
     100             :                 default:
     101           0 :                     break;
     102             :             }
     103           0 :         }
     104             :     }
     105           0 :     catch(Exception&)
     106             :     {
     107             :         OSL_FAIL("Exception catched while filling the image props");
     108             :     }
     109           0 : }
     110             : // -----------------------------------------------------------------------------
     111             : 
     112           0 : OXMLImage::~OXMLImage()
     113             : {
     114             : 
     115             :     DBG_DTOR( rpt_OXMLImage,NULL);
     116           0 : }
     117             : // -----------------------------------------------------------------------------
     118             : 
     119             : //----------------------------------------------------------------------------
     120             : } // namespace rptxml
     121             : // -----------------------------------------------------------------------------
     122             : 
     123             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10