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