LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLTextColumnsExport.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 93 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 <rtl/ustrbuf.hxx>
      21             : 
      22             : 
      23             : #include <com/sun/star/text/XTextColumns.hpp>
      24             : #include <com/sun/star/text/TextColumn.hpp>
      25             : #include <com/sun/star/style/VerticalAlignment.hpp>
      26             : #include <com/sun/star/beans/XPropertySet.hpp>
      27             : 
      28             : #include <sax/tools/converter.hxx>
      29             : 
      30             : #include <xmloff/xmltoken.hxx>
      31             : #include <xmloff/xmlnmspe.hxx>
      32             : #include <xmloff/xmluconv.hxx>
      33             : #include <xmloff/xmlexp.hxx>
      34             : #include "XMLTextColumnsExport.hxx"
      35             : 
      36             : using namespace ::com::sun::star::style;
      37             : using namespace ::com::sun::star::text;
      38             : using namespace ::com::sun::star::uno;
      39             : using namespace ::com::sun::star::beans;
      40             : using namespace ::xmloff::token;
      41             : 
      42             : 
      43           0 : XMLTextColumnsExport::XMLTextColumnsExport( SvXMLExport& rExp ) :
      44             :     rExport( rExp ),
      45             :     sSeparatorLineIsOn("SeparatorLineIsOn"),
      46             :     sSeparatorLineWidth("SeparatorLineWidth"),
      47             :     sSeparatorLineColor("SeparatorLineColor"),
      48             :     sSeparatorLineRelativeHeight("SeparatorLineRelativeHeight"),
      49             :     sSeparatorLineVerticalAlignment("SeparatorLineVerticalAlignment"),
      50             :     sIsAutomatic("IsAutomatic"),
      51             :     sAutomaticDistance("AutomaticDistance"),
      52           0 :     sSeparatorLineStyle("SeparatorLineStyle")
      53             : {
      54           0 : }
      55             : 
      56           0 : void XMLTextColumnsExport::exportXML( const Any& rAny )
      57             : {
      58           0 :     Reference < XTextColumns > xColumns;
      59           0 :     rAny >>= xColumns;
      60             : 
      61           0 :     Sequence < TextColumn > aColumns = xColumns->getColumns();
      62           0 :     const TextColumn *pColumns = aColumns.getArray();
      63           0 :     sal_Int32 nCount = aColumns.getLength();
      64             : 
      65           0 :     OUStringBuffer sValue;
      66           0 :     ::sax::Converter::convertNumber( sValue, (nCount) ? nCount : 1 );
      67           0 :     GetExport().AddAttribute( XML_NAMESPACE_FO, XML_COLUMN_COUNT,
      68           0 :                               sValue.makeStringAndClear() );
      69             : 
      70             :     // handle 'automatic' columns
      71           0 :     Reference < XPropertySet > xPropSet( xColumns, UNO_QUERY );
      72           0 :     if( xPropSet.is() )
      73             :     {
      74           0 :         Any aAny = xPropSet->getPropertyValue( sIsAutomatic );
      75           0 :         if ( *(sal_Bool*)aAny.getValue() )
      76             :         {
      77           0 :             aAny = xPropSet->getPropertyValue( sAutomaticDistance );
      78           0 :             sal_Int32 nDistance = 0;
      79           0 :             aAny >>= nDistance;
      80           0 :             OUStringBuffer aBuffer;
      81           0 :             GetExport().GetMM100UnitConverter().convertMeasureToXML(
      82           0 :                 aBuffer, nDistance );
      83           0 :             GetExport().AddAttribute( XML_NAMESPACE_FO,
      84             :                                       XML_COLUMN_GAP,
      85           0 :                                       aBuffer.makeStringAndClear() );
      86           0 :         }
      87             :     }
      88             : 
      89           0 :     SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, XML_COLUMNS,
      90           0 :                               true, true );
      91             : 
      92           0 :     if( xPropSet.is() )
      93             :     {
      94           0 :         Any aAny = xPropSet->getPropertyValue( sSeparatorLineIsOn );
      95           0 :         if( *(sal_Bool *)aAny.getValue() )
      96             :         {
      97             :             // style:width
      98           0 :             aAny = xPropSet->getPropertyValue( sSeparatorLineWidth );
      99           0 :             sal_Int32 nWidth = 0;
     100           0 :             aAny >>= nWidth;
     101           0 :             GetExport().GetMM100UnitConverter().convertMeasureToXML( sValue,
     102           0 :                                                                 nWidth );
     103           0 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_WIDTH,
     104           0 :                                       sValue.makeStringAndClear() );
     105             : 
     106             :             // style:color
     107           0 :             aAny = xPropSet->getPropertyValue( sSeparatorLineColor );
     108           0 :             sal_Int32 nColor = 0;
     109           0 :             aAny >>= nColor;
     110           0 :             ::sax::Converter::convertColor( sValue, nColor );
     111           0 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_COLOR,
     112           0 :                                       sValue.makeStringAndClear() );
     113             : 
     114             :             // style:height
     115           0 :             aAny = xPropSet->getPropertyValue( sSeparatorLineRelativeHeight );
     116           0 :             sal_Int8 nHeight = 0;
     117           0 :             aAny >>= nHeight;
     118           0 :             ::sax::Converter::convertPercent( sValue, nHeight );
     119           0 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_HEIGHT,
     120           0 :                                       sValue.makeStringAndClear() );
     121             : 
     122             :             // style::style
     123           0 :             aAny = xPropSet->getPropertyValue( sSeparatorLineStyle );
     124           0 :             sal_Int8 nStyle = 0;
     125           0 :             aAny >>= nStyle;
     126             : 
     127           0 :             enum XMLTokenEnum eStr = XML_TOKEN_INVALID;
     128           0 :             switch ( nStyle )
     129             :             {
     130           0 :                 case 0:  eStr = XML_NONE; break;
     131           0 :                 case 1:  eStr = XML_SOLID; break;
     132           0 :                 case 2:  eStr = XML_DOTTED; break;
     133           0 :                 case 3:  eStr = XML_DASHED; break;
     134             :                 default:
     135           0 :                          break;
     136             :             }
     137           0 :             if ( eStr != XML_TOKEN_INVALID )
     138           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_STYLE, eStr );
     139             : 
     140             :             // style:vertical-align
     141           0 :             aAny = xPropSet->getPropertyValue( sSeparatorLineVerticalAlignment );
     142             :             VerticalAlignment eVertAlign;
     143           0 :             aAny >>= eVertAlign;
     144             : 
     145           0 :             eStr = XML_TOKEN_INVALID;
     146           0 :             switch( eVertAlign )
     147             :             {
     148             : //          case VerticalAlignment_TOP: eStr = XML_TOP;
     149           0 :             case VerticalAlignment_MIDDLE: eStr = XML_MIDDLE; break;
     150           0 :             case VerticalAlignment_BOTTOM: eStr = XML_BOTTOM; break;
     151             :             default:
     152           0 :                 break;
     153             :             }
     154             : 
     155           0 :             if( eStr != XML_TOKEN_INVALID)
     156           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     157           0 :                                           XML_VERTICAL_ALIGN, eStr );
     158             : 
     159             :             // style:column-sep
     160           0 :             SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_STYLE,
     161             :                                       XML_COLUMN_SEP,
     162           0 :                                       true, true );
     163           0 :         }
     164             :     }
     165             : 
     166           0 :     while( nCount-- )
     167             :     {
     168             :         // style:rel-width
     169           0 :         ::sax::Converter::convertNumber( sValue, pColumns->Width );
     170           0 :         sValue.append( '*' );
     171           0 :         GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH,
     172           0 :                                   sValue.makeStringAndClear() );
     173             : 
     174             :         // fo:margin-left
     175           0 :         GetExport().GetMM100UnitConverter().convertMeasureToXML( sValue,
     176           0 :                                                        pColumns->LeftMargin );
     177           0 :         GetExport().AddAttribute( XML_NAMESPACE_FO, XML_START_INDENT,
     178           0 :                                        sValue.makeStringAndClear() );
     179             : 
     180             :         // fo:margin-right
     181           0 :         GetExport().GetMM100UnitConverter().convertMeasureToXML( sValue,
     182           0 :                                                        pColumns->RightMargin );
     183           0 :         GetExport().AddAttribute( XML_NAMESPACE_FO, XML_END_INDENT,
     184           0 :                                     sValue.makeStringAndClear() );
     185             : 
     186             :         // style:column
     187           0 :         SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_STYLE, XML_COLUMN,
     188           0 :                                   true, true );
     189           0 :         pColumns++;
     190           0 :     }
     191           0 : }
     192             : 
     193             : 
     194             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10