LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/style - XMLFillBitmapSizePropertyHandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 22 45.5 %
Date: 2012-12-27 Functions: 4 5 80.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 "XMLFillBitmapSizePropertyHandler.hxx"
      22             : #include <rtl/ustrbuf.hxx>
      23             : #include <com/sun/star/uno/Any.hxx>
      24             : #include <comphelper/extract.hxx>
      25             : #include <sax/tools/converter.hxx>
      26             : #include <xmloff/xmluconv.hxx>
      27             : 
      28             : using namespace ::com::sun::star;
      29             : using namespace ::com::sun::star::uno;
      30             : using ::rtl::OUString;
      31             : using ::rtl::OUStringBuffer;
      32             : 
      33             : 
      34         109 : XMLFillBitmapSizePropertyHandler::XMLFillBitmapSizePropertyHandler()
      35             : {
      36         109 : }
      37             : 
      38         218 : XMLFillBitmapSizePropertyHandler::~XMLFillBitmapSizePropertyHandler()
      39             : {
      40         218 : }
      41             : 
      42           4 : sal_Bool XMLFillBitmapSizePropertyHandler::importXML(
      43             :     const OUString& rStrImpValue,
      44             :     Any& rValue,
      45             :     const SvXMLUnitConverter& rUnitConverter ) const
      46             : {
      47             :     sal_Int32 nValue;
      48             :     sal_Bool bRet;
      49             : 
      50           4 :     if( rStrImpValue.indexOf( sal_Unicode('%') ) != -1 )
      51             :     {
      52           0 :         bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
      53           0 :         nValue *= -1;
      54             :     }
      55             :     else
      56             :     {
      57           4 :         bRet = rUnitConverter.convertMeasureToCore( nValue, rStrImpValue );
      58             :     }
      59             : 
      60           4 :     if( bRet )
      61           4 :         rValue <<= nValue;
      62             : 
      63           4 :     return bRet;
      64             : }
      65             : 
      66           0 : sal_Bool XMLFillBitmapSizePropertyHandler::exportXML(
      67             :     OUString& rStrExpValue,
      68             :     const Any& rValue,
      69             :     const SvXMLUnitConverter& rUnitConverter ) const
      70             : {
      71           0 :     OUStringBuffer aOut;
      72             : 
      73           0 :     sal_Int32 nValue = 0;
      74           0 :     if( rValue >>= nValue )
      75             :     {
      76           0 :         if( nValue < 0 )
      77             :         {
      78           0 :             ::sax::Converter::convertPercent( aOut, -nValue );
      79             :         }
      80             :         else
      81             :         {
      82           0 :             rUnitConverter.convertMeasureToXML( aOut, nValue );
      83             :         }
      84             : 
      85           0 :         rStrExpValue = aOut.makeStringAndClear();
      86           0 :         return sal_True;
      87             :     }
      88             : 
      89           0 :     return sal_False;
      90             : }
      91             : 
      92             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10