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