sfx2/source/doc/doctemplateslocal.cxx | 53 +++++++++++++++++----------------- sfx2/source/doc/doctemplateslocal.hxx | 6 --- 2 files changed, 27 insertions(+), 32 deletions(-)
New commits: commit 91081c56b0732a3b378d331ac3bd299a369788f7 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sat Apr 22 19:12:34 2017 +0200 Use automatic integer type, with minor simplifications Change-Id: I08b8370311b11d45ab744875f7ad6b885f318a74 diff --git a/sfx2/source/doc/doctemplateslocal.cxx b/sfx2/source/doc/doctemplateslocal.cxx index 30ca595a7fec..cccfb2fa9fc7 100644 --- a/sfx2/source/doc/doctemplateslocal.cxx +++ b/sfx2/source/doc/doctemplateslocal.cxx @@ -159,8 +159,8 @@ void SAL_CALL DocTemplLocaleHelper::startElement( const OUString& aName, const u m_aElementsSeq.push_back( aName ); - sal_Int32 nNewEntryNum = m_aResultSeq.size() + 1; - m_aResultSeq.resize( nNewEntryNum ); + const auto nNewEntryNum = m_aResultSeq.size(); + m_aResultSeq.resize( nNewEntryNum+1 ); const OUString aNameValue = xAttribs->getValueByName( g_sNameAttr ); if ( aNameValue.isEmpty() ) @@ -170,8 +170,8 @@ void SAL_CALL DocTemplLocaleHelper::startElement( const OUString& aName, const u if ( aUINameValue.isEmpty() ) throw xml::sax::SAXException(); // TODO: the ID value must present - m_aResultSeq[nNewEntryNum-1].First = aNameValue; - m_aResultSeq[nNewEntryNum-1].Second = aUINameValue; + m_aResultSeq[nNewEntryNum].First = aNameValue; + m_aResultSeq[nNewEntryNum].Second = aUINameValue; } else { commit 7c6345c5e9be7c377c11c0bd30b6739286075b2a Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sat Apr 22 19:04:22 2017 +0200 OUStrings: avoid temporaries and constify Change-Id: Id6b4b26df09ddb750f3e5430636b41c89e4d9e8e diff --git a/sfx2/source/doc/doctemplateslocal.cxx b/sfx2/source/doc/doctemplateslocal.cxx index 0e850095fff4..30ca595a7fec 100644 --- a/sfx2/source/doc/doctemplateslocal.cxx +++ b/sfx2/source/doc/doctemplateslocal.cxx @@ -46,8 +46,7 @@ const OUStringLiteral g_sUINameAttr("groupuinames:default-ui-name"); std::vector< beans::StringPair > DocTemplLocaleHelper::ReadGroupLocalizationSequence( const uno::Reference< io::XInputStream >& xInStream, const uno::Reference< uno::XComponentContext >& xContext ) { - OUString aStringID = "groupuinames.xml"; - return ReadLocalizationSequence_Impl( xInStream, aStringID, xContext ); + return ReadLocalizationSequence_Impl( xInStream, "groupuinames.xml", xContext ); } @@ -61,8 +60,8 @@ void SAL_CALL DocTemplLocaleHelper::WriteGroupLocalizationSequence( const uno::R xWriterHandler->setOutputStream( xOutStream ); - OUString aCDATAString( "CDATA" ); - OUString aWhiteSpace( " " ); + const OUString aCDATAString( "CDATA" ); + const OUString aWhiteSpace( " " ); // write the namespace ::comphelper::AttributeList* pRootAttrList = new ::comphelper::AttributeList; @@ -163,11 +162,11 @@ void SAL_CALL DocTemplLocaleHelper::startElement( const OUString& aName, const u sal_Int32 nNewEntryNum = m_aResultSeq.size() + 1; m_aResultSeq.resize( nNewEntryNum ); - OUString aNameValue = xAttribs->getValueByName( g_sNameAttr ); + const OUString aNameValue = xAttribs->getValueByName( g_sNameAttr ); if ( aNameValue.isEmpty() ) throw xml::sax::SAXException(); // TODO: the ID value must present - OUString aUINameValue = xAttribs->getValueByName( g_sUINameAttr ); + const OUString aUINameValue = xAttribs->getValueByName( g_sUINameAttr ); if ( aUINameValue.isEmpty() ) throw xml::sax::SAXException(); // TODO: the ID value must present commit 1e3261a2eac642c762a1b667a3653a470894446e Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sat Apr 22 18:57:46 2017 +0200 These data members can be file scope consts, and reused Change-Id: I977d523d6aefeb2475044783ba30744b950d3708 diff --git a/sfx2/source/doc/doctemplateslocal.cxx b/sfx2/source/doc/doctemplateslocal.cxx index 21d5bb277e7c..0e850095fff4 100644 --- a/sfx2/source/doc/doctemplateslocal.cxx +++ b/sfx2/source/doc/doctemplateslocal.cxx @@ -33,6 +33,16 @@ using namespace ::com::sun::star; +namespace +{ + +// Relations info related strings +const OUStringLiteral g_sGroupListElement("groupuinames:template-group-list"); +const OUStringLiteral g_sGroupElement("groupuinames:template-group"); +const OUStringLiteral g_sNameAttr("groupuinames:name"); +const OUStringLiteral g_sUINameAttr("groupuinames:default-ui-name"); + +} std::vector< beans::StringPair > DocTemplLocaleHelper::ReadGroupLocalizationSequence( const uno::Reference< io::XInputStream >& xInStream, const uno::Reference< uno::XComponentContext >& xContext ) { @@ -51,10 +61,6 @@ void SAL_CALL DocTemplLocaleHelper::WriteGroupLocalizationSequence( const uno::R xWriterHandler->setOutputStream( xOutStream ); - OUString aGroupListElement( "groupuinames:template-group-list" ); - OUString aGroupElement( "groupuinames:template-group" ); - OUString aNameAttr( "groupuinames:name" ); - OUString aUINameAttr( "groupuinames:default-ui-name" ); OUString aCDATAString( "CDATA" ); OUString aWhiteSpace( " " ); @@ -67,22 +73,22 @@ void SAL_CALL DocTemplLocaleHelper::WriteGroupLocalizationSequence( const uno::R "http://openoffice.org/2006/groupuinames" ); xWriterHandler->startDocument(); - xWriterHandler->startElement( aGroupListElement, xRootAttrList ); + xWriterHandler->startElement( g_sGroupListElement, xRootAttrList ); for (const auto & i : aSequence) { ::comphelper::AttributeList *pAttrList = new ::comphelper::AttributeList; uno::Reference< xml::sax::XAttributeList > xAttrList( pAttrList ); - pAttrList->AddAttribute( aNameAttr, aCDATAString, i.First ); - pAttrList->AddAttribute( aUINameAttr, aCDATAString, i.Second ); + pAttrList->AddAttribute( g_sNameAttr, aCDATAString, i.First ); + pAttrList->AddAttribute( g_sUINameAttr, aCDATAString, i.Second ); - xWriterHandler->startElement( aGroupElement, xAttrList ); + xWriterHandler->startElement( g_sGroupElement, xAttrList ); xWriterHandler->ignorableWhitespace( aWhiteSpace ); - xWriterHandler->endElement( aGroupElement ); + xWriterHandler->endElement( g_sGroupElement ); } xWriterHandler->ignorableWhitespace( aWhiteSpace ); - xWriterHandler->endElement( aGroupListElement ); + xWriterHandler->endElement( g_sGroupListElement ); xWriterHandler->endDocument(); } @@ -108,10 +114,6 @@ std::vector< beans::StringPair > SAL_CALL DocTemplLocaleHelper::ReadLocalization DocTemplLocaleHelper::DocTemplLocaleHelper() -: m_aGroupListElement( "groupuinames:template-group-list" ) -, m_aGroupElement( "groupuinames:template-group" ) -, m_aNameAttr( "groupuinames:name" ) -, m_aUINameAttr( "groupuinames:default-ui-name" ) { } @@ -142,7 +144,7 @@ void SAL_CALL DocTemplLocaleHelper::endDocument() void SAL_CALL DocTemplLocaleHelper::startElement( const OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs ) { - if ( aName == m_aGroupListElement ) + if ( aName == g_sGroupListElement ) { if ( m_aElementsSeq.size() != 0 ) throw xml::sax::SAXException(); // TODO: this element must be the first level element @@ -151,7 +153,7 @@ void SAL_CALL DocTemplLocaleHelper::startElement( const OUString& aName, const u return; // nothing to do } - else if ( aName == m_aGroupElement ) + else if ( aName == g_sGroupElement ) { if ( m_aElementsSeq.size() != 1 ) throw xml::sax::SAXException(); // TODO: this element must be the second level element @@ -161,11 +163,11 @@ void SAL_CALL DocTemplLocaleHelper::startElement( const OUString& aName, const u sal_Int32 nNewEntryNum = m_aResultSeq.size() + 1; m_aResultSeq.resize( nNewEntryNum ); - OUString aNameValue = xAttribs->getValueByName( m_aNameAttr ); + OUString aNameValue = xAttribs->getValueByName( g_sNameAttr ); if ( aNameValue.isEmpty() ) throw xml::sax::SAXException(); // TODO: the ID value must present - OUString aUINameValue = xAttribs->getValueByName( m_aUINameAttr ); + OUString aUINameValue = xAttribs->getValueByName( g_sUINameAttr ); if ( aUINameValue.isEmpty() ) throw xml::sax::SAXException(); // TODO: the ID value must present diff --git a/sfx2/source/doc/doctemplateslocal.hxx b/sfx2/source/doc/doctemplateslocal.hxx index 16167e1acc1c..3284df1f299e 100644 --- a/sfx2/source/doc/doctemplateslocal.hxx +++ b/sfx2/source/doc/doctemplateslocal.hxx @@ -30,12 +30,6 @@ class DocTemplLocaleHelper : public cppu::WeakImplHelper < css::xml::sax::XDocumentHandler > { - // Relations info related strings - OUString m_aGroupListElement; - OUString m_aGroupElement; - OUString m_aNameAttr; - OUString m_aUINameAttr; - std::vector< css::beans::StringPair > m_aResultSeq; std::vector< OUString > m_aElementsSeq; // stack of elements being parsed _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits