Update ooo320-m1
[ooovba.git] / xmloff / source / text / XMLTextMasterPageExport.cxx
blob7271afc935fe2706b94f3ab691f2c1b6477a6444
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLTextMasterPageExport.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <tools/debug.hxx>
34 #include "xmlnmspe.hxx"
35 #include <xmloff/xmltoken.hxx>
36 #include <com/sun/star/text/XText.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <xmloff/xmlexp.hxx>
39 #include <xmloff/XMLTextMasterPageExport.hxx>
42 using ::rtl::OUString;
43 using ::rtl::OUStringBuffer;
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::text;
48 using namespace ::com::sun::star::beans;
49 using namespace ::xmloff::token;
51 XMLTextMasterPageExport::XMLTextMasterPageExport( SvXMLExport& rExp ) :
52 XMLPageExport( rExp ),
53 sHeaderText( RTL_CONSTASCII_USTRINGPARAM( "HeaderText" ) ),
54 sHeaderOn( RTL_CONSTASCII_USTRINGPARAM( "HeaderIsOn" ) ),
55 sHeaderShareContent( RTL_CONSTASCII_USTRINGPARAM( "HeaderIsShared" ) ),
56 sHeaderTextLeft( RTL_CONSTASCII_USTRINGPARAM( "HeaderTextLeft" ) ),
57 sFooterText( RTL_CONSTASCII_USTRINGPARAM( "FooterText" ) ),
58 sFooterOn( RTL_CONSTASCII_USTRINGPARAM( "FooterIsOn" ) ),
59 sFooterShareContent( RTL_CONSTASCII_USTRINGPARAM( "FooterIsShared" ) ),
60 sFooterTextLeft( RTL_CONSTASCII_USTRINGPARAM( "FooterTextLeft" ) )
64 XMLTextMasterPageExport::~XMLTextMasterPageExport()
69 void XMLTextMasterPageExport::exportHeaderFooterContent(
70 const Reference< XText >& rText,
71 sal_Bool bAutoStyles, sal_Bool bExportParagraph )
73 DBG_ASSERT( rText.is(), "There is the text" );
75 // tracked changes (autostyles + changes list)
76 GetExport().GetTextParagraphExport()->recordTrackedChangesForXText(rText);
77 GetExport().GetTextParagraphExport()->exportTrackedChanges(rText,
78 bAutoStyles);
79 if( bAutoStyles )
80 GetExport().GetTextParagraphExport()
81 ->collectTextAutoStyles( rText, sal_True, bExportParagraph );
82 else
84 GetExport().GetTextParagraphExport()->exportTextDeclarations( rText );
85 GetExport().GetTextParagraphExport()->exportText( rText, sal_True, bExportParagraph );
88 // tracked changes (end of XText)
89 GetExport().GetTextParagraphExport()->recordTrackedChangesNoXText();
92 void XMLTextMasterPageExport::exportMasterPageContent(
93 const Reference < XPropertySet > & rPropSet,
94 sal_Bool bAutoStyles )
96 Any aAny;
98 Reference < XText > xHeaderText;
99 aAny = rPropSet->getPropertyValue( sHeaderText );
100 aAny >>= xHeaderText;
102 Reference < XText > xHeaderTextLeft;
103 aAny = rPropSet->getPropertyValue( sHeaderTextLeft );
104 aAny >>= xHeaderTextLeft;
106 Reference < XText > xFooterText;
107 aAny = rPropSet->getPropertyValue( sFooterText );
108 aAny >>= xFooterText;
110 Reference < XText > xFooterTextLeft;
111 aAny = rPropSet->getPropertyValue( sFooterTextLeft );
112 aAny >>= xFooterTextLeft;
114 if( bAutoStyles )
116 if( xHeaderText.is() )
117 exportHeaderFooterContent( xHeaderText, sal_True );
118 if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
119 exportHeaderFooterContent( xHeaderTextLeft, sal_True );
120 if( xFooterText.is() )
121 exportHeaderFooterContent( xFooterText, sal_True );
122 if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
123 exportHeaderFooterContent( xFooterTextLeft, sal_True );
125 else
127 aAny = rPropSet->getPropertyValue( sHeaderOn );
128 sal_Bool bHeader = *(sal_Bool *)aAny.getValue();
130 sal_Bool bHeaderLeft = sal_False;
131 if( bHeader )
133 aAny = rPropSet->getPropertyValue( sHeaderShareContent );
134 bHeaderLeft = !*(sal_Bool *)aAny.getValue();
137 if( xHeaderText.is() )
139 if( !bHeader )
140 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
141 XML_DISPLAY, XML_FALSE );
142 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
143 XML_HEADER, sal_True, sal_True );
144 exportHeaderFooterContent( xHeaderText, sal_False );
147 if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
149 if( !bHeaderLeft )
150 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
151 XML_DISPLAY, XML_FALSE );
152 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
153 XML_HEADER_LEFT, sal_True, sal_True );
154 exportHeaderFooterContent( xHeaderTextLeft, sal_False );
157 aAny = rPropSet->getPropertyValue( sFooterOn );
158 sal_Bool bFooter = *(sal_Bool *)aAny.getValue();
160 sal_Bool bFooterLeft = sal_False;
161 if( bFooter )
163 aAny = rPropSet->getPropertyValue( sFooterShareContent );
164 bFooterLeft = !*(sal_Bool *)aAny.getValue();
167 if( xFooterText.is() )
169 if( !bFooter )
170 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
171 XML_DISPLAY, XML_FALSE );
172 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
173 XML_FOOTER, sal_True, sal_True );
174 exportHeaderFooterContent( xFooterText, sal_False );
177 if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
179 if( !bFooterLeft )
180 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
181 XML_DISPLAY, XML_FALSE );
182 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
183 XML_FOOTER_LEFT, sal_True, sal_True );
184 exportHeaderFooterContent( xFooterTextLeft, sal_False );