diff options
author | Sarper Akdemir <sarper.akdemir@collabora.com> | 2023-03-29 19:44:18 +0300 |
---|---|---|
committer | Sarper Akdemir <sarper.akdemir@collabora.com> | 2023-05-12 12:19:00 +0200 |
commit | ab8591f066fba011815ec09dd4fa5a4ce87d6ddd (patch) | |
tree | 45b788345cdf79e9e7440c069dbfa0f9ef0bd227 /oox | |
parent | 1215aefee8d314a9cc0816e93399d8dc0fb3835e (diff) |
oox: tcPr vert roundtrip, introduce interopability grab bag for table cell
To properly roundtrip all possible values of <a:tcPr vert="...">
+ Introduce grab bag for table cell
+ on import: Store the unsupported values in the grab bag:
+ (e.g. wordArtVert, mongolianVert, wordArtVertRtl)
+ on export: if nothing is being exported from the doc
model, export the value from the grabbag
Also adds a unit test covering this behavior.
Change-Id: I791ed2d992b0a554ef6da37200f027cffd8c5f2f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149737
Tested-by: Jenkins
Reviewed-by: Sarper Akdemir <sarper.akdemir@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151609
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/table/tablecell.cxx | 38 | ||||
-rw-r--r-- | oox/source/export/shapes.cxx | 14 |
2 files changed, 47 insertions, 5 deletions
diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index 17b13526084d..b0849b7002f3 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -29,12 +29,15 @@ #include <oox/helper/propertyset.hxx> #include <oox/token/properties.hxx> #include <oox/token/tokens.hxx> +#include <oox/token/tokenmap.hxx> #include <tools/color.hxx> #include <com/sun/star/table/BorderLineStyle.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/text/XText.hpp> #include <com/sun/star/text/WritingMode.hpp> +#include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> using namespace ::oox::core; using namespace ::com::sun::star; @@ -566,6 +569,36 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons { xPropSet->setPropertyValue("TextWritingMode", Any(css::text::WritingMode_TB_RL)); } + else if ( getVertToken() == XML_vert ) + { + xPropSet->setPropertyValue("RotateAngle", Any(short(27000))); + } + else if ( getVertToken() == XML_vert270 ) + { + xPropSet->setPropertyValue("RotateAngle", Any(short(9000))); + } + else if ( getVertToken() != XML_horz ) + { + // put the vert value in the grab bag for roundtrip + const Sequence<sal_Int8>& aTokenNameSeq = StaticTokenMap().getUtf8TokenName(getVertToken()); + const OUString aTokenName{ reinterpret_cast<const char*>(aTokenNameSeq.getConstArray()), + aTokenNameSeq.getLength(), RTL_TEXTENCODING_UTF8 }; + + Sequence<PropertyValue> aGrabBag; + xPropSet->getPropertyValue("CellInteropGrabBag") >>= aGrabBag; + PropertyValue aPropertyValue = comphelper::makePropertyValue("mso-tcPr-vert-value", aTokenName); + if (aGrabBag.hasElements()) + { + sal_Int32 nLength = aGrabBag.getLength(); + aGrabBag.realloc(nLength + 1); + aGrabBag.getArray()[nLength] = aPropertyValue; + } + else + { + aGrabBag = { aPropertyValue }; + } + xPropSet->setPropertyValue("CellInteropGrabBag", Any(aGrabBag)); + } getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, pMasterTextListStyle ); @@ -582,11 +615,6 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase); } } - - if (getVertToken() == XML_vert) - xPropSet->setPropertyValue("RotateAngle", Any(short(27000))); - else if (getVertToken() == XML_vert270) - xPropSet->setPropertyValue("RotateAngle", Any(short(9000))); } } diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 8c20aeaa9cce..bec056d90e84 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -2280,6 +2280,20 @@ void ShapeExport::WriteTableCellProperties(const Reference< XPropertySet>& xCell aRotateAngle >>= nRotateAngle; std::optional<OString> aTextVerticalValue = GetTextVerticalType(nRotateAngle); + Sequence<PropertyValue> aGrabBag; + if( !aTextVerticalValue && + (xCellPropSet->getPropertyValue("CellInteropGrabBag") >>= aGrabBag) ) + { + for (auto const& rIt : std::as_const(aGrabBag)) + { + if (rIt.Name == "mso-tcPr-vert-value") + { + aTextVerticalValue = rIt.Value.get<OUString>().toUtf8(); + break; + } + } + } + mpFS->startElementNS(XML_a, XML_tcPr, XML_anchor, sVerticalAlignment, XML_vert, aTextVerticalValue, XML_marL, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nLeftMargin)), nLeftMargin > 0), |