Ignore:
Timestamp:
11/30/10 11:37:47 (14 years ago)
Author:
zeiss
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfHtmlFormatterVisitor.java

    r42 r43  
    1010import org.eclipse.xtext.parsetree.NodeUtil; 
    1111 
     12import de.ugoe.cs.swe.bnftools.ebnf.DefinitionList; 
    1213import de.ugoe.cs.swe.bnftools.ebnf.EtsiBnf; 
    1314import de.ugoe.cs.swe.bnftools.ebnf.Import; 
     
    1516import de.ugoe.cs.swe.bnftools.ebnf.RuleReference; 
    1617import de.ugoe.cs.swe.bnftools.ebnf.SectionHeading; 
     18import de.ugoe.cs.swe.bnftools.ebnf.SingleDefinition; 
    1719import de.ugoe.cs.swe.bnftools.ebnf.StringRule; 
    1820 
     
    193195                        isParagraphOpen = false; 
    194196                } 
    195                  
     197                openParagraph(); 
     198 
    196199                if ((ruleSpacingStack != null) && (!ruleSpacingStack.empty())) { 
    197200                        newLineOffsetCounter = ruleSpacingStack.peek(); 
     
    215218                metaText("</span>"); 
    216219        } 
     220         
     221        protected void wrap() { 
     222                if ((config.isWrapAfterThreshold()) && (newLineOffsetCounter > config.getWrapThreshold())) { 
     223                        char last = buf.toString().charAt(buf.toString().length()-1); 
     224                        if (!((last == '(' || last == '[' || last == '{' ))) { 
     225                                newLine(); 
     226                                newLine(); 
     227                                if (ruleSpacingStack.size() > 1) 
     228                                        spaces(ruleSpacingStack.peek() + 1); 
     229                                else 
     230                                        spaces(ruleSpacingStack.peek()); 
     231                        } 
     232                } 
     233        } 
     234         
     235        private void closeOpenParagraph() { 
     236                if (isParagraphOpen) { 
     237                        metaText("\n</p>\n"); 
     238                        isParagraphOpen = false; 
     239                } 
     240        } 
     241 
     242        private void openParagraph() { 
     243                if (!isParagraphOpen) { 
     244                        metaText("\n<p class=PL style='mso-pagination:widow-orphan lines-together;page-break-after: avoid'>\n"); 
     245                        isParagraphOpen = true; 
     246                } 
     247        } 
    217248        // ----------------------------------------------------------------------------- 
    218249         
     
    223254                originalTextNoWhitespaces = originalText.replaceAll("[ \t\n\r]", ""); 
    224255                 
    225                 textTransformed("grammar " + node.getName(),""); 
     256                textTransformed("grammar " + node.getName(), ""); 
    226257                if (node.getType() != null) 
    227                         textTransformed(node.getType(),""); 
    228                 textTransformed(";",""); 
    229                 metaText("<body lang=EN-US link=blue vlink=purple style='tab-interval:14.15pt'>\n"); 
    230                 metaText("<div class=WordSection1>\n"); 
     258                        textTransformed(node.getType(), ""); 
     259                textTransformed(";", ""); 
     260//              metaText("<body lang=EN-US link=blue vlink=purple style='tab-interval:14.15pt'>"); 
     261//              metaText("<div class=WordSection1>"); 
     262//              System.out.println("call!!!"); 
    231263                 
    232264//              newLine(); 
     
    235267         
    236268        protected void visitAfter(EtsiBnf node) { 
     269                closeOpenParagraph(); 
     270                 
    237271                metaText("</div>\n"); 
    238272                metaText("</body>\n"); 
     
    268302 
    269303        protected void visitAfter(SectionHeading node) { 
    270         } 
    271          
     304//              newLine(); 
     305                closeOpenParagraph(); 
     306        } 
     307 
    272308        protected void visitBefore(RuleReference node) { 
    273309                wrap(); 
    274310                 
    275                 metaText("<u><span style='color:blue'><a href=\"#T" + node.getRuleref().getName() + "\">"); 
    276                 text(node.getRuleref().getName()); 
    277                 metaText("</a></span></u>"); 
     311                metaText("<u><span style='color:blue'><a href=\"#T" + node.getRuleref().getName().replaceAll("[ \t\n\r]","") + "\">"); 
     312                textTransformed(node.getRuleref().getName(), node.getRuleref().getName().replaceAll("[ \t\n\r]", "") + "</a></span></u>"); 
    278313        } 
    279314 
     
    283318        protected void visitBefore(Rule node) { 
    284319//              if (lastWasSectionHeading) 
    285                         newLine(); 
     320                 
     321                newLine(); 
    286322                 
    287323                lastWasSectionHeading=false; 
     
    292328                        text(node.getRulenumber() + ". "); 
    293329 
    294                 metaText("<span lang=EN-GB style='mso-no-proof:no'>\n<a name=\"#T" + node.getName() + "\">"); 
     330                metaText("<span lang=EN-GB style='mso-no-proof:no'>"); 
     331                metaText("<a name=\"T" + node.getName() + "\">"); 
    295332                textTransformed(node.getName(), node.getName().replaceAll("[ \t\r\n]", "")); 
    296333                metaText("</a>"); 
Note: See TracChangeset for help on using the changeset viewer.