StyledEdit didn't print anything if there's only one line (bug #1288).

Note, though, that printing in StyledEdit is still very much broken. 
Often it prints only the current page, for example.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22511 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-10-12 07:58:33 +00:00
parent e0049e2c37
commit cbcae6ef9b
+21 -17
View File
@@ -1115,26 +1115,30 @@ StyledEditWindow::Print(const char* documentName)
lastLine = currentLine - 1; lastLine = currentLine - 1;
} }
printJob.BeginJob(); printJob.BeginJob();
int32 printLine = firstLine; if (fTextView->CountLines() > 0 && fTextView->TextLength() > 0) {
while (printLine < lastLine) { int32 printLine = firstLine;
float currentHeight = 0; while (printLine <= lastLine) {
int32 firstLineOnPage = printLine; float currentHeight = 0;
while (currentHeight < printableRect.Height() && printLine < lastLine) { int32 firstLineOnPage = printLine;
currentHeight += fTextView->LineHeight(printLine); while (currentHeight < printableRect.Height() && printLine <= lastLine) {
if (currentHeight < printableRect.Height()) currentHeight += fTextView->LineHeight(printLine);
printLine++; if (currentHeight < printableRect.Height())
printLine++;
}
float top = 0;
if (firstLineOnPage != 0)
top = fTextView->TextHeight(0, firstLineOnPage - 1);
float bottom = fTextView->TextHeight(0, printLine - 1);
BRect textRect(0.0, top + TEXT_INSET, printableRect.Width(), bottom + TEXT_INSET);
printJob.DrawView(fTextView, textRect, B_ORIGIN);
printJob.SpoolPage();
} }
float top = 0;
if (firstLineOnPage != 0)
top = fTextView->TextHeight(0, firstLineOnPage - 1);
float bottom = fTextView->TextHeight(0, printLine - 1);
BRect textRect(0.0, top + TEXT_INSET, printableRect.Width(), bottom + TEXT_INSET);
printJob.DrawView(fTextView, textRect, BPoint(0.0,0.0));
printJob.SpoolPage();
} }
printJob.CommitJob(); printJob.CommitJob();
} }