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