LCOV - code coverage report
Current view: top level - xmloff/source/style - prstylei.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 231 305 75.7 %
Date: 2014-11-03 Functions: 18 24 75.0 %
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             : #include <tools/debug.hxx>
      21             : #include <set>
      22             : #include <xmloff/xmlnmspe.hxx>
      23             : #include <xmloff/xmltoken.hxx>
      24             : #include <xmloff/xmlprcon.hxx>
      25             : #include <com/sun/star/style/XStyle.hpp>
      26             : #include <com/sun/star/style/XAutoStyleFamily.hpp>
      27             : #include <com/sun/star/container/XNameContainer.hpp>
      28             : #include <com/sun/star/beans/XPropertySet.hpp>
      29             : #include <com/sun/star/beans/XPropertyState.hpp>
      30             : #include <com/sun/star/beans/XMultiPropertyStates.hpp>
      31             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      32             : #include <xmloff/xmlimp.hxx>
      33             : #include <xmloff/prstylei.hxx>
      34             : #include <xmloff/attrlist.hxx>
      35             : #include <xmloff/xmlerror.hxx>
      36             : #include <xmloff/xmltypes.hxx>
      37             : #include <xmloff/maptype.hxx>
      38             : 
      39             : //UUUU
      40             : #include <com/sun/star/drawing/FillStyle.hpp>
      41             : 
      42             : using namespace ::com::sun::star;
      43             : using namespace ::com::sun::star::uno;
      44             : using namespace ::com::sun::star::xml::sax;
      45             : using namespace ::com::sun::star::style;
      46             : using namespace ::com::sun::star::container;
      47             : using namespace ::com::sun::star::beans;
      48             : using namespace ::com::sun::star::lang;
      49             : using namespace ::xmloff::token;
      50             : 
      51             : //UUUU
      52             : using namespace com::sun::star::drawing;
      53             : 
      54       60134 : void XMLPropStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
      55             :                                         const OUString& rLocalName,
      56             :                                         const OUString& rValue )
      57             : {
      58       60134 :     if( XML_NAMESPACE_STYLE == nPrefixKey && IsXMLToken( rLocalName, XML_FAMILY ) )
      59             :     {
      60             :         DBG_ASSERT( GetFamily() == static_cast<SvXMLStylesContext *>(&mxStyles)->GetFamily( rValue ), "unexpected style family" );
      61             :     }
      62             :     else
      63             :     {
      64       36794 :         SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
      65             :     }
      66       60134 : }
      67             : 
      68       21442 : TYPEINIT1( XMLPropStyleContext, SvXMLStyleContext );
      69             : 
      70             : //UUUU
      71         233 : OldFillStyleDefinitionSet XMLPropStyleContext::maStandardSet;
      72         233 : OldFillStyleDefinitionSet XMLPropStyleContext::maHeaderSet;
      73         233 : OldFillStyleDefinitionSet XMLPropStyleContext::maFooterSet;
      74         233 : OldFillStyleDefinitionSet XMLPropStyleContext::maParaSet;
      75             : 
      76       24872 : XMLPropStyleContext::XMLPropStyleContext( SvXMLImport& rImport,
      77             :         sal_uInt16 nPrfx, const OUString& rLName,
      78             :         const Reference< XAttributeList > & xAttrList,
      79             :         SvXMLStylesContext& rStyles, sal_uInt16 nFamily,
      80             :         bool bDefault )
      81             : :   SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList, nFamily, bDefault )
      82             : ,   msIsPhysical(  "IsPhysical"  )
      83             : ,   msFollowStyle(  "FollowStyle"  )
      84       24872 : ,   mxStyles( &rStyles )
      85             : {
      86       24872 : }
      87             : 
      88       24886 : XMLPropStyleContext::~XMLPropStyleContext()
      89             : {
      90       24886 : }
      91             : 
      92           0 : const OldFillStyleDefinitionSet& XMLPropStyleContext::getStandardSet()
      93             : {
      94           0 :     if(maStandardSet.empty())
      95             :     {
      96           0 :         maStandardSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BackColorRGB")));
      97           0 :         maStandardSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BackTransparent")));
      98           0 :         maStandardSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BackColorTransparency")));
      99           0 :         maStandardSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BackGraphicURL")));
     100           0 :         maStandardSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BackGraphicFilter")));
     101           0 :         maStandardSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BackGraphicLocation")));
     102           0 :         maStandardSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BackGraphicTransparency")));
     103             :     }
     104             : 
     105           0 :     return maStandardSet;
     106             : }
     107             : 
     108           0 : const OldFillStyleDefinitionSet& XMLPropStyleContext::getHeaderSet()
     109             : {
     110           0 :     if(maHeaderSet.empty())
     111             :     {
     112           0 :         maHeaderSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderBackColorRGB")));
     113           0 :         maHeaderSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderBackTransparent")));
     114           0 :         maHeaderSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderBackColorTransparency")));
     115           0 :         maHeaderSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderBackGraphicURL")));
     116           0 :         maHeaderSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderBackGraphicFilter")));
     117           0 :         maHeaderSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderBackGraphicLocation")));
     118           0 :         maHeaderSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderBackGraphicTransparency")));
     119             :     }
     120             : 
     121           0 :     return maHeaderSet;
     122             : }
     123             : 
     124           0 : const OldFillStyleDefinitionSet& XMLPropStyleContext::getFooterSet()
     125             : {
     126           0 :     if(maFooterSet.empty())
     127             :     {
     128           0 :         maFooterSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FooterBackColorRGB")));
     129           0 :         maFooterSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FooterBackTransparent")));
     130           0 :         maFooterSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FooterBackColorTransparency")));
     131           0 :         maFooterSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FooterBackGraphicURL")));
     132           0 :         maFooterSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FooterBackGraphicFilter")));
     133           0 :         maFooterSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FooterBackGraphicLocation")));
     134           0 :         maFooterSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FooterBackGraphicTransparency")));
     135             :     }
     136             : 
     137           0 :     return maFooterSet;
     138             : }
     139             : 
     140          10 : const OldFillStyleDefinitionSet& XMLPropStyleContext::getParaSet()
     141             : {
     142          10 :     if(maParaSet.empty())
     143             :     {
     144             :         // Caution: here it is *not* 'ParaBackColorRGB' as it should be, but indeed
     145             :         // 'ParaBackColor' is used, see aXMLParaPropMap definition (line 313)
     146           4 :         maParaSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParaBackColor")));
     147           4 :         maParaSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParaBackTransparent")));
     148           4 :         maParaSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParaBackGraphicLocation")));
     149           4 :         maParaSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParaBackGraphicFilter")));
     150           4 :         maParaSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParaBackGraphicURL")));
     151             : 
     152             :         // These are not used in aXMLParaPropMap definition, thus not needed here
     153             :         // maParaSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParaBackColorTransparency")));
     154             :         // maParaSet.insert(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParaBackGraphicTransparency")));
     155             :     }
     156             : 
     157          10 :     return maParaSet;
     158             : }
     159             : 
     160        5744 : SvXMLImportContext *XMLPropStyleContext::CreateChildContext(
     161             :         sal_uInt16 nPrefix,
     162             :         const OUString& rLocalName,
     163             :         const Reference< XAttributeList > & xAttrList )
     164             : {
     165        5744 :     SvXMLImportContext *pContext = 0;
     166             : 
     167        5744 :     sal_uInt32 nFamily = 0;
     168        5744 :     if( XML_NAMESPACE_STYLE == nPrefix || XML_NAMESPACE_LO_EXT == nPrefix )
     169             :     {
     170        5744 :         if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
     171          48 :             nFamily = XML_TYPE_PROP_GRAPHIC;
     172        5696 :         else if( IsXMLToken( rLocalName, XML_DRAWING_PAGE_PROPERTIES )  )
     173           0 :             nFamily = XML_TYPE_PROP_DRAWING_PAGE;
     174        5696 :         else if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES )  )
     175        1962 :             nFamily = XML_TYPE_PROP_TEXT;
     176        3734 :         else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES )  )
     177         764 :             nFamily = XML_TYPE_PROP_PARAGRAPH;
     178        2970 :         else if( IsXMLToken( rLocalName, XML_RUBY_PROPERTIES )  )
     179          14 :             nFamily = XML_TYPE_PROP_RUBY;
     180        2956 :         else if( IsXMLToken( rLocalName, XML_SECTION_PROPERTIES )  )
     181           0 :             nFamily = XML_TYPE_PROP_SECTION;
     182        2956 :         else if( IsXMLToken( rLocalName, XML_TABLE_PROPERTIES )  )
     183         334 :             nFamily = XML_TYPE_PROP_TABLE;
     184        2622 :         else if( IsXMLToken( rLocalName, XML_TABLE_COLUMN_PROPERTIES )  )
     185        2060 :             nFamily = XML_TYPE_PROP_TABLE_COLUMN;
     186         562 :         else if( IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES )  )
     187         552 :             nFamily = XML_TYPE_PROP_TABLE_ROW;
     188          10 :         else if( IsXMLToken( rLocalName, XML_TABLE_CELL_PROPERTIES )  )
     189           0 :             nFamily = XML_TYPE_PROP_TABLE_CELL;
     190          10 :         else if( IsXMLToken( rLocalName, XML_CHART_PROPERTIES ) )
     191           0 :             nFamily = XML_TYPE_PROP_CHART;
     192             :     }
     193        5744 :     if( nFamily )
     194             :     {
     195             :         rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap =
     196        5734 :             static_cast<SvXMLStylesContext *>(&mxStyles)->GetImportPropertyMapper(
     197        5734 :                                                         GetFamily() );
     198        5734 :         if( xImpPrMap.is() )
     199        5734 :             pContext = new SvXMLPropertySetContext( GetImport(), nPrefix,
     200             :                                                     rLocalName, xAttrList,
     201             :                                                     nFamily,
     202             :                                                     maProperties,
     203        5734 :                                                     xImpPrMap );
     204             :     }
     205             : 
     206        5744 :     if( !pContext )
     207             :         pContext = SvXMLStyleContext::CreateChildContext( nPrefix, rLocalName,
     208          10 :                                                           xAttrList );
     209             : 
     210        5744 :     return pContext;
     211             : }
     212             : 
     213       15040 : void XMLPropStyleContext::FillPropertySet(
     214             :             const Reference< XPropertySet > & rPropSet )
     215             : {
     216             :     rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap =
     217       15040 :         static_cast<SvXMLStylesContext *>(&mxStyles)->GetImportPropertyMapper(
     218       15040 :                                                                 GetFamily() );
     219             :     DBG_ASSERT( xImpPrMap.is(), "There is the import prop mapper" );
     220       15040 :     if( xImpPrMap.is() )
     221       15040 :         xImpPrMap->FillPropertySet( maProperties, rPropSet );
     222       15040 : }
     223             : 
     224           0 : void XMLPropStyleContext::SetDefaults()
     225             : {
     226           0 : }
     227             : 
     228        1492 : Reference < XStyle > XMLPropStyleContext::Create()
     229             : {
     230        1492 :     Reference < XStyle > xNewStyle;
     231             : 
     232             :     OUString sServiceName(
     233        2984 :         static_cast<SvXMLStylesContext *>(&mxStyles)->GetServiceName( GetFamily() ) );
     234        1492 :     if( !sServiceName.isEmpty() )
     235             :     {
     236        1492 :         Reference< XMultiServiceFactory > xFactory( GetImport().GetModel(),
     237        1492 :                                                     UNO_QUERY );
     238        1492 :         if( xFactory.is() )
     239             :         {
     240             :             Reference < XInterface > xIfc =
     241        1492 :                 xFactory->createInstance( sServiceName );
     242        1492 :             if( xIfc.is() )
     243        1492 :                 xNewStyle = Reference < XStyle >( xIfc, UNO_QUERY );
     244        1492 :         }
     245             :     }
     246             : 
     247        2984 :     return xNewStyle;
     248             : }
     249             : 
     250             : typedef ::std::set < OUString > PropertyNameSet;
     251             : 
     252       10416 : void XMLPropStyleContext::CreateAndInsert( bool bOverwrite )
     253             : {
     254       10416 :     SvXMLStylesContext* pSvXMLStylesContext = static_cast< SvXMLStylesContext* >(&mxStyles);
     255       10416 :     rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap = pSvXMLStylesContext->GetImportPropertyMapper(GetFamily());
     256             :     OSL_ENSURE(xImpPrMap.is(), "There is no import prop mapper");
     257             : 
     258             :     //UUUU need to filter out old fill definitions when the new ones are used. The new
     259             :     // ones are used when a FillStyle is defined
     260       10416 :     const bool bTakeCareOfDrawingLayerFillStyle(xImpPrMap.is() && GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH);
     261       10416 :     bool bDrawingLayerFillStylesUsed(false);
     262             : 
     263       10416 :     if(bTakeCareOfDrawingLayerFillStyle)
     264             :     {
     265             :         // check if new FillStyles are used and if so mark old ones with -1
     266        6036 :         static ::rtl::OUString s_FillStyle(RTL_CONSTASCII_USTRINGPARAM("FillStyle"));
     267             : 
     268        6036 :         if(doNewDrawingLayerFillStyleDefinitionsExist(s_FillStyle))
     269             :         {
     270          10 :             deactivateOldFillStyleDefinitions(getParaSet());
     271          10 :             bDrawingLayerFillStylesUsed = true;
     272             :         }
     273             :     }
     274             : 
     275       20832 :     if( pSvXMLStylesContext->IsAutomaticStyle()
     276       10416 :         && ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT || GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ) )
     277             :     {
     278             :         //UUUU Need to translate StyleName from temp MapNames to names
     279             :         // used in already imported items (already exist in the pool). This
     280             :         // is required for AutomaticStyles since these do *not* use FillPropertySet
     281             :         // and thus just trigger CheckSpecialContext in XMLTextStyleContext::FillPropertySet
     282             :         // (which may be double action anyways). The mechanism there to use _ContextID_Index_Pair
     283             :         // is not working for AutomaticStyles and is already too late, too (this
     284             :         // method is already called before XMLTextStyleContext::FillPropertySet gets called)
     285        2698 :         if(bDrawingLayerFillStylesUsed)
     286             :         {
     287           2 :             translateNameBasedDrawingLayerFillStyleDefinitionsToStyleDisplayNames();
     288             :         }
     289             : 
     290        2698 :         Reference < XAutoStyleFamily > xAutoFamily = pSvXMLStylesContext->GetAutoStyles( GetFamily() );
     291        2698 :         if( !xAutoFamily.is() )
     292           0 :             return;
     293        2698 :         if( xImpPrMap.is() )
     294             :         {
     295        2698 :             Sequence< PropertyValue > aValues;
     296        2698 :             xImpPrMap->FillPropertySequence( maProperties, aValues );
     297             : 
     298        2698 :             sal_Int32 nLen = aValues.getLength();
     299        2698 :             if( nLen )
     300             :             {
     301        2672 :                 if( GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH )
     302             :                 {
     303        1506 :                     aValues.realloc( nLen + 2 );
     304        1506 :                     PropertyValue *pProps = aValues.getArray() + nLen;
     305        1506 :                     pProps->Name = "ParaStyleName";
     306        1506 :                     OUString sParent( GetParentName() );
     307        1506 :                     if( !sParent.isEmpty() )
     308        1388 :                         sParent = GetImport().GetStyleDisplayName( GetFamily(), sParent );
     309             :                     else
     310         118 :                         sParent = "Standard";
     311        1506 :                     pProps->Value <<= sParent;
     312        1506 :                     ++pProps;
     313        1506 :                     pProps->Name = "ParaConditionalStyleName";
     314        1506 :                     pProps->Value <<= sParent;
     315             :                 }
     316             : 
     317        2672 :                 Reference < XAutoStyle > xAutoStyle = xAutoFamily->insertStyle( aValues );
     318        2672 :                 if( xAutoStyle.is() )
     319             :                 {
     320        2672 :                     Sequence< OUString > aPropNames(1);
     321        6850 :                     aPropNames[0] = GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ?
     322             :                         OUString("ParaAutoStyleName") :
     323        3838 :                         OUString("CharAutoStyleName");
     324        5344 :                     Sequence< Any > aAny = xAutoStyle->getPropertyValues( aPropNames );
     325        2672 :                     if( aAny.hasElements() )
     326             :                     {
     327        2672 :                         OUString aName;
     328        2672 :                         aAny[0] >>= aName;
     329        2672 :                         SetAutoName( aName );
     330        2672 :                     }
     331        2672 :                 }
     332        2698 :             }
     333        2698 :         }
     334             :     }
     335             :     else
     336             :     {
     337        7718 :         const OUString& rName = GetDisplayName();
     338        7718 :         if( rName.isEmpty() || IsDefaultStyle() )
     339         840 :             return;
     340             : 
     341        7718 :         Reference < XNameContainer > xFamilies = pSvXMLStylesContext->GetStylesContainer( GetFamily() );
     342        7718 :         if( !xFamilies.is() )
     343         840 :             return;
     344             : 
     345        6878 :         bool bNew = false;
     346        6878 :         if( xFamilies->hasByName( rName ) )
     347             :         {
     348        5386 :             Any aAny = xFamilies->getByName( rName );
     349        5386 :             aAny >>= mxStyle;
     350             :         }
     351             :         else
     352             :         {
     353        1492 :             mxStyle = Create();
     354        1492 :             if( !mxStyle.is() )
     355           0 :                 return;
     356             : 
     357        1492 :             Any aAny;
     358        1492 :             aAny <<= mxStyle;
     359        1492 :             xFamilies->insertByName( rName, aAny );
     360        1492 :             bNew = true;
     361             :         }
     362             : 
     363       13756 :         Reference < XPropertySet > xPropSet( mxStyle, UNO_QUERY );
     364             :         Reference< XPropertySetInfo > xPropSetInfo =
     365       13756 :                     xPropSet->getPropertySetInfo();
     366        6878 :         if( !bNew && xPropSetInfo->hasPropertyByName( msIsPhysical ) )
     367             :         {
     368        4056 :             Any aAny = xPropSet->getPropertyValue( msIsPhysical );
     369        4056 :             bNew = !*(sal_Bool *)aAny.getValue();
     370             :         }
     371        6878 :         SetNew( bNew );
     372        6878 :         if( rName != GetName() )
     373        1922 :             GetImport().AddStyleDisplayName( GetFamily(), GetName(), rName );
     374             : 
     375             : 
     376        6878 :         if( bOverwrite || bNew )
     377             :         {
     378        6368 :             Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
     379             : 
     380       12736 :             rtl::Reference < XMLPropertySetMapper > xPrMap;
     381        6368 :             if( xImpPrMap.is() )
     382        6368 :                 xPrMap = xImpPrMap->getPropertySetMapper();
     383        6368 :             if( xPrMap.is() )
     384             :             {
     385             :                 Reference < XMultiPropertyStates > xMultiStates( xPropSet,
     386        6368 :                                                                  UNO_QUERY );
     387        6368 :                 if( xMultiStates.is() )
     388             :                 {
     389        6368 :                     xMultiStates->setAllPropertiesToDefault();
     390             :                 }
     391             :                 else
     392             :                 {
     393           0 :                     PropertyNameSet aNameSet;
     394           0 :                     sal_Int32 nCount = xPrMap->GetEntryCount();
     395             :                     sal_Int32 i;
     396           0 :                     for( i = 0; i < nCount; i++ )
     397             :                     {
     398           0 :                         const OUString& rPrName = xPrMap->GetEntryAPIName( i );
     399           0 :                         if( xPropSetInfo->hasPropertyByName( rPrName ) )
     400           0 :                             aNameSet.insert( rPrName );
     401             :                     }
     402             : 
     403           0 :                     nCount = aNameSet.size();
     404           0 :                     Sequence < OUString > aNames( nCount );
     405           0 :                     OUString *pNames = aNames.getArray();
     406           0 :                     PropertyNameSet::iterator aIter = aNameSet.begin();
     407           0 :                     while( aIter != aNameSet.end() )
     408           0 :                         *pNames++ = *aIter++;
     409             : 
     410             :                     Sequence < PropertyState > aStates(
     411           0 :                         xPropState->getPropertyStates( aNames ) );
     412           0 :                     const PropertyState *pStates = aStates.getConstArray();
     413           0 :                     pNames = aNames.getArray();
     414             : 
     415           0 :                     for( i = 0; i < nCount; i++ )
     416             :                     {
     417           0 :                         if( PropertyState_DIRECT_VALUE == *pStates++ )
     418           0 :                             xPropState->setPropertyToDefault( pNames[i] );
     419           0 :                     }
     420        6368 :                 }
     421             :             }
     422             : 
     423        6368 :             if (mxStyle.is())
     424        6368 :                 mxStyle->setParentStyle(OUString());
     425             : 
     426       12736 :             FillPropertySet( xPropSet );
     427             :         }
     428             :         else
     429             :         {
     430         510 :             SetValid( false );
     431        6878 :         }
     432        9576 :     }
     433             : }
     434             : 
     435        7910 : void XMLPropStyleContext::Finish( bool bOverwrite )
     436             : {
     437        7910 :     if( mxStyle.is() && (IsNew() || bOverwrite) )
     438             :     {
     439             :         // The families cintaner must exist
     440             :         Reference < XNameContainer > xFamilies =
     441        6368 :             static_cast<SvXMLStylesContext *>(&mxStyles)->GetStylesContainer( GetFamily() );
     442             :         DBG_ASSERT( xFamilies.is(), "Families lost" );
     443        6368 :         if( !xFamilies.is() )
     444        7910 :             return;
     445             : 
     446             :         // connect parent
     447       12736 :         OUString sParent( GetParentName() );
     448        6368 :         if( !sParent.isEmpty() )
     449        4460 :             sParent = GetImport().GetStyleDisplayName( GetFamily(), sParent );
     450        6368 :         if( !sParent.isEmpty() && !xFamilies->hasByName( sParent ) )
     451          44 :             sParent = OUString();
     452             : 
     453        6368 :         if( sParent != mxStyle->getParentStyle() )
     454             :         {
     455             :             // this may except if setting the parent style forms a
     456             :             // circle in the style depencies; especially if the parent
     457             :             // style is the same as the current style
     458             :             try
     459             :             {
     460        3708 :                 mxStyle->setParentStyle( sParent );
     461             :             }
     462           0 :             catch(const uno::Exception& e)
     463             :             {
     464             :                 // according to the API definition, I would expect a
     465             :                 // container::NoSuchElementException. But it throws an
     466             :                 // uno::RuntimeException instead. I catch
     467             :                 // uno::Exception in order to process both of them.
     468             : 
     469             :                 // We can't set the parent style. For a proper
     470             :                 // Error-Message, we should pass in the name of the
     471             :                 // style, as well as the desired parent style.
     472           0 :                 Sequence<OUString> aSequence(2);
     473             : 
     474             :                 // getName() throws no non-Runtime exception:
     475           0 :                 aSequence[0] = mxStyle->getName();
     476           0 :                 aSequence[1] = sParent;
     477             : 
     478           0 :                 GetImport().SetError(
     479             :                     XMLERROR_FLAG_ERROR | XMLERROR_PARENT_STYLE_NOT_ALLOWED,
     480           0 :                     aSequence, e.Message, NULL );
     481             :             }
     482             :         }
     483             : 
     484             :         // connect follow
     485       12736 :         OUString sFollow( GetFollow() );
     486        6368 :         if( !sFollow.isEmpty() )
     487         472 :             sFollow = GetImport().GetStyleDisplayName( GetFamily(), sFollow );
     488        6368 :         if( sFollow.isEmpty() || !xFamilies->hasByName( sFollow ) )
     489        5896 :             sFollow = mxStyle->getName();
     490             : 
     491       12736 :         Reference < XPropertySet > xPropSet( mxStyle, UNO_QUERY );
     492             :         Reference< XPropertySetInfo > xPropSetInfo =
     493       12736 :             xPropSet->getPropertySetInfo();
     494        6368 :         if( xPropSetInfo->hasPropertyByName( msFollowStyle ) )
     495             :         {
     496        3386 :             Any aAny = xPropSet->getPropertyValue( msFollowStyle );
     497        6772 :             OUString sCurrFollow;
     498        3386 :             aAny >>= sCurrFollow;
     499        3386 :             if( sCurrFollow != sFollow )
     500             :             {
     501         118 :                 aAny <<= sFollow;
     502         118 :                 xPropSet->setPropertyValue( msFollowStyle, aAny );
     503        3386 :             }
     504             :         }
     505             : 
     506        6368 :         if ( xPropSetInfo->hasPropertyByName( "Hidden" ) )
     507             :         {
     508        6368 :             xPropSet->setPropertyValue( "Hidden", uno::makeAny( IsHidden( ) ) );
     509        6368 :         }
     510             : 
     511             :     }
     512             : }
     513             : 
     514             : //UUUU
     515       10278 : bool XMLPropStyleContext::doNewDrawingLayerFillStyleDefinitionsExist(
     516             :     const OUString& rFillStyleTag) const
     517             : {
     518       10278 :     if(maProperties.size() && rFillStyleTag.getLength())
     519             :     {
     520        8184 :         const rtl::Reference< XMLPropertySetMapper >& rMapper = GetStyles()->GetImportPropertyMapper(GetFamily())->getPropertySetMapper();
     521             : 
     522        8184 :         if(rMapper.is())
     523             :         {
     524      135488 :             for(::std::vector< XMLPropertyState >::const_iterator a = maProperties.begin(); a != maProperties.end(); ++a)
     525             :             {
     526      127314 :                 if(a->mnIndex != -1)
     527             :                 {
     528      121216 :                     const OUString& rPropName = rMapper->GetEntryAPIName(a->mnIndex);
     529             : 
     530      121216 :                     if(rPropName == rFillStyleTag)
     531             :                     {
     532          10 :                         FillStyle eFillStyle(FillStyle_NONE);
     533             : 
     534          10 :                         if(a->maValue >>= eFillStyle)
     535             :                         {
     536             :                             // okay, type was good, FillStyle is set
     537             :                         }
     538             :                         else
     539             :                         {
     540             :                             // also try an int (see XFillStyleItem::PutValue)
     541           0 :                             sal_Int32 nFillStyle(0);
     542             : 
     543           0 :                             if(a->maValue >>= nFillStyle)
     544             :                             {
     545           0 :                                 eFillStyle = static_cast< FillStyle >(nFillStyle);
     546             :                             }
     547             :                         }
     548             : 
     549             :                         // we found the entry, check it
     550          10 :                         return FillStyle_NONE != eFillStyle;
     551             :                     }
     552             :                 }
     553             :             }
     554             :         }
     555             :     }
     556             : 
     557       10268 :     return false;
     558             : }
     559             : 
     560             : //UUUU
     561          10 : bool XMLPropStyleContext::deactivateOldFillStyleDefinitions(
     562             :     const OldFillStyleDefinitionSet& rHashSetOfTags)
     563             : {
     564          10 :     bool bRetval(false);
     565             : 
     566          10 :     if(!rHashSetOfTags.empty() && maProperties.size())
     567             :     {
     568          10 :         const rtl::Reference< XMLPropertySetMapper >& rMapper = GetStyles()->GetImportPropertyMapper(GetFamily())->getPropertySetMapper();
     569             : 
     570          10 :         if(rMapper.is())
     571             :         {
     572         106 :             for(::std::vector< XMLPropertyState >::iterator a = maProperties.begin(); a != maProperties.end(); ++a)
     573             :             {
     574          96 :                 if(a->mnIndex != -1)
     575             :                 {
     576          96 :                     const OUString& rPropName = rMapper->GetEntryAPIName(a->mnIndex);
     577             : 
     578          96 :                     if(rHashSetOfTags.find(rPropName) != rHashSetOfTags.end())
     579             :                     {
     580             :                         // mark entry as inactive
     581          40 :                         a->mnIndex = -1;
     582          40 :                         bRetval = true;
     583             :                     }
     584             :                 }
     585             :             }
     586             :         }
     587             :     }
     588             : 
     589          10 :     return bRetval;
     590             : }
     591             : 
     592             : //UUUU
     593           2 : bool XMLPropStyleContext::translateNameBasedDrawingLayerFillStyleDefinitionsToStyleDisplayNames()
     594             : {
     595           2 :     bool bRetval(false);
     596             : 
     597           2 :     if(maProperties.size())
     598             :     {
     599           2 :         const rtl::Reference< XMLPropertySetMapper >& rMapper = GetStyles()->GetImportPropertyMapper(GetFamily())->getPropertySetMapper();
     600             : 
     601           2 :         if(rMapper.is())
     602             :         {
     603           2 :             static OUString s_FillGradientName(RTL_CONSTASCII_USTRINGPARAM("FillGradientName"));
     604           2 :             static OUString s_FillHatchName(RTL_CONSTASCII_USTRINGPARAM("FillHatchName"));
     605           2 :             static OUString s_FillBitmapName(RTL_CONSTASCII_USTRINGPARAM("FillBitmapName"));
     606           2 :             static OUString s_FillTransparenceGradientName(RTL_CONSTASCII_USTRINGPARAM("FillTransparenceGradientName"));
     607             : 
     608          10 :             for(::std::vector< XMLPropertyState >::iterator a = maProperties.begin(); a != maProperties.end(); ++a)
     609             :             {
     610           8 :                 if(a->mnIndex != -1)
     611             :                 {
     612           8 :                     const OUString& rPropName = rMapper->GetEntryAPIName(a->mnIndex);
     613           8 :                     sal_uInt16 aStyleFamily(0);
     614             : 
     615           8 :                     if(rPropName == s_FillGradientName || rPropName == s_FillTransparenceGradientName)
     616             :                     {
     617           0 :                         aStyleFamily = XML_STYLE_FAMILY_SD_GRADIENT_ID;
     618             :                     }
     619           8 :                     else if(rPropName == s_FillHatchName)
     620             :                     {
     621           0 :                         aStyleFamily = XML_STYLE_FAMILY_SD_HATCH_ID;
     622             :                     }
     623           8 :                     else if(rPropName == s_FillBitmapName)
     624             :                     {
     625           0 :                         aStyleFamily = XML_STYLE_FAMILY_SD_FILL_IMAGE_ID;
     626             :                     }
     627             : 
     628           8 :                     if(aStyleFamily)
     629             :                     {
     630           0 :                         OUString sStyleName;
     631             : 
     632           0 :                         a->maValue >>= sStyleName;
     633           0 :                         sStyleName = GetImport().GetStyleDisplayName( aStyleFamily, sStyleName );
     634           0 :                         a->maValue <<= sStyleName;
     635           0 :                         bRetval = true;
     636             :                     }
     637             :                 }
     638             :             }
     639             :         }
     640             :     }
     641             : 
     642           2 :     return bRetval;
     643         699 : }
     644             : 
     645             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10