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

Generated by: LCOV version 1.10