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

Generated by: LCOV version 1.10