merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0060-wpgimporter.diff
blob9fba63b4fc116d97d54f88e8645721f4b69c1b4c
1 --- configure.in.old 2009-04-06 16:41:41.000000000 +0000
2 +++ configure.in 2009-04-06 16:41:41.000000000 +0000
3 @@ -345,6 +345,9 @@ AC_ARG_WITH(system-libwpd,
4 AC_ARG_WITH(system-libwps,
5 [ --with-system-libwps Use libwps already on system
6 ],,)
7 +AC_ARG_WITH(system-libwpg,
8 +[ --with-system-libwpg Use libwpg already on system
9 +],,)
10 AC_ARG_WITH(system-libxml,
11 [ --with-system-libxml Use libxml already on system
12 ],,)
13 @@ -3500,6 +3503,24 @@ AC_SUBST(LIBWPS_CFLAGS)
14 AC_SUBST(LIBWPS_LIBS)
16 dnl ===================================================================
17 +dnl Check for system libwpg
18 +dnl ===================================================================
19 +AC_MSG_CHECKING([which libwpg to use])
20 +if test -n "$with_system_libwpg" -o -n "$with_system_libs" && \
21 + test "$with_system_libwpg" != "no"; then
22 + AC_MSG_RESULT([external])
23 + SYSTEM_LIBWPG=YES
24 + PKG_CHECK_MODULES( LIBWPG, libwpg-0.1 )
25 +else
26 + AC_MSG_RESULT([internal])
27 + SYSTEM_LIBWPG=NO
28 + BUILD_TYPE="$BUILD_TYPE LIBWPG"
29 +fi
30 +AC_SUBST(SYSTEM_LIBWPG)
31 +AC_SUBST(LIBWPG_CFLAGS)
32 +AC_SUBST(LIBWPG_LIBS)
34 +dnl ===================================================================
35 dnl Check whether freetype2 supports emboldening
36 dnl ===================================================================
37 if test "$test_freetype" = "yes"; then
38 --- set_soenv.in.old 2009-04-06 16:41:41.000000000 +0000
39 +++ set_soenv.in 2009-04-06 16:41:41.000000000 +0000
40 @@ -1964,6 +1964,9 @@ ToFile( "LIBWPD_LIBS", "@LIBWPD_LI
41 ToFile( "SYSTEM_LIBWPS", "@SYSTEM_LIBWPS@", "e" );
42 ToFile( "LIBWPS_CFLAGS", "@LIBWPS_CFLAGS@", "e" );
43 ToFile( "LIBWPS_LIBS", "@LIBWPS_LIBS@", "e" );
44 +ToFile( "SYSTEM_LIBWPG", "@SYSTEM_LIBWPG@", "e" );
45 +ToFile( "LIBWPG_CFLAGS", "@LIBWPG_CFLAGS@", "e" );
46 +ToFile( "LIBWPG_LIBS", "@LIBWPG_LIBS@", "e" );
47 ToFile( "SYSTEM_LIBXML", "@SYSTEM_LIBXML@", "e" );
48 ToFile( "USE_FT_EMBOLDEN", "@USE_FT_EMBOLDEN@", "e" );
49 ToFile( "LIBXML_CFLAGS", "@LIBXML_CFLAGS@", "e" );
50 --- filter/source/config/fragments/filters/WordPerfectGraphics.xcu.old 1970-01-01 00:00:00.000000000 +0000
51 +++ filter/source/config/fragments/filters/WordPerfectGraphics.xcu 2009-04-06 16:41:41.000000000 +0000
52 @@ -0,0 +1,14 @@
53 + <node oor:name="WordPerfect Graphics" oor:op="replace">
54 + <prop oor:name="Flags"><value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value></prop>
55 + <prop oor:name="UIComponent"/>
56 + <prop oor:name="FilterService"><value>com.sun.star.comp.Draw.WPGImportFilter</value></prop>
57 + <prop oor:name="UserData"><value></value></prop>
58 + <prop oor:name="UIName">
59 + <value xml:lang="x-default">WordPerfect Graphics</value>
60 + </prop>
61 + <prop oor:name="Installed"><value>true</value></prop>
62 + <prop oor:name="FileFormatVersion"><value>0</value></prop>
63 + <prop oor:name="Type"><value>draw_WordPerfect_Graphics</value></prop>
64 + <prop oor:name="TemplateName"/>
65 + <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop>
66 + </node>
67 --- filter/source/config/fragments/types/draw_WordPerfect_Graphics.xcu.old 1970-01-01 00:00:00.000000000 +0000
68 +++ filter/source/config/fragments/types/draw_WordPerfect_Graphics.xcu 2009-04-06 16:41:41.000000000 +0000
69 @@ -0,0 +1,12 @@
70 + <node oor:name="draw_WordPerfect_Graphics" oor:op="replace" >
71 + <prop oor:name="DetectService"><value>com.sun.star.comp.Draw.WPGImportFilter</value></prop>
72 + <prop oor:name="URLPattern"/>
73 + <prop oor:name="Extensions"><value>wpg</value></prop>
74 + <prop oor:name="MediaType"><value>image/x-wpg</value></prop>
75 + <prop oor:name="Preferred"><value>true</value></prop>
76 + <prop oor:name="PreferredFilter"><value>WordPerfect Graphics</value></prop>
77 + <prop oor:name="UIName">
78 + <value>WordPerfect Graphics</value>
79 + </prop>
80 + <prop oor:name="ClipboardFormat"/>
81 + </node>
82 --- filter/source/config/fragments/fcfg_draw.mk.old 2009-04-02 11:03:58.000000000 +0000
83 +++ filter/source/config/fragments/fcfg_draw.mk 2009-04-06 16:41:41.000000000 +0000
84 @@ -7,7 +7,8 @@ T4_DRAW = \
85 draw_StarOffice_XML_Draw_Template \
86 pdf_Portable_Document_Format\
87 draw8 \
88 - draw8_template
89 + draw8_template \
90 + draw_WordPerfect_Graphics
92 # -----------------------------------------------
93 # count = 9
94 @@ -16,7 +17,9 @@ F4_DRAW = \
95 draw_StarOffice_XML_Draw_Template \
96 draw_pdf_Export \
97 draw8 \
98 - draw8_template
99 + draw8_template \
100 + WordPerfectGraphics
103 # -----------------------------------------------
104 # count = 4
105 --- scp2/source/graphicfilter/file_graphicfilter.scp.old 2009-04-02 10:51:52.000000000 +0000
106 +++ scp2/source/graphicfilter/file_graphicfilter.scp 2009-04-06 16:41:41.000000000 +0000
107 @@ -62,3 +62,5 @@ STD_UNO_LIB_FILE( gid_File_Lib_Flash, fl
109 STD_UNO_LIB_FILE( gid_File_Lib_Svg, svgfilter )
111 +STD_UNO_LIB_FILE_PATCH( gid_File_Lib_WPGImport, wpgimport )
113 --- scp2/source/graphicfilter/module_graphicfilter.scp.old 2009-04-02 10:51:52.000000000 +0000
114 +++ scp2/source/graphicfilter/module_graphicfilter.scp 2009-04-06 16:41:41.000000000 +0000
115 @@ -36,7 +36,7 @@ Module gid_Module_Optional_Grfflt
116 Sortkey = "600";
117 ParentID = gid_Module_Optional;
118 Default = YES;
119 - Files = (gid_File_Lib_Svg, gid_File_Lib_Flash,
120 + Files = (gid_File_Lib_Svg, gid_File_Lib_Flash, gid_File_Lib_WPGImport,
121 gid_File_Registry_Spool_Oo_TypeDetection_ImpressGraphics_Types_Xcu,gid_File_Registry_Spool_Oo_TypeDetection_ImpressGraphics_Filters_Xcu,
122 gid_File_Registry_Spool_Oo_TypeDetection_DrawGraphics_Types_Xcu,gid_File_Registry_Spool_Oo_TypeDetection_DrawGraphics_Filters_Xcu);
124 --- writerperfect/source/wpgimp/makefile.mk.old 1970-01-01 00:00:00.000000000 +0000
125 +++ writerperfect/source/wpgimp/makefile.mk 2009-04-06 16:41:41.000000000 +0000
126 @@ -0,0 +1,35 @@
127 +PRJ=..$/..
129 +PRJNAME=writerperfect
130 +TARGET=wpgimp
131 +ENABLE_EXCEPTIONS=true
133 +.INCLUDE : settings.mk
135 +.IF "$(SYSTEM_LIBWPD)" == "YES"
136 +INCPRE+=$(LIBWPD_CFLAGS)
137 +.ELSE
138 +INCPRE+=$(SOLARVER)$/$(UPD)$/$(INPATH)$/inc$/libwpd
139 +.ENDIF
141 +.IF "$(SYSTEM_LIBWPS)" == "YES"
142 +INCPRE+=$(LIBWPS_CFLAGS)
143 +.ELSE
144 +INCPRE+=$(SOLARVER)$/$(UPD)$/$(INPATH)$/inc$/libwps
145 +.ENDIF
147 +.IF "$(SYSTEM_LIBWPG)" == "YES"
148 +INCPRE+=$(LIBWPG_CFLAGS)
149 +.ELSE
150 +INCPRE+=$(SOLARVER)$/$(UPD)$/$(INPATH)$/inc$/libwpg
151 +.ENDIF
153 +# broken but ... necessary, internal include shafted ...
154 +INCPRE+= -I..
156 +SLOFILES= \
157 + $(SLO)$/OdgExporter.obj \
158 + $(SLO)$/WPGImportFilter.obj \
159 + $(SLO)$/wpgimport_genericfilter.obj
161 +.INCLUDE : target.mk
162 --- writerperfect/source/wpgimp/OdgExporter.cxx.old 1970-01-01 00:00:00.000000000 +0000
163 +++ writerperfect/source/wpgimp/OdgExporter.cxx 2009-04-06 16:41:41.000000000 +0000
164 @@ -0,0 +1,510 @@
165 +/* libwpg
166 + * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
167 + * Copyright (C) 2006-2007 Fridrich Strba (fridrich.strba@bluewin.ch)
169 + * This library is free software; you can redistribute it and/or
170 + * modify it under the terms of the GNU Library General Public
171 + * License as published by the Free Software Foundation; either
172 + * version 2 of the License, or (at your option) any later version.
174 + * This library is distributed in the hope that it will be useful,
175 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
176 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
177 + * Library General Public License for more details.
179 + * You should have received a copy of the GNU Library General Public
180 + * License along with this library; if not, write to the
181 + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
182 + * Boston, MA 02111-1301 USA
184 + * For further information visit http://libwpg.sourceforge.net
185 + */
187 +/* "This product is not manufactured, approved, or supported by
188 + * Corel Corporation or Corel Corporation Limited."
189 + */
191 +#include "OdgExporter.hxx"
192 +#include "filter/DocumentElement.hxx"
193 +#include "filter/DocumentHandler.hxx"
194 +#include <rtl/math.hxx>
197 +OdgExporter::OdgExporter(DocumentHandler *pHandler):
198 + mpHandler(pHandler),
199 + m_fillRule(AlternatingFill),
200 + m_gradientIndex(1),
201 + m_dashIndex(1),
202 + m_styleIndex(1)
206 +OdgExporter::~OdgExporter()
210 +void OdgExporter::startDocument(double width, double height)
212 + m_gradientIndex = 1;
213 + m_dashIndex = 1;
214 + m_styleIndex = 1;
216 + mpHandler->startDocument();
217 + TagOpenElement tmpOfficeDocumentContent("office:document");
218 + tmpOfficeDocumentContent.addAttribute("xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0");
219 + tmpOfficeDocumentContent.addAttribute("xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
220 + tmpOfficeDocumentContent.addAttribute("xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
221 + tmpOfficeDocumentContent.addAttribute("xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
222 + tmpOfficeDocumentContent.addAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
223 + tmpOfficeDocumentContent.addAttribute("xmlns:svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
224 + tmpOfficeDocumentContent.addAttribute("xmlns:fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
225 + tmpOfficeDocumentContent.addAttribute("office:version", "1.0");
226 + tmpOfficeDocumentContent.write(mpHandler);
228 + TagOpenElement("office:styles").write(mpHandler);
229 + TagCloseElement("office:styles").write(mpHandler);
231 + TagOpenElement("office:automatic-styles").write(mpHandler);
233 + TagOpenElement tmpStylePageLayoutOpenElement("style:page-layout");
234 + tmpStylePageLayoutOpenElement.addAttribute("style:name", "PM0");
235 + tmpStylePageLayoutOpenElement.write(mpHandler);
237 + TagOpenElement tmpStylePageLayoutPropertiesOpenElement("style:page-layout-properties");
238 + tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-top", "0cm");
239 + tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-bottom", "0cm");
240 + tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-left", "0cm");
241 + tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-right", "0cm");
242 + WPXString sValue;
243 + sValue = doubleToString(2.54 * width); sValue.append("cm");
244 + tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:page-width", sValue);
245 + sValue = doubleToString(2.54 * height); sValue.append("cm");
246 + tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:page-height", sValue);
247 + tmpStylePageLayoutPropertiesOpenElement.addAttribute("style:print-orientation", "portrait");
248 + tmpStylePageLayoutPropertiesOpenElement.write(mpHandler);
250 + TagCloseElement("style:page-layout-properties").write(mpHandler);
252 + TagCloseElement("style:page-layout").write(mpHandler);
254 + TagOpenElement tmpStyleStyleOpenElement("style:style");
255 + tmpStyleStyleOpenElement.addAttribute("style:name", "dp1");
256 + tmpStyleStyleOpenElement.addAttribute("style:family", "drawing-page");
257 + tmpStyleStyleOpenElement.write(mpHandler);
259 + TagOpenElement tmpStyleDrawingPagePropertiesOpenElement("style:drawing-page-properties");
260 + tmpStyleDrawingPagePropertiesOpenElement.addAttribute("draw:background-size", "border");
261 + tmpStyleDrawingPagePropertiesOpenElement.addAttribute("draw:fill", "none");
262 + tmpStyleDrawingPagePropertiesOpenElement.write(mpHandler);
264 + TagCloseElement("style:drawing-page-properties").write(mpHandler);
266 + TagCloseElement("style:style").write(mpHandler);
269 +void OdgExporter::endDocument()
271 + TagCloseElement("office:automatic-styles").write(mpHandler);
273 + TagOpenElement("office:master-styles").write(mpHandler);
275 + TagOpenElement tmpStyleMasterPageOpenElement("style:master-page");
276 + tmpStyleMasterPageOpenElement.addAttribute("style:name", "Default");
277 + tmpStyleMasterPageOpenElement.addAttribute("style:page-layout-name", "PM0");
278 + tmpStyleMasterPageOpenElement.addAttribute("draw:style-name", "dp1");
279 + tmpStyleMasterPageOpenElement.write(mpHandler);
281 + TagCloseElement("style:master-page").write(mpHandler);
283 + TagCloseElement("office:master-styles").write(mpHandler);
285 + TagOpenElement("office:body").write(mpHandler);
287 + TagOpenElement("office:drawing").write(mpHandler);
289 + TagOpenElement tmpDrawPageOpenElement("draw:page");
290 + tmpDrawPageOpenElement.addAttribute("draw:name", "page1");
291 + tmpDrawPageOpenElement.addAttribute("draw:style-name", "dp1");
292 + tmpDrawPageOpenElement.addAttribute("draw:master-page-name", "Default");
293 + tmpDrawPageOpenElement.write(mpHandler);
295 + for (std::vector<DocumentElement *>::const_iterator bodyIter = mpBodyElements.begin();
296 + bodyIter != mpBodyElements.end(); bodyIter++)
298 + (*bodyIter)->write(mpHandler);
299 + }
301 + TagCloseElement("draw:page").write(mpHandler);
302 + TagCloseElement("office:drawing").write(mpHandler);
303 + TagCloseElement("office:body").write(mpHandler);
304 + TagCloseElement("office:document").write(mpHandler);
306 + mpHandler->endDocument();
309 +void OdgExporter::setPen(const libwpg::WPGPen& pen)
311 + m_pen = pen;
314 +void OdgExporter::setBrush(const libwpg::WPGBrush& brush)
316 + m_brush = brush;
319 +void OdgExporter::setFillRule(FillRule rule)
321 + m_fillRule = rule;
324 +void OdgExporter::startLayer(unsigned int /* id */)
328 +void OdgExporter::endLayer(unsigned int)
332 +void OdgExporter::drawRectangle(const libwpg::WPGRect& rect, double rx, double /* ry */)
334 + writeStyle();
335 + TagOpenElement *pDrawRectElement = new TagOpenElement("draw:rect");
336 + WPXString sValue;
337 + sValue.sprintf("gr%i", m_styleIndex-1);
338 + pDrawRectElement->addAttribute("draw:style-name", sValue);
339 + sValue = doubleToString(2.54 * rect.x1); sValue.append("cm");
340 + pDrawRectElement->addAttribute("svg:x", sValue);
341 + sValue = doubleToString(2.54 * rect.y1); sValue.append("cm");
342 + pDrawRectElement->addAttribute("svg:y", sValue);
343 + sValue = doubleToString(2.54 * (rect.x2-rect.x1)); sValue.append("cm");
344 + pDrawRectElement->addAttribute("svg:width", sValue);
345 + sValue = doubleToString(2.54 * (rect.y2-rect.y1)); sValue.append("cm");
346 + pDrawRectElement->addAttribute("svg:height", sValue);
347 + sValue = doubleToString(2.54 * rx); sValue.append("cm");
348 + // FIXME: what to do when rx != ry ?
349 + pDrawRectElement->addAttribute("draw:corner-radius", sValue);
350 + mpBodyElements.push_back(static_cast<DocumentElement *>(pDrawRectElement));
351 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagCloseElement("draw:rect")));
354 +void OdgExporter::drawEllipse(const libwpg::WPGPoint& center, double rx, double ry)
356 + writeStyle();
357 + TagOpenElement *pDrawEllipseElement = new TagOpenElement("draw:ellipse");
358 + WPXString sValue;
359 + sValue.sprintf("gr%i", m_styleIndex-1);
360 + pDrawEllipseElement->addAttribute("draw:style-name", sValue);
361 + sValue = doubleToString(2.54 * (center.x-rx)); sValue.append("cm");
362 + pDrawEllipseElement->addAttribute("svg:x", sValue);
363 + sValue = doubleToString(2.54 * (center.y-ry)); sValue.append("cm");
364 + pDrawEllipseElement->addAttribute("svg:y", sValue);
365 + sValue = doubleToString(2 * 2.54 * rx); sValue.append("cm");
366 + pDrawEllipseElement->addAttribute("svg:width", sValue);
367 + sValue = doubleToString(2 * 2.54 * ry); sValue.append("cm");
368 + pDrawEllipseElement->addAttribute("svg:height", sValue);
369 + mpBodyElements.push_back(static_cast<DocumentElement *>(pDrawEllipseElement));
370 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagCloseElement("draw:ellipse")));
373 +void OdgExporter::drawPolygon(const libwpg::WPGPointArray& vertices)
375 + if(vertices.count() < 2)
376 + return;
378 + if(vertices.count() == 2)
380 + const libwpg::WPGPoint& p1 = vertices[0];
381 + const libwpg::WPGPoint& p2 = vertices[1];
383 + writeStyle();
384 + TagOpenElement *pDrawLineElement = new TagOpenElement("draw:line");
385 + WPXString sValue;
386 + sValue.sprintf("gr%i", m_styleIndex-1);
387 + pDrawLineElement->addAttribute("draw:style-name", sValue);
388 + pDrawLineElement->addAttribute("draw:text-style-name", "P1");
389 + pDrawLineElement->addAttribute("draw:layer", "layout");
390 + sValue = doubleToString(2.54 * p1.x); sValue.append("cm");
391 + pDrawLineElement->addAttribute("svg:x1", sValue);
392 + sValue = doubleToString(2.54 * p1.y); sValue.append("cm");
393 + pDrawLineElement->addAttribute("svg:y1", sValue);
394 + sValue = doubleToString(2.54 * p2.x); sValue.append("cm");
395 + pDrawLineElement->addAttribute("svg:x2", sValue);
396 + sValue = doubleToString(2.54 * p2.y); sValue.append("cm");
397 + pDrawLineElement->addAttribute("svg:y2", sValue);
398 + mpBodyElements.push_back(static_cast<DocumentElement *>(pDrawLineElement));
399 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagCloseElement("draw:line")));
401 + else
403 + // draw as path
404 + libwpg::WPGPath path;
405 + path.moveTo(vertices[0]);
406 + for(unsigned long ii = 1; ii < vertices.count(); ii++)
407 + path.lineTo(vertices[ii]);
408 + path.closed = true;
409 + drawPath(path);
413 +void OdgExporter::drawPath(const libwpg::WPGPath& path)
415 + if(path.count() == 0)
416 + return;
418 + // try to find the bounding box
419 + // this is simple convex hull technique, the bounding box might not be
420 + // accurate but that should be enough for this purpose
421 + libwpg::WPGPoint p = path.element(0).point;
422 + libwpg::WPGPoint q = path.element(0).point;
423 + for(unsigned k = 0; k < path.count(); k++)
425 + libwpg::WPGPathElement element = path.element(k);
426 + p.x = (p.x > element.point.x) ? element.point.x : p.x;
427 + p.y = (p.y > element.point.y) ? element.point.y : p.y;
428 + q.x = (q.x < element.point.x) ? element.point.x : q.x;
429 + q.y = (q.y < element.point.y) ? element.point.y : q.y;
430 + if(element.type == libwpg::WPGPathElement::CurveToElement)
432 + p.x = (p.x > element.extra1.x) ? element.extra1.x : p.x;
433 + p.y = (p.y > element.extra1.y) ? element.extra1.y : p.y;
434 + q.x = (q.x < element.extra1.x) ? element.extra1.x : q.x;
435 + q.y = (q.y < element.extra1.y) ? element.extra1.y : q.y;
436 + p.x = (p.x > element.extra2.x) ? element.extra2.x : p.x;
437 + p.y = (p.y > element.extra2.y) ? element.extra2.y : p.y;
438 + q.x = (q.x < element.extra2.x) ? element.extra2.x : q.x;
439 + q.y = (q.y < element.extra2.y) ? element.extra2.y : q.y;
442 + double vw = q.x - p.x;
443 + double vh = q.y - p.y;
445 + writeStyle();
447 + TagOpenElement *pDrawPathElement = new TagOpenElement("draw:path");
448 + WPXString sValue;
449 + sValue.sprintf("gr%i", m_styleIndex-1);
450 + pDrawPathElement->addAttribute("draw:style-name", sValue);
451 + pDrawPathElement->addAttribute("draw:text-style-name", "P1");
452 + pDrawPathElement->addAttribute("draw:layer", "layout");
453 + sValue = doubleToString(2.54 * p.x); sValue.append("cm");
454 + pDrawPathElement->addAttribute("svg:x", sValue);
455 + sValue = doubleToString(2.54 * p.y); sValue.append("cm");
456 + pDrawPathElement->addAttribute("svg:y", sValue);
457 + sValue = doubleToString(2.54 * vw); sValue.append("cm");
458 + pDrawPathElement->addAttribute("svg:width", sValue);
459 + sValue = doubleToString(2.54 * vh); sValue.append("cm");
460 + pDrawPathElement->addAttribute("svg:height", sValue);
461 + sValue.sprintf("%i %i %i %i", 0, 0, (int)(vw*2540), (int)(vh*2540));
462 + pDrawPathElement->addAttribute("svg:viewBox", sValue);
464 + sValue.clear();
465 + for(unsigned i = 0; i < path.count(); i++)
467 + libwpg::WPGPathElement element = path.element(i);
468 + libwpg::WPGPoint point = element.point;
469 + WPXString sElement;
470 + switch(element.type)
472 + // 2540 is 2.54*1000, 2.54 cm = 1 inch
473 + case libwpg::WPGPathElement::MoveToElement:
474 + sElement.sprintf("M%i %i", (int)((point.x-p.x)*2540), (int)((point.y-p.y)*2540));
475 + break;
477 + case libwpg::WPGPathElement::LineToElement:
478 + sElement.sprintf("L%i %i", (int)((point.x-p.x)*2540), (int)((point.y-p.y)*2540));
479 + break;
481 + case libwpg::WPGPathElement::CurveToElement:
482 + sElement.sprintf("C%i %i %i %i %i %i", (int)((element.extra1.x-p.x)*2540),
483 + (int)((element.extra1.y-p.y)*2540), (int)((element.extra2.x-p.x)*2540),
484 + (int)((element.extra2.y-p.y)*2540), (int)((point.x-p.x)*2540), (int)((point.y-p.y)*2540));
485 + break;
487 + default:
488 + break;
490 + sValue.append(sElement);
492 + if(path.closed)
493 + sValue.append(" Z");
494 + pDrawPathElement->addAttribute("svg:d", sValue);
495 + mpBodyElements.push_back(static_cast<DocumentElement *>(pDrawPathElement));
496 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagCloseElement("draw:path")));
499 +void OdgExporter::drawBitmap(const libwpg::WPGBitmap& bitmap)
501 + TagOpenElement *pDrawFrameElement = new TagOpenElement("draw:frame");
502 + WPXString sValue;
503 + sValue = doubleToString(2.54 * bitmap.rect.x1); sValue.append("cm");
504 + pDrawFrameElement->addAttribute("svg:x", sValue);
505 + sValue = doubleToString(2.54 * bitmap.rect.y1); sValue.append("cm");
506 + pDrawFrameElement->addAttribute("svg:y", sValue);
507 + sValue = doubleToString(2.54 * bitmap.rect.height()); sValue.append("cm");
508 + pDrawFrameElement->addAttribute("svg:height", sValue);
509 + sValue = doubleToString(2.54 * bitmap.rect.width()); sValue.append("cm");
510 + pDrawFrameElement->addAttribute("svg:width", sValue);
511 + mpBodyElements.push_back(static_cast<DocumentElement *>(pDrawFrameElement));
513 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagOpenElement("draw:image")));
515 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagOpenElement("office:binary-data")));
517 + libwpg::WPGString base64Binary;
518 + bitmap.generateBase64DIB(base64Binary);
519 + mpBodyElements.push_back(static_cast<DocumentElement *>(new CharDataElement(base64Binary.cstr())));
521 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagCloseElement("office:binary-data")));
523 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagCloseElement("draw:image")));
525 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagCloseElement("draw:frame")));
528 +void OdgExporter::drawImageObject(const libwpg::WPGBinaryData& binaryData)
530 + if (binaryData.mimeType.length() <= 0)
531 + return;
533 + TagOpenElement *pDrawFrameElement = new TagOpenElement("draw:frame");
534 + WPXString sValue;
535 + sValue = doubleToString(2.54 * binaryData.rect.x1); sValue.append("cm");
536 + pDrawFrameElement->addAttribute("svg:x", sValue);
537 + sValue = doubleToString(2.54 * binaryData.rect.y1); sValue.append("cm");
538 + pDrawFrameElement->addAttribute("svg:y", sValue);
539 + sValue = doubleToString(2.54 * binaryData.rect.height()); sValue.append("cm");
540 + pDrawFrameElement->addAttribute("svg:height", sValue);
541 + sValue = doubleToString(2.54 * binaryData.rect.width()); sValue.append("cm");
542 + pDrawFrameElement->addAttribute("svg:width", sValue);
543 + mpBodyElements.push_back(static_cast<DocumentElement *>(pDrawFrameElement));
545 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagOpenElement("draw:image")));
547 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagOpenElement("office:binary-data")));
549 + libwpg::WPGString base64Binary = binaryData.getBase64Data();;
550 + mpBodyElements.push_back(static_cast<DocumentElement *>(new CharDataElement(base64Binary.cstr())));
552 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagCloseElement("office:binary-data")));
554 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagCloseElement("draw:image")));
556 + mpBodyElements.push_back(static_cast<DocumentElement *>(new TagCloseElement("draw:frame")));
559 +void OdgExporter::writeStyle()
561 + if(!m_pen.solid && (m_pen.dashArray.count() >=2 ) )
563 + // ODG only supports dashes with the same length of spaces inbetween
564 + // here we take the first space and assume everything else the same
565 + // note that dash length is written in percentage
566 + double distance = m_pen.dashArray.at(1);
567 + TagOpenElement tmpDrawStrokeDashElement("draw:stroke-dash");
568 + tmpDrawStrokeDashElement.addAttribute("draw:style", "rect");
569 + WPXString sValue;
570 + sValue.sprintf("Dash_%i", m_dashIndex++);
571 + tmpDrawStrokeDashElement.addAttribute("draw:name", sValue);
572 + sValue.sprintf("%i \%", distance*100);
573 + tmpDrawStrokeDashElement.addAttribute("draw:distance", sValue);
574 + WPXString sName;
575 + for(unsigned i = 0; i < m_pen.dashArray.count()/2; i++)
577 + sName.sprintf("draw:dots%i", i+1);
578 + tmpDrawStrokeDashElement.addAttribute(sName.cstr(), "1");
579 + sName.sprintf("draw:dots%i-length", i+1);
580 + sValue.sprintf("%i\%", 100*m_pen.dashArray.at(i*2));
581 + tmpDrawStrokeDashElement.addAttribute(sName.cstr(), sValue);
583 + tmpDrawStrokeDashElement.write(mpHandler);
584 + TagCloseElement("draw:stroke-dash").write(mpHandler);
587 + if(m_brush.style == libwpg::WPGBrush::Gradient)
589 + TagOpenElement tmpDrawGradientElement("draw:gradient");
590 + tmpDrawGradientElement.addAttribute("draw:style", "linear");
591 + WPXString sValue;
592 + sValue.sprintf("Gradient_%i", m_gradientIndex++);
593 + tmpDrawGradientElement.addAttribute("draw:name", sValue);
595 + // ODG angle unit is 0.1 degree
596 + double angle = -m_brush.gradient.angle();
597 + while(angle < 0)
598 + angle += 360;
599 + while(angle > 360)
600 + angle -= 360;
602 + sValue.sprintf("%i", angle*10);
603 + tmpDrawGradientElement.addAttribute("draw:angle", sValue);
605 + libwpg::WPGColor startColor = m_brush.gradient.stopColor(0);
606 + libwpg::WPGColor stopColor = m_brush.gradient.stopColor(1);
607 + sValue.sprintf("#%.2x%.2x%.2x", (startColor.red & 0xff), (startColor.green & 0xff), (startColor.blue & 0xff));
608 + tmpDrawGradientElement.addAttribute("draw:start-color", sValue);
609 + sValue.sprintf("#%.2x%.2x%.2x", (stopColor.red & 0xff), (stopColor.green & 0xff), (stopColor.blue & 0xff));
610 + tmpDrawGradientElement.addAttribute("draw:end-color", sValue);
611 + tmpDrawGradientElement.addAttribute("draw:start-intensity", "100%");
612 + tmpDrawGradientElement.addAttribute("draw:end-intensity", "100%");
613 + tmpDrawGradientElement.addAttribute("draw:border", "0%");
614 + tmpDrawGradientElement.write(mpHandler);
615 + TagCloseElement("draw:gradient").write(mpHandler);
618 + TagOpenElement tmpStyleStyleElement("style:style");
619 + WPXString sValue;
620 + sValue.sprintf("gr%i", m_styleIndex);
621 + tmpStyleStyleElement.addAttribute("style:name", sValue);
622 + tmpStyleStyleElement.addAttribute("style:family", "graphic");
623 + tmpStyleStyleElement.addAttribute("style:parent-style-name", "standard");
624 + tmpStyleStyleElement.write(mpHandler);
626 + TagOpenElement tmpStyleGraphicPropertiesElement("style:graphic-properties");
628 + if(m_pen.width > 0.0)
630 + sValue = doubleToString(2.54 * m_pen.width); sValue.append("cm");
631 + tmpStyleGraphicPropertiesElement.addAttribute("svg:stroke-width", sValue);
632 + sValue.sprintf("#%.2x%.2x%.2x", (m_pen.foreColor.red & 0xff),
633 + (m_pen.foreColor.green & 0xff), (m_pen.foreColor.blue & 0xff));
634 + tmpStyleGraphicPropertiesElement.addAttribute("svg:stroke-color", sValue);
636 + if(!m_pen.solid)
638 + tmpStyleGraphicPropertiesElement.addAttribute("draw:stroke", "dash");
639 + sValue.sprintf("Dash_%i", m_dashIndex-1);
640 + tmpStyleGraphicPropertiesElement.addAttribute("draw:stroke-dash", sValue);
643 + else
644 + tmpStyleGraphicPropertiesElement.addAttribute("draw:stroke", "none");
646 + if(m_brush.style == libwpg::WPGBrush::NoBrush)
647 + tmpStyleGraphicPropertiesElement.addAttribute("draw:fill", "none");
649 + if(m_brush.style == libwpg::WPGBrush::Solid)
651 + tmpStyleGraphicPropertiesElement.addAttribute("draw:fill", "solid");
652 + sValue.sprintf("#%.2x%.2x%.2x", (m_brush.foreColor.red & 0xff),
653 + (m_brush.foreColor.green & 0xff), (m_brush.foreColor.blue & 0xff));
654 + tmpStyleGraphicPropertiesElement.addAttribute("draw:fill-color", sValue);
657 + if(m_brush.style == libwpg::WPGBrush::Gradient)
659 + tmpStyleGraphicPropertiesElement.addAttribute("draw:fill", "gradient");
660 + sValue.sprintf("Gradient_%i", m_gradientIndex-1);
661 + tmpStyleGraphicPropertiesElement.addAttribute("draw:fill-gradient-name", sValue);
664 + tmpStyleGraphicPropertiesElement.write(mpHandler);
665 + TagCloseElement("style:graphic-properties").write(mpHandler);
667 + TagCloseElement("style:style").write(mpHandler);
668 + m_styleIndex++;
671 +WPXString OdgExporter::doubleToString(const double value)
673 + return WPXString((char *)::rtl::math::doubleToString(value, rtl_math_StringFormat_F, 4, '.').getStr());
675 --- writerperfect/source/wpgimp/OdgExporter.hxx.old 1970-01-01 00:00:00.000000000 +0000
676 +++ writerperfect/source/wpgimp/OdgExporter.hxx 2009-04-06 16:41:41.000000000 +0000
677 @@ -0,0 +1,78 @@
678 +/* libwpg
679 + * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
680 + * Copyright (C) 2007 Fridrich Strba (fridrich_strba@bluewin.ch)
682 + * This library is free software; you can redistribute it and/or
683 + * modify it under the terms of the GNU Library General Public
684 + * License as published by the Free Software Foundation; either
685 + * version 2 of the License, or (at your option) any later version.
687 + * This library is distributed in the hope that it will be useful,
688 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
689 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
690 + * Library General Public License for more details.
692 + * You should have received a copy of the GNU Library General Public
693 + * License along with this library; if not, write to the
694 + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
695 + * Boston, MA 02111-1301 USA
697 + * For further information visit http://libwpg.sourceforge.net
698 + */
700 +/* "This product is not manufactured, approved, or supported by
701 + * Corel Corporation or Corel Corporation Limited."
702 + */
704 +#ifndef __ODGEXPORTER_HXX__
705 +#define __ODGEXPORTER_HXX__
707 +#include <iostream>
708 +#include <sstream>
709 +#include <string>
711 +#include <libwpd/WPXString.h>
712 +#include <libwpg/libwpg.h>
713 +#include <libwpg/WPGBinaryData.h>
714 +#include "filter/DocumentElement.hxx"
715 +#include "filter/DocumentHandler.hxx"
717 +class OdgExporter : public libwpg::WPGPaintInterface {
718 +public:
719 + OdgExporter(DocumentHandler *pHandler);
720 + ~OdgExporter();
722 + void startDocument(double width, double height);
723 + void startGraphics(double width, double height) { startDocument(width, height); }
724 + void endDocument();
725 + void endGraphics() { endDocument(); };
726 + void startLayer(unsigned int id);
727 + void endLayer(unsigned int id);
729 + void setPen(const libwpg::WPGPen& pen);
730 + void setBrush(const libwpg::WPGBrush& brush);
731 + void setFillRule(FillRule rule);
733 + void drawRectangle(const libwpg::WPGRect& rect, double rx, double ry);
734 + void drawEllipse(const libwpg::WPGPoint& center, double rx, double ry);
735 + void drawPolygon(const libwpg::WPGPointArray& vertices);
736 + void drawPath(const libwpg::WPGPath& path);
737 + void drawBitmap(const libwpg::WPGBitmap& bitmap);
738 + void drawImageObject(const libwpg::WPGBinaryData& binaryData);
740 +private:
741 + std::vector <DocumentElement *> mpBodyElements;
742 + std::vector <DocumentElement *> mpStylesElements;
743 + DocumentHandler *mpHandler;
745 + libwpg::WPGPen m_pen;
746 + libwpg::WPGBrush m_brush;
747 + FillRule m_fillRule;
748 + int m_gradientIndex;
749 + int m_dashIndex;
750 + int m_styleIndex;
751 + void writeStyle();
752 + WPXString doubleToString(const double value);
755 +#endif // __ODGEXPORTER_HXX__
756 --- writerperfect/source/wpgimp/WPGImportFilter.cxx.old 1970-01-01 00:00:00.000000000 +0000
757 +++ writerperfect/source/wpgimp/WPGImportFilter.cxx 2009-04-06 16:41:41.000000000 +0000
758 @@ -0,0 +1,332 @@
759 +/* WPGImportFilter: Sets up the filter, and calls OdgExporter
760 + * to do the actual filtering
762 + * Copyright (C) 2000 by Sun Microsystems, Inc.
763 + * Copyright (C) 2002-2004 William Lachance (wlach@interlog.com)
764 + * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com)
765 + * Copyright (C) 2004-2006 Fridrich Strba <fridrich.strba@bluewin.ch>
766 + *
767 + * This program is free software; you can redistribute it and/or
768 + * modify it under the terms of the GNU General Public License
769 + * as published by the Free Software Foundation; either version 2
770 + * of the License, or (at your option) any later version.
771 + *
772 + * This program is distributed in the hope that it will be useful,
773 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
774 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
775 + * GNU General Public License for more details.
776 + *
777 + * You should have received a copy of the GNU General Public License
778 + * along with this program; if not, write to the Free Software
779 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
780 + * 02111-1307, USA.
782 + * Contributor(s): Martin Gallwey (gallwey@sun.com)
784 + */
786 +/* "This product is not manufactured, approved, or supported by
787 + * Corel Corporation or Corel Corporation Limited."
788 + */
790 +#ifndef _OSL_DIAGNOSE_H_
791 +#include <osl/diagnose.h>
792 +#endif
793 +#ifndef _RTL_TENCINFO_H_
794 +#include <rtl/tencinfo.h>
795 +#endif
796 +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
797 +#include <com/sun/star/lang/XMultiServiceFactory.hpp>
798 +#endif
799 +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
800 +#include <com/sun/star/io/XInputStream.hpp>
801 +#endif
802 +#ifndef _COM_SUN_STAR_XML_SAX_XATTRIBUTELIST_HPP_
803 +#include <com/sun/star/xml/sax/XAttributeList.hpp>
804 +#endif
805 +#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
806 +#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
807 +#endif
808 +#ifndef _COM_SUN_STAR_XML_SAX_INPUTSOURCE_HPP_
809 +#include <com/sun/star/xml/sax/InputSource.hpp>
810 +#endif
811 +#ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HPP_
812 +#include <com/sun/star/xml/sax/XParser.hpp>
813 +#endif
815 +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
816 +#include <com/sun/star/lang/XMultiServiceFactory.hpp>
817 +#endif
818 +#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
819 +#include <com/sun/star/io/XInputStream.hpp>
820 +#endif
822 +#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
823 +#include <com/sun/star/io/XSeekable.hpp>
824 +#endif
826 +#include <com/sun/star/uno/Reference.h>
828 +#ifndef _ATTRLIST_HPP_
829 +#include <xmloff/attrlist.hxx>
830 +#endif
831 +#ifndef _XMLKYWD_HPP
832 +#include <xmloff/xmlkywd.hxx>
833 +#endif
835 +#include "filter/DocumentHandler.hxx"
836 +#include "OdgExporter.hxx"
837 +#include "WPGImportFilter.hxx"
838 +#include "stream/WPXSvStream.h"
840 +#include <iostream>
842 +using namespace ::com::sun::star::uno;
843 +using com::sun::star::uno::Reference;
844 +using com::sun::star::io::XInputStream;
845 +using com::sun::star::io::XSeekable;
846 +using com::sun::star::uno::Sequence;
847 +using namespace ::rtl;
848 +using rtl::OString;
849 +using rtl::OUString;
850 +using com::sun::star::uno::Sequence;
851 +using com::sun::star::uno::Reference;
852 +using com::sun::star::uno::Any;
853 +using com::sun::star::uno::UNO_QUERY;
854 +using com::sun::star::uno::XInterface;
855 +using com::sun::star::uno::Exception;
856 +using com::sun::star::uno::RuntimeException;
857 +using com::sun::star::lang::XMultiServiceFactory;
858 +using com::sun::star::beans::PropertyValue;
859 +using com::sun::star::document::XFilter;
860 +using com::sun::star::document::XExtendedFilterDetection;
862 +using com::sun::star::io::XInputStream;
863 +using com::sun::star::document::XImporter;
864 +using com::sun::star::xml::sax::InputSource;
865 +using com::sun::star::xml::sax::XAttributeList;
866 +using com::sun::star::xml::sax::XDocumentHandler;
867 +using com::sun::star::xml::sax::XParser;
870 +sal_Bool SAL_CALL WPGImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
871 + throw (RuntimeException)
873 +#ifdef DEBUG
874 + std::cerr << "WPGImportFilter::filter" << std::endl;
875 +#endif
876 + sal_Int32 nLength = aDescriptor.getLength();
877 + const PropertyValue * pValue = aDescriptor.getConstArray();
878 + OUString sURL;
879 + Reference < XInputStream > xInputStream;
880 + for ( sal_Int32 i = 0 ; i < nLength; i++)
882 + if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "InputStream" ) ) )
883 + pValue[i].Value >>= xInputStream;
884 + else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "URL" ) ) )
885 + pValue[i].Value >>= sURL;
887 + if ( !xInputStream.is() )
889 + OSL_ASSERT( 0 );
890 + return sal_False;
892 + OString sFileName;
893 + sFileName = OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII);
895 + // An XML import service: what we push sax messages to..
896 + OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.XMLOasisImporter" ) );
897 + Reference < XDocumentHandler > xInternalHandler( mxMSF->createInstance( sXMLImportService ), UNO_QUERY );
899 + // The XImporter sets up an empty target document for XDocumentHandler to write to..
900 + Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
901 + xImporter->setTargetDocument( mxDoc );
903 + // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here
904 + // writes to in-memory target doc
905 + DocumentHandler xHandler(xInternalHandler);
907 + WPXInputStream* input = new WPXSvInputStream( xInputStream );
909 + if (input->isOLEStream())
911 + WPXInputStream* olestream = input->getDocumentOLEStream();
912 + if (olestream)
914 + delete input;
915 + input = olestream;
919 + OdgExporter exporter(&xHandler);
920 + bool tmpParseResult = libwpg::WPGraphics::parse(input, &exporter);
921 + if (input)
922 + delete input;
923 + xInputStream->closeInput();
924 + return tmpParseResult;
927 +void SAL_CALL WPGImportFilter::cancel( )
928 + throw (RuntimeException)
930 +#ifdef DEBUG
931 + std::cerr << "WPGImportFilter::cancel" << std::endl;
932 +#endif
935 +// XImporter
936 +void SAL_CALL WPGImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
937 + throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException)
939 +#ifdef DEBUG
940 + std::cerr << "WPGImportFilter::setTargetDocument" << std::endl;
941 +#endif
942 + meType = FILTER_IMPORT;
943 + mxDoc = xDoc;
946 +// XExtendedFilterDetection
947 +OUString SAL_CALL WPGImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
948 + throw( com::sun::star::uno::RuntimeException )
950 +#ifdef DEBUG
951 + std::cerr << "WPGImportFilter::detect" << std::endl;
952 +#endif
953 + OUString sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "" ) );
954 + sal_Int32 nLength = Descriptor.getLength();
955 + sal_Int32 location = nLength;
956 + const PropertyValue * pValue = Descriptor.getConstArray();
957 + Reference < XInputStream > xInputStream;
958 + for ( sal_Int32 i = 0 ; i < nLength; i++)
960 + if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "TypeName" ) ) )
961 + location=i;
962 + else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "InputStream" ) ) )
963 + pValue[i].Value >>= xInputStream;
966 + WPXInputStream* input = new WPXSvInputStream( xInputStream );
968 + if (input->isOLEStream())
970 + WPXInputStream* olestream = input->getDocumentOLEStream();
971 + if (olestream)
973 + delete input;
974 + input = olestream;
978 + if (libwpg::WPGraphics::isSupported(input))
979 + sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw_WordPerfect_Graphics" ) );
981 + if (input)
982 + delete input;
984 + if (!sTypeName.equalsAscii(""))
986 + if ( location == Descriptor.getLength() )
988 + Descriptor.realloc(nLength+1);
989 + Descriptor[location].Name = ::rtl::OUString::createFromAscii( "TypeName" );
992 + Descriptor[location].Value <<=sTypeName;
994 + return sTypeName;
998 +// XInitialization
999 +void SAL_CALL WPGImportFilter::initialize( const Sequence< Any >& aArguments )
1000 + throw (Exception, RuntimeException)
1002 +#ifdef DEBUG
1003 + std::cerr << "WPGImportFilter::initialize" << std::endl;
1004 +#endif
1005 + Sequence < PropertyValue > aAnySeq;
1006 + sal_Int32 nLength = aArguments.getLength();
1007 + if ( nLength && ( aArguments[0] >>= aAnySeq ) )
1009 + const PropertyValue * pValue = aAnySeq.getConstArray();
1010 + nLength = aAnySeq.getLength();
1011 + for ( sal_Int32 i = 0 ; i < nLength; i++)
1013 + if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "Type" ) ) )
1015 + pValue[i].Value >>= msFilterName;
1016 + break;
1021 +OUString WPGImportFilter_getImplementationName ()
1022 + throw (RuntimeException)
1024 +#ifdef DEBUG
1025 + std::cerr << "WPGImportFilter_getImplementationName" << std::endl;
1026 +#endif
1027 + return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.WPGImportFilter" ) );
1030 +#define SERVICE_NAME1 "com.sun.star.document.ImportFilter"
1031 +#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection"
1032 +sal_Bool SAL_CALL WPGImportFilter_supportsService( const OUString& ServiceName )
1033 + throw (RuntimeException)
1035 +#ifdef DEBUG
1036 + std::cerr << "WPGImportFilter_supportsService" << std::endl;
1037 +#endif
1038 + return (ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME1 ) ) ||
1039 + ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME2 ) ) );
1041 +Sequence< OUString > SAL_CALL WPGImportFilter_getSupportedServiceNames( )
1042 + throw (RuntimeException)
1044 +#ifdef DEBUG
1045 + std::cerr << "WPGImportFilter_getSupportedServiceNames" << std::endl;
1046 +#endif
1047 + Sequence < OUString > aRet(2);
1048 + OUString* pArray = aRet.getArray();
1049 + pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME1 ) );
1050 + pArray[1] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME2 ) );
1051 + return aRet;
1053 +#undef SERVICE_NAME2
1054 +#undef SERVICE_NAME1
1056 +Reference< XInterface > SAL_CALL WPGImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
1057 + throw( Exception )
1059 +#ifdef DEBUG
1060 + std::cerr << "WPGImportFilter_createInstance" << std::endl;
1061 +#endif
1062 + return (cppu::OWeakObject*) new WPGImportFilter( rSMgr );
1065 +// XServiceInfo
1066 +OUString SAL_CALL WPGImportFilter::getImplementationName( )
1067 + throw (RuntimeException)
1069 +#ifdef DEBUG
1070 + std::cerr << "WPGImportFilter::getImplementationName" << std::endl;
1071 +#endif
1072 + return WPGImportFilter_getImplementationName();
1074 +sal_Bool SAL_CALL WPGImportFilter::supportsService( const OUString& rServiceName )
1075 + throw (RuntimeException)
1077 +#ifdef DEBUG
1078 + std::cerr << "WPGImportFilter::supportsService" << std::endl;
1079 +#endif
1080 + return WPGImportFilter_supportsService( rServiceName );
1082 +Sequence< OUString > SAL_CALL WPGImportFilter::getSupportedServiceNames( )
1083 + throw (RuntimeException)
1085 +#ifdef DEBUG
1086 + std::cerr << "WPGImportFilter::getSupportedServiceNames" << std::endl;
1087 +#endif
1088 + return WPGImportFilter_getSupportedServiceNames();
1091 --- writerperfect/source/wpgimp/WPGImportFilter.hxx.old 1970-01-01 00:00:00.000000000 +0000
1092 +++ writerperfect/source/wpgimp/WPGImportFilter.hxx 2009-04-06 16:41:41.000000000 +0000
1093 @@ -0,0 +1,128 @@
1094 +/*
1095 + * Copyright (C) 2000 by Sun Microsystems, Inc.
1096 + * Copyright (C) 2002-2004 William Lachance (wlach@interlog.com)
1097 + * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com)
1098 + * Copyright (C) 2004 Fridrich Strba <fridrich.strba@bluewin.ch>
1099 + *
1100 + * This program is free software; you can redistribute it and/or
1101 + * modify it under the terms of the GNU General Public License
1102 + * as published by the Free Software Foundation; either version 2
1103 + * of the License, or (at your option) any later version.
1104 + *
1105 + * This program is distributed in the hope that it will be useful,
1106 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1107 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1108 + * GNU General Public License for more details.
1109 + *
1110 + * You should have received a copy of the GNU General Public License
1111 + * along with this program; if not, write to the Free Software
1112 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1113 + * 02111-1307, USA.
1115 + * Contributor(s): Martin Gallwey (gallwey@sun.com)
1117 + */
1119 +/* "This product is not manufactured, approved, or supported by
1120 + * Corel Corporation or Corel Corporation Limited."
1121 + */
1122 +#ifndef _WPGIMPORTFILTER_HXX
1123 +#define _WPGIMPORTFILTER_HXX
1125 +#ifndef _COM_SUN_STAR_DOCUMENT_XFILTER_HPP_
1126 +#include <com/sun/star/document/XFilter.hpp>
1127 +#endif
1128 +#ifndef _COM_SUN_STAR_DOCUMENT_XIMPORTER_HPP_
1129 +#include <com/sun/star/document/XImporter.hpp>
1130 +#endif
1131 +#ifndef _COM_SUN_STAR_DOCUMENT_XEXTENDEDFILTERDETECTION_HPP_
1132 +#include <com/sun/star/document/XExtendedFilterDetection.hpp>
1133 +#endif
1134 +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
1135 +#include <com/sun/star/lang/XInitialization.hpp>
1136 +#endif
1137 +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
1138 +#include <com/sun/star/lang/XServiceInfo.hpp>
1139 +#endif
1140 +#ifndef _COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
1141 +#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
1142 +#endif
1143 +#ifndef _CPPUHELPER_IMPLBASE5_HXX_
1144 +#include <cppuhelper/implbase5.hxx>
1145 +#endif
1147 +#include <stdio.h>
1149 +enum FilterType
1151 + FILTER_IMPORT,
1152 + FILTER_EXPORT
1154 +/* This component will be instantiated for both import or export. Whether it calls
1155 + * setSourceDocument or setTargetDocument determines which Impl function the filter
1156 + * member calls */
1157 +class WPGImportFilter : public cppu::WeakImplHelper5
1159 + com::sun::star::document::XFilter,
1160 + com::sun::star::document::XImporter,
1161 + com::sun::star::document::XExtendedFilterDetection,
1162 + com::sun::star::lang::XInitialization,
1163 + com::sun::star::lang::XServiceInfo
1166 +protected:
1167 + // oo.org declares
1168 + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
1169 + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
1170 + ::rtl::OUString msFilterName;
1171 + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
1173 + FilterType meType;
1175 +public:
1176 + WPGImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
1177 + : mxMSF( rxMSF ) {}
1178 + virtual ~WPGImportFilter() {}
1180 + // XFilter
1181 + virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
1182 + throw (::com::sun::star::uno::RuntimeException);
1183 + virtual void SAL_CALL cancel( )
1184 + throw (::com::sun::star::uno::RuntimeException);
1186 + // XImporter
1187 + virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
1188 + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
1190 + //XExtendedFilterDetection
1191 + virtual ::rtl::OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
1192 + throw( com::sun::star::uno::RuntimeException );
1194 + // XInitialization
1195 + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
1196 + throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
1198 + // XServiceInfo
1199 + virtual ::rtl::OUString SAL_CALL getImplementationName( )
1200 + throw (::com::sun::star::uno::RuntimeException);
1201 + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
1202 + throw (::com::sun::star::uno::RuntimeException);
1203 + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
1204 + throw (::com::sun::star::uno::RuntimeException);
1208 +::rtl::OUString WPGImportFilter_getImplementationName()
1209 + throw ( ::com::sun::star::uno::RuntimeException );
1211 +sal_Bool SAL_CALL WPGImportFilter_supportsService( const ::rtl::OUString& ServiceName )
1212 + throw ( ::com::sun::star::uno::RuntimeException );
1214 +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL WPGImportFilter_getSupportedServiceNames( )
1215 + throw ( ::com::sun::star::uno::RuntimeException );
1217 +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
1218 +SAL_CALL WPGImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
1219 + throw ( ::com::sun::star::uno::Exception );
1221 +#endif
1222 --- writerperfect/source/wpgimp/wpgimport_genericfilter.cxx.old 1970-01-01 00:00:00.000000000 +0000
1223 +++ writerperfect/source/wpgimp/wpgimport_genericfilter.cxx 2009-04-06 16:41:41.000000000 +0000
1224 @@ -0,0 +1,101 @@
1225 +/* genericfilter: mostly generic code for registering the filter
1227 + * Portions of this code Copyright 2000 by Sun Microsystems, Inc.
1228 + * Rest is Copyright (C) 2002 William Lachance (wlach@interlog.com)
1229 + *
1230 + * This program is free software; you can redistribute it and/or
1231 + * modify it under the terms of the GNU General Public License
1232 + * as published by the Free Software Foundation; either version 2
1233 + * of the License, or (at your option) any later version.
1234 + *
1235 + * This program is distributed in the hope that it will be useful,
1236 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1237 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1238 + * GNU General Public License for more details.
1239 + *
1240 + * You should have received a copy of the GNU General Public License
1241 + * along with this program; if not, write to the Free Software
1242 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1243 + * 02111-1307, USA.
1244 + */
1246 +/* "This product is not manufactured, approved, or supported by
1247 + * Corel Corporation or Corel Corporation Limited."
1248 + */
1249 +#include <stdio.h>
1251 +#include <osl/mutex.hxx>
1252 +#include <osl/thread.h>
1253 +#include <cppuhelper/factory.hxx>
1255 +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
1256 +#include <com/sun/star/lang/XSingleServiceFactory.hpp>
1257 +#endif
1259 +#include "WPGImportFilter.hxx"
1261 +using namespace ::rtl;
1262 +using namespace ::cppu;
1263 +using namespace ::com::sun::star::uno;
1264 +using namespace ::com::sun::star::lang;
1265 +using namespace ::com::sun::star::registry;
1267 +extern "C"
1269 +//==================================================================================================
1270 +void SAL_CALL component_getImplementationEnvironment(
1271 + const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
1273 + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
1275 +//==================================================================================================
1276 +sal_Bool SAL_CALL component_writeInfo(
1277 + void * /* pServiceManager */, void * pRegistryKey )
1279 + if (pRegistryKey)
1281 + try
1283 + sal_Int32 nPos = 0;
1284 + Reference< XRegistryKey > xNewKey(
1285 + reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( WPGImportFilter_getImplementationName() ) );
1286 + xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
1288 + const Sequence< OUString > & rSNL = WPGImportFilter_getSupportedServiceNames();
1289 + const OUString * pArray = rSNL.getConstArray();
1290 + for ( nPos = rSNL.getLength(); nPos--; )
1291 + xNewKey->createKey( pArray[nPos] );
1293 + return sal_True;
1295 + catch (InvalidRegistryException &)
1297 + OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
1300 + return sal_False;
1302 +//==================================================================================================
1303 +void * SAL_CALL component_getFactory(
1304 + const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
1306 + void * pRet = 0;
1308 + OUString implName = OUString::createFromAscii( pImplName );
1309 + if ( pServiceManager && implName.equals(WPGImportFilter_getImplementationName()) )
1311 + Reference< XSingleServiceFactory > xFactory( createSingleFactory(
1312 + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
1313 + OUString::createFromAscii( pImplName ),
1314 + WPGImportFilter_createInstance, WPGImportFilter_getSupportedServiceNames() ) );
1316 + if (xFactory.is())
1318 + xFactory->acquire();
1319 + pRet = xFactory.get();
1323 + return pRet;
1326 --- writerperfect/util/wpgimport.map.old 1970-01-01 00:00:00.000000000 +0000
1327 +++ writerperfect/util/wpgimport.map 2009-04-06 16:41:41.000000000 +0000
1328 @@ -0,0 +1,8 @@
1329 +WPFT_1_0 {
1330 + global:
1331 + component_getImplementationEnvironment;
1332 + component_writeInfo;
1333 + component_getFactory;
1334 + local:
1335 + *;
1337 --- writerperfect/prj/build.lst.old 2009-04-06 16:41:41.000000000 +0000
1338 +++ writerperfect/prj/build.lst 2009-04-06 16:41:41.000000000 +0000
1339 @@ -1,7 +1,8 @@
1340 -wp writerperfect : LIBWPS:libwps LIBWPD:libwpd sot comphelper xmloff NULL
1341 +wp writerperfect : LIBWPG:libwpg LIBWPS:libwps LIBWPD:libwpd sot comphelper xmloff NULL
1342 wp writerperfect usr1 - all wp_mkout NULL
1343 wp writerperfect\source\stream nmake - all wp_stream NULL
1344 wp writerperfect\source\filter nmake - all wp_filter NULL
1345 wp writerperfect\source\wpdimp nmake - all wp_wpdimp NULL
1346 wp writerperfect\source\wpsimp nmake - all wp_wpsimp NULL
1347 -wp writerperfect\util nmake - all wp_util wp_wpsimp wp_wpdimp wp_filter wp_stream NULL
1348 +wp writerperfect\source\wpgimp nmake - all wp_wpgimp NULL
1349 +wp writerperfect\util nmake - all wp_util wp_wpgimp wp_wpsimp wp_wpdimp wp_filter wp_stream NULL
1350 --- writerperfect/source/filter/DocumentHandler.cxx.old 2009-04-06 16:41:41.000000000 +0000
1351 +++ writerperfect/source/filter/DocumentHandler.cxx 2009-04-06 16:41:41.000000000 +0000
1352 @@ -61,7 +61,7 @@ void DocumentHandler::startElement(const
1353 for (i.rewind(); i.next(); )
1355 // filter out libwpd elements
1356 - if (strlen(i.key()) > 6 && strncmp(i.key(), "libwpd", 6) != 0)
1357 + if (strncmp(i.key(), "libwpd", 6) != 0)
1358 pAttrList->AddAttribute(OUString::createFromAscii(i.key()),
1359 OUString::createFromAscii(i()->getStr().cstr()));
1361 --- writerperfect/util/makefile.mk.old 2009-04-06 16:41:41.000000000 +0000
1362 +++ writerperfect/util/makefile.mk 2009-04-06 16:41:41.000000000 +0000
1363 @@ -19,10 +19,17 @@ LIBWPS=$(LIBWPS_LIBS)
1364 LIBWPS=-lwpslib
1365 .ENDIF
1367 +.IF "$(SYSTEM_LIBWPG)" == "YES"
1368 +LIBWPG=$(LIBWPG_LIBS)
1369 +.ELSE
1370 +LIBWPG=-lwpglib
1371 +.ENDIF
1373 .ELSE
1375 LIBWPD=$(LIBPRE) wpdlib.lib
1376 LIBWPS=$(LIBPRE) wpslib.lib
1377 +LIBWPG=$(LIBPRE) wpglib.lib
1379 .ENDIF
1381 @@ -82,4 +89,32 @@ SHL2LIBS = $(LIB2TARGET)
1382 SHL2VERSIONMAP=msworks.map
1383 DEF2NAME=$(SHL2TARGET)
1385 +LIB3TARGET= $(SLB)$/wpgimport.lib
1386 +LIB3FILES= \
1387 + $(SLB)$/stream.lib \
1388 + $(SLB)$/filter.lib \
1389 + $(SLB)$/wpgimp.lib
1390 +SHL3LIBS=$(LIB3TARGET)
1391 +SHL3STDLIBS+= \
1392 + $(SVLLIB) \
1393 + $(SOTLIB) \
1394 + $(SO2LIB) \
1395 + $(SVTOOLLIB) \
1396 + $(UNOTOOLSLIB) \
1397 + $(TOOLSLIB) \
1398 + $(COMPHELPERLIB) \
1399 + $(UCBHELPERLIB) \
1400 + $(CPPUHELPERLIB) \
1401 + $(CPPULIB) \
1402 + $(SALLIB) \
1403 + $(XMLOFFLIB) \
1404 + $(LIBWPD) \
1405 + $(LIBWPG)
1407 +SHL3TARGET = wpgimport$(DLLPOSTFIX)
1408 +SHL3IMPLIB = i$(SHL3TARGET)
1409 +SHL3LIBS = $(LIB3TARGET)
1410 +SHL3VERSIONMAP=wpgimport.map
1411 +DEF3NAME=$(SHL3TARGET)
1413 .INCLUDE : target.mk