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 sal_uInt16 nSId = rReq.GetSlot(); 334 std::auto_ptr< OutlineViewModelChangeGuard > aGuard; 335 if (nSId != SID_OUTLINE_BULLET && nSId != FN_SVX_SET_BULLET && nSId != FN_SVX_SET_NUMBER) 336 { 337 aGuard.reset( new OutlineViewModelChangeGuard(*pOlView) ); 338 } 339 DeactivateCurrentFunction(); 340 341 OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() ); 342 //sal_uInt16 nSId = rReq.GetSlot(); 343 344 switch( nSId ) 345 { 346 case SID_HYPERLINK_SETLINK: 347 { 348 const SfxItemSet* pReqArgs = rReq.GetArgs(); 349 350 if (pReqArgs) 351 { 352 SvxHyperlinkItem* pHLItem = 353 (SvxHyperlinkItem*) &pReqArgs->Get(SID_HYPERLINK_SETLINK); 354 355 SvxFieldItem aURLItem(SvxURLField(pHLItem->GetURL(), 356 pHLItem->GetName(), 357 SVXURLFORMAT_REPR), EE_FEATURE_FIELD); 358 ESelection aSel( pOutlinerView->GetSelection() ); 359 pOutlinerView->InsertField(aURLItem); 360 if ( aSel.nStartPos <= aSel.nEndPos ) 361 aSel.nEndPos = aSel.nStartPos + 1; 362 else 363 aSel.nStartPos = aSel.nEndPos + 1; 364 pOutlinerView->SetSelection( aSel ); 365 } 366 367 Cancel(); 368 rReq.Ignore (); 369 } 370 break; 371 372 case FN_INSERT_SOFT_HYPHEN: 373 case FN_INSERT_HARDHYPHEN: 374 case FN_INSERT_HARD_SPACE: 375 case SID_INSERT_RLM : 376 case SID_INSERT_LRM : 377 case SID_INSERT_ZWNBSP : 378 case SID_INSERT_ZWSP: 379 case SID_CHARMAP: 380 { 381 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 382 Cancel(); 383 } 384 break; 385 386 case SID_OUTLINE_BULLET: 387 case FN_SVX_SET_BULLET: 388 case FN_SVX_SET_NUMBER: 389 { 390 SetCurrentFunction( FuOutlineBullet::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 391 Cancel(); 392 } 393 break; 394 395 case SID_THESAURUS: 396 { 397 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 398 Cancel(); 399 rReq.Ignore (); 400 } 401 break; 402 403 case SID_CHAR_DLG_EFFECT: 404 case SID_CHAR_DLG: 405 { 406 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 407 Cancel(); 408 } 409 break; 410 411 case SID_INSERTFILE: 412 { 413 SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView, GetDoc(), rReq) ); 414 Cancel(); 415 } 416 break; 417 418 case SID_PRESENTATIONOBJECT: 419 { 420 SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView, GetDoc(), rReq) ); 421 Cancel(); 422 } 423 break; 424 425 case SID_SET_DEFAULT: 426 { 427 // 1. Selektion merken (kriegt die eselige EditEngine nicht selbst 428 // auf die Reihe!) 429 // 2. Update auf False (sonst flackert's noch staerker 430 // an allen selektierten Absaetzen: 431 // a. deren Vorlage nochmal setzen, um absatzweite harte Attribute 432 // zu entfernen 433 // b. harte Zeichenattribute loeschen 434 // 3. Update auf True und Selektion wieder setzen 435 /* 436 ESelection aEsel= pOutlinerView->GetSelection(); 437 Outliner* pOutl = pOutlinerView->GetOutliner(); 438 pOutl->SetUpdateMode(sal_False); 439 List* pSelectedParas = pOutlinerView->CreateSelectionList(); 440 Paragraph* pPara = (Paragraph*)pSelectedParas->First(); 441 while (pPara) 442 { 443 sal_uLong nParaPos = pOutl->GetAbsPos(pPara); 444 String aName; 445 SfxStyleFamily aFamily; 446 pOutl->GetStyleSheet(nParaPos, aName, aFamily); 447 pOutl->SetStyleSheet(nParaPos, aName, aFamily); 448 pOutl->QuickRemoveCharAttribs(nParaPos); 449 pPara = (Paragraph*)pSelectedParas->Next(); 450 } 451 delete pSelectedParas; 452 pOutl->SetUpdateMode(sal_True); 453 pOutlinerView->SetSelection(aEsel); 454 */ 455 pOutlinerView->RemoveAttribs(sal_True); // sal_True = auch Absatzattribute 456 Cancel(); 457 rReq.Done(); 458 } 459 break; 460 461 case SID_SUMMARY_PAGE: 462 { 463 pOlView->SetSelectedPages(); 464 SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 465 pOlView->GetOutliner()->Clear(); 466 pOlView->FillOutliner(); 467 pOlView->GetActualPage(); 468 Cancel(); 469 } 470 break; 471 472 case SID_EXPAND_PAGE: 473 { 474 pOlView->SetSelectedPages(); 475 SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) ); 476 pOlView->GetOutliner()->Clear(); 477 pOlView->FillOutliner(); 478 pOlView->GetActualPage(); 479 Cancel(); 480 } 481 break; 482 483 case SID_INSERT_FLD_DATE_FIX: 484 case SID_INSERT_FLD_DATE_VAR: 485 case SID_INSERT_FLD_TIME_FIX: 486 case SID_INSERT_FLD_TIME_VAR: 487 case SID_INSERT_FLD_AUTHOR: 488 case SID_INSERT_FLD_PAGE: 489 case SID_INSERT_FLD_PAGES: 490 case SID_INSERT_FLD_FILE: 491 { 492 SvxFieldItem* pFieldItem = 0; 493 494 switch( nSId ) 495 { 496 case SID_INSERT_FLD_DATE_FIX: 497 pFieldItem = new SvxFieldItem( 498 SvxDateField( Date(), SVXDATETYPE_FIX ), EE_FEATURE_FIELD ); 499 break; 500 501 case SID_INSERT_FLD_DATE_VAR: 502 pFieldItem = new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD ); 503 break; 504 505 case SID_INSERT_FLD_TIME_FIX: 506 pFieldItem = new SvxFieldItem( 507 SvxExtTimeField( Time(), SVXTIMETYPE_FIX ), EE_FEATURE_FIELD ); 508 break; 509 510 case SID_INSERT_FLD_TIME_VAR: 511 pFieldItem = new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD ); 512 break; 513 514 case SID_INSERT_FLD_AUTHOR: 515 { 516 SvtUserOptions aUserOptions; 517 pFieldItem = new SvxFieldItem( 518 SvxAuthorField( 519 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() ) 520 , EE_FEATURE_FIELD ); 521 } 522 break; 523 524 case SID_INSERT_FLD_PAGE: 525 pFieldItem = new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD ); 526 break; 527 528 case SID_INSERT_FLD_PAGES: 529 pFieldItem = new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD ); 530 break; 531 532 case SID_INSERT_FLD_FILE: 533 { 534 String aName; 535 if( GetDocSh()->HasName() ) 536 aName = GetDocSh()->GetMedium()->GetName(); 537 //else 538 // aName = GetDocSh()->GetName(); 539 pFieldItem = new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD ); 540 } 541 break; 542 } 543 544 const SvxFieldItem* pOldFldItem = pOutlinerView->GetFieldAtSelection(); 545 546 if( pOldFldItem && ( pOldFldItem->GetField()->ISA( SvxURLField ) || 547 pOldFldItem->GetField()->ISA( SvxDateField ) || 548 pOldFldItem->GetField()->ISA( SvxTimeField ) || 549 pOldFldItem->GetField()->ISA( SvxExtTimeField ) || 550 pOldFldItem->GetField()->ISA( SvxExtFileField ) || 551 pOldFldItem->GetField()->ISA( SvxAuthorField ) || 552 pOldFldItem->GetField()->ISA( SvxPageField ) || 553 pOldFldItem->GetField()->ISA( SvxPagesField )) ) 554 { 555 // Feld selektieren, so dass es beim Insert geloescht wird 556 ESelection aSel = pOutlinerView->GetSelection(); 557 if( aSel.nStartPos == aSel.nEndPos ) 558 aSel.nEndPos++; 559 pOutlinerView->SetSelection( aSel ); 560 } 561 562 if( pFieldItem ) 563 pOutlinerView->InsertField( *pFieldItem ); 564 565 delete pFieldItem; 566 567 Cancel(); 568 rReq.Ignore (); 569 } 570 break; 571 572 case SID_MODIFY_FIELD: 573 { 574 const SvxFieldItem* pFldItem = pOutlinerView->GetFieldAtSelection(); 575 576 if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) || 577 pFldItem->GetField()->ISA( SvxAuthorField ) || 578 pFldItem->GetField()->ISA( SvxExtFileField ) || 579 pFldItem->GetField()->ISA( SvxExtTimeField ) ) ) 580 { 581 // Dialog... 582 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 583 AbstractSdModifyFieldDlg* pDlg = pFact ? pFact->CreateSdModifyFieldDlg(GetActiveWindow(), pFldItem->GetField(), pOutlinerView->GetAttribs() ) : 0; 584 if( pDlg && (pDlg->Execute() == RET_OK) ) 585 { 586 SvxFieldData* pField = pDlg->GetField(); 587 if( pField ) 588 { 589 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD ); 590 //pOLV->DeleteSelected(); <-- fehlt leider ! 591 // Feld selektieren, so dass es beim Insert geloescht wird 592 ESelection aSel = pOutlinerView->GetSelection(); 593 sal_Bool bSel = sal_True; 594 if( aSel.nStartPos == aSel.nEndPos ) 595 { 596 bSel = sal_False; 597 aSel.nEndPos++; 598 } 599 pOutlinerView->SetSelection( aSel ); 600 601 pOutlinerView->InsertField( aFieldItem ); 602 603 // Selektion wird wieder in den Ursprungszustand gebracht 604 if( !bSel ) 605 aSel.nEndPos--; 606 pOutlinerView->SetSelection( aSel ); 607 608 delete pField; 609 } 610 611 SfxItemSet aSet( pDlg->GetItemSet() ); 612 if( aSet.Count() ) 613 { 614 pOutlinerView->SetAttribs( aSet ); 615 616 ::Outliner* pOutliner = pOutlinerView->GetOutliner(); 617 if( pOutliner ) 618 pOutliner->UpdateFields(); 619 } 620 } 621 delete pDlg; 622 } 623 624 Cancel(); 625 rReq.Ignore (); 626 } 627 break; 628 } 629 630 if(HasCurrentFunction()) 631 GetCurrentFunction()->Activate(); 632 633 Invalidate( SID_OUTLINE_COLLAPSE_ALL ); 634 Invalidate( SID_OUTLINE_COLLAPSE ); 635 Invalidate( SID_OUTLINE_EXPAND_ALL ); 636 Invalidate( SID_OUTLINE_EXPAND ); 637 638 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 639 rBindings.Invalidate( SID_OUTLINE_LEFT ); 640 rBindings.Invalidate( SID_OUTLINE_RIGHT ); 641 rBindings.Invalidate( SID_OUTLINE_UP ); 642 rBindings.Invalidate( SID_OUTLINE_DOWN ); 643 644 Invalidate( SID_OUTLINE_FORMAT ); 645 Invalidate( SID_COLORVIEW ); 646 Invalidate(SID_CUT); 647 Invalidate(SID_COPY); 648 Invalidate(SID_PASTE); 649 } 650 651 652 } // end of namespace sd 653