1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 // MARKER(update_precomp.py): autogen include statement, do not remove 23 #include "precompiled_svx.hxx" 24 25 #include <svx/svdmodel.hxx> 26 27 #include <rtl/uuid.h> 28 #include <com/sun/star/lang/XComponent.hpp> 29 #include <osl/endian.h> 30 #include <rtl/logfile.hxx> 31 #include <math.h> 32 #include <tools/urlobj.hxx> 33 #include <unotools/ucbstreamhelper.hxx> 34 35 #include <tools/string.hxx> 36 #include <svl/whiter.hxx> 37 #include <svx/xit.hxx> 38 #include <svx/xbtmpit.hxx> 39 #include <svx/xlndsit.hxx> 40 #include <svx/xlnedit.hxx> 41 #include <svx/xflgrit.hxx> 42 #include <svx/xflftrit.hxx> 43 #include <svx/xflhtit.hxx> 44 #include <svx/xlnstit.hxx> 45 46 #include "svx/svditext.hxx" 47 #include <editeng/editeng.hxx> // For EditEngine::CreatePool() 48 49 #include <svx/xtable.hxx> 50 51 #include "svx/svditer.hxx" 52 #include <svx/svdtrans.hxx> 53 #include <svx/svdpage.hxx> 54 #include <svx/svdlayer.hxx> 55 #include <svx/svdundo.hxx> 56 #include <svx/svdpool.hxx> 57 #include <svx/svdobj.hxx> 58 #include <svx/svdotext.hxx> // for ReformatAllTextObjects and CalcFieldValue 59 #include <svx/svdetc.hxx> 60 #include <svx/svdoutl.hxx> 61 #include <svx/svdoole2.hxx> 62 #include "svx/svdglob.hxx" // Stringcache 63 #include "svx/svdstr.hrc" // Objektname 64 #include "svdoutlinercache.hxx" 65 66 #include "svx/xflclit.hxx" 67 #include "svx/xflhtit.hxx" 68 #include "svx/xlnclit.hxx" 69 70 #include <svl/asiancfg.hxx> 71 #include "editeng/fontitem.hxx" 72 #include <editeng/colritem.hxx> 73 #include <editeng/fhgtitem.hxx> 74 #include <svl/style.hxx> 75 #include <tools/bigint.hxx> 76 #include <editeng/numitem.hxx> 77 #include <editeng/bulitem.hxx> 78 #include <editeng/outlobj.hxx> 79 #include "editeng/forbiddencharacterstable.hxx" 80 #include <svl/zforlist.hxx> 81 #include <comphelper/processfactory.hxx> 82 83 // #90477# 84 #include <tools/tenccvt.hxx> 85 #include <unotools/syslocale.hxx> 86 87 // #95114# 88 #include <vcl/svapp.hxx> 89 #include <svx/sdr/properties/properties.hxx> 90 #include <editeng/eeitem.hxx> 91 #include <svl/itemset.hxx> 92 93 using namespace ::com::sun::star; 94 using namespace ::com::sun::star::uno; 95 using namespace ::com::sun::star::lang; 96 97 struct SdrModelImpl 98 { 99 SfxUndoManager* mpUndoManager; 100 SdrUndoFactory* mpUndoFactory; 101 bool mbAllowShapePropertyChangeListener; 102 }; 103 104 //////////////////////////////////////////////////////////////////////////////////////////////////// 105 106 DBG_NAME(SdrModel) 107 TYPEINIT1(SdrModel,SfxBroadcaster); 108 void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbeddedHelper,bool bLoadRefCounts) 109 { 110 mpImpl = new SdrModelImpl; 111 mpImpl->mpUndoManager=0; 112 mpImpl->mpUndoFactory=0; 113 mpImpl->mbAllowShapePropertyChangeListener=false; 114 mbInDestruction=false; 115 aObjUnit=SdrEngineDefaults::GetMapFraction(); 116 eObjUnit=SdrEngineDefaults::GetMapUnit(); 117 eUIUnit=FUNIT_MM; 118 aUIScale=Fraction(1,1); 119 nUIUnitComma=0; 120 bUIOnlyComma=sal_False; 121 pLayerAdmin=NULL; 122 pItemPool=pPool; 123 bMyPool=sal_False; 124 m_pEmbeddedHelper=_pEmbeddedHelper; 125 pDrawOutliner=NULL; 126 pHitTestOutliner=NULL; 127 pRefOutDev=NULL; 128 nProgressAkt=0; 129 nProgressMax=0; 130 nProgressOfs=0; 131 pDefaultStyleSheet=NULL; 132 mpDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj = 0; 133 pLinkManager=NULL; 134 pUndoStack=NULL; 135 pRedoStack=NULL; 136 nMaxUndoCount=16; 137 pAktUndoGroup=NULL; 138 nUndoLevel=0; 139 mbUndoEnabled=true; 140 nProgressPercent=0; 141 nLoadVersion=0; 142 mbChanged = sal_False; 143 bInfoChanged=sal_False; 144 bPagNumsDirty=sal_False; 145 bMPgNumsDirty=sal_False; 146 bPageNotValid=sal_False; 147 bSavePortable=sal_False; 148 bSaveCompressed=sal_False; 149 bSaveNative=sal_False; 150 bSwapGraphics=sal_False; 151 nSwapGraphicsMode=SDR_SWAPGRAPHICSMODE_DEFAULT; 152 bSaveOLEPreview=sal_False; 153 bPasteResize=sal_False; 154 bNoBitmapCaching=sal_False; 155 bReadOnly=sal_False; 156 nStreamCompressMode=COMPRESSMODE_NONE; 157 nStreamNumberFormat=NUMBERFORMAT_INT_BIGENDIAN; 158 nDefaultTabulator=0; 159 mpNumberFormatter = NULL; 160 bTransparentTextFrames=sal_False; 161 bStarDrawPreviewMode = sal_False; 162 nStarDrawPreviewMasterPageNum = SDRPAGE_NOTFOUND; 163 pModelStorage = NULL; 164 mpForbiddenCharactersTable = NULL; 165 mbModelLocked = sal_False; 166 mpOutlinerCache = NULL; 167 mbKernAsianPunctuation = sal_False; 168 mbAddExtLeading = sal_False; 169 mnHandoutPageCount = 0; 170 mbDisableTextEditUsesCommonUndoManager = false; 171 SvxAsianConfig aAsian; 172 mnCharCompressType = aAsian.GetCharDistanceCompression(); 173 174 #ifdef OSL_LITENDIAN 175 nStreamNumberFormat=NUMBERFORMAT_INT_LITTLEENDIAN; 176 #endif 177 if ( pPool == NULL ) 178 { 179 pItemPool=new SdrItemPool(0L, bLoadRefCounts); 180 // Der Outliner hat keinen eigenen Pool, deshalb den der EditEngine 181 SfxItemPool* pOutlPool=EditEngine::CreatePool( bLoadRefCounts ); 182 // OutlinerPool als SecondaryPool des SdrPool 183 pItemPool->SetSecondaryPool(pOutlPool); 184 // Merken, dass ich mir die beiden Pools selbst gemacht habe 185 bMyPool=sal_True; 186 } 187 pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit); 188 189 // SJ: #95129# using static SdrEngineDefaults only if default SvxFontHeight item is not available 190 const SfxPoolItem* pPoolItem = pItemPool->GetPoolDefaultItem( EE_CHAR_FONTHEIGHT ); 191 if ( pPoolItem ) 192 nDefTextHgt = ((SvxFontHeightItem*)pPoolItem)->GetHeight(); 193 else 194 nDefTextHgt = SdrEngineDefaults::GetFontHeight(); 195 196 pItemPool->SetPoolDefaultItem( SdrTextWordWrapItem( sal_False ) ); 197 198 SetTextDefaults(); 199 200 pLayerAdmin=new SdrLayerAdmin; 201 pLayerAdmin->SetModel(this); 202 ImpSetUIUnit(); 203 204 // den DrawOutliner OnDemand erzeugen geht noch nicht, weil ich den Pool 205 // sonst nicht kriege (erst ab 302!) 206 pDrawOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this ); 207 ImpSetOutlinerDefaults(pDrawOutliner, sal_True); 208 209 pHitTestOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this ); 210 ImpSetOutlinerDefaults(pHitTestOutliner, sal_True); 211 } 212 213 SdrModel::SdrModel(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, sal_Bool bLoadRefCounts): 214 maMaPag(1024,32,32), 215 maPages(1024,32,32) 216 { 217 #ifdef TIMELOG 218 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" ); 219 #endif 220 221 DBG_CTOR(SdrModel,NULL); 222 ImpCtor(pPool,pPers,(FASTBOOL)bLoadRefCounts); 223 } 224 225 SdrModel::SdrModel(const String& rPath, SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, sal_Bool bLoadRefCounts): 226 maMaPag(1024,32,32), 227 maPages(1024,32,32), 228 aTablePath(rPath) 229 { 230 #ifdef TIMELOG 231 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" ); 232 #endif 233 234 DBG_CTOR(SdrModel,NULL); 235 ImpCtor(pPool,pPers,(FASTBOOL)bLoadRefCounts); 236 } 237 238 SdrModel::SdrModel(const SdrModel& /*rSrcModel*/): 239 SfxBroadcaster(), 240 tools::WeakBase< SdrModel >(), 241 maMaPag(1024,32,32), 242 maPages(1024,32,32) 243 { 244 #ifdef TIMELOG 245 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" ); 246 #endif 247 248 // noch nicht implementiert 249 DBG_ERROR("SdrModel::CopyCtor() ist noch nicht implementiert"); 250 } 251 252 SdrModel::~SdrModel() 253 { 254 #ifdef TIMELOG 255 RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::~SdrModel(...)" ); 256 #endif 257 258 DBG_DTOR(SdrModel,NULL); 259 260 mbInDestruction = true; 261 262 Broadcast(SdrHint(HINT_MODELCLEARED)); 263 264 delete mpOutlinerCache; 265 266 ClearUndoBuffer(); 267 #ifdef DBG_UTIL 268 if(pAktUndoGroup) 269 { 270 ByteString aStr("Im Dtor des SdrModel steht noch ein offenes Undo rum: \""); 271 272 aStr += ByteString(pAktUndoGroup->GetComment(), gsl_getSystemTextEncoding()); 273 aStr += '\"'; 274 275 DBG_ERROR(aStr.GetBuffer()); 276 } 277 #endif 278 if (pAktUndoGroup!=NULL) 279 delete pAktUndoGroup; 280 281 // #116168# 282 ClearModel(sal_True); 283 284 delete pLayerAdmin; 285 286 // Den DrawOutliner erst nach dem ItemPool löschen, da 287 // der ItemPool Items des DrawOutliners referenziert !!! (<- das war mal) 288 // Wg. Problem bei Malte Reihenfolge wieder umgestellt. 289 // Löschen des Outliners vor dem löschen des ItemPools 290 delete pHitTestOutliner; 291 delete pDrawOutliner; 292 293 // delete StyleSheetPool, derived classes should not do this since 294 // the DrawingEngine may need it in its destrctor (SB) 295 if( mxStyleSheetPool.is() ) 296 { 297 Reference< XComponent > xComponent( dynamic_cast< cppu::OWeakObject* >( mxStyleSheetPool.get() ), UNO_QUERY ); 298 if( xComponent.is() ) try 299 { 300 xComponent->dispose(); 301 } 302 catch( RuntimeException& ) 303 { 304 } 305 mxStyleSheetPool.clear(); 306 } 307 308 if (bMyPool) 309 { 310 // Pools löschen, falls es meine sind 311 SfxItemPool* pOutlPool=pItemPool->GetSecondaryPool(); 312 SfxItemPool::Free(pItemPool); 313 // Der OutlinerPool muss nach dem ItemPool plattgemacht werden, da der 314 // ItemPool SetItems enthält die ihrerseits Items des OutlinerPools 315 // referenzieren (Joe) 316 SfxItemPool::Free(pOutlPool); 317 } 318 319 if( mpForbiddenCharactersTable ) 320 mpForbiddenCharactersTable->release(); 321 322 if(mpNumberFormatter) 323 delete mpNumberFormatter; 324 325 delete mpImpl->mpUndoFactory; 326 delete mpImpl; 327 } 328 329 bool SdrModel::IsInDestruction() const 330 { 331 return mbInDestruction; 332 } 333 334 const SvNumberFormatter& SdrModel::GetNumberFormatter() const 335 { 336 if(!mpNumberFormatter) 337 { 338 // use cast here since from outside view this IS a const method 339 ((SdrModel*)this)->mpNumberFormatter = new SvNumberFormatter( 340 ::comphelper::getProcessServiceFactory(), LANGUAGE_SYSTEM); 341 } 342 343 return *mpNumberFormatter; 344 } 345 346 // noch nicht implementiert: 347 void SdrModel::operator=(const SdrModel& /*rSrcModel*/) 348 { 349 DBG_ERROR("SdrModel::operator=() ist noch nicht implementiert"); 350 } 351 352 FASTBOOL SdrModel::operator==(const SdrModel& /*rCmpModel*/) const 353 { 354 DBG_ERROR("SdrModel::operator==() ist noch nicht implementiert"); 355 return sal_False; 356 } 357 358 void SdrModel::SetSwapGraphics( FASTBOOL bSwap ) 359 { 360 bSwapGraphics = bSwap; 361 } 362 363 FASTBOOL SdrModel::IsReadOnly() const 364 { 365 return bReadOnly; 366 } 367 368 void SdrModel::SetReadOnly(FASTBOOL bYes) 369 { 370 bReadOnly=bYes; 371 } 372 373 //////////////////////////////////////////////////////////////////////////////////////////////////// 374 375 void SdrModel::SetMaxUndoActionCount(sal_uIntPtr nAnz) 376 { 377 if (nAnz<1) nAnz=1; 378 nMaxUndoCount=nAnz; 379 if (pUndoStack!=NULL) { 380 while (pUndoStack->Count()>nMaxUndoCount) { 381 delete (SfxUndoAction*) pUndoStack->Remove(pUndoStack->Count()); 382 } 383 } 384 } 385 386 void SdrModel::ClearUndoBuffer() 387 { 388 if (pUndoStack!=NULL) { 389 while (pUndoStack->Count()!=0) { 390 delete (SfxUndoAction*) pUndoStack->Remove(pUndoStack->Count()-1); 391 } 392 delete pUndoStack; 393 pUndoStack=NULL; 394 } 395 if (pRedoStack!=NULL) { 396 while (pRedoStack->Count()!=0) { 397 delete (SfxUndoAction*) pRedoStack->Remove(pRedoStack->Count()-1); 398 } 399 delete pRedoStack; 400 pRedoStack=NULL; 401 } 402 } 403 404 FASTBOOL SdrModel::Undo() 405 { 406 FASTBOOL bRet=sal_False; 407 if( mpImpl->mpUndoManager ) 408 { 409 DBG_ERROR("svx::SdrModel::Undo(), method not supported with application undo manager!"); 410 } 411 else 412 { 413 SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0); 414 if(pDo!=NULL) 415 { 416 const bool bWasUndoEnabled = mbUndoEnabled; 417 mbUndoEnabled = false; 418 pDo->Undo(); 419 if(pRedoStack==NULL) 420 pRedoStack=new Container(1024,16,16); 421 pRedoStack->Insert(pUndoStack->Remove((sal_uIntPtr)0),(sal_uIntPtr)0); 422 mbUndoEnabled = bWasUndoEnabled; 423 } 424 } 425 return bRet; 426 } 427 428 FASTBOOL SdrModel::Redo() 429 { 430 FASTBOOL bRet=sal_False; 431 if( mpImpl->mpUndoManager ) 432 { 433 DBG_ERROR("svx::SdrModel::Redo(), method not supported with application undo manager!"); 434 } 435 else 436 { 437 SfxUndoAction* pDo=(SfxUndoAction*)GetRedoAction(0); 438 if(pDo!=NULL) 439 { 440 const bool bWasUndoEnabled = mbUndoEnabled; 441 mbUndoEnabled = false; 442 pDo->Redo(); 443 if(pUndoStack==NULL) 444 pUndoStack=new Container(1024,16,16); 445 pUndoStack->Insert(pRedoStack->Remove((sal_uIntPtr)0),(sal_uIntPtr)0); 446 mbUndoEnabled = bWasUndoEnabled; 447 } 448 } 449 return bRet; 450 } 451 452 FASTBOOL SdrModel::Repeat(SfxRepeatTarget& rView) 453 { 454 FASTBOOL bRet=sal_False; 455 if( mpImpl->mpUndoManager ) 456 { 457 DBG_ERROR("svx::SdrModel::Redo(), method not supported with application undo manager!"); 458 } 459 else 460 { 461 SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0); 462 if(pDo!=NULL) 463 { 464 if(pDo->CanRepeat(rView)) 465 { 466 pDo->Repeat(rView); 467 bRet=sal_True; 468 } 469 } 470 } 471 return bRet; 472 } 473 474 void SdrModel::ImpPostUndoAction(SdrUndoAction* pUndo) 475 { 476 DBG_ASSERT( mpImpl->mpUndoManager == 0, "svx::SdrModel::ImpPostUndoAction(), method not supported with application undo manager!" ); 477 if( IsUndoEnabled() ) 478 { 479 if (aUndoLink.IsSet()) 480 { 481 aUndoLink.Call(pUndo); 482 } 483 else 484 { 485 if (pUndoStack==NULL) 486 pUndoStack=new Container(1024,16,16); 487 pUndoStack->Insert(pUndo,(sal_uIntPtr)0); 488 while (pUndoStack->Count()>nMaxUndoCount) 489 { 490 delete (SfxUndoAction*)pUndoStack->Remove(pUndoStack->Count()-1); 491 } 492 if (pRedoStack!=NULL) 493 pRedoStack->Clear(); 494 } 495 } 496 else 497 { 498 delete pUndo; 499 } 500 } 501 502 void SdrModel::BegUndo() 503 { 504 if( mpImpl->mpUndoManager ) 505 { 506 const String aEmpty; 507 mpImpl->mpUndoManager->EnterListAction(aEmpty,aEmpty); 508 nUndoLevel++; 509 } 510 else if( IsUndoEnabled() ) 511 { 512 if(pAktUndoGroup==NULL) 513 { 514 pAktUndoGroup = new SdrUndoGroup(*this); 515 nUndoLevel=1; 516 } 517 else 518 { 519 nUndoLevel++; 520 } 521 } 522 } 523 524 void SdrModel::BegUndo(const XubString& rComment) 525 { 526 if( mpImpl->mpUndoManager ) 527 { 528 const String aEmpty; 529 mpImpl->mpUndoManager->EnterListAction( rComment, aEmpty ); 530 nUndoLevel++; 531 } 532 else if( IsUndoEnabled() ) 533 { 534 BegUndo(); 535 if (nUndoLevel==1) 536 { 537 pAktUndoGroup->SetComment(rComment); 538 } 539 } 540 } 541 542 void SdrModel::BegUndo(const XubString& rComment, const XubString& rObjDescr, SdrRepeatFunc eFunc) 543 { 544 if( mpImpl->mpUndoManager ) 545 { 546 String aComment(rComment); 547 if( aComment.Len() && rObjDescr.Len() ) 548 { 549 String aSearchString(RTL_CONSTASCII_USTRINGPARAM("%1")); 550 aComment.SearchAndReplace(aSearchString, rObjDescr); 551 } 552 const String aEmpty; 553 mpImpl->mpUndoManager->EnterListAction( aComment,aEmpty ); 554 nUndoLevel++; 555 } 556 else if( IsUndoEnabled() ) 557 { 558 BegUndo(); 559 if (nUndoLevel==1) 560 { 561 pAktUndoGroup->SetComment(rComment); 562 pAktUndoGroup->SetObjDescription(rObjDescr); 563 pAktUndoGroup->SetRepeatFunction(eFunc); 564 } 565 } 566 } 567 568 void SdrModel::BegUndo(SdrUndoGroup* pUndoGrp) 569 { 570 if( mpImpl->mpUndoManager ) 571 { 572 DBG_ERROR("svx::SdrModel::BegUndo(), method not supported with application undo manager!" ); 573 nUndoLevel++; 574 } 575 else if( IsUndoEnabled() ) 576 { 577 if (pAktUndoGroup==NULL) 578 { 579 pAktUndoGroup=pUndoGrp; 580 nUndoLevel=1; 581 } 582 else 583 { 584 delete pUndoGrp; 585 nUndoLevel++; 586 } 587 } 588 else 589 { 590 delete pUndoGrp; 591 } 592 } 593 594 void SdrModel::EndUndo() 595 { 596 DBG_ASSERT(nUndoLevel!=0,"SdrModel::EndUndo(): UndoLevel is already 0!"); 597 if( mpImpl->mpUndoManager ) 598 { 599 if( nUndoLevel ) 600 { 601 nUndoLevel--; 602 mpImpl->mpUndoManager->LeaveListAction(); 603 } 604 } 605 else 606 { 607 if(pAktUndoGroup!=NULL && IsUndoEnabled()) 608 { 609 nUndoLevel--; 610 if(nUndoLevel==0) 611 { 612 if(pAktUndoGroup->GetActionCount()!=0) 613 { 614 SdrUndoAction* pUndo=pAktUndoGroup; 615 pAktUndoGroup=NULL; 616 ImpPostUndoAction(pUndo); 617 } 618 else 619 { 620 // was empty 621 delete pAktUndoGroup; 622 pAktUndoGroup=NULL; 623 } 624 } 625 } 626 } 627 } 628 629 void SdrModel::SetUndoComment(const XubString& rComment) 630 { 631 DBG_ASSERT(nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is on level 0!"); 632 633 if( mpImpl->mpUndoManager ) 634 { 635 DBG_ERROR("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" ); 636 } 637 else if( IsUndoEnabled() ) 638 { 639 if(nUndoLevel==1) 640 { 641 pAktUndoGroup->SetComment(rComment); 642 } 643 } 644 } 645 646 void SdrModel::SetUndoComment(const XubString& rComment, const XubString& rObjDescr) 647 { 648 DBG_ASSERT(nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is 0!"); 649 if( mpImpl->mpUndoManager ) 650 { 651 DBG_ERROR("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" ); 652 } 653 else 654 { 655 if (nUndoLevel==1) 656 { 657 pAktUndoGroup->SetComment(rComment); 658 pAktUndoGroup->SetObjDescription(rObjDescr); 659 } 660 } 661 } 662 663 void SdrModel::AddUndo(SdrUndoAction* pUndo) 664 { 665 if( mpImpl->mpUndoManager ) 666 { 667 mpImpl->mpUndoManager->AddUndoAction( pUndo ); 668 } 669 else if( !IsUndoEnabled() ) 670 { 671 delete pUndo; 672 } 673 else 674 { 675 if (pAktUndoGroup!=NULL) 676 { 677 pAktUndoGroup->AddAction(pUndo); 678 } 679 else 680 { 681 ImpPostUndoAction(pUndo); 682 } 683 } 684 } 685 686 void SdrModel::EnableUndo( bool bEnable ) 687 { 688 if( mpImpl->mpUndoManager ) 689 { 690 mpImpl->mpUndoManager->EnableUndo( bEnable ); 691 } 692 else 693 { 694 mbUndoEnabled = bEnable; 695 } 696 } 697 698 bool SdrModel::IsUndoEnabled() const 699 { 700 if( mpImpl->mpUndoManager ) 701 { 702 return mpImpl->mpUndoManager->IsUndoEnabled(); 703 } 704 else 705 { 706 return mbUndoEnabled; 707 } 708 } 709 710 //////////////////////////////////////////////////////////////////////////////////////////////////// 711 712 // #116168# 713 void SdrModel::ClearModel(sal_Bool bCalledFromDestructor) 714 { 715 if(bCalledFromDestructor) 716 { 717 mbInDestruction = true; 718 } 719 720 sal_Int32 i; 721 // delete all drawing pages 722 sal_Int32 nAnz=GetPageCount(); 723 for (i=nAnz-1; i>=0; i--) 724 { 725 DeletePage( (sal_uInt16)i ); 726 } 727 maPages.Clear(); 728 // #109538# 729 PageListChanged(); 730 731 // delete all Masterpages 732 nAnz=GetMasterPageCount(); 733 for(i=nAnz-1; i>=0; i--) 734 { 735 DeleteMasterPage( (sal_uInt16)i ); 736 } 737 maMaPag.Clear(); 738 // #109538# 739 MasterPageListChanged(); 740 741 pLayerAdmin->ClearLayer(); 742 } 743 744 SdrModel* SdrModel::AllocModel() const 745 { 746 SdrModel* pModel=new SdrModel; 747 pModel->SetScaleUnit(eObjUnit,aObjUnit); 748 return pModel; 749 } 750 751 SdrPage* SdrModel::AllocPage(FASTBOOL bMasterPage) 752 { 753 return new SdrPage(*this,bMasterPage); 754 } 755 756 void SdrModel::SetTextDefaults() const 757 { 758 SetTextDefaults( pItemPool, nDefTextHgt ); 759 } 760 761 void ImpGetDefaultFontsLanguage( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rComplex) 762 { 763 const sal_uInt16 nItemCnt = 3; 764 static struct { 765 sal_uInt16 nFntType, nLanguage; 766 } aOutTypeArr[ nItemCnt ] = { 767 { DEFAULTFONT_LATIN_TEXT, LANGUAGE_ENGLISH_US }, 768 { DEFAULTFONT_CJK_TEXT, LANGUAGE_ENGLISH_US }, 769 { DEFAULTFONT_CTL_TEXT, LANGUAGE_ARABIC_SAUDI_ARABIA } 770 }; 771 SvxFontItem* aItemArr[ nItemCnt ] = { &rLatin, &rAsian, &rComplex }; 772 773 for( sal_uInt16 n = 0; n < nItemCnt; ++n ) 774 { 775 Font aFnt( OutputDevice::GetDefaultFont( 776 aOutTypeArr[ n ].nFntType, aOutTypeArr[ n ].nLanguage, 777 DEFAULTFONT_FLAGS_ONLYONE, 0 )); 778 SvxFontItem* pI = aItemArr[ n ]; 779 pI->SetFamily( aFnt.GetFamily()); 780 pI->SetFamilyName( aFnt.GetName()); 781 pI->SetStyleName( String() ); 782 pI->SetPitch( aFnt.GetPitch()); 783 pI->SetCharSet( aFnt.GetCharSet() ); 784 } 785 } 786 787 void SdrModel::SetTextDefaults( SfxItemPool* pItemPool, sal_uIntPtr nDefTextHgt ) 788 { 789 // #95114# set application-language specific dynamic pool language defaults 790 SvxFontItem aSvxFontItem( EE_CHAR_FONTINFO) ; 791 SvxFontItem aSvxFontItemCJK(EE_CHAR_FONTINFO_CJK); 792 SvxFontItem aSvxFontItemCTL(EE_CHAR_FONTINFO_CTL); 793 sal_uInt16 nLanguage(Application::GetSettings().GetLanguage()); 794 795 // get DEFAULTFONT_LATIN_TEXT and set at pool as dynamic default 796 Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_LATIN_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0)); 797 aSvxFontItem.SetFamily(aFont.GetFamily()); 798 aSvxFontItem.SetFamilyName(aFont.GetName()); 799 aSvxFontItem.SetStyleName(String()); 800 aSvxFontItem.SetPitch( aFont.GetPitch()); 801 aSvxFontItem.SetCharSet( aFont.GetCharSet() ); 802 pItemPool->SetPoolDefaultItem(aSvxFontItem); 803 804 // get DEFAULTFONT_CJK_TEXT and set at pool as dynamic default 805 Font aFontCJK(OutputDevice::GetDefaultFont(DEFAULTFONT_CJK_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0)); 806 aSvxFontItemCJK.SetFamily( aFontCJK.GetFamily()); 807 aSvxFontItemCJK.SetFamilyName(aFontCJK.GetName()); 808 aSvxFontItemCJK.SetStyleName(String()); 809 aSvxFontItemCJK.SetPitch( aFontCJK.GetPitch()); 810 aSvxFontItemCJK.SetCharSet( aFontCJK.GetCharSet()); 811 pItemPool->SetPoolDefaultItem(aSvxFontItemCJK); 812 813 // get DEFAULTFONT_CTL_TEXT and set at pool as dynamic default 814 Font aFontCTL(OutputDevice::GetDefaultFont(DEFAULTFONT_CTL_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0)); 815 aSvxFontItemCTL.SetFamily(aFontCTL.GetFamily()); 816 aSvxFontItemCTL.SetFamilyName(aFontCTL.GetName()); 817 aSvxFontItemCTL.SetStyleName(String()); 818 aSvxFontItemCTL.SetPitch( aFontCTL.GetPitch() ); 819 aSvxFontItemCTL.SetCharSet( aFontCTL.GetCharSet()); 820 pItemPool->SetPoolDefaultItem(aSvxFontItemCTL); 821 822 // set dynamic FontHeight defaults 823 pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT ) ); 824 pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CJK ) ); 825 pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CTL ) ); 826 827 // set FontColor defaults 828 pItemPool->SetPoolDefaultItem( SvxColorItem(SdrEngineDefaults::GetFontColor(), EE_CHAR_COLOR) ); 829 } 830 831 SdrOutliner& SdrModel::GetDrawOutliner(const SdrTextObj* pObj) const 832 { 833 pDrawOutliner->SetTextObj(pObj); 834 return *pDrawOutliner; 835 } 836 837 boost::shared_ptr< SdrOutliner > SdrModel::CreateDrawOutliner(const SdrTextObj* pObj) 838 { 839 boost::shared_ptr< SdrOutliner > xDrawOutliner( SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this ) ); 840 ImpSetOutlinerDefaults(xDrawOutliner.get(), sal_True); 841 xDrawOutliner->SetTextObj(pObj); 842 return xDrawOutliner; 843 } 844 845 const SdrTextObj* SdrModel::GetFormattingTextObj() const 846 { 847 if (pDrawOutliner!=NULL) { 848 return pDrawOutliner->GetTextObj(); 849 } 850 return NULL; 851 } 852 853 void SdrModel::ImpSetOutlinerDefaults( SdrOutliner* pOutliner, sal_Bool bInit ) 854 { 855 /************************************************************************** 856 * Initialisierung der Outliner für Textausgabe und HitTest 857 **************************************************************************/ 858 if( bInit ) 859 { 860 pOutliner->EraseVirtualDevice(); 861 pOutliner->SetUpdateMode(sal_False); 862 pOutliner->SetEditTextObjectPool(pItemPool); 863 pOutliner->SetDefTab(nDefaultTabulator); 864 } 865 866 pOutliner->SetRefDevice(GetRefDevice()); 867 pOutliner->SetForbiddenCharsTable(GetForbiddenCharsTable()); 868 pOutliner->SetAsianCompressionMode( mnCharCompressType ); 869 pOutliner->SetKernAsianPunctuation( IsKernAsianPunctuation() ); 870 pOutliner->SetAddExtLeading( IsAddExtLeading() ); 871 872 if ( !GetRefDevice() ) 873 { 874 MapMode aMapMode(eObjUnit, Point(0,0), aObjUnit, aObjUnit); 875 pOutliner->SetRefMapMode(aMapMode); 876 } 877 } 878 879 void SdrModel::SetRefDevice(OutputDevice* pDev) 880 { 881 pRefOutDev=pDev; 882 ImpSetOutlinerDefaults( pDrawOutliner ); 883 ImpSetOutlinerDefaults( pHitTestOutliner ); 884 RefDeviceChanged(); 885 } 886 887 void SdrModel::ImpReformatAllTextObjects() 888 { 889 if( isLocked() ) 890 return; 891 892 sal_uInt16 nAnz=GetMasterPageCount(); 893 sal_uInt16 nNum; 894 for (nNum=0; nNum<nAnz; nNum++) { 895 GetMasterPage(nNum)->ReformatAllTextObjects(); 896 } 897 nAnz=GetPageCount(); 898 for (nNum=0; nNum<nAnz; nNum++) { 899 GetPage(nNum)->ReformatAllTextObjects(); 900 } 901 } 902 903 /** #103122# 904 steps over all available pages and sends notify messages to 905 all edge objects that are connected to other objects so that 906 they may reposition itselfs 907 */ 908 void SdrModel::ImpReformatAllEdgeObjects() 909 { 910 if( isLocked() ) 911 return; 912 913 sal_uInt16 nAnz=GetMasterPageCount(); 914 sal_uInt16 nNum; 915 for (nNum=0; nNum<nAnz; nNum++) 916 { 917 GetMasterPage(nNum)->ReformatAllEdgeObjects(); 918 } 919 nAnz=GetPageCount(); 920 for (nNum=0; nNum<nAnz; nNum++) 921 { 922 GetPage(nNum)->ReformatAllEdgeObjects(); 923 } 924 } 925 926 SvStream* SdrModel::GetDocumentStream(SdrDocumentStreamInfo& /*rStreamInfo*/) const 927 { 928 return NULL; 929 } 930 931 // Die Vorlagenattribute der Zeichenobjekte in harte Attribute verwandeln. 932 void SdrModel::BurnInStyleSheetAttributes() 933 { 934 sal_uInt16 nAnz=GetMasterPageCount(); 935 sal_uInt16 nNum; 936 for (nNum=0; nNum<nAnz; nNum++) { 937 GetMasterPage(nNum)->BurnInStyleSheetAttributes(); 938 } 939 nAnz=GetPageCount(); 940 for (nNum=0; nNum<nAnz; nNum++) { 941 GetPage(nNum)->BurnInStyleSheetAttributes(); 942 } 943 } 944 945 void SdrModel::RefDeviceChanged() 946 { 947 Broadcast(SdrHint(HINT_REFDEVICECHG)); 948 ImpReformatAllTextObjects(); 949 } 950 951 void SdrModel::SetDefaultFontHeight(sal_uIntPtr nVal) 952 { 953 if (nVal!=nDefTextHgt) { 954 nDefTextHgt=nVal; 955 Broadcast(SdrHint(HINT_DEFFONTHGTCHG)); 956 ImpReformatAllTextObjects(); 957 } 958 } 959 960 void SdrModel::SetDefaultTabulator(sal_uInt16 nVal) 961 { 962 if (nDefaultTabulator!=nVal) { 963 nDefaultTabulator=nVal; 964 Outliner& rOutliner=GetDrawOutliner(); 965 rOutliner.SetDefTab(nVal); 966 Broadcast(SdrHint(HINT_DEFAULTTABCHG)); 967 ImpReformatAllTextObjects(); 968 } 969 } 970 971 void SdrModel::ImpSetUIUnit() 972 { 973 if(0 == aUIScale.GetNumerator() || 0 == aUIScale.GetDenominator()) 974 { 975 aUIScale = Fraction(1,1); 976 } 977 978 // set start values 979 nUIUnitComma = 0; 980 sal_Int64 nMul(1); 981 sal_Int64 nDiv(1); 982 983 // normalize on meters resp. inch 984 switch (eObjUnit) 985 { 986 case MAP_100TH_MM : nUIUnitComma+=5; break; 987 case MAP_10TH_MM : nUIUnitComma+=4; break; 988 case MAP_MM : nUIUnitComma+=3; break; 989 case MAP_CM : nUIUnitComma+=2; break; 990 case MAP_1000TH_INCH: nUIUnitComma+=3; break; 991 case MAP_100TH_INCH : nUIUnitComma+=2; break; 992 case MAP_10TH_INCH : nUIUnitComma+=1; break; 993 case MAP_INCH : nUIUnitComma+=0; break; 994 case MAP_POINT : nDiv=72; break; // 1Pt = 1/72" 995 case MAP_TWIP : nDiv=144; nUIUnitComma++; break; // 1Twip = 1/1440" 996 case MAP_PIXEL : break; 997 case MAP_SYSFONT : break; 998 case MAP_APPFONT : break; 999 case MAP_RELATIVE : break; 1000 default: break; 1001 } // switch 1002 1003 // 1 mile = 8 furlong = 63.360" = 1.609.344,0mm 1004 // 1 furlong = 10 chains = 7.920" = 201.168,0mm 1005 // 1 chain = 4 poles = 792" = 20.116,8mm 1006 // 1 pole = 5 1/2 yd = 198" = 5.029,2mm 1007 // 1 yd = 3 ft = 36" = 914,4mm 1008 // 1 ft = 12 " = 1" = 304,8mm 1009 switch (eUIUnit) 1010 { 1011 case FUNIT_NONE : break; 1012 // Metrisch 1013 case FUNIT_100TH_MM: nUIUnitComma-=5; break; 1014 case FUNIT_MM : nUIUnitComma-=3; break; 1015 case FUNIT_CM : nUIUnitComma-=2; break; 1016 case FUNIT_M : nUIUnitComma+=0; break; 1017 case FUNIT_KM : nUIUnitComma+=3; break; 1018 // Inch 1019 case FUNIT_TWIP : nMul=144; nUIUnitComma--; break; // 1Twip = 1/1440" 1020 case FUNIT_POINT : nMul=72; break; // 1Pt = 1/72" 1021 case FUNIT_PICA : nMul=6; break; // 1Pica = 1/6" ? 1022 case FUNIT_INCH : break; // 1" = 1" 1023 case FUNIT_FOOT : nDiv*=12; break; // 1Ft = 12" 1024 case FUNIT_MILE : nDiv*=6336; nUIUnitComma++; break; // 1mile = 63360" 1025 // sonstiges 1026 case FUNIT_CUSTOM : break; 1027 case FUNIT_PERCENT: nUIUnitComma+=2; break; 1028 } // switch 1029 1030 // check if mapping is from metric to inch and adapt 1031 const bool bMapInch(IsInch(eObjUnit)); 1032 const bool bUIMetr(IsMetric(eUIUnit)); 1033 1034 if (bMapInch && bUIMetr) 1035 { 1036 nUIUnitComma += 4; 1037 nMul *= 254; 1038 } 1039 1040 // check if mapping is from inch to metric and adapt 1041 const bool bMapMetr(IsMetric(eObjUnit)); 1042 const bool bUIInch(IsInch(eUIUnit)); 1043 1044 if (bMapMetr && bUIInch) 1045 { 1046 nUIUnitComma -= 4; 1047 nDiv *= 254; 1048 } 1049 1050 // use temporary fraction for reduction (fallback to 32bit here), 1051 // may need to be changed in the future, too 1052 if(1 != nMul || 1 != nDiv) 1053 { 1054 const Fraction aTemp(static_cast< long >(nMul), static_cast< long >(nDiv)); 1055 nMul = aTemp.GetNumerator(); 1056 nDiv = aTemp.GetDenominator(); 1057 } 1058 1059 // #i89872# take Unit of Measurement into account 1060 if(1 != aUIScale.GetDenominator() || 1 != aUIScale.GetNumerator()) 1061 { 1062 // divide by UIScale 1063 nMul *= aUIScale.GetDenominator(); 1064 nDiv *= aUIScale.GetNumerator(); 1065 } 1066 1067 // shorten trailing zeroes for dividend 1068 while(0 == (nMul % 10)) 1069 { 1070 nUIUnitComma--; 1071 nMul /= 10; 1072 } 1073 1074 // shorten trailing zeroes for divisor 1075 while(0 == (nDiv % 10)) 1076 { 1077 nUIUnitComma++; 1078 nDiv /= 10; 1079 } 1080 1081 // end preparations, set member values 1082 aUIUnitFact = Fraction(sal_Int32(nMul), sal_Int32(nDiv)); 1083 bUIOnlyComma = (nMul == nDiv); 1084 TakeUnitStr(eUIUnit, aUIUnitStr); 1085 } 1086 1087 void SdrModel::SetScaleUnit(MapUnit eMap, const Fraction& rFrac) 1088 { 1089 if (eObjUnit!=eMap || aObjUnit!=rFrac) { 1090 eObjUnit=eMap; 1091 aObjUnit=rFrac; 1092 pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit); 1093 ImpSetUIUnit(); 1094 ImpSetOutlinerDefaults( pDrawOutliner ); 1095 ImpSetOutlinerDefaults( pHitTestOutliner ); 1096 ImpReformatAllTextObjects(); // #40424# 1097 } 1098 } 1099 1100 void SdrModel::SetScaleUnit(MapUnit eMap) 1101 { 1102 if (eObjUnit!=eMap) { 1103 eObjUnit=eMap; 1104 pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit); 1105 ImpSetUIUnit(); 1106 ImpSetOutlinerDefaults( pDrawOutliner ); 1107 ImpSetOutlinerDefaults( pHitTestOutliner ); 1108 ImpReformatAllTextObjects(); // #40424# 1109 } 1110 } 1111 1112 void SdrModel::SetScaleFraction(const Fraction& rFrac) 1113 { 1114 if (aObjUnit!=rFrac) { 1115 aObjUnit=rFrac; 1116 ImpSetUIUnit(); 1117 ImpSetOutlinerDefaults( pDrawOutliner ); 1118 ImpSetOutlinerDefaults( pHitTestOutliner ); 1119 ImpReformatAllTextObjects(); // #40424# 1120 } 1121 } 1122 1123 void SdrModel::SetUIUnit(FieldUnit eUnit) 1124 { 1125 if (eUIUnit!=eUnit) { 1126 eUIUnit=eUnit; 1127 ImpSetUIUnit(); 1128 ImpReformatAllTextObjects(); // #40424# 1129 } 1130 } 1131 1132 void SdrModel::SetUIScale(const Fraction& rScale) 1133 { 1134 if (aUIScale!=rScale) { 1135 aUIScale=rScale; 1136 ImpSetUIUnit(); 1137 ImpReformatAllTextObjects(); // #40424# 1138 } 1139 } 1140 1141 void SdrModel::SetUIUnit(FieldUnit eUnit, const Fraction& rScale) 1142 { 1143 if (eUIUnit!=eUnit || aUIScale!=rScale) { 1144 eUIUnit=eUnit; 1145 aUIScale=rScale; 1146 ImpSetUIUnit(); 1147 ImpReformatAllTextObjects(); // #40424# 1148 } 1149 } 1150 1151 void SdrModel::TakeUnitStr(FieldUnit eUnit, XubString& rStr) 1152 { 1153 switch(eUnit) 1154 { 1155 default: 1156 case FUNIT_NONE : 1157 case FUNIT_CUSTOM : 1158 { 1159 rStr = String(); 1160 break; 1161 } 1162 case FUNIT_100TH_MM: 1163 { 1164 const sal_Char aText[] = "/100mm"; 1165 rStr = UniString(aText, sizeof(aText)-1); 1166 break; 1167 } 1168 case FUNIT_MM : 1169 { 1170 const sal_Char aText[] = "mm"; 1171 rStr = UniString(aText, sizeof(aText)-1); 1172 break; 1173 } 1174 case FUNIT_CM : 1175 { 1176 const sal_Char aText[] = "cm"; 1177 rStr = UniString(aText, sizeof(aText)-1); 1178 break; 1179 } 1180 case FUNIT_M : 1181 { 1182 rStr = String(); 1183 rStr += sal_Unicode('m'); 1184 break; 1185 } 1186 case FUNIT_KM : 1187 { 1188 const sal_Char aText[] = "km"; 1189 rStr = UniString(aText, sizeof(aText)-1); 1190 break; 1191 } 1192 case FUNIT_TWIP : 1193 { 1194 const sal_Char aText[] = "twip"; 1195 rStr = UniString(aText, sizeof(aText)-1); 1196 break; 1197 } 1198 case FUNIT_POINT : 1199 { 1200 const sal_Char aText[] = "pt"; 1201 rStr = UniString(aText, sizeof(aText)-1); 1202 break; 1203 } 1204 case FUNIT_PICA : 1205 { 1206 sal_Char aText[] = "pica"; 1207 rStr = UniString(aText, sizeof(aText)-1); 1208 break; 1209 } 1210 case FUNIT_INCH : 1211 { 1212 rStr = String(); 1213 rStr += sal_Unicode('"'); 1214 break; 1215 } 1216 case FUNIT_FOOT : 1217 { 1218 const sal_Char aText[] = "ft"; 1219 rStr = UniString(aText, sizeof(aText)-1); 1220 break; 1221 } 1222 case FUNIT_MILE : 1223 { 1224 const sal_Char aText[] = "mile(s)"; 1225 rStr = UniString(aText, sizeof(aText)-1); 1226 break; 1227 } 1228 case FUNIT_PERCENT: 1229 { 1230 rStr = String(); 1231 rStr += sal_Unicode('%'); 1232 break; 1233 } 1234 } 1235 } 1236 1237 void SdrModel::TakeMetricStr(long nVal, XubString& rStr, FASTBOOL bNoUnitChars, sal_Int32 nNumDigits) const 1238 { 1239 // #i22167# 1240 // change to double precision usage to not loose decimal places after comma 1241 const bool bNegative(nVal < 0L); 1242 SvtSysLocale aSysLoc; 1243 const LocaleDataWrapper& rLoc(aSysLoc.GetLocaleData()); 1244 double fLocalValue(double(nVal) * double(aUIUnitFact)); 1245 1246 if(bNegative) 1247 { 1248 fLocalValue = -fLocalValue; 1249 } 1250 1251 if( -1 == nNumDigits ) 1252 { 1253 nNumDigits = rLoc.getNumDigits(); 1254 } 1255 1256 sal_Int32 nComma(nUIUnitComma); 1257 1258 if(nComma > nNumDigits) 1259 { 1260 const sal_Int32 nDiff(nComma - nNumDigits); 1261 const double fFactor(pow(10.0, static_cast<const int>(nDiff))); 1262 1263 fLocalValue /= fFactor; 1264 nComma = nNumDigits; 1265 } 1266 else if(nComma < nNumDigits) 1267 { 1268 const sal_Int32 nDiff(nNumDigits - nComma); 1269 const double fFactor(pow(10.0, static_cast<const int>(nDiff))); 1270 1271 fLocalValue *= fFactor; 1272 nComma = nNumDigits; 1273 } 1274 1275 rStr = UniString::CreateFromInt32(static_cast<sal_Int32>(fLocalValue + 0.5)); 1276 1277 if(nComma < 0) 1278 { 1279 // Negatives Komma bedeutet: Nullen dran 1280 sal_Int32 nAnz(-nComma); 1281 1282 for(sal_Int32 i=0; i<nAnz; i++) 1283 rStr += sal_Unicode('0'); 1284 1285 nComma = 0; 1286 } 1287 1288 // #83257# the second condition needs to be <= since inside this loop 1289 // also the leading zero is inserted. 1290 if(nComma > 0 && rStr.Len() <= nComma) 1291 { 1292 // Für Komma evtl. vorne Nullen dran 1293 sal_Int32 nAnz(nComma - rStr.Len()); 1294 1295 if(nAnz >= 0 && rLoc.isNumLeadingZero()) 1296 nAnz++; 1297 1298 for(sal_Int32 i=0; i<nAnz; i++) 1299 rStr.Insert(sal_Unicode('0'), 0); 1300 } 1301 1302 sal_Unicode cDec( rLoc.getNumDecimalSep().GetChar(0) ); 1303 1304 // KommaChar einfügen 1305 sal_Int32 nPreComma(rStr.Len() - nComma); 1306 1307 if(nComma > 0) 1308 rStr.Insert(cDec, (xub_StrLen) nPreComma); 1309 1310 if(!rLoc.isNumTrailingZeros()) 1311 { 1312 while(rStr.Len() && rStr.GetChar(rStr.Len() - 1) == sal_Unicode('0')) 1313 rStr.Erase(rStr.Len() - 1); 1314 1315 if(rStr.Len() && rStr.GetChar(rStr.Len() - 1) == cDec) 1316 rStr.Erase(rStr.Len() - 1); 1317 } 1318 1319 // ggf. Trennpunkte bei jedem Tausender einfügen 1320 if( nPreComma > 3 ) 1321 { 1322 String aThoSep( rLoc.getNumThousandSep() ); 1323 if ( aThoSep.Len() > 0 ) 1324 { 1325 sal_Unicode cTho( aThoSep.GetChar(0) ); 1326 sal_Int32 i(nPreComma - 3); 1327 1328 while(i > 0) // #78311# 1329 { 1330 rStr.Insert(cTho, (xub_StrLen)i); 1331 i -= 3; 1332 } 1333 } 1334 } 1335 1336 if(!rStr.Len()) 1337 { 1338 rStr = String(); 1339 rStr += sal_Unicode('0'); 1340 } 1341 1342 if(bNegative) 1343 { 1344 rStr.Insert(sal_Unicode('-'), 0); 1345 } 1346 1347 if(!bNoUnitChars) 1348 rStr += aUIUnitStr; 1349 } 1350 1351 void SdrModel::TakeWinkStr(long nWink, XubString& rStr, FASTBOOL bNoDegChar) const 1352 { 1353 sal_Bool bNeg(nWink < 0); 1354 1355 if(bNeg) 1356 nWink = -nWink; 1357 1358 rStr = UniString::CreateFromInt32(nWink); 1359 1360 SvtSysLocale aSysLoc; 1361 const LocaleDataWrapper& rLoc = aSysLoc.GetLocaleData(); 1362 xub_StrLen nAnz(2); 1363 1364 if(rLoc.isNumLeadingZero()) 1365 nAnz++; 1366 1367 while(rStr.Len() < nAnz) 1368 rStr.Insert(sal_Unicode('0'), 0); 1369 1370 rStr.Insert(rLoc.getNumDecimalSep().GetChar(0), rStr.Len() - 2); 1371 1372 if(bNeg) 1373 rStr.Insert(sal_Unicode('-'), 0); 1374 1375 if(!bNoDegChar) 1376 rStr += DEGREE_CHAR; 1377 } 1378 1379 void SdrModel::TakePercentStr(const Fraction& rVal, XubString& rStr, FASTBOOL bNoPercentChar) const 1380 { 1381 sal_Int32 nMul(rVal.GetNumerator()); 1382 sal_Int32 nDiv(rVal.GetDenominator()); 1383 sal_Bool bNeg(nMul < 0); 1384 1385 if(nDiv < 0) 1386 bNeg = !bNeg; 1387 1388 if(nMul < 0) 1389 nMul = -nMul; 1390 1391 if(nDiv < 0) 1392 nDiv = -nDiv; 1393 1394 nMul *= 100; 1395 nMul += nDiv/2; 1396 nMul /= nDiv; 1397 1398 rStr = UniString::CreateFromInt32(nMul); 1399 1400 if(bNeg) 1401 rStr.Insert(sal_Unicode('-'), 0); 1402 1403 if(!bNoPercentChar) 1404 rStr += sal_Unicode('%'); 1405 } 1406 1407 void SdrModel::SetChanged(sal_Bool bFlg) 1408 { 1409 mbChanged = bFlg; 1410 } 1411 1412 void SdrModel::RecalcPageNums(FASTBOOL bMaster) 1413 { 1414 Container& rPL=*(bMaster ? &maMaPag : &maPages); 1415 sal_uInt16 nAnz=sal_uInt16(rPL.Count()); 1416 sal_uInt16 i; 1417 for (i=0; i<nAnz; i++) { 1418 SdrPage* pPg=(SdrPage*)(rPL.GetObject(i)); 1419 pPg->SetPageNum(i); 1420 } 1421 if (bMaster) bMPgNumsDirty=sal_False; 1422 else bPagNumsDirty=sal_False; 1423 } 1424 1425 void SdrModel::InsertPage(SdrPage* pPage, sal_uInt16 nPos) 1426 { 1427 sal_uInt16 nAnz=GetPageCount(); 1428 if (nPos>nAnz) nPos=nAnz; 1429 maPages.Insert(pPage,nPos); 1430 // #109538# 1431 PageListChanged(); 1432 pPage->SetInserted(sal_True); 1433 pPage->SetPageNum(nPos); 1434 pPage->SetModel(this); 1435 if (nPos<nAnz) bPagNumsDirty=sal_True; 1436 SetChanged(); 1437 SdrHint aHint(HINT_PAGEORDERCHG); 1438 aHint.SetPage(pPage); 1439 Broadcast(aHint); 1440 } 1441 1442 void SdrModel::DeletePage(sal_uInt16 nPgNum) 1443 { 1444 SdrPage* pPg=RemovePage(nPgNum); 1445 delete pPg; 1446 } 1447 1448 SdrPage* SdrModel::RemovePage(sal_uInt16 nPgNum) 1449 { 1450 SdrPage* pPg=(SdrPage*)maPages.Remove(nPgNum); 1451 // #109538# 1452 PageListChanged(); 1453 if (pPg!=NULL) { 1454 pPg->SetInserted(sal_False); 1455 } 1456 bPagNumsDirty=sal_True; 1457 SetChanged(); 1458 SdrHint aHint(HINT_PAGEORDERCHG); 1459 aHint.SetPage(pPg); 1460 Broadcast(aHint); 1461 return pPg; 1462 } 1463 1464 void SdrModel::MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos) 1465 { 1466 SdrPage* pPg=(SdrPage*)maPages.Remove(nPgNum); 1467 // #109538# 1468 PageListChanged(); 1469 if (pPg!=NULL) { 1470 pPg->SetInserted(sal_False); 1471 InsertPage(pPg,nNewPos); 1472 } 1473 } 1474 1475 void SdrModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos) 1476 { 1477 sal_uInt16 nAnz=GetMasterPageCount(); 1478 if (nPos>nAnz) nPos=nAnz; 1479 maMaPag.Insert(pPage,nPos); 1480 // #109538# 1481 MasterPageListChanged(); 1482 pPage->SetInserted(sal_True); 1483 pPage->SetPageNum(nPos); 1484 pPage->SetModel(this); 1485 if (nPos<nAnz) { 1486 bMPgNumsDirty=sal_True; 1487 } 1488 SetChanged(); 1489 SdrHint aHint(HINT_PAGEORDERCHG); 1490 aHint.SetPage(pPage); 1491 Broadcast(aHint); 1492 } 1493 1494 void SdrModel::DeleteMasterPage(sal_uInt16 nPgNum) 1495 { 1496 SdrPage* pPg=RemoveMasterPage(nPgNum); 1497 if (pPg!=NULL) delete pPg; 1498 } 1499 1500 SdrPage* SdrModel::RemoveMasterPage(sal_uInt16 nPgNum) 1501 { 1502 SdrPage* pRetPg=(SdrPage*)maMaPag.Remove(nPgNum); 1503 // #109538# 1504 MasterPageListChanged(); 1505 1506 if(pRetPg) 1507 { 1508 // Nun die Verweise der normalen Zeichenseiten auf die entfernte MasterPage löschen 1509 sal_uInt16 nPageAnz(GetPageCount()); 1510 1511 for(sal_uInt16 np(0); np < nPageAnz; np++) 1512 { 1513 GetPage(np)->TRG_ImpMasterPageRemoved(*pRetPg); 1514 } 1515 1516 pRetPg->SetInserted(sal_False); 1517 } 1518 1519 bMPgNumsDirty=sal_True; 1520 SetChanged(); 1521 SdrHint aHint(HINT_PAGEORDERCHG); 1522 aHint.SetPage(pRetPg); 1523 Broadcast(aHint); 1524 return pRetPg; 1525 } 1526 1527 void SdrModel::MoveMasterPage(sal_uInt16 nPgNum, sal_uInt16 nNewPos) 1528 { 1529 SdrPage* pPg=(SdrPage*)maMaPag.Remove(nPgNum); 1530 // #109538# 1531 MasterPageListChanged(); 1532 if (pPg!=NULL) { 1533 pPg->SetInserted(sal_False); 1534 maMaPag.Insert(pPg,nNewPos); 1535 // #109538# 1536 MasterPageListChanged(); 1537 } 1538 bMPgNumsDirty=sal_True; 1539 SetChanged(); 1540 SdrHint aHint(HINT_PAGEORDERCHG); 1541 aHint.SetPage(pPg); 1542 Broadcast(aHint); 1543 } 1544 1545 //////////////////////////////////////////////////////////////////////////////////////////////////// 1546 1547 FASTBOOL SdrModel::CheckConsistence() const 1548 { 1549 FASTBOOL bRet=sal_True; 1550 #ifdef DBG_UTIL 1551 DBG_CHKTHIS(SdrModel,NULL); 1552 #endif 1553 return bRet; 1554 } 1555 1556 //////////////////////////////////////////////////////////////////////////////////////////////////// 1557 1558 // #48289# 1559 void SdrModel::CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum, 1560 sal_uInt16 nDestPos, 1561 FASTBOOL bUndo, FASTBOOL bMoveNoCopy) 1562 { 1563 if( bUndo && !IsUndoEnabled() ) 1564 bUndo = false; 1565 1566 if( bUndo ) 1567 BegUndo(ImpGetResStr(STR_UndoMergeModel)); 1568 1569 sal_uInt16 nPageAnz=GetPageCount(); 1570 sal_uInt16 nMaxPage=nPageAnz; 1571 1572 if (nMaxPage!=0) 1573 nMaxPage--; 1574 if (nFirstPageNum>nMaxPage) 1575 nFirstPageNum=nMaxPage; 1576 if (nLastPageNum>nMaxPage) 1577 nLastPageNum =nMaxPage; 1578 FASTBOOL bReverse=nLastPageNum<nFirstPageNum; 1579 if (nDestPos>nPageAnz) 1580 nDestPos=nPageAnz; 1581 1582 // Zunächst die Zeiger der betroffenen Seiten in einem Array sichern 1583 sal_uInt16 nPageNum=nFirstPageNum; 1584 sal_uInt16 nCopyAnz=((!bReverse)?(nLastPageNum-nFirstPageNum):(nFirstPageNum-nLastPageNum))+1; 1585 SdrPage** pPagePtrs=new SdrPage*[nCopyAnz]; 1586 sal_uInt16 nCopyNum; 1587 for(nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++) 1588 { 1589 pPagePtrs[nCopyNum]=GetPage(nPageNum); 1590 if (bReverse) 1591 nPageNum--; 1592 else 1593 nPageNum++; 1594 } 1595 1596 // Jetzt die Seiten kopieren 1597 sal_uInt16 nDestNum=nDestPos; 1598 for (nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++) 1599 { 1600 SdrPage* pPg=pPagePtrs[nCopyNum]; 1601 sal_uInt16 nPageNum2=pPg->GetPageNum(); 1602 if (!bMoveNoCopy) 1603 { 1604 const SdrPage* pPg1=GetPage(nPageNum2); 1605 pPg=pPg1->Clone(); 1606 InsertPage(pPg,nDestNum); 1607 if (bUndo) 1608 AddUndo(GetSdrUndoFactory().CreateUndoCopyPage(*pPg)); 1609 nDestNum++; 1610 } 1611 else 1612 { 1613 // Move ist nicht getestet! 1614 if (nDestNum>nPageNum2) 1615 nDestNum--; 1616 1617 if(bUndo) 1618 AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*GetPage(nPageNum2),nPageNum2,nDestNum)); 1619 1620 pPg=RemovePage(nPageNum2); 1621 InsertPage(pPg,nDestNum); 1622 nDestNum++; 1623 } 1624 1625 if(bReverse) 1626 nPageNum2--; 1627 else 1628 nPageNum2++; 1629 } 1630 1631 delete[] pPagePtrs; 1632 if(bUndo) 1633 EndUndo(); 1634 } 1635 1636 void SdrModel::Merge(SdrModel& rSourceModel, 1637 sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum, 1638 sal_uInt16 nDestPos, 1639 FASTBOOL bMergeMasterPages, FASTBOOL bAllMasterPages, 1640 FASTBOOL bUndo, FASTBOOL bTreadSourceAsConst) 1641 { 1642 if (&rSourceModel==this) 1643 { // #48289# 1644 CopyPages(nFirstPageNum,nLastPageNum,nDestPos,bUndo,!bTreadSourceAsConst); 1645 return; 1646 } 1647 1648 if( bUndo && !IsUndoEnabled() ) 1649 bUndo = false; 1650 1651 if (bUndo) 1652 BegUndo(ImpGetResStr(STR_UndoMergeModel)); 1653 1654 sal_uInt16 nSrcPageAnz=rSourceModel.GetPageCount(); 1655 sal_uInt16 nSrcMasterPageAnz=rSourceModel.GetMasterPageCount(); 1656 sal_uInt16 nDstMasterPageAnz=GetMasterPageCount(); 1657 FASTBOOL bInsPages=(nFirstPageNum<nSrcPageAnz || nLastPageNum<nSrcPageAnz); 1658 sal_uInt16 nMaxSrcPage=nSrcPageAnz; if (nMaxSrcPage!=0) nMaxSrcPage--; 1659 if (nFirstPageNum>nMaxSrcPage) nFirstPageNum=nMaxSrcPage; 1660 if (nLastPageNum>nMaxSrcPage) nLastPageNum =nMaxSrcPage; 1661 FASTBOOL bReverse=nLastPageNum<nFirstPageNum; 1662 1663 sal_uInt16* pMasterMap=NULL; 1664 int* pMasterNeed=NULL; 1665 sal_uInt16 nMasterNeed=0; 1666 if (bMergeMasterPages && nSrcMasterPageAnz!=0) { 1667 // Feststellen, welche MasterPages aus rSrcModel benötigt werden 1668 pMasterMap=new sal_uInt16[nSrcMasterPageAnz]; 1669 pMasterNeed=new int[nSrcMasterPageAnz]; 1670 memset(pMasterMap,0xFF,nSrcMasterPageAnz*sizeof(sal_uInt16)); 1671 if (bAllMasterPages) { 1672 memset(pMasterNeed,sal_True,nSrcMasterPageAnz*sizeof(FASTBOOL)); 1673 } else { 1674 memset(pMasterNeed,sal_False,nSrcMasterPageAnz*sizeof(FASTBOOL)); 1675 sal_uInt16 nAnf= bReverse ? nLastPageNum : nFirstPageNum; 1676 sal_uInt16 nEnd= bReverse ? nFirstPageNum : nLastPageNum; 1677 for (sal_uInt16 i=nAnf; i<=nEnd; i++) { 1678 const SdrPage* pPg=rSourceModel.GetPage(i); 1679 if(pPg->TRG_HasMasterPage()) 1680 { 1681 SdrPage& rMasterPage = pPg->TRG_GetMasterPage(); 1682 sal_uInt16 nMPgNum(rMasterPage.GetPageNum()); 1683 1684 if(nMPgNum < nSrcMasterPageAnz) 1685 { 1686 pMasterNeed[nMPgNum] = sal_True; 1687 } 1688 } 1689 } 1690 } 1691 // Nun das Mapping der MasterPages bestimmen 1692 sal_uInt16 nAktMaPagNum=nDstMasterPageAnz; 1693 for (sal_uInt16 i=0; i<nSrcMasterPageAnz; i++) { 1694 if (pMasterNeed[i]) { 1695 pMasterMap[i]=nAktMaPagNum; 1696 nAktMaPagNum++; 1697 nMasterNeed++; 1698 } 1699 } 1700 } 1701 1702 // rüberholen der Masterpages 1703 if (pMasterMap!=NULL && pMasterNeed!=NULL && nMasterNeed!=0) { 1704 for (sal_uInt16 i=nSrcMasterPageAnz; i>0;) { 1705 i--; 1706 if (pMasterNeed[i]) { 1707 SdrPage* pPg=NULL; 1708 if (bTreadSourceAsConst) { 1709 const SdrPage* pPg1=rSourceModel.GetMasterPage(i); 1710 pPg=pPg1->Clone(); 1711 } else { 1712 pPg=rSourceModel.RemoveMasterPage(i); 1713 } 1714 if (pPg!=NULL) { 1715 // und alle ans einstige Ende des DstModel reinschieben. 1716 // nicht InsertMasterPage() verwenden da die Sache 1717 // inkonsistent ist bis alle drin sind 1718 maMaPag.Insert(pPg,nDstMasterPageAnz); 1719 // #109538# 1720 MasterPageListChanged(); 1721 pPg->SetInserted(sal_True); 1722 pPg->SetModel(this); 1723 bMPgNumsDirty=sal_True; 1724 if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg)); 1725 } else { 1726 DBG_ERROR("SdrModel::Merge(): MasterPage im SourceModel nicht gefunden"); 1727 } 1728 } 1729 } 1730 } 1731 1732 // rüberholen der Zeichenseiten 1733 if (bInsPages) { 1734 sal_uInt16 nSourcePos=nFirstPageNum; 1735 sal_uInt16 nMergeCount=sal_uInt16(Abs((long)((long)nFirstPageNum-nLastPageNum))+1); 1736 if (nDestPos>GetPageCount()) nDestPos=GetPageCount(); 1737 while (nMergeCount>0) { 1738 SdrPage* pPg=NULL; 1739 if (bTreadSourceAsConst) { 1740 const SdrPage* pPg1=rSourceModel.GetPage(nSourcePos); 1741 pPg=pPg1->Clone(); 1742 } else { 1743 pPg=rSourceModel.RemovePage(nSourcePos); 1744 } 1745 if (pPg!=NULL) { 1746 InsertPage(pPg,nDestPos); 1747 if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg)); 1748 // und nun zu den MasterPageDescriptoren 1749 1750 if(pPg->TRG_HasMasterPage()) 1751 { 1752 SdrPage& rMasterPage = pPg->TRG_GetMasterPage(); 1753 sal_uInt16 nMaPgNum(rMasterPage.GetPageNum()); 1754 1755 if (bMergeMasterPages) 1756 { 1757 sal_uInt16 nNewNum(0xFFFF); 1758 1759 if(pMasterMap) 1760 { 1761 nNewNum = pMasterMap[nMaPgNum]; 1762 } 1763 1764 if(nNewNum != 0xFFFF) 1765 { 1766 if(bUndo) 1767 { 1768 AddUndo(GetSdrUndoFactory().CreateUndoPageChangeMasterPage(*pPg)); 1769 } 1770 1771 pPg->TRG_SetMasterPage(*GetMasterPage(nNewNum)); 1772 } 1773 DBG_ASSERT(nNewNum!=0xFFFF,"SdrModel::Merge(): Irgendwas ist krumm beim Mappen der MasterPages"); 1774 } else { 1775 if (nMaPgNum>=nDstMasterPageAnz) { 1776 // Aha, die ist ausserbalb des ursprünglichen Bereichs der Masterpages des DstModel 1777 pPg->TRG_ClearMasterPage(); 1778 } 1779 } 1780 } 1781 1782 } else { 1783 DBG_ERROR("SdrModel::Merge(): Zeichenseite im SourceModel nicht gefunden"); 1784 } 1785 nDestPos++; 1786 if (bReverse) nSourcePos--; 1787 else if (bTreadSourceAsConst) nSourcePos++; 1788 nMergeCount--; 1789 } 1790 } 1791 1792 delete [] pMasterMap; 1793 delete [] pMasterNeed; 1794 1795 bMPgNumsDirty=sal_True; 1796 bPagNumsDirty=sal_True; 1797 1798 SetChanged(); 1799 // Fehlt: Mergen und Mapping der Layer 1800 // an den Objekten sowie an den MasterPageDescriptoren 1801 if (bUndo) EndUndo(); 1802 } 1803 1804 void SdrModel::SetStarDrawPreviewMode(sal_Bool bPreview) 1805 { 1806 if (!bPreview && bStarDrawPreviewMode && GetPageCount()) 1807 { 1808 // Das Zurücksetzen ist nicht erlaubt, da das Model ev. nicht vollständig geladen wurde 1809 DBG_ASSERT(sal_False,"SdrModel::SetStarDrawPreviewMode(): Zurücksetzen nicht erlaubt, da Model ev. nicht vollständig"); 1810 } 1811 else 1812 { 1813 bStarDrawPreviewMode = bPreview; 1814 } 1815 } 1816 1817 uno::Reference< uno::XInterface > SdrModel::getUnoModel() 1818 { 1819 if( !mxUnoModel.is() ) 1820 mxUnoModel = createUnoModel(); 1821 1822 return mxUnoModel; 1823 } 1824 1825 void SdrModel::setUnoModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xModel ) 1826 { 1827 mxUnoModel = xModel; 1828 } 1829 1830 uno::Reference< uno::XInterface > SdrModel::createUnoModel() 1831 { 1832 DBG_ERROR( "SdrModel::createUnoModel() - base implementation should not be called!" ); 1833 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInt; 1834 return xInt; 1835 } 1836 1837 void SdrModel::setLock( sal_Bool bLock ) 1838 { 1839 if( mbModelLocked != bLock ) 1840 { 1841 // #120437# need to set first, else ImpReformatAllEdgeObjects will do nothing 1842 mbModelLocked = bLock; 1843 1844 if( sal_False == bLock ) 1845 { 1846 // ReformatAllTextObjects(); #103122# due to a typo in the above if, this code was never 1847 // executed, so I remove it until we discover that we need it here 1848 ImpReformatAllEdgeObjects(); // #103122# 1849 } 1850 } 1851 } 1852 1853 //////////////////////////////////////////////////////////////////////////////////////////////////// 1854 1855 void SdrModel::MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel ) 1856 { 1857 if( pSourceSet && pDestSet && (pSourceSet != pDestSet ) ) 1858 { 1859 if( pNewModel == NULL ) 1860 pNewModel = this; 1861 1862 SfxWhichIter aWhichIter(*pSourceSet); 1863 sal_uInt16 nWhich(aWhichIter.FirstWhich()); 1864 const SfxPoolItem *pPoolItem; 1865 1866 while(nWhich) 1867 { 1868 if(SFX_ITEM_SET == pSourceSet->GetItemState(nWhich, sal_False, &pPoolItem)) 1869 { 1870 const SfxPoolItem* pItem = pPoolItem; 1871 1872 switch( nWhich ) 1873 { 1874 case XATTR_FILLBITMAP: 1875 pItem = ((XFillBitmapItem*)pItem)->checkForUniqueItem( pNewModel ); 1876 break; 1877 case XATTR_LINEDASH: 1878 pItem = ((XLineDashItem*)pItem)->checkForUniqueItem( pNewModel ); 1879 break; 1880 case XATTR_LINESTART: 1881 pItem = ((XLineStartItem*)pItem)->checkForUniqueItem( pNewModel ); 1882 break; 1883 case XATTR_LINEEND: 1884 pItem = ((XLineEndItem*)pItem)->checkForUniqueItem( pNewModel ); 1885 break; 1886 case XATTR_FILLGRADIENT: 1887 pItem = ((XFillGradientItem*)pItem)->checkForUniqueItem( pNewModel ); 1888 break; 1889 case XATTR_FILLFLOATTRANSPARENCE: 1890 // #85953# allow all kinds of XFillFloatTransparenceItem to be set 1891 pItem = ((XFillFloatTransparenceItem*)pItem)->checkForUniqueItem( pNewModel ); 1892 break; 1893 case XATTR_FILLHATCH: 1894 pItem = ((XFillHatchItem*)pItem)->checkForUniqueItem( pNewModel ); 1895 break; 1896 } 1897 1898 // set item 1899 if( pItem ) 1900 { 1901 pDestSet->Put(*pItem); 1902 1903 // delete item if it was a generated one 1904 if( pItem != pPoolItem) 1905 delete (SfxPoolItem*)pItem; 1906 } 1907 } 1908 nWhich = aWhichIter.NextWhich(); 1909 } 1910 } 1911 } 1912 1913 //////////////////////////////////////////////////////////////////////////////////////////////////// 1914 1915 void SdrModel::SetForbiddenCharsTable( vos::ORef<SvxForbiddenCharactersTable> xForbiddenChars ) 1916 { 1917 if( mpForbiddenCharactersTable ) 1918 mpForbiddenCharactersTable->release(); 1919 1920 mpForbiddenCharactersTable = xForbiddenChars.getBodyPtr(); 1921 1922 if( mpForbiddenCharactersTable ) 1923 mpForbiddenCharactersTable->acquire(); 1924 1925 ImpSetOutlinerDefaults( pDrawOutliner ); 1926 ImpSetOutlinerDefaults( pHitTestOutliner ); 1927 } 1928 1929 vos::ORef<SvxForbiddenCharactersTable> SdrModel::GetForbiddenCharsTable() const 1930 { 1931 return mpForbiddenCharactersTable; 1932 } 1933 1934 void SdrModel::SetCharCompressType( sal_uInt16 nType ) 1935 { 1936 if( nType != mnCharCompressType ) 1937 { 1938 mnCharCompressType = nType; 1939 ImpSetOutlinerDefaults( pDrawOutliner ); 1940 ImpSetOutlinerDefaults( pHitTestOutliner ); 1941 } 1942 } 1943 1944 void SdrModel::SetKernAsianPunctuation( sal_Bool bEnabled ) 1945 { 1946 if( mbKernAsianPunctuation != bEnabled ) 1947 { 1948 mbKernAsianPunctuation = bEnabled; 1949 ImpSetOutlinerDefaults( pDrawOutliner ); 1950 ImpSetOutlinerDefaults( pHitTestOutliner ); 1951 } 1952 } 1953 1954 void SdrModel::SetAddExtLeading( sal_Bool bEnabled ) 1955 { 1956 if( mbAddExtLeading != bEnabled ) 1957 { 1958 mbAddExtLeading = bEnabled; 1959 ImpSetOutlinerDefaults( pDrawOutliner ); 1960 ImpSetOutlinerDefaults( pHitTestOutliner ); 1961 } 1962 } 1963 1964 void SdrModel::ReformatAllTextObjects() 1965 { 1966 ImpReformatAllTextObjects(); 1967 } 1968 1969 FASTBOOL SdrModel::HasTransparentObjects( sal_Bool bCheckForAlphaChannel ) const 1970 { 1971 FASTBOOL bRet = sal_False; 1972 sal_uInt16 n, nCount; 1973 1974 for( n = 0, nCount = GetMasterPageCount(); ( n < nCount ) && !bRet; n++ ) 1975 if( GetMasterPage( n )->HasTransparentObjects( bCheckForAlphaChannel ) ) 1976 bRet = sal_True; 1977 1978 if( !bRet ) 1979 { 1980 for( n = 0, nCount = GetPageCount(); ( n < nCount ) && !bRet; n++ ) 1981 if( GetPage( n )->HasTransparentObjects( bCheckForAlphaChannel ) ) 1982 bRet = sal_True; 1983 } 1984 1985 return bRet; 1986 } 1987 1988 SdrOutliner* SdrModel::createOutliner( sal_uInt16 nOutlinerMode ) 1989 { 1990 if( NULL == mpOutlinerCache ) 1991 mpOutlinerCache = new SdrOutlinerCache(this); 1992 1993 return mpOutlinerCache->createOutliner( nOutlinerMode ); 1994 } 1995 1996 void SdrModel::disposeOutliner( SdrOutliner* pOutliner ) 1997 { 1998 if( mpOutlinerCache ) 1999 { 2000 mpOutlinerCache->disposeOutliner( pOutliner ); 2001 } 2002 else 2003 { 2004 delete pOutliner; 2005 } 2006 } 2007 2008 SvxNumType SdrModel::GetPageNumType() const 2009 { 2010 return SVX_ARABIC; 2011 } 2012 2013 const SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum) const 2014 { 2015 DBG_ASSERT(nPgNum < maPages.Count(), "SdrModel::GetPage: Access out of range (!)"); 2016 return (SdrPage*)(maPages.GetObject(nPgNum)); 2017 } 2018 2019 SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum) 2020 { 2021 DBG_ASSERT(nPgNum < maPages.Count(), "SdrModel::GetPage: Access out of range (!)"); 2022 return (SdrPage*)(maPages.GetObject(nPgNum)); 2023 } 2024 2025 sal_uInt16 SdrModel::GetPageCount() const 2026 { 2027 return sal_uInt16(maPages.Count()); 2028 } 2029 2030 void SdrModel::PageListChanged() 2031 { 2032 } 2033 2034 const SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum) const 2035 { 2036 DBG_ASSERT(nPgNum < maMaPag.Count(), "SdrModel::GetMasterPage: Access out of range (!)"); 2037 return (SdrPage*)(maMaPag.GetObject(nPgNum)); 2038 } 2039 2040 SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum) 2041 { 2042 DBG_ASSERT(nPgNum < maMaPag.Count(), "SdrModel::GetMasterPage: Access out of range (!)"); 2043 return (SdrPage*)(maMaPag.GetObject(nPgNum)); 2044 } 2045 2046 sal_uInt16 SdrModel::GetMasterPageCount() const 2047 { 2048 return sal_uInt16(maMaPag.Count()); 2049 } 2050 2051 void SdrModel::MasterPageListChanged() 2052 { 2053 } 2054 2055 void SdrModel::SetSdrUndoManager( SfxUndoManager* pUndoManager ) 2056 { 2057 mpImpl->mpUndoManager = pUndoManager; 2058 } 2059 2060 SfxUndoManager* SdrModel::GetSdrUndoManager() const 2061 { 2062 return mpImpl->mpUndoManager; 2063 } 2064 2065 SdrUndoFactory& SdrModel::GetSdrUndoFactory() const 2066 { 2067 if( !mpImpl->mpUndoFactory ) 2068 mpImpl->mpUndoFactory = new SdrUndoFactory; 2069 return *mpImpl->mpUndoFactory; 2070 } 2071 2072 void SdrModel::SetSdrUndoFactory( SdrUndoFactory* pUndoFactory ) 2073 { 2074 if( pUndoFactory && (pUndoFactory != mpImpl->mpUndoFactory) ) 2075 { 2076 delete mpImpl->mpUndoFactory; 2077 mpImpl->mpUndoFactory = pUndoFactory; 2078 } 2079 } 2080 2081 /** cl: added this for OJ to complete his reporting engine, does not work 2082 correctly so only enable it for his model */ 2083 bool SdrModel::IsAllowShapePropertyChangeListener() const 2084 { 2085 return mpImpl && mpImpl->mbAllowShapePropertyChangeListener; 2086 } 2087 2088 void SdrModel::SetAllowShapePropertyChangeListener( bool bAllow ) 2089 { 2090 if( mpImpl ) 2091 { 2092 mpImpl->mbAllowShapePropertyChangeListener = bAllow; 2093 } 2094 } 2095 2096 const ::com::sun::star::uno::Sequence< sal_Int8 >& SdrModel::getUnoTunnelImplementationId() 2097 { 2098 static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0; 2099 if( !pSeq ) 2100 { 2101 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 2102 if( !pSeq ) 2103 { 2104 static Sequence< sal_Int8 > aSeq( 16 ); 2105 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 2106 pSeq = &aSeq; 2107 } 2108 } 2109 return *pSeq; 2110 } 2111 2112 //////////////////////////////////////////////////////////////////////////////////////////////////// 2113 2114 void SdrModel::SetColorTableAtSdrModel(XColorListSharedPtr aTable) 2115 { 2116 maColorTable = aTable; 2117 } 2118 2119 XColorListSharedPtr SdrModel::GetColorTableFromSdrModel() const 2120 { 2121 if(!maColorTable.get()) 2122 { 2123 const_cast< SdrModel* >(this)->maColorTable = XPropertyListFactory::CreateSharedXColorList(aTablePath); 2124 } 2125 2126 return maColorTable; 2127 } 2128 2129 void SdrModel::SetDashListAtSdrModel(XDashListSharedPtr aList) 2130 { 2131 maDashList = aList; 2132 } 2133 2134 XDashListSharedPtr SdrModel::GetDashListFromSdrModel() const 2135 { 2136 if(!maDashList.get()) 2137 { 2138 const_cast< SdrModel* >(this)->maDashList = XPropertyListFactory::CreateSharedXDashList(aTablePath); 2139 } 2140 2141 return maDashList; 2142 } 2143 2144 void SdrModel::SetLineEndListAtSdrModel(XLineEndListSharedPtr aList) 2145 { 2146 maLineEndList = aList; 2147 } 2148 2149 XLineEndListSharedPtr SdrModel::GetLineEndListFromSdrModel() const 2150 { 2151 if(!maLineEndList.get()) 2152 { 2153 const_cast< SdrModel* >(this)->maLineEndList = XPropertyListFactory::CreateSharedXLineEndList(aTablePath); 2154 } 2155 2156 return maLineEndList; 2157 } 2158 2159 void SdrModel::SetHatchListAtSdrModel(XHatchListSharedPtr aList) 2160 { 2161 maHatchList = aList; 2162 } 2163 2164 XHatchListSharedPtr SdrModel::GetHatchListFromSdrModel() const 2165 { 2166 if(!maHatchList.get()) 2167 { 2168 const_cast< SdrModel* >(this)->maHatchList = XPropertyListFactory::CreateSharedXHatchList(aTablePath); 2169 } 2170 2171 return maHatchList; 2172 } 2173 2174 void SdrModel::SetGradientListAtSdrModel(XGradientListSharedPtr aList) 2175 { 2176 maGradientList = aList; 2177 } 2178 2179 XGradientListSharedPtr SdrModel::GetGradientListFromSdrModel() const 2180 { 2181 if(!maGradientList.get()) 2182 { 2183 const_cast< SdrModel* >(this)->maGradientList = XPropertyListFactory::CreateSharedXGradientList(aTablePath); 2184 } 2185 2186 return maGradientList; 2187 } 2188 2189 void SdrModel::SetBitmapListAtSdrModel(XBitmapListSharedPtr aList) 2190 { 2191 maBitmapList = aList; 2192 } 2193 2194 XBitmapListSharedPtr SdrModel::GetBitmapListFromSdrModel() const 2195 { 2196 if(!maBitmapList.get()) 2197 { 2198 const_cast< SdrModel* >(this)->maBitmapList = XPropertyListFactory::CreateSharedXBitmapList(aTablePath); 2199 } 2200 2201 return maBitmapList; 2202 } 2203 2204 //////////////////////////////////////////////////////////////////////////////////////////////////// 2205 2206 TYPEINIT1(SdrHint,SfxHint); 2207 2208 SdrHint::SdrHint() 2209 : mpPage(0L), 2210 mpObj(0L), 2211 mpObjList(0L), 2212 meHint(HINT_UNKNOWN) 2213 { 2214 } 2215 2216 SdrHint::SdrHint(SdrHintKind eNewHint) 2217 : mpPage(0L), 2218 mpObj(0L), 2219 mpObjList(0L), 2220 meHint(eNewHint) 2221 { 2222 } 2223 2224 SdrHint::SdrHint(const SdrObject& rNewObj) 2225 : mpPage(rNewObj.GetPage()), 2226 mpObj(&rNewObj), 2227 mpObjList(rNewObj.GetObjList()), 2228 meHint(HINT_OBJCHG) 2229 { 2230 maRectangle = rNewObj.GetLastBoundRect(); 2231 } 2232 2233 SdrHint::SdrHint(const SdrObject& rNewObj, const Rectangle& rRect) 2234 : mpPage(rNewObj.GetPage()), 2235 mpObj(&rNewObj), 2236 mpObjList(rNewObj.GetObjList()), 2237 meHint(HINT_OBJCHG) 2238 { 2239 maRectangle = rRect; 2240 } 2241 2242 void SdrHint::SetPage(const SdrPage* pNewPage) 2243 { 2244 mpPage = pNewPage; 2245 } 2246 2247 void SdrHint::SetObjList(const SdrObjList* pNewOL) 2248 { 2249 mpObjList = pNewOL; 2250 } 2251 2252 void SdrHint::SetObject(const SdrObject* pNewObj) 2253 { 2254 mpObj = pNewObj; 2255 } 2256 2257 void SdrHint::SetKind(SdrHintKind eNewKind) 2258 { 2259 meHint = eNewKind; 2260 } 2261 2262 void SdrHint::SetRect(const Rectangle& rNewRect) 2263 { 2264 maRectangle = rNewRect; 2265 } 2266 2267 const SdrPage* SdrHint::GetPage() const 2268 { 2269 return mpPage; 2270 } 2271 2272 const SdrObjList* SdrHint::GetObjList() const 2273 { 2274 return mpObjList; 2275 } 2276 2277 const SdrObject* SdrHint::GetObject() const 2278 { 2279 return mpObj; 2280 } 2281 2282 SdrHintKind SdrHint::GetKind() const 2283 { 2284 return meHint; 2285 } 2286 2287 const Rectangle& SdrHint::GetRect() const 2288 { 2289 return maRectangle; 2290 } 2291 2292 /* vim: set noet sw=4 ts=4: */ 2293