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

Generated by: LCOV version 1.10