#i92516# print with XRenderable API
This commit is contained in:
parent
5b16a85b74
commit
04e3607173
11 changed files with 86 additions and 39 deletions
|
@ -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 __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 );
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -207,13 +207,6 @@ void __EXPORT IDEBaseWindow::UpdateData()
|
|||
}
|
||||
|
||||
|
||||
|
||||
void __EXPORT IDEBaseWindow::PrintData( Printer* )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
String __EXPORT IDEBaseWindow::GetTitle()
|
||||
{
|
||||
return String();
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
@ -1304,8 +1317,6 @@ void DlgEditor::PrintData( Printer* pPrinter, const String& rTitle ) // not w
|
|||
aPaperSz.Width() -= (LMARGPRN+RMARGPRN);
|
||||
aPaperSz.Height() -= (TMARGPRN+BMARGPRN);
|
||||
|
||||
pPrinter->StartPage();
|
||||
|
||||
lcl_PrintHeader( pPrinter, rTitle );
|
||||
|
||||
Bitmap aDlg;
|
||||
|
@ -1350,8 +1361,6 @@ void DlgEditor::PrintData( Printer* pPrinter, const String& rTitle ) // not w
|
|||
|
||||
pPrinter->DrawBitmap( aPosOffs, aOutputSz, aDlg );
|
||||
|
||||
pPrinter->EndPage();
|
||||
|
||||
pPrinter->SetMapMode( aOldMap );
|
||||
pPrinter->SetFont( aOldFont );
|
||||
}
|
||||
|
|
|
@ -105,7 +105,10 @@ public:
|
|||
virtual BOOL IsPasteAllowed();
|
||||
|
||||
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 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
|
||||
|
|
|
@ -199,7 +199,9 @@ public:
|
|||
|
||||
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 USHORT SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
|
||||
virtual String GetSelectionText( BOOL bCompleteWords );
|
||||
|
|
|
@ -215,9 +215,13 @@ public:
|
|||
|
||||
virtual void StoreData();
|
||||
virtual void UpdateData();
|
||||
virtual void PrintData( Printer* pPrinter );
|
||||
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();
|
||||
String CreateQualifiedName();
|
||||
virtual BasicEntryDescriptor CreateEntryDescriptor() = 0;
|
||||
|
|
|
@ -102,6 +102,8 @@ private:
|
|||
DECL_LINK( PaintTimeout, Timer * );
|
||||
DECL_LINK( MarkTimeout, Timer * );
|
||||
|
||||
void DlgEditor::Print( Printer* pPrinter, const String& rTitle );
|
||||
|
||||
protected:
|
||||
ScrollBar* pHScroll;
|
||||
ScrollBar* pVScroll;
|
||||
|
@ -199,7 +201,8 @@ public:
|
|||
void ShowProperties();
|
||||
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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue