bellakhalAmir / xdocreport

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

Include a set of IImageProvider (Lists, Maps...) placed in different parts in a DOCX #408

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
- What steps will reproduce the problem?

I've a set of Ports. Each port may have from 1 to N Catalogs. Each catalog have 
a HashMap (it may be changed to List) of IImageProvider.

I don't know whether is it possible to implement it or no. Here they are the 
example classes:

--------------------------------------------------------------------------
//The list of ports seems like:
List<Port> ports = ....

public class Port{

      private String descriptionPort;
      private String title;
      private String detail;
      private IImageProvider image1;
      private IImageProvider image2;
      private ArrayList<Catalogue> listCatalogue;
      .......
}

public class Catalogue{

      private String description;
      private String detail;
      private String duration;
      /* Formerly I had this one (it worked) instead of logos:
       * private IImageProvider logo;
       */
      //new: multiple images per catalogue
      private HashMap<String, IImageProvider> logos;
      private Number logosCount;
      ..........
}
--------------------------------------------------------------------------
So, when it comes to the creation of the DOCX Report:
--------------------------------------------------------------------------
InputStream in = fileTemp.getBinaryStream();
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(in,   
TemplateEngineKind.Velocity);
FieldsMetadata fieldsMetadata = report.createFieldsMetadata();
fieldsMetadata.load("ports", Port.class);
fieldsMetadata.addFieldAsImage("photoPort1", "p.Image1");
fieldsMetadata.addFieldAsImage("photoPort2", "p.Image2");
/*Formerly it worked this one when having a unique Image per Catalogue:
 *fieldsMetadata.addFieldAsImage("photoCat", "cat.Logo.");
 */
report.setFieldsMetadata(fieldsMetadata);
IContext context = report.createContext();
context.put("ports", ports);
report.process(context, outputStream); //ignore outputStream
--------------------------------------------------------------------------
Therefore, I wonder how can I add Images from the Hash of a Set of Catalogues. 
Its my idea supported by XDocReport? May I have to get out of my mind the 
List/Map idea and create single attributes within the class (for each image, an 
attribute)? Or should I Create a separate Class in which the unique attribute 
remains the IImageProvider (that way the method getImage() would work as the 
attribute may be private IImageProvider image)?

- What is the expected output? What do you see instead?
I do not know how to implement it. I'm stuck.

- What version of the product are you using? On what operating system?
WinXP with Latest version of XDocReport.

- Please provide any additional information below.
I think with the information above is enough. Anyway, should you require 
further explanation tell me, please.

Original issue reported on code.google.com by captai...@gmail.com on 11 Jun 2014 at 1:35

GoogleCodeExporter commented 8 years ago
It was a long time that I have developped image feature, but I'm not sure that 
it's possible to use Map for IImageProvider like you wish to do.

I suggest you to create several setter of image provider in your Catalog class 
like you have done with your Port class (image1, image2).

Original comment by angelo.z...@gmail.com on 12 Jun 2014 at 12:13

GoogleCodeExporter commented 8 years ago
Thank you Angelo. I'm trying it out this morning.

Original comment by captai...@gmail.com on 12 Jun 2014 at 7:17

GoogleCodeExporter commented 8 years ago
Can I close this issue?

Original comment by angelo.z...@gmail.com on 7 Aug 2014 at 6:48

GoogleCodeExporter commented 8 years ago
Yes

Original comment by captai...@gmail.com on 9 Aug 2014 at 7:39

GoogleCodeExporter commented 8 years ago
Ok Thank's.

Original comment by angelo.z...@gmail.com on 9 Aug 2014 at 8:47

GoogleCodeExporter commented 8 years ago
cleanup

Original comment by pascal.leclercq on 10 Oct 2014 at 7:37