Subversion Repositories Scribus

Compare Revisions

Regard whitespace Rev 20629 → Rev 20630

/trunk/Scribus/scribus/CMakeLists.txt
583,6 → 583,7
cmserrorhandling.cpp
cmsettings.cpp
collapsedtablepainter.cpp
collapsedtablepainterex.cpp
collect4output.cpp
colorblind.cpp
colorsetmanager.cpp
/trunk/Scribus/scribus/collapsedtablepainterex.cpp
0,0 → 1,485
/*
Copyright (C) 2011 Elvis Stansvik <elvstone@gmail.com>
 
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#include <QColor>
#include <QLineF>
#include <QRectF>
 
#include "pageitem_table.h"
#include "prefsmanager.h"
#include "scpageoutput.h"
#include "scpainterexbase.h"
#include "scribusdoc.h"
#include "tablecell.h"
#include "tableborder.h"
#include "tableutils.h"
 
#include "collapsedtablepainterex.h"
 
using namespace TableUtils;
 
CollapsedTablePainterEx::CollapsedTablePainterEx(ScPageOutput* pageOutput, PageItem_Table* table)
{
m_pageOutput = pageOutput;
m_table = table;
}
 
void CollapsedTablePainterEx::paintTable(ScPainterExBase* p)
{
p->save();
p->translate(m_table->gridOffset());
 
// Paint table fill.
paintTableFill(p);
 
/*
* We paint the table in five passes:
*
* 1) Cell fills.
* 2) Vertical borders.
* 3) Horizontal borders
* 4) Decorative grid lines.
* 5) Cell content.
*/
 
// Pass 1: Paint cell fills.
for (int row = 0; row < m_table->rows(); ++row)
{
int colSpan = 0;
for (int col = 0; col < m_table->columns(); col += colSpan)
{
TableCell cell = m_table->cellAt(row, col);
if (row == cell.row())
paintCellFill(cell, p);
colSpan = cell.columnSpan();
}
}
 
// Pass 2: Paint vertical borders.
for (int row = 0; row < m_table->rows(); ++row)
{
int colSpan = 0;
for (int col = 0; col < m_table->columns(); col += colSpan)
{
TableCell cell = m_table->cellAt(row, col);
if (row == cell.row())
{
paintCellRightBorders(cell, p);
if (col == 0)
paintCellLeftBorders(cell, p);
}
colSpan = cell.columnSpan();
}
}
 
// Pass 3: Paint horizontal borders.
for (int row = 0; row < m_table->rows(); ++row)
{
int colSpan = 0;
for (int col = 0; col < m_table->columns(); col += colSpan)
{
TableCell cell = m_table->cellAt(row, col);
if (row == cell.row())
{
paintCellBottomBorders(cell, p);
if (row == 0)
paintCellTopBorders(cell, p);
}
colSpan = cell.columnSpan();
}
}
 
// Pass 5: Paint cell content.
for (int row = 0; row < m_table->rows(); ++row)
{
for (int col = 0; col < m_table->columns(); col ++)
{
TableCell cell = m_table->cellAt(row, col);
if (cell.row() == row && cell.column() == col)
{
PageItem_TextFrame* textFrame = cell.textFrame();
m_pageOutput->drawItem(textFrame, p, QRect());
}
}
}
 
p->restore();
}
 
void CollapsedTablePainterEx::paintTableFill(ScPainterExBase* p) const
{
QString colorName = m_table->fillColor();
 
if (colorName == CommonStrings::None)
return;
 
p->save();
 
int lastCol = m_table->columns() - 1;
int lastRow = m_table->rows() - 1;
 
double x = m_table->columnPosition(0);
double y = m_table->rowPosition(0);
double width = m_table->columnPosition(lastCol) + m_table->columnWidth(lastCol) - x;
double height = m_table->rowPosition(lastRow) + m_table->rowHeight(lastRow) - y;
 
ScribusDoc* doc = m_table->doc();
ScColorShade colorShade(doc->PageColors[colorName], (int) m_table->fillShade());
p->setBrush(colorShade);
p->setFillMode(ScPainterExBase::Solid);
p->setStrokeMode(ScPainterExBase::None);
p->drawRect(x, y, width, height);
 
p->restore();
}
 
