Files
libreoffice/xmloff/source/text/txtstyle.cxx
Michael Brauer 3737f2dccd syntax
2001-04-10 11:35:52 +00:00

229 lines
7.6 KiB
C++

/*************************************************************************
*
* $RCSfile: txtstyle.cxx,v $
*
* $Revision: 1.13 $
*
* last change: $Author: mib $ $Date: 2001-04-10 12:35:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _TOOLS_DEBUG_HXX
//#include <tools/debug.hxx>
#endif
#ifndef _COM_SUN_STAR_STYLE_PARAGRAPHSTYLECATEGORY_HPP_
#include <com/sun/star/style/ParagraphStyleCategory.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
#include <com/sun/star/beans/XPropertyState.hpp>
#endif
#ifndef _XMLOFF_XMLKYWD_HXX
#include "xmlkywd.hxx"
#endif
#ifndef _XMLOFF_PROPERTYSETMAPPER_HXX
//#include "xmlprmap.hxx"
#endif
#ifndef _XMLOFF_XMLSMSPE_HXX
#include "xmlnmspe.hxx"
#endif
#ifndef _XMLOFF_FAMILIES_HXX
#include "families.hxx"
#endif
#ifndef _XMLOFF_TXTPRMAP_HXX
//#include "txtprmap.hxx"
#endif
#ifndef _XMLOFF_TXTPARAE_HXX
#include "txtparae.hxx"
#endif
#ifndef _XMLOFF_XMLNUME_HXX
#include "xmlnume.hxx"
#endif
#ifndef _XMLOFF_XMLEXP_HXX
#include "xmlexp.hxx"
#endif
#ifndef _XMLOFF_XMLSECTIONEXPORT_HXX
#include "XMLSectionExport.hxx"
#endif
#ifndef _XMLOFF_XMLLINENUMBERINGEXPORT_HXX_
#include "XMLLineNumberingExport.hxx"
#endif
#ifndef _XMLOFF_STYLEEXP_HXX
//#include "styleexp.hxx"
#endif
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::style;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::beans;
void XMLTextParagraphExport::exportStyleAttributes(
const ::com::sun::star::uno::Reference<
::com::sun::star::style::XStyle > & rStyle )
{
Any aAny;
Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
Reference< XPropertySetInfo > xPropSetInfo =
xPropSet->getPropertySetInfo();
if( xPropSetInfo->hasPropertyByName( sCategory ) )
{
aAny = xPropSet->getPropertyValue( sCategory );
sal_Int16 nCategory;
aAny >>= nCategory;
const sal_Char *pValue = 0;
if( -1 != nCategory )
{
switch( nCategory )
{
case ParagraphStyleCategory::TEXT:
pValue = sXML_text;
break;
case ParagraphStyleCategory::CHAPTER:
pValue = sXML_chapter;
break;
case ParagraphStyleCategory::LIST:
pValue = sXML_list;
break;
case ParagraphStyleCategory::INDEX:
pValue = sXML_index;
break;
case ParagraphStyleCategory::EXTRA:
pValue = sXML_extra;
break;
case ParagraphStyleCategory::HTML:
pValue = sXML_html;
break;
}
}
if( pValue )
GetExport().AddAttributeASCII( XML_NAMESPACE_STYLE, sXML_class,
pValue );
}
if( xPropSetInfo->hasPropertyByName( sPageDescName ) )
{
Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
if( PropertyState_DIRECT_VALUE ==
xPropState->getPropertyState( sPageDescName ) )
{
aAny = xPropSet->getPropertyValue( sPageDescName );
OUString sName;
aAny >>= sName;
GetExport().AddAttribute( XML_NAMESPACE_STYLE,
sXML_master_page_name,
sName );
}
}
if( bProgress )
{
ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
pProgress->SetValue( pProgress->GetValue()+2 );
}
}
void XMLTextParagraphExport::exportNumStyles( sal_Bool bUsed )
{
SvxXMLNumRuleExport aNumRuleExport( GetExport() );
aNumRuleExport.exportStyles( bUsed, pListAutoPool, !IsBlockMode() );
}
void XMLTextParagraphExport::exportTextStyles( sal_Bool bUsed, sal_Bool bProg )
{
sal_Bool bOldProg = bProgress;
bProgress = bProg;
Reference < lang::XMultiServiceFactory > xFactory (GetExport().GetModel(), UNO_QUERY);
if (xFactory.is())
{
OUString sTextDefaults ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) );
Reference < XInterface > xInt = xFactory->createInstance ( sTextDefaults );
if ( xInt.is() )
{
Reference < XPropertySet > xPropSet (xInt, UNO_QUERY);
if (xPropSet.is())
exportDefaultStyle( xPropSet, sXML_paragraph, GetParaPropMapper());
}
}
exportStyleFamily( "ParagraphStyles", sXML_paragraph, GetParaPropMapper(),
bUsed, XML_STYLE_FAMILY_TEXT_PARAGRAPH, 0);
exportStyleFamily( "CharacterStyles", sXML_text, GetTextPropMapper(),
bUsed, XML_STYLE_FAMILY_TEXT_TEXT );
// get shape export to make sure the the frame family is added correctly.
GetExport().GetShapeExport();
exportStyleFamily( "FrameStyles", XML_STYLE_FAMILY_SD_GRAPHICS_NAME, GetFramePropMapper(),
bUsed, XML_STYLE_FAMILY_TEXT_FRAME, 0);
exportNumStyles( bUsed );
if( !IsBlockMode() )
{
exportTextFootnoteConfiguration();
XMLSectionExport::ExportBibliographyConfiguration(GetExport());
XMLLineNumberingExport aLineNumberingExport(GetExport());
aLineNumberingExport.Export();
}
bProgress = bOldProg;
}