Bug 51971 - Writing custom properties doesn't work for DOCX and XLSX formats.
Summary: Writing custom properties doesn't work for DOCX and XLSX formats.
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.7-dev
Hardware: PC Windows XP
: P2 enhancement with 1 vote (vote)
Target Milestone: ---
Assignee: POI Developers List
: 61547 (view as bug list)
Depends on: 60977
  Show dependency tree
Reported: 2011-10-05 21:30 UTC by Sérgio Teixeira
Modified: 2019-05-22 15:53 UTC (History)
2 users (show)

new classes to provide the described enhancement (44.31 KB, patch)
2011-10-05 22:13 UTC, Sérgio Teixeira
Details | Diff
updated the patch according to previous indications (14.91 KB, patch)
2011-10-09 21:32 UTC, Sérgio Teixeira
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sérgio Teixeira 2011-10-05 21:30:44 UTC
With this enhancement I was able to provide methods to insert custom properties in DOCX and XLSX file types. In addition these classes also include the methods already working for DOC and XLS files. Powerpoint case is not handled. In addition in case the properties are being used in the body text of the DOCX document, the properties are also updated in the text. This propagation funcionality has not been treted for DOC, XLS and XLSX formats (I don't even know if it is possible to provide this kind of functionality in Excel. Again, Powerpoint hasn't got any of the previous enhancements. So to summarize it should be possible for:
DOCX -> update or insert custom properties; also propagate the updated propeties into the body text.
XLSX -> update or insert custom properties.
XLS -> update or insert custom properties.
DOC -> update or insert custom properties.
Comment 1 Nick Burch 2011-10-05 21:37:23 UTC
Any chance you could upload the patch for this?
Comment 2 Sérgio Teixeira 2011-10-05 22:02:10 UTC
(In reply to comment #1)
> Any chance you could upload the patch for this?

Hi Nick,

I'd gladly do so, but my authentication doesn't work when svn client (Tortoise) asks for it. Have you got any indication? This is my first commit with the project...

Comment 3 Sérgio Teixeira 2011-10-05 22:06:53 UTC
(In reply to comment #1)
> Any chance you could upload the patch for this?

I just saw I got this message in permissions tab:

You have the following permission bits set on your account:
canconfirm 	Can confirm a bug.
editbugs 	Can edit all aspects of any bug.

So I guess I can't commit due to permission restrictions or something related.
Comment 4 Nick Burch 2011-10-05 22:07:39 UTC
You won't be able to commit, instead please run a "svn diff" and post the patch
for review. (Add it as an attachment to this bug)
Comment 5 Sérgio Teixeira 2011-10-05 22:13:27 UTC
Created attachment 27702 [details]
new classes to provide the described enhancement

Source code patch only. Needs some review. I left a few comments tha could be deleted and I'm not sure anbout the logging...
Comment 6 Sérgio Teixeira 2011-10-05 22:17:47 UTC
Let me know what you think of the patch. If necessary I can spend a couple of hours during this weekend to fine-tune according to indications you might provide.
Comment 7 Nick Burch 2011-10-05 22:27:20 UTC
If it were me, I'd probably have this all work on an open document, rather than copying files about the place. That way, someone could do

   open file
   make changes
   have custom properties tweaked
   save where they want

Rather than having to do the custom properties in a whole separate step

I'd probably also be tempted to try to push a lot of the logic into POIDocument / POIXMLDocument, and then have a hook point where specific file formats can do special things (eg word update fields in the document). That may help reduce code duplication too, and keep things working in a common way
Comment 8 Sérgio Teixeira 2011-10-09 21:32:36 UTC
Created attachment 27748 [details]
updated the patch according to previous indications

Here's my patch updated. I've done it according to your indications regading Docx and Xlsx; I've also changed logging to be close to the POI standards (I hope). Main classes afected are: POIXMLDocument and XWPFDocument. I didn't have time to go for the Doc and Xls cases, because the code I have uses slightly different hooks to start processing the files. If you see that changing POIDocument class is a major addition let me know, I'll try to find some more time for that upgrade. But I couldn't get to the POIDocument derived class that handles the Doc file (I think I found the one for Xls though).

Any comments are most welcome. Sorry for having done only for the Docx and Xlsx but it seems to me that those 2 are the most critical for the project I guess and Doc and Xls already have examples etc.

Comment 9 Dominik Stadler 2017-12-30 15:32:43 UTC
*** Bug 61547 has been marked as a duplicate of this bug. ***