Date: prev next · Thread: first prev next last
2020 Archives by date, by thread · List index


On 28.06.20 20:57, Michael wrote:
I'm trying to write a unit test for https://bugs.documentfoundation.org/show_bug.cgi?id=133647. As I see it, in order for this unit test to be effective, it needs to either compare to the formatted display value of the function (to check whether or not "** Expression is faulty **" is being shown) or compare to the formula text value (to see if it is getting translated the way I expect). But, I am having a heck of a time getting either of those in the unit test.

I put what I have so far in https://paste.debian.net/1154267/ with the output at the bottom in a comment.

apparently there's a SwXCell::getFormula() function...

there's a problem in line 24:

   uno::Reference<table::XCell2> xCell2(xTable, uno::UNO_QUERY);

this should be 'xTable->getCellByName("B4")' not "xTable".

but line 62 already prints an empty formula from XCell interface.

The operational code in DomainMapper_Impl.cxx appears to be writing the formula text to a com.sun.star.text.TextField when importing the document, but trying to get an XTextField from an XCell like this:
         uno::Reference<text::XTextField> xTextField(xCell, uno::UNO_QUERY);

In the unit test isn't working, xTextField.is() is false.

a cell isn't a text field; to enumerate the fields in the cell you need to first enumerate the paragraphs in the cell and then enumerate the text portions in the paragraph... or use helpers getParagraph() / getRun() from SwModelTestBase.

I can get a calculated value by getting an XText from the XCell, but that's not what I am after.

As far as looking at the formatted display value, from what I can tell in a debugging session it seems like I need DocumentFieldsManager::UpdateTableFields() to run, but I don't know if this is happening when running a unit test, maybe it isn't. I can't tell if there is some way to force it from a unit test.

probably it's not happening automatically but you can call UpdateFields either via SwDoc or by dispatching ".uno:UpdateFields".

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.