summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2009-05-19 11:32:44 +0000
committerPhilipp Lohmann <pl@openoffice.org>2009-05-19 11:32:44 +0000
commit04e36071737ccca11f77d2c943248b08d66e76d6 (patch)
tree316ffb0f826eebdd7c1789748ee3e3226e22f6d1
parent5b16a85b74f89bd4a57304b00bb0ac084d61d67b (diff)
#i92516# print with XRenderable API
-rw-r--r--basctl/source/basicide/baside2.cxx50
-rw-r--r--basctl/source/basicide/baside2.hxx7
-rw-r--r--basctl/source/basicide/baside3.cxx9
-rw-r--r--basctl/source/basicide/basides2.cxx10
-rw-r--r--basctl/source/basicide/bastypes.cxx7
-rw-r--r--basctl/source/basicide/makefile.mk3
-rw-r--r--basctl/source/dlged/dlged.cxx19
-rw-r--r--basctl/source/inc/baside3.hxx5
-rw-r--r--basctl/source/inc/basidesh.hxx4
-rw-r--r--basctl/source/inc/bastypes.hxx6
-rw-r--r--basctl/source/inc/dlged.hxx5
11 files changed, 86 insertions, 39 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 \
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index 6d1080ed659b..b4a6e67e65dc 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -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 );
}
diff --git a/basctl/source/inc/baside3.hxx b/basctl/source/inc/baside3.hxx
index a1585f083b34..223939390354 100644
--- a/basctl/source/inc/baside3.hxx
+++ b/basctl/source/inc/baside3.hxx
@@ -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();
diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx
index a6c865ae0ee4..2c9e4fe2b747 100644
--- a/basctl/source/inc/basidesh.hxx
+++ b/basctl/source/inc/basidesh.hxx
@@ -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 );
diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx
index ba1ac9c57068..6d6580776471 100644
--- a/basctl/source/inc/bastypes.hxx
+++ b/basctl/source/inc/bastypes.hxx
@@ -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;
diff --git a/basctl/source/inc/dlged.hxx b/basctl/source/inc/dlged.hxx
index 908331b0ad63..2d8420fe59be 100644
--- a/basctl/source/inc/dlged.hxx
+++ b/basctl/source/inc/dlged.hxx
@@ -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();