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