summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2023-11-16 15:19:08 +0100
committerRegina Henschel <rb.henschel@t-online.de>2023-11-17 15:33:41 +0100
commit270b7efe92751a46c3d85e856b932a365c5f5b73 (patch)
treeea5db33aa01419be29d88198aab84bb775bf20c3 /oox
parent5af2041c551e97903d2ba7994c5e893836891832 (diff)
Add getUnicodeTokenName() to StaticTokenMap and use...
it in several places. Currently these places get a Sequence<sal_Int8> by call of StaticTokenMap().getUtf8TokenName() and immediately after that generate an OUString from it using reinterpret_cast<const char*> and the OUString ctor with 8-Bit character buffer array. The patch moves this conversion to StaticTokenMap. Change-Id: Ia2af110e2a0f1708e0685115d325c1c12cab3857 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159514 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/connectorhelper.hxx8
-rw-r--r--oox/inc/drawingml/customshapeproperties.hxx2
-rw-r--r--oox/qa/token/tokenmap-test.cxx13
-rw-r--r--oox/source/drawingml/connectorhelper.cxx13
-rw-r--r--oox/source/drawingml/customshapeproperties.cxx4
-rw-r--r--oox/source/drawingml/shape.cxx13
-rw-r--r--oox/source/drawingml/table/tablecell.cxx5
7 files changed, 21 insertions, 37 deletions
diff --git a/oox/inc/drawingml/connectorhelper.hxx b/oox/inc/drawingml/connectorhelper.hxx
index 1e875ab8ee95..f5409d635270 100644
--- a/oox/inc/drawingml/connectorhelper.hxx
+++ b/oox/inc/drawingml/connectorhelper.hxx
@@ -24,14 +24,6 @@
namespace ConnectorHelper
{
-/* ToDo: Other place? It uses getShapePresetTypeName() and that is only used in shape.cxx in
- Shape::createAndInsert() for "mso-orig-shape-type" property in GrabBag and for msConnectorName.
- In both cases it is immediately converted to OUString. So perhaps let
- getShapePresetTypeName() return an OUString directly?
-*/
-rtl::OUString getShapePresetTypeNameOUString(
- const oox::drawingml::CustomShapePropertiesPtr& pCustomShapePropertiesPtr);
-
/**
* Some preset shapes use the default connector site but in order right, bottom, left, top.
* The function detects this.
diff --git a/oox/inc/drawingml/customshapeproperties.hxx b/oox/inc/drawingml/customshapeproperties.hxx
index 61a151d9aa09..c699ffddcce7 100644
--- a/oox/inc/drawingml/customshapeproperties.hxx
+++ b/oox/inc/drawingml/customshapeproperties.hxx
@@ -101,7 +101,7 @@ public:
const css::awt::Size &aSize );
sal_Int32 getShapePresetType() const { return mnShapePresetType; }
- css::uno::Sequence< sal_Int8 > const & getShapePresetTypeName() const;
+ OUString getShapePresetTypeName() const;
void setShapePresetType( sal_Int32 nShapePresetType ){ mnShapePresetType = nShapePresetType; };
bool getShapeTypeOverride() const { return mbShapeTypeOverride; };
void setShapeTypeOverride( bool bShapeTypeOverride ) { mbShapeTypeOverride = bShapeTypeOverride; };
diff --git a/oox/qa/token/tokenmap-test.cxx b/oox/qa/token/tokenmap-test.cxx
index 058f7c16ebbf..e30b6aef806b 100644
--- a/oox/qa/token/tokenmap-test.cxx
+++ b/oox/qa/token/tokenmap-test.cxx
@@ -23,10 +23,12 @@ class TokenmapTest: public CppUnit::TestFixture
{
public:
void test_roundTrip();
+ void test_roundTripUnicode();
CPPUNIT_TEST_SUITE(TokenmapTest);
CPPUNIT_TEST(test_roundTrip);
+ CPPUNIT_TEST(test_roundTripUnicode);
CPPUNIT_TEST_SUITE_END();
private:
@@ -46,6 +48,17 @@ void TokenmapTest::test_roundTrip()
}
}
+void TokenmapTest::test_roundTripUnicode()
+{
+ for (sal_Int32 nToken = 0; nToken < XML_TOKEN_COUNT; ++nToken)
+ {
+ // check that the getIdentifier <-> getToken roundtrip works for OUString
+ OUString sName = tokenMap.getUnicodeTokenName(nToken);
+ sal_Int32 ret = oox::TokenMap::getTokenFromUnicode(sName);
+ CPPUNIT_ASSERT_EQUAL(ret, nToken);
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(TokenmapTest);
}
diff --git a/oox/source/drawingml/connectorhelper.cxx b/oox/source/drawingml/connectorhelper.cxx
index 82bd92a568b1..ff2c1fed42b9 100644
--- a/oox/source/drawingml/connectorhelper.cxx
+++ b/oox/source/drawingml/connectorhelper.cxx
@@ -38,15 +38,6 @@
using namespace ::com::sun::star;
-OUString ConnectorHelper::getShapePresetTypeNameOUString(
- const oox::drawingml::CustomShapePropertiesPtr& pCustomShapePropertiesPtr)
-{
- return rtl::OUString(reinterpret_cast<const char*>(
- pCustomShapePropertiesPtr->getShapePresetTypeName().getConstArray()),
- pCustomShapePropertiesPtr->getShapePresetTypeName().getLength(),
- RTL_TEXTENCODING_UTF8);
-}
-
// These shapes have no gluepoints defined in their mso_CustomShape struct, thus the gluepoint
// adaption to default gluepoints will be done. Other shapes having no gluepoint defined in the
// mso_CustomShape struct, have gluepoints in order top-left-bottom-right in OOXML. But the shapes
@@ -306,8 +297,8 @@ void ConnectorHelper::applyConnections(oox::drawingml::ShapePtr& rConnector,
// our default gluepoints are used. The order of the default gluepoints might differ
// from the order of the OOXML gluepoints. We try to change nGlueId so, that the
// connector attaches to a default gluepoint at the same side as it attaches in OOXML.
- const OUString sShapeType = ConnectorHelper::getShapePresetTypeNameOUString(
- pItem->second->getCustomShapeProperties());
+ const OUString sShapeType
+ = pItem->second->getCustomShapeProperties()->getShapePresetTypeName();
if (ConnectorHelper::hasClockwiseCxn(sShapeType))
nGlueId = (nGlueId + 1) % 4;
else
diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx
index 0ff24fce1789..321bc9bf537a 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -54,9 +54,9 @@ CustomShapeProperties::CustomShapeProperties()
{
}
-uno::Sequence< sal_Int8 > const & CustomShapeProperties::getShapePresetTypeName() const
+OUString CustomShapeProperties::getShapePresetTypeName() const
{
- return StaticTokenMap().getUtf8TokenName( mnShapePresetType );
+ return StaticTokenMap().getUnicodeTokenName(mnShapePresetType);
}
sal_Int32 CustomShapeProperties::SetCustomShapeGuideValue( std::vector< CustomShapeGuide >& rGuideList, const CustomShapeGuide& rGuide )
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 01798c344631..c42a9f7820a3 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1377,11 +1377,7 @@ Reference< XShape > const & Shape::createAndInsert(
aGrabBag.realloc( length+1);
auto pGrabBag = aGrabBag.getArray();
pGrabBag[length].Name = "mso-orig-shape-type";
- uno::Sequence< sal_Int8 > const & aNameSeq =
- mpCustomShapePropertiesPtr->getShapePresetTypeName();
- OUString sShapePresetTypeName(reinterpret_cast< const char* >(
- aNameSeq.getConstArray()), aNameSeq.getLength(), RTL_TEXTENCODING_UTF8);
- pGrabBag[length].Value <<= sShapePresetTypeName;
+ pGrabBag[length].Value <<= mpCustomShapePropertiesPtr->getShapePresetTypeName();
propertySet->setPropertyValue("FrameInteropGrabBag",uno::Any(aGrabBag));
}
//If the text box has links then save the link information so that
@@ -1766,12 +1762,7 @@ Reference< XShape > const & Shape::createAndInsert(
if (bIsConnectorShape)
{
- OUString sConnectorShapePresetTypeName(
- reinterpret_cast<const char*>(
- mpCustomShapePropertiesPtr->getShapePresetTypeName().getConstArray()),
- mpCustomShapePropertiesPtr->getShapePresetTypeName().getLength(),
- RTL_TEXTENCODING_UTF8);
- msConnectorName = sConnectorShapePresetTypeName;
+ msConnectorName = mpCustomShapePropertiesPtr->getShapePresetTypeName();
auto aAdjustmentList = mpCustomShapePropertiesPtr->getAdjustmentGuideList();
for (size_t i = 0; i < aAdjustmentList.size(); i++)
diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx
index 9d16bce09d17..687c987fe242 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -597,10 +597,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons
else if ( getVertToken() != XML_horz && getVertToken() != XML_eaVert )
{
// 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 };
-
+ const OUString aTokenName(StaticTokenMap().getUnicodeTokenName(getVertToken()));
Sequence<PropertyValue> aGrabBag;
xPropSet->getPropertyValue("CellInteropGrabBag") >>= aGrabBag;
PropertyValue aPropertyValue = comphelper::makePropertyValue("mso-tcPr-vert-value", aTokenName);