Back to index

scribus-ng  1.3.4.dfsg+svn20071115
pageitem_desaxe.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 #include "pageitem.h"
00005 #include "util.h"
00006 #include "desaxe/simple_actions.h"
00007 #include "desaxe/saxiohelper.h"
00008 #include "pageitem_imageframe.h"
00009 #include "pageitem_textframe.h"
00010 #include "pageitem_pathtext.h"
00011 #include "pageitem_polyline.h"
00012 #include "pageitem_polygon.h"
00013 #include "pageitem_line.h"
00014 #include "scribusdoc.h"
00015 #include "colorutil.h"
00016 
00017 
00018 using namespace desaxe;
00019 
00020 
00021 
00022 FPointArray parseSVG(const Xml_string& str)
00023 {
00024        FPointArray result;
00025        result.parseSVG(str);
00026        return result;
00027 }
00028 
00029 
00030 static Xml_attr PageItemXMLAttributes(const PageItem* item)
00031 {
00032        Xml_attr result;
00033        
00034        result.insert("id", "obj" + toXMLString(const_cast<PageItem*>(item)->getUId()));
00035        if (!item->AutoName)
00036               result.insert("name", item->itemName());
00037        const PageItem* nxt = item->nextInChain(); 
00038        if (nxt)
00039               result.insert("nextframe", "obj" + toXMLString(nxt->getUId())); 
00040        result.insert("layer", toXMLString(item->LayerNr));
00041        result.insert("level", toXMLString(item->ItemNr));
00042        result.insert("itemtype", toXMLString(item->itemType()));
00043        
00044        result.insert("is-annotation", toXMLString(item->isAnnotation()));
00045        result.insert("is-bookmark", toXMLString(item->isPDFBookmark()));
00046        result.insert("printable", toXMLString(item->printEnabled()));
00047        result.insert("locked", toXMLString(item->locked()));
00048        result.insert("size-locked", toXMLString(item->sizeLocked()));
00049        
00050        result.insert("width", toXMLString(item->width()));
00051        result.insert("height", toXMLString(item->height()));
00052        result.insert("ownpage", toXMLString(item->OwnPage));
00053        Page* page = item->doc()->Pages->at(item->OwnPage);
00054        if (page)
00055        {
00056               result.insert("xorigin", toXMLString(item->xPos() - page->xOffset()));
00057               result.insert("yorigin", toXMLString(item->yPos() - page->yOffset()));
00058        }
00059        else
00060        {
00061               result.insert("xorigin", toXMLString(item->xPos()));
00062               result.insert("yorigin", toXMLString(item->yPos()));
00063        }
00064        result.insert("rotation", toXMLString(item->rotation()));
00065        result.insert("fill-color", item->fillColor());
00066        result.insert("fill-shade", toXMLString(item->fillShade()));
00067        result.insert("fill-transparency", toXMLString(item->fillTransparency()));
00068        result.insert("fill-blendmode", toXMLString(item->fillBlendmode()));
00069        result.insert("fill-gradient-type", toXMLString(item->gradientType()));
00070        result.insert("fill-evenodd", toXMLString(item->fillEvenOdd()));
00071        result.insert("do-overprint", toXMLString(item->overprint()));
00072        
00073        result.insert("line-color", item->lineColor());
00074        result.insert("line-shade", toXMLString(item->lineShade()));
00075        result.insert("line-transparency", toXMLString(item->lineTransparency()));
00076        result.insert("line-blendmode", toXMLString(item->lineBlendmode()));
00077        result.insert("line-width", toXMLString(item->lineWidth()));
00078        result.insert("line-style", toXMLString(item->PLineArt));
00079        result.insert("line-cap", toXMLString(item->PLineEnd));
00080        result.insert("line-join", toXMLString(item->PLineJoin));
00081        result.insert("line-customstyle", item->customLineStyle());
00082        result.insert("line-start-arrow", toXMLString(item->startArrowIndex()));
00083        result.insert("line-end-arrow", toXMLString(item->endArrowIndex()));
00084 
00085        result.insert("frame-type", toXMLString(item->frameType()));
00086        result.insert("frame-shape", toXMLString(item->shape()));
00087        result.insert("frame-has-default-shape", toXMLString(item->hasDefaultShape()));     
00088        result.insert("corner-radius", toXMLString(item->cornerRadius()));    
00089        result.insert("frame-contour", toXMLString(item->contour()));
00090        result.insert("text-flow-mode", toXMLString((int) item->textFlowMode() ));
00091        
00092        result.insert("left-distance", toXMLString(item->textToFrameDistLeft()));
00093        result.insert("top-distance", toXMLString(item->textToFrameDistTop()));
00094        result.insert("bottom-distance", toXMLString(item->textToFrameDistBottom()));
00095        result.insert("right-distance", toXMLString(item->textToFrameDistRight()));
00096 
00097        result.insert("text-autoframes", toXMLString(item->isAutoFrame()));
00098        result.insert("text-columns", toXMLString(item->columns()));
00099        result.insert("text-columngap", toXMLString(item->columnGap()));
00100        result.insert("text-reversed", toXMLString(item->reversed()));
00101        result.insert("pathtext-type", toXMLString(item->pathTextType()));
00102        result.insert("pathtext-flipped", toXMLString(item->flipPathText()));
00103        result.insert("pathtext-baseoffset", toXMLString(item->pathTextBaseOffset()));
00104        result.insert("pathtext-showpath", toXMLString(item->pathTextShowFrame()));
00105 
00106        result.insert("image-scale-framesize", toXMLString(item->fitImageToFrame()));
00107        result.insert("image-scale-proportional", toXMLString(item->keepAspectRatio()));
00108        result.insert("image-x-scale", toXMLString(item->imageXScale()));
00109        result.insert("image-y-scale", toXMLString(item->imageYScale()));
00110        result.insert("image-x-position", toXMLString(item->imageXOffset()));
00111        result.insert("image-y-position", toXMLString(item->imageYOffset()));
00112        //     result.insert("image-x-dpi", toXMLString(item->imageXDpi()));
00113        //     result.insert("image-y-dpi", toXMLString(item->imageYDpi()));
00114        result.insert("image-shown", toXMLString(item->imageShown()));
00115        result.insert("image-use-embedded", toXMLString(item->useEmbeddedImageProfile()));
00116        result.insert("image-embedded-profile", item->embeddedImageProfile());
00117        result.insert("image-flipped-hor", toXMLString(item->imageFlippedH()));
00118        result.insert("image-flipped-vert", toXMLString(item->imageFlippedV()));
00119        result.insert("cms-profile", item->cmsProfile());
00120        result.insert("cms-intent", toXMLString(item->cmsRenderingIntent()));
00121        
00122        if (item->groups().count() > 0)
00123        {
00124               QString grouplist = "";
00125               QValueStack<int>::const_iterator it;
00126               for (it = item->groups().begin(); it != item->groups().end(); ++it)
00127                      grouplist += toXMLString( *it ) + " ";    
00128               result.insert("groups", toXMLString(grouplist));
00129               result.insert("isGroupControl", toXMLString(item->controlsGroup()));
00130               if (item->isGroupControl)
00131               {
00132                      if (item->groupsLastItem != 0)
00133                             result.insert("groupsLastItem", "obj" + toXMLString(item->groupsLastItem->getUId()));
00134               }
00135        }
00136        
00137        result.insert("isTableItem", toXMLString(item->isTableItem));
00138        if (item->isTableItem)
00139        {
00140               result.insert("TopLine", toXMLString(item->TopLine));
00141               result.insert("LeftLine", toXMLString(item->LeftLine));
00142               result.insert("RightLine", toXMLString(item->RightLine));
00143               result.insert("BottomLine", toXMLString(item->BottomLine));
00144               if (item->TopLink != 0)
00145                      result.insert("TopLINK", "obj" + toXMLString(item->TopLink->getUId()));
00146               if (item->LeftLink != 0)
00147                      result.insert("LeftLINK", "obj" + toXMLString(item->LeftLink->getUId()));
00148               if (item->RightLink != 0)
00149                      result.insert("RightLINK", "obj" + toXMLString(item->RightLink->getUId()));
00150               if (item->BottomLink != 0)
00151                      result.insert("BottomLINK", "obj" + toXMLString(item->BottomLink->getUId()));
00152        }
00153        
00154 //     result.insert("ANNAME", !item->AutoName ? item->itemName() : QString(""));  // not used
00155        
00156        if ((item->itemType()==PageItem::ImageFrame || item->itemType()==PageItem::TextFrame) && (!item->externalFile().isEmpty()))
00157               result.insert("image-file", Path2Relative(item->externalFile()));
00158        if (!item->fileIconPressed().isEmpty())
00159               result.insert("icon-pressed-file", Path2Relative(item->fileIconPressed()));
00160        if (!item->fileIconRollover().isEmpty())
00161               result.insert("icon-rollover-file", Path2Relative(item->fileIconRollover()));       
00162        
00163        if (item->dashes().count() > 0)
00164               result.insert("line-dashes", toXMLString(item->dashes()));
00165        if (item->dashOffset() != 0.0)
00166               result.insert("line-dash-offset", toXMLString(item->dashOffset()));
00167        return result;
00168 }      
00169 
00170 
00171 void PageItem::saxx(SaxHandler& handler, const Xml_string& elemtag) const
00172 {
00173        Xml_attr att(PageItemXMLAttributes(this));
00174        Xml_attr dumm;
00175 //     qDebug(QString("PageItem::saxx %1 %2").arg((ulong) &handler));
00176        handler.begin(elemtag, att);
00177 
00178        if (effectsInUse.count() != 0)
00179        {
00180               for (uint a = 0; a < effectsInUse.count(); ++a)
00181               {
00182                      Xml_attr imeff;
00183                      imeff.insert("Code", toXMLString((*effectsInUse.at(a)).effectCode));
00184                      imeff.insert("Param", (*effectsInUse.at(a)).effectParameters);
00185                      handler.begin("ImageEffect", imeff);
00186                      handler.end("ImageEffect");
00187               }
00188        }
00189        
00190        if ((itemType()==ImageFrame || itemType()==TextFrame) && !Pfile.isEmpty() 
00191               && pixm.imgInfo.layerInfo.count() != 0 && pixm.imgInfo.isRequest)
00192        {
00193               QMap<int, ImageLoadRequest>::const_iterator it2;
00194               for (it2 = pixm.imgInfo.RequestProps.begin(); it2 != pixm.imgInfo.RequestProps.end(); ++it2)
00195               {
00196                      Xml_attr psd;
00197                      psd.insert("Layer", toXMLString(it2.key()));
00198                      psd.insert("Visible", toXMLString(it2.data().visible));
00199                      psd.insert("useMask", toXMLString(it2.data().useMask));
00200                      psd.insert("Opacity", toXMLString(it2.data().opacity));
00201                      psd.insert("Blend", it2.data().blend);
00202                      handler.begin("PSDLayer", psd);
00203                      handler.end("PSDLayer");
00204               }
00205        }
00206        if (gradientType() != 0)
00207        {
00208               if (gradientType() == 8)
00209               {
00210                      Xml_attr patt;
00211                      patt.insert("pattern", pattern());
00212                      double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation;
00213                      patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
00214                      patt.insert("pScaleX", toXMLString(patternScaleX));
00215                      patt.insert("pScaleY", toXMLString(patternScaleY));
00216                      patt.insert("pOffsetX", toXMLString(patternOffsetX));
00217                      patt.insert("pOffsetY", toXMLString(patternOffsetY));
00218                      patt.insert("pRotation", toXMLString(patternRotation));
00219                      handler.begin("Pattern", patt);
00220                      handler.end("Pattern");
00221               }
00222               else
00223               {
00224                      Xml_attr gradient;
00225                      gradient.insert("GRTYPE", toXMLString(GrType));
00226                      gradient.insert("GRSTARTX", toXMLString(GrStartX));
00227                      gradient.insert("GRSTARTY", toXMLString(GrStartY));
00228                      gradient.insert("GRENDX", toXMLString(GrEndX));
00229                      gradient.insert("GRENDY", toXMLString(GrEndY));
00230                      handler.begin("Gradient", gradient);
00231                      QPtrVector<VColorStop> cstops = fill_gradient.colorStops();
00232                      for (uint cst = 0; cst < const_cast<VGradient&>(fill_gradient).Stops(); ++cst) //FIXME make const
00233                      {
00234                             Xml_attr itcl;
00235                             itcl.insert("RAMP", toXMLString(cstops.at(cst)->rampPoint));
00236                             itcl.insert("NAME", cstops.at(cst)->name);
00237                             itcl.insert("SHADE", toXMLString(cstops.at(cst)->shade));
00238                             itcl.insert("TRANS", toXMLString(cstops.at(cst)->opacity));
00239                             handler.begin("CStop",itcl);
00240                             handler.end("CStop");
00241                      }
00242                      handler.end("Gradient");
00243               }
00244        }
00245        
00246        // TODO: PI attributes...
00247        
00248        if (isAnnotation())
00249        {
00250               annotation().saxx(handler);
00251        }
00252        if (prevInChain() == NULL && itemText.length() > 0)
00253        {
00254               itemText.saxx(handler, "text-content");
00255        }
00256        handler.end(elemtag);
00257 }
00258 
00259 
00260 
00261 class CreatePageItem_body : public Generator_body<PageItem>
00262 {
00263        void begin (const Xml_string& /*tagname*/, Xml_attr attr)
00264        {
00265               PageItem* result;
00266               ScribusDoc* doc = this->dig->lookup<ScribusDoc>("<scribusdoc>");
00267               
00268               PageItem::ItemType type = parseEnum<PageItem::ItemType>(attr["itemtype"]);
00269               PageItem::ItemFrameType frametype = PageItem::Unspecified; // parseEnum<PageItem::ItemFrameType>(attr["frame-type"]);
00270               // int ownpage = parseInt(attr["ownpage"]);
00271               // doc->setCurrentPage(doc->Pages->at(ownpage));
00272               double xpos = parseDouble(attr["xorigin"]) + doc->currentPage()->xOffset();
00273               double ypos = parseDouble(attr["yorigin"]) + doc->currentPage()->yOffset();
00274               double width = parseDouble(attr["width"]);
00275               double height = parseDouble(attr["height"]);
00276               double linewidth = parseDouble(attr["line-width"]);
00277               QString fillC = attr["fill-color"];
00278               QString lineC = attr["line-color"];
00279               int nr = doc->itemAdd(type, frametype, xpos, ypos, width, height, linewidth, fillC, lineC, false);
00280               result = doc->Items->at(nr);
00281               this->dig->push(result);
00282 //            qDebug(QString("pushed item: %1,%2 params %3,%4").arg(result->xPos()).arg(result->yPos()).arg(xpos).arg(ypos));
00283        }
00284 };
00285 
00286 class CreatePageItem : public MakeGenerator<CreatePageItem_body, PageItem>
00287 {};
00288 
00289 
00290 
00292 class SetItemText_body : public Action_body
00293 {
00294        void end (const Xml_string& /*tagname*/)
00295        {
00296               PageItem* item = this->dig->top<PageItem>(1);
00297               StoryText* story = this->dig->top<StoryText>(0);
00298               item->itemText.clear();
00299               item->itemText.setDefaultStyle(story->defaultStyle());
00300               item->itemText.append(*story);  // story has no document attached, so we dont want to assign here
00301        }
00302 };
00303 
00304 class SetItemText : public MakeAction<SetItemText_body>
00305 {};
00306 
00307 
00308 
00309 class Gradient_body : public Action_body
00310 {
00311        void begin (const Xml_string& tagName, Xml_attr attr)
00312        {
00313 //            qDebug(QString("pageitem_desaxe: gradient %1").arg(tagName));
00314               if (tagName=="CStop")
00315               {
00316                      PageItem* item = this->dig->top<PageItem>();
00317                      QString name = attr["NAME"];
00318                      double ramp = parseDouble(attr["RAMP"]);
00319                      int shade = parseInt(attr["SHADE"]);
00320                      double opa = parseDouble(attr["TRANS"]);
00321                      // Hack : at this stage, colors may still not exists in document and SetColor would create it, 
00322                      // so use the dummy brown and update manually gradient colors in Serializer
00323                      // item->fill_gradient.addStop(SetColor(doc, name, shade), ramp, 0.5, opa, name, shade);
00324                      item->fill_gradient.addStop( QColor(150, 100, 50) , ramp, 0.5, opa, name, shade);
00325               }
00326               if (tagName=="Gradient")
00327               {
00328                      PageItem* item = this->dig->top<PageItem>();
00329                      item->GrType = parseInt(attr["GRTYPE"]);
00330                      item->GrStartX = parseDouble(attr["GRSTARTX"]);
00331                      item->GrStartY = parseDouble(attr["GRSTARTY"]);
00332                      item->GrEndX = parseDouble(attr["GRENDX"]);
00333                      item->GrEndY = parseDouble(attr["GRENDY"]);
00334                      item->fill_gradient.clearStops();
00335               }
00336        }
00337 };
00338 
00339 class Gradient : public MakeAction<Gradient_body>
00340 {};
00341 
00342 
00343 
00344 class Pattern_body : public Action_body
00345 {
00346        void begin (const Xml_string& tagName, Xml_attr attr)
00347        {
00348               PageItem* item = this->dig->top<PageItem>();
00349               
00350               double patternScaleX = parseDouble(attr["pScaleX"]);
00351               double patternScaleY = parseDouble(attr["pScaleY"]);
00352               double patternOffsetX = parseDouble(attr["pOffsetX"]);
00353               double patternOffsetY = parseDouble(attr["pOffsetY"]);
00354               double patternRotation = parseDouble(attr["pRotation"]);
00355 //            qDebug(QString("pageitem_desaxe: pattern %6: *(%1,%2) +(%3,%4) °%5").arg(patternScaleX).arg(patternScaleY).arg(patternOffsetX).arg(patternOffsetY).arg(patternRotation).arg(attr["pattern"]));
00356 
00357               item->setPattern(attr["pattern"]);
00358               item->setPatternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
00359        }
00360 };
00361 
00362 class Pattern : public MakeAction<Pattern_body>
00363 {};
00364 
00365 
00366 
00367 class ImageEffectsAndLayers_body : public Action_body
00368 {
00369        void begin (const Xml_string& tagName, Xml_attr attr)
00370        {
00371 //            qDebug(QString("pageitem_desaxe: effects/layers %1").arg(tagName));
00372               if (tagName=="ImageEffect")
00373               {
00374                      PageItem* obj = this->dig->top<PageItem>();
00375                      struct ScImage::imageEffect ef;
00376                      ef.effectParameters = attr["Param"];
00377                      ef.effectCode = parseInt(attr["Code"]);
00378                      obj->effectsInUse.append(ef);
00379               }
00380               if (tagName == "PSDLayer")
00381               {
00382                      PageItem* obj = this->dig->top<PageItem>();
00383                      struct ImageLoadRequest loadingInfo;
00384                      loadingInfo.blend = attr["Blend"];
00385                      loadingInfo.opacity = parseInt(attr["Opacity"]);
00386                      loadingInfo.visible = parseBool(attr["Visible"]);
00387                      loadingInfo.useMask = parseBool(attr["useMask"]);
00388                      obj->pixm.imgInfo.RequestProps.insert(parseInt(attr["Layer"]), loadingInfo);
00389                      obj->pixm.imgInfo.isRequest = true;
00390               }
00391        }
00392 };
00393 
00394 class ImageEffectsAndLayers : public MakeAction<ImageEffectsAndLayers_body>
00395 {};
00396 
00397 
00398 
00399 class LoadPicture_body : public Action_body
00400 {
00401        void end (const Xml_string& /*tagname*/)
00402        {
00403               PageItem* item = this->dig->top<PageItem>();
00404               if (item->itemType() == PageItem::ImageFrame)
00405                      item->loadImage(item->externalFile(), true);
00406        }
00407 };
00408 
00409 class LoadPicture : public MakeAction<LoadPicture_body>
00410 {};
00411 
00412 
00413 
00414 class AdjustGroupIds_body : public Action_body
00415 {
00416        void begin (const Xml_string& tagname, Xml_attr attr)
00417        {
00418               if (tagname != PageItem::saxxDefaultElem)
00419               {
00420                      ScribusDoc* doc = this->dig->lookup<ScribusDoc>("<scribusdoc>");
00421                      minGroup = doc->GroupCounter;
00422                      maxGroup = minGroup - 1;
00423               }
00424        }
00425 
00426        void end (const Xml_string& tagname)
00427        {
00428               if (tagname != PageItem::saxxDefaultElem)
00429               {
00430                      ScribusDoc* doc = this->dig->lookup<ScribusDoc>("<scribusdoc>");
00431                      doc->GroupCounter = maxGroup + 1;
00432               }
00433               else {
00434                      PageItem* item = this->dig->top<PageItem>();
00435                      QValueStack<int> groups;
00436                      for (uint i=0; i < item->groups().count(); ++i)
00437                      {
00438                             int newGroup = minGroup + item->groups()[i];
00439                             if (newGroup > maxGroup)
00440                                    maxGroup = newGroup;
00441 //                          qDebug(QString("group id %1 -> %2").arg(item->groups()[i]).arg(newGroup));
00442                             groups.append(newGroup);
00443                      }
00444                      item->setGroups(groups);
00445               }
00446        }
00447        
00448 private:
00449        int minGroup;
00450        int maxGroup;
00451 };
00452 
00453 class AdjustGroupIds : public MakeAction<AdjustGroupIds_body>
00454 {};
00455 
00456 
00457 
00458 
00459 const Xml_string PageItem::saxxDefaultElem("item");
00460 
00461 
00462 
00463 void PageItem::desaxeRules(const Xml_string& prefixPattern, Digester& ruleset, Xml_string elemtag)
00464 {
00465        Xml_string itemPrefix(Digester::concat(prefixPattern, elemtag));
00466        
00467        // the generator CreatePageItem *requires* the Scribusdoc stored as "<scribusdoc>"
00468        ruleset.addRule(itemPrefix, CreatePageItem() );
00469 
00470        ruleset.addRule(itemPrefix, IdRef<PageItem>() );
00471 //     ruleset.addRule(itemPrefix, SetAttribute<PageItem,QString>("id", toXMLString(const_cast<PageItem*>(item)->getUId())); // set automatically
00472        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setLayer, "layer", &parseInt )); // set to activelayer in constructor
00473        static const QString dummy(""); // otherwise the next line gives a warning: default-initialization of 'const QString& desaxe::SetAttributeWithConversion_body<PageItem, const QString&>::default_', which has reference type ...
00474        ruleset.addRule(itemPrefix, SetAttribute<PageItem,const QString&>( & PageItem::setItemName, "name", dummy ));    // ... which could be ignored, but without is nicer
00475        ruleset.addRule(itemPrefix, PatchIdRefAttribute<PageItem, PageItem>( & PageItem::link, "nextframe" ));
00476 //     ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & ?PageItem::setLevel, "level", &parseInt ));  // set automatically
00477 //     ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::??, "itemtype", &parseInt ));  // automatically in createPageItem()
00478 //     ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>(?, "ownpage", &parseInt);  // set to current page in constructor
00479        
00480        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setIsAnnotation,  "is-annotation", &parseBool ));
00481        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setIsPDFBookmark,  "is-bookmark", &parseBool ));
00482        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setPrintEnabled, "printable", &parseBool ));
00483        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setLocked, "locked", &parseBool ));
00484        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setSizeLocked, "size-locked", &parseBool ));
00485        
00486        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setWidth, "width", &parseDouble ));  // also in createPageItem()
00487        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setHeight, "height", &parseDouble ));  // also in createPageItem()
00488 //     ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setXPos, "xorigin", &parseDouble ));  // also in createPageItem()
00489 //     ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setYPos, "yorigin", &parseDouble ));  // also in createPageItem()
00490        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setRotation, "rotation", &parseDouble ));
00491        ruleset.addRule(itemPrefix, SetAttribute<PageItem,const QString&>( & PageItem::setFillColor, "fill-color", dummy ));  // also in createPageItem()
00492        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setFillShade, "fill-shade", &parseInt ));
00493        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setFillTransparency, "fill-transparency", &parseDouble ));
00494        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setFillBlendmode, "fill-blendmode", &parseInt ));
00495        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setGradientType, "fill-gradient-type", &parseInt ));
00496        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,PageItem::TextFlowMode>( & PageItem::setTextFlowMode, "text-flow-mode", &parseEnum<PageItem::TextFlowMode> ));
00497        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setFillEvenOdd, "frame-fill-evenodd", &parseBool ));
00498        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setOverprint, "do-overprint", &parseBool ));
00499        
00500        ruleset.addRule(itemPrefix, SetAttribute<PageItem,const QString&>( & PageItem::setLineColor, "line-color", dummy ));  // also in createPageItem()
00501        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setLineShade, "line-shade", &parseInt ));
00502        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setLineTransparency, "line-transparency", &parseDouble ));
00503        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setLineBlendmode, "line-blendmode", &parseInt ));
00504        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setLineWidth, "line-width", &parseDouble ));  // also in createPageItem()
00505        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,PenStyle>( & PageItem::setLineStyle, "line-style", &parseEnum<PenStyle> ));
00506        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,PenCapStyle>( & PageItem::setLineEnd, "line-cap", &parseEnum<PenCapStyle> ));
00507        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,PenJoinStyle>( & PageItem::setLineJoin, "line-join", &parseEnum<PenJoinStyle> ));
00508        ruleset.addRule(itemPrefix, SetAttribute<PageItem,const QString&>( & PageItem::setCustomLineStyle, "line-customstyle", dummy )); // see comment above for setItemName
00509        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setStartArrowIndex, "line-start-arrow", &parseInt ));
00510        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setEndArrowIndex, "line-end-arrow", &parseInt ));
00511        
00512        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setFrameType, "frame-type", &parseInt ));
00513        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,FPointArray>( & PageItem::setShape, "frame-shape", &parseSVG ));
00514        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setHasDefaultShape, "frame-has-default-shape", &parseBool ));   
00515        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setCornerRadius, "corner-radius", &parseDouble ));     
00516        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,FPointArray>( & PageItem::setContour, "frame-contour", &parseSVG ));
00517        
00518        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setTextToFrameDistLeft, "left-distance", &parseDouble ));
00519        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setTextToFrameDistTop, "top-distance", &parseDouble ));
00520        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setTextToFrameDistBottom, "bottom-distance", &parseDouble ));
00521        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setTextToFrameDistRight, "right-distance", &parseDouble ));
00522        
00523        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setIsAutoFrame, "text-autoframe", &parseBool ));
00524        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setColumns, "text-columns", &parseInt ));
00525        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setColumnGap, "text-columngap", &parseDouble ));
00526        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setReversed, "text-reversed", &parseBool ));
00527        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setPathTextType, "pathtext-type", &parseInt ));
00528        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setFlipPathText, "pathtext-flipped", &parseBool ));
00529        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setPathTextBaseOffset, "pathtext-baseoffset", &parseDouble));
00530        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setPathTextShowFrame, "pathtext-showpath", &parseBool ));
00531        
00532        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setFitImageToFrame, "image-scale-framesize", &parseBool ));
00533        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setKeepAspectRatio, "image-scale-proportional", &parseBool ));
00534        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setImageXScale, "image-x-scale", &parseDouble ));
00535        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setImageYScale, "image-y-scale", &parseDouble ));
00536        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setImageXOffset, "image-x-position", &parseDouble ));
00537        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setImageYOffset, "image-y-position", &parseDouble ));
00538        //     ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>("image-x-dpi", &parseDouble ));  //NYI
00539        //     ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>("image-y-dpi", &parseDouble ));  //NYI
00540        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setImageShown, "image-shown", &parseBool ));
00541        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setUseEmbeddedImageProfile, "image-use-embedded", &parseBool ));
00542        ruleset.addRule(itemPrefix, SetAttribute<PageItem,QString>( & PageItem::setEmbeddedImageProfile, "image-embedded-profile" ));
00543        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setImageFlippedH, "image-flipped-hor", &parseBool ));
00544        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setImageFlippedV, "image-flipped-vert", &parseBool ));
00545        ruleset.addRule(itemPrefix, SetAttribute<PageItem,QString>( & PageItem::setCmsProfile, "cms-profile" ));
00546        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,int>( & PageItem::setCmsRenderingIntent, "cms-intent", &parseInt ));
00547 
00548        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setControlsGroup, "isGroupControl", &parseBool ));
00549        ruleset.addRule(itemPrefix, PatchIdRefAttribute<PageItem, PageItem>( & PageItem::setGroupsLastItem, "groupsLastItem" ));
00550        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,QValueStack<int> >( & PageItem::setGroups, "groups", &parseIntStack ));
00551 
00552        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setIsTableItem, "isTableItem", &parseBool ));
00553        ruleset.addRule(itemPrefix, PatchIdRefAttribute<PageItem, PageItem>( & PageItem::setTopLink, "TopLink" ));
00554        ruleset.addRule(itemPrefix, PatchIdRefAttribute<PageItem, PageItem>( & PageItem::setLeftLink, "LeftLink" ));
00555        ruleset.addRule(itemPrefix, PatchIdRefAttribute<PageItem, PageItem>( & PageItem::setRightLink, "RightLink" ));
00556        ruleset.addRule(itemPrefix, PatchIdRefAttribute<PageItem, PageItem>( & PageItem::setBottomLink, "BottomLink" ));
00557        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setHasTopLine, "TopLine", &parseBool ));
00558        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setHasLeftLine, "LeftLine", &parseBool ));
00559        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setHasRightLine, "RightLine", &parseBool ));
00560        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,bool>( & PageItem::setHasBottomLine, "BottomLine", &parseBool ));
00561        
00562        ruleset.addRule(Digester::concat(itemPrefix, "Pattern"), Pattern()); 
00563        
00564        Gradient gradient;
00565        Xml_string gradientPrefix(Digester::concat(itemPrefix, "Gradient"));
00566        ruleset.addRule(gradientPrefix, gradient);
00567        ruleset.addRule(Digester::concat(gradientPrefix, "CStop"), gradient);
00568               
00569        ImageEffectsAndLayers effectsAndLayers;
00570        ruleset.addRule(Digester::concat(itemPrefix, "ImageEffect"), effectsAndLayers);
00571        ruleset.addRule(Digester::concat(itemPrefix, "PSDLayer"), effectsAndLayers);
00572        
00573        Annotation::desaxeRules(itemPrefix, ruleset);
00574        ruleset.addRule(Digester::concat(itemPrefix, Annotation::saxxDefaultElem), 
00575                                    SetterWithConversion<PageItem,const Annotation&,Annotation>( & PageItem::setAnnotation ));
00576 
00577        // TODO: obj attributes
00578        
00579        ruleset.addRule(itemPrefix, SetAttribute<PageItem,QString>( & PageItem::setExternalFile, "image-file" ));
00580        ruleset.addRule(itemPrefix, SetAttribute<PageItem,QString>( & PageItem::setFileIconPressed, "icon-pressed-file" ));
00581        ruleset.addRule(itemPrefix, SetAttribute<PageItem,QString>( & PageItem::setFileIconRollover, "icon-rollover-file" ));
00582        
00583        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,QValueList<double> >( & PageItem::setDashes, "line-dashes", &parseDoubleList ));
00584        ruleset.addRule(itemPrefix, SetAttributeWithConversion<PageItem,double>( & PageItem::setDashOffset, "line-dash-offset", &parseDouble ));
00585 
00586        StoryText::desaxeRules(itemPrefix, ruleset, "text-content");
00587        Xml_string storyPrefix = Digester::concat(itemPrefix, "text-content");
00588        ruleset.addRule(storyPrefix, SetItemText());
00589        
00590        ruleset.addRule(itemPrefix, LoadPicture());
00591        
00592        AdjustGroupIds adjustGroupIds;
00593        ruleset.addRule("/", adjustGroupIds);
00594        ruleset.addRule(PageItem::saxxDefaultElem, adjustGroupIds);
00595        
00596 }