diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-03-27 16:52:50 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-04-01 12:09:59 +0200 |
commit | 0267a2326b5282023e8b08a147eca178c5db1980 (patch) | |
tree | c1a1643ffa5fd49236048bc9c5ed76e9c442e3e0 | |
parent | 5c725eb7dee248c6d1792a9b9b9a9c813ca627e6 (diff) |
Get rid of XclXmlUtils::ToOString(const OUString& s)
The helper function is used in export code to convert UTF-16 internal
string representation to UTF-8 used in XML encoding. I suppose that all
strings here should be already valid UTF-16 (an invalid input should
have been validated at import/input stage). An invalid string at this
stage means a programming error in another part of code that breaks this
precondition, and should not be handled at export stage.
This effectively changes flags used in conversion from UTF-16 to UTF-8,
so that now RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR is used instead of
RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT, so that the result would be
truncated on invalid bytes instead of inserting U+FFFD, and would fail
assertion in debug builds.
Other changed flags don't affect UTF-16-to-UTF-8 conversion.
Change-Id: I8b154249e66ee32b531b8ab503e0222b9108d829
Reviewed-on: https://gerrit.libreoffice.org/69830
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sc/source/filter/excel/excdoc.cxx | 8 | ||||
-rw-r--r-- | sc/source/filter/excel/excrecds.cxx | 16 | ||||
-rw-r--r-- | sc/source/filter/excel/xecontent.cxx | 14 | ||||
-rw-r--r-- | sc/source/filter/excel/xedbdata.cxx | 8 | ||||
-rw-r--r-- | sc/source/filter/excel/xeescher.cxx | 14 | ||||
-rw-r--r-- | sc/source/filter/excel/xeextlst.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/excel/xelink.cxx | 10 | ||||
-rw-r--r-- | sc/source/filter/excel/xename.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xepivotxml.cxx | 32 | ||||
-rw-r--r-- | sc/source/filter/excel/xestream.cxx | 11 | ||||
-rw-r--r-- | sc/source/filter/excel/xestyle.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/inc/xestream.hxx | 1 | ||||
-rw-r--r-- | sc/source/filter/xcl97/XclExpChangeTrack.cxx | 18 | ||||
-rw-r--r-- | sc/source/filter/xcl97/xcl97rec.cxx | 22 |
14 files changed, 81 insertions, 87 deletions
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index c036b860413d..759c6d3caa82 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -687,8 +687,8 @@ void ExcTable::WriteXml( XclExpXmlStream& rStrm ) rStrm.PushStream( pWorksheet ); pWorksheet->startElement( XML_worksheet, - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), - FSNS( XML_xmlns, XML_r ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(officeRel))).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), + FSNS(XML_xmlns, XML_r), rStrm.getNamespaceURL(OOX_NS(officeRel)).toUtf8(), FSEND ); SetCurrScTab( mnScTab ); @@ -807,8 +807,8 @@ void ExcDocument::WriteXml( XclExpXmlStream& rStrm ) sax_fastparser::FSHelperPtr& rWorkbook = rStrm.GetCurrentStream(); rWorkbook->startElement( XML_workbook, - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), - FSNS(XML_xmlns, XML_r), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(officeRel))).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), + FSNS(XML_xmlns, XML_r), rStrm.getNamespaceURL(OOX_NS(officeRel)).toUtf8(), FSEND ); rWorkbook->singleElement( XML_fileVersion, XML_appName, "Calc", diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index f2b11b0bdd1c..07926576e087 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -449,9 +449,9 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm ) } sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); rWorksheet->singleElement( XML_sheetProtection, - XML_algorithmName, aPH.maAlgorithmName.isEmpty() ? nullptr : XclXmlUtils::ToOString( aPH.maAlgorithmName).getStr(), - XML_hashValue, aPH.maHashValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( aPH.maHashValue).getStr(), - XML_saltValue, aPH.maSaltValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( aPH.maSaltValue).getStr(), + XML_algorithmName, aPH.maAlgorithmName.isEmpty() ? nullptr : aPH.maAlgorithmName.toUtf8().getStr(), + XML_hashValue, aPH.maHashValue.isEmpty() ? nullptr : aPH.maHashValue.toUtf8().getStr(), + XML_saltValue, aPH.maSaltValue.isEmpty() ? nullptr : aPH.maSaltValue.toUtf8().getStr(), XML_spinCount, aPH.mnSpinCount ? OString::number( aPH.mnSpinCount).getStr() : nullptr, XML_sheet, ToPsz( true ), XML_password, sHash.isEmpty()? nullptr : sHash.getStr(), @@ -481,16 +481,16 @@ void XclExpSheetProtection::SaveXml( XclExpXmlStream& rStrm ) SAL_WARN_IF( rProt.maSecurityDescriptorXML.isEmpty() && !rProt.maSecurityDescriptor.empty(), "sc.filter", "XclExpSheetProtection::SaveXml: losing BIFF security descriptor"); rWorksheet->singleElement( XML_protectedRange, - XML_name, rProt.maTitle.isEmpty() ? nullptr : XclXmlUtils::ToOString( rProt.maTitle).getStr(), - XML_securityDescriptor, rProt.maSecurityDescriptorXML.isEmpty() ? nullptr : XclXmlUtils::ToOString( rProt.maSecurityDescriptorXML).getStr(), + XML_name, rProt.maTitle.isEmpty() ? nullptr : rProt.maTitle.toUtf8().getStr(), + XML_securityDescriptor, rProt.maSecurityDescriptorXML.isEmpty() ? nullptr : rProt.maSecurityDescriptorXML.toUtf8().getStr(), /* XXX 'password' is not part of OOXML, but Excel2013 * writes it if loaded from BIFF, in which case * 'algorithmName', 'hashValue', 'saltValue' and * 'spinCount' are absent; so do we if it was present. */ XML_password, rProt.mnPasswordVerifier ? OString::number( rProt.mnPasswordVerifier, 16).getStr() : nullptr, - XML_algorithmName, rProt.maPasswordHash.maAlgorithmName.isEmpty() ? nullptr : XclXmlUtils::ToOString( rProt.maPasswordHash.maAlgorithmName).getStr(), - XML_hashValue, rProt.maPasswordHash.maHashValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( rProt.maPasswordHash.maHashValue).getStr(), - XML_saltValue, rProt.maPasswordHash.maSaltValue.isEmpty() ? nullptr : XclXmlUtils::ToOString( rProt.maPasswordHash.maSaltValue).getStr(), + XML_algorithmName, rProt.maPasswordHash.maAlgorithmName.isEmpty() ? nullptr : rProt.maPasswordHash.maAlgorithmName.toUtf8().getStr(), + XML_hashValue, rProt.maPasswordHash.maHashValue.isEmpty() ? nullptr : rProt.maPasswordHash.maHashValue.toUtf8().getStr(), + XML_saltValue, rProt.maPasswordHash.maSaltValue.isEmpty() ? nullptr : rProt.maPasswordHash.maSaltValue.toUtf8().getStr(), XML_spinCount, rProt.maPasswordHash.mnSpinCount ? OString::number( rProt.maPasswordHash.mnSpinCount).getStr() : nullptr, XML_sqref, rProt.maRangeList.is() ? XclXmlUtils::ToOString( *rProt.maRangeList).getStr() : nullptr, FSEND); diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 4d3b12d9b123..b1b3b9a5d3ca 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -209,7 +209,7 @@ void XclExpSstImpl::SaveXml( XclExpXmlStream& rStrm ) rStrm.PushStream( pSst ); pSst->startElement( XML_sst, - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), XML_count, OString::number( mnTotal ).getStr(), XML_uniqueCount, OString::number( mnSize ).getStr(), FSEND ); @@ -524,13 +524,13 @@ void XclExpHyperlink::SaveXml( XclExpXmlStream& rStrm ) rStrm.GetCurrentStream()->singleElement( XML_hyperlink, XML_ref, XclXmlUtils::ToOString( maScPos ).getStr(), FSNS( XML_r, XML_id ), !sId.isEmpty() - ? XclXmlUtils::ToOString( sId ).getStr() + ? sId.toUtf8().getStr() : nullptr, XML_location, mxTextMark.get() != nullptr ? XclXmlUtils::ToOString( *mxTextMark ).getStr() : nullptr, // OOXTODO: XML_tooltip, from record HLinkTooltip 800h wzTooltip - XML_display, XclXmlUtils::ToOString(m_Repr).getStr(), + XML_display, m_Repr.toUtf8(), FSEND ); } @@ -1027,7 +1027,7 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm ) { // position and formula grammar are not important // we only store a number there - aRank = XclXmlUtils::ToOString(mrFormatEntry.GetExpression(ScAddress(0,0,0), 0)); + aRank = mrFormatEntry.GetExpression(ScAddress(0,0,0), 0).toUtf8(); } OString aText; if(IsTextRule(eOperation)) @@ -1037,7 +1037,7 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm ) // the token array for that std::unique_ptr<ScTokenArray> pTokenArray(mrFormatEntry.CreateFlatCopiedTokenArray(0)); if(pTokenArray->GetLen()) - aText = XclXmlUtils::ToOString(pTokenArray->FirstToken()->GetString().getString()); + aText = pTokenArray->FirstToken()->GetString().getString().toUtf8(); } sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); @@ -1409,7 +1409,7 @@ void XclExpCondfmt::SaveXml( XclExpXmlStream& rStrm ) sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); rWorksheet->startElement( XML_conditionalFormatting, - XML_sqref, XclXmlUtils::ToOString( msSeqRef ).getStr(), + XML_sqref, msSeqRef.toUtf8(), // OOXTODO: XML_pivot, FSEND ); @@ -1497,7 +1497,7 @@ void XclExpDataBar::SaveXml( XclExpXmlStream& rStrm ) // extLst entries for Excel 2010 and 2013 rWorksheet->startElement( XML_extLst, FSEND ); rWorksheet->startElement( XML_ext, - FSNS( XML_xmlns, XML_x14 ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls14Lst))).getStr(), + FSNS(XML_xmlns, XML_x14), rStrm.getNamespaceURL(OOX_NS(xls14Lst)).toUtf8(), XML_uri, "{B025F937-C7B1-47D3-B67F-A62EFF666E3E}", FSEND ); diff --git a/sc/source/filter/excel/xedbdata.cxx b/sc/source/filter/excel/xedbdata.cxx index 909e2ed586f8..e60bf5a14086 100644 --- a/sc/source/filter/excel/xedbdata.cxx +++ b/sc/source/filter/excel/xedbdata.cxx @@ -80,7 +80,7 @@ void XclExpTablesImpl8::SaveXml( XclExpXmlStream& rStrm ) &aRelId); pWorksheetStrm->singleElement( XML_tablePart, - FSNS(XML_r, XML_id), XclXmlUtils::ToOString(aRelId).getStr(), + FSNS(XML_r, XML_id), aRelId.toUtf8(), FSEND); rStrm.PushStream( pTableStrm); @@ -180,10 +180,10 @@ void XclExpTables::SaveTableXml( XclExpXmlStream& rStrm, const Entry& rEntry ) rData.GetArea( aRange); sax_fastparser::FSHelperPtr& pTableStrm = rStrm.GetCurrentStream(); pTableStrm->startElement( XML_table, - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), XML_id, OString::number( rEntry.mnTableId).getStr(), - XML_name, XclXmlUtils::ToOString( rData.GetName()).getStr(), - XML_displayName, XclXmlUtils::ToOString( rData.GetName()).getStr(), + XML_name, rData.GetName().toUtf8(), + XML_displayName, rData.GetName().toUtf8(), XML_ref, XclXmlUtils::ToOString(aRange), XML_headerRowCount, ToPsz10(rData.HasHeader()), XML_totalsRowCount, ToPsz10(rData.HasTotals()), diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 6be071381023..1780e00efc9e 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -438,7 +438,7 @@ void XclExpImgData::SaveXml( XclExpXmlStream& rStrm ) DrawingML aDML(pWorksheet, &rStrm, drawingml::DOCUMENT_XLSX); OUString rId = aDML.WriteImage( maGraphic ); pWorksheet->singleElement( XML_picture, - FSNS( XML_r, XML_id ), XclXmlUtils::ToOString( rId ).getStr(), + FSNS(XML_r, XML_id), rId.toUtf8(), FSEND ); } @@ -1422,16 +1422,16 @@ void XclExpComments::SaveXml( XclExpXmlStream& rStrm ) if( rStrm.getVersion() == oox::core::ISOIEC_29500_2008 ) rComments->startElement( XML_comments, - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), - FSNS( XML_xmlns, XML_mc ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(mce))).getStr(), - FSNS( XML_xmlns, XML_xdr ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(dmlSpreadDr))).getStr(), - FSNS( XML_xmlns, XML_v2 ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(mceTest))).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), + FSNS(XML_xmlns, XML_mc), rStrm.getNamespaceURL(OOX_NS(mce)).toUtf8(), + FSNS(XML_xmlns, XML_xdr), rStrm.getNamespaceURL(OOX_NS(dmlSpreadDr)).toUtf8(), + FSNS(XML_xmlns, XML_v2), rStrm.getNamespaceURL(OOX_NS(mceTest)).toUtf8(), FSNS( XML_mc, XML_Ignorable ), "v2", FSEND ); else rComments->startElement( XML_comments, - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), - FSNS( XML_xmlns, XML_xdr ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(dmlSpreadDr))).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), + FSNS(XML_xmlns, XML_xdr), rStrm.getNamespaceURL(OOX_NS(dmlSpreadDr)).toUtf8(), FSEND ); rComments->startElement( XML_authors, FSEND ); diff --git a/sc/source/filter/excel/xeextlst.cxx b/sc/source/filter/excel/xeextlst.cxx index 42aecd99b1f0..0dcd70e6fa4b 100644 --- a/sc/source/filter/excel/xeextlst.cxx +++ b/sc/source/filter/excel/xeextlst.cxx @@ -332,7 +332,7 @@ void XclExpExtConditionalFormatting::SaveXml( XclExpXmlStream& rStrm ) { sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); rWorksheet->startElementNS( XML_x14, XML_conditionalFormatting, - FSNS( XML_xmlns, XML_xm ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xm))).getStr(), + FSNS( XML_xmlns, XML_xm ), rStrm.getNamespaceURL(OOX_NS(xm)).toUtf8(), FSEND ); maCfRules.SaveXml( rStrm ); @@ -377,7 +377,7 @@ void XclExpExtCalcPr::SaveXml( XclExpXmlStream& rStrm ) { sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); rWorksheet->startElement( XML_ext, - FSNS( XML_xmlns, XML_loext ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(loext))).getStr(), + FSNS(XML_xmlns, XML_loext), rStrm.getNamespaceURL(OOX_NS(loext)).toUtf8(), XML_uri, maURI.getStr(), FSEND ); @@ -398,7 +398,7 @@ void XclExpExtCondFormat::SaveXml( XclExpXmlStream& rStrm ) { sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); rWorksheet->startElement( XML_ext, - FSNS( XML_xmlns, XML_x14 ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls14Lst))).getStr(), + FSNS(XML_xmlns, XML_x14), rStrm.getNamespaceURL(OOX_NS(xls14Lst)).toUtf8(), XML_uri, maURI.getStr(), FSEND ); diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx index 084277320706..73e3cc36b052 100644 --- a/sc/source/filter/excel/xelink.cxx +++ b/sc/source/filter/excel/xelink.cxx @@ -1057,7 +1057,7 @@ void XclExpExtName::SaveXml(XclExpXmlStream& rStrm) sax_fastparser::FSHelperPtr pExternalLink = rStrm.GetCurrentStream(); pExternalLink->startElement(XML_definedName, - XML_name, XclXmlUtils::ToOString(maName).getStr(), + XML_name, maName.toUtf8(), XML_refersTo, nullptr, XML_sheetId, nullptr, FSEND); @@ -1690,12 +1690,12 @@ void XclExpSupbook::SaveXml( XclExpXmlStream& rStrm ) true ); pExternalLink->startElement( XML_externalLink, - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), FSEND); pExternalLink->startElement( XML_externalBook, - FSNS(XML_xmlns, XML_r), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(officeRel))).getStr(), - FSNS(XML_r, XML_id), XclXmlUtils::ToOString( sId ).getStr(), + FSNS(XML_xmlns, XML_r), rStrm.getNamespaceURL(OOX_NS(officeRel)).toUtf8(), + FSNS(XML_r, XML_id), sId.toUtf8(), FSEND); if (!maXctList.IsEmpty()) @@ -2114,7 +2114,7 @@ void XclExpSupbookBuffer::SaveXml( XclExpXmlStream& rStrm ) // externalReference entry in workbook externalReferences rStrm.GetCurrentStream()->singleElement( XML_externalReference, - FSNS( XML_r, XML_id ), XclXmlUtils::ToOString( sId ).getStr(), + FSNS(XML_r, XML_id), sId.toUtf8(), FSEND ); // Each externalBook in a separate stream. diff --git a/sc/source/filter/excel/xename.cxx b/sc/source/filter/excel/xename.cxx index 0ee0da0d05b4..625578743f80 100644 --- a/sc/source/filter/excel/xename.cxx +++ b/sc/source/filter/excel/xename.cxx @@ -306,7 +306,7 @@ void XclExpName::SaveXml( XclExpXmlStream& rStrm ) // OOXTODO: XML_help, "", XML_hidden, ToPsz( ::get_flag( mnFlags, EXC_NAME_HIDDEN ) ), XML_localSheetId, mnScTab == SCTAB_GLOBAL ? nullptr : OString::number( mnScTab ).getStr(), - XML_name, XclXmlUtils::ToOString( maOrigName ).getStr(), + XML_name, maOrigName.toUtf8(), // OOXTODO: XML_publishToServer, "", // OOXTODO: XML_shortcutKey, "", // OOXTODO: XML_statusBar, "", diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx index 30fadd4ad722..30d4fa7a8424 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -40,8 +40,8 @@ void savePivotCacheRecordsXml( XclExpXmlStream& rStrm, const ScDPCache& rCache ) sax_fastparser::FSHelperPtr& pRecStrm = rStrm.GetCurrentStream(); pRecStrm->startElement(XML_pivotCacheRecords, - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), - FSNS(XML_xmlns, XML_r), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(officeRel))).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), + FSNS(XML_xmlns, XML_r), rStrm.getNamespaceURL(OOX_NS(officeRel)).toUtf8(), XML_count, OString::number(static_cast<long>(nCount)).getStr(), FSEND); @@ -142,7 +142,7 @@ void XclExpXmlPivotCaches::SaveXml( XclExpXmlStream& rStrm ) pWorkbookStrm->singleElement(XML_pivotCache, XML_cacheId, OString::number(nCacheId).getStr(), - FSNS(XML_r, XML_id), XclXmlUtils::ToOString(aRelId).getStr(), + FSNS(XML_r, XML_id), aRelId.toUtf8(), FSEND); rStrm.PushStream(pPCStrm); @@ -218,9 +218,9 @@ void XclExpXmlPivotCaches::SavePivotCacheXml( XclExpXmlStream& rStrm, const Entr rStrm.PopStream(); pDefStrm->startElement(XML_pivotCacheDefinition, - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), - FSNS(XML_xmlns, XML_r), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(officeRel))).getStr(), - FSNS(XML_r, XML_id), XclXmlUtils::ToOString(aRelId).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), + FSNS(XML_xmlns, XML_r), rStrm.getNamespaceURL(OOX_NS(officeRel)).toUtf8(), + FSNS(XML_r, XML_id), aRelId.toUtf8(), XML_recordCount, OString::number(rEntry.mpCache->GetDataSize()).getStr(), XML_createdVersion, "3", // MS Excel 2007, tdf#112936: setting version number makes MSO to handle the pivot table differently FSEND); @@ -233,7 +233,7 @@ void XclExpXmlPivotCaches::SavePivotCacheXml( XclExpXmlStream& rStrm, const Entr GetDoc().GetName(rEntry.maSrcRange.aStart.Tab(), aSheetName); pDefStrm->singleElement(XML_worksheetSource, XML_ref, XclXmlUtils::ToOString(rEntry.maSrcRange).getStr(), - XML_sheet, XclXmlUtils::ToOString(aSheetName).getStr(), + XML_sheet, aSheetName.toUtf8(), FSEND); pDefStrm->endElement(XML_cacheSource); @@ -248,7 +248,7 @@ void XclExpXmlPivotCaches::SavePivotCacheXml( XclExpXmlStream& rStrm, const Entr OUString aName = rCache.GetDimensionName(i); pDefStrm->startElement(XML_cacheField, - XML_name, XclXmlUtils::ToOString(aName).getStr(), + XML_name, aName.toUtf8(), XML_numFmtId, OString::number(0).getStr(), FSEND); @@ -344,8 +344,8 @@ void XclExpXmlPivotCaches::SavePivotCacheXml( XclExpXmlStream& rStrm, const Entr if (isContainsDate) { - pAttList->add(XML_minDate, XclXmlUtils::ToOString(GetExcelFormattedDate(fMin, GetFormatter()))); - pAttList->add(XML_maxDate, XclXmlUtils::ToOString(GetExcelFormattedDate(fMax, GetFormatter()))); + pAttList->add(XML_minDate, GetExcelFormattedDate(fMin, GetFormatter()).toUtf8()); + pAttList->add(XML_maxDate, GetExcelFormattedDate(fMax, GetFormatter()).toUtf8()); } //if (bListItems) // see TODO above @@ -364,14 +364,14 @@ void XclExpXmlPivotCaches::SavePivotCacheXml( XclExpXmlStream& rStrm, const Entr { case ScDPItemData::String: pDefStrm->singleElement(XML_s, - XML_v, XclXmlUtils::ToOString(rItem.GetString()), + XML_v, rItem.GetString().toUtf8(), FSEND); break; case ScDPItemData::Value: if (isContainsDate) { pDefStrm->singleElement(XML_d, - XML_v, XclXmlUtils::ToOString(GetExcelFormattedDate(rItem.GetValue(), GetFormatter())), + XML_v, GetExcelFormattedDate(rItem.GetValue(), GetFormatter()).toUtf8(), FSEND); } else @@ -384,7 +384,7 @@ void XclExpXmlPivotCaches::SavePivotCacheXml( XclExpXmlStream& rStrm, const Entr break; case ScDPItemData::Error: pDefStrm->singleElement(XML_e, - XML_v, XclXmlUtils::ToOString(rItem.GetString()), + XML_v, rItem.GetString().toUtf8(), FSEND); break; case ScDPItemData::GroupValue: @@ -658,8 +658,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP sax_fastparser::FSHelperPtr& pPivotStrm = rStrm.GetCurrentStream(); pPivotStrm->startElement(XML_pivotTableDefinition, - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), - XML_name, XclXmlUtils::ToOString(rDPObj.GetName()).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), + XML_name, rDPObj.GetName().toUtf8(), XML_cacheId, OString::number(nCacheId).getStr(), XML_applyNumberFormats, ToPsz10(false), XML_applyBorderFormats, ToPsz10(false), @@ -944,7 +944,7 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP const boost::optional<OUString> & pName = rDim.GetLayoutName(); pPivotStrm->write("<")->writeId(XML_dataField); if (pName) - rStrm.WriteAttributes(XML_name, XclXmlUtils::ToOString(*pName), FSEND); + rStrm.WriteAttributes(XML_name, pName->toUtf8(), FSEND); rStrm.WriteAttributes(XML_fld, OString::number(nDimIdx).getStr(), FSEND); diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index e2d70cda4f18..42fb49ddf6ee 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -699,11 +699,6 @@ OString XclXmlUtils::ToOString( const Color& rColor ) return OString( buf ); } -OString XclXmlUtils::ToOString( const OUString& s ) -{ - return OUStringToOString( s, RTL_TEXTENCODING_UTF8 ); -} - OStringBuffer& XclXmlUtils::ToOString( OStringBuffer& s, const ScAddress& rAddress ) { rAddress.Format(s, ScRefFlags::VALID, nullptr, ScAddress::Details( FormulaGrammar::CONV_XL_A1)); @@ -726,14 +721,14 @@ OString XclXmlUtils::ToOString( const ScRange& rRange, bool bFullAddressNotation OUString sRange(rRange.Format( ScRefFlags::VALID, nullptr, ScAddress::Details( FormulaGrammar::CONV_XL_A1 ), bFullAddressNotation ) ); - return ToOString( sRange ); + return sRange.toUtf8(); } OString XclXmlUtils::ToOString( const ScRangeList& rRangeList ) { OUString s; rRangeList.Format(s, ScRefFlags::VALID, nullptr, FormulaGrammar::CONV_XL_OOX, ' '); - return ToOString( s ); + return s.toUtf8(); } static ScAddress lcl_ToAddress( const XclAddress& rAddress ) @@ -902,7 +897,7 @@ sax_fastparser::FSHelperPtr XclXmlUtils::WriteFontData( sax_fastparser::FSHelper // OOXTODO: XML_theme, index into <clrScheme/> // OOXTODO: XML_tint, double FSEND ); - lcl_WriteValue( pStream, nFontId, XclXmlUtils::ToOString( rFontData.maName ).getStr() ); + lcl_WriteValue( pStream, nFontId, rFontData.maName.toUtf8().getStr() ); lcl_WriteValue( pStream, XML_family, OString::number( rFontData.mnFamily ).getStr() ); lcl_WriteValue( pStream, XML_charset, rFontData.mnCharSet != 0 ? OString::number( rFontData.mnCharSet ).getStr() : nullptr ); diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index ed71e063eda5..fb1fdd36e9af 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -1078,7 +1078,7 @@ void XclExpDxfFont::SaveXml(XclExpXmlStream& rStrm) if (!aFontName.isEmpty()) { rStyleSheet->singleElement(XML_name, - XML_val, XclXmlUtils::ToOString(aFontName).getStr(), + XML_val, aFontName.toUtf8(), FSEND); } @@ -2350,7 +2350,7 @@ void XclExpStyle::SaveXml( XclExpXmlStream& rStrm ) pBuiltinId = sBuiltinId.getStr(); } else - sName = XclXmlUtils::ToOString( maName ); + sName = maName.toUtf8(); // get the index in sortedlist associated with the mnXId sal_Int32 nXFId = rStrm.GetRoot().GetXFBuffer().GetXFIndex( maXFId.mnXFId ); @@ -3154,7 +3154,7 @@ void XclExpXmlStyleSheet::SaveXml( XclExpXmlStream& rStrm ) rStrm.PushStream( aStyleSheet ); aStyleSheet->startElement( XML_styleSheet, - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), FSEND ); CreateRecord( EXC_ID_FORMATLIST )->SaveXml( rStrm ); diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx index 20cd69085c98..d70446730644 100644 --- a/sc/source/filter/inc/xestream.hxx +++ b/sc/source/filter/inc/xestream.hxx @@ -252,7 +252,6 @@ public: static OUString GetStreamName( const char* sStreamDir, const char* sStream, sal_Int32 nId ); static OString ToOString( const Color& rColor ); - static OString ToOString( const OUString& s ); static OString ToOString( const ScfUInt16Vec& rBuffer ); static OStringBuffer& ToOString( OStringBuffer& s, const ScAddress& rRange ); static OString ToOString( const ScRange& rRange, bool bFullAddressNotation = false ); diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx index d5c4ef0e421b..7c491e5497cb 100644 --- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx +++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx @@ -380,8 +380,8 @@ void XclExpXmlChTrHeaders::SaveXml( XclExpXmlStream& rStrm ) pHeaders->write("<")->writeId(XML_headers); rStrm.WriteAttributes( - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), - FSNS(XML_xmlns, XML_r), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(officeRel))).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8().getStr(), + FSNS(XML_xmlns, XML_r), rStrm.getNamespaceURL(OOX_NS(officeRel)).toUtf8().getStr(), XML_guid, lcl_GuidToOString(maGUID).getStr(), XML_lastGuid, nullptr, // OOXTODO XML_shared, nullptr, // OOXTODO @@ -431,8 +431,8 @@ void XclExpXmlChTrHeader::SaveXml( XclExpXmlStream& rStrm ) rStrm.WriteAttributes( XML_guid, lcl_GuidToOString(maGUID).getStr(), XML_dateTime, lcl_DateTimeToOString(maDateTime).getStr(), - XML_userName, XclXmlUtils::ToOString(maUserName).getStr(), - FSNS(XML_r, XML_id), XclXmlUtils::ToOString(aRelId).getStr(), + XML_userName, maUserName.toUtf8(), + FSNS(XML_r, XML_id), aRelId.toUtf8(), FSEND); if (mnMinAction) @@ -473,8 +473,8 @@ void XclExpXmlChTrHeader::SaveXml( XclExpXmlStream& rStrm ) pRevLogStrm->write("<")->writeId(XML_revisions); rStrm.WriteAttributes( - XML_xmlns, XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(xls))).getStr(), - FSNS(XML_xmlns, XML_r), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(officeRel))).getStr(), + XML_xmlns, rStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), + FSNS(XML_xmlns, XML_r), rStrm.getNamespaceURL(OOX_NS(officeRel)).toUtf8(), FSEND); pRevLogStrm->write(">"); @@ -1241,7 +1241,7 @@ void XclExpChTrInsertTab::SaveXml( XclExpXmlStream& rStrm ) XML_ua, ToPsz( GetAccepted () ), // OOXTODO? bAccepted == ua or ra; not sure. XML_ra, nullptr, // OOXTODO: RRD.fUndoAction? Or RRD.fAccepted? XML_sheetId, OString::number( GetTabId( nTab ) ).getStr(), - XML_name, XclXmlUtils::ToOString( GetTabInfo().GetScTabName( nTab ) ).getStr(), + XML_name, GetTabInfo().GetScTabName(nTab).toUtf8(), XML_sheetPosition, OString::number( nTab ).getStr(), FSEND ); } @@ -1636,8 +1636,8 @@ static void lcl_WriteUserNamesXml( XclExpXmlStream& rWorkbookStrm ) "application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml", CREATE_OFFICEDOC_RELATION_TYPE("usernames")); pUserNames->startElement( XML_users, - XML_xmlns, XclXmlUtils::ToOString(rWorkbookStrm.getNamespaceURL(OOX_NS(xls))).getStr(), - FSNS( XML_xmlns, XML_r ), XclXmlUtils::ToOString(rWorkbookStrm.getNamespaceURL(OOX_NS(officeRel))).getStr(), + XML_xmlns, rWorkbookStrm.getNamespaceURL(OOX_NS(xls)).toUtf8(), + FSNS( XML_xmlns, XML_r ), rWorkbookStrm.getNamespaceURL(OOX_NS(officeRel)).toUtf8(), XML_count, "0", FSEND ); // OOXTODO: XML_userinfo elements for each user editing the file diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index 6f44099f08e9..2d2fa5decf18 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -236,14 +236,14 @@ void SaveDrawingMLObjects( XclExpObjList& rList, XclExpXmlStream& rStrm, sal_Int &sId ); rStrm.GetCurrentStream()->singleElement( XML_drawing, - FSNS( XML_r, XML_id ), XclXmlUtils::ToOString( sId ).getStr(), + FSNS(XML_r, XML_id), sId.toUtf8(), FSEND ); rStrm.PushStream( pDrawing ); pDrawing->startElement( FSNS( XML_xdr, XML_wsDr ), - FSNS( XML_xmlns, XML_xdr ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(dmlSpreadDr))).getStr(), - FSNS( XML_xmlns, XML_a ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(dml))).getStr(), - FSNS( XML_xmlns, XML_r ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(officeRel))).getStr(), + FSNS(XML_xmlns, XML_xdr), rStrm.getNamespaceURL(OOX_NS(dmlSpreadDr)).toUtf8(), + FSNS(XML_xmlns, XML_a), rStrm.getNamespaceURL(OOX_NS(dml)).toUtf8(), + FSNS(XML_xmlns, XML_r), rStrm.getNamespaceURL(OOX_NS(officeRel)).toUtf8(), FSEND ); for (const auto& rpObj : aList) @@ -270,15 +270,15 @@ void SaveVmlObjects( XclExpObjList& rList, XclExpXmlStream& rStrm, sal_Int32& nV &sId ); rStrm.GetCurrentStream()->singleElement( XML_legacyDrawing, - FSNS( XML_r, XML_id ), XclXmlUtils::ToOString( sId ).getStr(), + FSNS(XML_r, XML_id), sId.toUtf8(), FSEND ); rStrm.PushStream( pVmlDrawing ); pVmlDrawing->startElement( XML_xml, - FSNS( XML_xmlns, XML_v ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(vml))).getStr(), - FSNS( XML_xmlns, XML_o ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(vmlOffice))).getStr(), - FSNS( XML_xmlns, XML_x ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(vmlExcel))).getStr(), - FSNS( XML_xmlns, XML_w10 ), XclXmlUtils::ToOString(rStrm.getNamespaceURL(OOX_NS(vmlWord))).getStr(), + FSNS(XML_xmlns, XML_v), rStrm.getNamespaceURL(OOX_NS(vml)).toUtf8(), + FSNS(XML_xmlns, XML_o), rStrm.getNamespaceURL(OOX_NS(vmlOffice)).toUtf8(), + FSNS(XML_xmlns, XML_x), rStrm.getNamespaceURL(OOX_NS(vmlExcel)).toUtf8(), + FSNS(XML_xmlns, XML_w10), rStrm.getNamespaceURL(OOX_NS(vmlWord)).toUtf8(), FSEND ); for ( const auto& rxObj : rList ) @@ -1260,10 +1260,10 @@ void ExcBundlesheet8::SaveXml( XclExpXmlStream& rStrm ) &sId ); rStrm.GetCurrentStream()->singleElement( XML_sheet, - XML_name, XclXmlUtils::ToOString( sUnicodeName ).getStr(), + XML_name, sUnicodeName.toUtf8(), XML_sheetId, OString::number( ( nTab+1 ) ).getStr(), XML_state, nGrbit == 0x0000 ? "visible" : "hidden", - FSNS( XML_r, XML_id ), XclXmlUtils::ToOString( sId ).getStr(), + FSNS( XML_r, XML_id ), sId.toUtf8(), FSEND ); } |