Accounting Software
Small Business Software Estimating Software
Construction Estimating SoftwareBookkeeping SoftwareInventory SoftwareInventory Control SoftwareInventory Tracking SoftwareInventory Management SoftwareBusiness Management Software

Report Printer (Source Code)

Link to: header | record viewer directory

Copyright Turtle Creek Software 1996-2006. All Rights Reserved.

Comments

DB_ReportPrinter

This class manages report printers for the Goldenseal accounting software,
small business management software, construction project management software and
construction estimating software.

view for printing for accounting reports. We create a separate view for printing,
although that means that sorted tables don't print sorted. We need the separate
view because when printing, we insert blank rows in tables so we dont get split
text at page breaks.

We could possibly use an LPlaceHolder and insert rows before printing (and then
delete them after printing). Or it might be easier to just remember the sorting
and sort the printed table too.

SUPERCLASS = DB_ReportViewer

Constructor

/******************************************************************************
Default constructor v1.0, 04-25-1998
******************************************************************************/
DB_ReportPrinter::DB_ReportPrinter() :
THE_SUPERCLASS(CTCS_Pane::sDefaultPaneInfo,
CTCS_View::sDefaultViewInfo)
{
}/******************************************************************************
destructor v1.0, 04-25-1998
******************************************************************************/
DB_ReportPrinter::~DB_ReportPrinter()
{
}

Source Code

/*********************************************************************************

PrintReport v1.0, 04-25-1998

Prints the current report

*********************************************************************************/
void DB_ReportPrinter::PrintReport(DB_ReportViewer *inViewer)
{
TCS_FailNILMsg(gDocument, TCS_GetErrString(errID_BadDocument));

#if TCS_FOR_OSX
LPrintSpec *printSpec = gDocument->GetPrintSpec();
TCS_FailNILMsg(printSpec, TCS_GetErrString(errID_BadPrinting));

StPrintSession session(printSpec);

if (!UPrinting::AskPrintJob(printSpec))
return;
#else
TCS_PrintHandle printRecordH = gDocument->GetPrintRecord(); // TCS 1/8/00

if (!UPrintingMgr::AskPrintJob(printRecordH)) // formerly thePrintout.GetPrintRecord()
return; // moved TCS 11/27/00
#endif
DBid layoutID = inViewer->GetLayoutID();

// set up a printout object
CTCS_Printout thePrintout;

// load the layout. TCS moved 2/17/04
if (DB_Layout::LayoutExists(layoutID, GetLayoutClassID()))
{
LoadLayout(layoutID);
}
else
{
TCS_ErrorAlert(errID_BadLayout);
return;
}

// set print parameters in the printout object TCS 11/27/00
thePrintout.SetTopMargin(mTopMargin);
thePrintout.SetBottomMargin(mBottomMargin);
thePrintout.SetLeftMargin(mLeftMargin);
thePrintout.SetRightMargin(mRightMargin);
thePrintout.SetPrintPageSize(mPrintPageSize);
thePrintout.SetPrintOrientation(mPrintOrientation);
thePrintout.SetPrintColumns(print_fullpage);
thePrintout.SetPrintPlacement(print_multipages);

// adjust page size and orientation TCS 11/23/00
#if TCS_FOR_OSX
thePrintout.SetPrintSpec(printSpec);
#else
thePrintout.SetPrintRecord(printRecordH);
#endif

// adjust paper size etc in the printout.
thePrintout.AdjustPrintSpecs(true); // rev TCS 12/5/03
// fetch values from the current report viewer TCS 10/6/99
SetItemRange(inViewer->GetItemRange());
SetMatchClassID(inViewer->GetMatchClassID());
SetAccountClassID(inViewer->GetAccountClassID()); // TCS bugfix 4/17/01
SetGroup(inViewer->GetGroup()); // TCS bugfix 9/16/02
SetStartDate(inViewer->GetStartDate());
SetEndDate(inViewer->GetEndDate());

SetMatchValue(inViewer->GetMatchValue());
SetReportClassID(inViewer->GetReportClassID());
SetMatchTag(inViewer->GetMatchTag());
SetBreakdownTag(inViewer->GetBreakdownTag());

SetDateFieldType(inViewer->GetDateFieldType());
SetCondensed(inViewer->IsCondensed()); // TCS 9/16/02
SetStartsCondensed(inViewer->StartsCondensed());
SetDateRange(inViewer->GetDateRange());

// fill the report with data TCS 10/6/99
UpdateCalculatorPanes();

// resize, since table size may have changed TCS 11/27/00
StretchImageToFit();

// Put this viewer inside the printout object TCS moved 2/17/04
LView *oldSuperView = mSuperView;
PutInside(&thePrintout);

// put this viewer in the proper location TCS 11/27/00
thePrintout.AdjustPagePosition(this, 1);

// Run the print job
TCS_TRY // TCS 1/10/03
{
thePrintout.DoPrintJob();
}
TCS_CATCH {}

// Put our view back where it was
PutInside(oldSuperView);
}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

LoadLayout v1.0, 04-25-1998

load a new layout for the given id.
This method is the same as the inherited method except it does NOT
attempt to redraw, because the view may not be in a graphics port!
*********************************************************************************/
Boolean DB_ReportPrinter::LoadLayout(const DBid layoutID, const Boolean resourceOnly)
{
// update our member
mLayoutID = layoutID;
if (KillSubsBeforeLoad())
{ // first get rid of all the subpanes before adding the new ones
//LCommander::SwitchTarget(this);
DeleteAllSubPanes();
ClearFieldArrays();
}
// load the layout handle
if (layoutID)
{ // we have a layout id
TCS_Handle layoutH =
DB_Layout::GetLayoutHandle(GetLayoutClassID(), layoutID, resourceOnly);
CHandleWatcher watcher(layoutH);

TCS_TRY // TCS 6/14/00
{
LoadLayoutHandle(layoutH);
}
TCS_CATCH
{
}
return true; // rev TCS 9/27/00
}
else
return false;
}
/******************************************************************************

DrawSelf TCS 9/29/99

we override the drawing behavior of the superclass so we
don't get an all black page

*******************************************************************************/
void DB_ReportPrinter::DrawSelf()
{
}
/*********************************************************************************

CreateTablePane TCS 1/7/00

create a table pane for printing. We override to set table height

*********************************************************************************/
LPane *DB_ReportPrinter::CreateTablePane(const SPaneInfo &paneInfo,
const CTCS_TextInfo &/*textInfo*/,
CInputStream &stream,
const SMemberInfo &/*memberInfo*/,
Boolean /*isBreakdown*/,
const DB_ClassDescriptor */*descriptor*/)
{
// create a table from the stream
CReportTable *table =
NEW CReportTable(paneInfo, CTCS_View::sDefaultViewInfo, stream);
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));

// fetch the page height
TCS_FailNILMsg(gDocument, TCS_GetErrString(errID_BadDocument));
table->SetPaperHeight(GetPaperHeight()); // rev TCS 11/26/00
table->SetTopMargin(GetTopMargin());
table->SetBottomMargin(GetBottomMargin());
table->SetUsesMarginOffset(true); // rev TCS 2/9/04 rev TCS 2/17/04
table->SetIsPrinting(true);

return table;
}