xref: /aoo42x/main/xmloff/source/text/txtstyle.cxx (revision 63bba73c)
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
10*63bba73cSAndrew Rist  *
11*63bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist  *
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.
19*63bba73cSAndrew Rist  *
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 
27cdf0e10cSrcweir #include <com/sun/star/style/ParagraphStyleCategory.hpp>
28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
30cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp>
31cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp>
32cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
33cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
34cdf0e10cSrcweir #include <xmloff/families.hxx>
35cdf0e10cSrcweir #include <xmloff/txtparae.hxx>
36cdf0e10cSrcweir #include <xmloff/xmlnume.hxx>
37cdf0e10cSrcweir #include <xmloff/xmlexp.hxx>
38cdf0e10cSrcweir #include "XMLSectionExport.hxx"
39cdf0e10cSrcweir #include "XMLLineNumberingExport.hxx"
40cdf0e10cSrcweir #include "txtexppr.hxx"
41cdf0e10cSrcweir #include <xmloff/txtprmap.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir using ::rtl::OUString;
44cdf0e10cSrcweir using ::rtl::OUStringBuffer;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using namespace ::com::sun::star;
47cdf0e10cSrcweir using namespace ::com::sun::star::uno;
48cdf0e10cSrcweir using namespace ::com::sun::star::style;
49cdf0e10cSrcweir using namespace ::com::sun::star::container;
50cdf0e10cSrcweir using namespace ::com::sun::star::beans;
51cdf0e10cSrcweir using namespace ::xmloff::token;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir void XMLTextParagraphExport::exportStyleAttributes(
54cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference<
55cdf0e10cSrcweir 				::com::sun::star::style::XStyle > & rStyle )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 	OUString sName;
58cdf0e10cSrcweir 	Any aAny;
59cdf0e10cSrcweir 	Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
60cdf0e10cSrcweir 	Reference< XPropertySetInfo > xPropSetInfo(
61cdf0e10cSrcweir 			xPropSet->getPropertySetInfo());
62cdf0e10cSrcweir 	if( xPropSetInfo->hasPropertyByName( sCategory ) )
63cdf0e10cSrcweir 	{
64cdf0e10cSrcweir 		sal_Int16 nCategory = 0;
65cdf0e10cSrcweir 		xPropSet->getPropertyValue( sCategory ) >>= nCategory;
66cdf0e10cSrcweir 		enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
67cdf0e10cSrcweir 		if( -1 != nCategory )
68cdf0e10cSrcweir 		{
69cdf0e10cSrcweir 			switch( nCategory )
70cdf0e10cSrcweir 			{
71cdf0e10cSrcweir 			case ParagraphStyleCategory::TEXT:
72cdf0e10cSrcweir 				eValue = XML_TEXT;
73cdf0e10cSrcweir 				break;
74cdf0e10cSrcweir 			case ParagraphStyleCategory::CHAPTER:
75cdf0e10cSrcweir 				eValue = XML_CHAPTER;
76cdf0e10cSrcweir 				break;
77cdf0e10cSrcweir 			case ParagraphStyleCategory::LIST:
78cdf0e10cSrcweir 				eValue = XML_LIST;
79cdf0e10cSrcweir 				break;
80cdf0e10cSrcweir 			case ParagraphStyleCategory::INDEX:
81cdf0e10cSrcweir 				eValue = XML_INDEX;
82cdf0e10cSrcweir 				break;
83cdf0e10cSrcweir 			case ParagraphStyleCategory::EXTRA:
84cdf0e10cSrcweir 				eValue = XML_EXTRA;
85cdf0e10cSrcweir 				break;
86cdf0e10cSrcweir 			case ParagraphStyleCategory::HTML:
87cdf0e10cSrcweir 				eValue = XML_HTML;
88cdf0e10cSrcweir 				break;
89cdf0e10cSrcweir 			}
90cdf0e10cSrcweir 		}
91cdf0e10cSrcweir 		if( eValue != XML_TOKEN_INVALID )
92cdf0e10cSrcweir 			GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_CLASS, eValue);
93cdf0e10cSrcweir 	}
94cdf0e10cSrcweir 	if( xPropSetInfo->hasPropertyByName( sPageDescName ) )
95cdf0e10cSrcweir 	{
96cdf0e10cSrcweir 		Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
97cdf0e10cSrcweir 		if( PropertyState_DIRECT_VALUE ==
98cdf0e10cSrcweir 				xPropState->getPropertyState( sPageDescName  ) )
99cdf0e10cSrcweir 		{
100cdf0e10cSrcweir 			xPropSet->getPropertyValue( sPageDescName ) >>= sName;
101cdf0e10cSrcweir 			// fix for #i5551#  if( sName.getLength() > 0 )
102cdf0e10cSrcweir 			    GetExport().AddAttribute( XML_NAMESPACE_STYLE,
103cdf0e10cSrcweir 				    					  XML_MASTER_PAGE_NAME,
104cdf0e10cSrcweir 					    				  GetExport().EncodeStyleName( sName ) );
105cdf0e10cSrcweir 		}
106cdf0e10cSrcweir 	}
107cdf0e10cSrcweir 	//sal_Int32 nOutlineLevel = //#outline level, zhaojianwei, moved to styleexp.cxx - XMLStyleExport::exportStyle(����)
108cdf0e10cSrcweir 	//	GetExport().GetTextParagraphExport()->GetHeadingLevel( rStyle->getName() );
109cdf0e10cSrcweir 	//if( nOutlineLevel != -1 )
110cdf0e10cSrcweir 	//{
111cdf0e10cSrcweir 	//	OUStringBuffer sTmp;
112cdf0e10cSrcweir 	//				sTmp.append( static_cast<sal_Int32>(nOutlineLevel+1L) );
113cdf0e10cSrcweir 	//	GetExport().AddAttribute( XML_NAMESPACE_STYLE,
114cdf0e10cSrcweir 	//						XML_DEFAULT_OUTLINE_LEVEL,
115cdf0e10cSrcweir 	//						sTmp.makeStringAndClear() );
116cdf0e10cSrcweir 	//}
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	if( bProgress )
119cdf0e10cSrcweir 	{
120cdf0e10cSrcweir 		ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
121cdf0e10cSrcweir 			pProgress->SetValue( pProgress->GetValue()+2 );
122cdf0e10cSrcweir 	}
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir void XMLTextParagraphExport::exportNumStyles( sal_Bool bUsed )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir 	SvxXMLNumRuleExport aNumRuleExport( GetExport() );
128cdf0e10cSrcweir 	aNumRuleExport.exportStyles( bUsed, pListAutoPool, !IsBlockMode() );
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir void XMLTextParagraphExport::exportTextStyles( sal_Bool bUsed, sal_Bool bProg )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	sal_Bool bOldProg = bProgress;
134cdf0e10cSrcweir 	bProgress = bProg;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     Reference < lang::XMultiServiceFactory > xFactory (GetExport().GetModel(), UNO_QUERY);
137cdf0e10cSrcweir     if (xFactory.is())
138cdf0e10cSrcweir     {
139cdf0e10cSrcweir 		OUString sTextDefaults ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) );
140cdf0e10cSrcweir         Reference < XPropertySet > xPropSet (xFactory->createInstance ( sTextDefaults ), UNO_QUERY);
141cdf0e10cSrcweir         if (xPropSet.is())
142cdf0e10cSrcweir         {
143cdf0e10cSrcweir             exportDefaultStyle( xPropSet, GetXMLToken(XML_PARAGRAPH), GetParaPropMapper());
144cdf0e10cSrcweir 
145cdf0e10cSrcweir             exportDefaultStyle(
146cdf0e10cSrcweir                 xPropSet,
147cdf0e10cSrcweir                 GetXMLToken(XML_TABLE),
148cdf0e10cSrcweir                 new XMLTextExportPropertySetMapper(
149cdf0e10cSrcweir                     new XMLTextPropertySetMapper(
150cdf0e10cSrcweir                         TEXT_PROP_MAP_TABLE_DEFAULTS ),
151cdf0e10cSrcweir                     GetExport() ) );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir             exportDefaultStyle(
154cdf0e10cSrcweir                 xPropSet,
155cdf0e10cSrcweir                 GetXMLToken(XML_TABLE_ROW),
156cdf0e10cSrcweir                 new XMLTextExportPropertySetMapper(
157cdf0e10cSrcweir                     new XMLTextPropertySetMapper(
158cdf0e10cSrcweir                         TEXT_PROP_MAP_TABLE_ROW_DEFAULTS ),
159cdf0e10cSrcweir                     GetExport() ) );
160cdf0e10cSrcweir         }
161cdf0e10cSrcweir     }
162cdf0e10cSrcweir 	exportStyleFamily( "ParagraphStyles", GetXMLToken(XML_PARAGRAPH), GetParaPropMapper(),
163cdf0e10cSrcweir 					   bUsed, XML_STYLE_FAMILY_TEXT_PARAGRAPH, 0);
164cdf0e10cSrcweir 	exportStyleFamily( "CharacterStyles", GetXMLToken(XML_TEXT), GetTextPropMapper(),
165cdf0e10cSrcweir 					   bUsed, XML_STYLE_FAMILY_TEXT_TEXT );
166cdf0e10cSrcweir 	// get shape export to make sure the the frame family is added correctly.
167cdf0e10cSrcweir 	GetExport().GetShapeExport();
168cdf0e10cSrcweir 	exportStyleFamily( "FrameStyles", OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)), GetFramePropMapper(),
169cdf0e10cSrcweir 					   bUsed, XML_STYLE_FAMILY_TEXT_FRAME, 0);
170cdf0e10cSrcweir 	exportNumStyles( bUsed );
171cdf0e10cSrcweir 	if( !IsBlockMode() )
172cdf0e10cSrcweir 	{
173cdf0e10cSrcweir 		exportTextFootnoteConfiguration();
174cdf0e10cSrcweir 		XMLSectionExport::ExportBibliographyConfiguration(GetExport());
175cdf0e10cSrcweir 		XMLLineNumberingExport aLineNumberingExport(GetExport());
176cdf0e10cSrcweir 		aLineNumberingExport.Export();
177cdf0e10cSrcweir 	}
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	bProgress = bOldProg;
180cdf0e10cSrcweir }
181