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
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>
27#include <rtl/ref.hxx>
28#include <osl/diagnose.h>
29
30#include <unonames.hxx>
31#include "xmlexprt.hxx"
32
33using namespace ::com::sun::star;
34using namespace ::com::sun::star::uno;
35using namespace ::com::sun::star::text;
36using namespace ::com::sun::star::beans;
37using 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
64void 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 sal_uInt16 nNameSpace = XML_NAMESPACE_STYLE;
73 {
74 // Since ODF 1.3 OFFICE-3789 or 1.2-extended.
75 auto const nVersion(GetExport().getSaneDefaultVersion());
77 return;
79 nNameSpace = XML_NAMESPACE_LO_EXT;
80 }
81
82 Reference < XText > xCenter(xHeaderFooter->getCenterText());
83 Reference < XText > xLeft(xHeaderFooter->getLeftText());
84 Reference < XText > xRight(xHeaderFooter->getRightText());
85 if (!(xCenter.is() && xLeft.is() && xRight.is()))
86 return;
87
88 OUString sCenter (xCenter->getString());
89 OUString sLeft (xLeft->getString());
90 OUString sRight (xRight->getString());
91
92 if( !bDisplay )
95 SvXMLElementExport aElem( GetExport(), nNameSpace,
96 aName, true, true );
97 if (!sCenter.isEmpty() && sLeft.isEmpty() && sRight.isEmpty())
98 exportHeaderFooterContent( xCenter, false, false );
99 else
100 {
101 if (!sLeft.isEmpty())
102 {
104 XML_REGION_LEFT, true, true );
105 exportHeaderFooterContent( xLeft, false, false );
106 }
107 if (!sCenter.isEmpty())
108 {
110 XML_REGION_CENTER, true, true );
111 exportHeaderFooterContent( xCenter, false, false );
112 }
113 if (!sRight.isEmpty())
114 {
116 XML_REGION_RIGHT, true, true );
117 exportHeaderFooterContent( xRight, false, false );
118 }
119 }
120}
121
123 const Reference < XPropertySet > & rPropSet,
124 bool bAutoStyles )
125{
126 Reference < sheet::XHeaderFooterContent > xHeader(rPropSet->getPropertyValue( SC_UNO_PAGE_RIGHTHDRCON ), uno::UNO_QUERY);
127
128 Reference < sheet::XHeaderFooterContent > xHeaderLeft(rPropSet->getPropertyValue( SC_UNO_PAGE_LEFTHDRCONT ), uno::UNO_QUERY);
129
130 Reference < sheet::XHeaderFooterContent > xHeaderFirst(rPropSet->getPropertyValue( SC_UNO_PAGE_FIRSTHDRCONT ), uno::UNO_QUERY);
131
132 Reference < sheet::XHeaderFooterContent > xFooter(rPropSet->getPropertyValue( SC_UNO_PAGE_RIGHTFTRCON ), uno::UNO_QUERY);
133
134 Reference < sheet::XHeaderFooterContent > xFooterLeft(rPropSet->getPropertyValue( SC_UNO_PAGE_LEFTFTRCONT ), uno::UNO_QUERY);
135
136 Reference < sheet::XHeaderFooterContent > xFooterFirst(rPropSet->getPropertyValue( SC_UNO_PAGE_FIRSTFTRCONT ), uno::UNO_QUERY);
137
138 if( bAutoStyles )
139 {
140 if( xHeader.is() )
141 {
142 exportHeaderFooterContent( xHeader->getCenterText(), true, false );
143 exportHeaderFooterContent( xHeader->getLeftText(), true, false );
144 exportHeaderFooterContent( xHeader->getRightText(), true, false );
145 }
146 if( xHeaderLeft.is())
147 {
148 exportHeaderFooterContent( xHeaderLeft->getCenterText(), true, false );
149 exportHeaderFooterContent( xHeaderLeft->getLeftText(), true, false );
150 exportHeaderFooterContent( xHeaderLeft->getRightText(), true, false );
151 }
152 if( xHeaderFirst.is())
153 {
154 exportHeaderFooterContent( xHeaderFirst->getCenterText(), true, false );
155 exportHeaderFooterContent( xHeaderFirst->getLeftText(), true, false );
156 exportHeaderFooterContent( xHeaderFirst->getRightText(), true, false );
157 }
158 if( xFooter.is() )
159 {
160 exportHeaderFooterContent( xFooter->getCenterText(), true, false );
161 exportHeaderFooterContent( xFooter->getLeftText(), true, false );
162 exportHeaderFooterContent( xFooter->getRightText(), true, false );
163 }
164 if( xFooterLeft.is())
165 {
166 exportHeaderFooterContent( xFooterLeft->getCenterText(), true, false );
167 exportHeaderFooterContent( xFooterLeft->getLeftText(), true, false );
168 exportHeaderFooterContent( xFooterLeft->getRightText(), true, false );
169 }
170 if( xFooterFirst.is())
171 {
172 exportHeaderFooterContent( xFooterFirst->getCenterText(), true, false );
173 exportHeaderFooterContent( xFooterFirst->getLeftText(), true, false );
174 exportHeaderFooterContent( xFooterFirst->getRightText(), true, false );
175 }
176 }
177 else
178 {
179 bool bHeader(::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_HDRON )));
180
181 exportHeaderFooter(xHeader, XML_HEADER, bHeader );
182
183 bool bLeftHeader(!::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_HDRSHARED )) && bHeader);
184
185 exportHeaderFooter( xHeaderLeft, XML_HEADER_LEFT, bLeftHeader );
186
187 bool bFirstHeader(!::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_FIRSTHDRSHARED )) && bHeader);
188
189 exportHeaderFooter( xHeaderFirst, XML_HEADER_FIRST, bFirstHeader );
190
191 bool bFooter(::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_FTRON )));
192
193 exportHeaderFooter( xFooter, XML_FOOTER, bFooter );
194
195 bool bLeftFooter = (!::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_FTRSHARED )) && bFooter);
196
197 exportHeaderFooter( xFooterLeft, XML_FOOTER_LEFT, bLeftFooter );
198
199 bool bFirstFooter = (!::cppu::any2bool(rPropSet->getPropertyValue( SC_UNO_PAGE_FIRSTFTRSHARED )) && bFooter);
200
201 exportHeaderFooter( xFooterFirst, XML_FOOTER_FIRST, bFirstFooter );
202 }
203}
204
205/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
SvXMLExport & GetExport()
virtual void exportHeaderFooterContent(const css::uno::Reference< css::text::XText > &rText, bool bAutoStyles, bool bProgress=true) override
void exportHeaderFooter(const css::uno::Reference< css::sheet::XHeaderFooterContent > &xHeaderFooter, const xmloff::token::XMLTokenEnum aName, const bool bDisplay)
virtual ~XMLTableMasterPageExport() override
XMLTableMasterPageExport(ScXMLExport &rExp)
virtual void exportMasterPageContent(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, bool bAutoStyles) override
sal_Int16 nVersion
OUString aName
XMLTokenEnum
XML_FOOTER_LEFT
XML_REGION_RIGHT
XML_HEADER_LEFT
XML_DISPLAY
XML_REGION_LEFT
XML_REGION_CENTER
XML_FALSE
XML_FOOTER_FIRST
XML_FOOTER
XML_HEADER
XML_HEADER_FIRST
constexpr OUStringLiteral SC_UNO_PAGE_FTRSHARED
Definition: unonames.hxx:509
constexpr OUStringLiteral SC_UNO_PAGE_FIRSTFTRSHARED
Definition: unonames.hxx:455
constexpr OUStringLiteral SC_UNO_PAGE_HDRSHARED
Definition: unonames.hxx:486
constexpr OUStringLiteral SC_UNO_PAGE_FTRON
Definition: unonames.hxx:507
constexpr OUStringLiteral SC_UNO_PAGE_FIRSTFTRCONT
Definition: unonames.hxx:461
constexpr OUStringLiteral SC_UNO_PAGE_LEFTHDRCONT
Definition: unonames.hxx:456
constexpr OUStringLiteral SC_UNO_PAGE_LEFTFTRCONT
Definition: unonames.hxx:457
constexpr OUStringLiteral SC_UNO_PAGE_FIRSTHDRCONT
Definition: unonames.hxx:460
constexpr OUStringLiteral SC_UNO_PAGE_FIRSTHDRSHARED
Definition: unonames.hxx:454
constexpr OUStringLiteral SC_UNO_PAGE_RIGHTFTRCON
Definition: unonames.hxx:459
constexpr OUStringLiteral SC_UNO_PAGE_RIGHTHDRCON
Definition: unonames.hxx:458
constexpr OUStringLiteral SC_UNO_PAGE_HDRON
Definition: unonames.hxx:484
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_STYLE