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 > xHeaderFirst(rPropSet->getPropertyValue( SC_UNO_PAGE_FIRSTHDRCONT ), uno::UNO_QUERY);
120 
121  Reference < sheet::XHeaderFooterContent > xFooter(rPropSet->getPropertyValue( SC_UNO_PAGE_RIGHTFTRCON ), uno::UNO_QUERY);
122 
123  Reference < sheet::XHeaderFooterContent > xFooterLeft(rPropSet->getPropertyValue( SC_UNO_PAGE_LEFTFTRCONT ), uno::UNO_QUERY);
124 
125  Reference < sheet::XHeaderFooterContent > xFooterFirst(rPropSet->getPropertyValue( SC_UNO_PAGE_FIRSTFTRCONT ), uno::UNO_QUERY);
126 
127  if( bAutoStyles )
128  {
129  if( xHeader.is() )
130  {
131  exportHeaderFooterContent( xHeader->getCenterText(), true, false );
132  exportHeaderFooterContent( xHeader->getLeftText(), true, false );
133  exportHeaderFooterContent( xHeader->getRightText(), true, false );
134  }
135  if( xHeaderLeft.is())
136  {
137  exportHeaderFooterContent( xHeaderLeft->getCenterText(), true, false );
138  exportHeaderFooterContent( xHeaderLeft->getLeftText(), true, false );
139  exportHeaderFooterContent( xHeaderLeft->getRightText(), true, false );
140  }
141  if( xHeaderFirst.is())
142  {
143  exportHeaderFooterContent( xHeaderFirst->getCenterText(), true, false );
144  exportHeaderFooterContent( xHeaderFirst->getLeftText(), true, false );
145  exportHeaderFooterContent( xHeaderFirst->getRightText(), true, false );
146  }
147  if( xFooter.is() )
148  {
149  exportHeaderFooterContent( xFooter->getCenterText(), true, false );
150  exportHeaderFooterContent( xFooter->getLeftText(), true, false );
151  exportHeaderFooterContent( xFooter->getRightText(), true, false );
152  }
153  if( xFooterLeft.is())
154  {
155  exportHeaderFooterContent( xFooterLeft->getCenterText(), true, false );
156  exportHeaderFooterContent( xFooterLeft->getLeftText(), true, false );
157  exportHeaderFooterContent( xFooterLeft->getRightText(), true, false );
158  }
159  if( xFooterFirst.is())
160  {
161  exportHeaderFooterContent( xFooterFirst->getCenterText(), true, false );
162  exportHeaderFooterContent( xFooterFirst->getLeftText(), true, false );
163  exportHeaderFooterContent( xFooterFirst->getRightText(), true, false );
164  }
165  }
166  else
167  {
168  bool bHeader(::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_HDRON )));
169 
170  exportHeaderFooter(xHeader, XML_HEADER, bHeader );
171 
172  bool bLeftHeader(!::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_HDRSHARED )) && bHeader);
173 
174  exportHeaderFooter( xHeaderLeft, XML_HEADER_LEFT, bLeftHeader );
175 
176  bool bFirstHeader(!::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_FIRSTHDRSHARED )) && bHeader);
177 
178  exportHeaderFooter( xHeaderFirst, XML_HEADER_FIRST, bFirstHeader );
179 
180  bool bFooter(::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_FTRON )));
181 
182  exportHeaderFooter( xFooter, XML_FOOTER, bFooter );
183 
184  bool bLeftFooter = (!::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_FTRSHARED )) && bFooter);
185 
186  exportHeaderFooter( xFooterLeft, XML_FOOTER_LEFT, bLeftFooter );
187 
188  bool bFirstFooter = (!::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_FIRSTFTRSHARED )) && bFooter);
189 
190  exportHeaderFooter( xFooterFirst, XML_FOOTER_FIRST, bFirstFooter );
191  }
192 }
193 
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XML_FOOTER
#define SC_UNO_PAGE_FIRSTFTRCONT
Definition: unonames.hxx:451
XML_REGION_LEFT
#define SC_UNO_PAGE_RIGHTFTRCON
Definition: unonames.hxx:449
XML_FOOTER_FIRST
void exportHeaderFooter(const css::uno::Reference< css::sheet::XHeaderFooterContent > &xHeaderFooter, const xmloff::token::XMLTokenEnum aName, const bool bDisplay)
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
XML_FOOTER_LEFT
#define SC_UNO_PAGE_FIRSTHDRSHARED
Definition: unonames.hxx:444
#define SC_UNO_PAGE_FIRSTHDRCONT
Definition: unonames.hxx:450
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
#define SC_UNO_PAGE_LEFTHDRCONT
Definition: unonames.hxx:446
#define SC_UNO_PAGE_HDRON
Definition: unonames.hxx:474
virtual void exportMasterPageContent(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, bool bAutoStyles) override
XML_HEADER_FIRST
XML_REGION_RIGHT
XML_REGION_CENTER
virtual void exportHeaderFooterContent(const css::uno::Reference< css::text::XText > &rText, bool bAutoStyles, bool bProgress=true) override
XML_DISPLAY
SvXMLExport & GetExport()
XML_HEADER
#define SC_UNO_PAGE_LEFTFTRCONT
Definition: unonames.hxx:447
#define SC_UNO_PAGE_FIRSTFTRSHARED
Definition: unonames.hxx:445
XML_HEADER_LEFT
#define SC_UNO_PAGE_FTRON
Definition: unonames.hxx:497
XML_FALSE
#define SC_UNO_PAGE_HDRSHARED
Definition: unonames.hxx:476
XMLTokenEnum
XMLTableMasterPageExport(ScXMLExport &rExp)
#define SC_UNO_PAGE_FTRSHARED
Definition: unonames.hxx:499
virtual ~XMLTableMasterPageExport() override
#define SC_UNO_PAGE_RIGHTHDRCON
Definition: unonames.hxx:448
constexpr sal_uInt16 XML_NAMESPACE_STYLE
bool any2bool(const css::uno::Any &rAny)