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