1 /* This file is part of the KDE project 2 * Copyright (C) 2011 C. Boemann <cbo@kogmbh.com> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef KOTEXTLAYOUTTABLEAREA_H 21 #define KOTEXTLAYOUTTABLEAREA_H 22 23 #include "kritatextlayout_export.h" 24 25 #include "KoTextLayoutArea.h" 26 27 #include <QVector> 28 29 class KoPointedAt; 30 class TableIterator; 31 class QTextTableCell; 32 class QLineF; 33 34 /** 35 * This class represent a (full width) piece of a table 36 */ 37 class KRITATEXTLAYOUT_EXPORT KoTextLayoutTableArea : public KoTextLayoutArea 38 { 39 public: 40 /// constructor 41 explicit KoTextLayoutTableArea(QTextTable *table, KoTextLayoutArea *parent, KoTextDocumentLayout *documentLayout); 42 ~KoTextLayoutTableArea() override; 43 44 /// Layouts as much as it can 45 /// Returns true if it has reached the end of the table 46 bool layoutTable(TableIterator *cursor); 47 48 void paint(QPainter *painter, const KoTextDocumentLayout::PaintContext &context); 49 50 KoPointedAt hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const; 51 52 /// Calc a bounding box rect of the selection 53 QRectF selectionBoundingBox(QTextCursor &cursor) const; 54 55 private: 56 void layoutColumns(); 57 void collectBorderThicknesss(int row, qreal &topBorderWidth, qreal &bottomBorderWidth); 58 void nukeRow(TableIterator *cursor); 59 bool layoutRow(TableIterator *cursor, qreal topBorderWidth, qreal bottomBorderWidth); 60 bool layoutMergedCellsNotEnding(TableIterator *cursor, qreal topBorderWidth, qreal bottomBorderWidth, qreal rowBottom); 61 QRectF cellBoundingRect(const QTextTableCell &cell) const; 62 void paintCell(QPainter *painter, const KoTextDocumentLayout::PaintContext &context, const QTextTableCell &tableCell, KoTextLayoutArea *frameArea); 63 void paintCellBorders(QPainter *painter, const KoTextDocumentLayout::PaintContext &context, const QTextTableCell &tableCell, bool topRow, int maxRow, QVector<QLineF> *accuBlankBorders); 64 65 class Private; 66 Private * const d; 67 }; 68 69 #endif 70