LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/draw - propimp0.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 98 23.5 %
Date: 2013-07-09 Functions: 8 18 44.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 <rtl/ustrbuf.hxx>
      21             : #include "propimp0.hxx"
      22             : #include <com/sun/star/drawing/LineDash.hpp>
      23             : #include <com/sun/star/util/Duration.hpp>
      24             : #include <com/sun/star/uno/Any.hxx>
      25             : 
      26             : #include <sax/tools/converter.hxx>
      27             : 
      28             : #include <xmloff/xmluconv.hxx>
      29             : #include <xmloff/xmlimp.hxx>
      30             : 
      31             : #include <tools/time.hxx>
      32             : 
      33             : using namespace ::com::sun::star;
      34             : 
      35             : //////////////////////////////////////////////////////////////////////////////
      36             : // implementation of graphic property Stroke
      37             : 
      38             : 
      39             : //////////////////////////////////////////////////////////////////////////////
      40             : // implementation of presentation page property Change
      41             : 
      42             : //////////////////////////////////////////////////////////////////////////////
      43             : // implementation of an effect duration property handler
      44             : 
      45             : 
      46         684 : XMLDurationPropertyHdl::~XMLDurationPropertyHdl()
      47             : {
      48         684 : }
      49             : 
      50           0 : sal_Bool XMLDurationPropertyHdl::importXML(
      51             :     const OUString& rStrImpValue,
      52             :     ::com::sun::star::uno::Any& rValue,
      53             :     const SvXMLUnitConverter& ) const
      54             : {
      55           0 :     util::Duration aDuration;
      56           0 :     ::sax::Converter::convertDuration(aDuration,  rStrImpValue);
      57             : 
      58           0 :     const double fSeconds = ((aDuration.Days * 24 + aDuration.Hours) * 60
      59           0 :                              + aDuration.Minutes) * 60 + aDuration.Seconds + aDuration.NanoSeconds / static_cast<double>(::Time::nanoSecPerSec);
      60           0 :     rValue <<= fSeconds;
      61             : 
      62           0 :     return sal_True;
      63             : }
      64             : 
      65           0 : sal_Bool XMLDurationPropertyHdl::exportXML(
      66             :     OUString& rStrExpValue,
      67             :     const ::com::sun::star::uno::Any& rValue,
      68             :     const SvXMLUnitConverter& ) const
      69             : {
      70           0 :     double nVal = 0;
      71             : 
      72           0 :     if(rValue >>= nVal)
      73             :     {
      74           0 :         util::Duration aDuration;
      75           0 :         aDuration.Seconds = static_cast<sal_uInt16>(nVal);
      76           0 :         aDuration.NanoSeconds = static_cast<sal_uInt32>((nVal - aDuration.Seconds) * ::Time::nanoSecPerSec);
      77             : 
      78           0 :         OUStringBuffer aOut;
      79           0 :         ::sax::Converter::convertDuration(aOut, aDuration);
      80           0 :         rStrExpValue = aOut.makeStringAndClear();
      81           0 :         return sal_True;
      82             :     }
      83             : 
      84           0 :     return sal_False;
      85             : }
      86             : 
      87             : //////////////////////////////////////////////////////////////////////////////
      88             : // implementation of an opacity property handler
      89             : 
      90             : 
      91         580 : XMLOpacityPropertyHdl::XMLOpacityPropertyHdl( SvXMLImport* pImport )
      92         580 : : mpImport( pImport )
      93             : {
      94         580 : }
      95             : 
      96        1150 : XMLOpacityPropertyHdl::~XMLOpacityPropertyHdl()
      97             : {
      98        1150 : }
      99             : 
     100           3 : sal_Bool XMLOpacityPropertyHdl::importXML(
     101             :     const OUString& rStrImpValue,
     102             :     ::com::sun::star::uno::Any& rValue,
     103             :     const SvXMLUnitConverter& ) const
     104             : {
     105           3 :     sal_Bool bRet = sal_False;
     106           3 :     sal_Int32 nValue = 0;
     107             : 
     108           3 :     if( rStrImpValue.indexOf( sal_Unicode('%') ) != -1 )
     109             :     {
     110           3 :         if (::sax::Converter::convertPercent( nValue, rStrImpValue ))
     111           3 :             bRet = sal_True;
     112             :     }
     113             :     else
     114             :     {
     115           0 :         nValue = sal_Int32( rStrImpValue.toDouble() * 100.0 );
     116           0 :         bRet = sal_True;
     117             :     }
     118             : 
     119           3 :     if( bRet )
     120             :     {
     121             :         // check ranges
     122           3 :         if( nValue < 0 )
     123           0 :             nValue = 0;
     124           3 :         if( nValue > 100 )
     125           0 :             nValue = 100;
     126             : 
     127             :         // convert xml opacity to api transparency
     128           3 :         nValue = 100 - nValue;
     129             : 
     130             :         // #i42959#
     131           3 :         if( mpImport )
     132             :         {
     133             :             sal_Int32 nUPD, nBuild;
     134           3 :             if( mpImport->getBuildIds( nUPD, nBuild ) )
     135             :             {
     136             :                 // correct import of documents written prior to StarOffice 8/OOO 2.0 final
     137           0 :                 if( (nUPD == 680) && (nBuild < 8951) )
     138           0 :                     nValue = 100 - nValue;
     139             :             }
     140             :         }
     141             : 
     142           3 :         rValue <<= sal_uInt16(nValue);
     143             :     }
     144             : 
     145           3 :     return bRet;
     146             : }
     147             : 
     148           0 : sal_Bool XMLOpacityPropertyHdl::exportXML(
     149             :     OUString& rStrExpValue,
     150             :     const ::com::sun::star::uno::Any& rValue,
     151             :     const SvXMLUnitConverter& ) const
     152             : {
     153           0 :     sal_Bool bRet = sal_False;
     154           0 :     sal_uInt16 nVal = sal_uInt16();
     155             : 
     156           0 :     if( rValue >>= nVal )
     157             :     {
     158           0 :         OUStringBuffer aOut;
     159             : 
     160           0 :         nVal = 100 - nVal;
     161           0 :         ::sax::Converter::convertPercent( aOut, nVal );
     162           0 :         rStrExpValue = aOut.makeStringAndClear();
     163           0 :         bRet = sal_True;
     164             :     }
     165             : 
     166           0 :     return bRet;
     167             : }
     168             : 
     169             : //////////////////////////////////////////////////////////////////////////////
     170             : // implementation of an text animation step amount
     171             : 
     172        1150 : XMLTextAnimationStepPropertyHdl::~XMLTextAnimationStepPropertyHdl()
     173             : {
     174        1150 : }
     175             : 
     176           0 : sal_Bool XMLTextAnimationStepPropertyHdl::importXML(
     177             :     const OUString& rStrImpValue,
     178             :     ::com::sun::star::uno::Any& rValue,
     179             :     const SvXMLUnitConverter& rUnitConverter ) const
     180             : {
     181           0 :     sal_Bool bRet = sal_False;
     182           0 :     sal_Int32 nValue = 0;
     183             : 
     184           0 :     const OUString aPX( "px" );
     185           0 :     sal_Int32 nPos = rStrImpValue.indexOf( aPX );
     186           0 :     if( nPos != -1 )
     187             :     {
     188           0 :         if (::sax::Converter::convertNumber(nValue, rStrImpValue.copy(0, nPos)))
     189             :         {
     190           0 :             rValue <<= sal_Int16( -nValue );
     191           0 :             bRet = sal_True;
     192             :         }
     193             :     }
     194             :     else
     195             :     {
     196           0 :         if (rUnitConverter.convertMeasureToCore( nValue, rStrImpValue ))
     197             :         {
     198           0 :             rValue <<= sal_Int16( nValue );
     199           0 :             bRet = sal_True;
     200             :         }
     201             :     }
     202             : 
     203           0 :     return bRet;
     204             : }
     205             : 
     206           0 : sal_Bool XMLTextAnimationStepPropertyHdl::exportXML(
     207             :     OUString& rStrExpValue,
     208             :     const ::com::sun::star::uno::Any& rValue,
     209             :     const SvXMLUnitConverter& rUnitConverter ) const
     210             : {
     211           0 :     sal_Bool bRet = sal_False;
     212           0 :     sal_Int16 nVal = sal_Int16();
     213             : 
     214           0 :     if( rValue >>= nVal )
     215             :     {
     216           0 :         OUStringBuffer aOut;
     217             : 
     218           0 :         if( nVal < 0 )
     219             :         {
     220           0 :             const OUString aPX( "px" );
     221           0 :             ::sax::Converter::convertNumber( aOut, (sal_Int32)-nVal );
     222           0 :             aOut.append( aPX );
     223             :         }
     224             :         else
     225             :         {
     226           0 :             rUnitConverter.convertMeasureToXML( aOut, nVal );
     227             :         }
     228             : 
     229           0 :         rStrExpValue = aOut.makeStringAndClear();
     230           0 :         bRet = sal_True;
     231             :     }
     232             : 
     233           0 :     return bRet;
     234             : }
     235             : 
     236             : //////////////////////////////////////////////////////////////////////////////
     237             : 
     238             : #include "sdxmlexp_impl.hxx"
     239             : 
     240           0 : XMLDateTimeFormatHdl::XMLDateTimeFormatHdl( SvXMLExport* pExport )
     241           0 : : mpExport( pExport )
     242             : {
     243           0 : }
     244             : 
     245           0 : XMLDateTimeFormatHdl::~XMLDateTimeFormatHdl()
     246             : {
     247           0 : }
     248             : 
     249           0 : sal_Bool XMLDateTimeFormatHdl::importXML( const OUString& rStrImpValue, ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& ) const
     250             : {
     251           0 :     rValue <<= rStrImpValue;
     252           0 :     return true;
     253             : }
     254             : 
     255           0 : sal_Bool XMLDateTimeFormatHdl::exportXML( OUString& rStrExpValue, const ::com::sun::star::uno::Any& rValue, const SvXMLUnitConverter& ) const
     256             : {
     257           0 :     sal_Int32 nNumberFormat = 0;
     258           0 :     if( mpExport && (rValue >>= nNumberFormat) )
     259             :     {
     260           0 :         mpExport->addDataStyle( nNumberFormat );
     261           0 :         rStrExpValue = mpExport->getDataStyleName( nNumberFormat );
     262           0 :         return sal_True;
     263             :     }
     264             : 
     265           0 :     return sal_False;
     266             : }
     267             : 
     268             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10