xref: /trunk/main/sw/source/core/layout/atrfrm.cxx (revision 870262e3)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <hintids.hxx>
29 #include <com/sun/star/text/RelOrientation.hpp>
30 #include <com/sun/star/text/VertOrientation.hpp>
31 #include <com/sun/star/text/HorizontalAdjust.hpp>
32 #include <com/sun/star/text/DocumentStatistic.hpp>
33 #include <com/sun/star/text/HoriOrientation.hpp>
34 #include <com/sun/star/text/HoriOrientationFormat.hpp>
35 #include <com/sun/star/text/NotePrintMode.hpp>
36 #include <com/sun/star/text/SizeType.hpp>
37 #include <com/sun/star/text/VertOrientationFormat.hpp>
38 #include <com/sun/star/text/WrapTextMode.hpp>
39 #include <com/sun/star/text/XTextFrame.hpp>
40 #include <com/sun/star/text/TextContentAnchorType.hpp>
41 #include <com/sun/star/text/InvalidTextContentException.hpp>
42 #include <com/sun/star/container/XIndexContainer.hpp>
43 #include <com/sun/star/text/TextGridMode.hpp>
44 #include <com/sun/star/awt/Size.hpp>
45 #include <svtools/unoimap.hxx>
46 #include <svtools/unoevent.hxx>
47 #include <basic/sbxvar.hxx>
48 #include <svtools/imap.hxx>
49 #include <svtools/imapobj.hxx>
50 #include <editeng/ulspitem.hxx>
51 #include <editeng/lrspitem.hxx>
52 #include <svx/svdmodel.hxx>
53 #include <svx/svdpage.hxx>
54 #include <svl/itemiter.hxx>
55 #include <unosett.hxx>
56 #include <unostyle.hxx>
57 #include <fmtclds.hxx>
58 #include <fmtornt.hxx>
59 #include <fmthdft.hxx>
60 #include <fmtpdsc.hxx>
61 #include <fmtcntnt.hxx>
62 #include <fmtfsize.hxx>
63 #include <fmtfordr.hxx>
64 #include <fmtsrnd.hxx>
65 #include <fmtanchr.hxx>
66 #include <fmtlsplt.hxx>
67 #include <fmtrowsplt.hxx>
68 #include <fmtftntx.hxx>
69 #include <fmteiro.hxx>
70 #include <fmturl.hxx>
71 #include <fmtcnct.hxx>
72 #include <node.hxx>
73 #include <section.hxx>
74 #include <fmtline.hxx>
75 #include <tgrditem.hxx>
76 #include <hfspacingitem.hxx>
77 #include <doc.hxx>
78 #include <IDocumentUndoRedo.hxx>
79 #include <pagefrm.hxx>
80 #include <rootfrm.hxx>
81 #include <cntfrm.hxx>
82 #include <crsrsh.hxx>
83 #include <pam.hxx>
84 #include <dflyobj.hxx>
85 #include <dcontact.hxx>
86 #include <flyfrm.hxx>
87 #include <frmtool.hxx>
88 #include <flyfrms.hxx>
89 #include <pagedesc.hxx>
90 #include <grfatr.hxx>
91 #include <ndnotxt.hxx>
92 #include <docary.hxx>
93 #include <node2lay.hxx>
94 #include <fmtclbl.hxx>
95 #include <swunohelper.hxx>
96 #include <unoframe.hxx>
97 #include <unotextbodyhf.hxx>
98 #include <SwStyleNameMapper.hxx>
99 #include <editeng/brshitem.hxx>
100 #include <svtools/grfmgr.hxx>
101 #include <cmdid.h>
102 #include <unomid.h>
103 #include <comcore.hrc>
104 #include <svx/svdundo.hxx> // #111827#
105 #include <sortedobjs.hxx>
106 #include <HandleAnchorNodeChg.hxx>
107 #include <svl/cjkoptions.hxx>
108 #include <switerator.hxx>
109 #include <pagedeschint.hxx>
110 
111 //UUUU
112 #include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
113 #include <svx/xfillit0.hxx>
114 
115 using namespace ::com::sun::star;
116 using ::rtl::OUString;
117 
118 SV_IMPL_PTRARR(SwColumns,SwColumn*)
119 
120 TYPEINIT1(SwFmtVertOrient, SfxPoolItem);
121 TYPEINIT1(SwFmtHoriOrient, SfxPoolItem);
122 TYPEINIT2(SwFmtHeader,  SfxPoolItem, SwClient );
123 TYPEINIT2(SwFmtFooter,  SfxPoolItem, SwClient );
124 TYPEINIT2(SwFmtPageDesc,  SfxPoolItem, SwClient );
125 TYPEINIT1_AUTOFACTORY(SwFmtLineNumber, SfxPoolItem);
126 
127 /* -----------------19.05.98 09:26-------------------
128  * 	Umwandlung fuer QueryValue
129  * --------------------------------------------------*/
lcl_RelToINT(sal_Int16 eRelation)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 
lcl_IntToRelation(const uno::Any & rVal)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 
DelHFFormat(SwClient * pToRemove,SwFrmFmt * pFmt)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 
SwFmtFrmSize(SwFrmSize eSize,SwTwips nWidth,SwTwips nHeight)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 
operator =(const SwFmtFrmSize & rCpy)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 
operator ==(const SfxPoolItem & rAttr) const269 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 
Clone(SfxItemPool *) const279 SfxPoolItem*  SwFmtFrmSize::Clone( SfxItemPool* ) const
280 {
281 	return new SwFmtFrmSize( *this );
282 }
283 
284 
285 /* -----------------24.04.98 11:36-------------------
286  *
287  * --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const288 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  * --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)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 
SwFmtFillOrder(SwFillOrder nFO)481 SwFmtFillOrder::SwFmtFillOrder( SwFillOrder nFO )
482 	: SfxEnumItem( RES_FILL_ORDER, sal_uInt16(nFO) )
483 {}
484 
Clone(SfxItemPool *) const485 SfxPoolItem*  SwFmtFillOrder::Clone( SfxItemPool* ) const
486 {
487 	return new SwFmtFillOrder( GetFillOrder() );
488 }
489 
GetValueCount() const490 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 
SwFmtHeader(SwFrmFmt * pHeaderFmt)498 SwFmtHeader::SwFmtHeader( SwFrmFmt *pHeaderFmt )
499 	: SfxPoolItem( RES_HEADER ),
500 	SwClient( pHeaderFmt ),
501 	bActive( pHeaderFmt ? sal_True : sal_False )
502 {
503 }
504 
SwFmtHeader(const SwFmtHeader & rCpy)505 SwFmtHeader::SwFmtHeader( const SwFmtHeader &rCpy )
506 	: SfxPoolItem( RES_HEADER ),
507 	SwClient( (SwModify*)rCpy.GetRegisteredIn() ),
508 	bActive( rCpy.IsActive() )
509 {
510 }
511 
SwFmtHeader(sal_Bool bOn)512 SwFmtHeader::SwFmtHeader( sal_Bool bOn )
513 	: SfxPoolItem( RES_HEADER ),
514 	SwClient( 0 ),
515 	bActive( bOn )
516 {
517 }
518 
~SwFmtHeader()519  SwFmtHeader::~SwFmtHeader()
520 {
521 	if ( GetHeaderFmt() )
522 		DelHFFormat( this, GetHeaderFmt() );
523 }
524 
operator ==(const SfxPoolItem & rAttr) const525 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 
Clone(SfxItemPool *) const532 SfxPoolItem*  SwFmtHeader::Clone( SfxItemPool* ) const
533 {
534 	return new SwFmtHeader( *this );
535 }
536 
RegisterToFormat(SwFmt & rFmt)537 void SwFmtHeader::RegisterToFormat( SwFmt& rFmt )
538 {
539     rFmt.Add(this);
540 }
541 
542 //	class SwFmtFooter
543 //	Implementierung teilweise inline im hxx
544 
SwFmtFooter(SwFrmFmt * pFooterFmt)545 SwFmtFooter::SwFmtFooter( SwFrmFmt *pFooterFmt )
546 	: SfxPoolItem( RES_FOOTER ),
547 	SwClient( pFooterFmt ),
548 	bActive( pFooterFmt ? sal_True : sal_False )
549 {
550 }
551 
SwFmtFooter(const SwFmtFooter & rCpy)552 SwFmtFooter::SwFmtFooter( const SwFmtFooter &rCpy )
553 	: SfxPoolItem( RES_FOOTER ),
554 	SwClient( (SwModify*)rCpy.GetRegisteredIn() ),
555 	bActive( rCpy.IsActive() )
556 {
557 }
558 
SwFmtFooter(sal_Bool bOn)559 SwFmtFooter::SwFmtFooter( sal_Bool bOn )
560 	: SfxPoolItem( RES_FOOTER ),
561 	SwClient( 0 ),
562 	bActive( bOn )
563 {
564 }
565 
~SwFmtFooter()566  SwFmtFooter::~SwFmtFooter()
567 {
568 	if ( GetFooterFmt() )
569 		DelHFFormat( this, GetFooterFmt() );
570 }
571 
RegisterToFormat(SwFmt & rFmt)572 void SwFmtFooter::RegisterToFormat( SwFmt& rFmt )
573 {
574     rFmt.Add(this);
575 }
576 
operator ==(const SfxPoolItem & rAttr) const577 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 
Clone(SfxItemPool *) const584 SfxPoolItem*  SwFmtFooter::Clone( SfxItemPool* ) const
585 {
586 	return new SwFmtFooter( *this );
587 }
588 
589 //	class SwFmtCntnt
590 //	Implementierung teilweise inline im hxx
591 
SwFmtCntnt(const SwFmtCntnt & rCpy)592 SwFmtCntnt::SwFmtCntnt( const SwFmtCntnt &rCpy )
593 	: SfxPoolItem( RES_CNTNT )
594 {
595 	pStartNode = rCpy.GetCntntIdx() ?
596 					new SwNodeIndex( *rCpy.GetCntntIdx() ) : 0;
597 }
598 
SwFmtCntnt(const SwStartNode * pStartNd)599 SwFmtCntnt::SwFmtCntnt( const SwStartNode *pStartNd )
600 	: SfxPoolItem( RES_CNTNT )
601 {
602 	pStartNode = pStartNd ? new SwNodeIndex( *pStartNd ) : 0;
603 }
604 
~SwFmtCntnt()605  SwFmtCntnt::~SwFmtCntnt()
606 {
607 	delete pStartNode;
608 }
609 
SetNewCntntIdx(const SwNodeIndex * pIdx)610 void SwFmtCntnt::SetNewCntntIdx( const SwNodeIndex *pIdx )
611 {
612 	delete pStartNode;
613 	pStartNode = pIdx ? new SwNodeIndex( *pIdx ) : 0;
614 }
615 
operator ==(const SfxPoolItem & rAttr) const616 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 
Clone(SfxItemPool *) const626 SfxPoolItem*  SwFmtCntnt::Clone( SfxItemPool* ) const
627 {
628 	return new SwFmtCntnt( *this );
629 }
630 
631 //	class SwFmtPageDesc
632 //	Implementierung teilweise inline im hxx
633 
SwFmtPageDesc(const SwFmtPageDesc & rCpy)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 
SwFmtPageDesc(const SwPageDesc * pDesc)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 
~SwFmtPageDesc()652  SwFmtPageDesc::~SwFmtPageDesc() {}
653 
KnowsPageDesc() const654 bool SwFmtPageDesc::KnowsPageDesc() const
655 {
656     return (GetRegisteredIn() != 0);
657 }
658 
operator ==(const SfxPoolItem & rAttr) const659 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 
Clone(SfxItemPool *) const667 SfxPoolItem*  SwFmtPageDesc::Clone( SfxItemPool* ) const
668 {
669 	return new SwFmtPageDesc( *this );
670 }
671 
SwClientNotify(const SwModify &,const SfxHint & rHint)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 
RegisterToPageDesc(SwPageDesc & rDesc)699 void SwFmtPageDesc::RegisterToPageDesc( SwPageDesc& rDesc )
700 {
701     rDesc.Add( this );
702 }
703 
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)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 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const741 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( sal_False, "unknown MemberId" );
767 			bRet = sal_False;
768 	}
769 	return bRet;
770 }
771 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)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( sal_False, "unknown MemberId" );
796 			bRet = sal_False;
797 	}
798 	return bRet;
799 }
800 
801 
802 //	class SwFmtCol
803 //	Implementierung teilweise inline im hxx
804 
SwColumn()805 SwColumn::SwColumn() :
806     nWish ( 0 ),
807     nUpper( 0 ),
808 	nLower( 0 ),
809 	nLeft ( 0 ),
810     nRight( 0 )
811 {
812 }
813 
operator ==(const SwColumn & rCmp)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 
SwFmtCol(const SwFmtCol & rCpy)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 
~SwFmtCol()841 SwFmtCol::~SwFmtCol() {}
842 
operator =(const SwFmtCol & rCpy)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 
SwFmtCol()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 
operator ==(const SfxPoolItem & rAttr) const874 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 
Clone(SfxItemPool *) const896 SfxPoolItem*  SwFmtCol::Clone( SfxItemPool* ) const
897 {
898 	return new SwFmtCol( *this );
899 }
900 
GetGutterWidth(sal_Bool bMin) const901 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 
SetGutterWidth(sal_uInt16 nNew,sal_uInt16 nAct)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 
Init(sal_uInt16 nNumCols,sal_uInt16 nGutterWidth,sal_uInt16 nAct)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 
SetOrtho(sal_Bool bNew,sal_uInt16 nGutterWidth,sal_uInt16 nAct)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 
CalcColWidth(sal_uInt16 nCol,sal_uInt16 nAct) const974 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 
CalcPrtColWidth(sal_uInt16 nCol,sal_uInt16 nAct) const988 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 
Calc(sal_uInt16 nGutterWidth,sal_uInt16 nAct)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 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1052 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 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)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( sal_False, "unknown alignment" ); break;
1128 				}
1129 			}
1130 		}
1131 	}
1132 	return bRet;
1133 }
1134 
1135 
1136 //	class SwFmtSurround
1137 //	Implementierung teilweise inline im hxx
1138 
SwFmtSurround(SwSurround eFly)1139 SwFmtSurround::SwFmtSurround( SwSurround eFly ) :
1140 	SfxEnumItem( RES_SURROUND, sal_uInt16( eFly ) )
1141 {
1142 	bAnchorOnly = bContour = bOutside = sal_False;
1143 }
1144 
SwFmtSurround(const SwFmtSurround & rCpy)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 
operator ==(const SfxPoolItem & rAttr) const1153 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 
Clone(SfxItemPool *) const1162 SfxPoolItem*  SwFmtSurround::Clone( SfxItemPool* ) const
1163 {
1164 	return new SwFmtSurround( *this );
1165 }
1166 
GetValueCount() const1167 sal_uInt16  SwFmtSurround::GetValueCount() const
1168 {
1169 	return SURROUND_END - SURROUND_BEGIN;
1170 }
1171 
1172 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1173 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( sal_False, "unknown MemberId" );
1203 			bRet = sal_False;
1204 	}
1205 	return bRet;
1206 }
1207 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)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( sal_False, "unknown MemberId" );
1238 			bRet = sal_False;
1239 	}
1240 	return bRet;
1241 }
1242 
1243 //	class SwFmtVertOrient
1244 //	Implementierung teilweise inline im hxx
1245 
SwFmtVertOrient(SwTwips nY,sal_Int16 eVert,sal_Int16 eRel)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 
operator ==(const SfxPoolItem & rAttr) const1254 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 
Clone(SfxItemPool *) const1262 SfxPoolItem*  SwFmtVertOrient::Clone( SfxItemPool* ) const
1263 {
1264 	return new SwFmtVertOrient( nYPos, eOrient, eRelation );
1265 }
1266 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1267 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( sal_False, "unknown MemberId" );
1301 			bRet = sal_False;
1302 	}
1303 	return bRet;
1304 }
1305 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)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( sal_False, "unknown MemberId" );
1348 			bRet = sal_False;
1349 	}
1350 	return bRet;
1351 }
1352 
1353 
1354 
1355 //	class SwFmtHoriOrient
1356 //	Implementierung teilweise inline im hxx
1357 
SwFmtHoriOrient(SwTwips nX,sal_Int16 eHori,sal_Int16 eRel,sal_Bool bPos)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 
operator ==(const SfxPoolItem & rAttr) const1367 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 
Clone(SfxItemPool *) const1376 SfxPoolItem*  SwFmtHoriOrient::Clone( SfxItemPool* ) const
1377 {
1378 	return new SwFmtHoriOrient( nXPos, eOrient, eRelation, bPosToggle );
1379 }
1380 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1381 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( sal_False, "unknown MemberId" );
1423 			bRet = sal_False;
1424 	}
1425 	return bRet;
1426 }
1427 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)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( sal_False, "unknown MemberId" );
1474 			bRet = sal_False;
1475 	}
1476 	return bRet;
1477 }
1478 
1479 
1480 
1481 //	class SwFmtAnchor
1482 //	Implementierung teilweise inline im hxx
1483 
SwFmtAnchor(RndStdIds nRnd,sal_uInt16 nPage)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 
SwFmtAnchor(const SwFmtAnchor & rCpy)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 
~SwFmtAnchor()1504  SwFmtAnchor::~SwFmtAnchor()
1505 {
1506 	delete pCntntAnchor;
1507 }
1508 
SetAnchor(const SwPosition * pPos)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 
operator =(const SwFmtAnchor & rAnchor)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 
operator ==(const SfxPoolItem & rAttr) const1535 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 
Clone(SfxItemPool *) const1549 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#
GetOrder() const1558 sal_uInt32 SwFmtAnchor::GetOrder() const
1559 {
1560     return mnOrder;
1561 }
1562 
1563 /*-----------------16.02.98 15:21-------------------
1564 
1565 --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1566 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( sal_False, "unknown MemberId" );
1615 			bRet = sal_False;
1616 	}
1617 	return bRet;
1618 }
1619 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)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( sal_False, "unknown MemberId" );
1685 			bRet = sal_False;
1686 	}
1687 	return bRet;
1688 }
1689 
1690 //	class SwFmtURL
1691 //	Implementierung teilweise inline im hxx
1692 
SwFmtURL()1693 SwFmtURL::SwFmtURL() :
1694 	SfxPoolItem( RES_URL ),
1695 	pMap( 0 ),
1696 	bIsServerMap( sal_False )
1697 {
1698 }
1699 
SwFmtURL(const SwFmtURL & rURL)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 
~SwFmtURL()1710 SwFmtURL::~SwFmtURL()
1711 {
1712 	if ( pMap )
1713 		delete pMap;
1714 }
1715 
operator ==(const SfxPoolItem & rAttr) const1716 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 
Clone(SfxItemPool *) const1734 SfxPoolItem* SwFmtURL::Clone( SfxItemPool* ) const
1735 {
1736 	return new SwFmtURL( *this );
1737 }
1738 
SetURL(const XubString & rURL,sal_Bool bServerMap)1739 void SwFmtURL::SetURL( const XubString &rURL, sal_Bool bServerMap )
1740 {
1741 	sURL = rURL;
1742 	bIsServerMap = bServerMap;
1743 }
1744 
SetMap(const ImageMap * pM)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 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1753 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( sal_False, "unknown MemberId" );
1799 			bRet = sal_False;
1800 	}
1801 	return bRet;
1802 }
1803 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)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( sal_False, "unknown MemberId" );
1852 			bRet = sal_False;
1853 	}
1854 	return bRet;
1855 }
1856 
1857 
1858 // class SwNoReadOnly
1859 
Clone(SfxItemPool *) const1860 SfxPoolItem* SwFmtEditInReadonly::Clone( SfxItemPool* ) const
1861 {
1862 	return new SwFmtEditInReadonly( Which(), GetValue() );
1863 }
1864 
1865 // class SwFmtLayoutSplit
1866 
Clone(SfxItemPool *) const1867 SfxPoolItem* SwFmtLayoutSplit::Clone( SfxItemPool* ) const
1868 {
1869 	return new SwFmtLayoutSplit( GetValue() );
1870 }
1871 
1872 // class SwFmtRowSplit
1873 
Clone(SfxItemPool *) const1874 SfxPoolItem* SwFmtRowSplit::Clone( SfxItemPool* ) const
1875 {
1876     return new SwFmtRowSplit( GetValue() );
1877 }
1878 
1879 
1880 // class SwFmtNoBalancedColumns
1881 
Clone(SfxItemPool *) const1882 SfxPoolItem* SwFmtNoBalancedColumns::Clone( SfxItemPool* ) const
1883 {
1884 	return new SwFmtNoBalancedColumns( GetValue() );
1885 }
1886 
1887 // class SwFmtFtnEndAtTxtEnd
1888 
GetValueCount() const1889 sal_uInt16 SwFmtFtnEndAtTxtEnd::GetValueCount() const
1890 {
1891 	return sal_uInt16( FTNEND_ATTXTEND_END );
1892 }
1893 
operator =(const SwFmtFtnEndAtTxtEnd & rAttr)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 
operator ==(const SfxPoolItem & rItem) const1905 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 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1915 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 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)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 
Clone(SfxItemPool *) const2023 SfxPoolItem* SwFmtFtnAtTxtEnd::Clone( SfxItemPool* ) const
2024 {
2025 	SwFmtFtnAtTxtEnd* pNew = new SwFmtFtnAtTxtEnd;
2026 	*pNew = *this;
2027 	return pNew;
2028 }
2029 
2030 // class SwFmtEndAtTxtEnd
2031 
Clone(SfxItemPool *) const2032 SfxPoolItem* SwFmtEndAtTxtEnd::Clone( SfxItemPool* ) const
2033 {
2034 	SwFmtEndAtTxtEnd* pNew = new SwFmtEndAtTxtEnd;
2035 	*pNew = *this;
2036 	return pNew;
2037 }
2038 
2039 //class SwFmtChain
2040 
2041 
operator ==(const SfxPoolItem & rAttr) const2042 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 
SwFmtChain(const SwFmtChain & rCpy)2050 SwFmtChain::SwFmtChain( const SwFmtChain &rCpy ) :
2051 	SfxPoolItem( RES_CHAIN )
2052 {
2053 	SetPrev( rCpy.GetPrev() );
2054 	SetNext( rCpy.GetNext() );
2055 }
2056 
Clone(SfxItemPool *) const2057 SfxPoolItem* SwFmtChain::Clone( SfxItemPool* ) const
2058 {
2059 	SwFmtChain *pRet = new SwFmtChain;
2060 	pRet->SetPrev( GetPrev() );
2061 	pRet->SetNext( GetNext() );
2062 	return pRet;
2063 }
2064 
SetPrev(SwFlyFrmFmt * pFmt)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 
SetNext(SwFlyFrmFmt * pFmt)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 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const2081 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( sal_False, "unknown MemberId" );
2099 			bRet = sal_False;
2100 	}
2101 	rVal <<= OUString(aRet);
2102 	return bRet;
2103 }
2104 
2105 
2106 
2107 
2108 //class SwFmtLineNumber
2109 
SwFmtLineNumber()2110 SwFmtLineNumber::SwFmtLineNumber() :
2111 	SfxPoolItem( RES_LINENUMBER )
2112 {
2113 	nStartValue = 0;
2114 	bCountLines = sal_True;
2115 }
2116 
~SwFmtLineNumber()2117 SwFmtLineNumber::~SwFmtLineNumber()
2118 {
2119 }
2120 
operator ==(const SfxPoolItem & rAttr) const2121 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 
Clone(SfxItemPool *) const2129 SfxPoolItem* SwFmtLineNumber::Clone( SfxItemPool* ) const
2130 {
2131 	return new SwFmtLineNumber( *this );
2132 }
2133 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const2134 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( sal_False, "unknown MemberId" );
2152 			bRet = sal_False;
2153 	}
2154 	return bRet;
2155 }
2156 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)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( sal_False, "unknown MemberId" );
2178 			bRet = sal_False;
2179 	}
2180 	return bRet;
2181 }
2182 
2183 /*************************************************************************
2184  *    class SwTextGridItem
2185  *************************************************************************/
2186 
SwTextGridItem()2187 SwTextGridItem::SwTextGridItem()
2188     : SfxPoolItem( RES_TEXTGRID )
2189     , aColor( COL_LIGHTGRAY )
2190     , nLines( 20 )
2191     , nBaseHeight( 400 )
2192     , nRubyHeight( 200 )
2193     , eGridType( GRID_NONE )
2194     , bRubyTextBelow( 0 )
2195     , bPrintGrid( 1 )
2196     , bDisplayGrid( 1 )
2197     , nBaseWidth( 400 )
2198     , bSnapToChars( 1 )
2199     , bSquaredMode( 1 )
2200 {
2201 }
2202 
~SwTextGridItem()2203 SwTextGridItem::~SwTextGridItem()
2204 {
2205 }
2206 
operator ==(const SfxPoolItem & rAttr) const2207 int SwTextGridItem::operator==( const SfxPoolItem& rAttr ) const
2208 {
2209 	ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
2210     return eGridType == ((SwTextGridItem&)rAttr).GetGridType() &&
2211            nLines == ((SwTextGridItem&)rAttr).GetLines() &&
2212            nBaseHeight == ((SwTextGridItem&)rAttr).GetBaseHeight() &&
2213            nRubyHeight == ((SwTextGridItem&)rAttr).GetRubyHeight() &&
2214            bRubyTextBelow == ((SwTextGridItem&)rAttr).GetRubyTextBelow() &&
2215            bDisplayGrid == ((SwTextGridItem&)rAttr).GetDisplayGrid() &&
2216            bPrintGrid == ((SwTextGridItem&)rAttr).GetPrintGrid() &&
2217            aColor == ((SwTextGridItem&)rAttr).GetColor() &&
2218            nBaseWidth == ((SwTextGridItem&)rAttr).GetBaseWidth() &&
2219            bSnapToChars == ((SwTextGridItem&)rAttr).GetSnapToChars() &&
2220            bSquaredMode == ((SwTextGridItem&)rAttr).GetSquaredMode();
2221 }
2222 
Clone(SfxItemPool *) const2223 SfxPoolItem* SwTextGridItem::Clone( SfxItemPool* ) const
2224 {
2225     return new SwTextGridItem( *this );
2226 }
2227 
operator =(const SwTextGridItem & rCpy)2228 SwTextGridItem& SwTextGridItem::operator=( const SwTextGridItem& rCpy )
2229 {
2230     aColor = rCpy.GetColor();
2231     nLines = rCpy.GetLines();
2232     nBaseHeight = rCpy.GetBaseHeight();
2233     nRubyHeight = rCpy.GetRubyHeight();
2234     eGridType = rCpy.GetGridType();
2235     bRubyTextBelow = rCpy.GetRubyTextBelow();
2236     bPrintGrid = rCpy.GetPrintGrid();
2237     bDisplayGrid = rCpy.GetDisplayGrid();
2238     nBaseWidth = rCpy.GetBaseWidth();
2239     bSnapToChars = rCpy.GetSnapToChars();
2240     bSquaredMode = rCpy.GetSquaredMode();
2241 
2242 	return *this;
2243 }
2244 
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const2245 sal_Bool SwTextGridItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2246 {
2247     sal_Bool bRet = sal_True;
2248 
2249     switch( nMemberId & ~CONVERT_TWIPS )
2250     {
2251         case MID_GRID_COLOR:
2252             rVal <<= GetColor().GetColor();
2253             break;
2254         case MID_GRID_LINES:
2255             rVal <<= GetLines();
2256             break;
2257         case MID_GRID_RUBY_BELOW:
2258             rVal.setValue( &bRubyTextBelow, ::getBooleanCppuType() );
2259             break;
2260         case MID_GRID_PRINT:
2261             rVal.setValue( &bPrintGrid, ::getBooleanCppuType() );
2262             break;
2263         case MID_GRID_DISPLAY:
2264             rVal.setValue( &bDisplayGrid, ::getBooleanCppuType() );
2265             break;
2266         case MID_GRID_BASEHEIGHT:
2267             DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2268                         "This value needs TWIPS-MM100 conversion" );
2269             rVal <<= (sal_Int32) TWIP_TO_MM100_UNSIGNED(nBaseHeight);
2270             break;
2271         case MID_GRID_BASEWIDTH:
2272             DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2273                         "This value needs TWIPS-MM100 conversion" );
2274             rVal <<= (sal_Int32) TWIP_TO_MM100_UNSIGNED(nBaseWidth);
2275             break;
2276         case MID_GRID_RUBYHEIGHT:
2277             DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2278                         "This value needs TWIPS-MM100 conversion" );
2279             rVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(nRubyHeight);
2280             break;
2281         case MID_GRID_TYPE:
2282             switch( GetGridType() )
2283             {
2284                 case GRID_NONE:
2285                     rVal <<= text::TextGridMode::NONE;
2286                     break;
2287                 case GRID_LINES_ONLY:
2288                     rVal <<= text::TextGridMode::LINES;
2289                     break;
2290                 case GRID_LINES_CHARS:
2291                     rVal <<= text::TextGridMode::LINES_AND_CHARS;
2292                     break;
2293                 default:
2294                     DBG_ERROR("unknown SwTextGrid value");
2295                     bRet = sal_False;
2296                     break;
2297             }
2298             break;
2299         case MID_GRID_SNAPTOCHARS:
2300             rVal.setValue( &bSnapToChars, ::getBooleanCppuType() );
2301             break;
2302         case MID_GRID_STANDARD_MODE:
2303 			{
2304 				sal_Bool bStandardMode = !bSquaredMode;
2305     	        rVal.setValue( &bStandardMode, ::getBooleanCppuType() );
2306 			}
2307             break;
2308         default:
2309             DBG_ERROR("Unknown SwTextGridItem member");
2310             bRet = sal_False;
2311             break;
2312     }
2313 
2314 	return bRet;
2315 }
2316 
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)2317 sal_Bool SwTextGridItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2318 {
2319 	sal_Bool bRet = sal_True;
2320     switch( nMemberId & ~CONVERT_TWIPS )
2321     {
2322         case MID_GRID_COLOR:
2323         {
2324             sal_Int32 nTmp = 0;
2325             bRet = (rVal >>= nTmp);
2326             if( bRet )
2327                 SetColor( Color(nTmp) );
2328         }
2329         break;
2330         case MID_GRID_LINES:
2331         {
2332             sal_Int16 nTmp = 0;
2333             bRet = (rVal >>= nTmp);
2334             if( bRet && (nTmp >= 0) )
2335                 SetLines( (sal_uInt16)nTmp );
2336             else
2337                 bRet = sal_False;
2338         }
2339         break;
2340         case MID_GRID_RUBY_BELOW:
2341             SetRubyTextBelow( *(sal_Bool*)rVal.getValue() );
2342             break;
2343         case MID_GRID_PRINT:
2344             SetPrintGrid( *(sal_Bool*)rVal.getValue() );
2345             break;
2346         case MID_GRID_DISPLAY:
2347             SetDisplayGrid( *(sal_Bool*)rVal.getValue() );
2348             break;
2349         case MID_GRID_BASEHEIGHT:
2350         case MID_GRID_BASEWIDTH:
2351         case MID_GRID_RUBYHEIGHT:
2352         {
2353             DBG_ASSERT( (nMemberId & CONVERT_TWIPS) != 0,
2354                         "This value needs TWIPS-MM100 conversion" );
2355             sal_Int32 nTmp = 0;
2356             bRet = (rVal >>= nTmp);
2357             nTmp = MM100_TO_TWIP( nTmp );
2358             if( bRet && (nTmp >= 0) && ( nTmp <= USHRT_MAX) )
2359                 if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEHEIGHT )
2360                     SetBaseHeight( (sal_uInt16)nTmp );
2361                 else if( (nMemberId & ~CONVERT_TWIPS) == MID_GRID_BASEWIDTH )
2362                     SetBaseWidth( (sal_uInt16)nTmp );
2363                 else
2364                     SetRubyHeight( (sal_uInt16)nTmp );
2365             else
2366                 bRet = sal_False;
2367         }
2368         break;
2369         case MID_GRID_TYPE:
2370         {
2371             sal_Int16 nTmp = 0;
2372             bRet = (rVal >>= nTmp);
2373             if( bRet )
2374             {
2375                 switch( nTmp )
2376                 {
2377                     case text::TextGridMode::NONE:
2378                         SetGridType( GRID_NONE );
2379                         break;
2380                     case text::TextGridMode::LINES:
2381                         SetGridType( GRID_LINES_ONLY );
2382                         break;
2383                     case text::TextGridMode::LINES_AND_CHARS:
2384                         SetGridType( GRID_LINES_CHARS );
2385                         break;
2386                     default:
2387                         bRet = sal_False;
2388                         break;
2389                 }
2390             }
2391             break;
2392 		}
2393         case MID_GRID_SNAPTOCHARS:
2394             SetSnapToChars( *(sal_Bool*)rVal.getValue() );
2395             break;
2396         case MID_GRID_STANDARD_MODE:
2397 		{
2398 			sal_Bool bStandard = *(sal_Bool*)rVal.getValue();
2399            	SetSquaredMode( !bStandard );
2400         	break;
2401 		}
2402         default:
2403             DBG_ERROR("Unknown SwTextGridItem member");
2404             bRet = sal_False;
2405     }
2406 
2407     return bRet;
2408 }
2409 
SwitchPaperMode(sal_Bool bNew)2410 void SwTextGridItem::SwitchPaperMode(sal_Bool bNew)
2411 {
2412 	if( bNew == bSquaredMode )
2413 	{
2414 		//same paper mode, not switch
2415 		return;
2416 	}
2417 
2418 	// use default value when grid is disable
2419 	if( eGridType == GRID_NONE )
2420 	{
2421 		bSquaredMode = bNew;
2422 		Init();
2423 		return;
2424 	}
2425 
2426 	if( bSquaredMode )
2427 	{
2428 		//switch from "squared mode" to "standard mode"
2429 		nBaseWidth = nBaseHeight;
2430 		nBaseHeight = nBaseHeight + nRubyHeight;
2431 		nRubyHeight = 0;
2432 	}
2433 	else
2434 	{
2435 		//switch from "standard mode" to "squared mode"
2436 		nRubyHeight = nBaseHeight/3;
2437 		nBaseHeight = nBaseHeight - nRubyHeight;
2438 		nBaseWidth = nBaseHeight;
2439 	}
2440 	bSquaredMode = !bSquaredMode;
2441 }
2442 
Init()2443 void SwTextGridItem::Init()
2444 {
2445 	if( bSquaredMode )
2446 	{
2447 		nLines = 20;
2448 		nBaseHeight = 400;
2449 		nRubyHeight = 200;
2450 		eGridType = GRID_NONE;
2451 		bRubyTextBelow = 0;
2452 		bPrintGrid = 1;
2453 		bDisplayGrid = 1;
2454 		bSnapToChars = 1;
2455 		nBaseWidth = 400;
2456 	}
2457 	else
2458 	{
2459 		nLines = 44;
2460 		nBaseHeight = 312;
2461 		nRubyHeight = 0;
2462 		eGridType = GRID_NONE;
2463 		bRubyTextBelow = 0;
2464 		bPrintGrid = 1;
2465 		bDisplayGrid = 1;
2466 		nBaseWidth = 210;
2467 		bSnapToChars = 1;
2468 
2469 		//default grid type is line only in CJK env
2470 		//disable this function due to type area change
2471 		//if grid type change.
2472 		//if(SvtCJKOptions().IsAsianTypographyEnabled())
2473 		//{
2474 		//	bDisplayGrid = 0;
2475 		//	eGridType = GRID_LINES_ONLY;
2476 		//}
2477 	}
2478 }
2479 // class SwHeaderAndFooterEatSpacingItem
2480 
Clone(SfxItemPool *) const2481 SfxPoolItem* SwHeaderAndFooterEatSpacingItem::Clone( SfxItemPool* ) const
2482 {
2483     return new SwHeaderAndFooterEatSpacingItem( Which(), GetValue() );
2484 }
2485 
2486 //////////////////////////////////////////////////////////////////////////////
2487 //  class SwFrmFmt
2488 //	Implementierung teilweise inline im hxx
2489 
2490 TYPEINIT1( SwFrmFmt, SwFmt );
2491 IMPL_FIXEDMEMPOOL_NEWDEL_DLL( SwFrmFmt, 20, 20 )
2492 
SwFrmFmt(SwAttrPool & rPool,const sal_Char * pFmtNm,SwFrmFmt * pDrvdFrm,sal_uInt16 nFmtWhich,const sal_uInt16 * pWhichRange)2493 SwFrmFmt::SwFrmFmt(
2494     SwAttrPool& rPool,
2495     const sal_Char* pFmtNm,
2496     SwFrmFmt *pDrvdFrm,
2497     sal_uInt16 nFmtWhich,
2498     const sal_uInt16* pWhichRange)
2499 :   SwFmt(rPool, pFmtNm, (pWhichRange ? pWhichRange : aFrmFmtSetRange), pDrvdFrm, nFmtWhich),
2500     m_wXObject(),
2501     maFillAttributes(),
2502     pCaptionFmt(0)
2503 {
2504 }
2505 
SwFrmFmt(SwAttrPool & rPool,const String & rFmtNm,SwFrmFmt * pDrvdFrm,sal_uInt16 nFmtWhich,const sal_uInt16 * pWhichRange)2506 SwFrmFmt::SwFrmFmt(
2507     SwAttrPool& rPool,
2508     const String &rFmtNm,
2509     SwFrmFmt *pDrvdFrm,
2510     sal_uInt16 nFmtWhich,
2511     const sal_uInt16* pWhichRange)
2512 :   SwFmt(rPool, rFmtNm, (pWhichRange ? pWhichRange : aFrmFmtSetRange), pDrvdFrm, nFmtWhich),
2513     m_wXObject(),
2514     maFillAttributes(),
2515     pCaptionFmt(0)
2516 {
2517 }
2518 
2519 //UUUU
~SwFrmFmt()2520 SwFrmFmt::~SwFrmFmt()
2521 {
2522 }
2523 
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)2524 void SwFrmFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
2525 {
2526 	SwFmtHeader *pH = 0;
2527 	SwFmtFooter *pF = 0;
2528 
2529 	sal_uInt16 nWhich = pNew ? pNew->Which() : 0;
2530 
2531 	if( RES_ATTRSET_CHG == nWhich )
2532 	{
2533 		((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
2534 			RES_HEADER, sal_False, (const SfxPoolItem**)&pH );
2535 		((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
2536 			RES_FOOTER, sal_False, (const SfxPoolItem**)&pF );
2537 
2538         //UUUU reset fill information
2539         if(maFillAttributes.get() && supportsFullDrawingLayerFillAttributeSet())
2540         {
2541             SfxItemIter aIter(*((SwAttrSetChg*)pNew)->GetChgSet());
2542             bool bReset(false);
2543 
2544             for(const SfxPoolItem* pItem = aIter.FirstItem(); pItem && !bReset; pItem = aIter.NextItem())
2545             {
2546                 bReset = !IsInvalidItem(pItem) && pItem->Which() >= XATTR_FILL_FIRST && pItem->Which() <= XATTR_FILL_LAST;
2547             }
2548 
2549             if(bReset)
2550             {
2551                 maFillAttributes.reset();
2552             }
2553         }
2554     }
2555     else if(RES_FMT_CHG == nWhich)
2556     {
2557         //UUUU reset fill information on format change (e.g. style changed)
2558         if(maFillAttributes.get() && supportsFullDrawingLayerFillAttributeSet())
2559         {
2560             maFillAttributes.reset();
2561         }
2562     }
2563     else if( RES_HEADER == nWhich )
2564         pH = (SwFmtHeader*)pNew;
2565     else if( RES_FOOTER == nWhich )
2566         pF = (SwFmtFooter*)pNew;
2567 
2568 	if( pH && pH->IsActive() && !pH->GetHeaderFmt() )
2569 	{	//Hat er keinen, mach ich ihm einen
2570         SwFrmFmt *pFmt = GetDoc()->MakeLayoutFmt( RND_STD_HEADER, 0 );
2571         pH->RegisterToFormat( *pFmt );
2572 	}
2573 
2574 	if( pF && pF->IsActive() && !pF->GetFooterFmt() )
2575 	{	//Hat er keinen, mach ich ihm einen
2576         SwFrmFmt *pFmt = GetDoc()->MakeLayoutFmt( RND_STD_FOOTER, 0 );
2577         pF->RegisterToFormat( *pFmt );
2578 	}
2579 
2580 	// MIB 24.3.98: Modify der Basisklasse muss immer gerufen werden, z.B.
2581 	// wegen RESET_FMTWRITTEN.
2582 //	if ( GetDepends() )
2583 		SwFmt::Modify( pOld, pNew );
2584 
2585     if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
2586     {   // invalidate cached uno object
2587         SetXObject(uno::Reference<uno::XInterface>(0));
2588     }
2589 }
2590 
RegisterToFormat(SwFmt & rFmt)2591 void SwFrmFmt::RegisterToFormat( SwFmt& rFmt )
2592 {
2593     rFmt.Add( this );
2594 }
2595 
2596 //Vernichtet alle Frms, die in aDepend angemeldet sind.
2597 
DelFrms()2598 void SwFrmFmt::DelFrms()
2599 {
2600 	SwIterator<SwFrm,SwFmt> aIter( *this );
2601 	SwFrm * pLast = aIter.First();
2602 	if( pLast )
2603 		do {
2604 				pLast->Cut();
2605 				delete pLast;
2606 		} while( 0 != ( pLast = aIter.Next() ));
2607 }
2608 
MakeFrms()2609 void SwFrmFmt::MakeFrms()
2610 {
2611 	ASSERT( sal_False, "Sorry not implemented." );
2612 }
2613 
2614 
2615 
FindLayoutRect(const sal_Bool bPrtArea,const Point * pPoint,const sal_Bool bCalcFrm) const2616 SwRect SwFrmFmt::FindLayoutRect( const sal_Bool bPrtArea, const Point* pPoint,
2617 								 const sal_Bool bCalcFrm ) const
2618 {
2619 	SwRect aRet;
2620 	SwFrm *pFrm = 0;
2621 	if( ISA( SwSectionFmt ) )
2622 	{
2623         // dann den frame::Frame per Node2Layout besorgen
2624 		SwSectionNode* pSectNd = ((SwSectionFmt*)this)->GetSectionNode();
2625 		if( pSectNd )
2626 		{
2627 			SwNode2Layout aTmp( *pSectNd, pSectNd->GetIndex() - 1 );
2628 			pFrm = aTmp.NextFrm();
2629 
2630 			if( pFrm && !pFrm->KnowsFormat(*this) )
2631 			{
2632                 // die Section hat keinen eigenen frame::Frame, also falls
2633 				// jemand die tatsaechliche Groe?e braucht, so muss das
2634 				// noch implementier werden, in dem sich vom Ende noch
2635                 // der entsprechende frame::Frame besorgt wird.
2636 				// PROBLEM: was passiert bei SectionFrames, die auf unter-
2637 				//			schiedlichen Seiten stehen??
2638 				if( bPrtArea )
2639 					aRet = pFrm->Prt();
2640 				else
2641 				{
2642 					aRet = pFrm->Frm();
2643 					--aRet.Pos().Y();
2644 				}
2645 				pFrm = 0;		// das Rect ist ja jetzt fertig
2646 			}
2647 		}
2648 	}
2649 	else
2650 	{
2651 		sal_uInt16 nFrmType = RES_FLYFRMFMT == Which() ? FRM_FLY : USHRT_MAX;
2652 		pFrm = ::GetFrmOfModify( 0, *(SwModify*)this, nFrmType, pPoint,
2653 									0, bCalcFrm );
2654 	}
2655 
2656 	if( pFrm )
2657 	{
2658 		if( bPrtArea )
2659 			aRet = pFrm->Prt();
2660 		else
2661 			aRet = pFrm->Frm();
2662 	}
2663 	return aRet;
2664 }
2665 
FindContactObj()2666 SwContact* SwFrmFmt::FindContactObj()
2667 {
2668 	return SwIterator<SwContact,SwFmt>::FirstElement( *this );
2669 }
2670 
FindSdrObject()2671 SdrObject* SwFrmFmt::FindSdrObject()
2672 {
2673     // --> OD 2005-01-06 #i30669# - use method <FindContactObj()> instead of
2674     // duplicated code.
2675     SwContact* pFoundContact = FindContactObj();
2676     return pFoundContact ? pFoundContact->GetMaster() : 0;
2677     // <--
2678 }
2679 
FindRealSdrObject()2680 SdrObject* SwFrmFmt::FindRealSdrObject()
2681 {
2682 	if( RES_FLYFRMFMT == Which() )
2683 	{
2684 		Point aNullPt;
2685 		SwFlyFrm* pFly = (SwFlyFrm*)::GetFrmOfModify( 0, *this, FRM_FLY,
2686 													&aNullPt, 0, sal_False );
2687 		return pFly ? pFly->GetVirtDrawObj() : 0;
2688 	}
2689 	return FindSdrObject();
2690 }
2691 
2692 
IsLowerOf(const SwFrmFmt & rFmt) const2693 sal_Bool SwFrmFmt::IsLowerOf( const SwFrmFmt& rFmt ) const
2694 {
2695 	//Auch eine Verkettung von Innen nach aussen oder von aussen
2696 	//nach innen ist nicht zulaessig.
2697 	SwFlyFrm *pSFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(*this);
2698 	if( pSFly )
2699 	{
2700 		SwFlyFrm *pAskFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement(rFmt);
2701 		if( pAskFly )
2702             return pSFly->IsLowerOf( pAskFly );
2703 	}
2704 
2705 	// dann mal ueber die Node-Positionen versuchen
2706 	const SwFmtAnchor* pAnchor = &rFmt.GetAnchor();
2707     if ((FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetCntntAnchor())
2708     {
2709 		const SwSpzFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts();
2710 		const SwNode* pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode().
2711 								FindFlyStartNode();
2712 		while( pFlyNd )
2713 		{
2714 			// dann ueber den Anker nach oben "hangeln"
2715 			sal_uInt16 n;
2716 			for( n = 0; n < rFmts.Count(); ++n )
2717 			{
2718 				const SwFrmFmt* pFmt = rFmts[ n ];
2719 				const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
2720 				if( pIdx && pFlyNd == &pIdx->GetNode() )
2721 				{
2722 					if( pFmt == this )
2723 						return sal_True;
2724 
2725 					pAnchor = &pFmt->GetAnchor();
2726                     if ((FLY_AT_PAGE == pAnchor->GetAnchorId()) ||
2727                         !pAnchor->GetCntntAnchor() )
2728                     {
2729                         return sal_False;
2730                     }
2731 
2732 					pFlyNd = pAnchor->GetCntntAnchor()->nNode.GetNode().
2733 								FindFlyStartNode();
2734 					break;
2735 				}
2736 			}
2737 			if( n >= rFmts.Count() )
2738 			{
2739 				ASSERT( sal_False, "Fly-Section but no format found" );
2740 				return sal_False;
2741 			}
2742 		}
2743 	}
2744 	return sal_False;
2745 }
2746 
2747 // --> OD 2004-07-27 #i31698#
GetLayoutDir() const2748 SwFrmFmt::tLayoutDir SwFrmFmt::GetLayoutDir() const
2749 {
2750     return SwFrmFmt::HORI_L2R;
2751 }
2752 
SetLayoutDir(const SwFrmFmt::tLayoutDir)2753 void SwFrmFmt::SetLayoutDir( const SwFrmFmt::tLayoutDir )
2754 {
2755     // empty body, because default implementation does nothing
2756 }
2757 // <--
2758 
2759 // --> OD 2004-08-06 #i28749#
GetPositionLayoutDir() const2760 sal_Int16 SwFrmFmt::GetPositionLayoutDir() const
2761 {
2762     return text::PositionLayoutDir::PositionInLayoutDirOfAnchor;
2763 }
SetPositionLayoutDir(const sal_Int16)2764 void SwFrmFmt::SetPositionLayoutDir( const sal_Int16 )
2765 {
2766     // empty body, because default implementation does nothing
2767 }
2768 // <--
GetDescription() const2769 String SwFrmFmt::GetDescription() const
2770 {
2771     return SW_RES(STR_FRAME);
2772 }
2773 
2774 //	class SwFlyFrmFmt
2775 //	Implementierung teilweise inline im hxx
2776 
2777 TYPEINIT1( SwFlyFrmFmt, SwFrmFmt );
2778 IMPL_FIXEDMEMPOOL_NEWDEL( SwFlyFrmFmt,	10, 10 )
2779 
~SwFlyFrmFmt()2780 SwFlyFrmFmt::~SwFlyFrmFmt()
2781 {
2782 	SwIterator<SwFlyFrm,SwFmt> aIter( *this );
2783 	SwFlyFrm * pLast = aIter.First();
2784 	if( pLast )
2785 		do {
2786 				delete pLast;
2787 		} while( 0 != ( pLast = aIter.Next() ));
2788 
2789 	SwIterator<SwFlyDrawContact,SwFmt> a2ndIter( *this );
2790 	SwFlyDrawContact* pC = a2ndIter.First();
2791 	if( pC )
2792 		do {
2793 				delete pC;
2794 
2795 		} while( 0 != ( pC = a2ndIter.Next() ));
2796 }
2797 
2798 //Erzeugen der Frms wenn das Format einen Absatzgebundenen Rahmen beschreibt.
2799 //MA: 14. Feb. 94, Erzeugen der Frms auch fuer Seitengebundene Rahmen.
2800 
MakeFrms()2801 void SwFlyFrmFmt::MakeFrms()
2802 {
2803 	// gibts ueberhaupt ein Layout ??
2804 	if( !GetDoc()->GetCurrentViewShell() )
2805 		return;	//swmod 071108//swmod 071225
2806 
2807 	SwModify *pModify = 0;
2808     // OD 24.07.2003 #111032# - create local copy of anchor attribute for possible changes.
2809     SwFmtAnchor aAnchorAttr( GetAnchor() );
2810     switch( aAnchorAttr.GetAnchorId() )
2811     {
2812     case FLY_AS_CHAR:
2813     case FLY_AT_PARA:
2814     case FLY_AT_CHAR:
2815         if( aAnchorAttr.GetCntntAnchor() )
2816         {
2817             pModify = aAnchorAttr.GetCntntAnchor()->nNode.GetNode().GetCntntNode();
2818         }
2819 		break;
2820 
2821 	case FLY_AT_FLY:
2822         if( aAnchorAttr.GetCntntAnchor() )
2823 		{
2824 			//Erst einmal ueber den Inhalt suchen, weil konstant schnell. Kann
2825 			//Bei verketteten Rahmen aber auch schief gehen, weil dann evtl.
2826             //niemals ein frame::Frame zu dem Inhalt existiert. Dann muss leider noch
2827 			//die Suche vom StartNode zum FrameFormat sein.
2828             SwNodeIndex aIdx( aAnchorAttr.GetCntntAnchor()->nNode );
2829 			SwCntntNode *pCNd = GetDoc()->GetNodes().GoNext( &aIdx );
2830             // --> OD 2009-12-28 #i105535#
2831             if ( pCNd == 0 )
2832             {
2833                 pCNd = aAnchorAttr.GetCntntAnchor()->nNode.GetNode().GetCntntNode();
2834             }
2835             if ( pCNd )
2836             // <--
2837             {
2838                 if( SwIterator<SwFrm,SwCntntNode>::FirstElement( *pCNd ) )
2839                 {
2840                     pModify = pCNd;
2841                 }
2842             }
2843             // --> OD 2009-12-28 #i105535#
2844             if ( pModify == 0 )
2845             // <--
2846             {
2847                 const SwNodeIndex &rIdx = aAnchorAttr.GetCntntAnchor()->nNode;
2848 				SwSpzFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts();
2849 				for( sal_uInt16 i = 0; i < rFmts.Count(); ++i )
2850 				{
2851 					SwFrmFmt* pFlyFmt = rFmts[i];
2852 					if( pFlyFmt->GetCntnt().GetCntntIdx() &&
2853 						rIdx == *pFlyFmt->GetCntnt().GetCntntIdx() )
2854 					{
2855 						pModify = pFlyFmt;
2856 						break;
2857 					}
2858 				}
2859 			}
2860 		}
2861 		break;
2862 
2863     case FLY_AT_PAGE:
2864         {
2865             sal_uInt16 nPgNum = aAnchorAttr.GetPageNum();
2866             SwPageFrm *pPage = (SwPageFrm*)GetDoc()->GetCurrentLayout()->Lower();	//swmod 080218
2867             if( nPgNum == 0 && aAnchorAttr.GetCntntAnchor() )
2868             {
2869                 SwCntntNode *pCNd = aAnchorAttr.GetCntntAnchor()->nNode.GetNode().GetCntntNode();
2870                 SwIterator<SwFrm,SwCntntNode> aIter( *pCNd );
2871                 for ( SwFrm* pFrm = aIter.First(); pFrm != NULL; pFrm = aIter.Next() )
2872                 {
2873                     pPage = pFrm->FindPageFrm();
2874                     if( pPage )
2875                     {
2876                         nPgNum = pPage->GetPhyPageNum();
2877                         aAnchorAttr.SetPageNum( nPgNum );
2878                         aAnchorAttr.SetAnchor( 0 );
2879                         SetFmtAttr( aAnchorAttr );
2880                         break;
2881                     }
2882                 }
2883             }
2884             while ( pPage )
2885             {
2886                 if ( pPage->GetPhyPageNum() == nPgNum )
2887                 {
2888                     pPage->PlaceFly( 0, this );
2889                     break;
2890                 }
2891                 pPage = (SwPageFrm*)pPage->GetNext();
2892             }
2893         }
2894         break;
2895     default:
2896         break;
2897 	}
2898 
2899 	if( pModify )
2900 	{
2901         SwIterator<SwFrm,SwModify> aIter( *pModify );
2902 		for( SwFrm *pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
2903 		{
2904 			sal_Bool bAdd = !pFrm->IsCntntFrm() ||
2905 							!((SwCntntFrm*)pFrm)->IsFollow();
2906 
2907             if ( FLY_AT_FLY == aAnchorAttr.GetAnchorId() && !pFrm->IsFlyFrm() )
2908             {
2909                 // --> OD 2009-12-28 #i105535#
2910                 // fallback to anchor type at-paragraph, if no fly frame is found.
2911 //                pFrm = pFrm->FindFlyFrm();
2912                 SwFrm* pFlyFrm = pFrm->FindFlyFrm();
2913                 if ( pFlyFrm )
2914                 {
2915                     pFrm = pFlyFrm;
2916                 }
2917                 else
2918                 {
2919                     aAnchorAttr.SetType( FLY_AT_PARA );
2920                     SetFmtAttr( aAnchorAttr );
2921                     MakeFrms();
2922                     return;
2923                 }
2924                 // <--
2925             }
2926 
2927 			if( pFrm->GetDrawObjs() )
2928 			{
2929                 // --> OD 2004-07-01 #i28701# - new type <SwSortedObjs>
2930                 SwSortedObjs &rObjs = *pFrm->GetDrawObjs();
2931 				for( sal_uInt16 i = 0; i < rObjs.Count(); ++i)
2932 				{
2933                     // --> OD 2004-07-01 #i28701# - consider changed type of
2934                     // <SwSortedObjs> entries.
2935                     SwAnchoredObject* pObj = rObjs[i];
2936                     if( pObj->ISA(SwFlyFrm) &&
2937                         (&pObj->GetFrmFmt()) == this )
2938 					{
2939 						bAdd = sal_False;
2940 						break;
2941 					}
2942 				}
2943 			}
2944 
2945 			if( bAdd )
2946 			{
2947 				SwFlyFrm *pFly = 0;
2948                 switch( aAnchorAttr.GetAnchorId() )
2949 				{
2950 				case FLY_AT_FLY:
2951 					pFly = new SwFlyLayFrm( this, pFrm, pFrm );
2952 					break;
2953 
2954                 case FLY_AT_PARA:
2955                 case FLY_AT_CHAR:
2956 					pFly = new SwFlyAtCntFrm( this, pFrm, pFrm );
2957 					break;
2958 
2959                 case FLY_AS_CHAR:
2960 					pFly = new SwFlyInCntFrm( this, pFrm, pFrm );
2961 					break;
2962                 default:
2963                     ASSERT( sal_False, "New anchor type" )
2964                     break;
2965                 }
2966 				pFrm->AppendFly( pFly );
2967 				SwPageFrm *pPage = pFly->FindPageFrm();
2968 				if( pPage )
2969 					::RegistFlys( pPage, pFly );
2970             }
2971 		}
2972 	}
2973 }
2974 
GetFrm(const Point * pPoint,const sal_Bool bCalcFrm) const2975 SwFlyFrm* SwFlyFrmFmt::GetFrm( const Point* pPoint, const sal_Bool bCalcFrm ) const
2976 {
2977 	return (SwFlyFrm*)::GetFrmOfModify( 0, *(SwModify*)this, FRM_FLY,
2978 											pPoint, 0, bCalcFrm );
2979 }
2980 
GetAnchoredObj(const Point * pPoint,const sal_Bool bCalcFrm) const2981 SwAnchoredObject* SwFlyFrmFmt::GetAnchoredObj( const Point* pPoint, const sal_Bool bCalcFrm ) const
2982 {
2983     SwFlyFrm* pFlyFrm( GetFrm( pPoint, bCalcFrm ) );
2984     if ( pFlyFrm )
2985     {
2986         return dynamic_cast<SwAnchoredObject*>(pFlyFrm);
2987     }
2988     else
2989     {
2990         return 0L;
2991     }
2992 }
2993 
2994 
GetInfo(SfxPoolItem & rInfo) const2995 sal_Bool SwFlyFrmFmt::GetInfo( SfxPoolItem& rInfo ) const
2996 {
2997     sal_Bool bRet = sal_True;
2998     switch( rInfo.Which() )
2999     {
3000     case RES_CONTENT_VISIBLE:
3001         {
3002             ((SwPtrMsgPoolItem&)rInfo).pObject = SwIterator<SwFrm,SwFmt>::FirstElement( *this );
3003         }
3004         bRet = sal_False;
3005         break;
3006 
3007     default:
3008         bRet = SwFrmFmt::GetInfo( rInfo );
3009         break;
3010     }
3011     return bRet;
3012 }
3013 
3014 // --> OD 2009-07-14 #i73249#
SetObjTitle(const String & rTitle,bool bBroadcast)3015 void SwFlyFrmFmt::SetObjTitle( const String& rTitle, bool bBroadcast )
3016 {
3017     SdrObject* pMasterObject = FindSdrObject();
3018     ASSERT( pMasterObject,
3019             "<SwNoTxtNode::SetObjTitle(..)> - missing <SdrObject> instance" );
3020     if ( !pMasterObject )
3021     {
3022         return;
3023     }
3024 
3025     if( bBroadcast )
3026     {
3027         SwStringMsgPoolItem aOld( RES_TITLE_CHANGED, pMasterObject->GetTitle() );
3028         SwStringMsgPoolItem aNew( RES_TITLE_CHANGED, rTitle );
3029         pMasterObject->SetTitle( rTitle );
3030         ModifyNotification( &aOld, &aNew );
3031     }
3032     else
3033     {
3034         pMasterObject->SetTitle( rTitle );
3035     }
3036 }
3037 
GetObjTitle() const3038 const String SwFlyFrmFmt::GetObjTitle() const
3039 {
3040     const SdrObject* pMasterObject = FindSdrObject();
3041     ASSERT( pMasterObject,
3042             "<SwFlyFrmFmt::GetObjTitle(..)> - missing <SdrObject> instance" );
3043     if ( !pMasterObject )
3044     {
3045         return aEmptyStr;
3046     }
3047 
3048     return pMasterObject->GetTitle();
3049 }
3050 
SetObjDescription(const String & rDescription,bool bBroadcast)3051 void SwFlyFrmFmt::SetObjDescription( const String& rDescription, bool bBroadcast )
3052 {
3053     SdrObject* pMasterObject = FindSdrObject();
3054     ASSERT( pMasterObject,
3055             "<SwFlyFrmFmt::SetDescription(..)> - missing <SdrObject> instance" );
3056     if ( !pMasterObject )
3057     {
3058         return;
3059     }
3060 
3061     if( bBroadcast )
3062     {
3063         SwStringMsgPoolItem aOld( RES_DESCRIPTION_CHANGED, pMasterObject->GetDescription() );
3064         SwStringMsgPoolItem aNew( RES_DESCRIPTION_CHANGED, rDescription );
3065         pMasterObject->SetDescription( rDescription );
3066         ModifyNotification( &aOld, &aNew );
3067     }
3068     else
3069     {
3070         pMasterObject->SetDescription( rDescription );
3071     }
3072 }
3073 
GetObjDescription() const3074 const String SwFlyFrmFmt::GetObjDescription() const
3075 {
3076     const SdrObject* pMasterObject = FindSdrObject();
3077     ASSERT( pMasterObject,
3078             "<SwNoTxtNode::GetDescription(..)> - missing <SdrObject> instance" );
3079     if ( !pMasterObject )
3080     {
3081         return aEmptyStr;
3082     }
3083 
3084     return pMasterObject->GetDescription();
3085 }
3086 // <--
3087 
3088 /** SwFlyFrmFmt::IsBackgroundTransparent - for #99657#
3089 
3090     OD 22.08.2002 - overloading virtual method and its default implementation,
3091     because format of fly frame provides transparent backgrounds.
3092     Method determines, if background of fly frame is transparent.
3093 
3094     @author OD
3095 
3096     @return true, if background color is transparent, but not "no fill"
3097     or the transparency of a existing background graphic is set.
3098 */
IsBackgroundTransparent() const3099 sal_Bool SwFlyFrmFmt::IsBackgroundTransparent() const
3100 {
3101     //UUUU
3102     if(supportsFullDrawingLayerFillAttributeSet() && getSdrAllFillAttributesHelper())
3103     {
3104         return getSdrAllFillAttributesHelper()->isTransparent();
3105     }
3106 
3107     /// NOTE: If background color is "no fill"/"auto fill" (COL_TRANSPARENT)
3108     ///     and there is no background graphic, it "inherites" the background
3109     ///     from its anchor.
3110     if ( (GetBackground().GetColor().GetTransparency() != 0) &&
3111          (GetBackground().GetColor() != COL_TRANSPARENT)
3112        )
3113     {
3114         return sal_True;
3115     }
3116     else
3117     {
3118         const GraphicObject *pTmpGrf =
3119                 static_cast<const GraphicObject*>(GetBackground().GetGraphicObject());
3120         if ( (pTmpGrf) &&
3121              (pTmpGrf->GetAttr().GetTransparency() != 0)
3122            )
3123         {
3124             return sal_True;
3125         }
3126     }
3127 
3128     return sal_False;
3129 }
3130 
3131 /** SwFlyFrmFmt::IsBackgroundBrushInherited - for #103898#
3132 
3133     OD 08.10.2002 - method to determine, if the brush for drawing the
3134     background is "inherited" from its parent/grandparent.
3135     This is the case, if no background graphic is set and the background
3136     color is "no fill"/"auto fill"
3137     NOTE: condition is "copied" from method <SwFrm::GetBackgroundBrush(..).
3138 
3139     @author OD
3140 
3141     @return true, if background brush is "inherited" from parent/grandparent
3142 */
IsBackgroundBrushInherited() const3143 sal_Bool SwFlyFrmFmt::IsBackgroundBrushInherited() const
3144 {
3145     //UUUU
3146     if(supportsFullDrawingLayerFillAttributeSet() && getSdrAllFillAttributesHelper())
3147     {
3148         return !getSdrAllFillAttributesHelper()->isUsed();
3149     }
3150     else if ( (GetBackground().GetColor() == COL_TRANSPARENT) &&
3151          !(GetBackground().GetGraphicObject()) )
3152     {
3153         return sal_True;
3154     }
3155 
3156     return sal_False;
3157 }
3158 
3159 // --> OD 2006-02-28 #125892#
SwHandleAnchorNodeChg(SwFlyFrmFmt & _rFlyFrmFmt,const SwFmtAnchor & _rNewAnchorFmt,SwFlyFrm * _pKeepThisFlyFrm)3160 SwHandleAnchorNodeChg::SwHandleAnchorNodeChg( SwFlyFrmFmt& _rFlyFrmFmt,
3161                                               const SwFmtAnchor& _rNewAnchorFmt,
3162                                               SwFlyFrm* _pKeepThisFlyFrm )
3163     : mrFlyFrmFmt( _rFlyFrmFmt ),
3164       mbAnchorNodeChanged( false )
3165 {
3166     const RndStdIds nNewAnchorType( _rNewAnchorFmt.GetAnchorId() );
3167     if ( ((nNewAnchorType == FLY_AT_PARA) ||
3168           (nNewAnchorType == FLY_AT_CHAR)) &&
3169          _rNewAnchorFmt.GetCntntAnchor() &&
3170          _rNewAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode() )
3171     {
3172         const SwFmtAnchor& aOldAnchorFmt( _rFlyFrmFmt.GetAnchor() );
3173         if ( aOldAnchorFmt.GetAnchorId() == nNewAnchorType &&
3174              aOldAnchorFmt.GetCntntAnchor() &&
3175              aOldAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode() &&
3176              aOldAnchorFmt.GetCntntAnchor()->nNode !=
3177                                     _rNewAnchorFmt.GetCntntAnchor()->nNode )
3178         {
3179             // determine 'old' number of anchor frames
3180             sal_uInt32 nOldNumOfAnchFrm( 0L );
3181             SwIterator<SwFrm,SwCntntNode> aOldIter( *(aOldAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode()) );
3182             for( SwFrm* pOld = aOldIter.First(); pOld; pOld = aOldIter.Next() )
3183             {
3184                 ++nOldNumOfAnchFrm;
3185             }
3186             // determine 'new' number of anchor frames
3187             sal_uInt32 nNewNumOfAnchFrm( 0L );
3188             SwIterator<SwFrm,SwCntntNode> aNewIter( *(_rNewAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetCntntNode()) );
3189             for( SwFrm* pNew = aNewIter.First(); pNew; pNew = aNewIter.Next() )
3190             {
3191                 ++nNewNumOfAnchFrm;
3192             }
3193             if ( nOldNumOfAnchFrm != nNewNumOfAnchFrm )
3194             {
3195                 // delete existing fly frames except <_pKeepThisFlyFrm>
3196                 SwIterator<SwFrm,SwFmt> aIter( mrFlyFrmFmt );
3197                 SwFrm* pFrm = aIter.First();
3198                 if ( pFrm )
3199                 {
3200                     do {
3201                         if ( pFrm != _pKeepThisFlyFrm )
3202                         {
3203                             pFrm->Cut();
3204                             delete pFrm;
3205                         }
3206                     } while( 0 != ( pFrm = aIter.Next() ));
3207                 }
3208                 // indicate, that re-creation of fly frames necessary
3209                 mbAnchorNodeChanged = true;
3210             }
3211         }
3212     }
3213 }
3214 
~SwHandleAnchorNodeChg()3215 SwHandleAnchorNodeChg::~SwHandleAnchorNodeChg()
3216 {
3217     if ( mbAnchorNodeChanged )
3218     {
3219         mrFlyFrmFmt.MakeFrms();
3220     }
3221 }
3222 // <--
3223 //	class SwDrawFrmFmt
3224 //	Implementierung teilweise inline im hxx
3225 
3226 TYPEINIT1( SwDrawFrmFmt, SwFrmFmt );
3227 IMPL_FIXEDMEMPOOL_NEWDEL( SwDrawFrmFmt,	10, 10 )
3228 
~SwDrawFrmFmt()3229 SwDrawFrmFmt::~SwDrawFrmFmt()
3230 {
3231 	SwContact *pContact = FindContactObj();
3232 	delete pContact;
3233 }
3234 
MakeFrms()3235 void SwDrawFrmFmt::MakeFrms()
3236 {
3237 	SwDrawContact *pContact = (SwDrawContact*)FindContactObj();
3238     if ( pContact )
3239          pContact->ConnectToLayout();
3240 }
3241 
DelFrms()3242 void SwDrawFrmFmt::DelFrms()
3243 {
3244 	SwDrawContact *pContact = (SwDrawContact *)FindContactObj();
3245 	if ( pContact ) //fuer den Reader und andere Unabwaegbarkeiten.
3246 		pContact->DisconnectFromLayout();
3247 }
3248 
3249 // --> OD 2004-07-27 #i31698#
GetLayoutDir() const3250 SwFrmFmt::tLayoutDir SwDrawFrmFmt::GetLayoutDir() const
3251 {
3252     return meLayoutDir;
3253 }
3254 
SetLayoutDir(const SwFrmFmt::tLayoutDir _eLayoutDir)3255 void SwDrawFrmFmt::SetLayoutDir( const SwFrmFmt::tLayoutDir _eLayoutDir )
3256 {
3257     meLayoutDir = _eLayoutDir;
3258 }
3259 // <--
3260 
3261 // --> OD 2004-08-06 #i28749#
GetPositionLayoutDir() const3262 sal_Int16 SwDrawFrmFmt::GetPositionLayoutDir() const
3263 {
3264     return mnPositionLayoutDir;
3265 }
SetPositionLayoutDir(const sal_Int16 _nPositionLayoutDir)3266 void SwDrawFrmFmt::SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir )
3267 {
3268     switch ( _nPositionLayoutDir )
3269     {
3270         case text::PositionLayoutDir::PositionInHoriL2R:
3271         case text::PositionLayoutDir::PositionInLayoutDirOfAnchor:
3272         {
3273             mnPositionLayoutDir = _nPositionLayoutDir;
3274         }
3275         break;
3276         default:
3277         {
3278             ASSERT( false,
3279                     "<SwDrawFrmFmt::SetPositionLayoutDir(..)> - invalid attribute value." );
3280         }
3281     }
3282 }
3283 // <--
3284 
GetDescription() const3285 String SwDrawFrmFmt::GetDescription() const
3286 {
3287     String aResult;
3288     const SdrObject * pSdrObj = FindSdrObject();
3289 
3290     if (pSdrObj)
3291     {
3292         if (pSdrObj != pSdrObjCached)
3293         {
3294             SdrObject * pSdrObjCopy = pSdrObj->Clone();
3295             SdrUndoNewObj * pSdrUndo = new SdrUndoNewObj(*pSdrObjCopy);
3296             sSdrObjCachedComment = pSdrUndo->GetComment();
3297 
3298             delete pSdrUndo;
3299 
3300             pSdrObjCached = pSdrObj;
3301         }
3302 
3303         aResult = sSdrObjCachedComment;
3304     }
3305     else
3306         aResult = SW_RES(STR_GRAPHIC);
3307 
3308     return aResult;
3309 }
3310 
GetIMapObject(const Point & rPoint,const SwFlyFrm * pFly) const3311 IMapObject* SwFrmFmt::GetIMapObject( const Point& rPoint,
3312 										const SwFlyFrm *pFly ) const
3313 {
3314 	const SwFmtURL &rURL = GetURL();
3315 	if( !rURL.GetMap() )
3316 		return 0;
3317 
3318 	if( !pFly )
3319 	{
3320 		pFly = SwIterator<SwFlyFrm,SwFmt>::FirstElement( *this );
3321 		if( !pFly )
3322 			return 0;
3323 	}
3324 
3325 	//Orignialgroesse fuer OLE und Grafik ist die TwipSize,
3326 	//ansonsten die Groesse vom FrmFmt des Fly.
3327 	const SwFrm *pRef;
3328     SwNoTxtNode *pNd = 0;
3329 	Size aOrigSz;
3330 	if( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
3331 	{
3332 		pRef = pFly->Lower();
3333 		pNd = ((SwCntntFrm*)pRef)->GetNode()->GetNoTxtNode();
3334 		aOrigSz = pNd->GetTwipSize();
3335 	}
3336 	else
3337 	{
3338 		pRef = pFly;
3339 		aOrigSz = pFly->GetFmt()->GetFrmSize().GetSize();
3340 	}
3341 
3342 	if( aOrigSz.Width() != 0 && aOrigSz.Height() != 0 )
3343 	{
3344 		Point aPos( rPoint );
3345 		Size aActSz ( pRef == pFly ? pFly->Frm().SSize() : pRef->Prt().SSize() );
3346 		const MapMode aSrc ( MAP_TWIP );
3347 		const MapMode aDest( MAP_100TH_MM );
3348 		aOrigSz = OutputDevice::LogicToLogic( aOrigSz, aSrc, aDest );
3349 		aActSz  = OutputDevice::LogicToLogic( aActSz,  aSrc, aDest );
3350 		aPos -= pRef->Frm().Pos();
3351 		aPos -= pRef->Prt().Pos();
3352 		aPos    = OutputDevice::LogicToLogic( aPos, aSrc, aDest );
3353 		sal_uInt32 nFlags = 0;
3354 		if ( pFly != pRef && pNd->IsGrfNode() )
3355 		{
3356 			const sal_uInt16 nMirror = pNd->GetSwAttrSet().
3357 										GetMirrorGrf().GetValue();
3358             if ( RES_MIRROR_GRAPH_BOTH == nMirror )
3359 				nFlags = IMAP_MIRROR_HORZ | IMAP_MIRROR_VERT;
3360             else if ( RES_MIRROR_GRAPH_VERT == nMirror )
3361 				nFlags = IMAP_MIRROR_VERT;
3362             else if ( RES_MIRROR_GRAPH_HOR == nMirror )
3363 				nFlags = IMAP_MIRROR_HORZ;
3364 
3365 		}
3366 		return ((ImageMap*)rURL.GetMap())->GetHitIMapObject( aOrigSz,
3367 												aActSz, aPos, nFlags );
3368 	}
3369 
3370 	return 0;
3371 }
3372 
HasCaption() const3373 sal_Bool SwFrmFmt::HasCaption() const
3374 {
3375 	if(pCaptionFmt != NULL && pCaptionFmt->GetDepends())
3376 		return sal_True;
3377 	return sal_False;
3378 }
3379 
SetCaptionFmt(SwFrmFmt * pFmt)3380 void SwFrmFmt::SetCaptionFmt(SwFrmFmt * pFmt)
3381 {
3382 	pCaptionFmt = pFmt;
3383 }
3384 
GetCaptionFmt() const3385 SwFrmFmt* SwFrmFmt::GetCaptionFmt() const
3386 {
3387 	return pCaptionFmt;
3388 }
3389 
3390 //UUUU
getSdrAllFillAttributesHelper() const3391 drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFrmFmt::getSdrAllFillAttributesHelper() const
3392 {
3393     if(supportsFullDrawingLayerFillAttributeSet())
3394     {
3395         // create FillAttributes on demand
3396         if(!maFillAttributes.get())
3397         {
3398             const_cast< SwFrmFmt* >(this)->maFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(GetAttrSet()));
3399         }
3400     }
3401     else
3402     {
3403         // FALLBACKBREAKHERE assert wrong usage
3404         OSL_ENSURE(false, "getSdrAllFillAttributesHelper() call only valid for RES_FLYFRMFMT and RES_FRMFMT (!)");
3405     }
3406 
3407     return maFillAttributes;
3408 }
3409 
3410 // eof
3411