xref: /trunk/main/sw/source/filter/xml/xmlfmt.cxx (revision 870262e3)
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 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <rtl/ustrbuf.hxx>
29 #include <tools/urlobj.hxx>
30 
31 #ifndef _SVSTDARR_STRINGSSORT_DECL
32 #define _SVSTDARR_STRINGSSORT
33 #include <svl/svstdarr.hxx>
34 #endif
35 #include <xmloff/nmspmap.hxx>
36 #include <format.hxx>
37 #include <fmtcol.hxx>
38 #include <hints.hxx>
39 #include <poolfmt.hxx>
40 #include <charfmt.hxx>
41 #include <paratr.hxx>
42 #include <doc.hxx>
43 #include "docary.hxx"
44 #include "unostyle.hxx"
45 #include "fmtpdsc.hxx"
46 #include "pagedesc.hxx"
47 #include <xmloff/xmlnmspe.hxx>
48 #include <xmloff/i18nmap.hxx>
49 #include <xmloff/xmltkmap.hxx>
50 #include "xmlitem.hxx"
51 #include <xmloff/xmlstyle.hxx>
52 #include <xmloff/txtstyli.hxx>
53 #include <xmloff/txtimp.hxx>
54 #include <xmloff/families.hxx>
55 #include <xmloff/XMLTextMasterStylesContext.hxx>
56 #include <xmloff/XMLTextShapeStyleContext.hxx>
57 #include <xmloff/XMLGraphicsDefaultStyle.hxx>
58 #include "xmlimp.hxx"
59 #include "xmltbli.hxx"
60 #include "cellatr.hxx"
61 #include <SwStyleNameMapper.hxx>
62 #include <xmloff/attrlist.hxx>
63 #include <unotxdoc.hxx>
64 #include <docsh.hxx>
65 
66 
67 using namespace ::com::sun::star;
68 using ::rtl::OUString;
69 using ::rtl::OUStringBuffer;
70 using namespace ::xmloff::token;
71 
72 class SwXMLConditionParser_Impl
73 {
74 	OUString sInput;
75 
76 	sal_uInt32 nCondition;
77 	sal_uInt32 nSubCondition;
78 
79 	sal_Int32 nPos;
80 	sal_Int32 nLength;
81 
82 	inline sal_Bool SkipWS();
83 	inline sal_Bool MatchChar( sal_Unicode c );
84 	inline sal_Bool MatchName( OUString& rName );
85 	inline sal_Bool MatchNumber( sal_uInt32& rNumber );
86 
87 public:
88 
89 	SwXMLConditionParser_Impl( const OUString& rInp );
90 
IsValid() const91 	sal_Bool IsValid() const { return 0 != nCondition; }
92 
GetCondition() const93 	sal_uInt32 GetCondition() const { return nCondition; }
GetSubCondition() const94 	sal_uInt32 GetSubCondition() const { return nSubCondition; }
95 };
96 
SkipWS()97 inline sal_Bool SwXMLConditionParser_Impl::SkipWS()
98 {
99 	while( nPos < nLength && ' ' == sInput[nPos] )
100 		nPos++;
101 	return sal_True;
102 }
103 
MatchChar(sal_Unicode c)104 inline sal_Bool SwXMLConditionParser_Impl::MatchChar( sal_Unicode c )
105 {
106 	sal_Bool bRet = sal_False;
107 	if(	nPos < nLength && c == sInput[nPos] )
108 	{
109 		nPos++;
110 		bRet = sal_True;
111 	}
112 	return bRet;
113 }
114 
MatchName(OUString & rName)115 inline sal_Bool SwXMLConditionParser_Impl::MatchName( OUString& rName )
116 {
117 	OUStringBuffer sBuffer( nLength );
118 	while( nPos < nLength &&
119 		   ( ('a' <= sInput[nPos] && sInput[nPos] <= 'z') ||
120 		 	 '-' == sInput[nPos] ) )
121 	{
122 		sBuffer.append( sInput[nPos] );
123 		nPos++;
124 	}
125 	rName = sBuffer.makeStringAndClear();
126 	return rName.getLength() > 0;
127 }
128 
MatchNumber(sal_uInt32 & rNumber)129 inline sal_Bool SwXMLConditionParser_Impl::MatchNumber( sal_uInt32& rNumber )
130 {
131 	OUStringBuffer sBuffer( nLength );
132 	while( nPos < nLength && '0' <= sInput[nPos] && sInput[nPos] <= '9' )
133 	{
134 		sBuffer.append( sInput[nPos] );
135 		nPos++;
136 	}
137 
138 	OUString sNum( sBuffer.makeStringAndClear() );
139 	if( sNum.getLength() )
140 		rNumber = sNum.toInt32();
141 	return sNum.getLength() > 0;
142 }
143 
SwXMLConditionParser_Impl(const OUString & rInp)144 SwXMLConditionParser_Impl::SwXMLConditionParser_Impl( const OUString& rInp ) :
145 	sInput( rInp ),
146 	nCondition( 0 ),
147 	nSubCondition( 0 ),
148 	nPos( 0 ),
149 	nLength( rInp.getLength() )
150 {
151 	OUString sFunc;
152 	sal_Bool bHasSub = sal_False;
153 	sal_uInt32 nSub = 0;
154 	sal_Bool bOK = SkipWS() && MatchName( sFunc ) && SkipWS() &&
155 			   MatchChar( '(' ) && SkipWS() && MatchChar( ')' ) && SkipWS();
156 	if( bOK && MatchChar( '=' ) )
157 	{
158 		bOK = SkipWS() && MatchNumber( nSub ) && SkipWS();
159 		bHasSub = sal_True;
160 	}
161 
162 	bOK &= nPos == nLength;
163 
164 	if( bOK )
165 	{
166         if( IsXMLToken( sFunc, XML_ENDNOTE ) && !bHasSub )
167             nCondition = PARA_IN_ENDNOTE;
168         else if( IsXMLToken( sFunc, XML_FOOTER ) && !bHasSub )
169             nCondition = PARA_IN_FOOTER;
170         else if( IsXMLToken( sFunc, XML_FOOTNOTE ) && !bHasSub )
171             nCondition = PARA_IN_FOOTENOTE;
172         else if( IsXMLToken( sFunc, XML_HEADER ) && !bHasSub )
173             nCondition = PARA_IN_HEADER;
174         else if( IsXMLToken( sFunc, XML_LIST_LEVEL) &&
175 				nSub >=1 && nSub <= MAXLEVEL )
176 		{
177             nCondition = PARA_IN_LIST;
178             nSubCondition = nSub-1;
179         }
180         else if( IsXMLToken( sFunc, XML_OUTLINE_LEVEL) &&
181                  nSub >=1 && nSub <= MAXLEVEL )
182 		{
183             nCondition = PARA_IN_OUTLINE;
184             nSubCondition = nSub-1;
185         }
186         else if( IsXMLToken( sFunc, XML_SECTION ) && !bHasSub )
187 		{
188             nCondition = PARA_IN_SECTION;
189         }
190         else if( IsXMLToken( sFunc, XML_TABLE ) && !bHasSub )
191         {
192             nCondition = PARA_IN_TABLEBODY;
193         }
194         else if( IsXMLToken( sFunc, XML_TABLE_HEADER ) && !bHasSub )
195 		{
196             nCondition = PARA_IN_TABLEHEAD;
197         }
198         else if( IsXMLToken( sFunc, XML_TEXT_BOX ) && !bHasSub )
199 		{
200             nCondition = PARA_IN_FRAME;
201         }
202 	}
203 }
204 
205 // ---------------------------------------------------------------------
206 
207 class SwXMLConditionContext_Impl : public SvXMLImportContext
208 {
209 	sal_uInt32 nCondition;
210 	sal_uInt32 nSubCondition;
211 
212 	OUString sApplyStyle;
213 
214 	void ParseCondition( const OUString& rCond );
215 
216 public:
217 
218 	SwXMLConditionContext_Impl(
219 			SvXMLImport& rImport, sal_uInt16 nPrfx,
220 			const OUString& rLName,
221 			const uno::Reference< xml::sax::XAttributeList > & xAttrList );
222 	virtual ~SwXMLConditionContext_Impl();
223 
224 	TYPEINFO();
225 
IsValid() const226 	sal_Bool IsValid() const { return 0 != nCondition; }
227 
GetCondition() const228 	sal_uInt32 GetCondition() const { return nCondition; }
GetSubCondition() const229 	sal_uInt32 GetSubCondition() const { return nSubCondition; }
GetApplyStyle() const230 	const OUString& GetApplyStyle() const { return sApplyStyle; }
231 };
232 
SwXMLConditionContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)233 SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
234 			SvXMLImport& rImport, sal_uInt16 nPrfx,
235 			const OUString& rLName,
236 			const uno::Reference< xml::sax::XAttributeList > & xAttrList ) :
237 	SvXMLImportContext( rImport, nPrfx, rLName ),
238 	nCondition( 0 ),
239 	nSubCondition( 0 )
240 {
241 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
242 	for( sal_Int16 i=0; i < nAttrCount; i++ )
243 	{
244 		const OUString& rAttrName = xAttrList->getNameByIndex( i );
245 		OUString aLocalName;
246 		sal_uInt16 nPrefix =
247 			GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
248 															&aLocalName );
249 		const OUString& rValue = xAttrList->getValueByIndex( i );
250 
251 		// TODO: use a map here
252 		if( XML_NAMESPACE_STYLE == nPrefix )
253 		{
254 			if( IsXMLToken( aLocalName, XML_CONDITION ) )
255 			{
256 				SwXMLConditionParser_Impl aCondParser( rValue );
257 				if( aCondParser.IsValid() )
258 				{
259 					nCondition = aCondParser.GetCondition();
260 					nSubCondition = aCondParser.GetSubCondition();
261 				}
262 			}
263 			else if( IsXMLToken( aLocalName, XML_APPLY_STYLE_NAME ) )
264 			{
265 				sApplyStyle = rValue;
266 			}
267 		}
268 	}
269 }
270 
~SwXMLConditionContext_Impl()271 SwXMLConditionContext_Impl::~SwXMLConditionContext_Impl()
272 {
273 }
274 
275 TYPEINIT1( SwXMLConditionContext_Impl, XMLTextStyleContext );
276 
277 // ---------------------------------------------------------------------
278 
279 typedef SwXMLConditionContext_Impl *SwXMLConditionContextPtr;
280 SV_DECL_PTRARR( SwXMLConditions_Impl, SwXMLConditionContextPtr, 5, 2 )
281 
282 class SwXMLTextStyleContext_Impl : public XMLTextStyleContext
283 {
284 	SwXMLConditions_Impl	*pConditions;
285 
286 protected:
287 
288 	virtual uno::Reference < style::XStyle > Create();
289 
290 public:
291 
292 	TYPEINFO();
293 
294 	SwXMLTextStyleContext_Impl( SwXMLImport& rImport, sal_uInt16 nPrfx,
295 			const OUString& rLName,
296 			const uno::Reference< xml::sax::XAttributeList > & xAttrList,
297 			sal_uInt16 nFamily,
298 			SvXMLStylesContext& rStyles );
299 	virtual ~SwXMLTextStyleContext_Impl();
300 
301 	virtual SvXMLImportContext *CreateChildContext(
302 			sal_uInt16 nPrefix,
303 			const OUString& rLocalName,
304 			const uno::Reference< xml::sax::XAttributeList > & xAttrList );
305 
306 	virtual void Finish( sal_Bool bOverwrite );
307 };
308 
309 TYPEINIT1( SwXMLTextStyleContext_Impl, XMLTextStyleContext );
310 
Create()311 uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
312 {
313 	uno::Reference < style::XStyle > xNewStyle;
314 
315 	if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() )
316 	{
317 		uno::Reference< lang::XMultiServiceFactory > xFactory( GetImport().GetModel(),
318 													uno::UNO_QUERY );
319 		if( xFactory.is() )
320 		{
321 			OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM(
322 						"com.sun.star.style.ConditionalParagraphStyle" ) );
323 			uno::Reference < uno::XInterface > xIfc =
324 				xFactory->createInstance( sServiceName );
325 			if( xIfc.is() )
326 				xNewStyle = uno::Reference < style::XStyle >( xIfc, uno::UNO_QUERY );
327 		}
328 	}
329 	else
330 	{
331 		xNewStyle = XMLTextStyleContext::Create();
332 	}
333 
334 	return xNewStyle;
335 }
336 
SwXMLTextStyleContext_Impl(SwXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList,sal_uInt16 nFamily,SvXMLStylesContext & rStyles)337 SwXMLTextStyleContext_Impl::SwXMLTextStyleContext_Impl( SwXMLImport& rImport,
338 		sal_uInt16 nPrfx, const OUString& rLName,
339 		const uno::Reference< xml::sax::XAttributeList > & xAttrList,
340 		sal_uInt16 nFamily,
341 		SvXMLStylesContext& rStyles ) :
342 	XMLTextStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily ),
343 	pConditions( 0 )
344 {
345 }
346 
~SwXMLTextStyleContext_Impl()347 SwXMLTextStyleContext_Impl::~SwXMLTextStyleContext_Impl()
348 {
349 	if( pConditions )
350 	{
351 		while( pConditions->Count() )
352 		{
353 			SwXMLConditionContext_Impl *pCond = pConditions->GetObject(0);
354 			pConditions->Remove( 0UL );
355 			pCond->ReleaseRef();
356 		}
357 		delete pConditions;
358 	}
359 }
360 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)361 SvXMLImportContext *SwXMLTextStyleContext_Impl::CreateChildContext(
362 		sal_uInt16 nPrefix,
363 		const OUString& rLocalName,
364 		const uno::Reference< xml::sax::XAttributeList > & xAttrList )
365 {
366 	SvXMLImportContext *pContext = 0;
367 
368 	if( XML_NAMESPACE_STYLE == nPrefix && IsXMLToken( rLocalName, XML_MAP ) )
369 	{
370 		SwXMLConditionContext_Impl *pCond =
371 			new SwXMLConditionContext_Impl( GetImport(), nPrefix,
372 											rLocalName, xAttrList );
373 		if( pCond->IsValid() )
374 		{
375 			if( !pConditions )
376 			   pConditions = new SwXMLConditions_Impl;
377 			pConditions->Insert( pCond, pConditions->Count() );
378 			pCond->AddRef();
379 		}
380 		pContext = pCond;
381 	}
382 
383 	if( !pContext )
384 		pContext = XMLTextStyleContext::CreateChildContext( nPrefix, rLocalName,
385 														  xAttrList );
386 
387 	return pContext;
388 }
389 
Finish(sal_Bool bOverwrite)390 void SwXMLTextStyleContext_Impl::Finish( sal_Bool bOverwrite )
391 {
392 	XMLTextStyleContext::Finish( bOverwrite );
393 
394 	if( !pConditions || XML_STYLE_FAMILY_TEXT_PARAGRAPH != GetFamily() )
395 		return;
396 
397 	uno::Reference < style::XStyle > xStyle = GetStyle();
398 	if( !xStyle.is() )
399 		return;
400 
401 	const SwXStyle* pStyle = 0;
402 	uno::Reference<lang::XUnoTunnel> xStyleTunnel( xStyle, uno::UNO_QUERY);
403 	if( xStyleTunnel.is() )
404 	{
405 		pStyle = reinterpret_cast< SwXStyle * >(
406 				sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId() )));
407 	}
408 	if( !pStyle )
409 		return;
410 
411 	const SwDoc *pDoc = pStyle->GetDoc();
412 
413 	SwTxtFmtColl *pColl = pDoc->FindTxtFmtCollByName( pStyle->GetStyleName() );
414 	ASSERT( pColl, "Text collection not found" );
415 	if( !pColl || RES_CONDTXTFMTCOLL != pColl->Which() )
416 		return;
417 
418 	sal_uInt16 nCount = pConditions->Count();
419 	String aString;
420 	OUString sName;
421 	for( sal_uInt16 i = 0; i < nCount; i++ )
422 	{
423 		const SwXMLConditionContext_Impl *pCond = (*pConditions)[i];
424 		OUString aDisplayName(
425 			GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH,
426 				pCond->GetApplyStyle() ) );
427 		SwStyleNameMapper::FillUIName( aDisplayName,
428 									  aString,
429 									  nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL,
430 									  sal_True);
431 		sName = aString;
432 		SwTxtFmtColl* pCondColl = pDoc->FindTxtFmtCollByName( sName );
433 		ASSERT( pCondColl,
434 			"SwXMLItemSetStyleContext_Impl::ConnectConditions: cond coll missing" );
435 		if( pCondColl )
436 		{
437 			SwCollCondition aCond( pCondColl, pCond->GetCondition(),
438 											  pCond->GetSubCondition() );
439 			((SwConditionTxtFmtColl*)pColl)->InsertCondition( aCond );
440 		}
441 	}
442 }
443 
444 // ---------------------------------------------------------------------
445 
446 class SwXMLItemSetStyleContext_Impl : public SvXMLStyleContext
447 {
448 	OUString				sMasterPageName;
449 	SfxItemSet  			*pItemSet;
450     SwXMLTextStyleContext_Impl *pTextStyle;
451     SvXMLStylesContext      &rStyles;
452 
453 	OUString 				sDataStyleName;
454 
455 	sal_Bool				bHasMasterPageName : 1;
456 	sal_Bool 				bPageDescConnected : 1;
457 	sal_Bool				bDataStyleIsResolved;
458 
459 	SvXMLImportContext *CreateItemSetContext(
460 			sal_uInt16 nPrefix,
461 			const OUString& rLName,
462 			const uno::Reference< xml::sax::XAttributeList > & xAttrList);
463 
464 protected:
465 
466 	virtual void SetAttribute( sal_uInt16 nPrefixKey,
467 							   const OUString& rLocalName,
468 							   const OUString& rValue );
469 
GetSwImport() const470 	const SwXMLImport& GetSwImport() const
471 			{ return (const SwXMLImport&)GetImport(); }
GetSwImport()472 	SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
473 
474 public:
475 
476 	TYPEINFO();
477 
478 	SwXMLItemSetStyleContext_Impl(
479 			SwXMLImport& rImport, sal_uInt16 nPrfx,
480 			const OUString& rLName,
481 			const uno::Reference< xml::sax::XAttributeList > & xAttrList,
482             SvXMLStylesContext& rStylesC,
483 			sal_uInt16 nFamily);
484 	virtual ~SwXMLItemSetStyleContext_Impl();
485 
486    	virtual void CreateAndInsert( sal_Bool bOverwrite );
487 	virtual SvXMLImportContext *CreateChildContext(
488 			sal_uInt16 nPrefix,
489 			const OUString& rLocalName,
490 			const uno::Reference< xml::sax::XAttributeList > & xAttrList );
491 
492 	// The item set may be empty!
GetItemSet()493 	SfxItemSet *GetItemSet() { return pItemSet; }
GetItemSet() const494 	const SfxItemSet *GetItemSet() const { return pItemSet; }
495 
GetMasterPageName() const496 	const OUString& GetMasterPageName() const { return sMasterPageName; }
HasMasterPageName() const497 	sal_Bool HasMasterPageName() const { return bHasMasterPageName; }
498 
IsPageDescConnected() const499 	sal_Bool IsPageDescConnected() const { return bPageDescConnected; }
500 	void ConnectPageDesc();
501 
502 	sal_Bool ResolveDataStyleName();
503 };
504 
SetAttribute(sal_uInt16 nPrefixKey,const OUString & rLocalName,const OUString & rValue)505 void SwXMLItemSetStyleContext_Impl::SetAttribute( sal_uInt16 nPrefixKey,
506 										   const OUString& rLocalName,
507 										   const OUString& rValue )
508 {
509 	if( XML_NAMESPACE_STYLE == nPrefixKey )
510 	{
511 		if ( IsXMLToken( rLocalName, XML_MASTER_PAGE_NAME ) )
512 		{
513 			sMasterPageName = rValue;
514 			bHasMasterPageName = sal_True;
515 		}
516 		else if ( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
517 		{
518 			// if we have a valid data style name
519 			if (rValue.getLength() > 0)
520 			{
521 				sDataStyleName = rValue;
522 				bDataStyleIsResolved = sal_False;	// needs to be resolved
523 			}
524 		}
525 		else
526 		{
527 			SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
528 		}
529 	}
530 	else
531 	{
532 		SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
533 	}
534 }
535 
CreateItemSetContext(sal_uInt16 nPrefix,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)536 SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext(
537 		sal_uInt16 nPrefix, const OUString& rLName,
538 		const uno::Reference< xml::sax::XAttributeList > & xAttrList )
539 {
540 	ASSERT( !pItemSet,
541 			"SwXMLItemSetStyleContext_Impl::CreateItemSetContext: item set exists" );
542 
543 	SvXMLImportContext *pContext = 0;
544 
545 	SwDoc* pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
546 
547 	SfxItemPool& rItemPool = pDoc->GetAttrPool();
548 	switch( GetFamily() )
549 	{
550 	case XML_STYLE_FAMILY_TABLE_TABLE:
551 		pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
552 		break;
553 	case XML_STYLE_FAMILY_TABLE_COLUMN:
554 		pItemSet = new SfxItemSet( rItemPool, RES_FRM_SIZE, RES_FRM_SIZE, 0 );
555 		break;
556 	case XML_STYLE_FAMILY_TABLE_ROW:
557 		pItemSet = new SfxItemSet( rItemPool, aTableLineSetRange );
558 		break;
559 	case XML_STYLE_FAMILY_TABLE_CELL:
560 		pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange );
561 		break;
562 	default:
563 		ASSERT( sal_False,
564 		"SwXMLItemSetStyleContext_Impl::CreateItemSetContext: unknown family" );
565 		break;
566 	}
567 	if( pItemSet )
568 		pContext = GetSwImport().CreateTableItemImportContext(
569 								nPrefix, rLName, xAttrList, GetFamily(),
570 								*pItemSet );
571 	if( !pContext )
572 	{
573 		delete pItemSet;
574 		pItemSet = 0;
575 	}
576 
577 	return pContext;
578 }
579 
580 TYPEINIT1( SwXMLItemSetStyleContext_Impl, SvXMLStyleContext );
581 
SwXMLItemSetStyleContext_Impl(SwXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList,SvXMLStylesContext & rStylesC,sal_uInt16 nFamily)582 SwXMLItemSetStyleContext_Impl::SwXMLItemSetStyleContext_Impl( SwXMLImport& rImport,
583 		sal_uInt16 nPrfx, const OUString& rLName,
584 		const uno::Reference< xml::sax::XAttributeList > & xAttrList,
585         SvXMLStylesContext& rStylesC,
586 		sal_uInt16 nFamily ) :
587 	SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList, nFamily ),
588 	pItemSet( 0 ),
589     pTextStyle( 0 ),
590     rStyles( rStylesC ),
591 	bHasMasterPageName( sal_False ),
592 	bPageDescConnected( sal_False ),
593 	bDataStyleIsResolved( sal_True )
594 {
595 }
596 
~SwXMLItemSetStyleContext_Impl()597 SwXMLItemSetStyleContext_Impl::~SwXMLItemSetStyleContext_Impl()
598 {
599 	delete pItemSet;
600 }
601 
CreateAndInsert(sal_Bool bOverwrite)602 void SwXMLItemSetStyleContext_Impl::CreateAndInsert( sal_Bool bOverwrite )
603 {
604     if( pTextStyle )
605         pTextStyle->CreateAndInsert( bOverwrite );
606 }
607 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)608 SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateChildContext(
609 		sal_uInt16 nPrefix,
610 		const OUString& rLocalName,
611 		const uno::Reference< xml::sax::XAttributeList > & xAttrList )
612 {
613 	SvXMLImportContext *pContext = 0;
614 
615 	if( XML_NAMESPACE_STYLE == nPrefix )
616 	{
617 		if( IsXMLToken( rLocalName, XML_TABLE_PROPERTIES ) ||
618 			IsXMLToken( rLocalName, XML_TABLE_COLUMN_PROPERTIES ) ||
619 			IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES ) ||
620 			IsXMLToken( rLocalName, XML_TABLE_CELL_PROPERTIES ) )
621 		{
622 			pContext = CreateItemSetContext( nPrefix, rLocalName, xAttrList );
623 		}
624         else if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) ||
625                  IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ))
626         {
627             if( !pTextStyle )
628             {
629                 SvXMLAttributeList *pTmp = new SvXMLAttributeList;
630                 OUString aStr = GetImport().GetNamespaceMap().GetQNameByKey( nPrefix, GetXMLToken(XML_NAME) );
631                 pTmp->AddAttribute( aStr, GetName() );
632                 uno::Reference <xml::sax::XAttributeList> xTmpAttrList = pTmp;
633                 pTextStyle = new SwXMLTextStyleContext_Impl( GetSwImport(), nPrefix,
634 							     rLocalName, xTmpAttrList, XML_STYLE_FAMILY_TEXT_PARAGRAPH, rStyles );
635                 pTextStyle->StartElement( xTmpAttrList );
636                 rStyles.AddStyle( *pTextStyle );
637             }
638             pContext = pTextStyle->CreateChildContext( nPrefix, rLocalName, xAttrList );
639         }
640 	}
641 
642 	if( !pContext )
643 		pContext = SvXMLStyleContext::CreateChildContext( nPrefix, rLocalName,
644 														  xAttrList );
645 
646 	return pContext;
647 }
648 
ConnectPageDesc()649 void SwXMLItemSetStyleContext_Impl::ConnectPageDesc()
650 {
651 	if( bPageDescConnected || !HasMasterPageName() )
652 		return;
653 	bPageDescConnected = sal_True;
654 
655 	SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
656 
657 	String sName;
658     // --> OD 2005-02-01 #i40788# - first determine the display name of the
659     // page style, then map this name to the corresponding user interface name.
660     sName = GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_MASTER_PAGE,
661                                              GetMasterPageName() );
662     SwStyleNameMapper::FillUIName( sName,
663 								   sName,
664 								   nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC,
665 								   sal_True);
666     // <--
667 	SwPageDesc *pPageDesc = pDoc->FindPageDescByName( sName );
668 	if( !pPageDesc )
669 	{
670 		// If the page style is a pool style, then we maybe have to create it
671 		// first if it hasn't been used by now.
672 		sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
673 		if( USHRT_MAX != nPoolId )
674             pPageDesc = pDoc->GetPageDescFromPool( nPoolId, false );
675 	}
676 
677 	if( !pPageDesc )
678 		return;
679 
680 	if( !pItemSet )
681 	{
682 		SfxItemPool& rItemPool = pDoc->GetAttrPool();
683 		pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
684 	}
685 
686 	const SfxPoolItem *pItem;
687 	SwFmtPageDesc *pFmtPageDesc = 0;
688 	if( SFX_ITEM_SET == pItemSet->GetItemState( RES_PAGEDESC, sal_False,
689 												&pItem ) )
690 	{
691 	 	if( ((SwFmtPageDesc *)pItem)->GetPageDesc() != pPageDesc )
692 			pFmtPageDesc = new SwFmtPageDesc( *(SwFmtPageDesc *)pItem );
693 	}
694 	else
695 		pFmtPageDesc = new SwFmtPageDesc();
696 
697 	if( pFmtPageDesc )
698 	{
699         pFmtPageDesc->RegisterToPageDesc( *pPageDesc );
700 		pItemSet->Put( *pFmtPageDesc );
701 		delete pFmtPageDesc;
702 	}
703 }
704 
ResolveDataStyleName()705 sal_Bool SwXMLItemSetStyleContext_Impl::ResolveDataStyleName()
706 {
707 	// resolve, if not already done
708 	if (! bDataStyleIsResolved)
709 	{
710 		// get the format key
711 		sal_Int32 nFormat =
712 			GetImport().GetTextImport()->GetDataStyleKey(sDataStyleName);
713 
714 		// if the key is valid, insert Item into ItemSet
715 		if( -1 != nFormat )
716 		{
717 			if( !pItemSet )
718 			{
719 				SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
720 
721 				SfxItemPool& rItemPool = pDoc->GetAttrPool();
722 				pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange );
723 			}
724 			SwTblBoxNumFormat aNumFormatItem(nFormat);
725 			pItemSet->Put(aNumFormatItem);
726 		}
727 
728 		// now resolved
729 		bDataStyleIsResolved = sal_True;
730 		return sal_True;
731 	}
732 	else
733 	{
734 		// was already resolved; nothing to do
735 		return sal_False;
736 	}
737 }
738 
739 // ---------------------------------------------------------------------
740 //
741 class SwXMLStylesContext_Impl : public SvXMLStylesContext
742 {
743 	SwXMLItemSetStyleContext_Impl *GetSwStyle( sal_uInt16 i ) const;
744 
GetSwImport()745 	SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
GetSwImport() const746 	const SwXMLImport& GetSwImport() const
747 			{ return (const SwXMLImport&)GetImport(); }
748 
749 protected:
750 
751 	virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily,
752 		sal_uInt16 nPrefix, const OUString& rLocalName,
753 		const uno::Reference< xml::sax::XAttributeList > & xAttrList );
754 	virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
755 		sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
756 		const uno::Reference< xml::sax::XAttributeList > & xAttrList );
757 	// HACK
758 	virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
759         sal_uInt16 nFamily ) const;
760 
761 	virtual uno::Reference < container::XNameContainer >
762 		GetStylesContainer( sal_uInt16 nFamily ) const;
763 	virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const;
764 	// HACK
765 
766 public:
767 
768 	TYPEINFO();
769 
770 	SwXMLStylesContext_Impl(
771 			SwXMLImport& rImport, sal_uInt16 nPrfx,
772 			const OUString& rLName ,
773 			const uno::Reference< xml::sax::XAttributeList > & xAttrList,
774 			sal_Bool bAuto );
775 	virtual ~SwXMLStylesContext_Impl();
776 
777 	virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const;
778 
779 	virtual void EndElement();
780 };
781 
782 TYPEINIT1( SwXMLStylesContext_Impl, SvXMLStylesContext );
783 
GetSwStyle(sal_uInt16 i) const784 inline SwXMLItemSetStyleContext_Impl *SwXMLStylesContext_Impl::GetSwStyle(
785 		sal_uInt16 i ) const
786 {
787 	return PTR_CAST( SwXMLItemSetStyleContext_Impl, GetStyle( i ) );
788 }
789 
CreateStyleStyleChildContext(sal_uInt16 nFamily,sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)790 SvXMLStyleContext *SwXMLStylesContext_Impl::CreateStyleStyleChildContext(
791 		sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
792 		const uno::Reference< xml::sax::XAttributeList > & xAttrList )
793 {
794 	SvXMLStyleContext *pStyle = 0;
795 
796 	switch( nFamily )
797 	{
798 	case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
799 		pStyle = new SwXMLTextStyleContext_Impl( GetSwImport(), nPrefix,
800 							rLocalName, xAttrList, nFamily, *this );
801 		break;
802 	case XML_STYLE_FAMILY_TABLE_TABLE:
803 	case XML_STYLE_FAMILY_TABLE_COLUMN:
804 	case XML_STYLE_FAMILY_TABLE_ROW:
805 	case XML_STYLE_FAMILY_TABLE_CELL:
806 		pStyle = new SwXMLItemSetStyleContext_Impl( GetSwImport(), nPrefix,
807 							rLocalName, xAttrList, *this, nFamily  );
808 		break;
809 	case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
810 		// As long as there are no element items, we can use the text
811 		// style class.
812 		pStyle = new XMLTextShapeStyleContext( GetImport(), nPrefix,
813 							rLocalName, xAttrList, *this, nFamily );
814 		break;
815 	default:
816 		pStyle = SvXMLStylesContext::CreateStyleStyleChildContext( nFamily,
817 			   													nPrefix,
818 															  rLocalName,
819 															  xAttrList );
820 		break;
821 	}
822 
823 	return pStyle;
824 }
825 
CreateDefaultStyleStyleChildContext(sal_uInt16 nFamily,sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)826 SvXMLStyleContext *SwXMLStylesContext_Impl::CreateDefaultStyleStyleChildContext(
827 		sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
828 		const uno::Reference< xml::sax::XAttributeList > & xAttrList )
829 {
830 	SvXMLStyleContext *pStyle = 0;
831 
832 	switch( nFamily )
833 	{
834 	case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
835     case XML_STYLE_FAMILY_TABLE_TABLE:
836 	case XML_STYLE_FAMILY_TABLE_ROW:
837 		pStyle = new XMLTextStyleContext( GetImport(), nPrefix, rLocalName,
838 										  xAttrList, *this, nFamily,
839 										  sal_True );
840 		break;
841 	case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
842 		// There are no writer specific defaults for graphic styles!
843 		pStyle = new XMLGraphicsDefaultStyle( GetImport(), nPrefix,
844 							rLocalName, xAttrList, *this );
845 		break;
846 	default:
847 		pStyle = SvXMLStylesContext::CreateDefaultStyleStyleChildContext( nFamily,
848 			   													nPrefix,
849 															  rLocalName,
850 															  xAttrList );
851 		break;
852 	}
853 
854 	return pStyle;
855 }
856 
857 
SwXMLStylesContext_Impl(SwXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList,sal_Bool bAuto)858 SwXMLStylesContext_Impl::SwXMLStylesContext_Impl(
859 		SwXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName,
860 		const uno::Reference< xml::sax::XAttributeList > & xAttrList,
861 		sal_Bool bAuto ) :
862 	SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList, bAuto )
863 {
864 }
865 
~SwXMLStylesContext_Impl()866 SwXMLStylesContext_Impl::~SwXMLStylesContext_Impl()
867 {
868 }
869 
InsertStyleFamily(sal_uInt16 nFamily) const870 sal_Bool SwXMLStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const
871 {
872 	const SwXMLImport& rSwImport = GetSwImport();
873 	sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
874 
875 	sal_Bool bIns = sal_True;
876 	switch( nFamily )
877 	{
878 	case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
879 		bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PARA) != 0;
880 		break;
881 	case XML_STYLE_FAMILY_TEXT_TEXT:
882 		bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_CHAR) != 0;
883 		break;
884 	case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
885 		bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_FRAME) != 0;
886 		break;
887 	case XML_STYLE_FAMILY_TEXT_LIST:
888 		bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PSEUDO) != 0;
889 		break;
890 	case XML_STYLE_FAMILY_TEXT_OUTLINE:
891 	case XML_STYLE_FAMILY_TEXT_FOOTNOTECONFIG:
892 	case XML_STYLE_FAMILY_TEXT_ENDNOTECONFIG:
893 	case XML_STYLE_FAMILY_TEXT_LINENUMBERINGCONFIG:
894 	case XML_STYLE_FAMILY_TEXT_BIBLIOGRAPHYCONFIG:
895 		bIns = !(rSwImport.IsInsertMode() || rSwImport.IsStylesOnlyMode() ||
896 				 rSwImport.IsBlockMode());
897 		break;
898 	default:
899 		bIns = SvXMLStylesContext::InsertStyleFamily( nFamily );
900 		break;
901 	}
902 
903 	return bIns;
904 }
905 
GetImportPropertyMapper(sal_uInt16 nFamily) const906 UniReference < SvXMLImportPropertyMapper > SwXMLStylesContext_Impl::GetImportPropertyMapper(
907         sal_uInt16 nFamily ) const
908 {
909 	UniReference < SvXMLImportPropertyMapper > xMapper;
910     if( nFamily == XML_STYLE_FAMILY_TABLE_TABLE )
911         xMapper = XMLTextImportHelper::CreateTableDefaultExtPropMapper(
912             const_cast<SwXMLStylesContext_Impl*>( this )->GetImport() );
913     else if( nFamily == XML_STYLE_FAMILY_TABLE_ROW )
914         xMapper = XMLTextImportHelper::CreateTableRowDefaultExtPropMapper(
915             const_cast<SwXMLStylesContext_Impl*>( this )->GetImport() );
916     else
917         xMapper = SvXMLStylesContext::GetImportPropertyMapper( nFamily );
918 	return xMapper;
919 }
920 
GetStylesContainer(sal_uInt16 nFamily) const921 uno::Reference < container::XNameContainer > SwXMLStylesContext_Impl::GetStylesContainer(
922 												sal_uInt16 nFamily ) const
923 {
924 	uno::Reference < container::XNameContainer > xStyles;
925 	if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
926 		xStyles = ((SvXMLImport *)&GetImport())->GetTextImport()->GetFrameStyles();
927 	else
928 		xStyles = SvXMLStylesContext::GetStylesContainer( nFamily );
929 
930 	return xStyles;
931 }
932 
GetServiceName(sal_uInt16 nFamily) const933 OUString SwXMLStylesContext_Impl::GetServiceName( sal_uInt16 nFamily ) const
934 {
935 	String sServiceName;
936 	if( XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily )
937 		sServiceName = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.FrameStyle") );
938 	else
939 		sServiceName = SvXMLStylesContext::GetServiceName( nFamily );
940 
941 	return sServiceName;
942 }
943 
EndElement()944 void SwXMLStylesContext_Impl::EndElement()
945 {
946 	GetSwImport().InsertStyles( IsAutomaticStyle() );
947     // --> OD 2006-10-11 #i69629#
948     // assign paragraph styles to list levels of outline style after all styles
949     // are imported and finished.
950 //    if( !bAutoStyles )
951 //        GetImport().GetTextImport()->SetOutlineStyles( sal_True );
952     // <--
953 }
954 
955 // ---------------------------------------------------------------------
956 //
957 class SwXMLMasterStylesContext_Impl : public XMLTextMasterStylesContext
958 {
959 protected:
960 	virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const;
961 
GetSwImport()962 	SwXMLImport& GetSwImport() { return (SwXMLImport&)GetImport(); }
GetSwImport() const963 	const SwXMLImport& GetSwImport() const
964 			{ return (const SwXMLImport&)GetImport(); }
965 
966 public:
967 
968 	TYPEINFO();
969 
970 	SwXMLMasterStylesContext_Impl(
971 			SwXMLImport& rImport, sal_uInt16 nPrfx,
972 			const OUString& rLName ,
973 			const uno::Reference< xml::sax::XAttributeList > & xAttrList );
974 	virtual ~SwXMLMasterStylesContext_Impl();
975 	virtual void EndElement();
976 };
977 
978 TYPEINIT1( SwXMLMasterStylesContext_Impl, XMLTextMasterStylesContext );
979 
SwXMLMasterStylesContext_Impl(SwXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)980 SwXMLMasterStylesContext_Impl::SwXMLMasterStylesContext_Impl(
981 		SwXMLImport& rImport, sal_uInt16 nPrfx,
982 		const OUString& rLName ,
983 		const uno::Reference< xml::sax::XAttributeList > & xAttrList ) :
984 	XMLTextMasterStylesContext( rImport, nPrfx, rLName, xAttrList )
985 {
986 }
987 
~SwXMLMasterStylesContext_Impl()988 SwXMLMasterStylesContext_Impl::~SwXMLMasterStylesContext_Impl()
989 {
990 }
991 
InsertStyleFamily(sal_uInt16 nFamily) const992 sal_Bool SwXMLMasterStylesContext_Impl::InsertStyleFamily( sal_uInt16 nFamily ) const
993 {
994 	sal_Bool bIns;
995 
996 	const SwXMLImport& rSwImport = GetSwImport();
997 	sal_uInt16 nStyleFamilyMask = rSwImport.GetStyleFamilyMask();
998 	if( XML_STYLE_FAMILY_MASTER_PAGE == nFamily )
999 		bIns = (nStyleFamilyMask & SFX_STYLE_FAMILY_PAGE) != 0;
1000 	else
1001 		bIns = XMLTextMasterStylesContext::InsertStyleFamily( nFamily );
1002 
1003 	return bIns;
1004 }
1005 
EndElement()1006 void SwXMLMasterStylesContext_Impl::EndElement()
1007 {
1008 	FinishStyles( !GetSwImport().IsInsertMode() );
1009 	GetSwImport().FinishStyles();
1010 }
1011 // ---------------------------------------------------------------------
1012 
CreateStylesContext(const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList,sal_Bool bAuto)1013 SvXMLImportContext *SwXMLImport::CreateStylesContext(
1014 		const OUString& rLocalName,
1015 		const uno::Reference< xml::sax::XAttributeList > & xAttrList,
1016 		sal_Bool bAuto )
1017 {
1018 	SvXMLStylesContext *pContext =
1019 		new SwXMLStylesContext_Impl( *this, XML_NAMESPACE_OFFICE, rLocalName,
1020 								  	 xAttrList, bAuto );
1021 	if( bAuto )
1022 		SetAutoStyles( pContext );
1023 	else
1024 		SetStyles( pContext );
1025 
1026 	return pContext;
1027 }
1028 
CreateMasterStylesContext(const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> & xAttrList)1029 SvXMLImportContext *SwXMLImport::CreateMasterStylesContext(
1030 		const OUString& rLocalName,
1031 		const uno::Reference< xml::sax::XAttributeList > & xAttrList )
1032 {
1033 	SvXMLStylesContext *pContext =
1034 		new SwXMLMasterStylesContext_Impl( *this, XML_NAMESPACE_OFFICE, rLocalName,
1035 								  	    xAttrList );
1036 	SetMasterStyles( pContext );
1037 
1038 	return pContext;
1039 }
1040 
InsertStyles(sal_Bool bAuto)1041 void SwXMLImport::InsertStyles( sal_Bool bAuto )
1042 {
1043 	if( bAuto && GetAutoStyles() )
1044 		GetAutoStyles()->CopyAutoStylesToDoc();
1045 	if( !bAuto && GetStyles() )
1046 		GetStyles()->CopyStylesToDoc( !IsInsertMode(), sal_False );
1047 }
1048 
FinishStyles()1049 void SwXMLImport::FinishStyles()
1050 {
1051 	if( GetStyles() )
1052 		GetStyles()->FinishStyles( !IsInsertMode() );
1053 }
1054 
UpdateTxtCollConditions(SwDoc * pDoc)1055 void SwXMLImport::UpdateTxtCollConditions( SwDoc *pDoc )
1056 {
1057 	if( !pDoc )
1058 		pDoc = SwImport::GetDocFromXMLImport( *this );
1059 
1060 	const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls();
1061 	sal_uInt16 nCount = rColls.Count();
1062 	for( sal_uInt16 i=0; i < nCount; i++ )
1063 	{
1064 		SwTxtFmtColl *pColl = rColls[i];
1065 		if( pColl && RES_CONDTXTFMTCOLL == pColl->Which() )
1066 		{
1067 			const SwFmtCollConditions& rConditions =
1068 				((const SwConditionTxtFmtColl *)pColl)->GetCondColls();
1069 			sal_Bool bSendModify = sal_False;
1070 			for( sal_uInt16 j=0; j < rConditions.Count() && !bSendModify; j++ )
1071 			{
1072 				const SwCollCondition& rCond = *rConditions[j];
1073 				switch( rCond.GetCondition() )
1074 				{
1075 				case PARA_IN_TABLEHEAD:
1076 				case PARA_IN_TABLEBODY:
1077 				case PARA_IN_FOOTER:
1078 				case PARA_IN_HEADER:
1079 					bSendModify = sal_True;
1080 					break;
1081 				}
1082 			}
1083 			if( bSendModify )
1084 			{
1085 				SwCondCollCondChg aMsg( pColl );
1086 				pColl->ModifyNotification( &aMsg, &aMsg );
1087 			}
1088 		}
1089 	}
1090 }
1091 
FindAutomaticStyle(sal_uInt16 nFamily,const OUString & rName,const SfxItemSet ** ppItemSet,OUString * pParent) const1092 sal_Bool SwXMLImport::FindAutomaticStyle(
1093 		sal_uInt16 nFamily,
1094 		const OUString& rName,
1095 		const SfxItemSet **ppItemSet,
1096 		OUString *pParent ) const
1097 {
1098 	SwXMLItemSetStyleContext_Impl *pStyle = 0;
1099 	if( GetAutoStyles() )
1100 	{
1101 		pStyle = PTR_CAST( SwXMLItemSetStyleContext_Impl,
1102 			  GetAutoStyles()->
1103 					FindStyleChildContext( nFamily, rName,
1104 										   sal_True ) );
1105 		if( pStyle )
1106 		{
1107 			if( ppItemSet )
1108 			{
1109 				if( XML_STYLE_FAMILY_TABLE_TABLE == pStyle->GetFamily() &&
1110 					pStyle->HasMasterPageName() &&
1111 					!pStyle->IsPageDescConnected() )
1112 					pStyle->ConnectPageDesc();
1113 				(*ppItemSet) = pStyle->GetItemSet();
1114 
1115 				// resolve data style name late
1116 				if( XML_STYLE_FAMILY_TABLE_CELL == pStyle->GetFamily() &&
1117 					pStyle->ResolveDataStyleName() )
1118 				{
1119 					(*ppItemSet) = pStyle->GetItemSet();
1120 				}
1121 
1122 			}
1123 
1124 			if( pParent )
1125 				*pParent = pStyle->GetParentName();
1126 		}
1127 	}
1128 
1129 	return pStyle != 0;
1130 }
1131