merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / uiview / viewprt.cxx
blob4f3870c559dd0cd1500c2bf2c9d218472c77b9f4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewprt.cxx,v $
10 * $Revision: 1.42 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #include <com/sun/star/text/NotePrintMode.hpp>
36 #if STLPORT_VERSION>=321
37 #include <cstdarg>
38 #endif
40 #ifndef _CMDID_H
41 #include <cmdid.h>
42 #endif
44 #ifndef _SVSTDARR_HXX
45 #define _SVSTDARR_STRINGSDTOR
46 #include <svtools/svstdarr.hxx>
47 #endif
48 #include <sfx2/request.hxx>
50 #include <sfx2/app.hxx>
51 #include <svtools/flagitem.hxx>
52 #include <vcl/msgbox.hxx>
53 #include <svtools/printdlg.hxx>
54 #include <sfx2/printer.hxx>
55 #include <sfx2/prnmon.hxx>
56 #include <svx/paperinf.hxx>
57 #include <sfx2/dispatch.hxx>
58 #include <svtools/misccfg.hxx>
59 #include <svx/prtqry.hxx>
60 #include <svx/svdview.hxx>
61 #include <svtools/eitem.hxx>
62 #include <svtools/stritem.hxx>
63 #include <svtools/intitem.hxx>
64 #include <svtools/flagitem.hxx>
65 #include <svx/linkmgr.hxx>
67 #include <modcfg.hxx>
68 #include <edtwin.hxx>
69 #include <view.hxx>
70 #include <wrtsh.hxx>
71 #include <docsh.hxx>
72 #include <viewopt.hxx>
73 #include <prtopt.hxx>
74 #include <swprtopt.hxx>
75 #include <fontcfg.hxx>
76 #include <cfgitems.hxx>
77 #include <dbmgr.hxx>
78 #include <docstat.hxx>
79 #include <viewfunc.hxx>
80 #include <swmodule.hxx>
81 #include <wview.hxx>
82 #include <doc.hxx>
83 #include <fldbas.hxx>
85 #include <globals.hrc>
86 #include <view.hrc>
87 #include <app.hrc>
88 #include <svtools/eitem.hxx>
89 #include <swwrtshitem.hxx>
90 #include "swabstdlg.hxx"
91 #include <svtools/slstitm.hxx>
93 #include <unomid.h>
95 using namespace ::com::sun::star;
98 /*--------------------------------------------------------------------
99 Beschreibung: Drucker an Sfx uebergeben
100 --------------------------------------------------------------------*/
103 SfxPrinter* __EXPORT SwView::GetPrinter( BOOL bCreate )
105 const IDocumentDeviceAccess* pIDDA = GetWrtShell().getIDocumentDeviceAccess();
106 SfxPrinter *pOld = pIDDA->getPrinter( false );
107 SfxPrinter *pPrt = pIDDA->getPrinter( bCreate );
108 if ( pOld != pPrt )
110 BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
111 ::SetAppPrintOptions( &GetWrtShell(), bWeb );
113 return pPrt;
116 /*--------------------------------------------------------------------
117 Beschreibung: Druckerwechsel weitermelden
118 --------------------------------------------------------------------*/
120 void SetPrinter( IDocumentDeviceAccess* pIDDA, SfxPrinter* pNew, BOOL bWeb )
122 SwPrintOptions* pOpt = SW_MOD()->GetPrtOptions(bWeb);
123 if( !pOpt)
124 return;
126 // Applikationseigene Druckoptionen aus SfxPrinter auslesen
127 const SfxItemSet& rSet = pNew->GetOptions();
129 const SwAddPrinterItem* pAddPrinterAttr;
130 if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_ADDPRINTER, FALSE,
131 (const SfxPoolItem**)&pAddPrinterAttr ) )
133 if( pIDDA )
134 pIDDA->setPrintData( *pAddPrinterAttr );
135 if( pAddPrinterAttr->GetFax().getLength() )
136 pOpt->SetFaxName(pAddPrinterAttr->GetFax());
141 USHORT __EXPORT SwView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool )
143 SwWrtShell &rSh = GetWrtShell();
144 SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false );
145 if ( pOld && pOld->IsPrinting() )
146 return SFX_PRINTERROR_BUSY;
148 if ( (SFX_PRINTER_JOBSETUP | SFX_PRINTER_PRINTER) & nDiffFlags )
150 rSh.getIDocumentDeviceAccess()->setPrinter( pNew, true, true );
151 if ( nDiffFlags & SFX_PRINTER_PRINTER )
152 rSh.SetModified();
154 BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
155 if ( nDiffFlags & SFX_PRINTER_OPTIONS )
156 ::SetPrinter( rSh.getIDocumentDeviceAccess(), pNew, bWeb );
158 const BOOL bChgOri = nDiffFlags & SFX_PRINTER_CHG_ORIENTATION ? TRUE : FALSE;
159 const BOOL bChgSize= nDiffFlags & SFX_PRINTER_CHG_SIZE ? TRUE : FALSE;
160 if ( bChgOri || bChgSize )
162 rSh.StartAllAction();
163 if ( bChgOri )
164 rSh.ChgAllPageOrientation( USHORT(pNew->GetOrientation()) );
165 if ( bChgSize )
167 Size aSz( SvxPaperInfo::GetPaperSize( pNew ) );
168 rSh.ChgAllPageSize( aSz );
170 rSh.SetModified();
171 rSh.EndAllAction();
172 InvalidateRulerPos();
174 return 0;
177 /*--------------------------------------------------------------------
178 Beschreibung:
179 --------------------------------------------------------------------*/
181 ErrCode SwView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilent, BOOL bIsAPI )
183 // First test
184 SwWrtShell* pSh = &GetWrtShell();
185 SwNewDBMgr* pMgr = pSh->GetNewDBMgr();
187 int bPrintSelection = -1;
188 USHORT nMergeType = pMgr->GetMergeType();
189 if( DBMGR_MERGE_MAILMERGE != nMergeType &&
190 DBMGR_MERGE_DOCUMENTS != nMergeType &&
191 !pDlg &&
192 !bIsAPI && ( pSh->IsSelection() || pSh->IsFrmSelected() ||
193 pSh->IsObjSelected() ) )
195 short nBtn = SvxPrtQryBox(&GetEditWin()).Execute();
196 if( RET_CANCEL == nBtn )
197 return ERRCODE_IO_ABORT;
199 if( RET_OK == nBtn )
200 bPrintSelection = 1;
201 else
202 bPrintSelection = 0;
205 // Der PrintProgress stellt Handler am Printer der ViewShell ein.
206 // Das kann natuerlich erste nach dem evtl. Umschalten des Druckers korrekt
207 // funktionieren. #55210#
208 // SfxPrintProgress *pProgress = new SfxPrintProgress( this, !bSilent );
209 SfxPrintProgress *pProgress = 0;
210 SfxPrinter *pDocPrinter = GetPrinter(TRUE);
211 if ( !pPrinter )
212 pPrinter = pDocPrinter;
213 else if ( pDocPrinter != pPrinter )
215 //Da der Doc-Drucker beim SetPrinter geloescht wird,
216 // muss man ihn vorher clonen
217 SfxPrinter* pClone = pDocPrinter->Clone();
218 SetPrinter( pPrinter, SFX_PRINTER_PRINTER );
219 pProgress = new SfxPrintProgress( this, !bSilent );
220 pProgress->RestoreOnEndPrint( pClone );
222 if(!pProgress)
223 pProgress = new SfxPrintProgress( this, !bSilent );
224 pProgress->SetWaitMode(FALSE);
226 BOOL bStartJob = pPrinter->InitJob( &GetEditWin(),
227 !bIsAPI && pSh->HasDrawView() && pSh->GetDrawView()->GetModel()->HasTransparentObjects());
228 if( bStartJob )
230 // Drucker starten
231 PreparePrint( pDlg );
232 SfxObjectShell *pObjShell = GetViewFrame()->GetObjectShell();
233 //#i82625# GetTitle( 0 ) doesn't work for 'embedded' documents like forms or reports
234 String sDocumentTitle( pObjShell->GetTitle(SFX_TITLE_APINAME));
235 SwPrtOptions aOpts( sDocumentTitle );
236 BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
237 nMergeType = pMgr->GetMergeType();
239 BOOL bPrtPros;
240 BOOL bPrtPros_RTL;
241 SwView::MakeOptions( pDlg, aOpts, &bPrtPros, &bPrtPros_RTL, bWeb, GetPrinter(),
242 pSh->getIDocumentDeviceAccess()->getPrintData() );
244 //set the appropriate view options to print
245 //on silent mode the field commands have to be switched off always
246 //on default print the user is asked what to do
247 const SwViewOption* pCurrentViewOptions = pSh->GetViewOptions();
248 bool bSwitchOff_IsFldName = pCurrentViewOptions->IsFldName() && pSh->IsAnyFieldInDoc();
250 if(!bSilent && bSwitchOff_IsFldName)
252 QueryBox aBox( &GetEditWin(), SW_RES( DLG_PRT_FIELDNAME ) );
253 USHORT nRet = aBox.Execute();
254 if( RET_CANCEL == nRet)
255 return ERRCODE_IO_ABORT;
256 // disable field commands
257 if( RET_NO != nRet )
259 bSwitchOff_IsFldName = false;
262 bool bApplyViewOptions = bSwitchOff_IsFldName;
263 //switch off display of hidden characters if on and hidden characters are in use
264 const sal_Bool bOldShowHiddenChar = pCurrentViewOptions->IsShowHiddenChar();
265 const sal_Bool bOldMetaChars = pCurrentViewOptions->IsViewMetaChars();
266 if( bOldShowHiddenChar != aOpts.IsPrintHiddenText()
267 && pSh->GetDoc()->ContainsHiddenChars())
268 bApplyViewOptions |= true;
269 //switch off display of hidden paragraphs if on and hidden paragraphs are in use
270 const sal_Bool bOldShowHiddenPara = pCurrentViewOptions->IsShowHiddenPara();
271 if( aOpts.IsPrintHiddenText() != bOldShowHiddenPara )
273 const SwFieldType* pFldType = pSh->GetDoc()->GetSysFldType(RES_HIDDENPARAFLD);
274 if( pFldType && pFldType->GetDepends())
275 bApplyViewOptions |= true;
277 const sal_Bool bOldShowHiddenField = pCurrentViewOptions->IsShowHiddenField();
278 if( aOpts.IsPrintHiddenText() != bOldShowHiddenField )
280 const SwFieldType* pFldType = pSh->GetDoc()->GetSysFldType(RES_HIDDENTXTFLD);
281 if( pFldType || pFldType->GetDepends())
282 bApplyViewOptions |= true;
285 SwViewOption* pOrgViewOption = 0;
286 bApplyViewOptions |= !aOpts.IsPrintTextPlaceholder();
287 if(bApplyViewOptions)
289 pOrgViewOption = new SwViewOption(*pSh->GetViewOptions());
290 if(bSwitchOff_IsFldName)
291 pOrgViewOption->SetFldName(aOpts.IsPrintHiddenText());
293 pOrgViewOption->SetShowHiddenChar(aOpts.IsPrintHiddenText());
294 pOrgViewOption->SetViewMetaChars(sal_True);
295 pOrgViewOption->SetShowHiddenPara(aOpts.IsPrintHiddenText());
296 pOrgViewOption->SetShowHiddenField(aOpts.IsPrintHiddenText());
297 pOrgViewOption->SetShowPlaceHolderFields( aOpts.bPrintTextPlaceholder );
299 SW_MOD()->ApplyUsrPref(*pOrgViewOption, this, VIEWOPT_DEST_VIEW_ONLY );
302 if( nMergeType == DBMGR_MERGE_MAILMERGE ||
303 DBMGR_MERGE_DOCUMENTS == nMergeType )
305 if(DBMGR_MERGE_DOCUMENTS == nMergeType)
306 bStartJob = pMgr->MergePrintDocuments( *this, aOpts, *pProgress, bIsAPI );
307 else
308 bStartJob = pMgr->MergePrint( *this, aOpts, *pProgress, bIsAPI );
310 else
312 const BOOL bLockedView = pSh->IsViewLocked();
313 pSh->LockView( TRUE );
315 //BrowseView abschalten und die View gegen alle Paints locken.
316 BOOL bBrowse = pSh->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);
317 SfxAllItemSet aSet( SFX_APP()->GetPool() );
318 SfxBoolItem aBrowse( SID_BROWSER_MODE, FALSE );
319 if ( bBrowse )
321 if ( pSh->GetWin() )
322 pSh->GetWin()->Update();
323 pSh->LockPaint();
324 aSet.Put( aBrowse, aBrowse.Which() );
325 SfxRequest aReq( SID_BROWSER_MODE, 0, aSet );
326 GetDocShell()->Execute( aReq );
329 // die Felder aktualisieren
330 BOOL bIsModified = pSh->IsModified();
331 pSh->StartAllAction();
332 SwDocStat aDocStat;
333 pSh->UpdateDocStat( aDocStat );
334 pSh->EndAllTblBoxEdit();
335 pSh->ViewShell::UpdateFlds(TRUE);
336 if( pSh->IsCrsrInTbl() )
338 pSh->ClearTblBoxCntnt();
339 pSh->SaveTblBoxCntnt();
341 pSh->EndAllAction();
343 if( !bIsModified )
344 pSh->ResetModified();
346 if( -1 != bPrintSelection )
347 aOpts.bPrintSelection = 0 != bPrintSelection;
349 uno::Sequence< beans::PropertyValue> aViewProperties(18);
350 beans::PropertyValue* pViewProperties = aViewProperties.getArray();
351 pViewProperties[1].Name = C2U("PrintGraphics");
352 pViewProperties[1].Value <<= (sal_Bool)aOpts.IsPrintGraphic();
353 pViewProperties[2].Name = C2U("PrintTables");
354 pViewProperties[2].Value <<= (sal_Bool)aOpts.IsPrintTable();
355 pViewProperties[3].Name = C2U("PrintDrawings");
356 pViewProperties[3].Value <<= (sal_Bool)aOpts.IsPrintDraw();
357 pViewProperties[4].Name = C2U("PrintLeftPages");
358 pViewProperties[4].Value <<= (sal_Bool)aOpts.IsPrintLeftPage();
359 pViewProperties[5].Name = C2U("PrintRightPages");
360 pViewProperties[5].Value <<= (sal_Bool)aOpts.IsPrintRightPage();
361 pViewProperties[6].Name = C2U("PrintControls");
362 pViewProperties[6].Value <<= (sal_Bool)aOpts.IsPrintControl();
363 pViewProperties[7].Name = C2U("PrintReversed");
364 pViewProperties[7].Value <<= (sal_Bool)aOpts.IsPrintReverse();
365 pViewProperties[8].Name = C2U("PrintPaperFromSetup");
366 pViewProperties[8].Value <<= (sal_Bool)aOpts.IsPaperFromSetup();
367 pViewProperties[9].Name = C2U("PrintFaxName");
368 pViewProperties[9].Value <<= aOpts.GetFaxName();
369 pViewProperties[10].Name = C2U("PrintAnnotationMode");
370 pViewProperties[10].Value <<= (text::NotePrintMode) aOpts.GetPrintPostIts();
371 pViewProperties[11].Name = C2U("PrintProspect");
372 pViewProperties[11].Value <<= (sal_Bool)aOpts.IsPrintProspect();
373 pViewProperties[12].Name = C2U("PrintPageBackground");
374 pViewProperties[12].Value <<= (sal_Bool)aOpts.IsPrintPageBackground();
375 pViewProperties[13].Name = C2U("PrintBlackFonts");
376 pViewProperties[13].Value <<= (sal_Bool)aOpts.IsPrintBlackFont();
377 pViewProperties[0].Name = C2U("IsSinglePrintJob");
378 pViewProperties[0].Value <<= (sal_Bool)aOpts.IsPrintSingleJobs();
379 pViewProperties[14].Name = C2U("Selection");
380 pViewProperties[14].Value <<= (sal_Bool)aOpts.bPrintSelection;
381 pViewProperties[15].Name = C2U("PrintEmptyPages");
382 pViewProperties[15].Value <<= (sal_Bool)aOpts.bPrintEmptyPages;
383 pViewProperties[16].Name = C2U("PrintHiddenText");
384 pViewProperties[16].Value <<= (sal_Bool)aOpts.bPrintHiddenText;
385 pViewProperties[17].Name = C2U("PrintTextPlaceholder");
386 pViewProperties[17].Value <<= (sal_Bool)aOpts.bPrintTextPlaceholder;
387 SetAdditionalPrintOptions(aViewProperties);
389 SfxViewShell::Print(*pProgress, bIsAPI );
390 if ( !pProgress->IsAborted() )
392 if( bPrtPros )
394 bStartJob = pPrinter->StartJob( aOpts.GetJobName() );
395 if( bStartJob )
396 pSh->PrintProspect( aOpts, *pProgress, bPrtPros_RTL );
398 else
399 bStartJob = pSh->Prt( aOpts, pProgress );
401 if ( bBrowse )
403 aBrowse.SetValue( TRUE );
404 aSet.Put( aBrowse, aBrowse.Which() );
405 SfxRequest aReq( SID_BROWSER_MODE, 0, aSet );
406 GetDocShell()->Execute( aReq );
407 pSh->UnlockPaint();
410 else
411 bStartJob = FALSE;
413 pSh->LockView( bLockedView );
415 if(pOrgViewOption)
417 if(bSwitchOff_IsFldName)
418 pOrgViewOption->SetFldName(TRUE);
419 pOrgViewOption->SetShowHiddenChar(bOldShowHiddenChar);
420 pOrgViewOption->SetViewMetaChars(bOldMetaChars);
421 pOrgViewOption->SetShowHiddenField(bOldShowHiddenField);
422 pOrgViewOption->SetShowHiddenPara(bOldShowHiddenPara);
423 //must to be set to sal_True anyway
424 pOrgViewOption->SetShowPlaceHolderFields( sal_True );
425 SW_MOD()->ApplyUsrPref(*pOrgViewOption, this, VIEWOPT_DEST_VIEW_ONLY );
426 delete pOrgViewOption;
430 if( !bStartJob )
432 // Printer konnte nicht gestartet werden
433 delete pProgress;
434 return pPrinter->GetError();
437 pProgress->Stop();
438 if ( pPrinter->IsJobActive() )
440 pProgress->DeleteOnEndPrint();
441 pPrinter->EndJob();
442 return pPrinter->GetError();
444 else
446 // the next call might destroy pPrinter (in case it is not the usual document printer); so get the error before
447 ULONG nError = pPrinter->GetError();
448 pProgress->DeleteOnEndPrint();
449 return nError;
455 /*--------------------------------------------------------------------
456 Beschreibung: TabPage fuer applikationsspezifische Druckoptionen
457 --------------------------------------------------------------------*/
459 SfxTabPage* __EXPORT SwView::CreatePrintOptionsPage(Window* pParent,
460 const SfxItemSet& rSet)
462 return ::CreatePrintOptionsPage( pParent, rSet, FALSE );
465 /*--------------------------------------------------------------------
466 Beschreibung: Druckerdialog
467 --------------------------------------------------------------------*/
469 PrintDialog* CreatePrintDialog( Window* pParent, USHORT nPg, SwWrtShell* pSh )
471 PrintDialog *pDlg = new PrintDialog( pParent, false );
472 // pDlg->ChangeFirstPage( 1 );
474 if ( !nPg )
475 nPg = 1;
476 // pDlg->ChangeLastPage( nPg );
477 // pDlg->ChangeMaxPage( 9999 );
478 pDlg->EnableRange( PRINTDIALOG_FROMTO );
480 if (pSh && (pSh->IsSelection() || pSh->IsFrmSelected() || pSh->IsObjSelected()))
481 pDlg->EnableRange( PRINTDIALOG_SELECTION );
483 pDlg->SetRangeText( String::CreateFromInt32(nPg) );
484 pDlg->EnableRange( PRINTDIALOG_RANGE );
485 pDlg->EnableCollate();
486 return pDlg;
489 /*--------------------------------------------------------------------
490 Beschreibung:
491 --------------------------------------------------------------------*/
493 PrintDialog* __EXPORT SwView::CreatePrintDialog( Window* pParent )
495 // AMA: Hier sollte vielleicht die virtuelle Seitennummer angezeigt werden,
496 // aber nur, wenn das Drucken virtuelle Seitennummern und nicht wie
497 // bisher (auch beim SWG 2.0) physikalische beachtet werden.
498 return ::CreatePrintDialog( pParent, GetWrtShell().GetPhyPageNum(), &GetWrtShell() );
501 /*--------------------------------------------------------------------
502 Beschreibung: Print-Dispatcher
503 --------------------------------------------------------------------*/
505 void __EXPORT SwView::ExecutePrint(SfxRequest& rReq)
507 BOOL bWeb = 0 != PTR_CAST(SwWebView, this);
508 ::SetAppPrintOptions( &GetWrtShell(), bWeb );
509 switch (rReq.GetSlot())
511 case FN_FAX:
513 SwPrintOptions* pPrintOptions = SW_MOD()->GetPrtOptions(bWeb);
514 String sFaxName(pPrintOptions->GetFaxName());
515 if (sFaxName.Len())
517 SfxStringItem aPrinterName(SID_PRINTER_NAME, sFaxName);
518 SfxBoolItem aSilent( SID_SILENT, TRUE );
519 GetViewFrame()->GetDispatcher()->Execute( SID_PRINTDOC,
520 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
521 &aPrinterName, &aSilent, 0L );
523 else
525 InfoBox aInfoBox(&GetEditWin(), SW_RES(MSG_ERR_NO_FAX));
526 String sMsg = aInfoBox.GetMessText();
527 USHORT nResNo = bWeb ? STR_WEBOPTIONS : STR_TEXTOPTIONS;
528 sMsg.SearchAndReplace(String::CreateFromAscii("%1"), String(SW_RES(nResNo)));
529 aInfoBox.SetMessText(sMsg);
530 aInfoBox.Execute();
531 SfxUInt16Item aDefPage(SID_SW_EDITOPTIONS, TP_OPTPRINT_PAGE);
532 GetViewFrame()->GetDispatcher()->Execute(SID_SW_EDITOPTIONS,
533 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD,
534 &aDefPage, 0L );
537 break;
538 case SID_PRINTDOC:
539 case SID_PRINTDOCDIRECT:
541 SwWrtShell* pSh = &GetWrtShell();
542 SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, FALSE);
543 BOOL bSilent = pSilentItem ? pSilentItem->GetValue() : FALSE;
544 SFX_REQUEST_ARG(rReq, pPrintFromMergeItem, SfxBoolItem, FN_QRY_MERGE, FALSE);
545 if(pPrintFromMergeItem)
546 rReq.RemoveItem(FN_QRY_MERGE);
547 BOOL bFromMerge = pPrintFromMergeItem ? pPrintFromMergeItem->GetValue() : FALSE;
548 SwMiscConfig aMiscConfig;
549 if(!bSilent && !bFromMerge &&
550 SW_MOD()->GetModuleConfig()->IsAskForMailMerge() && pSh->IsAnyDatabaseFieldInDoc())
552 QueryBox aBox( &GetEditWin(), SW_RES( MSG_PRINT_AS_MERGE ));
553 short nRet = aBox.Execute();
554 if(RET_YES == nRet)
556 SfxBoolItem aBool(FN_QRY_MERGE, TRUE);
557 GetViewFrame()->GetDispatcher()->Execute(
558 FN_QRY_MERGE, SFX_CALLMODE_ASYNCHRON, &aBool, 0L);
559 rReq.Ignore();
560 return;
563 //#i61455# if master documentes are printed silently without loaded links then update the links now
564 if( bSilent && pSh->IsGlobalDoc() && !pSh->IsGlblDocSaveLinks() )
566 pSh->GetLinkManager().UpdateAllLinks( sal_False, sal_False, sal_False, 0 );
568 SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() );
569 return;
571 default:
572 ASSERT(!this, falscher Dispatcher);
573 return;
577 /*--------------------------------------------------------------------
578 Beschreibung: Page Drucker/Zusaetze erzeugen fuer SwView und
579 SwPagePreview
580 --------------------------------------------------------------------*/
582 SfxTabPage* CreatePrintOptionsPage( Window *pParent,
583 const SfxItemSet &rOptions, BOOL bPreview )
585 SfxTabPage* pPage = NULL;
586 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
587 if ( pFact )
589 ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( TP_OPTPRINT_PAGE );
590 if ( fnCreatePage )
591 pPage = (*fnCreatePage)( pParent, rOptions );
593 SfxAllItemSet aSet(*(rOptions.GetPool()));
594 aSet.Put (SfxBoolItem(SID_PREVIEWFLAG_TYPE, bPreview));
595 aSet.Put (SfxBoolItem(SID_FAX_LIST, sal_True));
596 pPage->PageCreated(aSet);
597 return pPage;
601 void SetAppPrintOptions( ViewShell* pSh, BOOL bWeb )
603 SwPrintData aPrtData = *SW_MOD()->GetPrtOptions(bWeb);
604 const IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess();
605 SwPrintData* pShellPrintData = pIDDA->getPrintData();
607 if(pShellPrintData)
608 aPrtData = *pShellPrintData;
610 if( pIDDA->getPrinter( false ) )
612 // Applikationseigene Druckoptionen in SfxPrinter schiessen
613 SwAddPrinterItem aAddPrinterItem (FN_PARAM_ADDPRINTER, aPrtData);
614 SfxItemSet aSet( pSh->GetAttrPool(),
615 FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
616 SID_HTML_MODE, SID_HTML_MODE,
617 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
618 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
619 0 );
621 SfxMiscCfg* pMisc = SFX_APP()->GetMiscConfig();
623 if(bWeb)
624 aSet.Put(SfxUInt16Item(SID_HTML_MODE,
625 ::GetHtmlMode(((SwWrtShell*)pSh)->GetView().GetDocShell())));
626 aSet.Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN,
627 pMisc->IsNotFoundWarning() ));
628 aSet.Put(aAddPrinterItem);
629 aSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC,
630 (pMisc->IsPaperSizeWarning() ? SFX_PRINTER_CHG_SIZE : 0) |
631 (pMisc->IsPaperOrientationWarning() ? SFX_PRINTER_CHG_ORIENTATION : 0 )));
633 pIDDA->getPrinter( true )->SetOptions( aSet );