1*63bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*63bba73cSAndrew Rist * distributed with this work for additional information 6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance 9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*63bba73cSAndrew Rist * software distributed under the License is distributed on an 15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the 17*63bba73cSAndrew Rist * specific language governing permissions and limitations 18*63bba73cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*63bba73cSAndrew Rist *************************************************************/ 21*63bba73cSAndrew Rist 22*63bba73cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 26cdf0e10cSrcweir #include <tools/debug.hxx> 27cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 28cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 29cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp> 30cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 31cdf0e10cSrcweir #include <xmloff/xmlexp.hxx> 32cdf0e10cSrcweir #include <xmloff/XMLTextMasterPageExport.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir 35cdf0e10cSrcweir using ::rtl::OUString; 36cdf0e10cSrcweir using ::rtl::OUStringBuffer; 37cdf0e10cSrcweir 38cdf0e10cSrcweir using namespace ::com::sun::star; 39cdf0e10cSrcweir using namespace ::com::sun::star::uno; 40cdf0e10cSrcweir using namespace ::com::sun::star::text; 41cdf0e10cSrcweir using namespace ::com::sun::star::beans; 42cdf0e10cSrcweir using namespace ::xmloff::token; 43cdf0e10cSrcweir 44cdf0e10cSrcweir XMLTextMasterPageExport::XMLTextMasterPageExport( SvXMLExport& rExp ) : 45cdf0e10cSrcweir XMLPageExport( rExp ), 46cdf0e10cSrcweir sHeaderText( RTL_CONSTASCII_USTRINGPARAM( "HeaderText" ) ), 47cdf0e10cSrcweir sHeaderOn( RTL_CONSTASCII_USTRINGPARAM( "HeaderIsOn" ) ), 48cdf0e10cSrcweir sHeaderShareContent( RTL_CONSTASCII_USTRINGPARAM( "HeaderIsShared" ) ), 49cdf0e10cSrcweir sHeaderTextLeft( RTL_CONSTASCII_USTRINGPARAM( "HeaderTextLeft" ) ), 50cdf0e10cSrcweir sFooterText( RTL_CONSTASCII_USTRINGPARAM( "FooterText" ) ), 51cdf0e10cSrcweir sFooterOn( RTL_CONSTASCII_USTRINGPARAM( "FooterIsOn" ) ), 52cdf0e10cSrcweir sFooterShareContent( RTL_CONSTASCII_USTRINGPARAM( "FooterIsShared" ) ), 53cdf0e10cSrcweir sFooterTextLeft( RTL_CONSTASCII_USTRINGPARAM( "FooterTextLeft" ) ) 54cdf0e10cSrcweir { 55cdf0e10cSrcweir } 56cdf0e10cSrcweir 57cdf0e10cSrcweir XMLTextMasterPageExport::~XMLTextMasterPageExport() 58cdf0e10cSrcweir { 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir 62cdf0e10cSrcweir void XMLTextMasterPageExport::exportHeaderFooterContent( 63cdf0e10cSrcweir const Reference< XText >& rText, 64cdf0e10cSrcweir sal_Bool bAutoStyles, sal_Bool bExportParagraph ) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir DBG_ASSERT( rText.is(), "There is the text" ); 67cdf0e10cSrcweir 68cdf0e10cSrcweir // tracked changes (autostyles + changes list) 69cdf0e10cSrcweir GetExport().GetTextParagraphExport()->recordTrackedChangesForXText(rText); 70cdf0e10cSrcweir GetExport().GetTextParagraphExport()->exportTrackedChanges(rText, 71cdf0e10cSrcweir bAutoStyles); 72cdf0e10cSrcweir if( bAutoStyles ) 73cdf0e10cSrcweir GetExport().GetTextParagraphExport() 74cdf0e10cSrcweir ->collectTextAutoStyles( rText, sal_True, bExportParagraph ); 75cdf0e10cSrcweir else 76cdf0e10cSrcweir { 77cdf0e10cSrcweir GetExport().GetTextParagraphExport()->exportTextDeclarations( rText ); 78cdf0e10cSrcweir GetExport().GetTextParagraphExport()->exportText( rText, sal_True, bExportParagraph ); 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir // tracked changes (end of XText) 82cdf0e10cSrcweir GetExport().GetTextParagraphExport()->recordTrackedChangesNoXText(); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir void XMLTextMasterPageExport::exportMasterPageContent( 86cdf0e10cSrcweir const Reference < XPropertySet > & rPropSet, 87cdf0e10cSrcweir sal_Bool bAutoStyles ) 88cdf0e10cSrcweir { 89cdf0e10cSrcweir Any aAny; 90cdf0e10cSrcweir 91cdf0e10cSrcweir Reference < XText > xHeaderText; 92cdf0e10cSrcweir aAny = rPropSet->getPropertyValue( sHeaderText ); 93cdf0e10cSrcweir aAny >>= xHeaderText; 94cdf0e10cSrcweir 95cdf0e10cSrcweir Reference < XText > xHeaderTextLeft; 96cdf0e10cSrcweir aAny = rPropSet->getPropertyValue( sHeaderTextLeft ); 97cdf0e10cSrcweir aAny >>= xHeaderTextLeft; 98cdf0e10cSrcweir 99cdf0e10cSrcweir Reference < XText > xFooterText; 100cdf0e10cSrcweir aAny = rPropSet->getPropertyValue( sFooterText ); 101cdf0e10cSrcweir aAny >>= xFooterText; 102cdf0e10cSrcweir 103cdf0e10cSrcweir Reference < XText > xFooterTextLeft; 104cdf0e10cSrcweir aAny = rPropSet->getPropertyValue( sFooterTextLeft ); 105cdf0e10cSrcweir aAny >>= xFooterTextLeft; 106cdf0e10cSrcweir 107cdf0e10cSrcweir if( bAutoStyles ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir if( xHeaderText.is() ) 110cdf0e10cSrcweir exportHeaderFooterContent( xHeaderText, sal_True ); 111cdf0e10cSrcweir if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText ) 112cdf0e10cSrcweir exportHeaderFooterContent( xHeaderTextLeft, sal_True ); 113cdf0e10cSrcweir if( xFooterText.is() ) 114cdf0e10cSrcweir exportHeaderFooterContent( xFooterText, sal_True ); 115cdf0e10cSrcweir if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText ) 116cdf0e10cSrcweir exportHeaderFooterContent( xFooterTextLeft, sal_True ); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir else 119cdf0e10cSrcweir { 120cdf0e10cSrcweir aAny = rPropSet->getPropertyValue( sHeaderOn ); 121cdf0e10cSrcweir sal_Bool bHeader = *(sal_Bool *)aAny.getValue(); 122cdf0e10cSrcweir 123cdf0e10cSrcweir sal_Bool bHeaderLeft = sal_False; 124cdf0e10cSrcweir if( bHeader ) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir aAny = rPropSet->getPropertyValue( sHeaderShareContent ); 127cdf0e10cSrcweir bHeaderLeft = !*(sal_Bool *)aAny.getValue(); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir 130cdf0e10cSrcweir if( xHeaderText.is() ) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir if( !bHeader ) 133cdf0e10cSrcweir GetExport().AddAttribute( XML_NAMESPACE_STYLE, 134cdf0e10cSrcweir XML_DISPLAY, XML_FALSE ); 135cdf0e10cSrcweir SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, 136cdf0e10cSrcweir XML_HEADER, sal_True, sal_True ); 137cdf0e10cSrcweir exportHeaderFooterContent( xHeaderText, sal_False ); 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir if( !bHeaderLeft ) 143cdf0e10cSrcweir GetExport().AddAttribute( XML_NAMESPACE_STYLE, 144cdf0e10cSrcweir XML_DISPLAY, XML_FALSE ); 145cdf0e10cSrcweir SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, 146cdf0e10cSrcweir XML_HEADER_LEFT, sal_True, sal_True ); 147cdf0e10cSrcweir exportHeaderFooterContent( xHeaderTextLeft, sal_False ); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir aAny = rPropSet->getPropertyValue( sFooterOn ); 151cdf0e10cSrcweir sal_Bool bFooter = *(sal_Bool *)aAny.getValue(); 152cdf0e10cSrcweir 153cdf0e10cSrcweir sal_Bool bFooterLeft = sal_False; 154cdf0e10cSrcweir if( bFooter ) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir aAny = rPropSet->getPropertyValue( sFooterShareContent ); 157cdf0e10cSrcweir bFooterLeft = !*(sal_Bool *)aAny.getValue(); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir if( xFooterText.is() ) 161cdf0e10cSrcweir { 162cdf0e10cSrcweir if( !bFooter ) 163cdf0e10cSrcweir GetExport().AddAttribute( XML_NAMESPACE_STYLE, 164cdf0e10cSrcweir XML_DISPLAY, XML_FALSE ); 165cdf0e10cSrcweir SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, 166cdf0e10cSrcweir XML_FOOTER, sal_True, sal_True ); 167cdf0e10cSrcweir exportHeaderFooterContent( xFooterText, sal_False ); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText ) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir if( !bFooterLeft ) 173cdf0e10cSrcweir GetExport().AddAttribute( XML_NAMESPACE_STYLE, 174cdf0e10cSrcweir XML_DISPLAY, XML_FALSE ); 175cdf0e10cSrcweir SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, 176cdf0e10cSrcweir XML_FOOTER_LEFT, sal_True, sal_True ); 177cdf0e10cSrcweir exportHeaderFooterContent( xFooterTextLeft, sal_False ); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir } 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182