zkh152 / xdocreport

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

Replace MACROBUTTON with MERGEFIELD and call preprocessor again #219

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Replaced field name "MACROBUTTON ##612993016421## name" with "MERGEFIELD 
${field59}"

What is the expected output? What do you see instead?
Usual working of XDocReport with MERGEFIELD - replace whole field with content

What version of the product are you using? On what operating system?
latest
win7

Please provide any additional information below.
Maybe it's not working like this? Maybe I have to call original preprocessors 
again? And can you help me to know, where can I change xml-structure of 
document? Can I do it in MacroButtonNamePreprocessor?

Original issue reported on code.google.com by MrSo...@gmail.com on 25 Jan 2013 at 6:56

GoogleCodeExporter commented 9 years ago
If I understand you have a docx with MACROBUTTON and you want :

1) preprocess MACROBUTTON to MERGEFIELD (with MacroButtonNamePreprocessor).
2) preprocess MERGEFILED to text (original preprocessor).

the problem is that you have just addPreprocesosr method and you can just add 
at the end of the original preprocessor a new preprocessor. So in your case you 
have 

1) preprocess MERGEFILED to text (original preprocessor) => do nothing because 
you have not MERGEFIELD.
2) preprocess MACROBUTTON to MERGEFIELD (with MacroButtonNamePreprocessor).

I have never tested, but you can try that : 
--------------------------------------------------------
report.removeAllPreprocessors();
//: 1) add macrobuttonname preprocessor
report.addPreprocessor(.. //
// 2) add original preprocessor (see 
http://code.google.com/p/xdocreport/source/browse/document/fr.opensagres.xdocrep
ort.document.docx/src/main/java/fr/opensagres/xdocreport/document/docx/DocxRepor
t.java method registerPreprocessors).
--------------------------------------------------------

But if I have understood you have MACROBUTTON with checkbox, list. How to 
manage that with MERGEFIELD? 

I understand that your user uses MACROBUTTON, but you and me have spent a lot 
of time  with your MACROBUTONNAME topic. Using MERGEFIELD is standard and you 
have a Macro  Word which help you a lot to design your report. I suggest you 
really to speak with your users about using MERGEFIELD.

Regards Angelo

Original comment by angelo.z...@gmail.com on 25 Jan 2013 at 8:49

GoogleCodeExporter commented 9 years ago
In my case checkboxes is only some digit in other font. It is only "J" or "R" 
in font "Windings 2", but I have some problems, when this digits separated with 
"newline". Can original preprocessors replace MERGEFILED with text separated 
with newlines?

And one more questing:
Now source starting with
---------------------------------
        IXDocReport report = super.loadReport(reportId, registry, request);

        MacroButtonNamePreprocessor preprocessor = new MacroButtonNamePreprocessor();
        report.addPreprocessor(DocxConstants.WORD_DOCUMENT_XML_ENTRY, preprocessor);
---------------------------------

How it will be when macrobuttonname preprocessor will be the first?
---------------------------------
IXDocReport report = super.loadReport(reportId, registry, request);
report.removeAllPreprocessors();
MacroButtonNamePreprocessor preprocessor = new MacroButtonNamePreprocessor();
report.addPreprocessor(DocxConstants.WORD_DOCUMENT_XML_ENTRY, preprocessor);
report.registerPreprocessors();
---------------------------------

Or I have to repeat whole registerPreprocessors code?

Original comment by MrSo...@gmail.com on 25 Jan 2013 at 9:41

GoogleCodeExporter commented 9 years ago
> Can original preprocessors replace MERGEFILED with text separated with 
newlines?
As I said you, the more complex development was for the preprocessing and 
preprocessor which transform MERGEFILED to text manages a lot of complex case 
like splitted MERGEFILED, etc

That's why I suggested you to use MERGEFIELD and not MACROBUTONNAME. 

You cannot call report.registerPreprocessors(), because this method is 
protected.

> Or I have to repeat whole registerPreprocessors code?
Yes like I have explained you. I know it's not clean code, but perhaps 
XDocReport API should change to add preprocesor on a given index. 

Original comment by angelo.z...@gmail.com on 25 Jan 2013 at 9:50

GoogleCodeExporter commented 9 years ago
I did like this:
--------------------------------
        IXDocReport report = super.loadReport(reportId, registry, request);

        report.removeAllPreprocessors();

        MacroButtonNamePreprocessor preprocessor = new MacroButtonNamePreprocessor();
        report.addPreprocessor(DocxConstants.WORD_DOCUMENT_XML_ENTRY, preprocessor);

        report.addPreprocessor( DocxConstants.WORD_STYLES_XML_ENTRY, DocxStylesPreprocessor.INSTANCE );
        report.addPreprocessor( DocxConstants.WORD_FOOTNOTES_XML_ENTRY, DocxFootnotesPreprocessor.INSTANCE );
        report.addPreprocessor( DocxConstants.WORD_ENDNOTES_XML_ENTRY, DocxEndnotesPreprocessor.INSTANCE );
        report.addPreprocessor( DocxConstants.WORD_DOCUMENT_XML_ENTRY, DocxPreprocessor.INSTANCE );
        report.addPreprocessor( DocxConstants.WORD_HEADER_XML_ENTRY, DocxPreprocessor.INSTANCE );
        report.addPreprocessor( DocxConstants.WORD_FOOTER_XML_ENTRY, DocxPreprocessor.INSTANCE );
        report.addPreprocessor( DocxConstants.CONTENT_TYPES_XML_ENTRY, DocxContentTypesPreprocessor.INSTANCE );
        report.addPreprocessor( DocxConstants.WORD_RELS_XMLRELS_XML_ENTRY, DocxDocumentXMLRelsPreprocessor.INSTANCE );
        report.addPreprocessor( DocxConstants.WORD_NUMBERING_XML_ENTRY, DocxNumberingPreprocessor.INSTANCE );

----------------------------

And I got interesting output: there is only checkboxes =) Looks like there is 
problem with encoding again =((( I think so because checkboxes is only a digits 
"J" or "R" in other font.

Original comment by MrSo...@gmail.com on 25 Jan 2013 at 9:59

GoogleCodeExporter commented 9 years ago
Sorry I cannot help you more. To understand the problem, debugging is the only 
mean. Your case is specific and I have no time to investigate it.

Original comment by angelo.z...@gmail.com on 25 Jan 2013 at 10:03

GoogleCodeExporter commented 9 years ago
no, it is not encoding problems... there is some only numbers content

field0 => 01.01.2013
field1 => 00
field2 => 00
field3 => 01.01.2013
field4 => 23
field5 => 59
field6 => 31.12.2013

Original comment by MrSo...@gmail.com on 25 Jan 2013 at 10:05

GoogleCodeExporter commented 9 years ago
Looks like MERGEFIELD just disappeared. Maybe I need some text field which will 
be next to MERGEFIELD?

Original comment by MrSo...@gmail.com on 25 Jan 2013 at 10:08

GoogleCodeExporter commented 9 years ago
I close this issue because it's a specific case for XDocReport.

Original comment by angelo.z...@gmail.com on 28 May 2013 at 7:11

GoogleCodeExporter commented 9 years ago
cleanup

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