Update ooo320-m1
[ooovba.git] / sw / source / core / layout / atrfrm.cxx
blobe327b0bbdf8083684e3c7c2d47849639c35c2a55
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: atrfrm.cxx,v $
10 * $Revision: 1.72.144.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <hintids.hxx>
36 #include <com/sun/star/text/RelOrientation.hpp>
37 #include <com/sun/star/text/VertOrientation.hpp>
38 #include <com/sun/star/text/HorizontalAdjust.hpp>
39 #include <com/sun/star/text/DocumentStatistic.hpp>
40 #include <com/sun/star/text/HoriOrientation.hpp>
41 #include <com/sun/star/text/HoriOrientationFormat.hpp>
42 #include <com/sun/star/text/NotePrintMode.hpp>
43 #include <com/sun/star/text/SizeType.hpp>
44 #include <com/sun/star/text/VertOrientationFormat.hpp>
45 #include <com/sun/star/text/WrapTextMode.hpp>
46 #include <com/sun/star/text/XTextFrame.hpp>
47 #include <com/sun/star/text/TextContentAnchorType.hpp>
48 #include <com/sun/star/text/InvalidTextContentException.hpp>
49 #include <com/sun/star/container/XIndexContainer.hpp>
50 #include <com/sun/star/text/TextGridMode.hpp>
51 #include <com/sun/star/awt/Size.hpp>
52 #include <svtools/unoimap.hxx>
53 #include <svtools/unoevent.hxx>
54 #ifndef __SBX_SBXVARIABLE_HXX //autogen
55 #include <basic/sbxvar.hxx>
56 #endif
57 #include <svtools/imap.hxx>
58 #include <svtools/imapobj.hxx>
59 #include <svx/ulspitem.hxx>
60 #include <svx/lrspitem.hxx>
61 #include <svx/svdmodel.hxx>
62 #include <svx/svdpage.hxx>
63 #include <unosett.hxx>
64 #include <unostyle.hxx>
65 #include <fmtclds.hxx>
66 #include <fmtornt.hxx>
67 #include <fmthdft.hxx>
68 #include <fmtpdsc.hxx>
69 #include <fmtcntnt.hxx>
70 #include <fmtfsize.hxx>
71 #include <fmtfordr.hxx>
72 #include <fmtsrnd.hxx>
73 #include <fmtanchr.hxx>
74 #include <fmtlsplt.hxx>
75 #include <fmtrowsplt.hxx>
76 #include <fmtftntx.hxx>
77 #include <fmteiro.hxx>
78 #include <fmturl.hxx>
79 #include <fmtcnct.hxx>
80 #include <node.hxx>
81 #include <section.hxx>
82 #ifndef _FMTLINE_HXX
83 #include <fmtline.hxx>
84 #endif
85 #include <tgrditem.hxx>
86 #include <hfspacingitem.hxx>
87 #include <doc.hxx>
88 #include <pagefrm.hxx>
89 #include <rootfrm.hxx>
90 #include <cntfrm.hxx>
91 #include <crsrsh.hxx>
92 #include <pam.hxx>
93 #include <dflyobj.hxx>
94 #include <dcontact.hxx>
95 #include <flyfrm.hxx>
96 #include <frmtool.hxx>
97 #include <flyfrms.hxx>
98 #include <pagedesc.hxx>
99 #include <grfatr.hxx>
100 #include <ndnotxt.hxx>
101 #include <docary.hxx>
102 #include <node2lay.hxx>
103 #include <fmtclbl.hxx>
104 #include <swunohelper.hxx>
105 #include <unoframe.hxx>
106 #include <SwStyleNameMapper.hxx>
107 /// OD 22.08.2002 #99657#
108 /// include definition of class SvxBrushItem and GraphicObject
109 /// in order to determine, if background is transparent.
110 #include <svx/brshitem.hxx>
111 #include <goodies/grfmgr.hxx>
113 #ifndef _CMDID_H
114 #include <cmdid.h>
115 #endif
116 #ifndef _UNOMID_H
117 #include <unomid.h>
118 #endif
119 #ifndef _COMCORE_HRC
120 #include <comcore.hrc>
121 #endif
122 #ifndef _SVX_SVUNDO_HXX
123 #include <svx/svdundo.hxx> // #111827#
124 #endif
125 // OD 2004-05-24 #i28701#
126 #include <sortedobjs.hxx>
127 // --> OD 2006-03-06 #125892#
128 #include <HandleAnchorNodeChg.hxx>
129 // <--
130 #include <svtools/cjkoptions.hxx>
132 using namespace ::com::sun::star;
133 using ::rtl::OUString;
135 SV_IMPL_PTRARR(SwColumns,SwColumn*)
137 TYPEINIT1(SwFmtVertOrient, SfxPoolItem);
138 TYPEINIT1(SwFmtHoriOrient, SfxPoolItem);
139 TYPEINIT2(SwFmtHeader, SfxPoolItem, SwClient );
140 TYPEINIT2(SwFmtFooter, SfxPoolItem, SwClient );
141 TYPEINIT2(SwFmtPageDesc, SfxPoolItem, SwClient );
142 TYPEINIT1_AUTOFACTORY(SwFmtLineNumber, SfxPoolItem);
144 /* -----------------19.05.98 09:26-------------------
145 * Umwandlung fuer QueryValue
146 * --------------------------------------------------*/
147 sal_Int16 lcl_RelToINT(sal_Int16 eRelation)
149 sal_Int16 nRet = text::RelOrientation::FRAME;
150 switch(eRelation)
152 case text::RelOrientation::PRINT_AREA: nRet = text::RelOrientation::PRINT_AREA; break;
153 case text::RelOrientation::CHAR: nRet = text::RelOrientation::CHAR; break;
154 case text::RelOrientation::PAGE_LEFT: nRet = text::RelOrientation::PAGE_LEFT; break;
155 case text::RelOrientation::PAGE_RIGHT: nRet = text::RelOrientation::PAGE_RIGHT; break;
156 case text::RelOrientation::FRAME_LEFT: nRet = text::RelOrientation::FRAME_LEFT; break;
157 case text::RelOrientation::FRAME_RIGHT: nRet = text::RelOrientation::FRAME_RIGHT; break;
158 case text::RelOrientation::PAGE_FRAME: nRet = text::RelOrientation::PAGE_FRAME; break;
159 case text::RelOrientation::PAGE_PRINT_AREA: nRet = text::RelOrientation::PAGE_PRINT_AREA; break;
160 // OD 13.11.2003 #i22341#
161 case text::RelOrientation::TEXT_LINE: nRet = text::RelOrientation::TEXT_LINE; break;
162 default: break;
164 return nRet;
167 sal_Int16 lcl_IntToRelation(const uno::Any& rVal)
169 sal_Int16 eRet = text::RelOrientation::FRAME;
170 sal_Int16 nVal = 0;
171 rVal >>= nVal;
172 switch(nVal)
174 case text::RelOrientation::PRINT_AREA: eRet = text::RelOrientation::PRINT_AREA ; break;
175 case text::RelOrientation::CHAR: eRet = text::RelOrientation::CHAR ; break;
176 case text::RelOrientation::PAGE_LEFT: eRet = text::RelOrientation::PAGE_LEFT ; break;
177 case text::RelOrientation::PAGE_RIGHT: eRet = text::RelOrientation::PAGE_RIGHT ; break;
178 case text::RelOrientation::FRAME_LEFT: eRet = text::RelOrientation::FRAME_LEFT ; break;
179 case text::RelOrientation::FRAME_RIGHT: eRet = text::RelOrientation::FRAME_RIGHT ; break;
180 case text::RelOrientation::PAGE_FRAME: eRet = text::RelOrientation::PAGE_FRAME ; break;
181 case text::RelOrientation::PAGE_PRINT_AREA: eRet = text::RelOrientation::PAGE_PRINT_AREA ; break;
182 // OD 13.11.2003 #i22341#
183 case text::RelOrientation::TEXT_LINE: eRet = text::RelOrientation::TEXT_LINE; break;
185 return eRet;
188 void DelHFFormat( SwClient *pToRemove, SwFrmFmt *pFmt )
190 //Wenn der Client der letzte ist der das Format benutzt, so muss dieses
191 //vernichtet werden. Zuvor muss jedoch ggf. die Inhaltssection vernichtet
192 //werden.
193 SwDoc* pDoc = pFmt->GetDoc();
194 pFmt->Remove( pToRemove );
195 if( pDoc->IsInDtor() )
197 delete pFmt;
198 return;
201 //Nur noch Frms angemeldet?
202 sal_Bool bDel = sal_True;
204 // Klammer, weil im DTOR SwClientIter das Flag bTreeChg zurueck
205 // gesetzt wird. Unguenstig, wenn das Format vorher zerstoert wird.
206 SwClientIter aIter( *pFmt );
207 SwClient *pLast = aIter.GoStart();
208 if( pLast )
209 do {
210 bDel = pLast->IsA( TYPE(SwFrm) )|| pLast->IsA(TYPE(SwXHeadFootText));
211 } while( bDel && 0 != ( pLast = aIter++ ));
214 if ( bDel )
216 //Wenn in einem der Nodes noch ein Crsr angemeldet ist, muss das
217 //ParkCrsr einer (beliebigen) Shell gerufen werden.
218 SwFmtCntnt& rCnt = (SwFmtCntnt&)pFmt->GetCntnt();
219 if ( rCnt.GetCntntIdx() )
221 SwNode *pNode = 0;
223 // --> OD 2008-10-07 #i92993#
224 // Begin with start node of page header/footer to assure that
225 // complete content is checked for cursors and the complete content
226 // is deleted on below made method call <pDoc->DeleteSection(pNode)>
227 // SwNodeIndex aIdx( *rCnt.GetCntntIdx(), 1 );
228 SwNodeIndex aIdx( *rCnt.GetCntntIdx(), 0 );
229 // <--
230 //Wenn in einem der Nodes noch ein Crsr angemeldet ist, muss das
231 //ParkCrsr einer (beliebigen) Shell gerufen werden.
232 pNode = pDoc->GetNodes()[ aIdx ];
233 sal_uInt32 nEnd = pNode->EndOfSectionIndex();
234 while ( aIdx < nEnd )
236 if ( pNode->IsCntntNode() &&
237 ((SwCntntNode*)pNode)->GetDepends() )
239 SwClientIter aIter( *(SwCntntNode*)pNode );
242 if( aIter()->ISA( SwCrsrShell ) )
244 ((SwCrsrShell*)aIter())->ParkCrsr( aIdx );
245 aIdx = nEnd-1;
246 break;
248 } while ( aIter++ );
250 aIdx++;
251 pNode = pDoc->GetNodes()[ aIdx ];
254 rCnt.SetNewCntntIdx( (const SwNodeIndex*)0 );
256 // beim Loeschen von Header/Footer-Formaten IMMER das Undo
257 // abschalten! (Bug 31069)
258 sal_Bool bDoesUndo = pDoc->DoesUndo();
259 pDoc->DoUndo( sal_False );
261 ASSERT( pNode, "Ein grosses Problem." );
262 pDoc->DeleteSection( pNode );
264 if( bDoesUndo )
265 pDoc->DoUndo( sal_True );
267 delete pFmt;
271 // class SwFmtFrmSize
272 // Implementierung teilweise inline im hxx
274 SwFmtFrmSize::SwFmtFrmSize( SwFrmSize eSize, SwTwips nWidth, SwTwips nHeight )
275 : SfxPoolItem( RES_FRM_SIZE ),
276 aSize( nWidth, nHeight ),
277 eFrmHeightType( eSize ),
278 eFrmWidthType( ATT_FIX_SIZE )
280 nWidthPercent = nHeightPercent = 0;
283 SwFmtFrmSize& SwFmtFrmSize::operator=( const SwFmtFrmSize& rCpy )
285 aSize = rCpy.GetSize();
286 eFrmHeightType = rCpy.GetHeightSizeType();
287 eFrmWidthType = rCpy.GetWidthSizeType();
288 nHeightPercent = rCpy.GetHeightPercent();
289 nWidthPercent = rCpy.GetWidthPercent();
290 return *this;
293 int SwFmtFrmSize::operator==( const SfxPoolItem& rAttr ) const
295 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
296 return( eFrmHeightType == ((SwFmtFrmSize&)rAttr).eFrmHeightType &&
297 eFrmWidthType == ((SwFmtFrmSize&)rAttr).eFrmWidthType &&
298 aSize == ((SwFmtFrmSize&)rAttr).GetSize()&&
299 nWidthPercent == ((SwFmtFrmSize&)rAttr).GetWidthPercent() &&
300 nHeightPercent == ((SwFmtFrmSize&)rAttr).GetHeightPercent() );
303 SfxPoolItem* SwFmtFrmSize::Clone( SfxItemPool* ) const
305 return new SwFmtFrmSize( *this );
309 /* -----------------24.04.98 11:36-------------------
311 * --------------------------------------------------*/
312 BOOL SwFmtFrmSize::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
314 // hier wird immer konvertiert!
315 nMemberId &= ~CONVERT_TWIPS;
316 switch ( nMemberId )
318 case MID_FRMSIZE_SIZE:
320 awt::Size aTmp;
321 aTmp.Height = TWIP_TO_MM100(aSize.Height());
322 aTmp.Width = TWIP_TO_MM100(aSize.Width());
323 rVal.setValue(&aTmp, ::getCppuType((const awt::Size*)0));
325 break;
326 case MID_FRMSIZE_REL_HEIGHT:
327 rVal <<= (sal_Int16)(GetHeightPercent() != 0xFF ? GetHeightPercent() : 0);
328 break;
329 case MID_FRMSIZE_REL_WIDTH:
330 rVal <<= (sal_Int16)(GetWidthPercent() != 0xFF ? GetWidthPercent() : 0);
331 break;
332 case MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH:
334 BOOL bTmp = 0xFF == GetHeightPercent();
335 rVal.setValue(&bTmp, ::getBooleanCppuType());
337 break;
338 case MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT:
340 BOOL bTmp = 0xFF == GetWidthPercent();
341 rVal.setValue(&bTmp, ::getBooleanCppuType());
343 break;
344 case MID_FRMSIZE_WIDTH :
345 rVal <<= (sal_Int32)TWIP_TO_MM100(aSize.Width());
346 break;
347 case MID_FRMSIZE_HEIGHT:
348 // #95848# returned size should never be zero.
349 // (there was a bug that allowed for setting height to 0.
350 // Thus there some documents existing with that not allowed
351 // attribut value which may cause problems on import.)
352 rVal <<= (sal_Int32)TWIP_TO_MM100(aSize.Height() < MINLAY ? MINLAY : aSize.Height() );
353 break;
354 case MID_FRMSIZE_SIZE_TYPE:
355 rVal <<= (sal_Int16)GetHeightSizeType();
356 break;
357 case MID_FRMSIZE_IS_AUTO_HEIGHT:
359 BOOL bTmp = ATT_FIX_SIZE != GetHeightSizeType();
360 rVal.setValue(&bTmp, ::getBooleanCppuType());
362 break;
363 case MID_FRMSIZE_WIDTH_TYPE:
364 rVal <<= (sal_Int16)GetWidthSizeType();
365 break;
367 return sal_True;
370 /* -----------------24.04.98 11:36-------------------
372 * --------------------------------------------------*/
373 BOOL SwFmtFrmSize::PutValue( const uno::Any& rVal, BYTE nMemberId )
375 sal_Bool bConvert = 0 != (nMemberId&CONVERT_TWIPS);
376 nMemberId &= ~CONVERT_TWIPS;
377 sal_Bool bRet = sal_True;
378 switch ( nMemberId )
380 case MID_FRMSIZE_SIZE:
382 awt::Size aVal;
383 if(!(rVal >>= aVal))
384 bRet = sal_False;
385 else
387 Size aTmp(aVal.Width, aVal.Height);
388 if(bConvert)
390 aTmp.Height() = MM100_TO_TWIP(aTmp.Height());
391 aTmp.Width() = MM100_TO_TWIP(aTmp.Width());
393 if(aTmp.Height() && aTmp.Width())
394 aSize = aTmp;
395 else
396 bRet = sal_False;
399 break;
400 case MID_FRMSIZE_REL_HEIGHT:
402 sal_Int16 nSet = 0;
403 rVal >>= nSet;
404 if(nSet >= 0 && nSet <= 0xfe)
405 SetHeightPercent((BYTE)nSet);
406 else
407 bRet = sal_False;
409 break;
410 case MID_FRMSIZE_REL_WIDTH:
412 sal_Int16 nSet = 0;
413 rVal >>= nSet;
414 if(nSet >= 0 && nSet <= 0xfe)
415 SetWidthPercent((BYTE)nSet);
416 else
417 bRet = sal_False;
419 break;
420 case MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH:
422 sal_Bool bSet = *(sal_Bool*)rVal.getValue();
423 if(bSet)
424 SetHeightPercent(0xff);
425 else if( 0xff == GetHeightPercent() )
426 SetHeightPercent( 0 );
428 break;
429 case MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT:
431 sal_Bool bSet = *(sal_Bool*)rVal.getValue();
432 if(bSet)
433 SetWidthPercent(0xff);
434 else if( 0xff == GetWidthPercent() )
435 SetWidthPercent(0);
437 break;
438 case MID_FRMSIZE_WIDTH :
440 sal_Int32 nWd = 0;
441 if(rVal >>= nWd)
443 if(bConvert)
444 nWd = MM100_TO_TWIP(nWd);
445 if(nWd < MINLAY)
446 nWd = MINLAY;
447 aSize.Width() = nWd;
449 else
450 bRet = sal_False;
452 break;
453 case MID_FRMSIZE_HEIGHT:
455 sal_Int32 nHg = 0;
456 if(rVal >>= nHg)
458 if(bConvert)
459 nHg = MM100_TO_TWIP(nHg);
460 if(nHg < MINLAY)
461 nHg = MINLAY;
462 aSize.Height() = nHg;
464 else
465 bRet = sal_False;
467 break;
468 case MID_FRMSIZE_SIZE_TYPE:
470 sal_Int16 nType = 0;
471 if((rVal >>= nType) && nType >= 0 && nType <= ATT_MIN_SIZE )
473 SetHeightSizeType((SwFrmSize)nType);
475 else
476 bRet = sal_False;
478 break;
479 case MID_FRMSIZE_IS_AUTO_HEIGHT:
481 sal_Bool bSet = *(sal_Bool*)rVal.getValue();
482 SetHeightSizeType(bSet ? ATT_VAR_SIZE : ATT_FIX_SIZE);
484 break;
485 case MID_FRMSIZE_WIDTH_TYPE:
487 sal_Int16 nType = 0;
488 if((rVal >>= nType) && nType >= 0 && nType <= ATT_MIN_SIZE )
490 SetWidthSizeType((SwFrmSize)nType);
492 else
493 bRet = sal_False;
495 break;
496 default:
497 bRet = sal_False;
499 return bRet;
502 // class SwFmtFillOrder
503 // Implementierung teilweise inline im hxx
505 SwFmtFillOrder::SwFmtFillOrder( SwFillOrder nFO )
506 : SfxEnumItem( RES_FILL_ORDER, sal_uInt16(nFO) )
509 SfxPoolItem* SwFmtFillOrder::Clone( SfxItemPool* ) const
511 return new SwFmtFillOrder( GetFillOrder() );
514 sal_uInt16 SwFmtFillOrder::GetValueCount() const
516 return SW_FILL_ORDER_END - SW_FILL_ORDER_BEGIN;
519 // class SwFmtHeader
520 // Implementierung teilweise inline im hxx
522 SwFmtHeader::SwFmtHeader( SwFrmFmt *pHeaderFmt )
523 : SfxPoolItem( RES_HEADER ),
524 SwClient( pHeaderFmt ),
525 bActive( pHeaderFmt ? sal_True : sal_False )
529 SwFmtHeader::SwFmtHeader( const SwFmtHeader &rCpy )
530 : SfxPoolItem( RES_HEADER ),
531 SwClient( (SwModify*)rCpy.GetRegisteredIn() ),
532 bActive( rCpy.IsActive() )
536 SwFmtHeader::SwFmtHeader( sal_Bool bOn )
537 : SfxPoolItem( RES_HEADER ),
538 SwClient( 0 ),
539 bActive( bOn )
543 SwFmtHeader::~SwFmtHeader()
545 if ( GetHeaderFmt() )
546 DelHFFormat( this, GetHeaderFmt() );
549 int SwFmtHeader::operator==( const SfxPoolItem& rAttr ) const
551 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
552 return ( pRegisteredIn == ((SwFmtHeader&)rAttr).GetRegisteredIn() &&
553 bActive == ((SwFmtHeader&)rAttr).IsActive() );
556 SfxPoolItem* SwFmtHeader::Clone( SfxItemPool* ) const
558 return new SwFmtHeader( *this );
561 // class SwFmtFooter
562 // Implementierung teilweise inline im hxx
564 SwFmtFooter::SwFmtFooter( SwFrmFmt *pFooterFmt )
565 : SfxPoolItem( RES_FOOTER ),
566 SwClient( pFooterFmt ),
567 bActive( pFooterFmt ? sal_True : sal_False )
571 SwFmtFooter::SwFmtFooter( const SwFmtFooter &rCpy )
572 : SfxPoolItem( RES_FOOTER ),
573 SwClient( (SwModify*)rCpy.GetRegisteredIn() ),
574 bActive( rCpy.IsActive() )
578 SwFmtFooter::SwFmtFooter( sal_Bool bOn )
579 : SfxPoolItem( RES_FOOTER ),
580 SwClient( 0 ),
581 bActive( bOn )
585 SwFmtFooter::~SwFmtFooter()
587 if ( GetFooterFmt() )
588 DelHFFormat( this, GetFooterFmt() );
591 int SwFmtFooter::operator==( const SfxPoolItem& rAttr ) const
593 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
594 return ( pRegisteredIn == ((SwFmtFooter&)rAttr).GetRegisteredIn() &&
595 bActive == ((SwFmtFooter&)rAttr).IsActive() );
598 SfxPoolItem* SwFmtFooter::Clone( SfxItemPool* ) const
600 return new SwFmtFooter( *this );
603 // class SwFmtCntnt
604 // Implementierung teilweise inline im hxx
606 SwFmtCntnt::SwFmtCntnt( const SwFmtCntnt &rCpy )
607 : SfxPoolItem( RES_CNTNT )
609 pStartNode = rCpy.GetCntntIdx() ?
610 new SwNodeIndex( *rCpy.GetCntntIdx() ) : 0;
613 SwFmtCntnt::SwFmtCntnt( const SwStartNode *pStartNd )
614 : SfxPoolItem( RES_CNTNT )
616 pStartNode = pStartNd ? new SwNodeIndex( *pStartNd ) : 0;
619 SwFmtCntnt::~SwFmtCntnt()
621 delete pStartNode;
624 void SwFmtCntnt::SetNewCntntIdx( const SwNodeIndex *pIdx )
626 delete pStartNode;
627 pStartNode = pIdx ? new SwNodeIndex( *pIdx ) : 0;
630 int SwFmtCntnt::operator==( const SfxPoolItem& rAttr ) const
632 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
633 if( (long)pStartNode ^ (long)((SwFmtCntnt&)rAttr).pStartNode )
634 return 0;
635 if( pStartNode )
636 return ( *pStartNode == *((SwFmtCntnt&)rAttr).GetCntntIdx() );
637 return 1;
640 SfxPoolItem* SwFmtCntnt::Clone( SfxItemPool* ) const
642 return new SwFmtCntnt( *this );
645 // class SwFmtPageDesc
646 // Implementierung teilweise inline im hxx
648 SwFmtPageDesc::SwFmtPageDesc( const SwFmtPageDesc &rCpy )
649 : SfxPoolItem( RES_PAGEDESC ),
650 SwClient( (SwPageDesc*)rCpy.GetPageDesc() ),
651 nNumOffset( rCpy.nNumOffset ),
652 nDescNameIdx( rCpy.nDescNameIdx ),
653 pDefinedIn( 0 )
657 SwFmtPageDesc::SwFmtPageDesc( const SwPageDesc *pDesc )
658 : SfxPoolItem( RES_PAGEDESC ),
659 SwClient( (SwPageDesc*)pDesc ),
660 nNumOffset( 0 ),
661 nDescNameIdx( 0xFFFF ), // IDX_NO_VALUE
662 pDefinedIn( 0 )
666 SwFmtPageDesc::~SwFmtPageDesc() {}
668 int SwFmtPageDesc::operator==( const SfxPoolItem& rAttr ) const
670 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
671 return ( pDefinedIn == ((SwFmtPageDesc&)rAttr).pDefinedIn ) &&
672 ( nNumOffset == ((SwFmtPageDesc&)rAttr).nNumOffset ) &&
673 ( GetPageDesc() == ((SwFmtPageDesc&)rAttr).GetPageDesc() );
676 SfxPoolItem* SwFmtPageDesc::Clone( SfxItemPool* ) const
678 return new SwFmtPageDesc( *this );
681 void SwFmtPageDesc::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew )
683 if( !pDefinedIn )
684 return;
686 const sal_uInt16 nWhichId = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
687 switch( nWhichId )
689 case RES_OBJECTDYING:
690 //Der Pagedesc, bei dem ich angemeldet bin stirbt, ich trage
691 //mich also bei meinem Format aus.
692 //Dabei werden ich Deletet!!!
693 if( IS_TYPE( SwFmt, pDefinedIn ))
694 #ifndef PRODUCT
696 sal_Bool bDel = ((SwFmt*)pDefinedIn)->ResetFmtAttr( RES_PAGEDESC );
697 ASSERT( bDel, ";-) FmtPageDesc nicht zerstoert." );
699 #else
700 ((SwFmt*)pDefinedIn)->ResetFmtAttr( RES_PAGEDESC );
701 #endif
702 else if( IS_TYPE( SwCntntNode, pDefinedIn ))
703 #ifndef PRODUCT
705 sal_Bool bDel = ((SwCntntNode*)pDefinedIn)->ResetAttr( RES_PAGEDESC );
706 ASSERT( bDel, ";-) FmtPageDesc nicht zerstoert." );
708 #else
709 ((SwCntntNode*)pDefinedIn)->ResetAttr( RES_PAGEDESC );
710 #endif
711 break;
713 default:
714 /* do nothing */;
718 BOOL SwFmtPageDesc::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
720 // hier wird immer konvertiert!
721 nMemberId &= ~CONVERT_TWIPS;
722 sal_Bool bRet = sal_True;
723 switch ( nMemberId )
725 case MID_PAGEDESC_PAGENUMOFFSET:
726 rVal <<= (sal_Int16)GetNumOffset();
727 break;
729 case MID_PAGEDESC_PAGEDESCNAME:
731 const SwPageDesc* pDesc = GetPageDesc();
732 if( pDesc )
734 String aString;
735 SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
736 rVal <<= OUString( aString );
738 else
739 rVal.clear();
741 break;
742 default:
743 ASSERT( !this, "unknown MemberId" );
744 bRet = sal_False;
746 return bRet;
749 BOOL SwFmtPageDesc::PutValue( const uno::Any& rVal, BYTE nMemberId )
751 // hier wird immer konvertiert!
752 nMemberId &= ~CONVERT_TWIPS;
753 sal_Bool bRet = sal_True;
754 switch ( nMemberId )
756 case MID_PAGEDESC_PAGENUMOFFSET:
758 sal_Int16 nOffset = 0;
759 if(rVal >>= nOffset)
760 SetNumOffset( nOffset );
761 else
762 bRet = sal_False;
764 break;
766 case MID_PAGEDESC_PAGEDESCNAME:
767 /* geht nicht, weil das Attribut eigentlich nicht den Namen
768 * sondern einen Pointer auf den PageDesc braucht (ist Client davon).
769 * Der Pointer waere aber ueber den Namen nur vom Dokument zu erfragen.
771 default:
772 ASSERT( !this, "unknown MemberId" );
773 bRet = sal_False;
775 return bRet;
779 // class SwFmtCol
780 // Implementierung teilweise inline im hxx
782 SwColumn::SwColumn() :
783 nWish ( 0 ),
784 nUpper( 0 ),
785 nLower( 0 ),
786 nLeft ( 0 ),
787 nRight( 0 )
791 sal_Bool SwColumn::operator==( const SwColumn &rCmp )
793 return (nWish == rCmp.GetWishWidth() &&
794 GetLeft() == rCmp.GetLeft() &&
795 GetRight() == rCmp.GetRight() &&
796 GetUpper() == rCmp.GetUpper() &&
797 GetLower() == rCmp.GetLower()) ? sal_True : sal_False;
800 SwFmtCol::SwFmtCol( const SwFmtCol& rCpy )
801 : SfxPoolItem( RES_COL ),
802 nLineWidth( rCpy.nLineWidth),
803 aLineColor( rCpy.aLineColor),
804 nLineHeight( rCpy.GetLineHeight() ),
805 eAdj( rCpy.GetLineAdj() ),
806 aColumns( (sal_Int8)rCpy.GetNumCols(), 1 ),
807 nWidth( rCpy.GetWishWidth() ),
808 bOrtho( rCpy.IsOrtho() )
810 for ( sal_uInt16 i = 0; i < rCpy.GetNumCols(); ++i )
812 SwColumn *pCol = new SwColumn( *rCpy.GetColumns()[i] );
813 aColumns.Insert( pCol, aColumns.Count() );
817 SwFmtCol::~SwFmtCol() {}
819 SwFmtCol& SwFmtCol::operator=( const SwFmtCol& rCpy )
821 nLineWidth = rCpy.nLineWidth;
822 aLineColor = rCpy.aLineColor;
823 nLineHeight = rCpy.GetLineHeight();
824 eAdj = rCpy.GetLineAdj();
825 nWidth = rCpy.GetWishWidth();
826 bOrtho = rCpy.IsOrtho();
828 if ( aColumns.Count() )
829 aColumns.DeleteAndDestroy( 0, aColumns.Count() );
830 for ( sal_uInt16 i = 0; i < rCpy.GetNumCols(); ++i )
832 SwColumn *pCol = new SwColumn( *rCpy.GetColumns()[i] );
833 aColumns.Insert( pCol, aColumns.Count() );
835 return *this;
838 SwFmtCol::SwFmtCol()
839 : SfxPoolItem( RES_COL ),
840 nLineWidth(0),
841 nLineHeight( 100 ),
842 eAdj( COLADJ_NONE ),
843 nWidth( USHRT_MAX ),
844 bOrtho( sal_True )
848 int SwFmtCol::operator==( const SfxPoolItem& rAttr ) const
850 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
851 const SwFmtCol &rCmp = (const SwFmtCol&)rAttr;
852 if( !(nLineWidth == rCmp.nLineWidth &&
853 aLineColor == rCmp.aLineColor &&
854 nLineHeight == rCmp.GetLineHeight() &&
855 eAdj == rCmp.GetLineAdj() &&
856 nWidth == rCmp.GetWishWidth() &&
857 bOrtho == rCmp.IsOrtho() &&
858 aColumns.Count() == rCmp.GetNumCols()) )
859 return 0;
861 for ( sal_uInt16 i = 0; i < aColumns.Count(); ++i )
862 if ( !(*aColumns[i] == *rCmp.GetColumns()[i]) )
863 return 0;
865 return 1;
868 SfxPoolItem* SwFmtCol::Clone( SfxItemPool* ) const
870 return new SwFmtCol( *this );
873 sal_uInt16 SwFmtCol::GetGutterWidth( sal_Bool bMin ) const
875 sal_uInt16 nRet = 0;
876 if ( aColumns.Count() == 2 )
877 nRet = aColumns[0]->GetRight() + aColumns[1]->GetLeft();
878 else if ( aColumns.Count() > 2 )
880 sal_Bool bSet = sal_False;
881 for ( sal_uInt16 i = 1; i < aColumns.Count()-1; ++i )
883 const sal_uInt16 nTmp = aColumns[i]->GetRight() + aColumns[i+1]->GetLeft();
884 if ( bSet )
886 if ( nTmp != nRet )
888 if ( !bMin )
889 return USHRT_MAX;
890 if ( nRet > nTmp )
891 nRet = nTmp;
894 else
895 { bSet = sal_True;
896 nRet = nTmp;
900 return nRet;
903 void SwFmtCol::SetGutterWidth( sal_uInt16 nNew, sal_uInt16 nAct )
905 if ( bOrtho )
906 Calc( nNew, nAct );
907 else
909 sal_uInt16 nHalf = nNew / 2;
910 for ( sal_uInt16 i = 0; i < aColumns.Count(); ++i )
911 { SwColumn *pCol = aColumns[i];
912 pCol->SetLeft ( nHalf );
913 pCol->SetRight( nHalf );
914 if ( i == 0 )
915 pCol->SetLeft( 0 );
916 else if ( i == (aColumns.Count() - 1) )
917 pCol->SetRight( 0 );
922 void SwFmtCol::Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct )
924 //Loeschen scheint hier auf den erste Blick vielleicht etwas zu heftig;
925 //anderfalls muessten allerdings alle Werte der verbleibenden SwColumn's
926 //initialisiert werden.
927 if ( aColumns.Count() )
928 aColumns.DeleteAndDestroy( 0, aColumns.Count() );
929 for ( sal_uInt16 i = 0; i < nNumCols; ++i )
930 { SwColumn *pCol = new SwColumn;
931 aColumns.Insert( pCol, i );
933 bOrtho = sal_True;
934 nWidth = USHRT_MAX;
935 if( nNumCols )
936 Calc( nGutterWidth, nAct );
939 void SwFmtCol::SetOrtho( sal_Bool bNew, sal_uInt16 nGutterWidth, sal_uInt16 nAct )
941 bOrtho = bNew;
942 if ( bNew && aColumns.Count() )
943 Calc( nGutterWidth, nAct );
946 sal_uInt16 SwFmtCol::CalcColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const
948 ASSERT( nCol < aColumns.Count(), ":-( ColumnsArr ueberindiziert." );
949 if ( nWidth != nAct )
951 long nW = aColumns[nCol]->GetWishWidth();
952 nW *= nAct;
953 nW /= nWidth;
954 return sal_uInt16(nW);
956 else
957 return aColumns[nCol]->GetWishWidth();
960 sal_uInt16 SwFmtCol::CalcPrtColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const
962 ASSERT( nCol < aColumns.Count(), ":-( ColumnsArr ueberindiziert." );
963 sal_uInt16 nRet = CalcColWidth( nCol, nAct );
964 SwColumn *pCol = aColumns[nCol];
965 nRet = nRet - pCol->GetLeft();
966 nRet = nRet - pCol->GetRight();
967 return nRet;
970 void SwFmtCol::Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct )
972 if(!GetNumCols())
973 return;
974 //Erstmal die Spalten mit der Aktuellen Breite einstellen, dann die
975 //Wunschbreite der Spalten anhand der Gesamtwunschbreite hochrechnen.
977 const sal_uInt16 nGutterHalf = nGutterWidth ? nGutterWidth / 2 : 0;
979 //Breite der PrtAreas ist Gesamtbreite - Zwischenraeume / Anzahl
980 const sal_uInt16 nPrtWidth =
981 (nAct - ((GetNumCols()-1) * nGutterWidth)) / GetNumCols();
982 sal_uInt16 nAvail = nAct;
984 //Die erste Spalte ist PrtBreite + (Zwischenraumbreite/2)
985 const sal_uInt16 nLeftWidth = nPrtWidth + nGutterHalf;
986 SwColumn *pCol = aColumns[0];
987 pCol->SetWishWidth( nLeftWidth );
988 pCol->SetRight( nGutterHalf );
989 pCol->SetLeft ( 0 );
990 nAvail = nAvail - nLeftWidth;
992 //Spalte 2 bis n-1 ist PrtBreite + Zwischenraumbreite
993 const sal_uInt16 nMidWidth = nPrtWidth + nGutterWidth;
994 sal_uInt16 i;
996 for ( i = 1; i < GetNumCols()-1; ++i )
998 pCol = aColumns[i];
999 pCol->SetWishWidth( nMidWidth );
1000 pCol->SetLeft ( nGutterHalf );
1001 pCol->SetRight( nGutterHalf );
1002 nAvail = nAvail - nMidWidth;
1005 //Die Letzte Spalte entspricht wieder der ersten, um Rundungsfehler
1006 //auszugleichen wird der letzten Spalte alles zugeschlagen was die
1007 //anderen nicht verbraucht haben.
1008 pCol = aColumns[aColumns.Count()-1];
1009 pCol->SetWishWidth( nAvail );
1010 pCol->SetLeft ( nGutterHalf );
1011 pCol->SetRight( 0 );
1013 //Umrechnen der aktuellen Breiten in Wunschbreiten.
1014 for ( i = 0; i < aColumns.Count(); ++i )
1016 pCol = aColumns[i];
1017 long nTmp = pCol->GetWishWidth();
1018 nTmp *= GetWishWidth();
1019 nTmp /= nAct;
1020 pCol->SetWishWidth( sal_uInt16(nTmp) );
1024 BOOL SwFmtCol::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
1026 // hier wird immer konvertiert!
1027 nMemberId &= ~CONVERT_TWIPS;
1028 if(MID_COLUMN_SEPARATOR_LINE == nMemberId)
1030 DBG_ERROR("not implemented");
1032 else
1034 uno::Reference< text::XTextColumns > xCols = new SwXTextColumns(*this);
1035 rVal.setValue(&xCols, ::getCppuType((uno::Reference< text::XTextColumns>*)0));
1037 return sal_True;
1040 BOOL SwFmtCol::PutValue( const uno::Any& rVal, BYTE nMemberId )
1042 // hier wird immer konvertiert!
1043 nMemberId &= ~CONVERT_TWIPS;
1044 sal_Bool bRet = sal_False;
1045 if(MID_COLUMN_SEPARATOR_LINE == nMemberId)
1047 DBG_ERROR("not implemented");
1049 else
1051 uno::Reference< text::XTextColumns > xCols;
1052 rVal >>= xCols;
1053 if(xCols.is())
1055 uno::Sequence<text::TextColumn> aSetColumns = xCols->getColumns();
1056 const text::TextColumn* pArray = aSetColumns.getConstArray();
1057 aColumns.DeleteAndDestroy(0, aColumns.Count());
1058 //max. Count ist hier 64K - das kann das Array aber nicht
1059 sal_uInt16 nCount = Min( (sal_uInt16)aSetColumns.getLength(),
1060 (sal_uInt16) 0x3fff );
1061 sal_uInt16 nWidthSum = 0;
1062 // #101224# one column is no column
1064 if(nCount > 1)
1065 for(sal_uInt16 i = 0; i < nCount; i++)
1067 SwColumn* pCol = new SwColumn;
1068 pCol->SetWishWidth( static_cast<USHORT>(pArray[i].Width) );
1069 nWidthSum = static_cast<USHORT>(nWidthSum + pArray[i].Width);
1070 pCol->SetLeft ( static_cast<USHORT>(MM100_TO_TWIP(pArray[i].LeftMargin)) );
1071 pCol->SetRight( static_cast<USHORT>(MM100_TO_TWIP(pArray[i].RightMargin)) );
1072 aColumns.Insert(pCol, i);
1074 bRet = sal_True;
1075 nWidth = nWidthSum;
1076 bOrtho = sal_False;
1078 uno::Reference<lang::XUnoTunnel> xNumTunnel(xCols, uno::UNO_QUERY);
1079 SwXTextColumns* pSwColums = 0;
1080 if(xNumTunnel.is())
1082 pSwColums = reinterpret_cast< SwXTextColumns * >(
1083 sal::static_int_cast< sal_IntPtr >(
1084 xNumTunnel->getSomething( SwXTextColumns::getUnoTunnelId() )));
1086 if(pSwColums)
1088 bOrtho = pSwColums->IsAutomaticWidth();
1089 nLineWidth = pSwColums->GetSepLineWidth();
1090 aLineColor.SetColor(pSwColums->GetSepLineColor());
1091 nLineHeight = pSwColums->GetSepLineHeightRelative();
1092 if(!pSwColums->GetSepLineIsOn())
1093 eAdj = COLADJ_NONE;
1094 else switch(pSwColums->GetSepLineVertAlign())
1096 case 0: eAdj = COLADJ_TOP; break; //VerticalAlignment_TOP
1097 case 1: eAdj = COLADJ_CENTER;break; //VerticalAlignment_MIDDLE
1098 case 2: eAdj = COLADJ_BOTTOM;break; //VerticalAlignment_BOTTOM
1099 default: ASSERT( !this, "unknown alignment" ); break;
1104 return bRet;
1108 // class SwFmtSurround
1109 // Implementierung teilweise inline im hxx
1111 SwFmtSurround::SwFmtSurround( SwSurround eFly ) :
1112 SfxEnumItem( RES_SURROUND, sal_uInt16( eFly ) )
1114 bAnchorOnly = bContour = bOutside = sal_False;
1117 SwFmtSurround::SwFmtSurround( const SwFmtSurround &rCpy ) :
1118 SfxEnumItem( RES_SURROUND, rCpy.GetValue() )
1120 bAnchorOnly = rCpy.bAnchorOnly;
1121 bContour = rCpy.bContour;
1122 bOutside = rCpy.bOutside;
1125 int SwFmtSurround::operator==( const SfxPoolItem& rAttr ) const
1127 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
1128 return ( GetValue() == ((SwFmtSurround&)rAttr).GetValue() &&
1129 bAnchorOnly== ((SwFmtSurround&)rAttr).bAnchorOnly &&
1130 bContour== ((SwFmtSurround&)rAttr).bContour &&
1131 bOutside== ((SwFmtSurround&)rAttr).bOutside );
1134 SfxPoolItem* SwFmtSurround::Clone( SfxItemPool* ) const
1136 return new SwFmtSurround( *this );
1139 sal_uInt16 SwFmtSurround::GetValueCount() const
1141 return SURROUND_END - SURROUND_BEGIN;
1145 BOOL SwFmtSurround::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
1147 // hier wird immer konvertiert!
1148 nMemberId &= ~CONVERT_TWIPS;
1149 sal_Bool bRet = sal_True;
1150 switch ( nMemberId )
1152 case MID_SURROUND_SURROUNDTYPE:
1153 rVal <<= (text::WrapTextMode)GetSurround();
1154 break;
1155 case MID_SURROUND_ANCHORONLY:
1157 BOOL bTmp = IsAnchorOnly();
1158 rVal.setValue(&bTmp, ::getBooleanCppuType());
1160 break;
1161 case MID_SURROUND_CONTOUR:
1163 BOOL bTmp = IsContour();
1164 rVal.setValue(&bTmp, ::getBooleanCppuType());
1166 break;
1167 case MID_SURROUND_CONTOUROUTSIDE:
1169 BOOL bTmp = IsOutside();
1170 rVal.setValue(&bTmp, ::getBooleanCppuType());
1172 break;
1173 default:
1174 ASSERT( !this, "unknown MemberId" );
1175 bRet = sal_False;
1177 return bRet;
1180 BOOL SwFmtSurround::PutValue( const uno::Any& rVal, BYTE nMemberId )
1182 // hier wird immer konvertiert!
1183 nMemberId &= ~CONVERT_TWIPS;
1184 sal_Bool bRet = sal_True;
1185 switch ( nMemberId )
1187 case MID_SURROUND_SURROUNDTYPE:
1189 sal_Int32 eVal = SWUnoHelper::GetEnumAsInt32( rVal );
1190 if( eVal >= 0 && eVal < (sal_Int16)SURROUND_END )
1191 SetValue( static_cast<USHORT>(eVal) );
1192 else {
1193 //exception
1197 break;
1199 case MID_SURROUND_ANCHORONLY:
1200 SetAnchorOnly( *(sal_Bool*)rVal.getValue() );
1201 break;
1202 case MID_SURROUND_CONTOUR:
1203 SetContour( *(sal_Bool*)rVal.getValue() );
1204 break;
1205 case MID_SURROUND_CONTOUROUTSIDE:
1206 SetOutside( *(sal_Bool*)rVal.getValue() );
1207 break;
1208 default:
1209 ASSERT( !this, "unknown MemberId" );
1210 bRet = sal_False;
1212 return bRet;
1215 // class SwFmtVertOrient
1216 // Implementierung teilweise inline im hxx
1218 SwFmtVertOrient::SwFmtVertOrient( SwTwips nY, sal_Int16 eVert,
1219 sal_Int16 eRel )
1220 : SfxPoolItem( RES_VERT_ORIENT ),
1221 nYPos( nY ),
1222 eOrient( eVert ),
1223 eRelation( eRel )
1226 int SwFmtVertOrient::operator==( const SfxPoolItem& rAttr ) const
1228 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
1229 return ( nYPos == ((SwFmtVertOrient&)rAttr).nYPos &&
1230 eOrient == ((SwFmtVertOrient&)rAttr).eOrient &&
1231 eRelation == ((SwFmtVertOrient&)rAttr).eRelation );
1234 SfxPoolItem* SwFmtVertOrient::Clone( SfxItemPool* ) const
1236 return new SwFmtVertOrient( nYPos, eOrient, eRelation );
1239 BOOL SwFmtVertOrient::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
1241 // hier wird immer konvertiert!
1242 nMemberId &= ~CONVERT_TWIPS;
1243 sal_Bool bRet = sal_True;
1244 switch ( nMemberId )
1246 case MID_VERTORIENT_ORIENT:
1248 sal_Int16 nRet = text::VertOrientation::NONE;
1249 switch( eOrient )
1251 case text::VertOrientation::TOP : nRet = text::VertOrientation::TOP ;break;
1252 case text::VertOrientation::CENTER : nRet = text::VertOrientation::CENTER ;break;
1253 case text::VertOrientation::BOTTOM : nRet = text::VertOrientation::BOTTOM ;break;
1254 case text::VertOrientation::CHAR_TOP : nRet = text::VertOrientation::CHAR_TOP ;break;
1255 case text::VertOrientation::CHAR_CENTER: nRet = text::VertOrientation::CHAR_CENTER;break;
1256 case text::VertOrientation::CHAR_BOTTOM: nRet = text::VertOrientation::CHAR_BOTTOM;break;
1257 case text::VertOrientation::LINE_TOP : nRet = text::VertOrientation::LINE_TOP ;break;
1258 case text::VertOrientation::LINE_CENTER: nRet = text::VertOrientation::LINE_CENTER;break;
1259 case text::VertOrientation::LINE_BOTTOM: nRet = text::VertOrientation::LINE_BOTTOM;break;
1260 default: break;
1262 rVal <<= nRet;
1264 break;
1265 case MID_VERTORIENT_RELATION:
1266 rVal <<= lcl_RelToINT(eRelation);
1267 break;
1268 case MID_VERTORIENT_POSITION:
1269 rVal <<= (sal_Int32)TWIP_TO_MM100(GetPos());
1270 break;
1271 default:
1272 ASSERT( !this, "unknown MemberId" );
1273 bRet = sal_False;
1275 return bRet;
1278 BOOL SwFmtVertOrient::PutValue( const uno::Any& rVal, BYTE nMemberId )
1280 sal_Bool bConvert = 0 != (nMemberId&CONVERT_TWIPS);
1281 nMemberId &= ~CONVERT_TWIPS;
1282 sal_Bool bRet = sal_True;
1283 switch ( nMemberId )
1285 case MID_VERTORIENT_ORIENT:
1287 sal_uInt16 nVal = 0;
1288 rVal >>= nVal;
1289 switch( nVal )
1291 case text::VertOrientation::NONE: eOrient = text::VertOrientation::NONE; break;
1292 case text::VertOrientation::TOP : eOrient = text::VertOrientation::TOP; break;
1293 case text::VertOrientation::CENTER : eOrient = text::VertOrientation::CENTER; break;
1294 case text::VertOrientation::BOTTOM : eOrient = text::VertOrientation::BOTTOM; break;
1295 case text::VertOrientation::CHAR_TOP : eOrient = text::VertOrientation::CHAR_TOP; break;
1296 case text::VertOrientation::CHAR_CENTER: eOrient = text::VertOrientation::CHAR_CENTER;break;
1297 case text::VertOrientation::CHAR_BOTTOM: eOrient = text::VertOrientation::CHAR_BOTTOM;break;
1298 case text::VertOrientation::LINE_TOP : eOrient = text::VertOrientation::LINE_TOP; break;
1299 case text::VertOrientation::LINE_CENTER: eOrient = text::VertOrientation::LINE_CENTER;break;
1300 case text::VertOrientation::LINE_BOTTOM: eOrient = text::VertOrientation::LINE_BOTTOM;break;
1303 break;
1304 case MID_VERTORIENT_RELATION:
1306 eRelation = lcl_IntToRelation(rVal);
1308 break;
1309 case MID_VERTORIENT_POSITION:
1311 sal_Int32 nVal = 0;
1312 rVal >>= nVal;
1313 if(bConvert)
1314 nVal = MM100_TO_TWIP(nVal);
1315 SetPos( nVal );
1317 break;
1318 default:
1319 ASSERT( !this, "unknown MemberId" );
1320 bRet = sal_False;
1322 return bRet;
1327 // class SwFmtHoriOrient
1328 // Implementierung teilweise inline im hxx
1330 SwFmtHoriOrient::SwFmtHoriOrient( SwTwips nX, sal_Int16 eHori,
1331 sal_Int16 eRel, sal_Bool bPos )
1332 : SfxPoolItem( RES_HORI_ORIENT ),
1333 nXPos( nX ),
1334 eOrient( eHori ),
1335 eRelation( eRel ),
1336 bPosToggle( bPos )
1339 int SwFmtHoriOrient::operator==( const SfxPoolItem& rAttr ) const
1341 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
1342 return ( nXPos == ((SwFmtHoriOrient&)rAttr).nXPos &&
1343 eOrient == ((SwFmtHoriOrient&)rAttr).eOrient &&
1344 eRelation == ((SwFmtHoriOrient&)rAttr).eRelation &&
1345 bPosToggle == ((SwFmtHoriOrient&)rAttr).bPosToggle );
1348 SfxPoolItem* SwFmtHoriOrient::Clone( SfxItemPool* ) const
1350 return new SwFmtHoriOrient( nXPos, eOrient, eRelation, bPosToggle );
1353 BOOL SwFmtHoriOrient::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
1355 // hier wird immer konvertiert!
1356 nMemberId &= ~CONVERT_TWIPS;
1357 sal_Bool bRet = sal_True;
1358 switch ( nMemberId )
1360 case MID_HORIORIENT_ORIENT:
1362 sal_Int16 nRet = text::HoriOrientation::NONE;
1363 switch( eOrient )
1365 case text::HoriOrientation::RIGHT: nRet = text::HoriOrientation::RIGHT; break;
1366 case text::HoriOrientation::CENTER : nRet = text::HoriOrientation::CENTER; break;
1367 case text::HoriOrientation::LEFT : nRet = text::HoriOrientation::LEFT; break;
1368 case text::HoriOrientation::INSIDE : nRet = text::HoriOrientation::INSIDE; break;
1369 case text::HoriOrientation::OUTSIDE: nRet = text::HoriOrientation::OUTSIDE; break;
1370 case text::HoriOrientation::FULL: nRet = text::HoriOrientation::FULL; break;
1371 case text::HoriOrientation::LEFT_AND_WIDTH :
1372 nRet = text::HoriOrientation::LEFT_AND_WIDTH;
1373 break;
1374 default:
1375 break;
1378 rVal <<= nRet;
1380 break;
1381 case MID_HORIORIENT_RELATION:
1382 rVal <<= lcl_RelToINT(eRelation);
1383 break;
1384 case MID_HORIORIENT_POSITION:
1385 rVal <<= (sal_Int32)TWIP_TO_MM100(GetPos());
1386 break;
1387 case MID_HORIORIENT_PAGETOGGLE:
1389 BOOL bTmp = IsPosToggle();
1390 rVal.setValue(&bTmp, ::getBooleanCppuType());
1392 break;
1393 default:
1394 ASSERT( !this, "unknown MemberId" );
1395 bRet = sal_False;
1397 return bRet;
1400 BOOL SwFmtHoriOrient::PutValue( const uno::Any& rVal, BYTE nMemberId )
1402 sal_Bool bConvert = 0 != (nMemberId&CONVERT_TWIPS);
1403 nMemberId &= ~CONVERT_TWIPS;
1404 sal_Bool bRet = sal_True;
1405 switch ( nMemberId )
1407 case MID_HORIORIENT_ORIENT:
1409 sal_Int16 nVal = 0;
1410 rVal >>= nVal;
1411 switch( nVal )
1413 case text::HoriOrientation::NONE: eOrient = text::HoriOrientation::NONE ; break;
1414 case text::HoriOrientation::RIGHT: eOrient = text::HoriOrientation::RIGHT; break;
1415 case text::HoriOrientation::CENTER : eOrient = text::HoriOrientation::CENTER; break;
1416 case text::HoriOrientation::LEFT : eOrient = text::HoriOrientation::LEFT; break;
1417 case text::HoriOrientation::INSIDE : eOrient = text::HoriOrientation::INSIDE; break;
1418 case text::HoriOrientation::OUTSIDE: eOrient = text::HoriOrientation::OUTSIDE; break;
1419 case text::HoriOrientation::FULL: eOrient = text::HoriOrientation::FULL; break;
1420 case text::HoriOrientation::LEFT_AND_WIDTH:
1421 eOrient = text::HoriOrientation::LEFT_AND_WIDTH;
1422 break;
1425 break;
1426 case MID_HORIORIENT_RELATION:
1428 eRelation = lcl_IntToRelation(rVal);
1430 break;
1431 case MID_HORIORIENT_POSITION:
1433 sal_Int32 nVal = 0;
1434 if(!(rVal >>= nVal))
1435 bRet = sal_False;
1436 if(bConvert)
1437 nVal = MM100_TO_TWIP(nVal);
1438 SetPos( nVal );
1440 break;
1441 case MID_HORIORIENT_PAGETOGGLE:
1442 SetPosToggle( *(sal_Bool*)rVal.getValue());
1443 break;
1444 default:
1445 ASSERT( !this, "unknown MemberId" );
1446 bRet = sal_False;
1448 return bRet;
1453 // class SwFmtAnchor
1454 // Implementierung teilweise inline im hxx
1456 SwFmtAnchor::SwFmtAnchor( RndStdIds nRnd, sal_uInt16 nPage )
1457 : SfxPoolItem( RES_ANCHOR ),
1458 pCntntAnchor( 0 ),
1459 nAnchorId( nRnd ),
1460 nPageNum( nPage ),
1461 // OD 2004-05-05 #i28701# - get always new increased order number
1462 mnOrder( ++mnOrderCounter )
1465 SwFmtAnchor::SwFmtAnchor( const SwFmtAnchor &rCpy )
1466 : SfxPoolItem( RES_ANCHOR ),
1467 nAnchorId( rCpy.GetAnchorId() ),
1468 nPageNum( rCpy.GetPageNum() ),
1469 // OD 2004-05-05 #i28701# - get always new increased order number
1470 mnOrder( ++mnOrderCounter )
1472 pCntntAnchor = rCpy.GetCntntAnchor() ?
1473 new SwPosition( *rCpy.GetCntntAnchor() ) : 0;
1476 SwFmtAnchor::~SwFmtAnchor()
1478 delete pCntntAnchor;
1481 void SwFmtAnchor::SetAnchor( const SwPosition *pPos )
1483 if ( pCntntAnchor )
1484 delete pCntntAnchor;
1485 pCntntAnchor = pPos ? new SwPosition( *pPos ) : 0;
1486 //AM Absatz gebundene Flys sollten nie in den Absatz hineinzeigen.
1487 if ( pCntntAnchor && ( FLY_AT_CNTNT == nAnchorId ||
1488 FLY_AT_FLY == nAnchorId ))
1489 pCntntAnchor->nContent.Assign( 0, 0 );
1492 SwFmtAnchor& SwFmtAnchor::operator=(const SwFmtAnchor& rAnchor)
1494 nAnchorId = rAnchor.GetAnchorId();
1495 nPageNum = rAnchor.GetPageNum();
1496 // OD 2004-05-05 #i28701# - get always new increased order number
1497 mnOrder = ++mnOrderCounter;
1499 delete pCntntAnchor;
1500 pCntntAnchor = rAnchor.pCntntAnchor ?
1501 new SwPosition(*(rAnchor.pCntntAnchor)) : 0;
1502 return *this;
1505 int SwFmtAnchor::operator==( const SfxPoolItem& rAttr ) const
1507 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
1508 // OD 2004-05-05 #i28701# - Note: <mnOrder> hasn't to be considered.
1509 return ( nAnchorId == ((SwFmtAnchor&)rAttr).GetAnchorId() &&
1510 nPageNum == ((SwFmtAnchor&)rAttr).GetPageNum() &&
1511 //Anker vergleichen. Entweder zeigen beide auf das gleiche
1512 //Attribut bzw. sind 0 oder die SwPosition* sind beide
1513 //gueltig und die SwPositions sind gleich.
1514 (pCntntAnchor == ((SwFmtAnchor&)rAttr).GetCntntAnchor() ||
1515 (pCntntAnchor && ((SwFmtAnchor&)rAttr).GetCntntAnchor() &&
1516 *pCntntAnchor == *((SwFmtAnchor&)rAttr).GetCntntAnchor())));
1519 SfxPoolItem* SwFmtAnchor::Clone( SfxItemPool* ) const
1521 return new SwFmtAnchor( *this );
1524 // OD 2004-05-05 #i28701#
1525 sal_uInt32 SwFmtAnchor::mnOrderCounter = 0;
1527 // OD 2004-05-05 #i28701#
1528 sal_uInt32 SwFmtAnchor::GetOrder() const
1530 return mnOrder;
1533 /*-----------------16.02.98 15:21-------------------
1535 --------------------------------------------------*/
1536 BOOL SwFmtAnchor::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
1538 // hier wird immer konvertiert!
1539 nMemberId &= ~CONVERT_TWIPS;
1540 sal_Bool bRet = sal_True;
1541 switch ( nMemberId )
1543 case MID_ANCHOR_ANCHORTYPE:
1545 text::TextContentAnchorType eRet;
1546 switch((sal_Int16)GetAnchorId())
1548 case FLY_AUTO_CNTNT : eRet = text::TextContentAnchorType_AT_CHARACTER;break;
1549 case FLY_PAGE : eRet = text::TextContentAnchorType_AT_PAGE; break;
1550 case FLY_AT_FLY : eRet = text::TextContentAnchorType_AT_FRAME; break;
1551 case FLY_IN_CNTNT : eRet = text::TextContentAnchorType_AS_CHARACTER;break;
1552 //case FLY_AT_CNTNT :
1553 default: eRet = text::TextContentAnchorType_AT_PARAGRAPH;
1555 rVal <<= eRet;
1556 break;
1557 case MID_ANCHOR_PAGENUM:
1558 rVal <<= (sal_Int16)GetPageNum();
1559 break;
1560 case MID_ANCHOR_ANCHORFRAME:
1562 if(pCntntAnchor && FLY_AT_FLY == nAnchorId)
1564 SwFrmFmt* pFmt = pCntntAnchor->nNode.GetNode().GetFlyFmt();
1565 if(pFmt)
1567 uno::Reference<container::XNamed> xNamed = SwXFrames::GetObject( *pFmt, FLYCNTTYPE_FRM );
1568 uno::Reference<text::XTextFrame> xRet(xNamed, uno::UNO_QUERY);
1569 rVal <<= xRet;
1573 break;
1574 default:
1575 ASSERT( !this, "unknown MemberId" );
1576 bRet = sal_False;
1578 return bRet;
1581 BOOL SwFmtAnchor::PutValue( const uno::Any& rVal, BYTE nMemberId )
1583 // hier wird immer konvertiert!
1584 nMemberId &= ~CONVERT_TWIPS;
1585 sal_Bool bRet = sal_True;
1586 switch ( nMemberId )
1588 case MID_ANCHOR_ANCHORTYPE:
1590 RndStdIds eAnchor;
1591 switch( SWUnoHelper::GetEnumAsInt32( rVal ) )
1593 case text::TextContentAnchorType_AS_CHARACTER:
1594 eAnchor = FLY_IN_CNTNT;
1595 break;
1596 case text::TextContentAnchorType_AT_PAGE:
1597 eAnchor = FLY_PAGE;
1598 if( GetPageNum() > 0 && pCntntAnchor )
1600 // If the anchor type is page and a valid page number
1601 // has been set, the content position isn't required
1602 // any longer.
1603 delete pCntntAnchor;
1604 pCntntAnchor = 0;
1606 break;
1607 case text::TextContentAnchorType_AT_FRAME:
1608 eAnchor = FLY_AT_FLY;
1609 break;
1610 case text::TextContentAnchorType_AT_CHARACTER:
1611 eAnchor = FLY_AUTO_CNTNT;
1612 break;
1613 //case text::TextContentAnchorType_AT_PARAGRAPH:
1614 default:
1615 eAnchor = FLY_AT_CNTNT;
1616 break;
1618 SetType( eAnchor );
1620 break;
1621 case MID_ANCHOR_PAGENUM:
1623 sal_Int16 nVal = 0;
1624 if((rVal >>= nVal) && nVal > 0)
1626 SetPageNum( nVal );
1627 if( FLY_PAGE == GetAnchorId() && pCntntAnchor )
1629 // If the anchor type is page and a valid page number
1630 // is set, the content paoition has to be deleted to not
1631 // confuse the layout (frmtool.cxx). However, if the
1632 // anchor type is not page, any content position will
1633 // be kept.
1634 delete pCntntAnchor;
1635 pCntntAnchor = 0;
1638 else
1639 bRet = sal_False;
1641 break;
1642 case MID_ANCHOR_ANCHORFRAME:
1643 //no break here!;
1644 default:
1645 ASSERT( !this, "unknown MemberId" );
1646 bRet = sal_False;
1648 return bRet;
1651 // class SwFmtURL
1652 // Implementierung teilweise inline im hxx
1654 SwFmtURL::SwFmtURL() :
1655 SfxPoolItem( RES_URL ),
1656 pMap( 0 ),
1657 bIsServerMap( sal_False )
1661 SwFmtURL::SwFmtURL( const SwFmtURL &rURL) :
1662 SfxPoolItem( RES_URL ),
1663 sTargetFrameName( rURL.GetTargetFrameName() ),
1664 sURL( rURL.GetURL() ),
1665 sName( rURL.GetName() ),
1666 bIsServerMap( rURL.IsServerMap() )
1668 pMap = rURL.GetMap() ? new ImageMap( *rURL.GetMap() ) : 0;
1671 SwFmtURL::~SwFmtURL()
1673 if ( pMap )
1674 delete pMap;
1677 int SwFmtURL::operator==( const SfxPoolItem &rAttr ) const
1679 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
1680 const SwFmtURL &rCmp = (SwFmtURL&)rAttr;
1681 sal_Bool bRet = bIsServerMap == rCmp.IsServerMap() &&
1682 sURL == rCmp.GetURL() &&
1683 sTargetFrameName == rCmp.GetTargetFrameName() &&
1684 sName == rCmp.GetName();
1685 if ( bRet )
1687 if ( pMap && rCmp.GetMap() )
1688 bRet = *pMap == *rCmp.GetMap();
1689 else
1690 bRet = pMap == rCmp.GetMap();
1692 return bRet;
1695 SfxPoolItem* SwFmtURL::Clone( SfxItemPool* ) const
1697 return new SwFmtURL( *this );
1700 void SwFmtURL::SetURL( const XubString &rURL, sal_Bool bServerMap )
1702 sURL = rURL;
1703 bIsServerMap = bServerMap;
1706 void SwFmtURL::SetMap( const ImageMap *pM )
1708 if ( pMap )
1709 delete pMap;
1710 pMap = pM ? new ImageMap( *pM ) : 0;
1712 extern const SvEventDescription* lcl_GetSupportedMacroItems();
1714 BOOL SwFmtURL::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
1716 // hier wird immer konvertiert!
1717 nMemberId &= ~CONVERT_TWIPS;
1718 sal_Bool bRet = sal_True;
1719 switch ( nMemberId )
1721 case MID_URL_URL:
1723 OUString sRet = GetURL();
1724 rVal <<= sRet;
1726 break;
1727 case MID_URL_TARGET:
1729 OUString sRet = GetTargetFrameName();
1730 rVal <<= sRet;
1732 break;
1733 case MID_URL_HYPERLINKNAME:
1734 rVal <<= OUString( GetName() );
1735 break;
1736 case MID_URL_CLIENTMAP:
1738 uno::Reference< uno::XInterface > xInt;
1739 if(pMap)
1741 xInt = SvUnoImageMap_createInstance( *pMap, lcl_GetSupportedMacroItems() );
1743 else
1745 ImageMap aEmptyMap;
1746 xInt = SvUnoImageMap_createInstance( aEmptyMap, lcl_GetSupportedMacroItems() );
1748 uno::Reference< container::XIndexContainer > xCont(xInt, uno::UNO_QUERY);
1749 rVal <<= xCont;
1751 break;
1752 case MID_URL_SERVERMAP:
1754 BOOL bTmp = IsServerMap();
1755 rVal.setValue(&bTmp, ::getBooleanCppuType());
1757 break;
1758 default:
1759 ASSERT( !this, "unknown MemberId" );
1760 bRet = sal_False;
1762 return bRet;
1765 BOOL SwFmtURL::PutValue( const uno::Any& rVal, BYTE nMemberId )
1767 // hier wird immer konvertiert!
1768 nMemberId &= ~CONVERT_TWIPS;
1769 sal_Bool bRet = sal_True;
1770 switch ( nMemberId )
1772 case MID_URL_URL:
1774 OUString sTmp;
1775 rVal >>= sTmp;
1776 SetURL( sTmp, bIsServerMap );
1778 break;
1779 case MID_URL_TARGET:
1781 OUString sTmp;
1782 rVal >>= sTmp;
1783 SetTargetFrameName( sTmp );
1785 break;
1786 case MID_URL_HYPERLINKNAME:
1788 OUString sTmp;
1789 rVal >>= sTmp;
1790 SetName( sTmp );
1792 break;
1793 case MID_URL_CLIENTMAP:
1795 uno::Reference<container::XIndexContainer> xCont;
1796 if(!rVal.hasValue())
1797 DELETEZ(pMap);
1798 else if(rVal >>= xCont)
1800 if(!pMap)
1801 pMap = new ImageMap;
1802 bRet = SvUnoImageMap_fillImageMap( xCont, *pMap );
1804 else
1805 bRet = FALSE;
1807 break;
1808 case MID_URL_SERVERMAP:
1809 bIsServerMap = *(sal_Bool*)rVal.getValue();
1810 break;
1811 default:
1812 ASSERT( !this, "unknown MemberId" );
1813 bRet = sal_False;
1815 return bRet;
1819 // class SwNoReadOnly
1821 SfxPoolItem* SwFmtEditInReadonly::Clone( SfxItemPool* ) const
1823 return new SwFmtEditInReadonly( Which(), GetValue() );
1826 // class SwFmtLayoutSplit
1828 SfxPoolItem* SwFmtLayoutSplit::Clone( SfxItemPool* ) const
1830 return new SwFmtLayoutSplit( GetValue() );
1833 // class SwFmtRowSplit
1835 SfxPoolItem* SwFmtRowSplit::Clone( SfxItemPool* ) const
1837 return new SwFmtRowSplit( GetValue() );
1841 // class SwFmtNoBalancedColumns
1843 SfxPoolItem* SwFmtNoBalancedColumns::Clone( SfxItemPool* ) const
1845 return new SwFmtNoBalancedColumns( GetValue() );
1848 // class SwFmtFtnEndAtTxtEnd
1850 sal_uInt16 SwFmtFtnEndAtTxtEnd::GetValueCount() const
1852 return sal_uInt16( FTNEND_ATTXTEND_END );
1855 SwFmtFtnEndAtTxtEnd& SwFmtFtnEndAtTxtEnd::operator=(
1856 const SwFmtFtnEndAtTxtEnd& rAttr )
1858 SfxEnumItem::SetValue( rAttr.GetValue() );
1859 aFmt = rAttr.aFmt;
1860 nOffset = rAttr.nOffset;
1861 sPrefix = rAttr.sPrefix;
1862 sSuffix = rAttr.sSuffix;
1863 return *this;
1866 int SwFmtFtnEndAtTxtEnd::operator==( const SfxPoolItem& rItem ) const
1868 const SwFmtFtnEndAtTxtEnd& rAttr = (SwFmtFtnEndAtTxtEnd&)rItem;
1869 return SfxEnumItem::operator==( rAttr ) &&
1870 aFmt.GetNumberingType() == rAttr.aFmt.GetNumberingType() &&
1871 nOffset == rAttr.nOffset &&
1872 sPrefix == rAttr.sPrefix &&
1873 sSuffix == rAttr.sSuffix;
1876 BOOL SwFmtFtnEndAtTxtEnd::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
1878 nMemberId &= ~CONVERT_TWIPS;
1879 switch(nMemberId)
1881 case MID_COLLECT :
1883 sal_Bool bVal = GetValue() >= FTNEND_ATTXTEND;
1884 rVal.setValue(&bVal, ::getBooleanCppuType());
1886 break;
1887 case MID_RESTART_NUM :
1889 sal_Bool bVal = GetValue() >= FTNEND_ATTXTEND_OWNNUMSEQ;
1890 rVal.setValue(&bVal, ::getBooleanCppuType());
1892 break;
1893 case MID_NUM_START_AT: rVal <<= (sal_Int16) nOffset; break;
1894 case MID_OWN_NUM :
1896 sal_Bool bVal = GetValue() >= FTNEND_ATTXTEND_OWNNUMANDFMT;
1897 rVal.setValue(&bVal, ::getBooleanCppuType());
1899 break;
1900 case MID_NUM_TYPE : rVal <<= aFmt.GetNumberingType(); break;
1901 case MID_PREFIX : rVal <<= OUString(sPrefix); break;
1902 case MID_SUFFIX : rVal <<= OUString(sSuffix); break;
1903 default: return FALSE;
1905 return TRUE;
1908 BOOL SwFmtFtnEndAtTxtEnd::PutValue( const uno::Any& rVal, BYTE nMemberId )
1910 BOOL bRet = TRUE;
1911 nMemberId &= ~CONVERT_TWIPS;
1912 switch(nMemberId)
1914 case MID_COLLECT :
1916 sal_Bool bVal = *(sal_Bool*)rVal.getValue();
1917 if(!bVal && GetValue() >= FTNEND_ATTXTEND)
1918 SetValue(FTNEND_ATPGORDOCEND);
1919 else if(bVal && GetValue() < FTNEND_ATTXTEND)
1920 SetValue(FTNEND_ATTXTEND);
1922 break;
1923 case MID_RESTART_NUM :
1925 sal_Bool bVal = *(sal_Bool*)rVal.getValue();
1926 if(!bVal && GetValue() >= FTNEND_ATTXTEND_OWNNUMSEQ)
1927 SetValue(FTNEND_ATTXTEND);
1928 else if(bVal && GetValue() < FTNEND_ATTXTEND_OWNNUMSEQ)
1929 SetValue(FTNEND_ATTXTEND_OWNNUMSEQ);
1931 break;
1932 case MID_NUM_START_AT:
1934 sal_Int16 nVal = 0;
1935 rVal >>= nVal;
1936 if(nVal >= 0)
1937 nOffset = nVal;
1938 else
1939 bRet = FALSE;
1941 break;
1942 case MID_OWN_NUM :
1944 sal_Bool bVal = *(sal_Bool*)rVal.getValue();
1945 if(!bVal && GetValue() >= FTNEND_ATTXTEND_OWNNUMANDFMT)
1946 SetValue(FTNEND_ATTXTEND_OWNNUMSEQ);
1947 else if(bVal && GetValue() < FTNEND_ATTXTEND_OWNNUMANDFMT)
1948 SetValue(FTNEND_ATTXTEND_OWNNUMANDFMT);
1950 break;
1951 case MID_NUM_TYPE :
1953 sal_Int16 nVal = 0;
1954 rVal >>= nVal;
1955 if(nVal >= 0 &&
1956 (nVal <= SVX_NUM_ARABIC ||
1957 SVX_NUM_CHARS_UPPER_LETTER_N == nVal ||
1958 SVX_NUM_CHARS_LOWER_LETTER_N == nVal ))
1959 aFmt.SetNumberingType(nVal);
1960 else
1961 bRet = FALSE;
1963 break;
1964 case MID_PREFIX :
1966 OUString sVal; rVal >>= sVal;
1967 sPrefix = sVal;
1969 break;
1970 case MID_SUFFIX :
1972 OUString sVal; rVal >>= sVal;
1973 sSuffix = sVal;
1975 break;
1976 default: bRet = FALSE;
1978 return bRet;
1982 // class SwFmtFtnAtTxtEnd
1984 SfxPoolItem* SwFmtFtnAtTxtEnd::Clone( SfxItemPool* ) const
1986 SwFmtFtnAtTxtEnd* pNew = new SwFmtFtnAtTxtEnd;
1987 *pNew = *this;
1988 return pNew;
1991 // class SwFmtEndAtTxtEnd
1993 SfxPoolItem* SwFmtEndAtTxtEnd::Clone( SfxItemPool* ) const
1995 SwFmtEndAtTxtEnd* pNew = new SwFmtEndAtTxtEnd;
1996 *pNew = *this;
1997 return pNew;
2000 //class SwFmtChain
2003 int SwFmtChain::operator==( const SfxPoolItem &rAttr ) const
2005 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
2007 return GetPrev() == ((SwFmtChain&)rAttr).GetPrev() &&
2008 GetNext() == ((SwFmtChain&)rAttr).GetNext();
2011 SwFmtChain::SwFmtChain( const SwFmtChain &rCpy ) :
2012 SfxPoolItem( RES_CHAIN )
2014 SetPrev( rCpy.GetPrev() );
2015 SetNext( rCpy.GetNext() );
2018 SfxPoolItem* SwFmtChain::Clone( SfxItemPool* ) const
2020 SwFmtChain *pRet = new SwFmtChain;
2021 pRet->SetPrev( GetPrev() );
2022 pRet->SetNext( GetNext() );
2023 return pRet;
2026 void SwFmtChain::SetPrev( SwFlyFrmFmt *pFmt )
2028 if ( pFmt )
2029 pFmt->Add( &aPrev );
2030 else if ( aPrev.GetRegisteredIn() )
2031 ((SwModify*)aPrev.GetRegisteredIn())->Remove( &aPrev );
2034 void SwFmtChain::SetNext( SwFlyFrmFmt *pFmt )
2036 if ( pFmt )
2037 pFmt->Add( &aNext );
2038 else if ( aNext.GetRegisteredIn() )
2039 ((SwModify*)aNext.GetRegisteredIn())->Remove( &aNext );
2042 BOOL SwFmtChain::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
2044 // hier wird immer konvertiert!
2045 nMemberId &= ~CONVERT_TWIPS;
2046 sal_Bool bRet = sal_True;
2047 XubString aRet;
2048 switch ( nMemberId )
2050 case MID_CHAIN_PREVNAME:
2051 if ( GetPrev() )
2052 aRet = GetPrev()->GetName();
2053 break;
2054 case MID_CHAIN_NEXTNAME:
2055 if ( GetNext() )
2056 aRet = GetNext()->GetName();
2057 break;
2058 default:
2059 ASSERT( !this, "unknown MemberId" );
2060 bRet = sal_False;
2062 rVal <<= OUString(aRet);
2063 return bRet;
2069 //class SwFmtLineNumber
2071 SwFmtLineNumber::SwFmtLineNumber() :
2072 SfxPoolItem( RES_LINENUMBER )
2074 nStartValue = 0;
2075 bCountLines = sal_True;
2078 SwFmtLineNumber::~SwFmtLineNumber()
2082 int SwFmtLineNumber::operator==( const SfxPoolItem &rAttr ) const
2084 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
2086 return nStartValue == ((SwFmtLineNumber&)rAttr).GetStartValue() &&
2087 bCountLines == ((SwFmtLineNumber&)rAttr).IsCount();
2090 SfxPoolItem* SwFmtLineNumber::Clone( SfxItemPool* ) const
2092 return new SwFmtLineNumber( *this );
2095 BOOL SwFmtLineNumber::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
2097 // hier wird immer konvertiert!
2098 nMemberId &= ~CONVERT_TWIPS;
2099 sal_Bool bRet = sal_True;
2100 switch ( nMemberId )
2102 case MID_LINENUMBER_COUNT:
2104 BOOL bTmp = IsCount();
2105 rVal.setValue(&bTmp, ::getBooleanCppuType());
2107 break;
2108 case MID_LINENUMBER_STARTVALUE:
2109 rVal <<= (sal_Int32)GetStartValue();
2110 break;
2111 default:
2112 ASSERT( !this, "unknown MemberId" );
2113 bRet = sal_False;
2115 return bRet;
2118 BOOL SwFmtLineNumber::PutValue( const uno::Any& rVal, BYTE nMemberId )
2120 // hier wird immer konvertiert!
2121 nMemberId &= ~CONVERT_TWIPS;
2122 sal_Bool bRet = sal_True;
2123 switch ( nMemberId )
2125 case MID_LINENUMBER_COUNT:
2126 SetCountLines( *(sal_Bool*)rVal.getValue() );
2127 break;
2128 case MID_LINENUMBER_STARTVALUE:
2130 sal_Int32 nVal = 0;
2131 if(rVal >>= nVal)
2132 SetStartValue( nVal );
2133 else
2134 bRet = sal_False;
2136 break;
2137 default:
2138 ASSERT( !this, "unknown MemberId" );
2139 bRet = sal_False;
2141 return bRet;
2144 /*************************************************************************
2145 * class SwTextGridItem
2146 *************************************************************************/
2148 SwTextGridItem::SwTextGridItem()
2149 : SfxPoolItem( RES_TEXTGRID ), aColor( COL_LIGHTGRAY ), nLines( 20 ),
2150 nBaseHeight( 400 ), nRubyHeight( 200 ), eGridType( GRID_NONE ),
2151 bRubyTextBelow( 0 ), bPrintGrid( 1 ), bDisplayGrid( 1 ),
2152 nBaseWidth(400), bSnapToChars( 1 ), bSquaredMode(1)
2156 SwTextGridItem::~SwTextGridItem()
2160 int SwTextGridItem::operator==( const SfxPoolItem& rAttr ) const
2162 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
2163 return eGridType == ((SwTextGridItem&)rAttr).GetGridType() &&
2164 nLines == ((SwTextGridItem&)rAttr).GetLines() &&
2165 nBaseHeight == ((SwTextGridItem&)rAttr).GetBaseHeight() &&
2166 nRubyHeight == ((SwTextGridItem&)rAttr).GetRubyHeight() &&
2167 bRubyTextBelow == ((SwTextGridItem&)rAttr).GetRubyTextBelow() &&
2168 bDisplayGrid == ((SwTextGridItem&)rAttr).GetDisplayGrid() &&
2169 bPrintGrid == ((SwTextGridItem&)rAttr).GetPrintGrid() &&
2170 aColor == ((SwTextGridItem&)rAttr).GetColor() &&
2171 nBaseWidth == ((SwTextGridItem&)rAttr).GetBaseWidth() &&
2172 bSnapToChars == ((SwTextGridItem&)rAttr).GetSnapToChars() &&
2173 bSquaredMode == ((SwTextGridItem&)rAttr).GetSquaredMode();
2176 SfxPoolItem* SwTextGridItem::Clone( SfxItemPool* ) const
2178 return new SwTextGridItem( *this );
2181 SwTextGridItem& SwTextGridItem::operator=( const SwTextGridItem& rCpy )
2183 aColor = rCpy.GetColor();
2184 nLines = rCpy.GetLines();
2185 nBaseHeight = rCpy.GetBaseHeight();
2186 nRubyHeight = rCpy.GetRubyHeight();
2187 eGridType = rCpy.GetGridType();
2188 bRubyTextBelow = rCpy.GetRubyTextBelow();
2189 bPrintGrid = rCpy.GetPrintGrid();
2190 bDisplayGrid = rCpy.GetDisplayGrid();
2191 nBaseWidth = rCpy.GetBaseWidth();
2192 bSnapToChars = rCpy.GetSnapToChars();
2193 bSquaredMode = rCpy.GetSquaredMode();
2195 return *this;
2198 BOOL SwTextGridItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
2200 BOOL bRet = TRUE;
2202 switch( nMemberId & ~CONVERT_TWIPS )
2204 case MID_GRID_COLOR:
2205 rVal <<= GetColor().GetColor();
2206 break;
2207 case MID_GRID_LINES:
2208 rVal <<= GetLines();
2209 break;
2210 case MID_GRID_RUBY_BELOW:
2211 rVal.setValue( &bRubyTextBelow, ::getBooleanCppuType() );
2212 break;
2213 case MID_GRID_PRINT:
2214 rVal.setValue( &bPrintGrid, ::getBooleanCppuType() );
2215 break;
2216 case MID_GRID_DISPLAY:
2217 rVal.setValue( &bDisplayGrid, ::getBooleanCppuType() );
2218 break;
2219 case MID_GRID_BASEHEIGHT:
2220 DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2221 "This value needs TWIPS-MM100 conversion" );
2222 rVal <<= (sal_Int32) TWIP_TO_MM100_UNSIGNED(nBaseHeight);
2223 break;
2224 case MID_GRID_BASEWIDTH:
2225 DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2226 "This value needs TWIPS-MM100 conversion" );
2227 rVal <<= (sal_Int32) TWIP_TO_MM100_UNSIGNED(nBaseWidth);
2228 break;
2229 case MID_GRID_RUBYHEIGHT:
2230 DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2231 "This value needs TWIPS-MM100 conversion" );
2232 rVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(nRubyHeight);
2233 break;
2234 case MID_GRID_TYPE:
2235 switch( GetGridType() )
2237 case GRID_NONE:
2238 rVal <<= text::TextGridMode::NONE;
2239 break;
2240 case GRID_LINES_ONLY:
2241 rVal <<= text::TextGridMode::LINES;
2242 break;
2243 case GRID_LINES_CHARS:
2244 rVal <<= text::TextGridMode::LINES_AND_CHARS;
2245 break;
2246 default:
2247 DBG_ERROR("unknown SwTextGrid value");
2248 bRet = FALSE;
2249 break;
2251 break;
2252 case MID_GRID_SNAPTOCHARS:
2253 rVal.setValue( &bSnapToChars, ::getBooleanCppuType() );
2254 break;
2255 case MID_GRID_STANDARD_MODE:
2257 sal_Bool bStandardMode = !bSquaredMode;
2258 rVal.setValue( &bStandardMode, ::getBooleanCppuType() );
2260 break;
2261 default:
2262 DBG_ERROR("Unknown SwTextGridItem member");
2263 bRet = FALSE;
2264 break;
2267 return bRet;
2270 BOOL SwTextGridItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
2272 BOOL bRet = TRUE;
2273 switch( nMemberId & ~CONVERT_TWIPS )
2275 case MID_GRID_COLOR:
2277 sal_Int32 nTmp = 0;
2278 bRet = (rVal >>= nTmp);
2279 if( bRet )
2280 SetColor( Color(nTmp) );
2282 break;
2283 case MID_GRID_LINES:
2285 sal_Int16 nTmp = 0;
2286 bRet = (rVal >>= nTmp);
2287 if( bRet && (nTmp >= 0) )
2288 SetLines( (sal_uInt16)nTmp );
2289 else
2290 bRet = FALSE;
2292 break;
2293 case MID_GRID_RUBY_BELOW:
2294 SetRubyTextBelow( *(sal_Bool*)rVal.getValue() );
2295 break;
2296 case MID_GRID_PRINT:
2297 SetPrintGrid( *(sal_Bool*)rVal.getValue() );
2298 break;
2299 case MID_GRID_DISPLAY:
2300 SetDisplayGrid( *(sal_Bool*)rVal.getValue() );
2301 break;
2302 case MID_GRID_BASEHEIGHT:
2303 case MID_GRID_BASEWIDTH:
2304 case MID_GRID_RUBYHEIGHT:
2306 DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2307 "This value needs TWIPS-MM100 conversion" );
2308 sal_Int32 nTmp = 0;
2309 bRet = (rVal >>= nTmp);
2310 nTmp = MM100_TO_TWIP( nTmp );
2311 if( bRet && (nTmp >= 0) && ( nTmp <= USHRT_MAX) )
2312 if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEHEIGHT )
2313 SetBaseHeight( (USHORT)nTmp );
2314 else if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEWIDTH )
2315 SetBaseWidth( (USHORT)nTmp );
2316 else
2317 SetRubyHeight( (USHORT)nTmp );
2318 else
2319 bRet = FALSE;
2321 break;
2322 case MID_GRID_TYPE:
2324 sal_Int16 nTmp = 0;
2325 bRet = (rVal >>= nTmp);
2326 if( bRet )
2328 switch( nTmp )
2330 case text::TextGridMode::NONE:
2331 SetGridType( GRID_NONE );
2332 break;
2333 case text::TextGridMode::LINES:
2334 SetGridType( GRID_LINES_ONLY );
2335 break;
2336 case text::TextGridMode::LINES_AND_CHARS:
2337 SetGridType( GRID_LINES_CHARS );
2338 break;
2339 default:
2340 bRet = FALSE;
2341 break;
2344 break;
2346 case MID_GRID_SNAPTOCHARS:
2347 SetSnapToChars( *(sal_Bool*)rVal.getValue() );
2348 break;
2349 case MID_GRID_STANDARD_MODE:
2351 sal_Bool bStandard = *(sal_Bool*)rVal.getValue();
2352 SetSquaredMode( !bStandard );
2353 break;
2355 default:
2356 DBG_ERROR("Unknown SwTextGridItem member");
2357 bRet = FALSE;
2360 return bRet;
2363 void SwTextGridItem::SwitchPaperMode(BOOL bNew)
2365 if( bNew == bSquaredMode )
2367 //same paper mode, not switch
2368 return;
2371 // use default value when grid is disable
2372 if( eGridType == GRID_NONE )
2374 bSquaredMode = bNew;
2375 Init();
2376 return;
2379 if( bSquaredMode )
2381 //switch from "squared mode" to "standard mode"
2382 nBaseWidth = nBaseHeight;
2383 nBaseHeight = nBaseHeight + nRubyHeight;
2384 nRubyHeight = 0;
2386 else
2388 //switch from "standard mode" to "squared mode"
2389 nRubyHeight = nBaseHeight/3;
2390 nBaseHeight = nBaseHeight - nRubyHeight;
2391 nBaseWidth = nBaseHeight;
2393 bSquaredMode = !bSquaredMode;
2396 void SwTextGridItem::Init()
2398 if( bSquaredMode )
2400 nLines = 20;
2401 nBaseHeight = 400;
2402 nRubyHeight = 200;
2403 eGridType = GRID_NONE;
2404 bRubyTextBelow = 0;
2405 bPrintGrid = 1;
2406 bDisplayGrid = 1;
2407 bSnapToChars = 1;
2408 nBaseWidth = 400;
2410 else
2412 nLines = 44;
2413 nBaseHeight = 312;
2414 nRubyHeight = 0;
2415 eGridType = GRID_NONE;
2416 bRubyTextBelow = 0;
2417 bPrintGrid = 1;
2418 bDisplayGrid = 1;
2419 nBaseWidth = 210;
2420 bSnapToChars = 1;
2422 //default grid type is line only in CJK env
2423 //disable this function due to type area change
2424 //if grid type change.
2425 //if(SvtCJKOptions().IsAsianTypographyEnabled())
2427 // bDisplayGrid = 0;
2428 // eGridType = GRID_LINES_ONLY;
2432 // class SwHeaderAndFooterEatSpacingItem
2434 SfxPoolItem* SwHeaderAndFooterEatSpacingItem::Clone( SfxItemPool* ) const
2436 return new SwHeaderAndFooterEatSpacingItem( Which(), GetValue() );
2440 // class SwFrmFmt
2441 // Implementierung teilweise inline im hxx
2443 TYPEINIT1( SwFrmFmt, SwFmt );
2444 IMPL_FIXEDMEMPOOL_NEWDEL_DLL( SwFrmFmt, 20, 20 )
2446 void SwFrmFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew )
2448 SwFmtHeader *pH = 0;
2449 SwFmtFooter *pF = 0;
2451 sal_uInt16 nWhich = pNew ? pNew->Which() : 0;
2453 if( RES_ATTRSET_CHG == nWhich )
2455 ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
2456 RES_HEADER, sal_False, (const SfxPoolItem**)&pH );
2457 ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
2458 RES_FOOTER, sal_False, (const SfxPoolItem**)&pF );
2460 else if( RES_HEADER == nWhich )
2461 pH = (SwFmtHeader*)pNew;
2462 else if( RES_FOOTER == nWhich )
2463 pF = (SwFmtFooter*)pNew;
2465 if( pH && pH->IsActive() && !pH->GetHeaderFmt() )
2466 { //Hat er keinen, mach ich ihm einen
2467 SwFrmFmt *pFmt = GetDoc()->MakeLayoutFmt( RND_STD_HEADER, 0 );
2468 pFmt->Add( pH );
2471 if( pF && pF->IsActive() && !pF->GetFooterFmt() )
2472 { //Hat er keinen, mach ich ihm einen
2473 SwFrmFmt *pFmt = GetDoc()->MakeLayoutFmt( RND_STD_FOOTER, 0 );
2474 pFmt->Add( pF );
2477 // MIB 24.3.98: Modify der Basisklasse muss immer gerufen werden, z.B.
2478 // wegen RESET_FMTWRITTEN.
2479 // if ( GetDepends() )
2480 SwFmt::Modify( pOld, pNew );
2483 //Vernichtet alle Frms, die in aDepend angemeldet sind.
2485 void SwFrmFmt::DelFrms()
2487 SwClientIter aIter( *this );
2488 SwClient * pLast = aIter.GoStart();
2489 if( pLast )
2490 do {
2491 if ( pLast->ISA(SwFrm) )
2493 ((SwFrm*)pLast)->Cut();
2494 delete pLast;
2496 } while( 0 != ( pLast = aIter++ ));
2499 void SwFrmFmt::MakeFrms()
2501 ASSERT( !this, "Sorry not implemented." );
2506 SwRect SwFrmFmt::FindLayoutRect( const sal_Bool bPrtArea, const Point* pPoint,
2507 const sal_Bool bCalcFrm ) const
2509 SwRect aRet;
2510 SwFrm *pFrm = 0;
2511 if( ISA( SwSectionFmt ) )
2513 // dann den frame::Frame per Node2Layout besorgen
2514 SwSectionNode* pSectNd = ((SwSectionFmt*)this)->GetSectionNode();
2515 if( pSectNd )
2517 SwNode2Layout aTmp( *pSectNd, pSectNd->GetIndex() - 1 );
2518 pFrm = aTmp.NextFrm();
2520 if( pFrm && pFrm->GetRegisteredIn() != this )
2522 // die Section hat keinen eigenen frame::Frame, also falls
2523 // jemand die tatsaechliche Groe?e braucht, so muss das
2524 // noch implementier werden, in dem sich vom Ende noch
2525 // der entsprechende frame::Frame besorgt wird.
2526 // PROBLEM: was passiert bei SectionFrames, die auf unter-
2527 // schiedlichen Seiten stehen??
2528 if( bPrtArea )
2529 aRet = pFrm->Prt();
2530 else
2532 aRet = pFrm->Frm();
2533 --aRet.Pos().Y();
2535 pFrm = 0; // das Rect ist ja jetzt fertig
2539 else
2541 sal_uInt16 nFrmType = RES_FLYFRMFMT == Which() ? FRM_FLY : USHRT_MAX;
2542 pFrm = ::GetFrmOfModify( *(SwModify*)this, nFrmType, pPoint,
2543 0, bCalcFrm );
2546 if( pFrm )
2548 if( bPrtArea )
2549 aRet = pFrm->Prt();
2550 else
2551 aRet = pFrm->Frm();
2553 return aRet;
2556 SwContact* SwFrmFmt::FindContactObj()
2558 SwClientIter aIter( *this );
2559 return (SwContact*)aIter.First( TYPE( SwContact ) );
2562 SdrObject* SwFrmFmt::FindSdrObject()
2564 // --> OD 2005-01-06 #i30669# - use method <FindContactObj()> instead of
2565 // duplicated code.
2566 SwContact* pFoundContact = FindContactObj();
2567 return pFoundContact ? pFoundContact->GetMaster() : 0;
2568 // <--
2571 SdrObject* SwFrmFmt::FindRealSdrObject()
2573 if( RES_FLYFRMFMT == Which() )
2575 Point aNullPt;
2576 SwFlyFrm* pFly = (SwFlyFrm*)::GetFrmOfModify( *this, FRM_FLY,
2577 &aNullPt, 0, sal_False );
2578 return pFly ? pFly->GetVirtDrawObj() : 0;
2580 return FindSdrObject();
2584 sal_Bool SwFrmFmt::IsLowerOf( const SwFrmFmt& rFmt ) const
2586 //Auch eine Verkettung von Innen nach aussen oder von aussen
2587 //nach innen ist nicht zulaessig.
2588 SwClientIter aIter( *(SwModify*)this );
2589 SwFlyFrm *pSFly = (SwFlyFrm*)aIter.First( TYPE(SwFlyFrm) );
2590 if( pSFly )
2592 SwClientIter aOtherIter( (SwModify&)rFmt );
2593 SwFlyFrm *pAskFly = (SwFlyFrm*)aOtherIter.First( TYPE(SwFlyFrm) );
2594 if( pAskFly )
2595 return pSFly->IsLowerOf( pAskFly );
2598 // dann mal ueber die Node-Positionen versuchen
2599 const SwFmtAnchor* pAnchor = &rFmt.GetAnchor();
2600 if( FLY_PAGE != pAnchor->GetAnchorId() && pAnchor->GetCntntAnchor() )
2602 const SwSpzFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts();
2603 const SwNode* pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode().
2604 FindFlyStartNode();
2605 while( pFlyNd )
2607 // dann ueber den Anker nach oben "hangeln"
2608 sal_uInt16 n;
2609 for( n = 0; n < rFmts.Count(); ++n )
2611 const SwFrmFmt* pFmt = rFmts[ n ];
2612 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2613 if( pIdx && pFlyNd == &pIdx->GetNode() )
2615 if( pFmt == this )
2616 return sal_True;
2618 pAnchor = &pFmt->GetAnchor();
2619 if( FLY_PAGE == pAnchor->GetAnchorId() ||
2620 !pAnchor->GetCntntAnchor() )
2621 return sal_False;
2623 pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode().
2624 FindFlyStartNode();
2625 break;
2628 if( n >= rFmts.Count() )
2630 ASSERT( !this, "Fly-Section aber kein Format gefunden" );
2631 return sal_False;
2635 return sal_False;
2638 // --> OD 2004-07-27 #i31698#
2639 SwFrmFmt::tLayoutDir SwFrmFmt::GetLayoutDir() const
2641 return SwFrmFmt::HORI_L2R;
2644 void SwFrmFmt::SetLayoutDir( const SwFrmFmt::tLayoutDir )
2646 // empty body, because default implementation does nothing
2648 // <--
2650 // --> OD 2004-08-06 #i28749#
2651 sal_Int16 SwFrmFmt::GetPositionLayoutDir() const
2653 return text::PositionLayoutDir::PositionInLayoutDirOfAnchor;
2655 void SwFrmFmt::SetPositionLayoutDir( const sal_Int16 )
2657 // empty body, because default implementation does nothing
2659 // <--
2660 String SwFrmFmt::GetDescription() const
2662 return SW_RES(STR_FRAME);
2665 // class SwFlyFrmFmt
2666 // Implementierung teilweise inline im hxx
2668 TYPEINIT1( SwFlyFrmFmt, SwFrmFmt );
2669 IMPL_FIXEDMEMPOOL_NEWDEL( SwFlyFrmFmt, 10, 10 )
2671 SwFlyFrmFmt::~SwFlyFrmFmt()
2673 SwClientIter aIter( *this );
2674 SwClient * pLast = aIter.GoStart();
2675 if( pLast )
2676 do {
2677 if ( pLast->ISA( SwFlyFrm ) )
2678 delete pLast;
2680 } while( 0 != ( pLast = aIter++ ));
2682 pLast = aIter.GoStart();
2683 if( pLast )
2684 do {
2685 if ( pLast->ISA( SwFlyDrawContact ) )
2686 delete pLast;
2688 } while( 0 != ( pLast = aIter++ ));
2691 //Erzeugen der Frms wenn das Format einen Absatzgebundenen Rahmen beschreibt.
2692 //MA: 14. Feb. 94, Erzeugen der Frms auch fuer Seitengebundene Rahmen.
2694 void SwFlyFrmFmt::MakeFrms()
2696 // gibts ueberhaupt ein Layout ??
2697 if( !GetDoc()->GetRootFrm() )
2698 return;
2700 SwModify *pModify = 0;
2701 // OD 24.07.2003 #111032# - create local copy of anchor attribute for possible changes.
2702 SwFmtAnchor aAnchorAttr( GetAnchor() );
2703 switch( aAnchorAttr.GetAnchorId() )
2705 case FLY_IN_CNTNT:
2706 case FLY_AT_CNTNT:
2707 case FLY_AUTO_CNTNT:
2708 if( aAnchorAttr.GetCntntAnchor() )
2709 pModify = aAnchorAttr.GetCntntAnchor()->nNode.GetNode().GetCntntNode();
2710 break;
2712 case FLY_AT_FLY:
2713 if( aAnchorAttr.GetCntntAnchor() )
2715 //Erst einmal ueber den Inhalt suchen, weil konstant schnell. Kann
2716 //Bei verketteten Rahmen aber auch schief gehen, weil dann evtl.
2717 //niemals ein frame::Frame zu dem Inhalt existiert. Dann muss leider noch
2718 //die Suche vom StartNode zum FrameFormat sein.
2719 SwNodeIndex aIdx( aAnchorAttr.GetCntntAnchor()->nNode );
2720 SwCntntNode *pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
2721 SwClientIter aIter( *pCNd );
2722 if ( aIter.First( TYPE(SwFrm) ) )
2723 pModify = pCNd;
2724 else
2726 const SwNodeIndex &rIdx = aAnchorAttr.GetCntntAnchor()->nNode;
2727 SwSpzFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts();
2728 for( sal_uInt16 i = 0; i < rFmts.Count(); ++i )
2730 SwFrmFmt* pFlyFmt = rFmts[i];
2731 if( pFlyFmt->GetCntnt().GetCntntIdx() &&
2732 rIdx == *pFlyFmt->GetCntnt().GetCntntIdx() )
2734 pModify = pFlyFmt;
2735 break;
2740 break;
2742 case FLY_PAGE:
2744 sal_uInt16 nPgNum = aAnchorAttr.GetPageNum();
2745 SwPageFrm *pPage = (SwPageFrm*)GetDoc()->GetRootFrm()->Lower();
2746 if( !nPgNum && aAnchorAttr.GetCntntAnchor() )
2748 SwCntntNode *pCNd =
2749 aAnchorAttr.GetCntntAnchor()->nNode.GetNode().GetCntntNode();
2750 SwClientIter aIter( *pCNd );
2753 if( aIter()->ISA( SwFrm ) )
2755 pPage = ((SwFrm*)aIter())->FindPageFrm();
2756 if( pPage )
2758 nPgNum = pPage->GetPhyPageNum();
2759 // OD 24.07.2003 #111032# - update anchor attribute
2760 aAnchorAttr.SetPageNum( nPgNum );
2761 aAnchorAttr.SetAnchor( 0 );
2762 SetFmtAttr( aAnchorAttr );
2764 break;
2766 } while ( aIter++ );
2768 while ( pPage )
2770 if ( pPage->GetPhyPageNum() == nPgNum )
2772 // --> OD 2005-06-09 #i50432# - adjust synopsis of <PlaceFly(..)>
2773 pPage->PlaceFly( 0, this );
2774 // <--
2775 break;
2777 pPage = (SwPageFrm*)pPage->GetNext();
2780 break;
2781 default:
2782 break;
2785 if( pModify )
2787 SwClientIter aIter( *pModify );
2788 for( SwFrm *pFrm = (SwFrm*)aIter.First( TYPE(SwFrm) );
2789 pFrm;
2790 pFrm = (SwFrm*)aIter.Next() )
2792 BOOL bAdd = !pFrm->IsCntntFrm() ||
2793 !((SwCntntFrm*)pFrm)->IsFollow();
2795 if ( FLY_AT_FLY == aAnchorAttr.GetAnchorId() && !pFrm->IsFlyFrm() )
2796 pFrm = pFrm->FindFlyFrm();
2798 if( pFrm->GetDrawObjs() )
2800 // --> OD 2004-07-01 #i28701# - new type <SwSortedObjs>
2801 SwSortedObjs &rObjs = *pFrm->GetDrawObjs();
2802 for( sal_uInt16 i = 0; i < rObjs.Count(); ++i)
2804 // --> OD 2004-07-01 #i28701# - consider changed type of
2805 // <SwSortedObjs> entries.
2806 SwAnchoredObject* pObj = rObjs[i];
2807 if( pObj->ISA(SwFlyFrm) &&
2808 (&pObj->GetFrmFmt()) == this )
2810 bAdd = sal_False;
2811 break;
2816 if( bAdd )
2818 SwFlyFrm *pFly = 0;
2819 switch( aAnchorAttr.GetAnchorId() )
2821 case FLY_AT_FLY:
2822 pFly = new SwFlyLayFrm( this, pFrm );
2823 break;
2825 case FLY_AT_CNTNT:
2826 case FLY_AUTO_CNTNT:
2827 pFly = new SwFlyAtCntFrm( this, pFrm );
2828 break;
2830 case FLY_IN_CNTNT:
2831 pFly = new SwFlyInCntFrm( this, pFrm );
2832 break;
2833 default:
2834 ASSERT( !this, "Neuer Ankertyp" )
2835 break;
2837 pFrm->AppendFly( pFly );
2838 SwPageFrm *pPage = pFly->FindPageFrm();
2839 if( pPage )
2840 ::RegistFlys( pPage, pFly );
2846 SwFlyFrm* SwFlyFrmFmt::GetFrm( const Point* pPoint, const sal_Bool bCalcFrm ) const
2848 return (SwFlyFrm*)::GetFrmOfModify( *(SwModify*)this, FRM_FLY,
2849 pPoint, 0, bCalcFrm );
2852 SwAnchoredObject* SwFlyFrmFmt::GetAnchoredObj( const Point* pPoint, const sal_Bool bCalcFrm ) const
2854 SwFlyFrm* pFlyFrm( GetFrm( pPoint, bCalcFrm ) );
2855 if ( pFlyFrm )
2857 return dynamic_cast<SwAnchoredObject*>(pFlyFrm);
2859 else
2861 return 0L;
2866 sal_Bool SwFlyFrmFmt::GetInfo( SfxPoolItem& rInfo ) const
2868 switch( rInfo.Which() )
2870 case RES_CONTENT_VISIBLE:
2872 ((SwPtrMsgPoolItem&)rInfo).pObject =
2873 SwClientIter( *(SwFlyFrmFmt*)this ).First( TYPE(SwFrm) );
2875 return sal_False;
2877 default:
2878 return SwFrmFmt::GetInfo( rInfo );
2880 return sal_True;
2883 // --> OD 2009-07-14 #i73249#
2884 void SwFlyFrmFmt::SetObjTitle( const String& rTitle, bool bBroadcast )
2886 SdrObject* pMasterObject = FindSdrObject();
2887 ASSERT( pMasterObject,
2888 "<SwNoTxtNode::SetObjTitle(..)> - missing <SdrObject> instance" );
2889 if ( !pMasterObject )
2891 return;
2894 if( bBroadcast )
2896 SwStringMsgPoolItem aOld( RES_TITLE_CHANGED, pMasterObject->GetTitle() );
2897 SwStringMsgPoolItem aNew( RES_TITLE_CHANGED, rTitle );
2898 pMasterObject->SetTitle( rTitle );
2899 Modify( &aOld, &aNew );
2901 else
2903 pMasterObject->SetTitle( rTitle );
2907 const String SwFlyFrmFmt::GetObjTitle() const
2909 const SdrObject* pMasterObject = FindSdrObject();
2910 ASSERT( pMasterObject,
2911 "<SwFlyFrmFmt::GetObjTitle(..)> - missing <SdrObject> instance" );
2912 if ( !pMasterObject )
2914 return aEmptyStr;
2917 return pMasterObject->GetTitle();
2920 void SwFlyFrmFmt::SetObjDescription( const String& rDescription, bool bBroadcast )
2922 SdrObject* pMasterObject = FindSdrObject();
2923 ASSERT( pMasterObject,
2924 "<SwFlyFrmFmt::SetDescription(..)> - missing <SdrObject> instance" );
2925 if ( !pMasterObject )
2927 return;
2930 if( bBroadcast )
2932 SwStringMsgPoolItem aOld( RES_DESCRIPTION_CHANGED, pMasterObject->GetDescription() );
2933 SwStringMsgPoolItem aNew( RES_DESCRIPTION_CHANGED, rDescription );
2934 pMasterObject->SetDescription( rDescription );
2935 Modify( &aOld, &aNew );
2937 else
2939 pMasterObject->SetDescription( rDescription );
2943 const String SwFlyFrmFmt::GetObjDescription() const
2945 const SdrObject* pMasterObject = FindSdrObject();
2946 ASSERT( pMasterObject,
2947 "<SwNoTxtNode::GetDescription(..)> - missing <SdrObject> instance" );
2948 if ( !pMasterObject )
2950 return aEmptyStr;
2953 return pMasterObject->GetDescription();
2955 // <--
2957 /** SwFlyFrmFmt::IsBackgroundTransparent - for #99657#
2959 OD 22.08.2002 - overloading virtual method and its default implementation,
2960 because format of fly frame provides transparent backgrounds.
2961 Method determines, if background of fly frame is transparent.
2963 @author OD
2965 @return true, if background color is transparent, but not "no fill"
2966 or the transparency of a existing background graphic is set.
2968 sal_Bool SwFlyFrmFmt::IsBackgroundTransparent() const
2970 sal_Bool bReturn = sal_False;
2972 /// NOTE: If background color is "no fill"/"auto fill" (COL_TRANSPARENT)
2973 /// and there is no background graphic, it "inherites" the background
2974 /// from its anchor.
2975 if ( (GetBackground().GetColor().GetTransparency() != 0) &&
2976 (GetBackground().GetColor() != COL_TRANSPARENT)
2979 bReturn = sal_True;
2981 else
2983 const GraphicObject *pTmpGrf =
2984 static_cast<const GraphicObject*>(GetBackground().GetGraphicObject());
2985 if ( (pTmpGrf) &&
2986 (pTmpGrf->GetAttr().GetTransparency() != 0)
2989 bReturn = sal_True;
2993 return bReturn;
2996 /** SwFlyFrmFmt::IsBackgroundBrushInherited - for #103898#
2998 OD 08.10.2002 - method to determine, if the brush for drawing the
2999 background is "inherited" from its parent/grandparent.
3000 This is the case, if no background graphic is set and the background
3001 color is "no fill"/"auto fill"
3002 NOTE: condition is "copied" from method <SwFrm::GetBackgroundBrush(..).
3004 @author OD
3006 @return true, if background brush is "inherited" from parent/grandparent
3008 sal_Bool SwFlyFrmFmt::IsBackgroundBrushInherited() const
3010 sal_Bool bReturn = sal_False;
3012 if ( (GetBackground().GetColor() == COL_TRANSPARENT) &&
3013 !(GetBackground().GetGraphicObject()) )
3015 bReturn = sal_True;
3018 return bReturn;
3021 // --> OD 2006-02-28 #125892#
3022 SwHandleAnchorNodeChg::SwHandleAnchorNodeChg( SwFlyFrmFmt& _rFlyFrmFmt,
3023 const SwFmtAnchor& _rNewAnchorFmt,
3024 SwFlyFrm* _pKeepThisFlyFrm )
3025 : mrFlyFrmFmt( _rFlyFrmFmt ),
3026 mbAnchorNodeChanged( false )
3028 const RndStdIds nNewAnchorType( _rNewAnchorFmt.GetAnchorId() );
3029 if ( ( nNewAnchorType == FLY_AT_CNTNT ||
3030 nNewAnchorType == FLY_AUTO_CNTNT ) &&
3031 _rNewAnchorFmt.GetCntntAnchor() &&
3032 _rNewAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode() )
3034 const SwFmtAnchor& aOldAnchorFmt( _rFlyFrmFmt.GetAnchor() );
3035 if ( aOldAnchorFmt.GetAnchorId() == nNewAnchorType &&
3036 aOldAnchorFmt.GetCntntAnchor() &&
3037 aOldAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode() &&
3038 aOldAnchorFmt.GetCntntAnchor()->nNode !=
3039 _rNewAnchorFmt.GetCntntAnchor()->nNode )
3041 // determine 'old' number of anchor frames
3042 sal_uInt32 nOldNumOfAnchFrm( 0L );
3043 SwClientIter aOldIter( *(aOldAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode()) );
3044 for( aOldIter.First( TYPE(SwFrm) ); aOldIter(); aOldIter.Next() )
3046 ++nOldNumOfAnchFrm;
3048 // determine 'new' number of anchor frames
3049 sal_uInt32 nNewNumOfAnchFrm( 0L );
3050 SwClientIter aNewIter( *(_rNewAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode()) );
3051 for( aNewIter.First( TYPE(SwFrm) ); aNewIter(); aNewIter.Next() )
3053 ++nNewNumOfAnchFrm;
3055 if ( nOldNumOfAnchFrm != nNewNumOfAnchFrm )
3057 // delete existing fly frames except <_pKeepThisFlyFrm>
3058 SwClientIter aIter( mrFlyFrmFmt );
3059 SwClient* pLast = aIter.GoStart();
3060 if ( pLast )
3062 do {
3063 SwFrm* pFrm( dynamic_cast<SwFrm*>(pLast) );
3064 if ( pFrm && pFrm != _pKeepThisFlyFrm )
3066 pFrm->Cut();
3067 delete pFrm;
3069 } while( 0 != ( pLast = aIter++ ));
3071 // indicate, that re-creation of fly frames necessary
3072 mbAnchorNodeChanged = true;
3078 SwHandleAnchorNodeChg::~SwHandleAnchorNodeChg()
3080 if ( mbAnchorNodeChanged )
3082 mrFlyFrmFmt.MakeFrms();
3085 // <--
3086 // class SwDrawFrmFmt
3087 // Implementierung teilweise inline im hxx
3089 TYPEINIT1( SwDrawFrmFmt, SwFrmFmt );
3090 IMPL_FIXEDMEMPOOL_NEWDEL( SwDrawFrmFmt, 10, 10 )
3092 SwDrawFrmFmt::~SwDrawFrmFmt()
3094 SwContact *pContact = FindContactObj();
3095 delete pContact;
3098 void SwDrawFrmFmt::MakeFrms()
3100 SwDrawContact *pContact = (SwDrawContact*)FindContactObj();
3101 if ( pContact )
3102 pContact->ConnectToLayout();
3105 void SwDrawFrmFmt::DelFrms()
3107 SwDrawContact *pContact = (SwDrawContact *)FindContactObj();
3108 if ( pContact ) //fuer den Reader und andere Unabwaegbarkeiten.
3109 pContact->DisconnectFromLayout();
3112 // --> OD 2004-07-27 #i31698#
3113 SwFrmFmt::tLayoutDir SwDrawFrmFmt::GetLayoutDir() const
3115 return meLayoutDir;
3118 void SwDrawFrmFmt::SetLayoutDir( const SwFrmFmt::tLayoutDir _eLayoutDir )
3120 meLayoutDir = _eLayoutDir;
3122 // <--
3124 // --> OD 2004-08-06 #i28749#
3125 sal_Int16 SwDrawFrmFmt::GetPositionLayoutDir() const
3127 return mnPositionLayoutDir;
3129 void SwDrawFrmFmt::SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir )
3131 switch ( _nPositionLayoutDir )
3133 case text::PositionLayoutDir::PositionInHoriL2R:
3134 case text::PositionLayoutDir::PositionInLayoutDirOfAnchor:
3136 mnPositionLayoutDir = _nPositionLayoutDir;
3138 break;
3139 default:
3141 ASSERT( false,
3142 "<SwDrawFrmFmt::SetPositionLayoutDir(..)> - invalid attribute value." );
3146 // <--
3148 String SwDrawFrmFmt::GetDescription() const
3150 String aResult;
3151 const SdrObject * pSdrObj = FindSdrObject();
3153 if (pSdrObj)
3155 if (pSdrObj != pSdrObjCached)
3157 SdrObject * pSdrObjCopy = pSdrObj->Clone();
3158 SdrUndoNewObj * pSdrUndo = new SdrUndoNewObj(*pSdrObjCopy);
3159 sSdrObjCachedComment = pSdrUndo->GetComment();
3161 delete pSdrUndo;
3163 pSdrObjCached = pSdrObj;
3166 aResult = sSdrObjCachedComment;
3168 else
3169 aResult = SW_RES(STR_GRAPHIC);
3171 return aResult;
3174 IMapObject* SwFrmFmt::GetIMapObject( const Point& rPoint,
3175 const SwFlyFrm *pFly ) const
3177 const SwFmtURL &rURL = GetURL();
3178 if( !rURL.GetMap() )
3179 return 0;
3181 if( !pFly )
3183 pFly = (SwFlyFrm*) SwClientIter( *(SwFrmFmt*)this ).First( TYPE( SwFlyFrm ));
3184 if( !pFly )
3185 return 0;
3188 //Orignialgroesse fuer OLE und Grafik ist die TwipSize,
3189 //ansonsten die Groesse vom FrmFmt des Fly.
3190 const SwFrm *pRef;
3191 SwNoTxtNode *pNd = 0;
3192 Size aOrigSz;
3193 if( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
3195 pRef = pFly->Lower();
3196 pNd = ((SwCntntFrm*)pRef)->GetNode()->GetNoTxtNode();
3197 aOrigSz = pNd->GetTwipSize();
3199 else
3201 pRef = pFly;
3202 aOrigSz = pFly->GetFmt()->GetFrmSize().GetSize();
3205 if( aOrigSz.Width() != 0 && aOrigSz.Height() != 0 )
3207 Point aPos( rPoint );
3208 Size aActSz ( pRef == pFly ? pFly->Frm().SSize() : pRef->Prt().SSize() );
3209 const MapMode aSrc ( MAP_TWIP );
3210 const MapMode aDest( MAP_100TH_MM );
3211 aOrigSz = OutputDevice::LogicToLogic( aOrigSz, aSrc, aDest );
3212 aActSz = OutputDevice::LogicToLogic( aActSz, aSrc, aDest );
3213 aPos -= pRef->Frm().Pos();
3214 aPos -= pRef->Prt().Pos();
3215 aPos = OutputDevice::LogicToLogic( aPos, aSrc, aDest );
3216 sal_uInt32 nFlags = 0;
3217 if ( pFly != pRef && pNd->IsGrfNode() )
3219 const sal_uInt16 nMirror = pNd->GetSwAttrSet().
3220 GetMirrorGrf().GetValue();
3221 if ( RES_MIRROR_GRAPH_BOTH == nMirror )
3222 nFlags = IMAP_MIRROR_HORZ | IMAP_MIRROR_VERT;
3223 else if ( RES_MIRROR_GRAPH_VERT == nMirror )
3224 nFlags = IMAP_MIRROR_VERT;
3225 else if ( RES_MIRROR_GRAPH_HOR == nMirror )
3226 nFlags = IMAP_MIRROR_HORZ;
3229 return ((ImageMap*)rURL.GetMap())->GetHitIMapObject( aOrigSz,
3230 aActSz, aPos, nFlags );
3233 return 0;