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

Generated by: LCOV version 1.10