1 |
dilfridge 12/02/07 19:46:21 |
2 |
|
3 |
Added: karbon-2.3.3-newlibwpd.patch |
4 |
Log: |
5 |
Add patch from Debian for newer libwpg support, bug 401463 |
6 |
|
7 |
(Portage version: 2.1.10.44/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 app-office/karbon/files/karbon-2.3.3-newlibwpd.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-office/karbon/files/karbon-2.3.3-newlibwpd.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-office/karbon/files/karbon-2.3.3-newlibwpd.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: karbon-2.3.3-newlibwpd.patch |
16 |
=================================================================== |
17 |
Description: porting to pwg & conversion as SVG output |
18 |
Reduced version of Calligra's commit 9cda7aed2ea103750172e61f5c800a474913fa59: |
19 |
make wpg import compile again, simplified code by using high level libwpg function to convert to svg, |
20 |
this makes us less dependent on libwpg API changes, code works with old an new libwpg versions |
21 |
Author: Jan Hambrecht <jaham@×××.net> |
22 |
Author: Pino Toscano <pino@×××.org> |
23 |
Last-Update: 2011-02-06 |
24 |
Applied-Upstream: Calligra 2.4 |
25 |
|
26 |
--- a/filters/karbon/wpg/import/CMakeLists.txt |
27 |
+++ b/filters/karbon/wpg/import/CMakeLists.txt |
28 |
@@ -4,13 +4,11 @@ |
29 |
|
30 |
set(wpgimport_PART_SRCS |
31 |
WPGImport.cpp |
32 |
-OdgExporter.cxx |
33 |
-FileOutputHandler.cxx |
34 |
-GraphicsElement.cxx) |
35 |
+) |
36 |
|
37 |
kde4_add_plugin(wpgimport ${wpgimport_PART_SRCS}) |
38 |
|
39 |
-target_link_libraries(wpgimport komain ${LIBWPG_LIBRARIES} ${LIBWPG_STREAM_LIBRARIES}) |
40 |
+target_link_libraries(wpgimport komain ${LIBWPG_LIBRARIES} ${LIBWPG_STREAM_LIBRARIES} ${WPD_LIBRARIES}) |
41 |
|
42 |
install(TARGETS wpgimport DESTINATION ${PLUGIN_INSTALL_DIR}) |
43 |
install(FILES karbon_wpg_import.desktop DESTINATION ${SERVICES_INSTALL_DIR}) |
44 |
--- a/filters/karbon/wpg/import/WPGImport.cpp |
45 |
+++ b/filters/karbon/wpg/import/WPGImport.cpp |
46 |
@@ -23,6 +23,7 @@ |
47 |
#include <QBuffer> |
48 |
#include <QByteArray> |
49 |
#include <QString> |
50 |
+#include <QFile> |
51 |
|
52 |
#include <kdebug.h> |
53 |
#include <KoFilterChain.h> |
54 |
@@ -37,11 +38,9 @@ |
55 |
#include <libwpg/WPGStreamImplementation.h> |
56 |
#else |
57 |
#include <libwpd-stream/libwpd-stream.h> |
58 |
+#include <libwpd/libwpd.h> |
59 |
#endif |
60 |
|
61 |
-#include "FileOutputHandler.hxx" |
62 |
-#include "OdgExporter.hxx" |
63 |
- |
64 |
#include <iostream> |
65 |
|
66 |
K_PLUGIN_FACTORY(WPGImportFactory, registerPlugin<WPGImport>();) |
67 |
@@ -56,35 +55,12 @@ |
68 |
{ |
69 |
} |
70 |
|
71 |
-static QByteArray createManifest() |
72 |
-{ |
73 |
- KoXmlWriter* manifestWriter; |
74 |
- QByteArray manifestData; |
75 |
- QBuffer manifestBuffer(&manifestData); |
76 |
- |
77 |
- manifestBuffer.open(QIODevice::WriteOnly); |
78 |
- manifestWriter = new KoXmlWriter(&manifestBuffer); |
79 |
- |
80 |
- manifestWriter->startDocument("manifest:manifest"); |
81 |
- manifestWriter->startElement("manifest:manifest"); |
82 |
- manifestWriter->addAttribute("xmlns:manifest", "urn:oasis:names:tc:openoffice:xmlns:manifest:1.0"); |
83 |
- manifestWriter->addManifestEntry("/", "application/vnd.oasis.opendocument.graphics"); |
84 |
- //manifestWriter->addManifestEntry( "styles.xml", "text/xml" ); |
85 |
- manifestWriter->addManifestEntry("content.xml", "text/xml"); |
86 |
- manifestWriter->endElement(); |
87 |
- manifestWriter->endDocument(); |
88 |
- delete manifestWriter; |
89 |
- |
90 |
- return manifestData; |
91 |
-} |
92 |
- |
93 |
- |
94 |
KoFilter::ConversionStatus WPGImport::convert(const QByteArray& from, const QByteArray& to) |
95 |
{ |
96 |
if (from != "application/x-wpg") |
97 |
return KoFilter::NotImplemented; |
98 |
|
99 |
- if (to != "application/vnd.oasis.opendocument.graphics") |
100 |
+ if (to != "image/svg+xml") |
101 |
return KoFilter::NotImplemented; |
102 |
|
103 |
#if LIBWPG_VERSION_MINOR<2 |
104 |
@@ -96,6 +72,7 @@ |
105 |
input = olestream; |
106 |
} |
107 |
} |
108 |
+ libwpg::WPGString output; |
109 |
#else |
110 |
WPXInputStream* input = new WPXFileStream(m_chain->inputFile().toLocal8Bit()); |
111 |
if (input->isOLEStream()) { |
112 |
@@ -105,6 +82,7 @@ |
113 |
input = olestream; |
114 |
} |
115 |
} |
116 |
+ ::WPXString output; |
117 |
#endif |
118 |
|
119 |
if (!libwpg::WPGraphics::isSupported(input)) { |
120 |
@@ -113,51 +91,21 @@ |
121 |
return KoFilter::NotImplemented; |
122 |
} |
123 |
|
124 |
- // do the conversion |
125 |
- std::ostringstream tmpStringStream; |
126 |
- FileOutputHandler tmpHandler(tmpStringStream); |
127 |
- OdgExporter exporter(&tmpHandler); |
128 |
- libwpg::WPGraphics::parse(input, &exporter); |
129 |
- delete input; |
130 |
- |
131 |
- |
132 |
- // create output store |
133 |
- KoStore* storeout; |
134 |
- storeout = KoStore::createStore(m_chain->outputFile(), KoStore::Write, |
135 |
- "application/vnd.oasis.opendocument.graphics", KoStore::Zip); |
136 |
- |
137 |
- if (!storeout) { |
138 |
- kWarning() << "Couldn't open the requested file."; |
139 |
- return KoFilter::FileNotFound; |
140 |
- } |
141 |
- |
142 |
-#if 0 |
143 |
- if (!storeout->open("styles.xml")) { |
144 |
- kWarning() << "Couldn't open the file 'styles.xml'."; |
145 |
- return KoFilter::CreationError; |
146 |
- } |
147 |
- //storeout->write( createStyles() ); |
148 |
- storeout->close(); |
149 |
-#endif |
150 |
- |
151 |
- if (!storeout->open("content.xml")) { |
152 |
- kWarning() << "Couldn't open the file 'content.xml'."; |
153 |
- return KoFilter::CreationError; |
154 |
- } |
155 |
- storeout->write(tmpStringStream.str().c_str()); |
156 |
- storeout->close(); |
157 |
- |
158 |
- // store document manifest |
159 |
- storeout->enterDirectory("META-INF"); |
160 |
- if (!storeout->open("manifest.xml")) { |
161 |
- kWarning() << "Couldn't open the file 'META-INF/manifest.xml'."; |
162 |
- return KoFilter::CreationError; |
163 |
+ if (!libwpg::WPGraphics::generateSVG(input, output)) { |
164 |
+ kWarning() << "ERROR: SVG Generation failed!"; |
165 |
+ delete input; |
166 |
+ return KoFilter::ParsingError; |
167 |
} |
168 |
- storeout->write(createManifest()); |
169 |
- storeout->close(); |
170 |
- |
171 |
- // we are done! |
172 |
- delete storeout; |
173 |
|
174 |
+ delete input; |
175 |
+ |
176 |
+ QFile outputFile(m_chain->outputFile()); |
177 |
+ if(!outputFile.open(QIODevice::WriteOnly | QIODevice::Text)) { |
178 |
+ kWarning() << "ERROR: Could not open output file" << m_chain->outputFile(); |
179 |
+ return KoFilter::InternalError; |
180 |
+ } |
181 |
+ outputFile.write(output.cstr()); |
182 |
+ outputFile.close(); |
183 |
+ |
184 |
return KoFilter::OK; |
185 |
} |
186 |
--- a/filters/karbon/wpg/import/karbon_wpg_import.desktop |
187 |
+++ b/filters/karbon/wpg/import/karbon_wpg_import.desktop |
188 |
@@ -42,7 +42,7 @@ |
189 |
Name[x-test]=xxKarbon WPG Import Filterxx |
190 |
Name[zh_CN]=Karbon WPG 导入过滤器 |
191 |
Name[zh_TW]=Karbon WPG 匯入過濾程式 |
192 |
-X-KDE-Export=application/vnd.oasis.opendocument.graphics |
193 |
+X-KDE-Export=image/svg+xml |
194 |
X-KDE-Import=application/x-wpg |
195 |
X-KDE-Weight=1 |
196 |
X-KDE-Library=wpgimport |