LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLTextMasterPageExport.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 103 115 89.6 %
Date: 2014-11-03 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         108 : 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         108 :     sFooterTextLeft( "FooterTextLeft" )
      49             : {
      50         108 : }
      51             : 
      52         168 : XMLTextMasterPageExport::~XMLTextMasterPageExport()
      53             : {
      54         168 : }
      55             : 
      56             : 
      57          52 : 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          52 :     GetExport().GetTextParagraphExport()->recordTrackedChangesForXText(rText);
      65          52 :     GetExport().GetTextParagraphExport()->exportTrackedChanges(rText,
      66         104 :                                                                bAutoStyles);
      67          52 :     if( bAutoStyles )
      68          26 :         GetExport().GetTextParagraphExport()
      69          52 :                 ->collectTextAutoStyles( rText, true, bExportParagraph );
      70             :     else
      71             :     {
      72          26 :         GetExport().GetTextParagraphExport()->exportTextDeclarations( rText );
      73          26 :         GetExport().GetTextParagraphExport()->exportText( rText, true, bExportParagraph );
      74             :     }
      75             : 
      76             :     // tracked changes (end of XText)
      77          52 :     GetExport().GetTextParagraphExport()->recordTrackedChangesNoXText();
      78          52 : }
      79             : 
      80         136 : void XMLTextMasterPageExport::exportMasterPageContent(
      81             :                 const Reference < XPropertySet > & rPropSet,
      82             :                 bool bAutoStyles )
      83             : {
      84         136 :     Any aAny;
      85             : 
      86         272 :     Reference < XText > xHeaderText;
      87         136 :     aAny = rPropSet->getPropertyValue( sHeaderText );
      88         136 :     aAny >>= xHeaderText;
      89             : 
      90         272 :     Reference < XText > xHeaderTextFirst;
      91         136 :     aAny = rPropSet->getPropertyValue( sHeaderTextFirst );
      92         136 :     aAny >>= xHeaderTextFirst;
      93             : 
      94         272 :     Reference < XText > xHeaderTextLeft;
      95         136 :     aAny = rPropSet->getPropertyValue( sHeaderTextLeft );
      96         136 :     aAny >>= xHeaderTextLeft;
      97             : 
      98         272 :     Reference < XText > xFooterText;
      99         136 :     aAny = rPropSet->getPropertyValue( sFooterText );
     100         136 :     aAny >>= xFooterText;
     101             : 
     102         272 :     Reference < XText > xFooterTextFirst;
     103         136 :     aAny = rPropSet->getPropertyValue( sFooterTextFirst );
     104         136 :     aAny >>= xFooterTextFirst;
     105             : 
     106         272 :     Reference < XText > xFooterTextLeft;
     107         136 :     aAny = rPropSet->getPropertyValue( sFooterTextLeft );
     108         136 :     aAny >>= xFooterTextLeft;
     109             : 
     110         136 :     if( bAutoStyles )
     111             :     {
     112          68 :         if( xHeaderText.is() )
     113           6 :             exportHeaderFooterContent( xHeaderText, true );
     114          68 :         if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
     115           4 :             exportHeaderFooterContent( xHeaderTextFirst, true );
     116          68 :         if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
     117           4 :             exportHeaderFooterContent( xHeaderTextLeft, true );
     118          68 :         if( xFooterText.is() )
     119           4 :             exportHeaderFooterContent( xFooterText, true );
     120          68 :         if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
     121           4 :             exportHeaderFooterContent( xFooterTextFirst, true );
     122          68 :         if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
     123           4 :             exportHeaderFooterContent( xFooterTextLeft, true );
     124             :     }
     125             :     else
     126             :     {
     127          68 :         aAny = rPropSet->getPropertyValue( sHeaderOn );
     128          68 :         bool bHeader = false;
     129          68 :         aAny >>= bHeader;
     130             : 
     131          68 :         bool bHeaderFirstShared = false;
     132          68 :         if( bHeader )
     133             :         {
     134           6 :             aAny = rPropSet->getPropertyValue( sFirstShareContent );
     135           6 :             aAny >>= bHeaderFirstShared;
     136             :         }
     137             : 
     138          68 :         bool bHeaderLeftShared = false;
     139          68 :         if( bHeader )
     140             :         {
     141           6 :             aAny = rPropSet->getPropertyValue( sHeaderShareContent );
     142           6 :             aAny >>= bHeaderLeftShared;
     143             :         }
     144             : 
     145          68 :         if( xHeaderText.is() )
     146             :         {
     147           6 :             if( !bHeader )
     148           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     149           0 :                                           XML_DISPLAY, XML_FALSE );
     150           6 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     151           6 :                                         XML_HEADER, true, true );
     152           6 :             exportHeaderFooterContent( xHeaderText, false );
     153             :         }
     154             : 
     155          68 :         if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
     156             :         {
     157           4 :             if (bHeaderFirstShared)
     158           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     159           0 :                                           XML_DISPLAY, XML_FALSE );
     160           4 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     161           4 :                                         XML_HEADER_FIRST, true, true );
     162           4 :             exportHeaderFooterContent( xHeaderTextFirst, false );
     163             :         }
     164             : 
     165          68 :         if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
     166             :         {
     167           4 :             if (bHeaderLeftShared)
     168           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     169           0 :                                           XML_DISPLAY, XML_FALSE );
     170           4 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     171           4 :                                         XML_HEADER_LEFT, true, true );
     172           4 :             exportHeaderFooterContent( xHeaderTextLeft, false );
     173             :         }
     174             : 
     175          68 :         aAny = rPropSet->getPropertyValue( sFooterOn );
     176          68 :         bool bFooter = false;
     177          68 :         aAny >>= bFooter;
     178             : 
     179          68 :         bool bFooterFirstShared = false;
     180          68 :         if( bFooter )
     181             :         {
     182           4 :             aAny = rPropSet->getPropertyValue( sFirstShareContent );
     183           4 :             aAny >>= bFooterFirstShared;
     184             :         }
     185             : 
     186          68 :         bool bFooterLeftShared = false;
     187          68 :         if( bFooter )
     188             :         {
     189           4 :             aAny = rPropSet->getPropertyValue( sFooterShareContent );
     190           4 :             aAny >>= bFooterLeftShared;
     191             :         }
     192             : 
     193          68 :         if( xFooterText.is() )
     194             :         {
     195           4 :             if( !bFooter )
     196           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     197           0 :                                           XML_DISPLAY, XML_FALSE );
     198           4 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     199           4 :                                         XML_FOOTER, true, true );
     200           4 :             exportHeaderFooterContent( xFooterText, false );
     201             :         }
     202             : 
     203          68 :         if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
     204             :         {
     205           4 :             if (bFooterFirstShared)
     206           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     207           0 :                                           XML_DISPLAY, XML_FALSE );
     208           4 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     209           4 :                                         XML_FOOTER_FIRST, true, true );
     210           4 :             exportHeaderFooterContent( xFooterTextFirst, false );
     211             :         }
     212             : 
     213          68 :         if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
     214             :         {
     215           4 :             if (bFooterLeftShared)
     216           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     217           0 :                                           XML_DISPLAY, XML_FALSE );
     218           4 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     219           4 :                                         XML_FOOTER_LEFT, true, true );
     220           4 :             exportHeaderFooterContent( xFooterTextLeft, false );
     221             :         }
     222         136 :     }
     223         136 : }
     224             : 
     225             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10