void CollapsedTablePainterEx::paintCellLeftBorders(const TableCell& cell, ScPainterExBase* p) const
{
/*
* We are going to paint the border marked # in the following setup.
*
* +----------------------+----------------------+
* | | |
* | | |
* | topLeftCell top topRightCell |
* | | |
* | | |
* +--------topLeft-------+-------topRight-------+
* | # |
* | # |
* | leftCell border cell |
* | # |
* | # |
* +-------bottomLeft-----+------bottomRight-----+
* | | |
* | | |
* | bottomLeftCell bottom bottomRightCell |
* | | |
* | | |
* +----------------------+----------------------+
*/
 
// The cell ends in this row.
const int lastRow = cell.row() + cell.rowSpan() - 1;
// The cell starts in this column.
const int firstCol = cell.column();
// The X position of the border segments to paint.
const double borderX = m_table->columnPosition(firstCol);
 
// The start point of the border segment currently being painted.
QPointF start(borderX, 0.0);
// The end point of the border segment currently being painted.
QPointF end(borderX, 0.0);
// The start and end offset factors for the border segment currently being painted.
QPointF startOffsetFactors, endOffsetFactors;
// Start and end row of border segment currently being painted.
int startRow, endRow;
 
for (int row = cell.row(); row <= lastRow; row += endRow - startRow + 1)
{
// Get the neighboring cell to the left and determine border segment row interval.
TableCell leftCell = m_table->cellAt(row, firstCol - 1);
startRow = qMax(cell.row(), leftCell.row());
endRow = qMin(lastRow, leftCell.isValid() ? leftCell.row() + leftCell.rowSpan() - 1 : lastRow);
 
// Get the remaining neighboring cells.
TableCell topLeftCell = m_table->cellAt(startRow - 1, firstCol - 1);
TableCell topRightCell = m_table->cellAt(startRow - 1, firstCol);
TableCell bottomRightCell = m_table->cellAt(lastRow + 1, firstCol);
TableCell bottomLeftCell = m_table->cellAt(lastRow + 1, firstCol - 1);
 
// Resolve borders between neighboring cells.
TableBorder topLeft, top, topRight, border, bottomLeft, bottom, bottomRight;
resolveBordersVertical(topLeftCell, topRightCell, leftCell, cell, bottomLeftCell, bottomRightCell, &topLeft, &top, &topRight, &border, &bottomLeft, &bottom, &bottomRight, m_table);
 
if (border.isNull())
continue; // Quit early if the border to paint is null.
 
// Set initial coordinates.
start.setY(m_table->rowPosition(startRow));
end.setY(m_table->rowPosition(endRow) + m_table->rowHeight(endRow));
 
// Adjust coordinates for joining.
joinVertical(border, topLeft, top, topRight, bottomLeft, bottom, bottomRight,
&start, &end, &startOffsetFactors, &endOffsetFactors);
 
// Paint the border segment.
paintBorder(border, start, end, startOffsetFactors, endOffsetFactors, p);
}
}
 
void CollapsedTablePainterEx::paintCellRightBorders(const TableCell& cell, ScPainterExBase* p) const
{
/*
* We are going to paint the border marked # in the following setup.
*
* +----------------------+----------------------+
* | | |
* | | |
* | topLeftCell top topRightCell |
* | | |
* | | |
* +--------topLeft-------+-------topRight-------+
* | # |
* | # |
* | cell border rightCell |
* | # |
* | # |
* +-------bottomLeft-----+------bottomRight-----+
* | | |
* | | |
* | bottomLeftCell bottom bottomRightCell |
* | | |
* | | |
* +----------------------+----------------------+
*/
 
// The cell ends in this row.
const int lastRow = cell.row() + cell.rowSpan() - 1;
// The cell ends in this column.
const int lastCol = cell.column() + cell.columnSpan() - 1;
// The X position of the border segments to paint.
const double borderX = m_table->columnPosition(lastCol) + m_table->columnWidth(lastCol);
 
// The start point of the border segment currently being painted.
QPointF start(borderX, 0.0);
// The end point of the border segment currently being painted.
QPointF end(borderX, 0.0);
// The start and end offset factors for the border segment currently being painted.
QPointF startOffsetFactors, endOffsetFactors;
// The start and end row of border segment currently being painted.
int startRow, endRow;
 
for (int row = cell.row(); row <= lastRow; row += endRow - startRow + 1)
{
// Get the neighboring cell to the right and determine border segment row interval.
TableCell rightCell = m_table->cellAt(row, lastCol + 1);
startRow = qMax(cell.row(), rightCell.row());
endRow = qMin(lastRow, rightCell.isValid() ? rightCell.row() + rightCell.rowSpan() - 1 : lastRow);
 
// Get the remaining neighboring cells surrounding the segment.
TableCell topLeftCell = m_table->cellAt(startRow - 1, lastCol);
TableCell topRightCell = m_table->cellAt(startRow - 1, lastCol + 1);
TableCell bottomRightCell = m_table->cellAt(endRow + 1, lastCol + 1);
TableCell bottomLeftCell = m_table->cellAt(endRow + 1, lastCol);
 
// Resolve borders between neighboring cells.
TableBorder topLeft, top, topRight, border, bottomLeft, bottom, bottomRight;
resolveBordersVertical(topLeftCell, topRightCell, cell, rightCell, bottomLeftCell, bottomRightCell, &topLeft, &top, &topRight, &border, &bottomLeft, &bottom, &bottomRight, m_table);
 
if (border.isNull())
continue; // Quit early if the border to paint is null.
 
// Set initial coordinates.
start.setY(m_table->rowPosition(startRow));
end.setY(m_table->rowPosition(endRow) + m_table->rowHeight(endRow));
 
// Adjust coordinates for joining.
joinVertical(border, topLeft, top, topRight, bottomLeft, bottom, bottomRight,
&start, &end, &startOffsetFactors, &endOffsetFactors);
 
// Paint the border.
paintBorder(border, start, end, startOffsetFactors, endOffsetFactors, p);
}
}
 
