alex
|
Posted: May 09, 2010 03:08 by alex
|
|
Hi everybody, if you load and save a file created with OpenOffice Writer 3.2 it becomes corrupt and OpenOffice tries to repair it next time. The same jobs works great with a file created with OO Writer 2.4.1. What can I do? Currently I use AODL v1.4.0.3. Here the sample code: public void CorruptOdt() { IList<string> templates = new List<string> { @"C:\Temp\blank2_4_1.odt", @"C:\Temp\blank3_2.odt" }; foreach (string template in templates) { using (TextDocument doc = new TextDocument()) { doc.Load(template); string newPath = Path.Combine(Path.GetDirectoryName(template), Path.GetFileNameWithoutExtension(template) + "_new") + Path.GetExtension(template); doc.SaveTo(newPath); } } } Thank you very much Alex |
Files created with OpenOffice 3 become corrupt
11 posts
» Share this
Replies: 10 - Last Post: August 12, 2010 15:40
by: Ralf
by: Ralf
showing 1 - 11 of 11
|
Darius Damalakas
|
Posted: May 10, 2010 09:22 by Darius Damalakas
|
| Hm... Probably the internal xml is mixed-up for some reason. I think you should raise a defect for this, but currently there are no active developers for this project, so dont' expect immediate help. |
alex
|
Posted: May 10, 2010 21:03 by alex
|
|
It's a pity. With this issue AODL is totally useless for me although it's a great library and I like it very much. Should I use the issue tracker of OpenOffice.org (http://qa.openoffice.org/issue_handling/pre_submission.html)? Are there any plans to push this project forward? How can I help? Do you need more developers or any other help? |
|
Darius Damalakas
|
Posted: May 14, 2010 08:16 by Darius Damalakas
|
|
>Are there any plans to push this project forward? How can I help? Do you need more developers or any other help? Currently I am the only more or less active participant. However, i have changed my employer so now this project is of little interest to myself. The best help would be that someone would volunteer to be a supporter/developer/project leader for AODL. I will help anybody and everybody to understand the library and start working on it. |
Sly17
|
Posted: May 10, 2010 11:28 by Sly17
|
|
Same pb for me... I just "load", and "saveto" an odt document, and my file become corrupted... :S I use AODL.dll 1.4.0.3 With AODL.dll 1.3.0.0 it's the same ! May be the open office version ? I continue to investigate, but help appreciated ! ![]() Edit : First investigation Step 1: I have a file created with the New() function ==> this file is good (we can call it RefFile) I have a file created with the .Load(_FilePath) function ==> this file is corrupted (we can call it BadFile) Step 2: I change the extension of those files in .zip and unzip all If I copy RefFile/META-INF/manifest.xml onto BadFile/META-INF/manifest.xml and RefFile/content.xml onto BadFile/content.xml, I zip my BadFile and change extension in .odt and all is good ! I continue to see if I can have something programmatically ! Edit : Second investigation Ok... let's go ! (note: my dev are in C# .Net) You have a file .odt. If you load it and SaveTo(), then it become corrupted. If you only load it and stop your process (debug mode) after the following lines : TextDocument doc = new TextDocument(); doc.Load(_FilePath); you have a temporary folder that you can zip, and then transform in .odt. The result is a good file. Then the problem is really in the "SaveTo()" function Little (but not terrible) patch: TextDocument doc = new TextDocument();
doc.Load(_FilePath);
TextDocument docRef = new TextDocument();
docRef.New();
doc.DocumentManifest = docRef.DocumentManifest;
XmlNode versionNode = doc.XmlDoc.SelectSingleNode("//office:document-content/@office:version", doc.NamespaceManager);
if (versionNode != null)
versionNode.Value = "1.0";
doc.SaveTo(_FilePath);
doc.Dispose();And your final file is not corrupted, but downgraded in OpenOffice file version 1.0 ! Pb is that SaveTo() function is not upgraded for the last OpenOffice format !! |
alex
|
Posted: May 10, 2010 21:22 by alex
|
|
Thank you very much for your help. There a good notices for further bug fixing. I have not tested your sample yet but it looks like same data are invalid and OpenOffice 3 seems to be much more stricter. I opened the corrupted file in OpenOffice 2.4.1 and everything is fine (indeed OO 2.4.1 throws a warning that this file was created with a newer version and there might be some features which do not work). Nevertheless your solution is a kind of workaround and it does not fit my needs. I'll need AODL for mail merge and will do it on my own now. This works very well for the moment. |
joan
|
Posted: June 02, 2010 13:31 by joan
|
|
Hi, I believe the issue is in the mimetype file. It has an CR/LF at the end, which apparently OO doesn't like. Here are the changes I made: in file : \AODL\Document\Export\OpenDocument\OpenDocumentTextExporter.cs 1. mimetyp to mimetype. //find (line 154): WriteMimetypeFile(exportDir+@"\mimetyp"); //replace with : WriteMimetypeFile(exportDir+@"\mimetype"); 2. WriteLine to Write.
//find (line 275) :
sw.WriteLine("application/vnd.oasis.opendocument.text");
//replace with:
sw.Write("application/vnd.oasis.opendocument.text");
// do the same for opendocument.spreadsheet (line 279)
Tested with Go-oo. |
|
Darius Damalakas
|
Posted: June 09, 2010 08:37 by Darius Damalakas
|
| I have applied the patch, the changes are in the tip |
alex
|
Posted: July 13, 2010 22:22 by alex
|
|
Wow, that solved the issue. Thank you very much! But now I have another one if I just instantiate a Frame object without using it.
public void BugFrame()
{
IList<string> templates = new List<string>
{
@"C:\Temp\empty2_4_1.odt",
@"C:\Temp\empty3_2.odt"
};
const string image = @"C:\Temp\test.jpg";
foreach (string template in templates)
{
using (TextDocument doc = new TextDocument())
{
doc.Load(template);
// This causes an error for documents created with OpenOffice 3.2
// OpenOffice 2.4.1 works without an error.
Frame frame = new Frame(doc, "frame1", "graphic1", image);
string newPath = Path.Combine(Path.GetDirectoryName(template),
Path.GetFileNameWithoutExtension(template) + "_new") +
Path.GetExtension(template);
doc.SaveTo(newPath);
}
}
}
Any ideas? Thanks Alex |
Ralf
|
Posted: August 12, 2010 15:32 by Ralf
|
|
Hi everybody! I've got a similar problem: I try to create an odt file with AODL that contains several paragraphs and images. When I create the file as a new file, it works without any problem. But when I load a file (created with OpenOffice 3.2), insert an image and save it, OpenOpffice says that the file is corrupted and must be repaired. The loaded file just contains two images in the page header. I insert the image by adding a paragraph, adding a frame to the paragraph and adding an image to the frame. The anchor type of the frame is "as-char". Here's the XML Code of the paragraph containing the image:
<text:p text:style-name="Style12" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
<draw:frame text:anchor-type="as-char" draw:style-name="Style13" draw:name="image" svg:height="7.5cm" svg:width="10cm" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0">
<draw:image xlink:href="Pictures/09b15387-8307-490f-a3e9-6b8dbe3c8f9dEnte.jpg" xlink:type="standard" xlink:show="embed" xlink:actuate="onLoad" xmlns:xlink="http://www.w3.org/1999/xlink" />
</draw:frame>
</text:p>
I tried to remove this paragraph manually from the content.xml file to see if this causes the error, but then OpenOffice wasn't even more able to repair the file. (Maybe I do not understand ODF good enough for manual edits...) Do you have any idea / hint what I'm doing wrong? Or is it another bug in the lib? Ralf |
Ralf
|
Posted: August 12, 2010 15:40 by Ralf
|
|
Sorry for the double post. But when I saw this post in the forum context, some content was cut off on the right side so I added some linebreaks manualla... -------------------------------------------------------------------------------------------------------- Hi everybody! I've got a similar problem: I try to create an odt file with AODL that contains several paragraphs and images. When I create the file as a new file, it works without any problem. But when I load a file (created with OpenOffice 3.2), insert an image and save it, OpenOpffice says that the file is corrupted and must be repaired. The loaded file just contains two images in the page header. I insert the image by adding a paragraph, adding a frame to the paragraph and adding an image to the frame. The anchor type of the frame is "as-char". Here's the XML Code of the paragraph containing the image:
<text:p text:style-name="Style12"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
<draw:frame text:anchor-type="as-char" draw:style-name="Style13"
draw:name="image" svg:height="7.5cm" svg:width="10cm"
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0">
<draw:image xlink:href="Pictures/09b15387-8307-490f-a3e9-6b8dbe3c8f9dEnte.jpg"
xlink:type="standard" xlink:show="embed" xlink:actuate="onLoad"
xmlns:xlink="http://www.w3.org/1999/xlink" />
</draw:frame>
</text:p>
I tried to remove this paragraph manually from the content.xml file to see if this causes the error, but then OpenOffice wasn't even more able to repair the file. (Maybe I do not understand ODF good enough for manual edits...) Do you have any idea / hint what I'm doing wrong? Or is it another bug in the lib? Ralf |
showing 1 - 11 of 11
Replies: 10 - Last Post: August 12, 2010 15:40
by: Ralf
by: Ralf




