1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 
21 #include "XMLTextPropertySetContext.hxx"
22 #include <xmloff/xmlnmspe.hxx>
23 #include <xmloff/XMLEventsImportContext.hxx>
24 #include <xmloff/families.hxx>
25 #include <xmloff/txtprmap.hxx>
26 #include <xmloff/txtstyli.hxx>
27 #include <xmloff/xmlimp.hxx>
28 #include <xmloff/xmltoken.hxx>
29 #include <xmloff/xmluconv.hxx>
30 #include <xmloff/maptype.hxx>
31 #include <xmloff/xmlimppr.hxx>
32 #include <xmloff/xmlement.hxx>
33 
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/container/XNameContainer.hpp>
36 #include <com/sun/star/document/XEventsSupplier.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/style/ParagraphStyleCategory.hpp>
39 #include <com/sun/star/style/XStyle.hpp>
40 
41 #include <o3tl/any.hxx>
42 
43 #include <sax/tools/converter.hxx>
44 
45 #include <tools/debug.hxx>
46 #include <tools/diagnose_ex.h>
47 #include <sal/log.hxx>
48 
49 #include <vector>
50 
51 #include <xmlsdtypes.hxx>
52 #include <xmloff/xmlerror.hxx>
53 
54 
55 using namespace ::std;
56 using namespace ::com::sun::star;
57 using namespace ::com::sun::star::uno;
58 using namespace ::com::sun::star::xml::sax;
59 using namespace ::com::sun::star::style;
60 using namespace ::com::sun::star::beans;
61 using namespace ::com::sun::star::lang;
62 using namespace ::com::sun::star::container;
63 using namespace ::xmloff::token;
64 
65 static const SvXMLEnumMapEntry<sal_uInt16> aCategoryMap[] =
66 {
67     { XML_TEXT,     ParagraphStyleCategory::TEXT },
68     { XML_CHAPTER,  ParagraphStyleCategory::CHAPTER },
69     { XML_LIST,     ParagraphStyleCategory::LIST },
70     { XML_INDEX,    ParagraphStyleCategory::INDEX },
71     { XML_EXTRA,    ParagraphStyleCategory::EXTRA },
72     { XML_HTML,     ParagraphStyleCategory::HTML },
73     { XML_TOKEN_INVALID, 0 }
74 };
75 
SetAttribute(sal_uInt16 nPrefixKey,const OUString & rLocalName,const OUString & rValue)76 void XMLTextStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
77                                         const OUString& rLocalName,
78                                         const OUString& rValue )
79 {
80     if( XML_NAMESPACE_STYLE == nPrefixKey )
81     {
82         // TODO: use a map here
83         if( IsXMLToken( rLocalName, XML_AUTO_UPDATE ) )
84         {
85             if( IsXMLToken( rValue, XML_TRUE ) )
86                 m_isAutoUpdate = true;
87         }
88         else if( IsXMLToken( rLocalName, XML_LIST_STYLE_NAME ) )
89         {
90             m_sListStyleName = rValue;
91             // Inherited paragraph style lost information about unset numbering (#i69523#)
92             m_bListStyleSet = true;
93         }
94         else if( IsXMLToken( rLocalName, XML_MASTER_PAGE_NAME ) )
95         {
96             m_sMasterPageName = rValue;
97             m_bHasMasterPageName = true;
98         }
99         else if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
100         {
101             m_sDataStyleName = rValue;
102         }
103         else if( IsXMLToken( rLocalName, XML_CLASS ) )
104         {
105             m_sCategoryVal = rValue;
106         }
107         else if( IsXMLToken( rLocalName, XML_DEFAULT_OUTLINE_LEVEL ) )
108         {
109             sal_Int32 nTmp;
110             if (::sax::Converter::convertNumber( nTmp, rValue ) &&
111                 0 <= nTmp && nTmp <= 10 )
112             {
113                 m_nOutlineLevel = static_cast<sal_Int8>(nTmp);
114             }
115         }
116         else
117         {
118             XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
119         }
120     }
121     else
122     {
123         XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
124     }
125 }
126 
127 
XMLTextStyleContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<XAttributeList> & xAttrList,SvXMLStylesContext & rStyles,sal_uInt16 nFamily,bool bDefaultStyle)128 XMLTextStyleContext::XMLTextStyleContext( SvXMLImport& rImport,
129         sal_uInt16 nPrfx, const OUString& rLName,
130         const Reference< XAttributeList > & xAttrList,
131         SvXMLStylesContext& rStyles, sal_uInt16 nFamily,
132         bool bDefaultStyle )
133 :   XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle )
134 ,   m_nOutlineLevel( -1 )
135 ,   m_isAutoUpdate( false )
136 ,   m_bHasMasterPageName( false )
137 ,   m_bHasCombinedCharactersLetter( false )
138 // Inherited paragraph style lost information about unset numbering (#i69523#)
139 ,   m_bListStyleSet( false )
140 {
141 }
142 
~XMLTextStyleContext()143 XMLTextStyleContext::~XMLTextStyleContext()
144 {}
145 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<XAttributeList> & xAttrList)146 SvXMLImportContextRef XMLTextStyleContext::CreateChildContext(
147         sal_uInt16 nPrefix,
148         const OUString& rLocalName,
149         const Reference< XAttributeList > & xAttrList )
150 {
151     SvXMLImportContextRef xContext;
152 
153     if( XML_NAMESPACE_STYLE == nPrefix )
154     {
155         sal_uInt32 nFamily = 0;
156         if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
157             nFamily = XML_TYPE_PROP_TEXT;
158         else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
159             nFamily = XML_TYPE_PROP_PARAGRAPH;
160         else if( IsXMLToken( rLocalName, XML_SECTION_PROPERTIES ) )
161             nFamily = XML_TYPE_PROP_SECTION;
162         else if( IsDefaultStyle() && IsXMLToken( rLocalName, XML_TABLE_PROPERTIES ) )
163             nFamily = XML_TYPE_PROP_TABLE;
164         else if( IsDefaultStyle() && IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES ) )
165             nFamily = XML_TYPE_PROP_TABLE_ROW;
166         if( nFamily )
167         {
168             rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap =
169                 GetStyles()->GetImportPropertyMapper( GetFamily() );
170             if( xImpPrMap.is() )
171                 xContext = new XMLTextPropertySetContext( GetImport(), nPrefix,
172                                                         rLocalName, xAttrList,
173                                                         nFamily,
174                                                         GetProperties(),
175                                                         xImpPrMap,
176                                                         m_sDropCapTextStyleName);
177         }
178     }
179     else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
180               IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
181     {
182         // create and remember events import context
183         // (for delayed processing of events)
184         m_xEventContext.set(new XMLEventsImportContext( GetImport(), nPrefix,
185                                                    rLocalName));
186         xContext = m_xEventContext.get();
187     }
188 
189     if (!xContext)
190         xContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName,
191                                                           xAttrList );
192 
193     return xContext;
194 }
195 
CreateAndInsert(bool bOverwrite)196 void XMLTextStyleContext::CreateAndInsert( bool bOverwrite )
197 {
198     XMLPropStyleContext::CreateAndInsert( bOverwrite );
199     Reference < XStyle > xStyle = GetStyle();
200     if( !xStyle.is() || !(bOverwrite || IsNew()) )
201         return;
202 
203     Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
204     Reference< XPropertySetInfo > xPropSetInfo =
205                 xPropSet->getPropertySetInfo();
206 
207     OUString const sIsAutoUpdate("IsAutoUpdate");
208     if( xPropSetInfo->hasPropertyByName( sIsAutoUpdate ) )
209     {
210         xPropSet->setPropertyValue( sIsAutoUpdate, Any(m_isAutoUpdate) );
211     }
212 
213     sal_uInt16 nCategory = ParagraphStyleCategory::TEXT;
214     if(  XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() &&
215          !m_sCategoryVal.isEmpty() && xStyle->isUserDefined() &&
216          xPropSetInfo->hasPropertyByName("Category") &&
217         SvXMLUnitConverter::convertEnum( nCategory, m_sCategoryVal, aCategoryMap))
218     {
219         xPropSet->setPropertyValue("Category", Any(static_cast<sal_Int16>(nCategory)));
220     }
221 
222     // tell the style about it's events (if applicable)
223     if (m_xEventContext.is())
224     {
225         // pass events into event supplier
226         Reference<document::XEventsSupplier> xEventsSupplier(xStyle,UNO_QUERY);
227         m_xEventContext->SetEvents(xEventsSupplier);
228         m_xEventContext.clear();
229     }
230 
231     // XML import: reconstrution of assignment of paragraph style to outline levels (#i69629#)
232     if (m_nOutlineLevel > 0)
233     {
234         GetImport().GetTextImport()->AddOutlineStyleCandidate(m_nOutlineLevel,
235                                                       GetDisplayName() );
236     }
237 }
238 
SetDefaults()239 void XMLTextStyleContext::SetDefaults( )
240 {
241     if( ( GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ) ||
242         ( GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE ) ||
243         ( GetFamily() == XML_STYLE_FAMILY_TABLE_ROW ) )
244     {
245         Reference < XMultiServiceFactory > xFactory ( GetImport().GetModel(), UNO_QUERY);
246         if (xFactory.is())
247         {
248             Reference < XInterface > xInt = xFactory->createInstance( "com.sun.star.text.Defaults" );
249             Reference < XPropertySet > xProperties ( xInt, UNO_QUERY );
250             if ( xProperties.is() )
251                 FillPropertySet ( xProperties );
252         }
253     }
254 }
255 
Finish(bool bOverwrite)256 void XMLTextStyleContext::Finish( bool bOverwrite )
257 {
258     XMLPropStyleContext::Finish( bOverwrite );
259 
260     Reference < XStyle > xStyle = GetStyle();
261     // Consider set empty list style (#i69523#)
262     if ( !( m_bListStyleSet ||
263             m_nOutlineLevel >= 0 ||
264             !m_sDropCapTextStyleName.isEmpty() ||
265             m_bHasMasterPageName ) ||
266          !xStyle.is() ||
267          !( bOverwrite || IsNew() ) )
268         return;
269 
270     Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
271     Reference< XPropertySetInfo > xPropSetInfo =
272                 xPropSet->getPropertySetInfo();
273 
274     OUString const sOutlineLevel("OutlineLevel");
275     if( xPropSetInfo->hasPropertyByName( sOutlineLevel ))
276     {
277         if (m_nOutlineLevel >= 0)
278         {
279             xPropSet->setPropertyValue( sOutlineLevel, Any(m_nOutlineLevel) );
280         }
281     }
282 
283     // Consider set empty list style (#i69523#)
284     OUString const sNumberingStyleName("NumberingStyleName");
285     if (m_bListStyleSet &&
286          xPropSetInfo->hasPropertyByName( sNumberingStyleName ) )
287     {
288         /* Only for text document from version prior OOo 2.1 resp. SO 8 PU5:
289            - Do not apply list style, if paragraph style has a default outline
290              level > 0 and thus, will be assigned to the corresponding list
291              level of the outline style. (#i70223#)
292         */
293         bool bApplyListStyle( true );
294         if (m_nOutlineLevel > 0)
295         {
296             if ( GetImport().IsTextDocInOOoFileFormat() )
297             {
298                 bApplyListStyle = false;
299             }
300             else
301             {
302                 sal_Int32 nUPD( 0 );
303                 sal_Int32 nBuild( 0 );
304                 // Check explicitly on certain versions (#i86058#)
305                 if ( GetImport().getBuildIds( nUPD, nBuild ) &&
306                      ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
307                        ( nUPD == 680 && nBuild <= 9073 ) ) ) // OOo 2.0 - OOo 2.0.4
308                 {
309                     bApplyListStyle = false;
310                 }
311             }
312         }
313 
314         if ( bApplyListStyle )
315         {
316             if (m_sListStyleName.isEmpty())
317             {
318                 xPropSet->setPropertyValue(sNumberingStyleName, Any(m_sListStyleName)); /* empty string */
319             }
320             else
321             {
322                 // change list style name to display name
323                 OUString sDisplayListStyleName(
324                     GetImport().GetStyleDisplayName(XML_STYLE_FAMILY_TEXT_LIST,
325                                                   m_sListStyleName));
326                 // The families container must exist
327                 const Reference < XNameContainer >& rNumStyles =
328                     GetImport().GetTextImport()->GetNumberingStyles();
329     //            if( rNumStyles.is() && rNumStyles->hasByName( sDisplayListStyleName ) &&
330     //                xPropSetInfo->hasPropertyByName( sNumberingStyleName ) )
331                 if ( rNumStyles.is() &&
332                      rNumStyles->hasByName( sDisplayListStyleName ) )
333                 {
334                     xPropSet->setPropertyValue( sNumberingStyleName, Any(sDisplayListStyleName) );
335                 }
336             }
337         }
338     }
339 
340     if (!m_sDropCapTextStyleName.isEmpty())
341     {
342         // change list style name to display name
343         OUString sDisplayDropCapTextStyleName(
344             GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_TEXT,
345                                           m_sDropCapTextStyleName));
346         // The families container must exist
347         const Reference < XNameContainer >& rTextStyles =
348             GetImport().GetTextImport()->GetTextStyles();
349         if( rTextStyles.is() &&
350             rTextStyles->hasByName( sDisplayDropCapTextStyleName ) &&
351             xPropSetInfo->hasPropertyByName("DropCapCharStyleName"))
352         {
353             xPropSet->setPropertyValue("DropCapCharStyleName", Any(sDisplayDropCapTextStyleName));
354         }
355     }
356 
357     if (m_bHasMasterPageName)
358     {
359         OUString sDisplayName(
360             GetImport().GetStyleDisplayName(
361                             XML_STYLE_FAMILY_MASTER_PAGE, m_sMasterPageName));
362         // The families container must exist
363         const Reference < XNameContainer >& rPageStyles =
364             GetImport().GetTextImport()->GetPageStyles();
365 
366         OUString const sPageDescName("PageDescName");
367         if( ( sDisplayName.isEmpty() ||
368               (rPageStyles.is() &&
369                rPageStyles->hasByName( sDisplayName )) ) &&
370             xPropSetInfo->hasPropertyByName( sPageDescName ) )
371         {
372             xPropSet->setPropertyValue( sPageDescName, Any(sDisplayName) );
373         }
374     }
375 }
376 
FillPropertySet(const Reference<XPropertySet> & rPropSet)377 void XMLTextStyleContext::FillPropertySet(
378     const Reference<XPropertySet > & rPropSet )
379 {
380     // imitate the FillPropertySet of the super class, so we get a chance to
381     // catch the combined characters attribute
382 
383     // imitate XMLPropStyleContext::FillPropertySet(...)
384     SvXMLStylesContext* pSvXMLStylesContext = GetStyles();
385     rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap = pSvXMLStylesContext->GetImportPropertyMapper(GetFamily());
386     DBG_ASSERT(xImpPrMap.is(),"Where is the import prop mapper?");
387 
388     if(!xImpPrMap.is())
389         return;
390 
391     // imitate SvXMLImportPropertyMapper::FillPropertySet(...)
392     // The reason for this is that we have no other way to
393     // efficiently intercept the value of combined characters. To
394     // get that value, we could iterate through the map once more,
395     // but instead we chose to insert the code into this
396     // iteration. I haven't been able to come up with a much more
397     // intelligent solution.
398     struct ContextID_Index_Pair aContextIDs[] =
399     {
400         { CTF_COMBINED_CHARACTERS_FIELD, -1 },
401         { CTF_KEEP_TOGETHER, -1 },
402         { CTF_BORDER_MODEL, -1 },
403         { CTF_TEXT_DISPLAY, -1 },
404         { CTF_FONTFAMILYNAME, -1 },
405         { CTF_FONTFAMILYNAME_CJK, -1 },
406         { CTF_FONTFAMILYNAME_CTL, -1 },
407 
408         //UUU need special handling for DrawingLayer FillStyle names
409         { CTF_FILLGRADIENTNAME, -1 },
410         { CTF_FILLTRANSNAME, -1 },
411         { CTF_FILLHATCHNAME, -1 },
412         { CTF_FILLBITMAPNAME, -1 },
413 
414         { -1, -1 }
415     };
416 
417     // the style families associated with the same index modulo 4
418     static const sal_uInt16 aFamilies[] =
419     {
420         XML_STYLE_FAMILY_SD_GRADIENT_ID,
421         XML_STYLE_FAMILY_SD_GRADIENT_ID,
422         XML_STYLE_FAMILY_SD_HATCH_ID,
423         XML_STYLE_FAMILY_SD_FILL_IMAGE_ID
424     };
425 
426     // get property set info
427     Reference< XPropertySetInfo > xInfo;
428     rtl::Reference< XMLPropertySetMapper > rPropMapper;
429     bool bAutomatic = false;
430 
431     if(pSvXMLStylesContext->IsAutomaticStyle() &&
432         (XML_STYLE_FAMILY_TEXT_TEXT == GetFamily() || XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily()))
433     {
434         bAutomatic = true;
435 
436         if( !GetAutoName().isEmpty() )
437         {
438             OUString sAutoProp = ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT ) ?
439                 OUString( "CharAutoStyleName" ):
440                 OUString( "ParaAutoStyleName" );
441 
442             try
443             {
444                 if(!xInfo.is())
445                 {
446                     xInfo = rPropSet->getPropertySetInfo();
447                 }
448 
449                 if ( xInfo->hasPropertyByName( sAutoProp ) )
450                 {
451                     rPropSet->setPropertyValue( sAutoProp, makeAny(GetAutoName()) );
452                 }
453                 else
454                 {
455                     bAutomatic = false;
456                 }
457             }
458             catch( const RuntimeException& ) { throw; }
459             catch( const Exception& )
460             {
461                 DBG_UNHANDLED_EXCEPTION("xmloff.text");
462                 bAutomatic = false;
463             }
464         }
465     }
466 
467     if( bAutomatic )
468     {
469         xImpPrMap->CheckSpecialContext( GetProperties(), rPropSet, aContextIDs );
470     }
471     else
472     {
473         xImpPrMap->FillPropertySet( GetProperties(), rPropSet, aContextIDs );
474     }
475 
476     sal_Int32 nIndex = aContextIDs[0].nIndex;
477 
478     // have we found a combined characters
479     if ( nIndex != -1 )
480     {
481         Any& rAny = GetProperties()[nIndex].maValue;
482         bool bVal = *o3tl::doAccess<bool>(rAny);
483         m_bHasCombinedCharactersLetter = bVal;
484     }
485 
486     // keep-together: the application default is different from
487     // the file format default. Hence, if we always set this
488     // value; if we didn't find one, we'll set to false, the file
489     // format default.
490     // border-model: same
491     if(IsDefaultStyle() && XML_STYLE_FAMILY_TABLE_ROW == GetFamily())
492     {
493         OUString sIsSplitAllowed("IsSplitAllowed");
494         SAL_WARN_IF( !rPropSet->getPropertySetInfo()->hasPropertyByName( sIsSplitAllowed ), "xmloff", "property missing?" );
495         rPropSet->setPropertyValue(
496             sIsSplitAllowed,
497             (aContextIDs[1].nIndex == -1) ? makeAny( false ) : GetProperties()[aContextIDs[1].nIndex].maValue );
498     }
499 
500     if(IsDefaultStyle() && XML_STYLE_FAMILY_TABLE_TABLE == GetFamily())
501     {
502         OUString sCollapsingBorders("CollapsingBorders");
503         SAL_WARN_IF( !rPropSet->getPropertySetInfo()->hasPropertyByName( sCollapsingBorders ), "xmloff", "property missing?" );
504         rPropSet->setPropertyValue(
505             sCollapsingBorders,
506             (aContextIDs[2].nIndex == -1)
507             ? makeAny( false )
508             : GetProperties()[aContextIDs[2].nIndex].maValue );
509     }
510 
511 
512     // iterate over aContextIDs entries, start with 3, prev ones are already used above
513     for(sal_uInt16 i(3); aContextIDs[i].nContextID != -1; i++)
514     {
515         nIndex = aContextIDs[i].nIndex;
516 
517         if ( nIndex != -1 )
518         {
519             // Found!
520             struct XMLPropertyState& rState = GetProperties()[nIndex];
521 
522             switch(aContextIDs[i].nContextID)
523             {
524                 case CTF_FILLGRADIENTNAME:
525                 case CTF_FILLTRANSNAME:
526                 case CTF_FILLHATCHNAME:
527                 case CTF_FILLBITMAPNAME:
528                 {
529                     // DrawingLayer FillStyle name needs to be mapped to DisplayName
530                     OUString sStyleName;
531                     rState.maValue >>= sStyleName;
532 
533                     // translate the used name from ODF intern to the name used in the Model
534                     sStyleName = GetImport().GetStyleDisplayName(aFamilies[i - 7], sStyleName);
535 
536                     if(bAutomatic)
537                     {
538                         // in this case the rPropSet got not really filled since above the call to
539                         // CheckSpecialContext was used and not FillPropertySet, thus the below call to
540                         // setPropertyValue can fail/will not be useful (e.g. when the rPropSet
541                         // is a SwXTextCursor).
542                         // This happens for AutoStyles which are already filled in XMLPropStyleContext::CreateAndInsert,
543                         // thus the whole mechanism based on _ContextID_Index_Pair will not work
544                         // in that case. Thus the slots which need to be converted already get
545                         // converted there (it's called first) and not here (see
546                         // translateNameBasedDrawingLayerFillStyleDefinitionsToStyleDisplayNames)
547                         // For convenience, still Write back the corrected value to the XMLPropertyState entry
548                         rState.maValue <<= sStyleName;
549                         break;
550                     }
551 
552                     // Still needed if it's not an AutomaticStyle (!)
553                     try
554                     {
555                         if(!rPropMapper.is())
556                         {
557                             rPropMapper = xImpPrMap->getPropertySetMapper();
558                         }
559 
560                         // set property
561                         const OUString& rPropertyName = rPropMapper->GetEntryAPIName(rState.mnIndex);
562 
563                         if(!xInfo.is())
564                         {
565                             xInfo = rPropSet->getPropertySetInfo();
566                         }
567 
568                         if(xInfo->hasPropertyByName(rPropertyName))
569                         {
570                             rPropSet->setPropertyValue(rPropertyName,Any(sStyleName));
571                         }
572                     }
573                     catch(css::lang::IllegalArgumentException& e)
574                     {
575                         Sequence<OUString> aSeq { sStyleName };
576                         GetImport().SetError(XMLERROR_STYLE_PROP_VALUE | XMLERROR_FLAG_WARNING, aSeq, e.Message, nullptr);
577                     }
578                     break;
579                 }
580                 default:
581                 {
582                     // check for StarBats and StarMath fonts
583                     Any rAny = rState.maValue;
584                     sal_Int32 nMapperIndex = rState.mnIndex;
585 
586                     // Now check for font name in rState and set corrected value,
587                     // if necessary.
588                     OUString sFontName;
589                     rAny >>= sFontName;
590 
591                     if ( !sFontName.isEmpty() )
592                     {
593                         if ( sFontName.equalsIgnoreAsciiCase( "StarBats" ) ||
594                              sFontName.equalsIgnoreAsciiCase( "StarMath" ) )
595                         {
596                             // construct new value
597                             sFontName = "StarSymbol";
598                             Any aAny(rAny);
599                             aAny <<= sFontName;
600 
601                             if(!rPropMapper.is())
602                             {
603                                 rPropMapper = xImpPrMap->getPropertySetMapper();
604                             }
605 
606                             // set property
607                             OUString rPropertyName(rPropMapper->GetEntryAPIName(nMapperIndex));
608 
609                             if(!xInfo.is())
610                             {
611                                 xInfo = rPropSet->getPropertySetInfo();
612                             }
613 
614                             if(xInfo->hasPropertyByName(rPropertyName))
615                             {
616                                 rPropSet->setPropertyValue(rPropertyName,aAny);
617                             }
618                         }
619                         // else: "normal" style name -> no correction is necessary
620                     }
621                     // else: no style name found -> illegal value -> ignore
622                 }
623             }
624         }
625     }
626 
627 }
628 
629 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
630