From 88c905293309b6f8f712d97a71514220bce29be3 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 3 Apr 2013 22:53:32 +0200 Subject: odf export: code clean up and preparatory work to allow gradients in export. Now only linear fill gradients are shown (not taking orientation and position into account). part of bug #474956 (odg export still doesn't work) (bzr r12264) --- src/extension/internal/odf.cpp | 1035 +++++++++++++++------------------------- 1 file changed, 374 insertions(+), 661 deletions(-) (limited to 'src/extension/internal/odf.cpp') diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 4c27925ae..9fc6ecfdb 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -89,7 +89,7 @@ #include "io/inkscapestream.h" #include "io/bufferstream.h" - +#include namespace Inkscape { namespace Extension @@ -805,7 +805,6 @@ void SingularValueDecomposition::calculate() } - /** * Return the left singular vectors * @return U @@ -903,7 +902,6 @@ static Glib::ustring getAttribute( Inkscape::XML::Node *node, char const *attrNa } - /** * Get the extension suffix from the end of a file name */ @@ -923,7 +921,6 @@ static Glib::ustring getExtension(const Glib::ustring &fname) return ext; } - static Glib::ustring formatTransform(Geom::Affine &tf) { Glib::ustring str; @@ -939,9 +936,6 @@ static Glib::ustring formatTransform(Geom::Affine &tf) } - - - /** * Get the general transform from SVG pixels to * ODF cm @@ -960,8 +954,6 @@ static Geom::Affine getODFTransform(const SPItem *item) } - - /** * Get the bounding box of an item, as mapped onto * an ODF document, in cm. @@ -977,7 +969,6 @@ static Geom::OptRect getODFBoundingBox(const SPItem *item) } - /** * Get the transform for an item, correcting for * handedness reversal @@ -991,7 +982,6 @@ static Geom::Affine getODFItemTransform(const SPItem *item) } - /** * Get some fun facts from the transform */ @@ -1015,16 +1005,9 @@ static void analyzeTransform(Geom::Affine &tf, double s1 = svd.getS(1); xscale = s0; yscale = s1; - //g_message("## s0:%.3f s1:%.3f", s0, s1); - //g_message("## u:%.3f %.3f %.3f %.3f", U(0,0), U(0,1), U(1,0), U(1,1)); - //g_message("## v:%.3f %.3f %.3f %.3f", V(0,0), V(0,1), V(1,0), V(1,1)); - //g_message("## vt:%.3f %.3f %.3f %.3f", Vt(0,0), Vt(0,1), Vt(1,0), Vt(1,1)); - //g_message("## uvt:%.3f %.3f %.3f %.3f", UVt(0,0), UVt(0,1), UVt(1,0), UVt(1,1)); rotate = UVt(0,0); } - - static void gatherText(Inkscape::XML::Node *node, Glib::ustring &buf) { if (node->type() == Inkscape::XML::TEXT_NODE) @@ -1047,10 +1030,8 @@ static void gatherText(Inkscape::XML::Node *node, Glib::ustring &buf) * Method descends into the repr tree, converting image, style, and gradient info * into forms compatible in ODF. */ -void -OdfOutput::preprocess(ZipFile &zf, Inkscape::XML::Node *node) +void OdfOutput::preprocess(ZipFile &zf, Inkscape::XML::Node *node) { - Glib::ustring nodeName = node->name(); Glib::ustring id = getAttribute(node, "id"); @@ -1085,13 +1066,9 @@ OdfOutput::preprocess(ZipFile &zf, Inkscape::XML::Node *node) { return; } - //SPItem *item = SP_ITEM(reprobj); - //### Get SVG-to-ODF transform - //Geom::Affine tf = getODFTransform(item); if (nodeName == "image" || nodeName == "svg:image") { - //g_message("image"); Glib::ustring href = getAttribute(node, "xlink:href"); if (href.size() > 0) { @@ -1109,11 +1086,9 @@ OdfOutput::preprocess(ZipFile &zf, Inkscape::XML::Node *node) Glib::ustring comment = "old name was: "; comment.append(oldName); URI oldUri(oldName); - //g_message("oldpath:%s", oldUri.getNativePath().c_str()); //# if relative to the documentURI, get proper path URI resUri = documentUri.resolve(oldUri); DOMString pathName = resUri.getNativePath(); - //g_message("native path:%s", pathName.c_str()); ZipEntry *ze = zf.addFile(pathName, comment); if (ze) { @@ -1133,7 +1108,6 @@ OdfOutput::preprocess(ZipFile &zf, Inkscape::XML::Node *node) } - /** * Writes the manifest. Currently it only changes according to the * file names of images packed into the zip file. @@ -1146,25 +1120,25 @@ bool OdfOutput::writeManifest(ZipFile &zf) time_t tim; time(&tim); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString(" \n"); + outs.writeString(" \n"); + outs.writeString(" \n"); + outs.writeString(" \n"); + outs.writeString(" \n"); std::map::iterator iter; for (iter = imageTable.begin() ; iter!=imageTable.end() ; ++iter) { @@ -1224,29 +1198,29 @@ bool OdfOutput::writeMeta(ZipFile &zf) date = iter->second; } - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); Glib::ustring tmp = Glib::ustring(" ") + InkscapeVersion + "\n"; outs.writeUString(tmp); outs.printf(" %s\n", creator.c_str()); @@ -1261,18 +1235,17 @@ bool OdfOutput::writeMeta(ZipFile &zf) outs.writeUString(tmp); } } - outs.printf(" 2\n"); - outs.printf(" PT56S\n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - + outs.writeString(" 2\n"); + outs.writeString(" PT56S\n"); + outs.writeString(" \n"); + outs.writeString(" \n"); + outs.writeString(" \n"); + outs.writeString(" \n"); + outs.writeString(" \n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); outs.close(); @@ -1285,208 +1258,6 @@ bool OdfOutput::writeMeta(ZipFile &zf) } - - -/** - * This is called just before writeTree(), since it will write style and - * gradient information above the tag in the content.xml file - */ -bool OdfOutput::writeStyle(ZipFile &zf) -{ - BufferOutputStream bouts; - OutputStreamWriter outs(bouts); - - /* - ========================================================== - Dump our style table. Styles should have a general layout - something like the following. Look in: - http://books.evc-cit.info/odbook/ch06.html#draw-style-file-section - for style and gradient information. - - - - ========================================================== - */ - outs.printf("\n"); - std::vector::iterator iter; - for (iter = styleTable.begin() ; iter != styleTable.end() ; ++iter) - { - outs.printf("name.c_str()); - StyleInfo s(*iter); - outs.printf(" style:family=\"graphic\" style:parent-style-name=\"standard\">\n"); - outs.printf(" \n"); - outs.printf("\n"); - } - - //## Dump our gradient table - unsigned int gradientCount = 0; - outs.printf("\n"); - outs.printf("\n"); - std::vector::iterator giter; - for (giter = gradientTable.begin() ; giter != gradientTable.end() ; ++giter) - { - GradientInfo gi(*giter); - if (gi.style == "linear") - { - /* - =================================================================== - LINEAR gradient. We need something that looks like this: - - =================================================================== - */ - if (gi.stops.size() < 2) - { - g_warning("Need at least 2 tops for a linear gradient"); - continue; - } - outs.printf("\n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf("\n"); - } - else if (gi.style == "radial") - { - /* - =================================================================== - RADIAL gradient. We need something that looks like this: - - - =================================================================== - */ - if (gi.stops.size() < 2) - { - g_warning("Need at least 2 tops for a radial gradient"); - continue; - } - outs.printf("\n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf("\n"); - } - else - { - g_warning("unsupported gradient style '%s'", gi.style.c_str()); - } - outs.printf("\n"); - outs.printf(" \n"); - outs.printf("\n\n"); - - gradientCount++; - } - - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - - //Make our entry - ZipEntry *ze = zf.newEntry("styles.xml", "ODF style file"); - ze->setUncompressedData(bouts.getBuffer()); - ze->finish(); - - return true; -} - - - /** * Writes an SVG path as an ODF and returns the number of points written */ @@ -1544,24 +1315,29 @@ writePath(Writer &outs, Geom::PathVector const &pathv, return nrPoints; } - - -bool OdfOutput::processStyle(Writer &outs, SPItem *item, - const Glib::ustring &id) +bool OdfOutput::processStyle(Writer &outs, SPItem *item, const Glib::ustring &id, const Glib::ustring &gradientNameFill)//, Glib::ustring &styleString) { + if (!item) + { + return false; + } + SPStyle *style = item->style; - + if (!style) + { + return false; + } + StyleInfo si; - //## FILL + // FILL if (style->fill.isColor()) - { + { guint32 fillCol = style->fill.value.color.toRGBA32( 0 ); char buf[16]; int r = (fillCol >> 24) & 0xff; int g = (fillCol >> 16) & 0xff; int b = (fillCol >> 8) & 0xff; - //g_message("## %s %lx", id.c_str(), (unsigned int)fillCol); snprintf(buf, 15, "#%02x%02x%02x", r, g, b); si.fillColor = buf; si.fill = "solid"; @@ -1569,11 +1345,19 @@ bool OdfOutput::processStyle(Writer &outs, SPItem *item, (SP_SCALE24_TO_FLOAT(style->fill_opacity.value)); snprintf(buf, 15, "%.3f%%", opacityPercent); si.fillOpacity = buf; + } + else if (style->fill.isPaintserver()) + { + SPGradient *gradient = SP_GRADIENT(SP_STYLE_FILL_SERVER(style)); + if (gradient) + { + si.fill = "gradient"; } + } - //## STROKE + // STROKE if (style->stroke.isColor()) - { + { guint32 strokeCol = style->stroke.value.color.toRGBA32( 0 ); char buf[16]; int r = (strokeCol >> 24) & 0xff; @@ -1588,157 +1372,169 @@ bool OdfOutput::processStyle(Writer &outs, SPItem *item, (SP_SCALE24_TO_FLOAT(style->stroke_opacity.value)); snprintf(buf, 15, "%.3f%%", opacityPercent); si.strokeOpacity = buf; + } + else if (style->stroke.isPaintserver()) + { + SPGradient *gradient = SP_GRADIENT(SP_STYLE_STROKE_SERVER(style)); + if (gradient) + { + si.stroke = "gradient"; } + } //Look for existing identical style; bool styleMatch = false; std::vector::iterator iter; for (iter=styleTable.begin() ; iter!=styleTable.end() ; ++iter) - { + { if (si.equals(*iter)) - { + { //map to existing styleTable entry Glib::ustring styleName = iter->name; - //g_message("found duplicate style:%s", styleName.c_str()); styleLookupTable[id] = styleName; styleMatch = true; break; - } } + } - //## Dont need a new style + // Dont need a new style if (styleMatch) + { return false; + } - char buf[16]; - snprintf(buf, 15, "style%d", (int)styleTable.size()); - Glib::ustring styleName = buf; + Glib::ustring styleName = Glib::ustring::compose("style%1", styleTable.size()); si.name = styleName; styleTable.push_back(si); styleLookupTable[id] = styleName; - outs.printf("\n"); - outs.printf(" \n", si.name); + // Glib::ustring tmpstring; + tmpstring += "\n"); - outs.printf("\n"); + } + tmpstring += "/>\n\n"; + outs.writeUString (tmpstring); return true; } - - - bool OdfOutput::processGradient(Writer &outs, SPItem *item, - const Glib::ustring &id, Geom::Affine &/*tf*/) + const Glib::ustring &id, Geom::Affine &/*tf*/, + Glib::ustring& gradientName, Glib::ustring& output, bool checkFillGradient) { + output.clear(); if (!item) + { return false; + } SPStyle *style = item->style; - if (!style) + { return false; + } - if (!style->fill.isPaintserver()) - return false; - - //## Gradient. Look in writeStyle() below to see what info - // we need to read into GradientInfo. - if (!SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style))) + if ((checkFillGradient? (!style->fill.isPaintserver()) : (!style->stroke.isPaintserver()))) + { return false; + } - SPGradient *gradient = SP_GRADIENT(SP_STYLE_FILL_SERVER(style)); + //## Gradient + SPGradient *gradient = SP_GRADIENT((checkFillGradient?(SP_STYLE_FILL_SERVER(style)) :(SP_STYLE_STROKE_SERVER(style)))); + if (gradient == NULL) + { + return false; + } GradientInfo gi; - SPGradient *grvec = gradient->getVector(FALSE); - for (SPStop *stop = grvec->getFirstStop() ; + for (SPStop *stop = grvec->getFirstStop(); stop ; stop = stop->getNextStop()) - { + { unsigned long rgba = sp_stop_get_rgba32(stop); unsigned long rgb = (rgba >> 8) & 0xffffff; - double opacity = ((double)(rgba & 0xff)) / 256.0; + double opacity = (static_cast(rgba & 0xff)) / 256.0; GradientStop gs(rgb, opacity); gi.stops.push_back(gs); - } + } if (SP_IS_LINEARGRADIENT(gradient)) - { + { gi.style = "linear"; SPLinearGradient *linGrad = SP_LINEARGRADIENT(gradient); - /* - Geom::Point p1(linGrad->x1.value, linGrad->y1.value); - p1 = p1 * tf; - gi.x1 = p1[Geom::X]; - gi.y1 = p1[Geom::Y]; - Geom::Point p2(linGrad->x2.value, linGrad->y2.value); - p2 = p2 * tf; - gi.x2 = p2[Geom::X]; - gi.y2 = p2[Geom::Y]; - */ gi.x1 = linGrad->x1.value; gi.y1 = linGrad->y1.value; gi.x2 = linGrad->x2.value; gi.y2 = linGrad->y2.value; - } + } else if (SP_IS_RADIALGRADIENT(gradient)) - { + { gi.style = "radial"; SPRadialGradient *radGrad = SP_RADIALGRADIENT(gradient); gi.cx = radGrad->cx.computed * 100.0;//ODG cx is percentages gi.cy = radGrad->cy.computed * 100.0; - } + } else - { + { g_warning("not a supported gradient type"); return false; - } + } //Look for existing identical style; bool gradientMatch = false; std::vector::iterator iter; for (iter=gradientTable.begin() ; iter!=gradientTable.end() ; ++iter) - { + { if (gi.equals(*iter)) - { + { //map to existing gradientTable entry - Glib::ustring gradientName = iter->name; - //g_message("found duplicate style:%s", gradientName.c_str()); + // Glib::ustring gradientName = iter->name; + gradientName = iter->name; gradientLookupTable[id] = gradientName; gradientMatch = true; break; - } } + } if (gradientMatch) + { return true; + } - //## No match, let us write a new entry - char buf[16]; - snprintf(buf, 15, "gradient%d", (int)gradientTable.size()); - Glib::ustring gradientName = buf; + // No match, let us write a new entry + // Glib::ustring gradientName = Glib::ustring::compose("gradient%1", gradientTable.size()); + gradientName = Glib::ustring::compose("gradient%1", gradientTable.size()); gi.name = gradientName; gradientTable.push_back(gi); gradientLookupTable[id] = gradientName; int gradientCount = gradientTable.size(); - + char buf[128]; if (gi.style == "linear") - { + { /* =================================================================== LINEAR gradient. We need something that looks like this: @@ -1751,36 +1547,24 @@ bool OdfOutput::processGradient(Writer &outs, SPItem *item, =================================================================== */ if (gi.stops.size() < 2) - { + { g_warning("Need at least 2 stops for a linear gradient"); - return false;; - } - outs.printf("\n", - gi.x2 * pxToCm, gi.y2 * pxToCm); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf("\n"); + return false; } + output += Glib::ustring::compose("\n", + gi.stops[0].opacity * 100.0, gi.stops[1].opacity * 100.0); + // outs.writeUString (tmpstring); + } else if (gi.style == "radial") - { + { /* =================================================================== RADIAL gradient. We need something that looks like this: @@ -1794,10 +1578,11 @@ bool OdfOutput::processGradient(Writer &outs, SPItem *item, =================================================================== */ if (gi.stops.size() < 2) - { + { g_warning("Need at least 2 stops for a radial gradient"); return false; - } + } + /* outs.printf("\n"); outs.printf("\n"); - } + */ + } else - { + { g_warning("unsupported gradient style '%s'", gi.style.c_str()); return false; - } - outs.printf("\n"); - outs.printf(" \n"); - outs.printf("\n\n"); - + } return true; } - - /** * SECOND PASS. - * This is the main SPObject tree output to ODF. preprocess() - * must be called prior to this, as elements will often reference - * data parsed and tabled in preprocess(). + * This is the main SPObject tree output to ODF. */ bool OdfOutput::writeTree(Writer &couts, Writer &souts, Inkscape::XML::Node *node) @@ -1857,22 +1629,19 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts, //# Get the SPItem, if applicable SPObject *reprobj = SP_ACTIVE_DOCUMENT->getObjectByRepr(node); if (!reprobj) + { return true; + } if (!SP_IS_ITEM(reprobj)) - { + { return true; - } + } SPItem *item = SP_ITEM(reprobj); - Glib::ustring nodeName = node->name(); Glib::ustring id = getAttribute(node, "id"); - - //### Get SVG-to-ODF transform - Geom::Affine tf = getODFTransform(item); - - //### Get ODF bounding box params for item - Geom::OptRect bbox = getODFBoundingBox(item); + Geom::Affine tf = getODFTransform(item);//Get SVG-to-ODF transform + Geom::OptRect bbox = getODFBoundingBox(item);//Get ODF bounding box params for item if (!bbox) { return true; } @@ -1892,8 +1661,6 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts, //# Do our stuff SPCurve *curve = NULL; - - if (nodeName == "svg" || nodeName == "svg:svg") { //# Iterate through the children @@ -1937,26 +1704,26 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts, return true; } - //###################################### - //# S T Y L E - //###################################### - processStyle(souts, item, id); - - //###################################### - //# G R A D I E N T - //###################################### - processGradient(souts, item, id, tf); - - - //###################################### - //# I T E M D A T A - //###################################### - //g_message("##### %s #####", nodeName.c_str()); + //# GRADIENT + Glib::ustring gradientNameFill; + Glib::ustring gradientNameStroke; + Glib::ustring outputFill; + Glib::ustring outputStroke; + // Glib::ustring styleString; + + processGradient(souts, item, id, tf, gradientNameFill, outputFill, 1); + souts.writeUString(outputFill); + + //# STYLE + processStyle(souts, item, id, gradientNameFill);//, styleString); + + + //# ITEM DATA if (nodeName == "image" || nodeName == "svg:image") { if (!SP_IS_IMAGE(item)) { - g_warning(" is not an SPImage. Why? ;-)"); + g_warning(" is not an SPImage."); return false; } @@ -2005,13 +1772,13 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts, couts.printf("draw:transform=\"translate(%.3fcm, %.3fcm)\" ", ix, iy); } - couts.printf(">\n"); + couts.writeString(">\n"); couts.printf(" \n"); - couts.printf(" \n"); - couts.printf(" \n"); - couts.printf("\n"); + couts.writeString(" xlink:show=\"embed\" xlink:actuate=\"onLoad\">\n"); + couts.writeString(" \n"); + couts.writeString(" \n"); + couts.writeString("\n"); return true; } else if (SP_IS_SHAPE(item)) @@ -2026,7 +1793,7 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts, if (curve) { //### Default output - couts.printf("second; couts.printf("draw:style-name=\"%s\" ", styleName.c_str()); } + // couts.writeUString(styleString); - std::map::iterator giter; - giter = gradientLookupTable.find(id); - if (giter != gradientLookupTable.end()) - { - Glib::ustring gradientName = giter->second; - couts.printf("draw:fill-gradient-name=\"%s\" ", - gradientName.c_str()); - } + // std::map::iterator giter; + // giter = gradientLookupTable.find(id); + // if (giter != gradientLookupTable.end()) + // { + // Glib::ustring gradientName = giter->second; + // couts.printf("draw:fill-gradient-name=\"%s\" ", + // gradientName.c_str()); + // } couts.printf("draw:layer=\"layout\" svg:x=\"%.3fcm\" svg:y=\"%.3fcm\" ", bbox_x, bbox_y); @@ -2059,12 +1827,11 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts, couts.printf(" svg:d=\""); int nrPoints = writePath(couts, curve->get_pathvector(), tf, bbox_x, bbox_y); - couts.printf("\""); + couts.writeString("\""); - couts.printf(">\n"); + couts.writeString(">\n"); couts.printf(" \n", nrPoints); - couts.printf("\n\n"); - + couts.writeString("\n\n"); curve->unref(); } @@ -2073,7 +1840,6 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts, } - /** * Write the header for the content.xml file */ @@ -2082,59 +1848,56 @@ bool OdfOutput::writeStyleHeader(Writer &outs) time_t tim; time(&tim); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); return true; } @@ -2145,58 +1908,49 @@ bool OdfOutput::writeStyleHeader(Writer &outs) */ bool OdfOutput::writeStyleFooter(Writer &outs) { - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf(" \n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf(" \n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf(" \n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + +///TODO: add default document style here + + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString(" \n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString(" \n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString(" \n"); + outs.writeString(" \n"); + outs.writeString(" \n"); + outs.writeString(" \n"); + outs.writeString(" \n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); return true; } - - /** * Write the header for the content.xml file */ @@ -2205,69 +1959,61 @@ bool OdfOutput::writeContentHeader(Writer &outs) time_t tim; time(&tim); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); return true; } @@ -2277,37 +2023,18 @@ bool OdfOutput::writeContentHeader(Writer &outs) */ bool OdfOutput::writeContentFooter(Writer &outs) { - outs.printf("\n"); - outs.printf("\n"); - - outs.printf("\n"); - outs.printf("\n"); - - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - outs.printf("\n"); - + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); + outs.writeString("\n"); return true; } - /** * Write the content.xml file. Writes the namesspace headers, then * calls writeTree(). @@ -2346,8 +2073,6 @@ bool OdfOutput::writeContent(ZipFile &zf, Inkscape::XML::Node *node) setlocale (LC_NUMERIC, oldlocale); g_free (oldlocale); - - //# Finish content file if (!writeContentFooter(couts)) { @@ -2358,8 +2083,6 @@ bool OdfOutput::writeContent(ZipFile &zf, Inkscape::XML::Node *node) ze->setUncompressedData(cbouts.getBuffer()); ze->finish(); - - //# Finish style file if (!writeStyleFooter(souts)) { @@ -2377,8 +2100,7 @@ bool OdfOutput::writeContent(ZipFile &zf, Inkscape::XML::Node *node) /** * Resets class to its pristine condition, ready to use again */ -void -OdfOutput::reset() +void OdfOutput::reset() { metadata.clear(); styleTable.clear(); @@ -2386,20 +2108,16 @@ OdfOutput::reset() gradientTable.clear(); gradientLookupTable.clear(); imageTable.clear(); - - } /** * Descends into the SVG tree, mapping things to ODF when appropriate */ -void -OdfOutput::save(Inkscape::Extension::Output */*mod*/, SPDocument *doc, gchar const *filename) +void OdfOutput::save(Inkscape::Extension::Output */*mod*/, SPDocument *doc, gchar const *filename) { reset(); - //g_message("native file:%s\n", filename); documentUri = URI(filename); /* fixme: It looks like we really are using documentUri as a URI, so we ought to call * g_filename_to_uri for the URI constructor. */ @@ -2437,8 +2155,7 @@ OdfOutput::save(Inkscape::Extension::Output */*mod*/, SPDocument *doc, gchar con * calls the extension system with the memory allocated XML that * describes the data. */ -void -OdfOutput::init() +void OdfOutput::init() { Inkscape::Extension::build_from_mem( "\n" @@ -2457,8 +2174,7 @@ OdfOutput::init() /** * Make sure that we are in the database */ -bool -OdfOutput::check (Inkscape::Extension::Extension */*module*/) +bool OdfOutput::check (Inkscape::Extension::Extension */*module*/) { /* We don't need a Key if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_POV)) @@ -2468,9 +2184,6 @@ OdfOutput::check (Inkscape::Extension::Extension */*module*/) return TRUE; } - - - } //namespace Internal } //namespace Extension } //namespace Inkscape -- cgit v1.2.3