diff options
author | Mathias Bauer <mba@openoffice.org> | 2010-01-21 13:49:22 +0100 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2010-01-21 13:49:22 +0100 |
commit | 7107b53f7ede12988e0de9fe024f71b03a316f84 (patch) | |
tree | 51377dfbb8f018049ccca52eba0362051b345382 /sw/source/ui/uiview/viewprt.cxx | |
parent | efc5bc01d58786caea0cbef0bfb457c95d988bf1 (diff) | |
parent | 6adbd7aec7e0a5dc76ee62ba91ba4660c3896290 (diff) |
resync to DEV300_m70
Diffstat (limited to 'sw/source/ui/uiview/viewprt.cxx')
-rw-r--r-- | sw/source/ui/uiview/viewprt.cxx | 304 |
1 files changed, 21 insertions, 283 deletions
diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index 0a1b3c58c7..d136ab470f 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -47,9 +47,11 @@ #endif #include <sfx2/request.hxx> +#include <sfx2/progress.hxx> #include <sfx2/app.hxx> #include <svl/flagitem.hxx> #include <vcl/msgbox.hxx> +#include <vcl/oldprintadaptor.hxx> #include <svtools/printdlg.hxx> #include <sfx2/printer.hxx> #include <sfx2/prnmon.hxx> @@ -175,287 +177,6 @@ USHORT __EXPORT SwView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) } /*-------------------------------------------------------------------- - Beschreibung: - --------------------------------------------------------------------*/ - -ErrCode SwView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilent, BOOL bIsAPI ) -{ - // First test - SwWrtShell* pSh = &GetWrtShell(); - SwNewDBMgr* pMgr = pSh->GetNewDBMgr(); - - int bPrintSelection = -1; - USHORT nMergeType = pMgr->GetMergeType(); - if( DBMGR_MERGE_MAILMERGE != nMergeType && - DBMGR_MERGE_DOCUMENTS != nMergeType && - !pDlg && - !bIsAPI && ( pSh->IsSelection() || pSh->IsFrmSelected() || - pSh->IsObjSelected() ) ) - { - short nBtn = SvxPrtQryBox(&GetEditWin()).Execute(); - if( RET_CANCEL == nBtn ) - return ERRCODE_IO_ABORT; - - if( RET_OK == nBtn ) - bPrintSelection = 1; - else - bPrintSelection = 0; - } - -// Der PrintProgress stellt Handler am Printer der ViewShell ein. -// Das kann natuerlich erste nach dem evtl. Umschalten des Druckers korrekt -// funktionieren. #55210# -// SfxPrintProgress *pProgress = new SfxPrintProgress( this, !bSilent ); - SfxPrintProgress *pProgress = 0; - SfxPrinter *pDocPrinter = GetPrinter(TRUE); - if ( !pPrinter ) - pPrinter = pDocPrinter; - else if ( pDocPrinter != pPrinter ) - { - //Da der Doc-Drucker beim SetPrinter geloescht wird, - // muss man ihn vorher clonen - SfxPrinter* pClone = pDocPrinter->Clone(); - SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); - pProgress = new SfxPrintProgress( this, !bSilent ); - pProgress->RestoreOnEndPrint( pClone ); - } - if(!pProgress) - pProgress = new SfxPrintProgress( this, !bSilent ); - pProgress->SetWaitMode(FALSE); - - BOOL bStartJob = pPrinter->InitJob( &GetEditWin(), - !bIsAPI && pSh->HasDrawView() && pSh->GetDrawView()->GetModel()->HasTransparentObjects()); - if( bStartJob ) - { - // Drucker starten - PreparePrint( pDlg ); - SfxObjectShell *pObjShell = GetViewFrame()->GetObjectShell(); - //#i82625# GetTitle( 0 ) doesn't work for 'embedded' documents like forms or reports - String sDocumentTitle( pObjShell->GetTitle(SFX_TITLE_APINAME)); - SwPrtOptions aOpts( sDocumentTitle ); - BOOL bWeb = 0 != PTR_CAST(SwWebView, this); - nMergeType = pMgr->GetMergeType(); - - BOOL bPrtPros; - BOOL bPrtPros_RTL; - SwView::MakeOptions( pDlg, aOpts, &bPrtPros, &bPrtPros_RTL, bWeb, GetPrinter(), - pSh->getIDocumentDeviceAccess()->getPrintData() ); - - //set the appropriate view options to print - //on silent mode the field commands have to be switched off always - //on default print the user is asked what to do - const SwViewOption* pCurrentViewOptions = pSh->GetViewOptions(); - bool bSwitchOff_IsFldName = pCurrentViewOptions->IsFldName() && pSh->IsAnyFieldInDoc(); - - if(!bSilent && bSwitchOff_IsFldName) - { - QueryBox aBox( &GetEditWin(), SW_RES( DLG_PRT_FIELDNAME ) ); - USHORT nRet = aBox.Execute(); - if( RET_CANCEL == nRet) - { - delete pProgress; - return ERRCODE_IO_ABORT; - } - // disable field commands - if( RET_NO != nRet ) - { - bSwitchOff_IsFldName = false; - } - } - bool bApplyViewOptions = bSwitchOff_IsFldName; - //switch off display of hidden characters if on and hidden characters are in use - const sal_Bool bOldShowHiddenChar = pCurrentViewOptions->IsShowHiddenChar(); - const sal_Bool bOldMetaChars = pCurrentViewOptions->IsViewMetaChars(); - if( bOldShowHiddenChar != aOpts.IsPrintHiddenText() - && pSh->GetDoc()->ContainsHiddenChars()) - bApplyViewOptions |= true; - //switch off display of hidden paragraphs if on and hidden paragraphs are in use - const sal_Bool bOldShowHiddenPara = pCurrentViewOptions->IsShowHiddenPara(); - if( aOpts.IsPrintHiddenText() != bOldShowHiddenPara ) - { - const SwFieldType* pFldType = pSh->GetDoc()->GetSysFldType(RES_HIDDENPARAFLD); - if( pFldType && pFldType->GetDepends()) - bApplyViewOptions |= true; - } - const sal_Bool bOldShowHiddenField = pCurrentViewOptions->IsShowHiddenField(); - if( aOpts.IsPrintHiddenText() != bOldShowHiddenField ) - { - const SwFieldType* pFldType = pSh->GetDoc()->GetSysFldType(RES_HIDDENTXTFLD); - if( pFldType || pFldType->GetDepends()) - bApplyViewOptions |= true; - } - - SwViewOption* pOrgViewOption = 0; - bApplyViewOptions |= !aOpts.IsPrintTextPlaceholder(); - if(bApplyViewOptions) - { - pOrgViewOption = new SwViewOption(*pSh->GetViewOptions()); - if(bSwitchOff_IsFldName) - pOrgViewOption->SetFldName(aOpts.IsPrintHiddenText()); - - pOrgViewOption->SetShowHiddenChar(aOpts.IsPrintHiddenText()); - pOrgViewOption->SetViewMetaChars(sal_True); - pOrgViewOption->SetShowHiddenPara(aOpts.IsPrintHiddenText()); - pOrgViewOption->SetShowHiddenField(aOpts.IsPrintHiddenText()); - pOrgViewOption->SetShowPlaceHolderFields( aOpts.bPrintTextPlaceholder ); - - SW_MOD()->ApplyUsrPref(*pOrgViewOption, this, VIEWOPT_DEST_VIEW_ONLY ); - } - - if( nMergeType == DBMGR_MERGE_MAILMERGE || - DBMGR_MERGE_DOCUMENTS == nMergeType ) - { - if(DBMGR_MERGE_DOCUMENTS == nMergeType) - bStartJob = pMgr->MergePrintDocuments( *this, aOpts, *pProgress, bIsAPI ); - else - bStartJob = pMgr->MergePrint( *this, aOpts, *pProgress, bIsAPI ); - } - else - { - const BOOL bLockedView = pSh->IsViewLocked(); - pSh->LockView( TRUE ); - - //BrowseView abschalten und die View gegen alle Paints locken. - BOOL bBrowse = pSh->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE); - SfxAllItemSet aSet( SFX_APP()->GetPool() ); - SfxBoolItem aBrowse( SID_BROWSER_MODE, FALSE ); - if ( bBrowse ) - { - if ( pSh->GetWin() ) - pSh->GetWin()->Update(); - pSh->LockPaint(); - aSet.Put( aBrowse, aBrowse.Which() ); - SfxRequest aReq( SID_BROWSER_MODE, 0, aSet ); - GetDocShell()->Execute( aReq ); - } - - // die Felder aktualisieren - BOOL bIsModified = pSh->IsModified(); - pSh->StartAllAction(); - SwDocStat aDocStat; - pSh->UpdateDocStat( aDocStat ); - pSh->EndAllTblBoxEdit(); - pSh->ViewShell::UpdateFlds(TRUE); - if( pSh->IsCrsrInTbl() ) - { - pSh->ClearTblBoxCntnt(); - pSh->SaveTblBoxCntnt(); - } - pSh->EndAllAction(); - - if( !bIsModified ) - pSh->ResetModified(); - - if( -1 != bPrintSelection ) - aOpts.bPrintSelection = 0 != bPrintSelection; - - uno::Sequence< beans::PropertyValue> aViewProperties(18); - beans::PropertyValue* pViewProperties = aViewProperties.getArray(); - pViewProperties[1].Name = C2U("PrintGraphics"); - pViewProperties[1].Value <<= (sal_Bool)aOpts.IsPrintGraphic(); - pViewProperties[2].Name = C2U("PrintTables"); - pViewProperties[2].Value <<= (sal_Bool)aOpts.IsPrintTable(); - pViewProperties[3].Name = C2U("PrintDrawings"); - pViewProperties[3].Value <<= (sal_Bool)aOpts.IsPrintDraw(); - pViewProperties[4].Name = C2U("PrintLeftPages"); - pViewProperties[4].Value <<= (sal_Bool)aOpts.IsPrintLeftPage(); - pViewProperties[5].Name = C2U("PrintRightPages"); - pViewProperties[5].Value <<= (sal_Bool)aOpts.IsPrintRightPage(); - pViewProperties[6].Name = C2U("PrintControls"); - pViewProperties[6].Value <<= (sal_Bool)aOpts.IsPrintControl(); - pViewProperties[7].Name = C2U("PrintReversed"); - pViewProperties[7].Value <<= (sal_Bool)aOpts.IsPrintReverse(); - pViewProperties[8].Name = C2U("PrintPaperFromSetup"); - pViewProperties[8].Value <<= (sal_Bool)aOpts.IsPaperFromSetup(); - pViewProperties[9].Name = C2U("PrintFaxName"); - pViewProperties[9].Value <<= aOpts.GetFaxName(); - pViewProperties[10].Name = C2U("PrintAnnotationMode"); - pViewProperties[10].Value <<= (text::NotePrintMode) aOpts.GetPrintPostIts(); - pViewProperties[11].Name = C2U("PrintProspect"); - pViewProperties[11].Value <<= (sal_Bool)aOpts.IsPrintProspect(); - pViewProperties[12].Name = C2U("PrintPageBackground"); - pViewProperties[12].Value <<= (sal_Bool)aOpts.IsPrintPageBackground(); - pViewProperties[13].Name = C2U("PrintBlackFonts"); - pViewProperties[13].Value <<= (sal_Bool)aOpts.IsPrintBlackFont(); - pViewProperties[0].Name = C2U("IsSinglePrintJob"); - pViewProperties[0].Value <<= (sal_Bool)aOpts.IsPrintSingleJobs(); - pViewProperties[14].Name = C2U("Selection"); - pViewProperties[14].Value <<= (sal_Bool)aOpts.bPrintSelection; - pViewProperties[15].Name = C2U("PrintEmptyPages"); - pViewProperties[15].Value <<= (sal_Bool)aOpts.bPrintEmptyPages; - pViewProperties[16].Name = C2U("PrintHiddenText"); - pViewProperties[16].Value <<= (sal_Bool)aOpts.bPrintHiddenText; - pViewProperties[17].Name = C2U("PrintTextPlaceholder"); - pViewProperties[17].Value <<= (sal_Bool)aOpts.bPrintTextPlaceholder; - SetAdditionalPrintOptions(aViewProperties); - - SfxViewShell::Print(*pProgress, bIsAPI ); - if ( !pProgress->IsAborted() ) - { - if( bPrtPros ) - { - bStartJob = pPrinter->StartJob( aOpts.GetJobName() ); - if( bStartJob ) - pSh->PrintProspect( aOpts, *pProgress, bPrtPros_RTL ); - } - else - bStartJob = pSh->Prt( aOpts, pProgress ); - - if ( bBrowse ) - { - aBrowse.SetValue( TRUE ); - aSet.Put( aBrowse, aBrowse.Which() ); - SfxRequest aReq( SID_BROWSER_MODE, 0, aSet ); - GetDocShell()->Execute( aReq ); - pSh->UnlockPaint(); - } - } - else - bStartJob = FALSE; - - pSh->LockView( bLockedView ); - } - if(pOrgViewOption) - { - if(bSwitchOff_IsFldName) - pOrgViewOption->SetFldName(TRUE); - pOrgViewOption->SetShowHiddenChar(bOldShowHiddenChar); - pOrgViewOption->SetViewMetaChars(bOldMetaChars); - pOrgViewOption->SetShowHiddenField(bOldShowHiddenField); - pOrgViewOption->SetShowHiddenPara(bOldShowHiddenPara); - //must to be set to sal_True anyway - pOrgViewOption->SetShowPlaceHolderFields( sal_True ); - SW_MOD()->ApplyUsrPref(*pOrgViewOption, this, VIEWOPT_DEST_VIEW_ONLY ); - delete pOrgViewOption; - } - } - - if( !bStartJob ) - { - // Printer konnte nicht gestartet werden - delete pProgress; - return pPrinter->GetError(); - } - - pProgress->Stop(); - if ( pPrinter->IsJobActive() ) - { - pProgress->DeleteOnEndPrint(); - pPrinter->EndJob(); - return pPrinter->GetError(); - } - else - { - // the next call might destroy pPrinter (in case it is not the usual document printer); so get the error before - ULONG nError = pPrinter->GetError(); - pProgress->DeleteOnEndPrint(); - return nError; - } -} - - - -/*-------------------------------------------------------------------- Beschreibung: TabPage fuer applikationsspezifische Druckoptionen --------------------------------------------------------------------*/ @@ -549,6 +270,7 @@ void __EXPORT SwView::ExecutePrint(SfxRequest& rReq) rReq.RemoveItem(FN_QRY_MERGE); BOOL bFromMerge = pPrintFromMergeItem ? pPrintFromMergeItem->GetValue() : FALSE; SwMiscConfig aMiscConfig; + bool bPrintSelection = false; if(!bSilent && !bFromMerge && SW_MOD()->GetModuleConfig()->IsAskForMailMerge() && pSh->IsAnyDatabaseFieldInDoc()) { @@ -563,12 +285,29 @@ void __EXPORT SwView::ExecutePrint(SfxRequest& rReq) return; } } + else if( rReq.GetSlot() == SID_PRINTDOCDIRECT && ! bSilent ) + { + if( /*!bIsAPI && */ + ( pSh->IsSelection() || pSh->IsFrmSelected() || pSh->IsObjSelected() ) ) + { + short nBtn = SvxPrtQryBox(&GetEditWin()).Execute(); + if( RET_CANCEL == nBtn ) + return;; + + if( RET_OK == nBtn ) + bPrintSelection = true; + } + } + //#i61455# if master documentes are printed silently without loaded links then update the links now if( bSilent && pSh->IsGlobalDoc() && !pSh->IsGlblDocSaveLinks() ) { pSh->GetLinkManager().UpdateAllLinks( sal_False, sal_False, sal_False, 0 ); } - SfxViewShell::ExecuteSlot( rReq, SfxViewShell::GetInterface() ); + SfxRequest aReq( rReq ); + SfxBoolItem aBool(SID_SELECTION, bPrintSelection); + aReq.AppendItem( aBool ); + SfxViewShell::ExecuteSlot( aReq, SfxViewShell::GetInterface() ); return; } default: @@ -637,4 +376,3 @@ void SetAppPrintOptions( ViewShell* pSh, BOOL bWeb ) } } - |