LibreOffice Module sc (master)  1
XMLTableMasterPageExport.cxx
Go to the documentation of this file.
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/xmlnamespace.hxx>
21 #include <xmloff/xmltoken.hxx>
22 #include <com/sun/star/text/XText.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/sheet/XHeaderFooterContent.hpp>
26 #include <comphelper/extract.hxx>
27 #include <rtl/ref.hxx>
28 #include <osl/diagnose.h>
29 
30 #include <unonames.hxx>
31 #include "xmlexprt.hxx"
32 
33 using namespace ::com::sun::star;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::text;
36 using namespace ::com::sun::star::beans;
37 using namespace xmloff::token;
38 
41 {
42 }
43 
45 {
46 }
47 
49  const Reference< XText >& rText,
50  bool bAutoStyles, bool bProgress )
51 {
52  OSL_ENSURE( rText.is(), "There is the text" );
53 
54  if( bAutoStyles )
56  ->collectTextAutoStyles( rText, bProgress, false );
57  else
58  {
59  GetExport().GetTextParagraphExport()->exportTextDeclarations( rText );
60  GetExport().GetTextParagraphExport()->exportText( rText, bProgress, false );
61  }
62 }
63 
64 void XMLTableMasterPageExport::exportHeaderFooter(const css::uno::Reference < css::sheet::XHeaderFooterContent >& xHeaderFooter,
65  const XMLTokenEnum aName,
66  const bool bDisplay)
67 {
68  if( !xHeaderFooter.is() )
69  return;
70 
71  Reference < XText > xCenter(xHeaderFooter->getCenterText());
72  Reference < XText > xLeft(xHeaderFooter->getLeftText());
73  Reference < XText > xRight(xHeaderFooter->getRightText());
74  if (!(xCenter.is() && xLeft.is() && xRight.is()))
75  return;
76 
77  OUString sCenter (xCenter->getString());
78  OUString sLeft (xLeft->getString());
79  OUString sRight (xRight->getString());
80 
81  if( !bDisplay )
85  aName, true, true );
86  if (!sCenter.isEmpty() && sLeft.isEmpty() && sRight.isEmpty())
87  exportHeaderFooterContent( xCenter, false, false );
88  else
89  {
90  if (!sLeft.isEmpty())
91  {
93  XML_REGION_LEFT, true, true );
94  exportHeaderFooterContent( xLeft, false, false );
95  }
96  if (!sCenter.isEmpty())
97  {
99  XML_REGION_CENTER, true, true );
100  exportHeaderFooterContent( xCenter, false, false );
101  }
102  if (!sRight.isEmpty())
103  {
105  XML_REGION_RIGHT, true, true );
106  exportHeaderFooterContent( xRight, false, false );
107  }
108  }
109 }
110 
112  const Reference < XPropertySet > & rPropSet,
113  bool bAutoStyles )
114 {
115  Reference < sheet::XHeaderFooterContent > xHeader(rPropSet->getPropertyValue( SC_UNO_PAGE_RIGHTHDRCON ), uno::UNO_QUERY);
116 
117  Reference < sheet::XHeaderFooterContent > xHeaderLeft(rPropSet->getPropertyValue( SC_UNO_PAGE_LEFTHDRCONT ), uno::UNO_QUERY);
118 
119  Reference < sheet::XHeaderFooterContent > xFooter(rPropSet->getPropertyValue( SC_UNO_PAGE_RIGHTFTRCON ), uno::UNO_QUERY);
120 
121  Reference < sheet::XHeaderFooterContent > xFooterLeft(rPropSet->getPropertyValue( SC_UNO_PAGE_LEFTFTRCONT ), uno::UNO_QUERY);
122 
123  if( bAutoStyles )
124  {
125  if( xHeader.is() )
126  {
127  exportHeaderFooterContent( xHeader->getCenterText(), true, false );
128  exportHeaderFooterContent( xHeader->getLeftText(), true, false );
129  exportHeaderFooterContent( xHeader->getRightText(), true, false );
130  }
131  if( xHeaderLeft.is())
132  {
133  exportHeaderFooterContent( xHeaderLeft->getCenterText(), true, false );
134  exportHeaderFooterContent( xHeaderLeft->getLeftText(), true, false );
135  exportHeaderFooterContent( xHeaderLeft->getRightText(), true, false );
136  }
137  if( xFooter.is() )
138  {
139  exportHeaderFooterContent( xFooter->getCenterText(), true, false );
140  exportHeaderFooterContent( xFooter->getLeftText(), true, false );
141  exportHeaderFooterContent( xFooter->getRightText(), true, false );
142  }
143  if( xFooterLeft.is())
144  {
145  exportHeaderFooterContent( xFooterLeft->getCenterText(), true, false );
146  exportHeaderFooterContent( xFooterLeft->getLeftText(), true, false );
147  exportHeaderFooterContent( xFooterLeft->getRightText(), true, false );
148  }
149  }
150  else
151  {
152  bool bHeader(::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_HDRON )));
153 
154  exportHeaderFooter(xHeader, XML_HEADER, bHeader );
155 
156  bool bLeftHeader(!::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_HDRSHARED )) && bHeader);
157 
158  exportHeaderFooter( xHeaderLeft, XML_HEADER_LEFT, bLeftHeader );
159 
160  bool bFooter(::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_FTRON )));
161 
162  exportHeaderFooter( xFooter, XML_FOOTER, bFooter );
163 
164  bool bLeftFooter = (!::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_FTRSHARED )) && bFooter);
165 
166  exportHeaderFooter( xFooterLeft, XML_FOOTER_LEFT, bLeftFooter );
167  }
168 }
169 
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XML_DISPLAY
#define SC_UNO_PAGE_RIGHTFTRCON
Definition: unonames.hxx:448
void exportHeaderFooter(const css::uno::Reference< css::sheet::XHeaderFooterContent > &xHeaderFooter, const xmloff::token::XMLTokenEnum aName, const bool bDisplay)
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
XML_HEADER_LEFT
XML_FOOTER_LEFT
XML_REGION_RIGHT
XML_HEADER
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
#define SC_UNO_PAGE_LEFTHDRCONT
Definition: unonames.hxx:445
XML_FALSE
XMLTokenEnum
XML_REGION_LEFT
#define SC_UNO_PAGE_HDRON
Definition: unonames.hxx:471
XML_REGION_CENTER
virtual void exportMasterPageContent(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, bool bAutoStyles) override
virtual void exportHeaderFooterContent(const css::uno::Reference< css::text::XText > &rText, bool bAutoStyles, bool bProgress=true) override
SvXMLExport & GetExport()
XML_FOOTER
#define SC_UNO_PAGE_LEFTFTRCONT
Definition: unonames.hxx:446
#define SC_UNO_PAGE_FTRON
Definition: unonames.hxx:494
#define SC_UNO_PAGE_HDRSHARED
Definition: unonames.hxx:473
XMLTableMasterPageExport(ScXMLExport &rExp)
#define SC_UNO_PAGE_FTRSHARED
Definition: unonames.hxx:496
virtual ~XMLTableMasterPageExport() override
#define SC_UNO_PAGE_RIGHTHDRCON
Definition: unonames.hxx:447
constexpr sal_uInt16 XML_NAMESPACE_STYLE
bool any2bool(const css::uno::Any &rAny)