LCOV - code coverage report
Current view: top level - xmloff/source/style - XMLFootnoteSeparatorExport.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 57 57 100.0 %
Date: 2014-04-11 Functions: 3 3 100.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 "XMLFootnoteSeparatorExport.hxx"
      22             : 
      23             : #include <tools/debug.hxx>
      24             : 
      25             : #include <sax/tools/converter.hxx>
      26             : 
      27             : #include <xmloff/xmlexp.hxx>
      28             : #include <xmloff/xmlnmspe.hxx>
      29             : #include <xmloff/xmluconv.hxx>
      30             : #include <xmloff/xmltoken.hxx>
      31             : #include <xmloff/xmlprmap.hxx>
      32             : 
      33             : #include <xmloff/PageMasterStyleMap.hxx>
      34             : #include <com/sun/star/text/HorizontalAdjust.hpp>
      35             : #include <rtl/ustrbuf.hxx>
      36             : 
      37             : 
      38             : using namespace ::com::sun::star;
      39             : using namespace ::xmloff::token;
      40             : using ::std::vector;
      41             : 
      42          39 : XMLFootnoteSeparatorExport::XMLFootnoteSeparatorExport(SvXMLExport& rExp) :
      43          39 :     rExport(rExp)
      44             : {
      45          39 : }
      46             : 
      47          39 : XMLFootnoteSeparatorExport::~XMLFootnoteSeparatorExport()
      48             : {
      49          39 : }
      50             : 
      51             : 
      52          24 : void XMLFootnoteSeparatorExport::exportXML(
      53             :     const vector<XMLPropertyState> * pProperties,
      54             :     sal_uInt32
      55             :     #ifdef DBG_UTIL
      56             :     nIdx
      57             :     #endif
      58             :     ,
      59             :     const UniReference<XMLPropertySetMapper> & rMapper)
      60             : {
      61             :     DBG_ASSERT(NULL != pProperties, "Need property states");
      62             : 
      63             :     // intialize values
      64          24 :     sal_Int16 eLineAdjust = text::HorizontalAdjust_LEFT;
      65          24 :     sal_Int32 nLineColor = 0;
      66          24 :     sal_Int32 nLineDistance = 0;
      67          24 :     sal_Int8 nLineRelWidth = 0;
      68          24 :     sal_Int32 nLineTextDistance = 0;
      69          24 :     sal_Int16 nLineWeight = 0;
      70          24 :     sal_Int8 nLineStyle = 0;
      71             : 
      72             :     // find indices into property map and get values
      73          24 :     sal_uInt32 nCount = pProperties->size();
      74         664 :     for(sal_uInt32 i = 0; i < nCount; i++)
      75             :     {
      76         640 :         const XMLPropertyState& rState = (*pProperties)[i];
      77             : 
      78         640 :         if( rState.mnIndex == -1 )
      79          58 :             continue;
      80             : 
      81         582 :         switch (rMapper->GetEntryContextId(rState.mnIndex))
      82             :         {
      83             :         case CTF_PM_FTN_LINE_ADJUST:
      84          24 :             rState.maValue >>= eLineAdjust;
      85          24 :             break;
      86             :         case CTF_PM_FTN_LINE_COLOR:
      87          24 :             rState.maValue >>= nLineColor;
      88          24 :             break;
      89             :         case CTF_PM_FTN_DISTANCE:
      90          24 :             rState.maValue >>= nLineDistance;
      91          24 :             break;
      92             :         case CTF_PM_FTN_LINE_WIDTH:
      93          24 :             rState.maValue >>= nLineRelWidth;
      94          24 :             break;
      95             :         case CTF_PM_FTN_LINE_DISTANCE:
      96          24 :             rState.maValue >>= nLineTextDistance;
      97          24 :             break;
      98             :         case CTF_PM_FTN_LINE_WEIGHT:
      99             :             DBG_ASSERT( i == nIdx,
     100             :                         "received wrong property state index" );
     101          24 :             rState.maValue >>= nLineWeight;
     102          24 :             break;
     103             :         case CTF_PM_FTN_LINE_STYLE:
     104          24 :             rState.maValue >>= nLineStyle;
     105          24 :             break;
     106             :         }
     107             :     }
     108             : 
     109          24 :     OUStringBuffer sBuf;
     110             : 
     111             :     // weight/width
     112          24 :     if (nLineWeight > 0)
     113             :     {
     114          24 :         rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf, nLineWeight);
     115             :         rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_WIDTH,
     116          24 :                              sBuf.makeStringAndClear());
     117             :     }
     118             : 
     119             :     // line text distance
     120          24 :     if (nLineTextDistance > 0)
     121             :     {
     122          24 :         rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf,
     123          48 :                 nLineTextDistance);
     124             :         rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_BEFORE_SEP,
     125          24 :                              sBuf.makeStringAndClear());
     126             :     }
     127             : 
     128             :     // line distance
     129          24 :     if (nLineDistance > 0)
     130             :     {
     131          24 :         rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf,
     132          48 :                 nLineDistance);
     133             :         rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_AFTER_SEP,
     134          24 :                              sBuf.makeStringAndClear());
     135             :     }
     136             : 
     137             :     // line style
     138             :     static const SvXMLEnumMapEntry aXML_LineStyle_Enum[] =
     139             :     {
     140             :         { XML_NONE,     0 },
     141             :         { XML_SOLID,    1 },
     142             :         { XML_DOTTED,   2 },
     143             :         { XML_DASH,     3 },
     144             :         { XML_TOKEN_INVALID, 0 }
     145             :     };
     146          48 :     if (rExport.GetMM100UnitConverter().convertEnum(
     147          24 :             sBuf, nLineStyle, aXML_LineStyle_Enum ) )
     148             :     {
     149             :         rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_LINE_STYLE,
     150          24 :                 sBuf.makeStringAndClear());
     151             :     }
     152             : 
     153             :     // adjustment
     154             :     static const SvXMLEnumMapEntry aXML_HorizontalAdjust_Enum[] =
     155             :     {
     156             :         { XML_LEFT,     text::HorizontalAdjust_LEFT },
     157             :         { XML_CENTER,   text::HorizontalAdjust_CENTER },
     158             :         { XML_RIGHT,    text::HorizontalAdjust_RIGHT },
     159             :         { XML_TOKEN_INVALID, 0 }
     160             :     };
     161             : 
     162          48 :     if (rExport.GetMM100UnitConverter().convertEnum(
     163          24 :         sBuf, eLineAdjust, aXML_HorizontalAdjust_Enum))
     164             :     {
     165             :         rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_ADJUSTMENT,
     166          24 :                              sBuf.makeStringAndClear());
     167             :     }
     168             : 
     169             :     // relative line width
     170          24 :     ::sax::Converter::convertPercent(sBuf, nLineRelWidth);
     171             :     rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_REL_WIDTH,
     172          24 :                          sBuf.makeStringAndClear());
     173             : 
     174             :     // color
     175          24 :     ::sax::Converter::convertColor(sBuf, nLineColor);
     176             :     rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_COLOR,
     177          24 :                          sBuf.makeStringAndClear());
     178             : 
     179             :     // line-style
     180             : 
     181             :     SvXMLElementExport aElem(rExport, XML_NAMESPACE_STYLE,
     182          24 :                              XML_FOOTNOTE_SEP, true, true);
     183          24 : }
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10