#i92516# migrate CWS printerpullpages to svn

This commit is contained in:
Philipp Lohmann 2008-10-01 18:22:22 +00:00
parent 9d58db011e
commit 91d8ce3ea9
22 changed files with 1419 additions and 134 deletions

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: aquaprintview.h,v $
* $Revision: 1.3 $
* $Revision: 1.3.114.1 $
*
* This file is part of OpenOffice.org.
*
@ -37,13 +37,14 @@
class ImplQPrinter;
class AquaSalInfoPrinter;
namespace vcl { class PrinterListener; }
@interface AquaPrintView : NSView
{
ImplQPrinter* mpQPrinter;
AquaSalInfoPrinter* mpInfoPrinter;
vcl::PrinterListener* mpListener;
AquaSalInfoPrinter* mpInfoPrinter;
}
-(id)initWithQPrinter: (ImplQPrinter*)pPrinter withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter;
-(id)initWithListener: (vcl::PrinterListener*)pListener withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter;
-(MacOSBOOL)knowsPageRange: (NSRangePointer)range;
-(NSRect)rectForPage: (int)page;
-(NSPoint)locationOfPrintRect: (NSRect)aRect;

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: salprn.h,v $
* $Revision: 1.12 $
* $Revision: 1.12.56.1 $
*
* This file is part of OpenOffice.org.
*
@ -104,10 +104,10 @@ class AquaSalInfoPrinter : public SalInfoPrinter
// so let's make AquaSalPrinter just a forwarder to AquaSalInfoPrinter
// and concentrate the real work in one class
// implement pull model print system
BOOL StartJob( const String* pFileName,
const String& rAppName,
ImplJobSetup* pSetupData,
ImplQPrinter* pQPrinter,
BOOL StartJob( const String* i_pFileName,
const String& i_rAppName,
ImplJobSetup* i_pSetupData,
vcl::PrinterListener& i_rListener,
bool bIsQuickJob );
BOOL EndJob();
BOOL AbortJob();
@ -142,10 +142,10 @@ class AquaSalPrinter : public SalPrinter
ULONG i_nCopies, BOOL i_bCollate,
ImplJobSetup* i_pSetupData );
// implement pull model print system
virtual BOOL StartJob( const String* pFileName,
const String& rAppName,
ImplJobSetup* pSetupData,
ImplQPrinter* pQPrinter );
virtual BOOL StartJob( const String* i_pFileName,
const String& i_rAppName,
ImplJobSetup* i_pSetupData,
vcl::PrinterListener& i_rListener );
virtual BOOL EndJob();
virtual BOOL AbortJob();

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: aquaprintview.mm,v $
* $Revision: 1.5 $
* $Revision: 1.5.56.1 $
*
* This file is part of OpenOffice.org.
*
@ -33,15 +33,15 @@
#include "aquaprintview.h"
#include "salprn.h"
#include "vcl/impprn.hxx"
#include "vcl/print.hxx"
@implementation AquaPrintView
-(id)initWithQPrinter: (ImplQPrinter*)pPrinter withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter
-(id)initWithListener: (vcl::PrinterListener*)pListener withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter
{
NSRect aRect = { { 0, 0 }, [pInfoPrinter->getPrintInfo() paperSize] };
if( (self = [super initWithFrame: aRect]) != nil )
{
mpQPrinter = pPrinter;
mpListener = pListener;
mpInfoPrinter = pInfoPrinter;
}
return self;
@ -76,6 +76,6 @@
int nPage = (int)(aPaperSize.width * rect.origin.y + rect.origin.x);
// page count is 1 based
mpQPrinter->PrintPage( nPage-1 + mpInfoPrinter->getCurPageRangeStart() );
mpListener->printFilteredPage( nPage-1 );
}
@end

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: salprn.cxx,v $
* $Revision: 1.16 $
* $Revision: 1.16.56.2 $
*
* This file is part of OpenOffice.org.
*
@ -125,8 +125,8 @@ void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const
if( mePageOrientation == ORIENTATION_PORTRAIT )
{
double dX = 0, dY = aPaperSize.height;
dX += [mpPrintInfo leftMargin];
dY -= [mpPrintInfo topMargin];
// dX += [mpPrintInfo leftMargin];
// dY -= [mpPrintInfo topMargin];
CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetX, dY - mnStartPageOffsetY );
CGContextScaleCTM( i_rContext, 0.1, -0.1 );
}
@ -134,8 +134,8 @@ void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const
{
CGContextRotateCTM( i_rContext, M_PI/2 );
double dX = aPaperSize.height, dY = -aPaperSize.width;
dY += [mpPrintInfo topMargin];
dX -= [mpPrintInfo rightMargin];
// dY += [mpPrintInfo topMargin];
// dX -= [mpPrintInfo rightMargin];
CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetY, dY - mnStartPageOffsetX );
CGContextScaleCTM( i_rContext, -0.1, 0.1 );
@ -447,77 +447,68 @@ void AquaSalInfoPrinter::GetPageInfo( const ImplJobSetup*,
}
}
BOOL AquaSalInfoPrinter::StartJob( const String* pFileName,
const String& rAppName,
ImplJobSetup* pSetupData,
ImplQPrinter* pQPrinter,
BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName,
const String& i_rAppName,
ImplJobSetup* i_pSetupData,
vcl::PrinterListener& i_rListener,
bool bIsQuickJob )
{
if( mbJob )
return FALSE;
BOOL bSuccess = FALSE;
std::vector<ULONG> aPaperRanges;
if( ! pQPrinter->GetPaperRanges( aPaperRanges, true ) )
return FALSE;
size_t nRanges = aPaperRanges.size();
// FIXME: make paper ranges work again
mnCurPageRangeStart = 1;
mnCurPageRangeCount = i_rListener.getPageCount();
AquaSalInstance* pInst = GetSalData()->mpFirstInstance;
for( ULONG nCurRange = 0; nCurRange < nRanges-1; nCurRange++ )
mnStartPageOffsetX = mnStartPageOffsetY = 0;
// update job data
if( i_pSetupData )
SetData( ~0, i_pSetupData );
// create view
NSView* pPrintView = [[AquaPrintView alloc] initWithListener: &i_rListener withInfoPrinter: this];
NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary];
// set filename
if( i_pFileName )
{
mnStartPageOffsetX = mnStartPageOffsetY = 0;
// update job data
ImplJobSetup* pSetup = pQPrinter->GetPageSetup( aPaperRanges[ nCurRange ] );
if( pSetup )
SetData( ~0, pSetup );
DBG_ASSERT( pSetup, "no job setup for range" );
mnCurPageRangeStart = aPaperRanges[nCurRange];
mnCurPageRangeCount = aPaperRanges[nCurRange+1] - aPaperRanges[nCurRange];
// create view
NSView* pPrintView = [[AquaPrintView alloc] initWithQPrinter: pQPrinter withInfoPrinter: this];
NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary];
// set filename
if( pFileName )
{
[mpPrintInfo setJobDisposition: NSPrintSaveJob];
NSString* pPath = CreateNSString( *pFileName );
[pPrintDict setObject: pPath forKey: NSPrintSavePath];
[pPath release];
// in this case we can only deliver the print job in one file
mnCurPageRangeStart = 0;
mnCurPageRangeCount = aPaperRanges.back();
nCurRange = nRanges;
}
[pPrintDict setObject: [[NSNumber numberWithInt: (int)pQPrinter->GetCopyCount()] autorelease] forKey: NSPrintCopies];
[pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting];
[pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage];
[pPrintDict setObject: [[NSNumber numberWithInt: (int)mnCurPageRangeCount] autorelease] forKey: NSPrintLastPage];
// create print operation
NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo];
if( pPrintOperation )
{
bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() );
[pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ];
// [pPrintOperation setShowsProgressPanel: NO];
bSuccess = TRUE;
mbJob = true;
pInst->startedPrintJob();
[pPrintOperation runOperation];
pInst->endedPrintJob();
mbJob = false;
}
[mpPrintInfo setJobDisposition: NSPrintSaveJob];
NSString* pPath = CreateNSString( *i_pFileName );
[pPrintDict setObject: pPath forKey: NSPrintSavePath];
[pPath release];
}
// FIXME copies
// [pPrintDict setObject: [[NSNumber numberWithInt: (int)pQPrinter->GetCopyCount()] autorelease] forKey: NSPrintCopies];
[pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting];
[pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage];
[pPrintDict setObject: [[NSNumber numberWithInt: mnCurPageRangeCount] autorelease] forKey: NSPrintLastPage];
// create print operation
NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo];
if( pPrintOperation )
{
bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() );
[pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ];
[pPrintOperation setShowsProgressPanel: bShowPanel ? YES : NO];
bSuccess = TRUE;
mbJob = true;
pInst->startedPrintJob();
[pPrintOperation runOperation];
pInst->endedPrintJob();
mbJob = false;
}
mnCurPageRangeStart = mnCurPageRangeCount = 0;
return bSuccess;
}
@ -583,22 +574,22 @@ AquaSalPrinter::~AquaSalPrinter()
// -----------------------------------------------------------------------
BOOL AquaSalPrinter::StartJob( const String* pFileName,
const String& rAppName,
ImplJobSetup* pSetupData,
ImplQPrinter* pQPrinter )
BOOL AquaSalPrinter::StartJob( const String* i_pFileName,
const String& i_rAppName,
ImplJobSetup* i_pSetupData,
vcl::PrinterListener& i_rListener )
{
bool bIsQuickJob = false;
std::hash_map< rtl::OUString, rtl::OUString, rtl::OUStringHash >::const_iterator quick_it =
pSetupData->maValueMap.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) );
i_pSetupData->maValueMap.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) );
if( quick_it != pSetupData->maValueMap.end() )
if( quick_it != i_pSetupData->maValueMap.end() )
{
if( quick_it->second.equalsIgnoreAsciiCaseAscii( "true" ) )
bIsQuickJob = true;
}
return mpInfoPrinter->StartJob( pFileName, rAppName, pSetupData, pQPrinter, bIsQuickJob );
return mpInfoPrinter->StartJob( i_pFileName, i_rAppName, i_pSetupData, i_rListener, bIsQuickJob );
}
// -----------------------------------------------------------------------

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: print.h,v $
* $Revision: 1.4 $
* $Revision: 1.4.114.2 $
*
* This file is part of OpenOffice.org.
*
@ -31,15 +31,18 @@
#ifndef _SV_PRINT_H
#define _SV_PRINT_H
#include <tools/list.hxx>
#include <vcl/sv.h>
#include <vcl/dllapi.h>
#include "vcl/sv.h"
#include "vcl/dllapi.h"
#include <vector>
#include <hash_map>
struct SalPrinterQueueInfo;
class QueueInfo;
class JobSetup;
namespace vcl
{ class PrinterListener; }
// ------------------------
// - private printer data -
@ -87,5 +90,7 @@ public:
// --------------
void ImplDeletePrnQueueList();
void SAL_DLLPRIVATE ImplUpdateJobSetupPaper( JobSetup& rJobSetup );
#endif // _SV_PRINT_H

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: print.hxx,v $
* $Revision: 1.6 $
* $Revision: 1.6.114.5 $
*
* This file is part of OpenOffice.org.
*
@ -31,14 +31,19 @@
#ifndef _SV_PRINT_HXX
#define _SV_PRINT_HXX
#include <tools/errcode.hxx>
#include <vcl/sv.h>
#include <vcl/dllapi.h>
#include <vcl/outdev.hxx>
#include <vcl/prntypes.hxx>
#include <vcl/jobset.hxx>
#include <vcl/gdimtf.hxx>
#include <tools/stream.hxx>
#include "tools/errcode.hxx"
#include "vcl/sv.h"
#include "vcl/dllapi.h"
#include "vcl/outdev.hxx"
#include "vcl/prntypes.hxx"
#include "vcl/jobset.hxx"
#include "vcl/gdimtf.hxx"
#include "tools/stream.hxx"
#include "tools/multisel.hxx"
#include "com/sun/star/beans/XPropertySet.hpp"
#include <boost/shared_ptr.hpp>
struct SalPrinterInfoQueue;
class SalInfoPrinter;
@ -47,12 +52,12 @@ class SalPrinter;
class VirtualDevice;
class Window;
class ImplQPrinter;
class RmPrinter;
struct ImplPrivatePrinterData;
namespace com { namespace sun { namespace star { namespace uno {
class Any;
} } } }
namespace vcl {
class PrinterListener;
class PrintDialog;
}
// -----------------
// - Printer-Types -
@ -264,6 +269,11 @@ private:
SAL_DLLPRIVATE void ImplUpdateFontList();
SAL_DLLPRIVATE void ImplFindPaperFormatForUserSize( JobSetup& );
DECL_DLLPRIVATE_LINK( ImplDestroyPrinterAsync, void* );
SAL_DLLPRIVATE bool StartJob( const XubString& rJobName, boost::shared_ptr<vcl::PrinterListener>& );
static SAL_DLLPRIVATE ULONG ImplSalPrinterErrorCodeToVCL( ULONG nError );
public:
SAL_DLLPRIVATE void ImplEndPrint();
SAL_DLLPRIVATE void ImplUpdateQuickStatus();
@ -421,6 +431,62 @@ public:
* if the printer list changed
*/
static void updatePrinters();
/** execute a print job
starts a print job asynchronously (that is will return
*/
static void PrintJob( const boost::shared_ptr<vcl::PrinterListener>& i_pListener,
const JobSetup& i_rInitSetup,
const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& i_xJobOptions
);
// implementation detail of PrintJob being asynchronous
// not exported, not usable outside vcl
static void SAL_DLLPRIVATE ImplPrintJob( const boost::shared_ptr<vcl::PrinterListener>& i_pListener,
const JobSetup& i_rInitSetup,
const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& i_xJobOptions
);
};
namespace vcl
{
class ImplPrinterListenerData;
class VCL_DLLPUBLIC PrinterListener
{
ImplPrinterListenerData* mpImplData;
public:
PrinterListener();
virtual ~PrinterListener();
const boost::shared_ptr<Printer>& getPrinter() const;
const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& getJobParameters() const;
const MultiSelection& getPageSelection() const;
virtual int getPageCount() const = 0; // must be overloaded by the app
/* get the page parameters, namely the jobsetup that should be active for the page
(describing among others the physical page size) and the "page size". In writer
case this would probably be the same as the JobSetup since writer sets the page size
draw/impress for example print their page on the paper set on the printer,
possibly adjusting the page size to fit. That means the page size can be different from
the paper size.
*/
virtual void getPageParameters( int i_nPage, JobSetup& o_rPageSetup, Size& o_rPageSize ) const = 0; // must be overloaded by the app, return page size in 1/100th mm
virtual void printPage( int i_nPage ) const = 0; // must be overloaded by the app
virtual void setListeners(); // optionally set listeners on mxJobParameters
virtual void jobFinished(); // optionally release resources bound to the job
void printFilteredPage( int i_nPage );
// implementation details, not usable outsid vcl
void SAL_DLLPRIVATE setPrinter( const boost::shared_ptr<Printer>& );
void SAL_DLLPRIVATE setJobParameters( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& );
void SAL_DLLPRIVATE setPageSelection( const MultiSelection& );
};
}
#endif // _SV_PRINT_HXX

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: prndlg.hxx,v $
* $Revision: 1.3 $
* $Revision: 1.3.114.5 $
*
* This file is part of OpenOffice.org.
*
@ -33,19 +33,122 @@
#include <vcl/dllapi.h>
#include <vcl/dialog.hxx>
#include "vcl/print.hxx"
#include "vcl/print.h"
class Printer;
#include "vcl/dialog.hxx"
#include "vcl/fixed.hxx"
#include "vcl/button.hxx"
#include "vcl/scrbar.hxx"
#include "vcl/gdimtf.hxx"
#include "vcl/lstbox.hxx"
#include "vcl/field.hxx"
#include "vcl/tabctrl.hxx"
#include "vcl/tabpage.hxx"
class VCL_DLLPUBLIC SystemDialog : public ModalDialog
#include "tools/multisel.hxx"
#include <boost/shared_ptr.hpp>
namespace vcl
{
public:
SystemDialog( Window* pParent, WinBits nWinStyle ) :
ModalDialog( pParent, nWinStyle ) {}
SystemDialog( Window* pParent, const ResId& rResId ) :
ModalDialog( pParent, rResId ) {}
class PrintDialog : public ModalDialog
{
class PrintPreviewWindow : public Window
{
GDIMetaFile maMtf;
public:
PrintPreviewWindow( Window* pParent, const ResId& );
virtual ~PrintPreviewWindow();
virtual void Paint( const Rectangle& rRect );
void setPreview( const GDIMetaFile& );
};
class PrinterTabPage : public TabPage
{
public:
ListBox maPrinters;
PushButton maSetupButton;
FixedText maType;
FixedText maTypeText;
FixedText maStatus;
FixedText maStatusText;
FixedText maLocation;
FixedText maLocText;
FixedText maComment;
FixedText maCommentText;
CheckBox maToFileBox;
PrinterTabPage( Window*, const ResId& );
virtual ~PrinterTabPage();
};
class JobTabPage : public TabPage
{
public:
FixedLine maPrintRange;
RadioButton maAllButton;
RadioButton maPagesButton;
RadioButton maSelectionButton;
Edit maPagesEdit;
FixedLine maCopies;
FixedText maCopyCount;
NumericField maCopyCountField;
CheckBox maCollateBox;
FixedImage maCollateImage;
Image maCollateImg;
Image maCollateHCImg;
Image maNoCollateImg;
Image maNoCollateHCImg;
JobTabPage( Window*, const ResId& );
virtual ~JobTabPage();
};
OKButton maOKButton;
CancelButton maCancelButton;
PrintPreviewWindow maPreviewWindow;
FixedText maPageText;
ScrollBar maPageScrollbar;
TabControl maTabCtrl;
PrinterTabPage maPrinterPage;
JobTabPage maJobPage;
FixedLine maButtonLine;
boost::shared_ptr< PrinterListener > maPListener;
rtl::OUString maPageStr;
sal_Int32 mnCurPage;
sal_Int32 mnCachedPages;
Rectangle maPreviewSpace;
void preparePreview();
void setPreviewText( sal_Int32 );
void updatePrinterText();
void checkControlDependencies();
DECL_LINK( ScrollHdl, ScrollBar* );
DECL_LINK( ScrollEndHdl, ScrollBar* );
DECL_LINK( SelectHdl, ListBox* );
DECL_LINK( ClickHdl, Button* );
DECL_LINK( ModifyHdl, Edit* );
public:
PrintDialog( Window*, const boost::shared_ptr< PrinterListener >& );
virtual ~PrintDialog();
bool isPrintToFile();
MultiSelection getPageSelection();
int getCopyCount();
bool isCollate();
};
}
virtual short Execute() { return 0; }
};
#endif // _SV_PRNDLG_HXX

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: salprn.hxx,v $
* $Revision: 1.5 $
* $Revision: 1.5.114.1 $
*
* This file is part of OpenOffice.org.
*
@ -41,7 +41,7 @@
class SalGraphics;
class SalFrame;
struct ImplJobSetup;
class ImplQPrinter;
namespace vcl { class PrinterListener; }
// -----------------------
// - SalPrinterQueueInfo -
@ -125,7 +125,7 @@ public: // public for Sal Implementation
virtual BOOL StartJob( const String* pFileName,
const String& rAppName,
ImplJobSetup* pSetupData,
ImplQPrinter* pQPrinter );
vcl::PrinterListener& rListener );
virtual BOOL EndJob() = 0;
virtual BOOL AbortJob() = 0;

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: svdata.hxx,v $
* $Revision: 1.13 $
* $Revision: 1.13.16.1 $
*
* This file is part of OpenOffice.org.
*
@ -352,6 +352,7 @@ void ImplDeInitSVData();
void ImplDestroySVData();
Window* ImplGetDefaultWindow();
VCL_DLLPUBLIC ResMgr* ImplGetResMgr();
VCL_DLLPUBLIC ResId VclResId( sal_Int32 nId ); // throws std::bad_alloc if no res mgr
DockingManager* ImplGetDockingManager();
void ImplWindowAutoMnemonic( Window* pWindow );

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: svids.hrc,v $
* $Revision: 1.8 $
* $Revision: 1.8.84.3 $
*
* This file is part of OpenOffice.org.
*
@ -73,6 +73,44 @@
#define SV_MENU_MAC_SHOWALL 2005
#define SV_MENU_MAC_QUITAPP 2006
#define SV_DLG_PRINT 2048
#define SV_PRINT_OK 1
#define SV_PRINT_CANCEL 2
#define SV_PRINT_PAGE_TXT 3
#define SV_PRINT_PAGE_PREVIEW 4
#define SV_PRINT_PAGE_SCROLL 5
#define SV_PRINT_TABCTRL 6
#define SV_PRINT_TAB_PRINTER 1
#define SV_PRINT_PRINTERS 1
#define SV_PRINT_PRT_TYPE 2
#define SV_PRINT_PRT_TYPE_TXT 3
#define SV_PRINT_PRT_STATUS 4
#define SV_PRINT_PRT_STATUS_TXT 5
#define SV_PRINT_PRT_LOCATION 6
#define SV_PRINT_PRT_LOCATION_TXT 7
#define SV_PRINT_PRT_COMMENT 8
#define SV_PRINT_PRT_COMMENT_TXT 9
#define SV_PRINT_PRT_TOFILE 10
#define SV_PRINT_PRT_SETUP 11
#define SV_PRINT_TAB_JOB 2
#define SV_PRINT_RANGE 1
#define SV_PRINT_ALL 2
#define SV_PRINT_PAGERANGE 3
#define SV_PRINT_SELECTION 4
#define SV_PRINT_PAGERANGE_EDIT 5
#define SV_PRINT_COPIES 6
#define SV_PRINT_COPYCOUNT 7
#define SV_PRINT_COPYCOUNT_FIELD 8
#define SV_PRINT_COLLATE 9
#define SV_PRINT_COLLATE_IMAGE 10
#define SV_PRINT_BUTTONLINE 11
#define SV_PRINT_COLLATE_IMG 12
#define SV_PRINT_NOCOLLATE_IMG 13
#define SV_PRINT_COLLATE_HC_IMG 14
#define SV_PRINT_NOCOLLATE_HC_IMG 15
#define SV_HELPTEXT_CLOSE 10000
#define SV_HELPTEXT_MINIMIZE 10001
#define SV_HELPTEXT_MAXIMIZE 10002
@ -107,7 +145,8 @@
#define SV_STDTEXT_ABOUT 10204
#define SV_STDTEXT_PREFERENCES 10205
#define SV_MAC_SCREENNNAME 10206
#define SV_STDTEXT_LAST SV_MAC_SCREENNNAME
#define SV_STDTEXT_ALLFILETYPES 10207
#define SV_STDTEXT_LAST SV_STDTEXT_ALLFILETYPES
#define SV_ACCESSERROR_FIRST SV_ACCESSERROR_WRONG_VERSION
#define SV_ACCESSERROR_WRONG_VERSION 10500

