Orb/Doxygen/src/xmlditadocvisitor.cpp
changeset 4 468f4c8d3d5b
parent 3 d8fccb2cd802
equal deleted inserted replaced
3:d8fccb2cd802 4:468f4c8d3d5b
    11 #include "message.h"
    11 #include "message.h"
    12 #include "util.h"
    12 #include "util.h"
    13 #include <qfileinfo.h> 
    13 #include <qfileinfo.h> 
    14 #include "parserintf.h"
    14 #include "parserintf.h"
    15 
    15 
    16 //#define DITA_DOT_HACK_REMOVE_XREFS
    16 // <simpletable> support
    17 #undef DITA_DOT_HACK_REMOVE_XREFS
    17 static const char* ELEM_SIMPLETABLE = "simpletable";
    18 // If 0 there is no <simpletable> support
    18 static const char* ELEM_SIMPLETABLEROW = "strow";
    19 // Need to lazily evaluate this so that <simpletable> is only written if
    19 
    20 // there is content in the table
    20 //XmlDitaDocVisitor(XmlStream &s,CodeOutputInterface &ci, DocBlockContents *docBlockMaps);
    21 #define DITA_SIMPLETABLE_SUPPORT 0
    21 XmlDitaDocVisitor::XmlDitaDocVisitor(XmlStream &s,CodeOutputInterface &ci, DocBlockContents *docBlockMaps) 
    22 
    22   : DocVisitor(DocVisitor_XML),
    23 XmlDitaDocVisitor::XmlDitaDocVisitor(XmlStream &s,CodeOutputInterface &ci) 
    23   xmlStream(s),
    24   : DocVisitor(DocVisitor_XML), xmlStream(s), xmlElemStack(s), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE), 
    24   xmlElemStack(s),
    25     m_insideParamlist(FALSE), paramMap(), paramDict(), currParam()
    25   m_ci(ci),
    26 {
    26   m_insidePre(false),
    27 	paramDict.setAutoDelete(true);
    27   m_hide(false), 
       
    28   m_insideParamlist(false),
       
    29   m_paramIsTemplate(false),
       
    30   m_docBlockMaps(docBlockMaps),
       
    31   m_writingDl(false),
       
    32   m_mustInsertStrow(false),
       
    33   m_strowOrStheadIsPending(false),
       
    34   m_addTextToReturnDoc(false),
       
    35   m_paraRefCount(0)
       
    36 {
       
    37 	//paramDict.setAutoDelete(true);
    28 }
    38 }
    29 
    39 
    30  
    40  
    31   //--------------------------------------
    41   //--------------------------------------
    32   // visitor functions for leaf nodes
    42   // visitor functions for leaf nodes
   145 	  return;
   155 	  return;
   146 	}
   156 	}
   147 	if (u->isEmail()) {
   157 	if (u->isEmail()) {
   148 		startXref(QString("mailto:")+QString(u->url()), u->url());
   158 		startXref(QString("mailto:")+QString(u->url()), u->url());
   149 	} else {
   159 	} else {
   150 		// Need format attribute
   160 		// Need format attribute for external URLs to prevent DITA proccessing persuing
       
   161 		// external links
   151 		AttributeMap myMap;
   162 		AttributeMap myMap;
   152 		myMap["href"] = u->url();
   163 		myMap["href"] = u->url();
   153 		myMap["format"] = "html";
   164 		myMap["format"] = "html";
   154 		push("xref", myMap);
   165 		push("xref", myMap);
   155 		write(u->url());	
   166 		write(u->url());	
   156 		//startXref(u->url(), u->url());
       
   157 	}
   167 	}
   158 	endXref();
   168 	endXref();
   159 }
   169 }
   160 
   170 
   161 void XmlDitaDocVisitor::visit(DocLineBreak *lb)
   171 void XmlDitaDocVisitor::visit(DocLineBreak *lb)
   162 {
   172 {
   163 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocLineBreak*)", lb)
   173 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocLineBreak*)", lb)
   164 	if (m_hide){
   174 	if (m_hide){
   165 	  return;
   175 	  return;
   166 	}
   176 	}
   167 	//pushpop("linebreak");
       
   168 	//if (lb->parent()->kind() == lb->Kind_Verbatim) {
       
   169 	if (m_insidePre) {
   177 	if (m_insidePre) {
   170 		write("\n");
   178 		write("\n");
   171 	}
   179 	}
   172 }
   180 }
   173 
   181 
   175 {
   183 {
   176 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHorRuler*)")
   184 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHorRuler*)")
   177 	if (m_hide) {
   185 	if (m_hide) {
   178 	  return;
   186 	  return;
   179 	}
   187 	}
   180 	//pushpop("hruler");
   188 	xmlStream.comment(" hruler not supported by DITA 1.1 ");
   181 	xmlStream.comment("hruler not supported by DITA 1.1");
       
   182 }
   189 }
   183 
   190 
   184 void XmlDitaDocVisitor::visit(DocStyleChange *s)
   191 void XmlDitaDocVisitor::visit(DocStyleChange *s)
   185 {
   192 {
   186 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocStyleChange*)", s)
   193 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocStyleChange*)", s)
   224 			pop("sup");
   231 			pop("sup");
   225 		}
   232 		}
   226 		break;
   233 		break;
   227 	case DocStyleChange::Center:
   234 	case DocStyleChange::Center:
   228 		if (s->enable()) {
   235 		if (s->enable()) {
   229 			xmlStream.comment("center not supported by DITA 1.1");
   236 			xmlStream.comment(" center not supported by DITA 1.1 ");
   230 			//push("center");
       
   231 		} else {
       
   232 			//pop("center");
       
   233 		}
   237 		}
   234 		break;
   238 		break;
   235 	case DocStyleChange::Small:
   239 	case DocStyleChange::Small:
   236 		if (s->enable()) {
   240 		if (s->enable()) {
   237 			xmlStream.comment("small not supported by DITA 1.1");
   241 			xmlStream.comment(" small not supported by DITA 1.1 ");
   238 			//push("small");
       
   239 		} else {
       
   240 			//pop("small");
       
   241 		}
   242 		}
   242 		break;
   243 		break;
   243 	case DocStyleChange::Preformatted:
   244 	case DocStyleChange::Preformatted:
   244 		if (s->enable()) 
   245 		if (s->enable()) 
   245 		{
   246 		{
   246 			push("pre");  
   247 			push("pre");  
   247 			m_insidePre = TRUE;
   248 			m_insidePre = true;
   248 		} else {
   249 		} else {
   249 			pop("pre");
   250 			pop("pre");
   250 			m_insidePre = FALSE;
   251 			m_insidePre = false;
   251 		}
   252 		}
   252 		break;
   253 		break;
   253 	case DocStyleChange::Div:  /* HTML only */ break;
   254 	case DocStyleChange::Div:
   254 	case DocStyleChange::Span: /* HTML only */ break;
   255 		if (s->enable()) {
       
   256 			xmlStream.comment(" div not supported by DITA 1.1 ");
       
   257 		}
       
   258 		break;
       
   259 	case DocStyleChange::Span:
       
   260 		if (s->enable()) {
       
   261 			xmlStream.comment(" span not supported by DITA 1.1 ");
       
   262 		}
       
   263 		break;
   255 	}
   264 	}
   256 }
   265 }
   257 
   266 
   258 void XmlDitaDocVisitor::visit(DocVerbatim *s)
   267 void XmlDitaDocVisitor::visit(DocVerbatim *s)
   259 {
   268 {
   261 	if (m_hide) {
   270 	if (m_hide) {
   262 	  return;
   271 	  return;
   263 	}
   272 	}
   264 	switch(s->type())
   273 	switch(s->type())
   265 	{
   274 	{
       
   275 		// Note fall through
   266 		case DocVerbatim::Code:
   276 		case DocVerbatim::Code:
       
   277 		case DocVerbatim::Verbatim:
       
   278 		case DocVerbatim::XmlOnly: 
       
   279 			pushpop("codeblock", s->text());
       
   280 			break;
       
   281 		// Note fall through
       
   282 		case DocVerbatim::HtmlOnly: 
       
   283 		case DocVerbatim::ManOnly: 
       
   284 		case DocVerbatim::LatexOnly: 
       
   285 		case DocVerbatim::Dot: 
       
   286 		case DocVerbatim::Msc: 
       
   287 			break;
       
   288 	}
       
   289 }
       
   290 
       
   291 void XmlDitaDocVisitor::visit(DocAnchor *anc)
       
   292 {
       
   293 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocAnchor*)", anc)
       
   294 	if (m_hide) {
       
   295 	  return;
       
   296 	}
       
   297 	xmlElemStack.addAttribute("id", anc->file()+"_1"+anc->anchor());
       
   298 }
       
   299 
       
   300 void XmlDitaDocVisitor::visit(DocInclude *inc)
       
   301 {
       
   302 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocInclude*)", inc)
       
   303 	if (m_hide) {
       
   304 	  return;
       
   305 	}
       
   306 	switch(inc->type()) {
       
   307 		case DocInclude::IncWithLines:
       
   308 		{ 
   267 			push("codeblock");
   309 			push("codeblock");
   268 			write(s->text());
   310 			QFileInfo cfi(inc->file());
   269 			pop("codeblock");
   311 			FileDef fd(cfi.dirPath(), cfi.fileName());
   270 			break;
   312 			Doxygen::parserManager->getParser(inc->extension())->parseCode(
   271 		case DocVerbatim::Verbatim:
   313 					m_ci,inc->context(),
   272 			pushpop("pre", s->text());
   314 					inc->text().latin1(),
   273 			break;
   315 					inc->isExample(),
   274 		case DocVerbatim::HtmlOnly: 
   316 					inc->exampleFile(),
   275 			//pushpop("htmlonly", s->text());
   317 					&fd
   276 			break;
   318 				);
   277 		case DocVerbatim::ManOnly: 
   319 			pop("codeblock"); 
   278 			//pushpop("manonly", s->text());
   320 		}
   279 			break;
   321 		break;    
   280 		case DocVerbatim::LatexOnly: 
       
   281 			//pushpop("latexonly", s->text());
       
   282 			break;
       
   283 		case DocVerbatim::XmlOnly: 
       
   284 			write(s->text());
       
   285 			break;
       
   286 		case DocVerbatim::Dot: 
       
   287 			//pushpop("dot", s->text());
       
   288 			break;
       
   289 		case DocVerbatim::Msc: 
       
   290 			//pushpop("msc", s->text());
       
   291 			break;
       
   292 	}
       
   293 }
       
   294 
       
   295 void XmlDitaDocVisitor::visit(DocAnchor *anc)
       
   296 {
       
   297 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocAnchor*)", anc)
       
   298 	if (m_hide) {
       
   299 	  return;
       
   300 	}
       
   301 	xmlElemStack.addAttribute("id", anc->file()+"_1"+anc->anchor());
       
   302 	//push("anchor", "id", anc->file()+"_1"+anc->anchor());
       
   303 	//pop("anchor");
       
   304 }
       
   305 
       
   306 void XmlDitaDocVisitor::visit(DocInclude *inc)
       
   307 {
       
   308 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocInclude*)", inc)
       
   309 	if (m_hide) {
       
   310 	  return;
       
   311 	}
       
   312   switch(inc->type())
       
   313   {
       
   314     case DocInclude::IncWithLines:
       
   315       { 
       
   316          push("codeblock");
       
   317          QFileInfo cfi( inc->file() );
       
   318          FileDef fd( cfi.dirPath(), cfi.fileName() );
       
   319          Doxygen::parserManager->getParser(inc->extension())
       
   320                                ->parseCode(m_ci,inc->context(),
       
   321                                            inc->text().latin1(),
       
   322                                            inc->isExample(),
       
   323                                            inc->exampleFile(), &fd);
       
   324          pop("codeblock"); 
       
   325       }
       
   326       break;    
       
   327     case DocInclude::Include: 
   322     case DocInclude::Include: 
   328       push("codeblock");
   323 		push("codeblock");
   329       Doxygen::parserManager->getParser(inc->extension())
   324 		Doxygen::parserManager->getParser(inc->extension())->parseCode(
   330                             ->parseCode(m_ci,inc->context(),
   325 				m_ci,inc->context(),
   331                                         inc->text().latin1(),
   326 				inc->text().latin1(),
   332                                         inc->isExample(),
   327 				inc->isExample(),
   333                                         inc->exampleFile());
   328 				inc->exampleFile()
   334       pop("codeblock"); 
   329 				);
   335       break;
   330 			pop("codeblock"); 
       
   331 		break;
   336     case DocInclude::DontInclude: 
   332     case DocInclude::DontInclude: 
   337       break;
   333       break;
   338     case DocInclude::HtmlInclude: 
   334     case DocInclude::HtmlInclude: 
   339 	  //pushpop("htmlonly", inc->text());
       
   340       break;
   335       break;
   341     case DocInclude::VerbInclude: 
   336     case DocInclude::VerbInclude: 
   342 	  pushpop("pre", inc->text());
   337 	  pushpop("pre", inc->text());
   343       break;
   338       break;
   344   }
   339 	}
   345 }
   340 }
   346 
   341 
   347 void XmlDitaDocVisitor::visit(DocIncOperator *op)
   342 void XmlDitaDocVisitor::visit(DocIncOperator *op)
   348 {
   343 {
   349 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocIncOperator*)", op)
   344 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocIncOperator*)", op)
   350   if (op->isFirst()) 
   345 	if (op->isFirst()) {
   351   {
   346 		if (!m_hide) {
   352     if (!m_hide) {
   347 			push("codeblock");
   353 		push("codeblock");
   348 		}
   354     }
   349 		pushEnabled();
   355     pushEnabled();
   350 		m_hide = true;
   356     m_hide = TRUE;
   351 	}
   357   }
   352 	if (op->type()!=DocIncOperator::Skip) {
   358   if (op->type()!=DocIncOperator::Skip) 
   353 		popEnabled();
   359   {
   354 		if (!m_hide) {
   360     popEnabled();
   355 			Doxygen::parserManager->getParser(m_langExt)->parseCode(
   361     if (!m_hide) {
   356 					m_ci,op->context(),
   362       Doxygen::parserManager->getParser(m_langExt)
   357 					op->text().latin1(),
   363                             ->parseCode(m_ci,op->context(),
   358 					op->isExample(),
   364                                         op->text().latin1(),op->isExample(),
   359 					op->exampleFile()
   365                                         op->exampleFile());
   360 				);
   366     }
   361 		}
   367     pushEnabled();
   362 		pushEnabled();
   368     m_hide=TRUE;
   363 		m_hide=true;
   369   }
   364 	}
   370   if (op->isLast())  
   365 	if (op->isLast()) {
   371   {
   366 		popEnabled();
   372     popEnabled();
   367 		if (!m_hide) {
   373 	if (!m_hide) {
   368 			pop("codeblock"); 
   374 		pop("codeblock"); 
   369 		}
   375 	}
   370 	}
   376   }
       
   377 }
   371 }
   378 
   372 
   379 void XmlDitaDocVisitor::visit(DocFormula *f)
   373 void XmlDitaDocVisitor::visit(DocFormula *f)
   380 {
   374 {
   381 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocFormula*)", f)
   375 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocFormula*)", f)
   396 {
   390 {
   397 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocIndexEntry*)", ie)
   391 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocIndexEntry*)", ie)
   398 	if (m_hide) {
   392 	if (m_hide) {
   399 	  return;
   393 	  return;
   400 	}
   394 	}
   401 
   395 	pushpop("indexterm", ie->entry());
   402 	push("indexterm");
   396 }
   403 	write(ie->entry());
   397 
   404 	pop("indexterm");
   398 void XmlDitaDocVisitor::visit(DocSimpleSectSep *ss)
   405 #if 0
   399 {
   406 	push("indexentry");
   400 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocSimpleSectSep*)", ss)
   407 	push("primaryie");
       
   408 	write(ie->entry());
       
   409 	pop("primaryie");
       
   410 	pushpop("secondaryie");
       
   411 	pop("indexentry");
       
   412 #endif
       
   413 }
       
   414 
       
   415 void XmlDitaDocVisitor::visit(DocSimpleSectSep *)
       
   416 {
       
   417   //pushpop("simplesectsep");
       
   418 }
   401 }
   419 
   402 
   420 //--------------------------------------
   403 //--------------------------------------
   421 // visitor functions for compound nodes
   404 // visitor functions for compound nodes
   422 //--------------------------------------
   405 //--------------------------------------
   423 
       
   424 void XmlDitaDocVisitor::visitPre(DocAutoList *l)
   406 void XmlDitaDocVisitor::visitPre(DocAutoList *l)
   425 {
   407 {
   426 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocAutoList*)", l)
   408 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocAutoList*)", l)
   427 	if (m_hide) {
       
   428 	  return;
       
   429 	}
       
   430 	if (l->isEnumList()) {
   409 	if (l->isEnumList()) {
   431 		push("ol");
   410 		visitPreDefault("ol");
   432 	} else {
   411 	} else {
   433 		push("ul");
   412 		visitPreDefault("ul");
   434 	}
   413 	}
   435 }
   414 }
   436 
   415 
   437 void XmlDitaDocVisitor::visitPost(DocAutoList *l)
   416 void XmlDitaDocVisitor::visitPost(DocAutoList *l)
   438 {
   417 {
   457 }
   436 }
   458 
   437 
   459 void XmlDitaDocVisitor::visitPre(DocPara *p) 
   438 void XmlDitaDocVisitor::visitPre(DocPara *p) 
   460 {
   439 {
   461 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocPara*)", p)
   440 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocPara*)", p)
   462 	if (canPushPara()) {
   441 	if (m_writingDl) {
       
   442 		// Do an asymetric pop/push for dt/dd
       
   443 		// Can not guarentee that we have a "dt" at the top of the stack so can not pop("dt")
       
   444 		pop();
       
   445 		push("dd");
       
   446 	} else if (canPushPara()) {
   463 		visitPreDefault("p");
   447 		visitPreDefault("p");
       
   448 	} else if (!canPushPara()) {
       
   449 		m_paraRefCount += 1;
   464 	}
   450 	}
   465 }
   451 }
   466 
   452 
   467 void XmlDitaDocVisitor::visitPost(DocPara *)
   453 void XmlDitaDocVisitor::visitPost(DocPara *)
   468 {
   454 {
   469 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocPara*)")
   455 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocPara*)")
   470 	if (canPopPara()) {
   456 	if (!m_writingDl && m_paraRefCount == 0 && canPopPara()) {
   471 		visitPostDefault("p");
   457 		visitPostDefault("p");
   472 	}
   458 	} else if (m_paraRefCount > 0){
       
   459 		m_paraRefCount -= 1;
       
   460 	}
       
   461 	ASSERT(m_paraRefCount >= 0);
   473 }
   462 }
   474 
   463 
   475 void XmlDitaDocVisitor::visitPre(DocRoot *)
   464 void XmlDitaDocVisitor::visitPre(DocRoot *)
   476 {
   465 {
   477 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocRoot*)")
   466 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocRoot*)")
   482 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocRoot*)")
   471 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocRoot*)")
   483 }
   472 }
   484 
   473 
   485 void XmlDitaDocVisitor::visitPre(DocSimpleSect *s)
   474 void XmlDitaDocVisitor::visitPre(DocSimpleSect *s)
   486 {
   475 {
   487 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocSimpleSect*)", s)
   476 #ifdef DITA_TRACE
       
   477 	// Trace stuff
       
   478 	switch(s->type()) {
       
   479 		case DocSimpleSect::See:
       
   480 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::See: ")
       
   481 			break;
       
   482 		case DocSimpleSect::Author:
       
   483 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Author: ")
       
   484 			break;
       
   485 		case DocSimpleSect::Authors:
       
   486 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Authors: ")
       
   487 			break;
       
   488 		case DocSimpleSect::Version:
       
   489 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Version: ")
       
   490 			break;
       
   491 		case DocSimpleSect::Since:
       
   492 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Since: ")
       
   493 			break;
       
   494 		case DocSimpleSect::Date:
       
   495 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Date: ")
       
   496 			break;
       
   497 		case DocSimpleSect::Invar:
       
   498 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Invar: ")
       
   499 			break;
       
   500 		case DocSimpleSect::Rcs:
       
   501 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Rcs: ")
       
   502 			break;
       
   503 		case DocSimpleSect::Pre:
       
   504 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Pre: ")
       
   505 			break;
       
   506 		case DocSimpleSect::Post:
       
   507 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Post: ")
       
   508 			break;
       
   509 		case DocSimpleSect::User:
       
   510 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::User: ")
       
   511 			break;
       
   512 		case DocSimpleSect::Note:
       
   513 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Note: ")
       
   514 			break;
       
   515 		case DocSimpleSect::Warning:
       
   516 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Warning: ")
       
   517 			break;
       
   518 		case DocSimpleSect::Remark:
       
   519 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Remark: ")
       
   520 			break;
       
   521 		case DocSimpleSect::Attention:
       
   522 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Attention: ")
       
   523 			break;
       
   524 		case DocSimpleSect::Unknown:
       
   525 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Unknown: ")
       
   526 			break;
       
   527 		case DocSimpleSect::Return:
       
   528 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPre(DocSimpleSect*): case DocSimpleSect::Return: ")
       
   529 			break;
       
   530 		default:
       
   531 			ASSERT(0);
       
   532 			break;
       
   533 	}
       
   534 #endif // DITA_TRACE
   488 	if (m_hide) {
   535 	if (m_hide) {
   489 	  return;
   536 	  return;
   490 	}
   537 	}
   491 	switch(s->type())
   538 	switch(s->type())
   492 	{
   539 	{
   493 		// Fall through
   540 		// Note Fall through, render as simple paragraph
   494 		case DocSimpleSect::See:		
   541 		case DocSimpleSect::See:
   495 		case DocSimpleSect::Return:		
   542 		case DocSimpleSect::Invar:
   496 		case DocSimpleSect::Author:		
   543 		case DocSimpleSect::Rcs:		
       
   544 			if (canPushPara()) {
       
   545 				push("p"); 
       
   546 			}
       
   547 			break;
       
   548 		//
       
   549 		// Types that make a definition list
       
   550 		//
       
   551 		case DocSimpleSect::Author:
       
   552 			pushDl("author");
       
   553 			write("Author");
       
   554 			break;
       
   555 		case DocSimpleSect::Authors:
       
   556 			pushDl("authors");
       
   557 			write("Authors");
       
   558 			break;
       
   559 		case DocSimpleSect::Version:
       
   560 			pushDl("version");
       
   561 			write("Version");
       
   562 			break;
       
   563 		case DocSimpleSect::Since:
       
   564 			pushDl("since");
       
   565 			write("Since");
       
   566 			break;
       
   567 		case DocSimpleSect::Date:
       
   568 			pushDl("date");
       
   569 			write("Date");
       
   570 			break;
       
   571 		case DocSimpleSect::Pre:
       
   572 			pushDl("precondition");
       
   573 			write("Pre-condition");
       
   574 			break;
       
   575 		case DocSimpleSect::Post:
       
   576 			pushDl("postcondition");
       
   577 			write("Post-condition");
       
   578 			break;
       
   579 		case DocSimpleSect::User:
       
   580 			// ALIAS tags are rendered as definition lists
       
   581 			pushDl("user");
       
   582 			break;
       
   583 		//
       
   584 		// Make a note element
       
   585 		//
       
   586 		case DocSimpleSect::Note:		
       
   587 			push("note", "type", "note"); 
       
   588 			break;
       
   589 		case DocSimpleSect::Warning:	
       
   590 			push("note", "type", "caution"); 
       
   591 			break;
       
   592 		case DocSimpleSect::Remark:		
       
   593 			push("note", "type", "other"); 
       
   594 			break;
       
   595 		case DocSimpleSect::Attention:	
       
   596 			push("note", "type", "attention"); 
       
   597 			break;
       
   598 		case DocSimpleSect::Unknown:	
       
   599 			break;
       
   600 		case DocSimpleSect::Return:
       
   601 			// Set flag to gather text into m_docBlockMaps->returnDoc rather than writing it out
       
   602 			//printf("Setting m_addTextToReturnDoc true\n");
       
   603 			m_addTextToReturnDoc = true;
       
   604 			break;
       
   605 		default:
       
   606 			ASSERT(0);
       
   607 			break;
       
   608 	}
       
   609 }
       
   610 
       
   611 void XmlDitaDocVisitor::visitPost(DocSimpleSect *s)
       
   612 {
       
   613 #ifdef DITA_TRACE
       
   614 	// Trace stuff
       
   615 	switch(s->type()) {
       
   616 		case DocSimpleSect::See:
       
   617 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::See: ")
       
   618 			break;
       
   619 		case DocSimpleSect::Author:
       
   620 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Author: ")
       
   621 			break;
       
   622 		case DocSimpleSect::Authors:
       
   623 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Authors: ")
       
   624 			break;
       
   625 		case DocSimpleSect::Version:
       
   626 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Version: ")
       
   627 			break;
       
   628 		case DocSimpleSect::Since:
       
   629 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Since: ")
       
   630 			break;
       
   631 		case DocSimpleSect::Date:
       
   632 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Date: ")
       
   633 			break;
       
   634 		case DocSimpleSect::Invar:
       
   635 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Invar: ")
       
   636 			break;
       
   637 		case DocSimpleSect::Rcs:
       
   638 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Rcs: ")
       
   639 			break;
       
   640 		case DocSimpleSect::Pre:
       
   641 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Pre: ")
       
   642 			break;
       
   643 		case DocSimpleSect::Post:
       
   644 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Post: ")
       
   645 			break;
       
   646 		case DocSimpleSect::User:
       
   647 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::User: ")
       
   648 			break;
       
   649 		case DocSimpleSect::Note:
       
   650 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Note: ")
       
   651 			break;
       
   652 		case DocSimpleSect::Warning:
       
   653 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Warning: ")
       
   654 			break;
       
   655 		case DocSimpleSect::Remark:
       
   656 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Remark: ")
       
   657 			break;
       
   658 		case DocSimpleSect::Attention:
       
   659 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Attention: ")
       
   660 			break;
       
   661 		case DocSimpleSect::Unknown:
       
   662 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Unknown: ")
       
   663 			break;
       
   664 		case DocSimpleSect::Return:
       
   665 			DITA_DOC_VISITOR_TRACE_STRING(" XmlDitaDocVisitor::visitPost(DocSimpleSect*): case DocSimpleSect::Return: ")
       
   666 			break;
       
   667 		default:
       
   668 			ASSERT(0);
       
   669 			break;
       
   670 	}
       
   671 #endif // DITA_TRACE
       
   672 	if (m_hide) {
       
   673 	  return;
       
   674 	}	
       
   675 	switch(s->type())
       
   676 	{
       
   677 		case DocSimpleSect::See:
       
   678 			break;
       
   679 		// Note fall through
       
   680 		case DocSimpleSect::Invar:		
       
   681 		case DocSimpleSect::Rcs:		
       
   682 			if (m_paraRefCount == 0 && canPopPara()) {
       
   683 				pop("p"); 
       
   684 			}
       
   685 			break;
       
   686 		// Note fall through for definiton lists
       
   687 		case DocSimpleSect::Author:
   497 		case DocSimpleSect::Authors:	
   688 		case DocSimpleSect::Authors:	
   498 		case DocSimpleSect::Version:	
   689 		case DocSimpleSect::Version:	
   499 		case DocSimpleSect::Since:		
   690 		case DocSimpleSect::Since:		
   500 		case DocSimpleSect::Date:		
   691 		case DocSimpleSect::Date:		
   501 		case DocSimpleSect::Pre:		
   692 		case DocSimpleSect::Pre:
   502 		case DocSimpleSect::Post:		
   693 		case DocSimpleSect::Post:
   503 		case DocSimpleSect::Invar:		
   694 		case DocSimpleSect::User:
   504 		case DocSimpleSect::User:		
   695 			popDl();
   505 		case DocSimpleSect::Rcs:		
   696 			break;
   506 			if (canPushPara()) {
   697 		// Note fall through for note element
   507 				push("p"); 
       
   508 			}
       
   509 			break;
       
   510 		case DocSimpleSect::Note:		
       
   511 			push("note", "type", "note"); 
       
   512 			break;
       
   513 		case DocSimpleSect::Warning:	
       
   514 			push("note", "type", "caution"); 
       
   515 			break;
       
   516 		case DocSimpleSect::Remark:		
       
   517 			push("note", "type", "other"); 
       
   518 			break;
       
   519 		case DocSimpleSect::Attention:	
       
   520 			push("note", "type", "attention"); 
       
   521 			break;
       
   522 		case DocSimpleSect::Unknown:	
       
   523 			break;
       
   524 		default:
       
   525 			ASSERT(0);
       
   526 #if 0
       
   527 		case DocSimpleSect::See:		push("simplesect", "kind", "see"); break;
       
   528 		case DocSimpleSect::Return:		push("simplesect", "kind", "return"); break;
       
   529 		case DocSimpleSect::Author:		push("simplesect", "kind", "author"); break;
       
   530 		case DocSimpleSect::Authors:	push("simplesect", "kind", "authors"); break;
       
   531 		case DocSimpleSect::Version:	push("simplesect", "kind", "version"); break;
       
   532 		case DocSimpleSect::Since:		push("simplesect", "kind", "since"); break;
       
   533 		case DocSimpleSect::Date:		push("simplesect", "kind", "date"); break;
       
   534 		case DocSimpleSect::Note:		push("simplesect", "kind", "note"); break;
       
   535 		case DocSimpleSect::Warning:	push("simplesect", "kind", "warning"); break;
       
   536 		case DocSimpleSect::Pre:		push("simplesect", "kind", "pre"); break;
       
   537 		case DocSimpleSect::Post:		push("simplesect", "kind", "post"); break;
       
   538 		case DocSimpleSect::Invar:		push("simplesect", "kind", "invariant"); break;
       
   539 		case DocSimpleSect::Remark:		push("simplesect", "kind", "remark"); break;
       
   540 		case DocSimpleSect::Attention:	push("simplesect", "kind", "attention"); break;
       
   541 		case DocSimpleSect::User:		push("simplesect", "kind", "par"); break;
       
   542 		case DocSimpleSect::Rcs:		push("simplesect", "kind", "rcs"); break;
       
   543 		case DocSimpleSect::Unknown:	break;
       
   544 #endif
       
   545 	}
       
   546 }
       
   547 
       
   548 void XmlDitaDocVisitor::visitPost(DocSimpleSect *s)
       
   549 {
       
   550 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPost(DocSimpleSect*)", s)
       
   551 	if (m_hide) {
       
   552 	  return;
       
   553 	}	
       
   554 	switch(s->type())
       
   555 	{
       
   556 		// Fall through
       
   557 		case DocSimpleSect::Note:		
   698 		case DocSimpleSect::Note:		
   558 		case DocSimpleSect::Warning:	
   699 		case DocSimpleSect::Warning:	
   559 		case DocSimpleSect::Remark:		
   700 		case DocSimpleSect::Remark:		
   560 		case DocSimpleSect::Attention:	
   701 		case DocSimpleSect::Attention:	
   561 			pop("note"); 
   702 			pop("note"); 
   562 			break;
   703 			break;
   563 		case DocSimpleSect::Unknown:	
   704 		case DocSimpleSect::Unknown:	
   564 			break;
   705 			break;
       
   706 		case DocSimpleSect::Return:
       
   707 			// Unset flag to gather text into m_docBlockMaps->returnDoc
       
   708 			//printf("Setting m_addTextToReturnDoc false\n");
       
   709 			m_addTextToReturnDoc = false;
       
   710 			break;
   565 		default:
   711 		default:
   566 			if (canPopPara()) {
   712 			ASSERT(0);
   567 				pop("p"); 
       
   568 			}
       
   569 			break;
   713 			break;
   570 	}
   714 	}
   571   //visitPostDefault("simplesect");
   715   //visitPostDefault("simplesect");
   572 }
   716 }
   573 
   717 
   580 		if (canPushPara()) {
   724 		if (canPushPara()) {
   581 			visitPreDefault("p");
   725 			visitPreDefault("p");
   582 		}
   726 		}
   583 		visitPreDefault("b");
   727 		visitPreDefault("b");
   584 	}
   728 	}
   585 
       
   586 }
   729 }
   587 
   730 
   588 void XmlDitaDocVisitor::visitPost(DocTitle *)
   731 void XmlDitaDocVisitor::visitPost(DocTitle *)
   589 {
   732 {
   590 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocTitle*)")
   733 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocTitle*)")
   591 	if (xmlElemStack.peek().getElemName() == "title") {
   734 	if (!xmlElemStack.isEmpty() && xmlElemStack.peek().getElemName() == "title") {
   592 		visitPostDefault("title");
   735 		visitPostDefault("title");
   593 	} else {
   736 	} else {
   594 		visitPostDefault("b");
   737 		visitPostDefault("b");
   595 		if (canPopPara()) {
   738 		if (canPopPara()) {
   596 			visitPostDefault("p");
   739 			visitPostDefault("p");
   624 
   767 
   625 void XmlDitaDocVisitor::visitPre(DocSection *s)
   768 void XmlDitaDocVisitor::visitPre(DocSection *s)
   626 {
   769 {
   627 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocSection*)", s)
   770 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocSection*)", s)
   628 	// Currently unsupported
   771 	// Currently unsupported
       
   772 	xmlStream.comment(" XmlDitaDocVisitor::visitPre(DocSection*) not currently supported by DITA 1.1 ");
   629 #if 0
   773 #if 0
   630 	if (m_hide) {
   774 	if (m_hide) {
   631 	  return;
   775 	  return;
   632 	}
   776 	}
   633 	QString sectNum;
   777 	QString sectNum;
   643 }
   787 }
   644 
   788 
   645 void XmlDitaDocVisitor::visitPost(DocSection *s) 
   789 void XmlDitaDocVisitor::visitPost(DocSection *s) 
   646 {
   790 {
   647 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPost(DocSection*)", s)
   791 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPost(DocSection*)", s)
       
   792 	xmlStream.comment(" XmlDitaDocVisitor::visitPre(DocSection*) not currently supported by DITA 1.1 ");
   648 #if 0
   793 #if 0
   649 	// The original did not have the if(m_hide) test.
   794 	// The original did not have the if(m_hide) test.
   650 	// I assume that is an error so visitPostDefault() uses it.
   795 	// I assume that is an error so visitPostDefault() uses it.
   651 	QString level;
   796 	QString level;
   652 	level.setNum(s->level());
   797 	level.setNum(s->level());
   707 	if (m_hide) {
   852 	if (m_hide) {
   708 	  return;
   853 	  return;
   709 	}
   854 	}
   710 	push("dlentry");
   855 	push("dlentry");
   711 	push("dt");
   856 	push("dt");
   712 	//push("varlistentry");
       
   713 	//push("term");
       
   714 }
   857 }
   715 
   858 
   716 void XmlDitaDocVisitor::visitPost(DocHtmlDescTitle *) 
   859 void XmlDitaDocVisitor::visitPost(DocHtmlDescTitle *) 
   717 {
   860 {
   718 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlDescTitle*)")
   861 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlDescTitle*)")
   719 	if (m_hide) {
   862 	if (m_hide) {
   720 	  return;
   863 	  return;
   721 	}
   864 	}
       
   865 	//printf("XmlDitaDocVisitor::visitPost(DocHtmlDescTitle *)\n");
   722 	pop("dt");
   866 	pop("dt");
   723 	//pop("dlentry");
   867 	// Note: We have to wait until XmlDitaDocVisitor::visitPost(DocHtmlDescData *) to pop("dlentry");
   724 	// pop("term");
       
   725 	// pop("varlistentry");
       
   726 }
   868 }
   727 
   869 
   728 void XmlDitaDocVisitor::visitPre(DocHtmlDescData *)
   870 void XmlDitaDocVisitor::visitPre(DocHtmlDescData *)
   729 {
   871 {
   730 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlDescData*)")
   872 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlDescData*)")
   731 	push("dd");
   873 	push("dd");
   732 	//visitPreDefault("li");
       
   733 }
   874 }
   734 
   875 
   735 void XmlDitaDocVisitor::visitPost(DocHtmlDescData *) 
   876 void XmlDitaDocVisitor::visitPost(DocHtmlDescData *) 
   736 {
   877 {
   737 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlDescData*)")
   878 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlDescData*)")
   738 	pop("dd");
   879 	pop("dd");
   739 	pop("dlentry");
   880 	pop("dlentry");
   740 	//visitPostDefault("li");  
       
   741 }
   881 }
   742 
   882 
   743 void XmlDitaDocVisitor::visitPre(DocHtmlTable *t)
   883 void XmlDitaDocVisitor::visitPre(DocHtmlTable *t)
   744 {
   884 {
   745 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocHtmlTable*)", t)
   885 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocHtmlTable*)", t)
   746 	if (m_hide) {
   886 	if (m_hide) {
   747 	  return;
   887 	  return;
   748 	}
   888 	}
   749 #if DITA_SIMPLETABLE_SUPPORT
   889 	push(ELEM_SIMPLETABLE);
   750 	push("simpletable");
       
   751 #endif
       
   752 #if 0
       
   753 	AttributeMap attrs;
       
   754 	QString vR, vC;
       
   755 	vR.setNum(t->numRows());
       
   756 	attrs["rows"] = vR;
       
   757 	vC.setNum(t->numCols());
       
   758 	attrs["cols"] = vC;
       
   759 	push("table", attrs);
       
   760 #endif
       
   761 }
   890 }
   762 
   891 
   763 void XmlDitaDocVisitor::visitPost(DocHtmlTable *) 
   892 void XmlDitaDocVisitor::visitPost(DocHtmlTable *) 
   764 {
   893 {
   765 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlTable*)")
   894 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlTable*)")
   766 #if DITA_SIMPLETABLE_SUPPORT
   895 	visitPostDefault(ELEM_SIMPLETABLE);
   767 	visitPostDefault("simpletable");
       
   768 #endif
       
   769 }
   896 }
   770 
   897 
   771 void XmlDitaDocVisitor::visitPre(DocHtmlRow *)
   898 void XmlDitaDocVisitor::visitPre(DocHtmlRow *)
   772 {
   899 {
   773 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlRow*)")
   900 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlRow*)")
   774 	// FIXME look ahead to first cell
   901 	// Set lazy flag
   775 	// if isHeading is true do
   902 	m_strowOrStheadIsPending = true;
   776 	// visitPreDefault("sthead");
   903 	// We have look ahead to first cell before deciding whether to use a "sthead" or not
   777 	// else
   904 	// this is done in XmlDitaDocVisitor::visitPre(DocHtmlCell *c)
   778 	visitPreDefault("strow");
       
   779 }
   905 }
   780 
   906 
   781 void XmlDitaDocVisitor::visitPost(DocHtmlRow *) 
   907 void XmlDitaDocVisitor::visitPost(DocHtmlRow *) 
   782 {
   908 {
   783 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlRow*)")
   909 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlRow*)")
   784 	visitPostDefault("strow");
   910 	// Note: No testing as we could be either poping a sthead or an strow but pop we must
       
   911 	// (well only if we have pushed).
       
   912 	if (!m_strowOrStheadIsPending) {
       
   913 		pop();
       
   914 	}
       
   915 	m_strowOrStheadIsPending = false;
   785 }
   916 }
   786 
   917 
   787 void XmlDitaDocVisitor::visitPre(DocHtmlCell *c)
   918 void XmlDitaDocVisitor::visitPre(DocHtmlCell *c)
   788 {
   919 {
   789 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocHtmlCell*)", c)
   920 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocHtmlCell*)", c)
       
   921 	if (m_strowOrStheadIsPending) {
       
   922 		// Write sthead or strow for the first cell only
       
   923 		if (c->isHeading()) {
       
   924 			visitPreDefault("sthead");
       
   925 		} else {
       
   926 			visitPreDefault(ELEM_SIMPLETABLEROW);
       
   927 		}
       
   928 		m_strowOrStheadIsPending = false;
       
   929 	}
   790 	visitPreDefault("stentry");
   930 	visitPreDefault("stentry");
   791 #if 0
       
   792 	if (m_hide) {
       
   793 	  return;
       
   794 	}
       
   795 	if (c->isHeading()) {
       
   796 	  push("entry", "thead", "yes");
       
   797 	} else {
       
   798 	  push("entry", "thead", "no");
       
   799 	}
       
   800 #endif
       
   801 }
   931 }
   802 
   932 
   803 void XmlDitaDocVisitor::visitPost(DocHtmlCell *c) 
   933 void XmlDitaDocVisitor::visitPost(DocHtmlCell *c) 
   804 {
   934 {
   805 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPost(DocHtmlCell*)", c)
   935 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPost(DocHtmlCell*)", c)
   806   visitPostDefault("stentry");
   936 	visitPostDefault("stentry");
   807 }
   937 }
   808 
   938 
   809 void XmlDitaDocVisitor::visitPre(DocHtmlCaption *)
   939 void XmlDitaDocVisitor::visitPre(DocHtmlCaption *)
   810 {
   940 {
   811 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlCaption*)")
   941 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlCaption*)")
   812 	// Caption is unsupported
   942 	// Caption is unsupported
       
   943 	xmlStream.comment(" XmlDitaDocVisitor::visitPre(DocHtmlCaption*) not currently supported by DITA 1.1 ");
   813 }
   944 }
   814 
   945 
   815 void XmlDitaDocVisitor::visitPost(DocHtmlCaption *) 
   946 void XmlDitaDocVisitor::visitPost(DocHtmlCaption *) 
   816 {
   947 {
   817 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlCaption*)")
   948 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlCaption*)")
   818 	// Caption is unsupported
   949 	// Caption is unsupported
       
   950 	xmlStream.comment(" XmlDitaDocVisitor::visitPost(DocHtmlCaption*) not currently supported by DITA 1.1 ");
   819 }
   951 }
   820 
   952 
   821 void XmlDitaDocVisitor::visitPre(DocInternal *)
   953 void XmlDitaDocVisitor::visitPre(DocInternal *)
   822 {
   954 {
   823 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocInternal*)")
   955 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocInternal*)")
   824 	//visitPreDefault("internal");
   956 	xmlStream.comment(" XmlDitaDocVisitor::visitPre(DocInternal*) not currently supported by DITA 1.1 ");
   825 }
   957 }
   826 
   958 
   827 void XmlDitaDocVisitor::visitPost(DocInternal *) 
   959 void XmlDitaDocVisitor::visitPost(DocInternal *) 
   828 {
   960 {
   829 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocInternal*)")
   961 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocInternal*)")
   830   //visitPostDefault("internal");
   962 	xmlStream.comment(" XmlDitaDocVisitor::visitPost(DocInternal*) not currently supported by DITA 1.1 ");
   831 }
   963 }
   832 
   964 
   833 void XmlDitaDocVisitor::visitPre(DocHRef *href)
   965 void XmlDitaDocVisitor::visitPre(DocHRef *href)
   834 {
   966 {
   835 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocHRef*)", href)
   967 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocHRef*)", href)
   861 
   993 
   862 void XmlDitaDocVisitor::visitPre(DocImage *img)
   994 void XmlDitaDocVisitor::visitPre(DocImage *img)
   863 {
   995 {
   864 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocImage*)", img)
   996 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocImage*)", img)
   865 	// Currently unsupported
   997 	// Currently unsupported
       
   998 	xmlStream.comment(" XmlDitaDocVisitor::visitPre(DocImage*) not currently supported by DITA 1.1 ");
   866 #if 0
   999 #if 0
   867   AttributeMap imgAttrs;
  1000   AttributeMap imgAttrs;
   868   // First the image type
  1001   // First the image type
   869   switch(img->type())
  1002   switch(img->type())
   870   {
  1003   {
   920 }
  1053 }
   921 
  1054 
   922 void XmlDitaDocVisitor::visitPost(DocImage *) 
  1055 void XmlDitaDocVisitor::visitPost(DocImage *) 
   923 {
  1056 {
   924 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocImage*)")
  1057 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocImage*)")
   925   //visitPostDefault("image");
  1058 	xmlStream.comment(" XmlDitaDocVisitor::visitPost(DocImage*) not currently supported by DITA 1.1 ");
   926 }
  1059 }
   927 
  1060 
   928 void XmlDitaDocVisitor::visitPre(DocDotFile *df)
  1061 void XmlDitaDocVisitor::visitPre(DocDotFile *df)
   929 {
  1062 {
   930 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocDotFile*)", df)
  1063 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocDotFile*)", df)
   931 	// Currently unsupported
  1064 	// Currently unsupported
   932 #if 0
  1065 	xmlStream.comment(" XmlDitaDocVisitor::visitPre(DocDotFile*) not currently supported by DITA 1.1 ");
   933 	if (m_hide) {
       
   934 	  return;
       
   935 	}
       
   936 	push("dotfile", "name", df->file());
       
   937 #endif
       
   938 }
  1066 }
   939 
  1067 
   940 void XmlDitaDocVisitor::visitPost(DocDotFile *) 
  1068 void XmlDitaDocVisitor::visitPost(DocDotFile *) 
   941 {
  1069 {
   942 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocDotFile*)")
  1070 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocDotFile*)")
   943 	//visitPostDefault("dotfile");
  1071 	xmlStream.comment(" XmlDitaDocVisitor::visitPost(DocDotFile*) not currently supported by DITA 1.1 ");
   944 }
  1072 }
   945 
  1073 
   946 void XmlDitaDocVisitor::visitPre(DocLink *lnk)
  1074 void XmlDitaDocVisitor::visitPre(DocLink *lnk)
   947 {
  1075 {
   948 	// The result of a \link...\endlink command
  1076 	// The result of a \link...\endlink command
   949 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocLink*)", lnk)
  1077 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocLink*)", lnk)
   950 	if (m_hide) {
  1078 	if (m_hide) {
   951 	  return;
  1079 	  return;
   952 	}
  1080 	}
   953 	if (0) {//lnk->getDefinition() != 0) {
  1081 	startLink(lnk->ref(), lnk->file(), lnk->anchor());
   954 		//printf("XmlDitaDocVisitor calling startLink() DocLink [name]=`%s'\n", lnk->getDefinition()->qualifiedName().data());
       
   955 		startLink("", lnk->getDefinition()->qualifiedName(), "");
       
   956 	} else {
       
   957 		//printf("XmlDitaDocVisitor calling startLink() DocLink [file]=`%s'\n", lnk->file().data());
       
   958 		//startLink(lnk->ref(),lnk->file(),lnk->anchor());
       
   959 		startLink(lnk->ref(), lnk->file(), lnk->anchor());
       
   960 	}	
       
   961 }
  1082 }
   962 
  1083 
   963 void XmlDitaDocVisitor::visitPost(DocLink *) 
  1084 void XmlDitaDocVisitor::visitPost(DocLink *) 
   964 {
  1085 {
   965 	// The result of a \link...\endlink command
  1086 	// The result of a \link...\endlink command
  1030 }
  1151 }
  1031 
  1152 
  1032 void XmlDitaDocVisitor::visitPre(DocParamSect *s)
  1153 void XmlDitaDocVisitor::visitPre(DocParamSect *s)
  1033 {
  1154 {
  1034 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocParamSect*)", s)
  1155 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocParamSect*)", s)
  1035 	m_insideParamlist = TRUE;
       
  1036 	if (m_hide) {
  1156 	if (m_hide) {
  1037 	  return;
  1157 	  return;
  1038 	}
  1158 	}
  1039 	switch(s->type()) {
  1159 	switch(s->type()) {
  1040 		case DocParamSect::Param: 
  1160 		case DocParamSect::Param:
       
  1161 			m_insideParamlist = true;
       
  1162 			m_paramIsTemplate = false;
  1041 			push("paraml", "class", "param"); 
  1163 			push("paraml", "class", "param"); 
  1042 			break;
  1164 			break;
  1043 		case DocParamSect::RetVal: 
  1165 		case DocParamSect::RetVal:
       
  1166 			// NOTE: This code never seems to get exercised
       
  1167 			m_insideParamlist = false;
  1044 			push("paraml", "class", "retval"); 
  1168 			push("paraml", "class", "retval"); 
  1045 			break;
  1169 			break;
  1046 		case DocParamSect::Exception: 
  1170 		case DocParamSect::Exception:
  1047 			push("paraml", "class", "exception"); 
  1171 			//printf("void XmlDitaDocVisitor::visitPre(DocParamSect *s) Exception\n");
       
  1172 			m_insideParamlist = false;
       
  1173 			push("dl", "outputclass", "exception");
       
  1174 			push("dlentry");
       
  1175 			pushpop("dt", "Exceptions");
       
  1176 			push("dd");
       
  1177 			push(ELEM_SIMPLETABLE);
  1048 			break;
  1178 			break;
  1049 		case DocParamSect::TemplateParam: 
  1179 		case DocParamSect::TemplateParam: 
  1050 			push("paraml", "class", "templateparam"); 
  1180 			m_insideParamlist = true;
       
  1181 			m_paramIsTemplate = true;
       
  1182 			push("paraml", "class", "templateparam");
  1051 			break;
  1183 			break;
  1052 		default:
  1184 		default:
  1053 		  ASSERT(0);
  1185 		  ASSERT(0);
  1054 	}
  1186 	}
  1055 }
  1187 }
  1056 
  1188 
  1057 void XmlDitaDocVisitor::visitPost(DocParamSect *)
  1189 void XmlDitaDocVisitor::visitPost(DocParamSect *s)
  1058 {
  1190 {
  1059 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocParamSect*)")
  1191 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocParamSect*)")
  1060 	visitPostDefault("paraml");
  1192 	if (m_hide) {
  1061 	m_insideParamlist = FALSE;
  1193 	  return;
       
  1194 	}
       
  1195 	switch(s->type()) {
       
  1196 		case DocParamSect::Exception:
       
  1197 			pop(ELEM_SIMPLETABLE); 
       
  1198 			pop("dd"); 
       
  1199 			pop("dlentry"); 
       
  1200 			pop("dl"); 
       
  1201 			break;
       
  1202 		default:
       
  1203 			visitPostDefault("paraml");
       
  1204 			break;
       
  1205 	}
       
  1206 	m_insideParamlist = false;
  1062 }
  1207 }
  1063 
  1208 
  1064 void XmlDitaDocVisitor::visitPre(DocParamList *pl)
  1209 void XmlDitaDocVisitor::visitPre(DocParamList *pl)
  1065 {
  1210 {
  1066 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocParamList*)", pl)
  1211 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocParamList*)", pl)
  1067 	if (m_hide) {
  1212 	if (m_hide) {
  1068 	  return;
  1213 	  return;
       
  1214 	}
       
  1215 	if (!m_insideParamlist) {
       
  1216 		push("strow");
       
  1217 		push("stentry");
  1069 	}
  1218 	}
  1070 	QListIterator<DocNode> li(pl->parameters());
  1219 	QListIterator<DocNode> li(pl->parameters());
  1071 	DocNode *param;
  1220 	DocNode *param;
  1072 	for (li.toFirst();(param=li.current());++li) {
  1221 	for (li.toFirst();(param=li.current());++li) {
  1073 		if (param->kind() == DocNode::Kind_Word) {			
  1222 		if (param->kind() == DocNode::Kind_Word) {			
  1076 			currParam = ((DocLinkedWord*)param)->word();
  1225 			currParam = ((DocLinkedWord*)param)->word();
  1077 		} else {
  1226 		} else {
  1078 			// FIXME, what should we use here
  1227 			// FIXME, what should we use here
  1079 			currParam = "";
  1228 			currParam = "";
  1080 		}
  1229 		}
  1081 		paramDict.insert(currParam, new QString(""));
  1230 		if (canLoadParameterMap()) {
  1082 	}
  1231 			if (m_paramIsTemplate) {
  1083 
  1232 				m_docBlockMaps->tparamMap.insert(currParam, "");
  1084 #if 0
  1233 			} else {
  1085 	push("parameteritem");
  1234 				m_docBlockMaps->paramMap.insert(currParam, "");
  1086 	push("parameternamelist");
       
  1087 	QListIterator<DocNode> li(pl->parameters());
       
  1088 	DocNode *param;
       
  1089 	for (li.toFirst();(param=li.current());++li) {
       
  1090 		AttributeMap attrs;
       
  1091 		if (pl->direction() != DocParamSect::Unspecified) {
       
  1092 			if (pl->direction() == DocParamSect::In) {
       
  1093 				attrs["direction"] = "in";
       
  1094 			} else if (pl->direction() == DocParamSect::Out) {
       
  1095 				attrs["direction"] = "out";
       
  1096 			} else if (pl->direction() == DocParamSect::InOut) {
       
  1097 				attrs["direction"] = "inout";
       
  1098 			} else{
       
  1099 				ASSERT(0);
       
  1100 			}
  1235 			}
  1101 		}
  1236 		} else {
  1102 		push("parametername", attrs);
  1237 			if (param->kind() == DocNode::Kind_Word)
  1103 		if (param->kind() == DocNode::Kind_Word)
  1238 			{
  1104 		{
  1239 			  visit((DocWord*)param); 		
  1105 		  visit((DocWord*)param); 		
  1240 			}
  1106 		}
  1241 			else if (param->kind() == DocNode::Kind_LinkedWord)
  1107 		else if (param->kind() == DocNode::Kind_LinkedWord)
  1242 			{
  1108 		{
  1243 			  visit((DocLinkedWord*)param); 
  1109 		  visit((DocLinkedWord*)param); 
  1244 			}
  1110 		}
  1245 		}
  1111 		pop("parametername");
  1246 	}
  1112 	}
  1247 	if (!m_insideParamlist) {
  1113 	pop("parameternamelist");
  1248 		pop("stentry");
  1114 	push("parameterdescription");
  1249 		push("stentry");
  1115 #endif
  1250 	}
  1116 }
  1251 }
  1117 
  1252 
  1118 void XmlDitaDocVisitor::visitPost(DocParamList *)
  1253 void XmlDitaDocVisitor::visitPost(DocParamList *)
  1119 {
  1254 {
  1120 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocParamList*)")
  1255 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocParamList*)")
  1121 	if (m_hide) {
  1256 	if (m_hide) {
  1122 	  return;
  1257 	  return;
  1123 	}
  1258 	}
  1124 	pop("parameterdescription");
  1259 	if (!m_insideParamlist) {
  1125 	pop("parameteritem");
  1260 		pop("stentry");
       
  1261 		pop("strow");
       
  1262 	}
  1126 }
  1263 }
  1127 
  1264 
  1128 void XmlDitaDocVisitor::visitPre(DocXRefItem *x)
  1265 void XmlDitaDocVisitor::visitPre(DocXRefItem *x)
  1129 {
  1266 {
  1130 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocXRefItem*)", x)
  1267 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocXRefItem*)", x)
  1143 		hrefStr.append("_1");
  1280 		hrefStr.append("_1");
  1144 		hrefStr.append(x->anchor());
  1281 		hrefStr.append(x->anchor());
  1145 		push("xref", "href", hrefStr);
  1282 		push("xref", "href", hrefStr);
  1146 		write(x->title());
  1283 		write(x->title());
  1147 	}
  1284 	}
  1148 #if 0
       
  1149 	push("xrefsect", "id", x->file()+"_1"+x->anchor());
       
  1150 	pushpop("xreftitle", x->title());
       
  1151 	push("xrefdescription");
       
  1152 #endif
       
  1153 }
  1285 }
  1154 
  1286 
  1155 void XmlDitaDocVisitor::visitPost(DocXRefItem *)
  1287 void XmlDitaDocVisitor::visitPost(DocXRefItem *)
  1156 {
  1288 {
  1157 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocXRefItem*)")
  1289 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocXRefItem*)")
  1161 	// An xref will be top of stack unless the current 
  1293 	// An xref will be top of stack unless the current 
  1162 	// DocXRefItem was caused by a \deprecated command
  1294 	// DocXRefItem was caused by a \deprecated command
  1163 	if (!xmlElemStack.isEmpty() && xmlElemStack.peek().getElemName() == "xref") {
  1295 	if (!xmlElemStack.isEmpty() && xmlElemStack.peek().getElemName() == "xref") {
  1164 		pop("xref");
  1296 		pop("xref");
  1165 	}
  1297 	}
  1166 	
       
  1167 #if 0
       
  1168 	pop("xrefdescription");
       
  1169 	pop("xrefsect");
       
  1170 #endif
       
  1171 }
  1298 }
  1172 
  1299 
  1173 void XmlDitaDocVisitor::visitPre(DocInternalRef *ref)
  1300 void XmlDitaDocVisitor::visitPre(DocInternalRef *ref)
  1174 {
  1301 {
  1175 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocInternalRef*)", ref)
  1302 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocInternalRef*)", ref)
  1176 	if (m_hide) {
  1303 	if (m_hide) {
  1177 	  return;
  1304 	  return;
  1178 	}
  1305 	}
  1179 	//printf("XmlDitaDocVisitor calling startLink() DocInternalRef [file]=`%s'\n", ref->file().data());
       
  1180 	startLink(0, ref->file(), ref->anchor());
  1306 	startLink(0, ref->file(), ref->anchor());
  1181 }
  1307 }
  1182 
  1308 
  1183 void XmlDitaDocVisitor::visitPost(DocInternalRef *) 
  1309 void XmlDitaDocVisitor::visitPost(DocInternalRef *) 
  1184 {
  1310 {
  1192 
  1318 
  1193 void XmlDitaDocVisitor::visitPre(DocCopy *c)
  1319 void XmlDitaDocVisitor::visitPre(DocCopy *c)
  1194 {
  1320 {
  1195 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocCopy*)", c)
  1321 	DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocCopy*)", c)
  1196 	// Currently unsupported
  1322 	// Currently unsupported
  1197 #if 0
  1323 	xmlStream.comment(" XmlDitaDocVisitor::visitPre(DocCopy*) not currently supported by DITA 1.1 ");
  1198 	if (m_hide) {
       
  1199 	  return;
       
  1200 	}
       
  1201 	push("copydoc", "link", c->link());
       
  1202 #endif
       
  1203 }
  1324 }
  1204 
  1325 
  1205 void XmlDitaDocVisitor::visitPost(DocCopy *)
  1326 void XmlDitaDocVisitor::visitPost(DocCopy *)
  1206 {
  1327 {
  1207 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocCopy*)")
  1328 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocCopy*)")
  1208 //	visitPostDefault("copydoc");
  1329 	xmlStream.comment(" XmlDitaDocVisitor::visitPost(DocCopy*) not currently supported by DITA 1.1 ");
  1209 }
  1330 }
  1210 
  1331 
  1211 void XmlDitaDocVisitor::visitPre(DocText *)
  1332 void XmlDitaDocVisitor::visitPre(DocText *)
  1212 {
  1333 {
  1213 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocText*)")
  1334 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocText*)")
  1218 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocText*)")
  1339 	DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocText*)")
  1219 }
  1340 }
  1220 
  1341 
  1221 void XmlDitaDocVisitor::startXref(const QString &href,const QString &text)
  1342 void XmlDitaDocVisitor::startXref(const QString &href,const QString &text)
  1222 {
  1343 {
  1223 #ifndef DITA_DOT_HACK_REMOVE_XREFS
       
  1224 	push("xref", "href", href);
  1344 	push("xref", "href", href);
  1225 #endif
       
  1226 	write(text);	
       
  1227 }
  1345 }
  1228 
  1346 
  1229 void XmlDitaDocVisitor::endXref()
  1347 void XmlDitaDocVisitor::endXref()
  1230 {
  1348 {
  1231 #ifndef DITA_DOT_HACK_REMOVE_XREFS
       
  1232 	pop("xref");
  1349 	pop("xref");
  1233 #endif
       
  1234 }
  1350 }
  1235 
  1351 
  1236 void XmlDitaDocVisitor::startLink(const QString &ref,const QString &file,const QString &anchor)
  1352 void XmlDitaDocVisitor::startLink(const QString &ref,const QString &file,const QString &anchor)
  1237 {
  1353 {
  1238   AttributeMap refAttrs;
  1354   AttributeMap refAttrs;
  1245   if (!anchor.isEmpty()) {
  1361   if (!anchor.isEmpty()) {
  1246 	  refAttrs["href"] = file+".xml#"+file+"_1"+anchor;
  1362 	  refAttrs["href"] = file+".xml#"+file+"_1"+anchor;
  1247   } else {
  1363   } else {
  1248 	  refAttrs["href"] = file+".xml#"+file;
  1364 	  refAttrs["href"] = file+".xml#"+file;
  1249   }
  1365   }
  1250 #ifndef DITA_DOT_HACK_REMOVE_XREFS
       
  1251   push("xref", refAttrs);
  1366   push("xref", refAttrs);
  1252 #endif
       
  1253 #if 0
       
  1254   AttributeMap refAttrs;
       
  1255   if (!anchor.isEmpty()) {
       
  1256 	  refAttrs["refid"] = file+"_1"+anchor;
       
  1257 	  refAttrs["kindref"] = "member";
       
  1258   } else {
       
  1259 	  refAttrs["refid"] = file;
       
  1260 	  refAttrs["kindref"] = "compound";
       
  1261   }
       
  1262   if (!ref.isEmpty()) {
       
  1263 	  refAttrs["external"] = ref;
       
  1264   }
       
  1265   push("ref", refAttrs);
       
  1266 #endif
       
  1267 }
  1367 }
  1268 
  1368 
  1269 void XmlDitaDocVisitor::endLink()
  1369 void XmlDitaDocVisitor::endLink()
  1270 {
  1370 {
  1271 #ifndef DITA_DOT_HACK_REMOVE_XREFS
       
  1272   visitPostDefault("xref");
  1371   visitPostDefault("xref");
  1273 #endif
       
  1274 }
  1372 }
  1275 
  1373 
  1276 void XmlDitaDocVisitor::pushEnabled()
  1374 void XmlDitaDocVisitor::pushEnabled()
  1277 {
  1375 {
  1278   m_enabled.push(new bool(m_hide));
  1376   m_enabled.push(new bool(m_hide));
  1284   ASSERT(v!=0);
  1382   ASSERT(v!=0);
  1285   m_hide = *v;
  1383   m_hide = *v;
  1286   delete v;
  1384   delete v;
  1287 }
  1385 }
  1288 
  1386 
       
  1387 bool XmlDitaDocVisitor::canWriteToXmlStream() const
       
  1388 {
       
  1389 	if (m_insideParamlist || m_addTextToReturnDoc || m_docBlockMaps != 0) {
       
  1390 		return false;
       
  1391 	} else {
       
  1392 		return true;
       
  1393 	}
       
  1394 }
       
  1395 
       
  1396 /// Returns true if I gather text into m_docBlockMaps->returnDoc?
       
  1397 bool XmlDitaDocVisitor::shouldAddTextToReturnDoc() const
       
  1398 {
       
  1399 	return (m_addTextToReturnDoc && m_docBlockMaps != 0);
       
  1400 }
       
  1401 
       
  1402 bool XmlDitaDocVisitor::canLoadParameterMap() const
       
  1403 {
       
  1404 	return m_insideParamlist && m_docBlockMaps != 0;
       
  1405 }
       
  1406 
       
  1407 /** Keeps track of state so that a simpletable has a strow. */
       
  1408 void XmlDitaDocVisitor::checkSimpleTable(const QString &tagName)
       
  1409 {
       
  1410 	if (tagName == ELEM_SIMPLETABLE) {
       
  1411 		m_mustInsertStrow = true;
       
  1412 	} else if (m_mustInsertStrow && tagName == "strow") {
       
  1413 		m_mustInsertStrow = false;
       
  1414 	}
       
  1415 }
       
  1416 
       
  1417 void XmlDitaDocVisitor::addStrowToSimpleTableOnPop(const QString &tagName)
       
  1418 {
       
  1419 	if (tagName == ELEM_SIMPLETABLE && m_mustInsertStrow) {
       
  1420 		pushpop(ELEM_SIMPLETABLEROW);
       
  1421 		m_mustInsertStrow = false;
       
  1422 	}
       
  1423 }
  1289 
  1424 
  1290 void XmlDitaDocVisitor::write(const QString &string)
  1425 void XmlDitaDocVisitor::write(const QString &string)
  1291 {
  1426 {
  1292 	if (m_insideParamlist) {
  1427 	if (canWriteToXmlStream()) {
  1293 		// TODO: Review the use of paramDict as I think that there is a
  1428 		xmlStream << string;
  1294 		// memory leak here [PaulRo 2010-01-20]
  1429 	} else if (canLoadParameterMap()) {
  1295 		QString *pStr = paramDict.find(currParam);
  1430 		if (m_paramIsTemplate) {
  1296 		if (pStr) {
  1431 			if (m_docBlockMaps->tparamMap.contains(currParam)) {
  1297 			paramDict.replace(currParam, new QString(*pStr + string));
  1432 				m_docBlockMaps->tparamMap[currParam].append(string);
       
  1433 			} else {
       
  1434 				m_docBlockMaps->tparamMap[currParam] = string;
       
  1435 			}
  1298 		} else {
  1436 		} else {
  1299 			paramDict.replace(currParam, new QString(string));
  1437 			if (m_docBlockMaps->paramMap.contains(currParam)) {
  1300 		}
  1438 				m_docBlockMaps->paramMap[currParam].append(string);
  1301 	} else {
  1439 			} else {
  1302 		xmlStream << string;
  1440 				m_docBlockMaps->paramMap[currParam] = string;
       
  1441 			}
       
  1442 		}
       
  1443 	} else if (shouldAddTextToReturnDoc()) {
       
  1444 		//printf("Adding \"%s\" to returnDoc\n", string.data());
       
  1445 		m_docBlockMaps->returnDoc.append(string);
  1303 	}
  1446 	}
  1304 }
  1447 }
  1305 
  1448 
  1306 void XmlDitaDocVisitor::push(const QString &tagName)
  1449 void XmlDitaDocVisitor::push(const QString &tagName)
  1307 {
  1450 {
  1308 	if (m_insideParamlist) {
  1451 	if (canWriteToXmlStream()) {
  1309 		// TODO
  1452 		checkSimpleTable(tagName);
  1310 	} else {
       
  1311 		xmlElemStack.push(tagName);
  1453 		xmlElemStack.push(tagName);
  1312 	}
  1454 	}
  1313 }
  1455 }
  1314 
  1456 
  1315 void XmlDitaDocVisitor::push(const QString &tagName, const QString &key, const QString &value)
  1457 void XmlDitaDocVisitor::push(const QString &tagName, const QString &key, const QString &value)
  1316 {
  1458 {
  1317 	if (m_insideParamlist) {
  1459 	if (canWriteToXmlStream()) {
  1318 		// TODO
  1460 		checkSimpleTable(tagName);
  1319 	} else {
       
  1320 		xmlElemStack.push(tagName, key, value);
  1461 		xmlElemStack.push(tagName, key, value);
  1321 	}
  1462 	}
  1322 }
  1463 }
  1323 
  1464 
  1324 void XmlDitaDocVisitor::push(const QString &tagName, AttributeMap &map)
  1465 void XmlDitaDocVisitor::push(const QString &tagName, AttributeMap &map)
  1325 {
  1466 {
  1326 	if (m_insideParamlist) {
  1467 	if (canWriteToXmlStream()) {
  1327 		// TODO
  1468 		checkSimpleTable(tagName);
  1328 	} else {
       
  1329 		xmlElemStack.push(tagName, map);
  1469 		xmlElemStack.push(tagName, map);
  1330 	}
  1470 	}
  1331 }
  1471 }
  1332 
  1472 
       
  1473 /** pop without checking element matches.
       
  1474 This can be useful when making asymetric push/pops
       
  1475 */
       
  1476 void XmlDitaDocVisitor::pop()
       
  1477 {
       
  1478 	if (canWriteToXmlStream()) {
       
  1479 		// Note: No use of addStrowToSimpleTableOnPop()
       
  1480 		xmlElemStack.pop();
       
  1481 	}
       
  1482 }
       
  1483 
  1333 void XmlDitaDocVisitor::pop(const QString &tagName)
  1484 void XmlDitaDocVisitor::pop(const QString &tagName)
  1334 {
  1485 {
  1335 	if (m_insideParamlist) {
  1486 	if (canWriteToXmlStream()) {
  1336 		// TODO
  1487 		addStrowToSimpleTableOnPop(tagName);
  1337 	} else {
       
  1338 		xmlElemStack.pop(tagName);
  1488 		xmlElemStack.pop(tagName);
  1339 	}
  1489 	}
  1340 }
  1490 }
  1341 
  1491 
  1342 void XmlDitaDocVisitor::pushpop(const QString &tagName)
  1492 void XmlDitaDocVisitor::pushpop(const QString &tagName)
  1343 {
  1493 {
  1344 	if (m_insideParamlist) {
  1494 	if (canWriteToXmlStream() && tagName != ELEM_SIMPLETABLE) {
  1345 		// TODO
       
  1346 	} else {
       
  1347 		xmlElemStack.pushpop(tagName);
  1495 		xmlElemStack.pushpop(tagName);
  1348 	}
  1496 	}
  1349 }
  1497 }
  1350 
  1498 
  1351 void XmlDitaDocVisitor::pushpop(const QString &tagName, const QString &text)
  1499 void XmlDitaDocVisitor::pushpop(const QString &tagName, const QString &text)
  1352 {
  1500 {
  1353 	if (m_insideParamlist) {
  1501 	if (canWriteToXmlStream() && tagName != ELEM_SIMPLETABLE) {
  1354 		paramDict.replace(currParam, new QString(*paramDict[currParam] + text));
       
  1355 	} else {
       
  1356 		xmlElemStack.pushpop(tagName, text);
  1502 		xmlElemStack.pushpop(tagName, text);
  1357 	}
  1503 	} else if (canLoadParameterMap()) {
  1358 }
  1504 		if (m_paramIsTemplate) {
  1359 
  1505 			if (m_docBlockMaps->tparamMap.contains(currParam)) {
  1360 const QString XmlDitaDocVisitor::query(const QString &paramName) const
  1506 				m_docBlockMaps->tparamMap[currParam].append(text);
  1361 {
  1507 			} else {
  1362 	if (paramDict.find(paramName)) {
  1508 				m_docBlockMaps->tparamMap[currParam] = text;
  1363 		return *paramDict[paramName];
  1509 			}
  1364 	} else {
  1510 		} else {
  1365 		// TODO positional option
  1511 			if (m_docBlockMaps->paramMap.contains(currParam)) {
  1366 		return "";
  1512 				m_docBlockMaps->paramMap[currParam].append(text);
  1367 	}
  1513 			} else {
       
  1514 				m_docBlockMaps->paramMap[currParam] = text;
       
  1515 			}
       
  1516 		}
       
  1517 	}
       
  1518 }
       
  1519 
       
  1520 /** Pushes a definition list onto the stack
       
  1521 @param outputClass The value of the outputclass attribute in the dl element
       
  1522 */
       
  1523 void XmlDitaDocVisitor::pushDl(const QString &outputClass)
       
  1524 {
       
  1525 
       
  1526 	// ALIAS tags are rendered as definition lists
       
  1527 	push("dl", "outputclass", outputClass);
       
  1528 	push("dlentry");
       
  1529 	push("dt");
       
  1530 	// This state allows us to do an asymetric push/pop when writing a DocPara
       
  1531 	m_writingDl = true;
       
  1532 }
       
  1533 
       
  1534 /** Pops a definition list onto the stack
       
  1535 */
       
  1536 void XmlDitaDocVisitor::popDl()
       
  1537 {
       
  1538 	// ALIAS tags are rendered as definition lists
       
  1539 	// Note that this is asymetric as pre pushed dt and we pop dd
       
  1540 	// We don't use pop("dd"); as the swap might not have happened
       
  1541 	// and we risk an assertion failure at that point.
       
  1542 	pop();
       
  1543 	pop("dlentry");
       
  1544 	pop("dl");
       
  1545 	// Unset the state variable that allows us to do an
       
  1546 	// asymetric push/pop when writing a DocPara
       
  1547 	m_writingDl = false;
  1368 }
  1548 }
  1369 
  1549 
  1370 /// Returns true if it is OK to write a para element
  1550 /// Returns true if it is OK to write a para element
  1371 bool XmlDitaDocVisitor::canPushPara() const
  1551 bool XmlDitaDocVisitor::canPushPara() const
  1372 {
  1552 {
  1373 	if (!xmlElemStack.isEmpty()) {
  1553 	if (!xmlElemStack.isEmpty()) {
  1374 		QString e = xmlElemStack.peek().getElemName();
  1554 		QString e = xmlElemStack.peek().getElemName();
  1375 		if (e == "xref" || e == "p") {
  1555 		if (e == "xref" || e == "p" || e == "dt") {
  1376 			return false;
  1556 			return false;
  1377 		}
  1557 		}
  1378 	}
  1558 	}
  1379 	return true;
  1559 	return true;
  1380 }
  1560 }