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