View file

@ -87,7 +87,6 @@ mkdir: %_DEST%\inc%_EXT%\vcl\plug\vcl
..\inc\vcl\outdev3d.hxx %_DEST%\inc%_EXT%\vcl\outdev3d.hxx
..\inc\vcl\pointr.hxx %_DEST%\inc%_EXT%\vcl\pointr.hxx
..\inc\vcl\print.hxx %_DEST%\inc%_EXT%\vcl\print.hxx
..\inc\vcl\prndlg.hxx %_DEST%\inc%_EXT%\vcl\prndlg.hxx
..\inc\vcl\prntypes.hxx %_DEST%\inc%_EXT%\vcl\prntypes.hxx
..\inc\vcl\ptrstyle.hxx %_DEST%\inc%_EXT%\vcl\ptrstyle.hxx
..\inc\vcl\regband.hxx %_DEST%\inc%_EXT%\vcl\regband.hxx

View file

@ -91,7 +91,7 @@ SalPrinter::~SalPrinter()
}
BOOL SalPrinter::StartJob( const String*, const String&,
ImplJobSetup*, ImplQPrinter* )
ImplJobSetup*, vcl::PrinterListener& )
{
return FALSE;
}

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: svdata.cxx,v $
* $Revision: 1.56 $
* $Revision: 1.56.114.1 $
*
* This file is part of OpenOffice.org.
*
@ -220,6 +220,15 @@ ResMgr* ImplGetResMgr()
return pSVData->mpResMgr;
}
ResId VclResId( sal_Int32 nId )
{
ResMgr* pMgr = ImplGetResMgr();
if( ! pMgr )
throw std::bad_alloc();
return ResId( nId, *pMgr );
}
DockingManager* ImplGetDockingManager()
{
ImplSVData* pSVData = ImplGetSVData();

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: impprn.cxx,v $
* $Revision: 1.19 $
* $Revision: 1.19.54.1 $
*
* This file is part of OpenOffice.org.
*
@ -464,10 +464,12 @@ void ImplQPrinter::EndQueuePrint()
DBG_ASSERT( mpPrinter, "no SalPrinter in ImplQPrinter" );
if( mpPrinter )
{
#if 0
mpPrinter->StartJob( mbPrintFile ? &maPrintFile : NULL,
Application::GetDisplayName(),
maJobSetup.ImplGetConstData(),
this );
#endif
EndJob();
mpParent->ImplEndPrint();
}

View file

@ -8,7 +8,7 @@
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.33 $
# $Revision: 1.33.92.1 $
#
# This file is part of OpenOffice.org.
#
@ -96,6 +96,7 @@ SLOFILES= $(SLO)$/salmisc.obj \
$(SLO)$/fontcvt.obj \
$(SLO)$/print.obj \
$(SLO)$/print2.obj \
$(SLO)$/print3.obj \
$(SLO)$/regband.obj \
$(SLO)$/region.obj \
$(SLO)$/wall.obj \
@ -121,6 +122,7 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \
$(SLO)$/gfxlink.obj \
$(SLO)$/print.obj \
$(SLO)$/print2.obj \
$(SLO)$/print3.obj \
$(SLO)$/sallayout.obj \
$(SLO)$/image.obj \
$(SLO)$/impimage.obj \

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: print.cxx,v $
* $Revision: 1.65 $
* $Revision: 1.65.114.1 $
*
* This file is part of OpenOffice.org.
*
@ -1309,7 +1309,7 @@ void Printer::PrintPage()
// -----------------------------------------------------------------------
ULONG ImplSalPrinterErrorCodeToVCL( ULONG nError )
ULONG Printer::ImplSalPrinterErrorCodeToVCL( ULONG nError )
{
ULONG nVCLError;
switch ( nError )

408
vcl/source/gdi/print3.cxx Normal file
View file

@ -0,0 +1,408 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: print3.cxx,v $
* $Revision: 1.1.2.11 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "precompiled_vcl.hxx"
#include "vcl/print.hxx"
#include "vcl/prndlg.hxx"
#include "vcl/svapp.hxx"
#include "vcl/svdata.hxx"
#include "vcl/salinst.hxx"
#include "vcl/salprn.hxx"
#include "vcl/svids.hrc"
#include "tools/urlobj.hxx"
#include "tools/multisel.hxx"
#include "com/sun/star/ui/dialogs/XFilePicker.hpp"
#include "com/sun/star/ui/dialogs/XFilterManager.hpp"
#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
#include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp"
#include "com/sun/star/lang/XMultiServiceFactory.hpp"
#include "comphelper/processfactory.hxx"
using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace vcl;
class vcl::ImplPrinterListenerData
{
public:
boost::shared_ptr<Printer> mpPrinter;
com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > mxJobParameters;
MultiSelection maSelection;
};
PrinterListener::PrinterListener()
: mpImplData( new ImplPrinterListenerData )
{
}
static rtl::OUString queryFile( Printer* pPrinter )
{
rtl::OUString aResult;
uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
if( xFactory.is() )
{
uno::Sequence< uno::Any > aTempl( 1 );
aTempl.getArray()[0] <<= ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION;
uno::Reference< ui::dialogs::XFilePicker > xFilePicker(
xFactory->createInstanceWithArguments(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ),
aTempl ), uno::UNO_QUERY );
DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
uno::Reference< ui::dialogs::XFilterManager > xFilterMgr( xFilePicker, uno::UNO_QUERY );
if( xFilePicker.is() && xFilterMgr.is() )
{
try
{
#ifdef UNX
// add PostScript and PDF
bool bPS = true, bPDF = true;
if( pPrinter )
{
if( pPrinter->GetCapabilities( PRINTER_CAPABILITIES_PDF ) )
bPS = false;
else
bPDF = false;
}
if( bPS )
xFilterMgr->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PostScript" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.ps" ) ) );
if( bPDF )
xFilterMgr->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Portable Document Format" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.pdf" ) ) );
#elif defined WNT
(void)pPrinter;
xFilterMgr->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.PRN" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.prn" ) ) );
#endif
// add arbitrary files
xFilterMgr->appendFilter( String( VclResId( SV_STDTEXT_ALLFILETYPES ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) ) );
}
catch( lang::IllegalArgumentException rExc )
{
DBG_ERRORFILE( "caught IllegalArgumentException when registering filter\n" );
}
if( xFilePicker->execute() == ui::dialogs::ExecutableDialogResults::OK )
{
uno::Sequence< ::rtl::OUString > aPathSeq( xFilePicker->getFiles() );
INetURLObject aObj( aPathSeq[0] );
aResult = aObj.PathToFileName();
}
}
}
return aResult;
}
struct PrintJobAsync
{
boost::shared_ptr<PrinterListener> mpListener;
JobSetup maInitSetup;
Reference< beans::XPropertySet > mxJobOptions;
PrintJobAsync( const boost::shared_ptr<PrinterListener>& i_pListener,
const JobSetup& i_rInitSetup,
const Reference< beans::XPropertySet >& i_xJobOptions
)
: mpListener( i_pListener ), maInitSetup( i_rInitSetup ), mxJobOptions( i_xJobOptions )
{}
DECL_LINK( ExecJob, void* );
};
IMPL_LINK( PrintJobAsync, ExecJob, void*, EMPTYARG )
{
Printer::ImplPrintJob( mpListener, maInitSetup, mxJobOptions );
// clean up, do not access members after this
delete this;
return 0;
}
void Printer::PrintJob( const boost::shared_ptr<PrinterListener>& i_pListener,
const JobSetup& i_rInitSetup,
const Reference< beans::XPropertySet >& i_xJobOptions
)
{
PrintJobAsync* pAsync = new PrintJobAsync( i_pListener, i_rInitSetup, i_xJobOptions );
Application::PostUserEvent( LINK( pAsync, PrintJobAsync, ExecJob ) );
}
void Printer::ImplPrintJob( const boost::shared_ptr<PrinterListener>& i_pListener,
const JobSetup& i_rInitSetup,
const Reference< beans::XPropertySet >& /*i_xJobOptions*/
)
{
// setup printer
boost::shared_ptr<PrinterListener> pListener( i_pListener );
boost::shared_ptr<Printer> pPrinter( new Printer( i_rInitSetup.GetPrinterName() ) );
pListener->setPrinter( pPrinter );
// setup page range selection
MultiSelection aSel;
int nPages = i_pListener->getPageCount();
aSel.SetTotalRange( Range( 1, nPages ) );
aSel.SelectAll();
// check if the printer brings up its own dialog
// in that case leave the work to that dialog
if( ! pListener->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) )
{
try
{
PrintDialog aDlg( NULL, i_pListener );
if( ! aDlg.Execute() )
return;
if( aDlg.isPrintToFile() )
{
rtl::OUString aFile = queryFile( pListener->getPrinter().get() );
if( ! aFile.getLength() )
return;
pListener->getPrinter()->EnablePrintFile( TRUE );
pListener->getPrinter()->SetPrintFile( aFile );
}
aSel = aDlg.getPageSelection();
pListener->getPrinter()->SetCopyCount( aDlg.getCopyCount(), aDlg.isCollate() );
}
catch( std::bad_alloc& )
{
}
}
pListener->setPageSelection( aSel );
pListener->getPrinter()->StartJob( String( RTL_CONSTASCII_USTRINGPARAM( "FIXME: no job name" ) ),
pListener );
pListener->jobFinished();
}
bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptr<vcl::PrinterListener>& i_pListener )
{
mnError = PRINTER_OK;
if ( IsDisplayPrinter() )
return FALSE;
if ( IsJobActive() || IsPrinting() )
return FALSE;
if( mpPrinterData->mbNextJobIsQuick )
{
String aKey( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) );
if( maJobSetup.GetValue( aKey ).Len() == 0 )
maJobSetup.SetValue( aKey, String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) );
}
ULONG nCopies = mnCopyCount;
BOOL bCollateCopy = mbCollateCopy;
BOOL bUserCopy = FALSE;
if ( nCopies > 1 )
{
ULONG nDevCopy;
if ( bCollateCopy )
nDevCopy = GetCapabilities( PRINTER_CAPABILITIES_COLLATECOPIES );
else
nDevCopy = GetCapabilities( PRINTER_CAPABILITIES_COPIES );
// Muessen Kopien selber gemacht werden?
if ( nCopies > nDevCopy )
{
bUserCopy = TRUE;
nCopies = 1;
bCollateCopy = FALSE;
}
}
else
bCollateCopy = FALSE;
ImplSVData* pSVData = ImplGetSVData();
mpPrinter = pSVData->mpDefInst->CreatePrinter( mpInfoPrinter );
if ( !mpPrinter )
return FALSE;
XubString* pPrintFile;
if ( mbPrintFile )
pPrintFile = &maPrintFile;
else
pPrintFile = NULL;
maJobName = i_rJobName;
mnCurPage = 1;
mnCurPrintPage = 1;
mbPrinting = TRUE;
if( ImplGetSVData()->maGDIData.mbPrinterPullModel )
{
mbJobActive = TRUE;
// sallayer does all necesseary page printing
if( mpPrinter->StartJob( pPrintFile,
Application::GetDisplayName(),
maJobSetup.ImplGetConstData(),
*i_pListener ) )
{
EndJob();
}
else
{
mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() );
if ( !mnError )
mnError = PRINTER_GENERALERROR;
pSVData->mpDefInst->DestroyPrinter( mpPrinter );
mnCurPage = 0;
mnCurPrintPage = 0;
mbPrinting = FALSE;
mpPrinter = NULL;
return false;
}
}
else
{
if( mpPrinter->StartJob( pPrintFile,
i_rJobName,
Application::GetDisplayName(),
nCopies, bCollateCopy,
maJobSetup.ImplGetConstData() ) )
{
mbJobActive = TRUE;
MultiSelection aSel( i_pListener->getPageSelection() );
for( long nPage = aSel.FirstSelected(); nPage != long(SFX_ENDOFSELECTION); nPage = aSel.NextSelected() )
{
// remember MultiSelection is 1 based (due to user input)
i_pListener->printFilteredPage( static_cast<int>(nPage-1) );
}
EndJob();
}
else
{
mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() );
if ( !mnError )
mnError = PRINTER_GENERALERROR;
pSVData->mpDefInst->DestroyPrinter( mpPrinter );
mnCurPage = 0;
mnCurPrintPage = 0;
mbPrinting = FALSE;
mpPrinter = NULL;
return false;
}
}
return true;
}
PrinterListener::~PrinterListener()
{
delete mpImplData;
}
const boost::shared_ptr<Printer>& PrinterListener::getPrinter() const
{
return mpImplData->mpPrinter;
}
const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& PrinterListener::getJobParameters() const
{
return mpImplData->mxJobParameters;
}
const MultiSelection& PrinterListener::getPageSelection() const
{
return mpImplData->maSelection;
}
void PrinterListener::setPrinter( const boost::shared_ptr<Printer>& i_rPrinter )
{
mpImplData->mpPrinter = i_rPrinter;
}
void PrinterListener::setJobParameters( const Reference< beans::XPropertySet >& i_pParams )
{
mpImplData->mxJobParameters = i_pParams;
}
void PrinterListener::setPageSelection( const MultiSelection& i_rSel )
{
mpImplData->maSelection = i_rSel;
}
void PrinterListener::printFilteredPage( int i_nPage )
{
// get page parameters
JobSetup aPageSetup;
Size aPageSize;
getPageParameters( i_nPage, aPageSetup, aPageSize );
const MapMode aMapMode( MAP_100TH_MM );
mpImplData->mpPrinter->Push();
mpImplData->mpPrinter->EnableOutput( FALSE );
mpImplData->mpPrinter->SetMapMode( aMapMode );
GDIMetaFile aMtf;
aMtf.Record( mpImplData->mpPrinter.get() );
printPage( i_nPage );
aMtf.Stop();
aMtf.WindStart();
mpImplData->mpPrinter->Pop();
// FIXME: do transparency filtering here when vcl92 is integrated
mpImplData->mpPrinter->EnableOutput( TRUE );
if( aPageSetup != mpImplData->mpPrinter->GetJobSetup() ) // set new setup if changed
mpImplData->mpPrinter->SetJobSetup( aPageSetup );
// actually print the page
mpImplData->mpPrinter->StartPage();
mpImplData->mpPrinter->Push();
mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM );
aMtf.WindStart();
aMtf.Play( mpImplData->mpPrinter.get() );
mpImplData->mpPrinter->Pop();
mpImplData->mpPrinter->EndPage();
}
void PrinterListener::setListeners()
{
}
void PrinterListener::jobFinished()
{
}

