Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "XMLTextPropertySetContext.hxx"
31 : : #include "xmloff/xmlnmspe.hxx"
32 : : #include "xmloff/XMLEventsImportContext.hxx"
33 : : #include "xmloff/attrlist.hxx"
34 : : #include "xmloff/families.hxx"
35 : : #include "xmloff/txtprmap.hxx"
36 : : #include "xmloff/txtstyli.hxx"
37 : : #include "xmloff/xmlimp.hxx"
38 : : #include "xmloff/xmltkmap.hxx"
39 : : #include "xmloff/xmltoken.hxx"
40 : : #include "xmloff/xmluconv.hxx"
41 : :
42 : : #include <com/sun/star/beans/XMultiPropertySet.hpp>
43 : : #include <com/sun/star/container/XNameContainer.hpp>
44 : : #include <com/sun/star/document/XEventsSupplier.hpp>
45 : : #include <com/sun/star/frame/XModel.hpp>
46 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
47 : : #include <com/sun/star/style/ParagraphStyleCategory.hpp>
48 : : #include <com/sun/star/style/XStyle.hpp>
49 : :
50 : : #include <sax/tools/converter.hxx>
51 : :
52 : : #include <tools/debug.hxx>
53 : : #include <tools/diagnose_ex.h>
54 : :
55 : : // STL includes
56 : : #include <algorithm>
57 : : #include <functional>
58 : : #include <utility>
59 : : #include <vector>
60 : :
61 : : using ::rtl::OUString;
62 : : using ::rtl::OUStringBuffer;
63 : :
64 : : using namespace ::std;
65 : : using namespace ::com::sun::star;
66 : : using namespace ::com::sun::star::uno;
67 : : using namespace ::com::sun::star::xml::sax;
68 : : using namespace ::com::sun::star::style;
69 : : using namespace ::com::sun::star::frame;
70 : : using namespace ::com::sun::star::beans;
71 : : using namespace ::com::sun::star::lang;
72 : : using namespace ::com::sun::star::container;
73 : : using namespace ::xmloff::token;
74 : :
75 : : static SvXMLEnumMapEntry aCategoryMap[] =
76 : : {
77 : : { XML_TEXT, ParagraphStyleCategory::TEXT },
78 : : { XML_CHAPTER, ParagraphStyleCategory::CHAPTER },
79 : : { XML_LIST, ParagraphStyleCategory::LIST },
80 : : { XML_INDEX, ParagraphStyleCategory::INDEX },
81 : : { XML_EXTRA, ParagraphStyleCategory::EXTRA },
82 : : { XML_HTML, ParagraphStyleCategory::HTML },
83 : : { XML_TOKEN_INVALID, 0 }
84 : : };
85 : :
86 : 4070 : void XMLTextStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
87 : : const OUString& rLocalName,
88 : : const OUString& rValue )
89 : : {
90 [ + - ]: 4070 : if( XML_NAMESPACE_STYLE == nPrefixKey )
91 : : {
92 : : // TODO: use a map here
93 [ - + ]: 4070 : if( IsXMLToken( rLocalName, XML_AUTO_UPDATE ) )
94 : : {
95 [ # # ]: 0 : if( IsXMLToken( rValue, XML_TRUE ) )
96 : 0 : bAutoUpdate = sal_True;
97 : : }
98 [ + + ]: 4070 : else if( IsXMLToken( rLocalName, XML_LIST_STYLE_NAME ) )
99 : : {
100 : 81 : sListStyleName = rValue;
101 : : // Inherited paragraph style lost information about unset numbering (#i69523#)
102 : 81 : mbListStyleSet = sal_True;
103 : : }
104 [ + + ]: 3989 : else if( IsXMLToken( rLocalName, XML_MASTER_PAGE_NAME ) )
105 : : {
106 : 48 : sMasterPageName = rValue;
107 : 48 : bHasMasterPageName = sal_True;
108 : : }
109 [ - + ]: 3941 : else if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
110 : : {
111 : 0 : sDataStyleName = rValue;
112 : : }
113 [ + + ]: 3941 : else if( IsXMLToken( rLocalName, XML_CLASS ) )
114 : : {
115 : 531 : sCategoryVal = rValue;
116 : : }
117 [ + + ]: 3410 : else if( IsXMLToken( rLocalName, XML_DEFAULT_OUTLINE_LEVEL ) )
118 : : {
119 : : sal_Int32 nTmp;
120 [ + - ][ + - ]: 42 : if (::sax::Converter::convertNumber( nTmp, rValue ) &&
[ + - ][ + - ]
[ + - ]
121 : : 0 <= nTmp && nTmp <= 10 )
122 : 42 : nOutlineLevel = static_cast< sal_Int8 >( nTmp );
123 : : }
124 : : else
125 : : {
126 : 3368 : XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
127 : : }
128 : : }
129 : : else
130 : : {
131 : 0 : XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
132 : : }
133 : 4070 : }
134 : :
135 [ + + ][ + + ]: 2751 : TYPEINIT1( XMLTextStyleContext, XMLPropStyleContext );
136 : :
137 : 1169 : XMLTextStyleContext::XMLTextStyleContext( SvXMLImport& rImport,
138 : : sal_uInt16 nPrfx, const OUString& rLName,
139 : : const Reference< XAttributeList > & xAttrList,
140 : : SvXMLStylesContext& rStyles, sal_uInt16 nFamily,
141 : : sal_Bool bDefaultStyle )
142 : : : XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle )
143 : : , sIsAutoUpdate( RTL_CONSTASCII_USTRINGPARAM( "IsAutoUpdate" ) )
144 : : , sCategory( RTL_CONSTASCII_USTRINGPARAM( "Category" ) )
145 : : , sNumberingStyleName( RTL_CONSTASCII_USTRINGPARAM( "NumberingStyleName" ) )
146 : : , sOutlineLevel(RTL_CONSTASCII_USTRINGPARAM( "OutlineLevel" ) )
147 : : , sDropCapCharStyleName( RTL_CONSTASCII_USTRINGPARAM( "DropCapCharStyleName" ) )
148 : : , sPageDescName( RTL_CONSTASCII_USTRINGPARAM( "PageDescName" ) )
149 : : , nOutlineLevel( -1 )
150 : : , bAutoUpdate( sal_False )
151 : : , bHasMasterPageName( sal_False )
152 : : , bHasCombinedCharactersLetter( sal_False )
153 : : // Inherited paragraph style lost information about unset numbering (#i69523#)
154 : : , mbListStyleSet( sal_False )
155 [ + - ][ + - ]: 1169 : , pEventContext( NULL )
[ + - ][ + - ]
[ + - ][ + - ]
156 : : {
157 : 1169 : }
158 : :
159 : 1169 : XMLTextStyleContext::~XMLTextStyleContext()
160 : : {
161 [ - + ]: 1590 : }
162 : :
163 : 1408 : SvXMLImportContext *XMLTextStyleContext::CreateChildContext(
164 : : sal_uInt16 nPrefix,
165 : : const OUString& rLocalName,
166 : : const Reference< XAttributeList > & xAttrList )
167 : : {
168 : 1408 : SvXMLImportContext *pContext = 0;
169 : :
170 [ + - ]: 1408 : if( XML_NAMESPACE_STYLE == nPrefix )
171 : : {
172 : 1408 : sal_uInt32 nFamily = 0;
173 [ + + ]: 1408 : if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
174 : 665 : nFamily = XML_TYPE_PROP_TEXT;
175 [ + + ]: 743 : else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
176 : 598 : nFamily = XML_TYPE_PROP_PARAGRAPH;
177 [ + + ]: 145 : else if( IsXMLToken( rLocalName, XML_SECTION_PROPERTIES ) )
178 : 19 : nFamily = XML_TYPE_PROP_SECTION;
179 [ + - ][ + + ]: 126 : else if( IsDefaultStyle() && IsXMLToken( rLocalName, XML_TABLE_PROPERTIES ) )
[ + + ]
180 : 63 : nFamily = XML_TYPE_PROP_TABLE;
181 [ + - ][ + - ]: 63 : else if( IsDefaultStyle() && IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES ) )
[ + - ]
182 : 63 : nFamily = XML_TYPE_PROP_TABLE_ROW;
183 [ + - ]: 1408 : if( nFamily )
184 : : {
185 : : UniReference < SvXMLImportPropertyMapper > xImpPrMap =
186 [ + - ]: 1408 : GetStyles()->GetImportPropertyMapper( GetFamily() );
187 [ + - ]: 1408 : if( xImpPrMap.is() )
188 : 1408 : pContext = new XMLTextPropertySetContext( GetImport(), nPrefix,
189 : : rLocalName, xAttrList,
190 : : nFamily,
191 : 1408 : GetProperties(),
192 : : xImpPrMap,
193 [ + - ][ + - ]: 1408 : sDropCapTextStyleName );
[ + - ]
194 : : }
195 : : }
196 [ # # # # ]: 0 : else if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
[ # # ]
197 : 0 : IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
198 : : {
199 : : // create and remember events import context
200 : : // (for delayed processing of events)
201 : 0 : pEventContext = new XMLEventsImportContext( GetImport(), nPrefix,
202 [ # # ]: 0 : rLocalName);
203 : 0 : pEventContext->AddRef();
204 : 0 : pContext = pEventContext;
205 : : }
206 : :
207 [ - + ]: 1408 : if( !pContext )
208 : : pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName,
209 : 0 : xAttrList );
210 : :
211 : 1408 : return pContext;
212 : : }
213 : :
214 : 909 : void XMLTextStyleContext::CreateAndInsert( sal_Bool bOverwrite )
215 : : {
216 [ + - ]: 909 : XMLPropStyleContext::CreateAndInsert( bOverwrite );
217 : 909 : Reference < XStyle > xStyle = GetStyle();
218 [ - + ][ # # ]: 909 : if( !xStyle.is() || !(bOverwrite || IsNew()) )
[ + + ][ + + ]
219 : 909 : return;
220 : :
221 [ + - ]: 781 : Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
222 : : Reference< XPropertySetInfo > xPropSetInfo =
223 [ + - ][ + - ]: 781 : xPropSet->getPropertySetInfo();
224 [ + - ][ + - ]: 781 : if( xPropSetInfo->hasPropertyByName( sIsAutoUpdate ) )
[ + + ]
225 : : {
226 : 611 : Any aAny;
227 : 611 : sal_Bool bTmp = bAutoUpdate;
228 [ + - ]: 611 : aAny.setValue( &bTmp, ::getBooleanCppuType() );
229 [ + - ][ + - ]: 611 : xPropSet->setPropertyValue( sIsAutoUpdate, aAny );
230 : : }
231 : :
232 : 781 : sal_uInt16 nCategory = ParagraphStyleCategory::TEXT;
233 [ + + + + ]: 1947 : if( XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() &&
[ + + ][ + - ]
[ + - ][ + + ]
234 [ + - ][ + - ]: 1142 : !sCategoryVal.isEmpty() && xStyle->isUserDefined() &&
235 [ + - ][ + - ]: 12 : xPropSetInfo->hasPropertyByName( sCategory ) &&
236 [ + - ]: 12 : SvXMLUnitConverter::convertEnum( nCategory, sCategoryVal, aCategoryMap ) )
237 : : {
238 : 12 : Any aAny;
239 [ + - ]: 12 : aAny <<= (sal_Int16)nCategory;
240 [ + - ][ + - ]: 12 : xPropSet->setPropertyValue( sCategory, aAny );
241 : : }
242 : :
243 : : // tell the style about it's events (if applicable)
244 [ - + ]: 781 : if (NULL != pEventContext)
245 : : {
246 : : // set event suppplier and release reference to context
247 [ # # ]: 0 : Reference<document::XEventsSupplier> xEventsSupplier(xStyle,UNO_QUERY);
248 [ # # ]: 0 : pEventContext->SetEvents(xEventsSupplier);
249 [ # # ]: 0 : pEventContext->ReleaseRef();
250 : : }
251 : :
252 : : // XML import: reconstrution of assignment of paragraph style to outline levels (#i69629#)
253 [ + + ]: 781 : if ( nOutlineLevel > 0 )
254 : : {
255 : 12 : GetImport().GetTextImport()->AddOutlineStyleCandidate( nOutlineLevel,
256 [ + - ][ + - ]: 24 : GetDisplayName() );
[ + - ][ + - ]
257 [ + + ]: 909 : }
258 : : }
259 : :
260 : 189 : void XMLTextStyleContext::SetDefaults( )
261 : : {
262 [ + + + + : 378 : if( ( GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ) ||
+ - ][ + - ]
263 : 126 : ( GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE ) ||
264 : 63 : ( GetFamily() == XML_STYLE_FAMILY_TABLE_ROW ) )
265 : : {
266 [ + - ]: 189 : Reference < XMultiServiceFactory > xFactory ( GetImport().GetModel(), UNO_QUERY);
267 [ + - ]: 189 : if (xFactory.is())
268 : : {
269 [ + - ]: 189 : Reference < XInterface > xInt = xFactory->createInstance (
270 [ + - ][ + - ]: 189 : OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) ) );
271 [ + - ]: 189 : Reference < XPropertySet > xProperties ( xInt, UNO_QUERY );
272 [ + - ]: 189 : if ( xProperties.is() )
273 [ + - ]: 189 : FillPropertySet ( xProperties );
274 : 189 : }
275 : : }
276 : 189 : }
277 : :
278 : 811 : void XMLTextStyleContext::Finish( sal_Bool bOverwrite )
279 : : {
280 [ + - ]: 811 : XMLPropStyleContext::Finish( bOverwrite );
281 : :
282 : 811 : Reference < XStyle > xStyle = GetStyle();
283 : : // Consider set empty list style (#i69523#)
284 [ - + ][ + + ]: 1622 : if ( !( mbListStyleSet ||
[ + + + - ]
285 : : nOutlineLevel >= 0 ||
286 : 745 : !sDropCapTextStyleName.isEmpty() ||
287 [ + + + - ]: 1529 : bHasMasterPageName ) ||
[ + + ]
288 : 90 : !xStyle.is() ||
289 [ # # ]: 0 : !( bOverwrite || IsNew() ) )
290 : 811 : return;
291 : :
292 [ + - ]: 90 : Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
293 : : Reference< XPropertySetInfo > xPropSetInfo =
294 [ + - ][ + - ]: 90 : xPropSet->getPropertySetInfo();
295 : :
296 [ + - ][ + - ]: 90 : if( xPropSetInfo->hasPropertyByName( sOutlineLevel ))
[ + - ]
297 : : {
298 : 90 : Any aAny;
299 [ + + ]: 90 : if( nOutlineLevel >= 0 )
300 : : {
301 [ + - ]: 42 : aAny <<= nOutlineLevel;
302 [ + - ][ + - ]: 42 : xPropSet->setPropertyValue( sOutlineLevel, aAny );
303 : 90 : }
304 : : }
305 : :
306 : : // Consider set empty list style (#i69523#)
307 [ + + ][ + - ]: 117 : if ( mbListStyleSet &&
[ + + ]
308 [ + - ][ + - ]: 27 : xPropSetInfo->hasPropertyByName( sNumberingStyleName ) )
309 : : {
310 : : /* Only for text document from version prior OOo 2.1 resp. SO 8 PU5:
311 : : - Do not apply list style, if paragraph style has a default outline
312 : : level > 0 and thus, will be assigned to the corresponding list
313 : : level of the outline style. (#i70223#)
314 : : */
315 : 27 : bool bApplyListStyle( true );
316 [ + + ]: 27 : if ( nOutlineLevel > 0 )
317 : : {
318 [ + - ][ - + ]: 3 : if ( GetImport().IsTextDocInOOoFileFormat() )
319 : : {
320 : 0 : bApplyListStyle = false;
321 : : }
322 : : else
323 : : {
324 : 3 : sal_Int32 nUPD( 0 );
325 : 3 : sal_Int32 nBuild( 0 );
326 : : // Check explicitly on certain versions (#i86058#)
327 [ + - ][ - + ]: 3 : if ( GetImport().getBuildIds( nUPD, nBuild ) &&
[ # # ][ # # ]
[ # # ][ # # ]
[ - + ]
328 : : ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
329 : : ( nUPD == 680 && nBuild <= 9073 ) ) ) // OOo 2.0 - OOo 2.0.4
330 : : {
331 : 3 : bApplyListStyle = false;
332 : : }
333 : : }
334 : : }
335 : :
336 [ + - ]: 27 : if ( bApplyListStyle )
337 : : {
338 [ - + ]: 27 : if ( sListStyleName.isEmpty() )
339 : : {
340 : 0 : Any aAny;
341 [ # # ]: 0 : aAny <<= sListStyleName /* empty string */;
342 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( sNumberingStyleName, aAny );
343 : : }
344 : : else
345 : : {
346 : : // change list style name to display name
347 : : OUString sDisplayListStyleName(
348 : 27 : GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_LIST,
349 [ + - ]: 27 : sListStyleName ) );
350 : : // The families container must exist
351 : : const Reference < XNameContainer >& rNumStyles =
352 [ + - ][ + - ]: 27 : GetImport().GetTextImport()->GetNumberingStyles();
[ + - ][ + - ]
353 : : // if( rNumStyles.is() && rNumStyles->hasByName( sDisplayListStyleName ) &&
354 : : // xPropSetInfo->hasPropertyByName( sNumberingStyleName ) )
355 [ + - ][ + - ]: 54 : if ( rNumStyles.is() &&
[ + - ]
356 [ + - ][ + - ]: 27 : rNumStyles->hasByName( sDisplayListStyleName ) )
357 : : {
358 : 27 : Any aAny;
359 [ + - ]: 27 : aAny <<= sDisplayListStyleName;
360 [ + - ][ + - ]: 27 : xPropSet->setPropertyValue( sNumberingStyleName, aAny );
361 : 27 : }
362 : : }
363 : : }
364 : : }
365 : :
366 [ - + ]: 90 : if( !sDropCapTextStyleName.isEmpty() )
367 : : {
368 : : // change list style name to display name
369 : : OUString sDisplayDropCapTextStyleName(
370 : 0 : GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_TEXT,
371 [ # # ]: 0 : sDropCapTextStyleName ) );
372 : : // The families cointaner must exist
373 : : const Reference < XNameContainer >& rTextStyles =
374 [ # # ][ # # ]: 0 : GetImport().GetTextImport()->GetTextStyles();
[ # # ][ # # ]
375 [ # # ][ # # ]: 0 : if( rTextStyles.is() &&
[ # # ][ # # ]
376 [ # # ][ # # ]: 0 : rTextStyles->hasByName( sDisplayDropCapTextStyleName ) &&
377 [ # # ][ # # ]: 0 : xPropSetInfo->hasPropertyByName( sDropCapCharStyleName ) )
378 : : {
379 : 0 : Any aAny;
380 [ # # ]: 0 : aAny <<= sDisplayDropCapTextStyleName;
381 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( sDropCapCharStyleName, aAny );
382 : 0 : }
383 : : }
384 : :
385 [ + + ]: 90 : if( bHasMasterPageName )
386 : : {
387 : : OUString sDisplayName(
388 : 24 : GetImport().GetStyleDisplayName(
389 [ + - ]: 24 : XML_STYLE_FAMILY_MASTER_PAGE, sMasterPageName ) );
390 : : // The families cointaner must exist
391 : : const Reference < XNameContainer >& rPageStyles =
392 [ + - ][ + - ]: 24 : GetImport().GetTextImport()->GetPageStyles();
[ + - ][ + - ]
393 [ - + # # ]: 48 : if( ( sDisplayName.isEmpty() ||
[ # # ][ + - ]
[ + - ]
394 : 0 : (rPageStyles.is() &&
395 [ # # ][ # # ]: 0 : rPageStyles->hasByName( sDisplayName )) ) &&
396 [ + - ][ + - ]: 24 : xPropSetInfo->hasPropertyByName( sPageDescName ) )
397 : : {
398 : 24 : Any aAny;
399 [ + - ]: 24 : aAny <<= sDisplayName;
400 [ + - ][ + - ]: 24 : xPropSet->setPropertyValue( sPageDescName, aAny );
401 : 24 : }
402 [ + + ]: 811 : }
403 : : }
404 : :
405 : 1814 : void XMLTextStyleContext::FillPropertySet(
406 : : const Reference<XPropertySet > & rPropSet )
407 : : {
408 : : // imitate the FillPropertySet of the super class, so we get a chance to
409 : : // catch the combined characters attribute
410 : :
411 : : // imitate XMLPropStyleContext::FillPropertySet(...)
412 : : UniReference < SvXMLImportPropertyMapper > xImpPrMap =
413 [ + - ]: 1814 : ((SvXMLStylesContext *)GetStyles())->GetImportPropertyMapper(GetFamily());
414 : : DBG_ASSERT( xImpPrMap.is(), "Where is the import prop mapper?" );
415 [ + - ]: 1814 : if( xImpPrMap.is() )
416 : : {
417 : :
418 : : // imitate SvXMLImportPropertyMapper::FillPropertySet(...)
419 : :
420 : : // The reason for this is that we have no other way to
421 : : // efficiently intercept the value of combined characters. To
422 : : // get that value, we could iterate through the map once more,
423 : : // but instead we chose to insert the code into this
424 : : // iteration. I haven't been able to come up with a much more
425 : : // intelligent solution.
426 : :
427 : :
428 : : struct _ContextID_Index_Pair aContextIDs[] =
429 : : {
430 : : { CTF_COMBINED_CHARACTERS_FIELD, -1 },
431 : : { CTF_KEEP_TOGETHER, -1 },
432 : : { CTF_BORDER_MODEL, -1 },
433 : : { CTF_TEXT_DISPLAY, -1 },
434 : : { CTF_FONTFAMILYNAME, -1 },
435 : : { CTF_FONTFAMILYNAME_CJK, -1 },
436 : : { CTF_FONTFAMILYNAME_CTL, -1 },
437 : : { -1, -1 }
438 : 1814 : };
439 : :
440 : : // get property set info
441 [ + - ][ + - ]: 1814 : Reference< XPropertySetInfo > xInfo( rPropSet->getPropertySetInfo(), UNO_SET_THROW );
[ + - ]
442 : :
443 : 1814 : bool bAutomatic = false;
444 [ + + + + : 2553 : if( ((SvXMLStylesContext *)GetStyles())->IsAutomaticStyle() &&
+ + ][ + + ]
[ + - ]
445 : 739 : ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT || GetFamily() == XML_STYLE_FAMILY_TEXT_PARAGRAPH ) )
446 : : {
447 : 312 : bAutomatic = true;
448 [ + + ]: 312 : if( !GetAutoName().isEmpty() )
449 : : {
450 : 184 : OUString sAutoProp = ( GetFamily() == XML_STYLE_FAMILY_TEXT_TEXT ) ?
451 : : OUString( RTL_CONSTASCII_USTRINGPARAM("CharAutoStyleName") ):
452 [ + - ][ + - ]: 184 : OUString( RTL_CONSTASCII_USTRINGPARAM("ParaAutoStyleName") );
[ + + ]
453 : : try
454 : : {
455 [ + - ][ + - ]: 184 : if ( xInfo->hasPropertyByName( sAutoProp ) )
[ + + ]
456 [ + - ][ + - ]: 164 : rPropSet->setPropertyValue( sAutoProp, makeAny(GetAutoName()) );
[ + - ]
457 : : else
458 : 20 : bAutomatic = false;
459 : : }
460 [ # # # ]: 0 : catch( const RuntimeException& ) { throw; }
461 [ # # ]: 0 : catch( const Exception& )
462 : : {
463 : : DBG_UNHANDLED_EXCEPTION();
464 : 0 : bAutomatic = false;
465 : 184 : }
466 : : }
467 : : }
468 [ + + ]: 1814 : if( bAutomatic )
469 [ + - ][ + - ]: 292 : xImpPrMap->CheckSpecialContext( GetProperties(), rPropSet, aContextIDs );
470 : : else
471 [ + - ][ + - ]: 1522 : xImpPrMap->FillPropertySet( GetProperties(), rPropSet, aContextIDs );
472 : :
473 : : // have we found a combined characters
474 : 1814 : sal_Int32 nIndex = aContextIDs[0].nIndex;
475 [ - + ]: 1814 : if ( nIndex != -1 )
476 : : {
477 : 0 : Any& rAny = GetProperties()[nIndex].maValue;
478 : 0 : sal_Bool bVal = *(sal_Bool*)rAny.getValue();
479 : 0 : bHasCombinedCharactersLetter = bVal;
480 : : }
481 : :
482 : : // keep-together: the application default is different from
483 : : // the file format default. Hence, if we always set this
484 : : // value; if we didn't find one, we'll set to false, the file
485 : : // format default.
486 : : // border-model: same
487 [ + + ][ + + ]: 1814 : if( IsDefaultStyle() && GetFamily() == XML_STYLE_FAMILY_TABLE_ROW )
[ + + ]
488 : : {
489 : : OUString sIsSplitAllowed =
490 [ + - ]: 63 : OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSplitAllowed" ) );
491 : : DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sIsSplitAllowed ),
492 : : "property missing?" );
493 [ + - ]: 63 : rPropSet->setPropertyValue( sIsSplitAllowed,
494 : : (aContextIDs[1].nIndex == -1)
495 : : ? makeAny( false )
496 [ - + ][ # # ]: 63 : : GetProperties()[aContextIDs[1].nIndex].maValue );
[ + - ][ - + ]
[ # # ]
497 : : }
498 : :
499 [ + + ][ + + ]: 1814 : if( IsDefaultStyle() && GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE )
[ + + ]
500 : : {
501 : : OUString sCollapsingBorders(
502 [ + - ]: 63 : OUString( RTL_CONSTASCII_USTRINGPARAM( "CollapsingBorders" ) ) );
503 : : DBG_ASSERT( rPropSet->getPropertySetInfo()->hasPropertyByName( sCollapsingBorders ),
504 : : "property missing?" );
505 [ + - ]: 63 : rPropSet->setPropertyValue( sCollapsingBorders,
506 : : (aContextIDs[2].nIndex == -1)
507 : : ? makeAny( false )
508 [ - + ][ # # ]: 63 : : GetProperties()[aContextIDs[2].nIndex].maValue );
[ + - ][ - + ]
[ # # ]
509 : : }
510 : :
511 : :
512 : : // check for StarBats and StarMath fonts
513 : :
514 : : // iterate over aContextIDs entries 3..6
515 [ + + ]: 9070 : for ( sal_Int32 i = 3; i < 7; i++ )
516 : : {
517 : 7256 : nIndex = aContextIDs[i].nIndex;
518 [ + + ]: 7256 : if ( nIndex != -1 )
519 : : {
520 : : // Found!
521 : 962 : struct XMLPropertyState& rState = GetProperties()[nIndex];
522 : 962 : Any rAny = rState.maValue;
523 : 962 : sal_Int32 nMapperIndex = rState.mnIndex;
524 : :
525 : : // Now check for font name in rState and set corrected value,
526 : : // if necessary.
527 : 962 : OUString sFontName;
528 : 962 : rAny >>= sFontName;
529 [ + - ]: 962 : if ( !sFontName.isEmpty() )
530 : : {
531 [ + - ]: 962 : OUString sStarBats( RTL_CONSTASCII_USTRINGPARAM("StarBats" ) );
532 [ + - ]: 962 : OUString sStarMath( RTL_CONSTASCII_USTRINGPARAM("StarMath" ) );
533 [ + - - + ]: 1924 : if ( sFontName.equalsIgnoreAsciiCase( sStarBats ) ||
[ - + ]
534 : 962 : sFontName.equalsIgnoreAsciiCase( sStarMath ) )
535 : : {
536 : : // construct new value
537 : : sFontName = OUString(
538 [ # # ]: 0 : RTL_CONSTASCII_USTRINGPARAM("StarSymbol") );
539 : 0 : Any aAny( rAny );
540 [ # # ]: 0 : aAny <<= sFontName;
541 : :
542 : : // get property set mapper
543 : : UniReference<XMLPropertySetMapper> rPropMapper =
544 [ # # ][ # # ]: 0 : xImpPrMap->getPropertySetMapper();
545 : :
546 : : // set property
547 : : OUString rPropertyName(
548 [ # # ][ # # ]: 0 : rPropMapper->GetEntryAPIName(nMapperIndex) );
549 [ # # ][ # # ]: 0 : if ( xInfo->hasPropertyByName( rPropertyName ) )
[ # # ]
550 : : {
551 [ # # ][ # # ]: 0 : rPropSet->setPropertyValue( rPropertyName, aAny );
552 [ # # ]: 0 : }
553 : 962 : }
554 : : // else: "normal" style name -> no correction is necessary
555 : 962 : }
556 : : // else: no style name found -> illegal value -> ignore
557 : : }
558 : 1814 : }
559 [ + - ]: 1814 : }
560 : 1814 : }
561 : :
562 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|