summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/dbmgr.hxx3
-rw-r--r--sw/inc/printdata.hxx2
-rw-r--r--sw/inc/unotxdoc.hxx4
-rw-r--r--sw/inc/viewsh.hxx3
-rw-r--r--sw/source/core/view/viewpg.cxx4
-rw-r--r--sw/source/core/view/vprint.cxx20
-rw-r--r--sw/source/ui/dbui/dbmgr.cxx172
-rw-r--r--sw/source/ui/inc/srcview.hxx8
-rw-r--r--sw/source/ui/uiview/srcview.cxx170
-rw-r--r--sw/source/ui/uno/unotxdoc.cxx482
10 files changed, 390 insertions, 478 deletions
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 9e13058e90e6..51242f33f224 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -252,9 +252,6 @@ public:
// Mischen von Datensaetzen in Felder
BOOL MergeNew( const SwMergeDescriptor& rMergeDesc );
BOOL Merge(SwWrtShell* pSh);
- // Mischen von Datensaetzen in Felder, dann drucken
- BOOL MergePrint( SwView& rView,
- SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI );
// printing parts of a merge result document
BOOL MergePrintDocuments( SwView& rView,
SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI );
diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx
index 14303ad40d5d..345546deabec 100644
--- a/sw/inc/printdata.hxx
+++ b/sw/inc/printdata.hxx
@@ -60,7 +60,7 @@ class SwPrintUIOptions : public vcl::PrinterOptionsHelper
OutputDevice* m_pLast;
public:
- SwPrintUIOptions( BOOL bWeb = FALSE );
+ SwPrintUIOptions( bool bWeb, bool bSwSrcView );
~SwPrintUIOptions();
bool processPropertiesAndCheckFormat( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp );
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index e0fa90de0ac7..8e56039cd53e 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -234,9 +234,9 @@ class SwXTextDocument : public SwXTextDocumentBaseClass,
void GetNumberFormatter();
// used for XRenderable implementation
- SfxViewShell * GuessViewShell( const css::uno::Reference< css::frame::XController > xController = css::uno::Reference< css::frame::XController >() );
+ SfxViewShell * GuessViewShell( /* out */ bool &rbIsSwSrcView, const css::uno::Reference< css::frame::XController > xController = css::uno::Reference< css::frame::XController >() );
SwDoc * GetRenderDoc( SfxViewShell *&rpView, const css::uno::Any& rSelection, bool bIsPDFExport );
- SfxViewShell * GetRenderView( const SwPrintUIOptions &rOpt, bool bIsPDFExport );
+ SfxViewShell * GetRenderView( bool &rbIsSwSrcView, const css::uno::Sequence< css::beans::PropertyValue >& rxOptions, bool bIsPDFExport );
rtl::OUString maBuildId;
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 636608279dbb..36da231f1832 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -388,8 +388,7 @@ public:
SwDoc * FillPrtDoc( SwDoc* pPrtDoc, const SfxPrinter* pPrt );
//Wird intern fuer die Shell gerufen die Druckt. Formatiert die Seiten.
- void CalcPagesForPrint( sal_uInt16 nMax, SfxProgress* pProgress = 0,
- const String* pStr = NULL, ULONG nMergeAct = 0, ULONG nMergeCnt = 0 );
+ void CalcPagesForPrint( sal_uInt16 nMax, SfxProgress* pProgress = 0 );
//All about fields.
void UpdateFlds(sal_Bool bCloseDB = sal_False);
diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx
index c3da2df6cf37..a9ab62df38fc 100644
--- a/sw/source/core/view/viewpg.cxx
+++ b/sw/source/core/view/viewpg.cxx
@@ -508,7 +508,7 @@ void ViewShell::PrintProspect(
}
// Seiten fuers Drucken formatieren
- aShell.CalcPagesForPrint( nPageMax, 0 /*(USHORT)aPages.Max(), &rProgress*/ );
+ aShell.CalcPagesForPrint( nPageMax, 0 );
#endif // TL_NOT_NOW // TLPDF
MapMode aMapMode( MAP_TWIP );
@@ -636,7 +636,7 @@ void ViewShell::PrintProspect(
{
SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
pFldType->Modify( &aHnt, 0);
- CalcPagesForPrint( nPageMax /*(USHORT)aPages.Max()*/ );
+ CalcPagesForPrint( nPageMax );
}
#endif // TL_NOT_NOW // TLPDF
pFntCache->Flush();
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index 081017f1aeb3..d811c12d02c5 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -369,7 +369,7 @@ void SwRenderData::MakeSwPrtOptions(
/*****************************************************************************/
-SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) :
+SwPrintUIOptions::SwPrintUIOptions( bool bWeb, bool bSwSrcView ) :
m_pLast( NULL )
{
ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) );
@@ -378,6 +378,14 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) :
if( aLocalizedStrings.Count() < 44 ) // bad resource ?
return;
+ // printing HTML sources does not have any valid UI options.
+ // Its just the source code that gets printed ...
+ if (bSwSrcView)
+ {
+ m_aUIProperties.realloc( 0 );
+ return;
+ }
+
// create sequence of print UI options
// (5 options are not available for Writer-Web)
const int nNumProps = bWeb? 17 : 21;
@@ -502,12 +510,14 @@ SwPrintUIOptions::SwPrintUIOptions( BOOL bWeb ) :
aHelpText.realloc( 2 );
aHelpText[0] = aLocalizedStrings.GetString( 25 );
aHelpText[1] = aLocalizedStrings.GetString( 25 );
+ vcl::PrinterOptionsHelper::UIControlOptions aAnnotOpt( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ), 1, sal_False );
m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 26 ),
aHelpText,
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintAnnotationMode" ) ),
aChoices,
0,
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) )
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ),
+ aAnnotOpt
);
// create subsection for Page settings
@@ -834,8 +844,7 @@ void lcl_SetState( SfxProgress& rProgress, ULONG nPage, ULONG nMax,
-void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress,
- const XubString* /*TLPDF pStr*/, ULONG /*TLPDF nMergeAct*/, ULONG /*TLPDF nMergeCnt*/ )
+void ViewShell::CalcPagesForPrint( USHORT nMax, SfxProgress* pProgress )
{
SET_CURR_SHELL( this );
@@ -1169,8 +1178,7 @@ sal_Bool ViewShell::PrintOrPDFExport(
#ifdef TL_NOT_NOW // TLPDF: applying view options and formatting the dcoument should now only be done in getRendererCount!
// benoetigte Seiten fuers Drucken formatieren
- pShell->CalcPagesForPrint( (USHORT)nPage, 0 /*TLPDF*/, 0 /*TLPDFpStr*/,
- 0, 0 /* TLPDF, there is no progressbar right now nMergeAct, nMergeCnt */ );
+ pShell->CalcPagesForPrint( (USHORT)nPage, 0 );
// Some field types, can require a valid layout
// (expression fields in tables). For these we do an UpdateFlds
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index dee7803a9798..487bc744e9eb 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -781,178 +781,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());
-
-//TLPDF SfxPrinter *pPrt = pSh->getIDocumentDeviceAccess()->getPrinter( false );
- const boost::shared_ptr< Printer > pPrt( new Printer /* Printer( const JobSetup& rJobSetup ) */ ); // TLPDF
- vcl::OldStylePrintAdaptor aPrtAdaptor( pPrt ); // TLPDF
- const boost::shared_ptr< vcl::PrinterController > pPrtController( &aPrtAdaptor );
-//TLPDF Link aSfxSaveLnk = pPrt->GetEndPrintHdl();
-//TLPDF if( rOpt.IsPrintSingleJobs() )
-//TLPDF pPrt->SetEndPrintHdl( Link() );
-
-//TLPDF BOOL bUserBreak = FALSE;
- BOOL 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, pSh->GetView().GetViewFrame()->GetObjectShell()));
- pSh->ViewShell::UpdateFlds();
- SFX_APP()->NotifyEvent(SfxEventHint(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())
- {
-#ifdef TL_NOT_NOW /*TLPDF*/
- if( ! pPrt->IsJobActive() )
- {
- pPrt->SetJobValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ),
- String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) );
- pPrt->StartJob( rOpt.GetJobName() );
- }
- if( pPrt->IsJobActive() )
- {
- pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspectRTL() ); /* TLPDF */
- bRet = TRUE;
- }
-#endif // TL_NOT_NOW /*TLPDF*/
-//TLPDFXX pSh->PrintProspectMM( aPrtAdaptor, aViewProperties, rOpt, rOpt.IsPrintProspectRTL() ); // TLPDF
- bRet = TRUE; // TLPDF
- }
- else if( 1 /*TLPDFXX pSh->PrintOrPDFExportMM( aPrtAdaptor, aViewProperties, rOpt ) */ )
- bRet = TRUE;
- bMergeLock = FALSE;
-
-#ifdef TL_NOT_NOW /*TLPDF*/
- if( !pPrt->IsJobActive() )
- {
- bUserBreak = TRUE;
- bRet = FALSE;
- break;
- }
-#endif // TL_NOT_NOW /*TLPDF*/
- 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() )
- {
-//TLPDF SfxPrinter* pTmpPrinter = pSh->getIDocumentDeviceAccess()->getPrinter( true );
-//TLPDF const boost::shared_ptr< Printer > pTmpPrinter( new Printer /* Printer( const JobSetup& rJobSetup ) */ ); // TLPDF
-//TLPDF vcl::OldStylePrintAdaptor aPrtAdaptor( pTmpPrinter );
- // TLPDF
-//TLPDF pTmpPrinter->SetEndPrintHdl( aSfxSaveLnk );
-//TLPDF if ( !bUserBreak && !pTmpPrinter->IsJobActive() ) //Schon zu spaet?
-//TLPDF 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
diff --git a/sw/source/ui/inc/srcview.hxx b/sw/source/ui/inc/srcview.hxx
index 996aab82b446..d66096d4418b 100644
--- a/sw/source/ui/inc/srcview.hxx
+++ b/sw/source/ui/inc/srcview.hxx
@@ -32,6 +32,8 @@
#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/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx
index 1b496b3b4fae..d1e0ab8e3bec 100644
--- a/sw/source/ui/uiview/srcview.cxx
+++ b/sw/source/ui/uiview/srcview.cxx
@@ -151,23 +151,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;
@@ -175,34 +175,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-----------------
@@ -725,9 +725,10 @@ 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();
@@ -753,114 +754,87 @@ 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 )
{
- #if 0
- 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 );
+ Point aPos( LMARGPRN, TMARGPRN );
+ 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 ) )
{
- 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 = Point( LMARGPRN, TMARGPRN + nLineHeight );
}
- aPos.Y() += nParaSpace;
+ if (!bCalcNumPagesOnly && nPage == nCurPage)
+ pOutDev->DrawText( aPos, aTmpLine );
}
- pPrinter->EndPage();
+ aPos.Y() += nParaSpace;
}
- pPrinter->SetFont( aOldFont );
- pPrinter->SetMapMode( eOldMapMode );
-
- if ( !bStartJob )
- {
- // Printer konnte nicht gestartet werden
- delete pProgress;
- return ERRCODE_IO_ABORT;
- }
+ pOutDev->Pop();
- pProgress->Stop();
- pProgress->DeleteOnEndPrint();
- pPrinter->EndJob();
- return pPrinter->GetError();
- #else
- DBG_ERROR( "dead code" );
- return ERRCODE_IO_NOTSUPPORTED;
- #endif
+ 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/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index fb765915f5b0..65bc181133e2 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -2470,20 +2470,50 @@ static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptio
}
-SfxViewShell * SwXTextDocument::GetRenderView( const SwPrintUIOptions &rOpt, bool bIsPDFExport )
+static bool lcl_SeqHasProperty(
+ const uno::Sequence< beans::PropertyValue >& rOptions,
+ const sal_Char *pPropName )
+{
+ 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 (pProps[i].Name.equalsAscii( pPropName ))
+ bRes = true;
+ }
+ return bRes;
+}
+
+
+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();
+ pView = GuessViewShell( rbIsSwSrcView );
else
{
- uno::Any aTmp( rOpt.getValue( C2U( "View" ) ));
+ 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( xController );
+ pView = GuessViewShell( rbIsSwSrcView, xController );
}
}
return pView;
@@ -2499,7 +2529,10 @@ SfxViewShell * SwXTextDocument::GetRenderView( const SwPrintUIOptions &rOpt, boo
* SfxViewShell.
*/
-SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rSelection, bool bIsPDFExport )
+SwDoc * SwXTextDocument::GetRenderDoc(
+ SfxViewShell *&rpView,
+ const uno::Any& rSelection,
+ bool bIsPDFExport )
{
SwDoc *pDoc = 0;
@@ -2518,8 +2551,9 @@ SwDoc * SwXTextDocument::GetRenderDoc( SfxViewShell *&rpView, const uno::Any& rS
// used for PDF export of (multi-)selection
if (rSelection.hasValue()) // is anything selected ?
{
+ bool bIsSwSrcView = false;
if (!rpView)
- rpView = GuessViewShell();
+ 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
@@ -2554,106 +2588,111 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
if(!IsValid())
throw RuntimeException();
- // actually m_pRenderData and m_pPrintUIOptions should have already been
- // destroyed in 'render' when IsLastPage was set (or should have been set)
-// if (m_pRenderData)
-// delete m_pRenderData, m_pRenderData = 0;
-// if (m_pPrintUIOptions)
-// delete m_pPrintUIOptions, m_pPrintUIOptions = 0;
+ const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
+ bool bIsSwSrcView = false;
+ SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
if (! m_pRenderData)
m_pRenderData = new SwRenderData;
if (! m_pPrintUIOptions)
{
- const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
- m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc );
+ const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
+ m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc, bIsSwSrcView );
}
bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions );
- const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" );
const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
- SfxViewShell *pView = GetRenderView( *m_pPrintUIOptions, bIsPDFExport );
SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
+ DBG_ASSERT( pDoc && pView, "doc or view shell missing!" );
if (!pDoc || !pView)
- throw RuntimeException();
-
- SwDocShell *pRenderDocShell = pDoc->GetDocShell();
- // #i38289
- if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE) /*TLPDF for printing as well?*/)
- {
- pRenderDocShell->ToggleBrowserMode(false,NULL);
- }
-
- SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell();
+ return 0;
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();
+ // #i38289
+ if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE))
+ {
+ pRenderDocShell->ToggleBrowserMode(false,NULL);
+ }
- m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) );
- m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell,
- m_pPrintUIOptions, m_pRenderData, bIsSkipEmptyPages, bIsPDFExport );
+ SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell();
- //SwViewOptionAdjust_Impl aAdjust(*pWrtShell);
- const TypeId aSwViewTypeId = TYPE(SwView);
- if (pView->IsA(aSwViewTypeId))
- m_pRenderData->ViewOptionAdjustStart( *((SwView*)pView)->GetWrtShellPtr() );
+ 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();
+ }
- if( bFormat )
- {
- // since printing now also use the API for PDF export this option
- // should be set for printing as well ...
- pWrtShell->SetPDFExportOption( sal_True );
+ m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) );
+ m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell,
+ m_pPrintUIOptions, m_pRenderData, bIsSkipEmptyPages, bIsPDFExport );
- // --> FME 2005-05-23 #122919# Force field update before PDF export:
- pWrtShell->ViewShell::UpdateFlds(TRUE);
- // <--
+ //SwViewOptionAdjust_Impl aAdjust(*pWrtShell);
+ const TypeId aSwViewTypeId = TYPE(SwView);
+ if (pView->IsA(aSwViewTypeId))
+ m_pRenderData->ViewOptionAdjustStart( *((SwView*)pView)->GetWrtShellPtr() );
- // there is some redundancy between those two fucntion 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() );
+ if( bFormat )
+ {
+ // since printing now also use the API for PDF export this option
+ // should be set for printing as well ...
+ pWrtShell->SetPDFExportOption( sal_True );
- pWrtShell->SetPDFExportOption( sal_False );
- }
+ // --> FME 2005-05-23 #122919# Force field update before PDF export:
+ pWrtShell->ViewShell::UpdateFlds(TRUE);
+ // <--
- const sal_Int32 nPageCount = pDoc->GetPageCount();
+ // 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() );
- //
- // 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 );
+ pWrtShell->SetPDFExportOption( sal_False );
}
- // get set of valid document pages (according to the current settings)
- // and their start frames
- pDoc->CalculatePagesForPrinting( *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount );
+ const sal_Int32 nPageCount = pDoc->GetPageCount();
- if (nPostItMode != POSTITS_NONE)
+ //
+ // get number of pages to be rendered
+ //
+ const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
+ if (bPrintProspect)
{
- pDoc->UpdatePagesForPrintingWithPostItData( *m_pRenderData,
- *m_pPrintUIOptions, bIsPDFExport, nPageCount );
+ 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 );
+ }
- nRet = m_pRenderData->GetPagesToPrint().size();
+ // 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???" );
@@ -2672,44 +2711,83 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
if(!IsValid())
throw RuntimeException();
- DBG_ASSERT( m_pRenderData, "data should have been created already in getRendererCount..." );
- DBG_ASSERT( m_pPrintUIOptions, "data should have been created already in getRendererCount..." );
+ 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 )
{
- const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
- m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc );
+ const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
+ m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc, bIsSwSrcView );
}
m_pPrintUIOptions->processProperties( rxOptions );
- const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" );
+ const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
- SfxViewShell *pView = GetRenderView( *m_pPrintUIOptions, bIsPDFExport );
SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
+ DBG_ASSERT( pDoc && pView, "doc or view shell missing!" );
if (!pDoc || !pView)
- throw RuntimeException();
+ 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()*/))
- throw IllegalArgumentException();
- if (nRenderer >= pDoc->GetPageCount())
- return uno::Sequence< beans::PropertyValue >();
+ if (0 > nRenderer)
+ throw IllegalArgumentException();
+ 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 >();
+
+ uno::Sequence< beans::PropertyValue > aRenderer;
+ if (m_pRenderData)
+ {
+ Size aPgSize;
+ if (bIsSwSrcView || m_pPrintUIOptions->getBoolValue( "PrintProspect", sal_False ))
+ {
+ // 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)
+ aPgSize = pPrinter->GetPaperSize();
+ }
+ else
+ {
+ bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
+ aPgSize = pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bIsSkipEmptyPages );
+ }
+ awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ),
+ TWIP_TO_MM100( aPgSize.Height() ));
- bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
- Size aPgSize( pDoc->GetPageSize( sal_uInt16(nRenderer + 1), bIsSkipEmptyPages ) );
- awt::Size aPageSize( TWIP_TO_MM100( aPgSize.Width() ),
- TWIP_TO_MM100( aPgSize.Height() ));
- // prospect printing should be landscape, thus switching width and height
- if (m_pPrintUIOptions->getBoolValue( "PrintProspect", sal_False ) &&
- aPageSize.Height > aPageSize.Width)
- aPageSize = awt::Size( aPageSize.Height, aPageSize.Width );
- uno::Sequence< beans::PropertyValue > aRenderer(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;
+ 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;
+ }
m_pPrintUIOptions->appendPrintUIOptions( aRenderer );
@@ -2719,6 +2797,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
---------------------------------------------------------------------------*/
SfxViewShell * SwXTextDocument::GuessViewShell(
+ /* out */ bool &rbIsSwSrcView,
const uno::Reference< css::frame::XController > xController )
{
// #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell()
@@ -2727,6 +2806,7 @@ 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,
@@ -2736,6 +2816,7 @@ SfxViewShell * SwXTextDocument::GuessViewShell(
{
pView = pFrame->GetViewShell();
pSwView = dynamic_cast< SwView * >(pView);
+ pSwSrcView = dynamic_cast< SwSrcView * >(pView);
if (!pSwPagePreView)
pSwPagePreView = dynamic_cast< SwPagePreView * >(pView);
if (xController.is())
@@ -2743,15 +2824,18 @@ SfxViewShell * SwXTextDocument::GuessViewShell(
if (pView && pView->GetController() == xController)
break;
}
- else if (pSwView)
+ else if (pSwView || pSwSrcView)
break;
pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, 0, sal_False );
}
- DBG_ASSERT( pSwView || pSwPagePreView, "failed to get view shell" );
- return pSwView ?
- dynamic_cast< SfxViewShell * >(pSwView) :
- dynamic_cast< SfxViewShell * >(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) );
}
@@ -2765,120 +2849,140 @@ void SAL_CALL SwXTextDocument::render(
if(!IsValid())
throw RuntimeException();
+ 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 (!m_pRenderData)
m_pRenderData = new SwRenderData;
if (!m_pPrintUIOptions)
{
- const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
- m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc );
+ const BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
+ m_pPrintUIOptions = new SwPrintUIOptions( bWebDoc, bIsSwSrcView );
}
m_pPrintUIOptions->processProperties( rxOptions );
const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
- const bool bIsPDFExport = !m_pPrintUIOptions->hasProperty( "IsPrinter" );
- SfxViewShell *pView = GetRenderView( *m_pPrintUIOptions, bIsPDFExport );
SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
-
+ DBG_ASSERT( pDoc && pView, "doc or view shell missing!" );
if (!pDoc || !pView)
- throw RuntimeException();
+ return;
// 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)
throw IllegalArgumentException();
- if ( (bPrintProspect && size_t(nRenderer) >= m_pRenderData->GetPagePairsForProspectPrinting().size())
- || (!bPrintProspect && size_t(nRenderer) >= m_pRenderData->GetPagesToPrint().size()))
- 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) !!
- 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();
+ sal_Int32 nMaxRenderer = 0;
+ if (!bIsSwSrcView)
+ {
+ 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)
+ return;
+
+ if (bIsSwSrcView)
+ {
+ SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView);
+ OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
+ pSwSrcView->PrintSource( pOutDev, nRenderer + 1, false );
}
-
- // get output device to use
- OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions );
-
- if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions())
+ else
{
- const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() );
- const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False );
- const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", 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)
+ // 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)
{
- SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_False );
+ pVwSh = pView->IsA(aSwViewTypeId) ?
+ ((SwView*)pView)->GetWrtShellPtr() :
+ ((SwPagePreView*)pView)->GetViewShell();
}
- // <--
- const SwPrtOptions &rSwPrtOptions = *m_pRenderData->GetSwPrtOptions();
- if (bPrintProspect)
- pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer );
- else // normal printing and PDF export
- pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer, bIsPDFExport );
+ // 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 (bIsPDFExport && bLastPage && pWrtShell)
+ if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions())
{
- SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True );
- }
- // <--
+ const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() );
+ const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False );
+ const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False );
+ bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
- pVwSh->SetPDFExportOption( sal_False );
+ DBG_ASSERT(( pView->IsA(aSwViewTypeId) && m_pRenderData->IsViewOptionAdjust())
+ || (!pView->IsA(aSwViewTypeId) && !m_pRenderData->IsViewOptionAdjust()),
+ "SwView / SwViewOptionAdjust_Impl availability mismatch" );
- // last page to be rendered? (not necessarily the last page of the document)
- // -> do clean-up of data
- if (bLastPage)
- {
- // #i96167# haggai: delete pViewOptionsAdjust here because it makes use
- // of the shell, which might get destroyed in lcl_DisposeView!
- if (m_pRenderData && m_pRenderData->IsViewOptionAdjust())
- m_pRenderData->ViewOptionAdjustStop();
+ // since printing now also use the API for PDF export this option
+ // should be set for printing as well ...
+ pVwSh->SetPDFExportOption( sal_True );
- if (m_pRenderData && m_pRenderData->HasPostItData())
- m_pRenderData->DeletePostItData();
- if (m_pHiddenViewFrame)
+ // --> 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, bIsPDFExport );
+
+ // --> 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)
{
- lcl_DisposeView( m_pHiddenViewFrame, pDocShell );
- m_pHiddenViewFrame = 0;
+ SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True );
}
+ // <--
- delete m_pRenderData; m_pRenderData = NULL;
- delete m_pPrintUIOptions; m_pPrintUIOptions = NULL;
+ pVwSh->SetPDFExportOption( sal_False );
+
+ // last page to be rendered? (not necessarily the last page of the document)
+ // -> do clean-up of data
+ if (bLastPage)
+ {
+ // #i96167# haggai: delete pViewOptionsAdjust 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;
+ }
+
+ delete m_pRenderData; m_pRenderData = NULL;
+ delete m_pPrintUIOptions; m_pPrintUIOptions = NULL;
+ }
}
}
}