editeng/source/editeng/editstt2.hxx | 3 +++ include/editeng/editstat.hxx | 3 ++- sc/source/filter/inc/richstring.hxx | 7 ++++++- sc/source/filter/oox/richstring.cxx | 12 +++++++++++- sc/source/filter/oox/richstringcontext.cxx | 4 +++- 5 files changed, 25 insertions(+), 4 deletions(-)
New commits: commit 1e7451560e3a03f6ca68bad8b0450e79a0cfa627 Author: Henry Castro <[email protected]> AuthorDate: Tue May 9 17:43:48 2023 -0400 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Jun 23 21:04:34 2023 +0200 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 <[email protected]> Change-Id: I380ba8726c03abc40bdc745ea74eceb80fec6e54 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151599 Tested-by: Jenkins CollaboraOffice <[email protected]> (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 Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153487 diff --git a/sc/source/filter/inc/richstring.hxx b/sc/source/filter/inc/richstring.hxx index 7c233507b419..b74e3036f473 100644 --- a/sc/source/filter/inc/richstring.hxx +++ b/sc/source/filter/inc/richstring.hxx @@ -208,7 +208,7 @@ class RichString public: /** Appends and returns an index of a portion object for a plain string (t element). */ - sal_Int32 importText(); + sal_Int32 importText(const AttributeList& rAttribs); /** Appends and returns an index of a portion object for a new formatting run (r element). */ sal_Int32 importRun(); /** Appends and returns a phonetic text object for a new phonetic run (rPh element). */ @@ -236,6 +236,10 @@ public: RichStringPortion& getPortion(sal_Int32 nPortionIdx) { return maTextPortions[nPortionIdx]; } + void setAttributes(const AttributeList& rAttribs); + + bool isPreserveSpace() const { return mbPreserveSpace; } + private: /** Creates, appends, and returns a new empty string portion. */ sal_Int32 createPortion(); @@ -253,6 +257,7 @@ private: std::vector<RichStringPortion> maTextPortions; /// String portions with font data. std::unique_ptr<PhoneticSettings> mxPhonSettings; /// Phonetic settings for this string. PhoneticVector maPhonPortions; /// Phonetic text portions. + bool mbPreserveSpace = false; }; typedef std::shared_ptr< RichString > RichStringRef; 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; commit 9fc88e6fd7f9177eedcd39ead1c39ef21240de37 Author: Henry Castro <[email protected]> AuthorDate: Tue Jan 31 16:01:08 2023 -0400 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Jun 23 21:04:24 2023 +0200 editeng: add flag EEControlBits::SINGLELINE The purpose of this flag is to draw a paragraph into a single line ignoring line breaks Signed-off-by: Henry Castro <[email protected]> Change-Id: I0a01e6d4db51d43707f7cdd0ab9d9cf3288e2221 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147999 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153391 Tested-by: Jenkins Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153483 diff --git a/editeng/source/editeng/editstt2.hxx b/editeng/source/editeng/editstt2.hxx index 4474df8b429b..334622b23495 100644 --- a/editeng/source/editeng/editstt2.hxx +++ b/editeng/source/editeng/editstt2.hxx @@ -91,6 +91,9 @@ public: bool ULSpaceSummation() const { return bool( nControlBits & EEControlBits::ULSPACESUMMATION ); } + + bool IsSingleLine() const + { return bool( nControlBits & EEControlBits::SINGLELINE ); } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/editeng/editstat.hxx b/include/editeng/editstat.hxx index eec50ea67c20..29653d5eec4f 100644 --- a/include/editeng/editstat.hxx +++ b/include/editeng/editstat.hxx @@ -50,10 +50,11 @@ enum class EEControlBits AUTOPAGESIZE = (AUTOPAGESIZEX | AUTOPAGESIZEY), FORMAT100 = 0x01000000, // Always format to 100% ULSPACESUMMATION = 0x02000000, // MS Compat: sum SA and SB, not maximum value + SINGLELINE = 0x04000000, // One line for all text }; namespace o3tl { - template<> struct typed_flags<EEControlBits> : is_typed_flags<EEControlBits, 0x037afff9> {}; + template<> struct typed_flags<EEControlBits> : is_typed_flags<EEControlBits, 0x07ffffff> {}; } enum class EVControlBits
