incubator-odf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Svante Schubert <svante.schub...@gmail.com>
Subject Re: setStringFormat doesn't always work as expected
Date Sun, 09 Feb 2014 19:05:37 GMT
Dear Nick,

Sorry, took a while till I was able to dive into it.

Thank you for creating a test file. I have adjusted it a little to fit
in our ODF Toolkit and attached them to an issue:
https://issues.apache.org/jira/browse/ODFTOOLKIT-384

Could you adjust the test, so it fails?
see
The test runs without failing. Could you add some test that makes the
problem obvious - let the test fail?

PS: The ODS is invalid due to the lines in the styles.xml

<text:date style:data-style-name="N2"
text:date-value="2014-01-22">00/00/0000</text:date>,
<text:time style:data-style-name="N2"
text:time-value="0000-00-00T09:12:28.400367354">00:00:00</text:time>

If we take a look into the spec, there is no content allowed:
http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#element-text_date
Might not be of importance, but wanted to mention it, from LO 4.1.4
<meta:generator>LibreOffice/4.1.4.2$Linux_X86_64
LibreOffice_project/0a0440ccc0227ad9829de5f46be37cfb6edcf72</meta:generator>

PPS: Many thanks for your test files, was still not able to look into
it, although such things I miss desperately.

Best regards,
Svante

Am 22.01.2014 10:15, schrieb Nicholas Evans:
> Dear Svante,
>
> Thanks for your response.
>
> In the end I solved my problem by directly manipulating the DOM with
> the "lower classes" as you call them.  However, I have also attached a
> template and a class that demonstrate the problem I was having with
> the Simple API setFormatString method. 
>
> The problem seems to be that when there are user defined styles
> present, the setFormatString method creates a number-style element in
> the content.xml file, and not in the
> styles.xml file.  This means that when LibreOffice follows the
> reference to this style, it cannot find it.  This behaviour of
> LibreOffice conforms with the odf spec (16.1):
>
> /Styles and font face declarations are referenced by their style:name
> attribute. A referenced style or font face declaration should be
> defined in the same file as the reference, or in styles.xml. /
>
> I have included some comments in the java file to try and clarify the
> problem.
>
> Best,
> Nick
>
>
> 2014/1/15 Svante Schubert <svante.schubert@gmail.com
> <mailto:svante.schubert@gmail.com>>
>
>     Hi Nicholas,
>
>     would it possible to test the problem in the latest sources?
>     In addition could you provide an issue and attach a test case. Test
>     Driven Development, you know..
>
>     For ease of you, just take an existing one, so one of us might debug
>     into it, if the solution might not become apparent at once.
>     In general I feel more responsible for the lower classes than for the
>     Simple API that IBM once added.
>
>     Thanks in advance,
>     Svante
>
>
>     Am 14.01.2014 16:59, schrieb Nicholas Evans:
>     > Dear odf users,
>     >
>     > I am writing an application that makes use of the
>     setFormatString function
>     > from the ODF Simple API (the 0.7-incubating version that is
>     available
>     > through maven central).  My use case is the following:
>     >
>     > 1) I select a cell in the spreadsheet.
>     > 2) I set the style of this cell using setCellStyleName
>     > 3) I set a double value in the cell using setDoubleValue
>     > 4) I set a format for the cell using setFormatString
>     >
>     > When I test run this sequence in a simple test project it works
>     fine.
>     > However, when I use the same sequence in a bigger spreadsheet,
>     the cell is
>     > not rendered as it should be.  When I open the generated
>     spreadsheet in
>     > LibreOffice and GoogleSpreadsheets, the cell is not formatted as
>     I want,
>     > although the double value is displayed.  However, when I open the
>     > spreadsheet in Excel, the cell is formatted properly. If I save
>     the file in
>     > excel and reopen it in LibreOffice, the cell is formatted correctly.
>     >
>     > I have compared the ods xml files before and after saving it in
>     Excel and
>     > there are quite substantial differences in the way in the which
>     the styles
>     > are handled.
>     >
>     > Interestingly, the following sequence produces different results
>     in my
>     > small test project and my large project:
>     >
>     > 1) I select a cell in the spreadsheet.
>     > 2) I set the style of this cell using setCellStyleName
>     > 3) I set a double value in the cell using setDoubleValue
>     > 4) I set a format for the cell using setStringFormat
>     > 5) I get the cell style using getCellStyleName
>     >
>     > In the small project, the style I get in step 5 is different
>     from the one I
>     > set in step 2. It seems that somewhere a new style is generated
>     that is a
>     > child of the Default style and this is returned in step 5.
>      However, in the
>     > larger project, step 5 returns the style I set in step 2.
>     >
>     > It seems like the API is working at least partially correctly,
>     because
>     > Excel can understand the generated spreadsheet.  However, it is
>     rather
>     > frustrating that LibreOffice can only understand the spreadsheet
>     after it
>     > has been through Excel.
>     >
>     > Has anyone experienced such a problem before?  Do you have any
>     suggestions
>     > for how I could get the setFormatString to work?
>     >
>     > Thanks for your help.
>     >
>     > Kind regards,
>     >
>     > Nick
>     >
>
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message