LibreOffice Module xmloff (master)  1
XMLTextMasterPageExport.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/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 <xmloff/xmlexp.hxx>
26 #include <sal/log.hxx>
27 
28 
29 using namespace ::com::sun::star;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::text;
32 using namespace ::com::sun::star::beans;
33 using namespace ::xmloff::token;
34 
35 static const OUStringLiteral gsHeaderText( "HeaderText" );
36 static const OUStringLiteral gsHeaderOn( "HeaderIsOn" );
37 static const OUStringLiteral gsHeaderShareContent( "HeaderIsShared" );
38 static const OUStringLiteral gsHeaderTextFirst( "HeaderTextFirst" );
39 static const OUStringLiteral gsHeaderTextLeft( "HeaderTextLeft" );
40 static const OUStringLiteral gsFirstShareContent( "FirstIsShared" );
41 static const OUStringLiteral gsFooterText( "FooterText" );
42 static const OUStringLiteral gsFooterOn( "FooterIsOn" );
43 static const OUStringLiteral gsFooterShareContent( "FooterIsShared" );
44 static const OUStringLiteral gsFooterTextFirst( "FooterTextFirst" );
45 static const OUStringLiteral gsFooterTextLeft( "FooterTextLeft" );
46 
48  XMLPageExport( rExp )
49 {
50 }
51 
53 {
54 }
55 
56 
58  const Reference< XText >& rText,
59  bool bAutoStyles, bool bExportParagraph )
60 {
61  SAL_WARN_IF( !rText.is(), "xmloff", "There is the text" );
62 
63  // tracked changes (autostyles + changes list)
64  GetExport().GetTextParagraphExport()->recordTrackedChangesForXText(rText);
65  GetExport().GetTextParagraphExport()->exportTrackedChanges(rText,
66  bAutoStyles);
67  if( bAutoStyles )
69  ->collectTextAutoStyles( rText, true, bExportParagraph );
70  else
71  {
72  GetExport().GetTextParagraphExport()->exportTextDeclarations( rText );
73  GetExport().GetTextParagraphExport()->exportText( rText, true, bExportParagraph );
74  }
75 
76  // tracked changes (end of XText)
77  GetExport().GetTextParagraphExport()->recordTrackedChangesNoXText();
78 }
79 
81  const Reference < XPropertySet > & rPropSet,
82  bool bAutoStyles )
83 {
84  Any aAny;
85 
86  Reference < XText > xHeaderText;
87  aAny = rPropSet->getPropertyValue( gsHeaderText );
88  aAny >>= xHeaderText;
89 
90  Reference < XText > xHeaderTextFirst;
91  aAny = rPropSet->getPropertyValue( gsHeaderTextFirst );
92  aAny >>= xHeaderTextFirst;
93 
94  Reference < XText > xHeaderTextLeft;
95  aAny = rPropSet->getPropertyValue( gsHeaderTextLeft );
96  aAny >>= xHeaderTextLeft;
97 
98  Reference < XText > xFooterText;
99  aAny = rPropSet->getPropertyValue( gsFooterText );
100  aAny >>= xFooterText;
101 
102  Reference < XText > xFooterTextFirst;
103  aAny = rPropSet->getPropertyValue( gsFooterTextFirst );
104  aAny >>= xFooterTextFirst;
105 
106  Reference < XText > xFooterTextLeft;
107  aAny = rPropSet->getPropertyValue( gsFooterTextLeft );
108  aAny >>= xFooterTextLeft;
109 
110  if( bAutoStyles )
111  {
112  if( xHeaderText.is() )
113  exportHeaderFooterContent( xHeaderText, true );
114  if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
115  exportHeaderFooterContent( xHeaderTextFirst, true );
116  if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
117  exportHeaderFooterContent( xHeaderTextLeft, true );
118  if( xFooterText.is() )
119  exportHeaderFooterContent( xFooterText, true );
120  if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
121  exportHeaderFooterContent( xFooterTextFirst, true );
122  if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
123  exportHeaderFooterContent( xFooterTextLeft, true );
124  }
125  else
126  {
127  aAny = rPropSet->getPropertyValue( gsHeaderOn );
128  bool bHeader = false;
129  aAny >>= bHeader;
130 
131  bool bHeaderFirstShared = false;
132  if( bHeader )
133  {
134  aAny = rPropSet->getPropertyValue( gsFirstShareContent );
135  aAny >>= bHeaderFirstShared;
136  }
137 
138  bool bHeaderLeftShared = false;
139  if( bHeader )
140  {
141  aAny = rPropSet->getPropertyValue( gsHeaderShareContent );
142  aAny >>= bHeaderLeftShared;
143  }
144 
145  if( xHeaderText.is() )
146  {
147  if( !bHeader )
151  XML_HEADER, true, true );
152  exportHeaderFooterContent( xHeaderText, false );
153  }
154 
155  if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
156  {
157  if (bHeaderLeftShared)
161  XML_HEADER_LEFT, true, true );
162  exportHeaderFooterContent( xHeaderTextLeft, false );
163  }
164 
165  if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
166  {
167  if (bHeaderFirstShared)
171  XML_HEADER_FIRST, true, true );
172  exportHeaderFooterContent( xHeaderTextFirst, false );
173  }
174 
175  aAny = rPropSet->getPropertyValue( gsFooterOn );
176  bool bFooter = false;
177  aAny >>= bFooter;
178 
179  bool bFooterFirstShared = false;
180  if( bFooter )
181  {
182  aAny = rPropSet->getPropertyValue( gsFirstShareContent );
183  aAny >>= bFooterFirstShared;
184  }
185 
186  bool bFooterLeftShared = false;
187  if( bFooter )
188  {
189  aAny = rPropSet->getPropertyValue( gsFooterShareContent );
190  aAny >>= bFooterLeftShared;
191  }
192 
193  if( xFooterText.is() )
194  {
195  if( !bFooter )
199  XML_FOOTER, true, true );
200  exportHeaderFooterContent( xFooterText, false );
201  }
202 
203  if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
204  {
205  if (bFooterLeftShared)
209  XML_FOOTER_LEFT, true, true );
210  exportHeaderFooterContent( xFooterTextLeft, false );
211  }
212 
213  if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
214  {
215  if (bFooterFirstShared)
219  XML_FOOTER_FIRST, true, true );
220  exportHeaderFooterContent( xFooterTextFirst, false );
221  }
222  }
223 }
224 
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
Definition: xmlnmspe.hxx:80
constexpr sal_uInt16 XML_NAMESPACE_STYLE
Definition: xmlnmspe.hxx:30
static const OUStringLiteral gsFirstShareContent("FirstIsShared")
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
Definition: xmlexp.hxx:561
static const OUStringLiteral gsHeaderShareContent("HeaderIsShared")
static const OUStringLiteral gsHeaderTextLeft("HeaderTextLeft")
XMLTextMasterPageExport(SvXMLExport &rExp)
static const OUStringLiteral gsHeaderTextFirst("HeaderTextFirst")
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
Definition: xmlexp.cxx:926
static const OUStringLiteral gsFooterTextFirst("FooterTextFirst")
static const OUStringLiteral gsHeaderText("HeaderText")
virtual void exportHeaderFooterContent(const css::uno::Reference< css::text::XText > &rText, bool bAutoStyles, bool bExportParagraph=true)
static const OUStringLiteral gsFooterText("FooterText")
SvXMLExport & GetExport()
virtual ~XMLTextMasterPageExport() override
static const OUStringLiteral gsFooterTextLeft("FooterTextLeft")
#define SAL_WARN_IF(condition, area, stream)
virtual void exportMasterPageContent(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, bool bAutoStyles) override
static const OUStringLiteral gsFooterOn("FooterIsOn")
Handling of tokens in XML:
static const OUStringLiteral gsHeaderOn("HeaderIsOn")
static const OUStringLiteral gsFooterShareContent("FooterIsShared")