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