1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtstyle.cxx,v $
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>
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>
49 #ifndef _XMLOFF_XMLSMSPE_HXX
50 #include "xmlnmspe.hxx"
52 #ifndef _XMLOFF_FAMILIES_HXX
53 #include <xmloff/families.hxx>
55 #ifndef _XMLOFF_TXTPRMAP_HXX
56 //#include <xmloff/txtprmap.hxx>
58 #ifndef _XMLOFF_TXTPARAE_HXX
59 #include <xmloff/txtparae.hxx>
61 #include <xmloff/xmlnume.hxx>
62 #include <xmloff/xmlexp.hxx>
63 #ifndef _XMLOFF_XMLSECTIONEXPORT_HXX
64 #include "XMLSectionExport.hxx"
66 #include "XMLLineNumberingExport.hxx"
67 #include "txtexppr.hxx"
68 #ifndef _XMLOFF_TXTPRMAP_HXX
69 #include <xmloff/txtprmap.hxx>
72 #ifndef _XMLOFF_STYLEEXP_HXX
73 //#include <xmloff/styleexp.hxx>
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
)
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
)
104 case ParagraphStyleCategory::TEXT
:
107 case ParagraphStyleCategory::CHAPTER
:
108 eValue
= XML_CHAPTER
;
110 case ParagraphStyleCategory::LIST
:
113 case ParagraphStyleCategory::INDEX
:
116 case ParagraphStyleCategory::EXTRA
:
119 case ParagraphStyleCategory::HTML
:
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() );
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
;
169 Reference
< lang::XMultiServiceFactory
> xFactory (GetExport().GetModel(), UNO_QUERY
);
172 OUString
sTextDefaults ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) );
173 Reference
< XPropertySet
> xPropSet (xFactory
->createInstance ( sTextDefaults
), UNO_QUERY
);
176 exportDefaultStyle( xPropSet
, GetXMLToken(XML_PARAGRAPH
), GetParaPropMapper());
180 GetXMLToken(XML_TABLE
),
181 new XMLTextExportPropertySetMapper(
182 new XMLTextPropertySetMapper(
183 TEXT_PROP_MAP_TABLE_DEFAULTS
),
188 GetXMLToken(XML_TABLE_ROW
),
189 new XMLTextExportPropertySetMapper(
190 new XMLTextPropertySetMapper(
191 TEXT_PROP_MAP_TABLE_ROW_DEFAULTS
),
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
);
206 exportTextFootnoteConfiguration();
207 XMLSectionExport::ExportBibliographyConfiguration(GetExport());
208 XMLLineNumberingExport
aLineNumberingExport(GetExport());
209 aLineNumberingExport
.Export();
212 bProgress
= bOldProg
;