diff options
Diffstat (limited to 'sw/source/ui')
24 files changed, 978 insertions, 1264 deletions
diff --git a/sw/source/ui/app/docst.cxx b/sw/source/ui/app/docst.cxx index 953ab1b8b8f7..8d723f64f28e 100644 --- a/sw/source/ui/app/docst.cxx +++ b/sw/source/ui/app/docst.cxx @@ -42,6 +42,7 @@ #include <sfx2/request.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/newstyle.hxx> +#include <sfx2/printer.hxx> #include <svl/macitem.hxx> #include <svx/brshitem.hxx> #include <svl/stritem.hxx> diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src index c58eaa369fc0..f89046c40f74 100644 --- a/sw/source/ui/app/mn.src +++ b/sw/source/ui/app/mn.src @@ -1065,12 +1065,6 @@ Menu MN_PPREVIEW_POPUPMENU HelpID = FN_PRINT_PAGEPREVIEW ; Text [ en-US ] = "Print" ; }; - MenuItem - { - Identifier = FN_PREVIEW_PRINT_OPTIONS; - HelpID = FN_PREVIEW_PRINT_OPTIONS; - Text [ en-US ] = "Print Options"; - }; SEPARATOR ; MenuItem { diff --git a/sw/source/ui/config/optdlg.hrc b/sw/source/ui/config/optdlg.hrc index 2ada884e48c7..63ad384c7bd9 100644 --- a/sw/source/ui/config/optdlg.hrc +++ b/sw/source/ui/config/optdlg.hrc @@ -96,13 +96,13 @@ #define CB_CHAR_HIDDEN 61 // Print-Extra-Page #define CB_PGRF 61 -#define CB_PTAB 62 -#define CB_PDRAW 63 +//#define CB_PTAB 62 merged with CB_PGRF in printerpullpages +//#define CB_PDRAW 63 removed in printerpullpages #define CB_LEFTP 64 #define CB_RIGHTP 65 -#define CB_REVERSE 66 +//#define CB_REVERSE 66 removed in printerpullpages #define CB_PROSPECT 67 -#define CB_SINGLEJOBS 68 +//#define CB_SINGLEJOBS 68 removed in printerpullpages #define CB_CTRLFLD 69 #define CB_PAPERFROMSETUP 70 #define FL_1 71 diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 41ba789789ff..f509b1cdcc5c 100644..100755 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -215,60 +215,66 @@ TabPage TP_OPTPRINT_PAGE Text [ en-US ] = "Contents" ; Group = TRUE ; }; - CheckBox CB_PGRF + CheckBox CB_PGRF /*functionally merged with CB_PDRAW*/ { Pos = MAP_APPFONT ( 12 , 14 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; - Text [ en-US ] = "~Graphics" ; + Text [ en-US ] = "~Pictures and objects" ; TabStop = TRUE ; Group = TRUE ; }; +/* + removed, tables now always get printed CheckBox CB_PTAB { Pos = MAP_APPFONT ( 12 , 27 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "~Tables" ; }; +*/ +/* + functionally merged with CB_PGRF (pictures and graphics) CheckBox CB_PDRAW { Pos = MAP_APPFONT ( 12 , 40 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Dra~wings" ; }; +*/ CheckBox CB_CTRLFLD { - Pos = MAP_APPFONT ( 12 , 53 ) ; + Pos = MAP_APPFONT ( 12 , 27 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; - Text [ en-US ] = "Control~s" ; + Text [ en-US ] = "Form control~s" ; }; CheckBox CB_BACKGROUND { - Pos = MAP_APPFONT ( 12 , 66 ) ; + Pos = MAP_APPFONT ( 12 , 40 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; - Text [ en-US ] = "Ba~ckground" ; + Text [ en-US ] = "Page ba~ckground" ; }; CheckBox CB_BLACK_FONT { - Pos = MAP_APPFONT ( 12 , 79 ) ; + Pos = MAP_APPFONT ( 12 , 53 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; - Text [ en-US ] = "Print blac~k" ; + Text [ en-US ] = "Print text in blac~k" ; }; CheckBox CB_HIDDEN_TEXT { - Pos = MAP_APPFONT ( 12 , 92 ) ; + Pos = MAP_APPFONT ( 12 , 66 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Hidden te~xt" ; }; CheckBox CB_TEXT_PLACEHOLDER { - Pos = MAP_APPFONT ( 12 , 105 ) ; + Pos = MAP_APPFONT ( 12 , 79 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Text ~placeholder" ; }; FixedLine FL_SEP_PRT_LEFT { Pos = MAP_APPFONT ( 85 , 14 ) ; - Size = MAP_APPFONT ( 4 , 104 ) ; + Size = MAP_APPFONT ( 4 , 78 ) ; Vert = TRUE; }; FixedLine FL_2 @@ -292,21 +298,24 @@ TabPage TP_OPTPRINT_PAGE Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "~Right pages" ; }; +/* + removed, noe handled by the new print dialog (i.e. vcl) itself CheckBox CB_REVERSE { Pos = MAP_APPFONT ( 96 , 40 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Re~versed" ; }; +*/ CheckBox CB_PROSPECT { - Pos = MAP_APPFONT ( 96 , 53 ) ; + Pos = MAP_APPFONT ( 96 , 40 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Broch~ure" ; }; CheckBox CB_PROSPECT_RTL { - Pos = MAP_APPFONT ( 103 , 66 ) ; + Pos = MAP_APPFONT ( 103 , 53 ) ; Size = MAP_APPFONT ( 70 , 10 ) ; Text [ en-US ] = "Right to Left" ; Text [ x-comment ] = " "; @@ -340,7 +349,7 @@ TabPage TP_OPTPRINT_PAGE FixedLine FL_SEP_PRT_RIGHT { Pos = MAP_APPFONT ( 169 , 14 ) ; - Size = MAP_APPFONT ( 4 , 104 ) ; + Size = MAP_APPFONT ( 4 , 78 ) ; Vert = TRUE; }; FixedLine FL_3 @@ -352,35 +361,37 @@ TabPage TP_OPTPRINT_PAGE }; FixedLine FL_4 { - Pos = MAP_APPFONT ( 6 , 121 ) ; + Pos = MAP_APPFONT ( 6 , 95 ) ; Size = MAP_APPFONT ( 248 , 8 ) ; Group = TRUE ; Text [ en-US ] = "Other"; }; CheckBox CB_PRINTEMPTYPAGES { - Pos = MAP_APPFONT ( 12 , 132 ) ; + Pos = MAP_APPFONT ( 12 , 106 ) ; Size = MAP_APPFONT ( 200 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Print ~automatically inserted blank pages"; }; +/* CheckBox CB_SINGLEJOBS { - Pos = MAP_APPFONT ( 12 , 145 ) ; + Pos = MAP_APPFONT ( 12 , 119 ) ; Size = MAP_APPFONT ( 200 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Create s~ingle print jobs" ; }; +*/ CheckBox CB_PAPERFROMSETUP { - Pos = MAP_APPFONT ( 12 , 158 ) ; + Pos = MAP_APPFONT ( 12 , 119 ) ; Size = MAP_APPFONT ( 200 , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~Paper tray from printer settings"; }; FixedText FT_FAX { - Pos = MAP_APPFONT ( 12 , 173 ) ; + Pos = MAP_APPFONT ( 12 , 134 ) ; Size = MAP_APPFONT ( 50 , 8 ) ; Group = TRUE ; Text [ en-US ] = "~Fax"; @@ -388,7 +399,7 @@ TabPage TP_OPTPRINT_PAGE ListBox LB_FAX { Border = TRUE ; - Pos = MAP_APPFONT ( 70 , 171 ) ; + Pos = MAP_APPFONT ( 70 , 132 ) ; Size = MAP_APPFONT ( 184 , 70 ) ; TabStop = TRUE ; DropDown = TRUE ; @@ -935,3 +946,55 @@ TabPage TP_OPTSHDWCRSR }; }; + +StringArray STR_PRINTOPTUI +{ + ItemList [en-US] = + { + < "%PRODUCTNAME %s"; >; + < "Contents"; >; + < "Page ba~ckground"; >; + < "Specifies whether to include colors and objects that are inserted to the background of the page (Format - Page - Background) in the printed document."; >; + < "~Pictures and objects"; >; + < "Specifies whether the graphics and drawing or OLE objects of your text document are printed"; >; + < "Hidden te~xt"; >; + < "Enable this option to print text that is marked as hidden."; >; + < "~Text placeholder"; >; + < "Enable this option to print text placeholders. Disable this option to leave the text placeholders blank in the printout."; >; + < "Form control~s"; >; + < "Specifies whether the form control fields of the text document are printed"; >; + < "Color"; >; + < "Print text in blac~k"; >; + < "Specifies whether to always print text in black."; >; + < "Pages"; >; + < "Print ~automatically inserted blank pages"; >; + < "If this option is enabled automatically inserted blank pages are printed. This is best if you are printing double-sided. For example, in a book, a \"chapter\" paragraph style has been set to always start with an odd numbered page. If the previous chapter ends on an odd page, %PRODUCTNAME inserts an even numbered blank page. This option controls whether to print that even numbered page or not"; >; + < "~Use only paper tray from printer preferences"; >; + < "For printers with multiple trays this option specifies whether the paper tray used is specified by the system settings of the printer."; >; + < "Print"; >; + < "None (document only)"; >; + < "Comments only"; >; + < "Place at end of document"; >; + < "Place at end of page"; >; + < "Specify where to print comments (if any)."; >; + < "~Comments"; >; + < "Page sides";>; + < "All pages"; >; + < "Back sides / left pages"; >; + < "Front sides / right pages"; >; + < "Specify which pages to include in the output"; >; + < "Include"; >; + < "Broch~ure"; >; + < "Select the Brochure option to print the document in brochure format."; >; + < "Left-to-right script"; >; + < "Right-to-left script"; >; + < "Ranges and copies"; >; + < "~All pages"; >; + < "Print the whole document."; >; + < "Pa~ges"; >; + < "Print a range of pages of the document."; >; + < "~Selection"; >; + < "Print only the selected parts of the document"; >; + }; +}; + diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index b206bce741fd..84e8958fa977 100644..100755 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -350,8 +350,8 @@ SwAddPrinterTabPage::SwAddPrinterTabPage( Window* pParent, SfxTabPage( pParent, SW_RES( TP_OPTPRINT_PAGE ), rCoreSet), aFL1 (this, SW_RES(FL_1)), aGrfCB (this, SW_RES(CB_PGRF)), - aTabCB (this, SW_RES(CB_PTAB)), - aDrawCB (this, SW_RES(CB_PDRAW)), +// aTabCB (this, SW_RES(CB_PTAB)), +// aDrawCB (this, SW_RES(CB_PDRAW)), aCtrlFldCB (this, SW_RES(CB_CTRLFLD)), aBackgroundCB (this, SW_RES(CB_BACKGROUND)), aBlackFontCB (this, SW_RES(CB_BLACK_FONT)), @@ -361,7 +361,7 @@ SwAddPrinterTabPage::SwAddPrinterTabPage( Window* pParent, aFL2 (this, SW_RES(FL_2)), aLeftPageCB (this, SW_RES(CB_LEFTP)), aRightPageCB (this, SW_RES(CB_RIGHTP)), - aReverseCB (this, SW_RES(CB_REVERSE)), +// aReverseCB (this, SW_RES(CB_REVERSE)), aProspectCB (this, SW_RES(CB_PROSPECT)), aProspectCB_RTL (this, SW_RES(CB_PROSPECT_RTL)), aSeparatorRFL (this, SW_RES(FL_SEP_PRT_RIGHT)), @@ -372,7 +372,7 @@ SwAddPrinterTabPage::SwAddPrinterTabPage( Window* pParent, aFL3 (this, SW_RES(FL_3)), aFL4 (this, SW_RES(FL_4)), aPrintEmptyPagesCB(this, SW_RES(CB_PRINTEMPTYPAGES)), - aSingleJobsCB (this, SW_RES(CB_SINGLEJOBS)), +// aSingleJobsCB (this, SW_RES(CB_SINGLEJOBS)), aPaperFromSetupCB(this, SW_RES(CB_PAPERFROMSETUP)), aFaxFT (this, SW_RES(FT_FAX)), aFaxLB (this, SW_RES(LB_FAX)), @@ -386,14 +386,14 @@ SwAddPrinterTabPage::SwAddPrinterTabPage( Window* pParent, aGrfCB.SetClickHdl( aLk ); aRightPageCB.SetClickHdl( aLk ); aLeftPageCB.SetClickHdl( aLk ); - aTabCB.SetClickHdl( aLk ); - aDrawCB.SetClickHdl( aLk ); +// aTabCB.SetClickHdl( aLk ); +// aDrawCB.SetClickHdl( aLk ); aCtrlFldCB.SetClickHdl( aLk ); aBackgroundCB.SetClickHdl( aLk ); aBlackFontCB.SetClickHdl( aLk ); aPrintHiddenTextCB.SetClickHdl( aLk ); aPrintTextPlaceholderCB.SetClickHdl( aLk ); - aReverseCB.SetClickHdl( aLk ); +// aReverseCB.SetClickHdl( aLk ); aProspectCB.SetClickHdl( aLk ); aProspectCB_RTL.SetClickHdl( aLk ); aPaperFromSetupCB.SetClickHdl( aLk ); @@ -402,27 +402,40 @@ SwAddPrinterTabPage::SwAddPrinterTabPage( Window* pParent, aEndRB.SetClickHdl( aLk ); aOnlyRB.SetClickHdl( aLk ); aNoRB.SetClickHdl( aLk ); - aSingleJobsCB.SetClickHdl( aLk ); +// aSingleJobsCB.SetClickHdl( aLk ); aFaxLB.SetSelectHdl( LINK( this, SwAddPrinterTabPage, SelectHdl ) ); const SfxPoolItem* pItem; if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_HTML_MODE, FALSE, &pItem ) && ((SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON) { - aDrawCB .Hide(); +// aDrawCB .Hide(); aLeftPageCB .Hide(); aRightPageCB .Hide(); aPrintHiddenTextCB.Hide(); aPrintTextPlaceholderCB.Hide(); - Point rPt(aReverseCB .GetPosPixel()); - rPt.setX(rPt.getX() + 15); // indent - aProspectCB_RTL.SetPosPixel(rPt); - aReverseCB.SetPosPixel(aLeftPageCB .GetPosPixel()); - aProspectCB.SetPosPixel(aRightPageCB .GetPosPixel()); - aPrintHiddenTextCB.SetPosPixel(aBlackFontCB.GetPosPixel()); - aBlackFontCB.SetPosPixel(aBackgroundCB.GetPosPixel()); - aBackgroundCB.SetPosPixel(aCtrlFldCB.GetPosPixel()); - aCtrlFldCB.SetPosPixel(aDrawCB.GetPosPixel()); +// aReverseCB.SetPosPixel(aLeftPageCB.GetPosPixel()); + aProspectCB.SetPosPixel(aLeftPageCB.GetPosPixel()); + Point aPt( aRightPageCB.GetPosPixel() ); + aPt.setX(aPt.getX() + 15); // indent + aProspectCB_RTL.SetPosPixel(aPt); +// aBlackFontCB.SetPosPixel(aBackgroundCB.GetPosPixel()); +// aPrintHiddenTextCB.SetPosPixel(aBlackFontCB.GetPosPixel()); +// aBackgroundCB.SetPosPixel(aCtrlFldCB.GetPosPixel()); +// aCtrlFldCB.SetPosPixel(aDrawCB.GetPosPixel()); + + // hide aPrintEmptyPagesCB and move everything below up accordingly + long nDeltaY = aPaperFromSetupCB.GetPosPixel().getY() - aPrintEmptyPagesCB.GetPosPixel().getY(); + aPrintEmptyPagesCB.Hide(); + aPt = aPaperFromSetupCB.GetPosPixel(); + aPt.setY( aPt.getY() - nDeltaY ); + aPaperFromSetupCB.SetPosPixel( aPt ); + aPt = aFaxFT.GetPosPixel(); + aPt.setY( aPt.getY() - nDeltaY ); + aFaxFT.SetPosPixel( aPt ); + aPt = aFaxLB.GetPosPixel(); + aPt.setY( aPt.getY() - nDeltaY ); + aFaxLB.SetPosPixel( aPt ); } aProspectCB_RTL.Disable(); SvtCTLOptions aCTLOptions; @@ -465,22 +478,22 @@ BOOL SwAddPrinterTabPage::FillItemSet( SfxItemSet& rCoreSet ) { SwAddPrinterItem aAddPrinterAttr (FN_PARAM_ADDPRINTER); aAddPrinterAttr.bPrintGraphic = aGrfCB.IsChecked(); - aAddPrinterAttr.bPrintTable = aTabCB.IsChecked(); - aAddPrinterAttr.bPrintDraw = aDrawCB.IsChecked(); + aAddPrinterAttr.bPrintTable = TRUE; // always enabled since CWS printerpullgpages /*aTabCB.IsChecked();*/ + aAddPrinterAttr.bPrintDraw = aGrfCB.IsChecked(); // UI merged with aGrfCB in CWS printerpullgpages /*aDrawCB.IsChecked()*/; aAddPrinterAttr.bPrintControl = aCtrlFldCB.IsChecked(); aAddPrinterAttr.bPrintPageBackground = aBackgroundCB.IsChecked(); aAddPrinterAttr.bPrintBlackFont = aBlackFontCB.IsChecked(); aAddPrinterAttr.bPrintHiddenText = aPrintHiddenTextCB.IsChecked(); aAddPrinterAttr.bPrintTextPlaceholder = aPrintTextPlaceholderCB.IsChecked(); - aAddPrinterAttr.bPrintLeftPage = aLeftPageCB.IsChecked(); - aAddPrinterAttr.bPrintRightPage = aRightPageCB.IsChecked(); - aAddPrinterAttr.bPrintReverse = aReverseCB.IsChecked(); - aAddPrinterAttr.bPrintProspect = aProspectCB.IsChecked(); - aAddPrinterAttr.bPrintProspect_RTL = aProspectCB_RTL.IsChecked(); - aAddPrinterAttr.bPaperFromSetup = aPaperFromSetupCB.IsChecked(); - aAddPrinterAttr.bPrintEmptyPages = aPrintEmptyPagesCB.IsChecked(); - aAddPrinterAttr.bPrintSingleJobs = aSingleJobsCB.IsChecked(); + aAddPrinterAttr.bPrintLeftPages = aLeftPageCB.IsChecked(); + aAddPrinterAttr.bPrintRightPages = aRightPageCB.IsChecked(); + aAddPrinterAttr.bPrintReverse = FALSE; // handled by vcl itself since CWS printerpullpages /*aReverseCB.IsChecked()*/; + aAddPrinterAttr.bPrintProspect = aProspectCB.IsChecked(); + aAddPrinterAttr.bPrintProspectRTL = aProspectCB_RTL.IsChecked(); + aAddPrinterAttr.bPaperFromSetup = aPaperFromSetupCB.IsChecked(); + aAddPrinterAttr.bPrintEmptyPages = aPrintEmptyPagesCB.IsChecked(); + aAddPrinterAttr.bPrintSingleJobs = TRUE; // handled by vcl in new print dialog since CWS printerpullpages /*aSingleJobsCB.IsChecked()*/; if (aNoRB.IsChecked()) aAddPrinterAttr.nPrintPostIts = POSTITS_NONE; @@ -508,22 +521,22 @@ void SwAddPrinterTabPage::Reset( const SfxItemSet& ) if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_ADDPRINTER , FALSE, (const SfxPoolItem**)&pAddPrinterAttr )) { - aGrfCB.Check( pAddPrinterAttr->bPrintGraphic); - aTabCB.Check( pAddPrinterAttr->bPrintTable); - aDrawCB.Check( pAddPrinterAttr->bPrintDraw); + aGrfCB.Check( pAddPrinterAttr->bPrintGraphic || pAddPrinterAttr->bPrintDraw ); +// aTabCB.Check( pAddPrinterAttr->bPrintTable); +// aDrawCB.Check( pAddPrinterAttr->bPrintDraw); aCtrlFldCB.Check( pAddPrinterAttr->bPrintControl); aBackgroundCB.Check( pAddPrinterAttr->bPrintPageBackground); aBlackFontCB.Check( pAddPrinterAttr->bPrintBlackFont); aPrintHiddenTextCB.Check( pAddPrinterAttr->bPrintHiddenText); aPrintTextPlaceholderCB.Check(pAddPrinterAttr->bPrintTextPlaceholder); - aLeftPageCB.Check( pAddPrinterAttr->bPrintLeftPage); - aRightPageCB.Check( pAddPrinterAttr->bPrintRightPage); - aReverseCB.Check( pAddPrinterAttr->bPrintReverse); + aLeftPageCB.Check( pAddPrinterAttr->bPrintLeftPages); + aRightPageCB.Check( pAddPrinterAttr->bPrintRightPages); +// aReverseCB.Check( pAddPrinterAttr->bPrintReverse); aPaperFromSetupCB.Check(pAddPrinterAttr->bPaperFromSetup); aPrintEmptyPagesCB.Check(pAddPrinterAttr->bPrintEmptyPages); aProspectCB.Check( pAddPrinterAttr->bPrintProspect); - aProspectCB_RTL.Check( pAddPrinterAttr->bPrintProspect_RTL); - aSingleJobsCB.Check( pAddPrinterAttr->bPrintSingleJobs); + aProspectCB_RTL.Check( pAddPrinterAttr->bPrintProspectRTL); +// aSingleJobsCB.Check( pAddPrinterAttr->bPrintSingleJobs); aNoRB.Check (pAddPrinterAttr->nPrintPostIts== POSTITS_NONE ) ; aOnlyRB.Check (pAddPrinterAttr->nPrintPostIts== POSTITS_ONLY ) ; diff --git a/sw/source/ui/config/prtopt.cxx b/sw/source/ui/config/prtopt.cxx index 31f3dde739c7..68f86cae4639 100644 --- a/sw/source/ui/config/prtopt.cxx +++ b/sw/source/ui/config/prtopt.cxx @@ -69,8 +69,8 @@ Sequence<OUString> SwPrintOptions::GetPropertyNames() "Page/LeftPage", // 13 not in SW/Web "Page/RightPage", // 14 not in SW/Web "EmptyPages", // 15 not in SW/Web - "Content/PrintPlaceholders", // 16 not in Sw/Web - "Content/PrintHiddenText" // 17 + "Content/PrintPlaceholders", // 16 not in Sw/Web + "Content/PrintHiddenText" // 17 not in Sw/Web }; const int nCount = bIsWeb ? 12 : 18; Sequence<OUString> aNames(nCount); @@ -92,6 +92,8 @@ SwPrintOptions::SwPrintOptions(sal_Bool bWeb) : bPrintPageBackground = !bWeb; bPrintBlackFont = bWeb; bPrintTextPlaceholder = bPrintHiddenText = sal_False; + if (bWeb) + bPrintEmptyPages = sal_False; Sequence<OUString> aNames = GetPropertyNames(); Sequence<Any> aValues = GetProperties(aNames); @@ -119,13 +121,13 @@ SwPrintOptions::SwPrintOptions(sal_Bool bWeb) : break; case 6: bPrintReverse = *(sal_Bool*)pValues[nProp].getValue(); break; case 7: bPrintProspect = *(sal_Bool*)pValues[nProp].getValue(); break; - case 8: bPrintProspect_RTL = *(sal_Bool*)pValues[nProp].getValue(); break; + case 8: bPrintProspectRTL = *(sal_Bool*)pValues[nProp].getValue(); break; case 9: bPrintSingleJobs = *(sal_Bool*)pValues[nProp].getValue(); break; case 10: pValues[nProp] >>= sFaxName; break; case 11: bPaperFromSetup = *(sal_Bool*)pValues[nProp].getValue(); break; case 12: bPrintDraw = *(sal_Bool*)pValues[nProp].getValue() ; break; - case 13: bPrintLeftPage = *(sal_Bool*)pValues[nProp].getValue(); break; - case 14: bPrintRightPage = *(sal_Bool*)pValues[nProp].getValue(); break; + case 13: bPrintLeftPages = *(sal_Bool*)pValues[nProp].getValue(); break; + case 14: bPrintRightPages = *(sal_Bool*)pValues[nProp].getValue(); break; case 15: bPrintEmptyPages = *(sal_Bool*)pValues[nProp].getValue(); break; case 16: bPrintTextPlaceholder = *(sal_Bool*)pValues[nProp].getValue(); break; case 17: bPrintHiddenText = *(sal_Bool*)pValues[nProp].getValue(); break; @@ -133,6 +135,12 @@ SwPrintOptions::SwPrintOptions(sal_Bool bWeb) : } } } + + // currently there is just one checkbox for print drawings and print graphics + // In the UI. (File/Print dialog and Tools/Options/.../Print) + // And since print graphics is the only available in Writer and WrtierWeb ... + + bPrintDraw = bPrintGraphic; } /* -----------------------------06.09.00 16:50-------------------------------- @@ -167,18 +175,24 @@ void SwPrintOptions::Commit() case 5: pValues[nProp] <<= (sal_Int32)nPrintPostIts ; break; case 6: bVal = bPrintReverse ; pValues[nProp].setValue(&bVal, rType); break; case 7: bVal = bPrintProspect ; pValues[nProp].setValue(&bVal, rType); break; - case 8: bVal = bPrintProspect_RTL ; pValues[nProp].setValue(&bVal, rType); break; + case 8: bVal = bPrintProspectRTL ; pValues[nProp].setValue(&bVal, rType); break; case 9: bVal = bPrintSingleJobs ; pValues[nProp].setValue(&bVal, rType); break; case 10: pValues[nProp] <<= sFaxName; break; case 11: bVal = bPaperFromSetup ; pValues[nProp].setValue(&bVal, rType); break; case 12: bVal = bPrintDraw ; pValues[nProp].setValue(&bVal, rType); break; - case 13: bVal = bPrintLeftPage ; pValues[nProp].setValue(&bVal, rType); break; - case 14: bVal = bPrintRightPage ; pValues[nProp].setValue(&bVal, rType); break; + case 13: bVal = bPrintLeftPages ; pValues[nProp].setValue(&bVal, rType); break; + case 14: bVal = bPrintRightPages ; pValues[nProp].setValue(&bVal, rType); break; case 15: bVal = bPrintEmptyPages ; pValues[nProp].setValue(&bVal, rType); break; case 16: bVal = bPrintTextPlaceholder; pValues[nProp].setValue(&bVal, rType); break; case 17: bVal = bPrintHiddenText; pValues[nProp].setValue(&bVal, rType); break; } } + + // currently there is just one checkbox for print drawings and print graphics + // In the UI. (File/Print dialog and Tools/Options/.../Print) + // And since print graphics is the only available in Writer and WrtierWeb ... + bPrintDraw = bPrintGraphic; + PutProperties(aNames, aValues); } diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 329316dcb21a..07ba1564c5ef 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -73,7 +73,7 @@ #include <svl/zformat.hxx> #include <svl/stritem.hxx> #include <svl/eitem.hxx> -#include <sfx2/printer.hxx> +#include <vcl/oldprintadaptor.hxx> #include <sfx2/docfile.hxx> #include <sfx2/progress.hxx> #include <sfx2/dispatch.hxx> @@ -454,80 +454,7 @@ BOOL SwNewDBMgr::MergeNew(const SwMergeDescriptor& rMergeDesc ) bRet = Merge(&rMergeDesc.rSh); // Mischen break; - case DBMGR_MERGE_MAILMERGE: // Serienbrief - { - SwView& rView = rMergeDesc.rSh.GetView(); - SfxDispatcher *pDis = rView.GetViewFrame()->GetDispatcher(); - SfxItemSet aPrintArgs( rView.GetPool(), - SID_SILENT, SID_SILENT, //5528 - SID_ASYNCHRON, SID_ASYNCHRON, //5811 - SID_PRINT_FIRST_PAGE, SID_PRINT_FIRST_PAGE, // 5001 - SID_PRINT_LAST_PAGE, SID_PRINT_LAST_PAGE, // 5002 - SID_PRINT_COPIES, SID_PRINT_COPIES, // 5003 - SID_PRINTER_NAME, SID_PRINTER_NAME, //5322 - SID_SELECTION, SID_SELECTION, //5346 - SID_FILE_NAME, SID_FILE_NAME, // 5507 - SID_PRINT_PAGES, SID_PRINT_PAGES, //6589 - SID_PRINT_COLLATE, SID_PRINT_COLLATE, //6590 - FN_QRY_MERGE, FN_QRY_MERGE, - 0 ); - aPrintArgs.Put(SfxBoolItem(FN_QRY_MERGE, TRUE) ); - - // !! Currently (Jan-2003) silent is defined by supplying *any* - // !! item!! (Thus according to OS it would be silent even when - // !! other items then SID_SILENT would be supplied!) - // !! Therefore it has to be the 0 pointer when not silent. - if(IsMergeSilent()) - { - aPrintArgs.Put( SfxBoolItem(SID_SILENT, TRUE) ); - // #i25686# printing should be done asynchronously to prevent dangling offices - // when mail merge is called as command line macro - // #i52629# aynchronous printing should only be done in silent mode - otherwise - // the printer dialog does not come up - aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, rMergeDesc.bPrintAsync )); - } - // convert PropertyValues - const beans::PropertyValue* pPrintOptions = rMergeDesc.aPrintOptions.getConstArray(); - for( sal_Int32 nOption = 0; nOption < rMergeDesc.aPrintOptions.getLength(); ++nOption) - { - if( pPrintOptions[nOption].Name.equalsAscii( "CopyCount" )) - { - sal_Int16 nCopies = 0; - if((pPrintOptions[nOption].Value >>= nCopies) && nCopies > 0) - aPrintArgs.Put( SfxInt16Item( SID_PRINT_COPIES, nCopies )); - } - else if( pPrintOptions[nOption].Name.equalsAscii( "FileName" )) - { - ::rtl::OUString sFileName; - if( (pPrintOptions[nOption].Value >>= sFileName) && sFileName.getLength() > 0) - aPrintArgs.Put( SfxStringItem( SID_FILE_NAME, sFileName )); - } - else if( pPrintOptions[nOption].Name.equalsAscii( "Collate" )) - { - sal_Bool bCollate = sal_False; - if( pPrintOptions[nOption].Value >>= bCollate ) - aPrintArgs.Put( SfxBoolItem( SID_PRINT_COLLATE, bCollate )); - } - else if( pPrintOptions[nOption].Name.equalsAscii( "Pages" )) - { - ::rtl::OUString sPages; - if( (pPrintOptions[nOption].Value >>= sPages) && sPages.getLength() ) - aPrintArgs.Put( SfxStringItem( SID_PRINT_PAGES, sPages )); - } - else if( pPrintOptions[nOption].Name.equalsAscii( "Wait" )) - { - sal_Bool bWait = sal_False; - if( pPrintOptions[nOption].Value >>= bWait ) - aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, !bWait )); - } - - } - pDis->Execute( SID_PRINTDOC, - SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, - aPrintArgs ); - } - break; - + case DBMGR_MERGE_MAILMERGE: // printing merge from 'old' merge dialog or from UNO-component case DBMGR_MERGE_MAILING: case DBMGR_MERGE_MAILFILES: case DBMGR_MERGE_SINGLE_FILE: @@ -853,323 +780,6 @@ SwNewDBMgr::~SwNewDBMgr() } delete pImpl; } -/*-------------------------------------------------------------------- - Beschreibung: Serienbrief drucken - --------------------------------------------------------------------*/ - - -BOOL SwNewDBMgr::MergePrint( SwView& rView, - SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ) -{ - SwWrtShell* pSh = &rView.GetWrtShell(); - //check if the doc is synchronized and contains at least one linked section - BOOL bSynchronizedDoc = pSh->IsLabelDoc() && pSh->GetSectionFmtCount() > 1; - //merge source is already open - rOpt.nMergeCnt = 0; - //#i56195# no field update while printing mail merge documents - rOpt.bUpdateFieldsInPrinting = sal_False; - if(pImpl->pMergeData) - { - if(pImpl->pMergeData->aSelection.getLength()) - rOpt.nMergeCnt = pImpl->pMergeData->aSelection.getLength(); - else if(pImpl->pMergeData->xResultSet.is()) - { - sal_Int32 nCount; - if( lcl_getCountFromResultSet( nCount, pImpl->pMergeData->xResultSet ) ) - rOpt.nMergeCnt = (ULONG)nCount; - } - } - - SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); - pModOpt->SetSinglePrintJob(rOpt.IsPrintSingleJobs()); - - SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); - Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); - if( rOpt.IsPrintSingleJobs() ) - pPrt->SetEndPrintHdl( Link() ); - - BOOL bUserBreak = FALSE, - bRet = FALSE; - long nStartRow, nEndRow; - //calculate number of data sets to be printed - - Sequence<PropertyValue> aViewProperties(16); - PropertyValue* pViewProperties = aViewProperties.getArray(); - pViewProperties[0].Name = C2U("MailMergeCount"); - pViewProperties[0].Value <<= (sal_Int32)rOpt.nMergeCnt; - pViewProperties[1].Name = C2U("PrintGraphics"); - pViewProperties[1].Value <<= (sal_Bool)rOpt.IsPrintGraphic(); - pViewProperties[2].Name = C2U("PrintTables"); - pViewProperties[2].Value <<= (sal_Bool)rOpt.IsPrintTable(); - pViewProperties[3].Name = C2U("PrintDrawings"); - pViewProperties[3].Value <<= (sal_Bool)rOpt.IsPrintDraw(); - pViewProperties[4].Name = C2U("PrintLeftPages"); - pViewProperties[4].Value <<= (sal_Bool)rOpt.IsPrintLeftPage(); - pViewProperties[5].Name = C2U("PrintRightPages"); - pViewProperties[5].Value <<= (sal_Bool)rOpt.IsPrintRightPage(); - pViewProperties[6].Name = C2U("PrintControls"); - pViewProperties[6].Value <<= (sal_Bool)rOpt.IsPrintControl(); - pViewProperties[7].Name = C2U("PrintReversed"); - pViewProperties[7].Value <<= (sal_Bool)rOpt.IsPrintReverse(); - pViewProperties[8].Name = C2U("PrintPaperFromSetup"); - pViewProperties[8].Value <<= (sal_Bool)rOpt.IsPaperFromSetup(); - pViewProperties[9].Name = C2U("PrintFaxName"); - pViewProperties[9].Value <<= rOpt.GetFaxName(); - pViewProperties[10].Name = C2U("PrintAnnotationMode"); - pViewProperties[10].Value <<= (text::NotePrintMode) rOpt.GetPrintPostIts(); - pViewProperties[11].Name = C2U("PrintProspect"); - pViewProperties[11].Value <<= (sal_Bool)rOpt.IsPrintProspect(); - pViewProperties[12].Name = C2U("PrintPageBackground"); - pViewProperties[12].Value <<= (sal_Bool)rOpt.IsPrintPageBackground(); - pViewProperties[13].Name = C2U("PrintBlackFonts"); - pViewProperties[13].Value <<= (sal_Bool)rOpt.IsPrintBlackFont(); - pViewProperties[14].Name = C2U("IsSinglePrintJob"); - pViewProperties[14].Value <<= (sal_Bool)rOpt.IsPrintSingleJobs(); - pViewProperties[15].Name = C2U("PrintEmptyPages"); - pViewProperties[15].Value <<= (sal_Bool)rOpt.IsPrintEmptyPages(); - - rView.SetAdditionalPrintOptions(aViewProperties); - do { - nStartRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0; - { - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), pSh->GetView().GetViewFrame()->GetObjectShell())); - pSh->ViewShell::UpdateFlds(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), pSh->GetView().GetViewFrame()->GetObjectShell())); - ++rOpt.nMergeAct; - - // launch MailMergeEvent if required - const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc(); - if (pEvtSrc) - { - uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc ); - text::MailMergeEvent aEvt( xRef, rView.GetDocShell()->GetModel() ); - pEvtSrc->LaunchMailMergeEvent( aEvt ); - } - - rView.SfxViewShell::Print( rProgress, bIsAPI ); // ggf Basic-Macro ausfuehren - if( rOpt.IsPrintSingleJobs() && bRet ) - { - //rOpt.bJobStartet = FALSE; - bRet = FALSE; - } - - bMergeLock = TRUE; - if(rOpt.IsPrintProspect()) - { - if( ! pPrt->IsJobActive() ) - { - pPrt->SetJobValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ), - String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); - pPrt->StartJob( rOpt.GetJobName() ); - } - if( pPrt->IsJobActive() ) - { - pSh->PrintProspect( rOpt, rProgress, rOpt.IsPrintProspect_RTL() ); - bRet = TRUE; - } - } - else if( pSh->Prt( rOpt, &rProgress ) ) - bRet = TRUE; - bMergeLock = FALSE; - - if( !pPrt->IsJobActive() ) - { - bUserBreak = TRUE; - bRet = FALSE; - break; - } - if( !rOpt.IsPrintSingleJobs() ) - { - String& rJNm = (String&)rOpt.GetJobName(); - rJNm.Erase(); - } - } - nEndRow = pImpl->pMergeData ? pImpl->pMergeData->xResultSet->getRow() : 0; - } while( bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()); - - if( rOpt.IsPrintSingleJobs() ) - { - SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true ); - pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk ); - if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet? - aSfxSaveLnk.Call( pTmpPrinter ); - } - - rOpt.nMergeCnt = 0; - rOpt.nMergeAct = 0; - - nMergeType = DBMGR_INSERT; - - SwDocShell* pDocSh = rView.GetDocShell(); - SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(pDocSh); - - while (pTmpFrm) // Alle Views Invalidieren - { - SwView *pVw = PTR_CAST(SwView, pTmpFrm->GetViewShell()); - if (pVw) - pVw->GetEditWin().Invalidate(); - pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, pDocSh); - } - - return bRet; -} -/*-- 21.06.2004 09:08:16--------------------------------------------------- - - -----------------------------------------------------------------------*/ -BOOL SwNewDBMgr::MergePrintDocuments( SwView& rView, - SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ) -{ - SwWrtShell* pSh = &rView.GetWrtShell(); - //check if the doc is synchronized and contains at least one linked section - //merge source is already open - rOpt.nMergeCnt = 0; - rOpt.SetPrintSingleJobs( sal_True ); - - SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false ); - Link aSfxSaveLnk = pPrt->GetEndPrintHdl(); - if( rOpt.IsPrintSingleJobs() ) - pPrt->SetEndPrintHdl( Link() ); - - BOOL bUserBreak = FALSE, - bRet = FALSE; - //calculate number of data sets to be printed - - Sequence<PropertyValue> aViewProperties(16); - PropertyValue* pViewProperties = aViewProperties.getArray(); - pViewProperties[0].Name = C2U("MailMergeCount"); - pViewProperties[0].Value <<= (sal_Int32)rOpt.nMergeCnt; - pViewProperties[1].Name = C2U("PrintGraphics"); - pViewProperties[1].Value <<= (sal_Bool)rOpt.IsPrintGraphic(); - pViewProperties[2].Name = C2U("PrintTables"); - pViewProperties[2].Value <<= (sal_Bool)rOpt.IsPrintTable(); - pViewProperties[3].Name = C2U("PrintDrawings"); - pViewProperties[3].Value <<= (sal_Bool)rOpt.IsPrintDraw(); - pViewProperties[4].Name = C2U("PrintLeftPages"); - pViewProperties[4].Value <<= (sal_Bool)rOpt.IsPrintLeftPage(); - pViewProperties[5].Name = C2U("PrintRightPages"); - pViewProperties[5].Value <<= (sal_Bool)rOpt.IsPrintRightPage(); - pViewProperties[6].Name = C2U("PrintControls"); - pViewProperties[6].Value <<= (sal_Bool)rOpt.IsPrintControl(); - pViewProperties[7].Name = C2U("PrintReversed"); - pViewProperties[7].Value <<= (sal_Bool)rOpt.IsPrintReverse(); - pViewProperties[8].Name = C2U("PrintPaperFromSetup"); - pViewProperties[8].Value <<= (sal_Bool)rOpt.IsPaperFromSetup(); - pViewProperties[9].Name = C2U("PrintFaxName"); - pViewProperties[9].Value <<= rOpt.GetFaxName(); - pViewProperties[10].Name = C2U("PrintAnnotationMode"); - pViewProperties[10].Value <<= (text::NotePrintMode) rOpt.GetPrintPostIts(); - pViewProperties[11].Name = C2U("PrintProspect"); - pViewProperties[11].Value <<= (sal_Bool)rOpt.IsPrintProspect(); - pViewProperties[12].Name = C2U("PrintPageBackground"); - pViewProperties[12].Value <<= (sal_Bool)rOpt.IsPrintPageBackground(); - pViewProperties[13].Name = C2U("PrintBlackFonts"); - pViewProperties[13].Value <<= (sal_Bool)rOpt.IsPrintBlackFont(); - pViewProperties[14].Name = C2U("IsSinglePrintJob"); - pViewProperties[14].Value <<= (sal_Bool)rOpt.IsPrintSingleJobs(); - pViewProperties[15].Name = C2U("PrintEmptyPages"); - pViewProperties[15].Value <<= (sal_Bool)rOpt.IsPrintEmptyPages(); - - rView.SetAdditionalPrintOptions(aViewProperties); - - SwMailMergeConfigItem* pConfigItem = rView.GetMailMergeConfigItem(); - DBG_ASSERT(pConfigItem, "mail merge config item is missing"); - if(!pConfigItem) - return sal_False; - - USHORT nDocStart = pConfigItem->GetPrintRangeStart(); - USHORT nDocEnd = pConfigItem->GetPrintRangeEnd(); - DBG_ASSERT(nDocStart < nDocEnd && nDocEnd <= pConfigItem->GetMergedDocumentCount(), - "merge print settings are not correct"); - - for( sal_uInt32 nPrintDocument = nDocStart; nPrintDocument < nDocEnd; ++nPrintDocument) - { - SwDocMergeInfo& rDocInfo = pConfigItem->GetDocumentMergeInfo(nPrintDocument); - rOpt.aMulti.SelectAll(FALSE); - rOpt.aMulti.Select(Range( rDocInfo.nStartPageInTarget, rDocInfo.nEndPageInTarget ), TRUE ); - - ++rOpt.nMergeAct; - - // launch MailMergeEvent if required - const SwXMailMerge *pEvtSrc = GetMailMergeEvtSrc(); - if (pEvtSrc) - { - uno::Reference< XInterface > xRef( (XMailMergeBroadcaster *) pEvtSrc ); - text::MailMergeEvent aEvt( xRef, rView.GetDocShell()->GetModel() ); - pEvtSrc->LaunchMailMergeEvent( aEvt ); - } - - String aTmp; - aTmp += String::CreateFromInt32( rDocInfo.nStartPageInTarget ); - aTmp += '-'; - aTmp += String::CreateFromInt32( rDocInfo.nEndPageInTarget ); - - Sequence<PropertyValue> aAddViewProperties(1); - PropertyValue* pAddViewProperties = aAddViewProperties.getArray(); - pAddViewProperties[0].Name = C2U("Pages"); - pAddViewProperties[0].Value <<= ::rtl::OUString( aTmp ); - rView.SetAdditionalPrintOptions(aAddViewProperties); - - rView.SfxViewShell::Print( rProgress, bIsAPI ); // ggf Basic-Macro ausfuehren - if( rOpt.IsPrintSingleJobs() && bRet ) - { - //rOpt.bJobStartet = FALSE; - bRet = FALSE; - } - - bMergeLock = TRUE; - if(rOpt.IsPrintProspect()) - { - if( pPrt->IsJobActive() || pPrt->StartJob( rOpt.GetJobName() )) - { - pSh->PrintProspect( rOpt, rProgress, rOpt.IsPrintProspect_RTL() ); - bRet = TRUE; - } - } - else if( pSh->Prt( rOpt, &rProgress ) ) - bRet = TRUE; - bMergeLock = FALSE; - - if( !pPrt->IsJobActive() ) - { - bUserBreak = TRUE; - bRet = FALSE; - break; - } - if( !rOpt.IsPrintSingleJobs() ) - { - String& rJNm = (String&)rOpt.GetJobName(); - rJNm.Erase(); - } - } - - if( rOpt.IsPrintSingleJobs() ) - { - SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true ); - pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk ); - if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet? - aSfxSaveLnk.Call( pTmpPrinter ); - } - - rOpt.nMergeCnt = 0; - rOpt.nMergeAct = 0; - - nMergeType = DBMGR_INSERT; - - SwDocShell* pDocSh = rView.GetDocShell(); - SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(pDocSh); - - while (pTmpFrm) // Alle Views Invalidieren - { - SwView *pVw = PTR_CAST(SwView, pTmpFrm->GetViewShell()); - if (pVw) - pVw->GetEditWin().Invalidate(); - pTmpFrm = pTmpFrm->GetNext(*pTmpFrm, pDocSh); - } - - return bRet; -} - - /*-------------------------------------------------------------------- Beschreibung: Serienbriefe als einzelne Dokumente speichern @@ -1317,6 +927,7 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, // in case of creating a single resulting file this has to be created here SwWrtShell* pTargetShell = 0; SfxObjectShellRef xTargetDocShell; + SwView* pTargetView = 0; std::auto_ptr< utl::TempFile > aTempFile; String sModifiedStartingPageDesc; String sStartingPageDesc; @@ -1329,7 +940,7 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, xTargetDocShell->DoInitNew( 0 ); SfxViewFrame* pTargetFrame = SfxViewFrame::CreateViewFrame( *xTargetDocShell, 0, TRUE ); - SwView* pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() ); + pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() ); //initiate SelectShell() to create sub shells pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() ); @@ -1650,27 +1261,83 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, // save the single output document if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile) { - DBG_ASSERT( aTempFile.get(), "Temporary file not available" ); - INetURLObject aTempFileURL(bAsSingleFile ? sSubject : aTempFile->GetURL()); - SfxMedium* pDstMed = new SfxMedium( - aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ), - STREAM_STD_READWRITE, TRUE ); - pDstMed->SetFilter( pStoreToFilter ); - if(pDstMed->GetItemSet()) + if( rMergeDescriptor.nMergeType != DBMGR_MERGE_MAILMERGE ) { - if(pStoreToFilterOptions ) - pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions)); - if(rMergeDescriptor.aSaveToFilterData.getLength()) - pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData))); - } + DBG_ASSERT( aTempFile.get(), "Temporary file not available" ); + INetURLObject aTempFileURL(bAsSingleFile ? sSubject : aTempFile->GetURL()); + SfxMedium* pDstMed = new SfxMedium( + aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ), + STREAM_STD_READWRITE, TRUE ); + pDstMed->SetFilter( pStoreToFilter ); + if(pDstMed->GetItemSet()) + { + if(pStoreToFilterOptions ) + pDstMed->GetItemSet()->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, *pStoreToFilterOptions)); + if(rMergeDescriptor.aSaveToFilterData.getLength()) + pDstMed->GetItemSet()->Put(SfxUsrAnyItem(SID_FILTER_DATA, makeAny(rMergeDescriptor.aSaveToFilterData))); + } - xTargetDocShell->DoSaveAs(*pDstMed); - xTargetDocShell->DoSaveCompleted(pDstMed); - if( xTargetDocShell->GetError() ) + xTargetDocShell->DoSaveAs(*pDstMed); + xTargetDocShell->DoSaveCompleted(pDstMed); + if( xTargetDocShell->GetError() ) + { + // error message ?? + ErrorHandler::HandleError( xTargetDocShell->GetError() ); + bLoop = FALSE; + } + } + else if( pTargetView ) // must be available! { - // error message ?? - ErrorHandler::HandleError( xTargetDocShell->GetError() ); - bLoop = FALSE; + //print the target document + #if OSL_DEBUG_LEVEL > 1 + sal_Bool _bVal; + sal_Int16 _nVal; + rtl::OUString _sVal; + const beans::PropertyValue* pDbgPrintOptions = rMergeDescriptor.aPrintOptions.getConstArray(); + for( sal_Int32 nOption = 0; nOption < rMergeDescriptor.aPrintOptions.getLength(); ++nOption) + { + rtl::OUString aName( pDbgPrintOptions[nOption].Name ); + uno::Any aVal( pDbgPrintOptions[nOption].Value ); + aVal >>= _bVal; + aVal >>= _nVal; + aVal >>= _sVal; + } + #endif + // printing should be done synchronously otherwise the document + // might already become invalid during the process + uno::Sequence< beans::PropertyValue > aOptions( rMergeDescriptor.aPrintOptions ); + const sal_Int32 nOpts = aOptions.getLength(); + aOptions.realloc( nOpts + 1 ); + aOptions[ nOpts ].Name = rtl::OUString::createFromAscii( "Wait" ); + aOptions[ nOpts ].Value <<= sal_True ; +// aPrintArgs.Put(SfxBoolItem(FN_QRY_MERGE, TRUE) ); +// // #i52629# aynchronous printing should only be done in silent mode - otherwise +// // the printer dialog does not come up +// aPrintArgs.Put( SfxBoolItem( SID_ASYNCHRON, rMergeDescriptor.bPrintAsync )); + // move print options + const beans::PropertyValue* pPrintOptions = rMergeDescriptor.aPrintOptions.getConstArray(); + for( sal_Int32 nOption = 0; nOption < rMergeDescriptor.aPrintOptions.getLength(); ++nOption) + { + if( pPrintOptions[nOption].Name.equalsAscii( "CopyCount" ) + ||( pPrintOptions[nOption].Name.equalsAscii( "FileName" )) + ||( pPrintOptions[nOption].Name.equalsAscii( "Collate" )) + ||( pPrintOptions[nOption].Name.equalsAscii( "Pages" )) + ||( pPrintOptions[nOption].Name.equalsAscii( "Wait" ))) + { + aOptions.realloc( nOpts + 1 ); + aOptions[ nOpts ].Name = pPrintOptions[nOption].Name; + aOptions[ nOpts ].Value = pPrintOptions[nOption].Value ; + } + } + +// const SwModuleOptions * pModOpt = SW_MOD()->GetModuleConfig(); +// if (pModOpt->IsSinglePrintJob()) +// { +// } +// else +// { + pTargetView->ExecPrint( aOptions, IsMergeSilent(), rMergeDescriptor.bPrintAsync ); +// } } xTargetDocShell->DoClose(); } @@ -2902,6 +2569,7 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh, SwMergeDescriptor aMergeDesc( pImpl->pMergeDialog->GetMergeType(), pView->GetWrtShell(), aDescriptor ); aMergeDesc.sSaveToFilter = pImpl->pMergeDialog->GetSaveFilter(); + aMergeDesc.bCreateSingleFile= true; MergeNew(aMergeDesc); pWorkDoc->SetNewDBMgr( pWorkDBMgr ); @@ -3255,8 +2923,8 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig, pWorkDoc->EmbedAllLinks(); if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds()) rWorkShell.Undo(); - // #i69485# lock fields to prevent access to the result set while calculating layout
- rWorkShell.LockExpFlds();
+ // #i69485# lock fields to prevent access to the result set while calculating layout + rWorkShell.LockExpFlds(); // create a layout rWorkShell.CalcLayout(); rWorkShell.UnlockExpFlds(); diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index 1106a1ac62fe..331589570246 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -991,6 +991,13 @@ IMPL_LINK(SwMailMergeOutputPage, PrintHdl_Impl, PushButton*, EMPTYARG) nEnd = rConfigItem.GetMergedDocumentCount(); } rConfigItem.SetPrintRange( (USHORT)nBegin, (USHORT)nEnd ); + SwDocMergeInfo& rStartInfo = rConfigItem.GetDocumentMergeInfo(nBegin); + SwDocMergeInfo& rEndInfo = rConfigItem.GetDocumentMergeInfo(nEnd - 1); + + rtl::OUString sPages(rtl::OUString::valueOf( rStartInfo.nStartPageInTarget )); + sPages += rtl::OUString::createFromAscii( " - "); + sPages += rtl::OUString::valueOf( rEndInfo.nEndPageInTarget ); + SwWrtShell& rSh = pTargetView->GetWrtShell(); pTargetView->SetMailMergeConfigItem(&rConfigItem, 0, sal_False); if(m_pTempPrinter) @@ -1002,11 +1009,17 @@ IMPL_LINK(SwMailMergeOutputPage, PrintHdl_Impl, PushButton*, EMPTYARG) SfxObjectShell* pObjSh = pTargetView->GetViewFrame()->GetObjectShell(); SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), pObjSh)); rSh.GetNewDBMgr()->SetMergeType( DBMGR_MERGE_DOCUMENTS ); - SfxDispatcher *pDis = pTargetView->GetViewFrame()->GetDispatcher(); + //SfxDispatcher *pDis = pTargetView->GetViewFrame()->GetDispatcher(); SfxBoolItem aMergeSilent(SID_SILENT, sal_False); m_pWizard->enableButtons(WZB_CANCEL, sal_False); - pDis->Execute(SID_PRINTDOCDIRECT, - SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aMergeSilent, 0L); + + uno::Sequence < beans::PropertyValue > aProps( 2 ); + aProps[0]. Name = rtl::OUString::createFromAscii("MonitorVisible"); + aProps[0].Value <<= sal_True; + aProps[1]. Name = rtl::OUString::createFromAscii("Pages"); + aProps[1]. Value <<= sPages; + + pTargetView->ExecPrint( aProps, false, true ); SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), pObjSh)); pTargetView->SetMailMergeConfigItem(0, 0, sal_False); diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx index 537a39dad8cf..4b9fb14d0500 100644 --- a/sw/source/ui/envelp/mailmrge.cxx +++ b/sw/source/ui/envelp/mailmrge.cxx @@ -227,6 +227,7 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell, m_aDialogSize( GetSizePixel() ) { FreeResource(); + aSingleJobsCB.Show(sal_False); // not supported in since cws printerpullpages anymore //task #97066# mailing of form letters is currently not supported aMailingRB.Show(FALSE); aSubjectFT.Show(FALSE); @@ -347,7 +348,7 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell, pModOpt = SW_MOD()->GetModuleConfig(); - aSingleJobsCB.Check(pModOpt->IsSinglePrintJob()); + //aSingleJobsCB.Check(pModOpt->IsSinglePrintJob());// not supported in since cws printerpullpages anymore sal_Int16 nMailingMode(pModOpt->GetMailingFormats()); aFormatSwCB.Check((nMailingMode & TXTFORMAT_OFFICE) != 0); @@ -941,4 +942,3 @@ SwMailMergeFieldConnectionsDlg::~SwMailMergeFieldConnectionsDlg() { } - diff --git a/sw/source/ui/inc/cfgitems.hxx b/sw/source/ui/inc/cfgitems.hxx index 3adfa962b9d7..913191ea7c3b 100644 --- a/sw/source/ui/inc/cfgitems.hxx +++ b/sw/source/ui/inc/cfgitems.hxx @@ -155,15 +155,15 @@ public: BOOL IsPrintProspect() const { return bPrintProspect; } - BOOL IsPrintProspect_RTL() const { return bPrintProspect_RTL; } + BOOL IsPrintProspectRTL() const { return bPrintProspectRTL; } void SetPrintProspect(BOOL bFlag ){ bPrintProspect = bFlag; } - void SetPrintProspect_RTL(BOOL bFlag ){ bPrintProspect_RTL = bFlag; } + void SetPrintProspectRTL(BOOL bFlag ){ bPrintProspectRTL = bFlag; } BOOL IsPrintGraphic () const { return bPrintGraphic; } BOOL IsPrintTable () const { return bPrintTable; } BOOL IsPrintDraw () const { return bPrintDraw; } BOOL IsPrintControl () const { return bPrintControl; } - BOOL IsPrintLeftPage () const { return bPrintLeftPage; } - BOOL IsPrintRightPage() const { return bPrintRightPage; } + BOOL IsPrintLeftPage () const { return bPrintLeftPages; } + BOOL IsPrintRightPage() const { return bPrintRightPages; } BOOL IsPrintReverse () const { return bPrintReverse; } BOOL IsPaperFromSetup() const { return bPaperFromSetup; } BOOL IsPrintEmptyPages() const { return bPrintEmptyPages; } diff --git a/sw/source/ui/inc/optpage.hxx b/sw/source/ui/inc/optpage.hxx index 959c4dc4fdd6..52611a703447 100644 --- a/sw/source/ui/inc/optpage.hxx +++ b/sw/source/ui/inc/optpage.hxx @@ -119,8 +119,8 @@ class SwAddPrinterTabPage : public SfxTabPage { FixedLine aFL1; CheckBox aGrfCB; - CheckBox aTabCB; - CheckBox aDrawCB; +// CheckBox aTabCB; +// CheckBox aDrawCB; CheckBox aCtrlFldCB; CheckBox aBackgroundCB; CheckBox aBlackFontCB; @@ -132,7 +132,7 @@ class SwAddPrinterTabPage : public SfxTabPage FixedLine aFL2; CheckBox aLeftPageCB; CheckBox aRightPageCB; - CheckBox aReverseCB; +// CheckBox aReverseCB; CheckBox aProspectCB; CheckBox aProspectCB_RTL; @@ -145,7 +145,7 @@ class SwAddPrinterTabPage : public SfxTabPage FixedLine aFL3; FixedLine aFL4; CheckBox aPrintEmptyPagesCB; - CheckBox aSingleJobsCB; +// CheckBox aSingleJobsCB; CheckBox aPaperFromSetupCB; FixedText aFaxFT; ListBox aFaxLB; diff --git a/sw/source/ui/inc/pview.hxx b/sw/source/ui/inc/pview.hxx index bcb96a26cb3d..9fe9e61e2d6f 100644 --- a/sw/source/ui/inc/pview.hxx +++ b/sw/source/ui/inc/pview.hxx @@ -222,8 +222,6 @@ class SW_DLLPUBLIC SwPagePreView: public SfxViewShell SW_DLLPRIVATE int ChgPage( int eMvMode, int bUpdateScrollbar = TRUE ); - SW_DLLPRIVATE virtual USHORT Print( SfxProgress &rProgress, BOOL bIsAPI, - PrintDialog *pPrintDialog = 0 ); SW_DLLPRIVATE virtual SfxPrinter* GetPrinter( BOOL bCreate = FALSE ); SW_DLLPRIVATE virtual USHORT SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false ); SW_DLLPRIVATE virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent, diff --git a/sw/source/ui/inc/srcview.hxx b/sw/source/ui/inc/srcview.hxx index 996aab82b446..687015759243 100644..100755 --- a/sw/source/ui/inc/srcview.hxx +++ b/sw/source/ui/inc/srcview.hxx @@ -28,10 +28,12 @@ * ************************************************************************/ #ifndef _SRCVIEW_HXX -#define _SRCIEW_HXX +#define _SRCVIEW_HXX #include <sfx2/viewfac.hxx> #include <sfx2/viewsh.hxx> +#include <vcl/outdev.hxx> + #include "srcedtw.hxx" #include "shellid.hxx" @@ -92,11 +94,11 @@ public: void Load(SwDocShell* pDocShell); - virtual USHORT SetPrinter( SfxPrinter* pNew, - USHORT nDiff = SFX_PRINTER_ALL, bool bIsAPI=false ); - virtual ErrCode DoPrint( SfxPrinter *pPrinter, PrintDialog *pPrintDialog, BOOL bSilent, BOOL bIsAPI ); + virtual USHORT SetPrinter( SfxPrinter* pNew, USHORT nDiff = SFX_PRINTER_ALL, bool bIsAPI=false ); virtual SfxPrinter* GetPrinter( BOOL bCreate = FALSE ); + sal_Int32 PrintSource( OutputDevice *pOutDev, sal_Int32 nPage, bool bCalcNumPagesOnly ); + void SourceSaved() {bSourceSaved = TRUE;} BOOL HasSourceSaved() const {return bSourceSaved;} diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index 7ddfc2775299..b181c85fa5ae 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -88,7 +88,7 @@ class SwPrtOptions; class SwTransferable; class SwMailMergeConfigItem; class SwTxtNode; // #i23726# -struct SwPrintData; +class SwPrintData; class SwFormatClipboard; struct SwConversionArgs; class Graphic; @@ -424,8 +424,6 @@ public: virtual USHORT SetPrinter( SfxPrinter* pNew, USHORT nDiff = SFX_PRINTER_ALL, bool bIsAPI=false); - virtual ErrCode DoPrint( SfxPrinter *pPrinter, PrintDialog *pPrintDialog, - BOOL bSilent, BOOL bIsAPI ); ShellModes GetShellMode(); com::sun::star::view::XSelectionSupplier* GetUNOObject(); @@ -632,10 +630,6 @@ public: //apply Accessiblity options void ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions); - // get print options (SwPrtOptions) - static void MakeOptions( PrintDialog* pDlg, SwPrtOptions& rOpts, - BOOL* pPrtProspect, BOOL* pPrtProspect_RTL, BOOL bWeb, SfxPrinter* pPrt, SwPrintData* pData ); - SwView(SfxViewFrame* pFrame, SfxViewShell*); ~SwView(); @@ -692,3 +686,4 @@ SfxTabPage* CreatePrintOptionsPage( Window *pParent, BOOL bPreview); #endif + diff --git a/sw/source/ui/uiview/makefile.mk b/sw/source/ui/uiview/makefile.mk index 2aa5e12e2631..28ab2271a823 100644 --- a/sw/source/ui/uiview/makefile.mk +++ b/sw/source/ui/uiview/makefile.mk @@ -54,6 +54,7 @@ EXCEPTIONSFILES= \ $(SLO)$/uivwimp.obj \ $(SLO)$/view.obj \ $(SLO)$/view2.obj \ + $(SLO)$/viewprt.obj \ $(SLO)$/viewling.obj \ $(SLO)$/viewmdi.obj \ diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index d7cc7936958b..801a5fa68f6a 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -45,6 +45,7 @@ #include <svl/stritem.hxx> #include <svl/eitem.hxx> #include <sfx2/printer.hxx> +#include <sfx2/progress.hxx> #include <sfx2/app.hxx> #include <sfx2/topfrm.hxx> #include <sfx2/bindings.hxx> @@ -1520,12 +1521,6 @@ MOVEPAGE: rReq.SetSlot( FN_PRINT_PAGEPREVIEW ); return; } - case FN_PREVIEW_PRINT_OPTIONS : - { - SwPreviewPrintOptionsDialog aDlg(aViewWin, *this); - aDlg.Execute(); - } - break; case SID_PRINTDOCDIRECT: case SID_PRINTDOC: ::SetAppPrintOptions( aViewWin.GetViewShell(), FALSE ); @@ -1788,7 +1783,7 @@ void SwPagePreView::Init(const SwViewOption * pPrefs) // OD 09.01.2003 #i6467# - adjust view shell option to the same as for print SwPrtOptions aPrintOptions( GetViewFrame()->GetObjectShell()->GetTitle(0) ); - SwView::MakeOptions( 0, aPrintOptions, 0, 0, false, 0, 0 ); + aPrintOptions.MakeOptions( false ); GetViewShell()->AdjustOptionsForPagePreview( aPrintOptions ); IDocumentSettingAccess* pIDSA = pESh->getIDocumentSettingAccess(); @@ -2416,72 +2411,6 @@ void SwPagePreView::ScrollDocSzChg() // alles zum Thema Drucken -USHORT SwPagePreView::Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pDlg ) -{ - ViewShell* pSh = aViewWin.GetViewShell(); - SfxPrinter* pPrinter = GetPrinter(); - if( !pPrinter || !pPrinter->InitJob( &aViewWin, - pSh->HasDrawView() && !bIsAPI && pSh->GetDrawView()->GetModel()->HasTransparentObjects() )) - return ERRCODE_IO_ABORT; - - SwWait aWait( *GetDocShell(), TRUE ); - - USHORT nRowCol = ( aViewWin.GetRow() << 8 ) + - aViewWin.GetCol(); // Zeilen / DoppelSeiten - - { - // die Felder aktualisieren - // ACHTUNG: hochcasten auf die EditShell, um die SS zu nutzen. - // In den Methoden wird auf die akt. Shell abgefragt! - SwEditShell* pESh = (SwEditShell*)pSh; - SwDocStat aDocStat; - BOOL bIsModified = pESh->IsModified(); - - pESh->StartAllAction(); - pESh->UpdateDocStat( aDocStat ); - pSh->UpdateFlds(); - pESh->EndAllAction(); - - if( !bIsModified ) - pESh->ResetModified(); - } - - // Druckauftrag starten - SfxObjectShell *pObjShell = GetViewFrame()->GetObjectShell(); - SwPrtOptions aOpts( pObjShell->GetTitle(0) ); - - BOOL bPrtPros; - BOOL bPrtPros_RTL; - SwView::MakeOptions( pDlg, aOpts, &bPrtPros, &bPrtPros_RTL, FALSE, GetPrinter(), GetDocShell()->GetDoc()->getPrintData() ); - - if( bNormalPrint ) - { - if( bPrtPros ) - pSh->PrintProspect( aOpts, rProgress, bPrtPros_RTL ); - else - pSh->Prt( aOpts, &rProgress ); - } - else - { - const SwPagePreViewPrtData* pPPVPD = pSh->GetDoc()->GetPreViewPrtData(); - if( pPPVPD && pPPVPD->GetCol() && pPPVPD->GetRow() ) - { - // Zeilen / Seiten - nRowCol = ( pPPVPD->GetRow() << 8 ) + pPPVPD->GetCol(); - } - else - pPPVPD = 0; - pSh->PrintPreViewPage( aOpts, nRowCol, rProgress, pPPVPD ); - } - - return 0; // OK -} - -/*-------------------------------------------------------------------- - Beschreibung: - --------------------------------------------------------------------*/ - - SfxPrinter* SwPagePreView::GetPrinter( BOOL bCreate ) { return aViewWin.GetViewShell()->getIDocumentDeviceAccess()->getPrinter( bCreate ); diff --git a/sw/source/ui/uiview/pview.src b/sw/source/ui/uiview/pview.src index a213c8df80e7..ff7f834db7a6 100644 --- a/sw/source/ui/uiview/pview.src +++ b/sw/source/ui/uiview/pview.src @@ -453,11 +453,6 @@ ToolBox RID_PVIEW_TOOLBOX Identifier = FN_PRINT_PAGEPREVIEW ; HelpID = FN_PRINT_PAGEPREVIEW ; }; - ToolBoxItem - { - Identifier = FN_PREVIEW_PRINT_OPTIONS ; - HelpID = FN_PREVIEW_PRINT_OPTIONS ; - }; ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; ToolBoxItem { diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index 26a1253c5486..050f5c9d3057 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -152,23 +152,23 @@ TYPEINIT1(SwSrcView, SfxViewShell) --------------------------------------------------*/ -void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const String& rTitle ) +void lcl_PrintHeader( OutputDevice &rOutDev, USHORT nPages, USHORT nCurPage, const String& rTitle ) { short nLeftMargin = LMARGPRN; - Size aSz = pPrinter->GetOutputSize(); + Size aSz = rOutDev.GetOutputSize(); short nBorder = BORDERPRN; - Color aOldFillColor( pPrinter->GetFillColor() ); - Font aOldFont( pPrinter->GetFont() ); + Color aOldFillColor( rOutDev.GetFillColor() ); + Font aOldFont( rOutDev.GetFont() ); - pPrinter->SetFillColor( Color(COL_TRANSPARENT) ); + rOutDev.SetFillColor( Color(COL_TRANSPARENT) ); Font aFont( aOldFont ); aFont.SetWeight( WEIGHT_BOLD ); aFont.SetAlign( ALIGN_BOTTOM ); - pPrinter->SetFont( aFont ); + rOutDev.SetFont( aFont ); - long nFontHeight = pPrinter->GetTextHeight(); + long nFontHeight = rOutDev.GetTextHeight(); // 1.Border => Strich, 2+3 Border = Freiraum. long nYTop = TMARGPRN-3*nBorder-nFontHeight; @@ -176,34 +176,34 @@ void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const S long nXLeft = nLeftMargin-nBorder; long nXRight = aSz.Width()-RMARGPRN+nBorder; - pPrinter->DrawRect( Rectangle( + rOutDev.DrawRect( Rectangle( Point( nXLeft, nYTop ), Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) ); long nY = TMARGPRN-2*nBorder; Point aPos( nLeftMargin, nY ); - pPrinter->DrawText( aPos, rTitle ); + rOutDev.DrawText( aPos, rTitle ); if ( nPages != 1 ) { aFont.SetWeight( WEIGHT_NORMAL ); - pPrinter->SetFont( aFont ); + rOutDev.SetFont( aFont ); String aPageStr( C2S(" [") ); aPageStr += String( SW_RES( STR_PAGE ) ); aPageStr += ' '; aPageStr += String::CreateFromInt32( nCurPage ); aPageStr += ']'; - aPos.X() += pPrinter->GetTextWidth( rTitle ); - pPrinter->DrawText( aPos, aPageStr ); + aPos.X() += rOutDev.GetTextWidth( rTitle ); + rOutDev.DrawText( aPos, aPageStr ); } nY = TMARGPRN-nBorder; - pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) ); + rOutDev.DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) ); - pPrinter->SetFont( aOldFont ); - pPrinter->SetFillColor( aOldFillColor ); + rOutDev.SetFont( aOldFont ); + rOutDev.SetFillColor( aOldFillColor ); } /* -----------------13.11.2003 16:24----------------- @@ -734,16 +734,13 @@ USHORT SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem, return nFound; } -/*-----------------02.07.97 09:29------------------- +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ ---------------------------------------------------*/ USHORT SwSrcView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) { SwDocShell* pDocSh = GetDocShell(); - SfxPrinter* pOld = pDocSh->GetDoc()->getPrinter( false ); - if ( pOld && pOld->IsPrinting() ) - return SFX_PRINTERROR_BUSY; - if ( (SFX_PRINTER_JOBSETUP | SFX_PRINTER_PRINTER) & nDiffFlags ) { pDocSh->GetDoc()->setPrinter( pNew, true, true ); @@ -766,109 +763,88 @@ USHORT SwSrcView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) Beschreibung: --------------------------------------------------------------------*/ -ErrCode SwSrcView::DoPrint( SfxPrinter *pPrinter, PrintDialog *pDlg, BOOL bSilent, BOOL bIsAPI ) +SfxPrinter* SwSrcView::GetPrinter( BOOL bCreate ) { - SfxPrintProgress *pProgress = new SfxPrintProgress( this, !bSilent ); - SfxPrinter *pDocPrinter = GetPrinter(TRUE); - if ( !pPrinter ) - pPrinter = pDocPrinter; - else if ( pDocPrinter != pPrinter ) - { - pProgress->RestoreOnEndPrint( pDocPrinter->Clone() ); - SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); - } - pProgress->SetWaitMode(FALSE); + return GetDocShell()->GetDoc()->getPrinter( bCreate ); +} - // Drucker starten - PreparePrint( pDlg ); +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ +sal_Int32 SwSrcView::PrintSource( + OutputDevice *pOutDev, + sal_Int32 nPage, + bool bCalcNumPagesOnly ) +{ + if (!pOutDev || nPage <= 0) + return 0; - SfxViewShell::Print(*pProgress, bIsAPI, pDlg ); //??? + //! this a lgorithm for printing the n-th page is very poor since it + //! needs to go over the text of all previous pages to get to the correct one. + //! But since HTML source code is expected to be just a small number of pages + //! even this poor algorithm should be enough... - MapMode eOldMapMode( pPrinter->GetMapMode() ); - Font aOldFont( pPrinter->Printer::GetFont() ); + pOutDev->Push(); TextEngine* pTextEngine = aEditWin.GetTextEngine(); - pPrinter->SetMapMode(MAP_100TH_MM); - Font aFont(aEditWin.GetOutWin()->GetFont()); - Size aSize(aFont.GetSize()); - aSize = aEditWin.GetOutWin()->PixelToLogic(aSize, MAP_100TH_MM); - aFont.SetSize(aSize); - aFont.SetColor(COL_BLACK); - pPrinter->SetFont( aFont ); + pOutDev->SetMapMode( MAP_100TH_MM ); + Font aFont( aEditWin.GetOutWin()->GetFont() ); + Size aSize( aFont.GetSize() ); + aSize = aEditWin.GetOutWin()->PixelToLogic( aSize, MAP_100TH_MM ); + aFont.SetSize( aSize ); + aFont.SetColor( COL_BLACK ); + pOutDev->SetFont( aFont ); String aTitle( GetViewFrame()->GetWindow().GetText() ); - USHORT nLineHeight = (USHORT) pPrinter->GetTextHeight(); // etwas mehr. + USHORT nLineHeight = (USHORT) pOutDev->GetTextHeight(); // etwas mehr. USHORT nParaSpace = 10; - Size aPaperSz = pPrinter->GetOutputSize(); - aPaperSz.Width() -= (LMARGPRN+RMARGPRN); - aPaperSz.Height() -= (TMARGPRN+BMARGPRN); + Size aPaperSz = pOutDev->GetOutputSize(); + aPaperSz.Width() -= (LMARGPRN + RMARGPRN); + aPaperSz.Height() -= (TMARGPRN + BMARGPRN); // nLinepPage stimmt nicht, wenn Zeilen umgebrochen werden muessen... - USHORT nLinespPage = (USHORT) (aPaperSz.Height()/nLineHeight); - USHORT nCharspLine = (USHORT) (aPaperSz.Width() / pPrinter->GetTextWidth( 'X' )); + USHORT nLinespPage = (USHORT) (aPaperSz.Height() / nLineHeight); + USHORT nCharspLine = (USHORT) (aPaperSz.Width() / pOutDev->GetTextWidth( 'X' )); USHORT nParas = static_cast< USHORT >( pTextEngine->GetParagraphCount() ); - USHORT nPages = (USHORT) (nParas/nLinespPage+1 ); + USHORT nPages = (USHORT) (nParas / nLinespPage + 1 ); USHORT nCurPage = 1; - BOOL bStartJob = pPrinter->StartJob( aTitle ); - if( bStartJob ) + // Header drucken... + if (!bCalcNumPagesOnly && nPage == nCurPage) + lcl_PrintHeader( *pOutDev, nPages, nCurPage, aTitle ); + const Point aStartPos( LMARGPRN, TMARGPRN ); + Point aPos( aStartPos ); + for ( USHORT nPara = 0; nPara < nParas; ++nPara ) { - pPrinter->StartPage(); - // Header drucken... - lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle ); - Point aPos( LMARGPRN, TMARGPRN ); - for ( USHORT nPara = 0; nPara < nParas; nPara++ ) + String aLine( pTextEngine->GetText( nPara ) ); + lcl_ConvertTabsToSpaces( aLine ); + USHORT nLines = aLine.Len() / nCharspLine + 1; + for ( USHORT nLine = 0; nLine < nLines; ++nLine ) { - String aLine( pTextEngine->GetText( nPara ) ); - lcl_ConvertTabsToSpaces( aLine ); - USHORT nLines = aLine.Len()/nCharspLine+1; - for ( USHORT nLine = 0; nLine < nLines; nLine++ ) + String aTmpLine( aLine, nLine * nCharspLine, nCharspLine ); + aPos.Y() += nLineHeight; + if ( aPos.Y() > ( aPaperSz.Height() + TMARGPRN - nLineHeight/2 ) ) { - String aTmpLine( aLine, nLine*nCharspLine, nCharspLine ); - aPos.Y() += nLineHeight; - if ( aPos.Y() > ( aPaperSz.Height()+TMARGPRN ) ) - { - nCurPage++; - pPrinter->EndPage(); - pPrinter->StartPage(); - lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle ); - aPos = Point( LMARGPRN, TMARGPRN+nLineHeight ); - } - pPrinter->DrawText( aPos, aTmpLine ); + ++nCurPage; + if (!bCalcNumPagesOnly && nPage == nCurPage) + lcl_PrintHeader( *pOutDev, nPages, nCurPage, aTitle ); + aPos = aStartPos; } - aPos.Y() += nParaSpace; + if (!bCalcNumPagesOnly && nPage == nCurPage) + pOutDev->DrawText( aPos, aTmpLine ); } - pPrinter->EndPage(); + aPos.Y() += nParaSpace; } - pPrinter->SetFont( aOldFont ); - pPrinter->SetMapMode( eOldMapMode ); + pOutDev->Pop(); - if ( !bStartJob ) - { - // Printer konnte nicht gestartet werden - delete pProgress; - return ERRCODE_IO_ABORT; - } - - pProgress->Stop(); - pProgress->DeleteOnEndPrint(); - pPrinter->EndJob(); - return pPrinter->GetError(); + DBG_ASSERT( bCalcNumPagesOnly || nPage <= nCurPage, "page number out of range" ); + return nCurPage; } -/*-------------------------------------------------------------------- - Beschreibung: - --------------------------------------------------------------------*/ - - -SfxPrinter* SwSrcView::GetPrinter( BOOL bCreate ) -{ - return GetDocShell()->GetDoc()->getPrinter( bCreate ); -} /*-------------------------------------------------------------------- Beschreibung: diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index d823f2e6c63b..3d9062b14684 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -1920,53 +1920,6 @@ void SwView::NotifyDBChanged() Beschreibung: Drucken --------------------------------------------------------------------*/ -void SwView::MakeOptions( PrintDialog* pDlg, SwPrtOptions& rOpts, - BOOL* pPrtProspect, BOOL* pPrtProspect_RTL, BOOL bWeb, SfxPrinter* pPrt, SwPrintData* pData ) -{ - SwAddPrinterItem* pAddPrinterAttr; - if( pPrt && SFX_ITEM_SET == pPrt->GetOptions().GetItemState( - FN_PARAM_ADDPRINTER, FALSE, (const SfxPoolItem**)&pAddPrinterAttr )) - { - pData = pAddPrinterAttr; - } - else if(!pData) - { - pData = SW_MOD()->GetPrtOptions(bWeb); - } - rOpts = *pData; - if( pPrtProspect ) - *pPrtProspect = pData->bPrintProspect; - if( pPrtProspect_RTL ) - *pPrtProspect_RTL = pData->bPrintProspect_RTL; - rOpts.aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); - rOpts.aMulti.SelectAll( FALSE ); - rOpts.nCopyCount = 1; - rOpts.bCollate = FALSE; - rOpts.bPrintSelection = FALSE; - rOpts.bJobStartet = FALSE; - - if ( pDlg ) - { - rOpts.nCopyCount = pDlg->GetCopyCount(); - rOpts.bCollate = pDlg->IsCollateChecked(); - if ( pDlg->GetCheckedRange() == PRINTDIALOG_SELECTION ) - { - rOpts.aMulti.SelectAll(); - rOpts.bPrintSelection = TRUE; - } - else if ( PRINTDIALOG_ALL == pDlg->GetCheckedRange() ) - rOpts.aMulti.SelectAll(); - else - { - rOpts.aMulti = MultiSelection( pDlg->GetRangeText() ); - rOpts.aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); - } - } - else - rOpts.aMulti.SelectAll(); - rOpts.aMulti.Select( 0, FALSE ); -} - /* -----------------------------28.10.02 13:25-------------------------------- ---------------------------------------------------------------------------*/ @@ -1995,3 +1948,20 @@ void SwView::AddTransferable(SwTransferable& rTransferable) { GetViewImpl()->AddTransferable(rTransferable); } + +/* --------------------------------------------------*/ + +void SwPrtOptions::MakeOptions( BOOL bWeb ) +{ + *this = *SW_MOD()->GetPrtOptions(bWeb); + + nCopyCount = 1; + bCollate = FALSE; + bPrintSelection = FALSE; + bJobStartet = FALSE; + + aMulti.SetTotalRange( Range( 0, RANGE_MAX ) ); + aMulti.SelectAll(); + aMulti.Select( 0, FALSE ); +} + diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index c53f6efbc3fc..4d46407d3f15 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 ) } } - diff --git a/sw/source/ui/uno/unomailmerge.cxx b/sw/source/ui/uno/unomailmerge.cxx index b47f599a9120..5d0b03a4eaad 100644 --- a/sw/source/ui/uno/unomailmerge.cxx +++ b/sw/source/ui/uno/unomailmerge.cxx @@ -725,6 +725,7 @@ uno::Any SAL_CALL SwXMailMerge::execute( // when mail merge is called as command line macro aMergeDesc.bPrintAsync = sal_False; aMergeDesc.aPrintOptions = aPrintSettings; + aMergeDesc.bCreateSingleFile = true; } else /* FILE and MAIL*/ { diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index ed6d61898804..75711a414620 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -576,7 +576,7 @@ void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, break; case HANDLE_PRINTSET_PROSPECT_RTL: { - bBoolVal = mpPrtOpt->IsPrintProspect_RTL(); + bBoolVal = mpPrtOpt->IsPrintProspectRTL(); } break; case HANDLE_PRINTSET_PLACEHOLDER: diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index aa2712225703..4b519bc747fd 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -31,13 +31,17 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include <cmdid.h> -#include <swtypes.hxx> +#include <vos/mutex.hxx> #include <vcl/image.hxx> #include <vcl/virdev.hxx> #include <vcl/svapp.hxx> +#include <vcl/print.hxx> #include <sfx2/viewfrm.hxx> +#include <sfx2/sfxbasecontroller.hxx> #include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/awt/vclxdevice.hxx> +#include <cmdid.h> +#include <swtypes.hxx> #include <wdocsh.hxx> #include <wrtsh.hxx> #include <view.hxx> @@ -54,7 +58,6 @@ #include <unocoll.hxx> #include <unoredlines.hxx> #include <unosrch.hxx> -#include <toolkit/awt/vclxdevice.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/request.hxx> #include <sfx2/objsh.hxx> // SfxObjectShellRef <-> SV_DECL_REF(SfxObjectShell) @@ -68,6 +71,7 @@ #include <unofield.hxx> #include <unoidx.hxx> #include <unoflatpara.hxx> +#include <unotxvw.hxx> #include <poolfmt.hxx> #include <globdoc.hxx> #include <viewopt.hxx> @@ -75,6 +79,8 @@ #include <doc.hxx> #include <charatr.hxx> #include <svx/xmleohlp.hxx> +#include <globals.hrc> +#include <unomid.h> #include <com/sun/star/util/SearchOptions.hpp> #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> @@ -129,11 +135,14 @@ #include <svl/stylepool.hxx> #include <swatrset.hxx> +#include <view.hxx> +#include <srcview.hxx> //#include <com/sun/star/i18n/ScriptType.hpp> #include <svtools/langtab.hxx> #include <map> #include <set> +#include <vector> #include <svx/eeitem.hxx> #include <svx/editeng.hxx> @@ -170,6 +179,32 @@ using ::osl::FileBase; /****************************************************************************** * ******************************************************************************/ + +extern bool lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst ); + +SwPrintUIOptions * lcl_GetPrintUIOptions( + SwDocShell * pDocShell, + const SfxViewShell * pView ) +{ + if (!pDocShell) + return NULL; + + const BOOL bWebDoc = NULL != dynamic_cast< const SwWebDocShell * >(pDocShell); + const bool bSwSrcView = NULL != dynamic_cast< const SwSrcView * >(pView); + const SwView * pSwView = dynamic_cast< const SwView * >(pView); + const bool bHasSelection = pSwView ? pSwView->HasSelection( sal_False ) : false; // check for any selection, not just text selection + const bool bHasPostIts = lcl_GetPostIts( pDocShell->GetDoc(), 0 ); + + // get default values to use in dialog from documents SwPrintData + const SwPrintData *pPrintData = pDocShell->GetDoc()->getPrintData(); + DBG_ASSERT( pPrintData, "failed to get SwPrintData from document" ); + + return new SwPrintUIOptions( bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, *pPrintData ); +} + +//////////////////////////////////////////////////////////// + + SwTxtFmtColl *lcl_GetParaStyle(const String& rCollName, SwDoc* pDoc) { SwTxtFmtColl* pColl = pDoc->FindTxtFmtCollByName( rCollName ); @@ -364,7 +399,9 @@ SwXTextDocument::SwXTextDocument(SwDocShell* pShell) : pxXLineNumberingProperties(0), pxLinkTargetSupplier(0), pxXRedlines(0), - m_pHiddenViewFrame(0) + m_pHiddenViewFrame(0), + m_pPrintUIOptions( NULL ), + m_pRenderData( NULL ) { } /*-- 18.12.98 11:53:00--------------------------------------------------- @@ -379,6 +416,8 @@ SwXTextDocument::~SwXTextDocument() xNumFmtAgg->setDelegator(x0); xNumFmtAgg = 0; } + delete m_pPrintUIOptions; + delete m_pRenderData; } @@ -2453,100 +2492,74 @@ Any SAL_CALL SwXTextDocument::getPropertyDefault( const OUString& rPropertyName } return aAny; } -/*-- 06.01.2004 15:08:34--------------------------------------------------- - The class SwViewOptionAdjust_Impl is used to adjust the SwViewOption of - the current ViewShell so that fields are not printed as commands and - hidden text and hidden characters are always invisible. - After printing the view options are restored - -----------------------------------------------------------------------*/ -class SwViewOptionAdjust_Impl -{ - bool m_bSwitchOff_IsFldName; - bool m_bSwitchOff_PlaceHolderView; - bool m_bSwitchOff_HiddenChar; - bool m_bSwitchOff_HiddenParagraphs; - bool m_bSwitchOff_IsShowHiddenField; - - SwViewOption* m_pViewOption; - SwWrtShell& m_rShell; -public: - SwViewOptionAdjust_Impl(SwWrtShell& rSh); - ~SwViewOptionAdjust_Impl(); -}; -/*-- 06.01.2004 15:08:34--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(SwWrtShell& rSh) : - m_pViewOption(0), - m_rShell(rSh) -{ - const SwViewOption* pCurrentViewOptions = m_rShell.GetViewOptions(); - m_bSwitchOff_IsFldName = pCurrentViewOptions->IsFldName() && m_rShell.IsAnyFieldInDoc(); - bool bApplyViewOptions = m_bSwitchOff_IsFldName; - //switch off painting of placeholder fields - m_bSwitchOff_PlaceHolderView = pCurrentViewOptions->IsShowPlaceHolderFields(); - //switch off display of hidden characters if on and hidden characters are in use - m_bSwitchOff_HiddenChar = pCurrentViewOptions->IsShowHiddenChar() && m_rShell.GetDoc()->ContainsHiddenChars(); - //switch off display of hidden paragraphs if on and hidden paragraphs are in use - m_bSwitchOff_HiddenParagraphs = pCurrentViewOptions->IsShowHiddenPara(); - if(m_bSwitchOff_HiddenParagraphs) - { - const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENPARAFLD); - if(!pFldType || !pFldType->GetDepends()) - m_bSwitchOff_HiddenParagraphs = false; - } - m_bSwitchOff_IsShowHiddenField = pCurrentViewOptions->IsShowHiddenField(); - if(m_bSwitchOff_IsShowHiddenField) - { - const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType(RES_HIDDENTXTFLD); - if( !pFldType || !pFldType->GetDepends()) - m_bSwitchOff_IsShowHiddenField = false; - } - - bApplyViewOptions |= m_bSwitchOff_PlaceHolderView; - bApplyViewOptions |= m_bSwitchOff_HiddenChar; - bApplyViewOptions |= m_bSwitchOff_HiddenParagraphs; - bApplyViewOptions |= m_bSwitchOff_IsShowHiddenField; - if(bApplyViewOptions) - { - m_pViewOption = new SwViewOption(*m_rShell.GetViewOptions()); - if(m_bSwitchOff_IsFldName) - m_pViewOption->SetFldName(FALSE); - if(m_bSwitchOff_PlaceHolderView) - m_pViewOption->SetShowPlaceHolderFields(FALSE); - if(m_bSwitchOff_HiddenChar) - m_pViewOption->SetShowHiddenChar(FALSE); - if(m_bSwitchOff_HiddenParagraphs) - m_pViewOption->SetShowHiddenPara(FALSE); - if(m_bSwitchOff_IsShowHiddenField) - m_pViewOption->SetShowHiddenField(FALSE); - SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); - } -} -/*-- 06.01.2004 15:08:34--------------------------------------------------- - -----------------------------------------------------------------------*/ -SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() +static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptions ) +{ + OutputDevice *pOut = 0; + + uno::Any aAny( rPrintUIOptions.getValue( C2U( "RenderDevice" ) )); + uno::Reference< awt::XDevice > xRenderDevice; + aAny >>= xRenderDevice; + if (xRenderDevice.is()) + { + VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); + pOut = pDevice ? pDevice->GetOutputDevice() : 0; + } + + return pOut; +} + + +static bool lcl_SeqHasProperty( + const uno::Sequence< beans::PropertyValue >& rOptions, + const sal_Char *pPropName ) { - if(m_pViewOption) + bool bRes = false; + const sal_Int32 nLen = rOptions.getLength(); + const beans::PropertyValue *pProps = rOptions.getConstArray(); + for (sal_Int32 i = 0; i < nLen && !bRes; ++i) { - if(m_bSwitchOff_IsFldName) - m_pViewOption->SetFldName(TRUE); - if(m_bSwitchOff_PlaceHolderView) - m_pViewOption->SetShowPlaceHolderFields(TRUE); - if(m_bSwitchOff_HiddenChar) - m_pViewOption->SetShowHiddenChar(TRUE); - if(m_bSwitchOff_HiddenParagraphs) - m_pViewOption->SetShowHiddenPara(TRUE); - if(m_bSwitchOff_IsShowHiddenField) - m_pViewOption->SetShowHiddenField(TRUE); - SW_MOD()->ApplyUsrPref(*m_pViewOption, &m_rShell.GetView(), VIEWOPT_DEST_VIEW_ONLY ); - delete m_pViewOption; + if (pProps[i].Name.equalsAscii( pPropName )) + bRes = true; } + return bRes; } -/* -----------------------------23.08.02 16:00-------------------------------- - ---------------------------------------------------------------------------*/ + +SfxViewShell * SwXTextDocument::GetRenderView( + bool &rbIsSwSrcView, + const uno::Sequence< beans::PropertyValue >& rOptions, + bool bIsPDFExport ) +{ + // get view shell to use + SfxViewShell *pView = 0; + if (bIsPDFExport) + pView = GuessViewShell( rbIsSwSrcView ); + else + { + uno::Any aTmp; + const sal_Int32 nLen = rOptions.getLength(); + const beans::PropertyValue *pProps = rOptions.getConstArray(); + for (sal_Int32 i = 0; i < nLen; ++i) + { + if (pProps[i].Name.equalsAscii( "View" )) + { + aTmp = pProps[i].Value; + break; + } + } + + uno::Reference< frame::XController > xController; + if (aTmp >>= xController) + { + DBG_ASSERT( xController.is(), "controller is empty!" ); + pView = GuessViewShell( rbIsSwSrcView, xController ); + } + } + return pView; +} + + /* * GetRenderDoc: * returns the document to be rendered, usually this will be the 'regular' @@ -2556,7 +2569,10 @@ SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() * SfxViewShell. */ -SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rSelection ) +SwDoc * SwXTextDocument::GetRenderDoc( + SfxViewShell *&rpView, + const uno::Any& rSelection, + bool bIsPDFExport ) { SwDoc *pDoc = 0; @@ -2566,11 +2582,22 @@ SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rS pDoc = pDocShell->GetDoc(); else { - // used for PDF export of (multi-)selection + DBG_ASSERT( !xModel.is(), "unexpected model found" ); + if (rSelection.hasValue()) // is anything selected ? { + // this part should only be called when a temporary document needs to be created, + // for example for PDF export or printing of (multi-)selection only. + + bool bIsSwSrcView = false; if (!rpView) - rpView = GuessViewShell(); + { + (void) bIsPDFExport; + // aside from maybe PDF export the view should always have been provided! + DBG_ASSERT( bIsPDFExport, "view is missing, guessing one..." ); + + rpView = GuessViewShell( bIsSwSrcView ); + } DBG_ASSERT( rpView, "ViewShell missing" ); // the view shell should be SwView for documents PDF export. // for the page preview no selection should be possible @@ -2585,55 +2612,187 @@ SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rS rpView = pDoc->GetDocShell()->GetView(); } } - else { + else + { DBG_ERROR( "unexpected ViewShell" ); } } } return pDoc; } + /* -----------------------------23.08.02 16:00-------------------------------- ---------------------------------------------------------------------------*/ + +static void lcl_SavePrintUIOptionsToDocumentPrintData( + SwDoc &rDoc, + const SwPrintUIOptions &rPrintUIOptions, + bool bIsPDFEXport ) +{ + if (!rDoc.getPrintData()) + { + SwPrintData *pTmpData = new SwPrintData; + rDoc.setPrintData ( *pTmpData ); + delete pTmpData; // setPrintData does make its own copy! + } + + SwPrintData *pDocPrintData = rDoc.getPrintData(); + + pDocPrintData->SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() ); + pDocPrintData->SetPrintTable( rPrintUIOptions.IsPrintTables() ); + pDocPrintData->SetPrintDraw( rPrintUIOptions.IsPrintDrawings() ); + pDocPrintData->SetPrintControl( rPrintUIOptions.IsPrintFormControls() ); + pDocPrintData->SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() ); + pDocPrintData->SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() ); + pDocPrintData->SetPrintReverse( rPrintUIOptions.IsPrintReverse() ); + pDocPrintData->SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() ); + pDocPrintData->SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) ); + pDocPrintData->SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() ); + pDocPrintData->SetPrintProspect( rPrintUIOptions.IsPrintProspect() ); + pDocPrintData->SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() ); + pDocPrintData->SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() ); + pDocPrintData->SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() ); + // pDocPrintData->SetPrintSingleJobs( b ); handled by File/Print dialog itself + // pDocPrintData->SetFaxName( s ); n/a in File/Print dialog + pDocPrintData->SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() ); + pDocPrintData->SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() ); +} + + sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( const uno::Any& rSelection, - const uno::Sequence< beans::PropertyValue >& /*rxOptions*/ ) + const uno::Sequence< beans::PropertyValue >& rxOptions ) throw (IllegalArgumentException, RuntimeException) { ::vos::OGuard aGuard(Application::GetSolarMutex()); if(!IsValid()) throw RuntimeException(); - SfxViewShell *pView = 0; - SwDoc *pDoc = GetRenderDoc( pView, rSelection ); - if (!pDoc) - throw RuntimeException(); - SwDocShell *pRenderDocShell = pDoc->GetDocShell(); - // #i38289 - if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE)) - { - pRenderDocShell->ToggleBrowserMode(false,NULL); - } + const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ); + bool bIsSwSrcView = false; + SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport ); - SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell(); + if (!bIsSwSrcView && !m_pRenderData) + m_pRenderData = new SwRenderData; + if (!m_pPrintUIOptions) + m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView ); + bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions ); + // const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); + + SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); + DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); + if (!pDoc || !pView) + return 0; + + // save current UI options from the print dialog for the next call to that dialog + lcl_SavePrintUIOptionsToDocumentPrintData( *pDoc, *m_pPrintUIOptions, bIsPDFExport ); sal_Int32 nRet = 0; - if( !pWrtShell ) + if (bIsSwSrcView) { - //create a hidden view to be able to export as PDF also in print preview - m_pHiddenViewFrame = SfxViewFrame::CreateViewFrame( *pRenderDocShell, 2, TRUE ); - SwView* pSwView = (SwView*) m_pHiddenViewFrame->GetViewShell(); - pWrtShell = pSwView->GetWrtShellPtr(); + SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView); + OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); + nRet = pSwSrcView->PrintSource( pOutDev, 1 /* dummy */, true /* get page count only */ ); } + else + { + SwDocShell *pRenderDocShell = pDoc->GetDocShell(); + SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell(); + if (bFormat) + { + // #i38289 + if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE)) + { + pRenderDocShell->ToggleBrowserMode(false,NULL); + } + + if (!pWrtShell) + { + //create a hidden view to be able to export as PDF also in print preview + m_pHiddenViewFrame = SfxViewFrame::CreateViewFrame( *pRenderDocShell, 2, TRUE ); + SwView* pSwView = (SwView*) m_pHiddenViewFrame->GetViewShell(); + pWrtShell = pSwView->GetWrtShellPtr(); + } + + // reformating the document for printing will show the changes in the view + // which is likely to produce many unwanted and not nice to view actions. + // We don't want that! Thus we disable updating of the view. + pWrtShell->StartAction(); + + const TypeId aSwViewTypeId = TYPE(SwView); + if (pView->IsA(aSwViewTypeId)) + { + if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust()) + m_pRenderData->ViewOptionAdjustStart( *pWrtShell, *pWrtShell->GetViewOptions() ); + } - SwViewOptionAdjust_Impl aAdjust(*pWrtShell); - pWrtShell->SetPDFExportOption( sal_True ); - // --> FME 2005-05-23 #122919# Force field update before PDF export: - pWrtShell->ViewShell::UpdateFlds(TRUE); - // <-- - pWrtShell->CalcLayout(); - pWrtShell->SetPDFExportOption( sal_False ); - nRet = pDoc->GetPageCount(); + m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) ); + m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell, + m_pPrintUIOptions, m_pRenderData, bIsPDFExport ); + + if (pView->IsA(aSwViewTypeId)) + { + // PDF export should not make use of the SwPrtOptions + const SwPrtOptions *pPrtOptions = bIsPDFExport? NULL : m_pRenderData->GetSwPrtOptions(); + m_pRenderData->ViewOptionAdjust( pPrtOptions ); + } + + // since printing now also use the API for PDF export this option + // should be set for printing as well ... + pWrtShell->SetPDFExportOption( sal_True ); + + // --> FME 2005-05-23 #122919# Force field update before PDF export: + pWrtShell->ViewShell::UpdateFlds(TRUE); + // <-- + + // there is some redundancy between those two function calls, but right now + // there is no time to sort this out. + //TODO: check what exatly needs to be done and make just one function for that + pWrtShell->CalcLayout(); + pWrtShell->CalcPagesForPrint( pDoc->GetPageCount() ); + + pWrtShell->SetPDFExportOption( sal_False ); + + + // enable view again + pWrtShell->EndAction(); + } + + const sal_Int32 nPageCount = pDoc->GetPageCount(); + + // + // get number of pages to be rendered + // + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); + if (bPrintProspect) + { + pDoc->CalculatePagePairsForProspectPrinting( *m_pRenderData, *m_pPrintUIOptions, nPageCount ); + nRet = m_pRenderData->GetPagePairsForProspectPrinting().size(); + } + else + { + const sal_Int16 nPostItMode = (sal_Int16) m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", 0 ); + if (nPostItMode != POSTITS_NONE) + { + OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); + m_pRenderData->CreatePostItData( pDoc, pWrtShell->GetViewOptions(), pOutDev ); + } + + // get set of valid document pages (according to the current settings) + // and their start frames + pDoc->CalculatePagesForPrinting( *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount ); + + if (nPostItMode != POSTITS_NONE) + { + pDoc->UpdatePagesForPrintingWithPostItData( *m_pRenderData, + *m_pPrintUIOptions, bIsPDFExport, nPageCount ); + } + + nRet = m_pRenderData->GetPagesToPrint().size(); + } + } + DBG_ASSERT( nRet >= 0, "negative number of pages???" ); return nRet; } @@ -2649,41 +2808,110 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer( ::vos::OGuard aGuard(Application::GetSolarMutex()); if(!IsValid()) throw RuntimeException(); - SfxViewShell *pView = 0; - SwDoc *pDoc = GetRenderDoc( pView, rSelection ); - if (!pDoc) - throw RuntimeException(); + + const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ); + bool bIsSwSrcView = false; + SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport ); + + // m_pRenderData should NOT be created here! + // That should only be done in getRendererCount. If this function is called before + // getRendererCount was called then the caller will probably just retrieve the extra UI options + // and is not interested in getting valid information about the other data that would + // otherwise be provided here! +// if( ! m_pRenderData ) +// m_pRenderData = new SwRenderData; + if (!m_pPrintUIOptions) + m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView ); + m_pPrintUIOptions->processProperties( rxOptions ); + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); + const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); + + SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); + DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); + if (!pDoc || !pView) + return uno::Sequence< beans::PropertyValue >(); // due to #110067# (document page count changes sometimes during // PDF export/printing) we can not check for the upper bound properly. // Thus instead of throwing the exception we silently return. - if (!(0 <= nRenderer /* && nRenderer < pDoc->GetPageCount()*/)) + if (0 > nRenderer) throw IllegalArgumentException(); - if (nRenderer >= pDoc->GetPageCount()) + sal_Int32 nMaxRenderer = 0; + if (!bIsSwSrcView && m_pRenderData) + { + DBG_ASSERT( m_pRenderData, "m_pRenderData missing!!" ); + nMaxRenderer = bPrintProspect? + m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 : + m_pRenderData->GetPagesToPrint().size() - 1; + } + // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print + // we obmit checking of the upper bound in this case. + if (!bIsSwSrcView && m_pRenderData && nRenderer > nMaxRenderer) return uno::Sequence< beans::PropertyValue >(); - bool bSkipEmptyPages = false; - for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty ) + uno::Sequence< beans::PropertyValue > aRenderer; + if (m_pRenderData) { - if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages" ) ) ) - rxOptions[ nProperty].Value >>= bSkipEmptyPages; - } + awt::Size aPageSize; + Size aTmpSize; + if (bIsSwSrcView || bPrintProspect) + { + // for printing of HTML source code and prospect printing we should use + // the printers paper size since + // a) HTML source view has no page size + // b) prospect printing has a different page size from the documents page + // since two document pages will get rendered on one printer page + + // since PageIncludesNonprintableArea will be set to true we can return the + // printers paper size here. + // Sometimes 'getRenderer' is only called to get "ExtraPrintUIOptions", in this + // case we won't get an OutputDevice here, but then the caller also has no need + // for the correct PageSisze right now... + Printer *pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions )); + if (pPrinter) + { + if (bPrintProspect) + { + aTmpSize = pDoc->GetPageSize( USHORT(nRenderer + 1), bIsSkipEmptyPages ); + // we just state what output size we would need + // the rest is nowadays up to vcl + aPageSize = awt::Size ( TWIP_TO_MM100( 2 * aTmpSize.Width() ), + TWIP_TO_MM100( aTmpSize.Height() )); + } + else + { + // printing HTML source view + aTmpSize = pPrinter->GetPaperSize(); + aTmpSize = pPrinter->LogicToLogic( aTmpSize, + pPrinter->GetMapMode(), MapMode( MAP_100TH_MM )); + aPageSize = awt::Size( aTmpSize.Width(), aTmpSize.Height() ); + } + } + } + else + { + aTmpSize = pDoc->GetPageSize( USHORT(nRenderer + 1), bIsSkipEmptyPages ); + aPageSize = awt::Size ( TWIP_TO_MM100( aTmpSize.Width() ), + TWIP_TO_MM100( aTmpSize.Height() )); + } - Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bSkipEmptyPages ) ); + aRenderer.realloc(2); + aRenderer[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); + aRenderer[0].Value <<= aPageSize; + aRenderer[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageIncludesNonprintableArea" ) ); + aRenderer[1].Value <<= sal_True; + } - awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ), - TWIP_TO_MM100( aPgSize.Height() )); - uno::Sequence< beans::PropertyValue > aRenderer(1); - PropertyValue &rValue = aRenderer.getArray()[0]; - rValue.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); - rValue.Value <<= aPageSize; + m_pPrintUIOptions->appendPrintUIOptions( aRenderer ); return aRenderer; } /* -----------------------------28.10.02 16:00-------------------------------- ---------------------------------------------------------------------------*/ -SfxViewShell * SwXTextDocument::GuessViewShell() +SfxViewShell * SwXTextDocument::GuessViewShell( + /* out */ bool &rbIsSwSrcView, + const uno::Reference< css::frame::XController > xController ) { // #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell() // must not be used (see comment from MBA) @@ -2691,24 +2919,39 @@ SfxViewShell * SwXTextDocument::GuessViewShell() SfxViewShell *pView = 0; SwView *pSwView = 0; SwPagePreView *pSwPagePreView = 0; + SwSrcView *pSwSrcView = 0; SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, 0, sal_False ); + + // look for the view shell with the same controller in use, + // otherwise look for a suitable view, preferably a SwView, + // if that one is not found use a SwPagePreView if found. while (pFrame) { pView = pFrame->GetViewShell(); pSwView = dynamic_cast< SwView * >(pView); - if (pSwView) - break; + pSwSrcView = dynamic_cast< SwSrcView * >(pView); if (!pSwPagePreView) pSwPagePreView = dynamic_cast< SwPagePreView * >(pView); + if (xController.is()) + { + if (pView && pView->GetController() == xController) + break; + } + else if (pSwView || pSwSrcView) + break; pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, 0, sal_False ); } - return pSwView ? pSwView : dynamic_cast< SwView * >(pSwPagePreView); + DBG_ASSERT( pSwView || pSwPagePreView || pSwSrcView, "failed to get view shell" ); + if (pView) + rbIsSwSrcView = pSwSrcView != 0; + return pView; +// return pSwView ? dynamic_cast< SfxViewShell * >(pSwView) : +// (pSwSrcView ? dynamic_cast< SfxViewShell * >(pSwSrcView) : +// dynamic_cast< SfxViewShell * >(pSwPagePreView) ); } -/* -----------------------------23.08.02 16:00-------------------------------- - ---------------------------------------------------------------------------*/ void SAL_CALL SwXTextDocument::render( sal_Int32 nRenderer, const uno::Any& rSelection, @@ -2718,121 +2961,143 @@ void SAL_CALL SwXTextDocument::render( ::vos::OGuard aGuard(Application::GetSolarMutex()); if(!IsValid()) throw RuntimeException(); - SfxViewShell *pView = GuessViewShell(); - SwDoc *pDoc = GetRenderDoc( pView, rSelection ); - if (!pDoc || !pView) - throw RuntimeException(); // due to #110067# (document page count changes sometimes during // PDF export/printing) we can not check for the upper bound properly. // Thus instead of throwing the exception we silently return. - if (!(0 <= nRenderer /* && nRenderer < pDoc->GetPageCount()*/)) + if (0 > nRenderer) throw IllegalArgumentException(); - if (nRenderer >= pDoc->GetPageCount()) - return; - // the view shell should be SwView for documents PDF export - // or SwPagePreView for PDF export of the page preview - //!! (check for SwView first as in GuessViewShell) !! - const TypeId aSwViewTypeId = TYPE(SwView); - ViewShell* pVwSh = pView->IsA(aSwViewTypeId) ? - ((SwView*)pView)->GetWrtShellPtr() : - ((SwPagePreView*)pView)->GetViewShell(); - - uno::Reference< awt::XDevice > xRenderDevice; - bool bFirstPage = false; - bool bLastPage = false; - rtl::OUString aPages; - bool bSkipEmptyPages = false; - - for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty ) - { - if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) - rxOptions[ nProperty].Value >>= xRenderDevice; - else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFirstPage" ) ) ) - rxOptions[ nProperty].Value >>= bFirstPage; - else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsLastPage" ) ) ) - rxOptions[ nProperty].Value >>= bLastPage; - else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ) ) - rxOptions[ nProperty].Value >>= aPages; - else if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSkipEmptyPages" ) ) ) - rxOptions[ nProperty].Value >>= bSkipEmptyPages; - } - - OutputDevice* pOut = 0; - if (xRenderDevice.is()) + const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ); + bool bIsSwSrcView = false; + SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport ); + + DBG_ASSERT( m_pRenderData, "data should have been created already in getRendererCount..." ); + DBG_ASSERT( m_pPrintUIOptions, "data should have been created already in getRendererCount..." ); + if (!bIsSwSrcView && !m_pRenderData) + m_pRenderData = new SwRenderData; + if (!m_pPrintUIOptions) + m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView ); + m_pPrintUIOptions->processProperties( rxOptions ); + const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); + const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False ); + + SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport ); + DBG_ASSERT( pDoc && pView, "doc or view shell missing!" ); + if (pDoc && pView) { - VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); - pOut = pDevice ? pDevice->GetOutputDevice() : 0; - } - - if(pVwSh && pOut) - { - SwPrtOptions aOptions( C2U("PDF export") ); - - const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell); - BOOL bWeb = pDocShell->IsA( aSwWebDocShellTypeId ); - SwView::MakeOptions( NULL, aOptions, NULL, NULL, bWeb, NULL, NULL ); - - Range aPageRange( nRenderer+1, nRenderer+1 ); - MultiSelection aPage( aPageRange ); - aPage.SetTotalRange( Range( 0, RANGE_MAX ) ); - aPage.Select( aPageRange ); - aOptions.aMulti = aPage; - - //! Note: Since for PDF export of (multi-)selection a temporary - //! document is created that contains only the selects parts, - //! and thus that document is to printed in whole the, - //! aOptions.bPrintSelection parameter will be false. - aOptions.bPrintSelection = FALSE; - - SwViewOptionAdjust_Impl* pViewOptionAdjust = pView->IsA(aSwViewTypeId) ? - new SwViewOptionAdjust_Impl(*((SwView*)pView)->GetWrtShellPtr()) : 0; - - - pVwSh->SetPDFExportOption( sal_True ); - - // --> FME 2004-06-08 #i12836# enhanced pdf export - // - // First, we have to export hyperlinks, notes, and outline to pdf. - // During this process, additional information required for tagging - // the pdf file are collected, which are evaulated during painting. - // - SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ? - ((SwView*)pView)->GetWrtShellPtr() : - 0; - - if ( bFirstPage && pWrtShell ) + sal_Int32 nMaxRenderer = 0; + if (!bIsSwSrcView) { - SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPages, bSkipEmptyPages, sal_False ); + DBG_ASSERT( m_pRenderData, "m_pRenderData missing!!" ); + nMaxRenderer = bPrintProspect? + m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 : + m_pRenderData->GetPagesToPrint().size() - 1; } - // <-- + // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print + // we obmit checking of the upper bound in this case. + if (bIsSwSrcView || nRenderer <= nMaxRenderer) + { + if (bIsSwSrcView) + { + SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView); + OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions ); + pSwSrcView->PrintSource( pOutDev, nRenderer + 1, false ); + } + else + { + // the view shell should be SwView for documents PDF export + // or SwPagePreView for PDF export of the page preview + //!! (check for SwView first as in GuessViewShell) !! + DBG_ASSERT( pView, "!! view missing !!" ); + const TypeId aSwViewTypeId = TYPE(SwView); + ViewShell* pVwSh = 0; + if (pView) + { + pVwSh = pView->IsA(aSwViewTypeId) ? + ((SwView*)pView)->GetWrtShellPtr() : + ((SwPagePreView*)pView)->GetViewShell(); + } - pVwSh->Prt( aOptions, 0, pOut ); + // get output device to use + OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); - // --> FME 2004-10-08 #i35176# - // - // After printing the last page, we take care for the links coming - // from the EditEngine. The links are generated during the painting - // process, but the destinations are still missing. - // - if ( bLastPage && pWrtShell ) - { - SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPages, bSkipEmptyPages, sal_True ); - } - // <-- + if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions()) + { + const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); + const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False ); + bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport ); + + DBG_ASSERT(( pView->IsA(aSwViewTypeId) && m_pRenderData->IsViewOptionAdjust()) + || (!pView->IsA(aSwViewTypeId) && !m_pRenderData->IsViewOptionAdjust()), + "SwView / SwViewOptionAdjust_Impl availability mismatch" ); + + // since printing now also use the API for PDF export this option + // should be set for printing as well ... + pVwSh->SetPDFExportOption( sal_True ); + + // --> FME 2004-06-08 #i12836# enhanced pdf export + // + // First, we have to export hyperlinks, notes, and outline to pdf. + // During this process, additional information required for tagging + // the pdf file are collected, which are evaulated during painting. + // + SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ? + ((SwView*)pView)->GetWrtShellPtr() : + 0; + + if (bIsPDFExport && bFirstPage && pWrtShell) + { + SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_False ); + } + // <-- + + const SwPrtOptions &rSwPrtOptions = *m_pRenderData->GetSwPrtOptions(); + if (bPrintProspect) + pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer ); + else // normal printing and PDF export + pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer ); + + // --> FME 2004-10-08 #i35176# + // + // After printing the last page, we take care for the links coming + // from the EditEngine. The links are generated during the painting + // process, but the destinations are still missing. + // + if (bIsPDFExport && bLastPage && pWrtShell) + { + SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True ); + } + // <-- - pVwSh->SetPDFExportOption( sal_False ); - // #i96167# haggai: delete pViewOptionsAdjust here because it makes use - // of the shell, which might get destroyed in lcl_DisposeView! - delete pViewOptionAdjust; + pVwSh->SetPDFExportOption( sal_False ); - if( bLastPage && m_pHiddenViewFrame) - { - lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); - m_pHiddenViewFrame = 0; + // last page to be rendered? (not necessarily the last page of the document) + // -> do clean-up of data + if (bLastPage) + { + // #i96167# haggai: delete ViewOptionsAdjust here because it makes use + // of the shell, which might get destroyed in lcl_DisposeView! + if (m_pRenderData && m_pRenderData->IsViewOptionAdjust()) + m_pRenderData->ViewOptionAdjustStop(); + + if (m_pRenderData && m_pRenderData->HasPostItData()) + m_pRenderData->DeletePostItData(); + if (m_pHiddenViewFrame) + { + lcl_DisposeView( m_pHiddenViewFrame, pDocShell ); + m_pHiddenViewFrame = 0; + } + } + } + } } } + if( bLastPage ) + { + delete m_pRenderData; m_pRenderData = NULL; + delete m_pPrintUIOptions; m_pPrintUIOptions = NULL; + } } /* -----------------------------03.10.04 ------------------------------------- @@ -3790,3 +4055,80 @@ void SwXDocumentPropertyHelper::onChange() if(m_pDoc) m_pDoc->SetModified(); } + + +/*****************************************************************************/ + +SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwViewOption &rViewOptions ) : + m_rShell( rSh ), + m_aOldViewOptions( rViewOptions ) +{ +} + + +SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() +{ + m_rShell.ApplyViewOptions( m_aOldViewOptions ); +} + + +void SwViewOptionAdjust_Impl::AdjustViewOptions( + const SwPrtOptions *pPrtOptions ) +{ + // to avoid unnecessary reformatting the view options related to the content + // below should only change if necessary, that is if respective content is present + const bool bContainsHiddenChars = m_rShell.GetDoc()->ContainsHiddenChars(); + const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENTXTFLD ); + const bool bContainsHiddenFields = pFldType && pFldType->GetDepends(); + pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENPARAFLD ); + const bool bContainsHiddenParagraphs = pFldType && pFldType->GetDepends(); + pFldType = m_rShell.GetDoc()->GetSysFldType( RES_JUMPEDITFLD ); + const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends(); + const bool bContainsFields = m_rShell.IsAnyFieldInDoc(); + + SwViewOption aRenderViewOptions( m_aOldViewOptions ); + + // disable anything in the view that should not be printed (or exported to PDF) by default + // (see also dialog "Tools/Options - StarOffice Writer - Formatting Aids" + // in section "Display of ...") + aRenderViewOptions.SetParagraph( FALSE ); // paragraph end + aRenderViewOptions.SetSoftHyph( FALSE ); // aka custom hyphens + aRenderViewOptions.SetBlank( FALSE ); // spaces + aRenderViewOptions.SetHardBlank( FALSE ); // non-breaking spaces + aRenderViewOptions.SetTab( FALSE ); // tabs + aRenderViewOptions.SetLineBreak( FALSE ); // breaks (type 1) + aRenderViewOptions.SetPageBreak( FALSE ); // breaks (type 2) + aRenderViewOptions.SetColumnBreak( FALSE ); // breaks (type 3) + BOOL bVal = pPrtOptions? pPrtOptions->bPrintHiddenText : FALSE; + if (bContainsHiddenChars) + aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text + if (bContainsHiddenFields) + aRenderViewOptions.SetShowHiddenField( bVal ); + if (bContainsHiddenParagraphs) + aRenderViewOptions.SetShowHiddenPara( bVal ); + + if (bContainsPlaceHolders) + { + // should always be printed in PDF export! + bVal = pPrtOptions ? pPrtOptions->bPrintTextPlaceholder : TRUE; + aRenderViewOptions.SetShowPlaceHolderFields( bVal ); + } + + if (bContainsFields) + aRenderViewOptions.SetFldName( FALSE ); + + // we need to set this flag in order to get to see the visible effect of + // some of the above settings (needed for correct rendering) + aRenderViewOptions.SetViewMetaChars( TRUE ); + + if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary + { + aRenderViewOptions.SetPrinting( pPrtOptions != NULL ); + m_rShell.ApplyViewOptions( aRenderViewOptions ); + } +} + + +/*****************************************************************************/ + + diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 6197bb489d61..667d0f987783 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -2214,5 +2214,6 @@ void SAL_CALL SwXTextView::insertTransferable( const uno::Reference< datatransfe } } } + // ----------------------------------------------------------------------------- |