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 : : #include <sfx2/printer.hxx>
30 : : #include <rtl/logfile.hxx>
31 : : #include <doc.hxx>
32 : : #include <IDocumentUndoRedo.hxx>
33 : : #include <docsh.hxx>
34 : : #include <viewsh.hxx>
35 : : #include <rootfrm.hxx>
36 : : #include <viewimp.hxx>
37 : : #include <viewopt.hxx>
38 : : #include <txtfrm.hxx> // Zugriff auf TxtCache
39 : : #include <notxtfrm.hxx>
40 : : #include <fntcache.hxx>
41 : : #include <docufld.hxx>
42 : : #include <ptqueue.hxx>
43 : : #include <dview.hxx> // SdrView
44 : : #include <ndgrf.hxx>
45 : : #include <ndindex.hxx>
46 : : #include <accessibilityoptions.hxx>
47 : : #include <switerator.hxx>
48 : :
49 : :
50 : : /*************************************************************************
51 : : |*
52 : : |* ViewShell::Init()
53 : : |*
54 : : |* Letzte Aenderung MA 14. Jun. 96
55 : : |*
56 : : |*************************************************************************/
57 : :
58 : 1337 : void ViewShell::Init( const SwViewOption *pNewOpt )
59 : : {
60 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "ViewShell::Init" );
61 : :
62 : 1337 : bDocSizeChgd = sal_False;
63 : :
64 : : // Wir gehen auf Nummer sicher:
65 : : // Wir muessen die alten Fontinformationen wegschmeissen,
66 : : // wenn die Druckeraufloesung oder der Zoomfaktor sich aendert.
67 : : // Init() und Reformat() sind die sichersten Stellen.
68 : 1337 : pFntCache->Flush( );
69 : :
70 : : // ViewOptions werden dynamisch angelegt
71 : :
72 [ + - ]: 1337 : if( !pOpt )
73 : : {
74 [ + - ]: 1337 : pOpt = new SwViewOption;
75 : :
76 : : // Ein ApplyViewOptions braucht nicht gerufen zu werden
77 [ + - ]: 1337 : if( pNewOpt )
78 : : {
79 : 1337 : *pOpt = *pNewOpt;
80 : : // Der Zoomfaktor muss eingestellt werden, weil in der CTOR-
81 : : // phase aus Performancegruenden kein ApplyViewOptions gerufen wird.
82 [ - + ][ - + ]: 1337 : if( GetWin() && 100 != pOpt->GetZoom() )
[ + + ]
83 : : {
84 [ # # ]: 0 : MapMode aMode( pWin->GetMapMode() );
85 [ # # ]: 0 : const Fraction aNewFactor( pOpt->GetZoom(), 100 );
86 [ # # ]: 0 : aMode.SetScaleX( aNewFactor );
87 [ # # ]: 0 : aMode.SetScaleY( aNewFactor );
88 [ # # ][ # # ]: 0 : pWin->SetMapMode( aMode );
89 : : }
90 : : }
91 : : }
92 : :
93 : 1337 : SwDocShell* pDShell = pDoc->GetDocShell();
94 : 1337 : pDoc->set(IDocumentSettingAccess::HTML_MODE, 0 != ::GetHtmlMode( pDShell ) );
95 : : // JP 02.02.99: Bug 61335 - Readonly-Flag an den ViewOptions setzen,
96 : : // bevor das Layout angelegt wird. Ansonsten muesste man
97 : : // nochmals durchformatieren!!
98 : :
99 [ + + ][ + + ]: 1337 : if( pDShell && pDShell->IsReadOnly() )
[ + - ]
100 : 2 : pOpt->SetReadonly( sal_True );
101 : :
102 : : RTL_LOGFILE_CONTEXT_TRACE( aLog, "View::Init - before InitPrt" );
103 : :
104 : : // --> FME 2007-11-06 #i82967#
105 : 1337 : OutputDevice* pPDFOut = 0;
106 : :
107 [ + - ][ - + ]: 1337 : if ( pOut && pOut->GetPDFWriter() )
[ - + ]
108 : 0 : pPDFOut = pOut;
109 : : // <--
110 : :
111 : : // --> FME 2005-01-21 #i41075#
112 : : // Only setup the printer if we need one:
113 : 1337 : const bool bBrowseMode = pOpt->getBrowseMode();
114 [ - + ]: 1337 : if( pPDFOut )
115 : 0 : InitPrt( pPDFOut );
116 : : // <--
117 : :
118 : : // --> FME 2005-03-16 #i44963# Good occasion to check if page sizes in
119 : : // page descriptions are still set to (LONG_MAX, LONG_MAX) (html import)
120 [ + + ]: 1337 : if ( !bBrowseMode )
121 : : {
122 : 1333 : pDoc->CheckDefaultPageFmt();
123 : : }
124 : : // <--
125 : :
126 : : RTL_LOGFILE_CONTEXT_TRACE( aLog, "View::Init - after InitPrt" );
127 : :
128 [ + + ]: 1337 : if( GetWin() )
129 : : {
130 : 1318 : pOpt->Init( GetWin() );
131 : 1318 : GetWin()->SetFillColor();
132 : 1318 : GetWin()->SetBackground();
133 : 1318 : GetWin()->SetLineColor();
134 : : }
135 : :
136 : : // Create a new layout, if there is no one available
137 [ + + ]: 1337 : if( !pLayout )
138 : : {
139 : : // Here's the code which disables the usage of "multiple" layouts at the moment
140 : : // If the problems with controls and groups objects are solved,
141 : : // this code can be removed...
142 : 1318 : ViewShell *pCurrShell = GetDoc()->GetCurrentViewShell();
143 [ - + ]: 1318 : if( pCurrShell )
144 : 0 : pLayout = pCurrShell->pLayout;
145 : : // end of "disable multiple layouts"
146 [ + - ]: 1318 : if( !pLayout )
147 : : {
148 : : // switched to two step construction because creating the layout in SwRootFrm needs a valid pLayout set
149 [ + - ][ + - ]: 1318 : pLayout = SwRootFrmPtr(new SwRootFrm( pDoc->GetDfltFrmFmt(), this ));//swmod081016
150 : 1318 : pLayout->Init( pDoc->GetDfltFrmFmt() );
151 : : }
152 : : }
153 : 1337 : SizeChgNotify(); //swmod 071108
154 : :
155 : : // --> #i31958#
156 : : // XForms mode: initialize XForms mode, based on design mode (draw view)
157 : : // MakeDrawView() requires layout
158 [ - + ]: 1337 : if( GetDoc()->isXForms() )
159 : : {
160 [ # # ]: 0 : if( ! HasDrawView() )
161 : 0 : MakeDrawView();
162 : 0 : pOpt->SetFormView( ! GetDrawView()->IsDesignMode() );
163 : : }
164 : : // <-- #i31958#
165 : 1337 : }
166 : :
167 : : /*************************************************************************
168 : : |*
169 : : |* ViewShell::ViewShell() CTor fuer die erste Shell.
170 : : |*
171 : : |* Letzte Aenderung MA 29. Aug. 95
172 : : |*
173 : : |*************************************************************************/
174 : :
175 : 1318 : ViewShell::ViewShell( SwDoc& rDocument, Window *pWindow,
176 : : const SwViewOption *pNewOpt, OutputDevice *pOutput,
177 : : long nFlags )
178 : : :
179 : : aBrowseBorder(),
180 : : pSfxViewShell( 0 ),
181 [ + - ]: 1318 : pImp( new SwViewImp( this ) ),
182 : : pWin( pWindow ),
183 : : pOut( pOutput ? pOutput
184 : : : pWindow ? (OutputDevice*)pWindow
185 : 0 : : (OutputDevice*)rDocument.getPrinter( true )),
186 : : mpTmpRef( 0 ),
187 : : pOpt( 0 ),
188 : 1318 : pAccOptions( new SwAccessibilityOptions ),
189 : : bShowHeaderSeparator( false ),
190 : : bShowFooterSeparator( false ),
191 : : bHeaderFooterEdit( false ),
192 : : mpTargetPaintWindow(0), // #i74769#
193 : : mpBufferedOut(0), // #i74769#
194 : : pDoc( &rDocument ),
195 : : nStartAction( 0 ),
196 : : nLockPaint( 0 ),
197 : : mpPrePostOutDev(0), // #i72754#
198 [ + - ][ + - ]: 3954 : maPrePostMapMode()
[ - + ][ # # ]
[ + - + - ]
[ + - ][ + - ]
[ + - ]
199 : : {
200 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "ViewShell::SwViewShell" );
201 : :
202 : : // OD 2004-06-01 #i26791# - in order to suppress event handling in
203 : : // <SwDrawContact::Changed> during contruction of <ViewShell> instance
204 : 1318 : mbInConstructor = true;
205 : :
206 : : bPaintInProgress = bViewLocked = bInEndAction = bFrameView =
207 : 1318 : bEndActionByVirDev = sal_False;
208 : 1318 : bPaintWorks = bEnableSmooth = sal_True;
209 : 1318 : bPreView = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags );
210 : :
211 : : // --> OD 2005-02-11 #i38810# - Do not reset modified state of document,
212 : : // if it's already been modified.
213 [ + - ]: 1318 : const bool bIsDocModified( pDoc->IsModified() );
214 [ + - ]: 1318 : pDoc->acquire();
215 : 1318 : pOutput = pOut;
216 [ + - ]: 1318 : Init( pNewOpt ); //verstellt ggf. das Outdev (InitPrt())
217 : 1318 : pOut = pOutput;
218 : :
219 : : // OD 28.03.2003 #108470# - initialize print preview layout after layout
220 : : // is created in <ViewShell::Init(..)> - called above.
221 [ - + ]: 1318 : if ( bPreView )
222 : : {
223 : : // OD 12.12.2002 #103492# - init page preview layout
224 [ # # ]: 0 : pImp->InitPagePreviewLayout();
225 : : }
226 : :
227 [ + - ]: 1318 : SET_CURR_SHELL( this );
228 : :
229 [ + - ]: 1318 : ((SwHiddenTxtFieldType*)pDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
230 [ + - ]: 2636 : SetHiddenFlag( !pOpt->IsShowHiddenField() );
231 : :
232 : : //In Init wird ein Standard-FrmFmt angelegt.
233 : : // --> OD 2005-02-11 #i38810#
234 [ + - ][ + - ]: 1318 : if ( !pDoc->GetIDocumentUndoRedo().IsUndoNoResetModified()
[ + - ][ + - ]
[ + - ]
235 : 1318 : && !bIsDocModified )
236 : : // <--
237 : : {
238 [ + - ]: 1318 : pDoc->ResetModified();
239 : : }
240 : :
241 : : //Format-Cache erweitern.
242 [ + + ]: 1318 : if ( SwTxtFrm::GetTxtCache()->GetCurMax() < 2550 )
243 [ + - ]: 1306 : SwTxtFrm::GetTxtCache()->IncreaseMax( 100 );
244 [ + - ][ + - ]: 1318 : if( pOpt->IsGridVisible() || getIDocumentDrawModelAccess()->GetDrawModel() )
[ + - ][ + + ]
[ + + ]
245 [ + - ]: 572 : Imp()->MakeDrawView();
246 : :
247 : : // OD 2004-06-01 #i26791#
248 [ + - ]: 1318 : mbInConstructor = false;
249 : 1318 : }
250 : :
251 : : /*************************************************************************
252 : : |*
253 : : |* ViewShell::ViewShell() CTor fuer weitere Shells auf ein Dokument.
254 : : |*
255 : : |* Letzte Aenderung MA 29. Aug. 95
256 : : |*
257 : : |*************************************************************************/
258 : :
259 : 19 : ViewShell::ViewShell( ViewShell& rShell, Window *pWindow,
260 : : OutputDevice *pOutput, long nFlags ) :
261 : : Ring( &rShell ),
262 : : aBrowseBorder( rShell.aBrowseBorder ),
263 : : pSfxViewShell( 0 ),
264 [ + - ]: 19 : pImp( new SwViewImp( this ) ),
265 : : pWin( pWindow ),
266 : : pOut( pOutput ? pOutput
267 : : : pWindow ? (OutputDevice*)pWindow
268 : 0 : : (OutputDevice*)rShell.GetDoc()->getPrinter( true )),
269 : : mpTmpRef( 0 ),
270 : : pOpt( 0 ),
271 : 19 : pAccOptions( new SwAccessibilityOptions ),
272 : : bShowHeaderSeparator( false ),
273 : : bShowFooterSeparator( false ),
274 : : bHeaderFooterEdit( false ),
275 : : mpTargetPaintWindow(0), // #i74769#
276 : : mpBufferedOut(0), // #i74769#
277 : 19 : pDoc( rShell.GetDoc() ),
278 : : nStartAction( 0 ),
279 : : nLockPaint( 0 ),
280 : : mpPrePostOutDev(0), // #i72754#
281 [ + - ][ - + ]: 76 : maPrePostMapMode()
[ # # # # ]
[ + - + - ]
[ + - ][ + - ]
[ + - ]
282 : : {
283 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "ViewShell::SwViewShell" );
284 : :
285 : : // OD 2004-06-01 #i26791# - in order to suppress event handling in
286 : : // <SwDrawContact::Changed> during contruction of <ViewShell> instance
287 : 19 : mbInConstructor = true;
288 : :
289 : 19 : bPaintWorks = bEnableSmooth = sal_True;
290 : : bPaintInProgress = bViewLocked = bInEndAction = bFrameView =
291 : 19 : bEndActionByVirDev = sal_False;
292 : 19 : bPreView = 0 !=( VSHELLFLAG_ISPREVIEW & nFlags );
293 : : // OD 12.12.2002 #103492#
294 [ + - ]: 19 : if( nFlags & VSHELLFLAG_SHARELAYOUT ) //swmod 080125
295 [ + - ]: 19 : pLayout = rShell.pLayout;//swmod 080125
296 : :
297 [ + - ]: 19 : SET_CURR_SHELL( this );
298 : :
299 [ + - ]: 19 : pDoc->acquire();
300 [ + - ]: 19 : sal_Bool bModified = pDoc->IsModified();
301 : :
302 : 19 : pOutput = pOut;
303 [ + - ]: 19 : Init( rShell.GetViewOptions() ); //verstellt ggf. das Outdev (InitPrt())
304 : 19 : pOut = pOutput;
305 : :
306 : : // OD 12.12.2002 #103492#
307 [ - + ]: 19 : if ( bPreView )
308 [ # # ]: 0 : pImp->InitPagePreviewLayout();
309 : :
310 [ + - ]: 19 : ((SwHiddenTxtFieldType*)pDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
311 [ + - ]: 38 : SetHiddenFlag( !pOpt->IsShowHiddenField() );
312 : :
313 : : // in Init wird ein Standard-FrmFmt angelegt
314 [ + + ][ + - ]: 19 : if( !bModified && !pDoc->GetIDocumentUndoRedo().IsUndoNoResetModified() )
[ + - ][ + - ]
[ + + ]
315 : : {
316 [ + - ]: 13 : pDoc->ResetModified();
317 : : }
318 : :
319 : : //Format-Cache erweitern.
320 [ + - ]: 19 : if ( SwTxtFrm::GetTxtCache()->GetCurMax() < 2550 )
321 [ + - ]: 19 : SwTxtFrm::GetTxtCache()->IncreaseMax( 100 );
322 [ + - ][ + - ]: 19 : if( pOpt->IsGridVisible() || getIDocumentDrawModelAccess()->GetDrawModel() )
[ + - ][ + - ]
[ + - ]
323 [ + - ]: 19 : Imp()->MakeDrawView();
324 : :
325 : : // OD 2004-06-01 #i26791#
326 [ + - ]: 19 : mbInConstructor = false;
327 : :
328 : 19 : }
329 : :
330 : : /******************************************************************************
331 : : |*
332 : : |* ViewShell::~ViewShell()
333 : : |*
334 : : |* Ersterstellung MA ??
335 : : |* Letzte Aenderung MA 10. May. 95
336 : : |*
337 : : ******************************************************************************/
338 : :
339 [ + - ][ + - ]: 1250 : ViewShell::~ViewShell()
340 : : {
341 : : {
342 [ + - ]: 1250 : SET_CURR_SHELL( this );
343 : 1250 : bPaintWorks = sal_False;
344 : :
345 : : // FME 2004-06-21 #i9684# Stopping the animated graphics is not
346 : : // necessary during printing or pdf export, because the animation
347 : : // has not been started in this case.
348 [ + - ][ + + ]: 1250 : if( pDoc && GetWin() )
[ + + ]
349 : : {
350 [ + - ]: 1231 : SwNodes& rNds = pDoc->GetNodes();
351 : : SwGrfNode *pGNd;
352 : :
353 : : SwStartNode *pStNd;
354 [ + - ]: 1231 : SwNodeIndex aIdx( *rNds.GetEndOfAutotext().StartOfSectionNode(), 1 );
355 [ + + ]: 1826 : while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
356 : : {
357 [ + - ]: 595 : aIdx++;
358 [ + + ]: 595 : if ( 0 != ( pGNd = aIdx.GetNode().GetGrfNode() ) )
359 : : {
360 [ - + ]: 42 : if( pGNd->IsAnimated() )
361 : : {
362 [ # # ]: 0 : SwIterator<SwFrm,SwGrfNode> aIter( *pGNd );
363 [ # # ][ # # ]: 0 : for( SwFrm* pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
[ # # ]
364 : : {
365 : : OSL_ENSURE( pFrm->IsNoTxtFrm(), "GraphicNode with Text?" );
366 [ # # ]: 0 : ((SwNoTxtFrm*)pFrm)->StopAnimation( pOut );
367 [ # # ]: 0 : }
368 : : }
369 : : }
370 [ + - ]: 595 : aIdx.Assign( *pStNd->EndOfSectionNode(), +1 );
371 : : }
372 : :
373 [ + - ][ + - ]: 1231 : GetDoc()->StopNumRuleAnimations( pOut );
374 : : }
375 : :
376 [ + - ][ + - ]: 1250 : delete pImp; //Erst loeschen, damit die LayoutViews vernichtet werden.
377 : 1250 : pImp = 0; // Set to zero, because ~SwFrm relies on it.
378 : :
379 [ + - ]: 1250 : if ( pDoc )
380 : : {
381 [ + - ][ - + ]: 1250 : if( !pDoc->release() )
382 [ # # ][ # # ]: 0 : delete pDoc, pDoc = 0;
383 : : else
384 [ + - ]: 1250 : GetLayout()->ResetNewLayout();
385 : : }//swmod 080317
386 : :
387 [ + - ][ + - ]: 1250 : delete pOpt;
388 : :
389 : : //Format-Cache zurueckschrauben.
390 [ + - ]: 1250 : if ( SwTxtFrm::GetTxtCache()->GetCurMax() > 250 )
391 [ + - ]: 1250 : SwTxtFrm::GetTxtCache()->DecreaseMax( 100 );
392 : :
393 : : //Ggf. aus der PaintQueue entfernen lassen
394 [ + - ]: 1250 : SwPaintQueue::Remove( this );
395 : :
396 [ + - ]: 1250 : OSL_ENSURE( !nStartAction, "EndAction() pending." );
397 : : }
398 : :
399 [ + - ]: 1250 : if ( pDoc )
400 : : {
401 [ + - ][ + - ]: 1250 : GetLayout()->DeRegisterShell( this );
402 [ + - ][ + + ]: 1250 : if(pDoc->GetCurrentViewShell()==this)
403 : 1231 : pDoc->SetCurrentViewShell( this->GetNext()!=this ?
404 [ + - ][ - + ]: 1231 : (ViewShell*)this->GetNext() : NULL );
405 : : }
406 : :
407 [ - + ][ # # ]: 1250 : delete mpTmpRef;
408 : 1250 : delete pAccOptions;
409 [ - + ]: 1269 : }
410 : :
411 : 40735 : sal_Bool ViewShell::HasDrawView() const
412 : : {
413 [ + - ]: 40735 : return Imp() ? Imp()->HasDrawView() : 0;
414 : : }
415 : :
416 : 1492 : void ViewShell::MakeDrawView()
417 : : {
418 : 1492 : Imp()->MakeDrawView( );
419 : 1492 : }
420 : :
421 : 168533 : SdrView* ViewShell::GetDrawView()
422 : : {
423 : 168533 : return Imp()->GetDrawView();
424 : : }
425 : :
426 : 0 : SdrView* ViewShell::GetDrawViewWithValidMarkList()
427 : : {
428 : 0 : SwDrawView* pDView = Imp()->GetDrawView();
429 : 0 : pDView->ValidateMarkList();
430 : 0 : return pDView;
431 : : }
432 : :
433 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|