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