void CollapsedTablePainterEx::paintCellTopBorders(const TableCell& cell, ScPainterExBase* p) const
{
/*
* We are going to paint the border marked # in the following setup.
*
* +--------------------------+--------------------------+--------------------------+
* | | | |
* | | | |
* | topLeftCell topLeft topCell topRight topRightCell |
* | | | |
* | | | |
* +----------left------------+######### border-#########+----------right-----------+
* | | | |
* | | | |
* | bottomLeftCell bottomLeft cell bottomRight bottomRightCell |
* | | | |
* | | | |
* +--------------------------+--------------------------+--------------------------+
*/
// The cell starts in this row.
const int firstRow = cell.row();
// The cell ends in this column.
const int lastCol = cell.column() + cell.columnSpan() - 1;
// The Y position of the border segments to paint.
const double borderY = m_table->rowPosition(firstRow);
 
// The start point of the border segment currently being painted.
QPointF start(0.0, borderY);
// The end point of the border segment currently being painted.
QPointF end(0.0, borderY);
// The start and end offset factors for the border segment currently being painted.
QPointF startOffsetFactors, endOffsetFactors;
// Start and end column of border segment currently being painted.
int startCol, endCol;
 
for (int col = cell.column(); col <= lastCol; col += endCol - startCol + 1)
{
// Get the neighboring cell above and determine border segment column interval.
TableCell topCell = m_table->cellAt(firstRow - 1, col);
startCol = qMax(cell.column(), topCell.column());
endCol = qMin(lastCol, topCell.isValid() ? topCell.column() + topCell.columnSpan() - 1 : lastCol);
 
// Get the remaining neighboring cells.
TableCell topLeftCell = m_table->cellAt(firstRow - 1, startCol - 1);
TableCell topRightCell = m_table->cellAt(firstRow - 1, endCol + 1);
TableCell bottomRightCell = m_table->cellAt(firstRow, endCol + 1);
TableCell bottomLeftCell = m_table->cellAt(firstRow, startCol - 1);
 
// Resolve borders between neighboring cells.
TableBorder topLeft, left, bottomLeft, border, topRight, right, bottomRight;
resolveBordersHorizontal(topLeftCell, topCell, topRightCell, bottomLeftCell, cell, bottomRightCell, &topLeft, &left, &bottomLeft, &border, &topRight, &right, &bottomRight, m_table);
 
if (border.isNull())
continue; // Quit early if the border is null.
 
// Set initial coordinates.
start.setX(m_table->columnPosition(startCol));
end.setX(m_table->columnPosition(endCol) + m_table->columnWidth(endCol));
 
// Adjust coordinates for joining.
joinHorizontal(border, topLeft, left, bottomLeft, topRight, right, bottomRight,
&start, &end, &startOffsetFactors, &endOffsetFactors);
 
// Paint the border segment.
paintBorder(border, start, end, startOffsetFactors, endOffsetFactors, p);
}
}
 
void CollapsedTablePainterEx::paintCellBottomBorders(const TableCell& cell, ScPainterExBase* p) const
{
/*
* We are going to paint the border marked # in the following setup.
*
* +--------------------------+--------------------------+--------------------------+
* | | | |
* | | | |
* | topLeftCell topLeft cell topRight topRightCell |
* | | | |
* | | | |
* +----------left------------+######### border-#########+----------right-----------+
* | | | |
* | | | |
* | bottomLeftCell bottomLeft bottomCell bottomRight bottomRightCell |
* | | | |
* | | | |
* +--------------------------+--------------------------+--------------------------+
*/
// The cell ends in this row.
const int lastRow = cell.row() + cell.rowSpan() - 1;
// The cell ends in this column.
const int lastCol = cell.column() + cell.columnSpan() - 1;
// The Y position of the border segments to paint.
const double borderY = m_table->rowPosition(lastRow) + m_table->rowHeight(lastRow);
 
// The start point of the border segment currently being painted.
QPointF start(0.0, borderY);
// The end point of the border segment currently being painted.
QPointF end(0.0, borderY);
// The start and end offset factors for the border segment currently being painted.
QPointF startOffsetFactors, endOffsetFactors;
// Start and end column of border segment currently being painted.
int startCol, endCol;
 
for (int col = cell.column(); col <= lastCol; col += endCol - startCol + 1)
{
// Get the neighboring cell below and determine border segment column interval.
TableCell bottomCell = m_table->cellAt(lastRow + 1, col);
startCol = qMax(cell.column(), bottomCell.column());
endCol = qMin(lastCol, bottomCell.isValid() ? bottomCell.column() + bottomCell.columnSpan() - 1 : lastCol);
 
// Get the remaining neighboring cells.
TableCell topLeftCell = m_table->cellAt(lastRow, startCol - 1);
TableCell topRightCell = m_table->cellAt(lastRow, endCol + 1);
TableCell bottomRightCell = m_table->cellAt(lastRow + 1, endCol + 1);
TableCell bottomLeftCell = m_table->cellAt(lastRow + 1, startCol - 1);
 
// Resolve borders between neighboring cells.
TableBorder topLeft, left, bottomLeft, border, topRight, right, bottomRight;
resolveBordersHorizontal(topLeftCell, cell, topRightCell, bottomLeftCell, bottomCell, bottomRightCell, &topLeft, &left, &bottomLeft, &border, &topRight, &right, &bottomRight, m_table);
 
if (border.isNull())
continue; // Quit early if the border is null.
 
// Set initial coordinates.
start.setX(m_table->columnPosition(startCol));
end.setX(m_table->columnPosition(endCol) + m_table->columnWidth(endCol));
 
// Adjust coordinates for joining.
joinHorizontal(border, topLeft, left, bottomLeft, topRight, right, bottomRight,
&start, &end, &startOffsetFactors, &endOffsetFactors);
 
// Paint the border segment.
paintBorder(border, start, end, startOffsetFactors, endOffsetFactors, p);
}
}
 
void CollapsedTablePainterEx::paintCellFill(const TableCell& cell, ScPainterExBase* p) const
{
QString colorName = cell.fillColor();
 
if (colorName == CommonStrings::None)
return;
 
p->save();
 
ScribusDoc* doc = m_table->doc();
ScColorShade colorShade(doc->PageColors[colorName], (int) cell.fillShade());
p->setBrush(colorShade);
p->setFillMode(ScPainterExBase::Solid);
p->setStrokeMode(ScPainterExBase::None);
 
int row = cell.row();
int col = cell.column();
int lastRow = row + cell.rowSpan() - 1;
int lastCol = col + cell.columnSpan() - 1;
 
double x = m_table->columnPosition(col);
double y = m_table->rowPosition(row);
double width = m_table->columnPosition(lastCol) + m_table->columnWidth(lastCol) - x;
double height = m_table->rowPosition(lastRow) + m_table->rowHeight(lastRow) - y;
p->drawRect(x, y, width, height);
 
p->restore();
}
 
