~ubuntu-branches/ubuntu/oneiric/koffice/oneiric-updates

« back to all changes in this revision

Viewing changes to filters/kspread/xlsx/XlsxXmlWorksheetReader_p.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of Office 2007 Filters for KOffice
 
3
 *
 
4
 * Copyright (C) 2010 Sebastian Sauer <sebsauer@kdab.com>
 
5
 * Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 
6
 *
 
7
 * Contact: Suresh Chande suresh.chande@nokia.com
 
8
 *
 
9
 * This library is free software; you can redistribute it and/or
 
10
 * modify it under the terms of the GNU Lesser General Public License
 
11
 * version 2.1 as published by the Free Software Foundation.
 
12
 *
 
13
 * This library is distributed in the hope that it will be useful, but
 
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
16
 * Lesser General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Lesser General Public
 
19
 * License along with this library; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
21
 * 02110-1301 USA
 
22
 *
 
23
 */
 
24
 
 
25
#ifndef XLSXXMLWORKSHEETREADER_P_H
 
26
#define XLSXXMLWORKSHEETREADER_P_H
 
27
 
 
28
//! @todo the workboot was designed after filters/kspread/excel/sidewinder to allow to shared as much
 
29
//!       logic as possible. Goal is to let them both share the same structures and OpenDocument logic
 
30
//!       some day.
 
31
 
 
32
#include <MsooXmlGlobal.h>
 
33
#include "XlsxXmlDrawingReader.h"
 
34
 
 
35
class Sheet;
 
36
 
 
37
class Cell
 
38
{
 
39
public:
 
40
    Sheet* sheet;
 
41
    int column, row;
 
42
    int rowsMerged, columnsMerged;
 
43
    QString styleName;
 
44
    QString charStyleName;
 
45
    QString text;
 
46
    bool isPlainText;
 
47
    QString valueType;
 
48
    QByteArray valueAttr;
 
49
    QString valueAttrValue;
 
50
    QString formula;
 
51
    QString hyperlink;
 
52
    QList<XlsxDrawingObject*> drawings;
 
53
 
 
54
    //QPair< oleObjectFile, imageReplacementFile>
 
55
    QList< QPair<QString,QString> > oleObjects;
 
56
 
 
57
    Cell(Sheet* s, int columnIndex, int rowIndex) : sheet(s), column(columnIndex), row(rowIndex), rowsMerged(1), columnsMerged(1), isPlainText(true) {}
 
58
    ~Cell() { qDeleteAll(drawings); }
 
59
};
 
60
 
 
61
class Row
 
62
{
 
63
public:
 
64
    Sheet* sheet;
 
65
    int rowIndex;
 
66
    bool hidden;
 
67
    QString styleName;
 
68
 
 
69
    Row(Sheet* s, int index) : sheet(s), rowIndex(index), hidden(false) {}
 
70
    ~Row() {}
 
71
};
 
72
 
 
73
class Column
 
74
{
 
75
public:
 
76
    Sheet* sheet;
 
77
    int columnIndex;
 
78
    bool hidden;
 
79
 
 
80
    Column(Sheet* s, int index) : sheet(s), columnIndex(index), hidden(false) {}
 
81
    ~Column() {}
 
82
};
 
83
 
 
84
class Sheet
 
85
{
 
86
public:
 
87
    QString m_name;
 
88
    double m_defaultRowHeight, m_defaultColWidth, m_baseColWidth;
 
89
    explicit Sheet(const QString &name) : m_name(name), m_defaultRowHeight(-1.0), m_defaultColWidth(-1.0), m_baseColWidth(-1.0), m_maxRow(0), m_maxColumn(0), m_visible(true) {}
 
90
    ~Sheet() { qDeleteAll(m_rows); qDeleteAll(m_columns); qDeleteAll(m_cells); }
 
91
 
 
92
    Row* row(int rowIndex, bool autoCreate)
 
93
    {
 
94
        Row* r = m_rows[ rowIndex ];
 
95
        if (!r && autoCreate) {
 
96
            r = new Row(this, rowIndex);
 
97
            m_rows[ rowIndex ] = r;
 
98
            if (rowIndex > m_maxRow) m_maxRow = rowIndex;
 
99
        }
 
100
        return r;
 
101
    }
 
102
 
 
103
    Column* column(int columnIndex, bool autoCreate)
 
104
    {
 
105
        Column* c = m_columns[ columnIndex ];
 
106
        if (!c && autoCreate) {
 
107
            c = new Column(this, columnIndex);
 
108
            m_columns[ columnIndex ] = c;
 
109
            if (columnIndex > m_maxColumn) m_maxColumn = columnIndex;
 
110
        }
 
111
        return c;
 
112
    }
 
113
 
 
114
    Cell* cell(int columnIndex, int rowIndex, bool autoCreate)
 
115
    {
 
116
        const unsigned hashed = (rowIndex + 1) * MSOOXML::maximumSpreadsheetColumns() + columnIndex + 1;
 
117
        Cell* c = m_cells[ hashed ];
 
118
        if (!c && autoCreate) {
 
119
            c = new Cell(this, columnIndex, rowIndex);
 
120
            m_cells[ hashed ] = c;
 
121
            this->column(columnIndex, true);
 
122
            this->row(rowIndex, true);
 
123
            if (rowIndex > m_maxRow) m_maxRow = rowIndex;
 
124
            if (columnIndex > m_maxColumn) m_maxColumn = columnIndex;
 
125
            if (!m_maxCellsInRow.contains(rowIndex) || columnIndex > m_maxCellsInRow[rowIndex])
 
126
                m_maxCellsInRow[rowIndex] = columnIndex;
 
127
        }
 
128
        return c;
 
129
    }
 
130
 
 
131
    int maxRow() const { return m_maxRow; }
 
132
    int maxColumn() const { return m_maxColumn; }
 
133
    int maxCellsInRow(int rowIndex) const { return m_maxCellsInRow[rowIndex]; }
 
134
 
 
135
    bool visible() { return m_visible; }
 
136
    void setVisible(bool visible) { m_visible = visible; }
 
137
 
 
138
    QString pictureBackgroundPath() { return m_pictureBackgroundPath; }
 
139
    void setPictureBackgroundPath(const QString& path) { m_pictureBackgroundPath = path; }
 
140
 
 
141
private:
 
142
    QHash<int, Row*> m_rows;
 
143
    QHash<int, Column*> m_columns;
 
144
    QHash<unsigned, Cell*> m_cells;
 
145
    int m_maxRow;
 
146
    int m_maxColumn;
 
147
    QHash<int, int> m_maxCellsInRow;
 
148
    bool m_visible;
 
149
    QString m_pictureBackgroundPath;
 
150
};
 
151
 
 
152
#endif