[Hint] How did I fix my ODT file

Discuss the word processor
User avatar
RoryOF
Moderator
Posts: 34669
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Hint] How did I fix my ODT file

Post by RoryOF »

Depending on a lot of things, the first thing to try is to make (on a working machine) a bootable linux USB key; if the broken computer has a functioning motherboard, it may then be booted from the linux USB key and the files in question copied to another USB key. If that does not work because the motherboard is broken, the next step is to remove the hard disk and put it in a working desktop.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Hint] How did I fix my ODT file

Post by John_Ha »

tazzy1981 wrote:Can anyone help me fix these files and maybe tell me how, so if I find more files I can reconstruct them myself?
I have never before seen a file like your two files.

They are not .xls or .xlsx files - they are flat ASCII files but strangely they are full of the " U " character so they cannot contain any user information, not even in encrypted form. I cannot understand how AOO could have created these files. When opened in a Hex editor the both look like this:
Clipboard01.png
You could see [Tutorial] How to find and un-delete AOO temporary files for detailed instructions on how to

a) use Previous Versions (W7 and later) to recover previous versions of the file (is there something similar on MacOS and Linux?);

b) recover your file as it was when you last opened or saved it, or as it was when it was last saved with AutoRecovery;

c) find previous versions of the file in the folder it is located in, but which have since been deleted;

d) un-delete the temporary files AOO wrote while you were editing the file, and then deleted. This will recover your file as it was when you last opened or you last saved it.

All .odt, .doc, .docx, .xls and .xlsx files are actually ZIP files and can be unzipped. For example this is what a .odt file looks like when unzipped:
Clipboard02.png
You should ask someone with good computer skills to analyse all the files on the disk. Some files and/or folders may be set to Hidden in which case you need to make them visible by Start > Control Panel > Folder options > View > Advanced settings ..., where you tick Show hidden files and folders.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
User avatar
RoryOF
Moderator
Posts: 34669
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Hint] How did I fix my ODT file

Post by RoryOF »

I confirm what John_Ha says: they are both flat files full of U's. They suggest to me that a hard disk failure occurred, and that a recovery program tried to clean the damaged area of the hard disk, but this is only a guess.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Mic90
Posts: 2
Joined: Thu Oct 03, 2019 3:15 pm

Re: [Hint] How did I fix my ODT file

Post by Mic90 »

Hello! can someone here help me fix this file? same READ ERROR, I will be forever grateful as I worked on tis essay for the past 5 hours before loosing it all.
Attachments
Essay Michela Filzi 4.odt
(71.82 KiB) Downloaded 5448 times
Open Office 4.1.3 on MacOS Sierra Version 10.12.6
User avatar
floris v
Volunteer
Posts: 4437
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: [Hint] How did I fix my ODT file

Post by floris v »

@Mic90: there is no need to post twice, and certainly if you do it, post a link to your other topic to prevent that the discussion splits over several threads and that people waste their time. Thank you.
 Edit: viewtopic.php?f=5&t=99550 
Solution offered there.
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
User avatar
RoryOF
Moderator
Posts: 34669
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Hint] How did I fix my ODT file

Post by RoryOF »

Please check the attached file and ensure content and formatting are as you require.
Attachments
Essay Michela Filzi 4_repaired.odt
(71.2 KiB) Downloaded 5473 times
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Medivh
Posts: 2
Joined: Thu Oct 10, 2019 1:50 pm

Re: [Hint] How did I fix my ODT file

Post by Medivh »

Hello,

new here, I found this page after a long desperate search and trying for hours with recovery etc. Got a file prepared in June, now finally need it but it seems corrupted.

Not sure if I'm right here with this file, and I understand if nothing can be done, but I would appreciate if someone could give it a shot.
Sorry , had to attach it as a rar. since its 5mb so exceeds the limitation. (Lots of inserted pictures, but if only the text can be recovered I'm just fine)


Any help appreciated!
Attachments
NewStoryboardEtc.rar
(411 Bytes) Downloaded 5463 times
OpenOffice 4.1.5 on Windows 10
User avatar
RoryOF
Moderator
Posts: 34669
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Hint] How did I fix my ODT file