View file

@ -8,7 +8,7 @@
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.8 $
# $Revision: 1.8.114.1 $
#
# This file is part of OpenOffice.org.
#
@ -47,7 +47,8 @@ SRC1FILES= images.src \
stdtext.src \
helptext.src \
units.src \
btntext.src
btntext.src \
print.src
RESLIB1NAME= $(RESTARGET)
RESLIB1IMAGES= $(PRJ)$/source/src

247
vcl/source/src/print.src Normal file
View file

@ -0,0 +1,247 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: print.src,v $
* $Revision: 1.1.2.4 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "vcl/svids.hrc"
ModalDialog SV_DLG_PRINT
{
Text [en-US] = "Printing";
Closeable = TRUE;
Sizeable = FALSE;
Moveable = TRUE;
SVLook = TRUE;
Size = MAP_APPFONT( 350, 195 );
OKButton SV_PRINT_OK
{
DefButton = TRUE;
Pos = MAP_APPFONT( 240, 175 );
Size = MAP_APPFONT( 50, 15 );
};
CancelButton SV_PRINT_CANCEL
{
Pos = MAP_APPFONT( 295, 175 );
Size = MAP_APPFONT( 50, 15 );
};
Window SV_PRINT_PAGE_PREVIEW
{
Pos = MAP_APPFONT( 5, 5 );
Size = MAP_APPFONT( 130, 130 );
Border = TRUE;
};
ScrollBar SV_PRINT_PAGE_SCROLL
{
Pos = MAP_APPFONT( 5, 140 );
Size = MAP_APPFONT( 130, 10 );
SVLook = TRUE;
HScroll = TRUE;
TabStop = TRUE;
};
FixedText SV_PRINT_PAGE_TXT
{
Pos = MAP_APPFONT( 5,150 );
Size = MAP_APPFONT( 130, 10 );
Text [ en-US ] = "Page %p of %n";
Center = TRUE;
};
TabControl SV_PRINT_TABCTRL
{
Pos = MAP_APPFONT( 140, 5 );
Size = MAP_APPFONT( 205, 155 );
};
FixedLine SV_PRINT_BUTTONLINE
{
Pos = MAP_APPFONT( 0, 165 );
Size = MAP_APPFONT( 350, 8 );
};
TabPage SV_PRINT_TAB_PRINTER
{
Text [en-US] = "Printer";
Hide = TRUE;
ListBox SV_PRINT_PRINTERS
{
Pos = MAP_APPFONT( 5, 5 );
Size = MAP_APPFONT( 100, 200 );
DropDown = TRUE;
};
PushButton SV_PRINT_PRT_SETUP
{
Pos = MAP_APPFONT( 115, 5 );
Size = MAP_APPFONT( 50, 15 );
Text [en-US] = "Properties...";
};
FixedText SV_PRINT_PRT_TYPE
{
Pos = MAP_APPFONT( 5, 30 );
Size = MAP_APPFONT( 40, 10 );
Text [en-US] = "Type";
};
FixedText SV_PRINT_PRT_TYPE_TXT
{
Pos = MAP_APPFONT( 50, 30 );
Size = MAP_APPFONT( 200, 10 );
};
FixedText SV_PRINT_PRT_STATUS
{
Pos = MAP_APPFONT( 5, 42 );
Size = MAP_APPFONT( 40, 10 );
Text [en-US] = "Status";
};
FixedText SV_PRINT_PRT_STATUS_TXT
{
Pos = MAP_APPFONT( 50, 42 );
Size = MAP_APPFONT( 200, 10 );
};
FixedText SV_PRINT_PRT_LOCATION
{
Pos = MAP_APPFONT( 5, 54 );
Size = MAP_APPFONT( 40, 10 );
Text [en-US] = "Location";
};
FixedText SV_PRINT_PRT_LOCATION_TXT
{
Pos = MAP_APPFONT( 50, 54 );
Size = MAP_APPFONT( 200, 10 );
};
FixedText SV_PRINT_PRT_COMMENT
{
Pos = MAP_APPFONT( 5, 66 );
Size = MAP_APPFONT( 40, 10 );
Text [en-US] = "Comment";
};
FixedText SV_PRINT_PRT_COMMENT_TXT
{
Pos = MAP_APPFONT( 50, 66 );
Size = MAP_APPFONT( 200, 10 );
};
CheckBox SV_PRINT_PRT_TOFILE
{
Pos = MAP_APPFONT( 5, 80 );
Size = MAP_APPFONT( 200, 12 );
Text [en-US] = "Print to file";
};
};
TabPage SV_PRINT_TAB_JOB
{
Text [en-US] = "Job Setup";
Hide = TRUE;
FixedLine SV_PRINT_RANGE
{
Pos = MAP_APPFONT( 5, 5 );
Size = MAP_APPFONT( 150, 10 );
Text [en-US] = "Print range";
};
RadioButton SV_PRINT_ALL
{
Pos = MAP_APPFONT( 10, 15 );
Size = MAP_APPFONT( 145, 15 );
Text [en-US] = "All pages";
Check = TRUE;
};
RadioButton SV_PRINT_PAGERANGE
{
Pos = MAP_APPFONT( 10, 30 );
Size = MAP_APPFONT( 60, 15 );
Text [en-US] = "Pages";
};
Edit SV_PRINT_PAGERANGE_EDIT
{
Pos = MAP_APPFONT( 70, 30 );
Size = MAP_APPFONT( 80, 15 );
Border = TRUE;
};
RadioButton SV_PRINT_SELECTION
{
Pos = MAP_APPFONT( 10, 45 );
Size = MAP_APPFONT( 145, 15 );
Text [en-US] = "Selection";
};
FixedLine SV_PRINT_COPIES
{
Pos = MAP_APPFONT( 5, 70 );
Size = MAP_APPFONT( 150, 10 );
Text [en-US] = "Copies";
};
FixedText SV_PRINT_COPYCOUNT
{
Pos = MAP_APPFONT( 10, 80 );
Size = MAP_APPFONT( 80, 10 );
Text [en-US] = "Number of copies";
};
NumericField SV_PRINT_COPYCOUNT_FIELD
{
Pos = MAP_APPFONT( 90, 80 );
Size = MAP_APPFONT( 40, 10 );
Border = TRUE;
Spin = TRUE;
Minimum = 1;
Maximum = 16384;
Value = 1;
};
FixedImage SV_PRINT_COLLATE_IMAGE
{
Pos = MAP_APPFONT( 10, 100 );
Size = MAP_PIXEL( 80, 30 );
};
CheckBox SV_PRINT_COLLATE
{
Pos = MAP_APPFONT( 80, 100 );
Size = MAP_APPFONT( 70, 10 );
Text [en-US] = "Collate";
};
Image SV_PRINT_COLLATE_IMG
{
ImageBitmap = Bitmap { File = "collate.png" ; };
};
Image SV_PRINT_NOCOLLATE_IMG
{
ImageBitmap = Bitmap { File = "ncollate.png" ; };
};
Image SV_PRINT_COLLATE_HC_IMG
{
ImageBitmap = Bitmap { File = "collate_h.png" ; };
};
Image SV_PRINT_NOCOLLATE_HC_IMG
{
ImageBitmap = Bitmap { File = "ncollate_h.png" ; };
};
};
};

