Deduplicate some serializer writing code, and simplify writing OString

Change-Id: I391f8cb499a83f1f774fdcaa794169a218bdc7e5
Reviewed-on: https://gerrit.libreoffice.org/80189
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2019-10-04 11:55:05 +03:00
parent 314958decf
commit 59e5d2c883
7 changed files with 20 additions and 34 deletions

View File

@@ -131,6 +131,7 @@ public:
{ startElement( FSNS( namespaceTokenId, elementTokenId ), xAttrList ); } { startElement( FSNS( namespaceTokenId, elementTokenId ), xAttrList ); }
FastSerializerHelper* write(const char* value); FastSerializerHelper* write(const char* value);
FastSerializerHelper* write(const OString& value);
FastSerializerHelper* write(const OUString& value); FastSerializerHelper* write(const OUString& value);
FastSerializerHelper* write(sal_Int32 value); FastSerializerHelper* write(sal_Int32 value);
FastSerializerHelper* write(sal_Int64 value); FastSerializerHelper* write(sal_Int64 value);

View File

@@ -1189,7 +1189,7 @@ sal_Int32 VMLExport::StartShape()
"<v:path shadowok=\"f\" o:extrusionok=\"f\" strokeok=\"f\" fillok=\"f\" o:connecttype=\"rect\"/>\n" "<v:path shadowok=\"f\" o:extrusionok=\"f\" strokeok=\"f\" fillok=\"f\" o:connecttype=\"rect\"/>\n"
"<o:lock v:ext=\"edit\" shapetype=\"t\"/>\n" "<o:lock v:ext=\"edit\" shapetype=\"t\"/>\n"
"</v:shapetype>"); "</v:shapetype>");
m_pSerializer->write(sShapeType.makeStringAndClear().getStr()); m_pSerializer->write(sShapeType.makeStringAndClear());
m_aShapeTypeWritten[ m_nShapeType ] = true; m_aShapeTypeWritten[ m_nShapeType ] = true;
} }
break; break;
@@ -1224,7 +1224,7 @@ sal_Int32 VMLExport::StartShape()
"<v:path o:extrusionok=\"f\" gradientshapeok=\"t\" o:connecttype=\"rect\"/>\n" "<v:path o:extrusionok=\"f\" gradientshapeok=\"t\" o:connecttype=\"rect\"/>\n"
"<o:lock v:ext=\"edit\" aspectratio=\"t\"/>\n" "<o:lock v:ext=\"edit\" aspectratio=\"t\"/>\n"
"</v:shapetype>"); "</v:shapetype>");
m_pSerializer->write(sShapeType.makeStringAndClear().getStr()); m_pSerializer->write(sShapeType.makeStringAndClear());
m_aShapeTypeWritten[ m_nShapeType ] = true; m_aShapeTypeWritten[ m_nShapeType ] = true;
} }
break; break;

View File

@@ -81,6 +81,12 @@ FastSerializerHelper* FastSerializerHelper::write(const char* value)
return this; return this;
} }
FastSerializerHelper* FastSerializerHelper::write(const OString& value)
{
mpSerializer->write(value);
return this;
}
FastSerializerHelper* FastSerializerHelper::write(const OUString& value) FastSerializerHelper* FastSerializerHelper::write(const OUString& value)
{ {
mpSerializer->write(value); mpSerializer->write(value);

View File

@@ -1507,7 +1507,7 @@ void XclExpDataBar::SaveXml( XclExpXmlStream& rStrm )
XML_uri, "{B025F937-C7B1-47D3-B67F-A62EFF666E3E}"); XML_uri, "{B025F937-C7B1-47D3-B67F-A62EFF666E3E}");
rWorksheet->startElementNS( XML_x14, XML_id ); rWorksheet->startElementNS( XML_x14, XML_id );
rWorksheet->write( maGUID.getStr() ); rWorksheet->write(maGUID);
rWorksheet->endElementNS( XML_x14, XML_id ); rWorksheet->endElementNS( XML_x14, XML_id );
rWorksheet->endElement( XML_ext ); rWorksheet->endElement( XML_ext );

View File

@@ -464,7 +464,7 @@ void XclExpExtConditionalFormatting::SaveXml( XclExpXmlStream& rStrm )
maCfRules.SaveXml( rStrm ); maCfRules.SaveXml( rStrm );
rWorksheet->startElementNS(XML_xm, XML_sqref); rWorksheet->startElementNS(XML_xm, XML_sqref);
rWorksheet->write(XclXmlUtils::ToOString(maRange).getStr()); rWorksheet->write(XclXmlUtils::ToOString(maRange));
rWorksheet->endElementNS( XML_xm, XML_sqref ); rWorksheet->endElementNS( XML_xm, XML_sqref );

View File

@@ -813,33 +813,6 @@ OUString XclXmlUtils::ToOUString( const XclExpString& s )
return ToOUString( s.GetUnicodeBuffer() ); return ToOUString( s.GetUnicodeBuffer() );
} }
sax_fastparser::FSHelperPtr XclXmlUtils::WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, sal_Int32 nValue )
{
pStream->startElement(nElement);
pStream->write( nValue );
pStream->endElement( nElement );
return pStream;
}
sax_fastparser::FSHelperPtr XclXmlUtils::WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, sal_Int64 nValue )
{
pStream->startElement(nElement);
pStream->write( nValue );
pStream->endElement( nElement );
return pStream;
}
sax_fastparser::FSHelperPtr XclXmlUtils::WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, const char* sValue )
{
pStream->startElement(nElement);
pStream->write( sValue );
pStream->endElement( nElement );
return pStream;
}
static void lcl_WriteValue( const sax_fastparser::FSHelperPtr& rStream, sal_Int32 nElement, const char* pValue ) static void lcl_WriteValue( const sax_fastparser::FSHelperPtr& rStream, sal_Int32 nElement, const char* pValue )
{ {
if( !pValue ) if( !pValue )

View File

@@ -265,9 +265,15 @@ public:
static OUString ToOUString( sc::CompileFormulaContext& rCtx, const ScAddress& rAddress, const ScTokenArray* pTokenArray ); static OUString ToOUString( sc::CompileFormulaContext& rCtx, const ScAddress& rAddress, const ScTokenArray* pTokenArray );
static OUString ToOUString( const XclExpString& s ); static OUString ToOUString( const XclExpString& s );
static sax_fastparser::FSHelperPtr WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, sal_Int32 nValue ); template <class T>
static sax_fastparser::FSHelperPtr WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, sal_Int64 nValue ); static sax_fastparser::FSHelperPtr WriteElement(sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, const T& value)
static sax_fastparser::FSHelperPtr WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, const char* sValue ); {
pStream->startElement(nElement);
pStream->write(value);
pStream->endElement(nElement);
return pStream;
}
static sax_fastparser::FSHelperPtr WriteFontData( sax_fastparser::FSHelperPtr pStream, const XclFontData& rFontData, sal_Int32 nNameId ); static sax_fastparser::FSHelperPtr WriteFontData( sax_fastparser::FSHelperPtr pStream, const XclFontData& rFontData, sal_Int32 nNameId );
}; };