Post by RoryOF »

A quick examination suggests that your file is completely corrupt. Wait for confirmation from another before panicking.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Zizi64
Volunteer
Posts: 11382
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: [Hint] How did I fix my ODT file

Post by Zizi64 »

I cannot open neither the unpacked .ods file, nor unpack the zip archive of the ODF fileformat...
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
F3K Total
Volunteer
Posts: 1039
Joined: Fri Dec 16, 2011 8:20 pm

Re: [Hint] How did I fix my ODT file

Post by F3K Total »

Medivh wrote:Sorry , had to attach it as a rar. since its 5mb so exceeds the limitation. (Lots of inserted pictures, but if only the text can be recovered I'm just fine)
That does not meat the file you loaded up:
C1.PNG
C1.PNG (2.75 KiB) Viewed 194224 times
it's 411 Bytes, not 5 Megabytes, means 1/12756 of the filesize expected. Even rar will never compress something by a factor of 12756!!!
R
  • MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
  • my current system
  • Windows 10 AOO, LOLinux Mint AOO, LO
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Hint] How did I fix my ODT file

Post by John_Ha »

In fact your 411 byte RAR file is a compression of NewStoryboardEtc.ods which is 5.11 MBytes. The file is full of NUL characters which is why it compresses so well. There is no user data in your file.
Clipboard01.png
See [Tutorial] How to find and un-delete AOO temporary files for detailed instructions on how to

a) use Previous Versions (W7 and later) to recover previous versions of the file (is there something similar on MacOS and Linux?);

b) recover your file as it was when you last opened or saved it, or as it was when it was last saved with AutoRecovery;

c) find previous versions of the file in the folder it is located in, but which have since been deleted;

d) un-delete the temporary files AOO wrote while you were editing the file, and then deleted. This will recover your file as it was when you last opened or you last saved it.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Medivh
Posts: 2
Joined: Thu Oct 10, 2019 1:50 pm

Re: [Hint] How did I fix my ODT file

Post by Medivh »

Thank you everyone for trying.

I was already surprised that the file compressed down t only about 400 byte rar file.
Thank you John for posting the Link, I tried the said guide before as well.

Can't be helped. But I apppreaciate the input, thank you all!
OpenOffice 4.1.5 on Windows 10
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Hint] How did I fix my ODT file

Post by John_Ha »

Keme gave me an idea at Re: one of Calc file broken and RoryOF found me the source.

While I have no serious coding experience I think the NULLs we see in broken .odt files are probably written by a routine called Deflater.cxx in the package bit of AOO which writes files at [Apache-SVN]/openoffice/trunk/main/package/source/package/zipapi/Deflater.cxx. The source is as below. Deflater is the routine which Zips the file.

Note that line 52 appears to set something (the memory for the file? the disk space to be used for the file?) to zeros or NULLs. I think these are the NULLs we see in the broken .odt files. Line 51 is a comment explaining that NULLs are about to be written.

Code: Select all

51 	        /* Memset it to 0...sets zalloc/zfree/opaque to NULL */
52 	        memset (pStream, 0, sizeof(*pStream));
My hypothesis is therefore that AOO executes line 52 and the NULLs are written. Then, at some point after line 52 is executed, but before the data is written, AOO receives a shutdown? hibernate? command from Windows because the user closes the laptop lid. Normally, AOO would execute a graceful shutdown/hibernate where AOO would prevent the shutdown/hibernate until all data had been written and the AOO program had reached a stable place at which it could safely be paused. However, I suspect that AOO mishandles this shutdown/hibernate command and does not do a graceful shutdown instead allowing the shutdown to happen before AOO has finished writing the file and made AOO safe. The file is therefore full of nulls.

I have done some testing where I have found that AOO does slightly different things depending on when a laptop lid is closed which supports my suspicion.

Code: Select all