View file

@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: stdtext.src,v $
* $Revision: 1.53 $
* $Revision: 1.53.84.1 $
*
* This file is part of OpenOffice.org.
*
@ -123,3 +123,8 @@ String SV_MAC_SCREENNNAME
{
Text [en-US] = "Screen %d";
};
String SV_STDTEXT_ALLFILETYPES
{
Text [en-US] = "Any type";
};

View file

@ -8,7 +8,7 @@
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.25 $
# $Revision: 1.25.114.1 $
#
# This file is part of OpenOffice.org.
#
@ -70,6 +70,7 @@ SLOFILES= \
$(SLO)$/mnemonicengine.obj \
$(SLO)$/msgbox.obj \
$(SLO)$/scrwnd.obj \
$(SLO)$/printdlg.obj \
$(SLO)$/seleng.obj \
$(SLO)$/split.obj \
$(SLO)$/splitwin.obj \

View file

@ -0,0 +1,405 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: printdlg.cxx,v $
* $Revision: 1.1.2.7 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "precompiled_vcl.hxx"
#include "vcl/print.hxx"
#include "vcl/prndlg.hxx"
#include "vcl/dialog.hxx"
#include "vcl/button.hxx"
#include "vcl/svdata.hxx"
#include "vcl/svids.hrc"
#include "vcl/wall.hxx"
#include "vcl/jobset.h"
#include "rtl/ustrbuf.hxx"
using namespace vcl;
PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId )
: Window( i_pParent, i_rId )
{
}
PrintDialog::PrintPreviewWindow::~PrintPreviewWindow()
{
}
void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& i_rRect )
{
Window::Paint( i_rRect );
SetFillColor( Color( COL_WHITE ) );
SetLineColor();
DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() ));
Push();
SetMapMode( MAP_100TH_MM );
maMtf.WindStart();
maMtf.Play( this, Point( 0, 0 ), PixelToLogic( GetSizePixel() ) );
Pop();
}
void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview )
{
maMtf = i_rNewPreview;
Invalidate();
}
PrintDialog::PrinterTabPage::PrinterTabPage( Window* i_pParent, const ResId& rResId )
: TabPage( i_pParent, rResId )
, maPrinters( this, VclResId( SV_PRINT_PRINTERS) )
, maSetupButton( this, VclResId( SV_PRINT_PRT_SETUP ) )
, maType( this, VclResId( SV_PRINT_PRT_TYPE ) )
, maTypeText( this, VclResId( SV_PRINT_PRT_TYPE_TXT ) )
, maStatus( this, VclResId( SV_PRINT_PRT_STATUS ) )
, maStatusText(this, VclResId( SV_PRINT_PRT_STATUS_TXT ) )
, maLocation( this, VclResId( SV_PRINT_PRT_LOCATION ) )
, maLocText( this, VclResId( SV_PRINT_PRT_LOCATION_TXT ) )
, maComment( this, VclResId( SV_PRINT_PRT_COMMENT ) )
, maCommentText( this, VclResId( SV_PRINT_PRT_COMMENT_TXT ) )
, maToFileBox( this, VclResId( SV_PRINT_PRT_TOFILE ) )
{
FreeResource();
}
PrintDialog::PrinterTabPage::~PrinterTabPage()
{
}
PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId )
: TabPage( i_pParent, rResId )
, maPrintRange( this, VclResId( SV_PRINT_RANGE ) )
, maAllButton( this, VclResId( SV_PRINT_ALL ) )
, maPagesButton( this, VclResId( SV_PRINT_PAGERANGE ) )
, maSelectionButton( this, VclResId( SV_PRINT_SELECTION ) )
, maPagesEdit( this, VclResId( SV_PRINT_PAGERANGE_EDIT ) )
, maCopies( this, VclResId( SV_PRINT_COPIES ) )
, maCopyCount( this, VclResId( SV_PRINT_COPYCOUNT ) )
, maCopyCountField( this, VclResId( SV_PRINT_COPYCOUNT_FIELD ) )
, maCollateBox( this, VclResId( SV_PRINT_COLLATE ) )
, maCollateImage( this, VclResId( SV_PRINT_COLLATE_IMAGE ) )
, maCollateImg( VclResId( SV_PRINT_COLLATE_IMG ) )
, maCollateHCImg( VclResId( SV_PRINT_COLLATE_HC_IMG ) )
, maNoCollateImg( VclResId( SV_PRINT_NOCOLLATE_IMG ) )
, maNoCollateHCImg( VclResId( SV_PRINT_NOCOLLATE_HC_IMG ) )
{
FreeResource();
}
PrintDialog::JobTabPage::~JobTabPage()
{
}
PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr<PrinterListener>& i_rListener )
: ModalDialog( i_pParent, VclResId( SV_DLG_PRINT ) )
, maOKButton( this, VclResId( SV_PRINT_OK ) )
, maCancelButton( this, VclResId( SV_PRINT_CANCEL ) )
, maPreviewWindow( this, VclResId( SV_PRINT_PAGE_PREVIEW ) )
, maPageText( this, VclResId( SV_PRINT_PAGE_TXT ) )
, maPageScrollbar( this, VclResId( SV_PRINT_PAGE_SCROLL ) )
, maTabCtrl( this, VclResId( SV_PRINT_TABCTRL ) )
, maPrinterPage( &maTabCtrl, VclResId( SV_PRINT_TAB_PRINTER ) )
, maJobPage( &maTabCtrl, VclResId( SV_PRINT_TAB_JOB ) )
, maButtonLine( this, VclResId( SV_PRINT_BUTTONLINE ) )
, maPListener( i_rListener )
, mnCurPage( 0 )
, mnCachedPages( 0 )
{
FreeResource();
// insert the tab pages
maTabCtrl.InsertPage( SV_PRINT_PAGE_PREVIEW, maPrinterPage.GetText() );
maTabCtrl.SetTabPage( SV_PRINT_PAGE_PREVIEW, &maPrinterPage );
maTabCtrl.InsertPage( SV_PRINT_TAB_JOB, maJobPage.GetText() );
maTabCtrl.SetTabPage( SV_PRINT_TAB_JOB, &maJobPage );
maPageStr = maPageText.GetText();
// save space for the preview window
maPreviewSpace = Rectangle( maPreviewWindow.GetPosPixel(), maPreviewWindow.GetSizePixel() );
// get the first page
preparePreview();
// set up the scrollbar for the preview pages
maPageScrollbar.SetScrollHdl( LINK( this, PrintDialog, ScrollHdl ) );
maPageScrollbar.SetEndScrollHdl( LINK( this, PrintDialog, ScrollEndHdl ) );
maPageScrollbar.EnableDrag( TRUE );
// fill printer listbox
const std::vector< rtl::OUString >& rQueues( Printer::GetPrinterQueues() );
for( std::vector< rtl::OUString >::const_iterator it = rQueues.begin();
it != rQueues.end(); ++it )
{
maPrinterPage.maPrinters.InsertEntry( *it );
}
// select current printer
if( maPrinterPage.maPrinters.GetEntryPos( maPListener->getPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND )
maPrinterPage.maPrinters.SelectEntry( maPListener->getPrinter()->GetName() );
else
{
// fall back to default printer
maPrinterPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() );
maPListener->setPrinter( boost::shared_ptr<Printer>( new Printer( Printer::GetDefaultPrinterName() ) ) );
}
// update the text fields for the printer
updatePrinterText();
// set a select handler
maPrinterPage.maPrinters.SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
// setup page range edit
rtl::OUStringBuffer aBuf( 16 );
aBuf.append( sal_Unicode('1') );
if( mnCachedPages > 1 )
{
aBuf.append( sal_Unicode('-') );
aBuf.append( mnCachedPages );
}
maJobPage.maPagesEdit.SetText( aBuf.makeStringAndClear() );
// setup click handler on the various buttons
maJobPage.maCollateBox.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
maJobPage.maAllButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
maJobPage.maSelectionButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
maJobPage.maPagesButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
maPrinterPage.maSetupButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
// setup modify hdl
maJobPage.maCopyCountField.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
// setup dependencies
checkControlDependencies();
}
PrintDialog::~PrintDialog()
{
}
bool PrintDialog::isPrintToFile()
{
return maPrinterPage.maToFileBox.IsChecked();
}
int PrintDialog::getCopyCount()
{
return maJobPage.maCopyCountField.GetValue();
}
bool PrintDialog::isCollate()
{
return maJobPage.maCopyCountField.GetValue() > 1 ? maJobPage.maCollateBox.IsChecked() : FALSE;
}
MultiSelection PrintDialog::getPageSelection()
{
if( maJobPage.maPagesButton.IsChecked() )
return MultiSelection( maJobPage.maPagesEdit.GetText() );
else if( maJobPage.maAllButton.IsChecked() )
{
MultiSelection aSel( Range( 1, maPListener->getPageCount() ) );
aSel.SelectAll();
return aSel;
}
DBG_ERROR( "NYI: Selection" );
return MultiSelection();
}
void PrintDialog::checkControlDependencies()
{
if( maJobPage.maCopyCountField.GetValue() > 1 )
maJobPage.maCollateBox.Enable( TRUE );
else
maJobPage.maCollateBox.Enable( FALSE );
maJobPage.maPagesEdit.Enable( maJobPage.maPagesButton.IsChecked() );
Image aImg( maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateImg : maJobPage.maNoCollateImg );
if( GetSettings().GetStyleSettings().GetFieldColor().IsDark() )
aImg = maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateHCImg : maJobPage.maNoCollateHCImg;
// adjust position and size of image
maJobPage.maCollateImage.SetSizePixel( aImg.GetSizePixel() );
Point aPos( maJobPage.maCollateImage.GetPosPixel() );
aPos.Y() = maJobPage.maCollateBox.GetPosPixel().Y();
aPos.Y() -= (aImg.GetSizePixel().Height() - maJobPage.maCollateBox.GetSizePixel().Height())/2;
maJobPage.maCollateImage.SetPosPixel( aPos );
maJobPage.maCollateImage.SetImage( aImg );
// enable setup button only for printers that can be setup
maPrinterPage.maSetupButton.Enable( maPListener->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG ) );
}
void PrintDialog::updatePrinterText()
{
const QueueInfo* pInfo = Printer::GetQueueInfo( maPrinterPage.maPrinters.GetSelectEntry(), true );
if( pInfo )
{
maPrinterPage.maTypeText.SetText( pInfo->GetDriver() );
// FIXME: status message
// maJobPage.maStatusText.SetText();
maPrinterPage.maLocText.SetText( pInfo->GetLocation() );
maPrinterPage.maCommentText.SetText( pInfo->GetComment() );
}
}
static rtl::OUString searchAndReplace( const rtl::OUString& i_rOrig, const char* i_pRepl, sal_Int32 i_nReplLen, sal_Int32 i_nReplacement )
{
sal_Int32 nPos = i_rOrig.indexOfAsciiL( i_pRepl, i_nReplLen );
if( nPos != -1 )
{
rtl::OUStringBuffer aBuf( i_rOrig.getLength() );
aBuf.append( i_rOrig.getStr(), nPos );
aBuf.append( i_nReplacement );
if( nPos + i_nReplLen < i_rOrig.getLength() )
aBuf.append( i_rOrig.getStr() + nPos + i_nReplLen );
return aBuf.makeStringAndClear();
}
return i_rOrig;
}
void PrintDialog::setPreviewText( sal_Int32 nSetPage )
{
rtl::OUString aNewText( searchAndReplace( maPageStr, "%p", 2, nSetPage+1 ) );
aNewText = searchAndReplace( aNewText, "%n", 2, mnCachedPages );
maPageText.SetText( aNewText );
}
void PrintDialog::preparePreview()
{
sal_Int32 nPages = maPListener->getPageCount();
mnCachedPages = nPages;
setPreviewText( mnCurPage );
maPageScrollbar.SetRange( Range( 0, nPages-1 ) );
maPageScrollbar.SetThumbPos( mnCurPage );
boost::shared_ptr<Printer> aPrt( maPListener->getPrinter() );
const MapMode aMapMode( MAP_100TH_MM );
Size aPageSize;
JobSetup aPageSetup( aPrt->GetJobSetup() );
maPListener->getPageParameters( mnCurPage, aPageSetup, aPageSize );
ImplUpdateJobSetupPaper( aPageSetup ); // fill in physical paper size
Size aPaperSize( aPageSetup.ImplGetConstData()->mnPaperWidth,
aPageSetup.ImplGetConstData()->mnPaperHeight );
if( aPageSetup.ImplGetConstData()->meOrientation == ORIENTATION_LANDSCAPE )
{
aPaperSize.Width() = aPageSetup.ImplGetConstData()->mnPaperHeight;
aPaperSize.Height() = aPageSetup.ImplGetConstData()->mnPaperWidth;
}
aPrt->Push();
aPrt->EnableOutput( FALSE );
aPrt->SetMapMode( aMapMode );
GDIMetaFile aMtf;
aMtf.SetPrefSize( aPageSize );
aMtf.SetPrefMapMode( aMapMode );
aMtf.Record( &(*aPrt) );
maPListener->printPage( mnCurPage );
aMtf.Stop();
aMtf.WindStart();
aPrt->Pop();
Size aPreviewSize;
Point aPreviewPos = maPreviewSpace.TopLeft();
const long nW = maPreviewSpace.GetSize().Width();
const long nH = maPreviewSpace.GetSize().Height();
if( aPaperSize.Width() > aPaperSize.Height() )
{
aPreviewSize = Size( nW, nW * aPaperSize.Height() / aPaperSize.Width() );
aPreviewPos.Y() += (maPreviewSpace.GetHeight() - aPreviewSize.Height())/2;
}
else
{
aPreviewSize = Size( nH * aPaperSize.Width() / aPaperSize.Height(), nH );
aPreviewPos.X() += (maPreviewSpace.GetWidth() - aPreviewSize.Width())/2;
}
maPreviewWindow.SetPosSizePixel( aPreviewPos, aPreviewSize );
const Size aLogicSize( maPreviewWindow.PixelToLogic( maPreviewWindow.GetSizePixel(), MapMode( MAP_100TH_MM ) ) );
aMtf.Scale( double(aLogicSize.Width())/double(aPaperSize.Width()),
double(aLogicSize.Height())/double(aPaperSize.Height()) );
maPreviewWindow.setPreview( aMtf );
}
IMPL_LINK( PrintDialog, ScrollHdl, ScrollBar*, pScrBar )
{
if( pScrBar == &maPageScrollbar )
{
sal_Int32 nNewPage = static_cast<sal_Int32>( maPageScrollbar.GetThumbPos() );
setPreviewText( nNewPage );
}
return 0;
}
IMPL_LINK( PrintDialog, ScrollEndHdl, ScrollBar*, pScrBar )
{
if( pScrBar == &maPageScrollbar )
{
sal_Int32 nNewPage = static_cast<sal_Int32>( maPageScrollbar.GetThumbPos() );
if( nNewPage != mnCurPage )
{
mnCurPage = nNewPage;
preparePreview();
}
}
return 0;
}
IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox )
{
if( pBox == &maPrinterPage.maPrinters )
{
// set new printer
maPListener->setPrinter( boost::shared_ptr<Printer>( new Printer( maPrinterPage.maPrinters.GetSelectEntry() ) ) );
// update text fields
updatePrinterText();
}
return 0;
}
IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton )
{
if( pButton == &maPrinterPage.maSetupButton )
{
maPListener->getPrinter()->Setup( this );
}
checkControlDependencies();
return 0;
}
IMPL_LINK( PrintDialog, ModifyHdl, Edit*, EMPTYARG )
{
checkControlDependencies();
return 0;
}