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

Generated by: LCOV version 1.10