diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-03-02 12:20:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-03-06 05:59:16 +0000 |
commit | 59fbef6cf83083d678571f706bebd5f3147a3d0e (patch) | |
tree | cd0eadde188de2c28ea840f61406f27e7bd3b640 /include | |
parent | e07dc67dedcb8450bc9d6076f5ef5322c316d20a (diff) |
templatize HTMLEnumOption::GetEnum methods
And consequently fix bug in htmlfld.cxx in
the RES_DOCSTATFLD/SwDocStatSubType handling, where it was updating
the m_bUpdateDocStat fields by comparing the wrong enum variable.
Change-Id: If9a68699a9d375ace120a3bf4f4bf4d4ae20a8e0
Reviewed-on: https://gerrit.libreoffice.org/34857
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/svtools/parhtml.hxx | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/include/svtools/parhtml.hxx b/include/svtools/parhtml.hxx index f48106695a4a..a46f07f4b8ca 100644 --- a/include/svtools/parhtml.hxx +++ b/include/svtools/parhtml.hxx @@ -72,10 +72,11 @@ enum HTMLScriptLanguage HTML_SL_UNKNOWN }; +template<typename EnumT> struct HTMLOptionEnum { const sal_Char *pName; // value of an HTML option - sal_uInt16 nValue; // and corresponding value of an enum + EnumT nValue; // and corresponding value of an enum }; /** Representation of an HTML option (=attribute in a start tag). @@ -105,10 +106,33 @@ public: void GetNumbers( std::vector<sal_uInt32> &rNumbers ) const; // ... as numbers void GetColor( Color& ) const; // ... as color - // ... as enum; pOptEnums is an HTMLOptionEnum array - sal_uInt16 GetEnum( const HTMLOptionEnum *pOptEnums, - sal_uInt16 nDflt=0 ) const; - bool GetEnum( sal_uInt16 &rEnum, const HTMLOptionEnum *pOptEnums ) const; + template<typename EnumT> + EnumT GetEnum( const HTMLOptionEnum<EnumT> *pOptEnums, + EnumT nDflt = static_cast<EnumT>(0) ) const + { + while( pOptEnums->pName ) + { + if( aValue.equalsIgnoreAsciiCaseAscii( pOptEnums->pName ) ) + return pOptEnums->nValue; + pOptEnums++; + } + return nDflt; + } + + template<typename EnumT> + bool GetEnum( EnumT &rEnum, const HTMLOptionEnum<EnumT> *pOptEnums ) const + { + while( pOptEnums->pName ) + { + if( aValue.equalsIgnoreAsciiCaseAscii( pOptEnums->pName ) ) + { + rEnum = pOptEnums->nValue; + return true; + } + pOptEnums++; + } + return false; + } // ... and as a few special enums HTMLInputType GetInputType() const; // <INPUT TYPE=...> |