LCOV - code coverage report
Current view: top level - sc/source/filter/xml - XMLTableMasterPageExport.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 72 75 96.0 %
Date: 2014-04-11 Functions: 6 6 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 <xmloff/xmlnmspe.hxx>
      21             : #include <xmloff/xmltoken.hxx>
      22             : #include <com/sun/star/text/XText.hpp>
      23             : #include <com/sun/star/beans/XPropertySet.hpp>
      24             : #include "XMLTableMasterPageExport.hxx"
      25             : #include <comphelper/extract.hxx>
      26             : 
      27             : #include "unonames.hxx"
      28             : #include "xmlexprt.hxx"
      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          18 : XMLTableMasterPageExport::XMLTableMasterPageExport( ScXMLExport& rExp ) :
      37          18 :         XMLTextMasterPageExport ( rExp )
      38             : {
      39          18 : }
      40             : 
      41          36 : XMLTableMasterPageExport::~XMLTableMasterPageExport()
      42             : {
      43          36 : }
      44             : 
      45         534 : void XMLTableMasterPageExport::exportHeaderFooterContent(
      46             :             const Reference< XText >& rText,
      47             :             bool bAutoStyles, bool bProgress )
      48             : {
      49             :     OSL_ENSURE( rText.is(), "There is the text" );
      50             : 
      51         534 :     if( bAutoStyles )
      52         444 :         GetExport().GetTextParagraphExport()
      53         888 :                 ->collectTextAutoStyles( rText, bProgress, false );
      54             :     else
      55             :     {
      56          90 :         GetExport().GetTextParagraphExport()->exportTextDeclarations( rText );
      57          90 :         GetExport().GetTextParagraphExport()->exportText( rText, bProgress, false );
      58             :     }
      59         534 : }
      60             : 
      61         148 : void XMLTableMasterPageExport::exportHeaderFooter(const com::sun::star::uno::Reference < com::sun::star::sheet::XHeaderFooterContent >& xHeaderFooter,
      62             :                                                     const XMLTokenEnum aName,
      63             :                                                     const bool bDisplay)
      64             : {
      65         148 :     if( xHeaderFooter.is() )
      66             :     {
      67         148 :         Reference < XText > xCenter(xHeaderFooter->getCenterText());
      68         296 :         Reference < XText > xLeft(xHeaderFooter->getLeftText());
      69         296 :         Reference < XText > xRight(xHeaderFooter->getRightText());
      70         148 :         if (xCenter.is() && xLeft.is() && xRight.is())
      71             :         {
      72         148 :             OUString sCenter (xCenter->getString());
      73         296 :             OUString sLeft (xLeft->getString());
      74         296 :             OUString sRight (xRight->getString());
      75             : 
      76         148 :             if( !bDisplay )
      77          76 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
      78          76 :                                                 XML_DISPLAY, XML_FALSE );
      79         148 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
      80         296 :                                       aName, true, true );
      81         148 :             if (!sCenter.isEmpty() && sLeft.isEmpty() && sRight.isEmpty())
      82          54 :                 exportHeaderFooterContent( xCenter, false, false );
      83             :             else
      84             :             {
      85          94 :                 if (!sLeft.isEmpty())
      86             :                 {
      87          18 :                     SvXMLElementExport aSubElem( GetExport(), XML_NAMESPACE_STYLE,
      88          18 :                                                 XML_REGION_LEFT, true, true );
      89          18 :                     exportHeaderFooterContent( xLeft, false, false );
      90             :                 }
      91          94 :                 if (!sCenter.isEmpty())
      92             :                 {
      93           0 :                     SvXMLElementExport aSubElem( GetExport(), XML_NAMESPACE_STYLE,
      94           0 :                                                 XML_REGION_CENTER, true, true );
      95           0 :                     exportHeaderFooterContent( xCenter, false, false );
      96             :                 }
      97          94 :                 if (!sRight.isEmpty())
      98             :                 {
      99          18 :                     SvXMLElementExport aSubElem( GetExport(), XML_NAMESPACE_STYLE,
     100          18 :                                                 XML_REGION_RIGHT, true, true );
     101          18 :                     exportHeaderFooterContent( xRight, false, false );
     102             :                 }
     103         148 :             }
     104         148 :         }
     105             :     }
     106         148 : }
     107             : 
     108          74 : void XMLTableMasterPageExport::exportMasterPageContent(
     109             :                 const Reference < XPropertySet > & rPropSet,
     110             :                 bool bAutoStyles )
     111             : {
     112          74 :     Reference < sheet::XHeaderFooterContent > xHeader(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_RIGHTHDRCON ) ), uno::UNO_QUERY);
     113             : 
     114         148 :     Reference < sheet::XHeaderFooterContent > xHeaderLeft(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_LEFTHDRCONT ) ), uno::UNO_QUERY);
     115             : 
     116         148 :     Reference < sheet::XHeaderFooterContent > xFooter(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_RIGHTFTRCON ) ), uno::UNO_QUERY);
     117             : 
     118         148 :     Reference < sheet::XHeaderFooterContent > xFooterLeft(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_LEFTFTRCONT ) ), uno::UNO_QUERY);
     119             : 
     120          74 :     if( bAutoStyles )
     121             :     {
     122          37 :         if( xHeader.is() )
     123             :         {
     124          37 :             exportHeaderFooterContent( xHeader->getCenterText(), true, false );
     125          37 :             exportHeaderFooterContent( xHeader->getLeftText(), true, false );
     126          37 :             exportHeaderFooterContent( xHeader->getRightText(), true, false );
     127             :         }
     128          37 :         if( xHeaderLeft.is())
     129             :         {
     130          37 :             exportHeaderFooterContent( xHeaderLeft->getCenterText(), true, false );
     131          37 :             exportHeaderFooterContent( xHeaderLeft->getLeftText(), true, false );
     132          37 :             exportHeaderFooterContent( xHeaderLeft->getRightText(), true, false );
     133             :         }
     134          37 :         if( xFooter.is() )
     135             :         {
     136          37 :             exportHeaderFooterContent( xFooter->getCenterText(), true, false );
     137          37 :             exportHeaderFooterContent( xFooter->getLeftText(), true, false );
     138          37 :             exportHeaderFooterContent( xFooter->getRightText(), true, false );
     139             :         }
     140          37 :         if( xFooterLeft.is())
     141             :         {
     142          37 :             exportHeaderFooterContent( xFooterLeft->getCenterText(), true, false );
     143          37 :             exportHeaderFooterContent( xFooterLeft->getLeftText(), true, false );
     144          37 :             exportHeaderFooterContent( xFooterLeft->getRightText(), true, false );
     145             :         }
     146             :     }
     147             :     else
     148             :     {
     149          37 :         sal_Bool bHeader(::cppu::any2bool(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_HDRON ) )));
     150             : 
     151          37 :         exportHeaderFooter(xHeader, XML_HEADER, bHeader );
     152             : 
     153          37 :         sal_Bool bLeftHeader(!::cppu::any2bool(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_HDRSHARED ) )) && bHeader);
     154             : 
     155          37 :         exportHeaderFooter( xHeaderLeft, XML_HEADER_LEFT, bLeftHeader );
     156             : 
     157          37 :         sal_Bool bFooter(::cppu::any2bool(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_FTRON ) )));
     158             : 
     159          37 :         exportHeaderFooter( xFooter, XML_FOOTER, bFooter );
     160             : 
     161          37 :         sal_Bool bLeftFooter = (!::cppu::any2bool(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_FTRSHARED ) )) && bFooter);
     162             : 
     163          37 :         exportHeaderFooter( xFooterLeft, XML_FOOTER_LEFT, bLeftFooter );
     164          74 :     }
     165          74 : }
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10