From 90ac4671c13ed4f548bb4188355b02217b9e24ba Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 28 Jul 2017 16:43:06 +0100 Subject: make IntlWrapper arg to GetPresentation non-implicit and non-optional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit which requires explicitly adding null in 1) SdrItemBrowserControl::SetAttributes(const SfxItemSet* pSet, const SfxItemSet* p2ndSet) where SdrItemBrowserControl is only used by SdrItemBrowser and the only use of that is within DBG_UTIL in SdrPaintView 2) SwCursorShell::GetContentAtPos( const Point& rPt, within a #ifdef DBG_UTIL block in 3) SvxSearchDialog::BuildAttrText_Impl( OUString& rStr, bool bSrchFlag ) const where the other branch uses SvxResId 4) SfxPoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const 5) XFillStyleItem::dumpAsXml(xmlTextWriterPtr pWriter) const looks very much like all uses (outside the dumpers) are intended to be in the ui locale results in that INetContentTypes::GetPresentation always called with UI Locale Change-Id: I5a110c107838b4db3c355476426d6532f2b6ce52 Reviewed-on: https://gerrit.libreoffice.org/40538 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- svl/source/items/cenumitm.cxx | 4 +-- svl/source/items/cintitem.cxx | 8 +++--- svl/source/items/ctypeitm.cxx | 12 +++------ svl/source/items/custritm.cxx | 2 +- svl/source/items/flagitem.cxx | 2 +- svl/source/items/int64item.cxx | 2 +- svl/source/items/intitem.cxx | 2 +- svl/source/items/itempool.cxx | 4 +-- svl/source/items/macitem.cxx | 2 +- svl/source/items/poolitem.cxx | 9 ++++--- svl/source/items/ptitem.cxx | 2 +- svl/source/items/rectitem.cxx | 2 +- svl/source/items/rngitem.cxx | 2 +- svl/source/items/sitem.cxx | 2 +- svl/source/items/slstitm.cxx | 2 +- svl/source/items/srchitem.cxx | 2 +- svl/source/items/style.cxx | 4 +-- svl/source/items/szitem.cxx | 2 +- svl/source/items/visitem.cxx | 2 +- svl/source/misc/getstringresource.cxx | 46 +++-------------------------------- svl/source/misc/getstringresource.hxx | 10 +------- svl/source/misc/inettype.cxx | 5 ++-- 22 files changed, 40 insertions(+), 88 deletions(-) (limited to 'svl/source') diff --git a/svl/source/items/cenumitm.cxx b/svl/source/items/cenumitm.cxx index 4a0cbd41b8af..7bafa1a0efcb 100644 --- a/svl/source/items/cenumitm.cxx +++ b/svl/source/items/cenumitm.cxx @@ -38,7 +38,7 @@ bool SfxEnumItemInterface::operator ==(const SfxPoolItem & rItem) const // virtual bool SfxEnumItemInterface::GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString & rText, - const IntlWrapper *) const + const IntlWrapper&) const { rText = OUString::number( GetEnumValue() ); return true; @@ -119,7 +119,7 @@ bool SfxBoolItem::operator ==(const SfxPoolItem & rItem) const bool SfxBoolItem::GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString & rText, - const IntlWrapper *) const + const IntlWrapper&) const { rText = GetValueTextByVal(m_bValue); return true; diff --git a/svl/source/items/cintitem.cxx b/svl/source/items/cintitem.cxx index e6ef22205b85..a74fb1a92529 100644 --- a/svl/source/items/cintitem.cxx +++ b/svl/source/items/cintitem.cxx @@ -32,7 +32,7 @@ bool CntByteItem::operator ==(const SfxPoolItem & rItem) const // virtual bool CntByteItem::GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString & rText, - const IntlWrapper *) const + const IntlWrapper&) const { rText = OUString::number( m_nValue ); return true; @@ -101,7 +101,7 @@ bool CntUInt16Item::operator ==(const SfxPoolItem & rItem) const bool CntUInt16Item::GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString & rText, - const IntlWrapper *) + const IntlWrapper&) const { rText = OUString::number( m_nValue ); @@ -169,7 +169,7 @@ bool CntInt32Item::operator ==(const SfxPoolItem & rItem) const bool CntInt32Item::GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString & rText, - const IntlWrapper *) const + const IntlWrapper&) const { rText = OUString::number( m_nValue ); return true; @@ -236,7 +236,7 @@ bool CntUInt32Item::operator ==(const SfxPoolItem & rItem) const bool CntUInt32Item::GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString & rText, - const IntlWrapper *) + const IntlWrapper&) const { rText = OUString::number(m_nValue); diff --git a/svl/source/items/ctypeitm.cxx b/svl/source/items/ctypeitm.cxx index 654c4a453fc2..f0002e138f41 100644 --- a/svl/source/items/ctypeitm.cxx +++ b/svl/source/items/ctypeitm.cxx @@ -118,16 +118,12 @@ bool CntContentTypeItem::GetPresentation( MapUnit eCoreMetric, MapUnit ePresMetric, OUString & rText, - const IntlWrapper * pIntlWrapper) const + const IntlWrapper & rIntlWrapper) const { if (_aPresentation.isEmpty()) { - DBG_ASSERT(pIntlWrapper, - "CntContentTypeItem::GetPresentation(): No IntlWrapper"); - if (pIntlWrapper) - (const_cast< CntContentTypeItem * >(this))->_aPresentation - = INetContentTypes::GetPresentation(GetEnumValue(), - pIntlWrapper->getLanguageTag()); + (const_cast< CntContentTypeItem * >(this))->_aPresentation = + INetContentTypes::GetPresentation(GetEnumValue()); } if (!_aPresentation.isEmpty()) { @@ -137,7 +133,7 @@ bool CntContentTypeItem::GetPresentation( else return CntUnencodedStringItem::GetPresentation(ePres, eCoreMetric, ePresMetric, rText, - pIntlWrapper); + rIntlWrapper); } INetContentType CntContentTypeItem::GetEnumValue() const diff --git a/svl/source/items/custritm.cxx b/svl/source/items/custritm.cxx index b29a6813ecad..77b869f2f301 100644 --- a/svl/source/items/custritm.cxx +++ b/svl/source/items/custritm.cxx @@ -38,7 +38,7 @@ bool CntUnencodedStringItem::operator ==(const SfxPoolItem & rItem) const // virtual bool CntUnencodedStringItem::GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString & rText, - const IntlWrapper *) const + const IntlWrapper&) const { rText = m_aValue; return true; diff --git a/svl/source/items/flagitem.cxx b/svl/source/items/flagitem.cxx index ee5ad34d1fb0..916c94ef961b 100644 --- a/svl/source/items/flagitem.cxx +++ b/svl/source/items/flagitem.cxx @@ -50,7 +50,7 @@ bool SfxFlagItem::GetPresentation MapUnit /*eCoreMetric*/, MapUnit /*ePresentationMetric*/, OUString& rText, - const IntlWrapper * + const IntlWrapper& ) const { rText.clear(); diff --git a/svl/source/items/int64item.cxx b/svl/source/items/int64item.cxx index 6cfc0036c619..afe284520bb8 100644 --- a/svl/source/items/int64item.cxx +++ b/svl/source/items/int64item.cxx @@ -35,7 +35,7 @@ bool SfxInt64Item::operator== ( const SfxPoolItem& rItem ) const bool SfxInt64Item::GetPresentation( SfxItemPresentation, MapUnit, MapUnit, OUString& rText, - const IntlWrapper* /*pIntlWrapper*/ ) const + const IntlWrapper& /*rIntlWrapper*/ ) const { rText = OUString::number(mnValue); return true; diff --git a/svl/source/items/intitem.cxx b/svl/source/items/intitem.cxx index 09d31f860436..9d1eee2db3c8 100644 --- a/svl/source/items/intitem.cxx +++ b/svl/source/items/intitem.cxx @@ -68,7 +68,7 @@ bool SfxInt16Item::operator ==(const SfxPoolItem & rItem) const bool SfxInt16Item::GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString & rText, - const IntlWrapper *) const + const IntlWrapper&) const { rText = OUString::number(m_nValue); return true; diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 1327a2bfea9c..a914bd6d24c5 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -475,11 +475,11 @@ bool SfxItemPool::GetPresentation const SfxPoolItem& rItem, MapUnit eMetric, OUString& rText, - const IntlWrapper * pIntlWrapper + const IntlWrapper& rIntlWrapper ) const { return rItem.GetPresentation( - SfxItemPresentation::Complete, GetMetric(rItem.Which()), eMetric, rText, pIntlWrapper ); + SfxItemPresentation::Complete, GetMetric(rItem.Which()), eMetric, rText, rIntlWrapper ); } diff --git a/svl/source/items/macitem.cxx b/svl/source/items/macitem.cxx index 9bf75713b6d9..505039c86d71 100644 --- a/svl/source/items/macitem.cxx +++ b/svl/source/items/macitem.cxx @@ -223,7 +223,7 @@ bool SvxMacroItem::GetPresentation MapUnit /*eCoreUnit*/, MapUnit /*ePresUnit*/, OUString& rText, - const IntlWrapper * + const IntlWrapper& ) const { /*!!! diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx index 5c2c77cae919..fb0ef21446d0 100644 --- a/svl/source/items/poolitem.cxx +++ b/svl/source/items/poolitem.cxx @@ -20,6 +20,8 @@ #include #include +#include +#include #include #include #include @@ -112,7 +114,7 @@ bool SfxPoolItem::GetPresentation MapUnit /*eCoreMetric*/, // IN: current metric of the SfxPoolItems MapUnit /*ePresentationMetric*/, // IN: target metric of the presentation OUString& /*rText*/, // OUT: textual representation - const IntlWrapper * + const IntlWrapper& ) const { return false; @@ -124,7 +126,8 @@ void SfxPoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); xmlTextWriterWriteAttribute(pWriter, BAD_CAST("typeName"), BAD_CAST(typeid(*this).name())); OUString rText; - if (GetPresentation( SfxItemPresentation::Complete, MapUnit::Map100thMM, MapUnit::Map100thMM, rText)) + IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag()); + if (GetPresentation( SfxItemPresentation::Complete, MapUnit::Map100thMM, MapUnit::Map100thMM, rText, aIntlWrapper)) xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(rText.getStr())); xmlTextWriterEndElement(pWriter); } @@ -171,7 +174,7 @@ bool SfxVoidItem::GetPresentation MapUnit /*eCoreMetric*/, MapUnit /*ePresentationMetric*/, OUString& rText, - const IntlWrapper * + const IntlWrapper& ) const { rText = "Void"; diff --git a/svl/source/items/ptitem.cxx b/svl/source/items/ptitem.cxx index 41c0e4922ece..dd6f3a6bd3bb 100644 --- a/svl/source/items/ptitem.cxx +++ b/svl/source/items/ptitem.cxx @@ -59,7 +59,7 @@ bool SfxPointItem::GetPresentation MapUnit /*eCoreMetric*/, MapUnit /*ePresentationMetric*/, OUString& rText, - const IntlWrapper * + const IntlWrapper& ) const { rText = OUString::number(aVal.X()) + ", " + OUString::number(aVal.Y()) + ", "; diff --git a/svl/source/items/rectitem.cxx b/svl/source/items/rectitem.cxx index 56ceccebce47..e4bd0d9b97c2 100644 --- a/svl/source/items/rectitem.cxx +++ b/svl/source/items/rectitem.cxx @@ -56,7 +56,7 @@ bool SfxRectangleItem::GetPresentation MapUnit /*eCoreMetric*/, MapUnit /*ePresentationMetric*/, OUString& rText, - const IntlWrapper * + const IntlWrapper& ) const { rText = OUString::number(aVal.Top()) + ", " + diff --git a/svl/source/items/rngitem.cxx b/svl/source/items/rngitem.cxx index be60ce3bf204..efb837eaab98 100644 --- a/svl/source/items/rngitem.cxx +++ b/svl/source/items/rngitem.cxx @@ -46,7 +46,7 @@ bool SfxRangeItem::GetPresentation MapUnit /*eCoreMetric*/, MapUnit /*ePresentationMetric*/, OUString& rText, - const IntlWrapper * + const IntlWrapper& ) const { rText = OUString::number(nFrom) + ":" + OUString::number(nTo); diff --git a/svl/source/items/sitem.cxx b/svl/source/items/sitem.cxx index fdfbe7870450..d209565f0d5d 100644 --- a/svl/source/items/sitem.cxx +++ b/svl/source/items/sitem.cxx @@ -66,7 +66,7 @@ bool SfxSetItem::GetPresentation MapUnit /*eCoreMetric*/, MapUnit /*ePresentationMetric*/, OUString& /*rText*/, - const IntlWrapper * + const IntlWrapper& ) const { return false; diff --git a/svl/source/items/slstitm.cxx b/svl/source/items/slstitm.cxx index 34399ee2f3e8..81025401e379 100644 --- a/svl/source/items/slstitm.cxx +++ b/svl/source/items/slstitm.cxx @@ -115,7 +115,7 @@ bool SfxStringListItem::GetPresentation MapUnit /*eCoreMetric*/, MapUnit /*ePresentationMetric*/, OUString& rText, - const IntlWrapper * + const IntlWrapper& ) const { rText = "(List)"; diff --git a/svl/source/items/srchitem.cxx b/svl/source/items/srchitem.cxx index 71584443a29c..0bfa0a9eea71 100644 --- a/svl/source/items/srchitem.cxx +++ b/svl/source/items/srchitem.cxx @@ -284,7 +284,7 @@ bool SvxSearchItem::GetPresentation MapUnit , MapUnit , OUString& , - const IntlWrapper * + const IntlWrapper& ) const { return false; diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index 1a54081eab52..ec5de87916e8 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -344,14 +344,14 @@ OUString SfxStyleSheetBase::GetDescription( MapUnit eMetric ) OUString aDesc; const SfxPoolItem* pItem = aIter.FirstItem(); - IntlWrapper aIntlWrapper( SvtSysLocale().GetLanguageTag() ); + IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag()); while ( pItem ) { OUString aItemPresentation; if ( !IsInvalidItem( pItem ) && pPool->GetPool().GetPresentation( - *pItem, eMetric, aItemPresentation, &aIntlWrapper ) ) + *pItem, eMetric, aItemPresentation, aIntlWrapper ) ) { if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() ) aDesc += " + "; diff --git a/svl/source/items/szitem.cxx b/svl/source/items/szitem.cxx index d983fcc0f943..ca7bac49880d 100644 --- a/svl/source/items/szitem.cxx +++ b/svl/source/items/szitem.cxx @@ -48,7 +48,7 @@ bool SfxSizeItem::GetPresentation MapUnit /*eCoreMetric*/, MapUnit /*ePresentationMetric*/, OUString& rText, - const IntlWrapper * + const IntlWrapper& ) const { rText = OUString::number(aVal.Width()) + ", " + OUString::number(aVal.Height()) + ", "; diff --git a/svl/source/items/visitem.cxx b/svl/source/items/visitem.cxx index d2952099e2c3..d0e58656ddd3 100644 --- a/svl/source/items/visitem.cxx +++ b/svl/source/items/visitem.cxx @@ -43,7 +43,7 @@ bool SfxVisibilityItem::operator ==(const SfxPoolItem & rItem) const bool SfxVisibilityItem::GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString & rText, - const IntlWrapper *) const + const IntlWrapper&) const { rText = m_nValue.bVisible ? OUString("TRUE") : OUString("FALSE"); return true; diff --git a/svl/source/misc/getstringresource.cxx b/svl/source/misc/getstringresource.cxx index 98c7d4a26ac4..59ee843391cb 100644 --- a/svl/source/misc/getstringresource.cxx +++ b/svl/source/misc/getstringresource.cxx @@ -22,56 +22,18 @@ #include #include #include -#include #include #include #include #include +#include #include "getstringresource.hxx" -namespace { - -class ResMgrMap { -public: - ResMgrMap() = default; - ResMgrMap(const ResMgrMap&) = delete; - ResMgrMap& operator=(const ResMgrMap&) = delete; - - const std::locale& get(LanguageTag const & locale); - -private: - typedef std::map Map; - - Map map_; - // one SimpleResMgr for each language for which a resource was requested - // (when using the "non-simple" resmgr, the first request for any - // language wins, any further requests for any other languages supply - // the resmgr of the first call; for the simple resmgr we have a mgr - // for each language ever requested) -}; - -const std::locale& ResMgrMap::get(LanguageTag const & locale) { - OUString code( locale.getBcp47()); - Map::iterator i(map_.find(code)); - if (i == map_.end()) { - std::locale loc = Translate::Create("svl", locale); - i = map_.insert(Map::value_type(code, loc)).first; - } - return i->second; -} - -struct theResMgrMap: public rtl::Static< ResMgrMap, theResMgrMap > {}; - -} - -namespace svl { - -OUString getStringResource(const char* id, LanguageTag const & locale) +OUString SvlResId(const char* id) { - return Translate::get(id, theResMgrMap::get().get(locale)); -} - + static std::locale loc = Translate::Create("svl", SvtSysLocale().GetUILanguageTag()); + return Translate::get(id, loc); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svl/source/misc/getstringresource.hxx b/svl/source/misc/getstringresource.hxx index 4776c1572754..b04553bc13e5 100644 --- a/svl/source/misc/getstringresource.hxx +++ b/svl/source/misc/getstringresource.hxx @@ -24,15 +24,7 @@ #include -namespace com { namespace sun { namespace star { namespace lang { - struct Locale; -} } } } - -namespace svl { - -OUString getStringResource( - const char* id, LanguageTag const & locale); -} +OUString SvlResId(const char* id); #endif diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx index 3da903827455..e34d41051588 100644 --- a/svl/source/misc/inettype.cxx +++ b/svl/source/misc/inettype.cxx @@ -601,8 +601,7 @@ OUString INetContentTypes::GetContentType(INetContentType eTypeID) } //static -OUString INetContentTypes::GetPresentation(INetContentType eTypeID, - const LanguageTag& aLocale) +OUString INetContentTypes::GetPresentation(INetContentType eTypeID) { const char* pResID = nullptr; if (eTypeID <= CONTENT_TYPE_LAST) @@ -615,7 +614,7 @@ OUString INetContentTypes::GetPresentation(INetContentType eTypeID, else return aPresentation; } - return svl::getStringResource(pResID, aLocale); + return SvlResId(pResID); } //static -- cgit