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