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

Generated by: LCOV version 1.10