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 "OutlineViewShell.hxx" 28 29 #include <com/sun/star/presentation/XPresentation2.hpp> 30 31 #include "app.hrc" 32 #include <svx/hlnkitem.hxx> 33 #include <sfx2/docfile.hxx> 34 #include <sfx2/dispatch.hxx> 35 #include <sfx2/request.hxx> 36 #include <svl/eitem.hxx> 37 #ifndef _ZOOMITEM_HXX //autogen 38 #include <svx/zoomitem.hxx> 39 #endif 40 #include <vcl/msgbox.hxx> 41 #include <editeng/eeitem.hxx> 42 #include <editeng/flditem.hxx> 43 #include <editeng/editstat.hxx> 44 #include "optsitem.hxx" 45 #include <unotools/useroptions.hxx> 46 47 #include <sfx2/viewfrm.hxx> 48 #include "Outliner.hxx" 49 #include "Window.hxx" 50 #include "OutlineViewShell.hxx" 51 #include "fubullet.hxx" 52 #include "fuolbull.hxx" 53 #include "FrameView.hxx" 54 #include "fuzoom.hxx" 55 #include "fuscale.hxx" 56 #include "fuchar.hxx" 57 #include "fuinsfil.hxx" 58 #include "fuprobjs.hxx" 59 #include "futhes.hxx" 60 #include "futempl.hxx" 61 #include "fusldlg.hxx" 62 #include "zoomlist.hxx" 63 #include "fuexpand.hxx" 64 #include "fusumry.hxx" 65 #include "fucushow.hxx" 66 #include "drawdoc.hxx" 67 #include "sdattr.hxx" 68 #include "ViewShellBase.hxx" 69 #include "sdabstdlg.hxx" 70 #include "framework/FrameworkHelper.hxx" 71 #include "DrawViewShell.hxx" 72 73 using namespace ::com::sun::star::uno; 74 using namespace ::com::sun::star::presentation; 75 76 namespace sd { 77 78 79 /************************************************************************/ 80 81 /************************************************************************* 82 |* 83 |* SfxRequests fuer temporaere Funktionen 84 |* 85 \************************************************************************/ 86 87 void OutlineViewShell::FuTemporary(SfxRequest &rReq) 88 { 89 DeactivateCurrentFunction(); 90 91 OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() ); 92 sal_uInt16 nSId = rReq.GetSlot(); 93 94 switch( nSId ) 95 { 96 case SID_ATTR_ZOOM: 97 { 98 const SfxItemSet* pArgs = rReq.GetArgs(); 99 100 if ( pArgs ) 101 { 102 SvxZoomType eZT = ( ( const SvxZoomItem& ) pArgs-> 103 Get( SID_ATTR_ZOOM ) ).GetType(); 104 switch( eZT ) 105 { 106 case SVX_ZOOM_PERCENT: 107 SetZoom( (long) ( ( const SvxZoomItem& ) pArgs-> 108 Get( SID_ATTR_ZOOM ) ).GetValue() ); 109 Invalidate( SID_ATTR_ZOOM ); 110 Invalidate( SID_ATTR_ZOOMSLIDER ); 111 break; 112 default: 113 break; 114 } 115 rReq.Done(); 116 } 117 else 118 { 119 // hier den Zoom-Dialog oeffnen 120 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 121 } 122 Cancel(); 123 } 124 break; 125 126 case SID_ATTR_ZOOMSLIDER: 127 { 128 const SfxItemSet* pArgs = rReq.GetArgs(); 129 130 if (pArgs && pArgs->Count () == 1 ) 131 { 132 SFX_REQUEST_ARG (rReq, pScale, SfxUInt16Item, SID_ATTR_ZOOMSLIDER, sal_False); 133 if (CHECK_RANGE (5, pScale->GetValue (), 3000)) 134 { 135 SetZoom (pScale->GetValue ()); 136 137 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 138 rBindings.Invalidate( SID_ATTR_ZOOM ); 139 rBindings.Invalidate( SID_ZOOM_IN ); 140 rBindings.Invalidate( SID_ZOOM_OUT ); 141 rBindings.Invalidate( SID_ATTR_ZOOMSLIDER ); 142 143 } 144 } 145 146 Cancel(); 147 rReq.Done (); 148 break; 149 } 150 151 case SID_ZOOM_OUT: 152 { 153 SetCurrentFunction( FuZoom::Create(this, GetActiveWindow(), pOlView, GetDoc(), rReq) ); 154 // Beendet sich selbst, kein Cancel() notwendig! 155 rReq.Done(); 156 } 157 break; 158 159 case SID_SIZE_REAL: 160 { 161 SetZoom( 100 ); 162 Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), 163 GetActiveWindow()->GetOutputSizePixel()) ); 164 mpZoomList->InsertZoomRect(aVisAreaWin); 165 Invalidate( SID_ATTR_ZOOM ); 166 Invalidate( SID_ATTR_ZOOMSLIDER ); 167 Cancel(); 168 rReq.Done(); 169 } 170 break; 171 172 case SID_ZOOM_IN: 173 { 174 SetZoom( Max( (long) ( GetActiveWindow()->GetZoom() / 2 ), (long) GetActiveWindow()->GetMinZoom() ) ); 175 Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), 176 GetActiveWindow()->GetOutputSizePixel()) ); 177 mpZoomList->InsertZoomRect(aVisAreaWin); 178 Invalidate( SID_ATTR_ZOOM ); 179 Invalidate( SID_ZOOM_OUT); 180 Invalidate( SID_ZOOM_IN ); 181 Invalidate( SID_ATTR_ZOOMSLIDER ); 182 Cancel(); 183 rReq.Done(); 184 } 185 break; 186 187 case SID_OUTLINE_COLLAPSE_ALL: 188 { 189 pOutlinerView->CollapseAll(); 190 Cancel(); 191 rReq.Done(); 192 } 193 break; 194 195 case SID_OUTLINE_COLLAPSE: 196 { 197 pOutlinerView->Collapse(); 198 Cancel(); 199 rReq.Done(); 200 } 201 break; 202 203 case SID_OUTLINE_EXPAND_ALL: 204 { 205 pOutlinerView->ExpandAll(); 206 Cancel(); 207 rReq.Done(); 208 } 209 break; 210 211 case SID_OUTLINE_EXPAND: 212 { 213 pOutlinerView->Expand(); 214 Cancel(); 215 rReq.Done(); 216 } 217 break; 218 219 case SID_OUTLINE_FORMAT: 220 { 221 ::Outliner* pOutl = pOutlinerView->GetOutliner(); 222 pOutl->SetFlatMode( !pOutl->IsFlatMode() ); 223 Invalidate( SID_COLORVIEW ); 224 Cancel(); 225 rReq.Done(); 226 } 227 break; 228 229 case SID_SELECTALL: 230 { 231 ::Outliner* pOutl = pOlView->GetOutliner(); 232 sal_uLong nParaCount = pOutl->GetParagraphCount(); 233 if (nParaCount > 0) 234 { 235 pOutlinerView->SelectRange( 0, (sal_uInt16) nParaCount ); 236 } 237 Cancel(); 238 } 239 break; 240 241 case SID_PRESENTATION: 242 case SID_REHEARSE_TIMINGS: 243 { 244 pOlView->PrepareClose(); 245 246 Reference< XPresentation2 > xPresentation( GetDoc()->getPresentation() ); 247 if( xPresentation.is() ) 248 { 249 if( ( SID_REHEARSE_TIMINGS != rReq.GetSlot() ) ) 250 xPresentation->start(); 251 else 252 xPresentation->rehearseTimings(); 253 } 254 Cancel(); 255 rReq.Done(); 256 } 257 break; 258 259 case SID_COLORVIEW: 260 { 261 ::Outliner* pOutl = pOutlinerView->GetOutliner(); 262 sal_uLong nCntrl = pOutl->GetControlWord(); 263 264 if ( !(nCntrl & EE_CNTRL_NOCOLORS) ) 265 { 266 // Farbansicht ist eingeschaltet: ausschalten 267 pOutl->SetControlWord(nCntrl | EE_CNTRL_NOCOLORS); 268 } 269 else 270 { 271 // Farbansicht ist ausgeschaltet: einschalten 272 pOutl->SetControlWord(nCntrl & ~EE_CNTRL_NOCOLORS); 273 } 274 275 InvalidateWindows(); 276 Invalidate( SID_COLORVIEW ); 277 Cancel(); 278 rReq.Done(); 279 } 280 break; 281 282 case SID_STYLE_EDIT: 283 case SID_STYLE_UPDATE_BY_EXAMPLE: 284 { 285 if( rReq.GetArgs() ) 286 { 287 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 288 Cancel(); 289 } 290 291 rReq.Ignore (); 292 } 293 break; 294 295 case SID_PRESENTATION_DLG: 296 { 297 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 298 Cancel(); 299 } 300 break; 301 302 case SID_CUSTOMSHOW_DLG: 303 { 304 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 305 Cancel(); 306 } 307 break; 308 } 309 310 if(HasCurrentFunction()) 311 GetCurrentFunction()->Activate(); 312 313 Invalidate( SID_OUTLINE_COLLAPSE_ALL ); 314 Invalidate( SID_OUTLINE_COLLAPSE ); 315 Invalidate( SID_OUTLINE_EXPAND_ALL ); 316 Invalidate( SID_OUTLINE_EXPAND ); 317 318 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 319 rBindings.Invalidate( SID_OUTLINE_LEFT ); 320 rBindings.Invalidate( SID_OUTLINE_RIGHT ); 321 rBindings.Invalidate( SID_OUTLINE_UP ); 322 rBindings.Invalidate( SID_OUTLINE_DOWN ); 323 324 Invalidate( SID_OUTLINE_FORMAT ); 325 Invalidate( SID_COLORVIEW ); 326 Invalidate(SID_CUT); 327 Invalidate(SID_COPY); 328 Invalidate(SID_PASTE); 329 } 330 331 void OutlineViewShell::FuTemporaryModify(SfxRequest &rReq) 332 { 333 OutlineViewModelChangeGuard aGuard( *pOlView ); 334 335 DeactivateCurrentFunction(); 336 337 OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() ); 338 sal_uInt16 nSId = rReq.GetSlot(); 339 340 switch( nSId ) 341 { 342 case SID_HYPERLINK_SETLINK: 343 { 344 const SfxItemSet* pReqArgs = rReq.GetArgs(); 345 346 if (pReqArgs) 347 { 348 SvxHyperlinkItem* pHLItem = 349 (SvxHyperlinkItem*) &pReqArgs->Get(SID_HYPERLINK_SETLINK); 350 351 SvxFieldItem aURLItem(SvxURLField(pHLItem->GetURL(), 352 pHLItem->GetName(), 353 SVXURLFORMAT_REPR), EE_FEATURE_FIELD); 354 ESelection aSel( pOutlinerView->GetSelection() ); 355 pOutlinerView->InsertField(aURLItem); 356 if ( aSel.nStartPos <= aSel.nEndPos ) 357 aSel.nEndPos = aSel.nStartPos + 1; 358 else 359 aSel.nStartPos = aSel.nEndPos + 1; 360 pOutlinerView->SetSelection( aSel ); 361 } 362 363 Cancel(); 364 rReq.Ignore (); 365 } 366 break; 367 368 case FN_INSERT_SOFT_HYPHEN: 369 case FN_INSERT_HARDHYPHEN: 370 case FN_INSERT_HARD_SPACE: 371 case SID_INSERT_RLM : 372 case SID_INSERT_LRM : 373 case SID_INSERT_ZWNBSP : 374 case SID_INSERT_ZWSP: 375 case SID_CHARMAP: 376 { 377 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 378 Cancel(); 379 } 380 break; 381 382 case SID_OUTLINE_BULLET: 383 { 384 SetCurrentFunction( FuOutlineBullet::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 385 Cancel(); 386 } 387 break; 388 389 case SID_THESAURUS: 390 { 391 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 392 Cancel(); 393 rReq.Ignore (); 394 } 395 break; 396 397 case SID_CHAR_DLG: 398 { 399 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 400 Cancel(); 401 } 402 break; 403 404 case SID_INSERTFILE: 405 { 406 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView, GetDoc(), rReq) ); 407 Cancel(); 408 } 409 break; 410 411 case SID_PRESENTATIONOBJECT: 412 { 413 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView, GetDoc(), rReq) ); 414 Cancel(); 415 } 416 break; 417 418 case SID_SET_DEFAULT: 419 { 420 // 1. Selektion merken (kriegt die eselige EditEngine nicht selbst 421 // auf die Reihe!) 422 // 2. Update auf False (sonst flackert's noch staerker 423 // an allen selektierten Absaetzen: 424 // a. deren Vorlage nochmal setzen, um absatzweite harte Attribute 425 // zu entfernen 426 // b. harte Zeichenattribute loeschen 427 // 3. Update auf True und Selektion wieder setzen 428 /* 429 ESelection aEsel= pOutlinerView->GetSelection(); 430 Outliner* pOutl = pOutlinerView->GetOutliner(); 431 pOutl->SetUpdateMode(sal_False); 432 List* pSelectedParas = pOutlinerView->CreateSelectionList(); 433 Paragraph* pPara = (Paragraph*)pSelectedParas->First(); 434 while (pPara) 435 { 436 sal_uLong nParaPos = pOutl->GetAbsPos(pPara); 437 String aName; 438 SfxStyleFamily aFamily; 439 pOutl->GetStyleSheet(nParaPos, aName, aFamily); 440 pOutl->SetStyleSheet(nParaPos, aName, aFamily); 441 pOutl->QuickRemoveCharAttribs(nParaPos); 442 pPara = (Paragraph*)pSelectedParas->Next(); 443 } 444 delete pSelectedParas; 445 pOutl->SetUpdateMode(sal_True); 446 pOutlinerView->SetSelection(aEsel); 447 */ 448 pOutlinerView->RemoveAttribs(sal_True); // sal_True = auch Absatzattribute 449 Cancel(); 450 rReq.Done(); 451 } 452 break; 453 454 case SID_SUMMARY_PAGE: 455 { 456 pOlView->SetSelectedPages(); 457 SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 458 pOlView->GetOutliner()->Clear(); 459 pOlView->FillOutliner(); 460 pOlView->GetActualPage(); 461 Cancel(); 462 } 463 break; 464 465 case SID_EXPAND_PAGE: 466 { 467 pOlView->SetSelectedPages(); 468 SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 469 pOlView->GetOutliner()->Clear(); 470 pOlView->FillOutliner(); 471 pOlView->GetActualPage(); 472 Cancel(); 473 } 474 break; 475 476 case SID_INSERT_FLD_DATE_FIX: 477 case SID_INSERT_FLD_DATE_VAR: 478 case SID_INSERT_FLD_TIME_FIX: 479 case SID_INSERT_FLD_TIME_VAR: 480 case SID_INSERT_FLD_AUTHOR: 481 case SID_INSERT_FLD_PAGE: 482 case SID_INSERT_FLD_PAGES: 483 case SID_INSERT_FLD_FILE: 484 { 485 SvxFieldItem* pFieldItem = 0; 486 487 switch( nSId ) 488 { 489 case SID_INSERT_FLD_DATE_FIX: 490 pFieldItem = new SvxFieldItem( 491 SvxDateField( Date(), SVXDATETYPE_FIX ), EE_FEATURE_FIELD ); 492 break; 493 494 case SID_INSERT_FLD_DATE_VAR: 495 pFieldItem = new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD ); 496 break; 497 498 case SID_INSERT_FLD_TIME_FIX: 499 pFieldItem = new SvxFieldItem( 500 SvxExtTimeField( Time(), SVXTIMETYPE_FIX ), EE_FEATURE_FIELD ); 501 break; 502 503 case SID_INSERT_FLD_TIME_VAR: 504 pFieldItem = new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD ); 505 break; 506 507 case SID_INSERT_FLD_AUTHOR: 508 { 509 SvtUserOptions aUserOptions; 510 pFieldItem = new SvxFieldItem( 511 SvxAuthorField( 512 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() ) 513 , EE_FEATURE_FIELD ); 514 } 515 break; 516 517 case SID_INSERT_FLD_PAGE: 518 pFieldItem = new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD ); 519 break; 520 521 case SID_INSERT_FLD_PAGES: 522 pFieldItem = new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD ); 523 break; 524 525 case SID_INSERT_FLD_FILE: 526 { 527 String aName; 528 if( GetDocSh()->HasName() ) 529 aName = GetDocSh()->GetMedium()->GetName(); 530 //else 531 // aName = GetDocSh()->GetName(); 532 pFieldItem = new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD ); 533 } 534 break; 535 } 536 537 const SvxFieldItem* pOldFldItem = pOutlinerView->GetFieldAtSelection(); 538 539 if( pOldFldItem && ( pOldFldItem->GetField()->ISA( SvxURLField ) || 540 pOldFldItem->GetField()->ISA( SvxDateField ) || 541 pOldFldItem->GetField()->ISA( SvxTimeField ) || 542 pOldFldItem->GetField()->ISA( SvxExtTimeField ) || 543 pOldFldItem->GetField()->ISA( SvxExtFileField ) || 544 pOldFldItem->GetField()->ISA( SvxAuthorField ) || 545 pOldFldItem->GetField()->ISA( SvxPageField ) || 546 pOldFldItem->GetField()->ISA( SvxPagesField )) ) 547 { 548 // Feld selektieren, so dass es beim Insert geloescht wird 549 ESelection aSel = pOutlinerView->GetSelection(); 550 if( aSel.nStartPos == aSel.nEndPos ) 551 aSel.nEndPos++; 552 pOutlinerView->SetSelection( aSel ); 553 } 554 555 if( pFieldItem ) 556 pOutlinerView->InsertField( *pFieldItem ); 557 558 delete pFieldItem; 559 560 Cancel(); 561 rReq.Ignore (); 562 } 563 break; 564 565 case SID_MODIFY_FIELD: 566 { 567 const SvxFieldItem* pFldItem = pOutlinerView->GetFieldAtSelection(); 568 569 if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) || 570 pFldItem->GetField()->ISA( SvxAuthorField ) || 571 pFldItem->GetField()->ISA( SvxExtFileField ) || 572 pFldItem->GetField()->ISA( SvxExtTimeField ) ) ) 573 { 574 // Dialog... 575 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 576 AbstractSdModifyFieldDlg* pDlg = pFact ? pFact->CreateSdModifyFieldDlg(GetActiveWindow(), pFldItem->GetField(), pOutlinerView->GetAttribs() ) : 0; 577 if( pDlg && (pDlg->Execute() == RET_OK) ) 578 { 579 SvxFieldData* pField = pDlg->GetField(); 580 if( pField ) 581 { 582 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD ); 583 //pOLV->DeleteSelected(); <-- fehlt leider ! 584 // Feld selektieren, so dass es beim Insert geloescht wird 585 ESelection aSel = pOutlinerView->GetSelection(); 586 sal_Bool bSel = sal_True; 587 if( aSel.nStartPos == aSel.nEndPos ) 588 { 589 bSel = sal_False; 590 aSel.nEndPos++; 591 } 592 pOutlinerView->SetSelection( aSel ); 593 594 pOutlinerView->InsertField( aFieldItem ); 595 596 // Selektion wird wieder in den Ursprungszustand gebracht 597 if( !bSel ) 598 aSel.nEndPos--; 599 pOutlinerView->SetSelection( aSel ); 600 601 delete pField; 602 } 603 604 SfxItemSet aSet( pDlg->GetItemSet() ); 605 if( aSet.Count() ) 606 { 607 pOutlinerView->SetAttribs( aSet ); 608 609 ::Outliner* pOutliner = pOutlinerView->GetOutliner(); 610 if( pOutliner ) 611 pOutliner->UpdateFields(); 612 } 613 } 614 delete pDlg; 615 } 616 617 Cancel(); 618 rReq.Ignore (); 619 } 620 break; 621 } 622 623 if(HasCurrentFunction()) 624 GetCurrentFunction()->Activate(); 625 626 Invalidate( SID_OUTLINE_COLLAPSE_ALL ); 627 Invalidate( SID_OUTLINE_COLLAPSE ); 628 Invalidate( SID_OUTLINE_EXPAND_ALL ); 629 Invalidate( SID_OUTLINE_EXPAND ); 630 631 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 632 rBindings.Invalidate( SID_OUTLINE_LEFT ); 633 rBindings.Invalidate( SID_OUTLINE_RIGHT ); 634 rBindings.Invalidate( SID_OUTLINE_UP ); 635 rBindings.Invalidate( SID_OUTLINE_DOWN ); 636 637 Invalidate( SID_OUTLINE_FORMAT ); 638 Invalidate( SID_COLORVIEW ); 639 Invalidate(SID_CUT); 640 Invalidate(SID_COPY); 641 Invalidate(SID_PASTE); 642 } 643 644 645 } // end of namespace sd 646