diff options
Diffstat (limited to 'svl/source')
-rw-r--r-- | svl/source/config/ctloptions.cxx | 41 | ||||
-rw-r--r-- | svl/source/crypto/cryptosign.cxx | 23 | ||||
-rw-r--r-- | svl/source/items/itemprop.cxx | 26 | ||||
-rw-r--r-- | svl/source/items/itemset.cxx | 58 | ||||
-rw-r--r-- | svl/source/items/poolitem.cxx | 27 | ||||
-rw-r--r-- | svl/source/items/style.cxx | 5 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 27 |
7 files changed, 117 insertions, 90 deletions
diff --git a/svl/source/config/ctloptions.cxx b/svl/source/config/ctloptions.cxx index 9f151bcb01cb..21418e80072c 100644 --- a/svl/source/config/ctloptions.cxx +++ b/svl/source/config/ctloptions.cxx @@ -38,6 +38,7 @@ class SvtCTLOptions_Impl : public utl::ConfigItem private: bool m_bIsLoaded; bool m_bCTLFontEnabled; + bool m_bCTLVerticalText; bool m_bCTLSequenceChecking; bool m_bCTLRestricted; bool m_bCTLTypeAndReplace; @@ -45,6 +46,7 @@ private: SvtCTLOptions::TextNumerals m_eCTLTextNumerals; bool m_bROCTLFontEnabled; + bool m_bROCTLVerticalText; bool m_bROCTLSequenceChecking; bool m_bROCTLRestricted; bool m_bROCTLTypeAndReplace; @@ -63,6 +65,8 @@ public: bool IsLoaded() const { return m_bIsLoaded; } void SetCTLFontEnabled( bool _bEnabled ); + void SetCTLVerticalText(bool bVertical); + void SetCTLSequenceChecking( bool _bEnabled ); void SetCTLSequenceCheckingRestricted( bool _bEnable ); @@ -94,6 +98,7 @@ bool SvtCTLOptions_Impl::IsReadOnly(SvtCTLOptions::EOption eOption) const case SvtCTLOptions::E_CTLTEXTNUMERALS : bReadOnly = m_bROCTLTextNumerals ; break; case SvtCTLOptions::E_CTLSEQUENCECHECKINGRESTRICTED: bReadOnly = m_bROCTLRestricted ; break; case SvtCTLOptions::E_CTLSEQUENCECHECKINGTYPEANDREPLACE: bReadOnly = m_bROCTLTypeAndReplace; break; + case SvtCTLOptions::E_CTLVERTICALTEXT : bReadOnly = m_bROCTLVerticalText ; break; default: assert(false); } return bReadOnly; @@ -104,6 +109,7 @@ SvtCTLOptions_Impl::SvtCTLOptions_Impl() : m_bIsLoaded ( false ), m_bCTLFontEnabled ( true ), + m_bCTLVerticalText ( true ), m_bCTLSequenceChecking ( false ), m_bCTLRestricted ( false ), m_bCTLTypeAndReplace ( false ), @@ -111,6 +117,7 @@ SvtCTLOptions_Impl::SvtCTLOptions_Impl() : m_eCTLTextNumerals ( SvtCTLOptions::NUMERALS_ARABIC ), m_bROCTLFontEnabled ( CFG_READONLY_DEFAULT ), + m_bROCTLVerticalText ( CFG_READONLY_DEFAULT ), m_bROCTLSequenceChecking( CFG_READONLY_DEFAULT ), m_bROCTLRestricted ( CFG_READONLY_DEFAULT ), m_bROCTLTypeAndReplace ( CFG_READONLY_DEFAULT ), @@ -210,6 +217,16 @@ void SvtCTLOptions_Impl::ImplCommit() } } break; + case 6: + { + if (!m_bROCTLVerticalText) + { + pNames[nRealCount] = pOrgNames[nProp]; + pValues[nRealCount] <<= m_bCTLVerticalText; + ++nRealCount; + } + } + break; } } aNames.realloc(nRealCount); @@ -230,7 +247,8 @@ void SvtCTLOptions_Impl::Load() u"CTLCursorMovement"_ustr, u"CTLTextNumerals"_ustr, u"CTLSequenceCheckingRestricted"_ustr, - u"CTLSequenceCheckingTypeAndReplace"_ustr }; + u"CTLSequenceCheckingTypeAndReplace"_ustr, + u"CTLVerticalText"_ustr}; EnableNotification( rPropertyNames ); } Sequence< Any > aValues = GetProperties( rPropertyNames ); @@ -256,6 +274,7 @@ void SvtCTLOptions_Impl::Load() case 1: { m_bCTLSequenceChecking = bValue; m_bROCTLSequenceChecking = pROStates[nProp]; } break; case 4: { m_bCTLRestricted = bValue; m_bROCTLRestricted = pROStates[nProp]; } break; case 5: { m_bCTLTypeAndReplace = bValue; m_bROCTLTypeAndReplace = pROStates[nProp]; } break; + case 6: { m_bCTLVerticalText = bValue; m_bROCTLVerticalText = pROStates[nProp]; } break; } } else if ( pValues[nProp] >>= nValue ) @@ -281,6 +300,15 @@ void SvtCTLOptions_Impl::SetCTLFontEnabled( bool _bEnabled ) NotifyListeners(ConfigurationHints::NONE); } } +void SvtCTLOptions_Impl::SetCTLVerticalText(bool bVertical) +{ + if (!m_bROCTLVerticalText && m_bCTLVerticalText != bVertical) + { + m_bCTLVerticalText = bVertical; + SetModified(); + NotifyListeners(ConfigurationHints::NONE); + } +} void SvtCTLOptions_Impl::SetCTLSequenceChecking( bool _bEnabled ) { if(!m_bROCTLSequenceChecking && m_bCTLSequenceChecking != _bEnabled) @@ -379,6 +407,17 @@ bool SvtCTLOptions::IsCTLFontEnabled() return officecfg::Office::Common::I18N::CTL::CTLFont::get(); } +void SvtCTLOptions::SetCTLVerticalText(bool bVertical) +{ + assert(m_pImpl->IsLoaded()); + m_pImpl->SetCTLVerticalText(bVertical); +} + +bool SvtCTLOptions::IsCTLVerticalText() +{ + return officecfg::Office::Common::I18N::CTL::CTLVerticalText::get(); +} + void SvtCTLOptions::SetCTLSequenceChecking( bool _bEnabled ) { assert(m_pImpl->IsLoaded()); diff --git a/svl/source/crypto/cryptosign.cxx b/svl/source/crypto/cryptosign.cxx index 90664e03caaf..c1f18f647962 100644 --- a/svl/source/crypto/cryptosign.cxx +++ b/svl/source/crypto/cryptosign.cxx @@ -14,6 +14,7 @@ #include <svl/cryptosign.hxx> #include <svl/sigstruct.hxx> #include <config_crypto.h> +#include <o3tl/numeric.hxx> #if USE_CRYPTO_NSS #include <systools/curlinit.hxx> @@ -884,24 +885,6 @@ bool CreateSigningCertificateAttribute(void const * pDerEncoded, int nDerEncoded namespace svl::crypto { -static int AsHex(char ch) -{ - int nRet = 0; - if (rtl::isAsciiDigit(static_cast<unsigned char>(ch))) - nRet = ch - '0'; - else - { - if (ch >= 'a' && ch <= 'f') - nRet = ch - 'a'; - else if (ch >= 'A' && ch <= 'F') - nRet = ch - 'A'; - else - return -1; - nRet += 10; - } - return nRet; -} - std::vector<unsigned char> DecodeHexString(std::string_view rHex) { std::vector<unsigned char> aRet; @@ -912,7 +895,7 @@ std::vector<unsigned char> DecodeHexString(std::string_view rHex) for (size_t i = 0; i < nHexLen; ++i) { nByte = nByte << 4; - sal_Int8 nParsed = AsHex(rHex[i]); + sal_Int8 nParsed = o3tl::convertToHex<int>(rHex[i]); if (nParsed == -1) { SAL_WARN("svl.crypto", "DecodeHexString: invalid hex value"); @@ -2405,7 +2388,7 @@ void Signing::appendHex(sal_Int8 nInt, OStringBuffer& rBuffer) rBuffer.append( pHexDigits[ nInt & 15 ] ); } -bool CertificateOrName::Is() +bool CertificateOrName::Is() const { return m_xCertificate.is() || !m_aName.isEmpty(); } diff --git a/svl/source/items/itemprop.cxx b/svl/source/items/itemprop.cxx index 329f84df722e..128bc190c390 100644 --- a/svl/source/items/itemprop.cxx +++ b/svl/source/items/itemprop.cxx @@ -41,7 +41,7 @@ SfxItemPropertyMap::SfxItemPropertyMap( std::span<const SfxItemPropertyMapEntry> for (const auto & pEntry : pEntries) { assert(!pEntry.aName.isEmpty() && "empty name? might be something left an empty entry at the end of this array"); - m_aMap.insert( { pEntry.aName, &pEntry } ); + m_aMap.insert( &pEntry ); } } @@ -51,12 +51,23 @@ SfxItemPropertyMap::~SfxItemPropertyMap() { } -const SfxItemPropertyMapEntry* SfxItemPropertyMap::getByName( const OUString & rName ) const +const SfxItemPropertyMapEntry* SfxItemPropertyMap::getByName( std::u16string_view rName ) const { - auto it = m_aMap.find(rName); - if (it == m_aMap.end()) + struct Compare + { + bool operator() ( const SfxItemPropertyMapEntry* lhs, std::u16string_view rhs ) const + { + return lhs->aName < rhs; + } + bool operator() ( std::u16string_view lhs, const SfxItemPropertyMapEntry* rhs ) const + { + return lhs < rhs->aName; + } + }; + auto it = std::lower_bound(m_aMap.begin(), m_aMap.end(), rName, Compare()); + if (it == m_aMap.end() || Compare()(rName, *it)) return nullptr; - return it->second; + return *it; } uno::Sequence<beans::Property> const & SfxItemPropertyMap::getProperties() const @@ -66,9 +77,8 @@ uno::Sequence<beans::Property> const & SfxItemPropertyMap::getProperties() const m_aPropSeq.realloc( m_aMap.size() ); beans::Property* pPropArray = m_aPropSeq.getArray(); sal_uInt32 n = 0; - for( const auto & rPair : m_aMap ) + for( const SfxItemPropertyMapEntry* pEntry : m_aMap ) { - const SfxItemPropertyMapEntry* pEntry = rPair.second; pPropArray[n].Name = pEntry->aName; pPropArray[n].Handle = pEntry->nWID; pPropArray[n].Type = pEntry->aType; @@ -94,7 +104,7 @@ beans::Property SfxItemPropertyMap::getPropertyByName( const OUString& rName ) c return aProp; } -bool SfxItemPropertyMap::hasPropertyByName( const OUString & rName ) const +bool SfxItemPropertyMap::hasPropertyByName( std::u16string_view rName ) const { return getByName(rName) != nullptr; } diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index d9da9c093cc9..d8aceb8dbb42 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -949,13 +949,9 @@ void SfxItemSet::Changed(const SfxPoolItem*, const SfxPoolItem*) const { } -/** - * Only retain the Items that are also present in rSet - * (nevermind their value). - */ void SfxItemSet::Intersect( const SfxItemSet& rSet ) { - // Delete all Items not contained in rSet + // Delete all Items *not* contained in rSet assert(m_pPool && "Not implemented without Pool"); if (!Count() || this == &rSet) @@ -970,21 +966,19 @@ void SfxItemSet::Intersect( const SfxItemSet& rSet ) return; } - // CAUTION: In the former impl, the - // - version for different ranges checked for SfxItemState::UNKNOWN - // in rSet -> this means that the WhichID is *not* defined in - // the ranges of rSet *at all* > definitely an *error* - // - version for same ranges checked for - // nullptr != local && nullptr == rSet. - // All together I think also using the text - // "Delete all Items not contained in rSet" leads to - // locally delete all Items that are *not* set in rSet - // -> != SfxItemState::SET - + // locally delete all items *not* contained in rSet, independent of their + // values, just dependent of existence. Iterate over all existing local items for (PoolItemMap::iterator aCandidate(m_aPoolItemMap.begin()); aCandidate != m_aPoolItemMap.end();) { - if (SfxItemState::SET != rSet.GetItemState_ForWhichID(SfxItemState::UNKNOWN, aCandidate->first, false, nullptr)) + // check if an item with that WhichID exists in rSet + const PoolItemMap::const_iterator aHit(rSet.m_aPoolItemMap.find(aCandidate->first)); + + if (aHit == rSet.m_aPoolItemMap.end()) { + // no item with that WhichID exists in rset, so we have to delete + // aCandidate. + // tdf#164712: NOTE: This includes all set items (SfxItemState::SET) + // but *also* SfxItemState::DISABLED and SfxItemState::INVALID. #ifdef DBG_UTIL assert(0 == m_nRegisteredSfxItemIter && "ITEM: SfxItemSet Intersect with active SfxItemIters (!)"); #endif @@ -1012,28 +1006,16 @@ void SfxItemSet::Differentiate(const SfxItemSet& rSet) return; } - // CAUTION: In the former impl, the - // - version for different ranges checked for SfxItemState::SET - // in rSet - // - version for same ranges checked for - // nullptr != local && nullptr != rSet. - // All together I think also using the text - // "Delete all Items contained in rSet" leads to - // locally delete all Items that *are *not* set in rSet - // -> ==SfxItemState::SET - - for (PoolItemMap::iterator aCandidate(m_aPoolItemMap.begin()); aCandidate != m_aPoolItemMap.end();) + // locally delete all items contained in rSet, independent of their + // values, just dependent of their existence in rSet. + // tdf#164712: NOTE: This includes all set items (SfxItemState::SET) + // but also SfxItemState::DISABLED and SfxItemState::INVALID. + // These are all items that exist in the std::unordered_map (PoolItemMap) + // of rSet, so we can just iterate over those and use the WhichID to + // delete the eventually Items in the local set + for (PoolItemMap::const_iterator aCandidate(rSet.m_aPoolItemMap.begin()); aCandidate != rSet.m_aPoolItemMap.end(); aCandidate++) { - if (SfxItemState::SET == rSet.GetItemState_ForWhichID(SfxItemState::UNKNOWN, aCandidate->first, false, nullptr)) - { -#ifdef DBG_UTIL - assert(0 == m_nRegisteredSfxItemIter && "ITEM: SfxItemSet Differentiate with active SfxItemIters (!)"); -#endif - ClearSingleItem_PrepareRemove(aCandidate->second); - aCandidate = m_aPoolItemMap.erase(aCandidate); - } - else - aCandidate++; + ClearSingleItem_ForWhichID(aCandidate->first); } } diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx index 2aa31be8db24..3bb040372f29 100644 --- a/svl/source/items/poolitem.cxx +++ b/svl/source/items/poolitem.cxx @@ -293,7 +293,9 @@ bool SfxPoolItem::areSame(const SfxPoolItem& rItem1, const SfxPoolItem& rItem2) namespace { -class InvalidOrDisabledItem final : public SfxPoolItem +// tdf#164745 make InvalidItem and DisabledItem two classes to +// avoid that op== sees them as equal +class InvalidItem final : public SfxPoolItem { virtual bool operator==(const SfxPoolItem&) const override { return true; } virtual SfxPoolItem* Clone(SfxItemPool*) const override { return nullptr; } @@ -301,15 +303,30 @@ class InvalidOrDisabledItem final : public SfxPoolItem public: // make it StaticDefaultItem to process similar to these // which is plausible (never change and are not allowed to) - DECLARE_ITEM_TYPE_FUNCTION(InvalidOrDisabledItem) - InvalidOrDisabledItem() + DECLARE_ITEM_TYPE_FUNCTION(InvalidItem) + InvalidItem() : SfxPoolItem(0) { setStaticDefault(); } }; -InvalidOrDisabledItem aInvalidItem; -InvalidOrDisabledItem aDisabledItem; +class DisabledItem final : public SfxPoolItem +{ + virtual bool operator==(const SfxPoolItem&) const override { return true; } + virtual SfxPoolItem* Clone(SfxItemPool*) const override { return nullptr; } + +public: + // make it StaticDefaultItem to process similar to these + // which is plausible (never change and are not allowed to) + DECLARE_ITEM_TYPE_FUNCTION(DisabledItem) + DisabledItem() + : SfxPoolItem(0) + { + setStaticDefault(); + } +}; +InvalidItem aInvalidItem; +DisabledItem aDisabledItem; } SfxPoolItem const* const INVALID_POOL_ITEM = &aInvalidItem; diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index 54b9e227ebce..a5144962632e 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -284,6 +284,11 @@ void SfxStyleSheetBase::SetHelpId( const OUString& rFile, sal_uInt32 nId ) nHelpId = nId; } +sal_Int32 SfxStyleSheetBase::GetSpotlightId() +{ + return -1; +} + /** * Next style possible? * Default: Yes diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index eda77fc62859..d72d7202dfe0 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -21,6 +21,7 @@ #include <o3tl/sprintf.hxx> #include <o3tl/string_view.hxx> +#include <o3tl/numeric.hxx> #include <comphelper/string.hxx> #include <sal/log.hxx> #include <tools/debug.hxx> @@ -1610,25 +1611,15 @@ SvNumberformat::LocaleType SvNumberformat::ImpGetLocaleType(std::u16string_view cToken = rString[nPos]; if (cToken == ']') break; - if ( '0' <= cToken && cToken <= '9' ) - { - nNum *= 16; - nNum += cToken - '0'; - } - else if ( 'a' <= cToken && cToken <= 'f' ) - { - nNum *= 16; - nNum += cToken - 'a' + 10; - } - else if ( 'A' <= cToken && cToken <= 'F' ) - { - nNum *= 16; - nNum += cToken - 'A' + 10; - } - else - { + + int nValue = o3tl::convertToHex<int>(cToken); + + if (nValue == -1) return LocaleType(); // LANGUAGE_DONTKNOW; - } + + nNum *= 16; + nNum += nValue; + ++nPos; } |