LCOV - code coverage report
Current view: top level - xmloff/source/text - txtstyle.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 64 71 90.1 %
Date: 2014-11-03 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         658 : void XMLTextParagraphExport::exportStyleAttributes(
      46             :         const ::com::sun::star::uno::Reference<
      47             :                 ::com::sun::star::style::XStyle > & rStyle )
      48             : {
      49         658 :     OUString sName;
      50        1316 :     Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
      51             :     Reference< XPropertySetInfo > xPropSetInfo(
      52        1316 :             xPropSet->getPropertySetInfo());
      53         658 :     if( xPropSetInfo->hasPropertyByName( sCategory ) )
      54             :     {
      55         504 :         sal_Int16 nCategory = 0;
      56         504 :         xPropSet->getPropertyValue( sCategory ) >>= nCategory;
      57         504 :         enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
      58         504 :         if( -1 != nCategory )
      59             :         {
      60         424 :             switch( nCategory )
      61             :             {
      62             :             case ParagraphStyleCategory::TEXT:
      63         190 :                 eValue = XML_TEXT;
      64         190 :                 break;
      65             :             case ParagraphStyleCategory::CHAPTER:
      66           0 :                 eValue = XML_CHAPTER;
      67           0 :                 break;
      68             :             case ParagraphStyleCategory::LIST:
      69          58 :                 eValue = XML_LIST;
      70          58 :                 break;
      71             :             case ParagraphStyleCategory::INDEX:
      72          78 :                 eValue = XML_INDEX;
      73          78 :                 break;
      74             :             case ParagraphStyleCategory::EXTRA:
      75          98 :                 eValue = XML_EXTRA;
      76          98 :                 break;
      77             :             case ParagraphStyleCategory::HTML:
      78           0 :                 eValue = XML_HTML;
      79           0 :                 break;
      80             :             }
      81             :         }
      82         504 :         if( eValue != XML_TOKEN_INVALID )
      83         424 :             GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_CLASS, eValue);
      84             :     }
      85         658 :     if( xPropSetInfo->hasPropertyByName( sPageDescName ) )
      86             :     {
      87         504 :         Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
      88         504 :         if( PropertyState_DIRECT_VALUE ==
      89         504 :                 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         504 :         }
      97             :     }
      98         658 :     if( bProgress )
      99             :     {
     100         658 :         ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
     101         658 :             pProgress->SetValue( pProgress->GetValue()+2 );
     102         658 :     }
     103         658 : }
     104             : 
     105          60 : void XMLTextParagraphExport::exportNumStyles( bool bUsed )
     106             : {
     107          60 :     SvxXMLNumRuleExport aNumRuleExport( GetExport() );
     108          60 :     aNumRuleExport.exportStyles( bUsed, pListAutoPool, !IsBlockMode() );
     109          60 : }
     110             : 
     111          60 : void XMLTextParagraphExport::exportTextStyles( bool bUsed, bool bProg )
     112             : {
     113          60 :     bool bOldProg = bProgress;
     114          60 :     bProgress = bProg;
     115             : 
     116          60 :     Reference < lang::XMultiServiceFactory > xFactory (GetExport().GetModel(), UNO_QUERY);
     117          60 :     if (xFactory.is())
     118             :     {
     119          60 :         OUString sTextDefaults ( "com.sun.star.text.Defaults" );
     120         120 :         Reference < XPropertySet > xPropSet (xFactory->createInstance ( sTextDefaults ), UNO_QUERY);
     121          60 :         if (xPropSet.is())
     122             :         {
     123          60 :             exportDefaultStyle( xPropSet, GetXMLToken(XML_PARAGRAPH), GetParaPropMapper());
     124             : 
     125             :             exportDefaultStyle(
     126             :                 xPropSet,
     127          60 :                 GetXMLToken(XML_TABLE),
     128             :                 new XMLTextExportPropertySetMapper(
     129             :                     new XMLTextPropertySetMapper(
     130          60 :                         TEXT_PROP_MAP_TABLE_DEFAULTS, true ),
     131         180 :                     GetExport() ) );
     132             : 
     133             :             exportDefaultStyle(
     134             :                 xPropSet,
     135          60 :                 GetXMLToken(XML_TABLE_ROW),
     136             :                 new XMLTextExportPropertySetMapper(
     137             :                     new XMLTextPropertySetMapper(
     138          60 :                         TEXT_PROP_MAP_TABLE_ROW_DEFAULTS, true ),
     139         180 :                     GetExport() ) );
     140          60 :         }
     141             :     }
     142          60 :     exportStyleFamily( "ParagraphStyles", GetXMLToken(XML_PARAGRAPH), GetParaPropMapper(),
     143         120 :                        bUsed, XML_STYLE_FAMILY_TEXT_PARAGRAPH, 0);
     144          60 :     exportStyleFamily( "CharacterStyles", GetXMLToken(XML_TEXT), GetTextPropMapper(),
     145         120 :                        bUsed, XML_STYLE_FAMILY_TEXT_TEXT );
     146             :     // get shape export to make sure the frame family is added correctly.
     147          60 :     GetExport().GetShapeExport();
     148             :     exportStyleFamily( "FrameStyles", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), GetFramePropMapper(),
     149          60 :                        bUsed, XML_STYLE_FAMILY_TEXT_FRAME, 0);
     150          60 :     exportNumStyles( bUsed );
     151          60 :     if( !IsBlockMode() )
     152             :     {
     153          58 :         exportTextFootnoteConfiguration();
     154          58 :         XMLSectionExport::ExportBibliographyConfiguration(GetExport());
     155          58 :         XMLLineNumberingExport aLineNumberingExport(GetExport());
     156          58 :         aLineNumberingExport.Export();
     157             :     }
     158             : 
     159          60 :     bProgress = bOldProg;
     160          60 : }
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10