LCOV - code coverage report
Current view: top level - xmloff/source/text - txtstyle.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 64 71 90.1 %
Date: 2014-04-11 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 <com/sun/star/style/ParagraphStyleCategory.hpp>
      22             : #include <com/sun/star/beans/XPropertySet.hpp>
      23             : #include <com/sun/star/beans/XPropertySetInfo.hpp>
      24             : #include <com/sun/star/beans/XPropertyState.hpp>
      25             : #include <com/sun/star/style/XStyle.hpp>
      26             : #include <xmloff/xmltoken.hxx>
      27             : #include <xmloff/xmlnmspe.hxx>
      28             : #include <xmloff/families.hxx>
      29             : #include <xmloff/txtparae.hxx>
      30             : #include <xmloff/xmlnume.hxx>
      31             : #include <xmloff/xmlexp.hxx>
      32             : #include "XMLSectionExport.hxx"
      33             : #include "XMLLineNumberingExport.hxx"
      34             : #include "txtexppr.hxx"
      35             : #include <xmloff/txtprmap.hxx>
      36             : 
      37             : 
      38             : using namespace ::com::sun::star;
      39             : using namespace ::com::sun::star::uno;
      40             : using namespace ::com::sun::star::style;
      41             : using namespace ::com::sun::star::container;
      42             : using namespace ::com::sun::star::beans;
      43             : using namespace ::xmloff::token;
      44             : 
      45         239 : void XMLTextParagraphExport::exportStyleAttributes(
      46             :         const ::com::sun::star::uno::Reference<
      47             :                 ::com::sun::star::style::XStyle > & rStyle )
      48             : {
      49         239 :     OUString sName;
      50         478 :     Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
      51             :     Reference< XPropertySetInfo > xPropSetInfo(
      52         478 :             xPropSet->getPropertySetInfo());
      53         239 :     if( xPropSetInfo->hasPropertyByName( sCategory ) )
      54             :     {
      55         166 :         sal_Int16 nCategory = 0;
      56         166 :         xPropSet->getPropertyValue( sCategory ) >>= nCategory;
      57         166 :         enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
      58         166 :         if( -1 != nCategory )
      59             :         {
      60         138 :             switch( nCategory )
      61             :             {
      62             :             case ParagraphStyleCategory::TEXT:
      63          61 :                 eValue = XML_TEXT;
      64          61 :                 break;
      65             :             case ParagraphStyleCategory::CHAPTER:
      66           0 :                 eValue = XML_CHAPTER;
      67           0 :                 break;
      68             :             case ParagraphStyleCategory::LIST:
      69          20 :                 eValue = XML_LIST;
      70          20 :                 break;
      71             :             case ParagraphStyleCategory::INDEX:
      72          27 :                 eValue = XML_INDEX;
      73          27 :                 break;
      74             :             case ParagraphStyleCategory::EXTRA:
      75          30 :                 eValue = XML_EXTRA;
      76          30 :                 break;
      77             :             case ParagraphStyleCategory::HTML:
      78           0 :                 eValue = XML_HTML;
      79           0 :                 break;
      80             :             }
      81             :         }
      82         166 :         if( eValue != XML_TOKEN_INVALID )
      83         138 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_CLASS, eValue);
      84             :     }
      85         239 :     if( xPropSetInfo->hasPropertyByName( sPageDescName ) )
      86             :     {
      87         166 :         Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
      88         166 :         if( PropertyState_DIRECT_VALUE ==
      89         166 :                 xPropState->getPropertyState( sPageDescName  ) )
      90             :         {
      91           0 :             xPropSet->getPropertyValue( sPageDescName ) >>= sName;
      92             :             // fix for #i5551#  if( sName.getLength() > 0 )
      93           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
      94             :                                           XML_MASTER_PAGE_NAME,
      95           0 :                                           GetExport().EncodeStyleName( sName ) );
      96         166 :         }
      97             :     }
      98         239 :     if( bProgress )
      99             :     {
     100         239 :         ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
     101         239 :             pProgress->SetValue( pProgress->GetValue()+2 );
     102         239 :     }
     103         239 : }
     104             : 
     105          21 : void XMLTextParagraphExport::exportNumStyles( bool bUsed )
     106             : {
     107          21 :     SvxXMLNumRuleExport aNumRuleExport( GetExport() );
     108          21 :     aNumRuleExport.exportStyles( bUsed, pListAutoPool, !IsBlockMode() );
     109          21 : }
     110             : 
     111          21 : void XMLTextParagraphExport::exportTextStyles( bool bUsed, bool bProg )
     112             : {
     113          21 :     sal_Bool bOldProg = bProgress;
     114          21 :     bProgress = bProg;
     115             : 
     116          21 :     Reference < lang::XMultiServiceFactory > xFactory (GetExport().GetModel(), UNO_QUERY);
     117          21 :     if (xFactory.is())
     118             :     {
     119          21 :         OUString sTextDefaults ( "com.sun.star.text.Defaults" );
     120          42 :         Reference < XPropertySet > xPropSet (xFactory->createInstance ( sTextDefaults ), UNO_QUERY);
     121          21 :         if (xPropSet.is())
     122             :         {
     123          21 :             exportDefaultStyle( xPropSet, GetXMLToken(XML_PARAGRAPH), GetParaPropMapper());
     124             : 
     125             :             exportDefaultStyle(
     126             :                 xPropSet,
     127          21 :                 GetXMLToken(XML_TABLE),
     128             :                 new XMLTextExportPropertySetMapper(
     129             :                     new XMLTextPropertySetMapper(
     130          21 :                         TEXT_PROP_MAP_TABLE_DEFAULTS, true ),
     131          63 :                     GetExport() ) );
     132             : 
     133             :             exportDefaultStyle(
     134             :                 xPropSet,
     135          21 :                 GetXMLToken(XML_TABLE_ROW),
     136             :                 new XMLTextExportPropertySetMapper(
     137             :                     new XMLTextPropertySetMapper(
     138          21 :                         TEXT_PROP_MAP_TABLE_ROW_DEFAULTS, true ),
     139          63 :                     GetExport() ) );
     140          21 :         }
     141             :     }
     142          21 :     exportStyleFamily( "ParagraphStyles", GetXMLToken(XML_PARAGRAPH), GetParaPropMapper(),
     143          42 :                        bUsed, XML_STYLE_FAMILY_TEXT_PARAGRAPH, 0);
     144          21 :     exportStyleFamily( "CharacterStyles", GetXMLToken(XML_TEXT), GetTextPropMapper(),
     145          42 :                        bUsed, XML_STYLE_FAMILY_TEXT_TEXT );
     146             :     // get shape export to make sure the frame family is added correctly.
     147          21 :     GetExport().GetShapeExport();
     148             :     exportStyleFamily( "FrameStyles", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), GetFramePropMapper(),
     149          21 :                        bUsed, XML_STYLE_FAMILY_TEXT_FRAME, 0);
     150          21 :     exportNumStyles( bUsed );
     151          21 :     if( !IsBlockMode() )
     152             :     {
     153          20 :         exportTextFootnoteConfiguration();
     154          20 :         XMLSectionExport::ExportBibliographyConfiguration(GetExport());
     155          20 :         XMLLineNumberingExport aLineNumberingExport(GetExport());
     156          20 :         aLineNumberingExport.Export();
     157             :     }
     158             : 
     159          21 :     bProgress = bOldProg;
     160          21 : }
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10