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

Generated by: LCOV version 1.10