LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLTextMasterPageExport.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 103 115 89.6 %
Date: 2015-06-13 12:38:46 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         102 : 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         102 :     sFooterTextLeft( "FooterTextLeft" )
      49             : {
      50         102 : }
      51             : 
      52         175 : XMLTextMasterPageExport::~XMLTextMasterPageExport()
      53             : {
      54         175 : }
      55             : 
      56             : 
      57          46 : 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          46 :     GetExport().GetTextParagraphExport()->recordTrackedChangesForXText(rText);
      65          46 :     GetExport().GetTextParagraphExport()->exportTrackedChanges(rText,
      66          92 :                                                                bAutoStyles);
      67          46 :     if( bAutoStyles )
      68          23 :         GetExport().GetTextParagraphExport()
      69          46 :                 ->collectTextAutoStyles( rText, true, bExportParagraph );
      70             :     else
      71             :     {
      72          23 :         GetExport().GetTextParagraphExport()->exportTextDeclarations( rText );
      73          23 :         GetExport().GetTextParagraphExport()->exportText( rText, true, bExportParagraph );
      74             :     }
      75             : 
      76             :     // tracked changes (end of XText)
      77          46 :     GetExport().GetTextParagraphExport()->recordTrackedChangesNoXText();
      78          46 : }
      79             : 
      80         174 : void XMLTextMasterPageExport::exportMasterPageContent(
      81             :                 const Reference < XPropertySet > & rPropSet,
      82             :                 bool bAutoStyles )
      83             : {
      84         174 :     Any aAny;
      85             : 
      86         348 :     Reference < XText > xHeaderText;
      87         174 :     aAny = rPropSet->getPropertyValue( sHeaderText );
      88         174 :     aAny >>= xHeaderText;
      89             : 
      90         348 :     Reference < XText > xHeaderTextFirst;
      91         174 :     aAny = rPropSet->getPropertyValue( sHeaderTextFirst );
      92         174 :     aAny >>= xHeaderTextFirst;
      93             : 
      94         348 :     Reference < XText > xHeaderTextLeft;
      95         174 :     aAny = rPropSet->getPropertyValue( sHeaderTextLeft );
      96         174 :     aAny >>= xHeaderTextLeft;
      97             : 
      98         348 :     Reference < XText > xFooterText;
      99         174 :     aAny = rPropSet->getPropertyValue( sFooterText );
     100         174 :     aAny >>= xFooterText;
     101             : 
     102         348 :     Reference < XText > xFooterTextFirst;
     103         174 :     aAny = rPropSet->getPropertyValue( sFooterTextFirst );
     104         174 :     aAny >>= xFooterTextFirst;
     105             : 
     106         348 :     Reference < XText > xFooterTextLeft;
     107         174 :     aAny = rPropSet->getPropertyValue( sFooterTextLeft );
     108         174 :     aAny >>= xFooterTextLeft;
     109             : 
     110         174 :     if( bAutoStyles )
     111             :     {
     112          87 :         if( xHeaderText.is() )
     113           6 :             exportHeaderFooterContent( xHeaderText, true );
     114          87 :         if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
     115           2 :             exportHeaderFooterContent( xHeaderTextFirst, true );
     116          87 :         if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
     117           2 :             exportHeaderFooterContent( xHeaderTextLeft, true );
     118          87 :         if( xFooterText.is() )
     119           7 :             exportHeaderFooterContent( xFooterText, true );
     120          87 :         if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
     121           2 :             exportHeaderFooterContent( xFooterTextFirst, true );
     122          87 :         if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
     123           4 :             exportHeaderFooterContent( xFooterTextLeft, true );
     124             :     }
     125             :     else
     126             :     {
     127          87 :         aAny = rPropSet->getPropertyValue( sHeaderOn );
     128          87 :         bool bHeader = false;
     129          87 :         aAny >>= bHeader;
     130             : 
     131          87 :         bool bHeaderFirstShared = false;
     132          87 :         if( bHeader )
     133             :         {
     134           6 :             aAny = rPropSet->getPropertyValue( sFirstShareContent );
     135           6 :             aAny >>= bHeaderFirstShared;
     136             :         }
     137             : 
     138          87 :         bool bHeaderLeftShared = false;
     139          87 :         if( bHeader )
     140             :         {
     141           6 :             aAny = rPropSet->getPropertyValue( sHeaderShareContent );
     142           6 :             aAny >>= bHeaderLeftShared;
     143             :         }
     144             : 
     145          87 :         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          87 :         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          87 :         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          87 :         aAny = rPropSet->getPropertyValue( sFooterOn );
     176          87 :         bool bFooter = false;
     177          87 :         aAny >>= bFooter;
     178             : 
     179          87 :         bool bFooterFirstShared = false;
     180          87 :         if( bFooter )
     181             :         {
     182           7 :             aAny = rPropSet->getPropertyValue( sFirstShareContent );
     183           7 :             aAny >>= bFooterFirstShared;
     184             :         }
     185             : 
     186          87 :         bool bFooterLeftShared = false;
     187          87 :         if( bFooter )
     188             :         {
     189           7 :             aAny = rPropSet->getPropertyValue( sFooterShareContent );
     190           7 :             aAny >>= bFooterLeftShared;
     191             :         }
     192             : 
     193          87 :         if( xFooterText.is() )
     194             :         {
     195           7 :             if( !bFooter )
     196           0 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
     197           0 :                                           XML_DISPLAY, XML_FALSE );
     198           7 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
     199           7 :                                         XML_FOOTER, true, true );
     200           7 :             exportHeaderFooterContent( xFooterText, false );
     201             :         }
     202             : 
     203          87 :         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          87 :         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         174 :     }
     223         174 : }
     224             : 
     225             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11