#i92516# print with XRenderable API

This commit is contained in:
Philipp Lohmann
2009-05-19 11:32:44 +00:00
parent 5b16a85b74
commit 04e3607173
11 changed files with 86 additions and 39 deletions

View File

@@ -110,7 +110,7 @@ DBG_NAME( ModulWindow )
TYPEINIT1( ModulWindow , IDEBaseWindow ); 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; short nLeftMargin = LMARGPRN;
Size aSz = pPrinter->GetOutputSize(); Size aSz = pPrinter->GetOutputSize();
@@ -136,14 +136,16 @@ void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const S
long nXLeft = nLeftMargin-nBorder; long nXLeft = nLeftMargin-nBorder;
long nXRight = aSz.Width()-RMARGPRN+nBorder; long nXRight = aSz.Width()-RMARGPRN+nBorder;
pPrinter->DrawRect( Rectangle( if( bOutput )
Point( nXLeft, nYTop ), pPrinter->DrawRect( Rectangle(
Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) ); Point( nXLeft, nYTop ),
Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) );
long nY = TMARGPRN-2*nBorder; long nY = TMARGPRN-2*nBorder;
Point aPos( nLeftMargin, nY ); Point aPos( nLeftMargin, nY );
pPrinter->DrawText( aPos, rTitle ); if( bOutput )
pPrinter->DrawText( aPos, rTitle );
if ( nPages != 1 ) if ( nPages != 1 )
{ {
aFont.SetWeight( WEIGHT_NORMAL ); aFont.SetWeight( WEIGHT_NORMAL );
@@ -154,13 +156,15 @@ void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const S
aPageStr += String::CreateFromInt32( nCurPage ); aPageStr += String::CreateFromInt32( nCurPage );
aPageStr += ']'; aPageStr += ']';
aPos.X() += pPrinter->GetTextWidth( rTitle ); aPos.X() += pPrinter->GetTextWidth( rTitle );
pPrinter->DrawText( aPos, aPageStr ); if( bOutput )
pPrinter->DrawText( aPos, aPageStr );
} }
nY = TMARGPRN-nBorder; 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->SetFont( aOldFont );
pPrinter->SetFillColor( aOldFillColor ); pPrinter->SetFillColor( aOldFillColor );
@@ -905,8 +909,23 @@ void __EXPORT ModulWindow::UpdateData()
} }
} }
sal_Int32 ModulWindow::countPages( Printer* pPrinter )
{
return FormatAndPrint( pPrinter, -1 );
}
void __EXPORT ModulWindow::PrintData( Printer* pPrinter ) void ModulWindow::printPage( sal_Int32 nPage, Printer* pPrinter )
{
FormatAndPrint( pPrinter, nPage );
}
/* 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 ); DBG_CHKTHIS( ModulWindow, 0 );
@@ -940,10 +959,8 @@ void __EXPORT ModulWindow::PrintData( Printer* pPrinter )
USHORT nPages = (USHORT) (nParas/nLinespPage+1 ); USHORT nPages = (USHORT) (nParas/nLinespPage+1 );
USHORT nCurPage = 1; USHORT nCurPage = 1;
pPrinter->StartJob( aTitle );
pPrinter->StartPage();
// Header drucken... // Header drucken...
lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle ); lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nPrintPage == 0 );
Point aPos( LMARGPRN, TMARGPRN ); Point aPos( LMARGPRN, TMARGPRN );
for ( ULONG nPara = 0; nPara < nParas; nPara++ ) for ( ULONG nPara = 0; nPara < nParas; nPara++ )
{ {
@@ -957,20 +974,19 @@ void __EXPORT ModulWindow::PrintData( Printer* pPrinter )
if ( aPos.Y() > ( aPaperSz.Height()+TMARGPRN ) ) if ( aPos.Y() > ( aPaperSz.Height()+TMARGPRN ) )
{ {
nCurPage++; nCurPage++;
pPrinter->EndPage(); lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nCurPage-1 == nPrintPage );
pPrinter->StartPage();
lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle );
aPos = Point( LMARGPRN, TMARGPRN+nLineHeight ); aPos = Point( LMARGPRN, TMARGPRN+nLineHeight );
} }
pPrinter->DrawText( aPos, aTmpLine ); if( nCurPage-1 == nPrintPage )
pPrinter->DrawText( aPos, aTmpLine );
} }
aPos.Y() += nParaSpace; aPos.Y() += nParaSpace;
} }
pPrinter->EndPage();
pPrinter->EndJob();
pPrinter->SetFont( aOldFont ); pPrinter->SetFont( aOldFont );
pPrinter->SetMapMode( eOldMapMode ); pPrinter->SetMapMode( eOldMapMode );
return sal_Int32(nCurPage);
} }

View File

@@ -354,6 +354,7 @@ private:
void GoOnTop(); void GoOnTop();
void AssertValidEditEngine(); void AssertValidEditEngine();
sal_Int32 FormatAndPrint( Printer* pPrinter, sal_Int32 nPage = -1 );
protected: protected:
virtual void Resize(); virtual void Resize();
virtual void GetFocus(); virtual void GetFocus();
@@ -375,7 +376,11 @@ public:
virtual void StoreData(); virtual void StoreData();
virtual void UpdateData(); virtual void UpdateData();
virtual BOOL CanClose(); 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 String GetTitle();
virtual BasicEntryDescriptor CreateEntryDescriptor(); virtual BasicEntryDescriptor CreateEntryDescriptor();
virtual BOOL AllowUndo(); virtual BOOL AllowUndo();

View File

@@ -962,9 +962,14 @@ void DialogWindow::Deactivating()
BasicIDE::MarkDocumentModified( GetDocument() ); 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 ) void DialogWindow::DataChanged( const DataChangedEvent& rDCEvt )

View File

@@ -38,8 +38,7 @@
#include <ide_pch.hxx> #include <ide_pch.hxx>
#include <basic/sbx.hxx> #include <basic/sbx.hxx>
#include "basicrenderable.hxx"
#define _SOLAR__PRIVATE 1
#include <com/sun/star/frame/XTitle.hpp> #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 ) USHORT __EXPORT BasicIDEShell::Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog )
{ {
if ( pCurWin ) if ( pCurWin )
@@ -98,6 +103,7 @@ USHORT __EXPORT BasicIDEShell::Print( SfxProgress &rProgress, BOOL bIsAPI, Print
} }
return 0; return 0;
} }
#endif
BOOL BasicIDEShell::HasSelection( BOOL /* bText */ ) const BOOL BasicIDEShell::HasSelection( BOOL /* bText */ ) const
{ {

View File

@@ -207,13 +207,6 @@ void __EXPORT IDEBaseWindow::UpdateData()
} }
void __EXPORT IDEBaseWindow::PrintData( Printer* )
{
}
String __EXPORT IDEBaseWindow::GetTitle() String __EXPORT IDEBaseWindow::GetTitle()
{ {
return String(); return String();

View File

@@ -51,7 +51,8 @@ CDEFS+=-DBASICDEBUG
# --- Allgemein ---------------------------------------------------------- # --- Allgemein ----------------------------------------------------------
EXCEPTIONSFILES=$(SLO)$/scriptdocument.obj \ EXCEPTIONSFILES=$(SLO)$/basicrenderable.obj \
$(SLO)$/scriptdocument.obj \
$(SLO)$/basidesh.obj \ $(SLO)$/basidesh.obj \
$(SLO)$/basides1.obj \ $(SLO)$/basides1.obj \
$(SLO)$/basides2.obj \ $(SLO)$/basides2.obj \

View File

@@ -1283,7 +1283,20 @@ void lcl_PrintHeader( Printer* pPrinter, const String& rTitle ) // not working y
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void DlgEditor::PrintData( Printer* pPrinter, const String& rTitle ) // not working yet sal_Int32 DlgEditor::countPages( Printer* )
{
return 1;
}
void DlgEditor::printPage( sal_Int32 nPage, Printer* pPrinter, const String& rTitle )
{
if( nPage == 0 )
Print( pPrinter, rTitle );
}
//----------------------------------------------------------------------------
void DlgEditor::Print( Printer* pPrinter, const String& rTitle ) // not working yet
{ {
if( pDlgEdView ) if( pDlgEdView )
{ {
@@ -1304,8 +1317,6 @@ void DlgEditor::PrintData( Printer* pPrinter, const String& rTitle ) // not w
aPaperSz.Width() -= (LMARGPRN+RMARGPRN); aPaperSz.Width() -= (LMARGPRN+RMARGPRN);
aPaperSz.Height() -= (TMARGPRN+BMARGPRN); aPaperSz.Height() -= (TMARGPRN+BMARGPRN);
pPrinter->StartPage();
lcl_PrintHeader( pPrinter, rTitle ); lcl_PrintHeader( pPrinter, rTitle );
Bitmap aDlg; Bitmap aDlg;
@@ -1350,8 +1361,6 @@ void DlgEditor::PrintData( Printer* pPrinter, const String& rTitle ) // not w
pPrinter->DrawBitmap( aPosOffs, aOutputSz, aDlg ); pPrinter->DrawBitmap( aPosOffs, aOutputSz, aDlg );
pPrinter->EndPage();
pPrinter->SetMapMode( aOldMap ); pPrinter->SetMapMode( aOldMap );
pPrinter->SetFont( aOldFont ); pPrinter->SetFont( aOldFont );
} }

View File

@@ -105,7 +105,10 @@ public:
virtual BOOL IsPasteAllowed(); virtual BOOL IsPasteAllowed();
virtual SfxUndoManager* GetUndoManager(); virtual SfxUndoManager* GetUndoManager();
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 void Deactivating(); virtual void Deactivating();
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();

View File

@@ -199,7 +199,9 @@ public:
SfxUndoManager* GetUndoManager(); SfxUndoManager* GetUndoManager();
virtual USHORT Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog = 0 ); virtual com::sun::star::uno::Reference< com::sun::star::view::XRenderable > GetRenderable();
// virtual USHORT Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog = 0 );
virtual SfxPrinter* GetPrinter( BOOL bCreate ); virtual SfxPrinter* GetPrinter( BOOL bCreate );
virtual USHORT SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false ); virtual USHORT SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
virtual String GetSelectionText( BOOL bCompleteWords ); virtual String GetSelectionText( BOOL bCompleteWords );

View File

@@ -215,9 +215,13 @@ public:
virtual void StoreData(); virtual void StoreData();
virtual void UpdateData(); virtual void UpdateData();
virtual void PrintData( Printer* pPrinter );
virtual BOOL CanClose(); virtual BOOL CanClose();
// return number of pages to be printed
virtual sal_Int32 countPages( Printer* pPrinter ) = 0;
// print page
virtual void printPage( sal_Int32 nPage, Printer* pPrinter ) = 0;
virtual String GetTitle(); virtual String GetTitle();
String CreateQualifiedName(); String CreateQualifiedName();
virtual BasicEntryDescriptor CreateEntryDescriptor() = 0; virtual BasicEntryDescriptor CreateEntryDescriptor() = 0;

View File

@@ -102,6 +102,8 @@ private:
DECL_LINK( PaintTimeout, Timer * ); DECL_LINK( PaintTimeout, Timer * );
DECL_LINK( MarkTimeout, Timer * ); DECL_LINK( MarkTimeout, Timer * );
void DlgEditor::Print( Printer* pPrinter, const String& rTitle );
protected: protected:
ScrollBar* pHScroll; ScrollBar* pHScroll;
ScrollBar* pVScroll; ScrollBar* pVScroll;
@@ -199,7 +201,8 @@ public:
void ShowProperties(); void ShowProperties();
void UpdatePropertyBrowserDelayed(); void UpdatePropertyBrowserDelayed();
void PrintData( Printer*, const String& rTitle ); // not working yet sal_Int32 countPages( Printer* pPrinter );
void printPage( sal_Int32 nPage, Printer* pPrinter, const String& );
bool AdjustPageSize(); bool AdjustPageSize();