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