summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-03-14 18:27:43 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-03-15 06:19:53 +0100
commitd65c8b37595a4775fd766b2b7becbc01fe21a04e (patch)
treefa238de0cde01f3a977c9f5cad928a200aba5fe3 /oox
parent055fcef3fe3c3f74ed485a35451c48f6723991b6 (diff)
Simplify GetOOXMLPresetGeometry and GETVMLShapeType
Let them use types that know string lengths, don't require conversion, and are convenient at call sites. Also inline the maps initialization, instead of having separate arrays and initialization loops. Change-Id: Id4469f3f99f3f0eb2cd83f0671cf892df4e420a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131550 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/DMLPresetShapeExport.cxx4
-rw-r--r--oox/source/export/drawingml.cxx12
-rw-r--r--oox/source/export/shapes.cxx4
3 files changed, 10 insertions, 10 deletions
diff --git a/oox/source/export/DMLPresetShapeExport.cxx b/oox/source/export/DMLPresetShapeExport.cxx
index ad603bcd2bd2..a2d08ec3e2e2 100644
--- a/oox/source/export/DMLPresetShapeExport.cxx
+++ b/oox/source/export/DMLPresetShapeExport.cxx
@@ -223,7 +223,7 @@ bool DMLPresetShapeExporter::WriteShape()
if (!m_bHasHandleValues)
{
OUString sShapeType = GetShapeType();
- const char* sPresetShape = msfilter::util::GetOOXMLPresetGeometry(sShapeType);
+ const OString& sPresetShape = msfilter::util::GetOOXMLPresetGeometry(sShapeType);
m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, IsXFlipped(), IsYFlipped(),
false, false);
m_pDMLexporter->WritePresetShape(sPresetShape);
@@ -254,7 +254,7 @@ bool DMLPresetShapeExporter::StartAVListWriting()
{
try
{
- const char* pShape = msfilter::util::GetOOXMLPresetGeometry(GetShapeType());
+ const OString& pShape = msfilter::util::GetOOXMLPresetGeometry(GetShapeType());
m_pDMLexporter->GetFS()->startElementNS(XML_a, XML_prstGeom, XML_prst, pShape);
m_pDMLexporter->GetFS()->startElementNS(XML_a, XML_avLst);
return true;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index e723a27a3445..4615bbd39503 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3618,7 +3618,7 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo
}
}
-void DrawingML::WritePresetShape( const char* pShape , std::vector< std::pair<sal_Int32,sal_Int32>> & rAvList )
+void DrawingML::WritePresetShape( const OString& pShape , std::vector< std::pair<sal_Int32,sal_Int32>> & rAvList )
{
mpFS->startElementNS(XML_a, XML_prstGeom, XML_prst, pShape);
if ( !rAvList.empty() )
@@ -3640,7 +3640,7 @@ void DrawingML::WritePresetShape( const char* pShape , std::vector< std::pair<sa
mpFS->endElementNS( XML_a, XML_prstGeom );
}
-void DrawingML::WritePresetShape( const char* pShape )
+void DrawingML::WritePresetShape( const OString& pShape )
{
mpFS->startElementNS(XML_a, XML_prstGeom, XML_prst, pShape);
mpFS->singleElementNS(XML_a, XML_avLst);
@@ -3670,13 +3670,13 @@ static std::map< OString, std::vector<OString> > lcl_getAdjNames()
return aRet;
}
-void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, const PropertyValue& rProp )
+void DrawingML::WritePresetShape( const OString& pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, const PropertyValue& rProp )
{
static std::map< OString, std::vector<OString> > aAdjMap = lcl_getAdjNames();
// If there are predefined adj names for this shape type, look them up now.
std::vector<OString> aAdjustments;
- if (aAdjMap.find(OString(pShape)) != aAdjMap.end())
- aAdjustments = aAdjMap[OString(pShape)];
+ if (aAdjMap.find(pShape) != aAdjMap.end())
+ aAdjustments = aAdjMap[pShape];
mpFS->startElementNS(XML_a, XML_prstGeom, XML_prst, pShape);
mpFS->startElementNS(XML_a, XML_avLst);
@@ -3685,7 +3685,7 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool b
if ( ( rProp.Value >>= aAdjustmentSeq )
&& eShapeType != mso_sptActionButtonForwardNext // we have adjustments values for these type of shape, but MSO doesn't like them
&& eShapeType != mso_sptActionButtonBackPrevious // so they are now disabled
- && pShape != std::string_view("rect") //some shape types are commented out in pCustomShapeTypeTranslationTable[] & are being defaulted to rect & rect does not have adjustment values/name.
+ && pShape != "rect" //some shape types are commented out in pCustomShapeTypeTranslationTable[] & are being defaulted to rect & rect does not have adjustment values/name.
)
{
SAL_INFO("oox.shape", "adj seq len: " << aAdjustmentSeq.getLength());
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 51bf3b528eaf..719836e77b70 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -768,7 +768,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
EscherPropertyContainer::IsDefaultObject(
rSdrObjCustomShape,
eShapeType));
- const char* sPresetShape = msfilter::util::GetOOXMLPresetGeometry(sShapeType);
+ OString sPresetShape = msfilter::util::GetOOXMLPresetGeometry(sShapeType);
SAL_INFO("oox.shape", "custom shape type: " << sShapeType << " ==> " << sPresetShape);
sal_Int32 nAdjustmentValuesIndex = -1;
@@ -1078,7 +1078,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
// case mso_sptBorderCallout3:
default:
{
- if (!strcmp( sPresetShape, "frame" ))
+ if ( sPresetShape == "frame" )
{
sal_Int32 adj1 = double( nYPosition )/aViewBox.Height *100000 ;
lcl_AppendAdjustmentValue( aAvList, 1, adj1 );