File: opencalcstyleexport.h

package info (click to toggle)
calligra 1%3A25.04.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 309,164 kB
  • sloc: cpp: 667,890; xml: 126,105; perl: 2,724; python: 2,497; yacc: 1,817; ansic: 1,326; sh: 1,223; lex: 1,107; javascript: 495; makefile: 24
file content (184 lines) | stat: -rw-r--r-- 3,518 bytes parent folder | download | duplicates (2)
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/* This file is part of the KDE project
   SPDX-FileCopyrightText: 2003 Norbert Andres <nandres@web.de>

   SPDX-License-Identifier: LGPL-2.0-or-later
*/

#ifndef OPENCALCSTYLEEXPORT_H
#define OPENCALCSTYLEEXPORT_H

#include "sheets/core/Style.h"

#include <QColor>
#include <QFont>
#include <QList>
#include <QPen>
#include <QString>

namespace Calligra
{
namespace Sheets
{
class Cell;
}
}

class QDomDocument;
class QDomElement;

class Style
{
public:
    enum breakBefore {
        none,
        automatic,
        page
    };

    Style()
        : breakB(none)
        , size(0.0)
    {
    }

    QString name;
    uint breakB;
    double size;
};

class SheetStyle
{
public:
    SheetStyle()
        : visible(true)
    {
    }

    void copyData(SheetStyle const &ts)
    {
        visible = ts.visible;
    }
    static bool isEqual(SheetStyle const *const t1, SheetStyle const &t2);

    QString name;
    bool visible;
};

class NumberStyle
{
public:
    NumberStyle() = default;

    enum NumberType {
        Boolean,
        Date,
        Number,
        Percentage,
        Time
    };

    void copyData(NumberStyle const &ts)
    {
        type = ts.type;
    }
    static bool isEqual(NumberStyle const *const t1, NumberStyle const &t2);

    QString name;

    NumberType type;
    QString pattern;
};

class CellStyle
{
public:
    CellStyle();

    void copyData(CellStyle const &ts);
    static bool isEqual(CellStyle const *const t1, CellStyle const &t2);

    // all except the number style
    static void loadData(CellStyle &cs, const Calligra::Sheets::Cell &cell);

    QString name;

    QFont font;
    QString numberStyle;
    QColor color;
    QColor bgColor;
    double indent;
    bool wrap;
    bool vertical;
    int angle;
    bool print;
    QPen left;
    QPen right;
    QPen top;
    QPen bottom;
    bool hideAll;
    bool hideFormula;
    bool notProtected;

    Calligra::Sheets::Style::HAlign alignX;
    Calligra::Sheets::Style::VAlign alignY;
};

class ColumnStyle : public Style
{
public:
    ColumnStyle()
        : Style()
    {
    }

    void copyData(ColumnStyle const &cs);
    static bool isEqual(ColumnStyle const *const c1, ColumnStyle const &c2);
};

class RowStyle : public Style
{
public:
    RowStyle()
        : Style()
    {
    }

    void copyData(RowStyle const &cs);
    static bool isEqual(RowStyle const *const c1, RowStyle const &c2);
};

class OpenCalcStyles
{
public:
    OpenCalcStyles();
    ~OpenCalcStyles();

    void writeStyles(QDomDocument &doc, QDomElement &autoStyles);
    void writeFontDecl(QDomDocument &doc, QDomElement &content);

    void addFont(QFont const &font, bool def = false);

    QString cellStyle(CellStyle const &cs);
    QString columnStyle(ColumnStyle const &cs);
    QString numberStyle(NumberStyle const &ns);
    QString rowStyle(RowStyle const &rs);
    QString sheetStyle(SheetStyle const &ts);

private:
    QList<CellStyle *> m_cellStyles;
    QList<ColumnStyle *> m_columnStyles;
    QList<NumberStyle *> m_numberStyles;
    QList<RowStyle *> m_rowStyles;
    QList<SheetStyle *> m_sheetStyles;
    QList<QFont *> m_fontList;

    QFont m_defaultFont;

    void addCellStyles(QDomDocument &doc, QDomElement &autoStyles);
    void addColumnStyles(QDomDocument &doc, QDomElement &autoStyles);
    void addNumberStyles(QDomDocument &doc, QDomElement &autoStyles);
    void addRowStyles(QDomDocument &doc, QDomElement &autoStyles);
    void addSheetStyles(QDomDocument &doc, QDomElement &autoStyles);
};

#endif