/**************************************************************
2 	 * 
3 	 * Licensed to the Apache Software Foundation (ASF) under one
4 	 * or more contributor license agreements.  See the NOTICE file
5 	 * distributed with this work for additional information
6 	 * regarding copyright ownership.  The ASF licenses this file
7 	 * to you under the Apache License, Version 2.0 (the
8 	 * "License"); you may not use this file except in compliance
9 	 * with the License.  You may obtain a copy of the License at
10 	 * 
11 	 *   http://www.apache.org/licenses/LICENSE-2.0
12 	 * 
13 	 * Unless required by applicable law or agreed to in writing,
14 	 * software distributed under the License is distributed on an
15 	 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 	 * KIND, either express or implied.  See the License for the
17 	 * specific language governing permissions and limitations
18 	 * under the License.
19 	 * 
20 	 *************************************************************/
21 	
22 	
23 	
24 	// MARKER(update_precomp.py): autogen include statement, do not remove
25 	#include "precompiled_package.hxx"
26 	#include <Deflater.hxx>
27 	#ifndef _ZLIB_H
28 	#ifdef SYSTEM_ZLIB
29 	#include <zlib.h>
30 	#else
31 	#include <external/zlib/zlib.h>
32 	#endif
33 	#endif
34 	#include <com/sun/star/packages/zip/ZipConstants.hpp>
35 	#include <string.h> // for memset
36 	
37 	using namespace com::sun::star::packages::zip::ZipConstants;
38 	using namespace com::sun::star;
39 	
40 	/** Provides general purpose compression using the ZLIB compression
41 	 * library.
42 	 */
43 	
44 	Deflater::~Deflater(void)
45 	{
46 	        end();  
47 	}
48 	void Deflater::init (sal_Int32 nLevelArg, sal_Int32 nStrategyArg, sal_Bool bNowrap)
49 	{
50 	        pStream = new z_stream;
51 	        /* Memset it to 0...sets zalloc/zfree/opaque to NULL */
52 	        memset (pStream, 0, sizeof(*pStream));
53 	
54 	        switch (deflateInit2(pStream, nLevelArg, Z_DEFLATED, bNowrap? -MAX_WBITS : MAX_WBITS,
55 	                                DEF_MEM_LEVEL, nStrategyArg))
56 	        {
57 	                case Z_OK:
58 	                        break;
59 	                case Z_MEM_ERROR:
60 	                        delete pStream;
61 	                        break;
62 	                case Z_STREAM_ERROR:
63 	                        delete pStream;
64 	                        break;
65 	                default:
66 	                         break;
67 	        }
68 	}
69 	
70 	Deflater::Deflater(sal_Int32 nSetLevel, sal_Bool bNowrap)
71 	: bFinish(sal_False)
72 	, bFinished(sal_False)
73 	, bSetParams(sal_False)
74 	, nLevel(nSetLevel)
75 	, nStrategy(DEFAULT_STRATEGY)
76 	, nOffset(0)
77 	, nLength(0)
78 	{
79 	        init(nSetLevel, DEFAULT_STRATEGY, bNowrap);
80 	}
81 	
82 	sal_Int32 Deflater::doDeflateBytes (uno::Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength)
83 	{
84 	        sal_Int32 nResult;
85 	        if (bSetParams)
86 	        {
87 	                pStream->next_in   = (unsigned char*) sInBuffer.getConstArray() + nOffset;
88 	                pStream->next_out  = (unsigned char*) rBuffer.getArray()+nNewOffset;
89 	                pStream->avail_in  = nLength;
90 	                pStream->avail_out = nNewLength;
91 	
92 	#if defined SYSTEM_ZLIB || !defined ZLIB_PREFIX
93 	                nResult = deflateParams(pStream, nLevel, nStrategy);
94 	#else
95 	                nResult = z_deflateParams(pStream, nLevel, nStrategy);
96 	#endif
97 	                switch (nResult)
98 	                {
99 	                        case Z_OK:
100 	                                bSetParams = sal_False;
101 	                                nOffset += nLength - pStream->avail_in;
102 	                                nLength = pStream->avail_in;
103 	                                return nNewLength - pStream->avail_out;
104 	                        case Z_BUF_ERROR:
105 	                                bSetParams = sal_False;
106 	                                return 0;
107 	                        default:
108 	                                return 0;
109 	                }
110 	        }
111 	        else
112 	        {
113 	                pStream->next_in   = (unsigned char*) sInBuffer.getConstArray() + nOffset;
114 	                pStream->next_out  = (unsigned char*) rBuffer.getArray()+nNewOffset;
115 	                pStream->avail_in  = nLength;
116 	                pStream->avail_out = nNewLength;
117 	
118 	#if defined SYSTEM_ZLIB || !defined ZLIB_PREFIX
119 	                nResult = deflate(pStream, bFinish ? Z_FINISH : Z_NO_FLUSH);
120 	#else
121 	                nResult = z_deflate(pStream, bFinish ? Z_FINISH : Z_NO_FLUSH);
122 	#endif
123 	                switch (nResult)
124 	                {
125 	                        case Z_STREAM_END:
126 	                                bFinished = sal_True;
127 	                        case Z_OK:
128 	                                nOffset += nLength - pStream->avail_in;
129 	                                nLength = pStream->avail_in;
130 	                                return nNewLength - pStream->avail_out;
131 	                        case Z_BUF_ERROR:
132 	                                bSetParams = sal_False;
133 	                                return 0;
134 	                        default:
135 	                                return 0;
136 	                }
137 	        }
138 	}
139 	
140 	void SAL_CALL Deflater::setInputSegment( const uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength ) 
141 	{
142 	    OSL_ASSERT( !(nNewOffset < 0 || nNewLength < 0 || nNewOffset + nNewLength > rBuffer.getLength()));
143 	        
144 	    sInBuffer = rBuffer;
145 	    nOffset = nNewOffset;
146 	    nLength = nNewLength;
147 	}
148 	void SAL_CALL Deflater::setLevel( sal_Int32 nNewLevel ) 
149 	{
150 	        if ((nNewLevel < 0 || nNewLevel > 9) && nNewLevel != DEFAULT_COMPRESSION)
151 	        {
152 	                // do error handling
153 	        }
154 	        if (nNewLevel != nLevel)
155 	        {
156 	                nLevel = nNewLevel;
157 	                bSetParams = sal_True;
158 	        }
159 	}
160 	sal_Bool SAL_CALL Deflater::needsInput(  ) 
161 	{
162 	        return nLength <=0;
163 	}
164 	void SAL_CALL Deflater::finish(  ) 
165 	{
166 	        bFinish = sal_True;
167 	}
168 	sal_Bool SAL_CALL Deflater::finished(  ) 
169 	{
170 	        return bFinished;
171 	}
172 	sal_Int32 SAL_CALL Deflater::doDeflateSegment( uno::Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength ) 
173 	{
174 	    OSL_ASSERT( !(nNewOffset < 0 || nNewLength < 0 || nNewOffset + nNewLength > rBuffer.getLength()));
175 	    return doDeflateBytes(rBuffer, nNewOffset, nNewLength);
176 	}
177 	sal_Int32 SAL_CALL Deflater::getTotalIn(  ) 
178 	{
179 	        return pStream->total_in;
180 	}
181 	sal_Int32 SAL_CALL Deflater::getTotalOut(  ) 
182 	{
183 	        return pStream->total_out;
184 	}
185 	void SAL_CALL Deflater::reset(  ) 
186 	{
187 	#if defined SYSTEM_ZLIB || !defined ZLIB_PREFIXB
188 	        deflateReset(pStream);
189 	#else
190 	        z_deflateReset(pStream);
191 	#endif
192 	        bFinish = sal_False;
193 	        bFinished = sal_False;
194 	        nOffset = nLength = 0;
195 	}
196 	void SAL_CALL Deflater::end(  ) 
197 	{
198 	        if (pStream != NULL)
199 	        {
200 	#if defined SYSTEM_ZLIB || !defined ZLIB_PREFIX
201 	                deflateEnd(pStream);
202 	#else
203 	                z_deflateEnd(pStream);
204 	#endif
205 	                delete pStream;
206 	        }
207 	        pStream = NULL;
208 	}
I realise this is unlikely ever to be fixed with the lack of AOO development but thought it worthwhile to record my thoughts just in case. It supports our idea that too quick shutting of a laptop lid could be causing problem and also explains why it is fairly infrequent - it has to occur at exactly the wrong time to catch the fault in the AOO coding.