void CollapsedTablePainterEx::paintBorder(const TableBorder& border, const QPointF& start, const QPointF& end,
const QPointF& startOffsetFactors, const QPointF& endOffsetFactors,
ScPainterExBase *p) const
{
ScribusDoc* doc = m_table->doc();
 
p->save();
p->setStrokeMode(ScPainterExBase::Solid);
p->setFillMode(ScPainterExBase::None);
 
QColor lineColor;
QPointF lineStart, lineEnd;
foreach (const TableBorderLine& line, border.borderLines())
{
// Adjust line start and ends by line width multipled by offset factors.
lineStart.setX(start.x() + line.width() * startOffsetFactors.x());
lineStart.setY(start.y() + line.width() * startOffsetFactors.y());
lineEnd.setX(end.x() + line.width() * endOffsetFactors.x());
lineEnd.setY(end.y() + line.width() * endOffsetFactors.y());
// Set line color.
if (line.color() == CommonStrings::None)
continue;
// Draw line.
ScColorShade penColor(doc->PageColors[line.color()], (int) line.shade());
p->setPen(penColor, line.width(), line.style(), Qt::FlatCap, Qt::MiterJoin);
p->drawLine(lineStart, lineEnd);
}
 
p->restore();
}
/trunk/Scribus/scribus/collapsedtablepainterex.h
0,0 → 1,62
/*
Copyright (C) 2011 Elvis Stansvik <elvstone@gmail.com>
 
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#ifndef COLLAPSEDTABLEPAINTEREX_H
#define COLLAPSEDTABLEPAINTEREX_H
 
#include <QtGlobal>
 
#include "tableborder.h"
 
class PageItem_Table;
class TableCell;
class ScPainterExBase;
class ScPageOutput;
 
/**
* CollapsedTablePainter is a table painter for painting a table using the collapsed border model.
*/
class CollapsedTablePainterEx
{
public:
/// Creates a new collapsed table painter configured to paint @a table.
explicit CollapsedTablePainterEx(ScPageOutput* pageOutput, PageItem_Table* table);
 
/// Paints the table using @a p and returns the table offset.
virtual void paintTable(ScPainterExBase* p);
 
private:
PageItem_Table* m_table;
ScPageOutput* m_pageOutput;
/// Paints the fill of the table.
void paintTableFill(ScPainterExBase* p) const;
/// Paints all of the borders along the left side of @a cell.
void paintCellLeftBorders(const TableCell& cell, ScPainterExBase* p) const;
/// Paints all of the borders along the right side of @a cell.
void paintCellRightBorders(const TableCell& cell, ScPainterExBase* p) const;
/// Paints all of the borders along the top side of @a cell.
void paintCellTopBorders(const TableCell& cell, ScPainterExBase* p) const;
/// Paints all of the borders along the bottom side of @a cell.
void paintCellBottomBorders(const TableCell& cell, ScPainterExBase* p) const;
/// Paints the fill of @a cell.
void paintCellFill(const TableCell& cell, ScPainterExBase* p) const;
 
/**
* Paints @a border from @a start to @a end.
*
* @a startOffsetFactors and @a endOffsetFactors specifies offset factors for the individual
* border lines of @a border. Each start and end point of the border lines will be offset by
* their own width multiplied by these factors before being painted.
*/
void paintBorder(const TableBorder& border, const QPointF& start, const QPointF& end,
const QPointF& startOffsetFactors, const QPointF& endOffsetFactors, ScPainterExBase *p) const;
 
};
 
#endif // COLLAPSEDTABLEPAINTEREX_H
/trunk/Scribus/scribus/pageitem_textframe.cpp
3226,19 → 3226,11
double desc, asce;
// tTabValues.clear();
p->save(); //SA1
// QRect e2;
if (isEmbedded)
{
// e2 = cullingArea;
}
else
{
// e2 = QRect(qRound(cullingArea.x() / sc + m_Doc->minCanvasCoordinate.x()), qRound(cullingArea.y() / sc + m_Doc->minCanvasCoordinate.y()),
// qRound(cullingArea.width() / sc), qRound(cullingArea.height() / sc));
 
if (!isEmbedded)
pf2.translate(m_xPos, m_yPos);
}
pf2.rotate(m_rotation);
 
pf2.rotate(m_rotation);
if (!m_Doc->layerOutline(LayerID))
{
if ((fillColor() != CommonStrings::None) || (GrType != 0))
/trunk/Scribus/scribus/scpageoutput.cpp
12,6 → 12,7
#include <QStack>
 
#include "cmsettings.h"
#include "collapsedtablepainterex.h"
#include "commonstrings.h"
#include "pageitem.h"
#include "pageitem_arc.h"
23,6 → 24,7
#include "pageitem_polyline.h"
#include "pageitem_regularpolygon.h"
#include "pageitem_spiral.h"
#include "pageitem_table.h"
#include "pageitem_textframe.h"
#include "prefsmanager.h"
#include "scfonts.h"
105,7 → 107,7
drawMarks(page, painter, m_marksOptions);
}
 
