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 <tools/debug.hxx>
21 : #include "xmloff/xmlnmspe.hxx"
22 : #include <xmloff/xmltoken.hxx>
23 : #include <com/sun/star/text/XText.hpp>
24 : #include <com/sun/star/beans/XPropertySet.hpp>
25 : #include <xmloff/xmlexp.hxx>
26 : #include <xmloff/XMLTextMasterPageExport.hxx>
27 :
28 :
29 :
30 : using namespace ::com::sun::star;
31 : using namespace ::com::sun::star::uno;
32 : using namespace ::com::sun::star::text;
33 : using namespace ::com::sun::star::beans;
34 : using namespace ::xmloff::token;
35 :
36 24 : XMLTextMasterPageExport::XMLTextMasterPageExport( SvXMLExport& rExp ) :
37 : XMLPageExport( rExp ),
38 : sHeaderText( "HeaderText" ),
39 : sHeaderOn( "HeaderIsOn" ),
40 : sHeaderShareContent( "HeaderIsShared" ),
41 : sHeaderTextFirst( "HeaderTextFirst" ),
42 : sHeaderTextLeft( "HeaderTextLeft" ),
43 : sFirstShareContent( "FirstIsShared" ),
44 : sFooterText( "FooterText" ),
45 : sFooterOn( "FooterIsOn" ),
46 : sFooterShareContent( "FooterIsShared" ),
47 : sFooterTextFirst( "FooterTextFirst" ),
48 24 : sFooterTextLeft( "FooterTextLeft" )
49 : {
50 24 : }
51 :
52 40 : XMLTextMasterPageExport::~XMLTextMasterPageExport()
53 : {
54 40 : }
55 :
56 :
57 24 : void XMLTextMasterPageExport::exportHeaderFooterContent(
58 : const Reference< XText >& rText,
59 : sal_Bool bAutoStyles, sal_Bool bExportParagraph )
60 : {
61 : DBG_ASSERT( rText.is(), "There is the text" );
62 :
63 : // tracked changes (autostyles + changes list)
64 24 : GetExport().GetTextParagraphExport()->recordTrackedChangesForXText(rText);
65 24 : GetExport().GetTextParagraphExport()->exportTrackedChanges(rText,
66 48 : bAutoStyles);
67 24 : if( bAutoStyles )
68 12 : GetExport().GetTextParagraphExport()
69 24 : ->collectTextAutoStyles( rText, sal_True, bExportParagraph );
70 : else
71 : {
72 12 : GetExport().GetTextParagraphExport()->exportTextDeclarations( rText );
73 12 : GetExport().GetTextParagraphExport()->exportText( rText, sal_True, bExportParagraph );
74 : }
75 :
76 : // tracked changes (end of XText)
77 24 : GetExport().GetTextParagraphExport()->recordTrackedChangesNoXText();
78 24 : }
79 :
80 38 : void XMLTextMasterPageExport::exportMasterPageContent(
81 : const Reference < XPropertySet > & rPropSet,
82 : sal_Bool bAutoStyles )
83 : {
84 38 : Any aAny;
85 :
86 76 : Reference < XText > xHeaderText;
87 38 : aAny = rPropSet->getPropertyValue( sHeaderText );
88 38 : aAny >>= xHeaderText;
89 :
90 76 : Reference < XText > xHeaderTextFirst;
91 38 : aAny = rPropSet->getPropertyValue( sHeaderTextFirst );
92 38 : aAny >>= xHeaderTextFirst;
93 :
94 76 : Reference < XText > xHeaderTextLeft;
95 38 : aAny = rPropSet->getPropertyValue( sHeaderTextLeft );
96 38 : aAny >>= xHeaderTextLeft;
97 :
98 76 : Reference < XText > xFooterText;
99 38 : aAny = rPropSet->getPropertyValue( sFooterText );
100 38 : aAny >>= xFooterText;
101 :
102 76 : Reference < XText > xFooterTextFirst;
103 38 : aAny = rPropSet->getPropertyValue( sFooterTextFirst );
104 38 : aAny >>= xFooterTextFirst;
105 :
106 76 : Reference < XText > xFooterTextLeft;
107 38 : aAny = rPropSet->getPropertyValue( sFooterTextLeft );
108 38 : aAny >>= xFooterTextLeft;
109 :
110 38 : if( bAutoStyles )
111 : {
112 19 : if( xHeaderText.is() )
113 2 : exportHeaderFooterContent( xHeaderText, sal_True );
114 19 : if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
115 2 : exportHeaderFooterContent( xHeaderTextFirst, sal_True );
116 19 : if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
117 2 : exportHeaderFooterContent( xHeaderTextLeft, sal_True );
118 19 : if( xFooterText.is() )
119 2 : exportHeaderFooterContent( xFooterText, sal_True );
120 19 : if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
121 2 : exportHeaderFooterContent( xFooterTextFirst, sal_True );
122 19 : if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
123 2 : exportHeaderFooterContent( xFooterTextLeft, sal_True );
124 : }
125 : else
126 : {
127 19 : aAny = rPropSet->getPropertyValue( sHeaderOn );
128 19 : sal_Bool bHeader = sal_False;
129 19 : aAny >>= bHeader;
130 :
131 19 : sal_Bool bHeaderFirst = sal_False;
132 19 : if( bHeader )
133 : {
134 2 : aAny = rPropSet->getPropertyValue( sFirstShareContent );
135 2 : aAny >>= bHeaderFirst;
136 : }
137 :
138 19 : sal_Bool bHeaderLeft = sal_False;
139 19 : if( bHeader )
140 : {
141 2 : aAny = rPropSet->getPropertyValue( sHeaderShareContent );
142 2 : aAny >>= bHeaderLeft;
143 : }
144 :
145 19 : if( xHeaderText.is() )
146 : {
147 2 : if( !bHeader )
148 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
149 0 : XML_DISPLAY, XML_FALSE );
150 2 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
151 2 : XML_HEADER, sal_True, sal_True );
152 2 : exportHeaderFooterContent( xHeaderText, sal_False );
153 : }
154 :
155 19 : if( xHeaderTextFirst.is() && xHeaderTextFirst != xHeaderText )
156 : {
157 2 : if( !bHeaderFirst )
158 2 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
159 2 : XML_DISPLAY, XML_FALSE );
160 2 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
161 2 : XML_HEADER_FIRST, sal_True, sal_True );
162 2 : exportHeaderFooterContent( xHeaderTextFirst, sal_False );
163 : }
164 :
165 19 : if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
166 : {
167 2 : if( !bHeaderLeft )
168 2 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
169 2 : XML_DISPLAY, XML_FALSE );
170 2 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
171 2 : XML_HEADER_LEFT, sal_True, sal_True );
172 2 : exportHeaderFooterContent( xHeaderTextLeft, sal_False );
173 : }
174 :
175 19 : aAny = rPropSet->getPropertyValue( sFooterOn );
176 19 : sal_Bool bFooter = sal_False;
177 19 : aAny >>= bFooter;
178 :
179 19 : sal_Bool bFooterFirst = sal_False;
180 19 : if( bFooter )
181 : {
182 2 : aAny = rPropSet->getPropertyValue( sFirstShareContent );
183 2 : aAny >>= bFooterFirst;
184 : }
185 :
186 19 : sal_Bool bFooterLeft = sal_False;
187 19 : if( bFooter )
188 : {
189 2 : aAny = rPropSet->getPropertyValue( sFooterShareContent );
190 2 : aAny >>= bFooterLeft;
191 : }
192 :
193 19 : if( xFooterText.is() )
194 : {
195 2 : if( !bFooter )
196 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
197 0 : XML_DISPLAY, XML_FALSE );
198 2 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
199 2 : XML_FOOTER, sal_True, sal_True );
200 2 : exportHeaderFooterContent( xFooterText, sal_False );
201 : }
202 :
203 19 : if( xFooterTextFirst.is() && xFooterTextFirst != xFooterText )
204 : {
205 2 : if( !bFooterFirst )
206 2 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
207 2 : XML_DISPLAY, XML_FALSE );
208 2 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
209 2 : XML_FOOTER_FIRST, sal_True, sal_True );
210 2 : exportHeaderFooterContent( xFooterTextFirst, sal_False );
211 : }
212 :
213 19 : if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
214 : {
215 2 : if( !bFooterLeft )
216 2 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
217 2 : XML_DISPLAY, XML_FALSE );
218 2 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
219 2 : XML_FOOTER_LEFT, sal_True, sal_True );
220 2 : exportHeaderFooterContent( xFooterTextLeft, sal_False );
221 : }
222 38 : }
223 38 : }
224 :
225 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|