[Libreoffice-commits] core.git: oox/source sax/source sc/source sw/qa sw/source xmloff/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Apr 13 18:40:29 UTC 2021
oox/source/export/drawingml.cxx | 12 +++----
oox/source/export/vmlexport.cxx | 2 -
sax/source/tools/fastattribs.cxx | 2 -
sc/source/filter/excel/xepage.cxx | 4 +-
sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 4 +-
sw/source/filter/ww8/docxattributeoutput.cxx | 44 +++++++++++++--------------
sw/source/filter/ww8/docxsdrexport.cxx | 7 +---
xmloff/source/core/xmlimp.cxx | 4 +-
8 files changed, 39 insertions(+), 40 deletions(-)
New commits:
commit 54054aaea74d524a05f899f8af27e2a65e17be52
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Apr 13 13:04:02 2021 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Apr 13 20:39:45 2021 +0200
tdf#79591: No need to use getStr here
7ea1bbe712cef48a97faffdf03b45f2812a93e62 had abused the C-style strings,
and relied on the names containing zero byte to be truncated on the byte.
However, that would only work for names with zero bytes, not with other
control characters. Additionally, that prevented the initial names from
correct round-trip.
This reverts the older fix, and makes sure to handle the attributes with
zeroes correctly (using memcpy instead of strncpy).
It also removes several similar unneeded uses of getStr.
Change-Id: I6c52874d99fe9eb9ccbe0c9a9b57e3b51c45a19f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114040
Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 32780296ce89..586b40c78304 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3972,7 +3972,7 @@ void DrawingML::WriteShapeEffect( std::u16string_view sName, const Sequence< Pro
{
OUString sVal;
rOuterShdwProp.Value >>= sVal;
- aOuterShdwAttrList->add( XML_algn, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() );
+ aOuterShdwAttrList->add( XML_algn, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ) );
}
else if( rOuterShdwProp.Name == "blurRad" )
{
@@ -4408,7 +4408,7 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
{
OUString sVal;
rEffectProp.Value >>= sVal;
- aCameraAttrList->add( XML_prst, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() );
+ aCameraAttrList->add(XML_prst, OUStringToOString(sVal, RTL_TEXTENCODING_UTF8));
}
else if( rEffectProp.Name == "fov" )
{
@@ -4453,7 +4453,7 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
nToken = XML_rig;
else if( rLightRigProp.Name == "dir" )
nToken = XML_dir;
- aLightRigAttrList->add( nToken, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() );
+ aLightRigAttrList->add(nToken, OUStringToOString(sVal, RTL_TEXTENCODING_UTF8));
}
else if( rLightRigProp.Name == "rotLat" ||
rLightRigProp.Name == "rotLon" ||
@@ -4532,7 +4532,7 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
{
OUString sVal;
rShape3DProp.Value >>= sVal;
- aShape3DAttrList->add( XML_prstMaterial, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() );
+ aShape3DAttrList->add(XML_prstMaterial, OUStringToOString(sVal, RTL_TEXTENCODING_UTF8));
}
else if( rShape3DProp.Name == "extrusionClr" )
{
@@ -4576,7 +4576,7 @@ void DrawingML::WriteShape3DEffects( const Reference< XPropertySet >& xPropSet )
{
OUString sVal;
rBevelProp.Value >>= sVal;
- aBevelAttrList->add( XML_prst, OUStringToOString( sVal, RTL_TEXTENCODING_UTF8 ).getStr() );
+ aBevelAttrList->add(XML_prst, OUStringToOString(sVal, RTL_TEXTENCODING_UTF8));
}
}
@@ -4783,7 +4783,7 @@ void DrawingML::WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rX
= sax_fastparser::FastSerializerHelper::createAttrList();
pDocPrAttrList->add(XML_id, OString::number(nDiagramId).getStr());
OUString sName = "Diagram" + OUString::number(nDiagramId);
- pDocPrAttrList->add(XML_name, OUStringToOString(sName, RTL_TEXTENCODING_UTF8).getStr());
+ pDocPrAttrList->add(XML_name, OUStringToOString(sName, RTL_TEXTENCODING_UTF8));
if (GetDocumentType() == DOCUMENT_DOCX)
{
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 9f8df2279611..36d35a7ed18b 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -1036,7 +1036,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle&
OUString idStr = SvxMSDffManager::MSDFFReadZString(aStream, opt.nProp.size(), true);
aStream.Seek(0);
if (!IsWaterMarkShape(m_pSdrObject->GetName()) && !m_bSkipwzName)
- m_pShapeAttrList->add(XML_ID, OUStringToOString(idStr, RTL_TEXTENCODING_UTF8).getStr());
+ m_pShapeAttrList->add(XML_ID, OUStringToOString(idStr, RTL_TEXTENCODING_UTF8));
bAlreadyWritten[ESCHER_Prop_wzName] = true;
}
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx
index 0ef8828b187d..554232260aef 100644
--- a/sax/source/tools/fastattribs.cxx
+++ b/sax/source/tools/fastattribs.cxx
@@ -111,7 +111,7 @@ void FastAttributeList::add( sal_Int32 nToken, const char* pValue, size_t nValue
mpChunk = p;
}
- strncpy(mpChunk + nWritePosition, pValue, nValueLength);
+ memcpy(mpChunk + nWritePosition, pValue, nValueLength);
mpChunk[nWritePosition + nValueLength] = '\0';
}
diff --git a/sc/source/filter/excel/xepage.cxx b/sc/source/filter/excel/xepage.cxx
index e2f51d706def..b2796ed99e11 100644
--- a/sc/source/filter/excel/xepage.cxx
+++ b/sc/source/filter/excel/xepage.cxx
@@ -102,8 +102,8 @@ void XclExpSetup::SaveXml( XclExpXmlStream& rStrm )
}
else
{
- pAttrList->add( XML_paperWidth, OString(OString::number( mrData.mnPaperWidth ) + "mm").getStr() );
- pAttrList->add( XML_paperHeight, OString(OString::number( mrData.mnPaperHeight ) + "mm").getStr() );
+ pAttrList->add( XML_paperWidth, OString::number( mrData.mnPaperWidth ) + "mm" );
+ pAttrList->add( XML_paperHeight, OString::number( mrData.mnPaperHeight ) + "mm" );
// pAttrList->add( XML_paperUnits, "mm" );
}
pAttrList->add( XML_scale, OString::number( mrData.mnScaling ).getStr() );
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index 54540c265977..c443120fecd5 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -851,8 +851,8 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testfdo79591, "fdo79591.docx")
*/
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
- assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr", "name", "");
- assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape", "ID", "");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr", "name", "_x0000_t0");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Fallback/w:pict/v:shape", "ID", "_x0000_t0");
}
DECLARE_OOXMLEXPORT_TEST(testBnc884615, "bnc884615.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index a74e66fcec89..37e5049cbbe1 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2637,7 +2637,7 @@ void lclProcessRecursiveGrabBag(sal_Int32 aElementId, const css::uno::Sequence<c
std::optional<sal_Int32> aSubElementId = lclGetElementIdForName(rAttribute.Name);
if(aSubElementId)
- pAttributes->add(*aSubElementId, aValue.getStr());
+ pAttributes->add(*aSubElementId, aValue);
}
pSerializer->startElement(aElementId, pAttributes);
@@ -3039,7 +3039,7 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge
oox::getRelationship(Relationship::HYPERLINK),
sUrl, true ), RTL_TEXTENCODING_UTF8 );
- m_pHyperlinkAttrList->add( FSNS( XML_r, XML_id), sId.getStr());
+ m_pHyperlinkAttrList->add(FSNS(XML_r, XML_id), sId);
}
else
{
@@ -3068,13 +3068,13 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge
// Spaces are prohibited in bookmark name.
sMark = sMark.replace(' ', '_');
m_pHyperlinkAttrList->add( FSNS( XML_w, XML_anchor ),
- OUStringToOString( sMark, RTL_TEXTENCODING_UTF8 ).getStr( ) );
+ OUStringToOString( sMark, RTL_TEXTENCODING_UTF8 ) );
}
if ( !rTarget.isEmpty() )
{
OString soTarget = OUStringToOString( rTarget, RTL_TEXTENCODING_UTF8 );
- m_pHyperlinkAttrList->add(FSNS( XML_w, XML_tgtFrame ), soTarget.getStr());
+ m_pHyperlinkAttrList->add(FSNS(XML_w, XML_tgtFrame), soTarget);
}
}
@@ -4001,16 +4001,16 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
OString sTblpYSpec = convertToOOXMLVertOrient( pFrame->GetFrameFormat().GetVertOrient().GetVertOrient() );
sOrientation = convertToOOXMLVertOrientRel( pFrame->GetFrameFormat().GetVertOrient().GetRelationOrient() );
- attrListTablePos->add( FSNS( XML_w, XML_vertAnchor ), sOrientation.getStr() );
+ attrListTablePos->add(FSNS(XML_w, XML_vertAnchor), sOrientation);
if( !sTblpYSpec.isEmpty() )
- attrListTablePos->add( FSNS( XML_w, XML_tblpYSpec ), sTblpYSpec.getStr() );
+ attrListTablePos->add(FSNS(XML_w, XML_tblpYSpec), sTblpYSpec);
sOrientation = convertToOOXMLHoriOrientRel( pFrame->GetFrameFormat().GetHoriOrient().GetRelationOrient() );
- attrListTablePos->add( FSNS( XML_w, XML_horzAnchor ), sOrientation.getStr() );
+ attrListTablePos->add(FSNS(XML_w, XML_horzAnchor), sOrientation);
if( !sTblpXSpec.isEmpty() )
- attrListTablePos->add( FSNS( XML_w, XML_tblpXSpec ), sTblpXSpec.getStr() );
+ attrListTablePos->add(FSNS(XML_w, XML_tblpXSpec), sTblpXSpec);
nValue = pFrame->GetFrameFormat().GetULSpace().GetLower();
if( nValue != 0 )
@@ -4065,22 +4065,22 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
if (rProp.Name == "vertAnchor" && !rProp.Value.get<OUString>().isEmpty())
{
OString sOrientation = OUStringToOString( rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
- attrListTablePos->add( FSNS( XML_w, XML_vertAnchor ), sOrientation.getStr() );
+ attrListTablePos->add(FSNS(XML_w, XML_vertAnchor), sOrientation);
}
else if (rProp.Name == "tblpYSpec" && !rProp.Value.get<OUString>().isEmpty())
{
OString sOrientation = OUStringToOString( rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
- attrListTablePos->add( FSNS( XML_w, XML_tblpYSpec ), sOrientation.getStr() );
+ attrListTablePos->add(FSNS(XML_w, XML_tblpYSpec), sOrientation);
}
else if (rProp.Name == "horzAnchor" && !rProp.Value.get<OUString>().isEmpty())
{
OString sOrientation = OUStringToOString( rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
- attrListTablePos->add( FSNS( XML_w, XML_horzAnchor ), sOrientation.getStr() );
+ attrListTablePos->add(FSNS(XML_w, XML_horzAnchor), sOrientation);
}
else if (rProp.Name == "tblpXSpec" && !rProp.Value.get<OUString>().isEmpty())
{
OString sOrientation = OUStringToOString( rProp.Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
- attrListTablePos->add( FSNS( XML_w, XML_tblpXSpec ), sOrientation.getStr() );
+ attrListTablePos->add(FSNS(XML_w, XML_tblpXSpec), sOrientation);
}
else if (rProp.Name == "bottomFromText")
{
@@ -5070,9 +5070,9 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
rtl::Reference<::sax_fastparser::FastAttributeList> docPrattrList = FastSerializerHelper::createAttrList();
docPrattrList->add( XML_id, OString::number( m_anchorId++).getStr());
docPrattrList->add( XML_name, OUStringToOString( pFrameFormat->GetName(), RTL_TEXTENCODING_UTF8 ) );
- docPrattrList->add( XML_descr, OUStringToOString( pGrfNode ? pGrfNode->GetDescription() : pOLEFrameFormat->GetObjDescription(), RTL_TEXTENCODING_UTF8 ).getStr());
+ docPrattrList->add( XML_descr, OUStringToOString( pGrfNode ? pGrfNode->GetDescription() : pOLEFrameFormat->GetObjDescription(), RTL_TEXTENCODING_UTF8 ));
if( GetExport().GetFilter().getVersion( ) != oox::core::ECMA_DIALECT )
- docPrattrList->add( XML_title, OUStringToOString( pGrfNode ? pGrfNode->GetTitle() : pOLEFrameFormat->GetObjTitle(), RTL_TEXTENCODING_UTF8 ).getStr());
+ docPrattrList->add( XML_title, OUStringToOString( pGrfNode ? pGrfNode->GetTitle() : pOLEFrameFormat->GetObjTitle(), RTL_TEXTENCODING_UTF8 ));
m_pSerializer->startElementNS( XML_wp, XML_docPr, docPrattrList );
OUString sURL, sRelId;
@@ -5696,14 +5696,14 @@ void DocxAttributeOutput::WriteOLEShape(const SwFlyFrameFormat& rFrameFormat, co
//Here is an attribute list where we collect the attributes what we want to export
rtl::Reference<FastAttributeList> pAttr = FastSerializerHelper::createAttrList();
- pAttr->add(XML_id, rShapeId.getStr());
+ pAttr->add(XML_id, rShapeId);
//export the fixed shape type for picture frame
m_pSerializer->write(vml::VMLExport::GetVMLShapeTypeDefinition(rShapeId, true));
pAttr->add(XML_type, "_x0000_t" + rShapeId);
//Export the style attribute for position and size
- pAttr->add(XML_style, GetOLEStyle(rFrameFormat, rSize).getStr());
+ pAttr->add(XML_style, GetOLEStyle(rFrameFormat, rSize));
//Get the OLE frame
const SvxBoxItem& rBox = rFrameFormat.GetAttrSet().GetBox();
OString sLineType;
@@ -6431,7 +6431,7 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType,
case STYLE_TYPE_LIST: pType = "numbering"; break;
}
pStyleAttributeList->add(FSNS( XML_w, XML_type ), pType);
- pStyleAttributeList->add(FSNS( XML_w, XML_styleId ), m_rExport.m_pStyles->GetStyleId(nId).getStr());
+ pStyleAttributeList->add(FSNS(XML_w, XML_styleId), m_rExport.m_pStyles->GetStyleId(nId));
if (bDefault)
pStyleAttributeList->add(FSNS(XML_w, XML_default), "1");
if (bCustomStyle)
@@ -6910,7 +6910,7 @@ void DocxAttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, const ::std
OString aCustomFormat;
OString aFormat(lcl_ConvertNumberingType(nNumType, nullptr, aCustomFormat));
if (!aFormat.isEmpty() && aCustomFormat.isEmpty())
- pAttr->add( FSNS( XML_w, XML_fmt ), aFormat.getStr() );
+ pAttr->add(FSNS(XML_w, XML_fmt), aFormat);
m_pSerializer->singleElementNS( XML_w, XML_pgNumType, pAttr );
@@ -6976,7 +6976,7 @@ void DocxAttributeOutput::FontCharset( sal_uInt8 nCharSet, rtl_TextEncoding nEnc
OString aCharSet( OString::number( nCharSet, 16 ) );
if ( aCharSet.getLength() == 1 )
aCharSet = "0" + aCharSet;
- pAttr->add( FSNS( XML_w, XML_val ), aCharSet.getStr());
+ pAttr->add(FSNS(XML_w, XML_val), aCharSet);
if( GetExport().GetFilter().getVersion( ) != oox::core::ECMA_DIALECT )
{
@@ -9097,14 +9097,14 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
if( !m_pBackgroundAttrList.is() )
{
m_pBackgroundAttrList = FastSerializerHelper::createAttrList();
- m_pBackgroundAttrList->add( FSNS( XML_w, XML_fill ), sColor.getStr() );
+ m_pBackgroundAttrList->add(FSNS(XML_w, XML_fill), sColor);
m_pBackgroundAttrList->add( FSNS( XML_w, XML_val ), "clear" );
}
else if ( sOriginalFill != sColor )
{
// fill was modified during edition, theme fill attribute must be dropped
m_pBackgroundAttrList = FastSerializerHelper::createAttrList();
- m_pBackgroundAttrList->add( FSNS( XML_w, XML_fill ), sColor.getStr() );
+ m_pBackgroundAttrList->add(FSNS(XML_w, XML_fill), sColor);
m_pBackgroundAttrList->add( FSNS( XML_w, XML_val ), "clear" );
}
m_sOriginalBackgroundColor.clear();
@@ -9419,7 +9419,7 @@ void DocxAttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid )
sGridType = OString( "linesAndChars" );
break;
}
- pGridAttrList->add( FSNS( XML_w, XML_type ), sGridType.getStr( ) );
+ pGridAttrList->add(FSNS(XML_w, XML_type), sGridType);
sal_uInt16 nHeight = rGrid.GetBaseHeight() + rGrid.GetRubyHeight();
pGridAttrList->add( FSNS( XML_w, XML_linePitch ),
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 90a0183817e4..1803ae90084a 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -979,8 +979,7 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrameFo
rtl::Reference<sax_fastparser::FastAttributeList> pDocPrAttrList
= sax_fastparser::FastSerializerHelper::createAttrList();
pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr());
- pDocPrAttrList->add(XML_name,
- OUStringToOString(pSdrObject->GetName(), RTL_TEXTENCODING_UTF8).getStr());
+ pDocPrAttrList->add(XML_name, OUStringToOString(pSdrObject->GetName(), RTL_TEXTENCODING_UTF8));
if (!pSdrObject->GetTitle().isEmpty())
pDocPrAttrList->add(XML_title,
OUStringToOString(pSdrObject->GetTitle(), RTL_TEXTENCODING_UTF8));
@@ -1356,8 +1355,8 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
rtl::Reference<sax_fastparser::FastAttributeList> pDocPrAttrList
= sax_fastparser::FastSerializerHelper::createAttrList();
pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr());
- pDocPrAttrList->add(
- XML_name, OUStringToOString(rFrameFormat.GetName(), RTL_TEXTENCODING_UTF8).getStr());
+ pDocPrAttrList->add(XML_name,
+ OUStringToOString(rFrameFormat.GetName(), RTL_TEXTENCODING_UTF8));
pFS->singleElementNS(XML_wp, XML_docPr, pDocPrAttrList);
pFS->startElementNS(XML_a, XML_graphic, FSNS(XML_xmlns, XML_a),
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index af6bf27a13c9..980891ffc175 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -2189,7 +2189,7 @@ void SAL_CALL SvXMLLegacyToFastDocHandler::startElement( const OUString& rName,
else
{
sal_Int32 const nAttr = NAMESPACE_TOKEN(nDefaultNamespace) | nToken;
- mxFastAttributes->add(nAttr, OUStringToOString(rAttrValue, RTL_TEXTENCODING_UTF8).getStr());
+ mxFastAttributes->add(nAttr, OUStringToOString(rAttrValue, RTL_TEXTENCODING_UTF8));
}
continue;
}
@@ -2211,7 +2211,7 @@ void SAL_CALL SvXMLLegacyToFastDocHandler::startElement( const OUString& rName,
else
{
sal_Int32 const nAttr = NAMESPACE_TOKEN(nAttrPrefix) | nToken;
- mxFastAttributes->add(nAttr, OUStringToOString(rAttrValue, RTL_TEXTENCODING_UTF8).getStr());
+ mxFastAttributes->add(nAttr, OUStringToOString(rAttrValue, RTL_TEXTENCODING_UTF8));
}
}
mrImport->startFastElement( mnElement, mxFastAttributes );
More information about the Libreoffice-commits
mailing list