9 #include "message.h" |
11 #include "message.h" |
10 #include "util.h" |
12 #include "util.h" |
11 #include <qfileinfo.h> |
13 #include <qfileinfo.h> |
12 #include "parserintf.h" |
14 #include "parserintf.h" |
13 |
15 |
|
16 //#define DITA_DOT_HACK_REMOVE_XREFS |
|
17 #undef DITA_DOT_HACK_REMOVE_XREFS |
|
18 // If 0 there is no <simpletable> support |
|
19 // Need to lazily evaluate this so that <simpletable> is only written if |
|
20 // there is content in the table |
|
21 #define DITA_SIMPLETABLE_SUPPORT 0 |
14 |
22 |
15 XmlDitaDocVisitor::XmlDitaDocVisitor(XmlStream &s,CodeOutputInterface &ci) |
23 XmlDitaDocVisitor::XmlDitaDocVisitor(XmlStream &s,CodeOutputInterface &ci) |
16 : DocVisitor(DocVisitor_XML), xmlStream(s), xmlElemStack(s), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE), |
24 : DocVisitor(DocVisitor_XML), xmlStream(s), xmlElemStack(s), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE), |
17 m_insideParamlist(FALSE), paramMap(), paramDict(), currParam() |
25 m_insideParamlist(FALSE), paramMap(), paramDict(), currParam() |
18 {} |
26 { |
|
27 paramDict.setAutoDelete(true); |
|
28 } |
19 |
29 |
20 |
30 |
21 //-------------------------------------- |
31 //-------------------------------------- |
22 // visitor functions for leaf nodes |
32 // visitor functions for leaf nodes |
23 //-------------------------------------- |
33 //-------------------------------------- |
24 |
34 |
25 void XmlDitaDocVisitor::visit(DocWord *w) |
35 void XmlDitaDocVisitor::visit(DocWord *w) |
26 { |
36 { |
|
37 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocWord*)", w) |
27 if (m_hide) { |
38 if (m_hide) { |
28 return; |
39 return; |
29 } |
40 } |
30 // Catches normal text (text outside of a tag or command) |
41 // Catches normal text (text outside of a tag or command) |
31 // and puts it in a "p" |
42 // and puts it in a "p" |
35 write(w->word()); |
46 write(w->word()); |
36 } |
47 } |
37 |
48 |
38 void XmlDitaDocVisitor::visit(DocLinkedWord *w) |
49 void XmlDitaDocVisitor::visit(DocLinkedWord *w) |
39 { |
50 { |
|
51 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocLinkedWord*)", w) |
40 if (m_hide) { |
52 if (m_hide) { |
41 return; |
53 return; |
42 } |
54 } |
43 if (w->getDefinition() != 0) { |
55 //printf("XmlDitaDocVisitor calling startLink() DocLinkedWord=`%s'\n", w->word().data()); |
44 startLink("", w->getDefinition()->qualifiedName(), ""); |
56 Definition *d = w->getDefinition(); |
45 } else { |
57 if (0) { |
|
58 QString myName; |
|
59 myName = d->qualifiedName(); |
|
60 //printf("XmlDitaDocVisitor calling startLink() DocLinkedWord [name]=`%s'\n", myName.data()); |
|
61 startLink("", myName, ""); |
|
62 } else { |
|
63 //printf("XmlDitaDocVisitor calling startLink() DocLinkedWord [file]=`%s'\n", w->file().data()); |
|
64 #if DITA_SUPRESS_NAMESPACE_LINKS |
|
65 if (w->file().find("namespace") != 0) { |
|
66 startLink(w->ref(), w->file(), w->anchor()); |
|
67 } |
|
68 #else |
46 startLink(w->ref(), w->file(), w->anchor()); |
69 startLink(w->ref(), w->file(), w->anchor()); |
|
70 #endif |
47 } |
71 } |
48 write(w->word()); |
72 write(w->word()); |
|
73 #if DITA_SUPRESS_NAMESPACE_LINKS |
|
74 if (w->file().find("namespace") != 0) { |
|
75 endLink(); |
|
76 } |
|
77 #else |
49 endLink(); |
78 endLink(); |
|
79 #endif |
50 } |
80 } |
51 |
81 |
52 void XmlDitaDocVisitor::visit(DocWhiteSpace *w) |
82 void XmlDitaDocVisitor::visit(DocWhiteSpace *w) |
53 { |
83 { |
|
84 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocWhiteSpace*)", w) |
54 if (m_hide) { |
85 if (m_hide) { |
55 return; |
86 return; |
56 } |
87 } |
57 if (m_insidePre) { |
88 if (m_insidePre) { |
58 write(w->chars()); |
89 write(w->chars()); |
106 } |
138 } |
107 } |
139 } |
108 |
140 |
109 void XmlDitaDocVisitor::visit(DocURL *u) |
141 void XmlDitaDocVisitor::visit(DocURL *u) |
110 { |
142 { |
|
143 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocURL*)", u) |
111 if (m_hide) { |
144 if (m_hide) { |
112 return; |
145 return; |
113 } |
146 } |
114 if (u->isEmail()) { |
147 if (u->isEmail()) { |
115 startXref(QString("mailto:")+QString(u->url()), u->url()); |
148 startXref(QString("mailto:")+QString(u->url()), u->url()); |
116 } else { |
149 } else { |
117 startXref(u->url(), u->url()); |
150 // Need format attribute |
|
151 AttributeMap myMap; |
|
152 myMap["href"] = u->url(); |
|
153 myMap["format"] = "html"; |
|
154 push("xref", myMap); |
|
155 write(u->url()); |
|
156 //startXref(u->url(), u->url()); |
118 } |
157 } |
119 endXref(); |
158 endXref(); |
120 } |
159 } |
121 |
160 |
122 void XmlDitaDocVisitor::visit(DocLineBreak *lb) |
161 void XmlDitaDocVisitor::visit(DocLineBreak *lb) |
123 { |
162 { |
|
163 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocLineBreak*)", lb) |
124 if (m_hide){ |
164 if (m_hide){ |
125 return; |
165 return; |
126 } |
166 } |
127 //pushpop("linebreak"); |
167 //pushpop("linebreak"); |
128 //if (lb->parent()->kind() == lb->Kind_Verbatim) { |
168 //if (lb->parent()->kind() == lb->Kind_Verbatim) { |
249 } |
292 } |
250 } |
293 } |
251 |
294 |
252 void XmlDitaDocVisitor::visit(DocAnchor *anc) |
295 void XmlDitaDocVisitor::visit(DocAnchor *anc) |
253 { |
296 { |
|
297 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocAnchor*)", anc) |
254 if (m_hide) { |
298 if (m_hide) { |
255 return; |
299 return; |
256 } |
300 } |
257 xmlElemStack.addAttribute("id", anc->file()+"_1"+anc->anchor()); |
301 xmlElemStack.addAttribute("id", anc->file()+"_1"+anc->anchor()); |
258 //push("anchor", "id", anc->file()+"_1"+anc->anchor()); |
302 //push("anchor", "id", anc->file()+"_1"+anc->anchor()); |
259 //pop("anchor"); |
303 //pop("anchor"); |
260 } |
304 } |
261 |
305 |
262 void XmlDitaDocVisitor::visit(DocInclude *inc) |
306 void XmlDitaDocVisitor::visit(DocInclude *inc) |
263 { |
307 { |
|
308 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visit(DocInclude*)", inc) |
264 if (m_hide) { |
309 if (m_hide) { |
265 return; |
310 return; |
266 } |
311 } |
267 switch(inc->type()) |
312 switch(inc->type()) |
268 { |
313 { |
386 } |
434 } |
387 } |
435 } |
388 |
436 |
389 void XmlDitaDocVisitor::visitPost(DocAutoList *l) |
437 void XmlDitaDocVisitor::visitPost(DocAutoList *l) |
390 { |
438 { |
|
439 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPost(DocAutoList*)", l) |
391 if (l->isEnumList()) { |
440 if (l->isEnumList()) { |
392 visitPostDefault("ol"); |
441 visitPostDefault("ol"); |
393 } else { |
442 } else { |
394 visitPostDefault("ul"); |
443 visitPostDefault("ul"); |
395 } |
444 } |
396 } |
445 } |
397 |
446 |
398 void XmlDitaDocVisitor::visitPre(DocAutoListItem *) |
447 void XmlDitaDocVisitor::visitPre(DocAutoListItem *) |
399 { |
448 { |
|
449 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocAutoListItem*)") |
400 visitPreDefault("li"); |
450 visitPreDefault("li"); |
401 } |
451 } |
402 |
452 |
403 void XmlDitaDocVisitor::visitPost(DocAutoListItem *) |
453 void XmlDitaDocVisitor::visitPost(DocAutoListItem *) |
404 { |
454 { |
|
455 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocAutoListItem*)") |
405 visitPostDefault("li"); |
456 visitPostDefault("li"); |
406 } |
457 } |
407 |
458 |
408 void XmlDitaDocVisitor::visitPre(DocPara *p) |
459 void XmlDitaDocVisitor::visitPre(DocPara *p) |
409 { |
460 { |
410 if (xmlElemStack.isEmpty() || xmlElemStack.peek().getElemName() != "p") { |
461 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocPara*)", p) |
|
462 if (canPushPara()) { |
411 visitPreDefault("p"); |
463 visitPreDefault("p"); |
412 } |
464 } |
413 } |
465 } |
414 |
466 |
415 void XmlDitaDocVisitor::visitPost(DocPara *) |
467 void XmlDitaDocVisitor::visitPost(DocPara *) |
416 { |
468 { |
417 if (!xmlElemStack.isEmpty() && xmlElemStack.peek().getElemName() == "p") { |
469 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocPara*)") |
|
470 if (canPopPara()) { |
418 visitPostDefault("p"); |
471 visitPostDefault("p"); |
419 } |
472 } |
420 } |
473 } |
421 |
474 |
422 void XmlDitaDocVisitor::visitPre(DocRoot *) |
475 void XmlDitaDocVisitor::visitPre(DocRoot *) |
423 {} |
476 { |
|
477 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocRoot*)") |
|
478 } |
424 |
479 |
425 void XmlDitaDocVisitor::visitPost(DocRoot *) |
480 void XmlDitaDocVisitor::visitPost(DocRoot *) |
426 {} |
481 { |
|
482 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocRoot*)") |
|
483 } |
427 |
484 |
428 void XmlDitaDocVisitor::visitPre(DocSimpleSect *s) |
485 void XmlDitaDocVisitor::visitPre(DocSimpleSect *s) |
429 { |
486 { |
|
487 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocSimpleSect*)", s) |
430 if (m_hide) { |
488 if (m_hide) { |
431 return; |
489 return; |
432 } |
490 } |
433 switch(s->type()) |
491 switch(s->type()) |
434 { |
492 { |
443 case DocSimpleSect::Pre: |
501 case DocSimpleSect::Pre: |
444 case DocSimpleSect::Post: |
502 case DocSimpleSect::Post: |
445 case DocSimpleSect::Invar: |
503 case DocSimpleSect::Invar: |
446 case DocSimpleSect::User: |
504 case DocSimpleSect::User: |
447 case DocSimpleSect::Rcs: |
505 case DocSimpleSect::Rcs: |
448 if (xmlElemStack.isEmpty() || xmlElemStack.peek().getElemName() != "p") { |
506 if (canPushPara()) { |
449 push("p"); |
507 push("p"); |
450 } |
508 } |
451 break; |
509 break; |
452 case DocSimpleSect::Note: |
510 case DocSimpleSect::Note: |
453 push("note", "type", "note"); |
511 push("note", "type", "note"); |
502 pop("note"); |
561 pop("note"); |
503 break; |
562 break; |
504 case DocSimpleSect::Unknown: |
563 case DocSimpleSect::Unknown: |
505 break; |
564 break; |
506 default: |
565 default: |
507 if (!xmlElemStack.isEmpty() && xmlElemStack.peek().getElemName() == "p") { |
566 if (canPopPara()) { |
508 pop("p"); |
567 pop("p"); |
509 } |
568 } |
510 break; |
569 break; |
511 } |
570 } |
512 //visitPostDefault("simplesect"); |
571 //visitPostDefault("simplesect"); |
513 } |
572 } |
514 |
573 |
515 void XmlDitaDocVisitor::visitPre(DocTitle *) |
574 void XmlDitaDocVisitor::visitPre(DocTitle *) |
516 { |
575 { |
|
576 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocTitle*)") |
517 if (!xmlElemStack.isEmpty() && xmlElemStack.peek().getElemName() == "concept") { |
577 if (!xmlElemStack.isEmpty() && xmlElemStack.peek().getElemName() == "concept") { |
518 visitPreDefault("title"); |
578 visitPreDefault("title"); |
519 } else { |
579 } else { |
520 if (xmlElemStack.isEmpty() || xmlElemStack.peek().getElemName() != "p") { |
580 if (canPushPara()) { |
521 visitPreDefault("p"); |
581 visitPreDefault("p"); |
522 } |
582 } |
523 visitPreDefault("b"); |
583 visitPreDefault("b"); |
524 } |
584 } |
525 |
585 |
526 } |
586 } |
527 |
587 |
528 void XmlDitaDocVisitor::visitPost(DocTitle *) |
588 void XmlDitaDocVisitor::visitPost(DocTitle *) |
529 { |
589 { |
|
590 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocTitle*)") |
530 if (xmlElemStack.peek().getElemName() == "title") { |
591 if (xmlElemStack.peek().getElemName() == "title") { |
531 visitPostDefault("title"); |
592 visitPostDefault("title"); |
532 } else { |
593 } else { |
533 visitPostDefault("b"); |
594 visitPostDefault("b"); |
534 if (!xmlElemStack.isEmpty() && xmlElemStack.peek().getElemName() == "p") { |
595 if (canPopPara()) { |
535 visitPostDefault("p"); |
596 visitPostDefault("p"); |
536 } |
597 } |
537 } |
598 } |
538 } |
599 } |
539 |
600 |
540 void XmlDitaDocVisitor::visitPre(DocSimpleList *) |
601 void XmlDitaDocVisitor::visitPre(DocSimpleList *) |
541 { |
602 { |
542 visitPreDefault("ul"); |
603 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocSimpleList*)") |
|
604 visitPreDefault("ul"); |
543 } |
605 } |
544 |
606 |
545 void XmlDitaDocVisitor::visitPost(DocSimpleList *) |
607 void XmlDitaDocVisitor::visitPost(DocSimpleList *) |
546 { |
608 { |
547 visitPostDefault("ul"); |
609 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocSimpleList*)") |
|
610 visitPostDefault("ul"); |
548 } |
611 } |
549 |
612 |
550 void XmlDitaDocVisitor::visitPre(DocSimpleListItem *) |
613 void XmlDitaDocVisitor::visitPre(DocSimpleListItem *) |
551 { |
614 { |
552 visitPreDefault("li"); |
615 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocSimpleListItem*)") |
|
616 visitPreDefault("li"); |
553 } |
617 } |
554 |
618 |
555 void XmlDitaDocVisitor::visitPost(DocSimpleListItem *) |
619 void XmlDitaDocVisitor::visitPost(DocSimpleListItem *) |
556 { |
620 { |
557 visitPostDefault("li"); |
621 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocSimpleListItem*)") |
|
622 visitPostDefault("li"); |
558 } |
623 } |
559 |
624 |
560 void XmlDitaDocVisitor::visitPre(DocSection *s) |
625 void XmlDitaDocVisitor::visitPre(DocSection *s) |
561 { |
626 { |
|
627 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocSection*)", s) |
562 // Currently unsupported |
628 // Currently unsupported |
563 #if 0 |
629 #if 0 |
564 if (m_hide) { |
630 if (m_hide) { |
565 return; |
631 return; |
566 } |
632 } |
599 } |
667 } |
600 } |
668 } |
601 |
669 |
602 void XmlDitaDocVisitor::visitPost(DocHtmlList *s) |
670 void XmlDitaDocVisitor::visitPost(DocHtmlList *s) |
603 { |
671 { |
|
672 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPost(DocHtmlList*)", s) |
604 if (s->type()==DocHtmlList::Ordered) { |
673 if (s->type()==DocHtmlList::Ordered) { |
605 visitPostDefault("ol"); |
674 visitPostDefault("ol"); |
606 } else { |
675 } else { |
607 visitPostDefault("ul"); |
676 visitPostDefault("ul"); |
608 } |
677 } |
609 } |
678 } |
610 |
679 |
611 void XmlDitaDocVisitor::visitPre(DocHtmlListItem *) |
680 void XmlDitaDocVisitor::visitPre(DocHtmlListItem *) |
612 { |
681 { |
613 visitPreDefault("li"); |
682 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlListItem*)") |
|
683 visitPreDefault("li"); |
614 } |
684 } |
615 |
685 |
616 void XmlDitaDocVisitor::visitPost(DocHtmlListItem *) |
686 void XmlDitaDocVisitor::visitPost(DocHtmlListItem *) |
617 { |
687 { |
618 visitPostDefault("li"); |
688 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlListItem*)") |
|
689 visitPostDefault("li"); |
619 } |
690 } |
620 |
691 |
621 void XmlDitaDocVisitor::visitPre(DocHtmlDescList *) |
692 void XmlDitaDocVisitor::visitPre(DocHtmlDescList *) |
622 { |
693 { |
623 visitPreDefault("dl"); |
694 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlDescList*)") |
|
695 visitPreDefault("dl"); |
624 } |
696 } |
625 |
697 |
626 void XmlDitaDocVisitor::visitPost(DocHtmlDescList *) |
698 void XmlDitaDocVisitor::visitPost(DocHtmlDescList *) |
627 { |
699 { |
628 visitPostDefault("dl"); |
700 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlDescList*)") |
|
701 visitPostDefault("dl"); |
629 } |
702 } |
630 |
703 |
631 void XmlDitaDocVisitor::visitPre(DocHtmlDescTitle *) |
704 void XmlDitaDocVisitor::visitPre(DocHtmlDescTitle *) |
632 { |
705 { |
|
706 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlDescTitle*)") |
633 if (m_hide) { |
707 if (m_hide) { |
634 return; |
708 return; |
635 } |
709 } |
636 push("dlentry"); |
710 push("dlentry"); |
637 push("dt"); |
711 push("dt"); |
650 // pop("varlistentry"); |
725 // pop("varlistentry"); |
651 } |
726 } |
652 |
727 |
653 void XmlDitaDocVisitor::visitPre(DocHtmlDescData *) |
728 void XmlDitaDocVisitor::visitPre(DocHtmlDescData *) |
654 { |
729 { |
655 push("dd"); |
730 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlDescData*)") |
656 //visitPreDefault("li"); |
731 push("dd"); |
|
732 //visitPreDefault("li"); |
657 } |
733 } |
658 |
734 |
659 void XmlDitaDocVisitor::visitPost(DocHtmlDescData *) |
735 void XmlDitaDocVisitor::visitPost(DocHtmlDescData *) |
660 { |
736 { |
661 pop("dd"); |
737 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlDescData*)") |
662 pop("dlentry"); |
738 pop("dd"); |
663 //visitPostDefault("li"); |
739 pop("dlentry"); |
|
740 //visitPostDefault("li"); |
664 } |
741 } |
665 |
742 |
666 void XmlDitaDocVisitor::visitPre(DocHtmlTable *t) |
743 void XmlDitaDocVisitor::visitPre(DocHtmlTable *t) |
667 { |
744 { |
668 if (m_hide) { |
745 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocHtmlTable*)", t) |
669 return; |
746 if (m_hide) { |
670 } |
747 return; |
|
748 } |
|
749 #if DITA_SIMPLETABLE_SUPPORT |
671 push("simpletable"); |
750 push("simpletable"); |
|
751 #endif |
672 #if 0 |
752 #if 0 |
673 AttributeMap attrs; |
753 AttributeMap attrs; |
674 QString vR, vC; |
754 QString vR, vC; |
675 vR.setNum(t->numRows()); |
755 vR.setNum(t->numRows()); |
676 attrs["rows"] = vR; |
756 attrs["rows"] = vR; |
680 #endif |
760 #endif |
681 } |
761 } |
682 |
762 |
683 void XmlDitaDocVisitor::visitPost(DocHtmlTable *) |
763 void XmlDitaDocVisitor::visitPost(DocHtmlTable *) |
684 { |
764 { |
|
765 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlTable*)") |
|
766 #if DITA_SIMPLETABLE_SUPPORT |
685 visitPostDefault("simpletable"); |
767 visitPostDefault("simpletable"); |
|
768 #endif |
686 } |
769 } |
687 |
770 |
688 void XmlDitaDocVisitor::visitPre(DocHtmlRow *) |
771 void XmlDitaDocVisitor::visitPre(DocHtmlRow *) |
689 { |
772 { |
|
773 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlRow*)") |
690 // FIXME look ahead to first cell |
774 // FIXME look ahead to first cell |
691 // if isHeading is true do |
775 // if isHeading is true do |
692 // visitPreDefault("sthead"); |
776 // visitPreDefault("sthead"); |
693 // else |
777 // else |
694 visitPreDefault("strow"); |
778 visitPreDefault("strow"); |
695 } |
779 } |
696 |
780 |
697 void XmlDitaDocVisitor::visitPost(DocHtmlRow *) |
781 void XmlDitaDocVisitor::visitPost(DocHtmlRow *) |
698 { |
782 { |
699 visitPostDefault("strow"); |
783 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlRow*)") |
|
784 visitPostDefault("strow"); |
700 } |
785 } |
701 |
786 |
702 void XmlDitaDocVisitor::visitPre(DocHtmlCell *c) |
787 void XmlDitaDocVisitor::visitPre(DocHtmlCell *c) |
703 { |
788 { |
|
789 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocHtmlCell*)", c) |
704 visitPreDefault("stentry"); |
790 visitPreDefault("stentry"); |
705 #if 0 |
791 #if 0 |
706 if (m_hide) { |
792 if (m_hide) { |
707 return; |
793 return; |
708 } |
794 } |
714 #endif |
800 #endif |
715 } |
801 } |
716 |
802 |
717 void XmlDitaDocVisitor::visitPost(DocHtmlCell *c) |
803 void XmlDitaDocVisitor::visitPost(DocHtmlCell *c) |
718 { |
804 { |
|
805 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPost(DocHtmlCell*)", c) |
719 visitPostDefault("stentry"); |
806 visitPostDefault("stentry"); |
720 } |
807 } |
721 |
808 |
722 void XmlDitaDocVisitor::visitPre(DocHtmlCaption *) |
809 void XmlDitaDocVisitor::visitPre(DocHtmlCaption *) |
723 { |
810 { |
724 // Caption is unsupported |
811 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocHtmlCaption*)") |
|
812 // Caption is unsupported |
725 } |
813 } |
726 |
814 |
727 void XmlDitaDocVisitor::visitPost(DocHtmlCaption *) |
815 void XmlDitaDocVisitor::visitPost(DocHtmlCaption *) |
728 { |
816 { |
729 // Caption is unsupported |
817 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlCaption*)") |
|
818 // Caption is unsupported |
730 } |
819 } |
731 |
820 |
732 void XmlDitaDocVisitor::visitPre(DocInternal *) |
821 void XmlDitaDocVisitor::visitPre(DocInternal *) |
733 { |
822 { |
734 //visitPreDefault("internal"); |
823 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocInternal*)") |
|
824 //visitPreDefault("internal"); |
735 } |
825 } |
736 |
826 |
737 void XmlDitaDocVisitor::visitPost(DocInternal *) |
827 void XmlDitaDocVisitor::visitPost(DocInternal *) |
738 { |
828 { |
|
829 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocInternal*)") |
739 //visitPostDefault("internal"); |
830 //visitPostDefault("internal"); |
740 } |
831 } |
741 |
832 |
742 void XmlDitaDocVisitor::visitPre(DocHRef *href) |
833 void XmlDitaDocVisitor::visitPre(DocHRef *href) |
743 { |
834 { |
744 push("xref", "href", href->url()); |
835 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocHRef*)", href) |
|
836 push("xref", "href", href->url()); |
745 } |
837 } |
746 |
838 |
747 void XmlDitaDocVisitor::visitPost(DocHRef *) |
839 void XmlDitaDocVisitor::visitPost(DocHRef *) |
748 { |
840 { |
749 visitPostDefault("xref"); |
841 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHRef*)") |
|
842 visitPostDefault("xref"); |
750 } |
843 } |
751 |
844 |
752 void XmlDitaDocVisitor::visitPre(DocHtmlHeader *header) |
845 void XmlDitaDocVisitor::visitPre(DocHtmlHeader *header) |
753 { |
846 { |
|
847 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocHtmlHeader*)", header) |
754 visitPreDefault("b"); |
848 visitPreDefault("b"); |
755 #if 0 |
849 #if 0 |
756 QString hdgLevel; |
850 QString hdgLevel; |
757 hdgLevel.setNum(header->level()); |
851 hdgLevel.setNum(header->level()); |
758 push("heading", "level", hdgLevel); |
852 push("heading", "level", hdgLevel); |
759 #endif |
853 #endif |
760 } |
854 } |
761 |
855 |
762 void XmlDitaDocVisitor::visitPost(DocHtmlHeader *) |
856 void XmlDitaDocVisitor::visitPost(DocHtmlHeader *) |
763 { |
857 { |
764 visitPostDefault("b"); |
858 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocHtmlHeader*)") |
|
859 visitPostDefault("b"); |
765 } |
860 } |
766 |
861 |
767 void XmlDitaDocVisitor::visitPre(DocImage *img) |
862 void XmlDitaDocVisitor::visitPre(DocImage *img) |
768 { |
863 { |
|
864 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocImage*)", img) |
769 // Currently unsupported |
865 // Currently unsupported |
770 #if 0 |
866 #if 0 |
771 AttributeMap imgAttrs; |
867 AttributeMap imgAttrs; |
772 // First the image type |
868 // First the image type |
773 switch(img->type()) |
869 switch(img->type()) |
839 #endif |
937 #endif |
840 } |
938 } |
841 |
939 |
842 void XmlDitaDocVisitor::visitPost(DocDotFile *) |
940 void XmlDitaDocVisitor::visitPost(DocDotFile *) |
843 { |
941 { |
844 // visitPostDefault("dotfile"); |
942 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocDotFile*)") |
|
943 //visitPostDefault("dotfile"); |
845 } |
944 } |
846 |
945 |
847 void XmlDitaDocVisitor::visitPre(DocLink *lnk) |
946 void XmlDitaDocVisitor::visitPre(DocLink *lnk) |
848 { |
947 { |
849 if (m_hide) { |
948 // The result of a \link...\endlink command |
850 return; |
949 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocLink*)", lnk) |
851 } |
950 if (m_hide) { |
852 if (lnk->getDefinition() != 0) { |
951 return; |
|
952 } |
|
953 if (0) {//lnk->getDefinition() != 0) { |
|
954 //printf("XmlDitaDocVisitor calling startLink() DocLink [name]=`%s'\n", lnk->getDefinition()->qualifiedName().data()); |
853 startLink("", lnk->getDefinition()->qualifiedName(), ""); |
955 startLink("", lnk->getDefinition()->qualifiedName(), ""); |
854 } else { |
956 } else { |
855 startLink(lnk->ref(),lnk->file(),lnk->anchor()); |
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()); |
856 } |
960 } |
857 } |
961 } |
858 |
962 |
859 void XmlDitaDocVisitor::visitPost(DocLink *) |
963 void XmlDitaDocVisitor::visitPost(DocLink *) |
860 { |
964 { |
|
965 // The result of a \link...\endlink command |
|
966 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocLink*)") |
861 if (m_hide) { |
967 if (m_hide) { |
862 return; |
968 return; |
863 } |
969 } |
864 endLink(); |
970 endLink(); |
865 } |
971 } |
866 |
972 |
867 void XmlDitaDocVisitor::visitPre(DocRef *ref) |
973 void XmlDitaDocVisitor::visitPre(DocRef *ref) |
868 { |
974 { |
|
975 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocRef*)", ref) |
869 if (m_hide) { |
976 if (m_hide) { |
870 return; |
977 return; |
871 } |
978 } |
872 if (!ref->file().isEmpty()) { |
979 if (!ref->file().isEmpty()) { |
873 if (ref->getDefinition() != 0) { |
980 if (ref->getDefinition() != 0) { |
|
981 //printf("XmlDitaDocVisitor calling startLink() DocRef [name]=`%s'\n", ref->getDefinition()->qualifiedName().data()); |
874 startLink("", ref->getDefinition()->qualifiedName(), ""); |
982 startLink("", ref->getDefinition()->qualifiedName(), ""); |
875 } else { |
983 } else { |
|
984 //printf("XmlDitaDocVisitor calling startLink() DocRef [file]=`%s'\n", ref->file().data()); |
876 startLink(ref->ref(), ref->file(), ref->anchor()); |
985 startLink(ref->ref(), ref->file(), ref->anchor()); |
877 } |
986 } |
878 } |
987 } |
879 if (!ref->hasLinkText()) { |
988 if (!ref->hasLinkText()) { |
880 write(ref->targetTitle()); |
989 write(ref->targetTitle()); |
881 } |
990 } |
882 } |
991 } |
883 |
992 |
884 void XmlDitaDocVisitor::visitPost(DocRef *ref) |
993 void XmlDitaDocVisitor::visitPost(DocRef *ref) |
885 { |
994 { |
|
995 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPost(DocRef*)", ref) |
886 if (m_hide) { |
996 if (m_hide) { |
887 return; |
997 return; |
888 } |
998 } |
889 if (!ref->file().isEmpty()) { |
999 if (!ref->file().isEmpty()) { |
890 endLink(); |
1000 endLink(); |
892 write(" "); |
1002 write(" "); |
893 } |
1003 } |
894 |
1004 |
895 void XmlDitaDocVisitor::visitPre(DocSecRefItem *ref) |
1005 void XmlDitaDocVisitor::visitPre(DocSecRefItem *ref) |
896 { |
1006 { |
|
1007 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocSecRefItem*)", ref) |
897 if (m_hide) { |
1008 if (m_hide) { |
898 return; |
1009 return; |
899 } |
1010 } |
900 push("li", "id", ref->file()+"_1"+ref->anchor()); |
1011 push("li", "id", ref->file()+"_1"+ref->anchor()); |
901 } |
1012 } |
902 |
1013 |
903 void XmlDitaDocVisitor::visitPost(DocSecRefItem *) |
1014 void XmlDitaDocVisitor::visitPost(DocSecRefItem *) |
904 { |
1015 { |
905 visitPostDefault("li"); |
1016 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocSecRefItem*)") |
|
1017 visitPostDefault("li"); |
906 } |
1018 } |
907 |
1019 |
908 void XmlDitaDocVisitor::visitPre(DocSecRefList *) |
1020 void XmlDitaDocVisitor::visitPre(DocSecRefList *) |
909 { |
1021 { |
910 visitPreDefault("ul"); |
1022 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocSecRefList*)") |
|
1023 visitPreDefault("ul"); |
911 } |
1024 } |
912 |
1025 |
913 void XmlDitaDocVisitor::visitPost(DocSecRefList *) |
1026 void XmlDitaDocVisitor::visitPost(DocSecRefList *) |
914 { |
1027 { |
915 visitPostDefault("ul"); |
1028 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocSecRefList*)") |
|
1029 visitPostDefault("ul"); |
916 } |
1030 } |
917 |
1031 |
918 void XmlDitaDocVisitor::visitPre(DocParamSect *s) |
1032 void XmlDitaDocVisitor::visitPre(DocParamSect *s) |
919 { |
1033 { |
|
1034 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocParamSect*)", s) |
920 m_insideParamlist = TRUE; |
1035 m_insideParamlist = TRUE; |
921 if (m_hide) { |
1036 if (m_hide) { |
922 return; |
1037 return; |
923 } |
1038 } |
924 switch(s->type()) { |
1039 switch(s->type()) { |
998 #endif |
1115 #endif |
999 } |
1116 } |
1000 |
1117 |
1001 void XmlDitaDocVisitor::visitPost(DocParamList *) |
1118 void XmlDitaDocVisitor::visitPost(DocParamList *) |
1002 { |
1119 { |
|
1120 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocParamList*)") |
1003 if (m_hide) { |
1121 if (m_hide) { |
1004 return; |
1122 return; |
1005 } |
1123 } |
1006 pop("parameterdescription"); |
1124 pop("parameterdescription"); |
1007 pop("parameteritem"); |
1125 pop("parameteritem"); |
1008 } |
1126 } |
1009 |
1127 |
1010 void XmlDitaDocVisitor::visitPre(DocXRefItem *x) |
1128 void XmlDitaDocVisitor::visitPre(DocXRefItem *x) |
1011 { |
1129 { |
|
1130 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocXRefItem*)", x) |
1012 if (m_hide) { |
1131 if (m_hide) { |
1013 return; |
1132 return; |
1014 } |
1133 } |
1015 // \deprecated commands result in DocXRefItem |
1134 // \deprecated commands result in DocXRefItem |
1016 // with "deprecated" as the filename |
1135 // with "deprecated" as the filename |
1017 if (x->file() == "deprecated"){ |
1136 if (x->file() == "deprecated"){ |
1018 // Fall through to start new paragraph for deprecated description |
1137 // Fall through to start new paragraph for deprecated description |
1019 }else |
1138 } else { |
1020 { |
1139 QString hrefStr = x->file(); |
1021 push("xref", "id", x->file()+"_1"+x->anchor()); |
1140 hrefStr.append(Config_getString("XML_DITA_EXTENSION")); |
|
1141 hrefStr.append("#"); |
|
1142 hrefStr.append(x->file()); |
|
1143 hrefStr.append("_1"); |
|
1144 hrefStr.append(x->anchor()); |
|
1145 push("xref", "href", hrefStr); |
1022 write(x->title()); |
1146 write(x->title()); |
1023 } |
1147 } |
1024 #if 0 |
1148 #if 0 |
1025 push("xrefsect", "id", x->file()+"_1"+x->anchor()); |
1149 push("xrefsect", "id", x->file()+"_1"+x->anchor()); |
1026 pushpop("xreftitle", x->title()); |
1150 pushpop("xreftitle", x->title()); |
1045 #endif |
1170 #endif |
1046 } |
1171 } |
1047 |
1172 |
1048 void XmlDitaDocVisitor::visitPre(DocInternalRef *ref) |
1173 void XmlDitaDocVisitor::visitPre(DocInternalRef *ref) |
1049 { |
1174 { |
1050 if (m_hide) { |
1175 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocInternalRef*)", ref) |
1051 return; |
1176 if (m_hide) { |
1052 } |
1177 return; |
|
1178 } |
|
1179 //printf("XmlDitaDocVisitor calling startLink() DocInternalRef [file]=`%s'\n", ref->file().data()); |
1053 startLink(0, ref->file(), ref->anchor()); |
1180 startLink(0, ref->file(), ref->anchor()); |
1054 } |
1181 } |
1055 |
1182 |
1056 void XmlDitaDocVisitor::visitPost(DocInternalRef *) |
1183 void XmlDitaDocVisitor::visitPost(DocInternalRef *) |
1057 { |
1184 { |
|
1185 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocXRefItem*)") |
1058 if (m_hide) { |
1186 if (m_hide) { |
1059 return; |
1187 return; |
1060 } |
1188 } |
1061 endLink(); |
1189 endLink(); |
1062 write(" "); |
1190 write(" "); |
1063 } |
1191 } |
1064 |
1192 |
1065 void XmlDitaDocVisitor::visitPre(DocCopy *c) |
1193 void XmlDitaDocVisitor::visitPre(DocCopy *c) |
1066 { |
1194 { |
|
1195 DITA_DOC_VISITOR_TRACE("XmlDitaDocVisitor::visitPre(DocCopy*)", c) |
1067 // Currently unsupported |
1196 // Currently unsupported |
1068 #if 0 |
1197 #if 0 |
1069 if (m_hide) { |
1198 if (m_hide) { |
1070 return; |
1199 return; |
1071 } |
1200 } |
1073 #endif |
1202 #endif |
1074 } |
1203 } |
1075 |
1204 |
1076 void XmlDitaDocVisitor::visitPost(DocCopy *) |
1205 void XmlDitaDocVisitor::visitPost(DocCopy *) |
1077 { |
1206 { |
|
1207 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocCopy*)") |
1078 // visitPostDefault("copydoc"); |
1208 // visitPostDefault("copydoc"); |
1079 } |
1209 } |
1080 |
1210 |
1081 void XmlDitaDocVisitor::visitPre(DocText *) |
1211 void XmlDitaDocVisitor::visitPre(DocText *) |
1082 {} |
1212 { |
|
1213 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPre(DocText*)") |
|
1214 } |
1083 |
1215 |
1084 void XmlDitaDocVisitor::visitPost(DocText *) |
1216 void XmlDitaDocVisitor::visitPost(DocText *) |
1085 {} |
1217 { |
|
1218 DITA_DOC_VISITOR_TRACE_NOARG("XmlDitaDocVisitor::visitPost(DocText*)") |
|
1219 } |
1086 |
1220 |
1087 void XmlDitaDocVisitor::startXref(const QString &href,const QString &text) |
1221 void XmlDitaDocVisitor::startXref(const QString &href,const QString &text) |
1088 { |
1222 { |
|
1223 #ifndef DITA_DOT_HACK_REMOVE_XREFS |
1089 push("xref", "href", href); |
1224 push("xref", "href", href); |
|
1225 #endif |
1090 write(text); |
1226 write(text); |
1091 } |
1227 } |
1092 |
1228 |
1093 void XmlDitaDocVisitor::endXref() |
1229 void XmlDitaDocVisitor::endXref() |
1094 { |
1230 { |
|
1231 #ifndef DITA_DOT_HACK_REMOVE_XREFS |
1095 pop("xref"); |
1232 pop("xref"); |
|
1233 #endif |
1096 } |
1234 } |
1097 |
1235 |
1098 void XmlDitaDocVisitor::startLink(const QString &ref,const QString &file,const QString &anchor) |
1236 void XmlDitaDocVisitor::startLink(const QString &ref,const QString &file,const QString &anchor) |
1099 { |
1237 { |
1100 AttributeMap refAttrs; |
1238 AttributeMap refAttrs; |
|
1239 /* |
|
1240 printf("XmlDitaDocVisitor::startLink(): ref: \"%s\", file: \"%s\", anchor: \"%s\"\n", |
|
1241 ref.data(), |
|
1242 file.data(), |
|
1243 anchor.data()); |
|
1244 */ |
1101 if (!anchor.isEmpty()) { |
1245 if (!anchor.isEmpty()) { |
1102 refAttrs["href"] = file+"_1"+anchor; |
1246 refAttrs["href"] = file+".xml#"+file+"_1"+anchor; |
1103 } else { |
1247 } else { |
1104 refAttrs["href"] = file; |
1248 refAttrs["href"] = file+".xml#"+file; |
1105 } |
1249 } |
|
1250 #ifndef DITA_DOT_HACK_REMOVE_XREFS |
1106 push("xref", refAttrs); |
1251 push("xref", refAttrs); |
|
1252 #endif |
1107 #if 0 |
1253 #if 0 |
1108 AttributeMap refAttrs; |
1254 AttributeMap refAttrs; |
1109 if (!anchor.isEmpty()) { |
1255 if (!anchor.isEmpty()) { |
1110 refAttrs["refid"] = file+"_1"+anchor; |
1256 refAttrs["refid"] = file+"_1"+anchor; |
1111 refAttrs["kindref"] = "member"; |
1257 refAttrs["kindref"] = "member"; |
1217 // TODO positional option |
1365 // TODO positional option |
1218 return ""; |
1366 return ""; |
1219 } |
1367 } |
1220 } |
1368 } |
1221 |
1369 |
|
1370 /// Returns true if it is OK to write a para element |
|
1371 bool XmlDitaDocVisitor::canPushPara() const |
|
1372 { |
|
1373 if (!xmlElemStack.isEmpty()) { |
|
1374 QString e = xmlElemStack.peek().getElemName(); |
|
1375 if (e == "xref" || e == "p") { |
|
1376 return false; |
|
1377 } |
|
1378 } |
|
1379 return true; |
|
1380 } |
|
1381 |
|
1382 bool XmlDitaDocVisitor::canPopPara() const |
|
1383 { |
|
1384 if (!xmlElemStack.isEmpty() && xmlElemStack.peek().getElemName() == "p") { |
|
1385 return true; |
|
1386 } |
|
1387 return false; |
|
1388 } |
|
1389 |
1222 /** Default treatment of a post traversal visit, this just |
1390 /** Default treatment of a post traversal visit, this just |
1223 pushes a single element with no attributes. */ |
1391 pushes a single element with no attributes. */ |
1224 void XmlDitaDocVisitor::visitPreDefault(const QString& elem) |
1392 void XmlDitaDocVisitor::visitPreDefault(const QString& elem) |
1225 { |
1393 { |
1226 if (m_hide) { |
1394 if (m_hide) { |