xref: /aoo42x/main/sw/source/core/layout/atrfrm.cxx (revision 28160478)
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 <hintids.hxx>
29 #include <com/sun/star/text/RelOrientation.hpp>
30 #include <com/sun/star/text/VertOrientation.hpp>
31 #include <com/sun/star/text/HorizontalAdjust.hpp>
32 #include <com/sun/star/text/DocumentStatistic.hpp>
33 #include <com/sun/star/text/HoriOrientation.hpp>
34 #include <com/sun/star/text/HoriOrientationFormat.hpp>
35 #include <com/sun/star/text/NotePrintMode.hpp>
36 #include <com/sun/star/text/SizeType.hpp>
37 #include <com/sun/star/text/VertOrientationFormat.hpp>
38 #include <com/sun/star/text/WrapTextMode.hpp>
39 #include <com/sun/star/text/XTextFrame.hpp>
40 #include <com/sun/star/text/TextContentAnchorType.hpp>
41 #include <com/sun/star/text/InvalidTextContentException.hpp>
42 #include <com/sun/star/container/XIndexContainer.hpp>
43 #include <com/sun/star/text/TextGridMode.hpp>
44 #include <com/sun/star/awt/Size.hpp>
45 #include <svtools/unoimap.hxx>
46 #include <svtools/unoevent.hxx>
47 #include <basic/sbxvar.hxx>
48 #include <svtools/imap.hxx>
49 #include <svtools/imapobj.hxx>
50 #include <editeng/ulspitem.hxx>
51 #include <editeng/lrspitem.hxx>
52 #include <svx/svdmodel.hxx>
53 #include <svx/svdpage.hxx>
54 #include <svl/itemiter.hxx>
55 #include <unosett.hxx>
56 #include <unostyle.hxx>
57 #include <fmtclds.hxx>
58 #include <fmtornt.hxx>
59 #include <fmthdft.hxx>
60 #include <fmtpdsc.hxx>
61 #include <fmtcntnt.hxx>
62 #include <fmtfsize.hxx>
63 #include <fmtfordr.hxx>
64 #include <fmtsrnd.hxx>
65 #include <fmtanchr.hxx>
66 #include <fmtlsplt.hxx>
67 #include <fmtrowsplt.hxx>
68 #include <fmtftntx.hxx>
69 #include <fmteiro.hxx>
70 #include <fmturl.hxx>
71 #include <fmtcnct.hxx>
72 #include <node.hxx>
73 #include <section.hxx>
74 #include <fmtline.hxx>
75 #include <tgrditem.hxx>
76 #include <hfspacingitem.hxx>
77 #include <doc.hxx>
78 #include <IDocumentUndoRedo.hxx>
79 #include <pagefrm.hxx>
80 #include <rootfrm.hxx>
81 #include <cntfrm.hxx>
82 #include <crsrsh.hxx>
83 #include <pam.hxx>
84 #include <dflyobj.hxx>
85 #include <dcontact.hxx>
86 #include <flyfrm.hxx>
87 #include <frmtool.hxx>
88 #include <flyfrms.hxx>
89 #include <pagedesc.hxx>
90 #include <grfatr.hxx>
91 #include <ndnotxt.hxx>
92 #include <docary.hxx>
93 #include <node2lay.hxx>
94 #include <fmtclbl.hxx>
95 #include <swunohelper.hxx>
96 #include <unoframe.hxx>
97 #include <unotextbodyhf.hxx>
98 #include <SwStyleNameMapper.hxx>
99 #include <editeng/brshitem.hxx>
100 #include <svtools/grfmgr.hxx>
101 #include <cmdid.h>
102 #include <unomid.h>
103 #include <comcore.hrc>
104 #include <svx/svdundo.hxx> // #111827#
105 #include <sortedobjs.hxx>
106 #include <HandleAnchorNodeChg.hxx>
107 #include <svl/cjkoptions.hxx>
108 #include <switerator.hxx>
109 #include <pagedeschint.hxx>
110 
111 //UUUU
112 #include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
113 #include <svx/xfillit0.hxx>
114 
115 using namespace ::com::sun::star;
116 using ::rtl::OUString;
117 
118 SV_IMPL_PTRARR(SwColumns,SwColumn*)
119 
120 TYPEINIT1(SwFmtVertOrient, SfxPoolItem);
121 TYPEINIT1(SwFmtHoriOrient, SfxPoolItem);
122 TYPEINIT2(SwFmtHeader,  SfxPoolItem, SwClient );
123 TYPEINIT2(SwFmtFooter,  SfxPoolItem, SwClient );
124 TYPEINIT2(SwFmtPageDesc,  SfxPoolItem, SwClient );
125 TYPEINIT1_AUTOFACTORY(SwFmtLineNumber, SfxPoolItem);
126 
127 /* -----------------19.05.98 09:26-------------------
128  * 	Umwandlung fuer QueryValue
129  * --------------------------------------------------*/
130 sal_Int16 lcl_RelToINT(sal_Int16 eRelation)
131 {
132     sal_Int16 nRet = text::RelOrientation::FRAME;
133 	switch(eRelation)
134 	{
135     case  text::RelOrientation::PRINT_AREA:           nRet = text::RelOrientation::PRINT_AREA; break;
136     case  text::RelOrientation::CHAR:         nRet = text::RelOrientation::CHAR; break;
137     case  text::RelOrientation::PAGE_LEFT:        nRet = text::RelOrientation::PAGE_LEFT; break;
138     case  text::RelOrientation::PAGE_RIGHT:       nRet = text::RelOrientation::PAGE_RIGHT; break;
139     case  text::RelOrientation::FRAME_LEFT:       nRet = text::RelOrientation::FRAME_LEFT; break;
140     case  text::RelOrientation::FRAME_RIGHT:  nRet = text::RelOrientation::FRAME_RIGHT; break;
141     case  text::RelOrientation::PAGE_FRAME:       nRet = text::RelOrientation::PAGE_FRAME; break;
142     case  text::RelOrientation::PAGE_PRINT_AREA:  nRet = text::RelOrientation::PAGE_PRINT_AREA; break;
143     // OD 13.11.2003 #i22341#
144     case  text::RelOrientation::TEXT_LINE:    nRet = text::RelOrientation::TEXT_LINE; break;
145     default: break;
146 	}
147 	return nRet;
148 }
149 
150 sal_Int16 lcl_IntToRelation(const uno::Any& rVal)
151 {
152     sal_Int16 eRet = text::RelOrientation::FRAME;
153     sal_Int16 nVal = 0;
154     rVal >>= nVal;
155     switch(nVal)
156 	{
157         case  text::RelOrientation::PRINT_AREA:         eRet =   text::RelOrientation::PRINT_AREA           ; break;
158         case  text::RelOrientation::CHAR:               eRet =   text::RelOrientation::CHAR          ; break;
159         case  text::RelOrientation::PAGE_LEFT:          eRet =   text::RelOrientation::PAGE_LEFT       ; break;
160         case  text::RelOrientation::PAGE_RIGHT:         eRet =   text::RelOrientation::PAGE_RIGHT      ; break;
161         case  text::RelOrientation::FRAME_LEFT:         eRet =   text::RelOrientation::FRAME_LEFT      ; break;
162         case  text::RelOrientation::FRAME_RIGHT:        eRet =   text::RelOrientation::FRAME_RIGHT     ; break;
163         case  text::RelOrientation::PAGE_FRAME:         eRet =   text::RelOrientation::PAGE_FRAME      ; break;
164         case  text::RelOrientation::PAGE_PRINT_AREA:    eRet =   text::RelOrientation::PAGE_PRINT_AREA    ; break;
165         // OD 13.11.2003 #i22341#
166         case  text::RelOrientation::TEXT_LINE: eRet = text::RelOrientation::TEXT_LINE; break;
167     }
168 	return eRet;
169 }
170 
171 void DelHFFormat( SwClient *pToRemove, SwFrmFmt *pFmt )
172 {
173 	//Wenn der Client der letzte ist der das Format benutzt, so muss dieses
174 	//vernichtet werden. Zuvor muss jedoch ggf. die Inhaltssection vernichtet
175 	//werden.
176 	SwDoc* pDoc = pFmt->GetDoc();
177 	pFmt->Remove( pToRemove );
178 	if( pDoc->IsInDtor() )
179 	{
180 		delete pFmt;
181 		return;
182 	}
183 
184 	//Nur noch Frms angemeldet?
185 	sal_Bool bDel = sal_True;
186 	{
187 		// Klammer, weil im DTOR SwClientIter das Flag bTreeChg zurueck
188 		// gesetzt wird. Unguenstig, wenn das Format vorher zerstoert wird.
189 		SwClientIter aIter( *pFmt );        // TODO
190 		SwClient *pLast = aIter.GoStart();
191 		if( pLast )
192 			do {
193                 bDel = pLast->IsA( TYPE(SwFrm) )
194                     || SwXHeadFootText::IsXHeadFootText(pLast);
195 			} while( bDel && 0 != ( pLast = ++aIter ));
196 	}
197 
198 	if ( bDel )
199 	{
200 		//Wenn in einem der Nodes noch ein Crsr angemeldet ist, muss das
201 		//ParkCrsr einer (beliebigen) Shell gerufen werden.
202 		SwFmtCntnt& rCnt = (SwFmtCntnt&)pFmt->GetCntnt();
203 		if ( rCnt.GetCntntIdx() )
204 		{
205 			SwNode *pNode = 0;
206 			{
207                 // --> OD 2008-10-07 #i92993#
208                 // Begin with start node of page header/footer to assure that
209                 // complete content is checked for cursors and the complete content
210                 // is deleted on below made method call <pDoc->DeleteSection(pNode)>
211 //                SwNodeIndex aIdx( *rCnt.GetCntntIdx(), 1 );
212                 SwNodeIndex aIdx( *rCnt.GetCntntIdx(), 0 );
213                 // <--
214 				//Wenn in einem der Nodes noch ein Crsr angemeldet ist, muss das
215 				//ParkCrsr einer (beliebigen) Shell gerufen werden.
216                 pNode = & aIdx.GetNode();
217 				sal_uInt32 nEnd = pNode->EndOfSectionIndex();
218 				while ( aIdx < nEnd )
219 				{
220 					if ( pNode->IsCntntNode() &&
221 						 ((SwCntntNode*)pNode)->GetDepends() )
222 					{
223 						SwCrsrShell *pShell = SwIterator<SwCrsrShell,SwCntntNode>::FirstElement( *(SwCntntNode*)pNode );
224 						if( pShell )
225 						{
226 							pShell->ParkCrsr( aIdx );
227 								aIdx = nEnd-1;
228 						}
229 					}
230 					aIdx++;
231                     pNode = & aIdx.GetNode();
232                 }
233             }
234             rCnt.SetNewCntntIdx( (const SwNodeIndex*)0 );
235 
236 			// beim Loeschen von Header/Footer-Formaten IMMER das Undo
237 			// abschalten! (Bug 31069)
238             ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
239 
240 			ASSERT( pNode, "Ein grosses Problem." );
241 			pDoc->DeleteSection( pNode );
242 		}
243 		delete pFmt;
244 	}
245 }
246 
247 //	class SwFmtFrmSize
248 //	Implementierung teilweise inline im hxx
249 
250 SwFmtFrmSize::SwFmtFrmSize( SwFrmSize eSize, SwTwips nWidth, SwTwips nHeight )
251 	: SfxPoolItem( RES_FRM_SIZE ),
252 	aSize( nWidth, nHeight ),
253     eFrmHeightType( eSize ),
254     eFrmWidthType( ATT_FIX_SIZE )
255 {
256 	nWidthPercent = nHeightPercent = 0;
257 }
258 
259 SwFmtFrmSize& SwFmtFrmSize::operator=( const SwFmtFrmSize& rCpy )
260 {
261 	aSize = rCpy.GetSize();
262     eFrmHeightType = rCpy.GetHeightSizeType();
263     eFrmWidthType = rCpy.GetWidthSizeType();
264 	nHeightPercent = rCpy.GetHeightPercent();
265 	nWidthPercent  = rCpy.GetWidthPercent();
266 	return *this;
267 }
268 
269 int  SwFmtFrmSize::operator==( const SfxPoolItem& rAttr ) const
270 {
271 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
272     return( eFrmHeightType  == ((SwFmtFrmSize&)rAttr).eFrmHeightType &&
273             eFrmWidthType  == ((SwFmtFrmSize&)rAttr).eFrmWidthType &&
274 			aSize    		== ((SwFmtFrmSize&)rAttr).GetSize()&&
275 			nWidthPercent	== ((SwFmtFrmSize&)rAttr).GetWidthPercent() &&
276 			nHeightPercent	== ((SwFmtFrmSize&)rAttr).GetHeightPercent() );
277 }
278 
279 SfxPoolItem*  SwFmtFrmSize::Clone( SfxItemPool* ) const
280 {
281 	return new SwFmtFrmSize( *this );
282 }
283 
284 
285 /* -----------------24.04.98 11:36-------------------
286  *
287  * --------------------------------------------------*/
288 sal_Bool SwFmtFrmSize::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
289 {
290 	// hier wird immer konvertiert!
291 	nMemberId &= ~CONVERT_TWIPS;
292 	switch ( nMemberId )
293 	{
294 		case MID_FRMSIZE_SIZE:
295 		{
296 			awt::Size aTmp;
297 			aTmp.Height = TWIP_TO_MM100(aSize.Height());
298 			aTmp.Width = TWIP_TO_MM100(aSize.Width());
299 			rVal.setValue(&aTmp, ::getCppuType((const awt::Size*)0));
300 		}
301 		break;
302 		case MID_FRMSIZE_REL_HEIGHT:
303 			rVal <<= (sal_Int16)(GetHeightPercent() != 0xFF ? GetHeightPercent() : 0);
304 		break;
305 		case MID_FRMSIZE_REL_WIDTH:
306 			rVal <<= (sal_Int16)(GetWidthPercent() != 0xFF ? GetWidthPercent() : 0);
307 		break;
308         case MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH:
309 		{
310 			sal_Bool bTmp = 0xFF == GetHeightPercent();
311 			rVal.setValue(&bTmp, ::getBooleanCppuType());
312 		}
313 		break;
314 		case MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT:
315 		{
316 			sal_Bool bTmp = 0xFF == GetWidthPercent();
317 			rVal.setValue(&bTmp, ::getBooleanCppuType());
318 		}
319 		break;
320 		case MID_FRMSIZE_WIDTH :
321 			rVal <<= (sal_Int32)TWIP_TO_MM100(aSize.Width());
322 		break;
323         case MID_FRMSIZE_HEIGHT:
324             // #95848# returned size should never be zero.
325             // (there was a bug that allowed for setting height to 0.
326             // Thus there some documents existing with that not allowed
327             // attribut value which may cause problems on import.)
328             rVal <<= (sal_Int32)TWIP_TO_MM100(aSize.Height() < MINLAY ? MINLAY : aSize.Height() );
329         break;
330         case MID_FRMSIZE_SIZE_TYPE:
331             rVal <<= (sal_Int16)GetHeightSizeType();
332 		break;
333 		case MID_FRMSIZE_IS_AUTO_HEIGHT:
334 		{
335             sal_Bool bTmp = ATT_FIX_SIZE != GetHeightSizeType();
336 			rVal.setValue(&bTmp, ::getBooleanCppuType());
337 		}
338 		break;
339         case MID_FRMSIZE_WIDTH_TYPE:
340             rVal <<= (sal_Int16)GetWidthSizeType();
341         break;
342 	}
343 	return sal_True;
344 }
345 
346 /* -----------------24.04.98 11:36-------------------
347  *
348  * --------------------------------------------------*/
349 sal_Bool SwFmtFrmSize::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
350 {
351 	sal_Bool bConvert = 0 != (nMemberId&CONVERT_TWIPS);
352 	nMemberId &= ~CONVERT_TWIPS;
353 	sal_Bool bRet = sal_True;
354 	switch ( nMemberId )
355 	{
356 		case MID_FRMSIZE_SIZE:
357 		{
358             awt::Size aVal;
359             if(!(rVal >>= aVal))
360                 bRet = sal_False;
361             else
362             {
363                 Size aTmp(aVal.Width, aVal.Height);
364                 if(bConvert)
365                 {
366                     aTmp.Height() = MM100_TO_TWIP(aTmp.Height());
367                     aTmp.Width() = MM100_TO_TWIP(aTmp.Width());
368                 }
369                 if(aTmp.Height() && aTmp.Width())
370                     aSize = aTmp;
371                 else
372                     bRet = sal_False;
373             }
374 		}
375 		break;
376 		case MID_FRMSIZE_REL_HEIGHT:
377 		{
378 			sal_Int16 nSet = 0;
379 			rVal >>= nSet;
380             if(nSet >= 0 && nSet <= 0xfe)
381 				SetHeightPercent((sal_uInt8)nSet);
382 			else
383 				bRet = sal_False;
384 		}
385 		break;
386 		case MID_FRMSIZE_REL_WIDTH:
387 		{
388 			sal_Int16 nSet = 0;
389 			rVal >>= nSet;
390             if(nSet >= 0 && nSet <= 0xfe)
391 				SetWidthPercent((sal_uInt8)nSet);
392 			else
393 				bRet = sal_False;
394 		}
395 		break;
396 		case MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH:
397 		{
398 			sal_Bool bSet = *(sal_Bool*)rVal.getValue();
399 			if(bSet)
400 				SetHeightPercent(0xff);
401 			else if( 0xff == GetHeightPercent() )
402 				SetHeightPercent( 0 );
403 		}
404 		break;
405 		case MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT:
406 		{
407 			sal_Bool bSet = *(sal_Bool*)rVal.getValue();
408 			if(bSet)
409 				SetWidthPercent(0xff);
410 			else if( 0xff == GetWidthPercent() )
411 				SetWidthPercent(0);
412 		}
413 		break;
414 		case MID_FRMSIZE_WIDTH :
415 		{
416             sal_Int32 nWd = 0;
417             if(rVal >>= nWd)
418             {
419                 if(bConvert)
420                     nWd = MM100_TO_TWIP(nWd);
421                 if(nWd < MINLAY)
422                    nWd = MINLAY;
423                 aSize.Width() = nWd;
424             }
425             else
426                 bRet = sal_False;
427         }
428 		break;
429 		case MID_FRMSIZE_HEIGHT:
430 		{
431             sal_Int32 nHg = 0;
432             if(rVal >>= nHg)
433             {
434                 if(bConvert)
435                     nHg = MM100_TO_TWIP(nHg);
436                 if(nHg < MINLAY)
437                     nHg = MINLAY;
438                 aSize.Height() = nHg;
439             }
440             else
441                 bRet = sal_False;
442         }
443 		break;
444 		case MID_FRMSIZE_SIZE_TYPE:
445 		{
446             sal_Int16 nType = 0;
447             if((rVal >>= nType) && nType >= 0 && nType <= ATT_MIN_SIZE )
448 			{
449                 SetHeightSizeType((SwFrmSize)nType);
450 			}
451             else
452                 bRet = sal_False;
453         }
454 		break;
455 		case MID_FRMSIZE_IS_AUTO_HEIGHT:
456 		{
457 			sal_Bool bSet = *(sal_Bool*)rVal.getValue();
458             SetHeightSizeType(bSet ? ATT_VAR_SIZE : ATT_FIX_SIZE);
459 		}
460 		break;
461         case MID_FRMSIZE_WIDTH_TYPE:
462         {
463             sal_Int16 nType = 0;
464             if((rVal >>= nType) && nType >= 0 && nType <= ATT_MIN_SIZE )
465 			{
466                 SetWidthSizeType((SwFrmSize)nType);
467 			}
468             else
469                 bRet = sal_False;
470         }
471         break;
472 		default:
473 			bRet = sal_False;
474 	}
475 	return bRet;
476 }
477 
478 //	class SwFmtFillOrder
479 //	Implementierung teilweise inline im hxx
480 
481 SwFmtFillOrder::SwFmtFillOrder( SwFillOrder nFO )
482 	: SfxEnumItem( RES_FILL_ORDER, sal_uInt16(nFO) )
483 {}
484 
485 SfxPoolItem*  SwFmtFillOrder::Clone( SfxItemPool* ) const
486 {
487 	return new SwFmtFillOrder( GetFillOrder() );
488 }
489 
490 sal_uInt16  SwFmtFillOrder::GetValueCount() const
491 {
492 	return SW_FILL_ORDER_END - SW_FILL_ORDER_BEGIN;
493 }
494 
495 //	class SwFmtHeader
496 //	Implementierung teilweise inline im hxx
497 
498 SwFmtHeader::SwFmtHeader( SwFrmFmt *pHeaderFmt )
499 	: SfxPoolItem( RES_HEADER ),
500 	SwClient( pHeaderFmt ),
501 	bActive( pHeaderFmt ? sal_True : sal_False )
502 {
503 }
504 
505 SwFmtHeader::SwFmtHeader( const SwFmtHeader &rCpy )
506 	: SfxPoolItem( RES_HEADER ),
507 	SwClient( (SwModify*)rCpy.GetRegisteredIn() ),
508 	bActive( rCpy.IsActive() )
509 {
510 }
511 
512 SwFmtHeader::SwFmtHeader( sal_Bool bOn )
513 	: SfxPoolItem( RES_HEADER ),
514 	SwClient( 0 ),
515 	bActive( bOn )
516 {
517 }
518 
519  SwFmtHeader::~SwFmtHeader()
520 {
521 	if ( GetHeaderFmt() )
522 		DelHFFormat( this, GetHeaderFmt() );
523 }
524 
525 int  SwFmtHeader::operator==( const SfxPoolItem& rAttr ) const
526 {
527 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
528 	return ( GetRegisteredIn() == ((SwFmtHeader&)rAttr).GetRegisteredIn() &&
529 			 bActive == ((SwFmtHeader&)rAttr).IsActive() );
530 }
531 
532 SfxPoolItem*  SwFmtHeader::Clone( SfxItemPool* ) const
533 {
534 	return new SwFmtHeader( *this );
535 }
536 
537 void SwFmtHeader::RegisterToFormat( SwFmt& rFmt )
538 {
539     rFmt.Add(this);
540 }
541 
542 //	class SwFmtFooter
543 //	Implementierung teilweise inline im hxx
544 
545 SwFmtFooter::SwFmtFooter( SwFrmFmt *pFooterFmt )
546 	: SfxPoolItem( RES_FOOTER ),
547 	SwClient( pFooterFmt ),
548 	bActive( pFooterFmt ? sal_True : sal_False )
549 {
550 }
551 
552 SwFmtFooter::SwFmtFooter( const SwFmtFooter &rCpy )
553 	: SfxPoolItem( RES_FOOTER ),
554 	SwClient( (SwModify*)rCpy.GetRegisteredIn() ),
555 	bActive( rCpy.IsActive() )
556 {
557 }
558 
559 SwFmtFooter::SwFmtFooter( sal_Bool bOn )
560 	: SfxPoolItem( RES_FOOTER ),
561 	SwClient( 0 ),
562 	bActive( bOn )
563 {
564 }
565 
566  SwFmtFooter::~SwFmtFooter()
567 {
568 	if ( GetFooterFmt() )
569 		DelHFFormat( this, GetFooterFmt() );
570 }
571 
572 void SwFmtFooter::RegisterToFormat( SwFmt& rFmt )
573 {
574     rFmt.Add(this);
575 }
576 
577 int  SwFmtFooter::operator==( const SfxPoolItem& rAttr ) const
578 {
579 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
580 	return ( GetRegisteredIn() == ((SwFmtFooter&)rAttr).GetRegisteredIn() &&
581 			 bActive == ((SwFmtFooter&)rAttr).IsActive() );
582 }
583 
584 SfxPoolItem*  SwFmtFooter::Clone( SfxItemPool* ) const
585 {
586 	return new SwFmtFooter( *this );
587 }
588 
589 //	class SwFmtCntnt
590 //	Implementierung teilweise inline im hxx
591 
592 SwFmtCntnt::SwFmtCntnt( const SwFmtCntnt &rCpy )
593 	: SfxPoolItem( RES_CNTNT )
594 {
595 	pStartNode = rCpy.GetCntntIdx() ?
596 					new SwNodeIndex( *rCpy.GetCntntIdx() ) : 0;
597 }
598 
599 SwFmtCntnt::SwFmtCntnt( const SwStartNode *pStartNd )
600 	: SfxPoolItem( RES_CNTNT )
601 {
602 	pStartNode = pStartNd ? new SwNodeIndex( *pStartNd ) : 0;
603 }
604 
605  SwFmtCntnt::~SwFmtCntnt()
606 {
607 	delete pStartNode;
608 }
609 
610 void SwFmtCntnt::SetNewCntntIdx( const SwNodeIndex *pIdx )
611 {
612 	delete pStartNode;
613 	pStartNode = pIdx ? new SwNodeIndex( *pIdx ) : 0;
614 }
615 
616 int  SwFmtCntnt::operator==( const SfxPoolItem& rAttr ) const
617 {
618 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
619 	if( (long)pStartNode ^ (long)((SwFmtCntnt&)rAttr).pStartNode )
620 		return 0;
621 	if( pStartNode )
622 		return ( *pStartNode == *((SwFmtCntnt&)rAttr).GetCntntIdx() );
623 	return 1;
624 }
625 
626 SfxPoolItem*  SwFmtCntnt::Clone( SfxItemPool* ) const
627 {
628 	return new SwFmtCntnt( *this );
629 }
630 
631 //	class SwFmtPageDesc
632 //	Implementierung teilweise inline im hxx
633 
634 SwFmtPageDesc::SwFmtPageDesc( const SwFmtPageDesc &rCpy )
635 	: SfxPoolItem( RES_PAGEDESC ),
636 	SwClient( (SwPageDesc*)rCpy.GetPageDesc() ),
637     nNumOffset( rCpy.nNumOffset ),
638     nDescNameIdx( rCpy.nDescNameIdx ),
639     pDefinedIn( 0 )
640 {
641 }
642 
643 SwFmtPageDesc::SwFmtPageDesc( const SwPageDesc *pDesc )
644 	: SfxPoolItem( RES_PAGEDESC ),
645 	SwClient( (SwPageDesc*)pDesc ),
646     nNumOffset( 0 ),
647     nDescNameIdx( 0xFFFF ), // IDX_NO_VALUE
648     pDefinedIn( 0 )
649 {
650 }
651 
652  SwFmtPageDesc::~SwFmtPageDesc() {}
653 
654 bool SwFmtPageDesc::KnowsPageDesc() const
655 {
656     return (GetRegisteredIn() != 0);
657 }
658 
659 int  SwFmtPageDesc::operator==( const SfxPoolItem& rAttr ) const
660 {
661 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
662 	return	( pDefinedIn == ((SwFmtPageDesc&)rAttr).pDefinedIn ) &&
663 			( nNumOffset == ((SwFmtPageDesc&)rAttr).nNumOffset ) &&
664 			( GetPageDesc() == ((SwFmtPageDesc&)rAttr).GetPageDesc() );
665 }
666 
667 SfxPoolItem*  SwFmtPageDesc::Clone( SfxItemPool* ) const
668 {
669 	return new SwFmtPageDesc( *this );
670 }
671 
672 void SwFmtPageDesc::SwClientNotify( const SwModify&, const SfxHint& rHint )
673 {
674     const SwPageDescHint* pHint = dynamic_cast<const SwPageDescHint*>(&rHint);
675     if ( pHint )
676     {
677         // mba: shouldn't that be broadcasted also?
678         SwFmtPageDesc aDfltDesc( pHint->GetPageDesc() );
679         SwPageDesc* pDesc = pHint->GetPageDesc();
680         const SwModify* pMod = GetDefinedIn();
681         if ( pMod )
682         {
683             if( pMod->ISA( SwCntntNode ) )
684                 ((SwCntntNode*)pMod)->SetAttr( aDfltDesc );
685             else if( pMod->ISA( SwFmt ))
686                 ((SwFmt*)pMod)->SetFmtAttr( aDfltDesc );
687             else
688             {
689                 DBG_ERROR( "What kind of SwModify is this?" );
690                 RegisterToPageDesc( *pDesc );
691             }
692         }
693         else
694             // there could be an Undo-copy
695             RegisterToPageDesc( *pDesc );
696     }
697 }
698 
699 void SwFmtPageDesc::RegisterToPageDesc( SwPageDesc& rDesc )
700 {
701     rDesc.Add( this );
702 }
703 
704 void SwFmtPageDesc::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
705 {
706 	if( !pDefinedIn )
707 		return;
708 
709     const sal_uInt16 nWhichId = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
710     switch( nWhichId )
711 	{
712 		case RES_OBJECTDYING:
713 				//Der Pagedesc, bei dem ich angemeldet bin stirbt, ich trage
714 				//mich also bei meinem Format aus.
715 				//Dabei werden ich Deletet!!!
716 			if( IS_TYPE( SwFmt, pDefinedIn ))
717 #ifdef DBG_UTIL
718 			{
719                 sal_Bool bDel = ((SwFmt*)pDefinedIn)->ResetFmtAttr( RES_PAGEDESC );
720 				ASSERT( bDel, ";-) FmtPageDesc nicht zerstoert." );
721 			}
722 #else
723                 ((SwFmt*)pDefinedIn)->ResetFmtAttr( RES_PAGEDESC );
724 #endif
725 			else if( IS_TYPE( SwCntntNode, pDefinedIn ))
726 #ifdef DBG_UTIL
727 			{
728 				sal_Bool bDel = ((SwCntntNode*)pDefinedIn)->ResetAttr( RES_PAGEDESC );
729 				ASSERT( bDel, ";-) FmtPageDesc nicht zerstoert." );
730 			}
731 #else
732 				((SwCntntNode*)pDefinedIn)->ResetAttr( RES_PAGEDESC );
733 #endif
734 			break;
735 
736 		default:
737 			/* do nothing */;
738 	}
739 }
740 
741 sal_Bool SwFmtPageDesc::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
742 {
743 	// hier wird immer konvertiert!
744 	nMemberId &= ~CONVERT_TWIPS;
745 	sal_Bool	bRet = sal_True;
746 	switch ( nMemberId )
747 	{
748 		case MID_PAGEDESC_PAGENUMOFFSET:
749 			rVal <<= (sal_Int16)GetNumOffset();
750 			break;
751 
752 		case MID_PAGEDESC_PAGEDESCNAME:
753 			{
754 				const SwPageDesc* pDesc = GetPageDesc();
755 				if( pDesc )
756 				{
757 					String aString;
758 					SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
759 					rVal <<= OUString( aString );
760 				}
761 				else
762 					rVal.clear();
763 			}
764 			break;
765 		default:
766 			ASSERT( !this, "unknown MemberId" );
767 			bRet = sal_False;
768 	}
769 	return bRet;
770 }
771 
772 sal_Bool SwFmtPageDesc::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
773 {
774 	// hier wird immer konvertiert!
775 	nMemberId &= ~CONVERT_TWIPS;
776 	sal_Bool bRet = sal_True;
777 	switch ( nMemberId )
778 	{
779 		case MID_PAGEDESC_PAGENUMOFFSET:
780         {
781             sal_Int16 nOffset = 0;
782             if(rVal >>= nOffset)
783                 SetNumOffset( nOffset );
784             else
785                 bRet = sal_False;
786         }
787         break;
788 
789 		case MID_PAGEDESC_PAGEDESCNAME:
790 			/* geht nicht, weil das Attribut eigentlich nicht den Namen
791 			 * sondern einen Pointer auf den PageDesc braucht (ist Client davon).
792 			 * Der Pointer waere aber ueber den Namen nur vom Dokument zu erfragen.
793 			 */
794 		default:
795 			ASSERT( !this, "unknown MemberId" );
796 			bRet = sal_False;
797 	}
798 	return bRet;
799 }
800 
801 
802 //	class SwFmtCol
803 //	Implementierung teilweise inline im hxx
804 
805 SwColumn::SwColumn() :
806     nWish ( 0 ),
807     nUpper( 0 ),
808 	nLower( 0 ),
809 	nLeft ( 0 ),
810     nRight( 0 )
811 {
812 }
813 
814 sal_Bool SwColumn::operator==( const SwColumn &rCmp )
815 {
816 	return (nWish    == rCmp.GetWishWidth() &&
817 			GetLeft()  == rCmp.GetLeft() &&
818 			GetRight() == rCmp.GetRight() &&
819 			GetUpper() == rCmp.GetUpper() &&
820 			GetLower() == rCmp.GetLower()) ? sal_True : sal_False;
821 }
822 
823 SwFmtCol::SwFmtCol( const SwFmtCol& rCpy )
824 	: SfxPoolItem( RES_COL ),
825 	nLineWidth( rCpy.nLineWidth),
826 	aLineColor( rCpy.aLineColor),
827 	nLineHeight( rCpy.GetLineHeight() ),
828 	eAdj( rCpy.GetLineAdj() ),
829     aColumns( (sal_Int8)rCpy.GetNumCols(), 1 ),
830     nWidth( rCpy.GetWishWidth() ),
831     aWidthAdjustValue( rCpy.aWidthAdjustValue ),
832     bOrtho( rCpy.IsOrtho() )
833 {
834 	for ( sal_uInt16 i = 0; i < rCpy.GetNumCols(); ++i )
835 	{
836 		SwColumn *pCol = new SwColumn( *rCpy.GetColumns()[i] );
837 		aColumns.Insert( pCol, aColumns.Count() );
838 	}
839 }
840 
841 SwFmtCol::~SwFmtCol() {}
842 
843 SwFmtCol& SwFmtCol::operator=( const SwFmtCol& rCpy )
844 {
845 	nLineWidth  = rCpy.nLineWidth;
846 	aLineColor  = rCpy.aLineColor;
847 	nLineHeight	= rCpy.GetLineHeight();
848 	eAdj		= rCpy.GetLineAdj();
849 	nWidth		= rCpy.GetWishWidth();
850 	bOrtho		= rCpy.IsOrtho();
851 	aWidthAdjustValue = rCpy.aWidthAdjustValue;
852 
853 	if ( aColumns.Count() )
854 		aColumns.DeleteAndDestroy( 0, aColumns.Count() );
855 	for ( sal_uInt16 i = 0; i < rCpy.GetNumCols(); ++i )
856 	{
857 		SwColumn *pCol = new SwColumn( *rCpy.GetColumns()[i] );
858 		aColumns.Insert( pCol, aColumns.Count() );
859 	}
860 	return *this;
861 }
862 
863 SwFmtCol::SwFmtCol()
864 	: SfxPoolItem( RES_COL ),
865     nLineWidth(0),
866     nLineHeight( 100 ),
867 	eAdj( COLADJ_NONE ),
868 	nWidth( USHRT_MAX ),
869 	aWidthAdjustValue( 0 ),
870 	bOrtho( sal_True )
871 {
872 }
873 
874 int SwFmtCol::operator==( const SfxPoolItem& rAttr ) const
875 {
876 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
877 	const SwFmtCol &rCmp = (const SwFmtCol&)rAttr;
878 	if( !(nLineWidth		== rCmp.nLineWidth  &&
879 		  aLineColor        == rCmp.aLineColor	&&
880 		  nLineHeight  		 == rCmp.GetLineHeight() &&
881 		  eAdj		 		 == rCmp.GetLineAdj() &&
882 		  nWidth  	 		 == rCmp.GetWishWidth() &&
883 		  bOrtho  			 == rCmp.IsOrtho() &&
884 		  aColumns.Count() == rCmp.GetNumCols() &&
885 		  aWidthAdjustValue == rCmp.GetAdjustValue()
886          ) )
887 		return 0;
888 
889 	for ( sal_uInt16 i = 0; i < aColumns.Count(); ++i )
890 		if ( !(*aColumns[i] == *rCmp.GetColumns()[i]) )
891 			return 0;
892 
893 	return 1;
894 }
895 
896 SfxPoolItem*  SwFmtCol::Clone( SfxItemPool* ) const
897 {
898 	return new SwFmtCol( *this );
899 }
900 
901 sal_uInt16 SwFmtCol::GetGutterWidth( sal_Bool bMin ) const
902 {
903 	sal_uInt16 nRet = 0;
904 	if ( aColumns.Count() == 2 )
905 		nRet = aColumns[0]->GetRight() + aColumns[1]->GetLeft();
906 	else if ( aColumns.Count() > 2 )
907 	{
908 		sal_Bool bSet = sal_False;
909 		for ( sal_uInt16 i = 1; i < aColumns.Count()-1; ++i )
910 		{
911 			const sal_uInt16 nTmp = aColumns[i]->GetRight() + aColumns[i+1]->GetLeft();
912 			if ( bSet )
913 			{
914 				if ( nTmp != nRet )
915 				{
916 					if ( !bMin )
917 						return USHRT_MAX;
918 					if ( nRet > nTmp )
919 						nRet = nTmp;
920 				}
921 			}
922 			else
923 			{	bSet = sal_True;
924 				nRet = nTmp;
925 			}
926 		}
927 	}
928 	return nRet;
929 }
930 
931 void SwFmtCol::SetGutterWidth( sal_uInt16 nNew, sal_uInt16 nAct )
932 {
933 	if ( bOrtho )
934 		Calc( nNew, nAct );
935 	else
936 	{
937 		sal_uInt16 nHalf = nNew / 2;
938 		for ( sal_uInt16 i = 0; i < aColumns.Count(); ++i )
939 		{	SwColumn *pCol = aColumns[i];
940 			pCol->SetLeft ( nHalf );
941 			pCol->SetRight( nHalf );
942 			if ( i == 0 )
943 				pCol->SetLeft( 0 );
944 			else if ( i == (aColumns.Count() - 1) )
945 				pCol->SetRight( 0 );
946 		}
947 	}
948 }
949 
950 void SwFmtCol::Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct )
951 {
952 	//Loeschen scheint hier auf den erste Blick vielleicht etwas zu heftig;
953 	//anderfalls muessten allerdings alle Werte der verbleibenden SwColumn's
954 	//initialisiert werden.
955 	if ( aColumns.Count() )
956 		aColumns.DeleteAndDestroy( 0, aColumns.Count() );
957 	for ( sal_uInt16 i = 0; i < nNumCols; ++i )
958 	{	SwColumn *pCol = new SwColumn;
959 		aColumns.Insert( pCol, i );
960 	}
961 	bOrtho = sal_True;
962 	nWidth = USHRT_MAX;
963 	if( nNumCols )
964 		Calc( nGutterWidth, nAct );
965 }
966 
967 void SwFmtCol::SetOrtho( sal_Bool bNew, sal_uInt16 nGutterWidth, sal_uInt16 nAct )
968 {
969 	bOrtho = bNew;
970 	if ( bNew && aColumns.Count() )
971 		Calc( nGutterWidth, nAct );
972 }
973 
974 sal_uInt16 SwFmtCol::CalcColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const
975 {
976 	ASSERT( nCol < aColumns.Count(), ":-( ColumnsArr ueberindiziert." );
977 	if ( nWidth != nAct )
978 	{
979 		long nW = aColumns[nCol]->GetWishWidth();
980 		nW *= nAct;
981 		nW /= nWidth;
982 		return sal_uInt16(nW);
983 	}
984 	else
985 		return aColumns[nCol]->GetWishWidth();
986 }
987 
988 sal_uInt16 SwFmtCol::CalcPrtColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const
989 {
990 	ASSERT( nCol < aColumns.Count(), ":-( ColumnsArr ueberindiziert." );
991 	sal_uInt16 nRet = CalcColWidth( nCol, nAct );
992 	SwColumn *pCol = aColumns[nCol];
993 	nRet = nRet - pCol->GetLeft();
994 	nRet = nRet - pCol->GetRight();
995 	return nRet;
996 }
997 
998 void SwFmtCol::Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct )
999 {
1000 	if(!GetNumCols())
1001         return;
1002     //Erstmal die Spalten mit der Aktuellen Breite einstellen, dann die
1003 	//Wunschbreite der Spalten anhand der Gesamtwunschbreite hochrechnen.
1004 
1005 	const sal_uInt16 nGutterHalf = nGutterWidth ? nGutterWidth / 2 : 0;
1006 
1007 	//Breite der PrtAreas ist Gesamtbreite - Zwischenraeume / Anzahl
1008 	const sal_uInt16 nPrtWidth =
1009 				(nAct - ((GetNumCols()-1) * nGutterWidth)) / GetNumCols();
1010 	sal_uInt16 nAvail = nAct;
1011 
1012 	//Die erste Spalte ist PrtBreite + (Zwischenraumbreite/2)
1013 	const sal_uInt16 nLeftWidth = nPrtWidth + nGutterHalf;
1014 	SwColumn *pCol = aColumns[0];
1015 	pCol->SetWishWidth( nLeftWidth );
1016 	pCol->SetRight( nGutterHalf );
1017 	pCol->SetLeft ( 0 );
1018 	nAvail = nAvail - nLeftWidth;
1019 
1020 	//Spalte 2 bis n-1 ist PrtBreite + Zwischenraumbreite
1021 	const sal_uInt16 nMidWidth = nPrtWidth + nGutterWidth;
1022 	sal_uInt16 i;
1023 
1024 	for ( i = 1; i < GetNumCols()-1; ++i )
1025 	{
1026 		pCol = aColumns[i];
1027 		pCol->SetWishWidth( nMidWidth );
1028 		pCol->SetLeft ( nGutterHalf );
1029 		pCol->SetRight( nGutterHalf );
1030 		nAvail = nAvail - nMidWidth;
1031 	}
1032 
1033 	//Die Letzte Spalte entspricht wieder der ersten, um Rundungsfehler
1034 	//auszugleichen wird der letzten Spalte alles zugeschlagen was die
1035 	//anderen nicht verbraucht haben.
1036 	pCol = aColumns[aColumns.Count()-1];
1037 	pCol->SetWishWidth( nAvail );
1038 	pCol->SetLeft ( nGutterHalf );
1039 	pCol->SetRight( 0 );
1040 
1041 	//Umrechnen der aktuellen Breiten in Wunschbreiten.
1042 	for ( i = 0; i < aColumns.Count(); ++i )
1043 	{
1044 		pCol = aColumns[i];
1045 		long nTmp = pCol->GetWishWidth();
1046 		nTmp *= GetWishWidth();
1047 		nTmp /= nAct;
1048 		pCol->SetWishWidth( sal_uInt16(nTmp) );
1049 	}
1050 }
1051 
1052 sal_Bool SwFmtCol::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1053 {
1054 	// hier wird immer konvertiert!
1055 	nMemberId &= ~CONVERT_TWIPS;
1056 	if(MID_COLUMN_SEPARATOR_LINE == nMemberId)
1057 	{
1058 		DBG_ERROR("not implemented");
1059 	}
1060 	else
1061 	{
1062 		uno::Reference< text::XTextColumns >  xCols = new SwXTextColumns(*this);
1063 		rVal.setValue(&xCols, ::getCppuType((uno::Reference< text::XTextColumns>*)0));
1064 	}
1065 	return sal_True;
1066 }
1067 
1068 sal_Bool SwFmtCol::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1069 {
1070 	// hier wird immer konvertiert!
1071 	nMemberId &= ~CONVERT_TWIPS;
1072 	sal_Bool bRet = sal_False;
1073 	if(MID_COLUMN_SEPARATOR_LINE == nMemberId)
1074 	{
1075 		DBG_ERROR("not implemented");
1076 	}
1077 	else
1078 	{
1079         uno::Reference< text::XTextColumns > xCols;
1080         rVal >>= xCols;
1081         if(xCols.is())
1082 		{
1083             uno::Sequence<text::TextColumn> aSetColumns = xCols->getColumns();
1084 			const text::TextColumn* pArray = aSetColumns.getConstArray();
1085 			aColumns.DeleteAndDestroy(0, aColumns.Count());
1086 			//max. Count ist hier 64K - das kann das Array aber nicht
1087 			sal_uInt16 nCount = Min( (sal_uInt16)aSetColumns.getLength(),
1088 									 (sal_uInt16) 0x3fff );
1089 			sal_uInt16 nWidthSum = 0;
1090             // #101224# one column is no column
1091             //
1092             if(nCount > 1)
1093                 for(sal_uInt16 i = 0; i < nCount; i++)
1094                 {
1095                     SwColumn* pCol = new SwColumn;
1096                     pCol->SetWishWidth( static_cast<sal_uInt16>(pArray[i].Width) );
1097                     nWidthSum = static_cast<sal_uInt16>(nWidthSum + pArray[i].Width);
1098                     pCol->SetLeft ( static_cast<sal_uInt16>(MM100_TO_TWIP(pArray[i].LeftMargin)) );
1099                     pCol->SetRight( static_cast<sal_uInt16>(MM100_TO_TWIP(pArray[i].RightMargin)) );
1100                     aColumns.Insert(pCol, i);
1101                 }
1102 			bRet = sal_True;
1103 			nWidth = nWidthSum;
1104             bOrtho = sal_False;
1105 
1106             uno::Reference<lang::XUnoTunnel> xNumTunnel(xCols, uno::UNO_QUERY);
1107 			SwXTextColumns* pSwColums = 0;
1108 			if(xNumTunnel.is())
1109 			{
1110                 pSwColums = reinterpret_cast< SwXTextColumns * >(
1111                     sal::static_int_cast< sal_IntPtr >(
1112                     xNumTunnel->getSomething( SwXTextColumns::getUnoTunnelId() )));
1113 			}
1114 			if(pSwColums)
1115 			{
1116                 bOrtho = pSwColums->IsAutomaticWidth();
1117                 nLineWidth = pSwColums->GetSepLineWidth();
1118 				aLineColor.SetColor(pSwColums->GetSepLineColor());
1119 				nLineHeight = pSwColums->GetSepLineHeightRelative();
1120 				if(!pSwColums->GetSepLineIsOn())
1121 					eAdj = COLADJ_NONE;
1122 				else switch(pSwColums->GetSepLineVertAlign())
1123 				{
1124 					case 0: eAdj = COLADJ_TOP;	break;	//VerticalAlignment_TOP
1125 					case 1: eAdj = COLADJ_CENTER;break; //VerticalAlignment_MIDDLE
1126 					case 2: eAdj = COLADJ_BOTTOM;break;	//VerticalAlignment_BOTTOM
1127                     default: ASSERT( !this, "unknown alignment" ); break;
1128 				}
1129 			}
1130 		}
1131 	}
1132 	return bRet;
1133 }
1134 
1135 
1136 //	class SwFmtSurround
1137 //	Implementierung teilweise inline im hxx
1138 
1139 SwFmtSurround::SwFmtSurround( SwSurround eFly ) :
1140 	SfxEnumItem( RES_SURROUND, sal_uInt16( eFly ) )
1141 {
1142 	bAnchorOnly = bContour = bOutside = sal_False;
1143 }
1144 
1145 SwFmtSurround::SwFmtSurround( const SwFmtSurround &rCpy ) :
1146 	SfxEnumItem( RES_SURROUND, rCpy.GetValue() )
1147 {
1148 	bAnchorOnly = rCpy.bAnchorOnly;
1149 	bContour = rCpy.bContour;
1150 	bOutside = rCpy.bOutside;
1151 }
1152 
1153 int  SwFmtSurround::operator==( const SfxPoolItem& rAttr ) const
1154 {
1155 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
1156 	return ( GetValue() == ((SwFmtSurround&)rAttr).GetValue() &&
1157 			 bAnchorOnly== ((SwFmtSurround&)rAttr).bAnchorOnly &&
1158 			 bContour== ((SwFmtSurround&)rAttr).bContour &&
1159 			 bOutside== ((SwFmtSurround&)rAttr).bOutside );
1160 }
1161 
1162 SfxPoolItem*  SwFmtSurround::Clone( SfxItemPool* ) const
1163 {
1164 	return new SwFmtSurround( *this );
1165 }
1166 
1167 sal_uInt16  SwFmtSurround::GetValueCount() const
1168 {
1169 	return SURROUND_END - SURROUND_BEGIN;
1170 }
1171 
1172 
1173 sal_Bool SwFmtSurround::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1174 {
1175 	// hier wird immer konvertiert!
1176 	nMemberId &= ~CONVERT_TWIPS;
1177 	sal_Bool bRet = sal_True;
1178 	switch ( nMemberId )
1179 	{
1180 		case MID_SURROUND_SURROUNDTYPE:
1181 				rVal <<= (text::WrapTextMode)GetSurround();
1182 		break;
1183 		case MID_SURROUND_ANCHORONLY:
1184 		{
1185 			sal_Bool bTmp = IsAnchorOnly();
1186 			rVal.setValue(&bTmp, ::getBooleanCppuType());
1187 		}
1188 				break;
1189 		case MID_SURROUND_CONTOUR:
1190 		{
1191 			sal_Bool bTmp = IsContour();
1192 			rVal.setValue(&bTmp, ::getBooleanCppuType());
1193 		}
1194 				break;
1195 		case MID_SURROUND_CONTOUROUTSIDE:
1196 		{
1197 			sal_Bool bTmp = IsOutside();
1198 			rVal.setValue(&bTmp, ::getBooleanCppuType());
1199 		}
1200 				break;
1201 		default:
1202 			ASSERT( !this, "unknown MemberId" );
1203 			bRet = sal_False;
1204 	}
1205 	return bRet;
1206 }
1207 
1208 sal_Bool SwFmtSurround::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1209 {
1210 	// hier wird immer konvertiert!
1211 	nMemberId &= ~CONVERT_TWIPS;
1212 	sal_Bool bRet = sal_True;
1213 	switch ( nMemberId )
1214 	{
1215 		case MID_SURROUND_SURROUNDTYPE:
1216 		{
1217 			sal_Int32 eVal = SWUnoHelper::GetEnumAsInt32( rVal );
1218 			if( eVal >= 0 && eVal < (sal_Int16)SURROUND_END )
1219 				SetValue( static_cast<sal_uInt16>(eVal) );
1220 			else {
1221 				//exception
1222 				;
1223             }
1224 		}
1225 		break;
1226 
1227 		case MID_SURROUND_ANCHORONLY:
1228 			SetAnchorOnly( *(sal_Bool*)rVal.getValue() );
1229 			break;
1230 		case MID_SURROUND_CONTOUR:
1231 			SetContour( *(sal_Bool*)rVal.getValue() );
1232 			break;
1233 		case MID_SURROUND_CONTOUROUTSIDE:
1234 			SetOutside( *(sal_Bool*)rVal.getValue() );
1235 			break;
1236 		default:
1237 			ASSERT( !this, "unknown MemberId" );
1238 			bRet = sal_False;
1239 	}
1240 	return bRet;
1241 }
1242 
1243 //	class SwFmtVertOrient
1244 //	Implementierung teilweise inline im hxx
1245 
1246 SwFmtVertOrient::SwFmtVertOrient( SwTwips nY, sal_Int16 eVert,
1247                                   sal_Int16 eRel )
1248 	: SfxPoolItem( RES_VERT_ORIENT ),
1249 	nYPos( nY ),
1250 	eOrient( eVert ),
1251 	eRelation( eRel )
1252 {}
1253 
1254 int  SwFmtVertOrient::operator==( const SfxPoolItem& rAttr ) const
1255 {
1256 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
1257 	return ( nYPos     == ((SwFmtVertOrient&)rAttr).nYPos &&
1258 			 eOrient   == ((SwFmtVertOrient&)rAttr).eOrient &&
1259 			 eRelation == ((SwFmtVertOrient&)rAttr).eRelation );
1260 }
1261 
1262 SfxPoolItem*  SwFmtVertOrient::Clone( SfxItemPool* ) const
1263 {
1264 	return new SwFmtVertOrient( nYPos, eOrient, eRelation );
1265 }
1266 
1267 sal_Bool SwFmtVertOrient::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1268 {
1269 	// hier wird immer konvertiert!
1270 	nMemberId &= ~CONVERT_TWIPS;
1271 	sal_Bool bRet = sal_True;
1272 	switch ( nMemberId )
1273 	{
1274 		case MID_VERTORIENT_ORIENT:
1275 		{
1276             sal_Int16 nRet = text::VertOrientation::NONE;
1277 			switch( eOrient )
1278 			{
1279                 case text::VertOrientation::TOP        :  nRet = text::VertOrientation::TOP        ;break;
1280                 case text::VertOrientation::CENTER     :  nRet = text::VertOrientation::CENTER     ;break;
1281                 case text::VertOrientation::BOTTOM     :  nRet = text::VertOrientation::BOTTOM     ;break;
1282                 case text::VertOrientation::CHAR_TOP   :  nRet = text::VertOrientation::CHAR_TOP   ;break;
1283                 case text::VertOrientation::CHAR_CENTER:  nRet = text::VertOrientation::CHAR_CENTER;break;
1284                 case text::VertOrientation::CHAR_BOTTOM:  nRet = text::VertOrientation::CHAR_BOTTOM;break;
1285                 case text::VertOrientation::LINE_TOP   :  nRet = text::VertOrientation::LINE_TOP   ;break;
1286                 case text::VertOrientation::LINE_CENTER:  nRet = text::VertOrientation::LINE_CENTER;break;
1287                 case text::VertOrientation::LINE_BOTTOM:  nRet = text::VertOrientation::LINE_BOTTOM;break;
1288                 default: break;
1289 			}
1290 			rVal <<= nRet;
1291 		}
1292 		break;
1293 		case MID_VERTORIENT_RELATION:
1294 				rVal <<= lcl_RelToINT(eRelation);
1295 		break;
1296 		case MID_VERTORIENT_POSITION:
1297 				rVal <<= (sal_Int32)TWIP_TO_MM100(GetPos());
1298 				break;
1299 		default:
1300 			ASSERT( !this, "unknown MemberId" );
1301 			bRet = sal_False;
1302 	}
1303 	return bRet;
1304 }
1305 
1306 sal_Bool SwFmtVertOrient::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1307 {
1308 	sal_Bool bConvert = 0 != (nMemberId&CONVERT_TWIPS);
1309 	nMemberId &= ~CONVERT_TWIPS;
1310 	sal_Bool bRet = sal_True;
1311 	switch ( nMemberId )
1312 	{
1313 		case MID_VERTORIENT_ORIENT:
1314 		{
1315 			sal_uInt16 nVal = 0;
1316 			rVal >>= nVal;
1317 			switch( nVal )
1318 			{
1319                 case text::VertOrientation::NONE:           eOrient = text::VertOrientation::NONE;    break;
1320                 case text::VertOrientation::TOP        :    eOrient = text::VertOrientation::TOP;     break;
1321                 case text::VertOrientation::CENTER     :    eOrient = text::VertOrientation::CENTER;     break;
1322                 case text::VertOrientation::BOTTOM     :    eOrient = text::VertOrientation::BOTTOM;     break;
1323                 case text::VertOrientation::CHAR_TOP   :    eOrient = text::VertOrientation::CHAR_TOP;   break;
1324                 case text::VertOrientation::CHAR_CENTER:    eOrient = text::VertOrientation::CHAR_CENTER;break;
1325                 case text::VertOrientation::CHAR_BOTTOM:    eOrient = text::VertOrientation::CHAR_BOTTOM;break;
1326                 case text::VertOrientation::LINE_TOP   :    eOrient = text::VertOrientation::LINE_TOP;    break;
1327                 case text::VertOrientation::LINE_CENTER:    eOrient = text::VertOrientation::LINE_CENTER;break;
1328                 case text::VertOrientation::LINE_BOTTOM:    eOrient = text::VertOrientation::LINE_BOTTOM;break;
1329 			}
1330 		}
1331 		break;
1332 		case MID_VERTORIENT_RELATION:
1333 		{
1334 			eRelation = lcl_IntToRelation(rVal);
1335 		}
1336 		break;
1337 		case MID_VERTORIENT_POSITION:
1338 		{
1339 			sal_Int32 nVal = 0;
1340 			rVal >>= nVal;
1341 			if(bConvert)
1342 				nVal = MM100_TO_TWIP(nVal);
1343 			SetPos( nVal );
1344 		}
1345 		break;
1346 		default:
1347 			ASSERT( !this, "unknown MemberId" );
1348 			bRet = sal_False;
1349 	}
1350 	return bRet;
1351 }
1352 
1353 
1354 
1355 //	class SwFmtHoriOrient
1356 //	Implementierung teilweise inline im hxx
1357 
1358 SwFmtHoriOrient::SwFmtHoriOrient( SwTwips nX, sal_Int16 eHori,
1359                               sal_Int16 eRel, sal_Bool bPos )
1360 	: SfxPoolItem( RES_HORI_ORIENT ),
1361 	nXPos( nX ),
1362 	eOrient( eHori ),
1363 	eRelation( eRel ),
1364 	bPosToggle( bPos )
1365 {}
1366 
1367 int  SwFmtHoriOrient::operator==( const SfxPoolItem& rAttr ) const
1368 {
1369 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
1370 	return ( nXPos == ((SwFmtHoriOrient&)rAttr).nXPos &&
1371 			 eOrient == ((SwFmtHoriOrient&)rAttr).eOrient &&
1372 			 eRelation == ((SwFmtHoriOrient&)rAttr).eRelation &&
1373 			 bPosToggle == ((SwFmtHoriOrient&)rAttr).bPosToggle );
1374 }
1375 
1376 SfxPoolItem*  SwFmtHoriOrient::Clone( SfxItemPool* ) const
1377 {
1378 	return new SwFmtHoriOrient( nXPos, eOrient, eRelation, bPosToggle );
1379 }
1380 
1381 sal_Bool SwFmtHoriOrient::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1382 {
1383 	// hier wird immer konvertiert!
1384 	nMemberId &= ~CONVERT_TWIPS;
1385 	sal_Bool bRet = sal_True;
1386 	switch ( nMemberId )
1387 	{
1388 		case MID_HORIORIENT_ORIENT:
1389 		{
1390             sal_Int16 nRet = text::HoriOrientation::NONE;
1391 			switch( eOrient )
1392 			{
1393                 case text::HoriOrientation::RIGHT:    nRet = text::HoriOrientation::RIGHT; break;
1394                 case text::HoriOrientation::CENTER :  nRet = text::HoriOrientation::CENTER; break;
1395                 case text::HoriOrientation::LEFT   :  nRet = text::HoriOrientation::LEFT; break;
1396                 case text::HoriOrientation::INSIDE :  nRet = text::HoriOrientation::INSIDE; break;
1397                 case text::HoriOrientation::OUTSIDE:  nRet = text::HoriOrientation::OUTSIDE; break;
1398                 case text::HoriOrientation::FULL:     nRet = text::HoriOrientation::FULL; break;
1399                 case text::HoriOrientation::LEFT_AND_WIDTH :
1400                     nRet = text::HoriOrientation::LEFT_AND_WIDTH;
1401                     break;
1402                 default:
1403                     break;
1404 
1405 			}
1406 			rVal <<= nRet;
1407 		}
1408 		break;
1409 		case MID_HORIORIENT_RELATION:
1410 			rVal <<= lcl_RelToINT(eRelation);
1411 		break;
1412 		case MID_HORIORIENT_POSITION:
1413 				rVal <<= (sal_Int32)TWIP_TO_MM100(GetPos());
1414 				break;
1415 		case MID_HORIORIENT_PAGETOGGLE:
1416 		{
1417 			sal_Bool bTmp = IsPosToggle();
1418 			rVal.setValue(&bTmp, ::getBooleanCppuType());
1419 		}
1420 				break;
1421 		default:
1422 			ASSERT( !this, "unknown MemberId" );
1423 			bRet = sal_False;
1424 	}
1425 	return bRet;
1426 }
1427 
1428 sal_Bool SwFmtHoriOrient::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1429 {
1430 	sal_Bool bConvert = 0 != (nMemberId&CONVERT_TWIPS);
1431 	nMemberId &= ~CONVERT_TWIPS;
1432 	sal_Bool bRet = sal_True;
1433 	switch ( nMemberId )
1434 	{
1435 		case MID_HORIORIENT_ORIENT:
1436 		{
1437             sal_Int16 nVal = 0;
1438             rVal >>= nVal;
1439             switch( nVal )
1440 			{
1441                 case text::HoriOrientation::NONE:       eOrient = text::HoriOrientation::NONE ;   break;
1442                 case text::HoriOrientation::RIGHT:  eOrient = text::HoriOrientation::RIGHT;   break;
1443                 case text::HoriOrientation::CENTER :    eOrient = text::HoriOrientation::CENTER;  break;
1444                 case text::HoriOrientation::LEFT   :    eOrient = text::HoriOrientation::LEFT;    break;
1445                 case text::HoriOrientation::INSIDE :    eOrient = text::HoriOrientation::INSIDE;  break;
1446                 case text::HoriOrientation::OUTSIDE:    eOrient = text::HoriOrientation::OUTSIDE; break;
1447                 case text::HoriOrientation::FULL:      eOrient = text::HoriOrientation::FULL;     break;
1448                 case text::HoriOrientation::LEFT_AND_WIDTH:
1449                     eOrient = text::HoriOrientation::LEFT_AND_WIDTH;
1450 				break;
1451 			}
1452 		}
1453 		break;
1454 		case MID_HORIORIENT_RELATION:
1455 		{
1456 			eRelation = lcl_IntToRelation(rVal);
1457 		}
1458 		break;
1459 		case MID_HORIORIENT_POSITION:
1460 		{
1461             sal_Int32 nVal = 0;
1462             if(!(rVal >>= nVal))
1463                 bRet = sal_False;
1464 			if(bConvert)
1465 				nVal = MM100_TO_TWIP(nVal);
1466 			SetPos( nVal );
1467 		}
1468 		break;
1469 		case MID_HORIORIENT_PAGETOGGLE:
1470 				SetPosToggle( *(sal_Bool*)rVal.getValue());
1471 			break;
1472 		default:
1473 			ASSERT( !this, "unknown MemberId" );
1474 			bRet = sal_False;
1475 	}
1476 	return bRet;
1477 }
1478 
1479 
1480 
1481 //	class SwFmtAnchor
1482 //	Implementierung teilweise inline im hxx
1483 
1484 SwFmtAnchor::SwFmtAnchor( RndStdIds nRnd, sal_uInt16 nPage )
1485 	: SfxPoolItem( RES_ANCHOR ),
1486 	pCntntAnchor( 0 ),
1487 	nAnchorId( nRnd ),
1488     nPageNum( nPage ),
1489     // OD 2004-05-05 #i28701# - get always new increased order number
1490     mnOrder( ++mnOrderCounter )
1491 {}
1492 
1493 SwFmtAnchor::SwFmtAnchor( const SwFmtAnchor &rCpy )
1494 	: SfxPoolItem( RES_ANCHOR ),
1495 	nAnchorId( rCpy.GetAnchorId() ),
1496     nPageNum( rCpy.GetPageNum() ),
1497     // OD 2004-05-05 #i28701# - get always new increased order number
1498     mnOrder( ++mnOrderCounter )
1499 {
1500 	pCntntAnchor = rCpy.GetCntntAnchor() ?
1501 						new SwPosition( *rCpy.GetCntntAnchor() ) : 0;
1502 }
1503 
1504  SwFmtAnchor::~SwFmtAnchor()
1505 {
1506 	delete pCntntAnchor;
1507 }
1508 
1509 void SwFmtAnchor::SetAnchor( const SwPosition *pPos )
1510 {
1511 	if ( pCntntAnchor )
1512 		delete pCntntAnchor;
1513 	pCntntAnchor = pPos ? new SwPosition( *pPos ) : 0;
1514 		//AM Absatz gebundene Flys sollten nie in den Absatz hineinzeigen.
1515     if (pCntntAnchor &&
1516         ((FLY_AT_PARA == nAnchorId) || (FLY_AT_FLY == nAnchorId)))
1517     {
1518 		pCntntAnchor->nContent.Assign( 0, 0 );
1519     }
1520 }
1521 
1522 SwFmtAnchor& SwFmtAnchor::operator=(const SwFmtAnchor& rAnchor)
1523 {
1524 	nAnchorId  = rAnchor.GetAnchorId();
1525 	nPageNum   = rAnchor.GetPageNum();
1526     // OD 2004-05-05 #i28701# - get always new increased order number
1527     mnOrder = ++mnOrderCounter;
1528 
1529 	delete pCntntAnchor;
1530 	pCntntAnchor = rAnchor.pCntntAnchor ?
1531 									new SwPosition(*(rAnchor.pCntntAnchor)) : 0;
1532 	return *this;
1533 }
1534 
1535 int  SwFmtAnchor::operator==( const SfxPoolItem& rAttr ) const
1536 {
1537 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
1538     // OD 2004-05-05 #i28701# - Note: <mnOrder> hasn't to be considered.
1539 	return ( nAnchorId == ((SwFmtAnchor&)rAttr).GetAnchorId() &&
1540 			 nPageNum == ((SwFmtAnchor&)rAttr).GetPageNum()   &&
1541 					//Anker vergleichen. Entweder zeigen beide auf das gleiche
1542 					//Attribut bzw. sind 0 oder die SwPosition* sind beide
1543 					//gueltig und die SwPositions sind gleich.
1544 			 (pCntntAnchor == ((SwFmtAnchor&)rAttr).GetCntntAnchor() ||
1545 			  (pCntntAnchor && ((SwFmtAnchor&)rAttr).GetCntntAnchor() &&
1546 			   *pCntntAnchor == *((SwFmtAnchor&)rAttr).GetCntntAnchor())));
1547 }
1548 
1549 SfxPoolItem*  SwFmtAnchor::Clone( SfxItemPool* ) const
1550 {
1551 	return new SwFmtAnchor( *this );
1552 }
1553 
1554 // OD 2004-05-05 #i28701#
1555 sal_uInt32 SwFmtAnchor::mnOrderCounter = 0;
1556 
1557 // OD 2004-05-05 #i28701#
1558 sal_uInt32 SwFmtAnchor::GetOrder() const
1559 {
1560     return mnOrder;
1561 }
1562 
1563 /*-----------------16.02.98 15:21-------------------
1564 
1565 --------------------------------------------------*/
1566 sal_Bool SwFmtAnchor::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1567 {
1568 	// hier wird immer konvertiert!
1569 	nMemberId &= ~CONVERT_TWIPS;
1570 	sal_Bool bRet = sal_True;
1571 	switch ( nMemberId )
1572 	{
1573 		case MID_ANCHOR_ANCHORTYPE:
1574 
1575 			text::TextContentAnchorType eRet;
1576             switch (GetAnchorId())
1577             {
1578                 case  FLY_AT_CHAR:
1579                     eRet = text::TextContentAnchorType_AT_CHARACTER;
1580                     break;
1581                 case  FLY_AT_PAGE:
1582                     eRet = text::TextContentAnchorType_AT_PAGE;
1583                     break;
1584                 case  FLY_AT_FLY:
1585                     eRet = text::TextContentAnchorType_AT_FRAME;
1586                     break;
1587                 case  FLY_AS_CHAR:
1588                     eRet = text::TextContentAnchorType_AS_CHARACTER;
1589                     break;
1590                 //case  FLY_AT_PARA:
1591                 default:
1592                     eRet = text::TextContentAnchorType_AT_PARAGRAPH;
1593             }
1594 			rVal <<= eRet;
1595 		break;
1596 		case MID_ANCHOR_PAGENUM:
1597 			rVal <<= (sal_Int16)GetPageNum();
1598         break;
1599         case MID_ANCHOR_ANCHORFRAME:
1600         {
1601             if(pCntntAnchor && FLY_AT_FLY == nAnchorId)
1602             {
1603                 SwFrmFmt* pFmt = pCntntAnchor->nNode.GetNode().GetFlyFmt();
1604                 if(pFmt)
1605                 {
1606                     uno::Reference<container::XNamed> xNamed = SwXFrames::GetObject( *pFmt, FLYCNTTYPE_FRM );
1607                     uno::Reference<text::XTextFrame> xRet(xNamed, uno::UNO_QUERY);
1608                     rVal <<= xRet;
1609                 }
1610             }
1611         }
1612         break;
1613         default:
1614 			ASSERT( !this, "unknown MemberId" );
1615 			bRet = sal_False;
1616 	}
1617 	return bRet;
1618 }
1619 
1620 sal_Bool SwFmtAnchor::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1621 {
1622 	// hier wird immer konvertiert!
1623 	nMemberId &= ~CONVERT_TWIPS;
1624 	sal_Bool bRet = sal_True;
1625 	switch ( nMemberId )
1626 	{
1627 		case MID_ANCHOR_ANCHORTYPE:
1628 		{
1629 			RndStdIds	eAnchor;
1630 			switch( SWUnoHelper::GetEnumAsInt32( rVal ) )
1631 			{
1632 				case  text::TextContentAnchorType_AS_CHARACTER:
1633                     eAnchor = FLY_AS_CHAR;
1634 					break;
1635 				case  text::TextContentAnchorType_AT_PAGE:
1636                     eAnchor = FLY_AT_PAGE;
1637 					if( GetPageNum() > 0 && pCntntAnchor )
1638 					{
1639 						// If the anchor type is page and a valid page number
1640 						// has been set, the content position isn't required
1641 						// any longer.
1642 						delete pCntntAnchor;
1643 						pCntntAnchor = 0;
1644 					}
1645 					break;
1646 				case  text::TextContentAnchorType_AT_FRAME:
1647 					eAnchor = FLY_AT_FLY;
1648 					break;
1649 				case  text::TextContentAnchorType_AT_CHARACTER:
1650                     eAnchor = FLY_AT_CHAR;
1651 					break;
1652 				//case  text::TextContentAnchorType_AT_PARAGRAPH:
1653 				default:
1654                     eAnchor = FLY_AT_PARA;
1655 					break;
1656 			}
1657 			SetType( eAnchor );
1658 		}
1659 		break;
1660 		case MID_ANCHOR_PAGENUM:
1661 		{
1662             sal_Int16 nVal = 0;
1663             if((rVal >>= nVal) && nVal > 0)
1664 			{
1665 				SetPageNum( nVal );
1666                 if ((FLY_AT_PAGE == GetAnchorId()) && pCntntAnchor)
1667                 {
1668 					// If the anchor type is page and a valid page number
1669 					// is set, the content paoition has to be deleted to not
1670 					// confuse the layout (frmtool.cxx). However, if the
1671 					// anchor type is not page, any content position will
1672 					// be kept.
1673 					delete pCntntAnchor;
1674 					pCntntAnchor = 0;
1675 				}
1676 			}
1677 			else
1678 				bRet = sal_False;
1679 		}
1680 		break;
1681         case MID_ANCHOR_ANCHORFRAME:
1682         //no break here!;
1683 		default:
1684 			ASSERT( !this, "unknown MemberId" );
1685 			bRet = sal_False;
1686 	}
1687 	return bRet;
1688 }
1689 
1690 //	class SwFmtURL
1691 //	Implementierung teilweise inline im hxx
1692 
1693 SwFmtURL::SwFmtURL() :
1694 	SfxPoolItem( RES_URL ),
1695 	pMap( 0 ),
1696 	bIsServerMap( sal_False )
1697 {
1698 }
1699 
1700 SwFmtURL::SwFmtURL( const SwFmtURL &rURL) :
1701 	SfxPoolItem( RES_URL ),
1702     sTargetFrameName( rURL.GetTargetFrameName() ),
1703     sURL( rURL.GetURL() ),
1704     sName( rURL.GetName() ),
1705 	bIsServerMap( rURL.IsServerMap() )
1706 {
1707 	pMap = rURL.GetMap() ? new ImageMap( *rURL.GetMap() ) : 0;
1708 }
1709 
1710 SwFmtURL::~SwFmtURL()
1711 {
1712 	if ( pMap )
1713 		delete pMap;
1714 }
1715 
1716 int SwFmtURL::operator==( const SfxPoolItem &rAttr ) const
1717 {
1718 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
1719 	const SwFmtURL &rCmp = (SwFmtURL&)rAttr;
1720 	sal_Bool bRet = bIsServerMap  	 == rCmp.IsServerMap() &&
1721 				sURL			 == rCmp.GetURL() &&
1722 				sTargetFrameName == rCmp.GetTargetFrameName() &&
1723 				sName 			 == rCmp.GetName();
1724 	if ( bRet )
1725 	{
1726 		if ( pMap && rCmp.GetMap() )
1727 			bRet = *pMap == *rCmp.GetMap();
1728 		else
1729 			bRet = pMap == rCmp.GetMap();
1730 	}
1731 	return bRet;
1732 }
1733 
1734 SfxPoolItem* SwFmtURL::Clone( SfxItemPool* ) const
1735 {
1736 	return new SwFmtURL( *this );
1737 }
1738 
1739 void SwFmtURL::SetURL( const XubString &rURL, sal_Bool bServerMap )
1740 {
1741 	sURL = rURL;
1742 	bIsServerMap = bServerMap;
1743 }
1744 
1745 void SwFmtURL::SetMap( const ImageMap *pM )
1746 {
1747 	if ( pMap )
1748 		delete pMap;
1749 	pMap = pM ? new ImageMap( *pM ) : 0;
1750 }
1751 extern const SvEventDescription* lcl_GetSupportedMacroItems();
1752 
1753 sal_Bool SwFmtURL::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1754 {
1755 	// hier wird immer konvertiert!
1756 	nMemberId &= ~CONVERT_TWIPS;
1757 	sal_Bool bRet = sal_True;
1758 	switch ( nMemberId )
1759 	{
1760 		case MID_URL_URL:
1761 		{
1762 			OUString sRet = GetURL();
1763 			rVal <<= sRet;
1764 		}
1765 		break;
1766 		case MID_URL_TARGET:
1767 		{
1768 			OUString sRet = GetTargetFrameName();
1769 			rVal <<= sRet;
1770 		}
1771 		break;
1772 		case MID_URL_HYPERLINKNAME:
1773 			rVal <<= OUString( GetName() );
1774 			break;
1775 		case MID_URL_CLIENTMAP:
1776         {
1777             uno::Reference< uno::XInterface > xInt;
1778             if(pMap)
1779             {
1780                 xInt = SvUnoImageMap_createInstance( *pMap, lcl_GetSupportedMacroItems() );
1781             }
1782             else
1783             {
1784                 ImageMap aEmptyMap;
1785                 xInt = SvUnoImageMap_createInstance( aEmptyMap, lcl_GetSupportedMacroItems() );
1786             }
1787             uno::Reference< container::XIndexContainer > xCont(xInt, uno::UNO_QUERY);
1788             rVal <<= xCont;
1789         }
1790         break;
1791 		case MID_URL_SERVERMAP:
1792 		{
1793 			sal_Bool bTmp = IsServerMap();
1794 			rVal.setValue(&bTmp, ::getBooleanCppuType());
1795 		}
1796 			break;
1797 		default:
1798 			ASSERT( !this, "unknown MemberId" );
1799 			bRet = sal_False;
1800 	}
1801 	return bRet;
1802 }
1803 
1804 sal_Bool SwFmtURL::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1805 {
1806 	// hier wird immer konvertiert!
1807 	nMemberId &= ~CONVERT_TWIPS;
1808 	sal_Bool bRet = sal_True;
1809 	switch ( nMemberId )
1810 	{
1811 		case MID_URL_URL:
1812         {
1813             OUString sTmp;
1814             rVal >>= sTmp;
1815             SetURL( sTmp, bIsServerMap );
1816         }
1817 		break;
1818 		case MID_URL_TARGET:
1819         {
1820             OUString sTmp;
1821             rVal >>= sTmp;
1822             SetTargetFrameName( sTmp );
1823         }
1824 		break;
1825 		case MID_URL_HYPERLINKNAME:
1826         {
1827             OUString sTmp;
1828             rVal >>= sTmp;
1829             SetName( sTmp );
1830         }
1831 		break;
1832 		case MID_URL_CLIENTMAP:
1833         {
1834             uno::Reference<container::XIndexContainer> xCont;
1835             if(!rVal.hasValue())
1836                 DELETEZ(pMap);
1837             else if(rVal >>= xCont)
1838             {
1839                 if(!pMap)
1840                     pMap = new ImageMap;
1841                 bRet = SvUnoImageMap_fillImageMap( xCont, *pMap );
1842             }
1843             else
1844                 bRet = sal_False;
1845         }
1846         break;
1847 		case MID_URL_SERVERMAP:
1848 			bIsServerMap = *(sal_Bool*)rVal.getValue();
1849 			break;
1850 		default:
1851 			ASSERT( !this, "unknown MemberId" );
1852 			bRet = sal_False;
1853 	}
1854 	return bRet;
1855 }
1856 
1857 
1858 // class SwNoReadOnly
1859 
1860 SfxPoolItem* SwFmtEditInReadonly::Clone( SfxItemPool* ) const
1861 {
1862 	return new SwFmtEditInReadonly( Which(), GetValue() );
1863 }
1864 
1865 // class SwFmtLayoutSplit
1866 
1867 SfxPoolItem* SwFmtLayoutSplit::Clone( SfxItemPool* ) const
1868 {
1869 	return new SwFmtLayoutSplit( GetValue() );
1870 }
1871 
1872 // class SwFmtRowSplit
1873 
1874 SfxPoolItem* SwFmtRowSplit::Clone( SfxItemPool* ) const
1875 {
1876     return new SwFmtRowSplit( GetValue() );
1877 }
1878 
1879 
1880 // class SwFmtNoBalancedColumns
1881 
1882 SfxPoolItem* SwFmtNoBalancedColumns::Clone( SfxItemPool* ) const
1883 {
1884 	return new SwFmtNoBalancedColumns( GetValue() );
1885 }
1886 
1887 // class SwFmtFtnEndAtTxtEnd
1888 
1889 sal_uInt16 SwFmtFtnEndAtTxtEnd::GetValueCount() const
1890 {
1891 	return sal_uInt16( FTNEND_ATTXTEND_END );
1892 }
1893 
1894 SwFmtFtnEndAtTxtEnd& SwFmtFtnEndAtTxtEnd::operator=(
1895 						const SwFmtFtnEndAtTxtEnd& rAttr )
1896 {
1897 	SfxEnumItem::SetValue( rAttr.GetValue() );
1898 	aFmt = rAttr.aFmt;
1899 	nOffset = rAttr.nOffset;
1900 	sPrefix = rAttr.sPrefix;
1901 	sSuffix = rAttr.sSuffix;
1902 	return *this;
1903 }
1904 
1905 int SwFmtFtnEndAtTxtEnd::operator==( const SfxPoolItem& rItem ) const
1906 {
1907 	const SwFmtFtnEndAtTxtEnd& rAttr = (SwFmtFtnEndAtTxtEnd&)rItem;
1908 	return SfxEnumItem::operator==( rAttr ) &&
1909 			aFmt.GetNumberingType() == rAttr.aFmt.GetNumberingType() &&
1910 			nOffset == rAttr.nOffset &&
1911 			sPrefix == rAttr.sPrefix &&
1912 			sSuffix == rAttr.sSuffix;
1913 }
1914 
1915 sal_Bool SwFmtFtnEndAtTxtEnd::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1916 {
1917 	nMemberId &= ~CONVERT_TWIPS;
1918 	switch(nMemberId)
1919 	{
1920 		case MID_COLLECT	 :
1921 		{
1922 			sal_Bool bVal = GetValue() >= FTNEND_ATTXTEND;
1923 			rVal.setValue(&bVal, ::getBooleanCppuType());
1924 		}
1925 		break;
1926 		case MID_RESTART_NUM :
1927 		{
1928 			sal_Bool bVal = GetValue() >= FTNEND_ATTXTEND_OWNNUMSEQ;
1929 			rVal.setValue(&bVal, ::getBooleanCppuType());
1930 		}
1931 		break;
1932 		case MID_NUM_START_AT: rVal <<= (sal_Int16) nOffset; break;
1933 		case MID_OWN_NUM     :
1934 		{
1935 			sal_Bool bVal = GetValue() >= FTNEND_ATTXTEND_OWNNUMANDFMT;
1936 			rVal.setValue(&bVal, ::getBooleanCppuType());
1937 		}
1938 		break;
1939 		case MID_NUM_TYPE    : rVal <<= aFmt.GetNumberingType(); break;
1940 		case MID_PREFIX      : rVal <<= OUString(sPrefix); break;
1941 		case MID_SUFFIX      : rVal <<= OUString(sSuffix); break;
1942 		default: return sal_False;
1943 	}
1944 	return sal_True;
1945 }
1946 
1947 sal_Bool SwFmtFtnEndAtTxtEnd::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1948 {
1949 	sal_Bool bRet = sal_True;
1950 	nMemberId &= ~CONVERT_TWIPS;
1951 	switch(nMemberId)
1952 	{
1953 		case MID_COLLECT	 :
1954 		{
1955 			sal_Bool bVal = *(sal_Bool*)rVal.getValue();
1956 			if(!bVal && GetValue() >= FTNEND_ATTXTEND)
1957 				SetValue(FTNEND_ATPGORDOCEND);
1958 			else if(bVal && GetValue() < FTNEND_ATTXTEND)
1959 				SetValue(FTNEND_ATTXTEND);
1960 		}
1961 		break;
1962 		case MID_RESTART_NUM :
1963 		{
1964 			sal_Bool bVal = *(sal_Bool*)rVal.getValue();
1965 			if(!bVal && GetValue() >= FTNEND_ATTXTEND_OWNNUMSEQ)
1966 				SetValue(FTNEND_ATTXTEND);
1967 			else if(bVal && GetValue() < FTNEND_ATTXTEND_OWNNUMSEQ)
1968 				SetValue(FTNEND_ATTXTEND_OWNNUMSEQ);
1969 		}
1970 		break;
1971 		case MID_NUM_START_AT:
1972 		{
1973 			sal_Int16 nVal = 0;
1974 			rVal >>= nVal;
1975 			if(nVal >= 0)
1976 				nOffset = nVal;
1977 			else
1978 				bRet = sal_False;
1979 		}
1980 		break;
1981 		case MID_OWN_NUM     :
1982 		{
1983 			sal_Bool bVal = *(sal_Bool*)rVal.getValue();
1984 			if(!bVal && GetValue() >= FTNEND_ATTXTEND_OWNNUMANDFMT)
1985 				SetValue(FTNEND_ATTXTEND_OWNNUMSEQ);
1986 			else if(bVal && GetValue() < FTNEND_ATTXTEND_OWNNUMANDFMT)
1987 				SetValue(FTNEND_ATTXTEND_OWNNUMANDFMT);
1988 		}
1989 		break;
1990 		case MID_NUM_TYPE    :
1991 		{
1992 			sal_Int16 nVal = 0;
1993 			rVal >>= nVal;
1994 			if(nVal >= 0 &&
1995 				(nVal <= SVX_NUM_ARABIC ||
1996 					SVX_NUM_CHARS_UPPER_LETTER_N == nVal ||
1997 						SVX_NUM_CHARS_LOWER_LETTER_N == nVal ))
1998 				aFmt.SetNumberingType(nVal);
1999 			else
2000 				bRet = sal_False;
2001 		}
2002 		break;
2003 		case MID_PREFIX      :
2004 		{
2005 			OUString sVal; rVal >>= sVal;
2006 			sPrefix = sVal;
2007 		}
2008 		break;
2009 		case MID_SUFFIX      :
2010 		{
2011 			OUString sVal; rVal >>= sVal;
2012 			sSuffix = sVal;
2013 		}
2014 		break;
2015 		default: bRet = sal_False;
2016 	}
2017 	return bRet;
2018 }
2019 
2020 
2021 // class SwFmtFtnAtTxtEnd
2022 
2023 SfxPoolItem* SwFmtFtnAtTxtEnd::Clone( SfxItemPool* ) const
2024 {
2025 	SwFmtFtnAtTxtEnd* pNew = new SwFmtFtnAtTxtEnd;
2026 	*pNew = *this;
2027 	return pNew;
2028 }
2029 
2030 // class SwFmtEndAtTxtEnd
2031 
2032 SfxPoolItem* SwFmtEndAtTxtEnd::Clone( SfxItemPool* ) const
2033 {
2034 	SwFmtEndAtTxtEnd* pNew = new SwFmtEndAtTxtEnd;
2035 	*pNew = *this;
2036 	return pNew;
2037 }
2038 
2039 //class SwFmtChain
2040 
2041 
2042 int SwFmtChain::operator==( const SfxPoolItem &rAttr ) const
2043 {
2044 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
2045 
2046 	return GetPrev() == ((SwFmtChain&)rAttr).GetPrev() &&
2047 		   GetNext() == ((SwFmtChain&)rAttr).GetNext();
2048 }
2049 
2050 SwFmtChain::SwFmtChain( const SwFmtChain &rCpy ) :
2051 	SfxPoolItem( RES_CHAIN )
2052 {
2053 	SetPrev( rCpy.GetPrev() );
2054 	SetNext( rCpy.GetNext() );
2055 }
2056 
2057 SfxPoolItem* SwFmtChain::Clone( SfxItemPool* ) const
2058 {
2059 	SwFmtChain *pRet = new SwFmtChain;
2060 	pRet->SetPrev( GetPrev() );
2061 	pRet->SetNext( GetNext() );
2062 	return pRet;
2063 }
2064 
2065 void SwFmtChain::SetPrev( SwFlyFrmFmt *pFmt )
2066 {
2067 	if ( pFmt )
2068 		pFmt->Add( &aPrev );
2069 	else if ( aPrev.GetRegisteredIn() )
2070 		((SwModify*)aPrev.GetRegisteredIn())->Remove( &aPrev );
2071 }
2072 
2073 void SwFmtChain::SetNext( SwFlyFrmFmt *pFmt )
2074 {
2075 	if ( pFmt )
2076 		pFmt->Add( &aNext );
2077 	else if ( aNext.GetRegisteredIn() )
2078 		((SwModify*)aNext.GetRegisteredIn())->Remove( &aNext );
2079 }
2080 
2081 sal_Bool SwFmtChain::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2082 {
2083 	// hier wird immer konvertiert!
2084 	nMemberId &= ~CONVERT_TWIPS;
2085 	sal_Bool   bRet = sal_True;
2086 	XubString aRet;
2087 	switch ( nMemberId )
2088 	{
2089 		case MID_CHAIN_PREVNAME:
2090 			if ( GetPrev() )
2091 				aRet = GetPrev()->GetName();
2092 			break;
2093 		case MID_CHAIN_NEXTNAME:
2094 			if ( GetNext() )
2095 				aRet = GetNext()->GetName();
2096 			break;
2097 		default:
2098 			ASSERT( !this, "unknown MemberId" );
2099 			bRet = sal_False;
2100 	}
2101 	rVal <<= OUString(aRet);
2102 	return bRet;
2103 }
2104 
2105 
2106 
2107 
2108 //class SwFmtLineNumber
2109 
2110 SwFmtLineNumber::SwFmtLineNumber() :
2111 	SfxPoolItem( RES_LINENUMBER )
2112 {
2113 	nStartValue = 0;
2114 	bCountLines = sal_True;
2115 }
2116 
2117 SwFmtLineNumber::~SwFmtLineNumber()
2118 {
2119 }
2120 
2121 int SwFmtLineNumber::operator==( const SfxPoolItem &rAttr ) const
2122 {
2123 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
2124 
2125 	return nStartValue	== ((SwFmtLineNumber&)rAttr).GetStartValue() &&
2126 		   bCountLines	== ((SwFmtLineNumber&)rAttr).IsCount();
2127 }
2128 
2129 SfxPoolItem* SwFmtLineNumber::Clone( SfxItemPool* ) const
2130 {
2131 	return new SwFmtLineNumber( *this );
2132 }
2133 
2134 sal_Bool SwFmtLineNumber::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2135 {
2136 	// hier wird immer konvertiert!
2137 	nMemberId &= ~CONVERT_TWIPS;
2138 	sal_Bool bRet = sal_True;
2139 	switch ( nMemberId )
2140 	{
2141 		case MID_LINENUMBER_COUNT:
2142 		{
2143 			sal_Bool bTmp = IsCount();
2144 			rVal.setValue(&bTmp, ::getBooleanCppuType());
2145 		}
2146 		break;
2147 		case MID_LINENUMBER_STARTVALUE:
2148 			rVal <<= (sal_Int32)GetStartValue();
2149 			break;
2150 		default:
2151 			ASSERT( !this, "unknown MemberId" );
2152 			bRet = sal_False;
2153 	}
2154 	return bRet;
2155 }
2156 
2157 sal_Bool SwFmtLineNumber::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2158 {
2159 	// hier wird immer konvertiert!
2160 	nMemberId &= ~CONVERT_TWIPS;
2161 	sal_Bool bRet = sal_True;
2162 	switch ( nMemberId )
2163 	{
2164 		case MID_LINENUMBER_COUNT:
2165 			SetCountLines( *(sal_Bool*)rVal.getValue() );
2166 			break;
2167 		case MID_LINENUMBER_STARTVALUE:
2168         {
2169             sal_Int32 nVal = 0;
2170             if(rVal >>= nVal)
2171                 SetStartValue( nVal );
2172             else
2173                 bRet = sal_False;
2174         }
2175         break;
2176 		default:
2177 			ASSERT( !this, "unknown MemberId" );
2178 			bRet = sal_False;
2179 	}
2180 	return bRet;
2181 }
2182 
2183 /*************************************************************************
2184  *    class SwTextGridItem
2185  *************************************************************************/
2186 
2187 SwTextGridItem::SwTextGridItem()
2188     : SfxPoolItem( RES_TEXTGRID ), aColor( COL_LIGHTGRAY ), nLines( 20 ),
2189       nBaseHeight( 400 ), nRubyHeight( 200 ), eGridType( GRID_NONE ),
2190       bRubyTextBelow( 0 ), bPrintGrid( 1 ), bDisplayGrid( 1 ),
2191       nBaseWidth(400), bSnapToChars( 1 ), bSquaredMode(1)
2192 {
2193 }
2194 
2195 SwTextGridItem::~SwTextGridItem()
2196 {
2197 }
2198 
2199 int SwTextGridItem::operator==( const SfxPoolItem& rAttr ) const
2200 {
2201 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
2202     return eGridType == ((SwTextGridItem&)rAttr).GetGridType() &&
2203            nLines == ((SwTextGridItem&)rAttr).GetLines() &&
2204            nBaseHeight == ((SwTextGridItem&)rAttr).GetBaseHeight() &&
2205            nRubyHeight == ((SwTextGridItem&)rAttr).GetRubyHeight() &&
2206            bRubyTextBelow == ((SwTextGridItem&)rAttr).GetRubyTextBelow() &&
2207            bDisplayGrid == ((SwTextGridItem&)rAttr).GetDisplayGrid() &&
2208            bPrintGrid == ((SwTextGridItem&)rAttr).GetPrintGrid() &&
2209            aColor == ((SwTextGridItem&)rAttr).GetColor() &&
2210            nBaseWidth == ((SwTextGridItem&)rAttr).GetBaseWidth() &&
2211            bSnapToChars == ((SwTextGridItem&)rAttr).GetSnapToChars() &&
2212            bSquaredMode == ((SwTextGridItem&)rAttr).GetSquaredMode();
2213 }
2214 
2215 SfxPoolItem* SwTextGridItem::Clone( SfxItemPool* ) const
2216 {
2217     return new SwTextGridItem( *this );
2218 }
2219 
2220 SwTextGridItem& SwTextGridItem::operator=( const SwTextGridItem& rCpy )
2221 {
2222     aColor = rCpy.GetColor();
2223     nLines = rCpy.GetLines();
2224     nBaseHeight = rCpy.GetBaseHeight();
2225     nRubyHeight = rCpy.GetRubyHeight();
2226     eGridType = rCpy.GetGridType();
2227     bRubyTextBelow = rCpy.GetRubyTextBelow();
2228     bPrintGrid = rCpy.GetPrintGrid();
2229     bDisplayGrid = rCpy.GetDisplayGrid();
2230     nBaseWidth = rCpy.GetBaseWidth();
2231     bSnapToChars = rCpy.GetSnapToChars();
2232     bSquaredMode = rCpy.GetSquaredMode();
2233 
2234 	return *this;
2235 }
2236 
2237 sal_Bool SwTextGridItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2238 {
2239     sal_Bool bRet = sal_True;
2240 
2241     switch( nMemberId & ~CONVERT_TWIPS )
2242     {
2243         case MID_GRID_COLOR:
2244             rVal <<= GetColor().GetColor();
2245             break;
2246         case MID_GRID_LINES:
2247             rVal <<= GetLines();
2248             break;
2249         case MID_GRID_RUBY_BELOW:
2250             rVal.setValue( &bRubyTextBelow, ::getBooleanCppuType() );
2251             break;
2252         case MID_GRID_PRINT:
2253             rVal.setValue( &bPrintGrid, ::getBooleanCppuType() );
2254             break;
2255         case MID_GRID_DISPLAY:
2256             rVal.setValue( &bDisplayGrid, ::getBooleanCppuType() );
2257             break;
2258         case MID_GRID_BASEHEIGHT:
2259             DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2260                         "This value needs TWIPS-MM100 conversion" );
2261             rVal <<= (sal_Int32) TWIP_TO_MM100_UNSIGNED(nBaseHeight);
2262             break;
2263         case MID_GRID_BASEWIDTH:
2264             DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2265                         "This value needs TWIPS-MM100 conversion" );
2266             rVal <<= (sal_Int32) TWIP_TO_MM100_UNSIGNED(nBaseWidth);
2267             break;
2268         case MID_GRID_RUBYHEIGHT:
2269             DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2270                         "This value needs TWIPS-MM100 conversion" );
2271             rVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(nRubyHeight);
2272             break;
2273         case MID_GRID_TYPE:
2274             switch( GetGridType() )
2275             {
2276                 case GRID_NONE:
2277                     rVal <<= text::TextGridMode::NONE;
2278                     break;
2279                 case GRID_LINES_ONLY:
2280                     rVal <<= text::TextGridMode::LINES;
2281                     break;
2282                 case GRID_LINES_CHARS:
2283                     rVal <<= text::TextGridMode::LINES_AND_CHARS;
2284                     break;
2285                 default:
2286                     DBG_ERROR("unknown SwTextGrid value");
2287                     bRet = sal_False;
2288                     break;
2289             }
2290             break;
2291         case MID_GRID_SNAPTOCHARS:
2292             rVal.setValue( &bSnapToChars, ::getBooleanCppuType() );
2293             break;
2294         case MID_GRID_STANDARD_MODE:
2295 			{
2296 				sal_Bool bStandardMode = !bSquaredMode;
2297     	        rVal.setValue( &bStandardMode, ::getBooleanCppuType() );
2298 			}
2299             break;
2300         default:
2301             DBG_ERROR("Unknown SwTextGridItem member");
2302             bRet = sal_False;
2303             break;
2304     }
2305 
2306 	return bRet;
2307 }
2308 
2309 sal_Bool SwTextGridItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2310 {
2311 	sal_Bool bRet = sal_True;
2312     switch( nMemberId & ~CONVERT_TWIPS )
2313     {
2314         case MID_GRID_COLOR:
2315         {
2316             sal_Int32 nTmp = 0;
2317             bRet = (rVal >>= nTmp);
2318             if( bRet )
2319                 SetColor( Color(nTmp) );
2320         }
2321         break;
2322         case MID_GRID_LINES:
2323         {
2324             sal_Int16 nTmp = 0;
2325             bRet = (rVal >>= nTmp);
2326             if( bRet && (nTmp >= 0) )
2327                 SetLines( (sal_uInt16)nTmp );
2328             else
2329                 bRet = sal_False;
2330         }
2331         break;
2332         case MID_GRID_RUBY_BELOW:
2333             SetRubyTextBelow( *(sal_Bool*)rVal.getValue() );
2334             break;
2335         case MID_GRID_PRINT:
2336             SetPrintGrid( *(sal_Bool*)rVal.getValue() );
2337             break;
2338         case MID_GRID_DISPLAY:
2339             SetDisplayGrid( *(sal_Bool*)rVal.getValue() );
2340             break;
2341         case MID_GRID_BASEHEIGHT:
2342         case MID_GRID_BASEWIDTH:
2343         case MID_GRID_RUBYHEIGHT:
2344         {
2345             DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2346                         "This value needs TWIPS-MM100 conversion" );
2347             sal_Int32 nTmp = 0;
2348             bRet = (rVal >>= nTmp);
2349             nTmp = MM100_TO_TWIP( nTmp );
2350             if( bRet && (nTmp >= 0) && ( nTmp <= USHRT_MAX) )
2351                 if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEHEIGHT )
2352                     SetBaseHeight( (sal_uInt16)nTmp );
2353                 else if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEWIDTH )
2354                     SetBaseWidth( (sal_uInt16)nTmp );
2355                 else
2356                     SetRubyHeight( (sal_uInt16)nTmp );
2357             else
2358                 bRet = sal_False;
2359         }
2360         break;
2361         case MID_GRID_TYPE:
2362         {
2363             sal_Int16 nTmp = 0;
2364             bRet = (rVal >>= nTmp);
2365             if( bRet )
2366             {
2367                 switch( nTmp )
2368                 {
2369                     case text::TextGridMode::NONE:
2370                         SetGridType( GRID_NONE );
2371                         break;
2372                     case text::TextGridMode::LINES:
2373                         SetGridType( GRID_LINES_ONLY );
2374                         break;
2375                     case text::TextGridMode::LINES_AND_CHARS:
2376                         SetGridType( GRID_LINES_CHARS );
2377                         break;
2378                     default:
2379                         bRet = sal_False;
2380                         break;
2381                 }
2382             }
2383             break;
2384 		}
2385         case MID_GRID_SNAPTOCHARS:
2386             SetSnapToChars( *(sal_Bool*)rVal.getValue() );
2387             break;
2388         case MID_GRID_STANDARD_MODE:
2389 		{
2390 			sal_Bool bStandard = *(sal_Bool*)rVal.getValue();
2391            	SetSquaredMode( !bStandard );
2392         	break;
2393 		}
2394         default:
2395             DBG_ERROR("Unknown SwTextGridItem member");
2396             bRet = sal_False;
2397     }
2398 
2399     return bRet;
2400 }
2401 
2402 void SwTextGridItem::SwitchPaperMode(sal_Bool bNew)
2403 {
2404 	if( bNew == bSquaredMode )
2405 	{
2406 		//same paper mode, not switch
2407 		return;
2408 	}
2409 
2410 	// use default value when grid is disable
2411 	if( eGridType == GRID_NONE )
2412 	{
2413 		bSquaredMode = bNew;
2414 		Init();
2415 		return;
2416 	}
2417 
2418 	if( bSquaredMode )
2419 	{
2420 		//switch from "squared mode" to "standard mode"
2421 		nBaseWidth = nBaseHeight;
2422 		nBaseHeight = nBaseHeight + nRubyHeight;
2423 		nRubyHeight = 0;
2424 	}
2425 	else
2426 	{
2427 		//switch from "standard mode" to "squared mode"
2428 		nRubyHeight = nBaseHeight/3;
2429 		nBaseHeight = nBaseHeight - nRubyHeight;
2430 		nBaseWidth = nBaseHeight;
2431 	}
2432 	bSquaredMode = !bSquaredMode;
2433 }
2434 
2435 void SwTextGridItem::Init()
2436 {
2437 	if( bSquaredMode )
2438 	{
2439 		nLines = 20;
2440 		nBaseHeight = 400;
2441 		nRubyHeight = 200;
2442 		eGridType = GRID_NONE;
2443 		bRubyTextBelow = 0;
2444 		bPrintGrid = 1;
2445 		bDisplayGrid = 1;
2446 		bSnapToChars = 1;
2447 		nBaseWidth = 400;
2448 	}
2449 	else
2450 	{
2451 		nLines = 44;
2452 		nBaseHeight = 312;
2453 		nRubyHeight = 0;
2454 		eGridType = GRID_NONE;
2455 		bRubyTextBelow = 0;
2456 		bPrintGrid = 1;
2457 		bDisplayGrid = 1;
2458 		nBaseWidth = 210;
2459 		bSnapToChars = 1;
2460 
2461 		//default grid type is line only in CJK env
2462 		//disable this function due to type area change
2463 		//if grid type change.
2464 		//if(SvtCJKOptions().IsAsianTypographyEnabled())
2465 		//{
2466 		//	bDisplayGrid = 0;
2467 		//	eGridType = GRID_LINES_ONLY;
2468 		//}
2469 	}
2470 }
2471 // class SwHeaderAndFooterEatSpacingItem
2472 
2473 SfxPoolItem* SwHeaderAndFooterEatSpacingItem::Clone( SfxItemPool* ) const
2474 {
2475     return new SwHeaderAndFooterEatSpacingItem( Which(), GetValue() );
2476 }
2477 
2478 //////////////////////////////////////////////////////////////////////////////
2479 //  class SwFrmFmt
2480 //	Implementierung teilweise inline im hxx
2481 
2482 TYPEINIT1( SwFrmFmt, SwFmt );
2483 IMPL_FIXEDMEMPOOL_NEWDEL_DLL( SwFrmFmt, 20, 20 )
2484 
2485 SwFrmFmt::SwFrmFmt(
2486     SwAttrPool& rPool,
2487     const sal_Char* pFmtNm,
2488     SwFrmFmt *pDrvdFrm,
2489     sal_uInt16 nFmtWhich,
2490     const sal_uInt16* pWhichRange)
2491 :   SwFmt(rPool, pFmtNm, (pWhichRange ? pWhichRange : aFrmFmtSetRange), pDrvdFrm, nFmtWhich),
2492     m_wXObject(),
2493     maFillAttributes(),
2494     pCaptionFmt(0)
2495 {
2496 }
2497 
2498 SwFrmFmt::SwFrmFmt(
2499     SwAttrPool& rPool,
2500     const String &rFmtNm,
2501     SwFrmFmt *pDrvdFrm,
2502     sal_uInt16 nFmtWhich,
2503     const sal_uInt16* pWhichRange)
2504 :   SwFmt(rPool, rFmtNm, (pWhichRange ? pWhichRange : aFrmFmtSetRange), pDrvdFrm, nFmtWhich),
2505     m_wXObject(),
2506     maFillAttributes(),
2507     pCaptionFmt(0)
2508 {
2509 }
2510 
2511 //UUUU
2512 SwFrmFmt::~SwFrmFmt()
2513 {
2514 }
2515 
2516 void SwFrmFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
2517 {
2518 	SwFmtHeader *pH = 0;
2519 	SwFmtFooter *pF = 0;
2520 
2521 	sal_uInt16 nWhich = pNew ? pNew->Which() : 0;
2522 
2523 	if( RES_ATTRSET_CHG == nWhich )
2524 	{
2525 		((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
2526 			RES_HEADER, sal_False, (const SfxPoolItem**)&pH );
2527 		((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
2528 			RES_FOOTER, sal_False, (const SfxPoolItem**)&pF );
2529 
2530         //UUUU reset fill information
2531         if(maFillAttributes.get() && supportsFullDrawingLayerFillAttributeSet())
2532         {
2533             SfxItemIter aIter(*((SwAttrSetChg*)pNew)->GetChgSet());
2534             bool bReset(false);
2535 
2536             for(const SfxPoolItem* pItem = aIter.FirstItem(); pItem && !bReset; pItem = aIter.NextItem())
2537             {
2538                 bReset = !IsInvalidItem(pItem) && pItem->Which() >= XATTR_FILL_FIRST && pItem->Which() <= XATTR_FILL_LAST;
2539             }
2540 
2541             if(bReset)
2542             {
2543                 maFillAttributes.reset();
2544             }
2545         }
2546     }
2547     else if(RES_FMT_CHG == nWhich)
2548     {
2549         //UUUU reset fill information on format change (e.g. style changed)
2550         if(maFillAttributes.get() && supportsFullDrawingLayerFillAttributeSet())
2551         {
2552             maFillAttributes.reset();
2553         }
2554     }
2555     else if( RES_HEADER == nWhich )
2556         pH = (SwFmtHeader*)pNew;
2557     else if( RES_FOOTER == nWhich )
2558         pF = (SwFmtFooter*)pNew;
2559 
2560 	if( pH && pH->IsActive() && !pH->GetHeaderFmt() )
2561 	{	//Hat er keinen, mach ich ihm einen
2562         SwFrmFmt *pFmt = GetDoc()->MakeLayoutFmt( RND_STD_HEADER, 0 );
2563         pH->RegisterToFormat( *pFmt );
2564 	}
2565 
2566 	if( pF && pF->IsActive() && !pF->GetFooterFmt() )
2567 	{	//Hat er keinen, mach ich ihm einen
2568         SwFrmFmt *pFmt = GetDoc()->MakeLayoutFmt( RND_STD_FOOTER, 0 );
2569         pF->RegisterToFormat( *pFmt );
2570 	}
2571 
2572 	// MIB 24.3.98: Modify der Basisklasse muss immer gerufen werden, z.B.
2573 	// wegen RESET_FMTWRITTEN.
2574 //	if ( GetDepends() )
2575 		SwFmt::Modify( pOld, pNew );
2576 
2577     if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
2578     {   // invalidate cached uno object
2579         SetXObject(uno::Reference<uno::XInterface>(0));
2580     }
2581 }
2582 
2583 void SwFrmFmt::RegisterToFormat( SwFmt& rFmt )
2584 {
2585     rFmt.Add( this );
2586 }
2587 
2588 //Vernichtet alle Frms, die in aDepend angemeldet sind.
2589 
2590 void SwFrmFmt::DelFrms()
2591 {
2592 	SwIterator<SwFrm,SwFmt> aIter( *this );
2593 	SwFrm * pLast = aIter.First();
2594 	if( pLast )
2595 		do {
2596 				pLast->Cut();
2597 				delete pLast;
2598 		} while( 0 != ( pLast = aIter.Next() ));
2599 }
2600 
2601 void SwFrmFmt::MakeFrms()
2602 {
2603 	ASSERT( !this, "Sorry not implemented." );
2604 }
2605 
2606 
2607 
2608 SwRect SwFrmFmt::FindLayoutRect( const sal_Bool bPrtArea, const Point* pPoint,
2609 								 const sal_Bool bCalcFrm ) const
2610 {
2611 	SwRect aRet;
2612 	SwFrm *pFrm = 0;
2613 	if( ISA( SwSectionFmt ) )
2614 	{
2615         // dann den frame::Frame per Node2Layout besorgen
2616 		SwSectionNode* pSectNd = ((SwSectionFmt*)this)->GetSectionNode();
2617 		if( pSectNd )
2618 		{
2619 			SwNode2Layout aTmp( *pSectNd, pSectNd->GetIndex() - 1 );
2620 			pFrm = aTmp.NextFrm();
2621 
2622 			if( pFrm && !pFrm->KnowsFormat(*this) )
2623 			{
2624                 // die Section hat keinen eigenen frame::Frame, also falls
2625 				// jemand die tatsaechliche Groe?e braucht, so muss das
2626 				// noch implementier werden, in dem sich vom Ende noch
2627                 // der entsprechende frame::Frame besorgt wird.
2628 				// PROBLEM: was passiert bei SectionFrames, die auf unter-
2629 				//			schiedlichen Seiten stehen??
2630 				if( bPrtArea )
2631 					aRet = pFrm->Prt();
2632 				else
2633 				{
2634 					aRet = pFrm->Frm();
2635 					--aRet.Pos().Y();
2636 				}
2637 				pFrm = 0;		// das Rect ist ja jetzt fertig
2638 			}
2639 		}
2640 	}
2641 	else
2642 	{
2643 		sal_uInt16 nFrmType = RES_FLYFRMFMT == Which() ? FRM_FLY : USHRT_MAX;
2644 		pFrm = ::GetFrmOfModify( 0, *(SwModify*)this, nFrmType, pPoint,
2645 									0, bCalcFrm );
2646 	}
2647 
2648 	if( pFrm )
2649 	{
2650 		if( bPrtArea )
2651 			aRet = pFrm->Prt();
2652 		else
2653 			aRet = pFrm->Frm();
2654 	}
2655 	return aRet;
2656 }
2657 
2658 SwContact* SwFrmFmt::FindContactObj()
2659 {
2660 	return SwIterator<SwContact,SwFmt>::FirstElement( *this );
2661 }
2662 
2663 SdrObject* SwFrmFmt::FindSdrObject()
2664 {
2665     // --> OD 2005-01-06 #i30669# - use method <FindContactObj()> instead of
2666     // duplicated code.
2667     SwContact* pFoundContact = FindContactObj();
2668     return pFoundContact ? pFoundContact->GetMaster() : 0;
2669     // <--
2670 }
2671 
2672 SdrObject* SwFrmFmt::FindRealSdrObject()
2673 {
2674 	if( RES_FLYFRMFMT == Which() )
2675 	{
2676 		Point aNullPt;
2677 		SwFlyFrm* pFly = (SwFlyFrm*)::GetFrmOfModify( 0, *this, FRM_FLY,
2678 													&aNullPt, 0, sal_False );
2679 		return pFly ? pFly->GetVirtDrawObj() : 0;
2680 	}
2681 	return FindSdrObject();
2682 }
2683 
2684 
2685 sal_Bool SwFrmFmt::IsLowerOf( const SwFrmFmt& rFmt ) const
2686 {
2687 	//Auch eine Verkettung von Innen nach aussen oder von aussen
2688 	//nach innen ist nicht zulaessig.
2689 	SwFlyFrm *pSFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(*this);
2690 	if( pSFly )
2691 	{
2692 		SwFlyFrm *pAskFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(rFmt);
2693 		if( pAskFly )
2694             return pSFly->IsLowerOf( pAskFly );
2695 	}
2696 
2697 	// dann mal ueber die Node-Positionen versuchen
2698 	const SwFmtAnchor* pAnchor = &rFmt.GetAnchor();
2699     if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor())
2700     {
2701 		const SwSpzFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts();
2702 		const SwNode* pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode().
2703 								FindFlyStartNode();
2704 		while( pFlyNd )
2705 		{
2706 			// dann ueber den Anker nach oben "hangeln"
2707 			sal_uInt16 n;
2708 			for( n = 0; n < rFmts.Count(); ++n )
2709 			{
2710 				const SwFrmFmt* pFmt = rFmts[ n ];
2711 				const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2712 				if( pIdx && pFlyNd == &pIdx->GetNode() )
2713 				{
2714 					if( pFmt == this )
2715 						return sal_True;
2716 
2717 					pAnchor = &pFmt->GetAnchor();
2718                     if ((FLY_AT_PAGE == pAnchor->GetAnchorId()) ||
2719                         !pAnchor->GetCntntAnchor() )
2720                     {
2721                         return sal_False;
2722                     }
2723 
2724 					pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode().
2725 								FindFlyStartNode();
2726 					break;
2727 				}
2728 			}
2729 			if( n >= rFmts.Count() )
2730 			{
2731 				ASSERT( !this, "Fly-Section aber kein Format gefunden" );
2732 				return sal_False;
2733 			}
2734 		}
2735 	}
2736 	return sal_False;
2737 }
2738 
2739 // --> OD 2004-07-27 #i31698#
2740 SwFrmFmt::tLayoutDir SwFrmFmt::GetLayoutDir() const
2741 {
2742     return SwFrmFmt::HORI_L2R;
2743 }
2744 
2745 void SwFrmFmt::SetLayoutDir( const SwFrmFmt::tLayoutDir )
2746 {
2747     // empty body, because default implementation does nothing
2748 }
2749 // <--
2750 
2751 // --> OD 2004-08-06 #i28749#
2752 sal_Int16 SwFrmFmt::GetPositionLayoutDir() const
2753 {
2754     return text::PositionLayoutDir::PositionInLayoutDirOfAnchor;
2755 }
2756 void SwFrmFmt::SetPositionLayoutDir( const sal_Int16 )
2757 {
2758     // empty body, because default implementation does nothing
2759 }
2760 // <--
2761 String SwFrmFmt::GetDescription() const
2762 {
2763     return SW_RES(STR_FRAME);
2764 }
2765 
2766 //	class SwFlyFrmFmt
2767 //	Implementierung teilweise inline im hxx
2768 
2769 TYPEINIT1( SwFlyFrmFmt, SwFrmFmt );
2770 IMPL_FIXEDMEMPOOL_NEWDEL( SwFlyFrmFmt,	10, 10 )
2771 
2772 SwFlyFrmFmt::~SwFlyFrmFmt()
2773 {
2774 	SwIterator<SwFlyFrm,SwFmt> aIter( *this );
2775 	SwFlyFrm * pLast = aIter.First();
2776 	if( pLast )
2777 		do {
2778 				delete pLast;
2779 		} while( 0 != ( pLast = aIter.Next() ));
2780 
2781 	SwIterator<SwFlyDrawContact,SwFmt> a2ndIter( *this );
2782 	SwFlyDrawContact* pC = a2ndIter.First();
2783 	if( pC )
2784 		do {
2785 				delete pC;
2786 
2787 		} while( 0 != ( pC = a2ndIter.Next() ));
2788 }
2789 
2790 //Erzeugen der Frms wenn das Format einen Absatzgebundenen Rahmen beschreibt.
2791 //MA: 14. Feb. 94, Erzeugen der Frms auch fuer Seitengebundene Rahmen.
2792 
2793 void SwFlyFrmFmt::MakeFrms()
2794 {
2795 	// gibts ueberhaupt ein Layout ??
2796 	if( !GetDoc()->GetCurrentViewShell() )
2797 		return;	//swmod 071108//swmod 071225
2798 
2799 	SwModify *pModify = 0;
2800     // OD 24.07.2003 #111032# - create local copy of anchor attribute for possible changes.
2801     SwFmtAnchor aAnchorAttr( GetAnchor() );
2802     switch( aAnchorAttr.GetAnchorId() )
2803     {
2804     case FLY_AS_CHAR:
2805     case FLY_AT_PARA:
2806     case FLY_AT_CHAR:
2807         if( aAnchorAttr.GetCntntAnchor() )
2808         {
2809             pModify = aAnchorAttr.GetCntntAnchor()->nNode.GetNode().GetCntntNode();
2810         }
2811 		break;
2812 
2813 	case FLY_AT_FLY:
2814         if( aAnchorAttr.GetCntntAnchor() )
2815 		{
2816 			//Erst einmal ueber den Inhalt suchen, weil konstant schnell. Kann
2817 			//Bei verketteten Rahmen aber auch schief gehen, weil dann evtl.
2818             //niemals ein frame::Frame zu dem Inhalt existiert. Dann muss leider noch
2819 			//die Suche vom StartNode zum FrameFormat sein.
2820             SwNodeIndex aIdx( aAnchorAttr.GetCntntAnchor()->nNode );
2821 			SwCntntNode *pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
2822             // --> OD 2009-12-28 #i105535#
2823             if ( pCNd == 0 )
2824             {
2825                 pCNd = aAnchorAttr.GetCntntAnchor()->nNode.GetNode().GetCntntNode();
2826             }
2827             if ( pCNd )
2828             // <--
2829             {
2830                 if( SwIterator<SwFrm,SwCntntNode>::FirstElement( *pCNd ) )
2831                 {
2832                     pModify = pCNd;
2833                 }
2834             }
2835             // --> OD 2009-12-28 #i105535#
2836             if ( pModify == 0 )
2837             // <--
2838             {
2839                 const SwNodeIndex &rIdx = aAnchorAttr.GetCntntAnchor()->nNode;
2840 				SwSpzFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts();
2841 				for( sal_uInt16 i = 0; i < rFmts.Count(); ++i )
2842 				{
2843 					SwFrmFmt* pFlyFmt = rFmts[i];
2844 					if( pFlyFmt->GetCntnt().GetCntntIdx() &&
2845 						rIdx == *pFlyFmt->GetCntnt().GetCntntIdx() )
2846 					{
2847 						pModify = pFlyFmt;
2848 						break;
2849 					}
2850 				}
2851 			}
2852 		}
2853 		break;
2854 
2855     case FLY_AT_PAGE:
2856         {
2857             sal_uInt16 nPgNum = aAnchorAttr.GetPageNum();
2858             SwPageFrm *pPage = (SwPageFrm*)GetDoc()->GetCurrentLayout()->Lower();	//swmod 080218
2859             if( nPgNum == 0 && aAnchorAttr.GetCntntAnchor() )
2860             {
2861                 SwCntntNode *pCNd = aAnchorAttr.GetCntntAnchor()->nNode.GetNode().GetCntntNode();
2862                 SwIterator<SwFrm,SwCntntNode> aIter( *pCNd );
2863                 for ( SwFrm* pFrm = aIter.First(); pFrm != NULL; pFrm = aIter.Next() )
2864                 {
2865                     pPage = pFrm->FindPageFrm();
2866                     if( pPage )
2867                     {
2868                         nPgNum = pPage->GetPhyPageNum();
2869                         aAnchorAttr.SetPageNum( nPgNum );
2870                         aAnchorAttr.SetAnchor( 0 );
2871                         SetFmtAttr( aAnchorAttr );
2872                         break;
2873                     }
2874                 }
2875             }
2876             while ( pPage )
2877             {
2878                 if ( pPage->GetPhyPageNum() == nPgNum )
2879                 {
2880                     pPage->PlaceFly( 0, this );
2881                     break;
2882                 }
2883                 pPage = (SwPageFrm*)pPage->GetNext();
2884             }
2885         }
2886         break;
2887     default:
2888         break;
2889 	}
2890 
2891 	if( pModify )
2892 	{
2893         SwIterator<SwFrm,SwModify> aIter( *pModify );
2894 		for( SwFrm *pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
2895 		{
2896 			sal_Bool bAdd = !pFrm->IsCntntFrm() ||
2897 							!((SwCntntFrm*)pFrm)->IsFollow();
2898 
2899             if ( FLY_AT_FLY == aAnchorAttr.GetAnchorId() && !pFrm->IsFlyFrm() )
2900             {
2901                 // --> OD 2009-12-28 #i105535#
2902                 // fallback to anchor type at-paragraph, if no fly frame is found.
2903 //                pFrm = pFrm->FindFlyFrm();
2904                 SwFrm* pFlyFrm = pFrm->FindFlyFrm();
2905                 if ( pFlyFrm )
2906                 {
2907                     pFrm = pFlyFrm;
2908                 }
2909                 else
2910                 {
2911                     aAnchorAttr.SetType( FLY_AT_PARA );
2912                     SetFmtAttr( aAnchorAttr );
2913                     MakeFrms();
2914                     return;
2915                 }
2916                 // <--
2917             }
2918 
2919 			if( pFrm->GetDrawObjs() )
2920 			{
2921                 // --> OD 2004-07-01 #i28701# - new type <SwSortedObjs>
2922                 SwSortedObjs &rObjs = *pFrm->GetDrawObjs();
2923 				for( sal_uInt16 i = 0; i < rObjs.Count(); ++i)
2924 				{
2925                     // --> OD 2004-07-01 #i28701# - consider changed type of
2926                     // <SwSortedObjs> entries.
2927                     SwAnchoredObject* pObj = rObjs[i];
2928                     if( pObj->ISA(SwFlyFrm) &&
2929                         (&pObj->GetFrmFmt()) == this )
2930 					{
2931 						bAdd = sal_False;
2932 						break;
2933 					}
2934 				}
2935 			}
2936 
2937 			if( bAdd )
2938 			{
2939 				SwFlyFrm *pFly = 0;
2940                 switch( aAnchorAttr.GetAnchorId() )
2941 				{
2942 				case FLY_AT_FLY:
2943 					pFly = new SwFlyLayFrm( this, pFrm, pFrm );
2944 					break;
2945 
2946                 case FLY_AT_PARA:
2947                 case FLY_AT_CHAR:
2948 					pFly = new SwFlyAtCntFrm( this, pFrm, pFrm );
2949 					break;
2950 
2951                 case FLY_AS_CHAR:
2952 					pFly = new SwFlyInCntFrm( this, pFrm, pFrm );
2953 					break;
2954                 default:
2955                     ASSERT( !this, "Neuer Ankertyp" )
2956                     break;
2957                 }
2958 				pFrm->AppendFly( pFly );
2959 				SwPageFrm *pPage = pFly->FindPageFrm();
2960 				if( pPage )
2961 					::RegistFlys( pPage, pFly );
2962             }
2963 		}
2964 	}
2965 }
2966 
2967 SwFlyFrm* SwFlyFrmFmt::GetFrm( const Point* pPoint, const sal_Bool bCalcFrm ) const
2968 {
2969 	return (SwFlyFrm*)::GetFrmOfModify( 0, *(SwModify*)this, FRM_FLY,
2970 											pPoint, 0, bCalcFrm );
2971 }
2972 
2973 SwAnchoredObject* SwFlyFrmFmt::GetAnchoredObj( const Point* pPoint, const sal_Bool bCalcFrm ) const
2974 {
2975     SwFlyFrm* pFlyFrm( GetFrm( pPoint, bCalcFrm ) );
2976     if ( pFlyFrm )
2977     {
2978         return dynamic_cast<SwAnchoredObject*>(pFlyFrm);
2979     }
2980     else
2981     {
2982         return 0L;
2983     }
2984 }
2985 
2986 
2987 sal_Bool SwFlyFrmFmt::GetInfo( SfxPoolItem& rInfo ) const
2988 {
2989     sal_Bool bRet = sal_True;
2990     switch( rInfo.Which() )
2991     {
2992     case RES_CONTENT_VISIBLE:
2993         {
2994             ((SwPtrMsgPoolItem&)rInfo).pObject = SwIterator<SwFrm,SwFmt>::FirstElement( *this );
2995         }
2996         bRet = sal_False;
2997         break;
2998 
2999     default:
3000         bRet = SwFrmFmt::GetInfo( rInfo );
3001         break;
3002     }
3003     return bRet;
3004 }
3005 
3006 // --> OD 2009-07-14 #i73249#
3007 void SwFlyFrmFmt::SetObjTitle( const String& rTitle, bool bBroadcast )
3008 {
3009     SdrObject* pMasterObject = FindSdrObject();
3010     ASSERT( pMasterObject,
3011             "<SwNoTxtNode::SetObjTitle(..)> - missing <SdrObject> instance" );
3012     if ( !pMasterObject )
3013     {
3014         return;
3015     }
3016 
3017     if( bBroadcast )
3018     {
3019         SwStringMsgPoolItem aOld( RES_TITLE_CHANGED, pMasterObject->GetTitle() );
3020         SwStringMsgPoolItem aNew( RES_TITLE_CHANGED, rTitle );
3021         pMasterObject->SetTitle( rTitle );
3022         ModifyNotification( &aOld, &aNew );
3023     }
3024     else
3025     {
3026         pMasterObject->SetTitle( rTitle );
3027     }
3028 }
3029 
3030 const String SwFlyFrmFmt::GetObjTitle() const
3031 {
3032     const SdrObject* pMasterObject = FindSdrObject();
3033     ASSERT( pMasterObject,
3034             "<SwFlyFrmFmt::GetObjTitle(..)> - missing <SdrObject> instance" );
3035     if ( !pMasterObject )
3036     {
3037         return aEmptyStr;
3038     }
3039 
3040     return pMasterObject->GetTitle();
3041 }
3042 
3043 void SwFlyFrmFmt::SetObjDescription( const String& rDescription, bool bBroadcast )
3044 {
3045     SdrObject* pMasterObject = FindSdrObject();
3046     ASSERT( pMasterObject,
3047             "<SwFlyFrmFmt::SetDescription(..)> - missing <SdrObject> instance" );
3048     if ( !pMasterObject )
3049     {
3050         return;
3051     }
3052 
3053     if( bBroadcast )
3054     {
3055         SwStringMsgPoolItem aOld( RES_DESCRIPTION_CHANGED, pMasterObject->GetDescription() );
3056         SwStringMsgPoolItem aNew( RES_DESCRIPTION_CHANGED, rDescription );
3057         pMasterObject->SetDescription( rDescription );
3058         ModifyNotification( &aOld, &aNew );
3059     }
3060     else
3061     {
3062         pMasterObject->SetDescription( rDescription );
3063     }
3064 }
3065 
3066 const String SwFlyFrmFmt::GetObjDescription() const
3067 {
3068     const SdrObject* pMasterObject = FindSdrObject();
3069     ASSERT( pMasterObject,
3070             "<SwNoTxtNode::GetDescription(..)> - missing <SdrObject> instance" );
3071     if ( !pMasterObject )
3072     {
3073         return aEmptyStr;
3074     }
3075 
3076     return pMasterObject->GetDescription();
3077 }
3078 // <--
3079 
3080 /** SwFlyFrmFmt::IsBackgroundTransparent - for #99657#
3081 
3082     OD 22.08.2002 - overloading virtual method and its default implementation,
3083     because format of fly frame provides transparent backgrounds.
3084     Method determines, if background of fly frame is transparent.
3085 
3086     @author OD
3087 
3088     @return true, if background color is transparent, but not "no fill"
3089     or the transparency of a existing background graphic is set.
3090 */
3091 sal_Bool SwFlyFrmFmt::IsBackgroundTransparent() const
3092 {
3093     //UUUU
3094     if(supportsFullDrawingLayerFillAttributeSet() && getSdrAllFillAttributesHelper())
3095     {
3096         return getSdrAllFillAttributesHelper()->isTransparent();
3097     }
3098 
3099     /// NOTE: If background color is "no fill"/"auto fill" (COL_TRANSPARENT)
3100     ///     and there is no background graphic, it "inherites" the background
3101     ///     from its anchor.
3102     if ( (GetBackground().GetColor().GetTransparency() != 0) &&
3103          (GetBackground().GetColor() != COL_TRANSPARENT)
3104        )
3105     {
3106         return sal_True;
3107     }
3108     else
3109     {
3110         const GraphicObject *pTmpGrf =
3111                 static_cast<const GraphicObject*>(GetBackground().GetGraphicObject());
3112         if ( (pTmpGrf) &&
3113              (pTmpGrf->GetAttr().GetTransparency() != 0)
3114            )
3115         {
3116             return sal_True;
3117         }
3118     }
3119 
3120     return sal_False;
3121 }
3122 
3123 /** SwFlyFrmFmt::IsBackgroundBrushInherited - for #103898#
3124 
3125     OD 08.10.2002 - method to determine, if the brush for drawing the
3126     background is "inherited" from its parent/grandparent.
3127     This is the case, if no background graphic is set and the background
3128     color is "no fill"/"auto fill"
3129     NOTE: condition is "copied" from method <SwFrm::GetBackgroundBrush(..).
3130 
3131     @author OD
3132 
3133     @return true, if background brush is "inherited" from parent/grandparent
3134 */
3135 sal_Bool SwFlyFrmFmt::IsBackgroundBrushInherited() const
3136 {
3137     //UUUU
3138     if(supportsFullDrawingLayerFillAttributeSet() && getSdrAllFillAttributesHelper())
3139     {
3140         return !getSdrAllFillAttributesHelper()->isUsed();
3141     }
3142     else if ( (GetBackground().GetColor() == COL_TRANSPARENT) &&
3143          !(GetBackground().GetGraphicObject()) )
3144     {
3145         return sal_True;
3146     }
3147 
3148     return sal_False;
3149 }
3150 
3151 // --> OD 2006-02-28 #125892#
3152 SwHandleAnchorNodeChg::SwHandleAnchorNodeChg( SwFlyFrmFmt& _rFlyFrmFmt,
3153                                               const SwFmtAnchor& _rNewAnchorFmt,
3154                                               SwFlyFrm* _pKeepThisFlyFrm )
3155     : mrFlyFrmFmt( _rFlyFrmFmt ),
3156       mbAnchorNodeChanged( false )
3157 {
3158     const RndStdIds nNewAnchorType( _rNewAnchorFmt.GetAnchorId() );
3159     if ( ((nNewAnchorType == FLY_AT_PARA) ||
3160           (nNewAnchorType == FLY_AT_CHAR)) &&
3161          _rNewAnchorFmt.GetCntntAnchor() &&
3162          _rNewAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode() )
3163     {
3164         const SwFmtAnchor& aOldAnchorFmt( _rFlyFrmFmt.GetAnchor() );
3165         if ( aOldAnchorFmt.GetAnchorId() == nNewAnchorType &&
3166              aOldAnchorFmt.GetCntntAnchor() &&
3167              aOldAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode() &&
3168              aOldAnchorFmt.GetCntntAnchor()->nNode !=
3169                                     _rNewAnchorFmt.GetCntntAnchor()->nNode )
3170         {
3171             // determine 'old' number of anchor frames
3172             sal_uInt32 nOldNumOfAnchFrm( 0L );
3173             SwIterator<SwFrm,SwCntntNode> aOldIter( *(aOldAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode()) );
3174             for( SwFrm* pOld = aOldIter.First(); pOld; pOld = aOldIter.Next() )
3175             {
3176                 ++nOldNumOfAnchFrm;
3177             }
3178             // determine 'new' number of anchor frames
3179             sal_uInt32 nNewNumOfAnchFrm( 0L );
3180             SwIterator<SwFrm,SwCntntNode> aNewIter( *(_rNewAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode()) );
3181             for( SwFrm* pNew = aNewIter.First(); pNew; pNew = aNewIter.Next() )
3182             {
3183                 ++nNewNumOfAnchFrm;
3184             }
3185             if ( nOldNumOfAnchFrm != nNewNumOfAnchFrm )
3186             {
3187                 // delete existing fly frames except <_pKeepThisFlyFrm>
3188                 SwIterator<SwFrm,SwFmt> aIter( mrFlyFrmFmt );
3189                 SwFrm* pFrm = aIter.First();
3190                 if ( pFrm )
3191                 {
3192                     do {
3193                         if ( pFrm != _pKeepThisFlyFrm )
3194                         {
3195                             pFrm->Cut();
3196                             delete pFrm;
3197                         }
3198                     } while( 0 != ( pFrm = aIter.Next() ));
3199                 }
3200                 // indicate, that re-creation of fly frames necessary
3201                 mbAnchorNodeChanged = true;
3202             }
3203         }
3204     }
3205 }
3206 
3207 SwHandleAnchorNodeChg::~SwHandleAnchorNodeChg()
3208 {
3209     if ( mbAnchorNodeChanged )
3210     {
3211         mrFlyFrmFmt.MakeFrms();
3212     }
3213 }
3214 // <--
3215 //	class SwDrawFrmFmt
3216 //	Implementierung teilweise inline im hxx
3217 
3218 TYPEINIT1( SwDrawFrmFmt, SwFrmFmt );
3219 IMPL_FIXEDMEMPOOL_NEWDEL( SwDrawFrmFmt,	10, 10 )
3220 
3221 SwDrawFrmFmt::~SwDrawFrmFmt()
3222 {
3223 	SwContact *pContact = FindContactObj();
3224 	delete pContact;
3225 }
3226 
3227 void SwDrawFrmFmt::MakeFrms()
3228 {
3229 	SwDrawContact *pContact = (SwDrawContact*)FindContactObj();
3230     if ( pContact )
3231          pContact->ConnectToLayout();
3232 }
3233 
3234 void SwDrawFrmFmt::DelFrms()
3235 {
3236 	SwDrawContact *pContact = (SwDrawContact *)FindContactObj();
3237 	if ( pContact ) //fuer den Reader und andere Unabwaegbarkeiten.
3238 		pContact->DisconnectFromLayout();
3239 }
3240 
3241 // --> OD 2004-07-27 #i31698#
3242 SwFrmFmt::tLayoutDir SwDrawFrmFmt::GetLayoutDir() const
3243 {
3244     return meLayoutDir;
3245 }
3246 
3247 void SwDrawFrmFmt::SetLayoutDir( const SwFrmFmt::tLayoutDir _eLayoutDir )
3248 {
3249     meLayoutDir = _eLayoutDir;
3250 }
3251 // <--
3252 
3253 // --> OD 2004-08-06 #i28749#
3254 sal_Int16 SwDrawFrmFmt::GetPositionLayoutDir() const
3255 {
3256     return mnPositionLayoutDir;
3257 }
3258 void SwDrawFrmFmt::SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir )
3259 {
3260     switch ( _nPositionLayoutDir )
3261     {
3262         case text::PositionLayoutDir::PositionInHoriL2R:
3263         case text::PositionLayoutDir::PositionInLayoutDirOfAnchor:
3264         {
3265             mnPositionLayoutDir = _nPositionLayoutDir;
3266         }
3267         break;
3268         default:
3269         {
3270             ASSERT( false,
3271                     "<SwDrawFrmFmt::SetPositionLayoutDir(..)> - invalid attribute value." );
3272         }
3273     }
3274 }
3275 // <--
3276 
3277 String SwDrawFrmFmt::GetDescription() const
3278 {
3279     String aResult;
3280     const SdrObject * pSdrObj = FindSdrObject();
3281 
3282     if (pSdrObj)
3283     {
3284         if (pSdrObj != pSdrObjCached)
3285         {
3286             SdrObject * pSdrObjCopy = pSdrObj->Clone();
3287             SdrUndoNewObj * pSdrUndo = new SdrUndoNewObj(*pSdrObjCopy);
3288             sSdrObjCachedComment = pSdrUndo->GetComment();
3289 
3290             delete pSdrUndo;
3291 
3292             pSdrObjCached = pSdrObj;
3293         }
3294 
3295         aResult = sSdrObjCachedComment;
3296     }
3297     else
3298         aResult = SW_RES(STR_GRAPHIC);
3299 
3300     return aResult;
3301 }
3302 
3303 IMapObject* SwFrmFmt::GetIMapObject( const Point& rPoint,
3304 										const SwFlyFrm *pFly ) const
3305 {
3306 	const SwFmtURL &rURL = GetURL();
3307 	if( !rURL.GetMap() )
3308 		return 0;
3309 
3310 	if( !pFly )
3311 	{
3312 		pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement( *this );
3313 		if( !pFly )
3314 			return 0;
3315 	}
3316 
3317 	//Orignialgroesse fuer OLE und Grafik ist die TwipSize,
3318 	//ansonsten die Groesse vom FrmFmt des Fly.
3319 	const SwFrm *pRef;
3320     SwNoTxtNode *pNd = 0;
3321 	Size aOrigSz;
3322 	if( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
3323 	{
3324 		pRef = pFly->Lower();
3325 		pNd = ((SwCntntFrm*)pRef)->GetNode()->GetNoTxtNode();
3326 		aOrigSz = pNd->GetTwipSize();
3327 	}
3328 	else
3329 	{
3330 		pRef = pFly;
3331 		aOrigSz = pFly->GetFmt()->GetFrmSize().GetSize();
3332 	}
3333 
3334 	if( aOrigSz.Width() != 0 && aOrigSz.Height() != 0 )
3335 	{
3336 		Point aPos( rPoint );
3337 		Size aActSz ( pRef == pFly ? pFly->Frm().SSize() : pRef->Prt().SSize() );
3338 		const MapMode aSrc ( MAP_TWIP );
3339 		const MapMode aDest( MAP_100TH_MM );
3340 		aOrigSz = OutputDevice::LogicToLogic( aOrigSz, aSrc, aDest );
3341 		aActSz  = OutputDevice::LogicToLogic( aActSz,  aSrc, aDest );
3342 		aPos -= pRef->Frm().Pos();
3343 		aPos -= pRef->Prt().Pos();
3344 		aPos    = OutputDevice::LogicToLogic( aPos, aSrc, aDest );
3345 		sal_uInt32 nFlags = 0;
3346 		if ( pFly != pRef && pNd->IsGrfNode() )
3347 		{
3348 			const sal_uInt16 nMirror = pNd->GetSwAttrSet().
3349 										GetMirrorGrf().GetValue();
3350             if ( RES_MIRROR_GRAPH_BOTH == nMirror )
3351 				nFlags = IMAP_MIRROR_HORZ | IMAP_MIRROR_VERT;
3352             else if ( RES_MIRROR_GRAPH_VERT == nMirror )
3353 				nFlags = IMAP_MIRROR_VERT;
3354             else if ( RES_MIRROR_GRAPH_HOR == nMirror )
3355 				nFlags = IMAP_MIRROR_HORZ;
3356 
3357 		}
3358 		return ((ImageMap*)rURL.GetMap())->GetHitIMapObject( aOrigSz,
3359 												aActSz, aPos, nFlags );
3360 	}
3361 
3362 	return 0;
3363 }
3364 
3365 sal_Bool SwFrmFmt::HasCaption() const
3366 {
3367 	if(pCaptionFmt != NULL && pCaptionFmt->GetDepends())
3368 		return sal_True;
3369 	return sal_False;
3370 }
3371 
3372 void SwFrmFmt::SetCaptionFmt(SwFrmFmt * pFmt)
3373 {
3374 	pCaptionFmt = pFmt;
3375 }
3376 
3377 SwFrmFmt* SwFrmFmt::GetCaptionFmt() const
3378 {
3379 	return pCaptionFmt;
3380 }
3381 
3382 //UUUU
3383 drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFrmFmt::getSdrAllFillAttributesHelper() const
3384 {
3385     if(supportsFullDrawingLayerFillAttributeSet())
3386     {
3387         // create FillAttributes on demand
3388         if(!maFillAttributes.get())
3389         {
3390             const_cast< SwFrmFmt* >(this)->maFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(GetAttrSet()));
3391         }
3392     }
3393     else
3394     {
3395         // FALLBACKBREAKHERE assert wrong usage
3396         OSL_ENSURE(false, "getSdrAllFillAttributesHelper() call only valid for RES_FLYFRMFMT and RES_FRMFMT (!)");
3397     }
3398 
3399     return maFillAttributes;
3400 }
3401 
3402 // eof
3403