diff options
author | Henry Castro <hcastro@collabora.com> | 2023-05-09 17:43:48 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2023-06-22 19:29:38 +0200 |
commit | 94297e037dd963b7e74dfff369145d0e0db30c97 (patch) | |
tree | 13e5566b890f3ad82c145fe2d7161925ae3bb051 /sc/source/filter/oox | |
parent | be53ee28d7435809e71e7e6b2ce929c87f07ba33 (diff) |
sc: filter: oox: fix preserve space, single line case
The unit test testPreserveTextWhitespace2XLSX fails
when a single line is enabled
Test name: ScExportTest::testPreserveTextWhitespace2XLSX
equality assertion failed
- Expected: 1
- Actual : 0
- In <>, XPath '/x:sst/x:si[2]/x:r[1]/x:t' number of nodes is incorrect
In order to fix, the single line cell should not be enabled and
import the attribute:
<t xml:space="preserve">abc</t>
Signed-off-by: Henry Castro <hcastro@collabora.com>
Change-Id: I380ba8726c03abc40bdc745ea74eceb80fec6e54
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151599
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
(cherry picked from commit 2dd86aa3f365057494bf41f4da7f2f410ea3bf2e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151615
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153459
Tested-by: Jenkins
Diffstat (limited to 'sc/source/filter/oox')
-rw-r--r-- | sc/source/filter/oox/richstring.cxx | 12 | ||||
-rw-r--r-- | sc/source/filter/oox/richstringcontext.cxx | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/sc/source/filter/oox/richstring.cxx b/sc/source/filter/oox/richstring.cxx index 8d2f964362d0..a1345179c19a 100644 --- a/sc/source/filter/oox/richstring.cxx +++ b/sc/source/filter/oox/richstring.cxx @@ -28,6 +28,7 @@ #include <oox/helper/binaryinputstream.hxx> #include <oox/helper/attributelist.hxx> #include <oox/helper/propertyset.hxx> +#include <oox/token/namespaces.hxx> #include <oox/token/tokens.hxx> #include <editutil.hxx> @@ -293,8 +294,10 @@ void PhoneticPortionModelList::importPortions( SequenceInputStream& rStrm ) } } -sal_Int32 RichString::importText() +sal_Int32 RichString::importText(const AttributeList& rAttribs) { + setAttributes(rAttribs); + return createPortion(); } @@ -303,6 +306,13 @@ sal_Int32 RichString::importRun() return createPortion(); } +void RichString::setAttributes(const AttributeList& rAttribs) +{ + auto aAttrSpace = rAttribs.getString(oox::NMSP_xml | oox::XML_space); + if (aAttrSpace && *aAttrSpace == "preserve") + mbPreserveSpace = true; +} + RichStringPhoneticRef RichString::importPhoneticRun( const AttributeList& rAttribs ) { RichStringPhoneticRef xPhonetic = createPhonetic(); diff --git a/sc/source/filter/oox/richstringcontext.cxx b/sc/source/filter/oox/richstringcontext.cxx index 280ac293a390..0c83fff2e9f3 100644 --- a/sc/source/filter/oox/richstringcontext.cxx +++ b/sc/source/filter/oox/richstringcontext.cxx @@ -33,7 +33,7 @@ ContextHandlerRef RichStringContext::onCreateContext( sal_Int32 nElement, const switch( nElement ) { case XLS_TOKEN( t ): - mnPortionIdx = mxString->importText(); + mnPortionIdx = mxString->importText(rAttribs); return this; // collect text in onCharacters() case XLS_TOKEN( r ): mnPortionIdx = mxString->importRun(); @@ -57,6 +57,7 @@ ContextHandlerRef RichStringContext::onCreateContext( sal_Int32 nElement, const break; case XLS_TOKEN( t ): + mxString->setAttributes(rAttribs); return this; // collect portion text in onCharacters() } break; @@ -65,6 +66,7 @@ ContextHandlerRef RichStringContext::onCreateContext( sal_Int32 nElement, const switch( nElement ) { case XLS_TOKEN( t ): + mxString->setAttributes(rAttribs); return this; // collect phonetic text in onCharacters() } break; |