I have never seen a report of LibreOffice causing this corruption so I think that LO may have fixed the bug.

I could be completely wrong ...
Last edited by John_Ha on Mon Nov 23, 2020 9:45 pm, edited 2 times in total.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
User avatar
RoryOF
Moderator
Posts: 34669
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Hint] How did I fix my ODT file

Post by RoryOF »

I doubt that there is any possible fix for this; an interrupt calling for a closedown can be inhibited (locked out, or postponed in software), but an actual physical loss of power, be it by power failure or by forced switch off of the power, can only be managed with an Uninterruptible Power Supply (UPS), the weight (and extra expense of which) prevent its inclusion in a laptop, and indeed, in most desktop computers.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Hint] How did I fix my ODT file

Post by John_Ha »

John_Ha wrote:I realise this is unlikely ever to be fixed with the lack of AOO development ...
I had a thought how my hypothesis could be tested.

Someone with coding experience could code a "pause" immediately after the nulls are written so AOO pauses after the nulls have been written but before the content gets written. If the tester then issued a sleep, hibernate or power off command, or shut the laptop lid, AOO should prevent the sleep or hibernate, and prevent the power off from happening, because AOO has a file open which has not been written.

On restarting the PC the file should be found to be full of nulls.
Last edited by John_Ha on Mon Nov 16, 2020 2:11 pm, edited 1 time in total.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Ensaf
Posts: 1
Joined: Wed Jun 10, 2020 5:19 pm

