LCOV - code coverage report
Current view: top level - xmloff/source/text - txtstyli.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 204 251 81.3 %
Date: 2015-06-13 12:38:46 Functions: 12 14 85.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11