diff -r b7447adddc9a -r 5522d1da7e37 xml.cpp --- a/xml.cpp Wed Jan 10 13:26:12 2007 +0000 +++ b/xml.cpp Tue Jan 23 11:50:53 2007 +0000 @@ -28,6 +28,8 @@ errorProt = ""; state = StateInit; laststate = StateInit; + stateStack.clear(); + stateStack.append(StateInit); branchDepth=0; htmldata=""; isVymPart=false; @@ -52,9 +54,10 @@ /* Testing cout << "startElement <"<< eName.ascii()<< "> state="<setColor(col ); } - } else if ( eName == "note" && state == StateMapCenter) + } else if ( eName == "note" && + (state == StateMapCenter ||state==StateBranch)) { // only for backward compatibility (<1.4.6). Use htmlnote now. - state=StateMapCenterNote; + state=StateNote; if (!readNoteAttr (atts) ) return false; } else if ( eName == "htmlnote" && state == StateMapCenter) { laststate=state; state=StateHtmlNote; - } else if ( eName == "floatimage" && state == StateMapCenter ) + } else if ( eName == "floatimage" && + (state == StateMapCenter ||state==StateBranch)) { - state=StateMapCenterFloatImage; + state=StateFloatImage; lastBranch->addFloatImage(); lastFloat=lastBranch->getLastFloatImage(); if (!readFloatImageAttr(atts)) return false; @@ -217,21 +225,6 @@ lastBranch->addBranch(); lastBranch=lastBranch->getLastBranch(); readBranchAttr (atts); - } else if ( (eName=="standardflag" ||eName == "standardFlag") && state == StateBranch) - { - state=StateBranchStandardFlag; - } else if ( eName == "heading" && state == StateBranch) - { - state=StateBranchHeading; - if (!atts.value( "textColor").isEmpty() ) - { - col.setNamedColor(atts.value("textColor")); - lastBranch->setColor(col ); - } - } else if ( eName == "note" && state == StateBranch) - { - state=StateBranchNote; - if (!readNoteAttr (atts) ) return false; } else if ( eName == "htmlnote" && state == StateBranch) { laststate=state; @@ -239,12 +232,11 @@ no.clear(); if (!atts.value( "fonthint").isEmpty() ) no.setFontHint(atts.value ("fonthint") ); - } else if ( eName == "floatimage" && state == StateBranch ) + } else if ( eName == "frame" && (state == StateBranch||state==StateMapCenter)) { - state=StateBranchFloatImage; - lastBranch->addFloatImage(); - lastFloat=lastBranch->getLastFloatImage(); - if (!readFloatImageAttr(atts)) return false; + laststate=state; + state=StateFrame; + if (!readFrameAttr(atts)) return false; } else if ( eName == "xlink" && state == StateBranch ) { state=StateBranchXLink; @@ -274,38 +266,18 @@ bool mapBuilderHandler::endElement ( const QString&, const QString&, const QString &eName) { -// cout << "endElement state="< state=" <"; if (eName=="html") @@ -314,16 +286,13 @@ htmldata.replace ("

","
"); no.setNote (htmldata); lastBranch->setNote (no); - return true; - } else - { - return true; } - case StateMap: state=StateInit; return true; - default : - // even for HTML includes, this should never be reached - return false; - } + break; + default: + break; + } + state=stateStack.takeLast(); + return true; } bool mapBuilderHandler::characters ( const QString& ch) @@ -343,30 +312,21 @@ break; case StateMapSetting:break; case StateMapCenter: break; - case StateMapCenterStandardFlag: - lastBranch->activateStandardFlag(ch_simplified); - break; - case StateMapCenterHeading: - lastBranch->setHeading(ch_simplified); - break; - case StateMapCenterNote: + case StateNote: lastBranch->setNote(ch_simplified); break; case StateBranch: break; - case StateBranchStandardFlag: + case StateStandardFlag: lastBranch->activateStandardFlag(ch_simplified); break; - case StateBranchHeading: - lastBranch->setHeading(ch_simplified); - break; - case StateBranchNote: - lastBranch->setNote(ch_simplified); - break; - case StateBranchFloatImage: break; + case StateFloatImage: break; case StateHtmlNote: break; case StateHtml: htmldata+=ch_org; break; + case StateHeading: + lastBranch->setHeading(ch_simplified); + break; default: return false; } @@ -452,6 +412,16 @@ return true; } +bool mapBuilderHandler::readFrameAttr (const QXmlAttributes& a) +{ + if (lastOO) + { + if (!a.value( "frameType").isEmpty() ) + lastOO->setFrameType (a.value("frameType")); + } + return true; +} + bool mapBuilderHandler::readOOAttr (const QXmlAttributes& a) { if (lastOO) @@ -532,10 +502,7 @@ } if (!a.value( "fonthint").isEmpty() ) no.setFontHint(a.value ("fonthint") ); - if (state == StateMapCenterNote) - mc->setNote(no); - else - lastBranch->setNote(no); + lastBranch->setNote(no); return true; }