xref: /trunk/main/sw/source/core/view/vprint.cxx (revision ca41231d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <com/sun/star/uno/Sequence.hxx>
29 #include <com/sun/star/uno/Any.hxx>
30 #include <com/sun/star/uno/Any.hxx>
31 #include <com/sun/star/view/XRenderable.hpp>
32 
33 #include <hintids.hxx>
34 #include <rtl/ustring.hxx>
35 #include <sfx2/app.hxx>
36 #include <sfx2/objsh.hxx>
37 #include <sfx2/prnmon.hxx>
38 #include <svl/languageoptions.hxx>
39 #include <editeng/paperinf.hxx>
40 #include <editeng/pbinitem.hxx>
41 #include <svx/svdview.hxx>
42 #include <toolkit/awt/vclxdevice.hxx>
43 #include <tools/debug.hxx>
44 #include <unotools/localedatawrapper.hxx>
45 #include <unotools/moduleoptions.hxx>
46 #include <unotools/syslocale.hxx>
47 #include <vcl/oldprintadaptor.hxx>
48 
49 #include <unotxdoc.hxx>
50 #include <docsh.hxx>
51 #include <txtfld.hxx>
52 #include <fmtfld.hxx>
53 #include <fmtfsize.hxx>
54 #include <frmatr.hxx>
55 #include <rootfrm.hxx>
56 #include <pagefrm.hxx>
57 #include <cntfrm.hxx>
58 #include <doc.hxx>
59 #include <IDocumentUndoRedo.hxx>
60 #include <wdocsh.hxx>
61 #include <fesh.hxx>
62 #include <pam.hxx>
63 #include <viewimp.hxx>		// Imp->SetFirstVisPageInvalid()
64 #include <layact.hxx>
65 #include <ndtxt.hxx>
66 #include <fldbas.hxx>
67 #include <docfld.hxx>		// _SetGetExpFld
68 #include <docufld.hxx>		// PostItFld /-Type
69 #include <shellres.hxx>
70 #include <viewopt.hxx>
71 #include <printdata.hxx>	// SwPrintData
72 #include <pagedesc.hxx>
73 #include <poolfmt.hxx>		// for RES_POOLPAGE_JAKET
74 #include <mdiexp.hxx>		// Ansteuern der Statusleiste
75 #include <statstr.hrc>		//      -- " --
76 #include <ptqueue.hxx>
77 #include <tabfrm.hxx>
78 #include <txtfrm.hxx>		// MinPrtLine
79 #include <viscrs.hxx>		// SwShellCrsr
80 #include <fmtpdsc.hxx>		// SwFmtPageDesc
81 #include <globals.hrc>
82 
83 
84 using namespace ::com::sun::star;
85 
86 //--------------------------------------------------------------------
87 //Klasse zum Puffern von Paints
88 class SwQueuedPaint
89 {
90 public:
91 	SwQueuedPaint *pNext;
92 	ViewShell	   *pSh;
93 	SwRect			aRect;
94 
SwQueuedPaint(ViewShell * pNew,const SwRect & rRect)95 	SwQueuedPaint( ViewShell *pNew, const SwRect &rRect ) :
96 		pNext( 0 ),
97 		pSh( pNew ),
98 		aRect( rRect )
99 	{}
100 };
101 
102 SwQueuedPaint *SwPaintQueue::pQueue = 0;
103 
104 // saves some settings from the draw view
105 class SwDrawViewSave
106 {
107 	String sLayerNm;
108 	SdrView* pDV;
109 	sal_Bool bPrintControls;
110 public:
111 	SwDrawViewSave( SdrView* pSdrView );
112 	~SwDrawViewSave();
113 };
114 
115 
Add(ViewShell * pNew,const SwRect & rNew)116 void SwPaintQueue::Add( ViewShell *pNew, const SwRect &rNew )
117 {
118 	SwQueuedPaint *pPt;
119 	if ( 0 != (pPt = pQueue) )
120 	{
121 		while ( pPt->pSh != pNew && pPt->pNext )
122 			pPt = pPt->pNext;
123 		if ( pPt->pSh == pNew )
124 		{
125 			pPt->aRect.Union( rNew );
126 			return;
127 		}
128 	}
129 	SwQueuedPaint *pNQ = new SwQueuedPaint( pNew, rNew );
130 	if ( pPt )
131 		pPt->pNext = pNQ;
132 	else
133 		pQueue = pNQ;
134 }
135 
136 
137 
Repaint()138 void SwPaintQueue::Repaint()
139 {
140 	if ( !SwRootFrm::IsInPaint() && pQueue )
141 	{
142 		SwQueuedPaint *pPt = pQueue;
143 		do
144 		{	ViewShell *pSh = pPt->pSh;
145 			SET_CURR_SHELL( pSh );
146 			if ( pSh->IsPreView() )
147 			{
148 				if ( pSh->GetWin() )
149 				{
150 					// Für PreView aussenherum, weil im PaintHdl (UI) die
151 					// Zeilen/Spalten bekannt sind.
152 					pSh->GetWin()->Invalidate();
153 					pSh->GetWin()->Update();
154 				}
155 			}
156 			else
157 				pSh->Paint( pPt->aRect.SVRect() );
158 			pPt = pPt->pNext;
159 		} while ( pPt );
160 
161 		do
162 		{	pPt = pQueue;
163 			pQueue = pQueue->pNext;
164 			delete pPt;
165 		} while ( pQueue );
166 	}
167 }
168 
169 
170 
Remove(ViewShell * pSh)171 void SwPaintQueue::Remove( ViewShell *pSh )
172 {
173 	SwQueuedPaint *pPt;
174 	if ( 0 != (pPt = pQueue) )
175 	{
176 		SwQueuedPaint *pPrev = 0;
177 		while ( pPt && pPt->pSh != pSh )
178 		{
179 			pPrev = pPt;
180 			pPt = pPt->pNext;
181 		}
182 		if ( pPt )
183 		{
184 			if ( pPrev )
185 				pPrev->pNext = pPt->pNext;
186 			else if ( pPt == pQueue )
187 				pQueue = 0;
188 			delete pPt;
189 		}
190 	}
191 }
192 
193 // ******************************************************************************
194 
SetSwVisArea(ViewShell * pSh,const SwRect & rRect)195 void SetSwVisArea( ViewShell *pSh, const SwRect &rRect /*, sal_Bool bPDFExport*/ )
196 {
197 	ASSERT( !pSh->GetWin(), "Drucken mit Window?" );
198 	pSh->aVisArea = rRect;
199 	pSh->Imp()->SetFirstVisPageInvalid();
200 	Point aPt( rRect.Pos() );
201 
202 	// calculate an offset for the rectangle of the n-th page to
203 	// move the start point of the output operation to a position
204 	// such that in the output device all pages will be painted
205 	// at the same position
206 	aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y();
207 
208 	OutputDevice *pOut = pSh->GetOut();
209 
210 	MapMode aMapMode( pOut->GetMapMode() );
211 	aMapMode.SetOrigin( aPt );
212 	pOut->SetMapMode( aMapMode );
213 }
214 
215 /******************************************************************************/
216 
InitPrt(OutputDevice * pOutDev)217 void ViewShell::InitPrt( OutputDevice *pOutDev )
218 {
219 	// Für den Printer merken wir uns einen negativen Offset, der
220 	// genau dem Offset der OutputSize entspricht. Das ist notwendig,
221 	// weil unser Ursprung die linke obere Ecke der physikalischen
222 	// Seite ist, die Ausgaben (SV) aber den Outputoffset als Ursprung
223 	// betrachten.
224 	if ( pOutDev )
225 	{
226 		aPrtOffst = Point();
227 
228 		aPrtOffst += pOutDev->GetMapMode().GetOrigin();
229 		MapMode aMapMode( pOutDev->GetMapMode() );
230 		aMapMode.SetMapUnit( MAP_TWIP );
231 		pOutDev->SetMapMode( aMapMode );
232 		pOutDev->SetLineColor();
233 		pOutDev->SetFillColor();
234 	}
235 	else
236 		aPrtOffst.X() = aPrtOffst.Y() = 0;
237 
238 	if ( !pWin )
239 		pOut = pOutDev; //Oder was sonst?
240 }
241 
242 /******************************************************************************
243  *	Methode 	:	void ViewShell::ChgAllPageOrientation
244  *	Erstellt	:	MA 08. Aug. 95
245  *	Aenderung	:
246  ******************************************************************************/
247 
248 
ChgAllPageOrientation(sal_uInt16 eOri)249 void ViewShell::ChgAllPageOrientation( sal_uInt16 eOri )
250 {
251 	ASSERT( nStartAction, "missing an Action" );
252 	SET_CURR_SHELL( this );
253 
254 	sal_uInt16 nAll = GetDoc()->GetPageDescCnt();
255 	sal_Bool bNewOri = Orientation(eOri) == ORIENTATION_PORTRAIT ? sal_False : sal_True;
256 
257 	for( sal_uInt16 i = 0; i < nAll; ++ i )
258 	{
259 		const SwPageDesc& rOld =
260 			const_cast<const SwDoc *>(GetDoc())->GetPageDesc( i );
261 
262 		if( rOld.GetLandscape() != bNewOri )
263 		{
264 			SwPageDesc aNew( rOld );
265 			{
266 				::sw::UndoGuard const ug(GetDoc()->GetIDocumentUndoRedo());
267 				GetDoc()->CopyPageDesc(rOld, aNew);
268 			}
269 			aNew.SetLandscape( bNewOri );
270 			SwFrmFmt& rFmt = aNew.GetMaster();
271 			SwFmtFrmSize aSz( rFmt.GetFrmSize() );
272 			// Groesse anpassen.
273 			// PORTRAIT  -> Hoeher als Breit
274 			// LANDSCAPE -> Breiter als Hoch
275 			// Hoehe ist die VarSize, Breite ist die FixSize (per Def.)
276 			if( bNewOri ? aSz.GetHeight() > aSz.GetWidth()
277 						: aSz.GetHeight() < aSz.GetWidth() )
278 			{
279 				SwTwips aTmp = aSz.GetHeight();
280 				aSz.SetHeight( aSz.GetWidth() );
281 				aSz.SetWidth( aTmp );
282 				rFmt.SetFmtAttr( aSz );
283 			}
284 			GetDoc()->ChgPageDesc( i, aNew );
285 		}
286 	}
287 }
288 
289 /******************************************************************************
290  *	Methode 	:	void ViewShell::ChgAllPageOrientation
291  *	Erstellt	:	MA 08. Aug. 95
292  *	Aenderung	:
293  ******************************************************************************/
294 
295 
ChgAllPageSize(Size & rSz)296 void ViewShell::ChgAllPageSize( Size &rSz )
297 {
298 	ASSERT( nStartAction, "missing an Action" );
299 	SET_CURR_SHELL( this );
300 
301 	SwDoc* pMyDoc = GetDoc();
302 	sal_uInt16 nAll = pMyDoc->GetPageDescCnt();
303 
304 	for( sal_uInt16 i = 0; i < nAll; ++i )
305 	{
306 		const SwPageDesc &rOld = const_cast<const SwDoc *>(pMyDoc)->GetPageDesc( i );
307 		SwPageDesc aNew( rOld );
308 		{
309 			::sw::UndoGuard const ug(GetDoc()->GetIDocumentUndoRedo());
310 			GetDoc()->CopyPageDesc( rOld, aNew );
311 		}
312 		SwFrmFmt& rPgFmt = aNew.GetMaster();
313 		Size aSz( rSz );
314 		const sal_Bool bOri = aNew.GetLandscape();
315 		if( bOri  ? aSz.Height() > aSz.Width()
316 				  : aSz.Height() < aSz.Width() )
317 		{
318 			SwTwips aTmp = aSz.Height();
319 			aSz.Height() = aSz.Width();
320 			aSz.Width()  = aTmp;
321 		}
322 
323 		SwFmtFrmSize aFrmSz( rPgFmt.GetFrmSize() );
324 		aFrmSz.SetSize( aSz );
325 		rPgFmt.SetFmtAttr( aFrmSz );
326 		pMyDoc->ChgPageDesc( i, aNew );
327 	}
328 }
329 
330 
CalcPagesForPrint(sal_uInt16 nMax)331 void ViewShell::CalcPagesForPrint( sal_uInt16 nMax )
332 {
333 	SET_CURR_SHELL( this );
334 
335 	SwRootFrm* pMyLayout = GetLayout();
336 
337 	const SwFrm *pPage = pMyLayout->Lower();
338 	SwLayAction aAction( pMyLayout, Imp() );
339 
340 	pMyLayout->StartAllAction();
341 	for ( sal_uInt16 i = 1; pPage && i <= nMax; pPage = pPage->GetNext(), ++i )
342 	{
343 		pPage->Calc();
344 		SwRect aOldVis( VisArea() );
345 		aVisArea = pPage->Frm();
346 		Imp()->SetFirstVisPageInvalid();
347 		aAction.Reset();
348 		aAction.SetPaint( sal_False );
349 		aAction.SetWaitAllowed( sal_False );
350 		aAction.SetReschedule( sal_True );
351 
352 		aAction.Action();
353 
354 		aVisArea = aOldVis; //Zuruecksetzen wg. der Paints!
355 		Imp()->SetFirstVisPageInvalid();
356 //		SwPaintQueue::Repaint();
357 	}
358 
359 	pMyLayout->EndAllAction();
360 }
361 
362 /******************************************************************************/
363 
FillPrtDoc(SwDoc * pPrtDoc,const SfxPrinter * pPrt)364 SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt)
365 {
366 	ASSERT( this->IsA( TYPE(SwFEShell) ),"ViewShell::Prt for FEShell only");
367 	SwFEShell* pFESh = (SwFEShell*)this;
368 	// Wir bauen uns ein neues Dokument
369 //	SwDoc *pPrtDoc = new SwDoc;
370 //	pPrtDoc->acquire();
371 //	pPrtDoc->SetRefForDocShell( (SvEmbeddedObjectRef*)&(long&)rDocShellRef );
372 	pPrtDoc->LockExpFlds();
373 
374 	// Der Drucker wird uebernommen
375 	//! Make a copy of it since it gets destroyed with the temporary document
376 	//! used for PDF export
377 	if (pPrt)
378 		pPrtDoc->setPrinter( new SfxPrinter(*pPrt), true, true );
379 
380 	const SfxPoolItem* pCpyItem;
381 	const SfxItemPool& rPool = GetAttrPool();
382 	for( sal_uInt16 nWh = POOLATTR_BEGIN; nWh < POOLATTR_END; ++nWh )
383 		if( 0 != ( pCpyItem = rPool.GetPoolDefaultItem( nWh ) ) )
384 			pPrtDoc->GetAttrPool().SetPoolDefaultItem( *pCpyItem );
385 
386 	// JP 29.07.99 - Bug 67951 - set all Styles from the SourceDoc into
387 	//                           the PrintDoc - will be replaced!
388 	pPrtDoc->ReplaceStyles( *GetDoc() );
389 
390 	SwShellCrsr *pActCrsr = pFESh->_GetCrsr();
391 	SwShellCrsr *pFirstCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetNext());
392 	if( !pActCrsr->HasMark() ) // bei Multiselektion kann der aktuelle Cursor leer sein
393 	{
394 		pActCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetPrev());
395 	}
396 
397 	// Die Y-Position der ersten Selektion
398 	// Die Y-Position der ersten Selektion
399 	Point aSelPoint;
400 	if( pFESh->IsTableMode() )
401 	{
402 		SwShellTableCrsr* pShellTblCrsr = pFESh->GetTableCrsr();
403 
404 		const SwCntntNode* pCntntNode = pShellTblCrsr->GetNode()->GetCntntNode();
405 		const SwCntntFrm *pCntntFrm = pCntntNode ? pCntntNode->getLayoutFrm( GetLayout(), 0, pShellTblCrsr->Start() ) : 0;
406 		if( pCntntFrm )
407 		{
408 			SwRect aCharRect;
409 			SwCrsrMoveState aTmpState( MV_NONE );
410 			pCntntFrm->GetCharRect( aCharRect, *pShellTblCrsr->Start(), &aTmpState );
411 	aSelPoint = Point( aCharRect.Left(), aCharRect.Top() );
412 		}
413 	}
414 	else
415 	{
416 		aSelPoint = pFirstCrsr->GetSttPos();
417 	}
418 
419 	const SwPageFrm* pPage = GetLayout()->GetPageAtPos( aSelPoint );
420 	ASSERT( pPage, "no page found!" );
421 
422 	// get page descriptor - fall back to the first one if pPage could not be found
423 	const SwPageDesc* pPageDesc = pPage ? pPrtDoc->FindPageDescByName(
424 		pPage->GetPageDesc()->GetName() ) : &pPrtDoc->_GetPageDesc( (sal_uInt16)0 );
425 
426 	if( !pFESh->IsTableMode() && pActCrsr->HasMark() )
427 	{	// Am letzten Absatz die Absatzattribute richten:
428 		SwNodeIndex aNodeIdx( *pPrtDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
429 		SwTxtNode* pTxtNd = pPrtDoc->GetNodes().GoNext( &aNodeIdx )->GetTxtNode();
430 		SwCntntNode *pLastNd =
431 			pActCrsr->GetCntntNode( (*pActCrsr->GetMark()) <= (*pActCrsr->GetPoint()) );
432 		// Hier werden die Absatzattribute des ersten Absatzes uebertragen
433 		if( pLastNd && pLastNd->IsTxtNode() )
434 			((SwTxtNode*)pLastNd)->CopyCollFmt( *pTxtNd );
435 	}
436 
437 	// es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!)
438 //REMOVE	//		if( aDocShellRef.Is() )
439 //REMOVE	//			SwDataExchange::InitOle( aDocShellRef, pPrtDoc );
440 	// und fuellen es mit dem selektierten Bereich
441 	pFESh->Copy( pPrtDoc );
442 
443 	//Jetzt noch am ersten Absatz die Seitenvorlage setzen
444 	{
445 		SwNodeIndex aNodeIdx( *pPrtDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
446 		SwCntntNode* pCNd = pPrtDoc->GetNodes().GoNext( &aNodeIdx ); // gehe zum 1. ContentNode
447 		if( pFESh->IsTableMode() )
448 		{
449 			SwTableNode* pTNd = pCNd->FindTableNode();
450 			if( pTNd )
451 				pTNd->GetTable().GetFrmFmt()->SetFmtAttr( SwFmtPageDesc( pPageDesc ) );
452 		}
453 		else
454 		{
455 			pCNd->SetAttr( SwFmtPageDesc( pPageDesc ) );
456 			if( pFirstCrsr->HasMark() )
457 			{
458 				SwTxtNode *pTxtNd = pCNd->GetTxtNode();
459 				if( pTxtNd )
460 				{
461 					SwCntntNode *pFirstNd =
462 						pFirstCrsr->GetCntntNode( (*pFirstCrsr->GetMark()) > (*pFirstCrsr->GetPoint()) );
463 					// Hier werden die Absatzattribute des ersten Absatzes uebertragen
464 					if( pFirstNd && pFirstNd->IsTxtNode() )
465 						((SwTxtNode*)pFirstNd)->CopyCollFmt( *pTxtNd );
466 				}
467 			}
468 		}
469 	}
470 	return pPrtDoc;
471 }
472 
473 
PrintOrPDFExport(OutputDevice * pOutDev,SwPrintData const & rPrintData,sal_Int32 nRenderer)474 sal_Bool ViewShell::PrintOrPDFExport(
475 	OutputDevice *pOutDev,
476 	SwPrintData const& rPrintData,
477 	sal_Int32 nRenderer /* the index in the vector of pages to be printed */ )
478 {
479 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
480 //Immer die Druckroutinen in viewpg.cxx (PrintProspect) mitpflegen!!
481 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
482 
483 	const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagesToPrint().size() - 1;
484 #if OSL_DEBUG_LEVEL > 1
485 	DBG_ASSERT( 0 <= nRenderer && nRenderer <= nMaxRenderer, "nRenderer out of bounds");
486 #endif
487 	if (!pOutDev || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer)
488 		return sal_False;
489 
490 	// save settings of OutputDevice (should be done always since the
491 	// output device is now provided by a call from outside the Writer)
492 	pOutDev->Push();
493 
494 	// eine neue Shell fuer den Printer erzeugen
495 	ViewShell *pShell;
496 	SwDoc *pOutDevDoc;
497 
498 	// Print/PDF export for (multi-)selection has already generated a
499 	// temporary document with the selected text.
500 	// (see XRenderable implementation in unotxdoc.cxx)
501 	// It is implemented this way because PDF export calls this Prt function
502 	// once per page and we do not like to always have the temporary document
503 	// to be created that often here.
504 	pOutDevDoc = GetDoc();
505 	pShell = new ViewShell( *this, 0, pOutDev );
506 
507 	SdrView *pDrawView = pShell->GetDrawView();
508 	if (pDrawView)
509 	{
510 		pDrawView->SetBufferedOutputAllowed( false );
511 		pDrawView->SetBufferedOverlayAllowed( false );
512 	}
513 
514 	{	//Zusaetzlicher Scope, damit die CurrShell vor dem zerstoeren der
515 		//Shell zurueckgesetzt wird.
516 
517 		SET_CURR_SHELL( pShell );
518 
519 		//JP 01.02.99: das ReadOnly Flag wird NIE mitkopiert; Bug 61335
520 		if( pOpt->IsReadonly() )
521 			pShell->pOpt->SetReadonly( sal_True );
522 
523 		// save options at draw view:
524 		SwDrawViewSave aDrawViewSave( pShell->GetDrawView() );
525 
526 		pShell->PrepareForPrint( rPrintData );
527 
528 		const sal_Int32 nPage = rPrintData.GetRenderData().GetPagesToPrint()[ nRenderer ];
529 #if OSL_DEBUG_LEVEL > 1
530 		DBG_ASSERT( nPage == 0 || rPrintData.GetRenderData().GetValidPagesSet().count( nPage ) == 1, "nPage not valid" );
531 #endif
532 		const SwPageFrm *pStPage = 0;
533 		if (nPage > 0) // a 'regular' page, not one from the post-it document
534 		{
535 			const SwRenderData::ValidStartFramesMap_t &rFrms = rPrintData.GetRenderData().GetValidStartFrames();
536 			SwRenderData::ValidStartFramesMap_t::const_iterator aIt( rFrms.find( nPage ) );
537 			DBG_ASSERT( aIt != rFrms.end(), "failed to find start frame" );
538 			if (aIt == rFrms.end())
539 				return sal_False;
540 			pStPage = aIt->second;
541 		}
542 		else // a page from the post-its document ...
543 		{
544 			DBG_ASSERT( nPage == 0, "unexpected page number. 0 for post-it pages expected" );
545 			pStPage = rPrintData.GetRenderData().GetPostItStartFrames()[ nRenderer ];
546 		}
547 		DBG_ASSERT( pStPage, "failed to get start page" );
548 
549 		//!! applying view options and formatting the document should now only be done in getRendererCount!
550 
551 		ViewShell *pViewSh2 = nPage == 0 ? /* post-it page? */
552 				rPrintData.GetRenderData().m_pPostItShell : pShell;
553 		::SetSwVisArea( pViewSh2, pStPage->Frm() );
554 
555 // FIXME disabled because rPrintData.aOffset is always (0,0)
556 #if 0
557 		// wenn wir einen Umschlag drucken wird ein Offset beachtet
558 		if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET )
559 		{
560 			Point aNewOrigin = pOutDev->GetMapMode().GetOrigin();
561 			aNewOrigin += rPrintData.aOffset;
562 			MapMode aTmp( pOutDev->GetMapMode() );
563 			aTmp.SetOrigin( aNewOrigin );
564 			pOutDev->SetMapMode( aTmp );
565 		}
566 #endif
567 
568 		pShell->InitPrt( pOutDev );
569 
570 		pViewSh2 = nPage == 0 ? /* post-it page? */
571 				rPrintData.GetRenderData().m_pPostItShell : pShell;
572 		::SetSwVisArea( pViewSh2, pStPage->Frm() );
573 
574 		pStPage->GetUpper()->Paint( pStPage->Frm(), &rPrintData );
575 
576 		SwPaintQueue::Repaint();
577 	} // Zus. Scope wg. CurShell!
578 
579 	delete pShell;
580 
581 	// restore settings of OutputDevice (should be done always now since the
582 	// output device is now provided by a call from outside the Writer)
583 	pOutDev->Pop();
584 
585 	return sal_True;
586 }
587 
588 /******************************************************************************
589  *	Methode 	:	PrtOle2()
590  *	Beschreibung:
591  *	Erstellt	:	PK 07.12.94
592  *	Aenderung	:	MA 16. Feb. 95
593  ******************************************************************************/
594 
595 
596 
PrtOle2(SwDoc * pDoc,const SwViewOption * pOpt,const SwPrintData & rOptions,OutputDevice * pOleOut,const Rectangle & rRect)597 void ViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData& rOptions,
598 						 OutputDevice* pOleOut, const Rectangle& rRect )
599 {
600 	// Wir brauchen eine Shell fuer das Drucken. Entweder hat das Doc schon
601 	// eine, dann legen wir uns eine neue Sicht an, oder das Doc hat noch
602 	// keine, dann erzeugen wir die erste Sicht.
603 	ViewShell *pSh;
604 	if( pDoc->GetCurrentViewShell() )
605 		pSh = new ViewShell( *pDoc->GetCurrentViewShell(), 0, pOleOut,VSHELLFLAG_SHARELAYOUT );//swmod 080129
606 	else	//swmod 071108//swmod 071225
607 		pSh = new ViewShell( *pDoc, 0, pOpt, pOleOut);//swmod 080129
608 
609 	{
610 		SET_CURR_SHELL( pSh );
611 		pSh->PrepareForPrint( rOptions );
612 		pSh->SetPrtFormatOption( sal_True );
613 
614 		SwRect aSwRect( rRect );
615 		pSh->aVisArea = aSwRect;
616 
617 		if ( pSh->GetViewOptions()->getBrowseMode() &&
618 			pSh->GetNext() == pSh )
619 		{
620 			pSh->CheckBrowseView( sal_False );
621 			pSh->GetLayout()->Lower()->InvalidateSize();
622 		}
623 
624 		// --> FME 2005-02-10 #119474#
625 		// CalcPagesForPrint() should not be necessary here. The pages in the
626 		// visible area will be formatted in SwRootFrm::Paint().
627 		// Removing this gives us a performance gain during saving the
628 		// document because the thumbnail creation will not trigger a complete
629 		// formatting of the document.
630 		// Seiten fuers Drucken formatieren
631 		// pSh->CalcPagesForPrint( SHRT_MAX );
632 		// <--
633 
634 		//#39275# jetzt will der Meyer doch ein Clipping
635 		pOleOut->Push( PUSH_CLIPREGION );
636 		pOleOut->IntersectClipRegion( aSwRect.SVRect() );
637 		pSh->GetLayout()->Paint( aSwRect );
638 //		SFX_APP()->SpoilDemoOutput( *pOleOut, rRect );
639 		pOleOut->Pop();
640 
641 		// erst muss das CurrShell Object zerstört werden!!
642 	}
643 	delete pSh;
644 }
645 
646 /******************************************************************************
647  *	Methode 	:	IsAnyFieldInDoc()
648  *	Beschreibung:	Stellt fest, ob im DocNodesArray Felder verankert sind
649  *	Erstellt	:	JP 27.07.95
650  *	Aenderung	:	JP 10.12.97
651  ******************************************************************************/
652 
653 
654 
IsAnyFieldInDoc() const655 sal_Bool ViewShell::IsAnyFieldInDoc() const
656 {
657 	const SfxPoolItem* pItem;
658 	sal_uInt32 nMaxItems = pDoc->GetAttrPool().GetItemCount2( RES_TXTATR_FIELD );
659 	for( sal_uInt32 n = 0; n < nMaxItems; ++n )
660 	{
661 		if( 0 != (pItem = pDoc->GetAttrPool().GetItem2( RES_TXTATR_FIELD, n )))
662 		{
663 			const SwFmtFld* pFmtFld = (SwFmtFld*)pItem;
664 			const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld();
665 			if( pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
666 			{
667 				return sal_True;
668 			}
669 		}
670 	}
671 
672 	nMaxItems = pDoc->GetAttrPool().GetItemCount2( RES_TXTATR_INPUTFIELD );
673 	for( sal_uInt32 n = 0; n < nMaxItems; ++n )
674 	{
675 		if( 0 != (pItem = pDoc->GetAttrPool().GetItem2( RES_TXTATR_INPUTFIELD, n )))
676 		{
677 			const SwFmtFld* pFmtFld = (SwFmtFld*)pItem;
678 			const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld();
679 			if( pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
680 			{
681 				return sal_True;
682 			}
683 		}
684 	}
685 
686 	return sal_False;
687 }
688 
689 
690 
691 /******************************************************************************
692  * SwDrawViewSave
693  *
694  * Saves some settings at the draw view
695  ******************************************************************************/
696 
SwDrawViewSave(SdrView * pSdrView)697 SwDrawViewSave::SwDrawViewSave( SdrView* pSdrView )
698 	: pDV( pSdrView )
699 {
700 	if ( pDV )
701 	{
702 		sLayerNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM("Controls" ) );
703 		bPrintControls = pDV->IsLayerPrintable( sLayerNm );
704 	}
705 }
706 
~SwDrawViewSave()707 SwDrawViewSave::~SwDrawViewSave()
708 {
709 	if ( pDV )
710 	{
711 		pDV->SetLayerPrintable( sLayerNm, bPrintControls );
712 	}
713 }
714 
715 
716 // OD 09.01.2003 #i6467# - method also called for page preview
PrepareForPrint(const SwPrintData & rOptions)717 void ViewShell::PrepareForPrint( const SwPrintData &rOptions )
718 {
719 	// Viewoptions fuer den Drucker setzen
720 	pOpt->SetGraphic ( sal_True == rOptions.bPrintGraphic );
721 	pOpt->SetTable	 ( sal_True == rOptions.bPrintTable );
722 	pOpt->SetDraw	 ( sal_True == rOptions.bPrintDraw );
723 	pOpt->SetControl ( sal_True == rOptions.bPrintControl );
724 	pOpt->SetPageBack( sal_True == rOptions.bPrintPageBackground );
725 	pOpt->SetBlackFont( sal_True == rOptions.bPrintBlackFont );
726 
727 	if ( HasDrawView() )
728 	{
729 		SdrView *pDrawView = GetDrawView();
730 		String sLayerNm;
731 		sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Controls" ));
732 		// OD 09.01.2003 #i6467# - consider, if view shell belongs to page preview
733 		if ( !IsPreView() )
734 		{
735 			pDrawView->SetLayerPrintable( sLayerNm, rOptions.bPrintControl );
736 		}
737 		else
738 		{
739 			pDrawView->SetLayerVisible( sLayerNm, rOptions.bPrintControl );
740 		}
741 	}
742 }
743 
744 /* vim: set noet sw=4 ts=4: */
745