Warning, file /office/calligra/libs/textlayout/KoTextLayoutObstruction.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2006-2007, 2010 Thomas Zander <zander@kde.org>
0003  * Copyright (C) 2010 Ko Gmbh <cbo@kogmbh.com>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #ifndef KOTEXTLAYOUTOBSTRUCTION_H
0022 #define KOTEXTLAYOUTOBSTRUCTION_H
0023 
0024 #include "kotextlayout_export.h"
0025 
0026 #include <QMultiMap>
0027 #include <QPolygonF>
0028 #include <QRectF>
0029 #include <QLineF>
0030 
0031 class KoShape;
0032 class QTransform;
0033 class QPainterPath;
0034 
0035 ///  Class that allows us with the runaround of QPainterPaths
0036 class KOTEXTLAYOUT_EXPORT KoTextLayoutObstruction
0037 {
0038 public:
0039     KoTextLayoutObstruction(KoShape *shape, const QTransform &matrix);
0040 
0041     KoTextLayoutObstruction(const QRectF &rect, bool rtl);
0042 
0043     void init(const QTransform &matrix, const QPainterPath &obstruction, qreal distanceLeft, qreal distanceTop, qreal distanceRight, qreal distanceBottom, qreal borderHalfWidth);
0044 
0045     QRectF limit(const QRectF &content);
0046 
0047     KoShape *shape() const { return m_shape; }
0048 
0049     static qreal xAtY(const QLineF &line, qreal y);
0050 
0051     void changeMatrix(const QTransform &matrix);
0052 
0053     //-------------------------------------------------------------------------------
0054 
0055     QRectF cropToLine(const QRectF &lineRect);
0056 
0057     QRectF getLeftLinePart(const QRectF &lineRect) const;
0058 
0059     QRectF getRightLinePart(const QRectF &lineRect) const;
0060 
0061     bool textOnLeft() const;
0062 
0063     bool textOnRight() const;
0064 
0065     bool textOnBiggerSide() const;
0066 
0067     bool textOnEnoughSides() const;
0068 
0069     bool noTextAround() const;
0070 
0071     // Don't run around unless available space is > than this when m_side == Enough.
0072     qreal runAroundThreshold() const;
0073 
0074     static bool compareRectLeft(KoTextLayoutObstruction *o1, KoTextLayoutObstruction *o2);
0075 private:
0076     QPainterPath decoratedOutline(const KoShape *shape, qreal &borderHalfWidth) const;
0077 
0078     enum Side { None, Left, Right, Empty, Both, Bigger, Enough };
0079     Side m_side;
0080     QRectF m_bounds;
0081     QPolygonF m_polygon;
0082     public:
0083     QRectF m_line;
0084     QMultiMap<qreal, QLineF> m_edges; //sorted with y-coord
0085     KoShape *m_shape;
0086     QRectF m_rect;
0087     qreal m_distanceLeft;
0088     qreal m_distanceTop;
0089     qreal m_distanceRight;
0090     qreal m_distanceBottom;
0091     qreal m_borderHalfWidth;
0092     qreal m_runAroundThreshold;
0093 };
0094 
0095 #endif