Re: [Hint] How did I fix my ODT file

Post by Ensaf »

I need your Urgent help

I am a Freelancer Journalist and I was using OpenOffice 3.1.4 until 08 June 2020. All my writing are and were in Farsi / Persian, as you may say.
All my writings were automatically saved as ODT format.
I was working on a new project that i need to read and refer to a lot books as my resources. I need to do search on E-book to go on faster. I tried some new software on my desktop that runs by Windows 10.
usually i do not turn off my pc. but on the June 08 I need to restart. Then I find out that All of my written files are working as before just the last one that I was working on. It is encrypted.
I am not familiar with formats or file codes. I just do open the Text Write and change to Farsi/Persian alphabets and do my job and just push Save button when i need. It does automatically do saving in the same format as always do.
I tried to open and recover it in different ways for example in Western Europe series, Unicodes, Arabics too but they did not worked for me.
Would you please help me.
Ensaf
hedayatensafali!gmail.com
oPENoFFICE 4.1.7 On Windows 10 home
FJCC
Moderator
Posts: 9316
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Hint] How did I fix my ODT file

Post by FJCC »

I seems your file has been corrupted and cannot be recovered. You can post it here for someone to look at it but I am not hopeful. To upload a file, click Post Reply and look for the Upload Attachment tab just below the box where you type a response.
There is also a tutorial here that explains about recovering temporary versions of files.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Hint] How did I fix my ODT file

Post by John_Ha »

Ensaf wrote:usually i do not turn off my pc. but on the June 08 I need to restart.
If
  • you had one or more files (fred.odt, tom.odt etc) open in AOO/LO and
  • the PC got restarted without your saving these files first
you should find that your files fred.odt and tom.odt are still on disk and as they were before you started editing. Also, the temporary file(s) AOO/LO wrote when you opened each file should still be there.

All edits since the file was opened will have been lost because they were stored in memory. They had not been saved to disk by your saving the file; nor by AutoRecovery as it was not enabled. As Always create a backup copy was not enabled there is no backup of the previously saved version.

See Why is my file full of #####? for a discussion.

[Tutorial] How to find and un-delete AOO temporary files gives detailed instructions on how to

a) use Previous Versions (W7 and later) to recover previous versions of the file (is there something similar on MacOS and Linux?);

b) recover your file as it was when you last opened or saved it, or as it was when it was last saved with AutoRecovery;

