diff options
author | Philipp Lohmann <pl@openoffice.org> | 2009-05-19 11:32:44 +0000 |
---|---|---|
committer | Philipp Lohmann <pl@openoffice.org> | 2009-05-19 11:32:44 +0000 |
commit | 04e36071737ccca11f77d2c943248b08d66e76d6 (patch) | |
tree | 316ffb0f826eebdd7c1789748ee3e3226e22f6d1 /basctl/source/basicide | |
parent | 5b16a85b74f89bd4a57304b00bb0ac084d61d67b (diff) |
#i92516# print with XRenderable API
Diffstat (limited to 'basctl/source/basicide')
-rw-r--r-- | basctl/source/basicide/baside2.cxx | 50 | ||||
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 7 | ||||
-rw-r--r-- | basctl/source/basicide/baside3.cxx | 9 | ||||
-rw-r--r-- | basctl/source/basicide/basides2.cxx | 10 | ||||
-rw-r--r-- | basctl/source/basicide/bastypes.cxx | 7 | ||||
-rw-r--r-- | basctl/source/basicide/makefile.mk | 3 |
6 files changed, 56 insertions, 30 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index e92e4251be54..964d88353688 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -110,7 +110,7 @@ DBG_NAME( ModulWindow ) TYPEINIT1( ModulWindow , IDEBaseWindow ); -void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const String& rTitle ) +void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const String& rTitle, bool bOutput ) { short nLeftMargin = LMARGPRN; Size aSz = pPrinter->GetOutputSize(); @@ -136,14 +136,16 @@ void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const S long nXLeft = nLeftMargin-nBorder; long nXRight = aSz.Width()-RMARGPRN+nBorder; - pPrinter->DrawRect( Rectangle( - Point( nXLeft, nYTop ), - Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) ); + if( bOutput ) + pPrinter->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 ); + if( bOutput ) + pPrinter->DrawText( aPos, rTitle ); if ( nPages != 1 ) { aFont.SetWeight( WEIGHT_NORMAL ); @@ -154,13 +156,15 @@ void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const S aPageStr += String::CreateFromInt32( nCurPage ); aPageStr += ']'; aPos.X() += pPrinter->GetTextWidth( rTitle ); - pPrinter->DrawText( aPos, aPageStr ); + if( bOutput ) + pPrinter->DrawText( aPos, aPageStr ); } nY = TMARGPRN-nBorder; - pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) ); + if( bOutput ) + pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) ); pPrinter->SetFont( aOldFont ); pPrinter->SetFillColor( aOldFillColor ); @@ -905,8 +909,23 @@ void __EXPORT ModulWindow::UpdateData() } } +sal_Int32 ModulWindow::countPages( Printer* pPrinter ) +{ + return FormatAndPrint( pPrinter, -1 ); +} + +void ModulWindow::printPage( sal_Int32 nPage, Printer* pPrinter ) +{ + FormatAndPrint( pPrinter, nPage ); +} -void __EXPORT ModulWindow::PrintData( Printer* pPrinter ) +/* implementation note: this is totally inefficient for the XRenderable interface + usage since the whole "document" will be format for every page. Should this ever + become a problem we should + - format only once for every new printer + - keep an index list for each page which is the starting paragraph +*/ +sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage ) { DBG_CHKTHIS( ModulWindow, 0 ); @@ -940,10 +959,8 @@ void __EXPORT ModulWindow::PrintData( Printer* pPrinter ) USHORT nPages = (USHORT) (nParas/nLinespPage+1 ); USHORT nCurPage = 1; - pPrinter->StartJob( aTitle ); - pPrinter->StartPage(); // Header drucken... - lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle ); + lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nPrintPage == 0 ); Point aPos( LMARGPRN, TMARGPRN ); for ( ULONG nPara = 0; nPara < nParas; nPara++ ) { @@ -957,20 +974,19 @@ void __EXPORT ModulWindow::PrintData( Printer* pPrinter ) if ( aPos.Y() > ( aPaperSz.Height()+TMARGPRN ) ) { nCurPage++; - pPrinter->EndPage(); - pPrinter->StartPage(); - lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle ); + lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nCurPage-1 == nPrintPage ); aPos = Point( LMARGPRN, TMARGPRN+nLineHeight ); } - pPrinter->DrawText( aPos, aTmpLine ); + if( nCurPage-1 == nPrintPage ) + pPrinter->DrawText( aPos, aTmpLine ); } aPos.Y() += nParaSpace; } - pPrinter->EndPage(); - pPrinter->EndJob(); pPrinter->SetFont( aOldFont ); pPrinter->SetMapMode( eOldMapMode ); + + return sal_Int32(nCurPage); } diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 640c0582ca9e..81cc80af0656 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -354,6 +354,7 @@ private: void GoOnTop(); void AssertValidEditEngine(); + sal_Int32 FormatAndPrint( Printer* pPrinter, sal_Int32 nPage = -1 ); protected: virtual void Resize(); virtual void GetFocus(); @@ -375,7 +376,11 @@ public: virtual void StoreData(); virtual void UpdateData(); virtual BOOL CanClose(); - virtual void PrintData( Printer* pPrinter ); + // virtual void PrintData( Printer* pPrinter ); + // return number of pages to be printed + virtual sal_Int32 countPages( Printer* pPrinter ); + // print page + virtual void printPage( sal_Int32 nPage, Printer* pPrinter ); virtual String GetTitle(); virtual BasicEntryDescriptor CreateEntryDescriptor(); virtual BOOL AllowUndo(); diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index 41f171c69480..89176a88a675 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -962,9 +962,14 @@ void DialogWindow::Deactivating() BasicIDE::MarkDocumentModified( GetDocument() ); } -void DialogWindow::PrintData( Printer* pPrinter ) +sal_Int32 DialogWindow::countPages( Printer* pPrinter ) { - pEditor->PrintData( pPrinter, CreateQualifiedName() ); + return pEditor->countPages( pPrinter ); +} + +void DialogWindow::printPage( sal_Int32 nPage, Printer* pPrinter ) +{ + pEditor->printPage( nPage, pPrinter, CreateQualifiedName() ); } void DialogWindow::DataChanged( const DataChangedEvent& rDCEvt ) diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index 74e1d59aad4d..eb59ca4f082b 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -38,8 +38,7 @@ #include <ide_pch.hxx> #include <basic/sbx.hxx> - -#define _SOLAR__PRIVATE 1 +#include "basicrenderable.hxx" #include <com/sun/star/frame/XTitle.hpp> @@ -85,6 +84,12 @@ IMPL_LINK( BasicIDEShell, ObjectDialogInsertHdl, ObjectCatalog *, pObjCat ) } */ +Reference< view::XRenderable > BasicIDEShell::GetRenderable() +{ + return Reference< view::XRenderable >( new basicide::BasicRenderable( pCurWin ) ); +} + +#if 0 USHORT __EXPORT BasicIDEShell::Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog ) { if ( pCurWin ) @@ -98,6 +103,7 @@ USHORT __EXPORT BasicIDEShell::Print( SfxProgress &rProgress, BOOL bIsAPI, Print } return 0; } +#endif BOOL BasicIDEShell::HasSelection( BOOL /* bText */ ) const { diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index 33d6f5af4961..02d527aace8c 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -207,13 +207,6 @@ void __EXPORT IDEBaseWindow::UpdateData() } - -void __EXPORT IDEBaseWindow::PrintData( Printer* ) -{ -} - - - String __EXPORT IDEBaseWindow::GetTitle() { return String(); diff --git a/basctl/source/basicide/makefile.mk b/basctl/source/basicide/makefile.mk index 8766473d8157..afd8a3cc366f 100644 --- a/basctl/source/basicide/makefile.mk +++ b/basctl/source/basicide/makefile.mk @@ -51,7 +51,8 @@ CDEFS+=-DBASICDEBUG # --- Allgemein ---------------------------------------------------------- -EXCEPTIONSFILES=$(SLO)$/scriptdocument.obj \ +EXCEPTIONSFILES=$(SLO)$/basicrenderable.obj \ + $(SLO)$/scriptdocument.obj \ $(SLO)$/basidesh.obj \ $(SLO)$/basides1.obj \ $(SLO)$/basides2.obj \ |