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