File: KoBorder.h

package info (click to toggle)
koffice 1%3A2.2.1-4
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 157,656 kB
  • ctags: 110,762
  • sloc: cpp: 889,358; xml: 22,758; ansic: 6,533; python: 5,224; perl: 2,771; sh: 1,805; yacc: 1,304; ruby: 1,219; sql: 720; lex: 455; makefile: 76
file content (163 lines) | stat: -rw-r--r-- 5,893 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* This file is part of the KDE project
 *
 * Copyright (C) 2009 Inge wallin <inge@lysator.liu.se>
 * Copyright (C) 2009 Thomas Zander <zander@kde.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */


#ifndef KOBORDER_H
#define KOBORDER_H

#include "koodf_export.h"

#include <QColor>
#include <QSharedData>

#include "KoXmlReaderForward.h"

class KoGenStyle;
class KoBorderPrivate;


/**
 * A container for all properties of a generic border as defined by ODF.
 *
 * A border is used in at least the following contexts:
 *  - paragraph
 *  - page
 *  - table
 *  - table cell
 *
 */

class KOODF_EXPORT KoBorder
{
public:

    /// The type of border.  Note that some of the border types are legacies from the old KWord format.
    enum BorderStyle {
        BorderNone, ///< no border. This value forces the computed value of 'border-width' to be '0'.
        BorderDotted,   ///< The border is a series of dots.
        BorderDashed,   ///< The border is a series of short line segments.
        BorderSolid,    ///< The border is a single line segment.
        BorderDouble,   ///< The border is two solid lines. The sum of the two lines and the space between them equals the value of 'border-width'.
        BorderGroove,   ///< The border looks as though it were carved into the canvas. (old kword type)
        BorderRidge,    ///< The opposite of 'groove': the border looks as though it were coming out of the canvas. (old kword type)
        BorderInset,    ///< The border makes the entire box look as though it were embedded in the canvas. (old kword type)
        BorderOutset,   ///< The opposite of 'inset': the border makes the entire box look as though it were coming out of the canvas. (old kword type)

        // kword legacy
        BorderDashDotPattern,
        BorderDashDotDotPattern
    };

    /// Holds data about one border line.
    struct BorderData {
        BorderData();
        BorderStyle  style; ///< The border style. (see BorderStyle)
        qreal        width; ///< The thickness of the border, or 0 if there is no border
        QColor       color; ///< The border Color
        qreal        innerWidth; ///< In case of style being 'double' the thickness of the inner border line
        qreal        spacing;      ///< In case of style being 'double' the space between the inner and outer border lines
    };


    /// Constructor
    KoBorder();
    KoBorder(const KoBorder &kb);

    /// Destructor
    ~KoBorder();

    /// Assignment
    KoBorder &operator=(const KoBorder &other);
    /// Compare the border with the other one
    bool operator==(const KoBorder &other) const;
    bool operator!=(const KoBorder &other) const { return !operator==(other); }

    void setLeftBorderStyle(BorderStyle style);
    BorderStyle leftBorderStyle() const;
    void setLeftBorderColor(const QColor &color);
    QColor leftBorderColor() const;
    void setLeftBorderWidth(qreal width);
    qreal leftBorderWidth() const;
    void setLeftInnerBorderWidth(qreal width);
    qreal leftInnerBorderWidth() const;
    void setLeftBorderSpacing(qreal width);
    qreal leftBorderSpacing() const;

    void setTopBorderStyle(BorderStyle style);
    BorderStyle topBorderStyle() const;
    void setTopBorderColor(const QColor &color);
    QColor topBorderColor() const;
    void setTopBorderWidth(qreal width);
    qreal topBorderWidth() const;
    void setTopInnerBorderWidth(qreal width);
    qreal topInnerBorderWidth() const;
    void setTopBorderSpacing(qreal width);
    qreal topBorderSpacing() const;

    void setRightBorderStyle(BorderStyle style);
    BorderStyle rightBorderStyle() const;
    void setRightBorderColor(const QColor &color);
    QColor rightBorderColor() const;
    void setRightBorderWidth(qreal width);
    qreal rightBorderWidth() const;
    void setRightInnerBorderWidth(qreal width);
    qreal rightInnerBorderWidth() const;
    void setRightBorderSpacing(qreal width);
    qreal rightBorderSpacing() const;

    void setBottomBorderStyle(BorderStyle style);
    BorderStyle bottomBorderStyle() const;
    void setBottomBorderColor(const QColor &color);
    QColor bottomBorderColor() const;
    void setBottomBorderWidth(qreal width);
    qreal bottomBorderWidth() const;
    void setBottomInnerBorderWidth(qreal width);
    qreal bottomInnerBorderWidth() const;
    void setBottomBorderSpacing(qreal width);
    qreal bottomBorderSpacing() const;

    BorderData leftBorderData() const;
    BorderData topBorderData() const;
    BorderData rightBorderData() const;
    BorderData bottomBorderData() const;


    /**
     * Load the style from the element
     *
     * @param style  the element containing the style to read from
     */
    void loadOdf(const KoXmlElement &style);

    void saveOdf(KoGenStyle &style) const;


    // Some public functions used in other places where borders are handled.
    // Example: KoParagraphStyle
    // FIXME: These places should be made to use KoBorder instead.
    static BorderStyle odfBorderStyle(const QString &borderstyle);
    static QString odfBorderStyleString(BorderStyle borderstyle);

private:
    QSharedDataPointer<KoBorderPrivate> d;
};

#endif