<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Writer document with tables lost data in cells (apparently) replacing with 0"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=131025#c15">Comment # 15</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Writer document with tables lost data in cells (apparently) replacing with 0"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=131025">bug 131025</a>
from <span class="vcard"><a class="email" href="mailto:from+documentfoundation@jdlh.com" title="Jim DeLaHunt <from+documentfoundation@jdlh.com>"> <span class="fn">Jim DeLaHunt</span></a>
</span></b>
<pre>I encountered this problem with the following current LibreOffice version on
macOS:
Version: 7.0.3.1
Build ID: d7547858d014d4cf69878db179d326fc3483e082
CPU threads: 8; OS: Mac OS X 10.13.6; UI render: default; VCL: osx
Locale: en-CA (en_CA.UTF-8); UI: en-US
Calc: threaded
I had success fixing the problem, guided by Mark van Rossum's <a href="show_bug.cgi?id=131025#c12">comment12</a>. I
unzipped the .odt file, edited contents.xml, changed the value of
"office:value-type" attributes from "float" to "string", and deleted
"office:value" attributes.
I did this with the following XSLT file. I won't attempt to explain how to use
XSLT here. It is tough to get working, but once it works, it's a great tool for
the job (of patching XML files).
Once I edited contents.xml, re-zipped the document directory, and opened the
new .odt file in LibreOffice, I saw a "document corrupted" message as Mark did.
LibreOffice was able to repair the document, and it seems OK.
=====
<?xml version="1.0" encoding="UTF-8"?>
<!-- Restore_odt_table_cell_text.xslt
by Jim DeLaHunt (jdlh.com), 2020-12-08. Donated to the public domain (cc0).
This XSLT fixes a LibreOffice bug where Writer table cells containing
text turn into digit 0 when the document is re-opened.
This is <a class="bz_bug_link
bz_status_NEW "
title="NEW - Writer document with tables lost data in cells (apparently) replacing with 0"
href="show_bug.cgi?id=131025">Bug 131025</a> - Writer document with tables lost data in cells
(apparently) replacing with 0
<<a class="bz_bug_link
bz_status_NEW "
title="NEW - Writer document with tables lost data in cells (apparently) replacing with 0"
href="show_bug.cgi?id=131025">https://bugs.documentfoundation.org/show_bug.cgi?id=131025</a>>
It does this by fixing table cells like
<table:table-cell table:style-name="…" office:value-type="float"
office:value="0">
<text:p text:style-name="P71">desired text</text:p>
</table:table-cell>
by changing to office:value-type="string" and deleting office:value="0".
-->
<xsl:stylesheet version="1.0" xmlns:xsl="<a href="http://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL/Transform</a>"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0">
<xsl:output method="xml" indent="no" encoding="UTF-8" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template
match="/office:document-content/office:body/office:text/table:table/table:table-row/table:table-cell[@office:value-type='float'][@office:value='0'][not(text()='')]"
>
<xsl:copy>
<xsl:attribute
name="office:value-type">string</xsl:attribute>
<xsl:apply-templates select="@*[name(.)!='office:value'
and name(.)!='office:value-type']" />
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
=====</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>