Mercurial > clickerconvert
annotate src/xlsx/xlsxabstractooxmlfile.cpp @ 56:5410f9f279ea
Redefine question pattern to be more robust
We now assume that a question begins after two empty lines.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 09 Aug 2016 09:59:16 +0200 |
parents | 93d3106bb9a4 |
children |
rev | line source |
---|---|
1
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
1 /**************************************************************************** |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
2 ** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me> |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
3 ** All right reserved. |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
4 ** |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
5 ** Permission is hereby granted, free of charge, to any person obtaining |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
6 ** a copy of this software and associated documentation files (the |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
7 ** "Software"), to deal in the Software without restriction, including |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
8 ** without limitation the rights to use, copy, modify, merge, publish, |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
9 ** distribute, sublicense, and/or sell copies of the Software, and to |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
10 ** permit persons to whom the Software is furnished to do so, subject to |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
11 ** the following conditions: |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
12 ** |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
13 ** The above copyright notice and this permission notice shall be |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
14 ** included in all copies or substantial portions of the Software. |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
15 ** |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
16 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
17 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
18 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
19 ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
20 ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
21 ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
22 ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
23 ** |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
24 ****************************************************************************/ |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
25 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
26 #include "xlsxabstractooxmlfile.h" |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
27 #include "xlsxabstractooxmlfile_p.h" |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
28 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
29 #include <QBuffer> |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
30 #include <QByteArray> |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
31 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
32 QT_BEGIN_NAMESPACE_XLSX |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
33 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
34 AbstractOOXmlFilePrivate::AbstractOOXmlFilePrivate(AbstractOOXmlFile *q, AbstractOOXmlFile::CreateFlag flag=AbstractOOXmlFile::F_NewFromScratch) |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
35 :relationships(new Relationships), flag(flag), q_ptr(q) |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
36 { |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
37 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
38 } |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
39 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
40 AbstractOOXmlFilePrivate::~AbstractOOXmlFilePrivate() |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
41 { |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
42 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
43 } |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
44 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
45 /*! |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
46 * \internal |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
47 * |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
48 * \class AbstractOOXmlFile |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
49 * |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
50 * Base class of all the ooxml part file. |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
51 */ |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
52 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
53 AbstractOOXmlFile::AbstractOOXmlFile(CreateFlag flag) |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
54 :d_ptr(new AbstractOOXmlFilePrivate(this, flag)) |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
55 { |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
56 } |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
57 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
58 AbstractOOXmlFile::AbstractOOXmlFile(AbstractOOXmlFilePrivate *d) |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
59 :d_ptr(d) |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
60 { |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
61 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
62 } |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
63 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
64 AbstractOOXmlFile::~AbstractOOXmlFile() |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
65 { |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
66 if (d_ptr->relationships) |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
67 delete d_ptr->relationships; |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
68 delete d_ptr; |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
69 } |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
70 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
71 QByteArray AbstractOOXmlFile::saveToXmlData() const |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
72 { |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
73 QByteArray data; |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
74 QBuffer buffer(&data); |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
75 buffer.open(QIODevice::WriteOnly); |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
76 saveToXmlFile(&buffer); |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
77 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
78 return data; |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
79 } |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
80 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
81 bool AbstractOOXmlFile::loadFromXmlData(const QByteArray &data) |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
82 { |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
83 QBuffer buffer; |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
84 buffer.setData(data); |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
85 buffer.open(QIODevice::ReadOnly); |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
86 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
87 return loadFromXmlFile(&buffer); |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
88 } |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
89 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
90 /*! |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
91 * \internal |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
92 */ |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
93 void AbstractOOXmlFile::setFilePath(const QString path) |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
94 { |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
95 Q_D(AbstractOOXmlFile); |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
96 d->filePathInPackage = path; |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
97 } |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
98 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
99 /*! |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
100 * \internal |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
101 */ |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
102 QString AbstractOOXmlFile::filePath() const |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
103 { |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
104 Q_D(const AbstractOOXmlFile); |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
105 return d->filePathInPackage; |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
106 } |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
107 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
108 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
109 /*! |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
110 * \internal |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
111 */ |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
112 Relationships *AbstractOOXmlFile::relationships() const |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
113 { |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
114 Q_D(const AbstractOOXmlFile); |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
115 return d->relationships; |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
116 } |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
117 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
118 |
93d3106bb9a4
Add qt xlsx library
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
119 QT_END_NAMESPACE_XLSX |