c) find previous versions of the file in the folder it is located in, but which have since been deleted;

d) find any temporary files AOO wrote while you were editing the file but which have not yet been deleted;

e) un-delete the temporary files AOO wrote while you were editing the file, and then deleted. d) and e) will recover your file as it was when you last opened or you last saved it.

If you cannot follow the instructions ask someone with more PC skills to help you. Act quickly - the longer you wait the more likely any temporary files are to be deleted.

If you have some files which you can upload, upload them here (128 kb max) or to a file share website like Dropbox, Google Drive or MediaFire etc. If the file has confidential information send it to me - I have sent you an email with my ID.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
User avatar
ardovm
Posts: 6
Joined: Thu Aug 01, 2019 11:13 am

Re: [Hint] How did I fix my ODT file

Post by ardovm »

John_Ha wrote:While I have no serious coding experience I think the NULLs we see in broken .odt files are probably written by a routine called Deflater.cxx in the package bit of AOO which writes files at [Apache-SVN]/openoffice/trunk/main/package/source/package/zipapi/Deflater.cxx. The source is as below. Deflater is the routine which Zips the file.

Note that line 52 appears to set something (the memory for the file? the disk space to be used for the file?) to zeros or NULLs. I think these are the NULLs we see in the broken .odt files. Line 51 is a comment explaining that NULLs are about to be written.

Code: Select all

51 	        /* Memset it to 0...sets zalloc/zfree/opaque to NULL */
52 	        memset (pStream, 0, sizeof(*pStream));
I am not sure that "those" NULLs are "the same" NULLs that were reported.

According to the zlib manual the structure pStream contains support data for the compression algorithm. It is zeroed at the beginning in order to have it in a "known state".

The compressed (i.e. output for zlib) data are written in another method:

Code: Select all

82 	sal_Int32 Deflater::doDeflateBytes (uno::Sequence < sal_Int8 > &rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength)
83 	{
84 	        sal_Int32 nResult;
85 	        if (bSetParams)
86 	        {
87 	                pStream->next_in   = (unsigned char*) sInBuffer.getConstArray() + nOffset;
88 	                pStream->next_out  = (unsigned char*) rBuffer.getArray()+nNewOffset;
89 	                pStream->avail_in  = nLength;
90 	                pStream->avail_out = nNewLength;
Here, it is clear that the the pStream just hold pointers to the input data (sInBuffer) and the output buffer (rBuffer)
...
It supports our idea that too quick shutting of a laptop lid could be causing problem and also explains why it is fairly infrequent - it has to occur at exactly the wrong time to catch the fault in the AOO coding.
In case it could be interesting for other forum readers, we are trying to reproduce the problem on the bug report #126869.
I could be completely wrong ...
Me too, of course! Any help, suggestions etc. are appreciated!
OpenOffice 4.1.13 on various platforms
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Hint] How did I fix my ODT file

Post by John_Ha »

ardovm wrote:I am not sure that "those" NULLs are "the same" NULLs that were reported.
I will defer to your vastly greater coding expertise!!
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Hint] How did I fix my ODT file

Post by John_Ha »

ardovm wrote:Any help, suggestions etc. are appreciated!
If you want to be puzzled have a peep at Format error discovered in the file in sub-document. :D

It is by no means the "normal" format error bug, with its repeated attributes or single bit error, which you seem to have fixed. It is something which I cannot even begin to guess what has happened as there are hundreds if not thousands of corruptions in content.xml!!

My head aches if I think about it so I have stopped thinking about it and I have put it down to alien life from outer space messing with us. :super:
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
User avatar
CannedMan
Posts: 244
Joined: Wed Aug 04, 2010 12:06 am

Re: [Hint] How did I fix my ODT file

Post by CannedMan »

Hi, folks

I tried the method above (OP), but instead got a new error message. In the original file, the error message located the fault at the very end of the file. After I fixed it, the error message stated that the fault was at 2:65220. If anyone are able to recover the file for me, it would mean the recovery of a week’s worth of writing. (I do have the file as a PDF as well, but of course would much prefer not to try to restore the text from that, especially with all the silly line breaks that results in.)

