1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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
;
36 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 sFooterTextLeft( "FooterTextLeft" )
52 XMLTextMasterPageExport::~XMLTextMasterPageExport()
57 void XMLTextMasterPageExport::exportHeaderFooterContent(
58 const Reference
< XText
>& rText
,
59 bool bAutoStyles
, bool bExportParagraph
)
61 DBG_ASSERT( rText
.is(), "There is the text" );
63 // tracked changes (autostyles + changes list)
64 GetExport().GetTextParagraphExport()->recordTrackedChangesForXText(rText
);
65 GetExport().GetTextParagraphExport()->exportTrackedChanges(rText
,
68 GetExport().GetTextParagraphExport()
69 ->collectTextAutoStyles( rText
, true, bExportParagraph
);
72 GetExport().GetTextParagraphExport()->exportTextDeclarations( rText
);
73 GetExport().GetTextParagraphExport()->exportText( rText
, true, bExportParagraph
);
76 // tracked changes (end of XText)
77 GetExport().GetTextParagraphExport()->recordTrackedChangesNoXText();
80 void XMLTextMasterPageExport::exportMasterPageContent(
81 const Reference
< XPropertySet
> & rPropSet
,
86 Reference
< XText
> xHeaderText
;
87 aAny
= rPropSet
->getPropertyValue( sHeaderText
);
90 Reference
< XText
> xHeaderTextFirst
;
91 aAny
= rPropSet
->getPropertyValue( sHeaderTextFirst
);
92 aAny
>>= xHeaderTextFirst
;
94 Reference
< XText
> xHeaderTextLeft
;
95 aAny
= rPropSet
->getPropertyValue( sHeaderTextLeft
);
96 aAny
>>= xHeaderTextLeft
;
98 Reference
< XText
> xFooterText
;
99 aAny
= rPropSet
->getPropertyValue( sFooterText
);
100 aAny
>>= xFooterText
;
102 Reference
< XText
> xFooterTextFirst
;
103 aAny
= rPropSet
->getPropertyValue( sFooterTextFirst
);
104 aAny
>>= xFooterTextFirst
;
106 Reference
< XText
> xFooterTextLeft
;
107 aAny
= rPropSet
->getPropertyValue( sFooterTextLeft
);
108 aAny
>>= xFooterTextLeft
;
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 );
127 aAny
= rPropSet
->getPropertyValue( sHeaderOn
);
128 bool bHeader
= false;
131 bool bHeaderFirstShared
= false;
134 aAny
= rPropSet
->getPropertyValue( sFirstShareContent
);
135 aAny
>>= bHeaderFirstShared
;
138 bool bHeaderLeftShared
= false;
141 aAny
= rPropSet
->getPropertyValue( sHeaderShareContent
);
142 aAny
>>= bHeaderLeftShared
;
145 if( xHeaderText
.is() )
148 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
149 XML_DISPLAY
, XML_FALSE
);
150 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_STYLE
,
151 XML_HEADER
, true, true );
152 exportHeaderFooterContent( xHeaderText
, false );
155 if( xHeaderTextFirst
.is() && xHeaderTextFirst
!= xHeaderText
)
157 if (bHeaderFirstShared
)
158 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
159 XML_DISPLAY
, XML_FALSE
);
160 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_STYLE
,
161 XML_HEADER_FIRST
, true, true );
162 exportHeaderFooterContent( xHeaderTextFirst
, false );
165 if( xHeaderTextLeft
.is() && xHeaderTextLeft
!= xHeaderText
)
167 if (bHeaderLeftShared
)
168 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
169 XML_DISPLAY
, XML_FALSE
);
170 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_STYLE
,
171 XML_HEADER_LEFT
, true, true );
172 exportHeaderFooterContent( xHeaderTextLeft
, false );
175 aAny
= rPropSet
->getPropertyValue( sFooterOn
);
176 bool bFooter
= false;
179 bool bFooterFirstShared
= false;
182 aAny
= rPropSet
->getPropertyValue( sFirstShareContent
);
183 aAny
>>= bFooterFirstShared
;
186 bool bFooterLeftShared
= false;
189 aAny
= rPropSet
->getPropertyValue( sFooterShareContent
);
190 aAny
>>= bFooterLeftShared
;
193 if( xFooterText
.is() )
196 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
197 XML_DISPLAY
, XML_FALSE
);
198 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_STYLE
,
199 XML_FOOTER
, true, true );
200 exportHeaderFooterContent( xFooterText
, false );
203 if( xFooterTextFirst
.is() && xFooterTextFirst
!= xFooterText
)
205 if (bFooterFirstShared
)
206 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
207 XML_DISPLAY
, XML_FALSE
);
208 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_STYLE
,
209 XML_FOOTER_FIRST
, true, true );
210 exportHeaderFooterContent( xFooterTextFirst
, false );
213 if( xFooterTextLeft
.is() && xFooterTextLeft
!= xFooterText
)
215 if (bFooterLeftShared
)
216 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
217 XML_DISPLAY
, XML_FALSE
);
218 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_STYLE
,
219 XML_FOOTER_LEFT
, true, true );
220 exportHeaderFooterContent( xFooterTextLeft
, false );
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */