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