update dev300-m58
[ooovba.git] / xmloff / source / text / txtstyle.cxx
blobd9e061be84e0853fa0b8fa77629f46a6048c7056
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: txtstyle.cxx,v $
10 * $Revision: 1.26 $
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"
34 #ifndef _TOOLS_DEBUG_HXX
35 //#include <tools/debug.hxx>
36 #endif
37 #include <com/sun/star/style/ParagraphStyleCategory.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/beans/XPropertySetInfo.hpp>
40 #include <com/sun/star/beans/XPropertyState.hpp>
41 #include <com/sun/star/style/XStyle.hpp>
44 #include <xmloff/xmltoken.hxx>
46 #ifndef _XMLOFF_PROPERTYSETMAPPER_HXX
47 //#include <xmloff/xmlprmap.hxx>
48 #endif
49 #ifndef _XMLOFF_XMLSMSPE_HXX
50 #include "xmlnmspe.hxx"
51 #endif
52 #ifndef _XMLOFF_FAMILIES_HXX
53 #include <xmloff/families.hxx>
54 #endif
55 #ifndef _XMLOFF_TXTPRMAP_HXX
56 //#include <xmloff/txtprmap.hxx>
57 #endif
58 #ifndef _XMLOFF_TXTPARAE_HXX
59 #include <xmloff/txtparae.hxx>
60 #endif
61 #include <xmloff/xmlnume.hxx>
62 #include <xmloff/xmlexp.hxx>
63 #ifndef _XMLOFF_XMLSECTIONEXPORT_HXX
64 #include "XMLSectionExport.hxx"
65 #endif
66 #include "XMLLineNumberingExport.hxx"
67 #include "txtexppr.hxx"
68 #ifndef _XMLOFF_TXTPRMAP_HXX
69 #include <xmloff/txtprmap.hxx>
70 #endif
72 #ifndef _XMLOFF_STYLEEXP_HXX
73 //#include <xmloff/styleexp.hxx>
74 #endif
76 using ::rtl::OUString;
77 using ::rtl::OUStringBuffer;
79 using namespace ::com::sun::star;
80 using namespace ::com::sun::star::uno;
81 using namespace ::com::sun::star::style;
82 using namespace ::com::sun::star::container;
83 using namespace ::com::sun::star::beans;
84 using namespace ::xmloff::token;
86 void XMLTextParagraphExport::exportStyleAttributes(
87 const ::com::sun::star::uno::Reference<
88 ::com::sun::star::style::XStyle > & rStyle )
90 OUString sName;
91 Any aAny;
92 Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
93 Reference< XPropertySetInfo > xPropSetInfo(
94 xPropSet->getPropertySetInfo());
95 if( xPropSetInfo->hasPropertyByName( sCategory ) )
97 sal_Int16 nCategory = 0;
98 xPropSet->getPropertyValue( sCategory ) >>= nCategory;
99 enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
100 if( -1 != nCategory )
102 switch( nCategory )
104 case ParagraphStyleCategory::TEXT:
105 eValue = XML_TEXT;
106 break;
107 case ParagraphStyleCategory::CHAPTER:
108 eValue = XML_CHAPTER;
109 break;
110 case ParagraphStyleCategory::LIST:
111 eValue = XML_LIST;
112 break;
113 case ParagraphStyleCategory::INDEX:
114 eValue = XML_INDEX;
115 break;
116 case ParagraphStyleCategory::EXTRA:
117 eValue = XML_EXTRA;
118 break;
119 case ParagraphStyleCategory::HTML:
120 eValue = XML_HTML;
121 break;
124 if( eValue != XML_TOKEN_INVALID )
125 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_CLASS, eValue);
127 if( xPropSetInfo->hasPropertyByName( sPageDescName ) )
129 Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
130 if( PropertyState_DIRECT_VALUE ==
131 xPropState->getPropertyState( sPageDescName ) )
133 xPropSet->getPropertyValue( sPageDescName ) >>= sName;
134 // fix for #i5551# if( sName.getLength() > 0 )
135 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
136 XML_MASTER_PAGE_NAME,
137 GetExport().EncodeStyleName( sName ) );
140 //sal_Int32 nOutlineLevel = //#outline level, zhaojianwei, moved to styleexp.cxx - XMLStyleExport::exportStyle(¡­¡­)
141 // GetExport().GetTextParagraphExport()->GetHeadingLevel( rStyle->getName() );
142 //if( nOutlineLevel != -1 )
144 // OUStringBuffer sTmp;
145 // sTmp.append( static_cast<sal_Int32>(nOutlineLevel+1L) );
146 // GetExport().AddAttribute( XML_NAMESPACE_STYLE,
147 // XML_DEFAULT_OUTLINE_LEVEL,
148 // sTmp.makeStringAndClear() );
151 if( bProgress )
153 ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
154 pProgress->SetValue( pProgress->GetValue()+2 );
158 void XMLTextParagraphExport::exportNumStyles( sal_Bool bUsed )
160 SvxXMLNumRuleExport aNumRuleExport( GetExport() );
161 aNumRuleExport.exportStyles( bUsed, pListAutoPool, !IsBlockMode() );
164 void XMLTextParagraphExport::exportTextStyles( sal_Bool bUsed, sal_Bool bProg )
166 sal_Bool bOldProg = bProgress;
167 bProgress = bProg;
169 Reference < lang::XMultiServiceFactory > xFactory (GetExport().GetModel(), UNO_QUERY);
170 if (xFactory.is())
172 OUString sTextDefaults ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) );
173 Reference < XPropertySet > xPropSet (xFactory->createInstance ( sTextDefaults ), UNO_QUERY);
174 if (xPropSet.is())
176 exportDefaultStyle( xPropSet, GetXMLToken(XML_PARAGRAPH), GetParaPropMapper());
178 exportDefaultStyle(
179 xPropSet,
180 GetXMLToken(XML_TABLE),
181 new XMLTextExportPropertySetMapper(
182 new XMLTextPropertySetMapper(
183 TEXT_PROP_MAP_TABLE_DEFAULTS ),
184 GetExport() ) );
186 exportDefaultStyle(
187 xPropSet,
188 GetXMLToken(XML_TABLE_ROW),
189 new XMLTextExportPropertySetMapper(
190 new XMLTextPropertySetMapper(
191 TEXT_PROP_MAP_TABLE_ROW_DEFAULTS ),
192 GetExport() ) );
195 exportStyleFamily( "ParagraphStyles", GetXMLToken(XML_PARAGRAPH), GetParaPropMapper(),
196 bUsed, XML_STYLE_FAMILY_TEXT_PARAGRAPH, 0);
197 exportStyleFamily( "CharacterStyles", GetXMLToken(XML_TEXT), GetTextPropMapper(),
198 bUsed, XML_STYLE_FAMILY_TEXT_TEXT );
199 // get shape export to make sure the the frame family is added correctly.
200 GetExport().GetShapeExport();
201 exportStyleFamily( "FrameStyles", OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)), GetFramePropMapper(),
202 bUsed, XML_STYLE_FAMILY_TEXT_FRAME, 0);
203 exportNumStyles( bUsed );
204 if( !IsBlockMode() )
206 exportTextFootnoteConfiguration();
207 XMLSectionExport::ExportBibliographyConfiguration(GetExport());
208 XMLLineNumberingExport aLineNumberingExport(GetExport());
209 aLineNumberingExport.Export();
212 bProgress = bOldProg;