LCOV - code coverage report
Current view: top level - xmloff/source/text - txtstyli.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 192 251 76.5 %
Date: 2014-11-03 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       35428 : void XMLTextStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
      80             :                                         const OUString& rLocalName,
      81             :                                         const OUString& rValue )
      82             : {
      83       35428 :     if( XML_NAMESPACE_STYLE == nPrefixKey )
      84             :     {
      85             :         // TODO: use a map here
      86       35428 :         if( IsXMLToken( rLocalName, XML_AUTO_UPDATE ) )
      87             :         {
      88           0 :             if( IsXMLToken( rValue, XML_TRUE ) )
      89           0 :                 bAutoUpdate = true;
      90             :         }
      91       35428 :         else if( IsXMLToken( rLocalName, XML_LIST_STYLE_NAME ) )
      92             :         {
      93         106 :             sListStyleName = rValue;
      94             :             // Inherited paragraph style lost information about unset numbering (#i69523#)
      95         106 :             mbListStyleSet = true;
      96             :         }
      97       35322 :         else if( IsXMLToken( rLocalName, XML_MASTER_PAGE_NAME ) )
      98             :         {
      99         286 :             sMasterPageName = rValue;
     100         286 :             bHasMasterPageName = true;
     101             :         }
     102       35036 :         else if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
     103             :         {
     104           0 :             sDataStyleName = rValue;
     105             :         }
     106       35036 :         else if( IsXMLToken( rLocalName, XML_CLASS ) )
     107             :         {
     108        4218 :             sCategoryVal = rValue;
     109             :         }
     110       30818 :         else if( IsXMLToken( rLocalName, XML_DEFAULT_OUTLINE_LEVEL ) )
     111             :         {
     112             :             sal_Int32 nTmp;
     113         846 :             if (::sax::Converter::convertNumber( nTmp, rValue ) &&
     114         564 :                 0 <= nTmp && nTmp <= 10 )
     115         282 :                 nOutlineLevel = static_cast< sal_Int8 >( nTmp );
     116             :         }
     117             :         else
     118             :         {
     119       30536 :             XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
     120             :         }
     121             :     }
     122             :     else
     123             :     {
     124           0 :         XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
     125             :     }
     126       35428 : }
     127             : 
     128       71634 : TYPEINIT1( XMLTextStyleContext, XMLPropStyleContext );
     129             : 
     130       10928 : 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       10928 : ,   pEventContext( NULL )
     149             : {
     150       10928 : }
     151             : 
     152       15100 : XMLTextStyleContext::~XMLTextStyleContext()
     153             : {
     154       15100 : }
     155             : 
     156       10498 : SvXMLImportContext *XMLTextStyleContext::CreateChildContext(
     157             :         sal_uInt16 nPrefix,
     158             :         const OUString& rLocalName,
     159             :         const Reference< XAttributeList > & xAttrList )
     160             : {
     161       10498 :     SvXMLImportContext *pContext = 0;
     162             : 
     163       10498 :     if( XML_NAMESPACE_STYLE == nPrefix )
     164             :     {
     165       10458 :         sal_uInt32 nFamily = 0;
     166       10458 :         if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
     167        5582 :             nFamily = XML_TYPE_PROP_TEXT;
     168        4876 :         else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
     169        4102 :             nFamily = XML_TYPE_PROP_PARAGRAPH;
     170         774 :         else if( IsXMLToken( rLocalName, XML_SECTION_PROPERTIES ) )
     171          52 :             nFamily = XML_TYPE_PROP_SECTION;
     172         722 :         else if( IsDefaultStyle() && IsXMLToken( rLocalName, XML_TABLE_PROPERTIES ) )
     173         306 :             nFamily = XML_TYPE_PROP_TABLE;
     174         416 :         else if( IsDefaultStyle() && IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES ) )
     175         408 :             nFamily = XML_TYPE_PROP_TABLE_ROW;
     176       10458 :         if( nFamily )
     177             :         {
     178             :             rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap =
     179       10450 :                 GetStyles()->GetImportPropertyMapper( GetFamily() );
     180       10450 :             if( xImpPrMap.is() )
     181       10450 :                 pContext = new XMLTextPropertySetContext( GetImport(), nPrefix,
     182             :                                                         rLocalName, xAttrList,
     183             :                                                         nFamily,
     184       10450 :                                                         GetProperties(),
     185             :                                                         xImpPrMap,
     186       20900 :                                                         sDropCapTextStyleName );
     187             :         }
     188             :     }
     189          40 :     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       10498 :     if( !pContext )
     201             :         pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName,
     202          48 :                                                           xAttrList );
     203             : 
     204       10498 :     return pContext;
     205             : }
     206             : 
     207        8672 : void XMLTextStyleContext::CreateAndInsert( bool bOverwrite )
     208             : {
     209        8672 :     XMLPropStyleContext::CreateAndInsert( bOverwrite );
     210        8672 :     Reference < XStyle > xStyle = GetStyle();
     211        8672 :     if( !xStyle.is() || !(bOverwrite || IsNew()) )
     212       12720 :         return;
     213             : 
     214        9248 :     Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
     215             :     Reference< XPropertySetInfo > xPropSetInfo =
     216        9248 :                 xPropSet->getPropertySetInfo();
     217        4624 :     if( xPropSetInfo->hasPropertyByName( sIsAutoUpdate ) )
     218             :     {
     219        3386 :         Any aAny;
     220        3386 :         sal_Bool bTmp = bAutoUpdate;
     221        3386 :         aAny.setValue( &bTmp, ::getBooleanCppuType() );
     222        3386 :         xPropSet->setPropertyValue( sIsAutoUpdate, aAny );
     223             :     }
     224             : 
     225        4624 :     sal_uInt16 nCategory = ParagraphStyleCategory::TEXT;
     226       12634 :     if(  XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() &&
     227        6498 :          !sCategoryVal.isEmpty() && xStyle->isUserDefined() &&
     228        4664 :          xPropSetInfo->hasPropertyByName( sCategory ) &&
     229          20 :           SvXMLUnitConverter::convertEnum( nCategory, sCategoryVal, aCategoryMap ) )
     230             :     {
     231          20 :         Any aAny;
     232          20 :         aAny <<= (sal_Int16)nCategory;
     233          20 :         xPropSet->setPropertyValue( sCategory, aAny );
     234             :     }
     235             : 
     236             :     // tell the style about it's events (if applicable)
     237        4624 :     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        4624 :     if ( nOutlineLevel > 0 )
     247             :     {
     248          74 :         GetImport().GetTextImport()->AddOutlineStyleCandidate( nOutlineLevel,
     249         148 :                                                       GetDisplayName() );
     250        4624 :     }
     251             : }
     252             : 
     253        1230 : void XMLTextStyleContext::SetDefaults( )
     254             : {
     255        3276 :     if( ( GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ) ||
     256        1638 :         ( GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE ) ||
     257         408 :         ( GetFamily() == XML_STYLE_FAMILY_TABLE_ROW ) )
     258             :     {
     259        1230 :         Reference < XMultiServiceFactory > xFactory ( GetImport().GetModel(), UNO_QUERY);
     260        1230 :         if (xFactory.is())
     261             :         {
     262        1230 :             Reference < XInterface > xInt = xFactory->createInstance (
     263        1230 :                 OUString ( "com.sun.star.text.Defaults" ) );
     264        2460 :             Reference < XPropertySet > xProperties ( xInt, UNO_QUERY );
     265        1230 :             if ( xProperties.is() )
     266        2460 :                 FillPropertySet ( xProperties );
     267        1230 :         }
     268             :     }
     269        1230 : }
     270             : 
     271        5942 : void XMLTextStyleContext::Finish( bool bOverwrite )
     272             : {
     273        5942 :     XMLPropStyleContext::Finish( bOverwrite );
     274             : 
     275        5942 :     Reference < XStyle > xStyle = GetStyle();
     276             :     // Consider set empty list style (#i69523#)
     277       17762 :     if ( !( mbListStyleSet ||
     278       11510 :             nOutlineLevel >= 0 ||
     279        5632 :             !sDropCapTextStyleName.isEmpty() ||
     280        5972 :             bHasMasterPageName ) ||
     281       12224 :          !xStyle.is() ||
     282         340 :          !( bOverwrite || IsNew() ) )
     283       11544 :         return;
     284             : 
     285         680 :     Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
     286             :     Reference< XPropertySetInfo > xPropSetInfo =
     287         680 :                 xPropSet->getPropertySetInfo();
     288             : 
     289         340 :     if( xPropSetInfo->hasPropertyByName( sOutlineLevel ))
     290             :     {
     291         340 :         Any aAny;
     292         340 :         if( nOutlineLevel >= 0 )
     293             :         {
     294         282 :             aAny <<= nOutlineLevel;
     295         282 :             xPropSet->setPropertyValue( sOutlineLevel, aAny );
     296         340 :         }
     297             :     }
     298             : 
     299             :     // Consider set empty list style (#i69523#)
     300         404 :     if ( mbListStyleSet &&
     301          64 :          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          64 :         bool bApplyListStyle( true );
     309          64 :         if ( nOutlineLevel > 0 )
     310             :         {
     311          34 :             if ( GetImport().IsTextDocInOOoFileFormat() )
     312             :             {
     313           0 :                 bApplyListStyle = false;
     314             :             }
     315             :             else
     316             :             {
     317          34 :                 sal_Int32 nUPD( 0 );
     318          34 :                 sal_Int32 nBuild( 0 );
     319             :                 // Check explicitly on certain versions (#i86058#)
     320          38 :                 if ( GetImport().getBuildIds( nUPD, nBuild ) &&
     321          12 :                      ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
     322           4 :                        ( nUPD == 680 && nBuild <= 9073 ) ) ) // OOo 2.0 - OOo 2.0.4
     323             :                 {
     324           0 :                     bApplyListStyle = false;
     325             :                 }
     326             :             }
     327             :         }
     328             : 
     329          64 :         if ( bApplyListStyle )
     330             :         {
     331          64 :             if ( sListStyleName.isEmpty() )
     332             :             {
     333          18 :                 Any aAny;
     334          18 :                 aAny <<= sListStyleName /* empty string */;
     335          18 :                 xPropSet->setPropertyValue( sNumberingStyleName, aAny );
     336             :             }
     337             :             else
     338             :             {
     339             :                 // change list style name to display name
     340             :                 OUString sDisplayListStyleName(
     341          46 :                     GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_LIST,
     342          92 :                                                   sListStyleName ) );
     343             :                 // The families container must exist
     344             :                 const Reference < XNameContainer >& rNumStyles =
     345          46 :                     GetImport().GetTextImport()->GetNumberingStyles();
     346             :     //            if( rNumStyles.is() && rNumStyles->hasByName( sDisplayListStyleName ) &&
     347             :     //                xPropSetInfo->hasPropertyByName( sNumberingStyleName ) )
     348          92 :                 if ( rNumStyles.is() &&
     349          46 :                      rNumStyles->hasByName( sDisplayListStyleName ) )
     350             :                 {
     351          46 :                     Any aAny;
     352          46 :                     aAny <<= sDisplayListStyleName;
     353          46 :                     xPropSet->setPropertyValue( sNumberingStyleName, aAny );
     354          46 :                 }
     355             :             }
     356             :         }
     357             :     }
     358             : 
     359         340 :     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         340 :     if( bHasMasterPageName )
     379             :     {
     380             :         OUString sDisplayName(
     381          42 :             GetImport().GetStyleDisplayName(
     382          84 :                             XML_STYLE_FAMILY_MASTER_PAGE, sMasterPageName ) );
     383             :         // The families cointaner must exist
     384             :         const Reference < XNameContainer >& rPageStyles =
     385          42 :             GetImport().GetTextImport()->GetPageStyles();
     386          86 :         if( ( sDisplayName.isEmpty() ||
     387           4 :               (rPageStyles.is() &&
     388          86 :                rPageStyles->hasByName( sDisplayName )) ) &&
     389          42 :             xPropSetInfo->hasPropertyByName( sPageDescName ) )
     390             :         {
     391          42 :             Any aAny;
     392          42 :             aAny <<= sDisplayName;
     393          42 :             xPropSet->setPropertyValue( sPageDescName, aAny );
     394          42 :         }
     395         340 :     }
     396             : }
     397             : 
     398       24498 : 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       24498 :     SvXMLStylesContext* pSvXMLStylesContext = static_cast< SvXMLStylesContext* >(GetStyles());
     406       24498 :     rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap = pSvXMLStylesContext->GetImportPropertyMapper(GetFamily());
     407             :     DBG_ASSERT(xImpPrMap.is(),"Where is the import prop mapper?");
     408             : 
     409       24498 :     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       24498 :         };
     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       24498 :         Reference< XPropertySetInfo > xInfo;
     448       48996 :         rtl::Reference< XMLPropertySetMapper > rPropMapper;
     449       24498 :         bool bAutomatic = false;
     450             : 
     451       49016 :         if(pSvXMLStylesContext->IsAutomaticStyle() &&
     452       17868 :             (XML_STYLE_FAMILY_TEXT_TEXT == GetFamily() || XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily()))
     453             :         {
     454       12194 :             bAutomatic = true;
     455             : 
     456       12194 :             if( !GetAutoName().isEmpty() )
     457             :             {
     458       12124 :                 OUString sAutoProp = ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT ) ?
     459             :                     OUString( "CharAutoStyleName" ):
     460       12124 :                     OUString( "ParaAutoStyleName" );
     461             : 
     462             :                 try
     463             :                 {
     464       12124 :                     if(!xInfo.is())
     465             :                     {
     466       12124 :                         xInfo = rPropSet->getPropertySetInfo();
     467             :                     }
     468             : 
     469       12124 :                     if ( xInfo->hasPropertyByName( sAutoProp ) )
     470             :                     {
     471       11764 :                         rPropSet->setPropertyValue( sAutoProp, makeAny(GetAutoName()) );
     472             :                     }
     473             :                     else
     474             :                     {
     475         360 :                         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       12124 :                 }
     484             :             }
     485             :         }
     486             : 
     487       24498 :         if( bAutomatic )
     488             :         {
     489       11834 :             xImpPrMap->CheckSpecialContext( GetProperties(), rPropSet, aContextIDs );
     490             :         }
     491             :         else
     492             :         {
     493       12664 :             xImpPrMap->FillPropertySet( GetProperties(), rPropSet, aContextIDs );
     494             :         }
     495             : 
     496       24498 :         sal_Int32 nIndex = aContextIDs[0].nIndex;
     497             : 
     498             :         // have we found a combined characters
     499       24498 :         if ( nIndex != -1 )
     500             :         {
     501           0 :             Any& rAny = GetProperties()[nIndex].maValue;
     502           0 :             bool bVal = *(sal_Bool*)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       24498 :         if(IsDefaultStyle() && XML_STYLE_FAMILY_TABLE_ROW == GetFamily())
     512             :         {
     513         408 :             OUString sIsSplitAllowed("IsSplitAllowed");
     514             :             DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sIsSplitAllowed ), "property missing?" );
     515         408 :             rPropSet->setPropertyValue(
     516             :                 sIsSplitAllowed,
     517         408 :                 (aContextIDs[1].nIndex == -1) ? makeAny( false ) : GetProperties()[aContextIDs[1].nIndex].maValue );
     518             :         }
     519             : 
     520       24498 :         if(IsDefaultStyle() && XML_STYLE_FAMILY_TABLE_TABLE == GetFamily())
     521             :         {
     522         408 :             OUString sCollapsingBorders("CollapsingBorders");
     523             :             DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sCollapsingBorders ), "property missing?" );
     524         408 :             rPropSet->setPropertyValue(
     525             :                 sCollapsingBorders,
     526         408 :                 (aContextIDs[2].nIndex == -1)
     527             :                 ? makeAny( false )
     528         816 :                 : GetProperties()[aContextIDs[2].nIndex].maValue );
     529             :         }
     530             : 
     531             : 
     532             :         // iterate over aContextIDs entries, start with 3, prev ones are already used above
     533      220482 :         for(sal_uInt16 i(3); aContextIDs[i].nContextID != -1; i++)
     534             :         {
     535      195984 :             nIndex = aContextIDs[i].nIndex;
     536             : 
     537      195984 :             if ( nIndex != -1 )
     538             :             {
     539             :                 // Found!
     540       33632 :                 struct XMLPropertyState& rState = GetProperties()[nIndex];
     541             : 
     542       33632 :                 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           0 :                         rtl::OUString sStyleName;
     551           0 :                         rState.maValue >>= sStyleName;
     552             : 
     553             :                         //UUUU translate the used name from ODF intern to the name used in the Model
     554           0 :                         sStyleName = GetImport().GetStyleDisplayName(aFamilies[i - 7], sStyleName);
     555             : 
     556           0 :                         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           0 :                             if(!rPropMapper.is())
     576             :                             {
     577           0 :                                 rPropMapper = xImpPrMap->getPropertySetMapper();
     578             :                             }
     579             : 
     580             :                             // set property
     581           0 :                             const rtl::OUString& rPropertyName = rPropMapper->GetEntryAPIName(rState.mnIndex);
     582             : 
     583           0 :                             if(!xInfo.is())
     584             :                             {
     585           0 :                                 xInfo = rPropSet->getPropertySetInfo();
     586             :                             }
     587             : 
     588           0 :                             if(xInfo->hasPropertyByName(rPropertyName))
     589             :                             {
     590           0 :                                 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           0 :                         break;
     600             :                     }
     601             :                     default:
     602             :                     {
     603             :                         // check for StarBats and StarMath fonts
     604       33632 :                         Any rAny = rState.maValue;
     605       33632 :                         sal_Int32 nMapperIndex = rState.mnIndex;
     606             : 
     607             :                         // Now check for font name in rState and set corrected value,
     608             :                         // if necessary.
     609       67264 :                         OUString sFontName;
     610       33632 :                         rAny >>= sFontName;
     611             : 
     612       33632 :                         if ( !sFontName.isEmpty() )
     613             :                         {
     614       67220 :                             if ( sFontName.equalsIgnoreAsciiCase( "StarBats" ) ||
     615       33610 :                                  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       33632 :                         }
     642             :                         // else: no style name found -> illegal value -> ignore
     643             :                     }
     644             :                 }
     645             :             }
     646       24498 :         }
     647       24498 :     }
     648       24498 : }
     649             : 
     650             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10