StimVinsh / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

Inline loop with @before-row #97

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello!

There are no possibility to use inline loops with directive @before-row. I 
expect that the code:

   <table>
      <row>
         <cell>
            @before-row#foreach($d in $developers)
               @before-row#foreach($r in $d.roles)
                  $d.name : $r.name
               @after-row#end
            @after-row#end
          </cell>
         .
         .
         .
      </row>
   </table>

will be transformed to following(prepared for template engine):

   <table>
      @before-row#foreach($d in $developers)
         @before-row#foreach($r in $d.roles)
            <row>
               <cell>
                  $d.name : $r.name
               </cell>
               .
               .
               .
            </row>
         @after-row#end
      @after-row#end
   </table>

In TransformedBufferedDocumentContentHandler I found that inner loop overrides 
the outer one:

   elementInfo.setContentBeforeStartTagElement(before);

instead of it You can use code like:

   String fullBefore = elementInfo.getContentBeforeStartTagElement();
   if (StringUtils.isEmpty(fullBefore)) {
      fullBefore = "";
   }
   fullBefore = fullBefore + " " + before;
   elementInfo.setContentBeforeStartTagElement(fullBefore);

I tried to use my own version of DocXBufferedDocumentContentHandler (through 
the extension of DocxPreprocessor) with overrided methods
processScriptAfter... But this way is a bit ugly(alsо I need to rewrite method 
getIndexOfScript that is private)....

Adding support for nested loops are easier 
TransformedBufferedDocumentContentHandler.

Original issue reported on code.google.com by roman.de...@gmail.com on 3 Apr 2012 at 9:45

GoogleCodeExporter commented 8 years ago
Hi,

Could you explain what you wish to generate and if you explain me your code 
changes, I could perhaps integrate it?

Regards Angelo

Original comment by angelo.z...@gmail.com on 3 Apr 2012 at 9:49

GoogleCodeExporter commented 8 years ago
Yes.
Changes in TransformedBufferedDocumentContentHandler (v0.9.6).

 elementInfo.setContentBeforeStartTagElement( before );
to:
  String existedBefore = elementInfo.getStartTagElement().getBefore();
  elementInfo.setContentBeforeStartTagElement((StringUtils.isEmpty(existedBefore) ? "" : existedBefore) + " " + before);

  elementInfo.setContentAfterEndTagElement( after );
to:
  String existedAfter = elementInfo.getEndTagElement().getAfter();
  elementInfo.setContentAfterEndTagElement(after + " " + (StringUtils.isEmpty(existedAfter) ? "" : existedAfter));

Template(it works after changes) and expected result are in attachment.

Original comment by roman.de...@gmail.com on 3 Apr 2012 at 11:26

Attachments:

GoogleCodeExporter commented 8 years ago
Hi Roman,

Ok I understand the problem. I will fix that as soon as possible.

Regards Angelo

Original comment by angelo.z...@gmail.com on 3 Apr 2012 at 2:53

GoogleCodeExporter commented 8 years ago
Hi Roman,

Problem should be fixed (I have commited my work on Git  and it will be 
available on 0.9.8). Please test this fix and tell me if it's OK. Fix was done 
on the BufferedTagElement class.

Regards Angelo

Original comment by angelo.z...@gmail.com on 4 Apr 2012 at 8:45

GoogleCodeExporter commented 8 years ago

Original comment by angelo.z...@gmail.com on 4 Apr 2012 at 8:45

GoogleCodeExporter commented 8 years ago

Original comment by angelo.z...@gmail.com on 28 Sep 2012 at 9:31

GoogleCodeExporter commented 8 years ago
Hello !

Could it possible to do something like :
Developer 1            Role 1
                       Role 2
-----------------
Developer 2            Role 1
-----------------
Developer 3            Role 1
                       Role 2

Thank you.

Original comment by xiro.p...@gmail.com on 22 Aug 2015 at 6:10

GoogleCodeExporter commented 8 years ago
Please create your issues at https://github.com/opensagres/xdocreport/issues

Original comment by angelo.z...@gmail.com on 23 Aug 2015 at 12:22