1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sd.hxx" 26 27 #include <algorithm> 28 29 #include <comphelper/classids.hxx> 30 31 #include <vcl/svapp.hxx> 32 #include "eetext.hxx" 33 #include <editeng/eeitem.hxx> 34 #include <svx/svdoutl.hxx> 35 #include <editeng/editdata.hxx> 36 #include <svx/pageitem.hxx> 37 #include <editeng/lrspitem.hxx> 38 #include <editeng/bulitem.hxx> 39 #include <svx/svdpagv.hxx> 40 #include <editeng/fhgtitem.hxx> 41 #include <editeng/outlobj.hxx> 42 #include <svx/svdoole2.hxx> 43 #include <svx/svdograf.hxx> 44 #include <svx/svdopage.hxx> 45 #include <svx/svdopage.hxx> 46 #include <sfx2/printer.hxx> 47 #include <basic/basmgr.hxx> 48 #include <editeng/pbinitem.hxx> 49 #include <svx/svdundo.hxx> 50 #include <svl/smplhint.hxx> 51 #include <editeng/adjitem.hxx> 52 #include <editeng/editobj.hxx> 53 #ifndef _SVX_SRIPTTYPEITEM_HXX 54 #include <editeng/scripttypeitem.hxx> 55 #endif 56 #include <svx/unopage.hxx> 57 #include <editeng/flditem.hxx> 58 #include <svx/sdr/contact/displayinfo.hxx> 59 #include <svx/svditer.hxx> 60 61 #include <editeng/adjitem.hxx> 62 63 #include "../ui/inc/DrawDocShell.hxx" 64 #include "Outliner.hxx" 65 #include "app.hrc" 66 #include "misc.hxx" 67 #include "eetext.hxx" 68 #include "drawdoc.hxx" 69 #include "sdpage.hxx" 70 #include "pglink.hxx" 71 #include "sdresid.hxx" 72 #include "stlsheet.hxx" 73 #include "glob.hrc" 74 #include "glob.hxx" 75 #include "helpids.h" 76 #include "anminfo.hxx" 77 #include "undo/undomanager.hxx" 78 #include "undo/undoobjects.hxx" 79 #include <svx/sdr/contact/displayinfo.hxx> 80 #include <svx/sdr/contact/viewobjectcontact.hxx> 81 #include <svx/sdr/contact/viewcontact.hxx> 82 #include <svx/sdr/contact/objectcontact.hxx> 83 #include <svx/unoapi.hxx> 84 85 #include <set> 86 87 using namespace ::sd; 88 using namespace ::com::sun::star; 89 90 TYPEINIT2( SdPage, FmFormPage, SdrObjUserCall ); 91 92 /************************************************************************* 93 |* Ctor 94 \************************************************************************/ 95 96 SdPage::SdPage(SdDrawDocument& rNewDoc, StarBASIC* pBasic, sal_Bool bMasterPage) 97 : FmFormPage(rNewDoc, pBasic, bMasterPage) 98 , SdrObjUserCall() 99 , mePageKind(PK_STANDARD) 100 , meAutoLayout(AUTOLAYOUT_NONE) 101 , mbSelected(sal_False) 102 , mePresChange(PRESCHANGE_MANUAL) 103 , mnTime(1) 104 , mbSoundOn(sal_False) 105 , mbExcluded(sal_False) 106 , mbLoopSound(sal_False) 107 , mbStopSound(sal_False) 108 , mbScaleObjects(sal_True) 109 , mbBackgroundFullSize( sal_False ) 110 , meCharSet(gsl_getSystemTextEncoding()) 111 , mnPaperBin(PAPERBIN_PRINTER_SETTINGS) 112 , mpPageLink(NULL) 113 , mpItems(NULL) 114 , mnTransitionType(0) 115 , mnTransitionSubtype(0) 116 , mbTransitionDirection(sal_True) 117 , mnTransitionFadeColor(0) 118 , mfTransitionDuration(2.0) 119 , mbIsPrecious(true) 120 { 121 // Der Layoutname der Seite wird von SVDRAW benutzt, um die Praesentations- 122 // vorlagen der Gliederungsobjekte zu ermitteln. Darum enthaelt er bereits 123 // den Bezeichner fuer die Gliederung (STR_LAYOUT_OUTLINE). 124 maLayoutName = String(SdResId(STR_LAYOUT_DEFAULT_NAME)); 125 maLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR )); 126 maLayoutName += String(SdResId(STR_LAYOUT_OUTLINE)); 127 128 Size aPageSize(GetSize()); 129 130 if (aPageSize.Width() > aPageSize.Height()) 131 { 132 meOrientation = ORIENTATION_LANDSCAPE; 133 } 134 else 135 { 136 meOrientation = ORIENTATION_PORTRAIT; 137 } 138 } 139 140 /************************************************************************* 141 |* Dtor 142 \************************************************************************/ 143 144 SdPage::~SdPage() 145 { 146 DisconnectLink(); 147 148 EndListenOutlineText(); 149 150 if( mpItems ) 151 delete mpItems; 152 } 153 154 struct OrdNumSorter 155 { 156 bool operator()( SdrObject* p1, SdrObject* p2 ) 157 { 158 return p1->GetOrdNum() < p2->GetOrdNum(); 159 } 160 }; 161 162 /** returns the nIndex'th object from the given PresObjKind, index starts with 1 */ 163 SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearch /* = false */ ) 164 { 165 // first sort all matching shapes with z-order 166 std::vector< SdrObject* > aMatches; 167 168 SdrObject* pObj = 0; 169 while( (pObj = maPresentationShapeList.getNextShape(pObj)) != 0 ) 170 { 171 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj); 172 if( pInfo ) 173 { 174 bool bFound = false; 175 if( pInfo->mePresObjKind == eObjKind ) 176 { 177 bFound = true; 178 } 179 else if( bFuzzySearch && (eObjKind == PRESOBJ_OUTLINE) ) 180 { 181 switch( pInfo->mePresObjKind ) 182 { 183 case PRESOBJ_GRAPHIC: 184 case PRESOBJ_OBJECT: 185 case PRESOBJ_CHART: 186 case PRESOBJ_ORGCHART: 187 case PRESOBJ_TABLE: 188 case PRESOBJ_CALC: 189 case PRESOBJ_IMAGE: 190 case PRESOBJ_MEDIA: 191 bFound = sal_True; 192 break; 193 default: 194 break; 195 } 196 } 197 if( bFound ) 198 { 199 aMatches.push_back( pObj ); 200 } 201 } 202 } 203 204 if( aMatches.size() > 1 ) 205 { 206 OrdNumSorter aSortHelper; 207 std::sort( aMatches.begin(), aMatches.end(), aSortHelper ); 208 } 209 210 if( nIndex > 0 ) 211 nIndex--; 212 213 if( (nIndex >= 0) && ( aMatches.size() > static_cast<unsigned int>(nIndex)) ) 214 return aMatches[nIndex]; 215 216 return 0; 217 } 218 219 /** create background properties */ 220 void SdPage::EnsureMasterPageDefaultBackground() 221 { 222 if(mbMaster) 223 { 224 // no hard attributes on MasterPage attributes 225 getSdrPageProperties().ClearItem(); 226 SfxStyleSheet* pSheetForPresObj = GetStyleSheetForMasterPageBackground(); 227 228 if(pSheetForPresObj) 229 { 230 // set StyleSheet for background fill attributes 231 getSdrPageProperties().SetStyleSheet(pSheetForPresObj); 232 } 233 else 234 { 235 // no style found, assert and set at least XFILL_NONE 236 OSL_ENSURE(false, "No Style for MasterPageBackground fill found (!)"); 237 getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE)); 238 } 239 } 240 } 241 242 /** creates a presentation object with the given PresObjKind on this page. A user call will be set 243 */ 244 SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, sal_Bool bVertical, const Rectangle& rRect, sal_Bool /* bInsert */ ) 245 { 246 ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0; 247 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted(); 248 249 SdrObject* pSdrObj = NULL; 250 251 bool bForceText = false; // forces the shape text to be set even if it's empty 252 bool bEmptyPresObj = true; 253 254 switch( eObjKind ) 255 { 256 case PRESOBJ_TITLE: 257 { 258 pSdrObj = new SdrRectObj(OBJ_TITLETEXT); 259 260 if (mbMaster) 261 { 262 pSdrObj->SetNotVisibleAsMaster(sal_True); 263 } 264 } 265 break; 266 267 case PRESOBJ_OUTLINE: 268 { 269 pSdrObj = new SdrRectObj(OBJ_OUTLINETEXT); 270 271 if (mbMaster) 272 { 273 pSdrObj->SetNotVisibleAsMaster(sal_True); 274 } 275 } 276 break; 277 278 case PRESOBJ_NOTES: 279 { 280 pSdrObj = new SdrRectObj(OBJ_TEXT); 281 282 if (mbMaster) 283 { 284 pSdrObj->SetNotVisibleAsMaster(sal_True); 285 } 286 } 287 break; 288 289 case PRESOBJ_TEXT: 290 { 291 pSdrObj = new SdrRectObj(OBJ_TEXT); 292 } 293 break; 294 295 case PRESOBJ_GRAPHIC: 296 { 297 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_GRAPHIC ) ); 298 Graphic aGraphic( aBmpEx ); 299 OutputDevice &aOutDev = *Application::GetDefaultDevice(); 300 aOutDev.Push(); 301 302 aOutDev.SetMapMode( aGraphic.GetPrefMapMode() ); 303 Size aSizePix = aOutDev.LogicToPixel( aGraphic.GetPrefSize() ); 304 aOutDev.SetMapMode(MAP_100TH_MM); 305 306 Size aSize = aOutDev.PixelToLogic(aSizePix); 307 Point aPnt (0, 0); 308 Rectangle aRect (aPnt, aSize); 309 pSdrObj = new SdrGrafObj(aGraphic, aRect); 310 aOutDev.Pop(); 311 } 312 break; 313 314 case PRESOBJ_MEDIA: 315 case PRESOBJ_OBJECT: 316 { 317 pSdrObj = new SdrOle2Obj(); 318 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_OBJECT ) ); 319 Graphic aGraphic( aBmpEx ); 320 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic); 321 } 322 break; 323 324 case PRESOBJ_CHART: 325 { 326 pSdrObj = new SdrOle2Obj(); 327 ( (SdrOle2Obj*) pSdrObj)->SetProgName( String( RTL_CONSTASCII_USTRINGPARAM( "StarChart" ))); 328 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_CHART ) ); 329 Graphic aGraphic( aBmpEx ); 330 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic); 331 } 332 break; 333 334 case PRESOBJ_ORGCHART: 335 { 336 pSdrObj = new SdrOle2Obj(); 337 ( (SdrOle2Obj*) pSdrObj)->SetProgName( String( RTL_CONSTASCII_USTRINGPARAM( "StarOrg" ))); 338 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_ORGCHART ) ); 339 Graphic aGraphic( aBmpEx ); 340 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic); 341 } 342 343 case PRESOBJ_TABLE: 344 case PRESOBJ_CALC: 345 { 346 pSdrObj = new SdrOle2Obj(); 347 ( (SdrOle2Obj*) pSdrObj)->SetProgName( String( RTL_CONSTASCII_USTRINGPARAM( "StarCalc" ))); 348 BitmapEx aBmpEx( SdResId( BMP_PRESOBJ_TABLE ) ); 349 Graphic aGraphic( aBmpEx ); 350 ( (SdrOle2Obj*) pSdrObj)->SetGraphic(&aGraphic); 351 } 352 break; 353 354 case PRESOBJ_HANDOUT: 355 { 356 //Erste Standardseite am SdrPageObj vermerken 357 // #i105146# We want no content to be displayed for PK_HANDOUT, 358 // so just never set a page as content 359 pSdrObj = new SdrPageObj(0); 360 // pSdrObj->SetResizeProtect(sal_True); 361 } 362 break; 363 364 case PRESOBJ_PAGE: 365 { 366 //Notizseite am SdrPageObj vermerken 367 sal_uInt16 nDestPageNum(GetPageNum()); 368 369 if(nDestPageNum) 370 { 371 // decrement only when != 0, else we get a 0xffff 372 nDestPageNum -= 1; 373 } 374 375 if(nDestPageNum < pModel->GetPageCount()) 376 { 377 pSdrObj = new SdrPageObj(pModel->GetPage(nDestPageNum)); 378 } 379 else 380 { 381 pSdrObj = new SdrPageObj(); 382 } 383 384 pSdrObj->SetResizeProtect(sal_True); 385 } 386 break; 387 388 case PRESOBJ_HEADER: 389 case PRESOBJ_FOOTER: 390 case PRESOBJ_DATETIME: 391 case PRESOBJ_SLIDENUMBER: 392 { 393 pSdrObj = new SdrRectObj(OBJ_TEXT); 394 bEmptyPresObj = false; 395 bForceText = true; 396 } 397 break; 398 default: 399 break; 400 } 401 402 if (pSdrObj) 403 { 404 pSdrObj->SetEmptyPresObj(bEmptyPresObj); 405 pSdrObj->SetLogicRect(rRect); 406 407 InsertObject(pSdrObj); 408 409 if ( pSdrObj->ISA(SdrTextObj) ) 410 { 411 // #96243# Tell the object EARLY that it is vertical to have the 412 // defaults for AutoGrowWidth/Height reversed 413 if(bVertical) 414 ((SdrTextObj*)pSdrObj)->SetVerticalWriting(sal_True); 415 416 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() ); 417 if( bVertical ) 418 aTempAttr.Put( SdrTextMinFrameWidthItem( rRect.GetSize().Width() ) ); 419 else 420 aTempAttr.Put( SdrTextMinFrameHeightItem( rRect.GetSize().Height() ) ); 421 422 if (mbMaster) 423 { 424 // Bei Praesentationsobjekten auf der MasterPage soll die 425 // Groesse vom Benutzer frei waehlbar sein 426 427 // #96243# potential problem: This action was still NOT 428 // adapted for vertical text. This sure needs to be done. 429 if(bVertical) 430 aTempAttr.Put(SdrTextAutoGrowWidthItem(sal_False)); 431 else 432 aTempAttr.Put(SdrTextAutoGrowHeightItem(sal_False)); 433 } 434 435 // check if we need another vertical adjustment then the default 436 SdrTextVertAdjust eV = SDRTEXTVERTADJUST_TOP; 437 438 if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind != PK_STANDARD) ) 439 { 440 eV = SDRTEXTVERTADJUST_BOTTOM; 441 } 442 else if( (eObjKind == PRESOBJ_SLIDENUMBER) && (mePageKind != PK_STANDARD) ) 443 { 444 eV = SDRTEXTVERTADJUST_BOTTOM; 445 } 446 447 if( eV != SDRTEXTVERTADJUST_TOP ) 448 aTempAttr.Put(SdrTextVertAdjustItem(eV)); 449 450 pSdrObj->SetMergedItemSet(aTempAttr); 451 452 pSdrObj->SetLogicRect(rRect); 453 } 454 455 String aString = GetPresObjText(eObjKind); 456 if( (aString.Len() || bForceText) && pSdrObj->ISA(SdrTextObj) ) 457 { 458 SdrOutliner* pOutliner = ( (SdDrawDocument*) GetModel() )->GetInternalOutliner(); 459 460 sal_uInt16 nOutlMode = pOutliner->GetMode(); 461 pOutliner->Init( OUTLINERMODE_TEXTOBJECT ); 462 pOutliner->SetStyleSheet( 0, NULL ); 463 pOutliner->SetVertical( bVertical ); 464 465 String aEmptyStr; 466 SetObjText( (SdrTextObj*) pSdrObj, (SdrOutliner*)pOutliner, eObjKind, aString ); 467 468 pOutliner->Init( nOutlMode ); 469 pOutliner->SetStyleSheet( 0, NULL ); 470 } 471 472 if( (eObjKind == PRESOBJ_HEADER) || (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_DATETIME) ) 473 { 474 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() ); 475 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT ) ); 476 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CTL ) ); 477 aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CJK ) ); 478 479 SvxAdjust eH = SVX_ADJUST_LEFT; 480 481 if( (eObjKind == PRESOBJ_DATETIME) && (mePageKind != PK_STANDARD ) ) 482 { 483 eH = SVX_ADJUST_RIGHT; 484 } 485 else if( (eObjKind == PRESOBJ_FOOTER) && (mePageKind == PK_STANDARD ) ) 486 { 487 eH = SVX_ADJUST_CENTER; 488 } 489 else if( eObjKind == PRESOBJ_SLIDENUMBER ) 490 { 491 eH = SVX_ADJUST_RIGHT; 492 } 493 494 if( eH != SVX_ADJUST_LEFT ) 495 aTempAttr.Put(SvxAdjustItem(eH, EE_PARA_JUST )); 496 497 pSdrObj->SetMergedItemSet(aTempAttr); 498 } 499 500 if (mbMaster) 501 { 502 SdrLayerAdmin& rLayerAdmin = pModel->GetLayerAdmin(); 503 504 // Hintergrundobjekte der MasterPage 505 pSdrObj->SetLayer( rLayerAdmin. 506 GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False) ); 507 } 508 509 // Objekt am StyleSheet anmelden 510 // #95114# Set style only when one was found (as in 5.2) 511 // pSdrObj->NbcSetStyleSheet( GetStyleSheetForPresObj(eObjKind), sal_False ); 512 if( mePageKind != PK_HANDOUT ) 513 { 514 SfxStyleSheet* pSheetForPresObj = GetStyleSheetForPresObj(eObjKind); 515 if(pSheetForPresObj) 516 pSdrObj->SetStyleSheet(pSheetForPresObj, sal_False); 517 } 518 519 if (eObjKind == PRESOBJ_OUTLINE) 520 { 521 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++) 522 { 523 String aName(maLayoutName); 524 aName += sal_Unicode( ' ' ); 525 aName += String::CreateFromInt32( nLevel ); 526 SfxStyleSheet* pSheet = (SfxStyleSheet*)pModel->GetStyleSheetPool()->Find(aName, SD_STYLE_FAMILY_MASTERPAGE); 527 DBG_ASSERT(pSheet, "Vorlage fuer Gliederungsobjekt nicht gefunden"); 528 if (pSheet) 529 pSdrObj->StartListening(*pSheet); 530 } 531 } 532 533 if ( eObjKind == PRESOBJ_OBJECT || 534 eObjKind == PRESOBJ_CHART || 535 eObjKind == PRESOBJ_ORGCHART || 536 eObjKind == PRESOBJ_CALC || 537 eObjKind == PRESOBJ_GRAPHIC ) 538 { 539 SfxItemSet aSet( ((SdDrawDocument*) pModel)->GetPool() ); 540 aSet.Put( SdrTextContourFrameItem( sal_True ) ); 541 aSet.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) ); 542 543 pSdrObj->SetMergedItemSet(aSet); 544 } 545 546 if( bUndo ) 547 { 548 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj)); 549 } 550 551 if( bUndo ) 552 { 553 pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pSdrObj ) ); 554 pUndoManager->AddUndoAction( new UndoObjectUserCall(*pSdrObj) ); 555 } 556 557 InsertPresObj(pSdrObj, eObjKind); 558 pSdrObj->SetUserCall(this); 559 560 pSdrObj->RecalcBoundRect(); 561 } 562 563 return(pSdrObj); 564 } 565 566 /************************************************************************* 567 |* Es werden Praesentationsobjekte auf der Page erzeugt. 568 |* Alle Praesentationsobjekte erhalten einen UserCall auf die Page. 569 \************************************************************************/ 570 571 SfxStyleSheet* SdPage::GetStyleSheetForMasterPageBackground() const 572 { 573 String aName(GetLayoutName()); 574 String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR )); 575 sal_uInt16 nPos = aName.Search(aSep); 576 577 if (nPos != STRING_NOTFOUND) 578 { 579 nPos = nPos + aSep.Len(); 580 aName.Erase(nPos); 581 } 582 583 aName += String(SdResId(STR_LAYOUT_BACKGROUND)); 584 585 SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool(); 586 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE); 587 return (SfxStyleSheet*)pResult; 588 } 589 590 SfxStyleSheet* SdPage::GetStyleSheetForPresObj(PresObjKind eObjKind) const 591 { 592 String aName(GetLayoutName()); 593 String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR )); 594 sal_uInt16 nPos = aName.Search(aSep); 595 if (nPos != STRING_NOTFOUND) 596 { 597 nPos = nPos + aSep.Len(); 598 aName.Erase(nPos); 599 } 600 601 switch (eObjKind) 602 { 603 case PRESOBJ_OUTLINE: 604 { 605 aName = GetLayoutName(); 606 aName += sal_Unicode( ' ' ); 607 aName += String::CreateFromInt32( 1 ); 608 } 609 break; 610 611 case PRESOBJ_TITLE: 612 aName += String(SdResId(STR_LAYOUT_TITLE)); 613 break; 614 615 case PRESOBJ_NOTES: 616 aName += String(SdResId(STR_LAYOUT_NOTES)); 617 break; 618 619 case PRESOBJ_TEXT: 620 aName += String(SdResId(STR_LAYOUT_SUBTITLE)); 621 break; 622 623 case PRESOBJ_HEADER: 624 case PRESOBJ_FOOTER: 625 case PRESOBJ_DATETIME: 626 case PRESOBJ_SLIDENUMBER: 627 aName += String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS)); 628 break; 629 630 default: 631 break; 632 } 633 634 SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool(); 635 SfxStyleSheetBase* pResult = pStShPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE); 636 return (SfxStyleSheet*)pResult; 637 } 638 639 /** returns the presentation style with the given helpid from this masterpage or this 640 slides masterpage */ 641 SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const 642 { 643 String aStyleName( pPage->GetLayoutName() ); 644 const String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR )); 645 aStyleName.Erase(aStyleName.Search(aSep) + aSep.Len()); 646 647 sal_uInt16 nNameId; 648 switch( nHelpId ) 649 { 650 case HID_PSEUDOSHEET_TITLE: nNameId = STR_LAYOUT_TITLE; break; 651 case HID_PSEUDOSHEET_SUBTITLE: nNameId = STR_LAYOUT_SUBTITLE; break; 652 case HID_PSEUDOSHEET_OUTLINE1: 653 case HID_PSEUDOSHEET_OUTLINE2: 654 case HID_PSEUDOSHEET_OUTLINE3: 655 case HID_PSEUDOSHEET_OUTLINE4: 656 case HID_PSEUDOSHEET_OUTLINE5: 657 case HID_PSEUDOSHEET_OUTLINE6: 658 case HID_PSEUDOSHEET_OUTLINE7: 659 case HID_PSEUDOSHEET_OUTLINE8: 660 case HID_PSEUDOSHEET_OUTLINE9: nNameId = STR_LAYOUT_OUTLINE; break; 661 case HID_PSEUDOSHEET_BACKGROUNDOBJECTS: nNameId = STR_LAYOUT_BACKGROUNDOBJECTS; break; 662 case HID_PSEUDOSHEET_BACKGROUND: nNameId = STR_LAYOUT_BACKGROUND; break; 663 case HID_PSEUDOSHEET_NOTES: nNameId = STR_LAYOUT_NOTES; break; 664 665 default: 666 DBG_ERROR( "SdPage::getPresentationStyle(), illegal argument!" ); 667 return 0; 668 } 669 aStyleName.Append( String( SdResId( nNameId ) ) ); 670 if( nNameId == STR_LAYOUT_OUTLINE ) 671 { 672 aStyleName.Append( sal_Unicode( ' ' )); 673 aStyleName.Append( String::CreateFromInt32( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE ))); 674 } 675 676 SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool(); 677 SfxStyleSheetBase* pResult = pStShPool->Find(aStyleName, SD_STYLE_FAMILY_MASTERPAGE); 678 return dynamic_cast<SdStyleSheet*>(pResult); 679 } 680 681 /************************************************************************* 682 |* Das Praesentationsobjekt rObj hat sich geaendert und wird nicht mehr 683 |* durch das Praesentationsobjekt der MasterPage referenziert. 684 |* Der UserCall wird geloescht. 685 \************************************************************************/ 686 687 void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const Rectangle& ) 688 { 689 if (!maLockAutoLayoutArrangement.isLocked()) 690 { 691 switch (eType) 692 { 693 case SDRUSERCALL_MOVEONLY: 694 case SDRUSERCALL_RESIZE: 695 { 696 if( pModel->isLocked() ) 697 break; 698 699 SdrObject* pObj = (SdrObject*) &rObj; 700 701 if (pObj) 702 { 703 if (!mbMaster) 704 { 705 if( pObj->GetUserCall() ) 706 { 707 ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0; 708 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted(); 709 /* 710 DBG_ASSERT( bUndo || (pUndoManager && pUndoManager->IsDoing()), 711 "SdPage::Changed(), model change without undo!?" ); 712 */ 713 if( bUndo ) 714 pUndoManager->AddUndoAction( new UndoObjectUserCall(*pObj) ); 715 716 // Object was resized by user and does not listen to its slide anymore 717 pObj->SetUserCall(0); 718 } 719 } 720 else if (pModel) 721 { 722 // MasterPage-Objekt wurde veraendert, daher 723 // Objekte auf allen Seiten anpassen 724 sal_uInt16 nPageCount = ((SdDrawDocument*) pModel)->GetSdPageCount(mePageKind); 725 726 for (sal_uInt16 i = 0; i < nPageCount; i++) 727 { 728 SdPage* pLoopPage = ((SdDrawDocument*) pModel)->GetSdPage(i, mePageKind); 729 730 if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage())) 731 { 732 // Seite hoert auf diese MasterPage, daher 733 // AutoLayout anpassen 734 pLoopPage->SetAutoLayout(pLoopPage->GetAutoLayout()); 735 } 736 } 737 } 738 } 739 } 740 break; 741 742 case SDRUSERCALL_DELETE: 743 case SDRUSERCALL_REMOVED: 744 default: 745 break; 746 } 747 } 748 } 749 750 /************************************************************************* 751 |* Erzeugt auf einer MasterPage Hintergrund, Titel- und Layout-Bereich 752 \************************************************************************/ 753 754 void SdPage::CreateTitleAndLayout(sal_Bool bInit, sal_Bool bCreate ) 755 { 756 ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0; 757 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted(); 758 759 SdPage* pMasterPage = this; 760 761 if (!mbMaster) 762 { 763 pMasterPage = (SdPage*)(&(TRG_GetMasterPage())); 764 } 765 766 if (!pMasterPage) 767 { 768 return; 769 } 770 771 /************************************************************************** 772 * Hintergrund, Titel- und Layout-Bereich werden angelegt 773 **************************************************************************/ 774 if( mePageKind == PK_STANDARD ) 775 { 776 pMasterPage->EnsureMasterPageDefaultBackground(); 777 } 778 779 if( ( (SdDrawDocument*) GetModel() )->GetDocumentType() == DOCUMENT_TYPE_IMPRESS ) 780 { 781 if( mePageKind == PK_HANDOUT && bInit ) 782 { 783 // handout template 784 785 // delete all available handout presentation objects 786 SdrObject *pObj=NULL; 787 while( (pObj = pMasterPage->GetPresObj(PRESOBJ_HANDOUT)) != 0 ) 788 { 789 pMasterPage->RemoveObject(pObj->GetOrdNum()); 790 791 if( bUndo ) 792 { 793 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); 794 } 795 else 796 { 797 SdrObject::Free( pObj ); // memory leak i120050 798 } 799 } 800 801 std::vector< Rectangle > aAreas; 802 CalculateHandoutAreas( *static_cast< SdDrawDocument* >(GetModel() ), pMasterPage->GetAutoLayout(), false, aAreas ); 803 804 const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3; 805 std::vector< Rectangle >::iterator iter( aAreas.begin() ); 806 807 while( iter != aAreas.end() ) 808 { 809 SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pMasterPage->CreatePresObj(PRESOBJ_HANDOUT, sal_False, (*iter++), sal_True) ); 810 // #i105146# We want no content to be displayed for PK_HANDOUT, 811 // so just never set a page as content 812 pPageObj->SetReferencedPage(0L); 813 814 if( bSkip && iter != aAreas.end() ) 815 iter++; 816 } 817 } 818 819 if( mePageKind != PK_HANDOUT ) 820 { 821 SdrObject* pMasterTitle = pMasterPage->GetPresObj( PRESOBJ_TITLE ); 822 if( pMasterTitle == NULL ) 823 pMasterPage->CreateDefaultPresObj(PRESOBJ_TITLE, true); 824 825 SdrObject* pMasterOutline = pMasterPage->GetPresObj( mePageKind==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE ); 826 if( pMasterOutline == NULL ) 827 pMasterPage->CreateDefaultPresObj( mePageKind == PK_STANDARD ? PRESOBJ_OUTLINE : PRESOBJ_NOTES, true ); 828 } 829 830 // create header&footer objects 831 832 if( bCreate ) 833 { 834 if( mePageKind != PK_STANDARD ) 835 { 836 SdrObject* pHeader = pMasterPage->GetPresObj( PRESOBJ_HEADER ); 837 if( pHeader == NULL ) 838 pMasterPage->CreateDefaultPresObj( PRESOBJ_HEADER, true ); 839 } 840 841 SdrObject* pDate = pMasterPage->GetPresObj( PRESOBJ_DATETIME ); 842 if( pDate == NULL ) 843 pMasterPage->CreateDefaultPresObj( PRESOBJ_DATETIME, true ); 844 845 SdrObject* pFooter = pMasterPage->GetPresObj( PRESOBJ_FOOTER ); 846 if( pFooter == NULL ) 847 pMasterPage->CreateDefaultPresObj( PRESOBJ_FOOTER, true ); 848 849 SdrObject* pNumber = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER ); 850 if( pNumber == NULL ) 851 pMasterPage->CreateDefaultPresObj( PRESOBJ_SLIDENUMBER, true ); 852 } 853 } 854 } 855 856 SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert) 857 { 858 if( eObjKind == PRESOBJ_TITLE ) 859 { 860 Rectangle aTitleRect( GetTitleRect() ); 861 return CreatePresObj(PRESOBJ_TITLE, sal_False, aTitleRect, bInsert); 862 } 863 else if( eObjKind == PRESOBJ_OUTLINE ) 864 { 865 Rectangle aLayoutRect( GetLayoutRect() ); 866 return CreatePresObj( PRESOBJ_OUTLINE, sal_False, aLayoutRect, bInsert); 867 } 868 else if( eObjKind == PRESOBJ_NOTES ) 869 { 870 Rectangle aLayoutRect( GetLayoutRect() ); 871 return CreatePresObj( PRESOBJ_NOTES, sal_False, aLayoutRect, bInsert); 872 } 873 else if( (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_DATETIME) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_HEADER ) ) 874 { 875 // create footer objects for standard master page 876 if( mePageKind == PK_STANDARD ) 877 { 878 const long nLftBorder = GetLftBorder(); 879 const long nUppBorder = GetUppBorder(); 880 881 Point aTitlePos ( nLftBorder, nUppBorder ); 882 Size aPageSize ( GetSize() ); 883 aPageSize.Width() -= nLftBorder + GetRgtBorder(); 884 aPageSize.Height() -= nUppBorder + GetLwrBorder(); 885 886 const int Y = long(nUppBorder + aPageSize.Height() * 0.911); 887 const int W1 = long(aPageSize.Width() * 0.233); 888 const int W2 = long(aPageSize.Width() * 0.317); 889 const int H = long(aPageSize.Height() * 0.069); 890 891 if( eObjKind == PRESOBJ_DATETIME ) 892 { 893 Point aPos( long(nLftBorder+(aPageSize.Width()*0.05)), Y ); 894 Size aSize( W1, H ); 895 Rectangle aRect( aPos, aSize ); 896 return CreatePresObj( PRESOBJ_DATETIME, sal_False, aRect, bInsert ); 897 } 898 else if( eObjKind == PRESOBJ_FOOTER ) 899 { 900 Point aPos( long(nLftBorder+ aPageSize.Width() * 0.342), Y ); 901 Size aSize( W2, H ); 902 Rectangle aRect( aPos, aSize ); 903 return CreatePresObj( PRESOBJ_FOOTER, sal_False, aRect, bInsert ); 904 } 905 else if( eObjKind == PRESOBJ_SLIDENUMBER ) 906 { 907 Point aPos( long(nLftBorder+(aPageSize.Width()*0.717)), Y ); 908 Size aSize( W1, H ); 909 Rectangle aRect( aPos, aSize ); 910 return CreatePresObj( PRESOBJ_SLIDENUMBER, sal_False, aRect, bInsert ); 911 } 912 else 913 { 914 DBG_ERROR( "SdPage::CreateDefaultPresObj() - can't create a header placeholder for a slide master" ); 915 return NULL; 916 } 917 } 918 else 919 { 920 // create header&footer objects for handout and notes master 921 Point aTitlePos ( GetLftBorder(), GetUppBorder() ); 922 Size aPageSize ( GetSize() ); 923 aPageSize.Width() -= GetLftBorder() + GetRgtBorder(); 924 aPageSize.Height() -= GetUppBorder() + GetLwrBorder(); 925 926 927 const int NOTES_HEADER_FOOTER_WIDTH = long(aPageSize.Width() * 0.434); 928 const int NOTES_HEADER_FOOTER_HEIGHT = long(aPageSize.Height() * 0.05); 929 930 Size aSize( NOTES_HEADER_FOOTER_WIDTH, NOTES_HEADER_FOOTER_HEIGHT ); 931 932 const int X1 = GetLftBorder(); 933 const int X2 = GetLftBorder() + long(aPageSize.Width() - NOTES_HEADER_FOOTER_WIDTH); 934 const int Y1 = GetUppBorder(); 935 const int Y2 = GetUppBorder() + long(aPageSize.Height() - NOTES_HEADER_FOOTER_HEIGHT ); 936 937 if( eObjKind == PRESOBJ_HEADER ) 938 { 939 Point aPos( X1, Y1 ); 940 Rectangle aRect( aPos, aSize ); 941 return CreatePresObj( PRESOBJ_HEADER, sal_False, aRect, bInsert ); 942 } 943 else if( eObjKind == PRESOBJ_DATETIME ) 944 { 945 Point aPos( X2, Y1 ); 946 Rectangle aRect( aPos, aSize ); 947 return CreatePresObj( PRESOBJ_DATETIME, sal_False, aRect, bInsert ); 948 } 949 else if( eObjKind == PRESOBJ_FOOTER ) 950 { 951 Point aPos( X1, Y2 ); 952 Rectangle aRect( aPos, aSize ); 953 return CreatePresObj( PRESOBJ_FOOTER, sal_False, aRect, bInsert ); 954 } 955 else if( eObjKind == PRESOBJ_SLIDENUMBER ) 956 { 957 Point aPos( X2, Y2 ); 958 Rectangle aRect( aPos, aSize ); 959 return CreatePresObj( PRESOBJ_SLIDENUMBER, sal_False, aRect, bInsert ); 960 } 961 962 DBG_ERROR("SdPage::CreateDefaultPresObj() - this should not happen!"); 963 return NULL; 964 } 965 } 966 else 967 { 968 DBG_ERROR("SdPage::CreateDefaultPresObj() - unknown PRESOBJ kind" ); 969 return NULL; 970 } 971 } 972 973 /************************************************************************* 974 |* Titelbereich zurueckgeben 975 \************************************************************************/ 976 977 Rectangle SdPage::GetTitleRect() const 978 { 979 Rectangle aTitleRect; 980 981 if (mePageKind != PK_HANDOUT) 982 { 983 /****************************************************************** 984 * Standard- oder Notiz-Seite: Titelbereich 985 ******************************************************************/ 986 Point aTitlePos ( GetLftBorder(), GetUppBorder() ); 987 Size aTitleSize ( GetSize() ); 988 aTitleSize.Width() -= GetLftBorder() + GetRgtBorder(); 989 aTitleSize.Height() -= GetUppBorder() + GetLwrBorder(); 990 991 if (mePageKind == PK_STANDARD) 992 { 993 aTitlePos.X() += long( aTitleSize.Width() * 0.05 ); 994 aTitlePos.Y() += long( aTitleSize.Height() * 0.0399 ); 995 aTitleSize.Width() = long( aTitleSize.Width() * 0.9 ); 996 aTitleSize.Height() = long( aTitleSize.Height() * 0.167 ); 997 } 998 else if (mePageKind == PK_NOTES) 999 { 1000 Point aPos = aTitlePos; 1001 aPos.Y() += long( aTitleSize.Height() * 0.076 ); 1002 1003 // Hoehe beschraenken 1004 aTitleSize.Height() = (long) (aTitleSize.Height() * 0.375); 1005 1006 Size aPartArea = aTitleSize; 1007 Size aSize; 1008 sal_uInt16 nDestPageNum(GetPageNum()); 1009 SdrPage* pRefPage = 0L; 1010 1011 if(nDestPageNum) 1012 { 1013 // only decrement if != 0, else we get 0xffff 1014 nDestPageNum -= 1; 1015 } 1016 1017 if(nDestPageNum < pModel->GetPageCount()) 1018 { 1019 pRefPage = pModel->GetPage(nDestPageNum); 1020 } 1021 1022 if ( pRefPage ) 1023 { 1024 // tatsaechliche Seitengroesse in das Handout-Rechteck skalieren 1025 double fH = (double) aPartArea.Width() / pRefPage->GetWdt(); 1026 double fV = (double) aPartArea.Height() / pRefPage->GetHgt(); 1027 1028 if ( fH > fV ) 1029 fH = fV; 1030 aSize.Width() = (long) (fH * pRefPage->GetWdt()); 1031 aSize.Height() = (long) (fH * pRefPage->GetHgt()); 1032 1033 aPos.X() += (aPartArea.Width() - aSize.Width()) / 2; 1034 aPos.Y() += (aPartArea.Height()- aSize.Height())/ 2; 1035 } 1036 1037 aTitlePos = aPos; 1038 aTitleSize = aSize; 1039 } 1040 1041 aTitleRect.SetPos(aTitlePos); 1042 aTitleRect.SetSize(aTitleSize); 1043 } 1044 1045 return aTitleRect; 1046 } 1047 1048 1049 /************************************************************************* 1050 |* Gliederungsbereich zurueckgeben 1051 \************************************************************************/ 1052 1053 Rectangle SdPage::GetLayoutRect() const 1054 { 1055 Rectangle aLayoutRect; 1056 1057 if (mePageKind != PK_HANDOUT) 1058 { 1059 Point aLayoutPos ( GetLftBorder(), GetUppBorder() ); 1060 Size aLayoutSize ( GetSize() ); 1061 aLayoutSize.Width() -= GetLftBorder() + GetRgtBorder(); 1062 aLayoutSize.Height() -= GetUppBorder() + GetLwrBorder(); 1063 1064 if (mePageKind == PK_STANDARD) 1065 { 1066 aLayoutPos.X() += long( aLayoutSize.Width() * 0.05 ); 1067 aLayoutPos.Y() += long( aLayoutSize.Height() * 0.234 ); 1068 aLayoutSize.Width() = long( aLayoutSize.Width() * 0.9 ); 1069 aLayoutSize.Height() = long( aLayoutSize.Height() * 0.66 ); 1070 aLayoutRect.SetPos(aLayoutPos); 1071 aLayoutRect.SetSize(aLayoutSize); 1072 } 1073 else if (mePageKind == PK_NOTES) 1074 { 1075 aLayoutPos.X() += long( aLayoutSize.Width() * 0.1 ); 1076 aLayoutPos.Y() += long( aLayoutSize.Height() * 0.475 ); 1077 aLayoutSize.Width() = long( aLayoutSize.Width() * 0.8 ); 1078 aLayoutSize.Height() = long( aLayoutSize.Height() * 0.45 ); 1079 aLayoutRect.SetPos(aLayoutPos); 1080 aLayoutRect.SetSize(aLayoutSize); 1081 } 1082 } 1083 1084 return aLayoutRect; 1085 } 1086 1087 1088 /************************************************************************** 1089 |* Diese Methode weist ein AutoLayout zu 1090 \*************************************************************************/ 1091 1092 const int MAX_PRESOBJS = 7; // maximum number of presentation objects per layout 1093 const int VERTICAL = 0x8000; 1094 1095 struct LayoutDescriptor 1096 { 1097 int mnLayout; 1098 PresObjKind meKind[MAX_PRESOBJS]; 1099 bool mbVertical[MAX_PRESOBJS]; 1100 1101 LayoutDescriptor( int nLayout, int k0 = 0, int k1 = 0, int k2 = 0, int k3 = 0, int k4 = 0, int k5 = 0, int k6 = 0 ); 1102 }; 1103 1104 LayoutDescriptor::LayoutDescriptor( int nLayout, int k0, int k1, int k2, int k3, int k4, int k5, int k6 ) 1105 : mnLayout( nLayout ) 1106 { 1107 meKind[0] = static_cast<PresObjKind>(k0 & (~VERTICAL)); mbVertical[0] = (k0 & VERTICAL) == VERTICAL; 1108 meKind[1] = static_cast<PresObjKind>(k1 & (~VERTICAL)); mbVertical[1] = (k1 & VERTICAL) == VERTICAL; 1109 meKind[2] = static_cast<PresObjKind>(k2 & (~VERTICAL)); mbVertical[2] = (k2 & VERTICAL) == VERTICAL; 1110 meKind[3] = static_cast<PresObjKind>(k3 & (~VERTICAL)); mbVertical[3] = (k3 & VERTICAL) == VERTICAL; 1111 meKind[4] = static_cast<PresObjKind>(k4 & (~VERTICAL)); mbVertical[4] = (k4 & VERTICAL) == VERTICAL; 1112 meKind[5] = static_cast<PresObjKind>(k5 & (~VERTICAL)); mbVertical[5] = (k5 & VERTICAL) == VERTICAL; 1113 meKind[6] = static_cast<PresObjKind>(k6 & (~VERTICAL)); mbVertical[6] = (k6 & VERTICAL) == VERTICAL; 1114 } 1115 1116 static const LayoutDescriptor& GetLayoutDescriptor( AutoLayout eLayout ) 1117 { 1118 static LayoutDescriptor aLayouts[AUTOLAYOUT__END-AUTOLAYOUT__START] = 1119 { 1120 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_TEXT ), // AUTOLAYOUT_TITLE 1121 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_ENUM 1122 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CHART 1123 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_2TEXT 1124 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTCHART 1125 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_ORG 1126 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTCLbIP 1127 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CHARTTEXT 1128 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TAB 1129 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_CLIPTEXT 1130 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOBJ 1131 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OBJECT ), // AUTOLAYOUT_OBJ 1132 LayoutDescriptor( 2, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXT2OBJ 1133 LayoutDescriptor( 1, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOBJ 1134 LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_OBJOVERTEXT 1135 LayoutDescriptor( 3, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_2OBJTEXT 1136 LayoutDescriptor( 5, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_2OBJOVERTEXT 1137 LayoutDescriptor( 4, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), // AUTOLAYOUT_TEXTOVEROBJ 1138 LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_4OBJ 1139 PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ), 1140 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_NONE ), // AUTOLAYOUT_ONLY_TITLE 1141 LayoutDescriptor( 0, PRESOBJ_NONE ), // AUTOLAYOUT_NONE 1142 LayoutDescriptor( 0, PRESOBJ_PAGE, PRESOBJ_NOTES ), // AUTOLAYOUT_NOTES 1143 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT1 1144 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT2 1145 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT3 1146 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT4 1147 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT6 1148 LayoutDescriptor( 7, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE ),// AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART 1149 LayoutDescriptor( 8, PRESOBJ_TITLE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE 1150 LayoutDescriptor( 0, PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE 1151 LayoutDescriptor( 9, PRESOBJ_TITLE, PRESOBJ_OUTLINE|VERTICAL, PRESOBJ_OUTLINE|VERTICAL ), // AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART 1152 LayoutDescriptor( 0 ), // AUTOLAYOUT_HANDOUT9 1153 LayoutDescriptor( 10, PRESOBJ_TEXT, PRESOBJ_NONE ), // AUTOLAYOUT_ONLY_TEXT 1154 LayoutDescriptor( 6, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_4CLIPART 1155 PRESOBJ_GRAPHIC, PRESOBJ_GRAPHIC ), 1156 LayoutDescriptor( 11, PRESOBJ_TITLE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, // AUTOLAYOUT_6CLIPART 1157 PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE, PRESOBJ_OUTLINE ) 1158 }; 1159 1160 if( (eLayout < AUTOLAYOUT__START) || (eLayout >= AUTOLAYOUT__END) ) 1161 eLayout = AUTOLAYOUT_NONE; 1162 1163 return aLayouts[ eLayout - AUTOLAYOUT__START ]; 1164 } 1165 1166 static void CalcAutoLayoutRectangles( SdPage& rPage, int nLayout, Rectangle* rRectangle ) 1167 { 1168 Rectangle aTitleRect; 1169 Rectangle aLayoutRect; 1170 1171 if( rPage.GetPageKind() != PK_HANDOUT ) 1172 { 1173 SdPage& rMasterPage = static_cast<SdPage&>(rPage.TRG_GetMasterPage()); 1174 SdrObject* pMasterTitle = rMasterPage.GetPresObj( PRESOBJ_TITLE ); 1175 SdrObject* pMasterSubTitle = rMasterPage.GetPresObj( PRESOBJ_TEXT ); 1176 SdrObject* pMasterOutline = rMasterPage.GetPresObj( rPage.GetPageKind()==PK_NOTES ? PRESOBJ_NOTES : PRESOBJ_OUTLINE ); 1177 1178 if( pMasterTitle ) 1179 aTitleRect = pMasterTitle->GetLogicRect(); 1180 1181 if (aTitleRect.IsEmpty() ) 1182 aTitleRect = rPage.GetTitleRect(); 1183 if( pMasterSubTitle ) 1184 aLayoutRect = pMasterSubTitle->GetLogicRect(); 1185 else if( pMasterOutline ) 1186 aLayoutRect = pMasterOutline->GetLogicRect(); 1187 1188 if (aLayoutRect.IsEmpty() ) 1189 aLayoutRect = rPage.GetLayoutRect(); 1190 } 1191 1192 rRectangle[0] = aTitleRect; 1193 1194 int i; 1195 for( i = 1; i < MAX_PRESOBJS; i++ ) 1196 rRectangle[i] = aLayoutRect; 1197 1198 Size aTitleSize( aTitleRect.GetSize() ); 1199 Point aTitlePos( aTitleRect.TopLeft() ); 1200 Size aLayoutSize( aLayoutRect.GetSize() ); 1201 Point aLayoutPos( aLayoutRect.TopLeft() ); 1202 Size aTempSize; 1203 Point aTempPnt; 1204 1205 sal_Bool bRightToLeft = ( rPage.GetModel() && static_cast< SdDrawDocument* >( rPage.GetModel() )->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB ); 1206 1207 switch( nLayout ) 1208 { 1209 case 0: // default layout using only the title and layout area 1210 break; // do nothing 1211 case 1: // title, 2 shapes 1212 case 9: // title, 2 vertical shapes 1213 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488); 1214 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize); 1215 1216 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05); 1217 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize); 1218 1219 if( bRightToLeft && (nLayout != 9) ) 1220 ::std::swap< Rectangle >( rRectangle[1], rRectangle[2] ); 1221 break; 1222 case 2: // title, shape, 2 shapes 1223 aTempPnt = aLayoutPos; 1224 aTempSize = aLayoutSize; 1225 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477); 1226 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488); 1227 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05); 1228 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize); 1229 1230 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095); 1231 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize); 1232 1233 aLayoutPos = aTempPnt; 1234 aLayoutSize = aTempSize; 1235 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488); 1236 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize); 1237 1238 if( bRightToLeft ) 1239 { 1240 ::std::swap< long >( rRectangle[1].Left(), rRectangle[2].Left() ); 1241 rRectangle[3].Left() = rRectangle[2].Left(); 1242 } 1243 break; 1244 case 3: // title, 2 shapes, shape 1245 aTempPnt = aLayoutPos; 1246 aTempSize = aLayoutSize; 1247 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477); 1248 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488); 1249 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize); 1250 1251 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095); 1252 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize); 1253 1254 aLayoutPos = aTempPnt; 1255 aLayoutSize = aTempSize; 1256 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488); 1257 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05); 1258 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize); 1259 1260 if( bRightToLeft ) 1261 { 1262 ::std::swap< long >( rRectangle[1].Left(), rRectangle[2].Left() ); 1263 rRectangle[3].Left() = rRectangle[2].Left(); 1264 } 1265 break; 1266 case 4: // title, shape above shape 1267 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477); 1268 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize); 1269 1270 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095); 1271 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize); 1272 break; 1273 1274 case 5: // title, 2 shapes above shape 1275 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477); 1276 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488); 1277 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize); 1278 1279 aTempPnt = aLayoutPos; 1280 aLayoutPos.X() = long (aLayoutPos.X() + aLayoutSize.Width() * 1.05); 1281 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize); 1282 1283 aLayoutPos.X() = aTempPnt.X(); 1284 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095); 1285 aLayoutSize.Width() = long (aLayoutSize.Width() / 0.488); 1286 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize); 1287 break; 1288 case 6: // title, 4 shapes 1289 { 1290 sal_uLong nX = long (aLayoutPos.X()); 1291 1292 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477); 1293 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.488); 1294 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize); 1295 1296 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05); 1297 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize); 1298 1299 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095); 1300 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize); 1301 1302 aLayoutPos.X() = nX; 1303 rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize); 1304 break; 1305 } 1306 case 7: // vertical title, shape above shape 1307 { 1308 Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() ); 1309 rRectangle[0].SetSize( aSize ); 1310 rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) ); 1311 1312 Size aPageSize ( rPage.GetSize() ); 1313 aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder(); 1314 aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 ); 1315 aSize.Width() = long( aPageSize.Width() * 0.7 ); 1316 rRectangle[1].SetPos( aTitleRect.TopLeft() ); 1317 rRectangle[1].SetSize( aSize ); 1318 1319 aSize.Height() = rRectangle[0].GetSize().Height(); 1320 Point aPos( aTitleRect.TopLeft() ); 1321 aPos.Y() += long ( aSize.Height() * 0.53 ); 1322 rRectangle[2].SetPos( aPos ); 1323 aSize.Height() = long ( rRectangle[0].GetSize().Height() * 0.47 ); 1324 rRectangle[2].SetSize( aSize ); 1325 break; 1326 } 1327 case 8: // vertical title, shape 1328 { 1329 Size aSize( rRectangle[0].GetSize().Height(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() ); 1330 rRectangle[0].SetSize( aSize ); 1331 rRectangle[0].SetPos( aTitleRect.TopRight() - Point( aSize.Width(), 0 ) ); 1332 1333 Size aPageSize ( rPage.GetSize() ); 1334 aPageSize.Height() -= rPage.GetUppBorder() + rPage.GetLwrBorder(); 1335 aSize.Height() = rRectangle[0].GetSize().Height(); 1336 aSize.Width() = long( aPageSize.Width() * 0.7 ); 1337 rRectangle[1].SetPos( aTitleRect.TopLeft() ); 1338 rRectangle[1].SetSize( aSize ); 1339 break; 1340 } 1341 case 10: // onlytext 1342 { 1343 Size aSize( rRectangle[0].GetSize().Width(), rRectangle[1].BottomLeft().Y() - rRectangle[0].TopLeft().Y() ); 1344 rRectangle[0].SetSize( aSize ); 1345 rRectangle[0].SetPos( aTitlePos); 1346 break; 1347 } 1348 case 11: // title, 6 shapes 1349 { 1350 sal_uLong nX = long (aLayoutPos.X()); 1351 1352 aLayoutSize.Height() = long (aLayoutSize.Height() * 0.477); 1353 aLayoutSize.Width() = long (aLayoutSize.Width() * 0.322); 1354 rRectangle[1] = Rectangle (aLayoutPos, aLayoutSize); 1355 1356 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05); 1357 rRectangle[2] = Rectangle (aLayoutPos, aLayoutSize); 1358 1359 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 2 * 1.05); 1360 rRectangle[3] = Rectangle (aLayoutPos, aLayoutSize); 1361 1362 aLayoutPos.Y() = long (aLayoutPos.Y() + aLayoutSize.Height() * 1.095); 1363 rRectangle[4] = Rectangle (aLayoutPos, aLayoutSize); 1364 1365 aLayoutPos.X() = long (nX + aLayoutSize.Width() * 1.05); 1366 rRectangle[5] = Rectangle (aLayoutPos, aLayoutSize); 1367 1368 aLayoutPos.X() = nX; 1369 rRectangle[6] = Rectangle (aLayoutPos, aLayoutSize); 1370 1371 break; 1372 } 1373 1374 } 1375 } 1376 1377 1378 void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescriptor, std::vector< SdrObject* >& rShapes, bool bInit, bool bSwitchLayout ) 1379 { 1380 int i; 1381 1382 // init list of indexes for each presentation shape kind 1383 // this is used to find subsequent shapes with the same presentation shape kind 1384 int PresObjIndex[PRESOBJ_MAX]; 1385 for( i = 0; i < PRESOBJ_MAX; i++ ) PresObjIndex[i] = 1; 1386 1387 bool bMissing = false; 1388 1389 // for each entry in the layoutdescriptor, arrange a presentation shape 1390 for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++) 1391 { 1392 PresObjKind eKind = rDescriptor.meKind[i]; 1393 SdrObject* pObj = 0; 1394 while( (pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind], true )) != 0 ) 1395 { 1396 PresObjIndex[eKind]++; // on next search for eKind, find next shape with same eKind 1397 1398 if( !bSwitchLayout || !pObj->IsEmptyPresObj() ) 1399 { 1400 rShapes[i] = pObj; 1401 break; 1402 } 1403 } 1404 1405 if( !pObj ) 1406 bMissing = true; 1407 } 1408 1409 if( bMissing && bInit ) 1410 { 1411 // for each entry in the layoutdescriptor, look for an alternative shape 1412 for (i = 0; (i < MAX_PRESOBJS) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++) 1413 { 1414 if( rShapes[i] ) 1415 continue; 1416 1417 PresObjKind eKind = rDescriptor.meKind[i]; 1418 1419 SdrObject* pObj = 0; 1420 bool bFound = false; 1421 1422 const int nShapeCount = rPage.GetObjCount(); 1423 int nShapeIndex = 0; 1424 while((nShapeIndex < nShapeCount) && !bFound ) 1425 { 1426 pObj = rPage.GetObj(nShapeIndex++); 1427 1428 if( pObj->IsEmptyPresObj() ) 1429 continue; 1430 1431 if( pObj->GetObjInventor() != SdrInventor ) 1432 continue; 1433 1434 // do not reuse shapes that are already part of the layout 1435 if( std::find( rShapes.begin(), rShapes.end(), pObj ) != rShapes.end() ) 1436 continue; 1437 1438 bool bPresStyle = pObj->GetStyleSheet() && (pObj->GetStyleSheet()->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE); 1439 SdrObjKind eSdrObjKind = static_cast< SdrObjKind >( pObj->GetObjIdentifier() ); 1440 1441 switch( eKind ) 1442 { 1443 case PRESOBJ_TITLE: 1444 bFound = eSdrObjKind == OBJ_TITLETEXT; 1445 break; 1446 case PRESOBJ_TABLE: 1447 bFound = eSdrObjKind == OBJ_TABLE; 1448 break; 1449 case PRESOBJ_MEDIA: 1450 bFound = eSdrObjKind == OBJ_MEDIA; 1451 break; 1452 case PRESOBJ_OUTLINE: 1453 bFound = (eSdrObjKind == OBJ_OUTLINETEXT) || 1454 ((eSdrObjKind == OBJ_TEXT) && bPresStyle) || 1455 (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2); 1456 break; 1457 case PRESOBJ_GRAPHIC: 1458 bFound = eSdrObjKind == OBJ_GRAF; 1459 break; 1460 case PRESOBJ_OBJECT: 1461 if( eSdrObjKind == OBJ_OLE2 ) 1462 { 1463 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj ); 1464 if( pOle2 ) 1465 { 1466 if( pOle2->IsEmpty() ) 1467 bFound = true; 1468 else if( rPage.GetModel() ) 1469 { 1470 SdrModel* pSdrModel = rPage.GetModel(); 1471 ::comphelper::IEmbeddedHelper *pPersist = pSdrModel->GetPersist(); 1472 if( pPersist ) 1473 { 1474 uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer(). 1475 GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() ); 1476 1477 // TODO CL->KA: Why is this not working anymore? 1478 if( xObject.is() ) 1479 { 1480 SvGlobalName aClassId( xObject->getClassID() ); 1481 1482 const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID ); 1483 const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID ); 1484 const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID ); 1485 1486 if( aPluginClassId != aClassId && aAppletClassId != aClassId && aIFrameClassId != aClassId ) 1487 { 1488 bFound = true; 1489 } 1490 } 1491 } 1492 } 1493 } 1494 } 1495 break; 1496 case PRESOBJ_CHART: 1497 case PRESOBJ_CALC: 1498 if( eSdrObjKind == OBJ_OLE2 ) 1499 { 1500 SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj ); 1501 if( pOle2 ) 1502 { 1503 if( 1504 ((eKind == PRESOBJ_CHART) && 1505 ( pOle2->GetProgName().EqualsAscii( "StarChart" ) || pOle2->IsChart() ) ) 1506 || 1507 ((eKind == PRESOBJ_CALC) && 1508 ( pOle2->GetProgName().EqualsAscii( "StarCalc" ) || pOle2->IsCalc() ) ) ) 1509 { 1510 bFound = true; 1511 } 1512 } 1513 break; 1514 } 1515 else if( eSdrObjKind == OBJ_TABLE ) 1516 { 1517 bFound = true; 1518 } 1519 break; 1520 case PRESOBJ_PAGE: 1521 case PRESOBJ_HANDOUT: 1522 bFound = eSdrObjKind == OBJ_PAGE; 1523 break; 1524 case PRESOBJ_NOTES: 1525 case PRESOBJ_TEXT: 1526 bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT); 1527 break; 1528 default: 1529 break; 1530 } 1531 } 1532 1533 if( bFound ) 1534 rShapes[i] = pObj; 1535 } 1536 } 1537 } 1538 1539 void SdPage::SetAutoLayout(AutoLayout eLayout, sal_Bool bInit, sal_Bool bCreate ) 1540 { 1541 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement ); 1542 1543 const bool bSwitchLayout = eLayout != GetAutoLayout(); 1544 1545 ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0; 1546 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted(); 1547 1548 meAutoLayout = eLayout; 1549 1550 // if needed, creates and initializes the presentation shapes on this slides master page 1551 CreateTitleAndLayout(bInit, bCreate); 1552 1553 if((meAutoLayout == AUTOLAYOUT_NONE && maPresentationShapeList.isEmpty()) || mbMaster) 1554 { 1555 // MasterPage or no layout and no presentation shapes available, nothing to do 1556 return; 1557 } 1558 1559 Rectangle aRectangle[MAX_PRESOBJS]; 1560 const LayoutDescriptor& aDescriptor = GetLayoutDescriptor( meAutoLayout ); 1561 CalcAutoLayoutRectangles( *this, aDescriptor.mnLayout, aRectangle ); 1562 1563 std::set< SdrObject* > aUsedPresentationObjects; 1564 1565 1566 std::vector< SdrObject* > aLayoutShapes(PRESOBJ_MAX, 0); 1567 findAutoLayoutShapesImpl( *this, aDescriptor, aLayoutShapes, bInit, bSwitchLayout ); 1568 1569 int i; 1570 1571 // for each entry in the layoutdescriptor, arrange a presentation shape 1572 for (i = 0; (i < MAX_PRESOBJS) && (aDescriptor.meKind[i] != PRESOBJ_NONE); i++) 1573 { 1574 PresObjKind eKind = aDescriptor.meKind[i]; 1575 SdrObject* pObj = InsertAutoLayoutShape( aLayoutShapes[i], eKind, aDescriptor.mbVertical[i], aRectangle[i], bInit ); 1576 if( pObj ) 1577 aUsedPresentationObjects.insert(pObj); // remember that we used this empty shape 1578 } 1579 1580 // now delete all empty presentation objects that are no longer used by the new layout 1581 if( bInit ) 1582 { 1583 SdrObject* pObj = maPresentationShapeList.getNextShape(0); 1584 1585 while( pObj ) 1586 { 1587 SdrObject* pNext = maPresentationShapeList.getNextShape(pObj); 1588 if( aUsedPresentationObjects.count(pObj) == 0 ) 1589 { 1590 1591 if( pObj->IsEmptyPresObj() ) 1592 { 1593 if( bUndo ) 1594 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); 1595 1596 RemoveObject( pObj->GetOrdNum() ); 1597 1598 if( !bUndo ) 1599 SdrObject::Free( pObj ); 1600 } 1601 /* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout 1602 else 1603 { 1604 if( bUndo ) 1605 { 1606 pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) ); 1607 if( pObj->GetUserCall() ) 1608 pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) ); 1609 } 1610 maPresentationShapeList.removeShape( *pObj ); 1611 pObj->SetUserCall(0); 1612 } 1613 */ 1614 } 1615 pObj = pNext; 1616 } 1617 } 1618 } 1619 1620 /************************************************************************* 1621 |* Insert object 1622 \************************************************************************/ 1623 1624 void SdPage::NbcInsertObject(SdrObject* pObj, sal_uLong nPos, const SdrInsertReason* pReason) 1625 { 1626 FmFormPage::NbcInsertObject(pObj, nPos, pReason); 1627 1628 ((SdDrawDocument*) pModel)->InsertObject(pObj, this); 1629 1630 SdrLayerID nId = pObj->GetLayer(); 1631 if( mbMaster ) 1632 { 1633 if( nId == 0 ) 1634 pObj->NbcSetLayer( 2 ); // wrong layer. corrected to BackgroundObj layer 1635 } 1636 else 1637 { 1638 if( nId == 2 ) 1639 pObj->NbcSetLayer( 0 ); // wrong layer. corrected to layout layer 1640 } 1641 } 1642 1643 /************************************************************************* 1644 |* Delete object 1645 \************************************************************************/ 1646 1647 SdrObject* SdPage::RemoveObject(sal_uLong nObjNum) 1648 { 1649 onRemoveObject(GetObj( nObjNum )); 1650 return FmFormPage::RemoveObject(nObjNum); 1651 } 1652 1653 /************************************************************************* 1654 |* Delete object, without broadcast 1655 \************************************************************************/ 1656 1657 SdrObject* SdPage::NbcRemoveObject(sal_uLong nObjNum) 1658 { 1659 onRemoveObject(GetObj( nObjNum )); 1660 return FmFormPage::NbcRemoveObject(nObjNum); 1661 } 1662 1663 // #95876# Also overload ReplaceObject methods to realize when 1664 // objects are removed with this mechanism instead of RemoveObject 1665 SdrObject* SdPage::NbcReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum) 1666 { 1667 onRemoveObject(GetObj( nObjNum )); 1668 return FmFormPage::NbcReplaceObject(pNewObj, nObjNum); 1669 } 1670 1671 // #95876# Also overload ReplaceObject methods to realize when 1672 // objects are removed with this mechanism instead of RemoveObject 1673 SdrObject* SdPage::ReplaceObject(SdrObject* pNewObj, sal_uLong nObjNum) 1674 { 1675 onRemoveObject(GetObj( nObjNum )); 1676 return FmFormPage::ReplaceObject(pNewObj, nObjNum); 1677 } 1678 1679 // ------------------------------------------------------------------------- 1680 1681 // called after a shape is removed or replaced from this slide 1682 1683 void SdPage::onRemoveObject( SdrObject* pObject ) 1684 { 1685 if( pObject ) 1686 { 1687 RemovePresObj(pObject); 1688 1689 if( pModel ) 1690 static_cast<SdDrawDocument*>(pModel)->RemoveObject(pObject, this); 1691 1692 removeAnimations( pObject ); 1693 } 1694 } 1695 1696 /************************************************************************* 1697 |* 1698 \************************************************************************/ 1699 1700 void SdPage::SetSize(const Size& aSize) 1701 { 1702 Size aOldSize = GetSize(); 1703 1704 if (aSize != aOldSize) 1705 { 1706 FmFormPage::SetSize(aSize); 1707 1708 if (aOldSize.Height() == 10 && aOldSize.Width() == 10) 1709 { 1710 // Die Seite bekommt erstmalig eine gueltige Groesse gesetzt, 1711 // daher wird nun die Orientation initialisiert 1712 if (aSize.Width() > aSize.Height()) 1713 { 1714 meOrientation = ORIENTATION_LANDSCAPE; 1715 } 1716 else 1717 { 1718 meOrientation = ORIENTATION_PORTRAIT; 1719 } 1720 } 1721 } 1722 } 1723 1724 1725 /************************************************************************* 1726 |* 1727 \************************************************************************/ 1728 1729 void SdPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 nLwr) 1730 { 1731 if (nLft != GetLftBorder() || nUpp != GetUppBorder() || 1732 nRgt != GetRgtBorder() || nLwr != GetLwrBorder() ) 1733 { 1734 FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr); 1735 } 1736 } 1737 1738 1739 /************************************************************************* 1740 |* 1741 \************************************************************************/ 1742 1743 void SdPage::SetLftBorder(sal_Int32 nBorder) 1744 { 1745 if (nBorder != GetLftBorder() ) 1746 { 1747 FmFormPage::SetLftBorder(nBorder); 1748 } 1749 } 1750 1751 1752 /************************************************************************* 1753 |* 1754 \************************************************************************/ 1755 1756 void SdPage::SetRgtBorder(sal_Int32 nBorder) 1757 { 1758 if (nBorder != GetRgtBorder() ) 1759 { 1760 FmFormPage::SetRgtBorder(nBorder); 1761 } 1762 } 1763 1764 1765 /************************************************************************* 1766 |* 1767 \************************************************************************/ 1768 1769 void SdPage::SetUppBorder(sal_Int32 nBorder) 1770 { 1771 if (nBorder != GetUppBorder() ) 1772 { 1773 FmFormPage::SetUppBorder(nBorder); 1774 } 1775 } 1776 1777 1778 /************************************************************************* 1779 |* 1780 \************************************************************************/ 1781 1782 void SdPage::SetLwrBorder(sal_Int32 nBorder) 1783 { 1784 if (nBorder != GetLwrBorder() ) 1785 { 1786 FmFormPage::SetLwrBorder(nBorder); 1787 } 1788 } 1789 1790 /************************************************************************* 1791 |* Setzt BackgroundFullSize und ruft dann AdjustBackground auf 1792 \************************************************************************/ 1793 1794 void SdPage::SetBackgroundFullSize( sal_Bool bIn ) 1795 { 1796 if( bIn != mbBackgroundFullSize ) 1797 { 1798 mbBackgroundFullSize = bIn; 1799 } 1800 } 1801 1802 /************************************************************************* 1803 |* Alle Objekte an neue Seitengroesse anpassen 1804 |* 1805 |* bScaleAllObj: Alle Objekte werden in die neue Flaeche innerhalb der 1806 |* Seitenraender skaliert. Dabei werden die Position, Groesse und bei 1807 |* Praesentationsobjekten auf der MasterPage auch die Schrifthoehe der 1808 |* Praesentationsvorlagen skaliert. 1809 \************************************************************************/ 1810 1811 void SdPage::ScaleObjects(const Size& rNewPageSize, const Rectangle& rNewBorderRect, sal_Bool bScaleAllObj) 1812 { 1813 sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement ); 1814 1815 mbScaleObjects = bScaleAllObj; 1816 SdrObject* pObj = NULL; 1817 Point aRefPnt(0, 0); 1818 Size aNewPageSize(rNewPageSize); 1819 sal_Int32 nLeft = rNewBorderRect.Left(); 1820 sal_Int32 nRight = rNewBorderRect.Right(); 1821 sal_Int32 nUpper = rNewBorderRect.Top(); 1822 sal_Int32 nLower = rNewBorderRect.Bottom(); 1823 1824 // Negative Werte stehen fuer nicht zu aendernde Werte 1825 // -> aktuelle Werte verwenden 1826 if (aNewPageSize.Width() < 0) 1827 { 1828 aNewPageSize.Width() = GetWdt(); 1829 } 1830 if (aNewPageSize.Height() < 0) 1831 { 1832 aNewPageSize.Height() = GetHgt(); 1833 } 1834 if (nLeft < 0) 1835 { 1836 nLeft = GetLftBorder(); 1837 } 1838 if (nRight < 0) 1839 { 1840 nRight = GetRgtBorder(); 1841 } 1842 if (nUpper < 0) 1843 { 1844 nUpper = GetUppBorder(); 1845 } 1846 if (nLower < 0) 1847 { 1848 nLower = GetLwrBorder(); 1849 } 1850 1851 Point aBackgroundPos(nLeft, nUpper); 1852 Size aBackgroundSize(aNewPageSize); 1853 Rectangle aBorderRect (aBackgroundPos, aBackgroundSize); 1854 1855 if (mbScaleObjects) 1856 { 1857 aBackgroundSize.Width() -= nLeft + nRight; 1858 aBackgroundSize.Height() -= nUpper + nLower; 1859 aBorderRect.SetSize(aBackgroundSize); 1860 aNewPageSize = aBackgroundSize; 1861 } 1862 1863 long nOldWidth = GetWdt() - GetLftBorder() - GetRgtBorder(); 1864 long nOldHeight = GetHgt() - GetUppBorder() - GetLwrBorder(); 1865 1866 Fraction aFractX = Fraction(aNewPageSize.Width(), nOldWidth); 1867 Fraction aFractY = Fraction(aNewPageSize.Height(), nOldHeight); 1868 1869 sal_uLong nObjCnt = (mbScaleObjects ? GetObjCount() : 0); 1870 1871 for (sal_uLong nObj = 0; nObj < nObjCnt; nObj++) 1872 { 1873 sal_Bool bIsPresObjOnMaster = sal_False; 1874 1875 // Alle Objekte 1876 pObj = GetObj(nObj); 1877 1878 if (mbMaster && IsPresObj(pObj)) 1879 { 1880 // Es ist ein Praesentationsobjekt auf der MasterPage 1881 bIsPresObjOnMaster = sal_True; 1882 } 1883 1884 if (pObj) 1885 { 1886 // #88084# remember aTopLeft as original TopLeft 1887 Point aTopLeft(pObj->GetCurrentBoundRect().TopLeft()); 1888 1889 if (!pObj->IsEdgeObj()) 1890 { 1891 /************************************************************** 1892 * Objekt skalieren 1893 **************************************************************/ 1894 if (mbScaleObjects) 1895 { 1896 // #88084# use aTopLeft as original TopLeft 1897 aRefPnt = aTopLeft; 1898 } 1899 1900 pObj->Resize(aRefPnt, aFractX, aFractY); 1901 1902 if (mbScaleObjects) 1903 { 1904 SdrObjKind eObjKind = (SdrObjKind) pObj->GetObjIdentifier(); 1905 1906 if (bIsPresObjOnMaster) 1907 { 1908 /********************************************************** 1909 * Praesentationsvorlage: Texthoehe anpassen 1910 **********************************************************/ 1911 sal_uInt16 nIndexTitle = 0; 1912 sal_uInt16 nIndexOutline = 0; 1913 sal_uInt16 nIndexNotes = 0; 1914 1915 if (pObj == GetPresObj(PRESOBJ_TITLE, nIndexTitle)) 1916 { 1917 SfxStyleSheet* pTitleSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE); 1918 1919 if (pTitleSheet) 1920 { 1921 SfxItemSet& rSet = pTitleSheet->GetItemSet(); 1922 1923 SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT); 1924 sal_uLong nFontHeight = rOldHgt.GetHeight(); 1925 nFontHeight = long(nFontHeight * (double) aFractY); 1926 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT)); 1927 1928 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) ) 1929 { 1930 rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CJK); 1931 nFontHeight = rOldHgt.GetHeight(); 1932 nFontHeight = long(nFontHeight * (double) aFractY); 1933 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK)); 1934 } 1935 1936 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) ) 1937 { 1938 rOldHgt = (SvxFontHeightItem&) rSet.Get(EE_CHAR_FONTHEIGHT_CTL); 1939 nFontHeight = rOldHgt.GetHeight(); 1940 nFontHeight = long(nFontHeight * (double) aFractY); 1941 rSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL)); 1942 } 1943 1944 pTitleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED)); 1945 } 1946 } 1947 else if (pObj == GetPresObj(PRESOBJ_OUTLINE, nIndexOutline)) 1948 { 1949 String aName(GetLayoutName()); 1950 aName += sal_Unicode( ' ' ); 1951 1952 for (sal_uInt16 i=1; i<=9; i++) 1953 { 1954 String sLayoutName(aName); 1955 sLayoutName += String::CreateFromInt32( (sal_Int32)i ); 1956 SfxStyleSheet* pOutlineSheet = (SfxStyleSheet*)((SdDrawDocument*) pModel)->GetStyleSheetPool()->Find(sLayoutName, SD_STYLE_FAMILY_MASTERPAGE); 1957 1958 if (pOutlineSheet) 1959 { 1960 // Neue Fonthoehe berechnen 1961 SfxItemSet aTempSet(pOutlineSheet->GetItemSet()); 1962 1963 SvxFontHeightItem& rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT); 1964 sal_uLong nFontHeight = rOldHgt.GetHeight(); 1965 nFontHeight = long(nFontHeight * (double) aFractY); 1966 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT)); 1967 1968 if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CJK ) ) 1969 { 1970 rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CJK); 1971 nFontHeight = rOldHgt.GetHeight(); 1972 nFontHeight = long(nFontHeight * (double) aFractY); 1973 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK)); 1974 } 1975 1976 if( SFX_ITEM_AVAILABLE == aTempSet.GetItemState( EE_CHAR_FONTHEIGHT_CTL ) ) 1977 { 1978 rOldHgt = (SvxFontHeightItem&) aTempSet.Get(EE_CHAR_FONTHEIGHT_CTL); 1979 nFontHeight = rOldHgt.GetHeight(); 1980 nFontHeight = long(nFontHeight * (double) aFractY); 1981 aTempSet.Put(SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL)); 1982 } 1983 1984 // Bullet anpassen 1985 ((SdStyleSheet*) pOutlineSheet)->AdjustToFontHeight(aTempSet, sal_False); 1986 1987 // Sonderbehandlung: die INVALIDS auf NULL-Pointer 1988 // zuruecksetzen (sonst landen INVALIDs oder 1989 // Pointer auf die DefaultItems in der Vorlage; 1990 // beides wuerde die Attribut-Vererbung unterbinden) 1991 aTempSet.ClearInvalidItems(); 1992 1993 // Sonderbehandlung: nur die gueltigen Anteile des 1994 // BulletItems 1995 if (aTempSet.GetItemState(EE_PARA_BULLET) == SFX_ITEM_AVAILABLE) 1996 { 1997 SvxBulletItem aOldBulItem((SvxBulletItem&) pOutlineSheet->GetItemSet().Get(EE_PARA_BULLET)); 1998 SvxBulletItem& rNewBulItem = (SvxBulletItem&) aTempSet.Get(EE_PARA_BULLET); 1999 aOldBulItem.CopyValidProperties(rNewBulItem); 2000 aTempSet.Put(aOldBulItem); 2001 } 2002 2003 pOutlineSheet->GetItemSet().Put(aTempSet); 2004 pOutlineSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED)); 2005 } 2006 } 2007 } 2008 else if (pObj == GetPresObj(PRESOBJ_NOTES, nIndexNotes)) 2009 { 2010 SfxStyleSheet* pNotesSheet = GetStyleSheetForPresObj(PRESOBJ_NOTES); 2011 2012 if (pNotesSheet) 2013 { 2014 sal_uLong nHeight = pObj->GetLogicRect().GetSize().Height(); 2015 sal_uLong nFontHeight = (sal_uLong) (nHeight * 0.0741); 2016 SfxItemSet& rSet = pNotesSheet->GetItemSet(); 2017 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT )); 2018 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CJK )); 2019 rSet.Put( SvxFontHeightItem(nFontHeight, 100, EE_CHAR_FONTHEIGHT_CTL )); 2020 pNotesSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED)); 2021 } 2022 } 2023 } 2024 else if ( eObjKind != OBJ_TITLETEXT && 2025 eObjKind != OBJ_OUTLINETEXT && 2026 pObj->ISA(SdrTextObj) && 2027 pObj->GetOutlinerParaObject() ) 2028 { 2029 /****************************************************** 2030 * Normales Textobjekt: Texthoehe anpassen 2031 ******************************************************/ 2032 sal_uLong nScriptType = pObj->GetOutlinerParaObject()->GetTextObject().GetScriptType(); 2033 sal_uInt16 nWhich = EE_CHAR_FONTHEIGHT; 2034 if ( nScriptType == SCRIPTTYPE_ASIAN ) 2035 nWhich = EE_CHAR_FONTHEIGHT_CJK; 2036 else if ( nScriptType == SCRIPTTYPE_COMPLEX ) 2037 nWhich = EE_CHAR_FONTHEIGHT_CTL; 2038 2039 // #88084# use more modern method to scale the text height 2040 sal_uInt32 nFontHeight = ((SvxFontHeightItem&)pObj->GetMergedItem(nWhich)).GetHeight(); 2041 sal_uInt32 nNewFontHeight = sal_uInt32((double)nFontHeight * (double)aFractY); 2042 2043 pObj->SetMergedItem(SvxFontHeightItem(nNewFontHeight, 100, nWhich)); 2044 } 2045 } 2046 } 2047 2048 if (mbScaleObjects && !pObj->IsEdgeObj()) 2049 { 2050 /************************************************************** 2051 * Objektposition skalieren 2052 **************************************************************/ 2053 Point aNewPos; 2054 2055 // #76447# corrected scaling; only distances may be scaled 2056 // #88084# use aTopLeft as original TopLeft 2057 aNewPos.X() = long((aTopLeft.X() - GetLftBorder()) * (double)aFractX) + nLeft; 2058 aNewPos.Y() = long((aTopLeft.Y() - GetUppBorder()) * (double)aFractY) + nUpper; 2059 2060 Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - aTopLeft.Y()); 2061 2062 if (aVec.Height() != 0 || aVec.Width() != 0) 2063 { 2064 pObj->NbcMove(aVec); 2065 } 2066 2067 pObj->SetChanged(); 2068 pObj->BroadcastObjectChange(); 2069 } 2070 } 2071 } 2072 } 2073 2074 SdrObject* convertPresentationObjectImpl( SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, Rectangle aRect ) 2075 { 2076 SdDrawDocument* pModel = static_cast< SdDrawDocument* >( rPage.GetModel() ); 2077 DBG_ASSERT( pModel, "sd::convertPresentationObjectImpl(), no model on page!" ); 2078 if( !pModel || !pSourceObj ) 2079 return pSourceObj; 2080 2081 ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0; 2082 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted(); 2083 2084 SdrObject* pNewObj = pSourceObj; 2085 if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() == OBJ_TEXT) ) 2086 { 2087 pNewObj = rPage.CreatePresObj(PRESOBJ_OUTLINE, bVertical, aRect); 2088 2089 // Text des Untertitels in das PRESOBJ_OUTLINE setzen 2090 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject(); 2091 2092 if(pOutlParaObj) 2093 { 2094 // Text umsetzen 2095 ::sd::Outliner* pOutl = pModel->GetInternalOutliner( sal_True ); 2096 pOutl->Clear(); 2097 pOutl->SetText( *pOutlParaObj ); 2098 pOutlParaObj = pOutl->CreateParaObject(); 2099 pNewObj->SetOutlinerParaObject( pOutlParaObj ); 2100 pOutl->Clear(); 2101 pNewObj->SetEmptyPresObj(sal_False); 2102 2103 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++) 2104 { 2105 // Neue Vorlage zuweisen 2106 String aName(rPage.GetLayoutName()); 2107 aName += sal_Unicode( ' ' ); 2108 aName += String::CreateFromInt32( nLevel ); 2109 SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( pModel->GetStyleSheetPool()->Find(aName, SD_STYLE_FAMILY_MASTERPAGE) ); 2110 2111 if (pSheet) 2112 { 2113 if (nLevel == 1) 2114 { 2115 SfxStyleSheet* pSubtitleSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT); 2116 2117 if (pSubtitleSheet) 2118 pOutlParaObj->ChangeStyleSheetName(SD_STYLE_FAMILY_MASTERPAGE, pSubtitleSheet->GetName(), pSheet->GetName()); 2119 } 2120 2121 pNewObj->StartListening(*pSheet); 2122 } 2123 } 2124 2125 // LRSpace-Item loeschen 2126 SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE ); 2127 2128 aSet.Put(pNewObj->GetMergedItemSet()); 2129 2130 aSet.ClearItem(EE_PARA_LRSPACE); 2131 2132 pNewObj->SetMergedItemSet(aSet); 2133 2134 if( bUndo ) 2135 pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) ); 2136 2137 // Remove outline shape from page 2138 rPage.RemoveObject( pSourceObj->GetOrdNum() ); 2139 2140 if( !bUndo ) 2141 SdrObject::Free( pSourceObj ); 2142 } 2143 } 2144 else if((eObjKind == PRESOBJ_TEXT) && (pSourceObj->GetObjIdentifier() == OBJ_OUTLINETEXT) ) 2145 { 2146 // is there an outline shape we can use to replace empty subtitle shape? 2147 pNewObj = rPage.CreatePresObj(PRESOBJ_TEXT, bVertical, aRect); 2148 2149 // Text des Gliederungsobjekts in das PRESOBJ_TITLE setzen 2150 OutlinerParaObject* pOutlParaObj = pSourceObj->GetOutlinerParaObject(); 2151 2152 if(pOutlParaObj) 2153 { 2154 // Text umsetzen 2155 ::sd::Outliner* pOutl = pModel->GetInternalOutliner(); 2156 pOutl->Clear(); 2157 pOutl->SetText( *pOutlParaObj ); 2158 pOutlParaObj = pOutl->CreateParaObject(); 2159 pNewObj->SetOutlinerParaObject( pOutlParaObj ); 2160 pOutl->Clear(); 2161 pNewObj->SetEmptyPresObj(sal_False); 2162 2163 // Linken Einzug zuruecksetzen 2164 SfxItemSet aSet(pModel->GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE ); 2165 2166 aSet.Put(pNewObj->GetMergedItemSet()); 2167 2168 const SvxLRSpaceItem& rLRItem = (const SvxLRSpaceItem&) aSet.Get(EE_PARA_LRSPACE); 2169 SvxLRSpaceItem aNewLRItem(rLRItem); 2170 aNewLRItem.SetTxtLeft(0); 2171 aSet.Put(aNewLRItem); 2172 2173 pNewObj->SetMergedItemSet(aSet); 2174 2175 SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj(PRESOBJ_TEXT); 2176 if (pSheet) 2177 pNewObj->SetStyleSheet(pSheet, sal_True); 2178 2179 // Remove subtitle shape from page 2180 if( bUndo ) 2181 pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj)); 2182 2183 rPage.RemoveObject( pSourceObj->GetOrdNum() ); 2184 2185 if( !bUndo ) 2186 SdrObject::Free( pSourceObj ); 2187 } 2188 } 2189 else if((eObjKind == PRESOBJ_OUTLINE) && (pSourceObj->GetObjIdentifier() != OBJ_OUTLINETEXT) ) 2190 { 2191 switch( pSourceObj->GetObjIdentifier() ) 2192 { 2193 case OBJ_TABLE: eObjKind = PRESOBJ_TABLE; break; 2194 case OBJ_MEDIA: eObjKind = PRESOBJ_MEDIA; break; 2195 case OBJ_GRAF: eObjKind = PRESOBJ_GRAPHIC; break; 2196 case OBJ_OLE2: eObjKind = PRESOBJ_OBJECT; break; 2197 } 2198 } 2199 2200 return pNewObj; 2201 } 2202 2203 /** reuses or creates a presentation shape for an auto layout that fits the given parameter 2204 2205 @param eObjKind 2206 The kind of presentation shape we like to have 2207 @param nIndex 2208 If > 1 we skip the first nIndex-1 shapes with the presentation shape kind eObjKind while 2209 looking for an existing presentation shape 2210 @param bVertical 2211 If true, the shape is created vertical if bInit is true 2212 @param aRect 2213 The rectangle that should be used to transform the shape 2214 @param bInit 2215 If true the shape is created if not found 2216 @returns 2217 A presentation shape that was either found or created with the given parameters 2218 */ 2219 SdrObject* SdPage::InsertAutoLayoutShape( SdrObject* pObj, PresObjKind eObjKind, bool bVertical, Rectangle aRect, bool bInit ) 2220 { 2221 ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : 0; 2222 const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted(); 2223 2224 if (!pObj && bInit) 2225 { 2226 pObj = CreatePresObj(eObjKind, bVertical, aRect); 2227 } 2228 else if ( pObj && (pObj->GetUserCall() || bInit) ) 2229 { 2230 // convert object if shape type does not match kind (f.e. converting outline text to subtitle text) 2231 if( bInit ) 2232 pObj = convertPresentationObjectImpl( *this, pObj, eObjKind, bVertical, aRect ); 2233 2234 if( bUndo ) 2235 { 2236 pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) ); 2237 pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoAttrObject( *pObj, sal_True, sal_True ) ); 2238 pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) ); 2239 } 2240 2241 // if ( pObj->ISA(SdrGrafObj) && !pObj->IsEmptyPresObj() ) 2242 ( /*(SdrGrafObj*)*/ pObj)->AdjustToMaxRect( aRect ); 2243 // else 2244 // SetLogicRect( pObj, aRect ); 2245 2246 pObj->SetUserCall(this); 2247 2248 SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj); 2249 if( pTextObject ) 2250 { 2251 if( pTextObject->IsVerticalWriting() != (bVertical ? sal_True : sal_False) ) 2252 { 2253 pTextObject->SetVerticalWriting( bVertical ); 2254 2255 // #94826# here make sure the correct anchoring is used when the object 2256 // is re-used but orientation is changed 2257 if(PRESOBJ_OUTLINE == eObjKind) 2258 pTextObject->SetMergedItem(SdrTextHorzAdjustItem( bVertical ? SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_BLOCK )); 2259 } 2260 2261 if( !mbMaster && (pTextObject->GetObjIdentifier() != OBJ_TABLE) ) 2262 { 2263 if ( pTextObject->IsAutoGrowHeight() ) 2264 { 2265 // switch off AutoGrowHeight, set new MinHeight 2266 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() ); 2267 SdrTextMinFrameHeightItem aMinHeight( aRect.GetSize().Height() ); 2268 aTempAttr.Put( aMinHeight ); 2269 aTempAttr.Put( SdrTextAutoGrowHeightItem(sal_False) ); 2270 pTextObject->SetMergedItemSet(aTempAttr); 2271 pTextObject->SetLogicRect(aRect); 2272 2273 // switch on AutoGrowHeight 2274 SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() ); 2275 aAttr.Put( SdrTextAutoGrowHeightItem(sal_True) ); 2276 2277 pTextObject->SetMergedItemSet(aAttr); 2278 } 2279 2280 if ( pTextObject->IsAutoGrowWidth() ) 2281 { 2282 // switch off AutoGrowWidth , set new MinWidth 2283 SfxItemSet aTempAttr( ((SdDrawDocument*) pModel)->GetPool() ); 2284 SdrTextMinFrameWidthItem aMinWidth( aRect.GetSize().Width() ); 2285 aTempAttr.Put( aMinWidth ); 2286 aTempAttr.Put( SdrTextAutoGrowWidthItem(sal_False) ); 2287 pTextObject->SetMergedItemSet(aTempAttr); 2288 pTextObject->SetLogicRect(aRect); 2289 2290 // switch on AutoGrowWidth 2291 SfxItemSet aAttr( ((SdDrawDocument*) pModel)->GetPool() ); 2292 aAttr.Put( SdrTextAutoGrowWidthItem(sal_True) ); 2293 pTextObject->SetMergedItemSet(aAttr); 2294 } 2295 } 2296 } 2297 } 2298 2299 if(pObj && bInit ) 2300 { 2301 if( !IsPresObj( pObj ) ) 2302 { 2303 if( bUndo ) 2304 pUndoManager->AddUndoAction( new UndoObjectPresentationKind( *pObj ) ); 2305 2306 InsertPresObj( pObj, eObjKind ); 2307 } 2308 2309 // make adjustments for vertical title and outline shapes 2310 if( bVertical && (( eObjKind == PRESOBJ_TITLE) || (eObjKind == PRESOBJ_OUTLINE))) 2311 { 2312 SfxItemSet aNewSet(pObj->GetMergedItemSet()); 2313 aNewSet.Put( SdrTextAutoGrowWidthItem(sal_True) ); 2314 aNewSet.Put( SdrTextAutoGrowHeightItem(sal_False) ); 2315 if( eObjKind == PRESOBJ_OUTLINE ) 2316 { 2317 aNewSet.Put( SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP) ); 2318 aNewSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) ); 2319 } 2320 pObj->SetMergedItemSet(aNewSet); 2321 } 2322 } 2323 2324 if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || !pObj->ISA(SdrGrafObj) ) ) 2325 pObj->AdjustToMaxRect( aRect ); 2326 2327 return pObj; 2328 } 2329 2330 2331 /************************************************************************* 2332 |* Liefert den PresObjKind eines Objektes zurueck 2333 \************************************************************************/ 2334 2335 PresObjKind SdPage::GetPresObjKind(SdrObject* pObj) const 2336 { 2337 PresObjKind eKind = PRESOBJ_NONE; 2338 if( (pObj != 0) && (maPresentationShapeList.hasShape(*pObj)) ) 2339 { 2340 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj); 2341 if( pInfo ) 2342 eKind = pInfo->mePresObjKind; 2343 } 2344 2345 return eKind; 2346 } 2347 2348 bool SdPage::IsPresObj(const SdrObject* pObj) 2349 { 2350 return pObj && maPresentationShapeList.hasShape( const_cast<SdrObject&>(*pObj) ); 2351 } 2352 2353 void SdPage::RemovePresObj(const SdrObject* pObj) 2354 { 2355 if( pObj && maPresentationShapeList.hasShape(const_cast<SdrObject&>(*pObj)) ) 2356 { 2357 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(const_cast<SdrObject&>(*pObj)); 2358 if( pInfo ) 2359 pInfo->mePresObjKind = PRESOBJ_NONE; 2360 maPresentationShapeList.removeShape(const_cast<SdrObject&>(*pObj)); 2361 } 2362 } 2363 2364 void SdPage::InsertPresObj(SdrObject* pObj, PresObjKind eKind ) 2365 { 2366 DBG_ASSERT( pObj, "sd::SdPage::InsertPresObj(), invalid presentation object inserted!" ); 2367 DBG_ASSERT( !IsPresObj(pObj), "sd::SdPage::InsertPresObj(), presentation object inserted twice!" ); 2368 if( pObj ) 2369 { 2370 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj, true); 2371 if( pInfo ) 2372 pInfo->mePresObjKind = eKind; 2373 maPresentationShapeList.addShape(*pObj); 2374 } 2375 } 2376 2377 /************************************************************************* 2378 |* Text des Objektes setzen 2379 \************************************************************************/ 2380 2381 void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eObjKind, const String& rString ) 2382 { 2383 if ( pObj ) 2384 { 2385 DBG_ASSERT( pObj->ISA(SdrTextObj), "SetObjText: Kein SdrTextObj!" ); 2386 ::Outliner* pOutl = pOutliner; 2387 2388 if (!pOutliner) 2389 { 2390 SfxItemPool* pPool = ((SdDrawDocument*) GetModel())->GetDrawOutliner().GetEmptyItemSet().GetPool(); 2391 pOutl = new ::Outliner( pPool, OUTLINERMODE_OUTLINEOBJECT ); 2392 pOutl->SetRefDevice( SD_MOD()->GetRefDevice( *( (SdDrawDocument*) GetModel() )->GetDocSh() ) ); 2393 pOutl->SetEditTextObjectPool(pPool); 2394 pOutl->SetStyleSheetPool((SfxStyleSheetPool*)GetModel()->GetStyleSheetPool()); 2395 pOutl->EnableUndo(sal_False); 2396 pOutl->SetUpdateMode( sal_False ); 2397 } 2398 2399 sal_uInt16 nOutlMode = pOutl->GetMode(); 2400 Size aPaperSize = pOutl->GetPaperSize(); 2401 sal_Bool bUpdateMode = pOutl->GetUpdateMode(); 2402 pOutl->SetUpdateMode(sal_False); 2403 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() ); 2404 2405 // #95114# Always set the object's StyleSheet at the Outliner to 2406 // use the current objects StyleSheet. Thus it's the same as in 2407 // SetText(...). 2408 // #95114# Moved this implementation from where SetObjText(...) was called 2409 // to inside this method to work even when outliner is fetched here. 2410 pOutl->SetStyleSheet(0, pObj->GetStyleSheet()); 2411 2412 String aString; 2413 2414 switch( eObjKind ) 2415 { 2416 case PRESOBJ_OUTLINE: 2417 { 2418 pOutl->Init( OUTLINERMODE_OUTLINEOBJECT ); 2419 2420 aString += sal_Unicode( '\t' ); 2421 aString += rString; 2422 2423 if (mbMaster) 2424 { 2425 pOutl->SetStyleSheet( 0, GetStyleSheetForPresObj(eObjKind) ); 2426 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t" )); 2427 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER2 ) ); 2428 2429 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t" )); 2430 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER3 ) ); 2431 2432 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t" )); 2433 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER4 ) ); 2434 2435 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t" )); 2436 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER5 ) ); 2437 2438 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t" )); 2439 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER6 ) ); 2440 2441 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t" )); 2442 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER7 ) ); 2443 2444 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t\t" )); 2445 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER8 ) ); 2446 2447 aString += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "\n\t\t\t\t\t\t\t\t\t" )); 2448 aString += String ( SdResId( STR_PRESOBJ_MPOUTLLAYER9 ) ); 2449 } 2450 } 2451 break; 2452 2453 case PRESOBJ_TITLE: 2454 { 2455 pOutl->Init( OUTLINERMODE_TITLEOBJECT ); 2456 aString += rString; 2457 } 2458 break; 2459 2460 default: 2461 { 2462 pOutl->Init( OUTLINERMODE_TEXTOBJECT ); 2463 aString += rString; 2464 2465 // check if we need to add a text field 2466 SvxFieldData* pData = NULL; 2467 2468 switch( eObjKind ) 2469 { 2470 case PRESOBJ_HEADER: 2471 pData = new SvxHeaderField(); 2472 break; 2473 case PRESOBJ_FOOTER: 2474 pData = new SvxFooterField(); 2475 break; 2476 case PRESOBJ_SLIDENUMBER: 2477 pData = new SvxPageField(); 2478 break; 2479 case PRESOBJ_DATETIME: 2480 pData = new SvxDateTimeField(); 2481 break; 2482 default: 2483 break; 2484 } 2485 2486 if( pData ) 2487 { 2488 ESelection e; 2489 SvxFieldItem aField( *pData, EE_FEATURE_FIELD ); 2490 pOutl->QuickInsertField(aField,e); 2491 delete pData; 2492 } 2493 } 2494 break; 2495 } 2496 2497 pOutl->SetPaperSize( pObj->GetLogicRect().GetSize() ); 2498 2499 if( aString.Len() ) 2500 pOutl->SetText( aString, pOutl->GetParagraph( 0 ) ); 2501 2502 ( (SdrTextObj*) pObj)->SetOutlinerParaObject( pOutl->CreateParaObject() ); 2503 2504 if (!pOutliner) 2505 { 2506 delete pOutl; 2507 pOutl = NULL; 2508 } 2509 else 2510 { 2511 // Outliner restaurieren 2512 pOutl->Init( nOutlMode ); 2513 pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() ); 2514 pOutl->SetUpdateMode( bUpdateMode ); 2515 pOutl->SetPaperSize( aPaperSize ); 2516 } 2517 } 2518 } 2519 2520 /************************************************************************* 2521 |* Link & Daten von einem VControl empfangen 2522 \************************************************************************/ 2523 2524 void SdPage::SetLinkData(const String&, const String& ) 2525 { 2526 } 2527 2528 /************************************************************************* 2529 |* Layoutname setzen 2530 \************************************************************************/ 2531 void SdPage::SetLayoutName(String aName) 2532 { 2533 maLayoutName = aName; 2534 2535 if( mbMaster ) 2536 { 2537 String aSep( RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR) ); 2538 sal_uInt16 nPos = maLayoutName.Search( aSep ); 2539 if ( nPos != STRING_NOTFOUND ) 2540 { 2541 FmFormPage::SetName(maLayoutName.Copy(0, nPos)); 2542 } 2543 } 2544 } 2545 2546 2547 /************************************************************************* 2548 |* Seitenname zurueckgeben und ggf. generieren 2549 \************************************************************************/ 2550 2551 const String& SdPage::GetName() const 2552 { 2553 String aCreatedPageName( maCreatedPageName ); 2554 if (GetRealName().Len() == 0) 2555 { 2556 if ((mePageKind == PK_STANDARD || mePageKind == PK_NOTES) && !mbMaster) 2557 { 2558 // default name for handout pages 2559 sal_uInt16 nNum = (GetPageNum() + 1) / 2; 2560 2561 aCreatedPageName = String(SdResId(STR_PAGE)); 2562 aCreatedPageName += sal_Unicode( ' ' ); 2563 if( GetModel()->GetPageNumType() == SVX_NUMBER_NONE ) 2564 { 2565 // if the document has number none as a formatting 2566 // for page numbers we still default to Arabic numbering 2567 // to keep the default page names unique 2568 aCreatedPageName += String::CreateFromInt32( (sal_Int32)nNum ); 2569 } 2570 else 2571 { 2572 aCreatedPageName += ((SdDrawDocument*) GetModel())->CreatePageNumValue(nNum); 2573 } 2574 } 2575 else 2576 { 2577 /****************************************************************** 2578 * Defaultname fuer Handzettelseiten 2579 ******************************************************************/ 2580 aCreatedPageName = String(SdResId(STR_LAYOUT_DEFAULT_NAME)); 2581 } 2582 } 2583 else 2584 { 2585 aCreatedPageName = GetRealName(); 2586 } 2587 2588 if (mePageKind == PK_NOTES) 2589 { 2590 aCreatedPageName += sal_Unicode( ' ' ); 2591 aCreatedPageName += String(SdResId(STR_NOTES)); 2592 } 2593 else if (mePageKind == PK_HANDOUT && mbMaster) 2594 { 2595 aCreatedPageName += String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( " (" )); 2596 aCreatedPageName += String(SdResId(STR_HANDOUT)); 2597 aCreatedPageName += sal_Unicode( ')' ); 2598 } 2599 2600 const_cast< SdPage* >(this)->maCreatedPageName = aCreatedPageName; 2601 return maCreatedPageName; 2602 } 2603 2604 /************************************************************************* 2605 |* 2606 \************************************************************************/ 2607 2608 void SdPage::SetOrientation( Orientation eOrient) 2609 { 2610 meOrientation = eOrient; 2611 } 2612 2613 /************************************************************************* 2614 |* 2615 \************************************************************************/ 2616 2617 Orientation SdPage::GetOrientation() const 2618 { 2619 return meOrientation; 2620 } 2621 2622 /************************************************************************* 2623 |* Liefert den Default-Text eines PresObjektes zurueck 2624 \************************************************************************/ 2625 2626 String SdPage::GetPresObjText(PresObjKind eObjKind) const 2627 { 2628 String aString; 2629 2630 if (eObjKind == PRESOBJ_TITLE) 2631 { 2632 if (mbMaster) 2633 { 2634 if (mePageKind != PK_NOTES) 2635 { 2636 aString = String ( SdResId( STR_PRESOBJ_MPTITLE ) ); 2637 } 2638 else 2639 { 2640 aString = String ( SdResId( STR_PRESOBJ_MPNOTESTITLE ) ); 2641 } 2642 } 2643 else 2644 { 2645 aString = String ( SdResId( STR_PRESOBJ_TITLE ) ); 2646 } 2647 } 2648 else if (eObjKind == PRESOBJ_OUTLINE) 2649 { 2650 if (mbMaster) 2651 { 2652 aString = String ( SdResId( STR_PRESOBJ_MPOUTLINE ) ); 2653 } 2654 else 2655 { 2656 aString = String ( SdResId( STR_PRESOBJ_OUTLINE ) ); 2657 } 2658 } 2659 else if (eObjKind == PRESOBJ_NOTES) 2660 { 2661 if (mbMaster) 2662 { 2663 aString = String ( SdResId( STR_PRESOBJ_MPNOTESTEXT ) ); 2664 } 2665 else 2666 { 2667 aString = String ( SdResId( STR_PRESOBJ_NOTESTEXT ) ); 2668 } 2669 } 2670 else if (eObjKind == PRESOBJ_TEXT) 2671 { 2672 aString = String ( SdResId( STR_PRESOBJ_TEXT ) ); 2673 } 2674 else if (eObjKind == PRESOBJ_GRAPHIC) 2675 { 2676 aString = String ( SdResId( STR_PRESOBJ_GRAPHIC ) ); 2677 } 2678 else if (eObjKind == PRESOBJ_OBJECT) 2679 { 2680 aString = String ( SdResId( STR_PRESOBJ_OBJECT ) ); 2681 } 2682 else if (eObjKind == PRESOBJ_CHART) 2683 { 2684 aString = String ( SdResId( STR_PRESOBJ_CHART ) ); 2685 } 2686 else if (eObjKind == PRESOBJ_ORGCHART) 2687 { 2688 aString = String ( SdResId( STR_PRESOBJ_ORGCHART ) ); 2689 } 2690 else if (eObjKind == PRESOBJ_CALC) 2691 { 2692 aString = String ( SdResId( STR_PRESOBJ_TABLE ) ); 2693 } 2694 2695 return(aString); 2696 } 2697 2698 extern uno::Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage ); 2699 2700 uno::Reference< uno::XInterface > SdPage::createUnoPage() 2701 { 2702 return createUnoPageImpl( this ); 2703 } 2704 2705 /** returns the SdPage implementation for the given XDrawPage or 0 if not available */ 2706 SdPage* SdPage::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage ) 2707 { 2708 try 2709 { 2710 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( xPage, ::com::sun::star::uno::UNO_QUERY ); 2711 if( xUnoTunnel.is() ) 2712 { 2713 SvxDrawPage* pUnoPage = reinterpret_cast<SvxDrawPage*>(sal::static_int_cast<sal_uIntPtr>(xUnoTunnel->getSomething( SvxDrawPage::getUnoTunnelId()) ) ); 2714 if( pUnoPage ) 2715 return static_cast< SdPage* >( pUnoPage->GetSdrPage() ); 2716 } 2717 } 2718 catch( ::com::sun::star::uno::Exception& e ) 2719 { 2720 (void)e; 2721 DBG_ERROR("sd::SdPage::getImplementation(), exception cathced!" ); 2722 } 2723 2724 return 0; 2725 } 2726 2727 void SdPage::SetName (const String& rName) 2728 { 2729 String aOldName = GetName(); 2730 FmFormPage::SetName (rName); 2731 static_cast<SdDrawDocument*>(pModel)->UpdatePageRelativeURLs(aOldName, rName); 2732 ActionChanged(); 2733 } 2734 2735 const HeaderFooterSettings& SdPage::getHeaderFooterSettings() const 2736 { 2737 if( mePageKind == PK_HANDOUT && !mbMaster ) 2738 { 2739 return (((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings); 2740 } 2741 else 2742 { 2743 return maHeaderFooterSettings; 2744 } 2745 } 2746 2747 void SdPage::setHeaderFooterSettings( const sd::HeaderFooterSettings& rNewSettings ) 2748 { 2749 if( mePageKind == PK_HANDOUT && !mbMaster ) 2750 { 2751 (((SdPage&)TRG_GetMasterPage()).maHeaderFooterSettings) = rNewSettings; 2752 } 2753 else 2754 { 2755 maHeaderFooterSettings = rNewSettings; 2756 } 2757 2758 SetChanged(); 2759 2760 if(TRG_HasMasterPage()) 2761 { 2762 TRG_GetMasterPageDescriptorViewContact().ActionChanged(); 2763 2764 // #119056# For HeaderFooterSettings SdrObjects are used, but the properties 2765 // used are not part of their model data, but kept in SD. This data is applied 2766 // using a 'backdoor' on primitive creation. Thus, the normal mechanism to detect 2767 // object changes does not work here. It is necessary to trigger updates here 2768 // directly. BroadcastObjectChange used for PagePreview invalidations, 2769 // flushViewObjectContacts used to invalidate and flush all visualizations in 2770 // edit views. 2771 SdPage* pMasterPage = dynamic_cast< SdPage* >(&TRG_GetMasterPage()); 2772 2773 if(pMasterPage) 2774 { 2775 SdrObject* pCandidate = 0; 2776 2777 pCandidate = pMasterPage->GetPresObj( PRESOBJ_HEADER ); 2778 2779 if(pCandidate) 2780 { 2781 pCandidate->BroadcastObjectChange(); 2782 pCandidate->GetViewContact().flushViewObjectContacts(); 2783 } 2784 2785 pCandidate = pMasterPage->GetPresObj( PRESOBJ_DATETIME ); 2786 2787 if(pCandidate) 2788 { 2789 pCandidate->BroadcastObjectChange(); 2790 pCandidate->GetViewContact().flushViewObjectContacts(); 2791 } 2792 2793 pCandidate = pMasterPage->GetPresObj( PRESOBJ_FOOTER ); 2794 2795 if(pCandidate) 2796 { 2797 pCandidate->BroadcastObjectChange(); 2798 pCandidate->GetViewContact().flushViewObjectContacts(); 2799 } 2800 2801 pCandidate = pMasterPage->GetPresObj( PRESOBJ_SLIDENUMBER ); 2802 2803 if(pCandidate) 2804 { 2805 pCandidate->BroadcastObjectChange(); 2806 pCandidate->GetViewContact().flushViewObjectContacts(); 2807 } 2808 } 2809 } 2810 } 2811 2812 bool SdPage::checkVisibility( 2813 const sdr::contact::ViewObjectContact& rOriginal, 2814 const sdr::contact::DisplayInfo& rDisplayInfo, 2815 bool bEdit ) 2816 { 2817 if( !FmFormPage::checkVisibility( rOriginal, rDisplayInfo, bEdit ) ) 2818 return false; 2819 2820 SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject(); 2821 if( pObj == NULL ) 2822 return false; 2823 2824 const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage()); 2825 const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter() || rOriginal.GetObjectContact().isOutputToPDFFile()); 2826 const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView(); 2827 const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage); 2828 2829 // empty presentation objects only visible during edit mode 2830 if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() ) 2831 { 2832 if( (pObj->GetObjInventor() != SdrInventor) || ( (pObj->GetObjIdentifier() != OBJ_RECT) && (pObj->GetObjIdentifier() != OBJ_PAGE) ) ) 2833 return false; 2834 } 2835 2836 if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_TEXT ) ) 2837 { 2838 const SdPage* pCheckPage = dynamic_cast< const SdPage* >(pObj->GetPage()); 2839 2840 if( pCheckPage ) 2841 { 2842 PresObjKind eKind = pCheckPage->GetPresObjKind(pObj); 2843 2844 if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) ) 2845 { 2846 const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive()); 2847 2848 if( bSubContentProcessing || ( pCheckPage->GetPageKind() == PK_HANDOUT && bIsPrinting ) ) 2849 { 2850 // use the page that is currently processed 2851 const SdPage* pVisualizedSdPage = dynamic_cast< const SdPage* >(pVisualizedPage); 2852 2853 if( pVisualizedSdPage ) 2854 { 2855 // if we are not on a masterpage, see if we have to draw this header&footer object at all 2856 const sd::HeaderFooterSettings& rSettings = pVisualizedSdPage->getHeaderFooterSettings(); 2857 2858 switch( eKind ) 2859 { 2860 case PRESOBJ_FOOTER: 2861 return rSettings.mbFooterVisible; 2862 case PRESOBJ_HEADER: 2863 return rSettings.mbHeaderVisible; 2864 case PRESOBJ_DATETIME: 2865 return rSettings.mbDateTimeVisible; 2866 case PRESOBJ_SLIDENUMBER: 2867 return rSettings.mbSlideNumberVisible; 2868 default: 2869 break; 2870 } 2871 } 2872 } 2873 } // check for placeholders on master 2874 else if( (eKind != PRESOBJ_NONE) && pCheckPage->IsMasterPage() && ( pVisualizedPage != pCheckPage ) ) 2875 { 2876 // presentation objects on master slide are always invisible if slide is shown. 2877 return false; 2878 } 2879 } 2880 } 2881 2882 // i63977, do not print SdrpageObjs from master pages 2883 if( ( pObj->GetObjInventor() == SdrInventor ) && ( pObj->GetObjIdentifier() == OBJ_PAGE ) ) 2884 { 2885 if( pObj->GetPage() && pObj->GetPage()->IsMasterPage() ) 2886 return false; 2887 } 2888 2889 return true; 2890 } 2891 2892 bool SdPage::RestoreDefaultText( SdrObject* pObj ) 2893 { 2894 bool bRet = false; 2895 2896 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj ); 2897 2898 if( pTextObj ) 2899 { 2900 PresObjKind ePresObjKind = GetPresObjKind(pTextObj); 2901 2902 if (ePresObjKind == PRESOBJ_TITLE || 2903 ePresObjKind == PRESOBJ_OUTLINE || 2904 ePresObjKind == PRESOBJ_NOTES || 2905 ePresObjKind == PRESOBJ_TEXT) 2906 { 2907 String aString( GetPresObjText(ePresObjKind) ); 2908 2909 if (aString.Len()) 2910 { 2911 sal_Bool bVertical = sal_False; 2912 OutlinerParaObject* pOldPara = pTextObj->GetOutlinerParaObject(); 2913 if( pOldPara ) 2914 bVertical = pOldPara->IsVertical(); // is old para object vertical? 2915 2916 SetObjText( pTextObj, 0, ePresObjKind, aString ); 2917 2918 if( pOldPara ) 2919 { 2920 //pTextObj->SetVerticalWriting( bVertical ); 2921 // 2922 // #94826# Here, only the vertical flag for the 2923 // OutlinerParaObjects needs to be changed. The 2924 // AutoGrowWidth/Height items still exist in the 2925 // not changed object. 2926 if(pTextObj 2927 && pTextObj->GetOutlinerParaObject() 2928 && pTextObj->GetOutlinerParaObject()->IsVertical() != (bool)bVertical) 2929 { 2930 Rectangle aObjectRect = pTextObj->GetSnapRect(); 2931 pTextObj->GetOutlinerParaObject()->SetVertical(bVertical); 2932 pTextObj->SetSnapRect(aObjectRect); 2933 } 2934 } 2935 2936 pTextObj->SetTextEditOutliner( NULL ); // to make stylesheet settings work 2937 pTextObj->NbcSetStyleSheet( GetStyleSheetForPresObj(ePresObjKind), sal_True ); 2938 pTextObj->SetEmptyPresObj(sal_True); 2939 bRet = true; 2940 } 2941 } 2942 } 2943 return bRet; 2944 } 2945 2946 void SdPage::CalculateHandoutAreas( SdDrawDocument& rModel, AutoLayout eLayout, bool bHorizontal, std::vector< Rectangle >& rAreas ) 2947 { 2948 SdPage& rHandoutMaster = *rModel.GetMasterSdPage( 0, PK_HANDOUT ); 2949 2950 if( eLayout == AUTOLAYOUT_NONE ) 2951 { 2952 // use layout from handout master 2953 SdrObjListIter aShapeIter (rHandoutMaster); 2954 while (aShapeIter.IsMore()) 2955 { 2956 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(aShapeIter.Next()); 2957 if (pPageObj) 2958 rAreas.push_back( pPageObj->GetCurrentBoundRect() ); 2959 } 2960 } 2961 else 2962 { 2963 Size aArea = rHandoutMaster.GetSize(); 2964 2965 const long nGapW = 1000; // gap is 1 cm 2966 const long nGapH = 1000; 2967 2968 long nLeftBorder = rHandoutMaster.GetLftBorder(); 2969 long nRightBorder = rHandoutMaster.GetRgtBorder(); 2970 long nTopBorder = rHandoutMaster.GetUppBorder(); 2971 long nBottomBorder = rHandoutMaster.GetLwrBorder(); 2972 2973 const long nHeaderFooterHeight = static_cast< long >( (aArea.Height() - nTopBorder - nLeftBorder) * 0.05 ); 2974 2975 nTopBorder += nHeaderFooterHeight; 2976 nBottomBorder += nHeaderFooterHeight; 2977 2978 long nX = nGapW + nLeftBorder; 2979 long nY = nGapH + nTopBorder; 2980 2981 aArea.Width() -= nGapW * 2 + nLeftBorder + nRightBorder; 2982 aArea.Height() -= nGapH * 2 + nTopBorder + nBottomBorder; 2983 2984 const bool bLandscape = aArea.Width() > aArea.Height(); 2985 2986 static sal_uInt16 aOffsets[5][9] = 2987 { 2988 { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, // AUTOLAYOUT_HANDOUT9, Portrait, Horizontal order 2989 { 0, 2, 4, 1, 3, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT3, Landscape, Vertical 2990 { 0, 2, 1, 3, 0, 0, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Landscape, Vertical 2991 { 0, 3, 1, 4, 2, 5, 0, 0, 0 }, // AUTOLAYOUT_HANDOUT4, Portrait, Vertical 2992 { 0, 3, 6, 1, 4, 7, 2, 5, 8 }, // AUTOLAYOUT_HANDOUT9, Landscape, Vertical 2993 }; 2994 2995 sal_uInt16* pOffsets = aOffsets[0]; 2996 sal_uInt16 nColCnt = 0, nRowCnt = 0; 2997 switch ( eLayout ) 2998 { 2999 case AUTOLAYOUT_HANDOUT1: 3000 nColCnt = 1; nRowCnt = 1; 3001 break; 3002 3003 case AUTOLAYOUT_HANDOUT2: 3004 if( bLandscape ) 3005 { 3006 nColCnt = 2; nRowCnt = 1; 3007 } 3008 else 3009 { 3010 nColCnt = 1; nRowCnt = 2; 3011 } 3012 break; 3013 3014 case AUTOLAYOUT_HANDOUT3: 3015 if( bLandscape ) 3016 { 3017 nColCnt = 3; nRowCnt = 2; 3018 } 3019 else 3020 { 3021 nColCnt = 2; nRowCnt = 3; 3022 } 3023 pOffsets = aOffsets[ bLandscape ? 1 : 0 ]; 3024 break; 3025 3026 case AUTOLAYOUT_HANDOUT4: 3027 nColCnt = 2; nRowCnt = 2; 3028 pOffsets = aOffsets[ bHorizontal ? 0 : 2 ]; 3029 break; 3030 3031 case AUTOLAYOUT_HANDOUT6: 3032 if( bLandscape ) 3033 { 3034 nColCnt = 3; nRowCnt = 2; 3035 } 3036 else 3037 { 3038 nColCnt = 2; nRowCnt = 3; 3039 } 3040 if( !bHorizontal ) 3041 pOffsets = aOffsets[ bLandscape ? 1 : 3 ]; 3042 break; 3043 3044 default: 3045 case AUTOLAYOUT_HANDOUT9: 3046 nColCnt = 3; nRowCnt = 3; 3047 3048 if( !bHorizontal ) 3049 pOffsets = aOffsets[4]; 3050 break; 3051 } 3052 3053 rAreas.resize( nColCnt * nRowCnt ); 3054 3055 Size aPartArea, aSize; 3056 aPartArea.Width() = ((aArea.Width() - ((nColCnt-1) * nGapW) ) / nColCnt); 3057 aPartArea.Height() = ((aArea.Height() - ((nRowCnt-1) * nGapH) ) / nRowCnt); 3058 3059 SdrPage* pFirstPage = rModel.GetMasterSdPage(0, PK_STANDARD); 3060 if ( pFirstPage ) 3061 { 3062 // scale actual size into handout rect 3063 double fScale = (double)aPartArea.Width() / (double)pFirstPage->GetWdt(); 3064 3065 aSize.Height() = (long)(fScale * pFirstPage->GetHgt() ); 3066 if( aSize.Height() > aPartArea.Height() ) 3067 { 3068 fScale = (double)aPartArea.Height() / (double)pFirstPage->GetHgt(); 3069 aSize.Height() = aPartArea.Height(); 3070 aSize.Width() = (long)(fScale * pFirstPage->GetWdt()); 3071 } 3072 else 3073 { 3074 aSize.Width() = aPartArea.Width(); 3075 } 3076 3077 nX += (aPartArea.Width() - aSize.Width()) / 2; 3078 nY += (aPartArea.Height()- aSize.Height())/ 2; 3079 } 3080 else 3081 { 3082 aSize = aPartArea; 3083 } 3084 3085 Point aPos( nX, nY ); 3086 3087 const bool bRTL = rModel.GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB; 3088 3089 const long nOffsetX = (aPartArea.Width() + nGapW) * (bRTL ? -1 : 1); 3090 const long nOffsetY = aPartArea.Height() + nGapH; 3091 const long nStartX = bRTL ? nOffsetX*(1 - nColCnt) - nX : nX; 3092 3093 for(sal_uInt16 nRow = 0; nRow < nRowCnt; nRow++) 3094 { 3095 aPos.X() = nStartX; 3096 for(sal_uInt16 nCol = 0; nCol < nColCnt; nCol++) 3097 { 3098 rAreas[*pOffsets++] = Rectangle(aPos, aSize); 3099 aPos.X() += nOffsetX; 3100 } 3101 3102 aPos.Y() += nOffsetY; 3103 } 3104 } 3105 } 3106 3107 3108 3109 3110 void SdPage::SetPrecious (const bool bIsPrecious) 3111 { 3112 mbIsPrecious = bIsPrecious; 3113 } 3114 3115 3116 3117 3118 bool SdPage::IsPrecious (void) const 3119 { 3120 return mbIsPrecious; 3121 } 3122 3123 3124 3125 3126 HeaderFooterSettings::HeaderFooterSettings() 3127 { 3128 mbHeaderVisible = true; 3129 mbFooterVisible = true; 3130 mbSlideNumberVisible = false; 3131 mbDateTimeVisible = true; 3132 mbDateTimeIsFixed = true; 3133 meDateTimeFormat = SVXDATEFORMAT_A; 3134 } 3135 3136 bool HeaderFooterSettings::operator==( const HeaderFooterSettings& rSettings ) const 3137 { 3138 return (mbHeaderVisible == rSettings.mbHeaderVisible) && 3139 (maHeaderText == rSettings.maHeaderText) && 3140 (mbFooterVisible == rSettings.mbFooterVisible) && 3141 (maFooterText == rSettings.maFooterText) && 3142 (mbSlideNumberVisible == rSettings.mbSlideNumberVisible) && 3143 (mbDateTimeVisible == rSettings.mbDateTimeVisible) && 3144 (mbDateTimeIsFixed == rSettings.mbDateTimeIsFixed) && 3145 (meDateTimeFormat == rSettings.meDateTimeFormat) && 3146 (maDateTimeText == rSettings.maDateTimeText); 3147 } 3148