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 : : #include <tools/debug.hxx>
30 : : #include <tools/string.hxx>
31 : : #include <xmloff/nmspmap.hxx>
32 : : #include "xmloff/xmlnmspe.hxx"
33 : : #include <xmloff/xmltoken.hxx>
34 : : #include <xmloff/xmluconv.hxx>
35 : : #include <xmloff/attrlist.hxx>
36 : : #include <xmloff/xmlprmap.hxx>
37 : : #include <xmloff/xmlexppr.hxx>
38 : : #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
39 : : #include <com/sun/star/frame/XModel.hpp>
40 : : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
41 : : #include <com/sun/star/style/XStyle.hpp>
42 : : #include <com/sun/star/container/XNameContainer.hpp>
43 : : #include <com/sun/star/beans/XPropertySet.hpp>
44 : : #include <com/sun/star/beans/XPropertyState.hpp>
45 : : #include <com/sun/star/document/XEventsSupplier.hpp>
46 : : #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
47 : : #include <xmloff/xmlaustp.hxx>
48 : : #include <xmloff/styleexp.hxx>
49 : : #include <xmloff/xmlexp.hxx>
50 : : #include <xmloff/XMLEventExport.hxx>
51 : : #include <set>
52 : : #include <boost/scoped_ptr.hpp>
53 : :
54 : : using ::rtl::OUString;
55 : : using ::rtl::OUStringBuffer;
56 : :
57 : : using namespace ::com::sun::star;
58 : : using namespace ::com::sun::star::uno;
59 : : using namespace ::com::sun::star::style;
60 : : using namespace ::com::sun::star::container;
61 : : using namespace ::com::sun::star::beans;
62 : : using namespace ::com::sun::star::text;
63 : : using namespace ::xmloff::token;
64 : :
65 : : using ::com::sun::star::document::XEventsSupplier;
66 : :
67 : 130 : XMLStyleExport::XMLStyleExport(
68 : : SvXMLExport& rExp,
69 : : const ::rtl::OUString& rPoolStyleName,
70 : : SvXMLAutoStylePoolP *pAutoStyleP ) :
71 : : rExport( rExp ),
72 : : sIsPhysical( RTL_CONSTASCII_USTRINGPARAM( "IsPhysical" ) ),
73 : : sIsAutoUpdate( RTL_CONSTASCII_USTRINGPARAM( "IsAutoUpdate" ) ),
74 : : sFollowStyle( RTL_CONSTASCII_USTRINGPARAM( "FollowStyle" ) ),
75 : : sNumberingStyleName( RTL_CONSTASCII_USTRINGPARAM( "NumberingStyleName" ) ),
76 : : sOutlineLevel( RTL_CONSTASCII_USTRINGPARAM( "OutlineLevel" ) ),
77 : : sPoolStyleName( rPoolStyleName ),
78 [ + - ][ + - ]: 130 : pAutoStylePool( pAutoStyleP )
[ + - ][ + - ]
[ + - ]
79 : : {
80 : 130 : }
81 : :
82 : 130 : XMLStyleExport::~XMLStyleExport()
83 : : {
84 [ - + ]: 130 : }
85 : :
86 : 236 : void XMLStyleExport::exportStyleAttributes( const Reference< XStyle >& )
87 : : {
88 : 236 : }
89 : :
90 : 236 : void XMLStyleExport::exportStyleContent( const Reference< XStyle >& )
91 : : {
92 : 236 : }
93 : :
94 : 3556 : sal_Bool XMLStyleExport::exportStyle(
95 : : const Reference< XStyle >& rStyle,
96 : : const OUString& rXMLFamily,
97 : : const UniReference < SvXMLExportPropertyMapper >& rPropMapper,
98 : : const Reference< XNameAccess >& xStyles,
99 : : const OUString* pPrefix )
100 : : {
101 [ + - ]: 3556 : Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
102 : : Reference< XPropertySetInfo > xPropSetInfo =
103 [ + - ][ + - ]: 3556 : xPropSet->getPropertySetInfo();
104 : 3556 : Any aAny;
105 : :
106 : : // Don't export styles that aren't existing really. This may be the
107 : : // case for StarOffice Writer's pool styles.
108 [ + - ][ + + ]: 3556 : if( xPropSetInfo->hasPropertyByName( sIsPhysical ) )
[ + - ]
109 : : {
110 [ + - ][ + - ]: 3300 : aAny = xPropSet->getPropertyValue( sIsPhysical );
111 [ + + ]: 3300 : if( !*(sal_Bool *)aAny.getValue() )
112 : 3144 : return sal_False;
113 : : }
114 : :
115 : : // <style:style ...>
116 : 412 : GetExport().CheckAttrList();
117 : :
118 : : // style:name="..."
119 : 412 : OUString sName;
120 : :
121 [ + + ]: 412 : if(pPrefix)
122 : 56 : sName = *pPrefix;
123 [ + - ][ + - ]: 412 : sName += rStyle->getName();
124 : :
125 : 412 : sal_Bool bEncoded = sal_False;
126 [ + - ]: 412 : const OUString sEncodedStyleName(GetExport().EncodeStyleName( sName, &bEncoded ));
127 [ + - ]: 412 : GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, sEncodedStyleName );
128 : :
129 [ + + ]: 412 : if( bEncoded )
130 : 57 : GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_DISPLAY_NAME,
131 [ + - ]: 57 : sName);
132 : :
133 : : // style:family="..."
134 [ + - ]: 412 : if( !rXMLFamily.isEmpty() )
135 [ + - ]: 412 : GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, rXMLFamily);
136 : :
137 : : // style:parent-style-name="..."
138 [ + - ][ + - ]: 412 : OUString sParentString(rStyle->getParentStyle());
139 : 412 : OUString sParent;
140 : :
141 [ + + ]: 412 : if(!sParentString.isEmpty())
142 : : {
143 [ + + ]: 346 : if(pPrefix)
144 : 32 : sParent = *pPrefix;
145 : 346 : sParent += sParentString;
146 : : }
147 : : else
148 : 66 : sParent = sPoolStyleName;
149 : :
150 [ + + ]: 412 : if( !sParent.isEmpty() )
151 : 346 : GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_PARENT_STYLE_NAME,
152 [ + - + - ]: 692 : GetExport().EncodeStyleName( sParent ) );
153 : :
154 : : // style:next-style-name="..." (paragraph styles only)
155 [ + - ][ + - ]: 412 : if( xPropSetInfo->hasPropertyByName( sFollowStyle ) )
[ + + ]
156 : : {
157 [ + - ][ + - ]: 139 : aAny = xPropSet->getPropertyValue( sFollowStyle );
158 : 139 : OUString sNextName;
159 : 139 : aAny >>= sNextName;
160 [ + + ]: 139 : if( sName != sNextName )
161 : : {
162 : 19 : GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NEXT_STYLE_NAME,
163 [ + - + - ]: 38 : GetExport().EncodeStyleName( sNextName ) );
164 : 139 : }
165 : : }
166 : :
167 : : // style:auto-update="..." (SW only)
168 [ + - ][ + - ]: 412 : if( xPropSetInfo->hasPropertyByName( sIsAutoUpdate ) )
[ + + ]
169 : : {
170 [ + - ][ + - ]: 139 : aAny = xPropSet->getPropertyValue( sIsAutoUpdate );
171 [ - + ]: 139 : if( *(sal_Bool *)aAny.getValue() )
172 : 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_AUTO_UPDATE,
173 [ # # ]: 0 : XML_TRUE );
174 : : }
175 : :
176 : : // style:default-outline-level"..."
177 : 412 : sal_Int32 nOutlineLevel = 0;
178 [ + - ][ + - ]: 412 : if( xPropSetInfo->hasPropertyByName( sOutlineLevel ) )
[ + + ]
179 : : {
180 [ + - ]: 139 : Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
181 [ + - ][ + - ]: 139 : if( PropertyState_DIRECT_VALUE == xPropState->getPropertyState( sOutlineLevel ) )
[ + + ]
182 : : {
183 [ + - ][ + - ]: 12 : aAny = xPropSet->getPropertyValue( sOutlineLevel );
184 : 12 : aAny >>= nOutlineLevel;
185 [ - + ]: 12 : if( nOutlineLevel > 0 )
186 : : {
187 : 0 : OUStringBuffer sTmp;
188 [ # # ]: 0 : sTmp.append( static_cast<sal_Int32>(nOutlineLevel));
189 : 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
190 : : XML_DEFAULT_OUTLINE_LEVEL,
191 [ # # # # ]: 0 : sTmp.makeStringAndClear() );
192 : : }
193 : : else
194 : : {
195 : : /* Empty value for style:default-outline-level does exist
196 : : since ODF 1.2. Thus, suppress its export for former versions. (#i104889#)
197 : : */
198 [ + - ][ + - ]: 24 : if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) != 0 &&
[ + - ]
199 [ + - ]: 12 : GetExport().getDefaultVersion() >= SvtSaveOptions::ODFVER_012 )
200 : : {
201 : 12 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
202 : : XML_DEFAULT_OUTLINE_LEVEL,
203 [ + - + - ]: 24 : OUString( RTL_CONSTASCII_USTRINGPARAM( "" )));
204 : : }
205 : : }
206 : 139 : }
207 : : }
208 : :
209 : : // style:list-style-name="..." (SW paragarph styles only)
210 [ + - ][ + - ]: 412 : if( xPropSetInfo->hasPropertyByName( sNumberingStyleName ) )
[ + + ]
211 : : {
212 [ + - ]: 139 : Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
213 [ - + ]: 139 : if( PropertyState_DIRECT_VALUE ==
214 [ + - ][ + - ]: 139 : xPropState->getPropertyState( sNumberingStyleName ) )
215 : : {
216 [ # # ][ # # ]: 0 : aAny = xPropSet->getPropertyValue( sNumberingStyleName );
217 [ # # ]: 0 : if( aAny.hasValue() )
218 : : {
219 : 0 : OUString sListName;
220 : 0 : aAny >>= sListName;
221 : :
222 : : /* An direct set empty list style has to be written. Otherwise,
223 : : this information is lost and causes an error, if the parent
224 : : style has a list style set. (#i69523#)
225 : : */
226 [ # # ]: 0 : if ( sListName.isEmpty() )
227 : : {
228 : 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
229 : : XML_LIST_STYLE_NAME,
230 [ # # ]: 0 : sListName /* empty string */);
231 : : }
232 : : else
233 : : {
234 : : // Written OpenDocument file format doesn't fit to the created text document (#i69627#)
235 : 0 : bool bSuppressListStyle( false );
236 : : {
237 [ # # ][ # # ]: 0 : if ( !GetExport().writeOutlineStyleAsNormalListStyle() )
238 : : {
239 : : Reference< XChapterNumberingSupplier > xCNSupplier
240 [ # # ]: 0 : (GetExport().GetModel(), UNO_QUERY);
241 : :
242 : 0 : OUString sOutlineName;
243 [ # # ]: 0 : if (xCNSupplier.is())
244 : : {
245 : : Reference< XIndexReplace > xNumRule
246 [ # # ][ # # ]: 0 : ( xCNSupplier->getChapterNumberingRules() );
247 : : DBG_ASSERT( xNumRule.is(), "no chapter numbering rules" );
248 : :
249 [ # # ]: 0 : if (xNumRule.is())
250 : : {
251 : : Reference< XPropertySet > xNumRulePropSet
252 [ # # ]: 0 : (xNumRule, UNO_QUERY);
253 [ # # ]: 0 : xNumRulePropSet->getPropertyValue(
254 : 0 : OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) )
255 [ # # ][ # # ]: 0 : >>= sOutlineName;
256 : 0 : bSuppressListStyle = ( sListName == sOutlineName );
257 : 0 : }
258 : 0 : }
259 : : }
260 : : }
261 : :
262 [ # # ][ # # ]: 0 : if ( !sListName.isEmpty() && !bSuppressListStyle )
[ # # ]
263 : : {
264 : 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
265 : : XML_LIST_STYLE_NAME,
266 [ # # # # ]: 0 : GetExport().EncodeStyleName( sListName ) );
267 : : }
268 : 0 : }
269 : : }
270 : : }
271 [ - + ]: 139 : else if( nOutlineLevel > 0 )
272 : : {
273 : :
274 : 0 : bool bNoInheritedListStyle( true );
275 : :
276 : : /////////////////////////////////////////////////
277 [ # # ]: 0 : Reference<XStyle> xStyle( xPropState, UNO_QUERY );
278 [ # # ]: 0 : while ( xStyle.is() )
279 : : {
280 [ # # ][ # # ]: 0 : OUString aParentStyle( xStyle->getParentStyle() );
281 [ # # ][ # # ]: 0 : if ( aParentStyle.isEmpty() || !xStyles->hasByName( aParentStyle ) )
[ # # ][ # # ]
[ # # ]
282 : : {
283 : : break;
284 : : }
285 : : else
286 : : {
287 [ # # ][ # # ]: 0 : xPropState = Reference< XPropertyState >( xStyles->getByName( aParentStyle ), UNO_QUERY );
[ # # ][ # # ]
288 [ # # ]: 0 : if ( !xPropState.is() )
289 : : {
290 : : break;
291 : : }
292 [ # # ][ # # ]: 0 : if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
[ # # ]
293 : : {
294 : 0 : bNoInheritedListStyle = false;
295 : : break;
296 : : }
297 : : else
298 : : {
299 [ # # ][ # # ]: 0 : xStyle = Reference<XStyle>( xPropState, UNO_QUERY );
[ # # ]
300 : : }
301 : : }
302 : 0 : }
303 : : /////////////////////////////////////////////////
304 [ # # ]: 0 : if ( bNoInheritedListStyle )
305 : 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
306 : : XML_LIST_STYLE_NAME,
307 [ # # # # ]: 0 : OUString( RTL_CONSTASCII_USTRINGPARAM( "" )));
308 : 139 : }
309 : : }
310 : :
311 : : // style:pool-id="..." is not required any longer since we use
312 : : // english style names only
313 [ + - ]: 412 : exportStyleAttributes( rStyle );
314 : :
315 : : // TODO: style:help-file-name="..." and style:help-id="..." can neither
316 : : // be modified by UI nor by API and that for, have not to be exported
317 : : // currently.
318 : :
319 : : {
320 : : // <style:style>
321 : 412 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE, XML_STYLE,
322 [ + - ]: 412 : sal_True, sal_True );
323 : :
324 [ + - ]: 412 : rPropMapper->SetStyleName( sName );
325 : :
326 : : // <style:properties>
327 : : ::std::vector< XMLPropertyState > xPropStates =
328 [ + - ][ + - ]: 412 : rPropMapper->Filter( xPropSet );
329 : 412 : rPropMapper->exportXML( GetExport(), xPropStates,
330 [ + - ][ + - ]: 412 : XML_EXPORT_FLAG_IGN_WS );
331 : :
332 [ + - ]: 412 : rPropMapper->SetStyleName( OUString() );
333 : :
334 [ + - ]: 412 : exportStyleContent( rStyle );
335 : :
336 : : // <script:events>, if they are supported by this style
337 [ + - ]: 412 : Reference<XEventsSupplier> xEventsSupp(rStyle, UNO_QUERY);
338 [ + - ][ + - ]: 412 : GetExport().GetEventExport().Export(xEventsSupp);
[ + - ]
339 : : }
340 : 3556 : return sal_True;
341 : : }
342 : :
343 : 100 : sal_Bool XMLStyleExport::exportDefaultStyle(
344 : : const Reference< XPropertySet >& xPropSet,
345 : : const OUString& rXMLFamily,
346 : : const UniReference < SvXMLExportPropertyMapper >& rPropMapper )
347 : : {
348 : : Reference< XPropertySetInfo > xPropSetInfo =
349 [ + - ][ + - ]: 100 : xPropSet->getPropertySetInfo();
350 : :
351 : 100 : Any aAny;
352 : :
353 : : // <style:default-style ...>
354 : 100 : GetExport().CheckAttrList();
355 : :
356 : : {
357 : : // style:family="..."
358 [ + - ]: 100 : if( !rXMLFamily.isEmpty() )
359 : 100 : GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY,
360 [ + - ]: 100 : rXMLFamily );
361 : : // <style:style>
362 : 100 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
363 : : XML_DEFAULT_STYLE,
364 [ + - ]: 100 : sal_True, sal_True );
365 : : // <style:properties>
366 : : ::std::vector< XMLPropertyState > xPropStates =
367 [ + - ][ + - ]: 100 : rPropMapper->FilterDefaults( xPropSet );
368 : 100 : rPropMapper->exportXML( GetExport(), xPropStates,
369 [ + - ][ + - ]: 100 : XML_EXPORT_FLAG_IGN_WS );
[ + - ]
370 : : }
371 : 100 : return sal_True;
372 : : }
373 : :
374 : 108 : void XMLStyleExport::exportStyleFamily(
375 : : const sal_Char *pFamily,
376 : : const OUString& rXMLFamily,
377 : : const UniReference < SvXMLExportPropertyMapper >& rPropMapper,
378 : : sal_Bool bUsed, sal_uInt16 nFamily, const OUString* pPrefix)
379 : : {
380 : 108 : const OUString sFamily(OUString::createFromAscii(pFamily ));
381 : : exportStyleFamily( sFamily, rXMLFamily, rPropMapper, bUsed, nFamily,
382 [ + - ]: 108 : pPrefix);
383 : 108 : }
384 : :
385 : 116 : void XMLStyleExport::exportStyleFamily(
386 : : const OUString& rFamily, const OUString& rXMLFamily,
387 : : const UniReference < SvXMLExportPropertyMapper >& rPropMapper,
388 : : sal_Bool bUsed, sal_uInt16 nFamily, const OUString* pPrefix)
389 : : {
390 : : DBG_ASSERT( GetExport().GetModel().is(), "There is the model?" );
391 [ + - ]: 116 : Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetExport().GetModel(), UNO_QUERY );
392 [ - + ]: 116 : if( !xFamiliesSupp.is() )
393 : : return; // family not available in current model
394 : :
395 : 116 : Reference< XNameAccess > xStyleCont;
396 : :
397 [ + - ][ + - ]: 116 : Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
398 [ + - ][ + - ]: 116 : if( xFamilies->hasByName( rFamily ) )
[ + + ]
399 [ + - ][ + - ]: 95 : xFamilies->getByName( rFamily ) >>= xStyleCont;
[ + - ]
400 : :
401 [ + + ]: 116 : if( !xStyleCont.is() )
402 : : return;
403 : :
404 [ + - ]: 95 : Reference< XNameAccess > xStyles( xStyleCont, UNO_QUERY );
405 : : // If next styles are supported and used styles should be exported only,
406 : : // the next style may be unused but has to be exported, too. In this case
407 : : // the names of all exported styles are remembered.
408 : 95 : boost::scoped_ptr<std::set<String> > pExportedStyles(0);
409 : 95 : sal_Bool bFirstStyle = sal_True;
410 : :
411 [ + - ][ + - ]: 95 : const uno::Sequence< ::rtl::OUString> aSeq = xStyles->getElementNames();
412 : 95 : const ::rtl::OUString* pIter = aSeq.getConstArray();
413 : 95 : const ::rtl::OUString* pEnd = pIter + aSeq.getLength();
414 [ + + ]: 4059 : for(;pIter != pEnd;++pIter)
415 : : {
416 : 3964 : Reference< XStyle > xStyle;
417 : : try
418 : : {
419 [ + - ][ + - ]: 3964 : xStyles->getByName( *pIter ) >>= xStyle;
[ # # ][ + - ]
420 : : }
421 [ # # ]: 0 : catch(const lang::IndexOutOfBoundsException&)
422 : : {
423 : : // due to bugs in prior versions it is possible that
424 : : // a binary file is missing some critical styles.
425 : : // The only possible way to deal with this is to
426 : : // not export them here and remain silent.
427 : 0 : continue;
428 : : }
429 : :
430 : : DBG_ASSERT( xStyle.is(), "Style not found for export!" );
431 [ + - ]: 3964 : if( xStyle.is() )
432 : : {
433 [ + + ][ + - ]: 3964 : if( !bUsed || xStyle->isInUse() )
[ + - ][ - + ]
[ + + ]
434 : : {
435 : : sal_Bool bExported = exportStyle( xStyle, rXMLFamily, rPropMapper,
436 [ + - ]: 3556 : xStyles,pPrefix );
437 [ - + ][ # # ]: 3556 : if( bUsed && bFirstStyle && bExported )
[ # # ]
438 : : {
439 : : // If this is the first style, find out whether next styles
440 : : // are supported.
441 [ # # ]: 0 : Reference< XPropertySet > xPropSet( xStyle, UNO_QUERY );
442 : : Reference< XPropertySetInfo > xPropSetInfo =
443 [ # # ][ # # ]: 0 : xPropSet->getPropertySetInfo();
444 : :
445 [ # # ][ # # ]: 0 : if( xPropSetInfo->hasPropertyByName( sFollowStyle ) )
[ # # ]
446 [ # # ][ # # ]: 0 : pExportedStyles.reset(new std::set<String>());
[ # # ]
447 : 0 : bFirstStyle = sal_False;
448 : : }
449 : :
450 [ - + ][ # # ]: 3556 : if( pExportedStyles && bExported )
[ - + ]
451 : : {
452 : : // If next styles are supported, remember this style's name.
453 [ # # ][ # # ]: 0 : pExportedStyles->insert( xStyle->getName() );
[ # # ][ # # ]
[ # # ]
454 : : }
455 : : }
456 : :
457 : : // if an auto style pool is given, remember this style's name as a
458 : : // style name that must not be used by automatic styles.
459 [ + - ]: 3964 : if( pAutoStylePool )
460 [ + - ][ + - ]: 3964 : pAutoStylePool->RegisterName( nFamily, xStyle->getName() );
[ + - ]
461 : : }
462 [ + - ]: 3964 : }
463 : :
464 [ - + ]: 95 : if( pExportedStyles )
465 : : {
466 : : // if next styles are supported, export all next styles that are
467 : : // unused and that for, haven't been exported in the first loop.
468 : 0 : pIter = aSeq.getConstArray();
469 [ # # ]: 0 : for(;pIter != pEnd;++pIter)
470 : : {
471 : 0 : Reference< XStyle > xStyle;
472 [ # # ][ # # ]: 0 : xStyles->getByName( *pIter ) >>= xStyle;
[ # # ]
473 : :
474 : : DBG_ASSERT( xStyle.is(), "Style not found for export!" );
475 [ # # ]: 0 : if( xStyle.is() )
476 : : {
477 [ # # ]: 0 : Reference< XPropertySet > xPropSet( xStyle, UNO_QUERY );
478 [ # # ][ # # ]: 0 : Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
479 : :
480 : : // styles that aren't existing realy are ignored.
481 [ # # ][ # # ]: 0 : if( xPropSetInfo->hasPropertyByName( sIsPhysical ) )
[ # # ]
482 : : {
483 [ # # ][ # # ]: 0 : Any aAny( xPropSet->getPropertyValue( sIsPhysical ) );
484 [ # # ]: 0 : if( !*(sal_Bool *)aAny.getValue() )
485 [ # # ]: 0 : continue;
486 : : }
487 : :
488 [ # # ][ # # ]: 0 : if( !xStyle->isInUse() )
[ # # ]
489 : 0 : continue;
490 : :
491 [ # # ][ # # ]: 0 : if( !xPropSetInfo->hasPropertyByName( sFollowStyle ) )
[ # # ]
492 : : {
493 : : DBG_ASSERT( sFollowStyle.isEmpty(), "no follow style???" );
494 : 0 : continue;
495 : : }
496 : :
497 : 0 : OUString sNextName;
498 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( sFollowStyle ) >>= sNextName;
499 [ # # ]: 0 : String sTmp( sNextName );
500 : : // if the next style hasn't been exported by now, export it now
501 : : // and remember its name.
502 [ # # ][ # # ]: 0 : if( xStyle->getName() != sNextName &&
[ # # ][ # # ]
[ # # ]
[ # # # # ]
503 [ # # ]: 0 : 0 == pExportedStyles->count( sTmp ) )
504 : : {
505 [ # # ][ # # ]: 0 : xStyleCont->getByName( sNextName ) >>= xStyle;
[ # # ]
506 : : DBG_ASSERT( xStyle.is(), "Style not found for export!" );
507 : :
508 [ # # ][ # # ]: 0 : if( xStyle.is() && exportStyle( xStyle, rXMLFamily, rPropMapper, xStyles,pPrefix ) )
[ # # ][ # # ]
509 [ # # ]: 0 : pExportedStyles->insert( sTmp );
510 [ # # ][ # # ]: 0 : }
[ # # ]
511 : : }
512 [ # # ]: 0 : }
513 [ + - ][ + - ]: 116 : }
[ + + ][ + + ]
[ + + ]
514 : : }
515 : :
516 : :
517 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|