LCOV - code coverage report
Current view: top level - sc/source/filter/xml - XMLTableMasterPageExport.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 72 75 96.0 %
Date: 2014-11-03 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          48 : XMLTableMasterPageExport::XMLTableMasterPageExport( ScXMLExport& rExp ) :
      37          48 :         XMLTextMasterPageExport ( rExp )
      38             : {
      39          48 : }
      40             : 
      41          96 : XMLTableMasterPageExport::~XMLTableMasterPageExport()
      42             : {
      43          96 : }
      44             : 
      45        1464 : 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        1464 :     if( bAutoStyles )
      52        1224 :         GetExport().GetTextParagraphExport()
      53        2448 :                 ->collectTextAutoStyles( rText, bProgress, false );
      54             :     else
      55             :     {
      56         240 :         GetExport().GetTextParagraphExport()->exportTextDeclarations( rText );
      57         240 :         GetExport().GetTextParagraphExport()->exportText( rText, bProgress, false );
      58             :     }
      59        1464 : }
      60             : 
      61         408 : 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         408 :     if( xHeaderFooter.is() )
      66             :     {
      67         408 :         Reference < XText > xCenter(xHeaderFooter->getCenterText());
      68         816 :         Reference < XText > xLeft(xHeaderFooter->getLeftText());
      69         816 :         Reference < XText > xRight(xHeaderFooter->getRightText());
      70         408 :         if (xCenter.is() && xLeft.is() && xRight.is())
      71             :         {
      72         408 :             OUString sCenter (xCenter->getString());
      73         816 :             OUString sLeft (xLeft->getString());
      74         816 :             OUString sRight (xRight->getString());
      75             : 
      76         408 :             if( !bDisplay )
      77         216 :                 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
      78         216 :                                                 XML_DISPLAY, XML_FALSE );
      79         408 :             SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
      80         816 :                                       aName, true, true );
      81         408 :             if (!sCenter.isEmpty() && sLeft.isEmpty() && sRight.isEmpty())
      82         144 :                 exportHeaderFooterContent( xCenter, false, false );
      83             :             else
      84             :             {
      85         264 :                 if (!sLeft.isEmpty())
      86             :                 {
      87          48 :                     SvXMLElementExport aSubElem( GetExport(), XML_NAMESPACE_STYLE,
      88          48 :                                                 XML_REGION_LEFT, true, true );
      89          48 :                     exportHeaderFooterContent( xLeft, false, false );
      90             :                 }
      91         264 :                 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         264 :                 if (!sRight.isEmpty())
      98             :                 {
      99          48 :                     SvXMLElementExport aSubElem( GetExport(), XML_NAMESPACE_STYLE,
     100          48 :                                                 XML_REGION_RIGHT, true, true );
     101          48 :                     exportHeaderFooterContent( xRight, false, false );
     102             :                 }
     103         408 :             }
     104         408 :         }
     105             :     }
     106         408 : }
     107             : 
     108         204 : void XMLTableMasterPageExport::exportMasterPageContent(
     109             :                 const Reference < XPropertySet > & rPropSet,
     110             :                 bool bAutoStyles )
     111             : {
     112         204 :     Reference < sheet::XHeaderFooterContent > xHeader(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_RIGHTHDRCON ) ), uno::UNO_QUERY);
     113             : 
     114         408 :     Reference < sheet::XHeaderFooterContent > xHeaderLeft(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_LEFTHDRCONT ) ), uno::UNO_QUERY);
     115             : 
     116         408 :     Reference < sheet::XHeaderFooterContent > xFooter(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_RIGHTFTRCON ) ), uno::UNO_QUERY);
     117             : 
     118         408 :     Reference < sheet::XHeaderFooterContent > xFooterLeft(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_LEFTFTRCONT ) ), uno::UNO_QUERY);
     119             : 
     120         204 :     if( bAutoStyles )
     121             :     {
     122         102 :         if( xHeader.is() )
     123             :         {
     124         102 :             exportHeaderFooterContent( xHeader->getCenterText(), true, false );
     125         102 :             exportHeaderFooterContent( xHeader->getLeftText(), true, false );
     126         102 :             exportHeaderFooterContent( xHeader->getRightText(), true, false );
     127             :         }
     128         102 :         if( xHeaderLeft.is())
     129             :         {
     130         102 :             exportHeaderFooterContent( xHeaderLeft->getCenterText(), true, false );
     131         102 :             exportHeaderFooterContent( xHeaderLeft->getLeftText(), true, false );
     132         102 :             exportHeaderFooterContent( xHeaderLeft->getRightText(), true, false );
     133             :         }
     134         102 :         if( xFooter.is() )
     135             :         {
     136         102 :             exportHeaderFooterContent( xFooter->getCenterText(), true, false );
     137         102 :             exportHeaderFooterContent( xFooter->getLeftText(), true, false );
     138         102 :             exportHeaderFooterContent( xFooter->getRightText(), true, false );
     139             :         }
     140         102 :         if( xFooterLeft.is())
     141             :         {
     142         102 :             exportHeaderFooterContent( xFooterLeft->getCenterText(), true, false );
     143         102 :             exportHeaderFooterContent( xFooterLeft->getLeftText(), true, false );
     144         102 :             exportHeaderFooterContent( xFooterLeft->getRightText(), true, false );
     145             :         }
     146             :     }
     147             :     else
     148             :     {
     149         102 :         bool bHeader(::cppu::any2bool(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_HDRON ) )));
     150             : 
     151         102 :         exportHeaderFooter(xHeader, XML_HEADER, bHeader );
     152             : 
     153         102 :         bool bLeftHeader(!::cppu::any2bool(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_HDRSHARED ) )) && bHeader);
     154             : 
     155         102 :         exportHeaderFooter( xHeaderLeft, XML_HEADER_LEFT, bLeftHeader );
     156             : 
     157         102 :         bool bFooter(::cppu::any2bool(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_FTRON ) )));
     158             : 
     159         102 :         exportHeaderFooter( xFooter, XML_FOOTER, bFooter );
     160             : 
     161         102 :         bool bLeftFooter = (!::cppu::any2bool(rPropSet->getPropertyValue( OUString( SC_UNO_PAGE_FTRSHARED ) )) && bFooter);
     162             : 
     163         102 :         exportHeaderFooter( xFooterLeft, XML_FOOTER_LEFT, bLeftFooter );
     164         204 :     }
     165         204 : }
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10