void ScPageOutput::drawMasterItems(ScPainterExBase *painter, ScPage *page, ScLayer& layer, const QRect& clip)
void ScPageOutput::drawMasterItems(ScPainterExBase *painter, ScPage *page, ScLayer& layer, QRect clip)
{
PageItem* currItem;
if (page->MPageNam.isEmpty())
157,7 → 159,7
}
}
 
void ScPageOutput::drawPageItems(ScPainterExBase *painter, ScPage *page, ScLayer& layer, const QRect& clip)
void ScPageOutput::drawPageItems(ScPainterExBase *painter, ScPage *page, ScLayer& layer, QRect clip)
{
PageItem *currItem;
if (m_doc->Items->count() <= 0)
187,8 → 189,14
}
}
 
void ScPageOutput::drawItem( PageItem* item, ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::drawItem( PageItem* item, ScPainterExBase* painter, QRect clip )
{
if (clip.isNull())
{
clip = QRectF(QPointF(m_doc->minCanvasCoordinate.x(), m_doc->minCanvasCoordinate.y()),
QPointF(m_doc->maxCanvasCoordinate.x(), m_doc->maxCanvasCoordinate.y())).toAlignedRect();
}
 
drawItem_Pre(item, painter);
PageItem::ItemType itemType = item->itemType();
if (itemType == PageItem::Arc)
209,6 → 217,8
drawItem_RegularPolygon( (PageItem_RegularPolygon*) item, painter, clip);
else if (itemType == PageItem::Spiral)
drawItem_Spiral( (PageItem_Spiral*) item, painter, clip);
else if (itemType == PageItem::Table)
drawItem_Table( (PageItem_Table*) item, painter, clip);
else if (itemType == PageItem::TextFrame)
drawItem_TextFrame( (PageItem_TextFrame*) item, painter, clip);
drawItem_Post(item, painter);
496,7 → 506,7
painter->restore();
}
 
void ScPageOutput::drawGlyphs(PageItem* item, ScPainterExBase *painter, const CharStyle& style, GlyphLayout& glyphs, const QRect& clip)
void ScPageOutput::drawGlyphs(PageItem* item, ScPainterExBase *painter, const CharStyle& style, GlyphLayout& glyphs, QRect clip)
{
uint glyph = glyphs.glyph;
if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode())) // NBSPACE
649,7 → 659,7
}
}
 
void ScPageOutput::drawItem_Embedded( PageItem* item, ScPainterExBase *p, const QRect& clip, const CharStyle& style, PageItem* cembedded)
void ScPageOutput::drawItem_Embedded( PageItem* item, ScPainterExBase *p, QRect clip, const CharStyle& style, PageItem* cembedded)
{
if (!cembedded)
return;
702,7 → 712,7
}
}
 
void ScPageOutput::drawPattern( PageItem* item, ScPainterExBase* painter, const QRect& clip)
void ScPageOutput::drawPattern( PageItem* item, ScPainterExBase* painter, QRect clip)
{
double x1, x2, y1, y2;
ScPattern& pattern = m_doc->docPatterns[item->pattern()];
798,13 → 808,13
 
}
 
void ScPageOutput::drawItem_Arc ( PageItem_Arc* item , ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::drawItem_Arc ( PageItem_Arc* item , ScPainterExBase* painter, QRect clip )
{
painter->setupPolygon(&item->PoLine);
fillPath(item, painter, clip);
}
 
void ScPageOutput::drawItem_Group( PageItem_Group* item, ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::drawItem_Group( PageItem_Group* item, ScPainterExBase* painter, QRect clip )
{
if (item->groupItemList.isEmpty())
return;
876,7 → 886,7
painter->restore();
}
 
void ScPageOutput::drawItem_ImageFrame( PageItem_ImageFrame* item, ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::drawItem_ImageFrame( PageItem_ImageFrame* item, ScPainterExBase* painter, QRect clip )
{
ScPainterExBase::ImageMode mode = ScPainterExBase::rgbImages;
if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0))
964,7 → 974,7
}
}
 
void ScPageOutput::drawItem_Line( PageItem_Line* item, ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::drawItem_Line( PageItem_Line* item, ScPainterExBase* painter, QRect clip )
{
if (item->PoLine.size() < 4)
return;
1065,7 → 1075,7
}
}
 
void ScPageOutput::drawItem_PathText( PageItem_PathText* item, ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::drawItem_PathText( PageItem_PathText* item, ScPainterExBase* painter, QRect clip )
{
QString chstr;
//ScText *hl;
1246,13 → 1256,13
}
}
 
