use more optional for CharClass
Change-Id: I67984321b8f38928bfab9fb0b624620e7d286a11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151722 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
3168d1ab07
commit
5dc82f62d5
@ -359,7 +359,7 @@ SvxAutoCorrect::~SvxAutoCorrect()
|
||||
|
||||
void SvxAutoCorrect::GetCharClass_( LanguageType eLang )
|
||||
{
|
||||
pCharClass.reset( new CharClass( LanguageTag( eLang)) );
|
||||
moCharClass.emplace( LanguageTag( eLang) );
|
||||
eCharClassLang = eLang;
|
||||
}
|
||||
|
||||
|
@ -28,14 +28,15 @@
|
||||
#include <tools/date.hxx>
|
||||
#include <editeng/swafopt.hxx>
|
||||
#include <editeng/editengdllapi.h>
|
||||
#include <unotools/charclass.hxx>
|
||||
|
||||
#include <optional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
class CharClass;
|
||||
class SfxPoolItem;
|
||||
class SotStorage;
|
||||
class SvxAutoCorrect;
|
||||
@ -255,7 +256,7 @@ class EDITENG_DLLPUBLIC SvxAutoCorrect
|
||||
// all languages in a table
|
||||
std::map<LanguageTag, SvxAutoCorrectLanguageLists> m_aLangTable;
|
||||
std::map<LanguageTag, sal_Int64> aLastFileTable;
|
||||
std::unique_ptr<CharClass> pCharClass;
|
||||
std::optional<CharClass> moCharClass;
|
||||
|
||||
LanguageType eCharClassLang;
|
||||
|
||||
@ -440,9 +441,9 @@ public:
|
||||
|
||||
CharClass& GetCharClass( LanguageType eLang )
|
||||
{
|
||||
if( !pCharClass || eLang != eCharClassLang )
|
||||
if( !moCharClass || eLang != eCharClassLang )
|
||||
GetCharClass_( eLang );
|
||||
return *pCharClass;
|
||||
return *moCharClass;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -394,9 +394,9 @@ bool SpellCheckerDispatcher::isValid_Impl(
|
||||
bRes = !xTmp->isNegative();
|
||||
} else {
|
||||
setCharClass(LanguageTag(nLanguage));
|
||||
CapType ct = capitalType(aChkWord, m_pCharClass.get());
|
||||
CapType ct = capitalType(aChkWord, m_oCharClass ? &*m_oCharClass : nullptr);
|
||||
if (ct == CapType::INITCAP || ct == CapType::ALLCAP) {
|
||||
Reference< XDictionaryEntry > xTmp2( lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_pCharClass.get()), nLanguage ) );
|
||||
Reference< XDictionaryEntry > xTmp2( lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_oCharClass), nLanguage ) );
|
||||
if (xTmp2.is()) {
|
||||
bRes = !xTmp2->isNegative();
|
||||
}
|
||||
@ -635,10 +635,10 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
|
||||
else
|
||||
{
|
||||
setCharClass(LanguageTag(nLanguage));
|
||||
CapType ct = capitalType(aChkWord, m_pCharClass.get());
|
||||
CapType ct = capitalType(aChkWord, m_oCharClass ? &*m_oCharClass : nullptr);
|
||||
if (ct == CapType::INITCAP || ct == CapType::ALLCAP)
|
||||
{
|
||||
Reference< XDictionaryEntry > xTmp2( lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_pCharClass.get()), nLanguage ) );
|
||||
Reference< XDictionaryEntry > xTmp2( lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_oCharClass), nLanguage ) );
|
||||
if (xTmp2.is())
|
||||
{
|
||||
if (xTmp2->isNegative()) // negative entry found
|
||||
@ -655,10 +655,10 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
|
||||
switch ( ct )
|
||||
{
|
||||
case CapType::INITCAP:
|
||||
aProposalList.Prepend( m_pCharClass->titlecase(aAddRplcTxt) );
|
||||
aProposalList.Prepend( m_oCharClass->titlecase(aAddRplcTxt) );
|
||||
break;
|
||||
case CapType::ALLCAP:
|
||||
aProposalList.Prepend( m_pCharClass->uppercase(aAddRplcTxt) );
|
||||
aProposalList.Prepend( m_oCharClass->uppercase(aAddRplcTxt) );
|
||||
break;
|
||||
default:
|
||||
/* can't happen because of if ct == above */
|
||||
@ -813,13 +813,13 @@ void SpellCheckerDispatcher::FlushSpellCache()
|
||||
|
||||
void SpellCheckerDispatcher::setCharClass(const LanguageTag& rLanguageTag)
|
||||
{
|
||||
if (m_pCharClass && m_pCharClass->getLanguageTag() == rLanguageTag)
|
||||
if (m_oCharClass && m_oCharClass->getLanguageTag() == rLanguageTag)
|
||||
return;
|
||||
m_pCharClass.reset( new CharClass(rLanguageTag) );
|
||||
m_oCharClass.emplace( rLanguageTag );
|
||||
}
|
||||
|
||||
|
||||
OUString SpellCheckerDispatcher::makeLowerCase(const OUString& aTerm, CharClass const * pCC)
|
||||
OUString SpellCheckerDispatcher::makeLowerCase(const OUString& aTerm, const std::optional<CharClass> & pCC)
|
||||
{
|
||||
if (pCC)
|
||||
return pCC->lowercase(aTerm);
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <unotools/charclass.hxx>
|
||||
|
||||
class LngSvcMgr;
|
||||
@ -53,7 +54,7 @@ class SpellCheckerDispatcher :
|
||||
|
||||
LngSvcMgr &m_rMgr;
|
||||
mutable std::unique_ptr<linguistic::SpellCache> m_pCache; // Spell Cache (holds known words)
|
||||
std::unique_ptr<CharClass> m_pCharClass;
|
||||
std::optional<CharClass> m_oCharClass;
|
||||
|
||||
SpellCheckerDispatcher(const SpellCheckerDispatcher &) = delete;
|
||||
SpellCheckerDispatcher & operator = (const SpellCheckerDispatcher &) = delete;
|
||||
@ -105,7 +106,7 @@ public:
|
||||
|
||||
private:
|
||||
void setCharClass(const LanguageTag& rLanguageTag);
|
||||
static OUString makeLowerCase(const OUString&, CharClass const *);
|
||||
static OUString makeLowerCase(const OUString&, const std::optional<CharClass> &);
|
||||
|
||||
};
|
||||
|
||||
|
@ -22,11 +22,13 @@
|
||||
#include <com/sun/star/text/WritingMode.hpp>
|
||||
#include <svl/style.hxx>
|
||||
#include <svx/fmmodel.hxx>
|
||||
#include <unotools/charclass.hxx>
|
||||
#include <vcl/prntypes.hxx>
|
||||
#include <xmloff/autolayout.hxx>
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
#include "sddllapi.h"
|
||||
@ -51,7 +53,6 @@ struct SpellCallbackInfo;
|
||||
class SdCustomShowList;
|
||||
class SdUndoGroup;
|
||||
class SdrObject;
|
||||
class CharClass;
|
||||
class Idle;
|
||||
class ImageMap;
|
||||
class Outliner;
|
||||
@ -162,8 +163,8 @@ private:
|
||||
::sd::DrawDocShellRef mxAllocedDocShRef; // => AllocModel()
|
||||
bool mbAllocDocSh; // => AllocModel()
|
||||
DocumentType meDocType;
|
||||
std::unique_ptr<CharClass>
|
||||
mpCharClass;
|
||||
std::optional<CharClass>
|
||||
moCharClass;
|
||||
|
||||
::std::unique_ptr<ImpDrawPageListWatcher> mpDrawPageListWatcher;
|
||||
::std::unique_ptr<ImpMasterPageListWatcher> mpMasterPageListWatcher;
|
||||
@ -464,7 +465,7 @@ public:
|
||||
|
||||
static SdAnimationInfo* GetShapeUserData(SdrObject& rObject, bool bCreate = false );
|
||||
|
||||
SAL_DLLPRIVATE CharClass* GetCharClass() const { return mpCharClass.get(); }
|
||||
SAL_DLLPRIVATE const std::optional<CharClass>& GetCharClass() const { return moCharClass; }
|
||||
|
||||
SAL_DLLPRIVATE void UpdateAllLinks();
|
||||
|
||||
|
@ -199,7 +199,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
|
||||
}
|
||||
|
||||
LanguageType eRealLanguage = MsLangId::getRealLanguage( meLanguage );
|
||||
mpCharClass.reset(new CharClass( LanguageTag( eRealLanguage) ));
|
||||
moCharClass.emplace(LanguageTag( eRealLanguage));
|
||||
|
||||
// If the current application language is a language that uses right-to-left text...
|
||||
LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
|
||||
@ -367,7 +367,7 @@ SdDrawDocument::~SdDrawDocument()
|
||||
mpCustomShowList.reset();
|
||||
mpOutliner.reset();
|
||||
mpInternalOutliner.reset();
|
||||
mpCharClass.reset();
|
||||
moCharClass.reset();
|
||||
}
|
||||
|
||||
void SdDrawDocument::adaptSizeAndBorderForAllPages(
|
||||
|
@ -195,7 +195,7 @@ void SdCustomShowDlg::SelectHdl(void const *p)
|
||||
{
|
||||
// replace number by a number increased by 1
|
||||
|
||||
const CharClass* pCharClass = rDoc.GetCharClass();
|
||||
const std::optional<CharClass>& pCharClass = rDoc.GetCharClass();
|
||||
while( pCharClass->isDigit( aStr, nStrPos ) )
|
||||
aStr = aStr.replaceAt( nStrPos, 1, u"" );
|
||||
aStr = aStr.subView( 0, nStrPos) + OUString::number( ++nNum ) + aStr.subView( nStrPos);
|
||||
|
@ -98,7 +98,7 @@ class SwAutoFormat
|
||||
SwTextFrame* m_pCurTextFrame; // frame of the current TextNode
|
||||
bool m_bIsRightToLeft; // text direction of the current frame
|
||||
SwNodeOffset m_nEndNdIdx; // for the percentage-display
|
||||
mutable std::unique_ptr<CharClass> m_pCharClass; // Character classification
|
||||
mutable std::optional<CharClass> m_oCharClass; // Character classification
|
||||
mutable LanguageType m_eCharClassLang;
|
||||
|
||||
sal_uInt16 m_nRedlAutoFormatSeqId;
|
||||
@ -121,12 +121,12 @@ class SwAutoFormat
|
||||
|
||||
CharClass& GetCharClass( LanguageType eLang ) const
|
||||
{
|
||||
if( !m_pCharClass || eLang != m_eCharClassLang )
|
||||
if( !m_oCharClass || eLang != m_eCharClassLang )
|
||||
{
|
||||
m_pCharClass.reset( new CharClass( LanguageTag( eLang ) ) );
|
||||
m_oCharClass.emplace( LanguageTag( eLang ) );
|
||||
m_eCharClassLang = eLang;
|
||||
}
|
||||
return *m_pCharClass;
|
||||
return *m_oCharClass;
|
||||
}
|
||||
|
||||
static bool IsSpace( const sal_Unicode c )
|
||||
|
@ -20,13 +20,14 @@
|
||||
#define INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX
|
||||
|
||||
#include <i18nlangtag/lang.h>
|
||||
#include <unotools/charclass.hxx>
|
||||
#include <nodeoffset.hxx>
|
||||
#include <tox.hxx>
|
||||
|
||||
#include <com/sun/star/lang/Locale.hpp>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
class CharClass;
|
||||
class SwContentNode;
|
||||
class SwTextNode;
|
||||
class SwTextTOXMark;
|
||||
@ -73,7 +74,7 @@ struct TextAndReading
|
||||
class SwTOXInternational
|
||||
{
|
||||
std::unique_ptr<IndexEntrySupplierWrapper> m_pIndexWrapper;
|
||||
std::unique_ptr<CharClass> m_pCharClass;
|
||||
std::optional<CharClass> m_oCharClass;
|
||||
LanguageType m_eLang;
|
||||
OUString m_sSortAlgorithm;
|
||||
SwTOIOptions m_nOptions;
|
||||
|
@ -91,24 +91,24 @@ void SwTOXInternational::Init()
|
||||
else
|
||||
m_pIndexWrapper->LoadAlgorithm( aLcl, m_sSortAlgorithm, SW_COLLATOR_IGNORES );
|
||||
|
||||
m_pCharClass.reset( new CharClass( LanguageTag( aLcl )) );
|
||||
m_oCharClass.emplace( LanguageTag( aLcl ) );
|
||||
|
||||
}
|
||||
|
||||
SwTOXInternational::~SwTOXInternational()
|
||||
{
|
||||
m_pCharClass.reset();
|
||||
m_oCharClass.reset();
|
||||
m_pIndexWrapper.reset();
|
||||
}
|
||||
|
||||
OUString SwTOXInternational::ToUpper( const OUString& rStr, sal_Int32 nPos ) const
|
||||
{
|
||||
return m_pCharClass->uppercase( rStr, nPos, 1 );
|
||||
return m_oCharClass->uppercase( rStr, nPos, 1 );
|
||||
}
|
||||
|
||||
bool SwTOXInternational::IsNumeric( const OUString& rStr ) const
|
||||
{
|
||||
return m_pCharClass->isNumeric( rStr );
|
||||
return m_oCharClass->isNumeric( rStr );
|
||||
}
|
||||
|
||||
sal_Int32 SwTOXInternational::Compare( const TextAndReading& rTaR1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user