* fixed crash in case one tries to print a new composed mail
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24696 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1863,23 +1863,30 @@ TMailWindow::Print()
|
||||
|
||||
print.SetSettings(new BMessage(fApp->PrintSettings()));
|
||||
|
||||
if (print.ConfigJob() == B_NO_ERROR) {
|
||||
if (print.ConfigJob() == B_OK) {
|
||||
int32 curPage = 1;
|
||||
int32 lastLine = 0;
|
||||
BTextView header_view(print.PrintableRect(),"header",print.PrintableRect().OffsetByCopy(BPoint(-print.PrintableRect().left,-print.PrintableRect().top)),B_FOLLOW_ALL_SIDES);
|
||||
BTextView header_view(print.PrintableRect(), "header",
|
||||
print.PrintableRect().OffsetByCopy(BPoint(-print.PrintableRect().left,
|
||||
-print.PrintableRect().top)),B_FOLLOW_ALL_SIDES);
|
||||
|
||||
//---------Init the header fields
|
||||
#define add_header_field(field) {/*header_view.SetFontAndColor(be_bold_font);*/ \
|
||||
header_view.Insert(fHeaderView->field->Label()); \
|
||||
header_view.Insert(" ");\
|
||||
/*header_view.SetFontAndColor(be_plain_font);*/ \
|
||||
header_view.Insert(fHeaderView->field->Text()); \
|
||||
header_view.Insert("\n");}
|
||||
#define add_header_field(field) { \
|
||||
/*header_view.SetFontAndColor(be_bold_font);*/ \
|
||||
header_view.Insert(fHeaderView->field->Label()); \
|
||||
header_view.Insert(" "); \
|
||||
/*header_view.SetFontAndColor(be_plain_font);*/ \
|
||||
header_view.Insert(fHeaderView->field->Text()); \
|
||||
header_view.Insert("\n"); \
|
||||
}
|
||||
|
||||
add_header_field(fSubject);
|
||||
add_header_field(fTo);
|
||||
if ((fHeaderView->fCc != NULL) && (strcmp(fHeaderView->fCc->Text(),"") != 0))
|
||||
add_header_field(fCc);
|
||||
header_view.Insert(fHeaderView->fDate->Text());
|
||||
|
||||
if (fHeaderView->fDate != NULL)
|
||||
header_view.Insert(fHeaderView->fDate->Text());
|
||||
|
||||
int32 maxLine = fContentView->fTextView->CountLines();
|
||||
BRect pageRect = print.PrintableRect();
|
||||
@@ -1887,13 +1894,15 @@ TMailWindow::Print()
|
||||
|
||||
print.BeginJob();
|
||||
float header_height = header_view.TextHeight(0,header_view.CountLines());
|
||||
BBitmap bmap(BRect(0,0,pageRect.Width(),header_height),B_BITMAP_ACCEPTS_VIEWS,B_RGBA32);
|
||||
|
||||
BRect rect(0, 0, pageRect.Width(), header_height);
|
||||
BBitmap bmap(rect, B_BITMAP_ACCEPTS_VIEWS, B_RGBA32);
|
||||
bmap.Lock();
|
||||
bmap.AddChild(&header_view);
|
||||
print.DrawView(&header_view,BRect(0,0,pageRect.Width(),header_height),BPoint(0.0,0.0));
|
||||
HorizontalLine line(BRect(0,0,pageRect.right,0));
|
||||
print.DrawView(&header_view, rect, BPoint(0.0, 0.0));
|
||||
HorizontalLine line(BRect(0, 0, pageRect.right, 0));
|
||||
bmap.AddChild(&line);
|
||||
print.DrawView(&line,line.Bounds(),BPoint(0,header_height+1));
|
||||
print.DrawView(&line, line.Bounds(), BPoint(0, header_height + 1));
|
||||
bmap.Unlock();
|
||||
header_height += 5;
|
||||
|
||||
@@ -1903,18 +1912,22 @@ TMailWindow::Print()
|
||||
curPageRect.OffsetTo(0, fContentView->fTextView->PointAt(lineOffset).y);
|
||||
|
||||
int32 fromLine = lastLine;
|
||||
lastLine = fContentView->fTextView->LineAt(BPoint(0.0, curPageRect.bottom - ((curPage == 1) ? header_height : 0)));
|
||||
lastLine = fContentView->fTextView->LineAt(
|
||||
BPoint(0.0, curPageRect.bottom - ((curPage == 1) ? header_height : 0)));
|
||||
|
||||
float curPageHeight = fContentView->fTextView->TextHeight(fromLine, lastLine) + ((curPage == 1) ? header_height : 0);
|
||||
if(curPageHeight > pageRect.Height())
|
||||
curPageHeight = fContentView->fTextView->TextHeight(fromLine, --lastLine) + ((curPage == 1) ? header_height : 0);
|
||||
float curPageHeight = fContentView->fTextView->
|
||||
TextHeight(fromLine, lastLine) + ((curPage == 1) ? header_height : 0);
|
||||
|
||||
if(curPageHeight > pageRect.Height()) {
|
||||
curPageHeight = fContentView->fTextView->TextHeight(
|
||||
fromLine, --lastLine) + ((curPage == 1) ? header_height : 0);
|
||||
}
|
||||
curPageRect.bottom = curPageRect.top + curPageHeight - 1.0;
|
||||
|
||||
if((curPage >= print.FirstPage()) &&
|
||||
(curPage <= print.LastPage()))
|
||||
{
|
||||
print.DrawView(fContentView->fTextView, curPageRect, BPoint(0.0, (curPage == 1) ? header_height : 0.0));
|
||||
if((curPage >= print.FirstPage())
|
||||
&& (curPage <= print.LastPage())) {
|
||||
print.DrawView(fContentView->fTextView, curPageRect,
|
||||
BPoint(0.0, (curPage == 1) ? header_height : 0.0));
|
||||
print.SpoolPage();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user