diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-03-12 18:52:17 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-03-12 19:44:26 +0100 |
commit | de81df1f3f9b7660db450c638925f90adf9c026b (patch) | |
tree | cf72e7a09a39e9a910c85dc0d3e88fd10c4d03b4 /oox | |
parent | 128d3b454467e34538903b2eab45e866f976b314 (diff) |
Introduce FastAttributeList::add(NS) taking std::u16string_view
... and simplify some places removing explicit conversions from
OUString to OString.
Change-Id: I4cdf9f3ee3101b3d00a0bbba53a983ed3bebce4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131445
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 24 | ||||
-rw-r--r-- | oox/source/drawingml/textfield.cxx | 19 | ||||
-rw-r--r-- | oox/source/export/chartexport.cxx | 9 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 37 | ||||
-rw-r--r-- | oox/source/export/vmlexport.cxx | 41 |
5 files changed, 52 insertions, 78 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index fa9811f4e7fa..7c5fe9188b81 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -861,26 +861,24 @@ writeCustomProperties( XmlFilterBase& rSelf, const Reference< XDocumentPropertie { if ( !rProp.Name.isEmpty() ) { - // tdf#127864 - export custom document properties using utf8 text encoding - OString aName = OUStringToOString(rProp.Name, RTL_TEXTENCODING_UTF8); // Skip storing these values in Custom Properties as it will be stored in Core/Extended Properties - if (( aName == "OOXMLCorePropertyCategory" ) || // stored in cp:category - ( aName == "OOXMLCorePropertyContentStatus" ) || // stored in cp:contentStatus - ( aName == "OOXMLCorePropertyContentType" ) || // stored in cp:contentType - ( aName == "OOXMLCorePropertyIdentifier" ) || // stored in dc:identifier - ( aName == "OOXMLCorePropertyVersion" ) || // stored in cp:version - ( aName == "HyperlinkBase" ) || // stored in Extended File Properties - ( aName == "AppVersion" ) || // stored in Extended File Properties - ( aName == "DocSecurity" ) || // stored in Extended File Properties - ( aName == "Manager" ) || // stored in Extended File Properties - ( aName == "Company" )) // stored in Extended File Properties + if (( rProp.Name == "OOXMLCorePropertyCategory" ) || // stored in cp:category + ( rProp.Name == "OOXMLCorePropertyContentStatus" ) || // stored in cp:contentStatus + ( rProp.Name == "OOXMLCorePropertyContentType" ) || // stored in cp:contentType + ( rProp.Name == "OOXMLCorePropertyIdentifier" ) || // stored in dc:identifier + ( rProp.Name == "OOXMLCorePropertyVersion" ) || // stored in cp:version + ( rProp.Name == "HyperlinkBase" ) || // stored in Extended File Properties + ( rProp.Name == "AppVersion" ) || // stored in Extended File Properties + ( rProp.Name == "DocSecurity" ) || // stored in Extended File Properties + ( rProp.Name == "Manager" ) || // stored in Extended File Properties + ( rProp.Name == "Company" )) // stored in Extended File Properties continue; // pid starts from 2 not from 1 as MS supports pid from 2 pAppProps->startElement( XML_property , XML_fmtid, "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}", XML_pid, OString::number(nIndex + 2), - XML_name, aName); + XML_name, rProp.Name); switch ( rProp.Value.getValueTypeClass() ) { diff --git a/oox/source/drawingml/textfield.cxx b/oox/source/drawingml/textfield.cxx index 405a874d8e57..4fc86776ad1f 100644 --- a/oox/source/drawingml/textfield.cxx +++ b/oox/source/drawingml/textfield.cxx @@ -67,11 +67,10 @@ void lclCreateTextFields( std::vector< Reference< XTextField > > & aFields, Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW ); if( o3tl::starts_with(sType, u"datetime")) { - OString s = OUStringToOString( sType, RTL_TEXTENCODING_UTF8); - OString p( s.pData->buffer + 8 ); + auto p = sType.substr(8); try { - if(p.startsWith("'")) + if (o3tl::starts_with(p, u"'")) { xIface = xFactory->createInstance( "com.sun.star.text.TextField.Custom" ); aFields.emplace_back( xIface, UNO_QUERY ); @@ -122,9 +121,7 @@ void lclCreateTextFields( std::vector< Reference< XTextField > > & aFields, } else if ( o3tl::starts_with(sType, u"file") ) { - OString s = OUStringToOString( sType, RTL_TEXTENCODING_UTF8); - OString p( s.pData->buffer + 4 ); - int idx = p.toInt32(); + int idx = rtl_ustr_toInt32(sType.data() + 4, 10); xIface = xFactory->createInstance( "com.sun.star.text.TextField.FileName" ); aFields.emplace_back( xIface, UNO_QUERY ); Reference< XPropertySet > xProps( xIface, UNO_QUERY_THROW ); @@ -213,12 +210,12 @@ sal_Int32 TextField::insertAt( SvxDateFormat TextField::getLODateFormat(std::u16string_view rDateTimeType) { - OString aDateTimeNum = OUStringToOString(rDateTimeType.substr(8), RTL_TEXTENCODING_UTF8); + auto aDateTimeNum = rDateTimeType.substr(8); - if( aDateTimeNum.isEmpty() ) // "datetime" + if( aDateTimeNum.empty() ) // "datetime" return SvxDateFormat::StdSmall; - int nDateTimeNum = aDateTimeNum.toInt32(); + int nDateTimeNum = rtl_ustr_toInt32(aDateTimeNum.data(), 10); switch( nDateTimeNum ) { @@ -246,8 +243,8 @@ SvxDateFormat TextField::getLODateFormat(std::u16string_view rDateTimeType) SvxTimeFormat TextField::getLOTimeFormat(std::u16string_view rDateTimeType) { - OString aDateTimeNum = OUStringToOString(rDateTimeType.substr(8), RTL_TEXTENCODING_UTF8); - int nDateTimeNum = aDateTimeNum.toInt32(); + auto aDateTimeNum = rDateTimeType.substr(8); + int nDateTimeNum = rtl_ustr_toInt32(aDateTimeNum.data(), 10); switch( nDateTimeNum ) { diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 8dd99152aadf..dde654497cf8 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -3350,9 +3350,8 @@ void ChartExport::_exportAxis( aNumberFormatString = getNumberFormatCode(nKey); } - OString sNumberFormatString = OUStringToOString(aNumberFormatString, RTL_TEXTENCODING_UTF8); pFS->singleElement(FSNS(XML_c, XML_numFmt), - XML_formatCode, sNumberFormatString.getStr(), + XML_formatCode, aNumberFormatString, XML_sourceLinked, bLinkedNumFmt ? "1" : "0"); // majorTickMark @@ -3881,10 +3880,9 @@ void ChartExport::exportDataLabels( mAny >>= nKey; OUString aNumberFormatString = getNumberFormatCode(nKey); - OString sNumberFormatString = OUStringToOString(aNumberFormatString, RTL_TEXTENCODING_UTF8); pFS->singleElement(FSNS(XML_c, XML_numFmt), - XML_formatCode, sNumberFormatString, + XML_formatCode, aNumberFormatString, XML_sourceLinked, ToPsz10(bLinkedNumFmt)); } @@ -3978,9 +3976,8 @@ void ChartExport::exportDataLabels( mAny >>= nKey; OUString aNumberFormatString = getNumberFormatCode(nKey); - OString sNumberFormatString = OUStringToOString(aNumberFormatString, RTL_TEXTENCODING_UTF8); - pFS->singleElement(FSNS(XML_c, XML_numFmt), XML_formatCode, sNumberFormatString.getStr(), + pFS->singleElement(FSNS(XML_c, XML_numFmt), XML_formatCode, aNumberFormatString, XML_sourceLinked, ToPsz10(bLinkedNumFmt)); } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 835654d7f3a2..e723a27a3445 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -4375,7 +4375,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 ) ); + aOuterShdwAttrList->add( XML_algn, sVal ); } else if( rOuterShdwProp.Name == "blurRad" ) { @@ -4786,7 +4786,7 @@ void DrawingML::Write3DEffects( const Reference< XPropertySet >& xPropSet, bool { OUString sVal; rEffectProp.Value >>= sVal; - aCameraAttrList->add(XML_prst, OUStringToOString(sVal, RTL_TEXTENCODING_UTF8)); + aCameraAttrList->add(XML_prst, sVal); } else if( rEffectProp.Name == "fov" ) { @@ -4831,7 +4831,7 @@ void DrawingML::Write3DEffects( const Reference< XPropertySet >& xPropSet, bool nToken = XML_rig; else if( rLightRigProp.Name == "dir" ) nToken = XML_dir; - aLightRigAttrList->add(nToken, OUStringToOString(sVal, RTL_TEXTENCODING_UTF8)); + aLightRigAttrList->add(nToken, sVal); } else if( rLightRigProp.Name == "rotLat" || rLightRigProp.Name == "rotLon" || @@ -4910,7 +4910,7 @@ void DrawingML::Write3DEffects( const Reference< XPropertySet >& xPropSet, bool { OUString sVal; rShape3DProp.Value >>= sVal; - aShape3DAttrList->add(XML_prstMaterial, OUStringToOString(sVal, RTL_TEXTENCODING_UTF8)); + aShape3DAttrList->add(XML_prstMaterial, sVal); } else if( rShape3DProp.Name == "extrusionClr" ) { @@ -4954,7 +4954,7 @@ void DrawingML::Write3DEffects( const Reference< XPropertySet >& xPropSet, bool { OUString sVal; rBevelProp.Value >>= sVal; - aBevelAttrList->add(XML_prst, OUStringToOString(sVal, RTL_TEXTENCODING_UTF8)); + aBevelAttrList->add(XML_prst, sVal); } } @@ -5159,8 +5159,8 @@ void DrawingML::WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rX rtl::Reference<sax_fastparser::FastAttributeList> pDocPrAttrList = 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)); + OString sName = "Diagram" + OString::number(nDiagramId); + pDocPrAttrList->add(XML_name, sName); if (GetDocumentType() == DOCUMENT_DOCX) { @@ -5215,34 +5215,27 @@ void DrawingML::WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rX // add data relation OUString dataFileName = "diagrams/data" + OUString::number(nDiagramId) + ".xml"; - OString dataRelId = OUStringToOString( + OUString dataRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(Relationship::DIAGRAMDATA), - OUStringConcatenation(sRelationCompPrefix + dataFileName)), - RTL_TEXTENCODING_UTF8); + OUStringConcatenation(sRelationCompPrefix + dataFileName)); // add layout relation OUString layoutFileName = "diagrams/layout" + OUString::number(nDiagramId) + ".xml"; - OString layoutRelId - = OUStringToOString(mpFB->addRelation(mpFS->getOutputStream(), + OUString layoutRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(Relationship::DIAGRAMLAYOUT), - OUStringConcatenation(sRelationCompPrefix + layoutFileName)), - RTL_TEXTENCODING_UTF8); + OUStringConcatenation(sRelationCompPrefix + layoutFileName)); // add style relation OUString styleFileName = "diagrams/quickStyle" + OUString::number(nDiagramId) + ".xml"; - OString styleRelId - = OUStringToOString(mpFB->addRelation(mpFS->getOutputStream(), + OUString styleRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(Relationship::DIAGRAMQUICKSTYLE), - OUStringConcatenation(sRelationCompPrefix + styleFileName)), - RTL_TEXTENCODING_UTF8); + OUStringConcatenation(sRelationCompPrefix + styleFileName)); // add color relation OUString colorFileName = "diagrams/colors" + OUString::number(nDiagramId) + ".xml"; - OString colorRelId - = OUStringToOString(mpFB->addRelation(mpFS->getOutputStream(), + OUString colorRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(Relationship::DIAGRAMCOLORS), - OUStringConcatenation(sRelationCompPrefix + colorFileName)), - RTL_TEXTENCODING_UTF8); + OUStringConcatenation(sRelationCompPrefix + colorFileName)); OUString drawingFileName; if (drawingDom.is()) diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index f00d59f4159e..c23604b6cb19 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -140,14 +140,14 @@ sal_uInt32 VMLExport::EnterGroup( const OUString& rShapeName, const tools::Recta pAttrList->add( XML_id, ShapeIdString( nShapeId ) ); if ( rShapeName.getLength() ) - pAttrList->add( XML_alt, OUStringToOString( rShapeName, RTL_TEXTENCODING_UTF8 ) ); + pAttrList->add( XML_alt, rShapeName ); bool rbAbsolutePos = true; //editAs OUString rEditAs = EscherEx::GetEditAs(); if (!rEditAs.isEmpty()) { - pAttrList->add(XML_editas, OUStringToOString( rEditAs, RTL_TEXTENCODING_UTF8 )); + pAttrList->add(XML_editas, rEditAs); rbAbsolutePos = false; } @@ -197,7 +197,7 @@ void VMLExport::AddShape( sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt else { // A watermark object - store the optional shape ID - m_pShapeAttrList->add( XML_id, OUStringToOString(m_pSdrObject->GetName(), RTL_TEXTENCODING_UTF8) ); + m_pShapeAttrList->add( XML_id, m_pSdrObject->GetName() ); // also ('o:spid') m_pShapeAttrList->addNS( XML_o, XML_spid, m_sShapeId ); } @@ -675,41 +675,32 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& if (!pSdrGrafObj->getSignatureLineId().isEmpty()) { pAttrListSignatureLine->add( - XML_id, OUStringToOString(pSdrGrafObj->getSignatureLineId(), - RTL_TEXTENCODING_UTF8)); + XML_id, pSdrGrafObj->getSignatureLineId()); } if (!pSdrGrafObj->getSignatureLineSuggestedSignerName().isEmpty()) { pAttrListSignatureLine->add( FSNS(XML_o, XML_suggestedsigner), - OUStringToOString( - pSdrGrafObj->getSignatureLineSuggestedSignerName(), - RTL_TEXTENCODING_UTF8)); + pSdrGrafObj->getSignatureLineSuggestedSignerName()); } if (!pSdrGrafObj->getSignatureLineSuggestedSignerTitle().isEmpty()) { pAttrListSignatureLine->add( FSNS(XML_o, XML_suggestedsigner2), - OUStringToOString( - pSdrGrafObj->getSignatureLineSuggestedSignerTitle(), - RTL_TEXTENCODING_UTF8)); + pSdrGrafObj->getSignatureLineSuggestedSignerTitle()); } if (!pSdrGrafObj->getSignatureLineSuggestedSignerEmail().isEmpty()) { pAttrListSignatureLine->add( FSNS(XML_o, XML_suggestedsigneremail), - OUStringToOString( - pSdrGrafObj->getSignatureLineSuggestedSignerEmail(), - RTL_TEXTENCODING_UTF8)); + pSdrGrafObj->getSignatureLineSuggestedSignerEmail()); } if (!pSdrGrafObj->getSignatureLineSigningInstructions().isEmpty()) { pAttrListSignatureLine->add(XML_signinginstructionsset, "t"); pAttrListSignatureLine->add( FSNS(XML_o, XML_signinginstructions), - OUStringToOString( - pSdrGrafObj->getSignatureLineSigningInstructions(), - RTL_TEXTENCODING_UTF8)); + pSdrGrafObj->getSignatureLineSigningInstructions()); } pAttrListSignatureLine->add( XML_showsigndate, @@ -735,8 +726,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& aImageId = m_pTextExport->GetDrawingML().WriteImage(aGraphic, false, &aFileName); m_pTextExport->CacheRelId(nChecksum, aImageId, aFileName); } - pAttrList->add(FSNS(XML_r, XML_id), - OUStringToOString(aImageId, RTL_TEXTENCODING_UTF8)); + pAttrList->add(FSNS(XML_r, XML_id), aImageId); imageData = true; } else if (rProps.GetOpt(ESCHER_Prop_fillBlip, aStruct) && m_pTextExport) @@ -758,8 +748,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& aImageId = m_pTextExport->GetDrawingML().WriteImage(aGraphic, false, &aFileName); m_pTextExport->CacheRelId(nChecksum, aImageId, aFileName); } - pAttrList->add(FSNS(XML_r, XML_id), - OUStringToOString(aImageId, RTL_TEXTENCODING_UTF8)); + pAttrList->add(FSNS(XML_r, XML_id), aImageId); imageData = true; } @@ -970,7 +959,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& rtl::Reference<sax_fastparser::FastAttributeList> pAttrList = FastSerializerHelper::createAttrList(); pAttrList->add(XML_on, "t"); pAttrList->add(XML_fitshape, "t"); - pAttrList->add(XML_string, OUStringToOString(aTextPathString, RTL_TEXTENCODING_UTF8)); + pAttrList->add(XML_string, aTextPathString); EscherPropSortStruct aFont; OUString aStyle; if (rProps.GetOpt(ESCHER_Prop_gtextFont, aFont)) @@ -991,7 +980,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle& pAttrList->add(XML_trim, "t"); if (!aStyle.isEmpty()) - pAttrList->add(XML_style, OUStringToOString(aStyle, RTL_TEXTENCODING_UTF8)); + pAttrList->add(XML_style, aStyle); m_pSerializer->singleElementNS(XML_v, XML_textpath, pAttrList); } @@ -1026,7 +1015,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)); + m_pShapeAttrList->add(XML_ID, idStr); bAlreadyWritten[ESCHER_Prop_wzName] = true; } @@ -1388,7 +1377,7 @@ sal_Int32 VMLExport::StartShape() if (!m_pSdrObject->getHyperlink().isEmpty()) m_pShapeAttrList->add( - XML_href, OUStringToOString(m_pSdrObject->getHyperlink(), RTL_TEXTENCODING_UTF8)); + XML_href, m_pSdrObject->getHyperlink()); m_pShapeAttrList->addNS(XML_o, XML_allowincell, m_IsFollowingTextFlow ? "t" : "f"); @@ -1397,7 +1386,7 @@ sal_Int32 VMLExport::StartShape() OUString sAnchorId = lcl_getAnchorIdFromGrabBag(m_pSdrObject); if (!sAnchorId.isEmpty()) - m_pShapeAttrList->addNS(XML_wp14, XML_anchorId, OUStringToOString(sAnchorId, RTL_TEXTENCODING_UTF8)); + m_pShapeAttrList->addNS(XML_wp14, XML_anchorId, sAnchorId); if ( nShapeElement >= 0 && !m_pShapeAttrList->hasAttribute( XML_type ) && bReferToShapeType ) { |