xref: /aoo41x/main/xmloff/source/text/txtstyli.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 "XMLTextPropertySetContext.hxx"
28cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
29cdf0e10cSrcweir #include "xmloff/XMLEventsImportContext.hxx"
30cdf0e10cSrcweir #include "xmloff/attrlist.hxx"
31cdf0e10cSrcweir #include "xmloff/families.hxx"
32cdf0e10cSrcweir #include "xmloff/txtprmap.hxx"
33cdf0e10cSrcweir #include "xmloff/txtstyli.hxx"
34cdf0e10cSrcweir #include "xmloff/xmlimp.hxx"
35cdf0e10cSrcweir #include "xmloff/xmltkmap.hxx"
36cdf0e10cSrcweir #include "xmloff/xmltoken.hxx"
37cdf0e10cSrcweir #include "xmloff/xmluconv.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <com/sun/star/beans/XMultiPropertySet.hpp>
40cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
41cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp>
42cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
43cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44cdf0e10cSrcweir #include <com/sun/star/style/ParagraphStyleCategory.hpp>
45cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include <tools/debug.hxx>
48cdf0e10cSrcweir #include <tools/diagnose_ex.h>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // STL includes
51cdf0e10cSrcweir #include <algorithm>
52cdf0e10cSrcweir #include <functional>
53cdf0e10cSrcweir #include <utility>
54cdf0e10cSrcweir #include <vector>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir using ::rtl::OUString;
57cdf0e10cSrcweir using ::rtl::OUStringBuffer;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir using namespace ::std;
60cdf0e10cSrcweir using namespace ::com::sun::star;
61cdf0e10cSrcweir using namespace ::com::sun::star::uno;
62cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
63cdf0e10cSrcweir using namespace ::com::sun::star::style;
64cdf0e10cSrcweir using namespace ::com::sun::star::frame;
65cdf0e10cSrcweir using namespace ::com::sun::star::beans;
66cdf0e10cSrcweir using namespace ::com::sun::star::lang;
67cdf0e10cSrcweir using namespace ::com::sun::star::container;
68cdf0e10cSrcweir //using namespace ::com::sun::star::text;
69cdf0e10cSrcweir using namespace ::xmloff::token;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir static __FAR_DATA SvXMLEnumMapEntry aCategoryMap[] =
72cdf0e10cSrcweir {
73cdf0e10cSrcweir 	{ XML_TEXT,     ParagraphStyleCategory::TEXT },
74cdf0e10cSrcweir 	{ XML_CHAPTER,  ParagraphStyleCategory::CHAPTER },
75cdf0e10cSrcweir 	{ XML_LIST,     ParagraphStyleCategory::LIST },
76cdf0e10cSrcweir 	{ XML_INDEX,    ParagraphStyleCategory::INDEX },
77cdf0e10cSrcweir 	{ XML_EXTRA,    ParagraphStyleCategory::EXTRA },
78cdf0e10cSrcweir 	{ XML_HTML,     ParagraphStyleCategory::HTML },
79cdf0e10cSrcweir 	{ XML_TOKEN_INVALID, 0 }
80cdf0e10cSrcweir };
81cdf0e10cSrcweir 
SetAttribute(sal_uInt16 nPrefixKey,const OUString & rLocalName,const OUString & rValue)82cdf0e10cSrcweir void XMLTextStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
83cdf0e10cSrcweir 										const OUString& rLocalName,
84cdf0e10cSrcweir 										const OUString& rValue )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	if( XML_NAMESPACE_STYLE == nPrefixKey )
87cdf0e10cSrcweir 	{
88cdf0e10cSrcweir 		// TODO: use a map here
89cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_AUTO_UPDATE ) )
90cdf0e10cSrcweir 		{
91cdf0e10cSrcweir 			if( IsXMLToken( rValue, XML_TRUE ) )
92cdf0e10cSrcweir 				bAutoUpdate = sal_True;
93cdf0e10cSrcweir 		}
94cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_LIST_STYLE_NAME ) )
95cdf0e10cSrcweir 		{
96cdf0e10cSrcweir 			sListStyleName = rValue;
97cdf0e10cSrcweir             // --> OD 2006-09-21 #i69523#
98cdf0e10cSrcweir             mbListStyleSet = sal_True;
99cdf0e10cSrcweir             // <--
100cdf0e10cSrcweir 		}
101cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_MASTER_PAGE_NAME ) )
102cdf0e10cSrcweir 		{
103cdf0e10cSrcweir 			sMasterPageName = rValue;
104cdf0e10cSrcweir 			bHasMasterPageName = sal_True;
105cdf0e10cSrcweir 		}
106cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
107cdf0e10cSrcweir 		{
108cdf0e10cSrcweir 			sDataStyleName = rValue;
109cdf0e10cSrcweir 		}
110cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_CLASS ) )
111cdf0e10cSrcweir 		{
112cdf0e10cSrcweir 			sCategoryVal = rValue;
113cdf0e10cSrcweir 		}
114cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_DEFAULT_OUTLINE_LEVEL ) )
115cdf0e10cSrcweir 		{
116cdf0e10cSrcweir 			sal_Int32 nTmp;
117cdf0e10cSrcweir 			if( SvXMLUnitConverter::convertNumber( nTmp, rValue ) &&
118cdf0e10cSrcweir 			//	nTmp > 0 && nTmp < 256 )	//#outline level, removed by zhaojianwei
119cdf0e10cSrcweir 				0 <= nTmp && nTmp <= 10 )	//<-end,add by zhaojianwei
120cdf0e10cSrcweir                 nOutlineLevel = static_cast< sal_Int8 >( nTmp );
121cdf0e10cSrcweir 		}
122cdf0e10cSrcweir 		else
123cdf0e10cSrcweir 		{
124cdf0e10cSrcweir 			XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
125cdf0e10cSrcweir 		}
126cdf0e10cSrcweir 	}
127cdf0e10cSrcweir 	else
128cdf0e10cSrcweir 	{
129cdf0e10cSrcweir 		XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
130cdf0e10cSrcweir 	}
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir TYPEINIT1( XMLTextStyleContext, XMLPropStyleContext );
134cdf0e10cSrcweir 
XMLTextStyleContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<XAttributeList> & xAttrList,SvXMLStylesContext & rStyles,sal_uInt16 nFamily,sal_Bool bDefaultStyle)135cdf0e10cSrcweir XMLTextStyleContext::XMLTextStyleContext( SvXMLImport& rImport,
136cdf0e10cSrcweir 		sal_uInt16 nPrfx, const OUString& rLName,
137cdf0e10cSrcweir 		const Reference< XAttributeList > & xAttrList,
138cdf0e10cSrcweir 		SvXMLStylesContext& rStyles, sal_uInt16 nFamily,
139cdf0e10cSrcweir 		sal_Bool bDefaultStyle )
140cdf0e10cSrcweir :	XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle )
141cdf0e10cSrcweir ,	sIsAutoUpdate( RTL_CONSTASCII_USTRINGPARAM( "IsAutoUpdate" ) )
142cdf0e10cSrcweir ,	sCategory( RTL_CONSTASCII_USTRINGPARAM( "Category" ) )
143cdf0e10cSrcweir ,	sNumberingStyleName( RTL_CONSTASCII_USTRINGPARAM( "NumberingStyleName" ) )
144cdf0e10cSrcweir ,       sOutlineLevel(RTL_CONSTASCII_USTRINGPARAM( "OutlineLevel" ) )//#outline level,add by zhaojianwei
145cdf0e10cSrcweir ,	sDropCapCharStyleName( RTL_CONSTASCII_USTRINGPARAM( "DropCapCharStyleName" ) )
146cdf0e10cSrcweir ,	sPageDescName( RTL_CONSTASCII_USTRINGPARAM( "PageDescName" ) )
147cdf0e10cSrcweir //,	nOutlineLevel( 0 )	// removed by zhaojianwei
148cdf0e10cSrcweir ,	nOutlineLevel( -1 )	//<-end, add by zhaojianwei
149cdf0e10cSrcweir ,	bAutoUpdate( sal_False )
150cdf0e10cSrcweir ,	bHasMasterPageName( sal_False )
151cdf0e10cSrcweir ,	bHasCombinedCharactersLetter( sal_False )
152cdf0e10cSrcweir // --> OD 2006-09-21 #i69523#
153cdf0e10cSrcweir ,   mbListStyleSet( sal_False )
154cdf0e10cSrcweir // <--
155cdf0e10cSrcweir ,	pEventContext( NULL )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
~XMLTextStyleContext()159cdf0e10cSrcweir XMLTextStyleContext::~XMLTextStyleContext()
160cdf0e10cSrcweir {
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<XAttributeList> & xAttrList)163cdf0e10cSrcweir SvXMLImportContext *XMLTextStyleContext::CreateChildContext(
164cdf0e10cSrcweir 		sal_uInt16 nPrefix,
165cdf0e10cSrcweir 		const OUString& rLocalName,
166cdf0e10cSrcweir 		const Reference< XAttributeList > & xAttrList )
167cdf0e10cSrcweir {
168cdf0e10cSrcweir 	SvXMLImportContext *pContext = 0;
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	if( XML_NAMESPACE_STYLE == nPrefix )
171cdf0e10cSrcweir 	{
172cdf0e10cSrcweir 		sal_uInt32 nFamily = 0;
173cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
174cdf0e10cSrcweir 			nFamily = XML_TYPE_PROP_TEXT;
175cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
176cdf0e10cSrcweir 			nFamily = XML_TYPE_PROP_PARAGRAPH;
177cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_SECTION_PROPERTIES ) )
178cdf0e10cSrcweir 			nFamily = XML_TYPE_PROP_SECTION;
179cdf0e10cSrcweir         else if( IsDefaultStyle() && IsXMLToken( rLocalName, XML_TABLE_PROPERTIES ) )
180cdf0e10cSrcweir             nFamily = XML_TYPE_PROP_TABLE;
181cdf0e10cSrcweir         else if( IsDefaultStyle() && IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES ) )
182cdf0e10cSrcweir             nFamily = XML_TYPE_PROP_TABLE_ROW;
183cdf0e10cSrcweir 		if( nFamily )
184cdf0e10cSrcweir 		{
185cdf0e10cSrcweir 			UniReference < SvXMLImportPropertyMapper > xImpPrMap =
186cdf0e10cSrcweir 				GetStyles()->GetImportPropertyMapper( GetFamily() );
187cdf0e10cSrcweir 			if( xImpPrMap.is() )
188cdf0e10cSrcweir 				pContext = new XMLTextPropertySetContext( GetImport(), nPrefix,
189cdf0e10cSrcweir 														rLocalName, xAttrList,
190cdf0e10cSrcweir 														nFamily,
191cdf0e10cSrcweir 														GetProperties(),
192cdf0e10cSrcweir 														xImpPrMap,
193cdf0e10cSrcweir 														sDropCapTextStyleName );
194cdf0e10cSrcweir 		}
195cdf0e10cSrcweir 	}
196cdf0e10cSrcweir 	else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
197cdf0e10cSrcweir 			  IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
198cdf0e10cSrcweir 	{
199cdf0e10cSrcweir 		// create and remember events import context
200cdf0e10cSrcweir 		// (for delayed processing of events)
201cdf0e10cSrcweir 		pEventContext = new XMLEventsImportContext( GetImport(), nPrefix,
202cdf0e10cSrcweir 												   rLocalName);
203cdf0e10cSrcweir 		pEventContext->AddRef();
204cdf0e10cSrcweir 		pContext = pEventContext;
205cdf0e10cSrcweir 	}
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	if( !pContext )
208cdf0e10cSrcweir 		pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName,
209cdf0e10cSrcweir 														  xAttrList );
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	return pContext;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
CreateAndInsert(sal_Bool bOverwrite)214cdf0e10cSrcweir void XMLTextStyleContext::CreateAndInsert( sal_Bool bOverwrite )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir 	XMLPropStyleContext::CreateAndInsert( bOverwrite );
217cdf0e10cSrcweir 	Reference < XStyle > xStyle = GetStyle();
218cdf0e10cSrcweir 	if( !xStyle.is() || !(bOverwrite || IsNew()) )
219cdf0e10cSrcweir 		return;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 	Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
222cdf0e10cSrcweir 	Reference< XPropertySetInfo > xPropSetInfo =
223cdf0e10cSrcweir 				xPropSet->getPropertySetInfo();
224cdf0e10cSrcweir 	if( xPropSetInfo->hasPropertyByName( sIsAutoUpdate ) )
225cdf0e10cSrcweir 	{
226cdf0e10cSrcweir 		Any aAny;
227cdf0e10cSrcweir 		sal_Bool bTmp = bAutoUpdate;
228cdf0e10cSrcweir 		aAny.setValue( &bTmp, ::getBooleanCppuType() );
229cdf0e10cSrcweir 		xPropSet->setPropertyValue( sIsAutoUpdate, aAny );
230cdf0e10cSrcweir 	}
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 	sal_uInt16 nCategory = ParagraphStyleCategory::TEXT;
233cdf0e10cSrcweir 	if(  XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() &&
234cdf0e10cSrcweir 		 sCategoryVal.getLength() && xStyle->isUserDefined() &&
235cdf0e10cSrcweir 		 xPropSetInfo->hasPropertyByName( sCategory ) &&
236cdf0e10cSrcweir 	 	 SvXMLUnitConverter::convertEnum( nCategory, sCategoryVal, aCategoryMap ) )
237cdf0e10cSrcweir 	{
238cdf0e10cSrcweir 		Any aAny;
239cdf0e10cSrcweir 		aAny <<= (sal_Int16)nCategory;
240cdf0e10cSrcweir 		xPropSet->setPropertyValue( sCategory, aAny );
241cdf0e10cSrcweir 	}
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	// tell the style about it's events (if applicable)
244cdf0e10cSrcweir 	if (NULL != pEventContext)
245cdf0e10cSrcweir 	{
246cdf0e10cSrcweir 		// set event suppplier and release reference to context
247cdf0e10cSrcweir 		Reference<document::XEventsSupplier> xEventsSupplier(xStyle,UNO_QUERY);
248cdf0e10cSrcweir 		pEventContext->SetEvents(xEventsSupplier);
249cdf0e10cSrcweir 		pEventContext->ReleaseRef();
250cdf0e10cSrcweir 	}
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     // --> OD 2006-10-12 #i69629#
253cdf0e10cSrcweir     if ( nOutlineLevel > 0 )
254cdf0e10cSrcweir     {
255cdf0e10cSrcweir         GetImport().GetTextImport()->AddOutlineStyleCandidate( nOutlineLevel,
256cdf0e10cSrcweir 													  GetDisplayName() );
257cdf0e10cSrcweir     }
258cdf0e10cSrcweir     // <--
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
SetDefaults()261cdf0e10cSrcweir void XMLTextStyleContext::SetDefaults( )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir     if( ( GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ) ||
264cdf0e10cSrcweir         ( GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE ) ||
265cdf0e10cSrcweir         ( GetFamily() == XML_STYLE_FAMILY_TABLE_ROW ) )
266cdf0e10cSrcweir     {
267cdf0e10cSrcweir         Reference < XMultiServiceFactory > xFactory ( GetImport().GetModel(), UNO_QUERY);
268cdf0e10cSrcweir         if (xFactory.is())
269cdf0e10cSrcweir         {
270cdf0e10cSrcweir             Reference < XInterface > xInt = xFactory->createInstance (
271cdf0e10cSrcweir                 OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) ) );
272cdf0e10cSrcweir             Reference < XPropertySet > xProperties ( xInt, UNO_QUERY );
273cdf0e10cSrcweir             if ( xProperties.is() )
274cdf0e10cSrcweir                 FillPropertySet ( xProperties );
275cdf0e10cSrcweir         }
276cdf0e10cSrcweir     }
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
Finish(sal_Bool bOverwrite)279cdf0e10cSrcweir void XMLTextStyleContext::Finish( sal_Bool bOverwrite )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir 	XMLPropStyleContext::Finish( bOverwrite );
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	Reference < XStyle > xStyle = GetStyle();
284cdf0e10cSrcweir     // --> OD 2006-09-21 #i69523#
285cdf0e10cSrcweir     // consider set empty list style
286cdf0e10cSrcweir //    if ( !( sListStyleName.getLength() ||
287cdf0e10cSrcweir     if ( !( mbListStyleSet ||
288cdf0e10cSrcweir 			nOutlineLevel >= 0 ||	//#outline level,add by zhaojianwei
289cdf0e10cSrcweir             sDropCapTextStyleName.getLength() ||
290cdf0e10cSrcweir             bHasMasterPageName ) ||
291cdf0e10cSrcweir          !xStyle.is() ||
292cdf0e10cSrcweir          !( bOverwrite || IsNew() ) )
293cdf0e10cSrcweir 		return;
294cdf0e10cSrcweir     // <--
295cdf0e10cSrcweir 
296cdf0e10cSrcweir 	Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
297cdf0e10cSrcweir 	Reference< XPropertySetInfo > xPropSetInfo =
298cdf0e10cSrcweir 				xPropSet->getPropertySetInfo();
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	//#outline level,add by zhaojianwei
301cdf0e10cSrcweir 	if( xPropSetInfo->hasPropertyByName( sOutlineLevel ))
302cdf0e10cSrcweir 	{
303cdf0e10cSrcweir 		Any aAny;
304cdf0e10cSrcweir 		if( nOutlineLevel >= 0 )
305cdf0e10cSrcweir 		{
306cdf0e10cSrcweir 		    aAny <<= nOutlineLevel;
307cdf0e10cSrcweir 			xPropSet->setPropertyValue( sOutlineLevel, aAny );
308cdf0e10cSrcweir 		}
309cdf0e10cSrcweir 	}
310cdf0e10cSrcweir 	//<-end,zhaojianwei
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 
313cdf0e10cSrcweir     // --> OD 2006-09-21 #i69523#
314cdf0e10cSrcweir     // consider set empty list style
315cdf0e10cSrcweir //    if( sListStyleName.getLength() )
316cdf0e10cSrcweir     if ( mbListStyleSet &&
317cdf0e10cSrcweir          xPropSetInfo->hasPropertyByName( sNumberingStyleName ) )
318cdf0e10cSrcweir     {
319cdf0e10cSrcweir         // --> OD 2006-10-12 #i70223#
320cdf0e10cSrcweir         // Only for text document from version prior OOo 2.1 resp. SO 8 PU5:
321cdf0e10cSrcweir         // - Do not apply list style, if paragraph style has a default outline
322cdf0e10cSrcweir         //   level > 0 and thus, will be assigned to the corresponding list
323cdf0e10cSrcweir         //   level of the outline style.
324cdf0e10cSrcweir         bool bApplyListStyle( true );
325cdf0e10cSrcweir         if ( nOutlineLevel > 0 )
326cdf0e10cSrcweir         {
327cdf0e10cSrcweir             // --> OD 2007-12-19 #152540#
328cdf0e10cSrcweir             if ( GetImport().IsTextDocInOOoFileFormat() )
329cdf0e10cSrcweir             {
330cdf0e10cSrcweir                 bApplyListStyle = false;
331cdf0e10cSrcweir             }
332cdf0e10cSrcweir             else
333cdf0e10cSrcweir             {
334cdf0e10cSrcweir                 sal_Int32 nUPD( 0 );
335cdf0e10cSrcweir                 sal_Int32 nBuild( 0 );
336cdf0e10cSrcweir                 // --> OD 2008-03-19 #i86058#
337cdf0e10cSrcweir                 // check explicitly on certain versions
338cdf0e10cSrcweir                 if ( GetImport().getBuildIds( nUPD, nBuild ) &&
339cdf0e10cSrcweir                      ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
340cdf0e10cSrcweir                        ( nUPD == 680 && nBuild <= 9073 ) ) ) // OOo 2.0 - OOo 2.0.4
341cdf0e10cSrcweir                 {
342cdf0e10cSrcweir                     bApplyListStyle = false;
343cdf0e10cSrcweir                 }
344cdf0e10cSrcweir                 // <--
345cdf0e10cSrcweir             }
346cdf0e10cSrcweir             // <--
347cdf0e10cSrcweir         }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir         if ( bApplyListStyle )
350cdf0e10cSrcweir         {
351cdf0e10cSrcweir             if ( !sListStyleName.getLength() )
352cdf0e10cSrcweir             {
353cdf0e10cSrcweir                 Any aAny;
354cdf0e10cSrcweir                 aAny <<= sListStyleName /* empty string */;
355cdf0e10cSrcweir                 xPropSet->setPropertyValue( sNumberingStyleName, aAny );
356cdf0e10cSrcweir             }
357cdf0e10cSrcweir             else
358cdf0e10cSrcweir             {
359cdf0e10cSrcweir                 // change list style name to display name
360cdf0e10cSrcweir                 OUString sDisplayListStyleName(
361cdf0e10cSrcweir                     GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_LIST,
362cdf0e10cSrcweir                                                   sListStyleName ) );
363cdf0e10cSrcweir                 // The families container must exist
364cdf0e10cSrcweir                 const Reference < XNameContainer >& rNumStyles =
365cdf0e10cSrcweir                     GetImport().GetTextImport()->GetNumberingStyles();
366cdf0e10cSrcweir     //            if( rNumStyles.is() && rNumStyles->hasByName( sDisplayListStyleName ) &&
367cdf0e10cSrcweir     //                xPropSetInfo->hasPropertyByName( sNumberingStyleName ) )
368cdf0e10cSrcweir                 if ( rNumStyles.is() &&
369cdf0e10cSrcweir                      rNumStyles->hasByName( sDisplayListStyleName ) )
370cdf0e10cSrcweir                 {
371cdf0e10cSrcweir                     Any aAny;
372cdf0e10cSrcweir                     aAny <<= sDisplayListStyleName;
373cdf0e10cSrcweir                     xPropSet->setPropertyValue( sNumberingStyleName, aAny );
374cdf0e10cSrcweir                 }
375cdf0e10cSrcweir             }
376cdf0e10cSrcweir         }
377cdf0e10cSrcweir         // <--
378cdf0e10cSrcweir     }
379cdf0e10cSrcweir     // <--
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	if( sDropCapTextStyleName.getLength() )
382cdf0e10cSrcweir 	{
383cdf0e10cSrcweir 		// change list style name to display name
384cdf0e10cSrcweir 		OUString sDisplayDropCapTextStyleName(
385cdf0e10cSrcweir 			GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_TEXT,
386cdf0e10cSrcweir 										  sDropCapTextStyleName ) );
387cdf0e10cSrcweir 		// The families cointaner must exist
388cdf0e10cSrcweir 		const Reference < XNameContainer >& rTextStyles =
389cdf0e10cSrcweir 			GetImport().GetTextImport()->GetTextStyles();
390cdf0e10cSrcweir 		if( rTextStyles.is() &&
391cdf0e10cSrcweir 			rTextStyles->hasByName( sDisplayDropCapTextStyleName ) &&
392cdf0e10cSrcweir 			xPropSetInfo->hasPropertyByName( sDropCapCharStyleName ) )
393cdf0e10cSrcweir 		{
394cdf0e10cSrcweir 			Any aAny;
395cdf0e10cSrcweir 			aAny <<= sDisplayDropCapTextStyleName;
396cdf0e10cSrcweir 			xPropSet->setPropertyValue( sDropCapCharStyleName, aAny );
397cdf0e10cSrcweir 		}
398cdf0e10cSrcweir 	}
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 	if( bHasMasterPageName )
401cdf0e10cSrcweir 	{
402cdf0e10cSrcweir 		OUString sDisplayName(
403cdf0e10cSrcweir 			GetImport().GetStyleDisplayName(
404cdf0e10cSrcweir 							XML_STYLE_FAMILY_MASTER_PAGE, sMasterPageName ) );
405cdf0e10cSrcweir 		// The families cointaner must exist
406cdf0e10cSrcweir 		const Reference < XNameContainer >& rPageStyles =
407cdf0e10cSrcweir 			GetImport().GetTextImport()->GetPageStyles();
408cdf0e10cSrcweir 		if( ( !sDisplayName.getLength() ||
409cdf0e10cSrcweir 			  (rPageStyles.is() &&
410cdf0e10cSrcweir 			   rPageStyles->hasByName( sDisplayName )) ) &&
411cdf0e10cSrcweir 			xPropSetInfo->hasPropertyByName( sPageDescName ) )
412cdf0e10cSrcweir 		{
413cdf0e10cSrcweir 			Any aAny;
414cdf0e10cSrcweir 			aAny <<= sDisplayName;
415cdf0e10cSrcweir 			xPropSet->setPropertyValue( sPageDescName, aAny );
416cdf0e10cSrcweir 		}
417cdf0e10cSrcweir 	}
418cdf0e10cSrcweir }
419cdf0e10cSrcweir 
FillPropertySet(const Reference<XPropertySet> & rPropSet)420cdf0e10cSrcweir void XMLTextStyleContext::FillPropertySet(
421cdf0e10cSrcweir 	const Reference<XPropertySet > & rPropSet )
422cdf0e10cSrcweir {
423cdf0e10cSrcweir 	// imitate the FillPropertySet of the super class, so we get a chance to
424cdf0e10cSrcweir 	// catch the combined characters attribute
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	// imitate XMLPropStyleContext::FillPropertySet(...)
427cdf0e10cSrcweir 	UniReference < SvXMLImportPropertyMapper > xImpPrMap =
428cdf0e10cSrcweir 		((SvXMLStylesContext *)GetStyles())->GetImportPropertyMapper(GetFamily());
429cdf0e10cSrcweir 	DBG_ASSERT( xImpPrMap.is(), "Where is the import prop mapper?" );
430cdf0e10cSrcweir 	if( xImpPrMap.is() )
431cdf0e10cSrcweir 	{
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 		// imitate SvXMLImportPropertyMapper::FillPropertySet(...)
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 		// The reason for this is that we have no other way to
436cdf0e10cSrcweir 		// efficiently intercept the value of combined characters. To
437cdf0e10cSrcweir 		// get that value, we could iterate through the map once more,
438cdf0e10cSrcweir 		// but instead we chose to insert the code into this
439cdf0e10cSrcweir 		// iteration. I haven't been able to come up with a much more
440cdf0e10cSrcweir 		// intelligent solution.
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 
443cdf0e10cSrcweir         struct _ContextID_Index_Pair aContextIDs[] =
444cdf0e10cSrcweir         {
445cdf0e10cSrcweir             { CTF_COMBINED_CHARACTERS_FIELD, -1 },
446cdf0e10cSrcweir             { CTF_KEEP_TOGETHER, -1 },
447cdf0e10cSrcweir             { CTF_BORDER_MODEL, -1 },
448cdf0e10cSrcweir             { CTF_TEXT_DISPLAY, -1 },
449cdf0e10cSrcweir             { CTF_FONTFAMILYNAME, -1 },
450cdf0e10cSrcweir             { CTF_FONTFAMILYNAME_CJK, -1 },
451cdf0e10cSrcweir             { CTF_FONTFAMILYNAME_CTL, -1 },
452cdf0e10cSrcweir             { -1, -1 }
453cdf0e10cSrcweir         };
454cdf0e10cSrcweir 
455cdf0e10cSrcweir         // get property set info
456cdf0e10cSrcweir         Reference< XPropertySetInfo > xInfo( rPropSet->getPropertySetInfo(), UNO_SET_THROW );
457cdf0e10cSrcweir 
458cdf0e10cSrcweir         bool bAutomatic = false;
459cdf0e10cSrcweir         if( ((SvXMLStylesContext *)GetStyles())->IsAutomaticStyle() &&
460cdf0e10cSrcweir             ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT || GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ) )
461cdf0e10cSrcweir         {
462cdf0e10cSrcweir             bAutomatic = true;
463cdf0e10cSrcweir             if( GetAutoName().getLength() )
464cdf0e10cSrcweir             {
465cdf0e10cSrcweir                 OUString sAutoProp = ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT ) ?
466cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM("CharAutoStyleName") ):
467cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM("ParaAutoStyleName") );
468cdf0e10cSrcweir                 try
469cdf0e10cSrcweir                 {
470cdf0e10cSrcweir                     if ( xInfo->hasPropertyByName( sAutoProp ) )
471cdf0e10cSrcweir                         rPropSet->setPropertyValue( sAutoProp, makeAny(GetAutoName()) );
472cdf0e10cSrcweir                     else
473cdf0e10cSrcweir                         bAutomatic = false;
474cdf0e10cSrcweir                 }
475cdf0e10cSrcweir                 catch( const RuntimeException& ) { throw; }
476cdf0e10cSrcweir                 catch( const Exception& )
477cdf0e10cSrcweir                 {
478cdf0e10cSrcweir                     DBG_UNHANDLED_EXCEPTION();
479cdf0e10cSrcweir                     bAutomatic = false;
480cdf0e10cSrcweir                 }
481cdf0e10cSrcweir             }
482cdf0e10cSrcweir         }
483cdf0e10cSrcweir         if( bAutomatic )
484cdf0e10cSrcweir             xImpPrMap->CheckSpecialContext( GetProperties(), rPropSet, aContextIDs );
485cdf0e10cSrcweir         else
486cdf0e10cSrcweir             xImpPrMap->FillPropertySet( GetProperties(), rPropSet, aContextIDs );
487cdf0e10cSrcweir 
488cdf0e10cSrcweir         // have we found a combined characters
489cdf0e10cSrcweir         sal_Int32 nIndex = aContextIDs[0].nIndex;
490cdf0e10cSrcweir         if ( nIndex != -1 )
491cdf0e10cSrcweir         {
492cdf0e10cSrcweir             Any& rAny = GetProperties()[nIndex].maValue;
493cdf0e10cSrcweir             sal_Bool bVal = *(sal_Bool*)rAny.getValue();
494cdf0e10cSrcweir             bHasCombinedCharactersLetter = bVal;
495cdf0e10cSrcweir         }
496cdf0e10cSrcweir 
497cdf0e10cSrcweir         // keep-together: the application default is different from
498cdf0e10cSrcweir         // the file format default. Hence, if we always set this
499cdf0e10cSrcweir         // value; if we didn't find one, we'll set to false, the file
500cdf0e10cSrcweir         // format default.
501cdf0e10cSrcweir         // border-model: same
502cdf0e10cSrcweir         if( IsDefaultStyle() && GetFamily() == XML_STYLE_FAMILY_TABLE_ROW )
503cdf0e10cSrcweir         {
504cdf0e10cSrcweir             OUString sIsSplitAllowed =
505cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSplitAllowed" ) );
506cdf0e10cSrcweir             DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sIsSplitAllowed ),
507cdf0e10cSrcweir                         "property missing?" );
508cdf0e10cSrcweir             rPropSet->setPropertyValue( sIsSplitAllowed,
509cdf0e10cSrcweir                 (aContextIDs[1].nIndex == -1)
510cdf0e10cSrcweir                 ? makeAny( false )
511cdf0e10cSrcweir                 : GetProperties()[aContextIDs[1].nIndex].maValue );
512cdf0e10cSrcweir         }
513cdf0e10cSrcweir 
514cdf0e10cSrcweir         if( IsDefaultStyle() && GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE )
515cdf0e10cSrcweir         {
516cdf0e10cSrcweir             OUString sCollapsingBorders(
517cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM( "CollapsingBorders" ) ) );
518cdf0e10cSrcweir             DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sCollapsingBorders ),
519cdf0e10cSrcweir                         "property missing?" );
520cdf0e10cSrcweir             rPropSet->setPropertyValue( sCollapsingBorders,
521cdf0e10cSrcweir                 (aContextIDs[2].nIndex == -1)
522cdf0e10cSrcweir                 ? makeAny( false )
523cdf0e10cSrcweir                 : GetProperties()[aContextIDs[2].nIndex].maValue );
524cdf0e10cSrcweir         }
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 
527cdf0e10cSrcweir         // check for StarBats and StarMath fonts
528cdf0e10cSrcweir 
529cdf0e10cSrcweir         // iterate over aContextIDs entries 3..6
530cdf0e10cSrcweir         for ( sal_Int32 i = 3; i < 7; i++ )
531cdf0e10cSrcweir         {
532cdf0e10cSrcweir             nIndex = aContextIDs[i].nIndex;
533cdf0e10cSrcweir             if ( nIndex != -1 )
534cdf0e10cSrcweir             {
535cdf0e10cSrcweir                 // Found!
536cdf0e10cSrcweir                 struct XMLPropertyState& rState = GetProperties()[nIndex];
537cdf0e10cSrcweir                 Any rAny = rState.maValue;
538cdf0e10cSrcweir                 sal_Int32 nMapperIndex = rState.mnIndex;
539cdf0e10cSrcweir 
540cdf0e10cSrcweir                 // Now check for font name in rState and set corrected value,
541cdf0e10cSrcweir                 // if necessary.
542cdf0e10cSrcweir                 OUString sFontName;
543cdf0e10cSrcweir                 rAny >>= sFontName;
544cdf0e10cSrcweir                 if ( sFontName.getLength() > 0 )
545cdf0e10cSrcweir                 {
546cdf0e10cSrcweir 					OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM("StarBats" ) );
547cdf0e10cSrcweir 					OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM("StarMath" ) );
548cdf0e10cSrcweir                     if ( sFontName.equalsIgnoreAsciiCase( sStarBats ) ||
549cdf0e10cSrcweir                          sFontName.equalsIgnoreAsciiCase( sStarMath ) )
550cdf0e10cSrcweir                     {
551cdf0e10cSrcweir                         // construct new value
552cdf0e10cSrcweir                         sFontName = OUString(
553cdf0e10cSrcweir                             RTL_CONSTASCII_USTRINGPARAM("StarSymbol") );
554cdf0e10cSrcweir                         Any aAny( rAny );
555cdf0e10cSrcweir                         aAny <<= sFontName;
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 						// get property set mapper
558cdf0e10cSrcweir 						UniReference<XMLPropertySetMapper> rPropMapper =
559cdf0e10cSrcweir 							xImpPrMap->getPropertySetMapper();
560cdf0e10cSrcweir 
561cdf0e10cSrcweir                         // set property
562cdf0e10cSrcweir                         OUString rPropertyName(
563cdf0e10cSrcweir                             rPropMapper->GetEntryAPIName(nMapperIndex) );
564cdf0e10cSrcweir                         if ( xInfo->hasPropertyByName( rPropertyName ) )
565cdf0e10cSrcweir                         {
566cdf0e10cSrcweir                             rPropSet->setPropertyValue( rPropertyName, aAny );
567cdf0e10cSrcweir                         }
568cdf0e10cSrcweir                     }
569cdf0e10cSrcweir                     // else: "normal" style name -> no correction is necessary
570cdf0e10cSrcweir                 }
571cdf0e10cSrcweir                 // else: no style name found -> illegal value -> ignore
572cdf0e10cSrcweir             }
573cdf0e10cSrcweir         }
574cdf0e10cSrcweir 	}
575cdf0e10cSrcweir }
576