LCOV - code coverage report
Current view: top level - xmloff/source/style - XMLFootnoteSeparatorExport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 57 57 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 42 72 58.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "XMLFootnoteSeparatorExport.hxx"
      31                 :            : 
      32                 :            : #include <tools/debug.hxx>
      33                 :            : 
      34                 :            : #include <sax/tools/converter.hxx>
      35                 :            : 
      36                 :            : #include <xmloff/xmlexp.hxx>
      37                 :            : #include "xmloff/xmlnmspe.hxx"
      38                 :            : #include <xmloff/xmluconv.hxx>
      39                 :            : #include <xmloff/xmltoken.hxx>
      40                 :            : #include <xmloff/xmlprmap.hxx>
      41                 :            : 
      42                 :            : #include <xmloff/PageMasterStyleMap.hxx>
      43                 :            : #include <com/sun/star/text/HorizontalAdjust.hpp>
      44                 :            : #include <rtl/ustrbuf.hxx>
      45                 :            : 
      46                 :            : 
      47                 :            : using namespace ::com::sun::star;
      48                 :            : using namespace ::xmloff::token;
      49                 :            : using ::rtl::OUStringBuffer;
      50                 :            : using ::std::vector;
      51                 :            : 
      52                 :         25 : XMLFootnoteSeparatorExport::XMLFootnoteSeparatorExport(SvXMLExport& rExp) :
      53                 :         25 :     rExport(rExp)
      54                 :            : {
      55                 :         25 : }
      56                 :            : 
      57                 :         25 : XMLFootnoteSeparatorExport::~XMLFootnoteSeparatorExport()
      58                 :            : {
      59                 :         25 : }
      60                 :            : 
      61                 :            : 
      62                 :         24 : void XMLFootnoteSeparatorExport::exportXML(
      63                 :            :     const vector<XMLPropertyState> * pProperties,
      64                 :            :     sal_uInt32
      65                 :            :     #ifdef DBG_UTIL
      66                 :            :     nIdx
      67                 :            :     #endif
      68                 :            :     ,
      69                 :            :     const UniReference<XMLPropertySetMapper> & rMapper)
      70                 :            : {
      71                 :            :     DBG_ASSERT(NULL != pProperties, "Need property states");
      72                 :            : 
      73                 :            :     // intialize values
      74                 :         24 :     sal_Int16 eLineAdjust = text::HorizontalAdjust_LEFT;
      75                 :         24 :     sal_Int32 nLineColor = 0;
      76                 :         24 :     sal_Int32 nLineDistance = 0;
      77                 :         24 :     sal_Int8 nLineRelWidth = 0;
      78                 :         24 :     sal_Int32 nLineTextDistance = 0;
      79                 :         24 :     sal_Int16 nLineWeight = 0;
      80                 :         24 :     sal_Int8 nLineStyle = 0;
      81                 :            : 
      82                 :            :     // find indices into property map and get values
      83                 :         24 :     sal_uInt32 nCount = pProperties->size();
      84         [ +  + ]:        576 :     for(sal_uInt32 i = 0; i < nCount; i++)
      85                 :            :     {
      86                 :        552 :         const XMLPropertyState& rState = (*pProperties)[i];
      87                 :            : 
      88         [ +  + ]:        552 :         if( rState.mnIndex == -1 )
      89                 :         27 :             continue;
      90                 :            : 
      91 [ +  - ][ +  - ]:        525 :         switch (rMapper->GetEntryContextId(rState.mnIndex))
           [ +  +  +  +  
             +  +  +  + ]
      92                 :            :         {
      93                 :            :         case CTF_PM_FTN_LINE_ADJUST:
      94                 :         24 :             rState.maValue >>= eLineAdjust;
      95                 :         24 :             break;
      96                 :            :         case CTF_PM_FTN_LINE_COLOR:
      97                 :         24 :             rState.maValue >>= nLineColor;
      98                 :         24 :             break;
      99                 :            :         case CTF_PM_FTN_DISTANCE:
     100                 :         24 :             rState.maValue >>= nLineDistance;
     101                 :         24 :             break;
     102                 :            :         case CTF_PM_FTN_LINE_WIDTH:
     103                 :         24 :             rState.maValue >>= nLineRelWidth;
     104                 :         24 :             break;
     105                 :            :         case CTF_PM_FTN_LINE_DISTANCE:
     106                 :         24 :             rState.maValue >>= nLineTextDistance;
     107                 :         24 :             break;
     108                 :            :         case CTF_PM_FTN_LINE_WEIGTH:
     109                 :            :             DBG_ASSERT( i == nIdx,
     110                 :            :                         "received wrong property state index" );
     111                 :         24 :             rState.maValue >>= nLineWeight;
     112                 :         24 :             break;
     113                 :            :         case CTF_PM_FTN_LINE_STYLE:
     114                 :         24 :             rState.maValue >>= nLineStyle;
     115                 :         24 :             break;
     116                 :            :         }
     117                 :            :     }
     118                 :            : 
     119                 :         24 :     OUStringBuffer sBuf;
     120                 :            : 
     121                 :            :     // weight/width
     122         [ +  - ]:         24 :     if (nLineWeight > 0)
     123                 :            :     {
     124         [ +  - ]:         24 :         rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf, nLineWeight);
     125                 :            :         rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_WIDTH,
     126 [ +  - ][ +  - ]:         24 :                              sBuf.makeStringAndClear());
     127                 :            :     }
     128                 :            : 
     129                 :            :     // line text distance
     130         [ +  - ]:         24 :     if (nLineTextDistance > 0)
     131                 :            :     {
     132                 :         24 :         rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf,
     133         [ +  - ]:         24 :                 nLineTextDistance);
     134                 :            :         rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_BEFORE_SEP,
     135 [ +  - ][ +  - ]:         24 :                              sBuf.makeStringAndClear());
     136                 :            :     }
     137                 :            : 
     138                 :            :     // line distance
     139         [ +  - ]:         24 :     if (nLineDistance > 0)
     140                 :            :     {
     141                 :         24 :         rExport.GetMM100UnitConverter().convertMeasureToXML(sBuf,
     142         [ +  - ]:         24 :                 nLineDistance);
     143                 :            :         rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_AFTER_SEP,
     144 [ +  - ][ +  - ]:         24 :                              sBuf.makeStringAndClear());
     145                 :            :     }
     146                 :            : 
     147                 :            :     // line style
     148                 :            :     static const SvXMLEnumMapEntry aXML_LineStyle_Enum[] =
     149                 :            :     {
     150                 :            :         { XML_NONE,     0 },
     151                 :            :         { XML_SOLID,    1 },
     152                 :            :         { XML_DOTTED,   2 },
     153                 :            :         { XML_DASH,     3 },
     154                 :            :         { XML_TOKEN_INVALID, 0 }
     155                 :            :     };
     156         [ +  - ]:         48 :     if (rExport.GetMM100UnitConverter().convertEnum(
     157         [ +  - ]:         24 :             sBuf, nLineStyle, aXML_LineStyle_Enum ) )
     158                 :            :     {
     159                 :            :         rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_LINE_STYLE,
     160 [ +  - ][ +  - ]:         24 :                 sBuf.makeStringAndClear());
     161                 :            :     }
     162                 :            : 
     163                 :            :     // adjustment
     164                 :            :     static const SvXMLEnumMapEntry aXML_HorizontalAdjust_Enum[] =
     165                 :            :     {
     166                 :            :         { XML_LEFT,     text::HorizontalAdjust_LEFT },
     167                 :            :         { XML_CENTER,   text::HorizontalAdjust_CENTER },
     168                 :            :         { XML_RIGHT,    text::HorizontalAdjust_RIGHT },
     169                 :            :         { XML_TOKEN_INVALID, 0 }
     170                 :            :     };
     171                 :            : 
     172         [ +  - ]:         48 :     if (rExport.GetMM100UnitConverter().convertEnum(
     173         [ +  - ]:         24 :         sBuf, eLineAdjust, aXML_HorizontalAdjust_Enum))
     174                 :            :     {
     175                 :            :         rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_ADJUSTMENT,
     176 [ +  - ][ +  - ]:         24 :                              sBuf.makeStringAndClear());
     177                 :            :     }
     178                 :            : 
     179                 :            :     // relative line width
     180         [ +  - ]:         24 :     ::sax::Converter::convertPercent(sBuf, nLineRelWidth);
     181                 :            :     rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_REL_WIDTH,
     182 [ +  - ][ +  - ]:         24 :                          sBuf.makeStringAndClear());
     183                 :            : 
     184                 :            :     // color
     185         [ +  - ]:         24 :     ::sax::Converter::convertColor(sBuf, nLineColor);
     186                 :            :     rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_COLOR,
     187 [ +  - ][ +  - ]:         24 :                          sBuf.makeStringAndClear());
     188                 :            : 
     189                 :            :     // line-style
     190                 :            : 
     191                 :            :     SvXMLElementExport aElem(rExport, XML_NAMESPACE_STYLE,
     192 [ +  - ][ +  - ]:         24 :                              XML_FOOTNOTE_SEP, sal_True, sal_True);
     193                 :         24 : }
     194                 :            : 
     195                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10