LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/text - XMLSectionFootnoteConfigExport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 64 0.0 %
Date: 2012-12-27 Functions: 0 1 0.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             : #include "XMLSectionFootnoteConfigExport.hxx"
      21             : #include <xmloff/xmlexp.hxx>
      22             : #include <xmloff/xmlprmap.hxx>
      23             : #include <com/sun/star/style/NumberingType.hpp>
      24             : #include <sax/tools/converter.hxx>
      25             : #include <xmloff/maptype.hxx>
      26             : 
      27             : #include <xmloff/txtprmap.hxx>
      28             : #include <xmloff/nmspmap.hxx>
      29             : #include "xmloff/xmlnmspe.hxx"
      30             : #include <xmloff/xmluconv.hxx>
      31             : #include <xmloff/xmltoken.hxx>
      32             : #include <xmloff/xmlnume.hxx>
      33             : #include <tools/debug.hxx>
      34             : #include <rtl/ustring.hxx>
      35             : #include <rtl/ustrbuf.hxx>
      36             : 
      37             : #include <vector>
      38             : 
      39             : 
      40             : using namespace ::xmloff::token;
      41             : 
      42             : using ::std::vector;
      43             : using ::rtl::OUString;
      44             : using ::rtl::OUStringBuffer;
      45             : using ::com::sun::star::style::NumberingType::ARABIC;
      46             : 
      47             : 
      48           0 : void XMLSectionFootnoteConfigExport::exportXML(
      49             :     SvXMLExport& rExport,
      50             :     sal_Bool bEndnote,
      51             :     const vector<XMLPropertyState> *pProperties,
      52             :     sal_uInt32
      53             :     #ifdef DBG_UTIL
      54             :     nIdx
      55             :     #endif
      56             :     ,
      57             :     const UniReference<XMLPropertySetMapper> & rMapper)
      58             : {
      59             :     // store and initialize the values
      60           0 :     sal_Bool bNumOwn = sal_False;
      61           0 :     sal_Bool bNumRestart = sal_False;
      62           0 :     sal_Int16 nNumRestartAt = 0;
      63           0 :     sal_Int16 nNumberingType = ARABIC;
      64           0 :     OUString sNumPrefix;
      65           0 :     OUString sNumSuffix;
      66           0 :     sal_Bool bEnd = sal_False;
      67             : 
      68             :     // find entries in property states vector
      69           0 :     sal_uInt32 nCount = pProperties->size();
      70           0 :     for(sal_uInt32 i = 0; i < nCount; i++)
      71             :     {
      72           0 :         const XMLPropertyState& rState = (*pProperties)[i];
      73             : 
      74           0 :         sal_Int16 nContextId = rMapper->GetEntryContextId(rState.mnIndex);
      75           0 :         if (!bEndnote)
      76             :         {
      77           0 :             switch (nContextId)
      78             :             {
      79             :                 case CTF_SECTION_FOOTNOTE_NUM_OWN:
      80           0 :                     rState.maValue >>= bNumOwn;
      81           0 :                     break;
      82             :                 case CTF_SECTION_FOOTNOTE_NUM_RESTART:
      83           0 :                     rState.maValue >>= bNumRestart;
      84           0 :                     break;
      85             :                 case CTF_SECTION_FOOTNOTE_NUM_RESTART_AT:
      86           0 :                     rState.maValue >>= nNumRestartAt;
      87           0 :                     break;
      88             :                 case CTF_SECTION_FOOTNOTE_NUM_TYPE:
      89           0 :                     rState.maValue >>= nNumberingType;
      90           0 :                     break;
      91             :                 case CTF_SECTION_FOOTNOTE_NUM_PREFIX:
      92           0 :                     rState.maValue >>= sNumPrefix;
      93           0 :                     break;
      94             :                 case CTF_SECTION_FOOTNOTE_NUM_SUFFIX:
      95           0 :                     rState.maValue >>= sNumSuffix;
      96           0 :                     break;
      97             :                 case CTF_SECTION_FOOTNOTE_END:
      98             :                     DBG_ASSERT( i == nIdx,
      99             :                                 "received wrong property state index" );
     100           0 :                     rState.maValue >>= bEnd;
     101           0 :                     break;
     102             :             }
     103             :         }
     104             :         else
     105             :         {
     106           0 :             switch (nContextId)
     107             :             {
     108             :                 case CTF_SECTION_ENDNOTE_NUM_OWN:
     109           0 :                     rState.maValue >>= bNumOwn;
     110           0 :                     break;
     111             :                 case CTF_SECTION_ENDNOTE_NUM_RESTART:
     112           0 :                     rState.maValue >>= bNumRestart;
     113           0 :                     break;
     114             :                 case CTF_SECTION_ENDNOTE_NUM_RESTART_AT:
     115           0 :                     rState.maValue >>= nNumRestartAt;
     116           0 :                     break;
     117             :                 case CTF_SECTION_ENDNOTE_NUM_TYPE:
     118           0 :                     rState.maValue >>= nNumberingType;
     119           0 :                     break;
     120             :                 case CTF_SECTION_ENDNOTE_NUM_PREFIX:
     121           0 :                     rState.maValue >>= sNumPrefix;
     122           0 :                     break;
     123             :                 case CTF_SECTION_ENDNOTE_NUM_SUFFIX:
     124           0 :                     rState.maValue >>= sNumSuffix;
     125           0 :                     break;
     126             :                 case CTF_SECTION_ENDNOTE_END:
     127             :                     DBG_ASSERT( i == nIdx,
     128             :                                 "received wrong property state index" );
     129           0 :                     rState.maValue >>= bEnd;
     130           0 :                     break;
     131             :             }
     132             :         }
     133             :     }
     134             : 
     135             :     // we only make an element if we have an own footnote/endnote numbering
     136           0 :     if (bEnd)
     137             :     {
     138             :         rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NOTE_CLASS,
     139             :                                  GetXMLToken( bEndnote ? XML_ENDNOTE
     140           0 :                                                          : XML_FOOTNOTE ) );
     141             :         // start numbering
     142           0 :         OUStringBuffer sBuf;
     143           0 :         if (bNumRestart)
     144             :         {
     145             :             // restart number is stored as 0.., but interpreted as 1..
     146             :             ::sax::Converter::convertNumber(sBuf,
     147           0 :                                               (sal_Int32)(nNumRestartAt+1));
     148             :             rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_START_VALUE,
     149           0 :                                  sBuf.makeStringAndClear());
     150             :         }
     151             : 
     152           0 :         if (bNumOwn)
     153             :         {
     154             :             // prefix and suffix
     155           0 :             if (!sNumPrefix.isEmpty())
     156             :             {
     157             :                     rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_PREFIX,
     158           0 :                                          sNumPrefix);
     159             :             }
     160           0 :             if (!sNumSuffix.isEmpty())
     161             :             {
     162             :                 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_SUFFIX,
     163           0 :                                      sNumSuffix);
     164             :             }
     165             : 
     166             :             // number type: num format
     167           0 :             rExport.GetMM100UnitConverter().convertNumFormat( sBuf,
     168           0 :                                                               nNumberingType );
     169             :             rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
     170           0 :                                  sBuf.makeStringAndClear());
     171             : 
     172             :             // and letter sync, if applicable
     173           0 :             rExport.GetMM100UnitConverter().convertNumLetterSync(
     174           0 :                 sBuf, nNumberingType );
     175           0 :             if (sBuf.getLength())
     176             :             {
     177             :                 rExport.AddAttribute(XML_NAMESPACE_STYLE,
     178             :                                      XML_NUM_LETTER_SYNC,
     179           0 :                                      sBuf.makeStringAndClear());
     180             :             }
     181             :         }
     182             : 
     183             :         // and finally, the element
     184             :         SvXMLElementExport rElem(rExport, XML_NAMESPACE_TEXT,
     185             :                                  XML_NOTES_CONFIGURATION,
     186           0 :                                  sal_True, sal_True);
     187           0 :     }
     188           0 : }
     189             : 
     190             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10