Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <config_features.h>
21 :
22 : #include <string>
23 : #include <stdlib.h>
24 : #include <hintids.hxx>
25 : #include <comphelper/string.hxx>
26 : #include <officecfg/Office/Common.hxx>
27 : #include <rtl/logfile.hxx>
28 : #include <vcl/graph.hxx>
29 : #include <vcl/inputctx.hxx>
30 : #include <basic/sbxobj.hxx>
31 : #include <svl/eitem.hxx>
32 : #include <unotools/lingucfg.hxx>
33 : #include <unotools/useroptions.hxx>
34 : #include <sfx2/dispatch.hxx>
35 : #include <sfx2/request.hxx>
36 : #include <sfx2/docfile.hxx>
37 : #include <sfx2/printer.hxx>
38 : #include <sfx2/app.hxx>
39 : #include <svx/ruler.hxx>
40 : #include <editeng/protitem.hxx>
41 : #include <svx/fmshell.hxx>
42 : #include <svx/extrusionbar.hxx>
43 : #include <svx/fontworkbar.hxx>
44 : #include <unotxvw.hxx>
45 : #include <cmdid.h>
46 : #include <swhints.hxx>
47 : #include <swmodule.hxx>
48 : #include <inputwin.hxx>
49 : #include <chartins.hxx>
50 : #include <uivwimp.hxx>
51 : #include <uitool.hxx>
52 : #include <edtwin.hxx>
53 : #include <textsh.hxx>
54 : #include <listsh.hxx>
55 : #include <tabsh.hxx>
56 : #include <grfsh.hxx>
57 : #include <mediash.hxx>
58 : #include <docsh.hxx>
59 : #include <frmsh.hxx>
60 : #include <olesh.hxx>
61 : #include <drawsh.hxx>
62 : #include <drawbase.hxx>
63 : #include <drformsh.hxx>
64 : #include <drwtxtsh.hxx>
65 : #include <beziersh.hxx>
66 : #include <navsh.hxx>
67 : #include <globdoc.hxx>
68 : #include <scroll.hxx>
69 : #include <navipi.hxx>
70 : #include <gloshdl.hxx>
71 : #include <usrpref.hxx>
72 : #include <srcview.hxx>
73 : #include <doc.hxx>
74 : #include <IDocumentUndoRedo.hxx>
75 : #include <drawdoc.hxx>
76 : #include <wdocsh.hxx>
77 : #include <wview.hxx>
78 : #include <workctrl.hxx>
79 : #include <wrtsh.hxx>
80 : #include <barcfg.hxx>
81 : #include <pview.hxx>
82 : #include <swdtflvr.hxx>
83 : #include <view.hrc>
84 : #include <globdoc.hrc>
85 : #include <frmui.hrc>
86 : #include <cfgitems.hxx>
87 : #include <prtopt.hxx>
88 : #include <linguistic/lngprops.hxx>
89 : #include <editeng/unolingu.hxx>
90 : #include <com/sun/star/frame/FrameSearchFlag.hpp>
91 : #include <com/sun/star/scanner/ScannerContext.hpp>
92 : #include <com/sun/star/scanner/XScannerManager2.hpp>
93 : #include <toolkit/helper/vclunohelper.hxx>
94 : #include <rtl/ustrbuf.hxx>
95 : #include <sax/tools/converter.hxx>
96 :
97 : #include "formatclipboard.hxx"
98 : #include <PostItMgr.hxx>
99 : #include <annotsh.hxx>
100 : #include <swruler.hxx>
101 :
102 : #include <fldbas.hxx>
103 :
104 : #include <unomid.h>
105 :
106 : #include <com/sun/star/document/XDocumentProperties.hpp>
107 : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
108 :
109 : #include <svl/cjkoptions.hxx>
110 :
111 : using namespace ::com::sun::star;
112 : using namespace ::com::sun::star::uno;
113 : using namespace ::com::sun::star::lang;
114 : using namespace ::com::sun::star::scanner;
115 :
116 : extern bool bNoInterrupt; // in mainwn.cxx
117 :
118 : #define SWVIEWFLAGS ( SFX_VIEW_CAN_PRINT| \
119 : SFX_VIEW_HAS_PRINTOPTIONS)
120 :
121 : // Statics
122 :
123 : int bDocSzUpdated = 1;
124 :
125 : SvxSearchItem* SwView::m_pSrchItem = 0;
126 :
127 : sal_uInt16 SwView::m_nInsertCtrlState = FN_INSERT_TABLE;
128 : sal_uInt16 SwView::m_nWebInsertCtrlState = FN_INSERT_TABLE;
129 : sal_uInt16 SwView::m_nInsertObjectCtrlState = SID_INSERT_DIAGRAM;
130 :
131 : bool SwView::m_bExtra = false;
132 : sal_Bool SwView::m_bFound = sal_False;
133 : bool SwView::m_bJustOpened = false;
134 :
135 : SvxSearchDialog* SwView::m_pSrchDlg = 0;
136 : SearchAttrItemList* SwView::m_pSrchList = 0;
137 : SearchAttrItemList* SwView::m_pReplList = 0;
138 :
139 : DBG_NAME(viewhdl)
140 :
141 21571 : inline SfxDispatcher &SwView::GetDispatcher()
142 : {
143 21571 : return *GetViewFrame()->GetDispatcher();
144 : }
145 :
146 796 : void SwView::ImpSetVerb( int nSelType )
147 : {
148 796 : sal_Bool bResetVerbs = m_bVerbsActive;
149 1592 : if ( !GetViewFrame()->GetFrame().IsInPlace() &&
150 796 : (nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF) & nSelType )
151 : {
152 0 : if ( !m_pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT) )
153 : {
154 0 : if ( nSelType & nsSelectionType::SEL_OLE )
155 : {
156 0 : SetVerbs( GetWrtShell().GetOLEObject()->getSupportedVerbs() );
157 0 : m_bVerbsActive = sal_True;
158 0 : bResetVerbs = sal_False;
159 : }
160 : }
161 : }
162 796 : if ( bResetVerbs )
163 : {
164 0 : SetVerbs( Sequence< embed::VerbDescriptor >() );
165 0 : m_bVerbsActive = sal_False;
166 : }
167 796 : }
168 :
169 : // Called by the SwEditWin when it gets the focus.
170 :
171 627 : void SwView::GotFocus() const
172 : {
173 : // if we got the focus, and the form shell *is* on the top of the dispatcher
174 : // stack, then we need to rebuild the stack (the form shell doesn't belong to
175 : // the top then)
176 627 : const SfxDispatcher& rDispatcher = const_cast< SwView* >( this )->GetDispatcher();
177 627 : SfxShell* pTopShell = rDispatcher.GetShell( 0 );
178 627 : FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell );
179 627 : if ( pAsFormShell )
180 : {
181 0 : pAsFormShell->ForgetActiveControl();
182 0 : const_cast< SwView* >( this )->AttrChangedNotify( m_pWrtShell );
183 : }
184 627 : else if ( m_pPostItMgr )
185 : {
186 627 : SwAnnotationShell* pAsAnnotationShell = PTR_CAST( SwAnnotationShell, pTopShell );
187 627 : if ( pAsAnnotationShell )
188 : {
189 0 : m_pPostItMgr->SetActiveSidebarWin(0);
190 0 : const_cast< SwView* >( this )->AttrChangedNotify( m_pWrtShell );
191 : }
192 : }
193 627 : if( GetWrtShellPtr() )
194 : {
195 627 : SwWrtShell& rWrtShell = GetWrtShell();
196 627 : rWrtShell.GetDoc()->SetCurrentViewShell( GetWrtShellPtr() );
197 627 : rWrtShell.GetDoc()->set( IDocumentSettingAccess::BROWSE_MODE,
198 627 : rWrtShell.GetViewOptions()->getBrowseMode() );
199 : }
200 627 : }
201 :
202 : // called by the FormShell when a form control is focused. This is
203 : // a request to put the form shell on the top of the dispatcher stack
204 :
205 4 : IMPL_LINK_NOARG(SwView, FormControlActivated)
206 : {
207 : // if a form control has been activated, and the form shell is not on the top
208 : // of the dispatcher stack, then we need to activate it
209 2 : const SfxDispatcher& rDispatcher = GetDispatcher();
210 2 : const SfxShell* pTopShell = rDispatcher.GetShell( 0 );
211 2 : const FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell );
212 2 : if ( !pAsFormShell )
213 : {
214 : // if we're editing text currently, cancel this
215 2 : SdrView *pSdrView = m_pWrtShell ? m_pWrtShell->GetDrawView() : NULL;
216 2 : if ( pSdrView && pSdrView->IsTextEdit() )
217 0 : pSdrView->SdrEndTextEdit( sal_True );
218 :
219 2 : const_cast< SwView* >( this )->AttrChangedNotify( m_pWrtShell );
220 : }
221 :
222 2 : return 0L;
223 : }
224 :
225 10858 : void SwView::SelectShell()
226 : {
227 :
228 :
229 : // Attention: Maintain the SelectShell for the WebView additionally
230 :
231 :
232 10858 : if(m_bInDtor)
233 10858 : return;
234 : // Decision if the UpdateTable has to be called
235 10858 : sal_Bool bUpdateTable = sal_False;
236 10858 : const SwFrmFmt* pCurTableFmt = m_pWrtShell->GetTableFmt();
237 10858 : if(pCurTableFmt && pCurTableFmt != m_pLastTableFormat)
238 : {
239 46 : bUpdateTable = sal_True; // can only be executed later
240 : }
241 10858 : m_pLastTableFormat = pCurTableFmt;
242 :
243 : //SEL_TBL and SEL_TBL_CELLS can be changed!
244 10858 : int nNewSelectionType = (m_pWrtShell->GetSelectionType()
245 10858 : & ~nsSelectionType::SEL_TBL_CELLS);
246 :
247 10858 : if ( m_pFormShell && m_pFormShell->IsActiveControl() )
248 2 : nNewSelectionType |= nsSelectionType::SEL_FOC_FRM_CTRL;
249 :
250 10858 : if ( nNewSelectionType == m_nSelectionType )
251 : {
252 10064 : GetViewFrame()->GetBindings().InvalidateAll( sal_False );
253 20128 : if ( m_nSelectionType & nsSelectionType::SEL_OLE ||
254 10064 : m_nSelectionType & nsSelectionType::SEL_GRF )
255 : // For graphs and OLE the verb can be modified of course!
256 0 : ImpSetVerb( nNewSelectionType );
257 : }
258 : else
259 : {
260 :
261 794 : SfxDispatcher &rDispatcher = GetDispatcher();
262 794 : SwToolbarConfigItem *pBarCfg = SW_MOD()->GetToolbarConfig();
263 :
264 794 : if ( m_pShell )
265 : {
266 9 : rDispatcher.Flush(); // Really erase all cached shells
267 : //Remember to the old selection which toolbar was visible
268 9 : sal_uInt16 nId = static_cast< sal_uInt16 >( rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT ));
269 9 : if ( nId )
270 6 : pBarCfg->SetTopToolbar( m_nSelectionType, nId );
271 :
272 : SfxShell *pSfxShell;
273 37 : for ( sal_uInt16 i = 0; sal_True; ++i )
274 : {
275 37 : pSfxShell = rDispatcher.GetShell( i );
276 74 : if ( pSfxShell->ISA( SwBaseShell )
277 18 : || pSfxShell->ISA( SwDrawTextShell )
278 18 : || pSfxShell->ISA( svx::ExtrusionBar )
279 18 : || pSfxShell->ISA( svx::FontworkBar )
280 55 : || pSfxShell->ISA( SwAnnotationShell )
281 : )
282 : {
283 19 : rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_DELETE );
284 : }
285 18 : else if ( pSfxShell->ISA( FmFormShell ) )
286 : {
287 9 : rDispatcher.Pop( *pSfxShell );
288 : }
289 : else
290 9 : break;
291 28 : }
292 : }
293 :
294 794 : sal_Bool bInitFormShell = sal_False;
295 794 : if (!m_pFormShell)
296 : {
297 785 : bInitFormShell = sal_True;
298 785 : m_pFormShell = new FmFormShell( this );
299 785 : m_pFormShell->SetControlActivationHandler( LINK( this, SwView, FormControlActivated ) );
300 785 : StartListening(*m_pFormShell);
301 : }
302 :
303 794 : sal_Bool bSetExtInpCntxt = sal_False;
304 794 : m_nSelectionType = nNewSelectionType;
305 : ShellModes eShellMode;
306 :
307 794 : if ( !( m_nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL ) )
308 792 : rDispatcher.Push( *m_pFormShell );
309 :
310 794 : eShellMode = SHELL_MODE_NAVIGATION;
311 794 : m_pShell = new SwNavigationShell( *this );
312 794 : rDispatcher.Push( *m_pShell );
313 :
314 794 : if ( m_nSelectionType & nsSelectionType::SEL_OLE )
315 : {
316 0 : eShellMode = SHELL_MODE_OBJECT;
317 0 : m_pShell = new SwOleShell( *this );
318 0 : rDispatcher.Push( *m_pShell );
319 : }
320 794 : else if ( m_nSelectionType & nsSelectionType::SEL_FRM
321 794 : || m_nSelectionType & nsSelectionType::SEL_GRF)
322 : {
323 0 : eShellMode = SHELL_MODE_FRAME;
324 0 : m_pShell = new SwFrameShell( *this );
325 0 : rDispatcher.Push( *m_pShell );
326 0 : if(m_nSelectionType & nsSelectionType::SEL_GRF )
327 : {
328 0 : eShellMode = SHELL_MODE_GRAPHIC;
329 0 : m_pShell = new SwGrfShell( *this );
330 0 : rDispatcher.Push( *m_pShell );
331 : }
332 : }
333 794 : else if ( m_nSelectionType & nsSelectionType::SEL_DRW )
334 : {
335 0 : eShellMode = SHELL_MODE_DRAW;
336 0 : m_pShell = new SwDrawShell( *this );
337 0 : rDispatcher.Push( *m_pShell );
338 :
339 0 : if ( m_nSelectionType & nsSelectionType::SEL_BEZ )
340 : {
341 0 : eShellMode = SHELL_MODE_BEZIER;
342 0 : m_pShell = new SwBezierShell( *this );
343 0 : rDispatcher.Push( *m_pShell );
344 : }
345 0 : else if( m_nSelectionType & nsSelectionType::SEL_MEDIA )
346 : {
347 0 : eShellMode = SHELL_MODE_MEDIA;
348 0 : m_pShell = new SwMediaShell( *this );
349 0 : rDispatcher.Push( *m_pShell );
350 : }
351 :
352 0 : if (m_nSelectionType & nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE)
353 : {
354 0 : eShellMode = SHELL_MODE_EXTRUDED_CUSTOMSHAPE;
355 0 : m_pShell = new svx::ExtrusionBar(this);
356 0 : rDispatcher.Push( *m_pShell );
357 : }
358 0 : if (m_nSelectionType & nsSelectionType::SEL_FONTWORK)
359 : {
360 0 : eShellMode = SHELL_MODE_FONTWORK;
361 0 : m_pShell = new svx::FontworkBar(this);
362 0 : rDispatcher.Push( *m_pShell );
363 : }
364 : }
365 794 : else if ( m_nSelectionType & nsSelectionType::SEL_DRW_FORM )
366 : {
367 0 : eShellMode = SHELL_MODE_DRAW_FORM;
368 0 : m_pShell = new SwDrawFormShell( *this );
369 :
370 0 : rDispatcher.Push( *m_pShell );
371 : }
372 794 : else if ( m_nSelectionType & nsSelectionType::SEL_DRW_TXT )
373 : {
374 0 : bSetExtInpCntxt = sal_True;
375 0 : eShellMode = SHELL_MODE_DRAWTEXT;
376 0 : rDispatcher.Push( *(new SwBaseShell( *this )) );
377 0 : m_pShell = new SwDrawTextShell( *this );
378 0 : rDispatcher.Push( *m_pShell );
379 : }
380 794 : else if ( m_nSelectionType & nsSelectionType::SEL_POSTIT )
381 : {
382 0 : eShellMode = SHELL_MODE_POSTIT;
383 0 : m_pShell = new SwAnnotationShell( *this );
384 0 : rDispatcher.Push( *m_pShell );
385 : }
386 : else
387 : {
388 794 : bSetExtInpCntxt = sal_True;
389 794 : eShellMode = SHELL_MODE_TEXT;
390 794 : sal_uInt32 nHelpId = 0;
391 794 : if ( m_nSelectionType & nsSelectionType::SEL_NUM )
392 : {
393 15 : eShellMode = SHELL_MODE_LIST_TEXT;
394 15 : m_pShell = new SwListShell( *this );
395 15 : nHelpId = m_pShell->GetHelpId();
396 15 : rDispatcher.Push( *m_pShell );
397 : }
398 794 : m_pShell = new SwTextShell(*this);
399 794 : if(nHelpId)
400 15 : m_pShell->SetHelpId(nHelpId);
401 794 : rDispatcher.Push( *m_pShell );
402 794 : if ( m_nSelectionType & nsSelectionType::SEL_TBL )
403 : {
404 : eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT
405 40 : : SHELL_MODE_TABLE_TEXT;
406 40 : m_pShell = new SwTableShell( *this );
407 40 : rDispatcher.Push( *m_pShell );
408 : }
409 : }
410 :
411 794 : if ( m_nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL )
412 2 : rDispatcher.Push( *m_pFormShell );
413 :
414 794 : m_pViewImpl->SetShellMode(eShellMode);
415 794 : ImpSetVerb( m_nSelectionType );
416 :
417 794 : if( !GetDocShell()->IsReadOnly() )
418 : {
419 790 : if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
420 1 : bSetExtInpCntxt = sal_False;
421 :
422 790 : InputContext aCntxt( GetEditWin().GetInputContext() );
423 : aCntxt.SetOptions( bSetExtInpCntxt
424 789 : ? (aCntxt.GetOptions() |
425 : ( INPUTCONTEXT_TEXT |
426 : INPUTCONTEXT_EXTTEXTINPUT ))
427 1 : : (aCntxt.GetOptions() & ~
428 : ( INPUTCONTEXT_TEXT |
429 1580 : INPUTCONTEXT_EXTTEXTINPUT )) );
430 790 : GetEditWin().SetInputContext( aCntxt );
431 : }
432 :
433 : // Activate the toolbar to the new selection which also was active last time.
434 : // Before a flush () must be, but does not affect the UI according to MBA and
435 : // is not a performance problem.
436 : // TODO/LATER: maybe now the Flush() command is superfluous?!
437 794 : rDispatcher.Flush();
438 :
439 794 : Point aPnt = GetEditWin().OutputToScreenPixel(GetEditWin().GetPointerPosPixel());
440 794 : aPnt = GetEditWin().PixelToLogic(aPnt);
441 794 : GetEditWin().UpdatePointer(aPnt);
442 :
443 794 : SdrView* pDView = GetWrtShell().GetDrawView();
444 794 : if ( bInitFormShell && pDView )
445 785 : m_pFormShell->SetView(PTR_CAST(FmFormView, pDView));
446 :
447 : }
448 : // Opportune time for the communication with OLE objects?
449 10858 : if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
450 4 : GetDocShell()->GetDoc()->PrtOLENotify( sal_False );
451 :
452 : // now the table-update
453 10858 : if(bUpdateTable)
454 46 : m_pWrtShell->UpdateTable();
455 :
456 10858 : GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
457 : }
458 :
459 : // Interaction: AttrChangedNotify() and TimeoutHdl.
460 : // No Update if actions are still open, since the cursor on the core side
461 : // can be somewhere in no man's land.
462 : // But since we can no longer supply status and we want instead lock
463 : // the dispatcher.
464 :
465 : extern "C"
466 : {
467 762 : static int lcl_CmpIds( const void *pFirst, const void *pSecond)
468 : {
469 762 : return (*(sal_uInt16*)pFirst) - (*(sal_uInt16*)pSecond);
470 : }
471 : }
472 :
473 19752 : IMPL_LINK_NOARG(SwView, AttrChangedNotify)
474 : {
475 10457 : if ( GetEditWin().IsChainMode() )
476 0 : GetEditWin().SetChainMode( sal_False );
477 :
478 : //Opt: Not if PaintLocked. During unlock a notify will be once more triggered.
479 20518 : if( !m_pWrtShell->IsPaintLocked() && !bNoInterrupt &&
480 10061 : GetDocShell()->IsReadOnly() )
481 4 : _CheckReadonlyState();
482 :
483 10457 : if( !m_pWrtShell->IsPaintLocked() && !bNoInterrupt )
484 10061 : _CheckReadonlySelection();
485 :
486 10457 : if( !m_bAttrChgNotified )
487 : {
488 41448 : if ( m_pWrtShell->BasicActionPend() || bNoInterrupt ||
489 30611 : GetDispatcher().IsLocked() || //do not confuse the SFX
490 10077 : GetViewFrame()->GetBindings().IsInUpdate() )//do not confuse the SFX
491 : {
492 380 : m_bAttrChgNotified = sal_True;
493 380 : m_aTimer.Start();
494 :
495 : const SfxPoolItem *pItem;
496 760 : if ( SFX_ITEM_SET != GetObjectShell()->GetMedium()->GetItemSet()->
497 767 : GetItemState( SID_HIDDEN, sal_False, &pItem ) ||
498 7 : !((SfxBoolItem*)pItem)->GetValue() )
499 : {
500 373 : GetViewFrame()->GetBindings().ENTERREGISTRATIONS();
501 373 : m_bAttrChgNotifiedWithRegistrations = sal_True;
502 : }
503 :
504 : }
505 : else
506 10077 : SelectShell();
507 :
508 : }
509 :
510 : // change ui if cursor is at a SwPostItField
511 10457 : if (m_pPostItMgr)
512 : {
513 : // only perform the code that is needed to determine, if at the
514 : // actual cursor position is a post-it field
515 10078 : m_pPostItMgr->SetShadowState( m_pWrtShell->GetPostItFieldAtCursor() );
516 : }
517 :
518 10457 : return 0;
519 : }
520 :
521 6 : IMPL_LINK_NOARG(SwView, TimeoutHdl)
522 : {
523 : DBG_PROFSTART(viewhdl);
524 :
525 3 : if( m_pWrtShell->BasicActionPend() || bNoInterrupt )
526 : {
527 0 : m_aTimer.Start();
528 : DBG_PROFSTOP(viewhdl);
529 0 : return 0;
530 : }
531 :
532 3 : if ( m_bAttrChgNotifiedWithRegistrations )
533 : {
534 1 : GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
535 1 : m_bAttrChgNotifiedWithRegistrations = sal_False;
536 : }
537 :
538 3 : _CheckReadonlyState();
539 3 : _CheckReadonlySelection();
540 :
541 3 : sal_Bool bOldUndo = m_pWrtShell->DoesUndo();
542 3 : m_pWrtShell->DoUndo( sal_False );
543 3 : SelectShell();
544 3 : m_pWrtShell->DoUndo( bOldUndo );
545 3 : m_bAttrChgNotified = sal_False;
546 3 : GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
547 :
548 : DBG_PROFSTOP(viewhdl);
549 3 : return 0;
550 : }
551 :
552 7 : void SwView::_CheckReadonlyState()
553 : {
554 7 : SfxDispatcher &rDis = GetDispatcher();
555 : // To be able to recognize if it is already disabled!
556 : SfxItemState eStateRO, eStateProtAll;
557 : const SfxPoolItem *pItem;
558 : // Query the status from a slot which is only known to us.
559 : // Otherwise the slot is known from other; like the BasidIde
560 7 : eStateRO = rDis.QueryState( FN_INSERT_BOOKMARK, pItem );
561 7 : eStateProtAll = rDis.QueryState( FN_EDIT_REGION, pItem );
562 7 : sal_Bool bChgd = sal_False;
563 :
564 7 : if ( !m_pWrtShell->IsCrsrReadonly() )
565 : {
566 : static sal_uInt16 aROIds[] =
567 : {
568 : SID_DELETE, FN_BACKSPACE, FN_SHIFT_BACKSPACE,
569 : SID_UNDO,
570 : SID_REDO, SID_REPEAT, SID_PASTE,
571 : SID_PASTE_UNFORMATTED,
572 : SID_PASTE_SPECIAL, SID_SBA_BRW_INSERT,
573 : SID_BACKGROUND_COLOR, FN_INSERT_BOOKMARK,
574 : SID_CHARMAP, FN_INSERT_SOFT_HYPHEN,
575 : FN_INSERT_HARDHYPHEN, FN_INSERT_HARD_SPACE, FN_INSERT_BREAK,
576 : FN_INSERT_LINEBREAK, FN_INSERT_COLUMN_BREAK, FN_INSERT_BREAK_DLG,
577 : FN_DELETE_SENT, FN_DELETE_BACK_SENT, FN_DELETE_WORD,
578 : FN_DELETE_BACK_WORD, FN_DELETE_LINE, FN_DELETE_BACK_LINE,
579 : FN_DELETE_PARA, FN_DELETE_BACK_PARA, FN_DELETE_WHOLE_LINE,
580 : FN_CALCULATE, FN_FORMAT_RESET,
581 : FN_POSTIT, FN_JAVAEDIT, SID_ATTR_PARA_ADJUST_LEFT,
582 : SID_ATTR_PARA_ADJUST_RIGHT, SID_ATTR_PARA_ADJUST_CENTER,SID_ATTR_PARA_ADJUST_BLOCK,
583 : SID_ATTR_PARA_LINESPACE_10, SID_ATTR_PARA_LINESPACE_15, SID_ATTR_PARA_LINESPACE_20,
584 : SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_FONTHEIGHT, SID_ATTR_CHAR_COLOR_BACKGROUND,
585 : SID_ATTR_CHAR_COLOR_BACKGROUND_EXT, SID_ATTR_CHAR_COLOR_EXT,
586 : SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_WEIGHT, SID_ATTR_CHAR_POSTURE,
587 : SID_ATTR_CHAR_OVERLINE,
588 : SID_ATTR_CHAR_UNDERLINE, SID_ATTR_FLASH, SID_ATTR_CHAR_STRIKEOUT,
589 : FN_UNDERLINE_DOUBLE, SID_ATTR_CHAR_CONTOUR, SID_ATTR_CHAR_SHADOWED,
590 : SID_ATTR_CHAR_AUTOKERN, SID_ATTR_CHAR_ESCAPEMENT, FN_SET_SUPER_SCRIPT,
591 : FN_SET_SUB_SCRIPT, SID_ATTR_CHAR_CASEMAP, SID_ATTR_CHAR_LANGUAGE,
592 : SID_ATTR_CHAR_KERNING, SID_CHAR_DLG, SID_ATTR_CHAR_WORDLINEMODE,
593 : FN_GROW_FONT_SIZE, FN_SHRINK_FONT_SIZE, FN_TXTATR_INET,
594 : FN_FORMAT_DROPCAPS, SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_LINESPACE,
595 : SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_KEEP, SID_ATTR_PARA_WIDOWS,
596 : SID_ATTR_PARA_ORPHANS,
597 : SID_ATTR_PARA_MODEL, SID_PARA_DLG,
598 : FN_SELECT_PARA, SID_DEC_INDENT,
599 : SID_INC_INDENT
600 : };
601 : static sal_Bool bFirst = sal_True;
602 3 : if ( bFirst )
603 : {
604 2 : qsort( (void*)aROIds, sizeof(aROIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
605 2 : bFirst = sal_False;
606 : }
607 3 : if ( SFX_ITEM_DISABLED == eStateRO )
608 : {
609 1 : rDis.SetSlotFilter( sal_Bool(2), sizeof(aROIds)/sizeof(sal_uInt16), aROIds );
610 1 : bChgd = sal_True;
611 : }
612 : }
613 4 : else if( m_pWrtShell->IsAllProtect() )
614 : {
615 0 : if ( SFX_ITEM_DISABLED == eStateProtAll )
616 : {
617 : static sal_uInt16 aAllProtIds[] = { SID_SAVEDOC, FN_EDIT_REGION };
618 : static sal_Bool bAllProtFirst = sal_True;
619 0 : if ( bAllProtFirst )
620 : {
621 0 : qsort( (void*)aAllProtIds, sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
622 0 : bAllProtFirst = sal_False;
623 : }
624 : rDis.SetSlotFilter( sal_Bool(2),
625 0 : sizeof(aAllProtIds)/sizeof(sal_uInt16),
626 0 : aAllProtIds );
627 0 : bChgd = sal_True;
628 : }
629 : }
630 4 : else if ( SFX_ITEM_DISABLED != eStateRO ||
631 : SFX_ITEM_DISABLED != eStateProtAll )
632 : {
633 0 : bChgd = sal_True;
634 0 : rDis.SetSlotFilter();
635 : }
636 7 : if ( bChgd )
637 1 : GetViewFrame()->GetBindings().InvalidateAll(sal_True);
638 7 : }
639 :
640 10064 : void SwView::_CheckReadonlySelection()
641 : {
642 10064 : sal_uInt32 nDisableFlags = 0;
643 10064 : SfxDispatcher &rDis = GetDispatcher();
644 :
645 10066 : if( m_pWrtShell->HasReadonlySel(m_bAnnotationMode) &&
646 2 : ( !m_pWrtShell->GetDrawView() ||
647 1 : !m_pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount() ))
648 1 : nDisableFlags |= SW_DISABLE_ON_PROTECTED_CURSOR;
649 :
650 10064 : if( (SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags ) !=
651 10064 : (SW_DISABLE_ON_PROTECTED_CURSOR & rDis.GetDisableFlags() ) )
652 : {
653 : // Additionally move at the Window the InputContext, so that
654 : // in japanese / chinese versions the external input will be
655 : // turned on or off. This but only if the correct shell is on
656 : // the stack.
657 1 : switch( m_pViewImpl->GetShellMode() )
658 : {
659 : case SHELL_MODE_TEXT:
660 : case SHELL_MODE_LIST_TEXT:
661 : case SHELL_MODE_TABLE_TEXT:
662 : case SHELL_MODE_TABLE_LIST_TEXT:
663 : {
664 : // Temporary solution!!! Should set the font of the current insertion point
665 : // at each cursor movement, so outside of this "if". But TH does not
666 : // evaluates the font at this time and the "purchase" appears to me
667 : // as too expensive.
668 : // Moreover, we don't have a font, but only attributes from which the
669 : // text formatting and the correct font will be build together.
670 :
671 1 : InputContext aCntxt( GetEditWin().GetInputContext() );
672 1 : aCntxt.SetOptions( SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags
673 1 : ? (aCntxt.GetOptions() & ~
674 : ( INPUTCONTEXT_TEXT |
675 : INPUTCONTEXT_EXTTEXTINPUT ))
676 0 : : (aCntxt.GetOptions() |
677 : ( INPUTCONTEXT_TEXT |
678 2 : INPUTCONTEXT_EXTTEXTINPUT )) );
679 1 : GetEditWin().SetInputContext( aCntxt );
680 : }
681 1 : break;
682 : default:
683 : ;
684 : }
685 :
686 : }
687 :
688 10064 : if( nDisableFlags != rDis.GetDisableFlags() )
689 : {
690 1 : rDis.SetDisableFlags( nDisableFlags );
691 1 : GetViewFrame()->GetBindings().InvalidateAll( sal_True );
692 : }
693 10064 : }
694 :
695 793 : SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
696 : : SfxViewShell( _pFrame, SWVIEWFLAGS ),
697 : m_aPageStr( SW_RES( STR_PAGE )),
698 : m_nNewPage(USHRT_MAX),
699 : m_pNumRuleNodeFromDoc(0),
700 793 : m_pEditWin( new SwEditWin( &_pFrame->GetWindow(), *this ) ),
701 : m_pWrtShell(0),
702 : m_pShell(0),
703 : m_pFormShell(0),
704 : m_pHScrollbar(0),
705 : m_pVScrollbar(0),
706 1586 : m_pScrollFill(new ScrollBarBox( &_pFrame->GetWindow(), _pFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )),
707 793 : m_pVRuler(new SvxRuler(&GetViewFrame()->GetWindow(), m_pEditWin,
708 : SVXRULER_SUPPORT_TABS | SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL|
709 : SVXRULER_SUPPORT_BORDERS | SVXRULER_SUPPORT_REDUCED_METRIC,
710 793 : GetViewFrame()->GetBindings(),
711 793 : WB_VSCROLL | WB_EXTRAFIELD | WB_BORDER )),
712 : m_pTogglePageBtn(0),
713 : m_pPageUpBtn(0),
714 : m_pPageDownBtn(0),
715 : m_pNaviBtn(0),
716 : m_pGlosHdl(0),
717 : m_pDrawActual(0),
718 : m_pLastTableFormat(0),
719 0 : m_pFormatClipboard(new SwFormatClipboard()),
720 : m_pPostItMgr(0),
721 : m_nSelectionType( INT_MAX ),
722 : m_nPageCnt(0),
723 : m_nDrawSfxId( USHRT_MAX ),
724 : m_nFormSfxId( USHRT_MAX ),
725 : m_nLastPasteDestination( 0xFFFF ),
726 : m_nLeftBorderDistance( 0 ),
727 : m_nRightBorderDistance( 0 ),
728 : m_bWheelScrollInProgress(false),
729 : m_bInMailMerge(sal_False),
730 : m_bInDtor(sal_False),
731 : m_bOldShellWasPagePreView(sal_False),
732 : m_bIsPreviewDoubleClick(sal_False),
733 5551 : m_bAnnotationMode(false)
734 : {
735 : // According to discussion with MBA and further
736 : // investigations, no old SfxViewShell will be set as parameter <pOldSh>,
737 : // if function "New Window" is performed to open an additional view beside
738 : // an already existing one.
739 : // If the view is switch from one to another, the 'old' view is given by
740 : // parameter <pOldSh>.
741 :
742 : RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwView::SwView" );
743 :
744 : m_bCenterCrsr = m_bTopCrsr = m_bAlwaysShowSel = m_bTabColFromDoc = m_bTabRowFromDoc =
745 : m_bSetTabColFromDoc = m_bSetTabRowFromDoc = m_bAttrChgNotified = m_bAttrChgNotifiedWithRegistrations =
746 : m_bVerbsActive = m_bDrawRotate = m_bInOuterResizePixel = m_bInInnerResizePixel =
747 793 : m_bPasteState = m_bPasteSpecialState = m_bMakeSelectionVisible = sal_False;
748 :
749 793 : m_bShowAtResize = m_bDrawSelMode = bDocSzUpdated = sal_True;
750 :
751 793 : _CreateScrollbar( sal_True );
752 793 : _CreateScrollbar( sal_False );
753 :
754 793 : m_pViewImpl = new SwView_Impl(this);
755 793 : SetName(OUString("View"));
756 793 : SetWindow( m_pEditWin );
757 :
758 793 : m_aTimer.SetTimeout( 120 );
759 :
760 793 : SwDocShell* pDocSh = PTR_CAST( SwDocShell, _pFrame->GetObjectShell() );
761 793 : sal_Bool bOldModifyFlag = pDocSh->IsEnableSetModified();
762 793 : if(bOldModifyFlag)
763 792 : pDocSh->EnableSetModified( sal_False );
764 : // HACK: SwDocShell has some cached font info, VCL informs about font updates,
765 : // but loading of docs with embedded fonts happens after SwDocShell is created
766 : // but before SwEditWin (which handles the VCL event) is created. So update
767 : // manually.
768 793 : if( pDocSh->GetDoc()->get( IDocumentSettingAccess::EMBED_FONTS ))
769 0 : pDocSh->UpdateFontList();
770 : OSL_ENSURE( pDocSh, "view without DocShell." );
771 793 : SwWebDocShell* pWebDShell = PTR_CAST( SwWebDocShell, pDocSh );
772 :
773 793 : const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(0 != pWebDShell);
774 793 : SwViewOption aUsrPref( *pUsrPref);
775 :
776 : //! get lingu options without loading lingu DLL
777 1586 : SvtLinguOptions aLinguOpt;
778 793 : SvtLinguConfig().GetOptions( aLinguOpt );
779 793 : aUsrPref.SetOnlineSpell( aLinguOpt.bIsSpellAuto );
780 :
781 793 : sal_Bool bOldShellWasSrcView = sal_False;
782 :
783 : // determine if there is an existing view for
784 : // document
785 793 : SfxViewShell* pExistingSh = 0;
786 793 : if ( pOldSh )
787 : {
788 0 : pExistingSh = pOldSh;
789 : // determine type of existing view
790 0 : if( pExistingSh->IsA( TYPE( SwPagePreView ) ) )
791 : {
792 0 : m_sSwViewData = ((SwPagePreView*)pExistingSh)->GetPrevSwViewData();
793 0 : m_sNewCrsrPos = ((SwPagePreView*)pExistingSh)->GetNewCrsrPos();
794 0 : m_nNewPage = ((SwPagePreView*)pExistingSh)->GetNewPage();
795 0 : m_bOldShellWasPagePreView = sal_True;
796 0 : m_bIsPreviewDoubleClick = m_sNewCrsrPos.Len() > 0 || m_nNewPage != USHRT_MAX;
797 : }
798 0 : else if( pExistingSh->IsA( TYPE( SwSrcView ) ) )
799 0 : bOldShellWasSrcView = sal_True;
800 : }
801 :
802 : RTL_LOGFILE_CONTEXT_TRACE( aLog, "before create WrtShell" );
803 793 : if(PTR_CAST( SwView, pExistingSh))
804 : {
805 : m_pWrtShell = new SwWrtShell( *((SwView*)pExistingSh)->m_pWrtShell,
806 0 : m_pEditWin, *this);
807 : }
808 793 : else if( dynamic_cast<SwWrtShell*>( pDocSh->GetDoc()->GetCurrentViewShell() ) )
809 : {
810 0 : m_pWrtShell = new SwWrtShell( *(SwWrtShell*)pDocSh->GetDoc()->GetCurrentViewShell(),
811 0 : m_pEditWin, *this);
812 : }
813 : else
814 : {
815 793 : SwDoc& rDoc = *((SwDocShell*)pDocSh)->GetDoc();
816 :
817 793 : if( !bOldShellWasSrcView && pWebDShell && !m_bOldShellWasPagePreView )
818 2 : aUsrPref.setBrowseMode( sal_True );
819 : else
820 791 : aUsrPref.setBrowseMode( rDoc.get(IDocumentSettingAccess::BROWSE_MODE) );
821 :
822 : //For the BrowseMode we do not assume a factor.
823 793 : if( aUsrPref.getBrowseMode() && aUsrPref.GetZoomType() != SVX_ZOOM_PERCENT )
824 : {
825 0 : aUsrPref.SetZoomType( SVX_ZOOM_PERCENT );
826 0 : aUsrPref.SetZoom( 100 );
827 : }
828 793 : if(pDocSh->IsPreview())
829 : {
830 0 : aUsrPref.SetZoomType( SVX_ZOOM_WHOLEPAGE );
831 0 : aUsrPref.SetViewLayoutBookMode( false );
832 0 : aUsrPref.SetViewLayoutColumns( 1 );
833 : }
834 793 : m_pWrtShell = new SwWrtShell( rDoc, m_pEditWin, *this, &aUsrPref );
835 : // creating an SwView from a SwPagePreView needs to
836 : // add the ViewShell to the ring of the other ViewShell(s)
837 793 : if(m_bOldShellWasPagePreView)
838 : {
839 0 : ViewShell& rPreviewViewShell = *((SwPagePreView*)pExistingSh)->GetViewShell();
840 0 : m_pWrtShell->MoveTo(&rPreviewViewShell);
841 : // to update the field command et.al. if necessary
842 0 : const SwViewOption* pPreViewOpt = rPreviewViewShell.GetViewOptions();
843 0 : if( pPreViewOpt->IsFldName() != aUsrPref.IsFldName() ||
844 0 : pPreViewOpt->IsShowHiddenField() != aUsrPref.IsShowHiddenField() ||
845 0 : pPreViewOpt->IsShowHiddenPara() != aUsrPref.IsShowHiddenPara() ||
846 0 : pPreViewOpt->IsShowHiddenChar() != aUsrPref.IsShowHiddenChar() )
847 0 : rPreviewViewShell.ApplyViewOptions(aUsrPref);
848 : // reset design mode at draw view for form
849 : // shell, if needed.
850 0 : if ( ((SwPagePreView*)pExistingSh)->ResetFormDesignMode() &&
851 0 : m_pWrtShell->HasDrawView() )
852 : {
853 0 : SdrView* pDrawView = m_pWrtShell->GetDrawView();
854 0 : pDrawView->SetDesignMode( ((SwPagePreView*)pExistingSh)->FormDesignModeToReset() );
855 : }
856 : }
857 : }
858 : RTL_LOGFILE_CONTEXT_TRACE( aLog, "after create WrtShell" );
859 :
860 793 : m_pHRuler = new SwCommentRuler(m_pWrtShell, &GetViewFrame()->GetWindow(), m_pEditWin,
861 : SVXRULER_SUPPORT_TABS |
862 : SVXRULER_SUPPORT_PARAGRAPH_MARGINS |
863 : SVXRULER_SUPPORT_BORDERS |
864 : SVXRULER_SUPPORT_NEGATIVE_MARGINS|
865 : SVXRULER_SUPPORT_REDUCED_METRIC,
866 793 : GetViewFrame()->GetBindings(),
867 1586 : WB_STDRULER | WB_EXTRAFIELD | WB_BORDER);
868 :
869 : // assure that modified state of document
870 : // isn't reset, if document is already modified.
871 793 : const bool bIsDocModified = m_pWrtShell->GetDoc()->IsModified();
872 :
873 : // Thus among other things, the HRuler is not displayed in the read-only case.
874 793 : aUsrPref.SetReadonly( m_pWrtShell->GetViewOptions()->IsReadonly() );
875 :
876 : // no margin for OLE!
877 793 : Size aBrwsBorder;
878 793 : if( SFX_CREATE_MODE_EMBEDDED != pDocSh->GetCreateMode() )
879 793 : aBrwsBorder = GetMargin();
880 :
881 793 : m_pWrtShell->SetBrowseBorder( aBrwsBorder );
882 :
883 : // In CTOR no shell changes may take place, which must be temporarily stored
884 : // with the timer. Otherwise, the SFX removes them from the stack!
885 793 : bool bOld = bNoInterrupt;
886 793 : bNoInterrupt = true;
887 :
888 793 : m_pHRuler->SetActive( sal_True );
889 793 : m_pVRuler->SetActive( sal_True );
890 :
891 793 : SfxViewFrame* pViewFrame = GetViewFrame();
892 793 : if( pViewFrame->GetFrame().GetParentFrame())
893 : {
894 0 : aUsrPref.SetViewHRuler(sal_False);
895 0 : aUsrPref.SetViewVRuler(sal_False);
896 : }
897 :
898 793 : StartListening( *pViewFrame, sal_True );
899 793 : StartListening( *pDocSh, sal_True );
900 :
901 : // Set Zoom-factor from HRuler
902 793 : Fraction aZoomFract( aUsrPref.GetZoom(), 100 );
903 793 : m_pHRuler->SetZoom( aZoomFract );
904 793 : m_pVRuler->SetZoom( aZoomFract );
905 793 : m_pHRuler->SetDoubleClickHdl(LINK( this, SwView, ExecRulerClick ));
906 793 : FieldUnit eMetric = pUsrPref->GetHScrollMetric();
907 793 : m_pHRuler->SetUnit( eMetric );
908 :
909 793 : eMetric = pUsrPref->GetVScrollMetric();
910 793 : m_pVRuler->SetUnit( eMetric );
911 :
912 793 : m_pHRuler->SetCharWidth( 371 ); // default character width
913 793 : m_pVRuler->SetLineHeight( 551 ); // default line height
914 :
915 : // Set DocShell
916 793 : pDocSh->SetView( this );
917 793 : SW_MOD()->SetView( this );
918 :
919 793 : m_pPostItMgr = new SwPostItMgr(this);
920 :
921 : // Check and process the DocSize. Via the handler, the shell could not
922 : // be found, because the shell is not known in the SFX management
923 : // within the CTOR phase.
924 793 : DocSzChgd( m_pWrtShell->GetDocSize() );
925 :
926 : // Set AttrChangedNotify link
927 793 : m_pWrtShell->SetChgLnk(LINK(this, SwView, AttrChangedNotify));
928 :
929 2379 : if( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED &&
930 : //TODO/LATER: why a cast here?
931 : //!((SvEmbeddedObject *)pDocSh)->GetVisArea().IsEmpty() )
932 : //SetVisArea( ((SvEmbeddedObject *)pDocSh)->GetVisArea(),sal_False);
933 793 : !pDocSh->GetVisArea(ASPECT_CONTENT).IsEmpty() )
934 0 : SetVisArea( pDocSh->GetVisArea(ASPECT_CONTENT),sal_False);
935 :
936 : SAL_WARN_IF(
937 : officecfg::Office::Common::Undo::Steps::get() <= 0,
938 : "sw", "/org.openoffice.Office.Common/Undo/Steps <= 0");
939 793 : m_pWrtShell->DoUndo( true );
940 :
941 793 : const sal_Bool bBrowse = m_pWrtShell->GetViewOptions()->getBrowseMode();
942 : // Disable "multiple window"
943 793 : SetNewWindowAllowed(!bBrowse);
944 : // End of disabled multiple window
945 :
946 793 : m_bVScrollbarEnabled = aUsrPref.IsViewVScrollBar();
947 793 : m_bHScrollbarEnabled = aUsrPref.IsViewHScrollBar();
948 793 : m_pHScrollbar->SetAuto(bBrowse);
949 793 : if( aUsrPref.IsViewHRuler() )
950 792 : CreateTab();
951 793 : if( aUsrPref.IsViewVRuler() )
952 790 : CreateVRuler();
953 :
954 793 : m_pWrtShell->SetUIOptions( aUsrPref );
955 793 : m_pWrtShell->SetReadOnlyAvailable( aUsrPref.IsCursorInProtectedArea() );
956 793 : m_pWrtShell->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
957 :
958 793 : if( m_pWrtShell->GetDoc()->IsUpdateExpFld() )
959 : {
960 26 : if (m_pWrtShell->GetDoc()->containsUpdatableFields())
961 : {
962 2 : SET_CURR_SHELL( m_pWrtShell );
963 2 : m_pWrtShell->StartAction();
964 2 : m_pWrtShell->CalcLayout();
965 2 : m_pWrtShell->GetDoc()->UpdateFlds(NULL, false);
966 2 : m_pWrtShell->EndAction();
967 : }
968 26 : m_pWrtShell->GetDoc()->SetUpdateExpFldStat( sal_False );
969 : }
970 :
971 : // Update all tables if necessary:
972 793 : if( m_pWrtShell->GetDoc()->IsUpdateTOX() )
973 : {
974 0 : SfxRequest aSfxRequest( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
975 0 : Execute( aSfxRequest );
976 0 : m_pWrtShell->GetDoc()->SetUpdateTOX( sal_False ); // reset again
977 0 : m_pWrtShell->SttEndDoc(sal_True);
978 : }
979 :
980 : // No ResetModified, if there is already a view to this doc.
981 793 : SfxViewFrame* pVFrame = GetViewFrame();
982 793 : SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh);
983 : // Currently(360) the view is registered firstly after the CTOR,
984 : // the following expression is also working if this changes.
985 : // If the modification cannot be canceled by undo, then do NOT set
986 : // the modify back.
987 : // no reset of modified state, if document
988 : // was already modified.
989 2379 : if (!m_pWrtShell->GetDoc()->GetIDocumentUndoRedo().IsUndoNoResetModified() &&
990 1586 : ( !pFirst || pFirst == pVFrame ) &&
991 793 : !bIsDocModified )
992 : {
993 793 : m_pWrtShell->ResetModified();
994 : }
995 :
996 793 : bNoInterrupt = bOld;
997 :
998 : // If a new GlobalDoc will be created, the navigator will also be generated.
999 793 : if( pDocSh->IsA(SwGlobalDocShell::StaticType()) &&
1000 0 : !pVFrame->GetChildWindow( SID_NAVIGATOR ))
1001 : {
1002 0 : SfxBoolItem aNavi(SID_NAVIGATOR, sal_True);
1003 0 : GetDispatcher().Execute(SID_NAVIGATOR, SFX_CALLMODE_ASYNCHRON, &aNavi, 0L);
1004 : }
1005 :
1006 1586 : uno::Reference< frame::XFrame > xFrame = pVFrame->GetFrame().GetFrameInterface();
1007 :
1008 793 : uno::Reference< frame::XFrame > xBeamerFrame = xFrame->findFrame(
1009 1586 : OUString("_beamer"), frame::FrameSearchFlag::CHILDREN);
1010 793 : if(xBeamerFrame.is())
1011 : {
1012 0 : SwDBData aData = m_pWrtShell->GetDBData();
1013 0 : SW_MOD()->ShowDBObj( *this, aData );
1014 : }
1015 :
1016 : // has anybody calls the attrchanged handler in the constructor?
1017 793 : if( m_bAttrChgNotifiedWithRegistrations )
1018 : {
1019 372 : GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1020 372 : if( m_aTimer.IsActive() )
1021 372 : m_aTimer.Stop();
1022 : }
1023 :
1024 793 : m_aTimer.SetTimeoutHdl(LINK(this, SwView, TimeoutHdl));
1025 793 : m_bAttrChgNotified = m_bAttrChgNotifiedWithRegistrations = sal_False;
1026 793 : if(bOldModifyFlag)
1027 792 : pDocSh->EnableSetModified( sal_True );
1028 793 : InvalidateBorder();
1029 :
1030 793 : if( !m_pHScrollbar->IsVisible( sal_True ) )
1031 791 : ShowHScrollbar( sal_False );
1032 793 : if( !m_pVScrollbar->IsVisible( sal_True ) )
1033 793 : ShowVScrollbar( sal_False );
1034 :
1035 1586 : GetViewFrame()->GetWindow().AddChildEventListener( LINK( this, SwView, WindowChildEventListener ) );
1036 793 : }
1037 :
1038 2374 : SwView::~SwView()
1039 : {
1040 792 : GetViewFrame()->GetWindow().RemoveChildEventListener( LINK( this, SwView, WindowChildEventListener ) );
1041 792 : delete m_pPostItMgr;
1042 792 : m_pPostItMgr = 0;
1043 :
1044 792 : m_bInDtor = sal_True;
1045 792 : m_pEditWin->Hide(); // damit kein Paint Aerger machen kann!
1046 : // An der SwDocShell den Pointer auf die View ruecksetzen
1047 :
1048 792 : SwDocShell* pDocSh = GetDocShell();
1049 792 : if( pDocSh && pDocSh->GetView() == this )
1050 792 : pDocSh->SetView( 0 );
1051 792 : if ( SW_MOD()->GetView() == this )
1052 778 : SW_MOD()->SetView( 0 );
1053 :
1054 792 : if( m_aTimer.IsActive() && m_bAttrChgNotifiedWithRegistrations )
1055 0 : GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1056 :
1057 : // the last view must end the text edit
1058 792 : SdrView *pSdrView = m_pWrtShell ? m_pWrtShell->GetDrawView() : 0;
1059 792 : if( pSdrView && pSdrView->IsTextEdit() )
1060 0 : pSdrView->SdrEndTextEdit( sal_True );
1061 :
1062 792 : SetWindow( 0 );
1063 :
1064 792 : m_pViewImpl->Invalidate();
1065 792 : EndListening(*GetViewFrame());
1066 792 : EndListening(*GetDocShell());
1067 792 : delete m_pScrollFill;
1068 792 : delete m_pWrtShell;
1069 792 : m_pWrtShell = 0; // Set to 0, so that it is not accessable by the following dtors cannot.
1070 792 : m_pShell = 0;
1071 792 : delete m_pHScrollbar;
1072 792 : delete m_pVScrollbar;
1073 792 : delete m_pHRuler;
1074 792 : delete m_pVRuler;
1075 792 : delete m_pTogglePageBtn;
1076 792 : delete m_pPageUpBtn;
1077 792 : delete m_pNaviBtn;
1078 792 : delete m_pPageDownBtn;
1079 792 : delete m_pGlosHdl;
1080 792 : delete m_pViewImpl;
1081 792 : delete m_pEditWin;
1082 792 : delete m_pFormatClipboard;
1083 1582 : }
1084 :
1085 72522 : SwDocShell* SwView::GetDocShell()
1086 : {
1087 72522 : SfxObjectShell* pDocShell = GetViewFrame()->GetObjectShell();
1088 72522 : return PTR_CAST(SwDocShell, pDocShell);
1089 : }
1090 :
1091 : // Remember CursorPos
1092 :
1093 0 : void SwView::WriteUserData( String &rUserData, sal_Bool bBrowse )
1094 : {
1095 : // The browse flag will be passed from Sfx when documents are browsed
1096 : // (not to be confused with the BrowseMode).
1097 : // Then that stored data are not persistent!
1098 :
1099 0 : const SwRect& rRect = m_pWrtShell->GetCharRect();
1100 0 : const Rectangle& rVis = GetVisArea();
1101 :
1102 0 : rUserData = OUString::number( rRect.Left() );
1103 0 : rUserData += ';';
1104 0 : rUserData += OUString::number( rRect.Top() );
1105 0 : rUserData += ';';
1106 0 : rUserData += OUString::number( m_pWrtShell->GetViewOptions()->GetZoom() );
1107 0 : rUserData += ';';
1108 0 : rUserData += OUString::number( rVis.Left() );
1109 0 : rUserData += ';';
1110 0 : rUserData += OUString::number( rVis.Top() );
1111 0 : rUserData += ';';
1112 0 : rUserData += OUString::number( bBrowse ? SAL_MIN_INT32 : rVis.Right());
1113 0 : rUserData += ';';
1114 0 : rUserData += OUString::number( bBrowse ? SAL_MIN_INT32 : rVis.Bottom());
1115 0 : rUserData += ';';
1116 0 : rUserData += OUString::number(
1117 0 : (sal_uInt16)m_pWrtShell->GetViewOptions()->GetZoomType());//eZoom;
1118 0 : rUserData += ';';
1119 0 : rUserData += FRMTYPE_NONE == m_pWrtShell->GetSelFrmType() ? '0' : '1';
1120 0 : }
1121 :
1122 : // Set CursorPos
1123 :
1124 782 : static bool lcl_IsOwnDocument( SwView& rView )
1125 : {
1126 : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1127 782 : rView.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW);
1128 : uno::Reference<document::XDocumentProperties> xDocProps
1129 1564 : = xDPS->getDocumentProperties();
1130 1564 : String Created = xDocProps->getAuthor();
1131 1564 : String Changed = xDocProps->getModifiedBy();
1132 1564 : String FullName = SW_MOD()->GetUserOptions().GetFullName();
1133 782 : return (FullName.Len() &&
1134 1564 : (Changed.Len() && Changed == FullName )) ||
1135 2996 : (!Changed.Len() && Created.Len() && Created == FullName );
1136 : }
1137 :
1138 0 : void SwView::ReadUserData( const String &rUserData, sal_Bool bBrowse )
1139 : {
1140 0 : if ( comphelper::string::getTokenCount(rUserData, ';') > 1 &&
1141 : // For document without layout only in the onlinelayout or
1142 : // while forward/backward
1143 0 : (!m_pWrtShell->IsNewLayout() || m_pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse) )
1144 : {
1145 0 : bool bIsOwnDocument = lcl_IsOwnDocument( *this );
1146 :
1147 0 : SET_CURR_SHELL(m_pWrtShell);
1148 :
1149 0 : sal_Int32 nPos = 0;
1150 :
1151 : // No it is *no* good idea to call GetToken within Point-Konstr. immediately,
1152 : // because which parameter is evaluated first?
1153 0 : long nX = rUserData.GetToken( 0, ';', nPos ).ToInt32(),
1154 0 : nY = rUserData.GetToken( 0, ';', nPos ).ToInt32();
1155 0 : Point aCrsrPos( nX, nY );
1156 :
1157 : sal_uInt16 nZoomFactor =
1158 0 : static_cast< sal_uInt16 >( rUserData.GetToken(0, ';', nPos ).ToInt32() );
1159 :
1160 0 : long nLeft = rUserData.GetToken(0, ';', nPos ).ToInt32(),
1161 0 : nTop = rUserData.GetToken(0, ';', nPos ).ToInt32(),
1162 0 : nRight = rUserData.GetToken(0, ';', nPos ).ToInt32(),
1163 0 : nBottom= rUserData.GetToken(0, ';', nPos ).ToInt32();
1164 :
1165 0 : const long nAdd = m_pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
1166 0 : if ( nBottom <= (m_pWrtShell->GetDocSize().Height()+nAdd) )
1167 : {
1168 0 : m_pWrtShell->EnableSmooth( sal_False );
1169 :
1170 0 : const Rectangle aVis( nLeft, nTop, nRight, nBottom );
1171 :
1172 0 : sal_uInt16 nOff = 0;
1173 : SvxZoomType eZoom;
1174 0 : if( !m_pWrtShell->GetViewOptions()->getBrowseMode() )
1175 0 : eZoom = (SvxZoomType) (sal_uInt16)rUserData.GetToken(nOff, ';', nPos ).ToInt32();
1176 : else
1177 : {
1178 0 : eZoom = SVX_ZOOM_PERCENT;
1179 0 : ++nOff;
1180 : }
1181 :
1182 0 : sal_Bool bSelectObj = (0 != rUserData.GetToken( nOff, ';', nPos ).ToInt32())
1183 0 : && m_pWrtShell->IsObjSelectable( aCrsrPos );
1184 :
1185 : // restore editing position
1186 0 : m_pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
1187 : // set flag value to avoid macro execution.
1188 0 : bool bSavedFlagValue = m_pWrtShell->IsMacroExecAllowed();
1189 0 : m_pWrtShell->SetMacroExecAllowed( false );
1190 : // os: changed: The user data has to be read if the view is switched back from page preview
1191 : // go to the last editing position when opening own files
1192 0 : if(m_bOldShellWasPagePreView || bIsOwnDocument)
1193 : {
1194 0 : m_pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
1195 0 : if( bSelectObj )
1196 : {
1197 0 : m_pWrtShell->SelectObj( aCrsrPos );
1198 0 : m_pWrtShell->EnterSelFrmMode( &aCrsrPos );
1199 : }
1200 : }
1201 :
1202 : // reset flag value
1203 0 : m_pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
1204 :
1205 : // set visible area before applying
1206 : // information from print preview. Otherwise, the applied information
1207 : // is lost.
1208 : // os: changed: The user data has to be read if the view is switched back from page preview
1209 : // go to the last editing position when opening own files
1210 0 : if(m_bOldShellWasPagePreView || bIsOwnDocument )
1211 : {
1212 0 : if ( bBrowse )
1213 0 : SetVisArea( aVis.TopLeft() );
1214 : else
1215 0 : SetVisArea( aVis );
1216 : }
1217 :
1218 : //apply information from print preview - if available
1219 0 : if( m_sNewCrsrPos.Len() )
1220 : {
1221 0 : long nXTmp = m_sNewCrsrPos.GetToken( 0, ';' ).ToInt32(),
1222 0 : nYTmp = m_sNewCrsrPos.GetToken( 1, ';' ).ToInt32();
1223 0 : Point aCrsrPos2( nXTmp, nYTmp );
1224 0 : bSelectObj = m_pWrtShell->IsObjSelectable( aCrsrPos2 );
1225 :
1226 0 : m_pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos2, sal_False );
1227 0 : if( bSelectObj )
1228 : {
1229 0 : m_pWrtShell->SelectObj( aCrsrPos2 );
1230 0 : m_pWrtShell->EnterSelFrmMode( &aCrsrPos2 );
1231 : }
1232 0 : m_pWrtShell->MakeSelVisible();
1233 0 : m_sNewCrsrPos.Erase();
1234 : }
1235 0 : else if(USHRT_MAX != m_nNewPage)
1236 : {
1237 0 : m_pWrtShell->GotoPage(m_nNewPage, sal_True);
1238 0 : m_nNewPage = USHRT_MAX;
1239 : }
1240 :
1241 0 : SelectShell();
1242 :
1243 0 : m_pWrtShell->StartAction();
1244 0 : const SwViewOption* pVOpt = m_pWrtShell->GetViewOptions();
1245 0 : if( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom )
1246 0 : SetZoom( eZoom, nZoomFactor);
1247 :
1248 0 : m_pWrtShell->LockView( sal_True );
1249 0 : m_pWrtShell->EndAction();
1250 0 : m_pWrtShell->LockView( sal_False );
1251 0 : m_pWrtShell->EnableSmooth( sal_True );
1252 0 : }
1253 : }
1254 0 : }
1255 :
1256 782 : void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
1257 : {
1258 782 : if(GetDocShell()->IsPreview()||m_bIsPreviewDoubleClick)
1259 782 : return;
1260 782 : bool bIsOwnDocument = lcl_IsOwnDocument( *this );
1261 782 : sal_Int32 nLength = rSequence.getLength();
1262 782 : if (nLength && (!m_pWrtShell->IsNewLayout() || m_pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse) )
1263 : {
1264 782 : SET_CURR_SHELL(m_pWrtShell);
1265 782 : const beans::PropertyValue *pValue = rSequence.getConstArray();
1266 782 : const SwRect& rRect = m_pWrtShell->GetCharRect();
1267 782 : const Rectangle &rVis = GetVisArea();
1268 782 : const SwViewOption* pVOpt = m_pWrtShell->GetViewOptions();
1269 :
1270 782 : long nX = rRect.Left(), nY = rRect.Top(), nLeft = rVis.Left(), nTop = rVis.Top();
1271 782 : long nRight = bBrowse ? LONG_MIN : rVis.Right(), nBottom = bBrowse ? LONG_MIN : rVis.Bottom();
1272 782 : sal_Int16 nZoomType = static_cast< sal_Int16 >(pVOpt->GetZoomType());
1273 782 : sal_Int16 nZoomFactor = static_cast < sal_Int16 > (pVOpt->GetZoom());
1274 782 : bool bViewLayoutBookMode = pVOpt->IsViewLayoutBookMode();
1275 782 : sal_Int16 nViewLayoutColumns = pVOpt->GetViewLayoutColumns();
1276 :
1277 782 : sal_Bool bSelectedFrame = ( m_pWrtShell->GetSelFrmType() != FRMTYPE_NONE ),
1278 782 : bGotVisibleLeft = sal_False,
1279 782 : bGotVisibleTop = sal_False, bGotVisibleRight = sal_False,
1280 782 : bGotVisibleBottom = sal_False, bGotZoomType = sal_False,
1281 782 : bGotZoomFactor = sal_False, bGotIsSelectedFrame = sal_False,
1282 782 : bGotViewLayoutColumns = sal_False, bGotViewLayoutBookMode = sal_False;
1283 :
1284 8175 : for (sal_Int16 i = 0 ; i < nLength; i++)
1285 : {
1286 7393 : if ( pValue->Name == "ViewLeft" )
1287 : {
1288 561 : pValue->Value >>= nX;
1289 561 : nX = MM100_TO_TWIP( nX );
1290 : }
1291 6832 : else if ( pValue->Name == "ViewTop" )
1292 : {
1293 561 : pValue->Value >>= nY;
1294 561 : nY = MM100_TO_TWIP( nY );
1295 : }
1296 6271 : else if ( pValue->Name == "VisibleLeft" )
1297 : {
1298 561 : pValue->Value >>= nLeft;
1299 561 : nLeft = MM100_TO_TWIP( nLeft );
1300 561 : bGotVisibleLeft = sal_True;
1301 : }
1302 5710 : else if ( pValue->Name == "VisibleTop" )
1303 : {
1304 561 : pValue->Value >>= nTop;
1305 561 : nTop = MM100_TO_TWIP( nTop );
1306 561 : bGotVisibleTop = sal_True;
1307 : }
1308 5149 : else if ( pValue->Name == "VisibleRight" )
1309 : {
1310 561 : pValue->Value >>= nRight;
1311 561 : nRight = MM100_TO_TWIP( nRight );
1312 561 : bGotVisibleRight = sal_True;
1313 : }
1314 4588 : else if ( pValue->Name == "VisibleBottom" )
1315 : {
1316 782 : pValue->Value >>= nBottom;
1317 782 : nBottom = MM100_TO_TWIP( nBottom );
1318 782 : bGotVisibleBottom = sal_True;
1319 : }
1320 3806 : else if ( pValue->Name == "ZoomType" )
1321 : {
1322 782 : pValue->Value >>= nZoomType;
1323 782 : bGotZoomType = sal_True;
1324 : }
1325 3024 : else if ( pValue->Name == "ZoomFactor" )
1326 : {
1327 782 : pValue->Value >>= nZoomFactor;
1328 782 : bGotZoomFactor = sal_True;
1329 : }
1330 2242 : else if ( pValue->Name == "ViewLayoutColumns" )
1331 : {
1332 560 : pValue->Value >>= nViewLayoutColumns;
1333 560 : bGotViewLayoutColumns = sal_True;
1334 : }
1335 1682 : else if ( pValue->Name == "ViewLayoutBookMode" )
1336 : {
1337 560 : bViewLayoutBookMode = * (sal_Bool *) pValue->Value.getValue();
1338 560 : bGotViewLayoutBookMode = sal_True;
1339 : }
1340 1122 : else if ( pValue->Name == "IsSelectedFrame" )
1341 : {
1342 561 : pValue->Value >>= bSelectedFrame;
1343 561 : bGotIsSelectedFrame = sal_True;
1344 : }
1345 7393 : pValue++;
1346 : }
1347 782 : if (bGotVisibleBottom)
1348 : {
1349 782 : Point aCrsrPos( nX, nY );
1350 782 : const long nAdd = m_pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
1351 782 : if (nBottom <= (m_pWrtShell->GetDocSize().Height()+nAdd) )
1352 : {
1353 782 : m_pWrtShell->EnableSmooth( sal_False );
1354 782 : const Rectangle aVis( nLeft, nTop, nRight, nBottom );
1355 :
1356 : SvxZoomType eZoom;
1357 782 : if ( !m_pWrtShell->GetViewOptions()->getBrowseMode() )
1358 780 : eZoom = static_cast < SvxZoomType > ( nZoomType );
1359 : else
1360 : {
1361 2 : eZoom = SVX_ZOOM_PERCENT;
1362 : }
1363 782 : if (bGotIsSelectedFrame)
1364 : {
1365 561 : sal_Bool bSelectObj = (sal_False != bSelectedFrame )
1366 561 : && m_pWrtShell->IsObjSelectable( aCrsrPos );
1367 :
1368 : // set flag value to avoid macro execution.
1369 561 : bool bSavedFlagValue = m_pWrtShell->IsMacroExecAllowed();
1370 561 : m_pWrtShell->SetMacroExecAllowed( false );
1371 : // os: changed: The user data has to be read if the view is switched back from page preview
1372 : // go to the last editing position when opening own files
1373 561 : m_pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
1374 561 : if(m_bOldShellWasPagePreView|| bIsOwnDocument)
1375 : {
1376 0 : m_pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
1377 :
1378 : // Update the shell to toggle Header/Footer edit if needed
1379 0 : sal_Bool bInHeader = sal_True;
1380 0 : if ( m_pWrtShell->IsInHeaderFooter( &bInHeader ) )
1381 : {
1382 0 : if ( !bInHeader )
1383 : {
1384 0 : m_pWrtShell->SetShowHeaderFooterSeparator( Footer, true );
1385 0 : m_pWrtShell->SetShowHeaderFooterSeparator( Header, false );
1386 : }
1387 : else
1388 : {
1389 0 : m_pWrtShell->SetShowHeaderFooterSeparator( Header, true );
1390 0 : m_pWrtShell->SetShowHeaderFooterSeparator( Footer, false );
1391 : }
1392 :
1393 : // Force repaint
1394 0 : m_pWrtShell->GetWin()->Invalidate();
1395 : }
1396 0 : if ( m_pWrtShell->IsInHeaderFooter() != m_pWrtShell->IsHeaderFooterEdit() )
1397 0 : m_pWrtShell->ToggleHeaderFooterEdit();
1398 :
1399 0 : if( bSelectObj )
1400 : {
1401 0 : m_pWrtShell->SelectObj( aCrsrPos );
1402 0 : m_pWrtShell->EnterSelFrmMode( &aCrsrPos );
1403 : }
1404 : }
1405 :
1406 : // reset flag value
1407 561 : m_pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
1408 : }
1409 782 : SelectShell();
1410 :
1411 : // Set ViewLayoutSettings
1412 1344 : const bool bSetViewLayoutSettings = bGotViewLayoutColumns && bGotViewLayoutBookMode &&
1413 1900 : ( pVOpt->GetViewLayoutColumns() != nViewLayoutColumns || pVOpt->IsViewLayoutBookMode() != bViewLayoutBookMode );
1414 :
1415 1633 : const bool bSetViewSettings = bGotZoomType && bGotZoomFactor &&
1416 2277 : ( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom );
1417 :
1418 : // In case we have a 'fixed' view layout of 2 or more columns,
1419 : // we have to apply the view options *before* starting the action.
1420 : // Otherwsie the SetZoom function cannot work correctly, because
1421 : // the view layout hasn't been calculated.
1422 2 : const bool bZoomNeedsViewLayout = bSetViewLayoutSettings &&
1423 2 : 1 < nViewLayoutColumns &&
1424 782 : bSetViewSettings &&
1425 782 : eZoom != SVX_ZOOM_PERCENT;
1426 :
1427 782 : if ( !bZoomNeedsViewLayout )
1428 782 : m_pWrtShell->StartAction();
1429 :
1430 782 : if ( bSetViewLayoutSettings )
1431 2 : SetViewLayout( nViewLayoutColumns, bViewLayoutBookMode, sal_True );
1432 :
1433 782 : if ( bZoomNeedsViewLayout )
1434 0 : m_pWrtShell->StartAction();
1435 :
1436 782 : if ( bSetViewSettings )
1437 69 : SetZoom( eZoom, nZoomFactor, sal_True );
1438 :
1439 : // os: changed: The user data has to be read if the view is switched back from page preview
1440 : // go to the last editing position when opening own files
1441 782 : if(m_bOldShellWasPagePreView||bIsOwnDocument)
1442 : {
1443 0 : if ( bBrowse && bGotVisibleLeft && bGotVisibleTop )
1444 : {
1445 0 : Point aTopLeft(aVis.TopLeft());
1446 : // make sure the document is still centered
1447 0 : const SwTwips lBorder = IsDocumentBorder() ? DOCUMENTBORDER : 2 * DOCUMENTBORDER;
1448 0 : SwTwips nEditWidth = GetEditWin().GetOutputSize().Width();
1449 0 : if(nEditWidth > (m_aDocSz.Width() + lBorder ))
1450 0 : aTopLeft.X() = ( m_aDocSz.Width() + lBorder - nEditWidth ) / 2;
1451 : else
1452 : {
1453 : //check if the values are possible
1454 0 : long nXMax = m_pHScrollbar->GetRangeMax() - m_pHScrollbar->GetVisibleSize();
1455 0 : if( aTopLeft.X() > nXMax )
1456 0 : aTopLeft.X() = nXMax < 0 ? 0 : nXMax;
1457 : }
1458 0 : SetVisArea( aTopLeft );
1459 : }
1460 0 : else if (bGotVisibleLeft && bGotVisibleTop && bGotVisibleRight && bGotVisibleBottom )
1461 0 : SetVisArea( aVis );
1462 : }
1463 :
1464 782 : m_pWrtShell->LockView( sal_True );
1465 782 : m_pWrtShell->EndAction();
1466 782 : m_pWrtShell->LockView( sal_False );
1467 782 : m_pWrtShell->EnableSmooth( sal_True );
1468 : }
1469 782 : }
1470 : }
1471 : }
1472 :
1473 : #define NUM_VIEW_SETTINGS 12
1474 526 : void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
1475 : {
1476 526 : const SwRect& rRect = m_pWrtShell->GetCharRect();
1477 526 : const Rectangle& rVis = GetVisArea();
1478 526 : Any aAny;
1479 :
1480 526 : rSequence.realloc ( NUM_VIEW_SETTINGS );
1481 526 : sal_Int16 nIndex = 0;
1482 526 : beans::PropertyValue *pValue = rSequence.getArray();
1483 :
1484 526 : sal_uInt16 nViewID( GetViewFrame()->GetCurViewId());
1485 526 : pValue->Name = OUString( "ViewId" );
1486 1052 : OUStringBuffer sBuffer ( OUString( "view" ) );
1487 526 : ::sax::Converter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
1488 526 : pValue->Value <<= sBuffer.makeStringAndClear();
1489 526 : pValue++;nIndex++;
1490 :
1491 526 : pValue->Name = OUString( "ViewLeft" );
1492 526 : pValue->Value <<= TWIP_TO_MM100 ( rRect.Left() );
1493 526 : pValue++;nIndex++;
1494 :
1495 526 : pValue->Name = OUString( "ViewTop" );
1496 526 : pValue->Value <<= TWIP_TO_MM100 ( rRect.Top() );
1497 526 : pValue++;nIndex++;
1498 :
1499 526 : pValue->Name = OUString( "VisibleLeft" );
1500 526 : pValue->Value <<= TWIP_TO_MM100 ( rVis.Left() );
1501 526 : pValue++;nIndex++;
1502 :
1503 526 : pValue->Name = OUString( "VisibleTop" );
1504 526 : pValue->Value <<= TWIP_TO_MM100 ( rVis.Top() );
1505 526 : pValue++;nIndex++;
1506 :
1507 526 : pValue->Name = OUString( "VisibleRight" );
1508 526 : pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Right() );
1509 526 : pValue++;nIndex++;
1510 :
1511 526 : pValue->Name = OUString( "VisibleBottom" );
1512 526 : pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Bottom() );
1513 526 : pValue++;nIndex++;
1514 :
1515 526 : pValue->Name = OUString( "ZoomType" );
1516 526 : const sal_Int16 nZoomType = static_cast< sal_Int16 >(m_pWrtShell->GetViewOptions()->GetZoomType());
1517 526 : pValue->Value <<= nZoomType;
1518 526 : pValue++;nIndex++;
1519 :
1520 526 : pValue->Name = OUString( "ViewLayoutColumns" );
1521 526 : const sal_Int16 nViewLayoutColumns = static_cast< sal_Int16 >(m_pWrtShell->GetViewOptions()->GetViewLayoutColumns());
1522 526 : pValue->Value <<= nViewLayoutColumns;
1523 526 : pValue++;nIndex++;
1524 :
1525 526 : pValue->Name = OUString( "ViewLayoutBookMode" );
1526 526 : const sal_Bool bIsViewLayoutBookMode = m_pWrtShell->GetViewOptions()->IsViewLayoutBookMode();
1527 526 : pValue->Value.setValue( &bIsViewLayoutBookMode, ::getBooleanCppuType() );
1528 526 : pValue++;nIndex++;
1529 :
1530 526 : pValue->Name = OUString( "ZoomFactor" );
1531 526 : pValue->Value <<= static_cast < sal_Int16 > (m_pWrtShell->GetViewOptions()->GetZoom());
1532 526 : pValue++;nIndex++;
1533 :
1534 526 : pValue->Name = OUString( "IsSelectedFrame" );
1535 526 : const sal_Bool bIsSelected = FRMTYPE_NONE == m_pWrtShell->GetSelFrmType() ? sal_False : sal_True;
1536 526 : pValue->Value.setValue ( &bIsSelected, ::getBooleanCppuType() );
1537 526 : nIndex++;
1538 :
1539 526 : if ( nIndex < NUM_VIEW_SETTINGS )
1540 526 : rSequence.realloc ( nIndex );
1541 526 : }
1542 : #undef NUM_VIEW_SETTINGS
1543 :
1544 220 : void SwView::ShowCursor( bool bOn )
1545 : {
1546 : //don't scroll the cursor into the visible area
1547 220 : sal_Bool bUnlockView = !m_pWrtShell->IsViewLocked();
1548 220 : m_pWrtShell->LockView( sal_True ); //lock visible section
1549 :
1550 220 : if( !bOn )
1551 111 : m_pWrtShell->HideCrsr();
1552 109 : else if( !m_pWrtShell->IsFrmSelected() && !m_pWrtShell->IsObjSelected() )
1553 109 : m_pWrtShell->ShowCrsr();
1554 :
1555 220 : if( bUnlockView )
1556 220 : m_pWrtShell->LockView( sal_False );
1557 220 : }
1558 :
1559 0 : ErrCode SwView::DoVerb( long nVerb )
1560 : {
1561 0 : if ( !GetViewFrame()->GetFrame().IsInPlace() )
1562 : {
1563 0 : SwWrtShell &rSh = GetWrtShell();
1564 0 : const int nSel = rSh.GetSelectionType();
1565 0 : if ( nSel & nsSelectionType::SEL_OLE )
1566 0 : rSh.LaunchOLEObj( nVerb );
1567 : }
1568 0 : return ERRCODE_NONE;
1569 : }
1570 :
1571 : // only return sal_True for a text selection
1572 :
1573 0 : sal_Bool SwView::HasSelection( sal_Bool bText ) const
1574 : {
1575 0 : return bText ? GetWrtShell().SwCrsrShell::HasSelection()
1576 0 : : GetWrtShell().HasSelection();
1577 : }
1578 :
1579 0 : String SwView::GetSelectionText( sal_Bool bCompleteWrds )
1580 : {
1581 0 : return GetSelectionTextParam( bCompleteWrds, sal_True );
1582 : }
1583 :
1584 0 : String SwView::GetSelectionTextParam( sal_Bool bCompleteWrds,
1585 : sal_Bool bEraseTrail )
1586 : {
1587 0 : String sReturn;
1588 0 : if( bCompleteWrds && !GetWrtShell().HasSelection() )
1589 0 : GetWrtShell().SelWrd();
1590 :
1591 0 : GetWrtShell().GetSelectedText( sReturn );
1592 0 : if( bEraseTrail )
1593 0 : sReturn = comphelper::string::stripEnd(sReturn, ' ');
1594 0 : return sReturn;
1595 : }
1596 :
1597 2 : SwGlossaryHdl* SwView::GetGlosHdl()
1598 : {
1599 2 : if(!m_pGlosHdl)
1600 1 : m_pGlosHdl = new SwGlossaryHdl(GetViewFrame(), m_pWrtShell);
1601 2 : return m_pGlosHdl;
1602 : }
1603 :
1604 28766 : void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1605 : {
1606 28766 : sal_Bool bCallBase = sal_True;
1607 28766 : if ( rHint.ISA(SfxSimpleHint) )
1608 : {
1609 19562 : sal_uInt32 nId = ((SfxSimpleHint&)rHint).GetId();
1610 19562 : switch ( nId )
1611 : {
1612 : // sub shells will be destroyed by the
1613 : // dispatcher, if the view frame is dying. Thus, reset member <pShell>.
1614 : case SFX_HINT_DYING:
1615 : {
1616 1576 : if ( &rBC == GetViewFrame() )
1617 : {
1618 792 : ResetSubShell();
1619 : }
1620 : }
1621 1576 : break;
1622 : case SFX_HINT_MODECHANGED:
1623 : {
1624 : // Modal mode change-over?
1625 3 : sal_Bool bModal = GetDocShell()->IsInModalMode();
1626 3 : m_pHRuler->SetActive( !bModal );
1627 3 : m_pVRuler->SetActive( !bModal );
1628 : }
1629 :
1630 : /* no break here */
1631 :
1632 : case SFX_HINT_TITLECHANGED:
1633 1717 : if ( GetDocShell()->IsReadOnly() != GetWrtShell().GetViewOptions()->IsReadonly() )
1634 : {
1635 0 : SwWrtShell &rSh = GetWrtShell();
1636 0 : rSh.SetReadonlyOption( GetDocShell()->IsReadOnly() );
1637 :
1638 0 : if ( rSh.GetViewOptions()->IsViewVRuler() )
1639 0 : CreateVRuler();
1640 : else
1641 0 : KillVRuler();
1642 0 : if ( rSh.GetViewOptions()->IsViewHRuler() )
1643 0 : CreateTab();
1644 : else
1645 0 : KillTab();
1646 0 : bool bReadonly = GetDocShell()->IsReadOnly();
1647 : // if document is to be opened in alive-mode then this has to be
1648 : // regarded while switching from readonly-mode to edit-mode
1649 0 : if( !bReadonly )
1650 : {
1651 0 : SwDrawDocument * pDrawDoc = 0;
1652 0 : if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (GetDocShell()->GetDoc()->GetDrawModel() ) ) )
1653 : {
1654 0 : if( !pDrawDoc->GetOpenInDesignMode() )
1655 0 : break;// don't touch the design mode
1656 : }
1657 : }
1658 0 : SfxBoolItem aItem( SID_FM_DESIGN_MODE, !bReadonly);
1659 0 : GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_ASYNCHRON,
1660 0 : &aItem, 0L );
1661 : }
1662 1717 : break;
1663 :
1664 : case SW_BROADCAST_DRAWVIEWS_CREATED:
1665 : {
1666 379 : bCallBase = sal_False;
1667 379 : if ( GetFormShell() )
1668 : {
1669 : GetFormShell()->SetView(
1670 0 : PTR_CAST(FmFormView, GetWrtShell().GetDrawView()) );
1671 0 : SfxBoolItem aItem( SID_FM_DESIGN_MODE, !GetDocShell()->IsReadOnly());
1672 0 : GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_SYNCHRON,
1673 0 : &aItem, 0L );
1674 : }
1675 : }
1676 379 : break;
1677 : }
1678 : }
1679 9204 : else if(rHint.ISA(FmDesignModeChangedHint))
1680 : {
1681 790 : sal_Bool bDesignMode = ((FmDesignModeChangedHint&)rHint).GetDesignMode();
1682 790 : if (!bDesignMode && GetDrawFuncPtr())
1683 : {
1684 0 : GetDrawFuncPtr()->Deactivate();
1685 0 : SetDrawFuncPtr(NULL);
1686 0 : LeaveDrawCreate();
1687 0 : AttrChangedNotify(m_pWrtShell);
1688 : }
1689 : }
1690 :
1691 28766 : if ( bCallBase )
1692 28387 : SfxViewShell::Notify(rBC, rHint);
1693 28766 : }
1694 :
1695 : #if defined WNT || defined UNX
1696 :
1697 0 : void SwView::ScannerEventHdl( const EventObject& /*rEventObject*/ )
1698 : {
1699 0 : uno::Reference< XScannerManager2 > xScanMgr = SW_MOD()->GetScannerManager();
1700 0 : if( xScanMgr.is() )
1701 : {
1702 0 : const ScannerContext aContext( xScanMgr->getAvailableScanners().getConstArray()[ 0 ] );
1703 0 : const ScanError eError = xScanMgr->getError( aContext );
1704 :
1705 0 : if( ScanError_ScanErrorNone == eError )
1706 : {
1707 0 : const uno::Reference< awt::XBitmap > xBitmap( xScanMgr->getBitmap( aContext ) );
1708 :
1709 0 : if( xBitmap.is() )
1710 : {
1711 0 : const BitmapEx aScanBmp( VCLUnoHelper::GetBitmap( xBitmap ) );
1712 :
1713 0 : if( !!aScanBmp )
1714 : {
1715 0 : Graphic aGrf(aScanBmp);
1716 0 : m_pWrtShell->Insert( aEmptyStr, aEmptyStr, aGrf );
1717 0 : }
1718 0 : }
1719 0 : }
1720 : }
1721 0 : SfxBindings& rBind = GetViewFrame()->GetBindings();
1722 0 : rBind.Invalidate( SID_TWAIN_SELECT );
1723 0 : rBind.Invalidate( SID_TWAIN_TRANSFER );
1724 0 : }
1725 : #endif
1726 :
1727 2 : void SwView::StopShellTimer()
1728 : {
1729 2 : if(m_aTimer.IsActive())
1730 : {
1731 0 : m_aTimer.Stop();
1732 0 : if ( m_bAttrChgNotifiedWithRegistrations )
1733 : {
1734 0 : GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1735 0 : m_bAttrChgNotifiedWithRegistrations = sal_False;
1736 : }
1737 0 : SelectShell();
1738 0 : m_bAttrChgNotified = sal_False;
1739 : }
1740 2 : }
1741 :
1742 1584 : sal_uInt16 SwView::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
1743 : {
1744 1584 : SfxViewFrame* pVFrame = GetViewFrame();
1745 1584 : pVFrame->SetChildWindow( SwInputChild::GetChildWindowId(), sal_False );
1746 1584 : if( pVFrame->GetDispatcher()->IsLocked() )
1747 1 : pVFrame->GetDispatcher()->Lock(sal_False);
1748 :
1749 : sal_uInt16 nRet;
1750 3156 : if ( m_pFormShell &&
1751 1572 : sal_True != (nRet = m_pFormShell->PrepareClose( bUI, bForBrowsing )) )
1752 :
1753 : {
1754 0 : return nRet;
1755 : }
1756 1584 : return SfxViewShell::PrepareClose( bUI, bForBrowsing );
1757 : }
1758 :
1759 : // status methods for clipboard.
1760 : // Status changes now notified from the clipboard.
1761 1189 : sal_Bool SwView::IsPasteAllowed()
1762 : {
1763 1189 : sal_uInt16 nPasteDestination = SwTransferable::GetSotDestination( *m_pWrtShell );
1764 1189 : if( m_nLastPasteDestination != nPasteDestination )
1765 : {
1766 : TransferableDataHelper aDataHelper(
1767 : TransferableDataHelper::CreateFromSystemClipboard(
1768 367 : &GetEditWin()) );
1769 367 : if( aDataHelper.GetXTransferable().is() )
1770 : {
1771 0 : m_bPasteState = SwTransferable::IsPaste( *m_pWrtShell, aDataHelper );
1772 : m_bPasteSpecialState = SwTransferable::IsPasteSpecial(
1773 0 : *m_pWrtShell, aDataHelper );
1774 : }
1775 : else
1776 367 : m_bPasteState = m_bPasteSpecialState = sal_False;
1777 :
1778 367 : if( 0xFFFF == m_nLastPasteDestination ) // the init value
1779 367 : m_pViewImpl->AddClipboardListener();
1780 367 : m_nLastPasteDestination = nPasteDestination;
1781 : }
1782 1189 : return m_bPasteState;
1783 : }
1784 :
1785 10 : sal_Bool SwView::IsPasteSpecialAllowed()
1786 : {
1787 10 : if ( m_pFormShell && m_pFormShell->IsActiveControl() )
1788 0 : return sal_False;
1789 :
1790 10 : sal_uInt16 nPasteDestination = SwTransferable::GetSotDestination( *m_pWrtShell );
1791 10 : if( m_nLastPasteDestination != nPasteDestination )
1792 : {
1793 : TransferableDataHelper aDataHelper(
1794 : TransferableDataHelper::CreateFromSystemClipboard(
1795 0 : &GetEditWin()) );
1796 0 : if( aDataHelper.GetXTransferable().is() )
1797 : {
1798 0 : m_bPasteState = SwTransferable::IsPaste( *m_pWrtShell, aDataHelper );
1799 : m_bPasteSpecialState = SwTransferable::IsPasteSpecial(
1800 0 : *m_pWrtShell, aDataHelper );
1801 : }
1802 : else
1803 0 : m_bPasteState = m_bPasteSpecialState = sal_False;
1804 :
1805 0 : if( 0xFFFF == m_nLastPasteDestination ) // the init value
1806 0 : m_pViewImpl->AddClipboardListener();
1807 : }
1808 10 : return m_bPasteSpecialState;
1809 : }
1810 :
1811 0 : void SwView::NotifyDBChanged()
1812 : {
1813 0 : GetViewImpl()->GetUNOObject_Impl()->NotifyDBChanged();
1814 0 : }
1815 :
1816 : // Printing
1817 :
1818 0 : SfxObjectShellLock SwView::CreateTmpSelectionDoc()
1819 : {
1820 0 : SwXTextView *const pImpl = GetViewImpl()->GetUNOObject_Impl();
1821 0 : return pImpl->BuildTmpSelectionDoc();
1822 : }
1823 :
1824 10 : void SwView::AddTransferable(SwTransferable& rTransferable)
1825 : {
1826 10 : GetViewImpl()->AddTransferable(rTransferable);
1827 10 : }
1828 :
1829 : namespace sw {
1830 :
1831 0 : void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb)
1832 : {
1833 0 : o_rData = *SW_MOD()->GetPrtOptions(bWeb);
1834 0 : }
1835 :
1836 99 : } // namespace sw
1837 :
1838 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|