void ScPageOutput::drawItem_Polygon ( PageItem_Polygon* item , ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::drawItem_Polygon ( PageItem_Polygon* item , ScPainterExBase* painter, QRect clip )
{
painter->setupPolygon(&item->PoLine);
fillPath(item, painter, clip);
}
 
void ScPageOutput::drawItem_PolyLine( PageItem_PolyLine* item, ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::drawItem_PolyLine( PageItem_PolyLine* item, ScPainterExBase* painter, QRect clip )
{
if (item->PoLine.size() < 4)
return;
1412,13 → 1422,13
}
}
 
void ScPageOutput::drawItem_RegularPolygon( PageItem_RegularPolygon* item, ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::drawItem_RegularPolygon( PageItem_RegularPolygon* item, ScPainterExBase* painter, QRect clip )
{
painter->setupPolygon(&item->PoLine);
painter->fillPath();
}
 
void ScPageOutput::drawItem_Spiral( PageItem_Spiral* item, ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::drawItem_Spiral( PageItem_Spiral* item, ScPainterExBase* painter, QRect clip )
{
if (item->PoLine.size() < 4)
return;
1578,8 → 1588,23
}
}
 
void ScPageOutput::drawItem_TextFrame( PageItem_TextFrame* item, ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::drawItem_Table( PageItem_Table* item, ScPainterExBase* painter, QRect clip )
{
painter->save();
 
// Set the clip path.
painter->setupPolygon(&item->PoLine);
painter->setClipPath();
 
// Paint the table.
CollapsedTablePainterEx tablePainter(this, item);
tablePainter.paintTable(painter);
 
painter->restore();
}
 
void ScPageOutput::drawItem_TextFrame( PageItem_TextFrame* item, ScPainterExBase* painter, QRect cullingArea )
{
QTransform wm;
QPoint pt1, pt2;
FPoint ColBound;
1587,20 → 1612,15
int a;
double desc, asce;
QRect e2;
painter->save();
if (item->isEmbedded)
e2 = clip;
else
{
e2 = QRect(qRound(clip.x() + m_doc->minCanvasCoordinate.x()), qRound(clip.y() + m_doc->minCanvasCoordinate.y()), clip.width(), clip.height());
if (!item->isEmbedded)
wm.translate(item->xPos(), item->yPos());
}
wm.rotate(item->rotation());
 
if ((item->fillColor() != CommonStrings::None) || (item->GrType != 0))
{
painter->setupPolygon(&item->PoLine);
fillPath(item, painter, clip);
fillPath(item, painter, cullingArea);
}
if ((item->isAnnotation()) && (item->annotation().Type() == Annotation::Button) && (!item->Pfile.isEmpty()) && (item->imageIsAvailable) && (item->imageVisible()) && (item->annotation().UseIcons()))
{
1619,11 → 1639,15
{
painter->translate(item->width(), 0);
painter->scale(-1, 1);
wm.translate(item->width(), 0);
wm.scale(-1, 1);
}
if (item->imageFlippedV())
{
painter->translate(0, item->height());
painter->scale(1, -1);
wm.translate(0, item->height());
wm.scale(1, -1);
}
 
for (uint ll=0; ll < item->textLayout.lines(); ++ll)
1656,14 → 1680,14
ScColorShade tmp(m_doc->PageColors[charStyle.strokeColor()], (int) charStyle.strokeShade());
painter->setPen(tmp, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
}
if (e2.intersects(wm.mapRect(QRect(qRound(CurX + glyphs->xoffset),qRound(ls.y + glyphs->yoffset-asce), qRound(glyphs->xadvance+1), qRound(asce+desc)))))
if (item->isEmbedded || cullingArea.intersects(wm.mapRect(QRect(qRound(CurX + glyphs->xoffset),qRound(ls.y + glyphs->yoffset-asce), qRound(glyphs->xadvance+1), qRound(asce+desc)))))
{
painter->save();
painter->translate(CurX, ls.y);
if (item->itemText.hasObject(a))
drawItem_Embedded(item, painter, clip, charStyle, item->itemText.object(a));
drawItem_Embedded(item, painter, cullingArea, charStyle, item->itemText.object(a));
else
drawGlyphs(item, painter, charStyle, *glyphs, clip);
drawGlyphs(item, painter, charStyle, *glyphs, cullingArea);
painter->restore();
}
// Unneeded now that glyph xadvance is set appropriately for inline objects by PageItem_TextFrame::layout() - JG
1928,7 → 1952,7
painter->restore();
}
 
void ScPageOutput::fillPath( PageItem* item, ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::fillPath( PageItem* item, ScPainterExBase* painter, QRect clip )
{
if( painter->fillMode() == ScPainterExBase::Pattern && !painter->hasCapability(ScPainterExBase::patterns) )
drawPattern( item, painter, clip );
1936,7 → 1960,7
painter->fillPath();
}
 
void ScPageOutput::strokePath( PageItem* item, ScPainterExBase* painter, const QRect& clip )
void ScPageOutput::strokePath( PageItem* item, ScPainterExBase* painter, QRect clip )
{
painter->strokePath();
}
/trunk/Scribus/scribus/scpageoutput.h
28,6 → 28,7
class PageItem_PolyLine;
class PageItem_Spiral;
class PageItem_RegularPolygon;
class PageItem_Table;
class PageItem_TextFrame;
class ScLayer;
class ScribusDoc;
52,8 → 53,18
 
class SCRIBUS_API ScPageOutput
{
public:
ScPageOutput(ScribusDoc* doc, bool reloadImages = false, int resolution = 72, bool useProfiles = false);
virtual ~ScPageOutput() { }
 
virtual void begin(void) {};
virtual void drawPage( ScPage* page ) {};
virtual void drawPage( ScPage* page, ScPainterExBase* painter);
virtual void end(void) {};
 
void setMarksOptions(const MarksOptions& opt) { m_marksOptions = opt; }
 
protected:
 
ScribusDoc* m_doc;
 
bool m_reloadImages;
61,31 → 72,32
bool m_useProfiles;
MarksOptions m_marksOptions;
 
virtual void fillPath( PageItem* item, ScPainterExBase* painter, const QRect& clip );
virtual void strokePath( PageItem* item, ScPainterExBase* painter, const QRect& clip );
virtual void fillPath( PageItem* item, ScPainterExBase* painter, QRect clip );
virtual void strokePath( PageItem* item, ScPainterExBase* painter, QRect clip );
 
virtual void drawMasterItems( ScPainterExBase *painter, ScPage *page, ScLayer& layer, const QRect& clip);
virtual void drawPageItems( ScPainterExBase *painter, ScPage *page, ScLayer& layer, const QRect& clip);
virtual void drawMasterItems( ScPainterExBase *painter, ScPage *page, ScLayer& layer, QRect clip);
virtual void drawPageItems( ScPainterExBase *painter, ScPage *page, ScLayer& layer, QRect clip);
 
virtual void drawItem( PageItem* item, ScPainterExBase* painter, const QRect& clip );
virtual void drawItem( PageItem* item, ScPainterExBase* painter, QRect clip );
virtual void drawItem_Pre( PageItem* item, ScPainterExBase* painter );
virtual void drawItem_Post( PageItem* item, ScPainterExBase* painter );
 
virtual void drawGlyphs(PageItem* item, ScPainterExBase *painter, const CharStyle& style, GlyphLayout& glyphs, const QRect& clip);
virtual void drawItem_Embedded( PageItem* item, ScPainterExBase *p, const QRect& clip, const CharStyle& style, PageItem* cembedded);
virtual void drawPattern(PageItem* item, ScPainterExBase* painter, const QRect& clip);
virtual void drawGlyphs(PageItem* item, ScPainterExBase *painter, const CharStyle& style, GlyphLayout& glyphs, QRect clip);
virtual void drawItem_Embedded( PageItem* item, ScPainterExBase *p, QRect clip, const CharStyle& style, PageItem* cembedded);
virtual void drawPattern(PageItem* item, ScPainterExBase* painter, QRect clip);
virtual void drawStrokePattern(PageItem* item, ScPainterExBase* painter, const QPainterPath& path);
virtual void drawItem_Arc( PageItem_Arc* item, ScPainterExBase* painter, const QRect& clip );
virtual void drawItem_Group( PageItem_Group* item, ScPainterExBase* painter, const QRect& clip );
virtual void drawItem_ImageFrame( PageItem_ImageFrame* item, ScPainterExBase* painter, const QRect& clip );
virtual void drawItem_Line( PageItem_Line* item, ScPainterExBase* painter, const QRect& clip);
virtual void drawItem_PathText( PageItem_PathText* item, ScPainterExBase* painter, const QRect& clip );
virtual void drawItem_Polygon ( PageItem_Polygon* item , ScPainterExBase* painter, const QRect& clip );
virtual void drawItem_PolyLine( PageItem_PolyLine* item, ScPainterExBase* painte, const QRect& clip );
virtual void drawItem_RegularPolygon( PageItem_RegularPolygon* item, ScPainterExBase* painte, const QRect& clip );
virtual void drawItem_Spiral( PageItem_Spiral* item, ScPainterExBase* painter, const QRect& clip );
virtual void drawItem_TextFrame( PageItem_TextFrame* item, ScPainterExBase* painter, const QRect& clip );
virtual void drawItem_Arc( PageItem_Arc* item, ScPainterExBase* painter, QRect clip );
virtual void drawItem_Group( PageItem_Group* item, ScPainterExBase* painter, QRect clip );
virtual void drawItem_ImageFrame( PageItem_ImageFrame* item, ScPainterExBase* painter, QRect clip );
virtual void drawItem_Line( PageItem_Line* item, ScPainterExBase* painter, QRect clip);
virtual void drawItem_PathText( PageItem_PathText* item, ScPainterExBase* painter, QRect clip );
virtual void drawItem_Polygon ( PageItem_Polygon* item , ScPainterExBase* painter, QRect clip );
virtual void drawItem_PolyLine( PageItem_PolyLine* item, ScPainterExBase* painte, QRect clip );
virtual void drawItem_RegularPolygon( PageItem_RegularPolygon* item, ScPainterExBase* painte, QRect clip );
virtual void drawItem_Spiral( PageItem_Spiral* item, ScPainterExBase* painter, QRect clip );
virtual void drawItem_Table( PageItem_Table* item, ScPainterExBase* painter, QRect clip );
virtual void drawItem_TextFrame( PageItem_TextFrame* item, ScPainterExBase* painter, QRect clip );
 
virtual void drawArrow(ScPainterExBase* painter, PageItem* item, QTransform &arrowTrans, int arrowIndex);
virtual void drawMarks( ScPage* page, ScPainterExBase* painter, const MarksOptions& options );
94,17 → 106,7
 
ScImage::RequestType translateImageModeToRequest( ScPainterExBase::ImageMode mode);
 
public:
virtual ~ScPageOutput() { }
 
ScPageOutput(ScribusDoc* doc, bool reloadImages = false, int resolution = 72, bool useProfiles = false);
 
virtual void begin(void) {};
virtual void drawPage( ScPage* page ) {};
virtual void drawPage( ScPage* page, ScPainterExBase* painter);
virtual void end(void) {};
 
void setMarksOptions(const MarksOptions& opt) { m_marksOptions = opt; }
friend class CollapsedTablePainterEx;
};
 
#endif
/trunk/Scribus/scribus/scpageoutput_ps2.h
21,19 → 21,7
 
class SCRIBUS_API ScPageOutput_Ps2 : public ScPageOutput
{
protected:
 
QRect m_clip;
QIODevice* m_device;
QTextStream m_stream;
ScPs2OutputParams m_options;
 
int m_pageIndex;
 
virtual void initStream(QIODevice* dev);
 
public:
 
ScPageOutput_Ps2(QIODevice* dev, ScribusDoc* doc, int pageIndex, ScPs2OutputParams& options);
virtual ~ScPageOutput_Ps2();
 
43,6 → 31,16
 
const QRect clip(void);
void setClip(const QRect& rect) { m_clip = rect; }
 
protected:
QRect m_clip;
QIODevice* m_device;
QTextStream m_stream;
ScPs2OutputParams m_options;
 
int m_pageIndex;
 
virtual void initStream(QIODevice* dev);
};
 
#endif
/trunk/Scribus/scribus/scpainterex_cairo.cpp
120,6 → 120,11
cairo_translate(m_cr, x, y);
}
 
void ScPainterEx_Cairo::translate( const QPointF& offset )
{
cairo_translate(m_cr, offset.x(), offset.y());
}
 
void ScPainterEx_Cairo::rotate( double r )
{
cairo_rotate(m_cr, r * 3.1415927 / 180.0);
605,6 → 610,14
strokePath();
}
 
void ScPainterEx_Cairo::drawLine(const QPointF& start, const QPointF& end)
{
newPath();
moveTo(start.x(), start.y());
lineTo(end.x(), end.y());
strokePath();
}
 
void ScPainterEx_Cairo::drawRect(double x, double y, double w, double h)
{
newPath();
/trunk/Scribus/scribus/scpainterex_cairo.h
34,6 → 34,7
virtual void setWorldMatrix( const QTransform & );
virtual const QTransform worldMatrix();
virtual void translate( double, double );
virtual void translate( const QPointF& offset );
virtual void rotate( double );
virtual void scale( double, double );
 
71,6 → 72,7
virtual void drawPolygon();
virtual void drawPolyLine();
virtual void drawLine(FPoint start, FPoint end);
virtual void drawLine(const QPointF& start, const QPointF& end);
virtual void drawRect(double, double, double, double);
 
// pen + brush
/trunk/Scribus/scribus/scpainterex_ps2.cpp
186,6 → 186,11
m_matrix.translate(x, y);
}
 
void ScPainterEx_Ps2::translate( const QPointF& offset )
{
m_matrix.translate(offset.x(), offset.y());
}
 
void ScPainterEx_Ps2::rotate( double r )
{
m_matrix.rotate(r);
934,6 → 939,14
strokePath();
}
 
void ScPainterEx_Ps2::drawLine(const QPointF& start, const QPointF& end)
{
newPath();
moveTo(start.x(), start.y());
lineTo(end.x(), end.y());
strokePath();
}
 
void ScPainterEx_Ps2::drawRect(double x, double y, double w, double h)
{
newPath();
/trunk/Scribus/scribus/scpainterex_ps2.h
90,6 → 90,7
virtual void setWorldMatrix( const QTransform & );
virtual const QTransform worldMatrix();
virtual void translate( double, double );
virtual void translate( const QPointF& offset );
virtual void rotate( double );
virtual void scale( double, double );
 
132,6 → 133,7
virtual void drawPolygon();
virtual void drawPolyLine();
virtual void drawLine(FPoint start, FPoint end);
virtual void drawLine(const QPointF& start, const QPointF& end);
virtual void drawRect(double, double, double, double);
 
// pen + brush
/trunk/Scribus/scribus/scpainterexbase.h
34,6 → 34,7
#include <QList>
#include <QTransform>
#include <QPixmap>
#include <QPointF>
#include <QStack>
 
#include "scribusapi.h"
49,12 → 50,9
 
class SCRIBUS_API ScPainterExBase
{
protected:
int m_capabilities;
ScPainterExBase(void);
public:
virtual ~ScPainterExBase() {};
 
virtual ~ScPainterExBase() {};
enum FillMode { None, Solid, Gradient, Pattern };
enum ColorMode { rgbMode = 1, cmykMode = 2 };
enum ImageMode { cmykImages, rgbImages, rawImages };
76,6 → 74,7
virtual void setWorldMatrix( const QTransform & ) = 0;
virtual const QTransform worldMatrix() = 0;
virtual void translate( double, double ) = 0;
virtual void translate( const QPointF& offset ) = 0;
virtual void rotate( double ) = 0;
virtual void scale( double, double ) = 0;
 
112,6 → 111,7
virtual void drawPolygon() = 0;
virtual void drawPolyLine() = 0;
virtual void drawLine(FPoint start, FPoint end) = 0;
virtual void drawLine(const QPointF& start, const QPointF& end) = 0;
virtual void drawRect(double, double, double, double) = 0;
 
// pen + brush
142,6 → 142,10
ScPattern* m_pattern;
ScPattern* m_maskPattern;
QTransform m_patternTransform;
 
protected:
int m_capabilities;
ScPainterExBase(void);
};
 
#endif
/trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj
237,6 → 237,7
<ItemGroup>
<moc Include="..\..\..\scribus\appmodehelper.h" />
<ClInclude Include="..\..\..\scribus\appmodes.h" />
<ClInclude Include="..\..\..\scribus\collapsedtablepainterex.h" />
<ClInclude Include="..\..\..\scribus\colormgmt\sccolorspacedata_labdbl.h" />
<ClInclude Include="..\..\..\scribus\desaxe\actions.h" />
<ClInclude Include="..\..\..\scribus\desaxe\automata.h" />
894,6 → 895,7
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\scribus\appmodehelper.cpp" />
<ClCompile Include="..\..\..\scribus\collapsedtablepainterex.cpp" />
<ClCompile Include="..\..\..\scribus\desaxe\digester.cpp" />
<ClCompile Include="..\..\..\scribus\desaxe\digester_parse.cpp" />
<ClCompile Include="..\..\..\scribus\desaxe\saxfilter.cpp" />
/trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj.filters
1022,6 → 1022,9
<ClInclude Include="..\..\..\scribus\ui\ui_resourcemanagerlicensebase.h">
<Filter>Generated Form Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\scribus\collapsedtablepainterex.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\scribus\desaxe\digester.cpp">
2554,6 → 2557,9
<ClCompile Include="..\..\..\scribus\marks.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\scribus\collapsedtablepainterex.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Scribus.rc">