fpicker/source/office/contentenumeration.cxx | 16 ++++++++-------- fpicker/source/office/contentenumeration.hxx | 3 ++- sc/inc/rangeseq.hxx | 5 ++--- sc/source/core/tool/compiler.cxx | 17 ++++++++--------- sc/source/core/tool/ddelink.cxx | 3 +-- sc/source/core/tool/rangeseq.cxx | 21 +++++++++++++-------- sc/source/ui/docshell/docsh4.cxx | 4 ++-- 7 files changed, 36 insertions(+), 33 deletions(-)
New commits: commit f52dfc6fff0fa5f94aed433b22a87764c13e8e53 Author: Mike Kaganski <[email protected]> AuthorDate: Mon Feb 27 10:04:31 2023 +0300 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Feb 27 10:20:47 2023 +0000 Simplify a bit Change-Id: I2b4dc36e102f47b7fe61cd7c32bb2810cb35ea7d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147855 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index d37823695fd5..0c6a4baee7bd 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -3093,17 +3093,16 @@ bool ScCompiler::ParseOpCode( const OUString& rName, bool bInArray ) bool ScCompiler::ParseOpCode2( std::u16string_view rName ) { - bool bFound = false; - sal_uInt16 i; - - for( i = ocInternalBegin; i <= ocInternalEnd && !bFound; i++ ) - bFound = o3tl::equalsAscii( rName, pInternal[ i-ocInternalBegin ] ); - - if (bFound) + for (sal_uInt16 i = ocInternalBegin; i <= ocInternalEnd; i++) { - maRawToken.SetOpCode( static_cast<OpCode>(--i) ); + if (o3tl::equalsAscii(rName, pInternal[i - ocInternalBegin])) + { + maRawToken.SetOpCode(static_cast<OpCode>(i)); + return true; + } } - return bFound; + + return false; } static bool lcl_ParenthesisFollows( const sal_Unicode* p ) commit b3b18f8606131fc9998e872de84aab475acabf1a Author: Mike Kaganski <[email protected]> AuthorDate: Mon Feb 27 09:56:06 2023 +0300 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Feb 27 10:20:39 2023 +0000 Related: tdf#151429 Move fix for tdf#152717 to ScByteSequenceToString The GetString method is only used in DDE context; and allowing it to handle Anys with OUStrings generalizes the fix, simplifying its use. Change-Id: I50952c25fa736a9ca73515801cc1b1903c62453e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147753 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sc/inc/rangeseq.hxx b/sc/inc/rangeseq.hxx index d1dc7f9cd4b7..9f424d0f3812 100644 --- a/sc/inc/rangeseq.hxx +++ b/sc/inc/rangeseq.hxx @@ -94,10 +94,9 @@ public: class ScByteSequenceToString { public: - // rAny must contain Sequence<sal_Int8>, + // rAny must contain either OUString or Sequence<sal_Int8> (thread encoding assumed), // may or may not contain 0-bytes at the end - static bool GetString( OUString& rString, const css::uno::Any& rAny, - sal_uInt16 nEncoding ); + static bool GetString( OUString& rString, const css::uno::Any& rAny ); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx index 775c71808488..5000e0bf8769 100644 --- a/sc/source/core/tool/ddelink.cxx +++ b/sc/source/core/tool/ddelink.cxx @@ -130,8 +130,7 @@ sfx2::SvBaseLink::UpdateResult ScDdeLink::DataChanged( return SUCCESS; OUString aLinkStr; - if (!(rValue >>= aLinkStr)) - ScByteSequenceToString::GetString( aLinkStr, rValue, osl_getThreadTextEncoding() ); + ScByteSequenceToString::GetString( aLinkStr, rValue ); aLinkStr = convertLineEnd(aLinkStr, LINEEND_LF); // if string ends with line end, discard: diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx index c4ceea23d3e1..75652b720aa9 100644 --- a/sc/source/core/tool/rangeseq.cxx +++ b/sc/source/core/tool/rangeseq.cxx @@ -21,6 +21,7 @@ #include <rtl/math.hxx> #include <o3tl/float_int_conversion.hxx> #include <osl/diagnose.h> +#include <osl/thread.h> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Sequence.hxx> @@ -429,18 +430,22 @@ ScMatrixRef ScSequenceToMatrix::CreateMixedMatrix( const css::uno::Any & rAny ) return xMatrix; } -bool ScByteSequenceToString::GetString( OUString& rString, const uno::Any& rAny, - sal_uInt16 nEncoding ) +bool ScByteSequenceToString::GetString( OUString& rString, const uno::Any& rAny ) { - uno::Sequence<sal_Int8> aSeq; - if ( rAny >>= aSeq ) + bool bResult = false; + if (rAny >>= rString) + { + bResult = true; + } + else if (uno::Sequence<sal_Int8> aSeq; rAny >>= aSeq) { rString = OUString( reinterpret_cast<const char*>(aSeq.getConstArray()), - aSeq.getLength(), nEncoding ); - rString = comphelper::string::stripEnd(rString, 0); - return true; + aSeq.getLength(), osl_getThreadTextEncoding() ); + bResult = true; } - return false; + if (bResult) + rString = comphelper::string::stripEnd(rString, 0); + return bResult; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 72ca520453b8..737acbddd80c 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -2453,7 +2453,7 @@ bool ScDocShell::DdeSetData( const OUString& rItem, { if( rItem.equalsIgnoreAsciiCase( "Format" ) ) { - if ( ScByteSequenceToString::GetString( m_aDdeTextFmt, rValue, osl_getThreadTextEncoding() ) ) + if ( ScByteSequenceToString::GetString( m_aDdeTextFmt, rValue ) ) { m_aDdeTextFmt = m_aDdeTextFmt.toAsciiUpperCase(); return true; @@ -2467,7 +2467,7 @@ bool ScDocShell::DdeSetData( const OUString& rItem, m_aDdeTextFmt == "FSYLK" ) { OUString aData; - if ( ScByteSequenceToString::GetString( aData, rValue, osl_getThreadTextEncoding() ) ) + if ( ScByteSequenceToString::GetString( aData, rValue ) ) { return aObj.ImportString( aData, SotClipboardFormatId::SYLK ); } commit edf8047e854f78d5b90a601eda598d19a40301bf Author: Noel Grandin <[email protected]> AuthorDate: Fri Feb 24 15:02:01 2023 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Mon Feb 27 10:20:32 2023 +0000 osl::Mutex->std::mutex in FileViewContentEnumerator Change-Id: Ib9f0b7ba39f5acbfbdbd664f74a4a91f645c8192 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147862 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/fpicker/source/office/contentenumeration.cxx b/fpicker/source/office/contentenumeration.cxx index fbf310a0dc91..5eb12feeef2e 100644 --- a/fpicker/source/office/contentenumeration.cxx +++ b/fpicker/source/office/contentenumeration.cxx @@ -92,7 +92,7 @@ namespace svt void FileViewContentEnumerator::cancel() { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); m_bCancelled = true; m_pResultHandler = nullptr; m_aFolder.aContent = ::ucbhelper::Content(); @@ -105,7 +105,7 @@ namespace svt const css::uno::Sequence< OUString >& rDenyList ) { { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); m_aFolder = _rFolder; m_pResultHandler = nullptr; m_rDenyList = rDenyList; @@ -117,7 +117,7 @@ namespace svt void FileViewContentEnumerator::enumerateFolderContent( const FolderDescriptor& _rFolder, IEnumerationResultHandler* _pResultHandler ) { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); m_aFolder = _rFolder; m_pResultHandler = _pResultHandler; @@ -157,7 +157,7 @@ namespace svt { FolderDescriptor aFolder; { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); aFolder = m_aFolder; xEnvironment = m_xCommandEnv; } @@ -165,7 +165,7 @@ namespace svt { aFolder.aContent = ::ucbhelper::Content( aFolder.sURL, xEnvironment, comphelper::getProcessComponentContext() ); { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); m_aFolder.aContent = aFolder.aContent; } } @@ -215,7 +215,7 @@ namespace svt // check for restrictions { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); if ( /* m_rDenyList.hasElements() && */ URLOnDenyList ( sRealURL ) ) continue; } @@ -268,7 +268,7 @@ namespace svt } { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); bCancelled = m_bCancelled; } } @@ -287,7 +287,7 @@ namespace svt IEnumerationResultHandler* pHandler = nullptr; { - ::osl::MutexGuard aGuard( m_aMutex ); + std::unique_lock aGuard( m_aMutex ); pHandler = m_pResultHandler; if ( m_bCancelled ) return EnumerationResult::ERROR; diff --git a/fpicker/source/office/contentenumeration.hxx b/fpicker/source/office/contentenumeration.hxx index b1c07afcf1c4..d15db4d7a55f 100644 --- a/fpicker/source/office/contentenumeration.hxx +++ b/fpicker/source/office/contentenumeration.hxx @@ -22,6 +22,7 @@ #include <sal/config.h> #include <memory> +#include <mutex> #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <salhelper/thread.hxx> @@ -163,7 +164,7 @@ namespace svt ContentData& m_rContent; ::osl::Mutex& m_rContentMutex; - mutable ::osl::Mutex m_aMutex; + mutable std::mutex m_aMutex; FolderDescriptor m_aFolder; css::uno::Reference< css::ucb::XCommandEnvironment >
