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