Files
libreoffice/xmloff/source/text/XMLTextMasterPageExport.cxx

186 lines
6.9 KiB
C++
Raw Normal View History

2000-10-11 06:51:24 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-10-11 06:51:24 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-10-11 06:51:24 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-10-11 06:51:24 +00:00
*
* This file is part of OpenOffice.org.
2000-10-11 06:51:24 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-10-11 06:51:24 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-10-11 06:51:24 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-10-11 06:51:24 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_xmloff.hxx"
2000-10-11 06:51:24 +00:00
#include <tools/debug.hxx>
#include "xmlnmspe.hxx"
#include <xmloff/xmltoken.hxx>
2000-10-11 06:51:24 +00:00
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <xmloff/xmlexp.hxx>
#include <xmloff/XMLTextMasterPageExport.hxx>
2000-10-11 06:51:24 +00:00
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
2000-10-11 06:51:24 +00:00
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::beans;
using namespace ::xmloff::token;
2000-10-11 06:51:24 +00:00
XMLTextMasterPageExport::XMLTextMasterPageExport( SvXMLExport& rExp ) :
XMLPageExport( rExp ),
sHeaderText( RTL_CONSTASCII_USTRINGPARAM( "HeaderText" ) ),
2000-10-23 10:33:22 +00:00
sHeaderOn( RTL_CONSTASCII_USTRINGPARAM( "HeaderIsOn" ) ),
sHeaderShareContent( RTL_CONSTASCII_USTRINGPARAM( "HeaderIsShared" ) ),
2000-10-11 06:51:24 +00:00
sHeaderTextLeft( RTL_CONSTASCII_USTRINGPARAM( "HeaderTextLeft" ) ),
sFooterText( RTL_CONSTASCII_USTRINGPARAM( "FooterText" ) ),
2000-10-23 10:33:22 +00:00
sFooterOn( RTL_CONSTASCII_USTRINGPARAM( "FooterIsOn" ) ),
sFooterShareContent( RTL_CONSTASCII_USTRINGPARAM( "FooterIsShared" ) ),
2000-10-11 06:51:24 +00:00
sFooterTextLeft( RTL_CONSTASCII_USTRINGPARAM( "FooterTextLeft" ) )
{
}
XMLTextMasterPageExport::~XMLTextMasterPageExport()
{
}
void XMLTextMasterPageExport::exportHeaderFooterContent(
const Reference< XText >& rText,
sal_Bool bAutoStyles, sal_Bool bExportParagraph )
2000-10-11 06:51:24 +00:00
{
DBG_ASSERT( rText.is(), "There is the text" );
// tracked changes (autostyles + changes list)
GetExport().GetTextParagraphExport()->recordTrackedChangesForXText(rText);
GetExport().GetTextParagraphExport()->exportTrackedChanges(rText,
bAutoStyles);
2000-10-11 06:51:24 +00:00
if( bAutoStyles )
GetExport().GetTextParagraphExport()
->collectTextAutoStyles( rText, sal_True, bExportParagraph );
2000-10-11 06:51:24 +00:00
else
{
GetExport().GetTextParagraphExport()->exportTextDeclarations( rText );
GetExport().GetTextParagraphExport()->exportText( rText, sal_True, bExportParagraph );
}
// tracked changes (end of XText)
GetExport().GetTextParagraphExport()->recordTrackedChangesNoXText();
2000-10-11 06:51:24 +00:00
}
void XMLTextMasterPageExport::exportMasterPageContent(
const Reference < XPropertySet > & rPropSet,
sal_Bool bAutoStyles )
{
Any aAny;
Reference < XText > xHeaderText;
aAny = rPropSet->getPropertyValue( sHeaderText );
aAny >>= xHeaderText;
Reference < XText > xHeaderTextLeft;
aAny = rPropSet->getPropertyValue( sHeaderTextLeft );
aAny >>= xHeaderTextLeft;
Reference < XText > xFooterText;
aAny = rPropSet->getPropertyValue( sFooterText );
aAny >>= xFooterText;
Reference < XText > xFooterTextLeft;
aAny = rPropSet->getPropertyValue( sFooterTextLeft );
aAny >>= xFooterTextLeft;
if( bAutoStyles )
{
if( xHeaderText.is() )
exportHeaderFooterContent( xHeaderText, sal_True );
if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
exportHeaderFooterContent( xHeaderTextLeft, sal_True );
if( xFooterText.is() )
exportHeaderFooterContent( xFooterText, sal_True );
if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
exportHeaderFooterContent( xFooterTextLeft, sal_True );
}
else
{
aAny = rPropSet->getPropertyValue( sHeaderOn );
sal_Bool bHeader = *(sal_Bool *)aAny.getValue();
sal_Bool bHeaderLeft = sal_False;
if( bHeader )
{
aAny = rPropSet->getPropertyValue( sHeaderShareContent );
bHeaderLeft = !*(sal_Bool *)aAny.getValue();
}
if( xHeaderText.is() )
{
if( !bHeader )
GetExport().AddAttribute( XML_NAMESPACE_STYLE,
XML_DISPLAY, XML_FALSE );
2000-10-11 06:51:24 +00:00
SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
XML_HEADER, sal_True, sal_True );
2000-10-11 06:51:24 +00:00
exportHeaderFooterContent( xHeaderText, sal_False );
}
if( xHeaderTextLeft.is() && xHeaderTextLeft != xHeaderText )
{
if( !bHeaderLeft )
GetExport().AddAttribute( XML_NAMESPACE_STYLE,
XML_DISPLAY, XML_FALSE );
2000-10-11 06:51:24 +00:00
SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
XML_HEADER_LEFT, sal_True, sal_True );
2000-10-11 06:51:24 +00:00
exportHeaderFooterContent( xHeaderTextLeft, sal_False );
}
aAny = rPropSet->getPropertyValue( sFooterOn );
sal_Bool bFooter = *(sal_Bool *)aAny.getValue();
sal_Bool bFooterLeft = sal_False;
if( bFooter )
{
aAny = rPropSet->getPropertyValue( sFooterShareContent );
bFooterLeft = !*(sal_Bool *)aAny.getValue();
}
if( xFooterText.is() )
{
if( !bFooter )
GetExport().AddAttribute( XML_NAMESPACE_STYLE,
XML_DISPLAY, XML_FALSE );
2000-10-11 06:51:24 +00:00
SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
XML_FOOTER, sal_True, sal_True );
2000-10-11 06:51:24 +00:00
exportHeaderFooterContent( xFooterText, sal_False );
}
if( xFooterTextLeft.is() && xFooterTextLeft != xFooterText )
{
if( !bFooterLeft )
GetExport().AddAttribute( XML_NAMESPACE_STYLE,
XML_DISPLAY, XML_FALSE );
2000-10-11 06:51:24 +00:00
SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
XML_FOOTER_LEFT, sal_True, sal_True );
2000-10-11 06:51:24 +00:00
exportHeaderFooterContent( xFooterTextLeft, sal_False );
}
}
}