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