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 "ViewShellImplementation.hxx" 30 #include <memory> 31 #include "helpids.h" 32 #include "app.hrc" 33 #include <svx/hyprlink.hxx> 34 #include <svx/hyperdlg.hxx> 35 #include <svx/zoomslideritem.hxx> 36 37 #include <sfx2/objface.hxx> 38 #include <sot/exchange.hxx> 39 #include <svx/ruler.hxx> 40 #include <svx/zoomitem.hxx> 41 #include <editeng/eeitem.hxx> 42 #include <editeng/flditem.hxx> 43 #include <sfx2/shell.hxx> 44 #include <sfx2/templdlg.hxx> 45 #include <sfx2/viewfac.hxx> 46 #include <sfx2/request.hxx> 47 #include <svx/hlnkitem.hxx> 48 #include <svx/svdotext.hxx> 49 #include <sfx2/dispatch.hxx> 50 #include <vcl/scrbar.hxx> 51 #include <svl/whiter.hxx> 52 #include <editeng/editstat.hxx> 53 #include <svl/itempool.hxx> 54 #include <sfx2/tplpitem.hxx> 55 #include <sfx2/sidebar/SidebarChildWindow.hxx> 56 #include <sfx2/sidebar/EnumContext.hxx> 57 #include <svx/svdorect.hxx> 58 #include <sot/formats.hxx> 59 #include <com/sun/star/linguistic2/XThesaurus.hpp> 60 #include <com/sun/star/i18n/TransliterationModules.hpp> 61 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp> 62 #include <editeng/unolingu.hxx> 63 #include <comphelper/processfactory.hxx> 64 #include <editeng/outlobj.hxx> 65 #include <svl/cjkoptions.hxx> 66 #include <svtools/cliplistener.hxx> 67 #include <svl/srchitem.hxx> 68 #include <editeng/editobj.hxx> 69 #include "fubullet.hxx" 70 #include "optsitem.hxx" 71 72 #include "strings.hrc" 73 #include "glob.hrc" 74 #include "res_bmp.hrc" 75 #include "Outliner.hxx" 76 #include "Window.hxx" 77 #include "TextObjectBar.hxx" 78 #include "drawdoc.hxx" 79 #include "sdresid.hxx" 80 #include "sdpage.hxx" 81 #include "fuoltext.hxx" 82 #include "FrameView.hxx" 83 #include "zoomlist.hxx" 84 #include "stlsheet.hxx" 85 #include "slideshow.hxx" 86 #include "SdUnoOutlineView.hxx" 87 #include "SpellDialogChildWindow.hxx" 88 89 #include "AccessibleOutlineView.hxx" 90 #include "ViewShellBase.hxx" 91 #include "ViewShellManager.hxx" 92 #include "DrawController.hxx" 93 #include "framework/FrameworkHelper.hxx" 94 95 using ::rtl::OUString; 96 using namespace ::com::sun::star; 97 using namespace ::com::sun::star::uno; 98 using namespace ::com::sun::star::lang; 99 using namespace ::com::sun::star::linguistic2; 100 101 using namespace sd; 102 #define OutlineViewShell 103 #include "sdslots.hxx" 104 105 namespace sd { 106 107 #define MIN_ZOOM 10 // Minimaler Zoomfaktor 108 #define MAX_ZOOM 1000 // Maximaler Zoomfaktor 109 110 /************************************************************************/ 111 112 113 /************************************************************************* 114 |* 115 |* SFX-Slotmap und Standardinterface deklarieren 116 |* 117 \************************************************************************/ 118 119 120 SFX_IMPL_INTERFACE(OutlineViewShell, SfxShell, SdResId(STR_OUTLINEVIEWSHELL)) 121 { 122 SFX_POPUPMENU_REGISTRATION( SdResId(RID_OUTLINE_POPUP) ); 123 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS | SFX_VISIBILITY_STANDARD | 124 SFX_VISIBILITY_FULLSCREEN | SFX_VISIBILITY_SERVER, 125 SdResId(RID_OUTLINE_TOOLBOX) ); 126 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION | SFX_VISIBILITY_DESKTOP | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_CLIENT | SFX_VISIBILITY_VIEWER | SFX_VISIBILITY_READONLYDOC, 127 SdResId(RID_DRAW_VIEWER_TOOLBOX) ); 128 SFX_CHILDWINDOW_REGISTRATION( SfxTemplateDialogWrapper::GetChildWindowId() ); 129 SFX_CHILDWINDOW_REGISTRATION( SvxHyperlinkDlgWrapper::GetChildWindowId() ); 130 SFX_CHILDWINDOW_REGISTRATION( SvxHlinkDlgWrapper::GetChildWindowId() ); 131 SFX_CHILDWINDOW_REGISTRATION( ::sd::SpellDialogChildWindow::GetChildWindowId() ); 132 SFX_CHILDWINDOW_REGISTRATION( SID_SEARCH_DLG ); 133 SFX_CHILDWINDOW_REGISTRATION(::sfx2::sidebar::SidebarChildWindow::GetChildWindowId()); 134 } 135 136 137 TYPEINIT1( OutlineViewShell, ViewShell ); 138 139 140 /************************************************************************* 141 |* 142 |* gemeinsamer Initialiserungsanteil der beiden Konstruktoren 143 |* 144 \************************************************************************/ 145 146 void OutlineViewShell::Construct(DrawDocShell* ) 147 { 148 sal_Bool bModified = GetDoc()->IsChanged(); 149 150 meShellType = ST_OUTLINE; 151 Size aSize(29700, 21000); 152 Point aWinPos (0, 0); 153 Point aViewOrigin(0, 0); 154 GetActiveWindow()->SetMinZoomAutoCalc(sal_False); 155 GetActiveWindow()->SetMinZoom( MIN_ZOOM ); 156 GetActiveWindow()->SetMaxZoom( MAX_ZOOM ); 157 InitWindows(aViewOrigin, aSize, aWinPos); 158 pOlView = new OutlineView(GetDocSh(), GetActiveWindow(), this); 159 mpView = pOlView; // Pointer der Basisklasse ViewShell 160 161 SetPool( &GetDoc()->GetPool() ); 162 163 SetZoom(69); 164 165 // Einstellungen der FrameView uebernehmen 166 ReadFrameViewData(mpFrameView); 167 168 ::Outliner* pOutl = pOlView->GetOutliner(); 169 pOutl->SetUpdateMode(sal_True); 170 171 if (!bModified) 172 { 173 pOutl->ClearModifyFlag(); 174 } 175 176 pLastPage = GetActualPage(); 177 178 String aName( RTL_CONSTASCII_USTRINGPARAM( "OutlineViewShell" )); 179 SetName (aName); 180 181 SetHelpId( SD_IF_SDOUTLINEVIEWSHELL ); 182 GetActiveWindow()->SetHelpId( HID_SDOUTLINEVIEWSHELL ); 183 GetActiveWindow()->SetUniqueId( HID_SDOUTLINEVIEWSHELL ); 184 } 185 186 187 188 189 Reference<drawing::XDrawSubController> OutlineViewShell::CreateSubController (void) 190 { 191 Reference<drawing::XDrawSubController> xSubController; 192 193 if (IsMainViewShell()) 194 { 195 // Create uno sub controller for the main view shell. 196 xSubController = Reference<drawing::XDrawSubController>( 197 new SdUnoOutlineView ( 198 GetViewShellBase().GetDrawController(), 199 *this, 200 *GetView())); 201 } 202 203 return xSubController; 204 } 205 206 207 208 209 /************************************************************************* 210 |* 211 |* Standard-Konstruktor, Fenster duerfen nicht automatisch zentrieren 212 |* 213 \************************************************************************/ 214 215 OutlineViewShell::OutlineViewShell ( 216 SfxViewFrame* pFrame, 217 ViewShellBase& rViewShellBase, 218 ::Window* pParentWindow, 219 FrameView* pFrameViewArgument) 220 : ViewShell(pFrame, pParentWindow, rViewShellBase), 221 pOlView(NULL), 222 pLastPage( NULL ), 223 pClipEvtLstnr(NULL), 224 bPastePossible(false), 225 mbInitialized(false) 226 227 { 228 if (pFrameViewArgument != NULL) 229 mpFrameView = pFrameViewArgument; 230 else 231 mpFrameView = new FrameView(GetDoc()); 232 233 mpFrameView->Connect(); 234 235 Construct(GetDocSh()); 236 237 SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_OutlineText)); 238 } 239 240 /************************************************************************* 241 |* 242 |* Destruktor 243 |* 244 \************************************************************************/ 245 246 OutlineViewShell::~OutlineViewShell() 247 { 248 DisposeFunctions(); 249 250 delete pOlView; 251 252 mpFrameView->Disconnect(); 253 254 if ( pClipEvtLstnr ) 255 { 256 pClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_False ); 257 pClipEvtLstnr->ClearCallbackLink(); // #103849# prevent callback if another thread is waiting 258 pClipEvtLstnr->release(); 259 } 260 } 261 262 263 264 265 void OutlineViewShell::Shutdown (void) 266 { 267 ViewShell::Shutdown(); 268 269 PrepareClose(); 270 } 271 272 273 274 275 /************************************************************************* 276 |* 277 |* Paint-Methode: das Ereignis wird vom Fenster pWindow an 278 |* die Viewshell und die aktuelle Funktion weitergeleitet 279 |* 280 \************************************************************************/ 281 282 void OutlineViewShell::Paint(const Rectangle& rRect, ::sd::Window* pWin) 283 { 284 if (pOlView) 285 { 286 pOlView->Paint(rRect, pWin); 287 } 288 289 if(HasCurrentFunction()) 290 { 291 GetCurrentFunction()->Paint(rRect, pWin); 292 } 293 } 294 295 void OutlineViewShell::ArrangeGUIElements () 296 { 297 // Retrieve the current size (thickness) of the scroll bars. That is 298 // the width of the vertical and the height of the horizontal scroll 299 // bar. 300 int nScrollBarSize = 301 GetParentWindow()->GetSettings().GetStyleSettings().GetScrollBarSize(); 302 maScrBarWH = Size (nScrollBarSize, nScrollBarSize); 303 304 ViewShell::ArrangeGUIElements (); 305 306 ::sd::Window* pWindow = mpContentWindow.get(); 307 if (pWindow != NULL) 308 { 309 pWindow->SetMinZoomAutoCalc(sal_False); 310 311 // pWindow->SetPosSizePixel(rNewPos, Size(nSizeX, nSizeY)); 312 313 // OutputArea der OutlinerView aendern 314 OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow); 315 316 Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel()); 317 // aWin.nLeft = pOlView->GetPageNumberWidthPixel(); 318 319 aWin = pWindow->PixelToLogic(aWin); 320 pOutlinerView->SetOutputArea(aWin); 321 322 Rectangle aVis = pOutlinerView->GetVisArea(); 323 324 Rectangle aText = Rectangle(Point(0,0), 325 Size(pOlView->GetPaperWidth(), 326 pOlView->GetOutliner()->GetTextHeight())); 327 aText.Bottom() += aWin.GetHeight(); 328 329 if (!aWin.IsEmpty()) // nicht beim Oeffnen 330 { 331 InitWindows(Point(0,0), aText.GetSize(), Point(aVis.TopLeft())); 332 UpdateScrollBars(); 333 } 334 } 335 } 336 337 /************************************************************************* 338 |* 339 |* SfxRequests fuer Controller bearbeiten 340 |* 341 \************************************************************************/ 342 343 void OutlineViewShell::ExecCtrl(SfxRequest &rReq) 344 { 345 sal_uInt16 nSlot = rReq.GetSlot(); 346 switch ( nSlot ) 347 { 348 case SID_MAIL_SCROLLBODY_PAGEDOWN: 349 { 350 ExecReq( rReq ); 351 break; 352 } 353 354 case SID_OPT_LOCALE_CHANGED: 355 { 356 pOlView->GetOutliner()->UpdateFields(); 357 UpdatePreview( GetActualPage() ); 358 rReq.Done(); 359 break; 360 } 361 362 default: 363 break; 364 } 365 } 366 367 368 369 370 void OutlineViewShell::AddWindow (::sd::Window* pWin) 371 { 372 pOlView->AddWindowToPaintView(pWin); 373 } 374 375 376 377 378 void OutlineViewShell::RemoveWindow (::sd::Window* pWin) 379 { 380 pOlView->DeleteWindowFromPaintView(pWin); 381 } 382 383 384 385 386 /************************************************************************* 387 |* 388 |* Activate(), beim ersten Aufruf erfolgt ein Update der Felder 389 |* 390 \************************************************************************/ 391 void OutlineViewShell::Activate( sal_Bool bIsMDIActivate ) 392 { 393 if ( ! mbInitialized) 394 { 395 mbInitialized = true; 396 SfxRequest aRequest (SID_EDIT_OUTLINER, 0, GetDoc()->GetItemPool()); 397 FuPermanent (aRequest); 398 } 399 400 ViewShell::Activate( bIsMDIActivate ); 401 SfxShell::BroadcastContextForActivation(true); 402 403 pOlView->SetLinks(); 404 pOlView->ConnectToApplication(); 405 406 if( bIsMDIActivate ) 407 { 408 OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() ); 409 ::Outliner* pOutl = pOutlinerView->GetOutliner(); 410 pOutl->UpdateFields(); 411 } 412 } 413 414 /************************************************************************* 415 |* 416 |* Deactivate() 417 |* 418 \************************************************************************/ 419 void OutlineViewShell::Deactivate( sal_Bool bIsMDIActivate ) 420 { 421 pOlView->DisconnectFromApplication(); 422 423 // #96416# Links must be kept also on deactivated viewshell, to allow drag'n'drop 424 // to function properly 425 // pOlView->ResetLinks(); 426 427 ViewShell::Deactivate( bIsMDIActivate ); 428 } 429 430 /************************************************************************* 431 |* 432 |* Status von Controller-SfxSlots setzen 433 |* 434 \************************************************************************/ 435 void OutlineViewShell::GetCtrlState(SfxItemSet &rSet) 436 { 437 if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_HYPERLINK_GETLINK)) 438 { 439 SvxHyperlinkItem aHLinkItem; 440 441 OutlinerView* pOLV = pOlView->GetViewByWindow(GetActiveWindow()); 442 if (pOLV) 443 { 444 const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection(); 445 if (pFieldItem) 446 { 447 ESelection aSel = pOLV->GetSelection(); 448 if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 ) 449 { 450 const SvxFieldData* pField = pFieldItem->GetField(); 451 if ( pField->ISA(SvxURLField) ) 452 { 453 aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation()); 454 aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL()); 455 aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame()); 456 } 457 } 458 } 459 } 460 rSet.Put(aHLinkItem); 461 } 462 rSet.Put( SfxBoolItem( SID_READONLY_MODE, GetDocSh()->IsReadOnly() ) ); 463 464 if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) ) 465 rSet.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, sal_True ) ); 466 467 if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_HALFWIDTH) || 468 SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_FULLWIDTH) || 469 SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_HIRAGANA) || 470 SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_KATAGANA) ) 471 { 472 SvtCJKOptions aCJKOptions; 473 if( !aCJKOptions.IsChangeCaseMapEnabled() ) 474 { 475 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_False ); 476 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_False ); 477 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_False ); 478 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_False ); 479 rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH ); 480 rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH ); 481 rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA ); 482 rSet.DisableItem( SID_TRANSLITERATE_KATAGANA ); 483 } 484 else 485 { 486 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_True ); 487 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_True ); 488 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_True ); 489 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_True ); 490 } 491 } 492 } 493 494 /************************************************************************* 495 |* 496 |* SfxRequests fuer Support-Funktionen 497 |* 498 \************************************************************************/ 499 500 void OutlineViewShell::FuSupport(SfxRequest &rReq) 501 { 502 if( rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs()) 503 GetDocSh()->SetStyleFamily(((SfxUInt16Item&)rReq.GetArgs()->Get( SID_STYLE_FAMILY )).GetValue()); 504 505 sal_Bool bPreviewState = sal_False; 506 sal_uLong nSlot = rReq.GetSlot(); 507 508 std::auto_ptr< OutlineViewModelChangeGuard > aGuard; 509 if( pOlView && ( 510 (nSlot == SID_TRANSLITERATE_SENTENCE_CASE) || 511 (nSlot == SID_TRANSLITERATE_TITLE_CASE) || 512 (nSlot == SID_TRANSLITERATE_TOGGLE_CASE) || 513 (nSlot == SID_TRANSLITERATE_UPPER) || 514 (nSlot == SID_TRANSLITERATE_LOWER) || 515 (nSlot == SID_TRANSLITERATE_HALFWIDTH) || 516 (nSlot == SID_TRANSLITERATE_FULLWIDTH) || 517 (nSlot == SID_TRANSLITERATE_HIRAGANA) || 518 (nSlot == SID_TRANSLITERATE_KATAGANA) || 519 (nSlot == SID_CUT) || 520 // (nSlot == SID_COPY) || 521 (nSlot == SID_PASTE) || 522 (nSlot == SID_DELETE))) 523 { 524 aGuard.reset( new OutlineViewModelChangeGuard( *pOlView ) ); 525 } 526 527 switch ( nSlot ) 528 { 529 case SID_CUT: 530 { 531 if(HasCurrentFunction()) 532 { 533 GetCurrentFunction()->DoCut(); 534 } 535 else if (pOlView) 536 { 537 pOlView->DoCut(); 538 } 539 rReq.Done(); 540 bPreviewState = sal_True; 541 } 542 break; 543 544 case SID_COPY: 545 { 546 if(HasCurrentFunction()) 547 { 548 GetCurrentFunction()->DoCopy(); 549 } 550 else if (pOlView) 551 { 552 pOlView->DoCopy(); 553 } 554 rReq.Done(); 555 bPreviewState = sal_True; 556 } 557 break; 558 559 case SID_PASTE: 560 { 561 OutlineViewPageChangesGuard aGuard2(pOlView); 562 563 if(HasCurrentFunction()) 564 { 565 GetCurrentFunction()->DoPaste(); 566 } 567 else if (pOlView) 568 { 569 pOlView->DoPaste(); 570 } 571 rReq.Done(); 572 bPreviewState = sal_True; 573 } 574 break; 575 576 case SID_DELETE: 577 { 578 if( pOlView ) 579 { 580 OutlinerView* pOutlView = pOlView->GetViewByWindow(GetActiveWindow()); 581 if (pOutlView) 582 { 583 OutlineViewPageChangesGuard aGuard2(pOlView); 584 585 KeyCode aKCode(KEY_DELETE); 586 KeyEvent aKEvt( 0, aKCode ); 587 pOutlView->PostKeyEvent(aKEvt); 588 589 FunctionReference xFunc( GetCurrentFunction() ); 590 FuOutlineText* pFuOutlineText = dynamic_cast< FuOutlineText* >( xFunc.get() ); 591 if( pFuOutlineText ) 592 pFuOutlineText->UpdateForKeyPress (aKEvt); 593 } 594 } 595 rReq.Done(); 596 bPreviewState = sal_True; 597 } 598 break; 599 600 case SID_DRAWINGMODE: 601 case SID_NOTESMODE: 602 case SID_HANDOUTMODE: 603 case SID_DIAMODE: 604 case SID_OUTLINEMODE: 605 framework::FrameworkHelper::Instance(GetViewShellBase())->HandleModeChangeSlot( 606 nSlot, 607 rReq); 608 rReq.Done(); 609 break; 610 611 case SID_RULER: 612 SetRuler( !HasRuler() ); 613 Invalidate( SID_RULER ); 614 rReq.Done(); 615 break; 616 617 case SID_ZOOM_PREV: 618 { 619 if (mpZoomList->IsPreviousPossible()) 620 { 621 // Vorheriges ZoomRect einstellen 622 SetZoomRect(mpZoomList->GetPreviousZoomRect()); 623 } 624 rReq.Done (); 625 } 626 break; 627 628 case SID_ZOOM_NEXT: 629 { 630 if (mpZoomList->IsNextPossible()) 631 { 632 // Naechstes ZoomRect einstellen 633 SetZoomRect(mpZoomList->GetNextZoomRect()); 634 } 635 rReq.Done (); 636 } 637 break; 638 639 case SID_AUTOSPELL_CHECK: 640 { 641 GetDoc()->SetOnlineSpell(!GetDoc()->GetOnlineSpell()); 642 rReq.Done (); 643 } 644 break; 645 646 case SID_TRANSLITERATE_SENTENCE_CASE: 647 case SID_TRANSLITERATE_TITLE_CASE: 648 case SID_TRANSLITERATE_TOGGLE_CASE: 649 case SID_TRANSLITERATE_UPPER: 650 case SID_TRANSLITERATE_LOWER: 651 case SID_TRANSLITERATE_HALFWIDTH: 652 case SID_TRANSLITERATE_FULLWIDTH: 653 case SID_TRANSLITERATE_HIRAGANA: 654 case SID_TRANSLITERATE_KATAGANA: 655 { 656 OutlinerView* pOLV = pOlView->GetViewByWindow( GetActiveWindow() ); 657 if( pOLV ) 658 { 659 using namespace ::com::sun::star::i18n; 660 sal_Int32 nType = 0; 661 662 switch( nSlot ) 663 { 664 case SID_TRANSLITERATE_SENTENCE_CASE: 665 nType = TransliterationModulesExtra::SENTENCE_CASE; 666 break; 667 case SID_TRANSLITERATE_TITLE_CASE: 668 nType = TransliterationModulesExtra::TITLE_CASE; 669 break; 670 case SID_TRANSLITERATE_TOGGLE_CASE: 671 nType = TransliterationModulesExtra::TOGGLE_CASE; 672 break; 673 case SID_TRANSLITERATE_UPPER: 674 nType = TransliterationModules_LOWERCASE_UPPERCASE; 675 break; 676 case SID_TRANSLITERATE_LOWER: 677 nType = TransliterationModules_UPPERCASE_LOWERCASE; 678 break; 679 case SID_TRANSLITERATE_HALFWIDTH: 680 nType = TransliterationModules_FULLWIDTH_HALFWIDTH; 681 break; 682 case SID_TRANSLITERATE_FULLWIDTH: 683 nType = TransliterationModules_HALFWIDTH_FULLWIDTH; 684 break; 685 case SID_TRANSLITERATE_HIRAGANA: 686 nType = TransliterationModules_KATAKANA_HIRAGANA; 687 break; 688 case SID_TRANSLITERATE_KATAGANA: 689 nType = TransliterationModules_HIRAGANA_KATAKANA; 690 break; 691 } 692 693 pOLV->TransliterateText( nType ); 694 } 695 696 rReq.Done(); 697 bPreviewState = sal_True; 698 } 699 break; 700 701 // #96090# added Undo/Redo handling 702 case SID_UNDO : 703 { 704 OutlineViewPageChangesGuard aGuard2(pOlView); 705 ImpSidUndo(sal_False, rReq); 706 } 707 break; 708 case SID_REDO : 709 { 710 OutlineViewPageChangesGuard aGuard2(pOlView); 711 ImpSidRedo(sal_False, rReq); 712 } 713 break; 714 715 default: 716 break; 717 } 718 719 if( bPreviewState ) 720 Invalidate( SID_PREVIEW_STATE ); 721 722 Invalidate(SID_CUT); 723 Invalidate(SID_COPY); 724 Invalidate(SID_PASTE); 725 } 726 727 /************************************************************************* 728 |* 729 |* SfxRequests fuer permanente Funktionen 730 |* 731 \************************************************************************/ 732 733 void OutlineViewShell::FuPermanent(SfxRequest &rReq) 734 { 735 if(HasCurrentFunction()) 736 { 737 DeactivateCurrentFunction(true); 738 } 739 740 switch ( rReq.GetSlot() ) 741 { 742 case SID_EDIT_OUTLINER: 743 { 744 ::Outliner* pOutl = pOlView->GetOutliner(); 745 if( pOutl ) 746 { 747 pOutl->GetUndoManager().Clear(); 748 pOutl->UpdateFields(); 749 } 750 751 SetCurrentFunction( FuOutlineText::Create(this,GetActiveWindow(),pOlView,GetDoc(),rReq) ); 752 753 rReq.Done(); 754 } 755 break; 756 757 default: 758 break; 759 } 760 761 if(HasOldFunction()) 762 { 763 GetOldFunction()->Deactivate(); 764 SetOldFunction(0); 765 } 766 767 if(HasCurrentFunction()) 768 { 769 GetCurrentFunction()->Activate(); 770 SetOldFunction(GetCurrentFunction()); 771 } 772 } 773 774 775 IMPL_LINK( OutlineViewShell, ClipboardChanged, TransferableDataHelper*, pDataHelper ) 776 { 777 if ( pDataHelper ) 778 { 779 bPastePossible = ( pDataHelper->GetFormatCount() != 0 && 780 ( pDataHelper->HasFormat( FORMAT_STRING ) || 781 pDataHelper->HasFormat( FORMAT_RTF ) || 782 pDataHelper->HasFormat( SOT_FORMATSTR_ID_HTML ) ) ); 783 784 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 785 rBindings.Invalidate( SID_PASTE ); 786 rBindings.Invalidate( SID_PASTE_SPECIAL ); 787 rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); 788 } 789 return 0; 790 } 791 792 /************************************************************************* 793 |* 794 |* Status (Enabled/Disabled) von Menue-SfxSlots setzen 795 |* 796 \************************************************************************/ 797 798 void OutlineViewShell::GetMenuState( SfxItemSet &rSet ) 799 { 800 ViewShell::GetMenuState(rSet); 801 802 // Vorlagenkatalog darf nicht aufgerufen werden 803 rSet.DisableItem( SID_STYLE_CATALOG ); 804 805 rSet.Put(SfxBoolItem(SID_DIAMODE, sal_False)); 806 rSet.Put(SfxBoolItem(SID_DRAWINGMODE, sal_False)); 807 rSet.Put(SfxBoolItem(SID_OUTLINEMODE, sal_True)); 808 rSet.Put(SfxBoolItem(SID_NOTESMODE, sal_False)); 809 rSet.Put(SfxBoolItem(SID_HANDOUTMODE, sal_False)); 810 811 if (!mpZoomList->IsNextPossible()) 812 { 813 rSet.DisableItem(SID_ZOOM_NEXT); 814 } 815 if (!mpZoomList->IsPreviousPossible()) 816 { 817 rSet.DisableItem(SID_ZOOM_PREV); 818 } 819 820 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_IN ) || 821 SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_OUT ) ) 822 { 823 if( GetActiveWindow()->GetZoom() <= GetActiveWindow()->GetMinZoom() || GetDocSh()->IsUIActive() ) 824 rSet.DisableItem( SID_ZOOM_IN ); 825 if( GetActiveWindow()->GetZoom() >= GetActiveWindow()->GetMaxZoom() || GetDocSh()->IsUIActive() ) 826 rSet.DisableItem( SID_ZOOM_OUT ); 827 } 828 829 ::Outliner* pOutl = pOlView->GetOutliner(); 830 DBG_ASSERT(pOutl, "OutlineViewShell::GetMenuState(), no outliner? Fatality!"); 831 if( !pOutl ) 832 return; 833 834 // 'Alles auswaehlen' zulassen? 835 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_SELECTALL ) ) 836 { 837 sal_uLong nParaCount = pOutl->GetParagraphCount(); 838 sal_Bool bDisable = nParaCount == 0; 839 if (!bDisable && nParaCount == 1) 840 { 841 String aTest( pOutl->GetText( pOutl->GetParagraph( 0 ) ) ); 842 if (aTest.Len() == 0) 843 { 844 bDisable = sal_True; 845 } 846 } 847 if (bDisable) 848 rSet.DisableItem(SID_SELECTALL); 849 } 850 851 // Status des Lineals setzen 852 rSet.Put( SfxBoolItem( SID_RULER, HasRuler() ) ); 853 854 // Formatierung ein oder aus? 855 rSet.Put( SfxBoolItem( SID_OUTLINE_FORMAT, !pOutl->IsFlatMode() ) ); 856 857 if( pOutl->IsFlatMode() ) 858 rSet.DisableItem( SID_COLORVIEW ); 859 else 860 { 861 // Farbansicht ein/aus 862 sal_uLong nCntrl = pOutl->GetControlWord(); 863 sal_Bool bNoColor = sal_False; 864 if (nCntrl & EE_CNTRL_NOCOLORS) 865 bNoColor = sal_True; 866 867 rSet.Put( SfxBoolItem( SID_COLORVIEW, bNoColor ) ); 868 } 869 870 // Buttons der Werkzeugleiste 871 // zunaechst selektionsabhaengige: COLLAPSE, EXPAND 872 sal_Bool bDisableCollapse = sal_True; 873 sal_Bool bDisableExpand = sal_True; 874 sal_Bool bUnique = sal_True; 875 OutlinerView* pOutlinerView = pOlView->GetViewByWindow(GetActiveWindow()); 876 List* pList = pOutlinerView->CreateSelectionList(); 877 Paragraph* pPara = (Paragraph*)pList->First(); 878 879 sal_Int16 nDepth; 880 sal_Int16 nTmpDepth = pOutl->GetDepth( (sal_uInt16) pOutl->GetAbsPos( pPara ) ); 881 bool bPage = pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ); 882 while (pPara) 883 { 884 nDepth = pOutl->GetDepth( (sal_uInt16) pOutl->GetAbsPos( pPara ) ); 885 886 if( nDepth != nTmpDepth ) 887 bUnique = sal_False; 888 if( bPage != pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) ) 889 bUnique = sal_False; 890 if (!pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara)) 891 bDisableExpand = sal_False; 892 if (pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara)) 893 bDisableCollapse = sal_False; 894 895 pPara = (Paragraph*)pList->Next(); 896 } 897 898 delete pList; 899 900 if (bDisableExpand) 901 rSet.DisableItem(SID_OUTLINE_EXPAND); 902 if (bDisableCollapse) 903 rSet.DisableItem(SID_OUTLINE_COLLAPSE); 904 905 // ergibt die Selektion ein eindeutiges Praesentationslayout? 906 // wenn nicht, duerfen die Vorlagen nicht bearbeitet werden 907 SfxItemSet aSet(*rSet.GetPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT); 908 GetStatusBarState(aSet); 909 String aTest(((SfxStringItem&)aSet.Get(SID_STATUS_LAYOUT)).GetValue()); 910 if (aTest.Len() == 0) 911 { 912 bUnique = sal_False; 913 rSet.DisableItem(SID_PRESENTATION_TEMPLATES); 914 } 915 916 if (!bUnique) 917 rSet.DisableItem( SID_PRESENTATIONOBJECT ); 918 919 // jetzt die selektionsunabhaengigen: COLLAPSE_ALL, EXPAND_ALL 920 sal_Bool bDisableCollapseAll = sal_True; 921 sal_Bool bDisableExpandAll = sal_True; 922 923 // wenn schon die Selektion etwas kollabierbares/expandierbares enthaelt 924 if (!bDisableCollapse) 925 bDisableCollapseAll = sal_False; 926 if (!bDisableExpand) 927 bDisableExpandAll = sal_False; 928 929 // schade, so billig kommen wir nicht davon; alle Absaetze durchsuchen 930 if (bDisableCollapseAll || bDisableExpandAll) 931 { 932 sal_uLong nParaPos = 0; 933 pPara = pOutl->GetParagraph( nParaPos ); 934 while (pPara && (bDisableCollapseAll || bDisableExpandAll)) 935 { 936 if (!pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara)) 937 bDisableExpandAll = sal_False; 938 939 if (pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara)) 940 bDisableCollapseAll = sal_False; 941 942 pPara = pOutl->GetParagraph( ++nParaPos ); 943 } 944 } 945 946 if (bDisableExpandAll) 947 rSet.DisableItem(SID_OUTLINE_EXPAND_ALL); 948 if (bDisableCollapseAll) 949 rSet.DisableItem(SID_OUTLINE_COLLAPSE_ALL); 950 951 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PASTE ) ) 952 { 953 if ( !pClipEvtLstnr ) 954 { 955 // create listener 956 pClipEvtLstnr = new TransferableClipboardListener( LINK( this, OutlineViewShell, ClipboardChanged ) ); 957 pClipEvtLstnr->acquire(); 958 pClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_True ); 959 960 // get initial state 961 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) ); 962 bPastePossible = ( aDataHelper.GetFormatCount() != 0 && 963 ( aDataHelper.HasFormat( FORMAT_STRING ) || 964 aDataHelper.HasFormat( FORMAT_RTF ) || 965 aDataHelper.HasFormat( SOT_FORMATSTR_ID_HTML ) ) ); 966 } 967 968 if( !bPastePossible ) 969 { 970 rSet.DisableItem( SID_PASTE ); 971 } 972 } 973 974 if (!pOlView->GetViewByWindow(GetActiveWindow())->HasSelection()) 975 { 976 rSet.DisableItem(SID_CUT); 977 rSet.DisableItem(SID_COPY); 978 } 979 980 if (pOlView->GetOutliner()->IsModified()) 981 { 982 GetDoc()->SetChanged(sal_True); 983 } 984 985 // Da �berladen, muss hier der Status gesetzt werden 986 if( !GetDocSh()->IsModified() ) 987 { 988 rSet.DisableItem( SID_SAVEDOC ); 989 } 990 991 if ( GetDocSh()->IsReadOnly() ) 992 { 993 rSet.DisableItem( SID_AUTOSPELL_CHECK ); 994 } 995 else 996 { 997 if (GetDoc()->GetOnlineSpell()) 998 { 999 rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, sal_True)); 1000 } 1001 else 1002 { 1003 rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, sal_False)); 1004 } 1005 } 1006 1007 // Feldbefehle 1008 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_MODIFY_FIELD ) ) 1009 { 1010 const SvxFieldItem* pFldItem = pOutlinerView->GetFieldAtSelection(); 1011 1012 if( !( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) || 1013 pFldItem->GetField()->ISA( SvxAuthorField ) || 1014 pFldItem->GetField()->ISA( SvxExtFileField ) || 1015 pFldItem->GetField()->ISA( SvxExtTimeField ) ) ) ) 1016 { 1017 rSet.DisableItem( SID_MODIFY_FIELD ); 1018 } 1019 } 1020 1021 if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_EXPAND_PAGE)) 1022 { 1023 sal_Bool bDisable = sal_True; 1024 sal_uInt16 i = 0; 1025 sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD); 1026 pOlView->SetSelectedPages(); 1027 1028 while (i < nCount && bDisable) 1029 { 1030 SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD); 1031 1032 if (pPage->IsSelected()) 1033 { 1034 SdrObject* pObj = pPage->GetPresObj(PRESOBJ_OUTLINE); 1035 1036 if (pObj!=NULL ) 1037 { 1038 if( !pObj->IsEmptyPresObj() ) 1039 { 1040 bDisable = false; 1041 } 1042 else 1043 { 1044 // check if the object is in edit, than its temporarely not empty 1045 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj ); 1046 if( pTextObj ) 1047 { 1048 OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject(); 1049 if( pParaObj ) 1050 { 1051 delete pParaObj; 1052 bDisable = false; 1053 } 1054 } 1055 } 1056 } 1057 } 1058 1059 i++; 1060 } 1061 1062 if (bDisable) 1063 { 1064 rSet.DisableItem(SID_EXPAND_PAGE); 1065 } 1066 } 1067 1068 if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_SUMMARY_PAGE)) 1069 { 1070 sal_Bool bDisable = sal_True; 1071 sal_uInt16 i = 0; 1072 sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD); 1073 pOlView->SetSelectedPages(); 1074 1075 while (i < nCount && bDisable) 1076 { 1077 SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD); 1078 1079 if (pPage->IsSelected()) 1080 { 1081 SdrObject* pObj = pPage->GetPresObj(PRESOBJ_TITLE); 1082 1083 if (pObj && !pObj->IsEmptyPresObj()) 1084 { 1085 bDisable = sal_False; 1086 } 1087 } 1088 1089 i++; 1090 } 1091 1092 if (bDisable) 1093 { 1094 rSet.DisableItem(SID_SUMMARY_PAGE); 1095 } 1096 } 1097 1098 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_THESAURUS ) ) 1099 { 1100 if ( !pOlView->IsTextEdit() ) 1101 { 1102 rSet.DisableItem( SID_THESAURUS ); 1103 } 1104 else 1105 { 1106 LanguageType eLang = GetDoc()->GetLanguage( EE_CHAR_LANGUAGE ); 1107 Reference< XThesaurus > xThesaurus( LinguMgr::GetThesaurus() ); 1108 Locale aLocale; 1109 1110 SvxLanguageToLocale( aLocale, eLang ); 1111 1112 if (!xThesaurus.is() || eLang == LANGUAGE_NONE || !xThesaurus->hasLocale(aLocale)) 1113 rSet.DisableItem( SID_THESAURUS ); 1114 } 1115 } 1116 1117 // Starten der Praesentation moeglich? 1118 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PRESENTATION ) ) 1119 { 1120 sal_Bool bDisable = sal_True; 1121 sal_uInt16 nCount = GetDoc()->GetSdPageCount( PK_STANDARD ); 1122 1123 for( sal_uInt16 i = 0; i < nCount && bDisable; i++ ) 1124 { 1125 SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD); 1126 1127 if( !pPage->IsExcluded() ) 1128 bDisable = sal_False; 1129 } 1130 if( bDisable || GetDocSh()->IsPreview()) 1131 { 1132 rSet.DisableItem( SID_PRESENTATION ); 1133 } 1134 } 1135 1136 FuBullet::GetSlotState( rSet, this, GetViewFrame() ); 1137 1138 //rSet.DisableItem( SID_PRINTDOC ); 1139 //rSet.DisableItem( SID_PRINTDOCDIRECT ); 1140 //rSet.DisableItem( SID_SETUPPRINTER ); 1141 } 1142 1143 /************************************************************************* 1144 |* 1145 |* wird gerufen, wenn ScrollBar benutzt wird 1146 |* 1147 \************************************************************************/ 1148 1149 long OutlineViewShell::VirtHScrollHdl(ScrollBar* pHScroll) 1150 { 1151 long nThumb = pHScroll->GetThumbPos(); 1152 long nRange = pHScroll->GetRange().Len(); 1153 double fX = (double) nThumb / nRange; 1154 1155 Window* pWin = mpContentWindow.get(); 1156 OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWin); 1157 long nViewWidth = pWin->PixelToLogic( 1158 pWin->GetSizePixel()).Width(); 1159 long nTextWidth = pOlView->GetPaperWidth(); 1160 nViewWidth = Max(nViewWidth, nTextWidth); 1161 long nCurrentPos = pOutlinerView->GetVisArea().Left(); 1162 long nTargetPos = (long)(fX * nViewWidth); 1163 long nDelta = nTargetPos - nCurrentPos; 1164 1165 pOutlinerView->HideCursor(); 1166 pOutlinerView->Scroll(-nDelta, 0); 1167 pOutlinerView->ShowCursor(sal_False); 1168 1169 pOlView->InvalidateSlideNumberArea(); 1170 return 0; 1171 } 1172 1173 /************************************************************************* 1174 |* 1175 |* wird gerufen, wenn ScrollBar benutzt wird 1176 |* 1177 \************************************************************************/ 1178 1179 long OutlineViewShell::VirtVScrollHdl(ScrollBar* pVScroll) 1180 { 1181 long nThumb = pVScroll->GetThumbPos(); 1182 long nRange = pVScroll->GetRange().Len(); 1183 double fY = (double) nThumb / nRange; 1184 1185 Window* pWin = mpContentWindow.get(); 1186 OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWin); 1187 long nViewHeight = pWin->PixelToLogic( 1188 pWin->GetSizePixel()).Height(); 1189 long nTextHeight = pOlView->GetOutliner()->GetTextHeight(); 1190 nViewHeight += nTextHeight; 1191 long nCurrentPos = pOutlinerView->GetVisArea().Top(); 1192 long nTargetPos = (long)(fY * nViewHeight); 1193 long nDelta = nTargetPos - nCurrentPos; 1194 1195 pOutlinerView->HideCursor(); 1196 pOutlinerView->Scroll(0, -nDelta); 1197 pOutlinerView->ShowCursor(sal_False); 1198 1199 pOlView->InvalidateSlideNumberArea(); 1200 1201 return 0; 1202 } 1203 1204 /************************************************************************* 1205 |* 1206 |* PrepareClose, wird gerufen, wenn die Shell zestoert werden soll, 1207 |* leitet den Aufruf an die View weiter 1208 |* 1209 \************************************************************************/ 1210 1211 sal_uInt16 OutlineViewShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing ) 1212 { 1213 if( ViewShell::PrepareClose(bUI, bForBrowsing) != sal_True ) 1214 return sal_False; 1215 1216 return pOlView == NULL || pOlView->PrepareClose(bUI); 1217 } 1218 1219 1220 /************************************************************************* 1221 |* 1222 |* Zoomen mit Zoomfaktor, OutlinerView informieren 1223 |* 1224 \************************************************************************/ 1225 1226 void OutlineViewShell::SetZoom(long nZoom) 1227 { 1228 ViewShell::SetZoom(nZoom); 1229 1230 ::sd::Window* pWindow = mpContentWindow.get(); 1231 if (pWindow) 1232 { 1233 // OutputArea der OutlinerView aendern 1234 OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow); 1235 Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel()); 1236 aWin = pWindow->PixelToLogic(aWin); 1237 pOutlinerView->SetOutputArea(aWin); 1238 } 1239 1240 // #106268# 1241 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM ); 1242 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); 1243 } 1244 1245 /************************************************************************* 1246 |* 1247 |* Zoomen mit Zoomrechteck, OutlinerView informieren 1248 |* 1249 \************************************************************************/ 1250 1251 void OutlineViewShell::SetZoomRect(const Rectangle& rZoomRect) 1252 { 1253 ViewShell::SetZoomRect(rZoomRect); 1254 1255 ::sd::Window* pWindow = mpContentWindow.get(); 1256 if (pWindow) 1257 { 1258 // OutputArea der OutlinerView aendern 1259 OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow); 1260 Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel()); 1261 aWin = pWindow->PixelToLogic(aWin); 1262 pOutlinerView->SetOutputArea(aWin); 1263 } 1264 1265 // #106268# 1266 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM ); 1267 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); 1268 } 1269 1270 /************************************************************************* 1271 |* 1272 |* Vorm Speichern das Model der Drawing Engine aktualisieren, dann den 1273 |* Call weiterleiten an die ObjectShell. 1274 |* 1275 \************************************************************************/ 1276 1277 void OutlineViewShell::Execute(SfxRequest& rReq) 1278 { 1279 bool bForwardCall = true; 1280 1281 switch(rReq.GetSlot()) 1282 { 1283 case SID_SAVEDOC: 1284 case SID_SAVEASDOC: 1285 PrepareClose(); 1286 break; 1287 1288 case SID_SEARCH_ITEM: 1289 // Forward this request to the the common (old) code of the 1290 // document shell. 1291 GetDocSh()->Execute (rReq); 1292 bForwardCall = false; 1293 break; 1294 1295 case SID_SPELL_DIALOG: 1296 { 1297 SfxViewFrame* pViewFrame = GetViewFrame(); 1298 if (rReq.GetArgs() != NULL) 1299 pViewFrame->SetChildWindow (SID_SPELL_DIALOG, 1300 ((const SfxBoolItem&) (rReq.GetArgs()-> 1301 Get(SID_SPELL_DIALOG))).GetValue()); 1302 else 1303 pViewFrame->ToggleChildWindow(SID_SPELL_DIALOG); 1304 1305 pViewFrame->GetBindings().Invalidate(SID_SPELL_DIALOG); 1306 rReq.Done (); 1307 1308 bForwardCall = false; 1309 } 1310 break; 1311 1312 default: 1313 OSL_TRACE ("OutlineViewShell::Execute(): can not handle slot %d", rReq.GetSlot()); 1314 break; 1315 1316 } 1317 1318 if (bForwardCall) 1319 ((DrawDocShell*)GetViewFrame()->GetObjectShell())->ExecuteSlot( rReq ); 1320 } 1321 1322 /************************************************************************* 1323 |* 1324 |* Read FrameViews data and set actual views data 1325 |* 1326 \************************************************************************/ 1327 1328 void OutlineViewShell::ReadFrameViewData(FrameView* pView) 1329 { 1330 ::Outliner* pOutl = pOlView->GetOutliner(); 1331 1332 if ( pView->IsNoAttribs() ) 1333 pOutl->SetFlatMode( sal_True ); // Attribut-Darstellung ausschalten 1334 else 1335 pOutl->SetFlatMode( sal_False ); // Attribut-Darstellung einschalten 1336 1337 sal_uLong nCntrl = pOutl->GetControlWord(); 1338 1339 if ( pView->IsNoColors() ) 1340 pOutl->SetControlWord(nCntrl | EE_CNTRL_NOCOLORS); // Farbansicht ausschalten 1341 else 1342 pOutl->SetControlWord(nCntrl & ~EE_CNTRL_NOCOLORS); // Farbansicht einschalten 1343 1344 sal_uInt16 nPage = mpFrameView->GetSelectedPage(); 1345 pLastPage = GetDoc()->GetSdPage( nPage, PK_STANDARD ); 1346 pOlView->SetActualPage(pLastPage); 1347 } 1348 1349 1350 1351 /************************************************************************* 1352 |* 1353 |* Write actual views data to FrameView 1354 |* 1355 \************************************************************************/ 1356 1357 void OutlineViewShell::WriteFrameViewData() 1358 { 1359 ::Outliner* pOutl = pOlView->GetOutliner(); 1360 1361 sal_uLong nCntrl = pOutl->GetControlWord(); 1362 sal_Bool bNoColor = sal_False; 1363 if (nCntrl & EE_CNTRL_NOCOLORS) 1364 bNoColor = sal_True; 1365 mpFrameView->SetNoColors(bNoColor); 1366 mpFrameView->SetNoAttribs( pOutl->IsFlatMode() ); 1367 SdPage* pActualPage = pOlView->GetActualPage(); 1368 DBG_ASSERT(pActualPage, "No current page"); 1369 if( pActualPage ) 1370 mpFrameView->SetSelectedPage((pActualPage->GetPageNum() - 1) / 2); 1371 } 1372 1373 1374 /************************************************************************* 1375 |* 1376 |* SfxRequests fuer StatusBar bearbeiten 1377 |* 1378 \************************************************************************/ 1379 1380 void OutlineViewShell::ExecStatusBar(SfxRequest&) 1381 { 1382 } 1383 1384 /************************************************************************* 1385 |* 1386 |* Statuswerte der Statusbar zurueckgeben 1387 |* 1388 \************************************************************************/ 1389 1390 void OutlineViewShell::GetStatusBarState(SfxItemSet& rSet) 1391 { 1392 // Zoom-Item 1393 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOM ) ) 1394 { 1395 SvxZoomItem* pZoomItem; 1396 sal_uInt16 nZoom = (sal_uInt16) GetActiveWindow()->GetZoom(); 1397 1398 pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom ); 1399 1400 // Bereich einschraenken 1401 sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL; 1402 nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL; 1403 nZoomValues &= ~SVX_ZOOM_ENABLE_WHOLEPAGE; 1404 nZoomValues &= ~SVX_ZOOM_ENABLE_PAGEWIDTH; 1405 1406 pZoomItem->SetValueSet( nZoomValues ); 1407 rSet.Put( *pZoomItem ); 1408 delete pZoomItem; 1409 } 1410 1411 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) ) 1412 { 1413 if (GetDocSh()->IsUIActive() || !GetActiveWindow() ) 1414 { 1415 rSet.DisableItem( SID_ATTR_ZOOMSLIDER ); 1416 } 1417 else 1418 { 1419 sd::Window * pActiveWindow = GetActiveWindow(); 1420 SvxZoomSliderItem aZoomItem( (sal_uInt16) pActiveWindow->GetZoom(), (sal_uInt16)pActiveWindow->GetMinZoom(), (sal_uInt16)pActiveWindow->GetMaxZoom() ) ; 1421 aZoomItem.AddSnappingPoint(100); 1422 rSet.Put( aZoomItem ); 1423 } 1424 } 1425 1426 1427 // Seitenanzeige und Layout 1428 /* 1429 if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_PAGE ) || 1430 SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_LAYOUT ) ) 1431 */ 1432 sal_uInt16 nPageCount = GetDoc()->GetSdPageCount( PK_STANDARD ); 1433 String aPageStr, aLayoutStr; 1434 1435 ::sd::Window* pWin = GetActiveWindow(); 1436 OutlinerView* pActiveView = pOlView->GetViewByWindow( pWin ); 1437 ::Outliner* pOutliner = pOlView->GetOutliner(); 1438 List* pSelList = (List*)pActiveView->CreateSelectionList(); 1439 Paragraph* pFirstPara = (Paragraph*)pSelList->First(); 1440 Paragraph* pLastPara = (Paragraph*)pSelList->Last(); 1441 1442 if( !pOutliner->HasParaFlag(pFirstPara,PARAFLAG_ISPAGE) ) 1443 pFirstPara = pOlView->GetPrevTitle( pFirstPara ); 1444 1445 if( !pOutliner->HasParaFlag(pLastPara, PARAFLAG_ISPAGE) ) 1446 pLastPara = pOlView->GetPrevTitle( pLastPara ); 1447 1448 delete pSelList; // die wurde extra fuer uns erzeugt 1449 1450 // nur eine Seite selektiert? 1451 if( pFirstPara == pLastPara ) 1452 { 1453 // wieviele Seiten sind vor der selektierten Seite? 1454 sal_uLong nPos = 0L; 1455 while( pFirstPara ) 1456 { 1457 pFirstPara = pOlView->GetPrevTitle( pFirstPara ); 1458 if( pFirstPara ) 1459 nPos++; 1460 } 1461 1462 if( nPos >= GetDoc()->GetSdPageCount( PK_STANDARD ) ) 1463 nPos = 0; 1464 1465 SdrPage* pPage = GetDoc()->GetSdPage( (sal_uInt16) nPos, PK_STANDARD ); 1466 1467 aPageStr = String(SdResId( STR_SD_PAGE )); 1468 aPageStr += sal_Unicode(' '); 1469 aPageStr += String::CreateFromInt32( (sal_Int32)(nPos + 1) ); // sal_uLong -> sal_Int32 1470 aPageStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " )); 1471 aPageStr += String::CreateFromInt32( nPageCount ); 1472 1473 aLayoutStr = pPage->GetLayoutName(); 1474 aLayoutStr.Erase( aLayoutStr.SearchAscii( SD_LT_SEPARATOR ) ); 1475 } 1476 rSet.Put( SfxStringItem( SID_STATUS_PAGE, aPageStr ) ); 1477 rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aLayoutStr ) ); 1478 } 1479 1480 /************************************************************************* 1481 |* 1482 |* Command event 1483 |* 1484 \************************************************************************/ 1485 1486 void OutlineViewShell::Command( const CommandEvent& rCEvt, ::sd::Window* pWin ) 1487 { 1488 if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) 1489 { 1490 GetActiveWindow()->ReleaseMouse(); 1491 1492 OutlinerView* pOLV = pOlView->GetViewByWindow(GetActiveWindow()); 1493 Point aPos(rCEvt.GetMousePosPixel()); 1494 1495 if (pOLV && pOLV->IsWrongSpelledWordAtPos(aPos)) 1496 { 1497 // #91457# Popup for Online-Spelling now handled by DrawDocShell 1498 // Link aLink = LINK(GetDoc(), SdDrawDocument, OnlineSpellCallback); 1499 Link aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback); 1500 1501 pOLV->ExecuteSpellPopup(aPos, &aLink); 1502 } 1503 else 1504 { 1505 GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(RID_OUTLINE_POPUP)); 1506 } 1507 } 1508 else 1509 { 1510 ViewShell::Command( rCEvt, pWin ); 1511 1512 // ggfs. Preview den neuen Kontext mitteilen 1513 Invalidate( SID_PREVIEW_STATE ); 1514 1515 } 1516 } 1517 1518 1519 /************************************************************************* 1520 |* 1521 |* Keyboard event 1522 |* 1523 \************************************************************************/ 1524 1525 sal_Bool OutlineViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin) 1526 { 1527 sal_Bool bReturn = sal_False; 1528 OutlineViewPageChangesGuard aGuard(pOlView); 1529 1530 if (pWin == NULL && HasCurrentFunction()) 1531 { 1532 bReturn = GetCurrentFunction()->KeyInput(rKEvt); 1533 } 1534 1535 // nein, weiterleiten an Basisklasse 1536 else 1537 { 1538 bReturn = ViewShell::KeyInput(rKEvt, pWin); 1539 } 1540 1541 Invalidate(SID_STYLE_EDIT); 1542 Invalidate(SID_STYLE_NEW); 1543 Invalidate(SID_STYLE_DELETE); 1544 Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE); 1545 Invalidate(SID_STYLE_NEW_BY_EXAMPLE); 1546 Invalidate(SID_STYLE_WATERCAN); 1547 Invalidate(SID_STYLE_FAMILY5); 1548 1549 // Pruefen und Unterscheiden von CursorBewegungs- oder Eingabe-Keys 1550 KeyCode aKeyGroup( rKEvt.GetKeyCode().GetGroup() ); 1551 if( (aKeyGroup != KEYGROUP_CURSOR && aKeyGroup != KEYGROUP_FKEYS) || 1552 (GetActualPage() != pLastPage) ) 1553 { 1554 Invalidate( SID_PREVIEW_STATE ); 1555 } 1556 1557 return(bReturn); 1558 } 1559 1560 1561 /************************************************************************* 1562 |* 1563 |* Optimale Groesse zurueckgeben 1564 |* 1565 \************************************************************************/ 1566 1567 Size OutlineViewShell::GetOptimalSizePixel() const 1568 { 1569 Size aResult(200, 200); 1570 if (pOlView) 1571 { 1572 ::Outliner* pOutliner = pOlView->GetOutliner(); 1573 if (pOutliner) 1574 { 1575 Size aTemp = pOutliner->CalcTextSize(); 1576 aTemp = GetActiveWindow()->LogicToPixel(aTemp); 1577 aResult.Width() = Max(aResult.Width(), aTemp.Width()); 1578 aResult.Height() = Max(aResult.Height(), aTemp.Height()); 1579 if (4 * aResult.Height() > 3 * aResult.Width()) 1580 { 1581 aResult.Height() = 3 * aResult.Width() / 4; 1582 } 1583 } 1584 } 1585 1586 // und jetzt jetzt das Standardgelumpe draufaddieren 1587 aResult.Width() += mpVerticalScrollBar->GetSizePixel().Width(); 1588 aResult.Height() += mpHorizontalScrollBar->GetSizePixel().Height(); 1589 //!!! + System::GetMenuBarHeightPixel(); // statt Titlebar 1590 return aResult; 1591 } 1592 1593 1594 /************************************************************************* 1595 |* 1596 |* Text der Selektion zurueckgeben 1597 |* 1598 \************************************************************************/ 1599 1600 String OutlineViewShell::GetSelectionText(sal_Bool bCompleteWords) 1601 { 1602 String aStrSelection; 1603 ::Outliner* pOl = pOlView->GetOutliner(); 1604 OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() ); 1605 1606 if (pOl && pOlView) 1607 { 1608 if (bCompleteWords) 1609 { 1610 ESelection aSel = pOutlinerView->GetSelection(); 1611 String aStrCurrentDelimiters = pOl->GetWordDelimiters(); 1612 1613 pOl->SetWordDelimiters( String( RTL_CONSTASCII_USTRINGPARAM( " .,;\"'" ))); 1614 aStrSelection = pOl->GetWord( aSel.nEndPara, aSel.nEndPos ); 1615 pOl->SetWordDelimiters( aStrCurrentDelimiters ); 1616 } 1617 else 1618 { 1619 aStrSelection = pOutlinerView->GetSelected(); 1620 } 1621 } 1622 1623 return (aStrSelection); 1624 } 1625 1626 1627 /************************************************************************* 1628 |* 1629 |* Ist etwas selektiert? 1630 |* 1631 \************************************************************************/ 1632 1633 sal_Bool OutlineViewShell::HasSelection(sal_Bool bText) const 1634 { 1635 sal_Bool bReturn = sal_False; 1636 1637 if (bText) 1638 { 1639 OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() ); 1640 1641 if (pOutlinerView && pOutlinerView->GetSelected().Len() != 0) 1642 { 1643 bReturn = sal_True; 1644 } 1645 } 1646 1647 return bReturn; 1648 } 1649 1650 1651 /************************************************************************* 1652 |* 1653 |* Status der Attribut-Items 1654 |* 1655 \************************************************************************/ 1656 1657 void OutlineViewShell::GetAttrState( SfxItemSet& rSet ) 1658 { 1659 SfxWhichIter aIter( rSet ); 1660 sal_uInt16 nWhich = aIter.FirstWhich(); 1661 SfxAllItemSet aAllSet( *rSet.GetPool() ); 1662 1663 while ( nWhich ) 1664 { 1665 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich) 1666 ? GetPool().GetSlotId(nWhich) 1667 : nWhich; 1668 1669 switch ( nSlotId ) 1670 { 1671 case SID_STYLE_FAMILY2: 1672 case SID_STYLE_FAMILY3: 1673 { 1674 rSet.DisableItem( nWhich ); 1675 } 1676 break; 1677 1678 case SID_STYLE_FAMILY5: 1679 { 1680 SfxStyleSheet* pStyleSheet = pOlView->GetViewByWindow(GetActiveWindow())->GetStyleSheet(); 1681 1682 if( pStyleSheet ) 1683 { 1684 pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet(); 1685 1686 if (pStyleSheet) 1687 { 1688 SfxTemplateItem aItem( nWhich, pStyleSheet->GetName() ); 1689 aAllSet.Put( aItem, aItem.Which() ); 1690 } 1691 } 1692 1693 if( !pStyleSheet ) 1694 { 1695 SfxTemplateItem aItem( nWhich, String() ); 1696 aAllSet.Put( aItem, aItem.Which() ); 1697 // rSet.DisableItem( nWhich ); 1698 } 1699 } 1700 break; 1701 1702 case SID_STYLE_EDIT: 1703 { 1704 ISfxTemplateCommon* pTmplCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings()); 1705 1706 if (pTmplCommon && pTmplCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO) 1707 { 1708 SfxItemSet aSet(*rSet.GetPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT); 1709 GetStatusBarState(aSet); 1710 String aRealStyle(((SfxStringItem&) aSet.Get(SID_STATUS_LAYOUT)).GetValue()); 1711 1712 if (!aRealStyle.Len()) 1713 { 1714 // Kein eindeutiger Layoutname gefunden 1715 rSet.DisableItem(nWhich); 1716 } 1717 } 1718 } 1719 break; 1720 1721 case SID_STYLE_UPDATE_BY_EXAMPLE: 1722 { 1723 ::sd::Window* pActWin = GetActiveWindow(); 1724 OutlinerView* pOV = pOlView->GetViewByWindow(pActWin); 1725 ESelection aESel(pOV->GetSelection()); 1726 1727 if (aESel.nStartPara != aESel.nEndPara || 1728 aESel.nStartPos != aESel.nEndPos) 1729 // aufgespannte Selektion, also StyleSheet und/oder 1730 // Attributierung nicht zwingend eindeutig 1731 rSet.DisableItem(nWhich); 1732 } 1733 break; 1734 1735 case SID_STYLE_NEW: 1736 case SID_STYLE_DELETE: 1737 case SID_STYLE_NEW_BY_EXAMPLE: 1738 case SID_STYLE_WATERCAN: 1739 { 1740 rSet.DisableItem(nWhich); 1741 } 1742 break; 1743 } 1744 1745 nWhich = aIter.NextWhich(); 1746 } 1747 1748 rSet.Put( aAllSet, sal_False ); 1749 } 1750 1751 1752 1753 /************************************************************************* 1754 |* 1755 |* MouseButtonUp event 1756 |* 1757 \************************************************************************/ 1758 1759 void OutlineViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin) 1760 { 1761 // Zuerst die Basisklasse 1762 ViewShell::MouseButtonUp(rMEvt, pWin); 1763 1764 Invalidate(SID_STYLE_EDIT); 1765 Invalidate(SID_STYLE_NEW); 1766 Invalidate(SID_STYLE_DELETE); 1767 Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE); 1768 Invalidate(SID_STYLE_NEW_BY_EXAMPLE); 1769 Invalidate(SID_STYLE_WATERCAN); 1770 Invalidate(SID_STYLE_FAMILY5); 1771 1772 // ggfs. Preview den neuen Kontext mitteilen 1773 if( GetActualPage() != pLastPage ) 1774 Invalidate( SID_PREVIEW_STATE ); 1775 } 1776 1777 1778 1779 SdPage* OutlineViewShell::getCurrentPage() const 1780 { 1781 // since there are no master pages in outline view, we can 1782 // for now use the GetActualPage method 1783 return const_cast<OutlineViewShell*>(this)->GetActualPage(); 1784 } 1785 1786 /************************************************************************* 1787 |* 1788 |* Liefert die erste selektierte Seite zurueck. 1789 |* Wenn nichts selektiert ist, wird die erste Seite zurueckgeliefert. 1790 |* 1791 \************************************************************************/ 1792 SdPage* OutlineViewShell::GetActualPage() 1793 { 1794 return pOlView->GetActualPage(); 1795 } 1796 1797 1798 void OutlineViewShell::UpdatePreview( SdPage* pPage, sal_Bool ) 1799 { 1800 const bool bNewPage = pPage != pLastPage; 1801 pLastPage = pPage; 1802 if (bNewPage) 1803 { 1804 OutlineViewPageChangesGuard aGuard(pOlView); 1805 SetCurrentPage(pPage); 1806 } 1807 } 1808 1809 /************************************************************************* 1810 |* 1811 |* Update Title 1812 |* 1813 \************************************************************************/ 1814 1815 bool OutlineViewShell::UpdateTitleObject( SdPage* pPage, Paragraph* pPara ) 1816 { 1817 DBG_ASSERT( pPage, "sd::OutlineViewShell::UpdateTitleObject(), pPage == 0?" ); 1818 DBG_ASSERT( pPara, "sd::OutlineViewShell::UpdateTitleObject(), pPara == 0?" ); 1819 1820 if( !pPage || !pPara ) 1821 return false; 1822 1823 ::Outliner* pOutliner = pOlView->GetOutliner(); 1824 SdrTextObj* pTO = pOlView->GetTitleTextObject( pPage ); 1825 OutlinerParaObject* pOPO = NULL; 1826 1827 String aTest( pOutliner->GetText( pPara ) ); 1828 bool bText = aTest.Len() > 0; 1829 bool bNewObject = false; 1830 1831 if( bText ) 1832 { 1833 // create a title object if we don't have one but have text 1834 if( !pTO ) 1835 { 1836 DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" ); 1837 pTO = pOlView->CreateTitleTextObject(pPage); 1838 bNewObject = sal_True; 1839 } 1840 1841 // if we have a title object and a text, set the text 1842 if( pTO ) 1843 { 1844 pOPO = pOutliner->CreateParaObject( (sal_uInt16) pOutliner->GetAbsPos( pPara ), 1 ); 1845 pOPO->SetOutlinerMode( OUTLINERMODE_TITLEOBJECT ); 1846 pOPO->SetVertical( pTO->IsVerticalWriting() ); 1847 if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) ) 1848 { 1849 // do nothing, same text already set 1850 delete pOPO; 1851 } 1852 else 1853 { 1854 DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" ); 1855 if( !bNewObject && pOlView->isRecordingUndo() ) 1856 pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0)); 1857 1858 pTO->SetOutlinerParaObject( pOPO ); 1859 pTO->SetEmptyPresObj( sal_False ); 1860 pTO->ActionChanged(); 1861 } 1862 } 1863 } 1864 else if( pTO ) 1865 { 1866 // no text but object available? 1867 // outline object available, but we have no text 1868 if(pPage->IsPresObj(pTO)) 1869 { 1870 // if it is not already empty 1871 if( !pTO->IsEmptyPresObj() ) 1872 { 1873 DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" ); 1874 1875 // make it empty 1876 if( pOlView->isRecordingUndo() ) 1877 pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0)); 1878 pPage->RestoreDefaultText( pTO ); 1879 pTO->SetEmptyPresObj(sal_True); 1880 pTO->ActionChanged(); 1881 } 1882 } 1883 else 1884 { 1885 DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" ); 1886 // outline object is not part of the layout, delete it 1887 if( pOlView->isRecordingUndo() ) 1888 pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO)); 1889 pPage->RemoveObject(pTO->GetOrdNum()); 1890 } 1891 } 1892 1893 return bNewObject; 1894 } 1895 1896 /************************************************************************* 1897 |* 1898 |* Update LayoutObject 1899 |* 1900 \************************************************************************/ 1901 1902 bool OutlineViewShell::UpdateOutlineObject( SdPage* pPage, Paragraph* pPara ) 1903 { 1904 DBG_ASSERT( pPage, "sd::OutlineViewShell::UpdateOutlineObject(), pPage == 0?" ); 1905 DBG_ASSERT( pPara, "sd::OutlineViewShell::UpdateOutlineObject(), pPara == 0?" ); 1906 1907 if( !pPage || !pPara ) 1908 return false; 1909 1910 ::Outliner* pOutliner = pOlView->GetOutliner(); 1911 OutlinerParaObject* pOPO = NULL; 1912 SdrTextObj* pTO = NULL; 1913 1914 sal_Bool bNewObject = sal_False; 1915 1916 sal_uInt16 eOutlinerMode = OUTLINERMODE_TITLEOBJECT; 1917 pTO = (SdrTextObj*)pPage->GetPresObj( PRESOBJ_TEXT ); 1918 if( !pTO ) 1919 { 1920 eOutlinerMode = OUTLINERMODE_OUTLINEOBJECT; 1921 pTO = pOlView->GetOutlineTextObject( pPage ); 1922 } 1923 1924 // wieviele Absaetze in der Gliederung? 1925 sal_uLong nTitlePara = pOutliner->GetAbsPos( pPara ); 1926 sal_uLong nPara = nTitlePara + 1; 1927 sal_uLong nParasInLayout = 0L; 1928 pPara = pOutliner->GetParagraph( nPara ); 1929 while( pPara && !pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) ) 1930 { 1931 nParasInLayout++; 1932 pPara = pOutliner->GetParagraph( ++nPara ); 1933 } 1934 if( nParasInLayout ) 1935 { 1936 // ein OutlinerParaObject erzeugen 1937 pPara = pOutliner->GetParagraph( nTitlePara + 1 ); 1938 pOPO = pOutliner->CreateParaObject( (sal_uInt16) nTitlePara + 1, (sal_uInt16) nParasInLayout ); 1939 } 1940 1941 if( pOPO ) 1942 { 1943 DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" ); 1944 1945 // do we need an outline text object? 1946 if( !pTO ) 1947 { 1948 pTO = pOlView->CreateOutlineTextObject( pPage ); 1949 bNewObject = sal_True; 1950 } 1951 1952 // Seitenobjekt, Gliederungstext im Outliner: 1953 // Text uebernehmen 1954 if( pTO ) 1955 { 1956 pOPO->SetVertical( pTO->IsVerticalWriting() ); 1957 pOPO->SetOutlinerMode( eOutlinerMode ); 1958 if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) ) 1959 { 1960 // do nothing, same text already set 1961 delete pOPO; 1962 } 1963 else 1964 { 1965 if( !bNewObject && pOlView->isRecordingUndo() ) 1966 pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0)); 1967 1968 pTO->SetOutlinerParaObject( pOPO ); 1969 pTO->SetEmptyPresObj( sal_False ); 1970 pTO->ActionChanged(); 1971 } 1972 } 1973 } 1974 else if( pTO ) 1975 { 1976 // Seitenobjekt, aber kein Gliederungstext: 1977 // wenn Objekt in Praesentationsliste der Seite ist -> Defaulttext, 1978 // sonst Objekt loeschen 1979 if( pPage->IsPresObj(pTO) ) 1980 { 1981 if( !pTO->IsEmptyPresObj() ) 1982 { 1983 DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" ); 1984 1985 // loescht auch altes OutlinerParaObject 1986 if( pOlView->isRecordingUndo() ) 1987 pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0)); 1988 pPage->RestoreDefaultText( pTO ); 1989 pTO->SetEmptyPresObj(sal_True); 1990 pTO->ActionChanged(); 1991 } 1992 } 1993 else 1994 { 1995 DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" ); 1996 if( pOlView->isRecordingUndo() ) 1997 pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO)); 1998 pPage->RemoveObject(pTO->GetOrdNum()); 1999 } 2000 } 2001 2002 return bNewObject; 2003 } 2004 2005 2006 /************************************************************************* 2007 |* 2008 |* Outliner aus Stream fuellen 2009 |* 2010 \************************************************************************/ 2011 2012 sal_uLong OutlineViewShell::Read(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat) 2013 { 2014 sal_uLong bRet = 0; 2015 2016 ::Outliner* pOutl = pOlView->GetOutliner(); 2017 2018 { 2019 OutlineViewPageChangesGuard aGuard( pOlView ); 2020 OutlineViewModelChangeGuard aGuard2( *pOlView ); 2021 2022 bRet = pOutl->Read( rInput, rBaseURL, eFormat, GetDocSh()->GetHeaderAttributes() ); 2023 2024 SdPage* pPage = GetDoc()->GetSdPage( GetDoc()->GetSdPageCount(PK_STANDARD) - 1, PK_STANDARD );; 2025 SfxStyleSheet* pTitleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE ); 2026 SfxStyleSheet* pOutlSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE ); 2027 2028 sal_uInt16 nParaCount = (sal_uInt16)pOutl->GetParagraphCount(); 2029 if ( nParaCount > 0 ) 2030 { 2031 for ( sal_uInt16 nPara = 0; nPara < nParaCount; nPara++ ) 2032 { 2033 pOlView->UpdateParagraph( nPara ); 2034 2035 sal_Int16 nDepth = pOutl->GetDepth( nPara ); 2036 2037 if( (nDepth == 0) || !nPara ) 2038 { 2039 Paragraph* pPara = pOutl->GetParagraph( nPara ); 2040 pOutl->SetDepth(pPara, -1); 2041 pOutl->SetParaFlag(pPara, PARAFLAG_ISPAGE); 2042 2043 pOutl->SetStyleSheet( nPara, pTitleSheet ); 2044 2045 if( nPara ) // first slide already exists 2046 pOlView->InsertSlideForParagraph( pPara ); 2047 } 2048 else 2049 { 2050 pOutl->SetDepth( pOutl->GetParagraph( nPara ), nDepth - 1 ); 2051 String aStyleSheetName( pOutlSheet->GetName() ); 2052 aStyleSheetName.Erase( aStyleSheetName.Len() - 1, 1 ); 2053 aStyleSheetName += String::CreateFromInt32( nDepth ); 2054 SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool(); 2055 SfxStyleSheet* pStyle = (SfxStyleSheet*) pStylePool->Find( aStyleSheetName, pOutlSheet->GetFamily() ); 2056 DBG_ASSERT( pStyle, "AutoStyleSheetName - Style not found!" ); 2057 if ( pStyle ) 2058 pOutl->SetStyleSheet( nPara, pStyle ); 2059 } 2060 } 2061 } 2062 } 2063 2064 pOutl->GetUndoManager().Clear(); 2065 2066 return( bRet ); 2067 } 2068 2069 void OutlineViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse ) 2070 { 2071 WriteFrameViewData(); 2072 2073 ViewShell::WriteUserDataSequence( rSequence, bBrowse ); 2074 } 2075 2076 void OutlineViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse ) 2077 { 2078 WriteFrameViewData(); 2079 2080 ViewShell::ReadUserDataSequence( rSequence, bBrowse ); 2081 2082 ReadFrameViewData( mpFrameView ); 2083 } 2084 2085 void OutlineViewShell::VisAreaChanged(const Rectangle& rRect) 2086 { 2087 ViewShell::VisAreaChanged( rRect ); 2088 2089 GetViewShellBase().GetDrawController().FireVisAreaChanged(rRect); 2090 } 2091 2092 /** If there is a valid controller then create a new instance of 2093 <type>AccessibleDrawDocumentView</type>. Otherwise delegate this call 2094 to the base class to return a default object (probably an empty 2095 reference). 2096 */ 2097 ::com::sun::star::uno::Reference< 2098 ::com::sun::star::accessibility::XAccessible> 2099 OutlineViewShell::CreateAccessibleDocumentView (::sd::Window* pWindow) 2100 { 2101 OSL_ASSERT (GetViewShell()!=NULL); 2102 if (GetViewShell()->GetController() != NULL) 2103 { 2104 ::accessibility::AccessibleOutlineView* pDocumentView = 2105 new ::accessibility::AccessibleOutlineView ( 2106 pWindow, 2107 this, 2108 GetViewShell()->GetController(), 2109 pWindow->GetAccessibleParentWindow()->GetAccessible()); 2110 pDocumentView->Init(); 2111 return ::com::sun::star::uno::Reference< 2112 ::com::sun::star::accessibility::XAccessible> 2113 (static_cast< ::com::sun::star::uno::XWeak*>(pDocumentView), 2114 ::com::sun::star::uno::UNO_QUERY); 2115 } 2116 else 2117 { 2118 OSL_TRACE ("OutlineViewShell::CreateAccessibleDocumentView: no controller"); 2119 return ViewShell::CreateAccessibleDocumentView (pWindow); 2120 } 2121 } 2122 2123 2124 2125 2126 void OutlineViewShell::GetState (SfxItemSet& rSet) 2127 { 2128 // Iterate over all requested items in the set. 2129 SfxWhichIter aIter( rSet ); 2130 sal_uInt16 nWhich = aIter.FirstWhich(); 2131 while (nWhich) 2132 { 2133 switch (nWhich) 2134 { 2135 case SID_SEARCH_ITEM: 2136 case SID_SEARCH_OPTIONS: 2137 // Call common (old) implementation in the document shell. 2138 GetDocSh()->GetState (rSet); 2139 break; 2140 default: 2141 OSL_TRACE ("OutlineViewShell::GetState(): can not handle which id %d", nWhich); 2142 break; 2143 } 2144 nWhich = aIter.NextWhich(); 2145 } 2146 } 2147 2148 2149 2150 2151 void OutlineViewShell::SetCurrentPage (SdPage* pPage) 2152 { 2153 // Adapt the selection of the model. 2154 for (sal_uInt16 i=0; i<GetDoc()->GetSdPageCount(PK_STANDARD); i++) 2155 GetDoc()->SetSelected( 2156 GetDoc()->GetSdPage(i, PK_STANDARD), 2157 sal_False); 2158 GetDoc()->SetSelected (pPage, sal_True); 2159 2160 DrawController& rController(GetViewShellBase().GetDrawController()); 2161 rController.FireSelectionChangeListener(); 2162 rController.FireSwitchCurrentPage (pPage); 2163 2164 pOlView->SetActualPage(pPage); 2165 } 2166 2167 2168 } // end of namespace sd 2169