r17314 by fschmid - Tables: moved the commonly used functions for resolving table borders to tableutils
scribus-commit
scribus-commit at lists.scribus.net
Sat Feb 18 20:59:07 UTC 2012
Author: fschmid
Date: Sat Feb 18 20:59:07 2012
New Revision: 17314
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17314
Log:
Tables: moved the commonly used functions for resolving table borders to tableutils
Modified:
trunk/Scribus/scribus/collapsedtablepainter.cpp
trunk/Scribus/scribus/collapsedtablepainter.h
trunk/Scribus/scribus/pdflib_core.cpp
trunk/Scribus/scribus/pdflib_core.h
trunk/Scribus/scribus/pslib.cpp
trunk/Scribus/scribus/pslib.h
trunk/Scribus/scribus/tableutils.cpp
trunk/Scribus/scribus/tableutils.h
Modified: trunk/Scribus/scribus/collapsedtablepainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17314&path=/trunk/Scribus/scribus/collapsedtablepainter.cpp
==============================================================================
--- trunk/Scribus/scribus/collapsedtablepainter.cpp (original)
+++ trunk/Scribus/scribus/collapsedtablepainter.cpp Sat Feb 18 20:59:07 2012
@@ -163,214 +163,6 @@
p->restore();
}
-void CollapsedTablePainter::resolveBordersVertical(const TableCell& topLeftCell, const TableCell& topRightCell,
- const TableCell& leftCell, const TableCell& rightCell, const TableCell& bottomLeftCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* top, TableBorder* topRight,
- TableBorder* center, TableBorder* bottomLeft, TableBorder* bottom, TableBorder* bottomRight) const
-{
- Q_ASSERT(topLeft);
- Q_ASSERT(top);
- Q_ASSERT(topRight);
- Q_ASSERT(center);
- Q_ASSERT(bottomLeft);
- Q_ASSERT(bottom);
- Q_ASSERT(bottomRight);
-
- if (!leftCell.isValid() && !rightCell.isValid())
- {
- qWarning("leftCell and rightCell invalid!");
- return;
- }
-
- // Resolve top left.
- if (topLeftCell.row() == leftCell.row())
- *topLeft = TableBorder();
- else if (topLeftCell.isValid() && leftCell.isValid())
- *topLeft = collapseBorders(leftCell.topBorder(), topLeftCell.bottomBorder());
- else if (topLeftCell.isValid())
- *topLeft = collapseBorders(table()->bottomBorder(), topLeftCell.bottomBorder());
- else if (leftCell.isValid())
- *topLeft = collapseBorders(leftCell.topBorder(), table()->topBorder());
- else
- *topLeft = TableBorder();
-
- // Resolve top.
- if (topLeftCell.column() == topRightCell.column())
- *top = TableBorder();
- else if (topLeftCell.isValid() && topRightCell.isValid())
- *top = collapseBorders(topRightCell.leftBorder(), topLeftCell.rightBorder());
- else if (topLeftCell.isValid())
- *top = collapseBorders(table()->rightBorder(), topLeftCell.rightBorder());
- else if (topRightCell.isValid())
- *top = collapseBorders(topRightCell.leftBorder(), table()->leftBorder());
- else
- *top = TableBorder();
-
- // Resolve top right.
- if (topRightCell.row() == rightCell.row())
- *topRight = TableBorder();
- else if (topRightCell.isValid() && rightCell.isValid())
- *topRight = collapseBorders(rightCell.topBorder(), topRightCell.bottomBorder());
- else if (topRightCell.isValid())
- *topRight = collapseBorders(table()->bottomBorder(), topRightCell.bottomBorder());
- else if (rightCell.isValid())
- *topRight = collapseBorders(rightCell.topBorder(), table()->topBorder());
- else
- *topRight = TableBorder();
-
- // Resolve center.
- if (leftCell.column() == rightCell.column())
- *center = TableBorder();
- else if (leftCell.isValid() && rightCell.isValid())
- *center = collapseBorders(rightCell.leftBorder(), leftCell.rightBorder());
- else if (leftCell.isValid())
- *center = collapseBorders(table()->rightBorder(), leftCell.rightBorder());
- else if (rightCell.isValid())
- *center = collapseBorders(rightCell.leftBorder(), table()->leftBorder());
- else
- *center = TableBorder();
-
- // Resolve bottom left.
- if (bottomLeftCell.row() == leftCell.row())
- *bottomLeft = TableBorder();
- else if (bottomLeftCell.isValid() && leftCell.isValid())
- *bottomLeft = collapseBorders(bottomLeftCell.topBorder(), leftCell.bottomBorder());
- else if (bottomLeftCell.isValid())
- *bottomLeft = collapseBorders(bottomLeftCell.topBorder(), table()->topBorder());
- else if (leftCell.isValid())
- *bottomLeft = collapseBorders(table()->bottomBorder(), leftCell.bottomBorder());
- else
- *bottomLeft = TableBorder();
-
- // Resolve bottom.
- if (bottomLeftCell.column() == bottomRightCell.column())
- *bottom = TableBorder();
- else if (bottomLeftCell.isValid() && bottomRightCell.isValid())
- *bottom = collapseBorders(bottomRightCell.leftBorder(), bottomLeftCell.rightBorder());
- else if (bottomLeftCell.isValid())
- *bottom = collapseBorders(table()->rightBorder(), bottomLeftCell.rightBorder());
- else if (bottomRightCell.isValid())
- *bottom = collapseBorders(bottomRightCell.leftBorder(), table()->leftBorder());
- else
- *bottom = TableBorder();
-
- // Resolve bottom right.
- if (bottomRightCell.row() == rightCell.row())
- *bottomRight = TableBorder();
- else if (bottomRightCell.isValid() && rightCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.topBorder(), rightCell.bottomBorder());
- else if (bottomRightCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.topBorder(), table()->topBorder());
- else if (rightCell.isValid())
- *bottomRight = collapseBorders(table()->bottomBorder(), rightCell.bottomBorder());
- else
- *bottomRight = TableBorder();
-}
-
-void CollapsedTablePainter::resolveBordersHorizontal(const TableCell& topLeftCell, const TableCell& topCell,
- const TableCell& topRightCell, const TableCell& bottomLeftCell, const TableCell& bottomCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* left, TableBorder* bottomLeft,
- TableBorder* center, TableBorder* topRight, TableBorder* right, TableBorder* bottomRight) const
-{
- Q_ASSERT(topLeft);
- Q_ASSERT(left);
- Q_ASSERT(bottomLeft);
- Q_ASSERT(center);
- Q_ASSERT(topRight);
- Q_ASSERT(right);
- Q_ASSERT(bottomRight);
-
- if (!topCell.isValid() && !bottomCell.isValid())
- {
- qWarning("topCell and bottomCell invalid!");
- return;
- }
-
- // Resolve top left.
- if (topLeftCell.column() == topCell.column())
- *topLeft = TableBorder();
- else if (topLeftCell.isValid() && topCell.isValid())
- *topLeft = collapseBorders(topCell.leftBorder(), topLeftCell.rightBorder());
- else if (topLeftCell.isValid())
- *topLeft = collapseBorders(table()->rightBorder(), topLeftCell.rightBorder());
- else if (topCell.isValid())
- *topLeft = collapseBorders(topCell.leftBorder(), table()->leftBorder());
- else
- *topLeft = TableBorder();
-
- // Resolve left.
- if (topLeftCell.row() == bottomLeftCell.row())
- *left = TableBorder();
- else if (topLeftCell.isValid() && bottomLeftCell.isValid())
- *left = collapseBorders(bottomLeftCell.topBorder(), topLeftCell.bottomBorder());
- else if (topLeftCell.isValid())
- *left = collapseBorders(table()->bottomBorder(), topLeftCell.bottomBorder());
- else if (bottomLeftCell.isValid())
- *left = collapseBorders(bottomLeftCell.topBorder(), table()->topBorder());
- else
- *left = TableBorder();
-
- // Resolve bottom left.
- if (bottomLeftCell.column() == bottomCell.column())
- *bottomLeft = TableBorder();
- else if (bottomLeftCell.isValid() && bottomCell.isValid())
- *bottomLeft = collapseBorders(bottomCell.leftBorder(), bottomLeftCell.rightBorder());
- else if (bottomLeftCell.isValid())
- *bottomLeft = collapseBorders(table()->rightBorder(), bottomLeftCell.rightBorder());
- else if (bottomCell.isValid())
- *bottomLeft = collapseBorders(bottomCell.leftBorder(), table()->leftBorder());
- else
- *bottomLeft = TableBorder();
-
- // Resolve center.
- if (topCell.row() == bottomCell.row())
- *center = TableBorder();
- else if (topCell.isValid() && bottomCell.isValid())
- *center = collapseBorders(topCell.bottomBorder(), bottomCell.topBorder());
- else if (topCell.isValid())
- *center = collapseBorders(table()->bottomBorder(), topCell.bottomBorder());
- else if (bottomCell.isValid())
- *center = collapseBorders(bottomCell.topBorder(), table()->topBorder());
- else
- *center = TableBorder();
-
- // Resolve top right.
- if (topRightCell.column() == topCell.column())
- *topRight = TableBorder();
- else if (topRightCell.isValid() && topCell.isValid())
- *topRight = collapseBorders(topRightCell.leftBorder(), topCell.rightBorder());
- else if (topRightCell.isValid())
- *topRight = collapseBorders(topRightCell.leftBorder(), table()->leftBorder());
- else if (topCell.isValid())
- *topRight = collapseBorders(table()->rightBorder(), topCell.rightBorder());
- else
- *topRight = TableBorder();
-
- // Resolve right.
- if (topRightCell.row() == bottomRightCell.row())
- *right = TableBorder();
- else if (topRightCell.isValid() && bottomRightCell.isValid())
- *right = collapseBorders(bottomRightCell.topBorder(), topRightCell.bottomBorder());
- else if (topRightCell.isValid())
- *right = collapseBorders(table()->bottomBorder(), topRightCell.bottomBorder());
- else if (bottomRightCell.isValid())
- *right = collapseBorders(bottomRightCell.topBorder(), table()->topBorder());
- else
- *right = TableBorder();
-
- // Resolve bottom right.
- if (bottomRightCell.column() == bottomCell.column())
- *bottomRight = TableBorder();
- else if (bottomRightCell.isValid() && bottomCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.leftBorder(), bottomCell.rightBorder());
- else if (bottomRightCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.leftBorder(), table()->leftBorder());
- else if (bottomCell.isValid())
- *bottomRight = collapseBorders(table()->rightBorder(), bottomCell.rightBorder());
- else
- *bottomRight = TableBorder();
-}
-
void CollapsedTablePainter::paintCellLeftBorders(const TableCell& cell, ScPainter* p) const
{
/*
@@ -428,8 +220,7 @@
// 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);
+ resolveBordersVertical(topLeftCell, topRightCell, leftCell, cell, bottomLeftCell, bottomRightCell, &topLeft, &top, &topRight, &border, &bottomLeft, &bottom, &bottomRight, table());
if (border.isNull())
continue; // Quit early if the border to paint is null.
@@ -504,8 +295,7 @@
// 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);
+ resolveBordersVertical(topLeftCell, topRightCell, cell, rightCell, bottomLeftCell, bottomRightCell, &topLeft, &top, &topRight, &border, &bottomLeft, &bottom, &bottomRight, table());
if (border.isNull())
continue; // Quit early if the border to paint is null.
@@ -573,8 +363,7 @@
// 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);
+ resolveBordersHorizontal(topLeftCell, topCell, topRightCell, bottomLeftCell, cell, bottomRightCell, &topLeft, &left, &bottomLeft, &border, &topRight, &right, &bottomRight, table());
if (border.isNull())
continue; // Quit early if the border is null.
@@ -642,8 +431,7 @@
// 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);
+ resolveBordersHorizontal(topLeftCell, cell, topRightCell, bottomLeftCell, bottomCell, bottomRightCell, &topLeft, &left, &bottomLeft, &border, &topRight, &right, &bottomRight, table());
if (border.isNull())
continue; // Quit early if the border is null.
Modified: trunk/Scribus/scribus/collapsedtablepainter.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17314&path=/trunk/Scribus/scribus/collapsedtablepainter.h
==============================================================================
--- trunk/Scribus/scribus/collapsedtablepainter.h (original)
+++ trunk/Scribus/scribus/collapsedtablepainter.h Sat Feb 18 20:59:07 2012
@@ -57,93 +57,6 @@
/// Paints a decorative thin blue line from @a start to @a end.
void paintGridLine(const QPointF& start, const QPointF& end, ScPainter *p) const;
- /**
- * Resolves the collapsed borders between six cells in a 2x3 area.
- *
- * Given the six cells @a topLeftCell, @a topRightCell, @a leftCell, @a rightCell,
- * @a bottomLeftCell and @a bottomRightCell in the following picture
- *
- * <pre>
- * +----------------------+----------------------+
- * | | |
- * | | |
- * | topLeftCell top topRightCell |
- * | | |
- * | | |
- * +--------topLeft-------+-------topRight-------+
- * | | |
- * | | |
- * | leftCell center rightCell |
- * | | |
- * | | |
- * +-------bottomLeft-----+------bottomRight-----+
- * | | |
- * | | |
- * | bottomLeftCell bottom bottomRightCell |
- * | | |
- * | | |
- * +----------------------+----------------------+
- * </pre>
- *
- * the function will return the collapsed borders @a topLeft, @a top, @a topRight,
- * @a center, @a bottomLeft, @a bottom and @a bottomRight. If two adjacent cells are
- * invalid, the returned collapsed border between them is null. If only one of two adjacent
- * cells is valid, the returned collapsed border will be the border of the valid cell
- * collapsed with the appropriate table border instead. If two "adjacent" cells are
- * actually the same cell, the returned collapsed border between them is null.
- *
- * If both @a leftCell and @a rightCell are invalid, the function will print a
- * warning message and return immediately, leaving @a topLeft, @a top, @a topRight,
- * @a center, @a bottomLeft, @a bottom and @a bottomRight unchanged.
- *
- * @a topLeft, @a top, @a topRight, @a center, @a bottomLeft, @a bottom and
- * @a bottomRight must point to existing borders.
- */
- void resolveBordersVertical(const TableCell& topLeftCell, const TableCell& topRightCell,
- const TableCell& leftCell, const TableCell& rightCell, const TableCell& bottomLeftCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* top, TableBorder* topRight,
- TableBorder* center, TableBorder* bottomLeft, TableBorder* bottom, TableBorder* bottomRight) const;
-
- /**
- * Resolves the collapsed borders between six cells in a 3x2 area.
- *
- * Given the six cells @a topLeftCell, @a topCell, @a topRightCell, @a bottomLeftCell,
- * @a bottomCell and @a bottomRightCell in the following picture
- *
- * <pre>
- * +--------------------------+--------------------------+--------------------------+
- * | | | |
- * | | | |
- * | topLeftCell topLeft topCell topRight topRightCell |
- * | | | |
- * | | | |
- * +----------left------------+--------- center ---------+----------right-----------+
- * | | | |
- * | | | |
- * | bottomLeftCell bottomLeft bottomCell bottomRight bottomRightCell |
- * | | | |
- * | | | |
- * +--------------------------+--------------------------+--------------------------+
- * </pre>
- *
- * the function will return the collapsed borders @a topLeft, @a left, @a bottomLeft,
- * @a center, @a topRight, @a right and @a bottomRight. If two adjacent cells are invalid,
- * the returned collapsed border between them is null. If only one of two adjacent cells is
- * valid, the returned collapsed border will be the border of the valid cell collapsed with
- * the appropriate table border instead. If two "adjacent" cells are actually the same
- * cell, the returned collapsed border between them is null.
- *
- * If both @a topCell and @a bottomCell are invalid, the function will print a
- * warning message and return immediately, leaving @a topLeft, @a top, @a bottomLeft,
- * @a center, @a topRight, @a right and @a bottomRight unchanged.
- *
- * @a topLeft, @a left , @a bottomLeft, @a center, @a topRight, @a right and
- * @a bottomRight must point to existing borders.
- */
- void resolveBordersHorizontal(const TableCell& topLeftCell, const TableCell& topCell,
- const TableCell& topRightCell, const TableCell& bottomLeftCell, const TableCell& bottomCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* left, TableBorder* bottomLeft,
- TableBorder* center, TableBorder* topRight, TableBorder* right, TableBorder* bottomRight) const;
};
#endif // COLLAPSEDTABLEPAINTER_H
Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17314&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Sat Feb 18 20:59:07 2012
@@ -4679,169 +4679,6 @@
return tmp;
}
-void PDFLibCore::resolveBordersHorizontal(const TableCell& topLeftCell, const TableCell& topCell,
- const TableCell& topRightCell, const TableCell& bottomLeftCell, const TableCell& bottomCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* left, TableBorder* bottomLeft,
- TableBorder* center, TableBorder* topRight, TableBorder* right, TableBorder* bottomRight, PageItem_Table* table)
-{
- if (!topCell.isValid() && !bottomCell.isValid())
- return;
- if (topLeftCell.column() == topCell.column())
- *topLeft = TableBorder();
- else if (topLeftCell.isValid() && topCell.isValid())
- *topLeft = collapseBorders(topCell.leftBorder(), topLeftCell.rightBorder());
- else if (topLeftCell.isValid())
- *topLeft = collapseBorders(table->rightBorder(), topLeftCell.rightBorder());
- else if (topCell.isValid())
- *topLeft = collapseBorders(topCell.leftBorder(), table->leftBorder());
- else
- *topLeft = TableBorder();
- if (topLeftCell.row() == bottomLeftCell.row())
- *left = TableBorder();
- else if (topLeftCell.isValid() && bottomLeftCell.isValid())
- *left = collapseBorders(bottomLeftCell.topBorder(), topLeftCell.bottomBorder());
- else if (topLeftCell.isValid())
- *left = collapseBorders(table->bottomBorder(), topLeftCell.bottomBorder());
- else if (bottomLeftCell.isValid())
- *left = collapseBorders(bottomLeftCell.topBorder(), table->topBorder());
- else
- *left = TableBorder();
- if (bottomLeftCell.column() == bottomCell.column())
- *bottomLeft = TableBorder();
- else if (bottomLeftCell.isValid() && bottomCell.isValid())
- *bottomLeft = collapseBorders(bottomCell.leftBorder(), bottomLeftCell.rightBorder());
- else if (bottomLeftCell.isValid())
- *bottomLeft = collapseBorders(table->rightBorder(), bottomLeftCell.rightBorder());
- else if (bottomCell.isValid())
- *bottomLeft = collapseBorders(bottomCell.leftBorder(), table->leftBorder());
- else
- *bottomLeft = TableBorder();
- if (topCell.row() == bottomCell.row())
- *center = TableBorder();
- else if (topCell.isValid() && bottomCell.isValid())
- *center = collapseBorders(topCell.bottomBorder(), bottomCell.topBorder());
- else if (topCell.isValid())
- *center = collapseBorders(table->bottomBorder(), topCell.bottomBorder());
- else if (bottomCell.isValid())
- *center = collapseBorders(bottomCell.topBorder(), table->topBorder());
- else
- *center = TableBorder();
- if (topRightCell.column() == topCell.column())
- *topRight = TableBorder();
- else if (topRightCell.isValid() && topCell.isValid())
- *topRight = collapseBorders(topRightCell.leftBorder(), topCell.rightBorder());
- else if (topRightCell.isValid())
- *topRight = collapseBorders(topRightCell.leftBorder(), table->leftBorder());
- else if (topCell.isValid())
- *topRight = collapseBorders(table->rightBorder(), topCell.rightBorder());
- else
- *topRight = TableBorder();
- if (topRightCell.row() == bottomRightCell.row())
- *right = TableBorder();
- else if (topRightCell.isValid() && bottomRightCell.isValid())
- *right = collapseBorders(bottomRightCell.topBorder(), topRightCell.bottomBorder());
- else if (topRightCell.isValid())
- *right = collapseBorders(table->bottomBorder(), topRightCell.bottomBorder());
- else if (bottomRightCell.isValid())
- *right = collapseBorders(bottomRightCell.topBorder(), table->topBorder());
- else
- *right = TableBorder();
- if (bottomRightCell.column() == bottomCell.column())
- *bottomRight = TableBorder();
- else if (bottomRightCell.isValid() && bottomCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.leftBorder(), bottomCell.rightBorder());
- else if (bottomRightCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.leftBorder(), table->leftBorder());
- else if (bottomCell.isValid())
- *bottomRight = collapseBorders(table->rightBorder(), bottomCell.rightBorder());
- else
- *bottomRight = TableBorder();
-}
-
-void PDFLibCore::resolveBordersVertical(const TableCell& topLeftCell, const TableCell& topRightCell, const TableCell& leftCell, const TableCell& rightCell, const TableCell& bottomLeftCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* top, TableBorder* topRight, TableBorder* center, TableBorder* bottomLeft, TableBorder* bottom, TableBorder* bottomRight, PageItem_Table* table)
-{
- if (!leftCell.isValid() && !rightCell.isValid())
- return;
- // Resolve top left.
- if (topLeftCell.row() == leftCell.row())
- *topLeft = TableBorder();
- else if (topLeftCell.isValid() && leftCell.isValid())
- *topLeft = collapseBorders(leftCell.topBorder(), topLeftCell.bottomBorder());
- else if (topLeftCell.isValid())
- *topLeft = collapseBorders(table->bottomBorder(), topLeftCell.bottomBorder());
- else if (leftCell.isValid())
- *topLeft = collapseBorders(leftCell.topBorder(), table->topBorder());
- else
- *topLeft = TableBorder();
- // Resolve top.
- if (topLeftCell.column() == topRightCell.column())
- *top = TableBorder();
- else if (topLeftCell.isValid() && topRightCell.isValid())
- *top = collapseBorders(topRightCell.leftBorder(), topLeftCell.rightBorder());
- else if (topLeftCell.isValid())
- *top = collapseBorders(table->rightBorder(), topLeftCell.rightBorder());
- else if (topRightCell.isValid())
- *top = collapseBorders(topRightCell.leftBorder(), table->leftBorder());
- else
- *top = TableBorder();
- // Resolve top right.
- if (topRightCell.row() == rightCell.row())
- *topRight = TableBorder();
- else if (topRightCell.isValid() && rightCell.isValid())
- *topRight = collapseBorders(rightCell.topBorder(), topRightCell.bottomBorder());
- else if (topRightCell.isValid())
- *topRight = collapseBorders(table->bottomBorder(), topRightCell.bottomBorder());
- else if (rightCell.isValid())
- *topRight = collapseBorders(rightCell.topBorder(), table->topBorder());
- else
- *topRight = TableBorder();
- // Resolve center.
- if (leftCell.column() == rightCell.column())
- *center = TableBorder();
- else if (leftCell.isValid() && rightCell.isValid())
- *center = collapseBorders(rightCell.leftBorder(), leftCell.rightBorder());
- else if (leftCell.isValid())
- *center = collapseBorders(table->rightBorder(), leftCell.rightBorder());
- else if (rightCell.isValid())
- *center = collapseBorders(rightCell.leftBorder(), table->leftBorder());
- else
- *center = TableBorder();
- // Resolve bottom left.
- if (bottomLeftCell.row() == leftCell.row())
- *bottomLeft = TableBorder();
- else if (bottomLeftCell.isValid() && leftCell.isValid())
- *bottomLeft = collapseBorders(bottomLeftCell.topBorder(), leftCell.bottomBorder());
- else if (bottomLeftCell.isValid())
- *bottomLeft = collapseBorders(bottomLeftCell.topBorder(), table->topBorder());
- else if (leftCell.isValid())
- *bottomLeft = collapseBorders(table->bottomBorder(), leftCell.bottomBorder());
- else
- *bottomLeft = TableBorder();
- // Resolve bottom.
- if (bottomLeftCell.column() == bottomRightCell.column())
- *bottom = TableBorder();
- else if (bottomLeftCell.isValid() && bottomRightCell.isValid())
- *bottom = collapseBorders(bottomRightCell.leftBorder(), bottomLeftCell.rightBorder());
- else if (bottomLeftCell.isValid())
- *bottom = collapseBorders(table->rightBorder(), bottomLeftCell.rightBorder());
- else if (bottomRightCell.isValid())
- *bottom = collapseBorders(bottomRightCell.leftBorder(), table->leftBorder());
- else
- *bottom = TableBorder();
- // Resolve bottom right.
- if (bottomRightCell.row() == rightCell.row())
- *bottomRight = TableBorder();
- else if (bottomRightCell.isValid() && rightCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.topBorder(), rightCell.bottomBorder());
- else if (bottomRightCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.topBorder(), table->topBorder());
- else if (rightCell.isValid())
- *bottomRight = collapseBorders(table->bottomBorder(), rightCell.bottomBorder());
- else
- *bottomRight = TableBorder();
-}
-
QString PDFLibCore::HandleBrushPattern(PageItem* ite, QPainterPath &path, const ScPage* pag, uint PNr)
{
QString tmp;
Modified: trunk/Scribus/scribus/pdflib_core.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17314&path=/trunk/Scribus/scribus/pdflib_core.h
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.h (original)
+++ trunk/Scribus/scribus/pdflib_core.h Sat Feb 18 20:59:07 2012
@@ -30,7 +30,6 @@
class MultiProgressDialog;
class ScLayer;
class ScText;
-class TableCell;
#include "scribusstructs.h"
#include "scimagestructs.h"
@@ -153,14 +152,6 @@
bool PDF_ProcessItem(QString& output, PageItem* ite, const ScPage* pag, uint PNr, bool embedded = false, bool pattern = false);
QString PDF_ProcessTableItem(PageItem* ite, const ScPage* pag);
QString paintBorder(const TableBorder& border, const QPointF& start, const QPointF& end, const QPointF& startOffsetFactors, const QPointF& endOffsetFactors);
- void resolveBordersHorizontal(const TableCell& topLeftCell, const TableCell& topCell,
- const TableCell& topRightCell, const TableCell& bottomLeftCell, const TableCell& bottomCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* left, TableBorder* bottomLeft,
- TableBorder* center, TableBorder* topRight, TableBorder* right, TableBorder* bottomRight, PageItem_Table* table);
- void resolveBordersVertical(const TableCell& topLeftCell, const TableCell& topRightCell,
- const TableCell& leftCell, const TableCell& rightCell, const TableCell& bottomLeftCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* top, TableBorder* topRight,
- TableBorder* center, TableBorder* bottomLeft, TableBorder* bottom, TableBorder* bottomRight, PageItem_Table* table);
QString HandleBrushPattern(PageItem* ite, QPainterPath &path, const ScPage* pag, uint PNr);
QString drawArrow(PageItem *ite, QTransform &arrowTrans, int arrowIndex);
void PDF_Bookmark(PageItem *currItem, double ypos);
Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17314&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp (original)
+++ trunk/Scribus/scribus/pslib.cpp Sat Feb 18 20:59:07 2012
@@ -2881,169 +2881,6 @@
putColor(line.color(), line.shade(), false);
}
PS_restore();
-}
-
-void PSLib::resolveBordersHorizontal(const TableCell& topLeftCell, const TableCell& topCell,
- const TableCell& topRightCell, const TableCell& bottomLeftCell, const TableCell& bottomCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* left, TableBorder* bottomLeft,
- TableBorder* center, TableBorder* topRight, TableBorder* right, TableBorder* bottomRight, PageItem_Table* table)
-{
- if (!topCell.isValid() && !bottomCell.isValid())
- return;
- if (topLeftCell.column() == topCell.column())
- *topLeft = TableBorder();
- else if (topLeftCell.isValid() && topCell.isValid())
- *topLeft = collapseBorders(topCell.leftBorder(), topLeftCell.rightBorder());
- else if (topLeftCell.isValid())
- *topLeft = collapseBorders(table->rightBorder(), topLeftCell.rightBorder());
- else if (topCell.isValid())
- *topLeft = collapseBorders(topCell.leftBorder(), table->leftBorder());
- else
- *topLeft = TableBorder();
- if (topLeftCell.row() == bottomLeftCell.row())
- *left = TableBorder();
- else if (topLeftCell.isValid() && bottomLeftCell.isValid())
- *left = collapseBorders(bottomLeftCell.topBorder(), topLeftCell.bottomBorder());
- else if (topLeftCell.isValid())
- *left = collapseBorders(table->bottomBorder(), topLeftCell.bottomBorder());
- else if (bottomLeftCell.isValid())
- *left = collapseBorders(bottomLeftCell.topBorder(), table->topBorder());
- else
- *left = TableBorder();
- if (bottomLeftCell.column() == bottomCell.column())
- *bottomLeft = TableBorder();
- else if (bottomLeftCell.isValid() && bottomCell.isValid())
- *bottomLeft = collapseBorders(bottomCell.leftBorder(), bottomLeftCell.rightBorder());
- else if (bottomLeftCell.isValid())
- *bottomLeft = collapseBorders(table->rightBorder(), bottomLeftCell.rightBorder());
- else if (bottomCell.isValid())
- *bottomLeft = collapseBorders(bottomCell.leftBorder(), table->leftBorder());
- else
- *bottomLeft = TableBorder();
- if (topCell.row() == bottomCell.row())
- *center = TableBorder();
- else if (topCell.isValid() && bottomCell.isValid())
- *center = collapseBorders(topCell.bottomBorder(), bottomCell.topBorder());
- else if (topCell.isValid())
- *center = collapseBorders(table->bottomBorder(), topCell.bottomBorder());
- else if (bottomCell.isValid())
- *center = collapseBorders(bottomCell.topBorder(), table->topBorder());
- else
- *center = TableBorder();
- if (topRightCell.column() == topCell.column())
- *topRight = TableBorder();
- else if (topRightCell.isValid() && topCell.isValid())
- *topRight = collapseBorders(topRightCell.leftBorder(), topCell.rightBorder());
- else if (topRightCell.isValid())
- *topRight = collapseBorders(topRightCell.leftBorder(), table->leftBorder());
- else if (topCell.isValid())
- *topRight = collapseBorders(table->rightBorder(), topCell.rightBorder());
- else
- *topRight = TableBorder();
- if (topRightCell.row() == bottomRightCell.row())
- *right = TableBorder();
- else if (topRightCell.isValid() && bottomRightCell.isValid())
- *right = collapseBorders(bottomRightCell.topBorder(), topRightCell.bottomBorder());
- else if (topRightCell.isValid())
- *right = collapseBorders(table->bottomBorder(), topRightCell.bottomBorder());
- else if (bottomRightCell.isValid())
- *right = collapseBorders(bottomRightCell.topBorder(), table->topBorder());
- else
- *right = TableBorder();
- if (bottomRightCell.column() == bottomCell.column())
- *bottomRight = TableBorder();
- else if (bottomRightCell.isValid() && bottomCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.leftBorder(), bottomCell.rightBorder());
- else if (bottomRightCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.leftBorder(), table->leftBorder());
- else if (bottomCell.isValid())
- *bottomRight = collapseBorders(table->rightBorder(), bottomCell.rightBorder());
- else
- *bottomRight = TableBorder();
-}
-
-void PSLib::resolveBordersVertical(const TableCell& topLeftCell, const TableCell& topRightCell, const TableCell& leftCell, const TableCell& rightCell, const TableCell& bottomLeftCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* top, TableBorder* topRight, TableBorder* center, TableBorder* bottomLeft, TableBorder* bottom, TableBorder* bottomRight, PageItem_Table* table)
-{
- if (!leftCell.isValid() && !rightCell.isValid())
- return;
- // Resolve top left.
- if (topLeftCell.row() == leftCell.row())
- *topLeft = TableBorder();
- else if (topLeftCell.isValid() && leftCell.isValid())
- *topLeft = collapseBorders(leftCell.topBorder(), topLeftCell.bottomBorder());
- else if (topLeftCell.isValid())
- *topLeft = collapseBorders(table->bottomBorder(), topLeftCell.bottomBorder());
- else if (leftCell.isValid())
- *topLeft = collapseBorders(leftCell.topBorder(), table->topBorder());
- else
- *topLeft = TableBorder();
- // Resolve top.
- if (topLeftCell.column() == topRightCell.column())
- *top = TableBorder();
- else if (topLeftCell.isValid() && topRightCell.isValid())
- *top = collapseBorders(topRightCell.leftBorder(), topLeftCell.rightBorder());
- else if (topLeftCell.isValid())
- *top = collapseBorders(table->rightBorder(), topLeftCell.rightBorder());
- else if (topRightCell.isValid())
- *top = collapseBorders(topRightCell.leftBorder(), table->leftBorder());
- else
- *top = TableBorder();
- // Resolve top right.
- if (topRightCell.row() == rightCell.row())
- *topRight = TableBorder();
- else if (topRightCell.isValid() && rightCell.isValid())
- *topRight = collapseBorders(rightCell.topBorder(), topRightCell.bottomBorder());
- else if (topRightCell.isValid())
- *topRight = collapseBorders(table->bottomBorder(), topRightCell.bottomBorder());
- else if (rightCell.isValid())
- *topRight = collapseBorders(rightCell.topBorder(), table->topBorder());
- else
- *topRight = TableBorder();
- // Resolve center.
- if (leftCell.column() == rightCell.column())
- *center = TableBorder();
- else if (leftCell.isValid() && rightCell.isValid())
- *center = collapseBorders(rightCell.leftBorder(), leftCell.rightBorder());
- else if (leftCell.isValid())
- *center = collapseBorders(table->rightBorder(), leftCell.rightBorder());
- else if (rightCell.isValid())
- *center = collapseBorders(rightCell.leftBorder(), table->leftBorder());
- else
- *center = TableBorder();
- // Resolve bottom left.
- if (bottomLeftCell.row() == leftCell.row())
- *bottomLeft = TableBorder();
- else if (bottomLeftCell.isValid() && leftCell.isValid())
- *bottomLeft = collapseBorders(bottomLeftCell.topBorder(), leftCell.bottomBorder());
- else if (bottomLeftCell.isValid())
- *bottomLeft = collapseBorders(bottomLeftCell.topBorder(), table->topBorder());
- else if (leftCell.isValid())
- *bottomLeft = collapseBorders(table->bottomBorder(), leftCell.bottomBorder());
- else
- *bottomLeft = TableBorder();
- // Resolve bottom.
- if (bottomLeftCell.column() == bottomRightCell.column())
- *bottom = TableBorder();
- else if (bottomLeftCell.isValid() && bottomRightCell.isValid())
- *bottom = collapseBorders(bottomRightCell.leftBorder(), bottomLeftCell.rightBorder());
- else if (bottomLeftCell.isValid())
- *bottom = collapseBorders(table->rightBorder(), bottomLeftCell.rightBorder());
- else if (bottomRightCell.isValid())
- *bottom = collapseBorders(bottomRightCell.leftBorder(), table->leftBorder());
- else
- *bottom = TableBorder();
- // Resolve bottom right.
- if (bottomRightCell.row() == rightCell.row())
- *bottomRight = TableBorder();
- else if (bottomRightCell.isValid() && rightCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.topBorder(), rightCell.bottomBorder());
- else if (bottomRightCell.isValid())
- *bottomRight = collapseBorders(bottomRightCell.topBorder(), table->topBorder());
- else if (rightCell.isValid())
- *bottomRight = collapseBorders(table->bottomBorder(), rightCell.bottomBorder());
- else
- *bottomRight = TableBorder();
}
void PSLib::ProcessPage(ScribusDoc* Doc, ScPage* a, uint PNr, bool sep, bool farb, bool ic, bool gcr)
Modified: trunk/Scribus/scribus/pslib.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17314&path=/trunk/Scribus/scribus/pslib.h
==============================================================================
--- trunk/Scribus/scribus/pslib.h (original)
+++ trunk/Scribus/scribus/pslib.h Sat Feb 18 20:59:07 2012
@@ -48,7 +48,6 @@
class MultiProgressDialog;
class ScImage;
class ScLayer;
-class TableCell;
/**
*@author Franz Schmid
@@ -165,14 +164,6 @@
void encodeColor(QDataStream &vs, QString col);
void paintBorder(const TableBorder& border, const QPointF& start, const QPointF& end, const QPointF& startOffsetFactors, const QPointF& endOffsetFactors, bool gcr);
- void resolveBordersHorizontal(const TableCell& topLeftCell, const TableCell& topCell,
- const TableCell& topRightCell, const TableCell& bottomLeftCell, const TableCell& bottomCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* left, TableBorder* bottomLeft,
- TableBorder* center, TableBorder* topRight, TableBorder* right, TableBorder* bottomRight, PageItem_Table* table);
- void resolveBordersVertical(const TableCell& topLeftCell, const TableCell& topRightCell,
- const TableCell& leftCell, const TableCell& rightCell, const TableCell& bottomLeftCell,
- const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* top, TableBorder* topRight,
- TableBorder* center, TableBorder* bottomLeft, TableBorder* bottom, TableBorder* bottomRight, PageItem_Table* table);
Optimization optimization;
Modified: trunk/Scribus/scribus/tableutils.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17314&path=/trunk/Scribus/scribus/tableutils.cpp
==============================================================================
--- trunk/Scribus/scribus/tableutils.cpp (original)
+++ trunk/Scribus/scribus/tableutils.cpp Sat Feb 18 20:59:07 2012
@@ -12,9 +12,180 @@
#include "tableborder.h"
#include "tableutils.h"
+#include "pageitem_table.h"
namespace TableUtils
{
+
+void resolveBordersHorizontal(const TableCell& topLeftCell, const TableCell& topCell,
+ const TableCell& topRightCell, const TableCell& bottomLeftCell, const TableCell& bottomCell,
+ const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* left, TableBorder* bottomLeft,
+ TableBorder* center, TableBorder* topRight, TableBorder* right, TableBorder* bottomRight, PageItem_Table* table)
+{
+ // Resolve top left.
+ if (!topCell.isValid() && !bottomCell.isValid())
+ return;
+ if (topLeftCell.column() == topCell.column())
+ *topLeft = TableBorder();
+ else if (topLeftCell.isValid() && topCell.isValid())
+ *topLeft = collapseBorders(topCell.leftBorder(), topLeftCell.rightBorder());
+ else if (topLeftCell.isValid())
+ *topLeft = collapseBorders(table->rightBorder(), topLeftCell.rightBorder());
+ else if (topCell.isValid())
+ *topLeft = collapseBorders(topCell.leftBorder(), table->leftBorder());
+ else
+ *topLeft = TableBorder();
+ // Resolve left.
+ if (topLeftCell.row() == bottomLeftCell.row())
+ *left = TableBorder();
+ else if (topLeftCell.isValid() && bottomLeftCell.isValid())
+ *left = collapseBorders(bottomLeftCell.topBorder(), topLeftCell.bottomBorder());
+ else if (topLeftCell.isValid())
+ *left = collapseBorders(table->bottomBorder(), topLeftCell.bottomBorder());
+ else if (bottomLeftCell.isValid())
+ *left = collapseBorders(bottomLeftCell.topBorder(), table->topBorder());
+ else
+ *left = TableBorder();
+ // Resolve bottom left.
+ if (bottomLeftCell.column() == bottomCell.column())
+ *bottomLeft = TableBorder();
+ else if (bottomLeftCell.isValid() && bottomCell.isValid())
+ *bottomLeft = collapseBorders(bottomCell.leftBorder(), bottomLeftCell.rightBorder());
+ else if (bottomLeftCell.isValid())
+ *bottomLeft = collapseBorders(table->rightBorder(), bottomLeftCell.rightBorder());
+ else if (bottomCell.isValid())
+ *bottomLeft = collapseBorders(bottomCell.leftBorder(), table->leftBorder());
+ else
+ *bottomLeft = TableBorder();
+ // Resolve center.
+ if (topCell.row() == bottomCell.row())
+ *center = TableBorder();
+ else if (topCell.isValid() && bottomCell.isValid())
+ *center = collapseBorders(topCell.bottomBorder(), bottomCell.topBorder());
+ else if (topCell.isValid())
+ *center = collapseBorders(table->bottomBorder(), topCell.bottomBorder());
+ else if (bottomCell.isValid())
+ *center = collapseBorders(bottomCell.topBorder(), table->topBorder());
+ else
+ *center = TableBorder();
+ // Resolve top right.
+ if (topRightCell.column() == topCell.column())
+ *topRight = TableBorder();
+ else if (topRightCell.isValid() && topCell.isValid())
+ *topRight = collapseBorders(topRightCell.leftBorder(), topCell.rightBorder());
+ else if (topRightCell.isValid())
+ *topRight = collapseBorders(topRightCell.leftBorder(), table->leftBorder());
+ else if (topCell.isValid())
+ *topRight = collapseBorders(table->rightBorder(), topCell.rightBorder());
+ else
+ *topRight = TableBorder();
+ // Resolve right.
+ if (topRightCell.row() == bottomRightCell.row())
+ *right = TableBorder();
+ else if (topRightCell.isValid() && bottomRightCell.isValid())
+ *right = collapseBorders(bottomRightCell.topBorder(), topRightCell.bottomBorder());
+ else if (topRightCell.isValid())
+ *right = collapseBorders(table->bottomBorder(), topRightCell.bottomBorder());
+ else if (bottomRightCell.isValid())
+ *right = collapseBorders(bottomRightCell.topBorder(), table->topBorder());
+ else
+ *right = TableBorder();
+ // Resolve bottom right.
+ if (bottomRightCell.column() == bottomCell.column())
+ *bottomRight = TableBorder();
+ else if (bottomRightCell.isValid() && bottomCell.isValid())
+ *bottomRight = collapseBorders(bottomRightCell.leftBorder(), bottomCell.rightBorder());
+ else if (bottomRightCell.isValid())
+ *bottomRight = collapseBorders(bottomRightCell.leftBorder(), table->leftBorder());
+ else if (bottomCell.isValid())
+ *bottomRight = collapseBorders(table->rightBorder(), bottomCell.rightBorder());
+ else
+ *bottomRight = TableBorder();
+}
+
+void resolveBordersVertical(const TableCell& topLeftCell, const TableCell& topRightCell, const TableCell& leftCell, const TableCell& rightCell, const TableCell& bottomLeftCell,
+ const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* top, TableBorder* topRight, TableBorder* center, TableBorder* bottomLeft, TableBorder* bottom, TableBorder* bottomRight, PageItem_Table* table)
+{
+ if (!leftCell.isValid() && !rightCell.isValid())
+ return;
+ // Resolve top left.
+ if (topLeftCell.row() == leftCell.row())
+ *topLeft = TableBorder();
+ else if (topLeftCell.isValid() && leftCell.isValid())
+ *topLeft = collapseBorders(leftCell.topBorder(), topLeftCell.bottomBorder());
+ else if (topLeftCell.isValid())
+ *topLeft = collapseBorders(table->bottomBorder(), topLeftCell.bottomBorder());
+ else if (leftCell.isValid())
+ *topLeft = collapseBorders(leftCell.topBorder(), table->topBorder());
+ else
+ *topLeft = TableBorder();
+ // Resolve top.
+ if (topLeftCell.column() == topRightCell.column())
+ *top = TableBorder();
+ else if (topLeftCell.isValid() && topRightCell.isValid())
+ *top = collapseBorders(topRightCell.leftBorder(), topLeftCell.rightBorder());
+ else if (topLeftCell.isValid())
+ *top = collapseBorders(table->rightBorder(), topLeftCell.rightBorder());
+ else if (topRightCell.isValid())
+ *top = collapseBorders(topRightCell.leftBorder(), table->leftBorder());
+ else
+ *top = TableBorder();
+ // Resolve top right.
+ if (topRightCell.row() == rightCell.row())
+ *topRight = TableBorder();
+ else if (topRightCell.isValid() && rightCell.isValid())
+ *topRight = collapseBorders(rightCell.topBorder(), topRightCell.bottomBorder());
+ else if (topRightCell.isValid())
+ *topRight = collapseBorders(table->bottomBorder(), topRightCell.bottomBorder());
+ else if (rightCell.isValid())
+ *topRight = collapseBorders(rightCell.topBorder(), table->topBorder());
+ else
+ *topRight = TableBorder();
+ // Resolve center.
+ if (leftCell.column() == rightCell.column())
+ *center = TableBorder();
+ else if (leftCell.isValid() && rightCell.isValid())
+ *center = collapseBorders(rightCell.leftBorder(), leftCell.rightBorder());
+ else if (leftCell.isValid())
+ *center = collapseBorders(table->rightBorder(), leftCell.rightBorder());
+ else if (rightCell.isValid())
+ *center = collapseBorders(rightCell.leftBorder(), table->leftBorder());
+ else
+ *center = TableBorder();
+ // Resolve bottom left.
+ if (bottomLeftCell.row() == leftCell.row())
+ *bottomLeft = TableBorder();
+ else if (bottomLeftCell.isValid() && leftCell.isValid())
+ *bottomLeft = collapseBorders(bottomLeftCell.topBorder(), leftCell.bottomBorder());
+ else if (bottomLeftCell.isValid())
+ *bottomLeft = collapseBorders(bottomLeftCell.topBorder(), table->topBorder());
+ else if (leftCell.isValid())
+ *bottomLeft = collapseBorders(table->bottomBorder(), leftCell.bottomBorder());
+ else
+ *bottomLeft = TableBorder();
+ // Resolve bottom.
+ if (bottomLeftCell.column() == bottomRightCell.column())
+ *bottom = TableBorder();
+ else if (bottomLeftCell.isValid() && bottomRightCell.isValid())
+ *bottom = collapseBorders(bottomRightCell.leftBorder(), bottomLeftCell.rightBorder());
+ else if (bottomLeftCell.isValid())
+ *bottom = collapseBorders(table->rightBorder(), bottomLeftCell.rightBorder());
+ else if (bottomRightCell.isValid())
+ *bottom = collapseBorders(bottomRightCell.leftBorder(), table->leftBorder());
+ else
+ *bottom = TableBorder();
+ // Resolve bottom right.
+ if (bottomRightCell.row() == rightCell.row())
+ *bottomRight = TableBorder();
+ else if (bottomRightCell.isValid() && rightCell.isValid())
+ *bottomRight = collapseBorders(bottomRightCell.topBorder(), rightCell.bottomBorder());
+ else if (bottomRightCell.isValid())
+ *bottomRight = collapseBorders(bottomRightCell.topBorder(), table->topBorder());
+ else if (rightCell.isValid())
+ *bottomRight = collapseBorders(table->bottomBorder(), rightCell.bottomBorder());
+ else
+ *bottomRight = TableBorder();
+}
TableBorder collapseBorders(const TableBorder& firstBorder, const TableBorder& secondBorder)
{
Modified: trunk/Scribus/scribus/tableutils.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17314&path=/trunk/Scribus/scribus/tableutils.h
==============================================================================
--- trunk/Scribus/scribus/tableutils.h (original)
+++ trunk/Scribus/scribus/tableutils.h Sat Feb 18 20:59:07 2012
@@ -12,12 +12,102 @@
#include "tableborder.h"
class QPointF;
+class TableCell;
+class PageItem_Table;
/**
* Table utility functions.
*/
namespace TableUtils
{
+
+/**
+ * Resolves the collapsed borders between six cells in a 3x2 area.
+ *
+ * Given the six cells @a topLeftCell, @a topCell, @a topRightCell, @a bottomLeftCell,
+ * @a bottomCell and @a bottomRightCell in the following picture
+ *
+ * <pre>
+ * +--------------------------+--------------------------+--------------------------+
+ * | | | |
+ * | | | |
+ * | topLeftCell topLeft topCell topRight topRightCell |
+ * | | | |
+ * | | | |
+ * +----------left------------+--------- center ---------+----------right-----------+
+ * | | | |
+ * | | | |
+ * | bottomLeftCell bottomLeft bottomCell bottomRight bottomRightCell |
+ * | | | |
+ * | | | |
+ * +--------------------------+--------------------------+--------------------------+
+ * </pre>
+ *
+ * the function will return the collapsed borders @a topLeft, @a left, @a bottomLeft,
+ * @a center, @a topRight, @a right and @a bottomRight. If two adjacent cells are invalid,
+ * the returned collapsed border between them is null. If only one of two adjacent cells is
+ * valid, the returned collapsed border will be the border of the valid cell collapsed with
+ * the appropriate table border instead. If two "adjacent" cells are actually the same
+ * cell, the returned collapsed border between them is null.
+ *
+ * If both @a topCell and @a bottomCell are invalid, the function will print a
+ * warning message and return immediately, leaving @a topLeft, @a top, @a bottomLeft,
+ * @a center, @a topRight, @a right and @a bottomRight unchanged.
+ *
+ * @a topLeft, @a left , @a bottomLeft, @a center, @a topRight, @a right and
+ * @a bottomRight must point to existing borders.
+ */
+void resolveBordersHorizontal(const TableCell& topLeftCell, const TableCell& topCell,
+ const TableCell& topRightCell, const TableCell& bottomLeftCell, const TableCell& bottomCell,
+ const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* left, TableBorder* bottomLeft,
+ TableBorder* center, TableBorder* topRight, TableBorder* right, TableBorder* bottomRight, PageItem_Table* table);
+
+/**
+ * Resolves the collapsed borders between six cells in a 2x3 area.
+ *
+ * Given the six cells @a topLeftCell, @a topRightCell, @a leftCell, @a rightCell,
+ * @a bottomLeftCell and @a bottomRightCell in the following picture
+ *
+ * <pre>
+ * +----------------------+----------------------+
+ * | | |
+ * | | |
+ * | topLeftCell top topRightCell |
+ * | | |
+ * | | |
+ * +--------topLeft-------+-------topRight-------+
+ * | | |
+ * | | |
+ * | leftCell center rightCell |
+ * | | |
+ * | | |
+ * +-------bottomLeft-----+------bottomRight-----+
+ * | | |
+ * | | |
+ * | bottomLeftCell bottom bottomRightCell |
+ * | | |
+ * | | |
+ * +----------------------+----------------------+
+ * </pre>
+ *
+ * the function will return the collapsed borders @a topLeft, @a top, @a topRight,
+ * @a center, @a bottomLeft, @a bottom and @a bottomRight. If two adjacent cells are
+ * invalid, the returned collapsed border between them is null. If only one of two adjacent
+ * cells is valid, the returned collapsed border will be the border of the valid cell
+ * collapsed with the appropriate table border instead. If two "adjacent" cells are
+ * actually the same cell, the returned collapsed border between them is null.
+ *
+ * If both @a leftCell and @a rightCell are invalid, the function will print a
+ * warning message and return immediately, leaving @a topLeft, @a top, @a topRight,
+ * @a center, @a bottomLeft, @a bottom and @a bottomRight unchanged.
+ *
+ * @a topLeft, @a top, @a topRight, @a center, @a bottomLeft, @a bottom and
+ * @a bottomRight must point to existing borders.
+ */
+void resolveBordersVertical(const TableCell& topLeftCell, const TableCell& topRightCell,
+ const TableCell& leftCell, const TableCell& rightCell, const TableCell& bottomLeftCell,
+ const TableCell& bottomRightCell, TableBorder* topLeft, TableBorder* top, TableBorder* topRight,
+ TableBorder* center, TableBorder* bottomLeft, TableBorder* bottom, TableBorder* bottomRight, PageItem_Table* table);
/**
* Collapses @a firstBorder with @a secondBorder and returns the collapsed border.
More information about the scribus-commit
mailing list