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_sw.hxx" 30 31 32 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers 33 #include <stdlib.h> 34 #include <hintids.hxx> 35 #include <rtl/logfile.hxx> 36 #include <vcl/graph.hxx> 37 #include <vcl/inputctx.hxx> 38 #include <basic/sbxobj.hxx> 39 #include <svl/eitem.hxx> 40 #include <unotools/undoopt.hxx> 41 #include <unotools/lingucfg.hxx> 42 #include <unotools/useroptions.hxx> 43 #include <sfx2/dispatch.hxx> 44 #include <sfx2/request.hxx> 45 #include <sfx2/docfile.hxx> 46 #include <sfx2/printer.hxx> 47 #include <sfx2/app.hxx> 48 #include <svx/ruler.hxx> 49 #include <editeng/protitem.hxx> 50 #include <svx/fmshell.hxx> 51 #include <svx/extrusionbar.hxx> 52 #include <svx/fontworkbar.hxx> 53 #include <unotxvw.hxx> 54 #include <cmdid.h> 55 #include <swhints.hxx> 56 #include <swmodule.hxx> 57 #include <inputwin.hxx> 58 #include <chartins.hxx> 59 #include <uivwimp.hxx> 60 #include <uitool.hxx> 61 #include <edtwin.hxx> 62 #include <textsh.hxx> 63 #include <listsh.hxx> 64 #include <tabsh.hxx> 65 #include <grfsh.hxx> 66 #include <mediash.hxx> 67 #include <docsh.hxx> 68 #include <frmsh.hxx> 69 #include <olesh.hxx> 70 #include <drawsh.hxx> 71 #include <drawbase.hxx> 72 #include <drformsh.hxx> 73 #include <drwtxtsh.hxx> 74 #include <beziersh.hxx> 75 #include <globdoc.hxx> 76 #include <scroll.hxx> 77 #include <navipi.hxx> 78 #include <gloshdl.hxx> 79 #include <usrpref.hxx> 80 #include <srcview.hxx> 81 #include <doc.hxx> 82 #include <IDocumentUndoRedo.hxx> 83 #include <drawdoc.hxx> 84 #include <wdocsh.hxx> 85 #include <wview.hxx> 86 #include <workctrl.hxx> 87 #include <wrtsh.hxx> 88 #include <barcfg.hxx> 89 #include <pview.hxx> 90 #include <swdtflvr.hxx> 91 #include <view.hrc> 92 #include <globdoc.hrc> 93 #include <frmui.hrc> 94 #include <cfgitems.hxx> 95 #include <prtopt.hxx> 96 #include <linguistic/lngprops.hxx> 97 #include <editeng/unolingu.hxx> 98 //#include <sfx2/app.hxx> 99 #include <com/sun/star/frame/FrameSearchFlag.hpp> 100 #include <com/sun/star/scanner/ScannerContext.hpp> 101 #include <com/sun/star/scanner/XScannerManager.hpp> 102 #include <toolkit/unohlp.hxx> 103 #include <rtl/ustrbuf.hxx> 104 #include <xmloff/xmluconv.hxx> 105 106 #include "formatclipboard.hxx" 107 #include <PostItMgr.hxx> 108 #include <annotsh.hxx> 109 110 #include <fldbas.hxx> 111 112 #include <unomid.h> 113 114 #include <com/sun/star/document/XDocumentProperties.hpp> 115 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> 116 117 118 using namespace ::com::sun::star; 119 using namespace ::com::sun::star::uno; 120 using namespace ::com::sun::star::lang; 121 using namespace ::com::sun::star::scanner; 122 using ::rtl::OUString; 123 using ::rtl::OUStringBuffer; 124 125 126 extern sal_Bool bNoInterrupt; // in mainwn.cxx 127 128 #define SWVIEWFLAGS ( SFX_VIEW_CAN_PRINT| \ 129 SFX_VIEW_HAS_PRINTOPTIONS) 130 131 /*-------------------------------------------------------------------- 132 Beschreibung: Statics 133 --------------------------------------------------------------------*/ 134 135 int bDocSzUpdated = 1; 136 137 SvxSearchItem* SwView::pSrchItem = 0; 138 139 sal_uInt16 SwView::nInsertCtrlState = FN_INSERT_TABLE; 140 sal_uInt16 SwView::nWebInsertCtrlState = FN_INSERT_TABLE; 141 sal_uInt16 SwView::nInsertObjectCtrlState = SID_INSERT_DIAGRAM; 142 143 sal_Bool SwView::bExtra = sal_False; 144 sal_Bool SwView::bFound = sal_False; 145 sal_Bool SwView::bJustOpened = sal_False; 146 147 148 SvxSearchDialog* SwView::pSrchDlg = 0; 149 SearchAttrItemList* SwView::pSrchList = 0; 150 SearchAttrItemList* SwView::pReplList = 0; 151 152 DBG_NAME(viewhdl) 153 154 /*-------------------------------------------------------------------- 155 Beschreibung: 156 --------------------------------------------------------------------*/ 157 158 inline SfxDispatcher &SwView::GetDispatcher() 159 { 160 return *GetViewFrame()->GetDispatcher(); 161 } 162 163 /*-------------------------------------------------------------------- 164 Beschreibung: 165 --------------------------------------------------------------------*/ 166 167 void SwView::ImpSetVerb( int nSelType ) 168 { 169 sal_Bool bResetVerbs = bVerbsActive; 170 if ( !GetViewFrame()->GetFrame().IsInPlace() && 171 (nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF) & nSelType ) 172 { 173 if ( !pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT) ) 174 { 175 if ( nSelType & nsSelectionType::SEL_OLE ) 176 { 177 SetVerbs( GetWrtShell().GetOLEObject()->getSupportedVerbs() ); 178 bVerbsActive = sal_True; 179 bResetVerbs = sal_False; 180 } 181 } 182 } 183 if ( bResetVerbs ) 184 { 185 SetVerbs( Sequence< embed::VerbDescriptor >() ); 186 bVerbsActive = sal_False; 187 } 188 } 189 190 /*-------------------------------------------------------------------- 191 Description: 192 called by the SwEditWin when it gets the focus 193 --------------------------------------------------------------------*/ 194 195 void SwView::GotFocus() const 196 { 197 // if we got the focus, and the form shell *is* on the top of the dispatcher 198 // stack, then we need to rebuild the stack (the form shell doesn't belong to 199 // the top then) 200 const SfxDispatcher& rDispatcher = const_cast< SwView* >( this )->GetDispatcher(); 201 SfxShell* pTopShell = rDispatcher.GetShell( 0 ); 202 FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell ); 203 if ( pAsFormShell ) 204 { 205 pAsFormShell->ForgetActiveControl(); 206 const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell ); 207 } 208 else if ( mpPostItMgr ) 209 { 210 SwAnnotationShell* pAsAnnotationShell = PTR_CAST( SwAnnotationShell, pTopShell ); 211 if ( pAsAnnotationShell ) 212 { 213 mpPostItMgr->SetActiveSidebarWin(0); 214 const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell ); 215 } 216 } 217 if( GetWrtShellPtr() ) 218 { 219 SwWrtShell& rWrtShell = GetWrtShell(); 220 rWrtShell.GetDoc()->SetCurrentViewShell( GetWrtShellPtr() ); 221 rWrtShell.GetDoc()->set( IDocumentSettingAccess::BROWSE_MODE, 222 rWrtShell.GetViewOptions()->getBrowseMode() ); 223 } 224 } 225 226 /*-------------------------------------------------------------------- 227 Description: 228 called by the FormShell when a form control is focused. This is 229 a request to put the form shell on the top of the dispatcher 230 stack 231 --------------------------------------------------------------------*/ 232 233 IMPL_LINK( SwView, FormControlActivated, FmFormShell*, EMPTYARG ) 234 { 235 // if a form control has been activated, and the form shell is not on the top 236 // of the dispatcher stack, then we need to activate it 237 const SfxDispatcher& rDispatcher = GetDispatcher(); 238 const SfxShell* pTopShell = rDispatcher.GetShell( 0 ); 239 const FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell ); 240 if ( !pAsFormShell ) 241 { 242 // if we're editing text currently, cancel this 243 SdrView *pSdrView = pWrtShell ? pWrtShell->GetDrawView() : NULL; 244 if ( pSdrView && pSdrView->IsTextEdit() ) 245 pSdrView->SdrEndTextEdit( sal_True ); 246 247 const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell ); 248 } 249 250 return 0L; 251 } 252 253 void SwView::SelectShell() 254 { 255 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 256 // 257 // Achtung: SelectShell fuer die WebView mitpflegen 258 // 259 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 260 261 if(bInDtor) 262 return; 263 // Entscheidung, ob UpdateTable gerufen werden muss 264 sal_Bool bUpdateTable = sal_False; 265 const SwFrmFmt* pCurTableFmt = pWrtShell->GetTableFmt(); 266 if(pCurTableFmt && pCurTableFmt != pLastTableFormat) 267 { 268 bUpdateTable = sal_True; // kann erst spaeter ausgefuehrt werden 269 } 270 pLastTableFormat = pCurTableFmt; 271 272 //SEL_TBL und SEL_TBL_CELLS koennen verodert sein! 273 int nNewSelectionType = (pWrtShell->GetSelectionType() 274 & ~nsSelectionType::SEL_TBL_CELLS); 275 276 if ( pFormShell && pFormShell->IsActiveControl() ) 277 nNewSelectionType |= nsSelectionType::SEL_FOC_FRM_CTRL; 278 279 if ( nNewSelectionType == nSelectionType ) 280 { 281 GetViewFrame()->GetBindings().InvalidateAll( sal_False ); 282 if ( nSelectionType & nsSelectionType::SEL_OLE || 283 nSelectionType & nsSelectionType::SEL_GRF ) 284 //Fuer Grafiken und OLE kann sich natuerlich das Verb aendern! 285 ImpSetVerb( nNewSelectionType ); 286 } 287 else 288 { 289 290 SfxDispatcher &rDispatcher = GetDispatcher(); 291 SwToolbarConfigItem *pBarCfg = SW_MOD()->GetToolbarConfig(); 292 293 // DELETEZ(pxSelectionObj); //Selektionsobjekt loeschen 294 if ( pShell ) 295 { 296 rDispatcher.Flush(); // alle gecachten Shells wirklich loeschen 297 298 //Zur alten Selektion merken welche Toolbar sichtbar war 299 sal_uInt16 nId = static_cast< sal_uInt16 >( rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT )); 300 if ( nId ) 301 pBarCfg->SetTopToolbar( nSelectionType, nId ); 302 303 SfxShell *pSfxShell; 304 for ( sal_uInt16 i = 0; sal_True; ++i ) 305 { 306 pSfxShell = rDispatcher.GetShell( i ); 307 if ( pSfxShell->ISA( SwBaseShell ) 308 || pSfxShell->ISA( SwDrawTextShell ) 309 || pSfxShell->ISA( svx::ExtrusionBar ) 310 || pSfxShell->ISA( svx::FontworkBar ) 311 || pSfxShell->ISA( SwAnnotationShell ) 312 ) 313 { 314 rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_DELETE ); 315 } 316 else if ( pSfxShell->ISA( FmFormShell ) ) 317 { 318 rDispatcher.Pop( *pSfxShell ); 319 } 320 else 321 break; 322 } 323 } 324 325 sal_Bool bInitFormShell = sal_False; 326 if (!pFormShell) 327 { 328 bInitFormShell = sal_True; 329 pFormShell = new FmFormShell( this ); 330 pFormShell->SetControlActivationHandler( LINK( this, SwView, FormControlActivated ) ); 331 StartListening(*pFormShell); 332 } 333 334 sal_Bool bSetExtInpCntxt = sal_False; 335 nSelectionType = nNewSelectionType; 336 ShellModes eShellMode; 337 338 if ( !( nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL ) ) 339 rDispatcher.Push( *pFormShell ); 340 341 if ( nSelectionType & nsSelectionType::SEL_OLE ) 342 { 343 eShellMode = SHELL_MODE_OBJECT; 344 pShell = new SwOleShell( *this ); 345 rDispatcher.Push( *pShell ); 346 } 347 else if ( nSelectionType & nsSelectionType::SEL_FRM 348 || nSelectionType & nsSelectionType::SEL_GRF) 349 { 350 eShellMode = SHELL_MODE_FRAME; 351 pShell = new SwFrameShell( *this ); 352 rDispatcher.Push( *pShell ); 353 if(nSelectionType & nsSelectionType::SEL_GRF ) 354 { 355 eShellMode = SHELL_MODE_GRAPHIC; 356 pShell = new SwGrfShell( *this ); 357 rDispatcher.Push( *pShell ); 358 } 359 } 360 else if ( nSelectionType & nsSelectionType::SEL_DRW ) 361 { 362 eShellMode = SHELL_MODE_DRAW; 363 pShell = new SwDrawShell( *this ); 364 rDispatcher.Push( *pShell ); 365 366 if ( nSelectionType & nsSelectionType::SEL_BEZ ) 367 { 368 eShellMode = SHELL_MODE_BEZIER; 369 pShell = new SwBezierShell( *this ); 370 rDispatcher.Push( *pShell ); 371 } 372 else if( nSelectionType & nsSelectionType::SEL_MEDIA ) 373 { 374 eShellMode = SHELL_MODE_MEDIA; 375 pShell = new SwMediaShell( *this ); 376 rDispatcher.Push( *pShell ); 377 } 378 379 if (nSelectionType & nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE) 380 { 381 eShellMode = SHELL_MODE_EXTRUDED_CUSTOMSHAPE; 382 pShell = new svx::ExtrusionBar(this); 383 rDispatcher.Push( *pShell ); 384 } 385 if (nSelectionType & nsSelectionType::SEL_FONTWORK) 386 { 387 eShellMode = SHELL_MODE_FONTWORK; 388 pShell = new svx::FontworkBar(this); 389 rDispatcher.Push( *pShell ); 390 } 391 } 392 else if ( nSelectionType & nsSelectionType::SEL_DRW_FORM ) 393 { 394 eShellMode = SHELL_MODE_DRAW_FORM; 395 pShell = new SwDrawFormShell( *this ); 396 397 rDispatcher.Push( *pShell ); 398 } 399 else if ( nSelectionType & nsSelectionType::SEL_DRW_TXT ) 400 { 401 bSetExtInpCntxt = sal_True; 402 eShellMode = SHELL_MODE_DRAWTEXT; 403 rDispatcher.Push( *(new SwBaseShell( *this )) ); 404 pShell = new SwDrawTextShell( *this ); 405 rDispatcher.Push( *pShell ); 406 } 407 else if ( nSelectionType & nsSelectionType::SEL_POSTIT ) 408 { 409 eShellMode = SHELL_MODE_POSTIT; 410 pShell = new SwAnnotationShell( *this ); 411 rDispatcher.Push( *pShell ); 412 } 413 else 414 { 415 bSetExtInpCntxt = sal_True; 416 eShellMode = SHELL_MODE_TEXT; 417 sal_uInt32 nHelpId = 0; 418 if ( nSelectionType & nsSelectionType::SEL_NUM ) 419 { 420 eShellMode = SHELL_MODE_LIST_TEXT; 421 pShell = new SwListShell( *this ); 422 nHelpId = pShell->GetHelpId(); 423 rDispatcher.Push( *pShell ); 424 } 425 pShell = new SwTextShell(*this); 426 if(nHelpId) 427 pShell->SetHelpId(nHelpId); 428 rDispatcher.Push( *pShell ); 429 if ( nSelectionType & nsSelectionType::SEL_TBL ) 430 { 431 eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT 432 : SHELL_MODE_TABLE_TEXT; 433 pShell = new SwTableShell( *this ); 434 rDispatcher.Push( *pShell ); 435 } 436 } 437 438 if ( nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL ) 439 rDispatcher.Push( *pFormShell ); 440 441 pViewImpl->SetShellMode(eShellMode); 442 ImpSetVerb( nSelectionType ); 443 444 if( !GetDocShell()->IsReadOnly() ) 445 { 446 if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() ) 447 bSetExtInpCntxt = sal_False; 448 449 InputContext aCntxt( GetEditWin().GetInputContext() ); 450 aCntxt.SetOptions( bSetExtInpCntxt 451 ? (aCntxt.GetOptions() | 452 ( INPUTCONTEXT_TEXT | 453 INPUTCONTEXT_EXTTEXTINPUT )) 454 : (aCntxt.GetOptions() & ~ 455 ( INPUTCONTEXT_TEXT | 456 INPUTCONTEXT_EXTTEXTINPUT )) ); 457 GetEditWin().SetInputContext( aCntxt ); 458 } 459 460 //Zur neuen Selektion die Toolbar aktivieren, die auch beim letzten Mal 461 //aktiviert war 462 //Vorher muss ein Flush() sein, betrifft aber lt. MBA nicht das UI und ist 463 //kein Performance-Problem 464 // TODO/LATER: maybe now the Flush() command is superfluous?! 465 rDispatcher.Flush(); 466 467 Point aPnt = GetEditWin().OutputToScreenPixel(GetEditWin().GetPointerPosPixel()); 468 aPnt = GetEditWin().PixelToLogic(aPnt); 469 GetEditWin().UpdatePointer(aPnt); 470 471 SdrView* pDView = GetWrtShell().GetDrawView(); 472 if ( bInitFormShell && pDView ) 473 pFormShell->SetView(PTR_CAST(FmFormView, pDView)); 474 475 } 476 //Guenstiger Zeitpunkt fuer die Kommunikation mit OLE-Objekten? 477 if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() ) 478 GetDocShell()->GetDoc()->PrtOLENotify( sal_False ); 479 480 //jetzt das Tabellen-Update 481 if(bUpdateTable) 482 pWrtShell->UpdateTable(); 483 484 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged(); 485 } 486 487 //Zusammenspiel: AttrChangedNotify() und TimeoutHdl. 488 //Falls noch Actions offen sind keine Aktualisierung, da der 489 //Cursor auf der Core-Seite im Wald stehen kann. 490 //Da wir aber keine Stati mehr liefern koennen und wollen locken wir 491 //stattdessen den Dispatcher. 492 493 494 495 extern "C" 496 { 497 int lcl_CmpIds( const void *pFirst, const void *pSecond) 498 { 499 return (*(sal_uInt16*)pFirst) - (*(sal_uInt16*)pSecond); 500 } 501 } 502 503 504 505 IMPL_LINK( SwView, AttrChangedNotify, SwWrtShell *, EMPTYARG ) 506 { 507 if ( GetEditWin().IsChainMode() ) 508 GetEditWin().SetChainMode( sal_False ); 509 510 //Opt: Nicht wenn PaintLocked. Beim Unlock wird dafuer nocheinmal ein 511 //Notify ausgeloest. 512 if( !pWrtShell->IsPaintLocked() && !bNoInterrupt && 513 GetDocShell()->IsReadOnly() ) 514 _CheckReadonlyState(); 515 516 // JP 19.01.99: Cursor in Readonly Bereichen 517 if( !pWrtShell->IsPaintLocked() && !bNoInterrupt ) 518 _CheckReadonlySelection(); 519 520 if( !bAttrChgNotified ) 521 { 522 if ( pWrtShell->BasicActionPend() || bNoInterrupt || 523 GetDispatcher().IsLocked() || //do not confuse the SFX 524 GetViewFrame()->GetBindings().IsInUpdate() )//do not confuse the SFX 525 { 526 bAttrChgNotified = sal_True; 527 aTimer.Start(); 528 529 const SfxPoolItem *pItem; 530 if ( SFX_ITEM_SET != GetObjectShell()->GetMedium()->GetItemSet()-> 531 GetItemState( SID_HIDDEN, sal_False, &pItem ) || 532 !((SfxBoolItem*)pItem)->GetValue() ) 533 { 534 GetViewFrame()->GetBindings().ENTERREGISTRATIONS(); 535 bAttrChgNotifiedWithRegistrations = sal_True; 536 } 537 538 } 539 else 540 SelectShell(); 541 542 } 543 544 //#i6193#, change ui if cursor is at a SwPostItField 545 if (mpPostItMgr) 546 { 547 // --> OD 2008-06-19 #i90516# 548 // only perform the code that is needed to determine, if at the 549 // actual cursor position is a post-it field 550 // SwRect aFldRect; 551 // SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD); 552 // if( pWrtShell->GetContentAtPos( pWrtShell->GetCrsrDocPos(), aCntntAtPos, sal_False, &aFldRect ) ) 553 // { 554 // const SwField* pFld = aCntntAtPos.aFnd.pFld; 555 // if (pFld->Which()== RES_POSTITFLD) 556 // { 557 // mpPostItMgr->SetShadowState(reinterpret_cast<const SwPostItField*>(pFld)); 558 // } 559 // else 560 // mpPostItMgr->SetShadowState(0); 561 // } 562 // else 563 // mpPostItMgr->SetShadowState(0); 564 mpPostItMgr->SetShadowState( pWrtShell->GetPostItFieldAtCursor() ); 565 } 566 567 return 0; 568 } 569 570 571 572 IMPL_LINK( SwView, TimeoutHdl, Timer *, EMPTYARG ) 573 { 574 DBG_PROFSTART(viewhdl); 575 576 if( pWrtShell->BasicActionPend() || bNoInterrupt ) 577 { 578 aTimer.Start(); 579 DBG_PROFSTOP(viewhdl); 580 return 0; 581 } 582 583 if ( bAttrChgNotifiedWithRegistrations ) 584 { 585 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS(); 586 bAttrChgNotifiedWithRegistrations = sal_False; 587 } 588 589 _CheckReadonlyState(); 590 _CheckReadonlySelection(); 591 592 sal_Bool bOldUndo = pWrtShell->DoesUndo(); 593 pWrtShell->DoUndo( sal_False ); 594 SelectShell(); 595 pWrtShell->DoUndo( bOldUndo ); 596 bAttrChgNotified = sal_False; 597 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged(); 598 599 DBG_PROFSTOP(viewhdl); 600 return 0; 601 } 602 603 void SwView::_CheckReadonlyState() 604 { 605 SfxDispatcher &rDis = GetDispatcher(); 606 //Um erkennen zu koennen ob bereits disabled ist! 607 SfxItemState eStateRO, eStateProtAll; 608 const SfxPoolItem *pItem; 609 // JP 29.04.97: von einem nur uns bekannten Slot den Status abfragen. 610 // Ansonsten kennen andere den Slot; wie z.B. die BasidIde 611 eStateRO = rDis.QueryState( FN_INSERT_BOOKMARK, pItem ); 612 eStateProtAll = rDis.QueryState( FN_EDIT_REGION, pItem ); 613 sal_Bool bChgd = sal_False; 614 615 if ( !pWrtShell->IsCrsrReadonly() ) 616 { 617 static sal_uInt16 aROIds[] = 618 { 619 SID_DELETE, FN_BACKSPACE, FN_SHIFT_BACKSPACE, 620 SID_UNDO, 621 SID_REDO, SID_REPEAT, SID_PASTE, 622 SID_PASTE_UNFORMATTED, 623 SID_PASTE_SPECIAL, SID_SBA_BRW_INSERT, 624 SID_BACKGROUND_COLOR, FN_INSERT_BOOKMARK, 625 SID_CHARMAP, FN_INSERT_SOFT_HYPHEN, 626 FN_INSERT_HARDHYPHEN, FN_INSERT_HARD_SPACE, FN_INSERT_BREAK, 627 FN_INSERT_LINEBREAK, FN_INSERT_COLUMN_BREAK, FN_INSERT_BREAK_DLG, 628 FN_DELETE_SENT, FN_DELETE_BACK_SENT, FN_DELETE_WORD, 629 FN_DELETE_BACK_WORD, FN_DELETE_LINE, FN_DELETE_BACK_LINE, 630 FN_DELETE_PARA, FN_DELETE_BACK_PARA, FN_DELETE_WHOLE_LINE, 631 FN_CALCULATE, FN_FORMAT_RESET, 632 FN_POSTIT, FN_JAVAEDIT, SID_ATTR_PARA_ADJUST_LEFT, 633 SID_ATTR_PARA_ADJUST_RIGHT, SID_ATTR_PARA_ADJUST_CENTER,SID_ATTR_PARA_ADJUST_BLOCK, 634 SID_ATTR_PARA_LINESPACE_10, SID_ATTR_PARA_LINESPACE_15, SID_ATTR_PARA_LINESPACE_20, 635 SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_FONTHEIGHT, SID_ATTR_CHAR_COLOR_BACKGROUND, 636 SID_ATTR_CHAR_COLOR_BACKGROUND_EXT, SID_ATTR_CHAR_COLOR_EXT, 637 SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_WEIGHT, SID_ATTR_CHAR_POSTURE, 638 SID_ATTR_CHAR_OVERLINE, 639 SID_ATTR_CHAR_UNDERLINE, SID_ATTR_FLASH, SID_ATTR_CHAR_STRIKEOUT, 640 FN_UNDERLINE_DOUBLE, SID_ATTR_CHAR_CONTOUR, SID_ATTR_CHAR_SHADOWED, 641 SID_ATTR_CHAR_AUTOKERN, SID_ATTR_CHAR_ESCAPEMENT, FN_SET_SUPER_SCRIPT, 642 FN_SET_SUB_SCRIPT, SID_ATTR_CHAR_CASEMAP, SID_ATTR_CHAR_LANGUAGE, 643 SID_ATTR_CHAR_KERNING, SID_CHAR_DLG, SID_ATTR_CHAR_WORDLINEMODE, 644 FN_GROW_FONT_SIZE, FN_SHRINK_FONT_SIZE, FN_TXTATR_INET, 645 FN_FORMAT_DROPCAPS, SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_LINESPACE, 646 SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_KEEP, SID_ATTR_PARA_WIDOWS, 647 SID_ATTR_PARA_ORPHANS, 648 SID_ATTR_PARA_MODEL, SID_PARA_DLG, 649 FN_SELECT_PARA, SID_DEC_INDENT, 650 SID_INC_INDENT 651 }; 652 static sal_Bool bFirst = sal_True; 653 if ( bFirst ) 654 { 655 qsort( (void*)aROIds, sizeof(aROIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds ); 656 bFirst = sal_False; 657 } 658 if ( SFX_ITEM_DISABLED == eStateRO ) 659 { 660 rDis.SetSlotFilter( sal_Bool(2), sizeof(aROIds)/sizeof(sal_uInt16), aROIds ); 661 bChgd = sal_True; 662 } 663 } 664 else if( pWrtShell->IsAllProtect() ) 665 { 666 if ( SFX_ITEM_DISABLED == eStateProtAll ) 667 { 668 static sal_uInt16 aAllProtIds[] = { SID_SAVEDOC, FN_EDIT_REGION }; 669 static sal_Bool bAllProtFirst = sal_True; 670 if ( bAllProtFirst ) 671 { 672 qsort( (void*)aAllProtIds, sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds ); 673 bAllProtFirst = sal_False; 674 } 675 rDis.SetSlotFilter( sal_Bool(2), 676 sizeof(aAllProtIds)/sizeof(sal_uInt16), 677 aAllProtIds ); 678 bChgd = sal_True; 679 } 680 } 681 else if ( SFX_ITEM_DISABLED != eStateRO || 682 SFX_ITEM_DISABLED != eStateProtAll ) 683 { 684 bChgd = sal_True; 685 rDis.SetSlotFilter(); 686 } 687 if ( bChgd ) 688 GetViewFrame()->GetBindings().InvalidateAll(sal_True); 689 } 690 691 void SwView::_CheckReadonlySelection() 692 { 693 sal_uInt32 nDisableFlags = 0; 694 SfxDispatcher &rDis = GetDispatcher(); 695 696 if( pWrtShell->HasReadonlySel() && 697 ( !pWrtShell->GetDrawView() || 698 !pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount() )) 699 nDisableFlags |= SW_DISABLE_ON_PROTECTED_CURSOR; 700 701 if( (SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags ) != 702 (SW_DISABLE_ON_PROTECTED_CURSOR & rDis.GetDisableFlags() ) ) 703 { 704 // zusaetzlich am Window den InputContext umsetzen, damit in 705 // japanischen / chinesischen Versionen die externe Eingabe 706 // ab-/angeschaltet wird. Das aber nur wenn auch die richtige 707 // Shell auf dem Stack steht. 708 switch( pViewImpl->GetShellMode() ) 709 { 710 case SHELL_MODE_TEXT: 711 case SHELL_MODE_LIST_TEXT: 712 case SHELL_MODE_TABLE_TEXT: 713 case SHELL_MODE_TABLE_LIST_TEXT: 714 { 715 //JP 22.01.99: temporaere Loesung!!! Sollte bei jeder Cursorbewegung 716 // den Font von der akt. Einfuegeposition setzen, also ausserhalb 717 // dieses if's. Aber TH wertet den Font zur Zeit nicht aus und 718 // das besorgen erscheint mir hier zu teuer zu sein. 719 // Ausserdem haben wir keinen Font, sondern nur Attribute aus denen 720 // die Textformatierung dann den richtigen Font zusammen baut. 721 722 InputContext aCntxt( GetEditWin().GetInputContext() ); 723 aCntxt.SetOptions( SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags 724 ? (aCntxt.GetOptions() & ~ 725 ( INPUTCONTEXT_TEXT | 726 INPUTCONTEXT_EXTTEXTINPUT )) 727 : (aCntxt.GetOptions() | 728 ( INPUTCONTEXT_TEXT | 729 INPUTCONTEXT_EXTTEXTINPUT )) ); 730 GetEditWin().SetInputContext( aCntxt ); 731 } 732 break; 733 default: 734 ; 735 } 736 737 } 738 739 if( nDisableFlags != rDis.GetDisableFlags() ) 740 { 741 rDis.SetDisableFlags( nDisableFlags ); 742 GetViewFrame()->GetBindings().InvalidateAll( sal_True ); 743 } 744 } 745 746 747 SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) 748 : SfxViewShell( _pFrame, SWVIEWFLAGS ), 749 aPageStr( SW_RES( STR_PAGE )), 750 nNewPage(USHRT_MAX), 751 pNumRuleNodeFromDoc(0), // #i23726# 752 pEditWin( new SwEditWin( &_pFrame->GetWindow(), *this ) ), 753 pWrtShell(0), 754 pShell(0), 755 pFormShell(0), 756 pHScrollbar(0), 757 pVScrollbar(0), 758 pScrollFill(new ScrollBarBox( &_pFrame->GetWindow(), _pFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )), 759 pHRuler( new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin, 760 SVXRULER_SUPPORT_TABS | 761 SVXRULER_SUPPORT_PARAGRAPH_MARGINS | 762 SVXRULER_SUPPORT_BORDERS | 763 SVXRULER_SUPPORT_NEGATIVE_MARGINS| 764 SVXRULER_SUPPORT_REDUCED_METRIC, 765 GetViewFrame()->GetBindings(), 766 WB_STDRULER | WB_EXTRAFIELD | WB_BORDER)), 767 pVRuler(new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin, 768 SVXRULER_SUPPORT_TABS | SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL| 769 SVXRULER_SUPPORT_BORDERS | SVXRULER_SUPPORT_REDUCED_METRIC, 770 GetViewFrame()->GetBindings(), 771 WB_VSCROLL | WB_EXTRAFIELD | WB_BORDER )), 772 pTogglePageBtn(0), 773 pPageUpBtn(0), 774 pPageDownBtn(0), 775 pNaviBtn(0), 776 pGlosHdl(0), 777 pDrawActual(0), 778 pLastTableFormat(0), 779 pFormatClipboard(new SwFormatClipboard()), 780 mpPostItMgr(0), 781 nSelectionType( INT_MAX ), 782 nPageCnt(0), 783 nDrawSfxId( USHRT_MAX ), 784 nFormSfxId( USHRT_MAX ), 785 nLastPasteDestination( 0xFFFF ), 786 nLeftBorderDistance( 0 ), 787 nRightBorderDistance( 0 ), 788 bInMailMerge(sal_False), 789 bInDtor(sal_False), 790 bOldShellWasPagePreView(sal_False), 791 bIsPreviewDoubleClick(sal_False) 792 { 793 // OD 18.12.2002 #103492# - According to discussion with MBA and further 794 // investigations, no old SfxViewShell will be set as parameter <pOldSh>, 795 // if function "New Window" is performed to open an additional view beside 796 // an already existing one. 797 // If the view is switch from one to another, the 'old' view is given by 798 // parameter <pOldSh>. 799 800 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwView::SwView" ); 801 802 bCenterCrsr = bTopCrsr = bAllwaysShowSel = bTabColFromDoc = bTabRowFromDoc = 803 bSetTabColFromDoc = bSetTabRowFromDoc = bAttrChgNotified = bAttrChgNotifiedWithRegistrations = 804 bVerbsActive = bDrawRotate = bInOuterResizePixel = bInInnerResizePixel = 805 bPasteState = bPasteSpecialState = bMakeSelectionVisible = sal_False; 806 807 bShowAtResize = bDrawSelMode = bDocSzUpdated = sal_True; 808 809 _CreateScrollbar( sal_True ); 810 _CreateScrollbar( sal_False ); 811 812 pViewImpl = new SwView_Impl(this); 813 SetName(C2S("View")); 814 SetWindow( pEditWin ); 815 816 aTimer.SetTimeout( 120 ); 817 818 SwDocShell* pDocSh = PTR_CAST( SwDocShell, _pFrame->GetObjectShell() ); 819 sal_Bool bOldModifyFlag = pDocSh->IsEnableSetModified(); 820 if(bOldModifyFlag) 821 pDocSh->EnableSetModified( sal_False ); 822 ASSERT( pDocSh, "View ohne DocShell." ); 823 SwWebDocShell* pWebDShell = PTR_CAST( SwWebDocShell, pDocSh ); 824 825 const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(0 != pWebDShell); 826 SwViewOption aUsrPref( *pUsrPref); 827 828 //! get lingu options without loading lingu DLL 829 SvtLinguOptions aLinguOpt; 830 SvtLinguConfig().GetOptions( aLinguOpt ); 831 aUsrPref.SetOnlineSpell( aLinguOpt.bIsSpellAuto ); 832 833 sal_Bool bOldShellWasSrcView = sal_False; 834 835 // OD 18.12.2002 #103492# - determine, if there is an existing view for 836 // document 837 SfxViewShell* pExistingSh = 0; 838 if ( pOldSh ) 839 { 840 pExistingSh = pOldSh; 841 // determine type of existing view 842 if( pExistingSh->IsA( TYPE( SwPagePreView ) ) ) 843 { 844 sSwViewData = ((SwPagePreView*)pExistingSh)->GetPrevSwViewData(); 845 sNewCrsrPos = ((SwPagePreView*)pExistingSh)->GetNewCrsrPos(); 846 nNewPage = ((SwPagePreView*)pExistingSh)->GetNewPage(); 847 bOldShellWasPagePreView = sal_True; 848 bIsPreviewDoubleClick = sNewCrsrPos.Len() > 0 || nNewPage != USHRT_MAX; 849 } 850 else if( pExistingSh->IsA( TYPE( SwSrcView ) ) ) 851 bOldShellWasSrcView = sal_True; 852 } 853 854 RTL_LOGFILE_CONTEXT_TRACE( aLog, "before create WrtShell" ); 855 if(PTR_CAST( SwView, pExistingSh)) 856 { 857 pWrtShell = new SwWrtShell( *((SwView*)pExistingSh)->pWrtShell, 858 pEditWin, *this); 859 } 860 else if( dynamic_cast<SwWrtShell*>( pDocSh->GetDoc()->GetCurrentViewShell() ) ) 861 { 862 pWrtShell = new SwWrtShell( *(SwWrtShell*)pDocSh->GetDoc()->GetCurrentViewShell(), 863 pEditWin, *this); 864 } 865 else 866 { 867 SwDoc& rDoc = *((SwDocShell*)pDocSh)->GetDoc(); 868 869 if( !bOldShellWasSrcView && pWebDShell && !bOldShellWasPagePreView ) 870 aUsrPref.setBrowseMode( sal_True ); 871 else if( rDoc.IsLoaded() ) 872 aUsrPref.setBrowseMode( rDoc.get(IDocumentSettingAccess::BROWSE_MODE) ); 873 874 //Fuer den BrowseMode wollen wir keinen Factor uebernehmen. 875 if( aUsrPref.getBrowseMode() && aUsrPref.GetZoomType() != SVX_ZOOM_PERCENT ) 876 { 877 aUsrPref.SetZoomType( SVX_ZOOM_PERCENT ); 878 aUsrPref.SetZoom( 100 ); 879 } 880 if(pDocSh->IsPreview()) 881 { 882 aUsrPref.SetZoomType( SVX_ZOOM_WHOLEPAGE ); 883 aUsrPref.SetViewLayoutBookMode( false ); 884 aUsrPref.SetViewLayoutColumns( 1 ); 885 } 886 pWrtShell = new SwWrtShell( rDoc, pEditWin, *this, &aUsrPref ); 887 //#97610# creating an SwView from a SwPagePreView needs to 888 // add the ViewShell to the ring of the other ViewShell(s) 889 if(bOldShellWasPagePreView) 890 { 891 ViewShell& rPreviewViewShell = *((SwPagePreView*)pExistingSh)->GetViewShell(); 892 pWrtShell->MoveTo(&rPreviewViewShell); 893 //#95521# to update the field command et.al. if necessary 894 const SwViewOption* pPreViewOpt = rPreviewViewShell.GetViewOptions(); 895 if( pPreViewOpt->IsFldName() != aUsrPref.IsFldName() || 896 pPreViewOpt->IsShowHiddenField() != aUsrPref.IsShowHiddenField() || 897 pPreViewOpt->IsShowHiddenPara() != aUsrPref.IsShowHiddenPara() || 898 pPreViewOpt->IsShowHiddenChar() != aUsrPref.IsShowHiddenChar() ) 899 rPreviewViewShell.ApplyViewOptions(aUsrPref); 900 // OD 09.01.2003 #106334# - reset design mode at draw view for form 901 // shell, if needed. 902 if ( ((SwPagePreView*)pExistingSh)->ResetFormDesignMode() && 903 pWrtShell->HasDrawView() ) 904 { 905 SdrView* pDrawView = pWrtShell->GetDrawView(); 906 pDrawView->SetDesignMode( ((SwPagePreView*)pExistingSh)->FormDesignModeToReset() ); 907 } 908 } 909 } 910 RTL_LOGFILE_CONTEXT_TRACE( aLog, "after create WrtShell" ); 911 912 // --> OD 2005-02-11 #i38810# - assure that modified state of document 913 // isn't reset, if document is already modified. 914 const bool bIsDocModified = pWrtShell->GetDoc()->IsModified(); 915 // <-- 916 917 // JP 05.02.99: Bug 61495 - damit unter anderem das HLineal im 918 // ReadonlyFall nicht angezeigt wird 919 aUsrPref.SetReadonly( pWrtShell->GetViewOptions()->IsReadonly() ); 920 921 //Kein Margin fuer OLE! 922 Size aBrwsBorder; 923 if( SFX_CREATE_MODE_EMBEDDED != pDocSh->GetCreateMode() ) 924 aBrwsBorder = GetMargin(); 925 926 pWrtShell->SetBrowseBorder( aBrwsBorder ); 927 928 // Im CTOR duerfen keine Shell wechsel erfolgen, die muessen ueber 929 // den Timer "zwischen gespeichert" werden. Sonst raeumt der SFX 930 // sie wieder vom Stack! 931 sal_Bool bOld = bNoInterrupt; 932 bNoInterrupt = sal_True; 933 934 pHRuler->SetActive( sal_True ); 935 pVRuler->SetActive( sal_True ); 936 937 SfxViewFrame* pViewFrame = GetViewFrame(); 938 if( pViewFrame->GetFrame().GetParentFrame()) 939 { 940 aUsrPref.SetViewHRuler(sal_False); 941 aUsrPref.SetViewVRuler(sal_False); 942 } 943 944 StartListening( *pViewFrame, sal_True ); 945 StartListening( *pDocSh, sal_True ); 946 947 // Vom HLineal den ZOOM-Faktor einstellen 948 Fraction aZoomFract( aUsrPref.GetZoom(), 100 ); 949 pHRuler->SetZoom( aZoomFract ); 950 pVRuler->SetZoom( aZoomFract ); 951 pHRuler->SetDoubleClickHdl(LINK( this, SwView, ExecRulerClick )); 952 FieldUnit eMetric = pUsrPref->GetHScrollMetric(); 953 pHRuler->SetUnit( eMetric ); 954 eMetric = pUsrPref->GetVScrollMetric(); 955 pVRuler->SetUnit( eMetric ); 956 957 // DocShell setzen 958 pDocSh->SetView( this ); 959 SW_MOD()->SetView( this ); 960 961 mpPostItMgr = new SwPostItMgr(this); 962 963 // Die DocSize erfragen und verarbeiten. Ueber die Handler konnte 964 // die Shell nicht gefunden werden, weil die Shell innerhalb CTOR-Phase 965 // nicht in der SFX-Verwaltung bekannt ist. 966 DocSzChgd( pWrtShell->GetDocSize() ); 967 968 // AttrChangedNotify Link setzen 969 pWrtShell->SetChgLnk(LINK(this, SwView, AttrChangedNotify)); 970 971 if( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED && 972 //TODO/LATER: why a cast here? 973 //!((SvEmbeddedObject *)pDocSh)->GetVisArea().IsEmpty() ) 974 //SetVisArea( ((SvEmbeddedObject *)pDocSh)->GetVisArea(),sal_False); 975 !pDocSh->GetVisArea(ASPECT_CONTENT).IsEmpty() ) 976 SetVisArea( pDocSh->GetVisArea(ASPECT_CONTENT),sal_False); 977 978 pWrtShell->DoUndo( 0 != SW_MOD()->GetUndoOptions().GetUndoCount() ); 979 980 const sal_Bool bBrowse = pWrtShell->GetViewOptions()->getBrowseMode(); 981 // Disable "multiple window" 982 SetNewWindowAllowed(!bBrowse); 983 // End of disabled multiple window 984 985 ShowVScrollbar(aUsrPref.IsViewVScrollBar()); 986 ShowHScrollbar(aUsrPref.IsViewHScrollBar()); 987 pHScrollbar->SetAuto(bBrowse); 988 if( aUsrPref.IsViewHRuler() ) 989 CreateTab(); 990 if( aUsrPref.IsViewVRuler() ) 991 CreateVLineal(); 992 993 pWrtShell->SetUIOptions( aUsrPref ); 994 pWrtShell->SetReadOnlyAvailable( aUsrPref.IsCursorInProtectedArea() ); 995 pWrtShell->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions()); 996 997 if( pWrtShell->GetDoc()->IsUpdateExpFld() ) 998 { 999 SET_CURR_SHELL( pWrtShell ); 1000 pWrtShell->StartAction(); 1001 pWrtShell->CalcLayout(); 1002 pWrtShell->GetDoc()->UpdateFlds(NULL, false); 1003 pWrtShell->EndAction(); 1004 pWrtShell->GetDoc()->SetUpdateExpFldStat( sal_False ); 1005 } 1006 1007 // ggfs. alle Verzeichnisse updaten: 1008 if( pWrtShell->GetDoc()->IsUpdateTOX() ) 1009 { 1010 SfxRequest aSfxRequest( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() ); 1011 Execute( aSfxRequest ); 1012 pWrtShell->GetDoc()->SetUpdateTOX( sal_False ); // wieder zurueck setzen 1013 pWrtShell->SttEndDoc(sal_True); 1014 } 1015 1016 // kein ResetModified, wenn es schone eine View auf dieses Doc gibt 1017 SfxViewFrame* pVFrame = GetViewFrame(); 1018 SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh); 1019 // zur Zeit(360) wird die View erst nach dem Ctor eingetragen 1020 // der folgende Ausdruck funktioniert auch, wenn sich das aendert 1021 //JP 27.07.98: wenn per Undo nicht mehr die Modifizierung aufhebar ist, 1022 // so setze das Modified NICHT zurueck. 1023 // --> OD 2005-02-11 #i38810# - no reset of modified state, if document 1024 // was already modified. 1025 if (!pWrtShell->GetDoc()->GetIDocumentUndoRedo().IsUndoNoResetModified() && 1026 ( !pFirst || pFirst == pVFrame ) && 1027 !bIsDocModified ) 1028 // <-- 1029 { 1030 pWrtShell->ResetModified(); 1031 } 1032 1033 bNoInterrupt = bOld; 1034 1035 // wird ein GlobalDoc neu angelegt, soll auch der Navigator erzeugt werden 1036 if( pDocSh->IsA(SwGlobalDocShell::StaticType()) && 1037 !pVFrame->GetChildWindow( SID_NAVIGATOR )) 1038 { 1039 SfxBoolItem aNavi(SID_NAVIGATOR, sal_True); 1040 GetDispatcher().Execute(SID_NAVIGATOR, SFX_CALLMODE_ASYNCHRON, &aNavi, 0L); 1041 } 1042 1043 1044 uno::Reference< frame::XFrame > xFrame = pVFrame->GetFrame().GetFrameInterface(); 1045 1046 uno::Reference< frame::XFrame > xBeamerFrame = xFrame->findFrame( 1047 OUString::createFromAscii("_beamer"), frame::FrameSearchFlag::CHILDREN); 1048 if(xBeamerFrame.is()) 1049 { 1050 SwDBData aData = pWrtShell->GetDBData(); 1051 SW_MOD()->ShowDBObj( *this, aData ); 1052 } 1053 1054 // has anybody calls the attrchanged handler in the constructor? 1055 if( bAttrChgNotifiedWithRegistrations ) 1056 { 1057 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS(); 1058 if( aTimer.IsActive() ) 1059 aTimer.Stop(); 1060 } 1061 1062 aTimer.SetTimeoutHdl(LINK(this, SwView, TimeoutHdl)); 1063 bAttrChgNotified = bAttrChgNotifiedWithRegistrations = sal_False; 1064 if(bOldModifyFlag) 1065 pDocSh->EnableSetModified( sal_True ); 1066 InvalidateBorder(); 1067 } 1068 1069 SwView::~SwView() 1070 { 1071 delete mpPostItMgr; 1072 // --> OD 2009-03-10 #i100035# 1073 mpPostItMgr = 0; 1074 // <-- 1075 1076 bInDtor = sal_True; 1077 pEditWin->Hide(); // damit kein Paint Aerger machen kann! 1078 // An der SwDocShell den Pointer auf die View ruecksetzen 1079 SwDocShell* pDocSh = GetDocShell(); 1080 if( pDocSh && pDocSh->GetView() == this ) 1081 pDocSh->SetView( 0 ); 1082 if ( SW_MOD()->GetView() == this ) 1083 SW_MOD()->SetView( 0 ); 1084 1085 if( aTimer.IsActive() && bAttrChgNotifiedWithRegistrations ) 1086 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS(); 1087 1088 //JP 27.11.00: Bug 80631 - the last view must end the text edit 1089 SdrView *pSdrView = pWrtShell ? pWrtShell->GetDrawView() : 0; 1090 if( pSdrView && pSdrView->IsTextEdit() ) 1091 pSdrView->SdrEndTextEdit( sal_True ); 1092 1093 SetWindow( 0 ); 1094 1095 pViewImpl->Invalidate(); 1096 EndListening(*GetViewFrame()); 1097 EndListening(*GetDocShell()); 1098 delete pScrollFill; 1099 delete pWrtShell; 1100 pWrtShell = 0; // Auf 0 setzen, damit folgende DToren nicht drauf zugreifen 1101 pShell = 0; 1102 delete pHScrollbar; 1103 delete pVScrollbar; 1104 delete pHRuler; 1105 delete pVRuler; 1106 delete pTogglePageBtn; 1107 delete pPageUpBtn; 1108 delete pNaviBtn; 1109 delete pPageDownBtn; 1110 delete pGlosHdl; 1111 delete pViewImpl; 1112 delete pEditWin; 1113 delete pFormatClipboard; 1114 } 1115 1116 SwDocShell* SwView::GetDocShell() 1117 { 1118 SfxObjectShell* pDocShell = GetViewFrame()->GetObjectShell(); 1119 return PTR_CAST(SwDocShell, pDocShell); 1120 } 1121 1122 /*-------------------------------------------------------------------- 1123 Beschreibung: CursorPos merken 1124 --------------------------------------------------------------------*/ 1125 1126 1127 void SwView::WriteUserData( String &rUserData, sal_Bool bBrowse ) 1128 { 1129 //Das Browse-Flag wird vom Sfx durchgereicht, wenn Dokumente gebrowsed 1130 //werden (nicht zu verwechseln mit dem BrowseMode). 1131 //Die dann gespeicherten Daten sind nicht persistent!! 1132 1133 const SwRect& rRect = pWrtShell->GetCharRect(); 1134 const Rectangle& rVis = GetVisArea(); 1135 1136 rUserData = String::CreateFromInt32( rRect.Left() ); 1137 rUserData += ';'; 1138 rUserData += String::CreateFromInt32( rRect.Top() ); 1139 rUserData += ';'; 1140 rUserData += String::CreateFromInt32( pWrtShell->GetViewOptions()->GetZoom() ); 1141 rUserData += ';'; 1142 rUserData += String::CreateFromInt32( rVis.Left() ); 1143 rUserData += ';'; 1144 rUserData += String::CreateFromInt32( rVis.Top() ); 1145 rUserData += ';'; 1146 rUserData += String::CreateFromInt32( bBrowse ? LONG_MIN : rVis.Right()); 1147 rUserData += ';'; 1148 rUserData += String::CreateFromInt32( bBrowse ? LONG_MIN : rVis.Bottom()); 1149 rUserData += ';'; 1150 rUserData += String::CreateFromInt32( 1151 (sal_uInt16)pWrtShell->GetViewOptions()->GetZoomType());//eZoom; 1152 rUserData += ';'; 1153 rUserData += FRMTYPE_NONE == pWrtShell->GetSelFrmType() ? '0' : '1'; 1154 } 1155 /*-------------------------------------------------------------------- 1156 Beschreibung: CursorPos setzen 1157 --------------------------------------------------------------------*/ 1158 //#i43146# go to the last editing position when opening own files 1159 bool lcl_IsOwnDocument( SwView& rView ) 1160 { 1161 uno::Reference<document::XDocumentPropertiesSupplier> xDPS( 1162 rView.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW); 1163 uno::Reference<document::XDocumentProperties> xDocProps 1164 = xDPS->getDocumentProperties(); 1165 String Created = xDocProps->getAuthor(); 1166 String Changed = xDocProps->getModifiedBy(); 1167 String FullName = SW_MOD()->GetUserOptions().GetFullName(); 1168 return (FullName.Len() && 1169 (Changed.Len() && Changed == FullName )) || 1170 (!Changed.Len() && Created.Len() && Created == FullName ); 1171 } 1172 1173 1174 void SwView::ReadUserData( const String &rUserData, sal_Bool bBrowse ) 1175 { 1176 if ( rUserData.GetTokenCount() > 1 && 1177 //Fuer Dokumente ohne Layout nur im OnlineLayout oder beim 1178 //Forward/Backward 1179 (!pWrtShell->IsNewLayout() || pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse) ) 1180 { 1181 //#i43146# go to the last editing position when opening own files 1182 bool bIsOwnDocument = lcl_IsOwnDocument( *this ); 1183 1184 SET_CURR_SHELL(pWrtShell); 1185 1186 sal_uInt16 nPos = 0; 1187 1188 // Nein, es ist *keine* gute Idee GetToken gleich im Point-Konstr. 1189 // aufzurufen, denn welcher Parameter wird zuerst ausgewertet? 1190 long nX = rUserData.GetToken( 0, ';', nPos ).ToInt32(), 1191 nY = rUserData.GetToken( 0, ';', nPos ).ToInt32(); 1192 Point aCrsrPos( nX, nY ); 1193 1194 sal_uInt16 nZoomFactor = 1195 static_cast< sal_uInt16 >( rUserData.GetToken(0, ';', nPos ).ToInt32() ); 1196 1197 long nLeft = rUserData.GetToken(0, ';', nPos ).ToInt32(), 1198 nTop = rUserData.GetToken(0, ';', nPos ).ToInt32(), 1199 nRight = rUserData.GetToken(0, ';', nPos ).ToInt32(), 1200 nBottom= rUserData.GetToken(0, ';', nPos ).ToInt32(); 1201 1202 const long nAdd = pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2; 1203 if ( nBottom <= (pWrtShell->GetDocSize().Height()+nAdd) ) 1204 { 1205 pWrtShell->EnableSmooth( sal_False ); 1206 1207 const Rectangle aVis( nLeft, nTop, nRight, nBottom ); 1208 1209 sal_uInt16 nOff = 0; 1210 SvxZoomType eZoom; 1211 if( !pWrtShell->GetViewOptions()->getBrowseMode() ) 1212 eZoom = (SvxZoomType) (sal_uInt16)rUserData.GetToken(nOff, ';', nPos ).ToInt32(); 1213 else 1214 { 1215 eZoom = SVX_ZOOM_PERCENT; 1216 ++nOff; 1217 } 1218 1219 sal_Bool bSelectObj = (0 != rUserData.GetToken( nOff, ';', nPos ).ToInt32()) 1220 && pWrtShell->IsObjSelectable( aCrsrPos ); 1221 1222 //#i33307# restore editing position 1223 pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj); 1224 // OD 11.02.2003 #100556# - set flag value to avoid macro execution. 1225 bool bSavedFlagValue = pWrtShell->IsMacroExecAllowed(); 1226 pWrtShell->SetMacroExecAllowed( false ); 1227 //!!! pb (11.08.2004): #i32536# 1228 // os: changed: The user data has to be read if the view is switched back from page preview 1229 //#i43146# go to the last editing position when opening own files 1230 if(bOldShellWasPagePreView || bIsOwnDocument) 1231 { 1232 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj ); 1233 if( bSelectObj ) 1234 { 1235 pWrtShell->SelectObj( aCrsrPos ); 1236 pWrtShell->EnterSelFrmMode( &aCrsrPos ); 1237 } 1238 } 1239 1240 // OD 11.02.2003 #100556# - reset flag value 1241 pWrtShell->SetMacroExecAllowed( bSavedFlagValue ); 1242 1243 // OD 08.04.2003 #108693# - set visible area before applying 1244 // information from print preview. Otherwise, the applied information 1245 // is lost. 1246 //!!! pb (11.08.2004): #i32536# 1247 // os: changed: The user data has to be read if the view is switched back from page preview 1248 //#i43146# go to the last editing position when opening own files 1249 if(bOldShellWasPagePreView || bIsOwnDocument ) 1250 { 1251 if ( bBrowse ) 1252 SetVisArea( aVis.TopLeft() ); 1253 else 1254 SetVisArea( aVis ); 1255 } 1256 1257 //apply information from print preview - if available 1258 if( sNewCrsrPos.Len() ) 1259 { 1260 long nXTmp = sNewCrsrPos.GetToken( 0, ';' ).ToInt32(), 1261 nYTmp = sNewCrsrPos.GetToken( 1, ';' ).ToInt32(); 1262 Point aCrsrPos2( nXTmp, nYTmp ); 1263 bSelectObj = pWrtShell->IsObjSelectable( aCrsrPos2 ); 1264 1265 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos2, sal_False ); 1266 if( bSelectObj ) 1267 { 1268 pWrtShell->SelectObj( aCrsrPos2 ); 1269 pWrtShell->EnterSelFrmMode( &aCrsrPos2 ); 1270 } 1271 pWrtShell->MakeSelVisible(); 1272 sNewCrsrPos.Erase(); 1273 } 1274 else if(USHRT_MAX != nNewPage) 1275 { 1276 pWrtShell->GotoPage(nNewPage, sal_True); 1277 nNewPage = USHRT_MAX; 1278 } 1279 1280 SelectShell(); 1281 1282 pWrtShell->StartAction(); 1283 const SwViewOption* pVOpt = pWrtShell->GetViewOptions(); 1284 if( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom ) 1285 SetZoom( eZoom, nZoomFactor); 1286 1287 pWrtShell->LockView( sal_True ); 1288 pWrtShell->EndAction(); 1289 pWrtShell->LockView( sal_False ); 1290 pWrtShell->EnableSmooth( sal_True ); 1291 } 1292 } 1293 } 1294 1295 void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse ) 1296 { 1297 if(GetDocShell()->IsPreview()||bIsPreviewDoubleClick) 1298 return; 1299 //#i43146# go to the last editing position when opening own files 1300 bool bIsOwnDocument = lcl_IsOwnDocument( *this ); 1301 sal_Int32 nLength = rSequence.getLength(); 1302 if (nLength && (!pWrtShell->IsNewLayout() || pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse) ) 1303 { 1304 SET_CURR_SHELL(pWrtShell); 1305 const beans::PropertyValue *pValue = rSequence.getConstArray(); 1306 const SwRect& rRect = pWrtShell->GetCharRect(); 1307 const Rectangle &rVis = GetVisArea(); 1308 const SwViewOption* pVOpt = pWrtShell->GetViewOptions(); 1309 1310 long nX = rRect.Left(), nY = rRect.Top(), nLeft = rVis.Left(), nTop = rVis.Top(); 1311 long nRight = bBrowse ? LONG_MIN : rVis.Right(), nBottom = bBrowse ? LONG_MIN : rVis.Bottom(); 1312 sal_Int16 nZoomType = static_cast< sal_Int16 >(pVOpt->GetZoomType()); 1313 sal_Int16 nZoomFactor = static_cast < sal_Int16 > (pVOpt->GetZoom()); 1314 bool bViewLayoutBookMode = pVOpt->IsViewLayoutBookMode(); 1315 sal_Int16 nViewLayoutColumns = pVOpt->GetViewLayoutColumns(); 1316 1317 sal_Bool bSelectedFrame = ( pWrtShell->GetSelFrmType() != FRMTYPE_NONE ), 1318 bGotViewLeft = sal_False, bGotViewTop = sal_False, bGotVisibleLeft = sal_False, 1319 bGotVisibleTop = sal_False, bGotVisibleRight = sal_False, 1320 bGotVisibleBottom = sal_False, bGotZoomType = sal_False, 1321 bGotZoomFactor = sal_False, bGotIsSelectedFrame = sal_False, 1322 bGotViewLayoutColumns = sal_False, bGotViewLayoutBookMode = sal_False; 1323 1324 for (sal_Int16 i = 0 ; i < nLength; i++) 1325 { 1326 if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLeft" ) ) ) 1327 { 1328 pValue->Value >>= nX; 1329 nX = MM100_TO_TWIP( nX ); 1330 bGotViewLeft = sal_True; 1331 } 1332 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewTop" ) ) ) 1333 { 1334 pValue->Value >>= nY; 1335 nY = MM100_TO_TWIP( nY ); 1336 bGotViewTop = sal_True; 1337 } 1338 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleLeft" ) ) ) 1339 { 1340 pValue->Value >>= nLeft; 1341 nLeft = MM100_TO_TWIP( nLeft ); 1342 bGotVisibleLeft = sal_True; 1343 } 1344 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleTop" ) ) ) 1345 { 1346 pValue->Value >>= nTop; 1347 nTop = MM100_TO_TWIP( nTop ); 1348 bGotVisibleTop = sal_True; 1349 } 1350 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleRight" ) ) ) 1351 { 1352 pValue->Value >>= nRight; 1353 nRight = MM100_TO_TWIP( nRight ); 1354 bGotVisibleRight = sal_True; 1355 } 1356 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleBottom" ) ) ) 1357 { 1358 pValue->Value >>= nBottom; 1359 nBottom = MM100_TO_TWIP( nBottom ); 1360 bGotVisibleBottom = sal_True; 1361 } 1362 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ZoomType" ) ) ) 1363 { 1364 pValue->Value >>= nZoomType; 1365 bGotZoomType = sal_True; 1366 } 1367 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ZoomFactor" ) ) ) 1368 { 1369 pValue->Value >>= nZoomFactor; 1370 bGotZoomFactor = sal_True; 1371 } 1372 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLayoutColumns" ) ) ) 1373 { 1374 pValue->Value >>= nViewLayoutColumns; 1375 bGotViewLayoutColumns = sal_True; 1376 } 1377 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLayoutBookMode" ) ) ) 1378 { 1379 bViewLayoutBookMode = * (sal_Bool *) pValue->Value.getValue(); 1380 bGotViewLayoutBookMode = sal_True; 1381 } 1382 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsSelectedFrame" ) ) ) 1383 { 1384 pValue->Value >>= bSelectedFrame; 1385 bGotIsSelectedFrame = sal_True; 1386 } 1387 pValue++; 1388 } 1389 if (bGotVisibleBottom) 1390 { 1391 Point aCrsrPos( nX, nY ); 1392 const long nAdd = pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2; 1393 if (nBottom <= (pWrtShell->GetDocSize().Height()+nAdd) ) 1394 { 1395 pWrtShell->EnableSmooth( sal_False ); 1396 const Rectangle aVis( nLeft, nTop, nRight, nBottom ); 1397 1398 sal_uInt16 nOff = 0; 1399 SvxZoomType eZoom; 1400 if ( !pWrtShell->GetViewOptions()->getBrowseMode() ) 1401 eZoom = static_cast < SvxZoomType > ( nZoomType ); 1402 else 1403 { 1404 eZoom = SVX_ZOOM_PERCENT; 1405 ++nOff; 1406 } 1407 if (bGotIsSelectedFrame) 1408 { 1409 sal_Bool bSelectObj = (sal_False != bSelectedFrame ) 1410 && pWrtShell->IsObjSelectable( aCrsrPos ); 1411 1412 // OD 11.02.2003 #100556# - set flag value to avoid macro execution. 1413 bool bSavedFlagValue = pWrtShell->IsMacroExecAllowed(); 1414 pWrtShell->SetMacroExecAllowed( false ); 1415 //!!! pb (11.08.2004): #i32536# 1416 // os: changed: The user data has to be read if the view is switched back from page preview 1417 //#i43146# go to the last editing position when opening own files 1418 //#i33307# restore editing position 1419 pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj); 1420 if(bOldShellWasPagePreView|| bIsOwnDocument) 1421 { 1422 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj ); 1423 if( bSelectObj ) 1424 { 1425 pWrtShell->SelectObj( aCrsrPos ); 1426 pWrtShell->EnterSelFrmMode( &aCrsrPos ); 1427 } 1428 } 1429 1430 // OD 11.02.2003 #100556# - reset flag value 1431 pWrtShell->SetMacroExecAllowed( bSavedFlagValue ); 1432 } 1433 SelectShell(); 1434 1435 // Set ViewLayoutSettings 1436 const bool bSetViewLayoutSettings = bGotViewLayoutColumns && bGotViewLayoutBookMode && 1437 ( pVOpt->GetViewLayoutColumns() != nViewLayoutColumns || pVOpt->IsViewLayoutBookMode() != bViewLayoutBookMode ); 1438 1439 const bool bSetViewSettings = bGotZoomType && bGotZoomFactor && 1440 ( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom ); 1441 1442 // In case we have a 'fixed' view layout of 2 or more columns, 1443 // we have to apply the view options *before* starting the action. 1444 // Otherwsie the SetZoom function cannot work correctly, because 1445 // the view layout hasn't been calculated. 1446 const bool bZoomNeedsViewLayout = bSetViewLayoutSettings && 1447 1 < nViewLayoutColumns && 1448 bSetViewSettings && 1449 eZoom != SVX_ZOOM_PERCENT; 1450 1451 1452 if ( !bZoomNeedsViewLayout ) 1453 pWrtShell->StartAction(); 1454 1455 if ( bSetViewLayoutSettings ) 1456 SetViewLayout( nViewLayoutColumns, bViewLayoutBookMode, sal_True ); 1457 1458 if ( bZoomNeedsViewLayout ) 1459 pWrtShell->StartAction(); 1460 1461 if ( bSetViewSettings ) 1462 SetZoom( eZoom, nZoomFactor, sal_True ); 1463 1464 //!!! pb (11.08.2004): #i32536# 1465 // os: changed: The user data has to be read if the view is switched back from page preview 1466 //#i43146# go to the last editing position when opening own files 1467 if(bOldShellWasPagePreView||bIsOwnDocument) 1468 { 1469 if ( bBrowse && bGotVisibleLeft && bGotVisibleTop ) 1470 { 1471 Point aTopLeft(aVis.TopLeft()); 1472 //#i76699# make sure the document is still centered 1473 const SwTwips lBorder = IsDocumentBorder() ? DOCUMENTBORDER : 2 * DOCUMENTBORDER; 1474 SwTwips nEditWidth = GetEditWin().GetOutputSize().Width(); 1475 if(nEditWidth > (aDocSz.Width() + lBorder )) 1476 aTopLeft.X() = ( aDocSz.Width() + lBorder - nEditWidth ) / 2; 1477 else 1478 { 1479 //check if the values are possible 1480 long nXMax = pHScrollbar->GetRangeMax() - pHScrollbar->GetVisibleSize(); 1481 if( aTopLeft.X() > nXMax ) 1482 aTopLeft.X() = nXMax < 0 ? 0 : nXMax; 1483 } 1484 SetVisArea( aTopLeft ); 1485 } 1486 else if (bGotVisibleLeft && bGotVisibleTop && bGotVisibleRight && bGotVisibleBottom ) 1487 SetVisArea( aVis ); 1488 } 1489 1490 pWrtShell->LockView( sal_True ); 1491 pWrtShell->EndAction(); 1492 pWrtShell->LockView( sal_False ); 1493 pWrtShell->EnableSmooth( sal_True ); 1494 } 1495 } 1496 } 1497 } 1498 #define NUM_VIEW_SETTINGS 12 1499 void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse ) 1500 { 1501 const SwRect& rRect = pWrtShell->GetCharRect(); 1502 const Rectangle& rVis = GetVisArea(); 1503 Any aAny; 1504 1505 rSequence.realloc ( NUM_VIEW_SETTINGS ); 1506 sal_Int16 nIndex = 0; 1507 beans::PropertyValue *pValue = rSequence.getArray(); 1508 1509 sal_uInt16 nViewID( GetViewFrame()->GetCurViewId()); 1510 pValue->Name = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM( "ViewId" ) ); 1511 OUStringBuffer sBuffer ( OUString(RTL_CONSTASCII_USTRINGPARAM( "view" ) ) ); 1512 SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID)); 1513 pValue->Value <<= sBuffer.makeStringAndClear(); 1514 pValue++;nIndex++; 1515 1516 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLeft" ) ); 1517 pValue->Value <<= TWIP_TO_MM100 ( rRect.Left() ); 1518 pValue++;nIndex++; 1519 1520 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewTop" ) ); 1521 pValue->Value <<= TWIP_TO_MM100 ( rRect.Top() ); 1522 pValue++;nIndex++; 1523 1524 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleLeft" ) ); 1525 pValue->Value <<= TWIP_TO_MM100 ( rVis.Left() ); 1526 pValue++;nIndex++; 1527 1528 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleTop" ) ); 1529 pValue->Value <<= TWIP_TO_MM100 ( rVis.Top() ); 1530 pValue++;nIndex++; 1531 1532 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleRight" ) ); 1533 pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Right() ); 1534 pValue++;nIndex++; 1535 1536 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleBottom" ) ); 1537 pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Bottom() ); 1538 pValue++;nIndex++; 1539 1540 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ZoomType" ) ); 1541 const sal_Int16 nZoomType = static_cast< sal_Int16 >(pWrtShell->GetViewOptions()->GetZoomType()); 1542 pValue->Value <<= nZoomType; 1543 pValue++;nIndex++; 1544 1545 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLayoutColumns" ) ); 1546 const sal_Int16 nViewLayoutColumns = static_cast< sal_Int16 >(pWrtShell->GetViewOptions()->GetViewLayoutColumns()); 1547 pValue->Value <<= nViewLayoutColumns; 1548 pValue++;nIndex++; 1549 1550 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLayoutBookMode" ) ); 1551 const sal_Bool bIsViewLayoutBookMode = pWrtShell->GetViewOptions()->IsViewLayoutBookMode(); 1552 pValue->Value.setValue( &bIsViewLayoutBookMode, ::getBooleanCppuType() ); 1553 pValue++;nIndex++; 1554 1555 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ZoomFactor" ) ); 1556 pValue->Value <<= static_cast < sal_Int16 > (pWrtShell->GetViewOptions()->GetZoom()); 1557 pValue++;nIndex++; 1558 1559 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "IsSelectedFrame" ) ); 1560 const sal_Bool bIsSelected = FRMTYPE_NONE == pWrtShell->GetSelFrmType() ? sal_False : sal_True; 1561 pValue->Value.setValue ( &bIsSelected, ::getBooleanCppuType() ); 1562 nIndex++; 1563 1564 if ( nIndex < NUM_VIEW_SETTINGS ) 1565 rSequence.realloc ( nIndex ); 1566 } 1567 #undef NUM_VIEW_SETTINGS 1568 1569 1570 1571 void SwView::ShowCursor( FASTBOOL bOn ) 1572 { 1573 //JP 10.10.2001: Bug 90461 - don't scroll the cursor into the visible area 1574 sal_Bool bUnlockView = !pWrtShell->IsViewLocked(); 1575 pWrtShell->LockView( sal_True ); //lock visible section 1576 1577 if( !bOn ) 1578 pWrtShell->HideCrsr(); 1579 else if( !pWrtShell->IsFrmSelected() && !pWrtShell->IsObjSelected() ) 1580 pWrtShell->ShowCrsr(); 1581 1582 if( bUnlockView ) 1583 pWrtShell->LockView( sal_False ); 1584 } 1585 1586 1587 1588 ErrCode SwView::DoVerb( long nVerb ) 1589 { 1590 if ( !GetViewFrame()->GetFrame().IsInPlace() ) 1591 { 1592 SwWrtShell &rSh = GetWrtShell(); 1593 const int nSel = rSh.GetSelectionType(); 1594 if ( nSel & nsSelectionType::SEL_OLE ) 1595 rSh.LaunchOLEObj( nVerb ); 1596 } 1597 return ERRCODE_NONE; 1598 } 1599 1600 /*-----------------17.02.98 13:33------------------- 1601 nur sal_True fuer eine Textselektion zurueck geben 1602 --------------------------------------------------*/ 1603 sal_Bool SwView::HasSelection( sal_Bool bText ) const 1604 { 1605 return bText ? GetWrtShell().SwCrsrShell::HasSelection() 1606 : GetWrtShell().HasSelection(); 1607 } 1608 1609 /*-----------------09/16/97 09:50am----------------- 1610 1611 --------------------------------------------------*/ 1612 1613 String SwView::GetSelectionText( sal_Bool bCompleteWrds ) 1614 { 1615 return GetSelectionTextParam( bCompleteWrds, sal_True ); 1616 } 1617 1618 /*-----------------09/16/97 09:50am----------------- 1619 1620 --------------------------------------------------*/ 1621 String SwView::GetSelectionTextParam( sal_Bool bCompleteWrds, 1622 sal_Bool bEraseTrail ) 1623 { 1624 String sReturn; 1625 if( bCompleteWrds && !GetWrtShell().HasSelection() ) 1626 GetWrtShell().SelWrd(); 1627 1628 GetWrtShell().GetSelectedText( sReturn ); 1629 if( bEraseTrail ) 1630 sReturn.EraseTrailingChars(); 1631 return sReturn; 1632 } 1633 1634 /*-------------------------------------------------------------------- 1635 Beschreibung: 1636 --------------------------------------------------------------------*/ 1637 1638 1639 1640 SwGlossaryHdl* SwView::GetGlosHdl() 1641 { 1642 if(!pGlosHdl) 1643 pGlosHdl = new SwGlossaryHdl(GetViewFrame(), pWrtShell); 1644 return pGlosHdl; 1645 } 1646 1647 /*-----------------05.09.96 15.50------------------- 1648 1649 --------------------------------------------------*/ 1650 1651 1652 1653 void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 1654 { 1655 sal_Bool bCallBase = sal_True; 1656 if ( rHint.ISA(SfxSimpleHint) ) 1657 { 1658 sal_uInt32 nId = ((SfxSimpleHint&)rHint).GetId(); 1659 switch ( nId ) 1660 { 1661 // --> OD 2005-03-03 #i43775# - sub shells will be destroyed by the 1662 // dispatcher, if the view frame is dying. Thus, reset member <pShell>. 1663 case SFX_HINT_DYING: 1664 { 1665 if ( &rBC == GetViewFrame() ) 1666 { 1667 ResetSubShell(); 1668 } 1669 } 1670 break; 1671 // <-- 1672 case SFX_HINT_MODECHANGED: 1673 { 1674 // Modalmodus-Umschaltung? 1675 sal_Bool bModal = GetDocShell()->IsInModalMode(); 1676 pHRuler->SetActive( !bModal ); 1677 pVRuler->SetActive( !bModal ); 1678 } 1679 1680 /* kein break hier */ 1681 1682 case SFX_HINT_TITLECHANGED: 1683 if ( GetDocShell()->IsReadOnly() != GetWrtShell().GetViewOptions()->IsReadonly() ) 1684 { 1685 SwWrtShell &rSh = GetWrtShell(); 1686 rSh.SetReadonlyOption( GetDocShell()->IsReadOnly() ); 1687 1688 if ( rSh.GetViewOptions()->IsViewVRuler() ) 1689 CreateVLineal(); 1690 else 1691 KillVLineal(); 1692 if ( rSh.GetViewOptions()->IsViewHRuler() ) 1693 CreateTab(); 1694 else 1695 KillTab(); 1696 bool bReadonly = GetDocShell()->IsReadOnly(); 1697 //#i76332# if document is to be opened in alive-mode then this has to be regarded while switching from readonly-mode to edit-mode 1698 if( !bReadonly ) 1699 { 1700 SwDrawDocument * pDrawDoc = 0; 1701 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (GetDocShell()->GetDoc()->GetDrawModel() ) ) ) 1702 { 1703 if( !pDrawDoc->GetOpenInDesignMode() ) 1704 break;// don't touch the design mode 1705 } 1706 } 1707 SfxBoolItem aItem( SID_FM_DESIGN_MODE, !bReadonly); 1708 GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_ASYNCHRON, 1709 &aItem, 0L ); 1710 } 1711 break; 1712 1713 case SW_BROADCAST_DRAWVIEWS_CREATED: 1714 { 1715 bCallBase = sal_False; 1716 if ( GetFormShell() ) 1717 { 1718 GetFormShell()->SetView( 1719 PTR_CAST(FmFormView, GetWrtShell().GetDrawView()) ); 1720 SfxBoolItem aItem( SID_FM_DESIGN_MODE, !GetDocShell()->IsReadOnly()); 1721 GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_SYNCHRON, 1722 &aItem, 0L ); 1723 } 1724 } 1725 break; 1726 } 1727 } 1728 else if(rHint.ISA(FmDesignModeChangedHint)) 1729 { 1730 sal_Bool bDesignMode = ((FmDesignModeChangedHint&)rHint).GetDesignMode(); 1731 if (!bDesignMode && GetDrawFuncPtr()) 1732 { 1733 GetDrawFuncPtr()->Deactivate(); 1734 SetDrawFuncPtr(NULL); 1735 LeaveDrawCreate(); 1736 AttrChangedNotify(pWrtShell); 1737 } 1738 } 1739 1740 if ( bCallBase ) 1741 SfxViewShell::Notify(rBC, rHint); 1742 } 1743 1744 /*-----------------02.12.96 12:36------------------- 1745 1746 --------------------------------------------------*/ 1747 #if defined WNT || defined UNX 1748 1749 void SwView::ScannerEventHdl( const EventObject& /*rEventObject*/ ) 1750 { 1751 uno::Reference< XScannerManager > xScanMgr = SW_MOD()->GetScannerManager(); 1752 if( xScanMgr.is() ) 1753 { 1754 const ScannerContext aContext( xScanMgr->getAvailableScanners().getConstArray()[ 0 ] ); 1755 const ScanError eError = xScanMgr->getError( aContext ); 1756 1757 if( ScanError_ScanErrorNone == eError ) 1758 { 1759 const uno::Reference< awt::XBitmap > xBitmap( xScanMgr->getBitmap( aContext ) ); 1760 1761 if( xBitmap.is() ) 1762 { 1763 const BitmapEx aScanBmp( VCLUnoHelper::GetBitmap( xBitmap ) ); 1764 1765 if( !!aScanBmp ) 1766 { 1767 Graphic aGrf(aScanBmp); 1768 pWrtShell->Insert( aEmptyStr, aEmptyStr, aGrf ); 1769 } 1770 } 1771 } 1772 } 1773 SfxBindings& rBind = GetViewFrame()->GetBindings(); 1774 rBind.Invalidate( SID_TWAIN_SELECT ); 1775 rBind.Invalidate( SID_TWAIN_TRANSFER ); 1776 } 1777 #endif 1778 1779 /*-----------------04.03.97 15:07------------------- 1780 1781 --------------------------------------------------*/ 1782 1783 1784 void SwView::StopShellTimer() 1785 { 1786 if(aTimer.IsActive()) 1787 { 1788 aTimer.Stop(); 1789 if ( bAttrChgNotifiedWithRegistrations ) 1790 { 1791 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS(); 1792 bAttrChgNotifiedWithRegistrations = sal_False; 1793 } 1794 SelectShell(); 1795 bAttrChgNotified = sal_False; 1796 } 1797 } 1798 1799 /*-----------------09/03/97 04:12pm----------------- 1800 1801 --------------------------------------------------*/ 1802 sal_uInt16 SwView::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing ) 1803 { 1804 SfxViewFrame* pVFrame = GetViewFrame(); 1805 pVFrame->SetChildWindow( SwInputChild::GetChildWindowId(), sal_False ); 1806 if( pVFrame->GetDispatcher()->IsLocked() ) 1807 pVFrame->GetDispatcher()->Lock(sal_False); 1808 1809 sal_uInt16 nRet; 1810 if ( pFormShell && 1811 sal_True != (nRet = pFormShell->PrepareClose( bUI, bForBrowsing )) ) 1812 1813 { 1814 return nRet; 1815 } 1816 return SfxViewShell::PrepareClose( bUI, bForBrowsing ); 1817 } 1818 1819 1820 1821 // status methods for clipboard. 1822 // Status changes now notified from the clipboard. 1823 sal_Bool SwView::IsPasteAllowed() 1824 { 1825 sal_uInt16 nPasteDestination = SwTransferable::GetSotDestination( *pWrtShell ); 1826 if( nLastPasteDestination != nPasteDestination ) 1827 { 1828 TransferableDataHelper aDataHelper( 1829 TransferableDataHelper::CreateFromSystemClipboard( 1830 &GetEditWin()) ); 1831 if( aDataHelper.GetXTransferable().is() ) 1832 { 1833 bPasteState = SwTransferable::IsPaste( *pWrtShell, aDataHelper ); 1834 bPasteSpecialState = SwTransferable::IsPasteSpecial( 1835 *pWrtShell, aDataHelper ); 1836 } 1837 else 1838 bPasteState = bPasteSpecialState = sal_False; 1839 1840 if( 0xFFFF == nLastPasteDestination ) // the init value 1841 pViewImpl->AddClipboardListener(); 1842 nLastPasteDestination = nPasteDestination; 1843 } 1844 return bPasteState; 1845 } 1846 1847 sal_Bool SwView::IsPasteSpecialAllowed() 1848 { 1849 if ( pFormShell && pFormShell->IsActiveControl() ) 1850 return sal_False; 1851 1852 sal_uInt16 nPasteDestination = SwTransferable::GetSotDestination( *pWrtShell ); 1853 if( nLastPasteDestination != nPasteDestination ) 1854 { 1855 TransferableDataHelper aDataHelper( 1856 TransferableDataHelper::CreateFromSystemClipboard( 1857 &GetEditWin()) ); 1858 if( aDataHelper.GetXTransferable().is() ) 1859 { 1860 bPasteState = SwTransferable::IsPaste( *pWrtShell, aDataHelper ); 1861 bPasteSpecialState = SwTransferable::IsPasteSpecial( 1862 *pWrtShell, aDataHelper ); 1863 } 1864 else 1865 bPasteState = bPasteSpecialState = sal_False; 1866 1867 if( 0xFFFF == nLastPasteDestination ) // the init value 1868 pViewImpl->AddClipboardListener(); 1869 } 1870 return bPasteSpecialState; 1871 } 1872 /* -----------------------------12.07.01 13:25-------------------------------- 1873 1874 ---------------------------------------------------------------------------*/ 1875 void SwView::NotifyDBChanged() 1876 { 1877 GetViewImpl()->GetUNOObject_Impl()->NotifyDBChanged(); 1878 } 1879 1880 /*-------------------------------------------------------------------- 1881 Beschreibung: Drucken 1882 --------------------------------------------------------------------*/ 1883 1884 /* -----------------------------28.10.02 13:25-------------------------------- 1885 1886 ---------------------------------------------------------------------------*/ 1887 SfxObjectShellLock & SwView::GetTmpSelectionDoc() 1888 { 1889 return GetViewImpl()->GetTmpSelectionDoc(); 1890 } 1891 /* -----------------------------31.10.02 13:25-------------------------------- 1892 1893 ---------------------------------------------------------------------------*/ 1894 SfxObjectShellLock & SwView::GetOrCreateTmpSelectionDoc() 1895 { 1896 SfxObjectShellLock &rxTmpDoc = GetViewImpl()->GetTmpSelectionDoc(); 1897 if (!rxTmpDoc.Is()) 1898 { 1899 SwXTextView *pImpl = GetViewImpl()->GetUNOObject_Impl(); 1900 rxTmpDoc = pImpl->BuildTmpSelectionDoc(); 1901 } 1902 return rxTmpDoc; 1903 } 1904 /* -----------------3/31/2003 12:39PM---------------- 1905 1906 --------------------------------------------------*/ 1907 void SwView::AddTransferable(SwTransferable& rTransferable) 1908 { 1909 GetViewImpl()->AddTransferable(rTransferable); 1910 } 1911 1912 /* --------------------------------------------------*/ 1913 1914 namespace sw { 1915 1916 void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb) 1917 { 1918 o_rData = *SW_MOD()->GetPrtOptions(bWeb); 1919 } 1920 1921 } // namespace sw 1922 1923