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