LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLLineNumberingExport.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 72 0.0 %
Date: 2014-04-14 Functions: 0 2 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 "XMLLineNumberingExport.hxx"
      21             : #include <com/sun/star/beans/XPropertySet.hpp>
      22             : #include <com/sun/star/text/XLineNumberingProperties.hpp>
      23             : #include <com/sun/star/style/LineNumberPosition.hpp>
      24             : #include <sax/tools/converter.hxx>
      25             : #include <xmloff/xmlexp.hxx>
      26             : #include <xmloff/xmluconv.hxx>
      27             : #include <xmloff/xmlnmspe.hxx>
      28             : #include <xmloff/xmltoken.hxx>
      29             : #include <xmloff/xmlnume.hxx>
      30             : 
      31             : 
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star;
      34             : using namespace ::xmloff::token;
      35             : 
      36             : using ::com::sun::star::beans::XPropertySet;
      37             : using ::com::sun::star::text::XLineNumberingProperties;
      38             : 
      39             : 
      40           0 : XMLLineNumberingExport::XMLLineNumberingExport(SvXMLExport& rExp)
      41             : :   sCharStyleName("CharStyleName")
      42             : ,   sCountEmptyLines("CountEmptyLines")
      43             : ,   sCountLinesInFrames("CountLinesInFrames")
      44             : ,   sDistance("Distance")
      45             : ,   sInterval("Interval")
      46             : ,   sSeparatorText("SeparatorText")
      47             : ,   sNumberPosition("NumberPosition")
      48             : ,   sNumberingType("NumberingType")
      49             : ,   sIsOn("IsOn")
      50             : ,   sRestartAtEachPage("RestartAtEachPage")
      51             : ,   sSeparatorInterval("SeparatorInterval")
      52           0 : ,   rExport(rExp)
      53             : {
      54           0 : }
      55             : 
      56             : SvXMLEnumMapEntry const aLineNumberPositionMap[] =
      57             : {
      58             :     { XML_LEFT,     style::LineNumberPosition::LEFT },
      59             :     { XML_RIGHT,    style::LineNumberPosition::RIGHT },
      60             :     { XML_INSIDE,   style::LineNumberPosition::INSIDE },
      61             :     { XML_OUTSIDE,  style::LineNumberPosition::OUTSIDE },
      62             :     { XML_TOKEN_INVALID, 0 }
      63             : };
      64             : 
      65             : 
      66             : 
      67           0 : void XMLLineNumberingExport::Export()
      68             : {
      69             :     // export element if we have line numbering info
      70           0 :     Reference<XLineNumberingProperties> xSupplier(rExport.GetModel(),
      71           0 :                                                   UNO_QUERY);
      72           0 :     if (xSupplier.is())
      73             :     {
      74             :         Reference<XPropertySet> xLineNumbering =
      75           0 :             xSupplier->getLineNumberingProperties();
      76             : 
      77           0 :         if (xLineNumbering.is())
      78             :         {
      79           0 :             Any aAny;
      80             : 
      81             :             // char style
      82           0 :             aAny = xLineNumbering->getPropertyValue(sCharStyleName);
      83           0 :             OUString sTmp;
      84           0 :             aAny >>= sTmp;
      85           0 :             if (!sTmp.isEmpty())
      86             :             {
      87             :                 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME,
      88           0 :                                      rExport.EncodeStyleName( sTmp ));
      89             :             }
      90             : 
      91             :             // enable
      92           0 :             aAny = xLineNumbering->getPropertyValue(sIsOn);
      93           0 :             if (! *(sal_Bool*)aAny.getValue())
      94             :             {
      95             :                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
      96           0 :                                      XML_NUMBER_LINES, XML_FALSE);
      97             :             }
      98             : 
      99             :             // count empty lines
     100           0 :             aAny = xLineNumbering->getPropertyValue(sCountEmptyLines);
     101           0 :             if (! *(sal_Bool*)aAny.getValue())
     102             :             {
     103             :                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
     104           0 :                                      XML_COUNT_EMPTY_LINES, XML_FALSE);
     105             :             }
     106             : 
     107             :             // count in frames
     108           0 :             aAny = xLineNumbering->getPropertyValue(sCountLinesInFrames);
     109           0 :             if (*(sal_Bool*)aAny.getValue())
     110             :             {
     111             :                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
     112           0 :                                      XML_COUNT_IN_TEXT_BOXES, XML_TRUE);
     113             :             }
     114             : 
     115             :             // restart numbering
     116           0 :             aAny = xLineNumbering->getPropertyValue(sRestartAtEachPage);
     117           0 :             if (*(sal_Bool*)aAny.getValue())
     118             :             {
     119             :                 rExport.AddAttribute(XML_NAMESPACE_TEXT,
     120           0 :                                      XML_RESTART_ON_PAGE, XML_TRUE);
     121             :             }
     122             : 
     123             :             // Distance
     124           0 :             aAny = xLineNumbering->getPropertyValue(sDistance);
     125           0 :             sal_Int32 nLength = 0;
     126           0 :             aAny >>= nLength;
     127           0 :             if (nLength != 0)
     128             :             {
     129           0 :                 OUStringBuffer sBuf;
     130           0 :                 rExport.GetMM100UnitConverter().convertMeasureToXML(
     131           0 :                         sBuf, nLength);
     132             :                 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_OFFSET,
     133           0 :                                      sBuf.makeStringAndClear());
     134             :             }
     135             : 
     136             :             // NumeringType
     137           0 :             OUStringBuffer sNumPosBuf;
     138           0 :             aAny = xLineNumbering->getPropertyValue(sNumberingType);
     139           0 :             sal_Int16 nFormat = 0;
     140           0 :             aAny >>= nFormat;
     141           0 :             rExport.GetMM100UnitConverter().convertNumFormat( sNumPosBuf, nFormat );
     142             :             rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT,
     143           0 :                                  sNumPosBuf.makeStringAndClear());
     144           0 :             rExport.GetMM100UnitConverter().convertNumLetterSync( sNumPosBuf, nFormat );
     145           0 :             if( !sNumPosBuf.isEmpty() )
     146             :             {
     147             :                 rExport.AddAttribute(XML_NAMESPACE_STYLE,
     148             :                                      XML_NUM_LETTER_SYNC,
     149           0 :                                      sNumPosBuf.makeStringAndClear() );
     150             :             }
     151             : 
     152             :             // number position
     153           0 :             aAny = xLineNumbering->getPropertyValue(sNumberPosition);
     154           0 :             sal_Int16 nPosition = 0;
     155           0 :             aAny >>= nPosition;
     156           0 :             if (SvXMLUnitConverter::convertEnum(sNumPosBuf, nPosition,
     157           0 :                                                 aLineNumberPositionMap))
     158             :             {
     159             :                 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NUMBER_POSITION,
     160           0 :                                      sNumPosBuf.makeStringAndClear());
     161             :             }
     162             : 
     163             :             // sInterval
     164           0 :             aAny = xLineNumbering->getPropertyValue(sInterval);
     165           0 :             sal_Int16 nLineInterval = 0;
     166           0 :             aAny >>= nLineInterval;
     167           0 :             OUStringBuffer sBuf;
     168             :             ::sax::Converter::convertNumber(sBuf,
     169           0 :                                               (sal_Int32)nLineInterval);
     170             :             rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT,
     171           0 :                                  sBuf.makeStringAndClear());
     172             : 
     173             :             SvXMLElementExport aConfigElem(rExport, XML_NAMESPACE_TEXT,
     174             :                                            XML_LINENUMBERING_CONFIGURATION,
     175           0 :                                            true, true);
     176             : 
     177             :             // line separator
     178           0 :             aAny = xLineNumbering->getPropertyValue(sSeparatorText);
     179           0 :             OUString sSeparator;
     180           0 :             aAny >>= sSeparator;
     181           0 :             if (!sSeparator.isEmpty())
     182             :             {
     183             : 
     184             :                 // SeparatorInterval
     185           0 :                 aAny = xLineNumbering->getPropertyValue(sSeparatorInterval);
     186           0 :                 sal_Int16 nLineDistance = 0;
     187           0 :                 aAny >>= nLineDistance;
     188             :                 ::sax::Converter::convertNumber(sBuf,
     189           0 :                                                   (sal_Int32)nLineDistance);
     190             :                 rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT,
     191           0 :                                      sBuf.makeStringAndClear());
     192             : 
     193             :                 SvXMLElementExport aSeparatorElem(rExport, XML_NAMESPACE_TEXT,
     194             :                                                   XML_LINENUMBERING_SEPARATOR,
     195           0 :                                                   true, false);
     196           0 :                 rExport.Characters(sSeparator);
     197           0 :             }
     198           0 :         }
     199             :         // else: no configuration: don't save -> default
     200           0 :     }
     201             :     // can't even get supplier: don't save -> default
     202           0 : }
     203             : 
     204             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10