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