LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLTextMasterPageExport.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 103 115 89.6 %
Date: 2014-04-11 Functions: 5 5 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             : #include <tools/debug.hxx>
      21             : #include <xmloff/xmlnmspe.hxx>
      22             : #include <xmloff/xmltoken.hxx>
      23             : #include <com/sun/star/text/XText.hpp>
      24             : #include <com/sun/star/beans/XPropertySet.hpp>
      25             : #include <xmloff/xmlexp.hxx>
      26             : #include <xmloff/XMLTextMasterPageExport.hxx>
      27             : 
      28             : 
      29             : 
      30             : using namespace ::com::sun::star;
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::text;
      33             : using namespace ::com::sun::star::beans;
      34             : using namespace ::xmloff::token;
      35             : 
      36          39 : XMLTextMasterPageExport::XMLTextMasterPageExport( SvXMLExport& rExp ) :
      37             :     XMLPageExport( rExp ),
      38             :     sHeaderText( "HeaderText" ),
      39             :     sHeaderOn( "HeaderIsOn" ),
      40             :     sHeaderShareContent( "HeaderIsShared" ),
      41             :     sHeaderTextFirst( "HeaderTextFirst" ),
      42             :     sHeaderTextLeft( "HeaderTextLeft" ),
      43             :     sFirstShareContent( "FirstIsShared" ),
      44             :     sFooterText( "FooterText" ),
      45             :     sFooterOn( "FooterIsOn" ),
      46             :     sFooterShareContent( "FooterIsShared" ),
      47             :     sFooterTextFirst( "FooterTextFirst" ),
      48          39 :     sFooterTextLeft( "FooterTextLeft" )
      49             : {
      50          39 : }
      51             : 
      52          60 : XMLTextMasterPageExport::~XMLTextMasterPageExport()
      53             : {
      54          60 : }
      55             : 
      56             : 
      57          24 : void XMLTextMasterPageExport::exportHeaderFooterContent(
      58             :             const Reference< XText >& rText,
      59             :             bool bAutoStyles, bool bExportParagraph )
      60             : {
      61             :     DBG_ASSERT( rText.is(), "There is the text" );
      62             : 
      63             :     // tracked changes (autostyles + changes list)
      64          24 :     GetExport().GetTextParagraphExport()->recordTrackedChangesForXText(rText);
      65          24 :     GetExport().GetTextParagraphExport()->exportTrackedChanges(rText,
      66          48 :                                                                bAutoStyles);
      67          24 :     if( bAutoStyles )
      68          12 :         GetExport().GetTextParagraphExport()
      69          24 :                 ->collectTextAutoStyles( rText, true, bExportParagraph );
      70             :     else
      71             :     {
      72          12 :         GetExport().GetTextParagraphExport()->exportTextDeclarations( rText );
      73          12 :         GetExport().GetTextParagraphExport()->exportText( rText, true, bExportParagraph );
      74             :     }
      75             : 
      76             :     // tracked changes (end of XText)
      77          24 :     GetExport().GetTextParagraphExport()->recordTrackedChangesNoXText();
      78          24 : }
      79             : 
      80          48 : void XMLTextMasterPageExport::exportMasterPageContent(
      81             :                 const Reference < XPropertySet > & rPropSet,
      82             :                 bool bAutoStyles )
      83             : {
      84          48 :     Any aAny;
      85             : 
      86          96 :     Reference < XText > xHeaderText;
      87          48 :     aAny = rPropSet->getPropertyValue( sHeaderText );
      88          48 :     aAny >>= xHeaderText;
      89             : 
      90          96 :     Reference < XText > xHeaderTextFirst;
      91          48 :     aAny = rPropSet->getPropertyValue( sHeaderTextFirst );
      92          48 :     aAny >>= xHeaderTextFirst;
      93             : 
      94          96 :     Reference < XText > xHeaderTextLeft;
      95          48 :     aAny = rPropSet->getPropertyValue( sHeaderTextLeft );
      96          48 :     aAny >>= xHeaderTextLeft;
      97             : 
      98          96 :     Reference < XText > xFooterText;
      99          48 :     aAny = rPropSet->getPropertyValue( sFooterText );
     100          48 :     aAny >>= xFooterText;
     101             : 
     102          96 :     Reference < XText > xFooterTextFirst;
     103          48 :     aAny = rPropSet->getPropertyValue( sFooterTextFirst );
     104          48 :     aAny >>= xFooterTextFirst;
     105             : 
     106          96 :     Reference < XText > xFooterTextLeft;
     107          48 :     aAny = rPropSet->getPropertyValue( sFooterTextLeft );
     108          48 :     aAny >>= xFooterTextLeft;
     109             : 
     110          48 :     if( bAutoStyles )
     111             :     {
     112          24 :         if( xHeaderText.is() )
     113           2 :             exportHeaderFooterContent( xHeaderText, true );
     114          24 :         if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
     115           2 :             exportHeaderFooterContent( xHeaderTextFirst, true );
     116          24 :         if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
     117           2 :             exportHeaderFooterContent( xHeaderTextLeft, true );
     118          24 :         if( xFooterText.is() )
     119           2 :             exportHeaderFooterContent( xFooterText, true );
     120          24 :         if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
     121           2 :             exportHeaderFooterContent( xFooterTextFirst, true );
     122          24 :         if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
     123           2 :             exportHeaderFooterContent( xFooterTextLeft, true );
     124             :     }
     125             :     else
     126             :     {
     127          24 :         aAny = rPropSet->getPropertyValue( sHeaderOn );
     128          24 :         sal_Bool bHeader = sal_False;
     129          24 :         aAny >>= bHeader;
     130             : 
     131          24 :         sal_Bool bHeaderFirstShared = sal_False;
     132          24 :         if( bHeader )
     133             :         {
     134           2 :             aAny = rPropSet->getPropertyValue( sFirstShareContent );
     135           2 :             aAny >>= bHeaderFirstShared;
     136             :         }
     137             : 
     138          24 :         sal_Bool bHeaderLeftShared = sal_False;
     139          24 :         if( bHeader )
     140             :         {
     141           2 :             aAny = rPropSet->getPropertyValue( sHeaderShareContent );
     142           2 :             aAny >>= bHeaderLeftShared;
     143             :         }
     144             : 
     145          24 :         if( xHeaderText.is() )
     146             :         {
     147           2 :             if( !bHeader )
     148           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     149           0 :                                           XML_DISPLAY, XML_FALSE );
     150           2 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     151           2 :                                         XML_HEADER, true, true );
     152           2 :             exportHeaderFooterContent( xHeaderText, false );
     153             :         }
     154             : 
     155          24 :         if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
     156             :         {
     157           2 :             if (bHeaderFirstShared)
     158           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     159           0 :                                           XML_DISPLAY, XML_FALSE );
     160           2 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     161           2 :                                         XML_HEADER_FIRST, true, true );
     162           2 :             exportHeaderFooterContent( xHeaderTextFirst, false );
     163             :         }
     164             : 
     165          24 :         if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
     166             :         {
     167           2 :             if (bHeaderLeftShared)
     168           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     169           0 :                                           XML_DISPLAY, XML_FALSE );
     170           2 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     171           2 :                                         XML_HEADER_LEFT, true, true );
     172           2 :             exportHeaderFooterContent( xHeaderTextLeft, false );
     173             :         }
     174             : 
     175          24 :         aAny = rPropSet->getPropertyValue( sFooterOn );
     176          24 :         sal_Bool bFooter = sal_False;
     177          24 :         aAny >>= bFooter;
     178             : 
     179          24 :         sal_Bool bFooterFirstShared = sal_False;
     180          24 :         if( bFooter )
     181             :         {
     182           2 :             aAny = rPropSet->getPropertyValue( sFirstShareContent );
     183           2 :             aAny >>= bFooterFirstShared;
     184             :         }
     185             : 
     186          24 :         sal_Bool bFooterLeftShared = sal_False;
     187          24 :         if( bFooter )
     188             :         {
     189           2 :             aAny = rPropSet->getPropertyValue( sFooterShareContent );
     190           2 :             aAny >>= bFooterLeftShared;
     191             :         }
     192             : 
     193          24 :         if( xFooterText.is() )
     194             :         {
     195           2 :             if( !bFooter )
     196           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     197           0 :                                           XML_DISPLAY, XML_FALSE );
     198           2 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     199           2 :                                         XML_FOOTER, true, true );
     200           2 :             exportHeaderFooterContent( xFooterText, false );
     201             :         }
     202             : 
     203          24 :         if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
     204             :         {
     205           2 :             if (bFooterFirstShared)
     206           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     207           0 :                                           XML_DISPLAY, XML_FALSE );
     208           2 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     209           2 :                                         XML_FOOTER_FIRST, true, true );
     210           2 :             exportHeaderFooterContent( xFooterTextFirst, false );
     211             :         }
     212             : 
     213          24 :         if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
     214             :         {
     215           2 :             if (bFooterLeftShared)
     216           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     217           0 :                                           XML_DISPLAY, XML_FALSE );
     218           2 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     219           2 :                                         XML_FOOTER_LEFT, true, true );
     220           2 :             exportHeaderFooterContent( xFooterTextLeft, false );
     221             :         }
     222          48 :     }
     223          48 : }
     224             : 
     225             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10