Google Disk links (as the files are too large):
  1. Original file
  2. Attempted fix
The file has only been edited in LibreOffice, as I do not own MS Office (nor do I have a copy of it ;-) – I don’t want it).
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
User avatar
RoryOF
Moderator
Posts: 34669
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Hint] How did I fix my ODT file

Post by RoryOF »

OpenOffice refused to open the original file, with no other error message. LibreOffice announced that the error was at the very end of the file.

I opened the file with an archive manager, and then opened content.xml with XML Copy Editor, which opened immediately with no errors. The file then passed XML Copy Editor's Well-formed check and PrettyPrint, which suggest that it is in good condition. I tried the quick trick of making and unmaking a trivial change to content.xml, then resaving it to the .odt file, but that made no difference.

Google Drive is showing 40 pages of the original file, finishing with some foot/end-notes, so you might be able to copy paste your text from there.

I worked only with the original "damaged" file, and the tests I made were "quick and dirty".
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
CannedMan
Posts: 244
Joined: Wed Aug 04, 2010 12:06 am

Re: [Hint] How did I fix my ODT file

Post by CannedMan »

I didn’t even think about trying to open it in Google Docs/Drive. I too, when opening through the link, get it to parse; Google Drive is able to display the contents in preview mode. What then is causing this error when actually opening it in LibreOffice?
Error message opening original file.
Error message opening original file.
Bilde_2024-06-03_124520037.png (4.78 KiB) Viewed 1225 times
Reading error.
Found format error in the file in the sub document content.xml at 2.423173(row.col).
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
User avatar
RoryOF
Moderator
Posts: 34669
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Hint] How did I fix my ODT file

Post by RoryOF »

I suspect there is some minor internal error/irregularity in the XML code, which Libre-/Open-Office are picking up. Extracting the content.xml from the original file and passing it through a rigorous XML parser/validator might throw up that error.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
RoryOF
Moderator
Posts: 34669
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Hint] How did I fix my ODT file

Post by RoryOF »

A quick suggestion: you know how you intended the document to look. Look at the pages in the Google preview, and note the text where the image differs from your intention; then check content.xml and adjust (perhaps by careful deletion) the xml at that point, working on a copy file. That may allow the file open, and you might then redo any altered formatting.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
CannedMan
Posts: 244
Joined: Wed Aug 04, 2010 12:06 am

Re: [Hint] How did I fix my ODT file

Post by CannedMan »

RoryOF wrote: Mon Jun 03, 2024 12:52 pm I opened the file with an archive manager, and then opened content.xml with XML Copy Editor, which opened immediately with no errors. The file then passed XML Copy Editor's Well-formed check and PrettyPrint, which suggest that it is in good condition. I tried the quick trick of making and unmaking a trivial change to content.xml, then resaving it to the .odt file, but that made no difference.
I downloaded the software and had a go at it. It passed (as expected) the Well-formed check, but when I ran the validation, I got the following error:
Error at line 2, column 2053: no declaration found for element 'office:document-content'
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
User avatar
RoryOF
Moderator
Posts: 34669
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Hint] How did I fix my ODT file

Post by RoryOF »

All I can tell you is that that error seems to relate to the schema against which the Validator is run. I don't understand the entire xml coding system.

I think if you posted a query on ask.libreoffice.org you might get some useful advice from the senior participants on that list..
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
CannedMan
Posts: 244
Joined: Wed Aug 04, 2010 12:06 am

Re: [Hint] How did I fix my ODT file

Post by CannedMan »

Alright, cheers. I decided it would be quicker to recreate the document from the PDF, as my knowledge of XML is very poor.
LibreOffice 7.6.7.2 (X86_64) on Windows 10.0 (19045)
cwolan
Posts: 135
Joined: Sun Feb 07, 2021 3:44 pm

Re: [Hint] How did I fix my ODT file

Post by cwolan »

@CannedMan

Does this file resemble the original?
OpenOffice 1.1.5 – 4.1.15
LibreOffice 3.3.0.4 – 24.2
Windows 7,10,11 64-bit
Post Reply