abiword-3.0.0-librevenge.patch 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  1. Index: plugins/wpg/xp/ie_impGraphic_WPG.cpp
  2. ===================================================================
  3. --- plugins/wpg/xp/ie_impGraphic_WPG.cpp (revision 34460)
  4. +++ plugins/wpg/xp/ie_impGraphic_WPG.cpp (working copy)
  5. @@ -31,7 +31,7 @@
  6. #include <gsf/gsf-input-memory.h>
  7. #include <gsf/gsf-input-stdio.h>
  8. #include <gsf/gsf-infile-msole.h>
  9. -#include <libwpd-stream/libwpd-stream.h>
  10. +#include <librevenge-stream/librevenge-stream.h>
  11. #include "xap_Module.h"
  12. using libwpg::WPGraphics;
  13. @@ -38,30 +38,35 @@
  14. ABI_PLUGIN_DECLARE("WPG")
  15. -class AbiWordPerfectGraphicsInputStream : public WPXInputStream
  16. +class AbiWordPerfectGraphicsInputStream : public librevenge::RVNGInputStream
  17. {
  18. public:
  19. AbiWordPerfectGraphicsInputStream(GsfInput *input);
  20. ~AbiWordPerfectGraphicsInputStream();
  21. - virtual bool isOLEStream();
  22. - virtual WPXInputStream * getDocumentOLEStream();
  23. - virtual WPXInputStream * getDocumentOLEStream(const char * name);
  24. + virtual bool isStructured();
  25. + virtual unsigned subStreamCount();
  26. + virtual const char* subStreamName(unsigned);
  27. + bool existsSubStream(const char*);
  28. + virtual librevenge::RVNGInputStream* getSubStreamByName(const char*);
  29. + virtual librevenge::RVNGInputStream* getSubStreamById(unsigned);
  30. virtual const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead);
  31. - virtual int seek(long offset, WPX_SEEK_TYPE seekType);
  32. + virtual int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType);
  33. virtual long tell();
  34. - virtual bool atEOS();
  35. + virtual bool isEnd();
  36. private:
  37. GsfInput *m_input;
  38. GsfInfile *m_ole;
  39. + std::map<unsigned, std::string> m_substreams;
  40. };
  41. AbiWordPerfectGraphicsInputStream::AbiWordPerfectGraphicsInputStream(GsfInput *input) :
  42. - WPXInputStream(),
  43. + librevenge::RVNGInputStream(),
  44. m_input(input),
  45. - m_ole(NULL)
  46. + m_ole(NULL),
  47. + m_substreams()
  48. {
  49. g_object_ref(G_OBJECT(input));
  50. }
  51. @@ -86,50 +91,120 @@
  52. return buf;
  53. }
  54. -int AbiWordPerfectGraphicsInputStream::seek(long offset, WPX_SEEK_TYPE seekType)
  55. +int AbiWordPerfectGraphicsInputStream::seek(long offset, librevenge::RVNG_SEEK_TYPE seekType)
  56. {
  57. GSeekType gsfSeekType = G_SEEK_SET;
  58. switch(seekType)
  59. {
  60. - case WPX_SEEK_CUR:
  61. + case librevenge::RVNG_SEEK_CUR:
  62. gsfSeekType = G_SEEK_CUR;
  63. break;
  64. - case WPX_SEEK_SET:
  65. + case librevenge::RVNG_SEEK_SET:
  66. gsfSeekType = G_SEEK_SET;
  67. break;
  68. + case librevenge::RVNG_SEEK_END:
  69. + gsfSeekType = G_SEEK_END;
  70. + break;
  71. }
  72. return gsf_input_seek(m_input, offset, gsfSeekType);
  73. }
  74. -bool AbiWordPerfectGraphicsInputStream::isOLEStream()
  75. +bool AbiWordPerfectGraphicsInputStream::isStructured()
  76. {
  77. if (!m_ole)
  78. m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  79. - if (m_ole != NULL)
  80. + if (!m_ole)
  81. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  82. +
  83. + if (m_ole)
  84. return true;
  85. return false;
  86. }
  87. -WPXInputStream * AbiWordPerfectGraphicsInputStream::getDocumentOLEStream()
  88. +unsigned AbiWordPerfectGraphicsInputStream::subStreamCount()
  89. {
  90. - return getDocumentOLEStream("PerfectOffice_MAIN");
  91. + if (!m_ole)
  92. + m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  93. +
  94. + if (!m_ole)
  95. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  96. +
  97. + if (m_ole)
  98. + {
  99. + int numChildren = gsf_infile_num_children(m_ole);
  100. + if (numChildren > 0)
  101. + return numChildren;
  102. + return 0;
  103. + }
  104. +
  105. + return 0;
  106. }
  107. -WPXInputStream * AbiWordPerfectGraphicsInputStream::getDocumentOLEStream(const char * name)
  108. +const char * AbiWordPerfectGraphicsInputStream::subStreamName(unsigned id)
  109. {
  110. - WPXInputStream *documentStream = NULL;
  111. + if (!m_ole)
  112. + m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  113. if (!m_ole)
  114. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  115. +
  116. + if (m_ole)
  117. + {
  118. + if ((int)id >= gsf_infile_num_children(m_ole))
  119. + {
  120. + return 0;
  121. + }
  122. + std::map<unsigned, std::string>::iterator i = m_substreams.lower_bound(id);
  123. + if (i == m_substreams.end() || m_substreams.key_comp()(id, i->first))
  124. + {
  125. + std::string name = gsf_infile_name_by_index(m_ole, (int)id);
  126. + i = m_substreams.insert(i, std::map<unsigned, std::string>::value_type(id, name));
  127. + }
  128. + return i->second.c_str();
  129. + }
  130. +
  131. + return 0;
  132. +}
  133. +
  134. +bool AbiWordPerfectGraphicsInputStream::existsSubStream(const char * name)
  135. +{
  136. + if (!m_ole)
  137. m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  138. + if (!m_ole)
  139. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  140. +
  141. if (m_ole)
  142. {
  143. GsfInput *document = gsf_infile_child_by_name(m_ole, name);
  144. if (document)
  145. {
  146. + g_object_unref(G_OBJECT (document));
  147. + return true;
  148. + }
  149. + }
  150. +
  151. + return false;
  152. +}
  153. +
  154. +librevenge::RVNGInputStream * AbiWordPerfectGraphicsInputStream::getSubStreamByName(const char * name)
  155. +{
  156. + librevenge::RVNGInputStream *documentStream = NULL;
  157. +
  158. + if (!m_ole)
  159. + m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  160. +
  161. + if (!m_ole)
  162. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  163. +
  164. + if (m_ole)
  165. + {
  166. + GsfInput *document = gsf_infile_child_by_name(m_ole, name);
  167. + if (document)
  168. + {
  169. documentStream = new AbiWordPerfectGraphicsInputStream(document);
  170. g_object_unref(G_OBJECT (document)); // the only reference should be encapsulated within the new stream
  171. }
  172. @@ -138,12 +213,35 @@
  173. return documentStream;
  174. }
  175. +librevenge::RVNGInputStream * AbiWordPerfectGraphicsInputStream::getSubStreamById(unsigned id)
  176. +{
  177. + librevenge::RVNGInputStream *documentStream = NULL;
  178. +
  179. + if (!m_ole)
  180. + m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  181. +
  182. + if (!m_ole)
  183. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  184. +
  185. + if (m_ole)
  186. + {
  187. + GsfInput *document = gsf_infile_child_by_index(m_ole, (int)id);
  188. + if (document)
  189. + {
  190. + documentStream = new AbiWordPerfectGraphicsInputStream(document);
  191. + g_object_unref(G_OBJECT (document)); // the only reference should be encapsulated within the new stream
  192. + }
  193. + }
  194. +
  195. + return documentStream;
  196. +}
  197. +
  198. long AbiWordPerfectGraphicsInputStream::tell()
  199. {
  200. return gsf_input_tell(m_input);
  201. }
  202. -bool AbiWordPerfectGraphicsInputStream::atEOS()
  203. +bool AbiWordPerfectGraphicsInputStream::isEnd()
  204. {
  205. return gsf_input_eof(m_input);
  206. }
  207. @@ -244,14 +342,24 @@
  208. UT_Error IE_Imp_WordPerfectGraphics::importGraphic(GsfInput *input, FG_Graphic **ppfg)
  209. {
  210. AbiWordPerfectGraphicsInputStream gsfInput(input);
  211. - WPXString svgOutput;
  212. - if (WPGraphics::generateSVG(&gsfInput, svgOutput))
  213. + librevenge::RVNGString svgOutput;
  214. + librevenge::RVNGStringVector vec;
  215. + librevenge::RVNGSVGDrawingGenerator generator(vec, "");
  216. +
  217. + if (!libwpg::WPGraphics::parse(&gsfInput, &generator) || vec.empty() || vec[0].empty())
  218. {
  219. - GsfInput * svgInput = gsf_input_memory_new((const guint8*)svgOutput.cstr(), svgOutput.len(), false);
  220. - UT_Error result = IE_ImpGraphic::loadGraphic(svgInput, IE_ImpGraphic::fileTypeForSuffix(".svg"), ppfg);
  221. - g_object_unref(svgInput);
  222. - return result;
  223. + return UT_ERROR;
  224. }
  225. - return UT_ERROR;
  226. +
  227. + svgOutput.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
  228. + svgOutput.append("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"");
  229. + svgOutput.append(" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
  230. + svgOutput.append(vec[0]);
  231. + svgOutput.append("\n");
  232. +
  233. + GsfInput * svgInput = gsf_input_memory_new((const guint8*)svgOutput.cstr(), svgOutput.len(), false);
  234. + UT_Error result = IE_ImpGraphic::loadGraphic(svgInput, IE_ImpGraphic::fileTypeForSuffix(".svg"), ppfg);
  235. + g_object_unref(svgInput);
  236. + return result;
  237. }
  238. Index: plugins/wpg/plugin.m4
  239. ===================================================================
  240. --- plugins/wpg/plugin.m4 (revision 34460)
  241. +++ plugins/wpg/plugin.m4 (working copy)
  242. @@ -1,5 +1,5 @@
  243. -wpg_pkgs="$gsf_req libwpg-0.2 >= 0.2.0 libwpd-0.9 >= 0.9.0 libwpd-stream-0.9 >= 0.9.0"
  244. +wpg_pkgs="libwpg-0.3 $gsf_req"
  245. wpg_deps="no"
  246. if test "$enable_wpg" != ""; then
  247. Index: plugins/wordperfect/xp/ie_imp_WordPerfect.h
  248. ===================================================================
  249. --- plugins/wordperfect/xp/ie_imp_WordPerfect.h (revision 34460)
  250. +++ plugins/wordperfect/xp/ie_imp_WordPerfect.h (working copy)
  251. @@ -30,7 +30,7 @@
  252. #define IE_IMP_WP_H
  253. #include <stdio.h>
  254. -#include <libwpd/libwpd.h>
  255. +#include <librevenge/librevenge.h>
  256. #include "ie_imp.h"
  257. #include "ut_string.h"
  258. #include "ut_string_class.h"
  259. @@ -92,7 +92,7 @@
  260. IE_Imp ** ppie);
  261. };
  262. -class IE_Imp_WordPerfect : public IE_Imp, public WPXDocumentInterface
  263. +class IE_Imp_WordPerfect : public IE_Imp, public librevenge::RVNGTextInterface
  264. {
  265. public:
  266. IE_Imp_WordPerfect(PD_Document * pDocument);
  267. @@ -101,69 +101,83 @@
  268. virtual void pasteFromBuffer(PD_DocumentRange * pDocRange,
  269. UT_uint8 * pData, UT_uint32 lenData, const char * szEncoding = 0);
  270. - virtual void setDocumentMetaData(const WPXPropertyList &propList);
  271. + virtual void setDocumentMetaData(const librevenge::RVNGPropertyList &propList);
  272. - virtual void startDocument();
  273. - virtual void endDocument();
  274. + virtual void startDocument(const librevenge::RVNGPropertyList &propList);
  275. + virtual void endDocument();
  276. - virtual void openPageSpan(const WPXPropertyList &propList);
  277. - virtual void closePageSpan() {}
  278. - virtual void openHeader(const WPXPropertyList &propList);
  279. - virtual void closeHeader();
  280. - virtual void openFooter(const WPXPropertyList &propList);
  281. - virtual void closeFooter();
  282. + virtual void defineEmbeddedFont(const librevenge::RVNGPropertyList & /* propList */) {}
  283. - virtual void openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
  284. - virtual void closeParagraph() {}
  285. + virtual void definePageStyle(const librevenge::RVNGPropertyList &) {}
  286. + virtual void openPageSpan(const librevenge::RVNGPropertyList &propList);
  287. + virtual void closePageSpan() {}
  288. + virtual void openHeader(const librevenge::RVNGPropertyList &propList);
  289. + virtual void closeHeader();
  290. + virtual void openFooter(const librevenge::RVNGPropertyList &propList);
  291. + virtual void closeFooter();
  292. - virtual void openSpan(const WPXPropertyList &propList);
  293. - virtual void closeSpan() {}
  294. + virtual void defineSectionStyle(const librevenge::RVNGPropertyList &) {}
  295. + virtual void openSection(const librevenge::RVNGPropertyList &propList);
  296. + virtual void closeSection() {}
  297. - virtual void openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns);
  298. - virtual void closeSection() {}
  299. + virtual void defineParagraphStyle(const librevenge::RVNGPropertyList &) {}
  300. + virtual void openParagraph(const librevenge::RVNGPropertyList &propList);
  301. + virtual void closeParagraph() {}
  302. - virtual void insertTab();
  303. - virtual void insertText(const WPXString &text);
  304. - virtual void insertLineBreak();
  305. + virtual void defineCharacterStyle(const librevenge::RVNGPropertyList &) {}
  306. + virtual void openSpan(const librevenge::RVNGPropertyList &propList);
  307. + virtual void closeSpan() {}
  308. - virtual void defineOrderedListLevel(const WPXPropertyList &propList);
  309. - virtual void defineUnorderedListLevel(const WPXPropertyList &propList);
  310. - virtual void openOrderedListLevel(const WPXPropertyList &propList);
  311. - virtual void openUnorderedListLevel(const WPXPropertyList &propList);
  312. - virtual void closeOrderedListLevel();
  313. - virtual void closeUnorderedListLevel();
  314. - virtual void openListElement(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops);
  315. - virtual void closeListElement() {}
  316. + virtual void openLink(const librevenge::RVNGPropertyList & /* propList */) {}
  317. + virtual void closeLink() {}
  318. - virtual void openFootnote(const WPXPropertyList &propList);
  319. - virtual void closeFootnote();
  320. - virtual void openEndnote(const WPXPropertyList &propList);
  321. - virtual void closeEndnote();
  322. + virtual void insertTab();
  323. + virtual void insertText(const librevenge::RVNGString &text);
  324. + virtual void insertSpace();
  325. + virtual void insertLineBreak();
  326. + virtual void insertField(const librevenge::RVNGPropertyList & /* propList */) {}
  327. - virtual void openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns);
  328. - virtual void openTableRow(const WPXPropertyList &propList);
  329. - virtual void closeTableRow() {}
  330. - virtual void openTableCell(const WPXPropertyList &propList);
  331. - virtual void closeTableCell() {}
  332. - virtual void insertCoveredTableCell(const WPXPropertyList & /*propList*/) {}
  333. - virtual void closeTable();
  334. + virtual void openOrderedListLevel(const librevenge::RVNGPropertyList &propList);
  335. + virtual void openUnorderedListLevel(const librevenge::RVNGPropertyList &propList);
  336. + virtual void closeOrderedListLevel();
  337. + virtual void closeUnorderedListLevel();
  338. + virtual void openListElement(const librevenge::RVNGPropertyList &propList);
  339. + virtual void closeListElement() {}
  340. - virtual void definePageStyle(const WPXPropertyList&) {}
  341. - virtual void defineParagraphStyle(const WPXPropertyList&, const WPXPropertyListVector&) {}
  342. - virtual void defineCharacterStyle(const WPXPropertyList&) {}
  343. - virtual void defineSectionStyle(const WPXPropertyList&, const WPXPropertyListVector&) {}
  344. - virtual void insertSpace() {}
  345. - virtual void insertField(const WPXString&, const WPXPropertyList&) {}
  346. - virtual void openComment(const WPXPropertyList&) {}
  347. - virtual void closeComment() {}
  348. - virtual void openTextBox(const WPXPropertyList&) {}
  349. - virtual void closeTextBox() {}
  350. - virtual void openFrame(const WPXPropertyList&) {}
  351. - virtual void closeFrame() {}
  352. - virtual void insertBinaryObject(const WPXPropertyList&, const WPXBinaryData&) {}
  353. - virtual void insertEquation(const WPXPropertyList&, const WPXString&) {}
  354. + virtual void openFootnote(const librevenge::RVNGPropertyList &propList);
  355. + virtual void closeFootnote();
  356. + virtual void openEndnote(const librevenge::RVNGPropertyList &propList);
  357. + virtual void closeEndnote();
  358. + virtual void openComment(const librevenge::RVNGPropertyList & /* propList */) {}
  359. + virtual void closeComment() {}
  360. + virtual void openTextBox(const librevenge::RVNGPropertyList & /* propList */) {}
  361. + virtual void closeTextBox() {}
  362. + virtual void openTable(const librevenge::RVNGPropertyList &propList);
  363. + virtual void openTableRow(const librevenge::RVNGPropertyList &propList);
  364. + virtual void closeTableRow() {}
  365. + virtual void openTableCell(const librevenge::RVNGPropertyList &propList);
  366. + virtual void closeTableCell() {}
  367. + virtual void insertCoveredTableCell(const librevenge::RVNGPropertyList & /* propList */) {}
  368. + virtual void closeTable();
  369. + virtual void openFrame(const librevenge::RVNGPropertyList & /* propList */) {}
  370. + virtual void closeFrame() {}
  371. +
  372. + virtual void openGroup(const librevenge::RVNGPropertyList & /* propList */) {}
  373. + virtual void closeGroup() {}
  374. +
  375. + virtual void defineGraphicStyle(const librevenge::RVNGPropertyList & /* propList */) {}
  376. + virtual void drawRectangle(const librevenge::RVNGPropertyList & /* propList */) {}
  377. + virtual void drawEllipse(const librevenge::RVNGPropertyList & /* propList */) {}
  378. + virtual void drawPolygon(const librevenge::RVNGPropertyList & /* propList */) {}
  379. + virtual void drawPolyline(const librevenge::RVNGPropertyList & /* propList */) {}
  380. + virtual void drawPath(const librevenge::RVNGPropertyList & /* propList */) {}
  381. + virtual void drawConnector(const librevenge::RVNGPropertyList & /* propList */) {}
  382. +
  383. + virtual void insertBinaryObject(const librevenge::RVNGPropertyList & /* propList */) {}
  384. + virtual void insertEquation(const librevenge::RVNGPropertyList & /* propList */) {}
  385. +
  386. protected:
  387. virtual UT_Error _loadFile(GsfInput * input);
  388. UT_Error _appendSection(int numColumns, const float, const float);
  389. Index: plugins/wordperfect/xp/ie_impexp_WordPerfect.cpp
  390. ===================================================================
  391. --- plugins/wordperfect/xp/ie_impexp_WordPerfect.cpp (revision 34460)
  392. +++ plugins/wordperfect/xp/ie_impexp_WordPerfect.cpp (working copy)
  393. @@ -35,7 +35,6 @@
  394. ABI_PLUGIN_DECLARE("WordPerfect")
  395. static IE_Imp_WordPerfect_Sniffer * m_ImpSniffer = 0;
  396. -static IE_Exp_WordPerfect_Sniffer * m_ExpSniffer = 0;
  397. #ifdef HAVE_LIBWPS
  398. static IE_Imp_MSWorks_Sniffer * m_MSWorks_ImpSniffer = 0;
  399. @@ -49,13 +48,7 @@
  400. m_ImpSniffer = new IE_Imp_WordPerfect_Sniffer ();
  401. }
  402. - if (!m_ExpSniffer)
  403. - {
  404. - m_ExpSniffer = new IE_Exp_WordPerfect_Sniffer ();
  405. - }
  406. -
  407. UT_ASSERT (m_ImpSniffer);
  408. - UT_ASSERT (m_ExpSniffer);
  409. #ifdef HAVE_LIBWPS
  410. if (!m_MSWorks_ImpSniffer)
  411. @@ -79,7 +72,7 @@
  412. mi->usage = "No Usage";
  413. IE_Imp::registerImporter (m_ImpSniffer);
  414. - //IE_Exp::registerExporter (m_ExpSniffer);
  415. +
  416. return 1;
  417. }
  418. @@ -93,18 +86,11 @@
  419. mi->usage = 0;
  420. UT_ASSERT (m_ImpSniffer);
  421. - UT_ASSERT (m_ExpSniffer);
  422. IE_Imp::unregisterImporter (m_ImpSniffer);
  423. delete m_ImpSniffer;
  424. m_ImpSniffer = 0;
  425. - /*
  426. - IE_Exp::unregisterExporter (m_ExpSniffer);
  427. - delete m_ExpSniffer;
  428. - m_ExpSniffer = 0;
  429. - */
  430. -
  431. #ifdef HAVE_LIBWPS
  432. IE_Imp::unregisterImporter (m_MSWorks_ImpSniffer);
  433. delete m_MSWorks_ImpSniffer;
  434. Index: plugins/wordperfect/xp/ie_imp_WordPerfect.cpp
  435. ===================================================================
  436. --- plugins/wordperfect/xp/ie_imp_WordPerfect.cpp (revision 34460)
  437. +++ plugins/wordperfect/xp/ie_imp_WordPerfect.cpp (working copy)
  438. @@ -31,6 +31,8 @@
  439. #include <stdlib.h>
  440. #include <string.h>
  441. #include <math.h>
  442. +#include <map>
  443. +#include <string>
  444. #include <gsf/gsf-utils.h>
  445. #include <gsf/gsf-input-memory.h>
  446. #include <gsf/gsf-input-stdio.h>
  447. @@ -60,42 +62,47 @@
  448. // Stream class
  449. -#include <libwpd-stream/libwpd-stream.h>
  450. +#include <librevenge-stream/librevenge-stream.h>
  451. +#include <libwpd/libwpd.h>
  452. #include <gsf/gsf-input.h>
  453. #include <gsf/gsf-infile.h>
  454. #include <gsf/gsf-infile-msole.h>
  455. +#include <gsf/gsf-infile-zip.h>
  456. #ifdef HAVE_LIBWPS
  457. #include <libwps/libwps.h>
  458. #endif
  459. -class AbiWordperfectInputStream : public WPXInputStream
  460. +class AbiWordperfectInputStream : public librevenge::RVNGInputStream
  461. {
  462. public:
  463. AbiWordperfectInputStream(GsfInput *input);
  464. ~AbiWordperfectInputStream();
  465. - virtual bool isOLEStream();
  466. - virtual WPXInputStream * getDocumentOLEStream();
  467. -
  468. - virtual WPXInputStream * getDocumentOLEStream(const char * name);
  469. -
  470. + virtual bool isStructured();
  471. + virtual unsigned subStreamCount();
  472. + virtual const char* subStreamName(unsigned);
  473. + bool existsSubStream(const char*);
  474. + virtual librevenge::RVNGInputStream* getSubStreamByName(const char*);
  475. + virtual librevenge::RVNGInputStream* getSubStreamById(unsigned);
  476. virtual const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead);
  477. - virtual int seek(long offset, WPX_SEEK_TYPE seekType);
  478. + virtual int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType);
  479. virtual long tell();
  480. - virtual bool atEOS();
  481. + virtual bool isEnd();
  482. private:
  483. GsfInput *m_input;
  484. GsfInfile *m_ole;
  485. + std::map<unsigned, std::string> m_substreams;
  486. };
  487. AbiWordperfectInputStream::AbiWordperfectInputStream(GsfInput *input) :
  488. - WPXInputStream(),
  489. + librevenge::RVNGInputStream(),
  490. m_input(input),
  491. - m_ole(NULL)
  492. + m_ole(NULL),
  493. + m_substreams()
  494. {
  495. g_object_ref(G_OBJECT(input));
  496. }
  497. @@ -120,50 +127,120 @@
  498. return buf;
  499. }
  500. -int AbiWordperfectInputStream::seek(long offset, WPX_SEEK_TYPE seekType)
  501. +int AbiWordperfectInputStream::seek(long offset, librevenge::RVNG_SEEK_TYPE seekType)
  502. {
  503. GSeekType gsfSeekType = G_SEEK_SET;
  504. switch(seekType)
  505. {
  506. - case WPX_SEEK_CUR:
  507. + case librevenge::RVNG_SEEK_CUR:
  508. gsfSeekType = G_SEEK_CUR;
  509. break;
  510. - case WPX_SEEK_SET:
  511. + case librevenge::RVNG_SEEK_SET:
  512. gsfSeekType = G_SEEK_SET;
  513. break;
  514. + case librevenge::RVNG_SEEK_END:
  515. + gsfSeekType = G_SEEK_END;
  516. + break;
  517. }
  518. return gsf_input_seek(m_input, offset, gsfSeekType);
  519. }
  520. -bool AbiWordperfectInputStream::isOLEStream()
  521. +bool AbiWordperfectInputStream::isStructured()
  522. {
  523. if (!m_ole)
  524. m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  525. - if (m_ole != NULL)
  526. + if (!m_ole)
  527. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  528. +
  529. + if (m_ole)
  530. return true;
  531. return false;
  532. }
  533. -WPXInputStream * AbiWordperfectInputStream::getDocumentOLEStream()
  534. +unsigned AbiWordperfectInputStream::subStreamCount()
  535. {
  536. - return getDocumentOLEStream("PerfectOffice_MAIN");
  537. + if (!m_ole)
  538. + m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  539. +
  540. + if (!m_ole)
  541. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  542. +
  543. + if (m_ole)
  544. + {
  545. + int numChildren = gsf_infile_num_children(m_ole);
  546. + if (numChildren > 0)
  547. + return numChildren;
  548. + return 0;
  549. + }
  550. +
  551. + return 0;
  552. }
  553. -WPXInputStream * AbiWordperfectInputStream::getDocumentOLEStream(const char * name)
  554. +const char * AbiWordperfectInputStream::subStreamName(unsigned id)
  555. {
  556. - WPXInputStream *documentStream = NULL;
  557. + if (!m_ole)
  558. + m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  559. if (!m_ole)
  560. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  561. +
  562. + if (m_ole)
  563. + {
  564. + if ((int)id >= gsf_infile_num_children(m_ole))
  565. + {
  566. + return 0;
  567. + }
  568. + std::map<unsigned, std::string>::iterator i = m_substreams.lower_bound(id);
  569. + if (i == m_substreams.end() || m_substreams.key_comp()(id, i->first))
  570. + {
  571. + std::string name = gsf_infile_name_by_index(m_ole, (int)id);
  572. + i = m_substreams.insert(i, std::map<unsigned, std::string>::value_type(id, name));
  573. + }
  574. + return i->second.c_str();
  575. + }
  576. +
  577. + return 0;
  578. +}
  579. +
  580. +bool AbiWordperfectInputStream::existsSubStream(const char * name)
  581. +{
  582. + if (!m_ole)
  583. m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  584. + if (!m_ole)
  585. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  586. +
  587. if (m_ole)
  588. {
  589. GsfInput *document = gsf_infile_child_by_name(m_ole, name);
  590. if (document)
  591. {
  592. + g_object_unref(G_OBJECT (document));
  593. + return true;
  594. + }
  595. + }
  596. +
  597. + return false;
  598. +}
  599. +
  600. +librevenge::RVNGInputStream * AbiWordperfectInputStream::getSubStreamByName(const char * name)
  601. +{
  602. + librevenge::RVNGInputStream *documentStream = NULL;
  603. +
  604. + if (!m_ole)
  605. + m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  606. +
  607. + if (!m_ole)
  608. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  609. +
  610. + if (m_ole)
  611. + {
  612. + GsfInput *document = gsf_infile_child_by_name(m_ole, name);
  613. + if (document)
  614. + {
  615. documentStream = new AbiWordperfectInputStream(document);
  616. g_object_unref(G_OBJECT (document)); // the only reference should be encapsulated within the new stream
  617. }
  618. @@ -172,12 +249,35 @@
  619. return documentStream;
  620. }
  621. +librevenge::RVNGInputStream * AbiWordperfectInputStream::getSubStreamById(unsigned id)
  622. +{
  623. + librevenge::RVNGInputStream *documentStream = NULL;
  624. +
  625. + if (!m_ole)
  626. + m_ole = GSF_INFILE(gsf_infile_msole_new (m_input, NULL));
  627. +
  628. + if (!m_ole)
  629. + m_ole = GSF_INFILE(gsf_infile_zip_new (m_input, NULL));
  630. +
  631. + if (m_ole)
  632. + {
  633. + GsfInput *document = gsf_infile_child_by_index(m_ole, (int)id);
  634. + if (document)
  635. + {
  636. + documentStream = new AbiWordperfectInputStream(document);
  637. + g_object_unref(G_OBJECT (document)); // the only reference should be encapsulated within the new stream
  638. + }
  639. + }
  640. +
  641. + return documentStream;
  642. +}
  643. +
  644. long AbiWordperfectInputStream::tell()
  645. {
  646. return gsf_input_tell(m_input);
  647. }
  648. -bool AbiWordperfectInputStream::atEOS()
  649. +bool AbiWordperfectInputStream::isEnd()
  650. {
  651. return gsf_input_eof(m_input);
  652. }
  653. @@ -247,13 +347,13 @@
  654. {
  655. AbiWordperfectInputStream gsfInput(input);
  656. - WPDConfidence confidence = WPDocument::isFileFormatSupported(&gsfInput);
  657. -
  658. + libwpd::WPDConfidence confidence = libwpd::WPDocument::isFileFormatSupported(&gsfInput);
  659. +
  660. switch (confidence)
  661. {
  662. - case WPD_CONFIDENCE_NONE:
  663. + case libwpd::WPD_CONFIDENCE_NONE:
  664. return UT_CONFIDENCE_ZILCH;
  665. - case WPD_CONFIDENCE_EXCELLENT:
  666. + case libwpd::WPD_CONFIDENCE_EXCELLENT:
  667. return UT_CONFIDENCE_PERFECT;
  668. default:
  669. return UT_CONFIDENCE_ZILCH;
  670. @@ -312,9 +412,9 @@
  671. UT_Error IE_Imp_WordPerfect::_loadFile(GsfInput * input)
  672. {
  673. AbiWordperfectInputStream gsfInput(input);
  674. - WPDResult error = WPDocument::parse(&gsfInput, static_cast<WPXDocumentInterface *>(this), NULL);
  675. + libwpd::WPDResult error = libwpd::WPDocument::parse(&gsfInput, static_cast<librevenge::RVNGTextInterface *>(this), NULL);
  676. - if (error != WPD_OK)
  677. + if (error != libwpd::WPD_OK)
  678. {
  679. UT_DEBUGMSG(("AbiWordPerfect: ERROR: %i!\n", (int)error));
  680. return UT_IE_IMPORTERROR;
  681. @@ -329,7 +429,7 @@
  682. // nada
  683. }
  684. -void IE_Imp_WordPerfect::setDocumentMetaData(const WPXPropertyList &propList)
  685. +void IE_Imp_WordPerfect::setDocumentMetaData(const librevenge::RVNGPropertyList &propList)
  686. {
  687. if (propList["dc:author"])
  688. getDoc()->setMetaDataProp(PD_META_KEY_CREATOR, propList["dc:author"]->getStr().cstr());
  689. @@ -339,15 +439,15 @@
  690. getDoc()->setMetaDataProp(PD_META_KEY_PUBLISHER, propList["dc:publisher"]->getStr().cstr());
  691. if (propList["dc:type"])
  692. getDoc()->setMetaDataProp(PD_META_KEY_TYPE, propList["dc:category"]->getStr().cstr());
  693. - if (propList["libwpd:keywords"])
  694. - getDoc()->setMetaDataProp(PD_META_KEY_KEYWORDS, propList["libwpd:keywords"]->getStr().cstr());
  695. + if (propList["librevenge:keywords"])
  696. + getDoc()->setMetaDataProp(PD_META_KEY_KEYWORDS, propList["librevenge:keywords"]->getStr().cstr());
  697. if (propList["dc:language"])
  698. getDoc()->setMetaDataProp(PD_META_KEY_LANGUAGE, propList["dc:language"]->getStr().cstr());
  699. - if (propList["libwpd:abstract"])
  700. - getDoc()->setMetaDataProp(PD_META_KEY_DESCRIPTION, propList["libwpd:abstract"]->getStr().cstr());
  701. + if (propList["librevenge:abstract"])
  702. + getDoc()->setMetaDataProp(PD_META_KEY_DESCRIPTION, propList["librevenge:abstract"]->getStr().cstr());
  703. }
  704. -void IE_Imp_WordPerfect::startDocument()
  705. +void IE_Imp_WordPerfect::startDocument(const librevenge::RVNGPropertyList & /* propList */)
  706. {
  707. UT_DEBUGMSG(("AbiWordPerfect: startDocument\n"));
  708. }
  709. @@ -357,7 +457,7 @@
  710. UT_DEBUGMSG(("AbiWordPerfect: endDocument\n"));
  711. }
  712. -void IE_Imp_WordPerfect::openPageSpan(const WPXPropertyList &propList)
  713. +void IE_Imp_WordPerfect::openPageSpan(const librevenge::RVNGPropertyList &propList)
  714. {
  715. if (m_bHdrFtrOpenCount) return; // HACK
  716. UT_DEBUGMSG(("AbiWordPerfect: openPageSpan\n"));
  717. @@ -378,7 +478,7 @@
  718. }
  719. -void IE_Imp_WordPerfect::openHeader(const WPXPropertyList & /*propList*/)
  720. +void IE_Imp_WordPerfect::openHeader(const librevenge::RVNGPropertyList & /*propList*/)
  721. {
  722. m_bHdrFtrOpenCount++;
  723. @@ -420,7 +520,7 @@
  724. */
  725. }
  726. -void IE_Imp_WordPerfect::openFooter(const WPXPropertyList & /*propList*/)
  727. +void IE_Imp_WordPerfect::openFooter(const librevenge::RVNGPropertyList & /*propList*/)
  728. {
  729. m_bHdrFtrOpenCount++;
  730. // see above comments re: openHeader
  731. @@ -432,7 +532,7 @@
  732. // see above comments re: closeHeader
  733. }
  734. -void IE_Imp_WordPerfect::openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector &tabStops)
  735. +void IE_Imp_WordPerfect::openParagraph(const librevenge::RVNGPropertyList &propList)
  736. {
  737. if (m_bHdrFtrOpenCount) return; // HACK
  738. UT_DEBUGMSG(("AbiWordPerfect: openParagraph()\n"));
  739. @@ -478,13 +578,15 @@
  740. (int)(m_topMargin*72), (int)(m_bottomMargin*72), m_leftMarginOffset, m_rightMarginOffset, m_textIndent, lineSpacing);
  741. propBuffer += tmpBuffer;
  742. - if (tabStops.count() > 0) // Append the tabstop information
  743. + const librevenge::RVNGPropertyListVector *tabStops = propList.child("style:tab-stops");
  744. +
  745. + if (tabStops && tabStops->count()) // Append the tabstop information
  746. {
  747. propBuffer += "; tabstops:";
  748. tmpBuffer = "";
  749. - WPXPropertyListVector::Iter i(tabStops);
  750. - for (i.rewind(); i.next();)
  751. - {
  752. + librevenge::RVNGPropertyListVector::Iter i(*tabStops);
  753. + for (i.rewind(); i.next();)
  754. + {
  755. propBuffer += tmpBuffer;
  756. if (i()["style:position"])
  757. {
  758. @@ -515,8 +617,8 @@
  759. propBuffer += "0";
  760. tmpBuffer = ",";
  761. - }
  762. - }
  763. + }
  764. + }
  765. @@ -543,7 +645,7 @@
  766. }
  767. }
  768. -void IE_Imp_WordPerfect::openSpan(const WPXPropertyList &propList)
  769. +void IE_Imp_WordPerfect::openSpan(const librevenge::RVNGPropertyList &propList)
  770. {
  771. if (m_bHdrFtrOpenCount) return; // HACK
  772. UT_DEBUGMSG(("AbiWordPerfect: Appending current text properties\n"));
  773. @@ -614,13 +716,14 @@
  774. X_CheckDocumentError(appendFmt(propsArray));
  775. }
  776. -void IE_Imp_WordPerfect::openSection(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
  777. +void IE_Imp_WordPerfect::openSection(const librevenge::RVNGPropertyList &propList)
  778. {
  779. if (m_bHdrFtrOpenCount) return; // HACK
  780. UT_DEBUGMSG(("AbiWordPerfect: openSection\n"));
  781. float marginLeft = 0.0f, marginRight = 0.0f;
  782. - int columnsCount = ((columns.count() == 0) ? 1 : columns.count());
  783. + const librevenge::RVNGPropertyListVector *columns = propList.child("style:columns");
  784. + int columnsCount = ((!columns || !columns->count()) ? 1 : columns->count());
  785. // TODO: support spaceAfter
  786. if (propList["fo:start-indent"])
  787. @@ -647,7 +750,7 @@
  788. X_CheckDocumentError(appendSpan(&ucs,1));
  789. }
  790. -void IE_Imp_WordPerfect::insertText(const WPXString &text)
  791. +void IE_Imp_WordPerfect::insertText(const librevenge::RVNGString &text)
  792. {
  793. if (m_bHdrFtrOpenCount) return; // HACK
  794. if (text.len())
  795. @@ -658,6 +761,15 @@
  796. }
  797. }
  798. +void IE_Imp_WordPerfect::insertSpace()
  799. +{
  800. + if (m_bHdrFtrOpenCount) return; // HACK
  801. + UT_DEBUGMSG(("AbiWordPerfect: insertSpace\n"));
  802. +
  803. + UT_UCS4Char ucs = UCS_SPACE;
  804. + X_CheckDocumentError(appendSpan(&ucs,1));
  805. +}
  806. +
  807. void IE_Imp_WordPerfect::insertLineBreak()
  808. {
  809. if (m_bHdrFtrOpenCount) return; // HACK
  810. @@ -668,12 +780,11 @@
  811. }
  812. -
  813. -void IE_Imp_WordPerfect::defineOrderedListLevel(const WPXPropertyList &propList)
  814. +void IE_Imp_WordPerfect::openOrderedListLevel(const librevenge::RVNGPropertyList &propList)
  815. {
  816. if (m_bHdrFtrOpenCount) return; // HACK
  817. - UT_DEBUGMSG(("AbiWordPerfect: defineOrderedListLevel\n"));
  818. -
  819. + UT_DEBUGMSG(("AbiWordPerfect: openOrderedListLevel\n"));
  820. +
  821. int listID = 0, startingNumber = 0, level = 1;
  822. char listType = '1';
  823. UT_UTF8String textBeforeNumber, textAfterNumber;
  824. @@ -680,12 +791,12 @@
  825. float listLeftOffset = 0.0f;
  826. float listMinLabelWidth = 0.0f;
  827. - if (propList["libwpd:id"])
  828. - listID = propList["libwpd:id"]->getInt();
  829. + if (propList["librevenge:id"])
  830. + listID = propList["librevenge:id"]->getInt();
  831. if (propList["text:start-value"])
  832. startingNumber = propList["text:start-value"]->getInt();
  833. - if (propList["libwpd:level"])
  834. - level = propList["libwpd:level"]->getInt();
  835. + if (propList["librevenge:level"])
  836. + level = propList["librevenge:level"]->getInt();
  837. if (propList["style:num-prefix"])
  838. textBeforeNumber += propList["style:num-prefix"]->getStr().cstr();
  839. if (propList["style:num-suffix"])
  840. @@ -716,22 +827,38 @@
  841. m_pCurrentListDefinition->setListMinLabelWidth(level, listMinLabelWidth);
  842. _updateDocumentOrderedListDefinition(m_pCurrentListDefinition, level, listType, textBeforeNumber, textAfterNumber, startingNumber);
  843. }
  844. +
  845. + m_iCurrentListLevel++;
  846. }
  847. -void IE_Imp_WordPerfect::defineUnorderedListLevel(const WPXPropertyList &propList)
  848. +void IE_Imp_WordPerfect::closeOrderedListLevel()
  849. {
  850. if (m_bHdrFtrOpenCount) return; // HACK
  851. - UT_DEBUGMSG(("AbiWordPerfect: defineUnorderedListLevel\n"));
  852. + UT_DEBUGMSG(("AbiWordPerfect: closeOrderedListLevel (level: %i)\n", m_iCurrentListLevel));
  853. + UT_ASSERT(m_iCurrentListLevel > 0);
  854. +
  855. + // every time we close a list level, the level above it is normally renumbered to start at "1"
  856. + // again. this code takes care of that.
  857. + if (m_iCurrentListLevel < (WP6_NUM_LIST_LEVELS-1))
  858. + m_pCurrentListDefinition->setLevelNumber(m_iCurrentListLevel + 1, 0);
  859. +
  860. + m_iCurrentListLevel--;
  861. +}
  862. +void IE_Imp_WordPerfect::openUnorderedListLevel(const librevenge::RVNGPropertyList &propList)
  863. +{
  864. + if (m_bHdrFtrOpenCount) return; // HACK
  865. + UT_DEBUGMSG(("AbiWordPerfect: openUNorderedListLevel\n"));
  866. +
  867. int listID = 0, level = 1;
  868. - WPXString textBeforeNumber, textAfterNumber;
  869. + librevenge::RVNGString textBeforeNumber, textAfterNumber;
  870. float listLeftOffset = 0.0f;
  871. float listMinLabelWidth = 0.0f;
  872. - if (propList["libwpd:id"])
  873. - listID = propList["libwpd:id"]->getInt();
  874. - if (propList["libwpd:level"])
  875. - level = propList["libwpd:level"]->getInt();
  876. + if (propList["librevenge:id"])
  877. + listID = propList["librevenge:id"]->getInt();
  878. + if (propList["librevenge:level"])
  879. + level = propList["librevenge:level"]->getInt();
  880. if (propList["text:space-before"])
  881. listLeftOffset = propList["text:space-before"]->getDouble();
  882. if (propList["text:min-label-width"])
  883. @@ -752,39 +879,10 @@
  884. m_pCurrentListDefinition->setListMinLabelWidth(level, listMinLabelWidth);
  885. _updateDocumentUnorderedListDefinition(m_pCurrentListDefinition, level);
  886. }
  887. -}
  888. -//void IE_Imp_WordPerfect::openOrderedListLevel(const int listID)
  889. -void IE_Imp_WordPerfect::openOrderedListLevel(const WPXPropertyList & /*propList*/)
  890. -{
  891. - if (m_bHdrFtrOpenCount) return; // HACK
  892. - UT_DEBUGMSG(("AbiWordPerfect: openOrderedListLevel\n"));
  893. -
  894. m_iCurrentListLevel++;
  895. }
  896. -void IE_Imp_WordPerfect::closeOrderedListLevel()
  897. -{
  898. - if (m_bHdrFtrOpenCount) return; // HACK
  899. - UT_DEBUGMSG(("AbiWordPerfect: closeOrderedListLevel (level: %i)\n", m_iCurrentListLevel));
  900. - UT_ASSERT(m_iCurrentListLevel > 0);
  901. -
  902. - // every time we close a list level, the level above it is normally renumbered to start at "1"
  903. - // again. this code takes care of that.
  904. - if (m_iCurrentListLevel < (WP6_NUM_LIST_LEVELS-1))
  905. - m_pCurrentListDefinition->setLevelNumber(m_iCurrentListLevel + 1, 0);
  906. -
  907. - m_iCurrentListLevel--;
  908. -}
  909. -
  910. -void IE_Imp_WordPerfect::openUnorderedListLevel(const WPXPropertyList & /*propList*/)
  911. -{
  912. - if (m_bHdrFtrOpenCount) return; // HACK
  913. - UT_DEBUGMSG(("AbiWordPerfect: openUNorderedListLevel\n"));
  914. -
  915. - m_iCurrentListLevel++;
  916. -}
  917. -
  918. void IE_Imp_WordPerfect::closeUnorderedListLevel()
  919. {
  920. if (m_bHdrFtrOpenCount) return; // HACK
  921. @@ -796,7 +894,7 @@
  922. // ASSUMPTION: We assume that unordered lists will always pass a number of "0". unpredictable behaviour
  923. // may result otherwise
  924. -void IE_Imp_WordPerfect::openListElement(const WPXPropertyList &propList, const WPXPropertyListVector & /*tabStops*/)
  925. +void IE_Imp_WordPerfect::openListElement(const librevenge::RVNGPropertyList &propList)
  926. {
  927. if (m_bHdrFtrOpenCount) return; // HACK
  928. UT_DEBUGMSG(("AbiWordPerfect: openListElement\n"));
  929. @@ -885,7 +983,7 @@
  930. X_CheckDocumentError(appendSpan(&ucs,1));
  931. }
  932. -void IE_Imp_WordPerfect::openFootnote(const WPXPropertyList & /*propList*/)
  933. +void IE_Imp_WordPerfect::openFootnote(const librevenge::RVNGPropertyList & /*propList*/)
  934. {
  935. if (m_bHdrFtrOpenCount) return; // HACK
  936. @@ -934,7 +1032,7 @@
  937. X_CheckDocumentError(appendStrux(PTX_EndFootnote,NULL));
  938. }
  939. -void IE_Imp_WordPerfect::openEndnote(const WPXPropertyList & /*propList*/)
  940. +void IE_Imp_WordPerfect::openEndnote(const librevenge::RVNGPropertyList & /*propList*/)
  941. {
  942. if (m_bHdrFtrOpenCount) return; // HACK
  943. const gchar** propsArray = NULL;
  944. @@ -975,7 +1073,7 @@
  945. X_CheckDocumentError(appendStrux(PTX_EndEndnote,NULL));
  946. }
  947. -void IE_Imp_WordPerfect::openTable(const WPXPropertyList &propList, const WPXPropertyListVector &columns)
  948. +void IE_Imp_WordPerfect::openTable(const librevenge::RVNGPropertyList &propList)
  949. {
  950. if (m_bHdrFtrOpenCount) return; // HACK
  951. // TODO: handle 'marginLeftOffset' and 'marginRightOffset'
  952. @@ -1000,14 +1098,18 @@
  953. }
  954. }
  955. - propBuffer += "table-column-props:";
  956. - WPXPropertyListVector::Iter i(columns);
  957. - for (i.rewind(); i.next();)
  958. + const librevenge::RVNGPropertyListVector *columns = propList.child("librevenge:table-columns");
  959. + if (columns)
  960. {
  961. - UT_String tmpBuffer;
  962. - if (i()["style:column-width"])
  963. - UT_String_sprintf(tmpBuffer, "%s/", i()["style:column-width"]->getStr().cstr());
  964. - propBuffer += tmpBuffer;
  965. + propBuffer += "table-column-props:";
  966. + librevenge::RVNGPropertyListVector::Iter i(*columns);
  967. + for (i.rewind(); i.next();)
  968. + {
  969. + UT_String tmpBuffer;
  970. + if (i()["style:column-width"])
  971. + UT_String_sprintf(tmpBuffer, "%s/", i()["style:column-width"]->getStr().cstr());
  972. + propBuffer += tmpBuffer;
  973. + }
  974. }
  975. const gchar* propsArray[3];
  976. @@ -1018,7 +1120,7 @@
  977. X_CheckDocumentError(appendStrux(PTX_SectionTable, propsArray));
  978. }
  979. -void IE_Imp_WordPerfect::openTableRow(const WPXPropertyList & /*propList*/)
  980. +void IE_Imp_WordPerfect::openTableRow(const librevenge::RVNGPropertyList & /*propList*/)
  981. {
  982. if (m_bHdrFtrOpenCount) return; // HACK
  983. UT_DEBUGMSG(("AbiWordPerfect: openRow\n"));
  984. @@ -1030,14 +1132,14 @@
  985. m_bInCell = false;
  986. }
  987. -void IE_Imp_WordPerfect::openTableCell(const WPXPropertyList &propList)
  988. +void IE_Imp_WordPerfect::openTableCell(const librevenge::RVNGPropertyList &propList)
  989. {
  990. if (m_bHdrFtrOpenCount) return; // HACK
  991. int col =0, row = 0, colSpan = 0, rowSpan = 0;
  992. - if (propList["libwpd:column"])
  993. - col = propList["libwpd:column"]->getInt();
  994. - if (propList["libwpd:row"])
  995. - row = propList["libwpd:row"]->getInt();
  996. + if (propList["librevenge:column"])
  997. + col = propList["librevenge:column"]->getInt();
  998. + if (propList["librevenge:row"])
  999. + row = propList["librevenge:row"]->getInt();
  1000. if (propList["table:number-columns-spanned"])
  1001. colSpan = propList["table:number-columns-spanned"]->getInt();
  1002. if (propList["table:number-rows-spanned"])
  1003. @@ -1247,9 +1349,9 @@
  1004. virtual UT_Error _loadFile(GsfInput * input)
  1005. {
  1006. AbiWordperfectInputStream gsfInput(input);
  1007. - WPSResult error = WPSDocument::parse(&gsfInput, static_cast<WPXDocumentInterface *>(this));
  1008. + libwps::WPSResult error = libwps::WPSDocument::parse(&gsfInput, static_cast<librevenge::RVNGTextInterface *>(this));
  1009. - if (error != WPS_OK)
  1010. + if (error != libwps::WPS_OK)
  1011. {
  1012. UT_DEBUGMSG(("AbiMSWorks: ERROR: %i!\n", (int)error));
  1013. return UT_IE_IMPORTERROR;
  1014. @@ -1286,13 +1388,17 @@
  1015. {
  1016. AbiWordperfectInputStream gsfInput(input);
  1017. - WPSConfidence confidence = WPSDocument::isFileFormatSupported(&gsfInput);
  1018. + libwps::WPSKind kind;
  1019. + libwps::WPSConfidence confidence = libwps::WPSDocument::isFileFormatSupported(&gsfInput, kind);
  1020. +
  1021. + if (kind != libwps::WPS_TEXT)
  1022. + confidence = libwps::WPS_CONFIDENCE_NONE;
  1023. switch (confidence)
  1024. {
  1025. - case WPS_CONFIDENCE_NONE:
  1026. + case libwps::WPS_CONFIDENCE_NONE:
  1027. return UT_CONFIDENCE_ZILCH;
  1028. - case WPS_CONFIDENCE_EXCELLENT:
  1029. + case libwps::WPS_CONFIDENCE_EXCELLENT:
  1030. return UT_CONFIDENCE_PERFECT;
  1031. default:
  1032. return UT_CONFIDENCE_ZILCH;
  1033. Index: plugins/wordperfect/xp/Makefile.am
  1034. ===================================================================
  1035. --- plugins/wordperfect/xp/Makefile.am (revision 34460)
  1036. +++ plugins/wordperfect/xp/Makefile.am (working copy)
  1037. @@ -6,8 +6,6 @@
  1038. -DABI_BUILD_VERSION=\"$(VERSION)\"
  1039. libxp_la_SOURCES = \
  1040. - ie_exp_WordPerfect.cpp \
  1041. - ie_exp_WordPerfect.h \
  1042. ie_impexp_WordPerfect.cpp \
  1043. ie_impexp_WordPerfect.h \
  1044. ie_imp_WordPerfect.cpp \
  1045. Index: plugins/wordperfect/xp/ie_impexp_WordPerfect.h
  1046. ===================================================================
  1047. --- plugins/wordperfect/xp/ie_impexp_WordPerfect.h (revision 34460)
  1048. +++ plugins/wordperfect/xp/ie_impexp_WordPerfect.h (working copy)
  1049. @@ -24,7 +24,6 @@
  1050. */
  1051. #include "ie_imp_WordPerfect.h"
  1052. -#include "ie_exp_WordPerfect.h"
  1053. #include "xap_Module.h"
  1054. #define IE_MIMETYPE_WP_51 "application/wordperfect5.1"
  1055. Index: plugins/wordperfect/plugin.m4
  1056. ===================================================================
  1057. --- plugins/wordperfect/plugin.m4 (revision 34460)
  1058. +++ plugins/wordperfect/plugin.m4 (working copy)
  1059. @@ -1,6 +1,6 @@
  1060. -wordperfect_pkgs="libwpg-0.2 >= 0.2.0 libwpd-0.9 >= 0.9.0 libwpd-stream-0.9 >= 0.9.0 $gsf_req"
  1061. -wordperfect_wps_pkgs='libwps-0.2 >= 0.1.0'
  1062. +wordperfect_pkgs="libwpd-0.10 $gsf_req"
  1063. +wordperfect_wps_pkgs='libwps-0.3'
  1064. wordperfect_deps="no"
  1065. WORDPERFECT_CFLAGS=
  1066. @@ -29,7 +29,7 @@
  1067. PKG_CHECK_EXISTS([ $wordperfect_wps_pkgs ],
  1068. [
  1069. - wp_deps_pkgs="$wp_deps_pkgs $wordperfect_wps_pkgs"
  1070. + wp_deps_pkgs="$wordperfect_wps_pkgs $wp_deps_pkgs"
  1071. WPS_DEFINE=" -DHAVE_LIBWPS"
  1072. ])