class SfxPoolItem; class SotStorage; class SvxAutoCorrect; class SfxObjectShell; namespace vcl { class Window; } namespace com::sun::star::embed { class XStorage; }
class SvStringsISortDtor
: public o3tl::sorted_vector<OUString, CompareSvStringsISortDtor>
{
};
// Auto correct flags enumclass ACFlags : sal_uInt32 {
NONE = 0x00000000,
CapitalStartSentence = 0x00000001, // Capital letters at the beginning of a sentence
CapitalStartWord = 0x00000002, // not two Capital letters at the beginning of a word
AddNonBrkSpace = 0x00000004, // Add non breaking space before :,?!%
ChgOrdinalNumber = 0x00000008, // Ordinal-Number 1st, 2nd,..
ChgToEnEmDash = 0x00000010, // - -> Endash/Emdash
ChgWeightUnderl = 0x00000020, // * -> Bold, _ -> Underscore
SetINetAttr = 0x00000040, // Set INetAttribute
Autocorrect = 0x00000080, // Call AutoCorrect
ChgQuotes = 0x00000100, // replace double quotes
SaveWordCplSttLst = 0x00000200, // Save Auto correction of Capital letter at beginning of sentence.
SaveWordWordStartLst = 0x00000400, // Save Auto correction of TWo INitial CApitals or sMALL iNITIAL.
IgnoreDoubleSpace = 0x00000800, // Ignore 2 Spaces
ChgSglQuotes = 0x00001000, // Replace simple quotes
CorrectCapsLock = 0x00002000, // Correct accidental use of cAPS LOCK key
TransliterateRTL = 0x00004000, // Transliterate RTL text
ChgAngleQuotes = 0x00008000, // >>, << -> angle quotes in some languages
SetDOIAttr = 0x00010000, // Set DOIAttribute
ChgWordLstLoad = 0x20000000, // Replacement list loaded
CplSttLstLoad = 0x40000000, // Exception list for Capital letters Start loaded
WordStartLstLoad = 0x80000000, // Exception list for Word Start loaded
}; namespace o3tl { template<> struct typed_flags<ACFlags> : is_typed_flags<ACFlags, 0xe001ffff> {};
}
// Return the text of a previous paragraph. // If no paragraph exits or just an empty one, then return an empty string. // The flag indicates: // TRUE: before the normal insertion position (TRUE) // FALSE: in which the corrected word was inserted. // (Does not to have to be the same paragraph !!!!) virtual OUString const* GetPrevPara(bool bAtNormalPos) = 0;
// Is called after the change of the signs by the functions // - FnCapitalStartWord // - FnCapitalStartSentence // As an option, the words can then be inserted into the exception lists. virtualvoid SaveCpltSttWord( ACFlags nFlag, sal_Int32 nPos, const OUString& rExceptWord,
sal_Unicode cChar );
// which language at the position? virtual LanguageType GetLanguage( sal_Int32 nPos ) const;
};
class EDITENG_DLLPUBLIC SvxAutocorrWord
{
OUString sShort, sLong; bool bIsTxtOnly; // Is pure ASCII - Text public:
SvxAutocorrWord( OUString aS, OUString aL, bool bFlag = true )
: sShort(std::move( aS )), sLong(std::move( aL )), bIsTxtOnly( bFlag )
{}
class EDITENG_DLLPUBLIC SvxAutoCorrectLanguageLists
{
OUString sShareAutoCorrFile, sUserAutoCorrFile; // If the AutoCorr file is newer
Date aModifiedDate;
tools::Time aModifiedTime, aLastCheckTime;
// Load, Set, Get - the replacement list
SvxAutocorrWordList* LoadAutocorrWordList(); const SvxAutocorrWordList* GetAutocorrWordList();
// Load, Set, Get - the exception list for Capital letter at the // beginning of a sentence
SvStringsISortDtor* LoadCplSttExceptList(); void SaveCplSttExceptList();
SvStringsISortDtor* GetCplSttExceptList(); bool AddToCplSttExceptList(const OUString& rNew);
// Load, Set, Get the exception list for TWo INitial CApitals or sMALL iNITIAL
SvStringsISortDtor* LoadWordStartExceptList(); void SaveWordStartExceptList();
SvStringsISortDtor* GetWordStartExceptList(); bool AddToWordStartExceptList(const OUString& rNew);
// Save word substitutions: // Store these directly in the storage. The word list is updated // accordingly! // - pure Text bool PutText( const OUString& rShort, const OUString& rLong ); // - Text with attribution (only the SWG - SWG format!) void PutText( const OUString& rShort, SfxObjectShell& ); // - Make combined changes in one pass bool MakeCombinedChanges( std::vector<SvxAutocorrWord>& aNewEntries, std::vector<SvxAutocorrWord>& aDeleteEntries );
};
class EDITENG_DLLPUBLIC SvxAutoCorrect
{ friendclass SvxAutoCorrectLanguageLists;
// all languages in a table
std::map<LanguageTag, SvxAutoCorrectLanguageLists> m_aLangTable;
std::map<LanguageTag, sal_Int64> aLastFileTable;
std::optional<CharClass> moCharClass;
protected: // - Text with attribution (only the SWG - SWG format!) // rShort is the stream name - encrypted! virtualbool PutText( const css::uno::Reference < css::embed::XStorage >& rStg, const OUString& rFileName, const OUString& rShort, SfxObjectShell&, OUString& );
// required language in the table add if possible only when the file exists bool CreateLanguageFile(const LanguageTag& rLanguageTag, bool bNewFile = true); // - Return the replacement text (only for SWG format, all others can be // taken from the word list!) // rShort is the stream name - encrypted! public:
/** Execute an AutoCorrect. Returnswhathasbeenexecuted,accordingtotheaboveautocorrectflags. @paramio_bNbspRunNext RemembersifaNO-BREAKSPACEwasadded(eg.in"fr"language) (setto<TRUE/>)atthelastcharacterinputthatmayhaveto beremovedagaindependingonwhatcharacterisfollowing.
*/ // FIXME: this has the horrible flaw that the rTxt must be a reference // to the actual SwTxtNode/EditNode string because it inserts the character // in rDoc and expects that to side-effect rTxt void DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
sal_Int32 nPos, sal_Unicode cInsChar, bool bInsert, bool& io_bNbspRunNext,
vcl::Window const * pFrameWin = nullptr );
// Return for the autotext expansion the previous word, // AutoCorrect - corresponding algorithm
OUString GetPrevAutoCorrWord(SvxAutoCorrDoc const& rDoc, const OUString& rTxt, sal_Int32 nPos);
// Returns vector candidates for AutoText name match, starting with the longest string between // 3 and 9 characters long, that is a chunk of text starting with a whitespace or with a word's // first character, and ending at the current cursor position or empty string if no such string // exists static std::vector<OUString> GetChunkForAutoText(std::u16string_view rTxt, sal_Int32 nPos);
// Search for the words in the replacement table. // rText - check in this text the words of the list // rStt - the detected starting position // nEnd - to check position - as of this item forward // rLang - Input: in which language is searched // Output: in which "language list" was it found
std::optional<SvxAutocorrWordList::WordSearchStatus>
SearchWordsInList( std::u16string_view rTxt,
sal_Int32& rStt, sal_Int32 nEndPos,
SvxAutoCorrDoc& rDoc,
LanguageTag& rLang ); staticbool SearchWordsNext( std::u16string_view rTxt,
sal_Int32& rStt, sal_Int32 nEndPos,
SvxAutocorrWordList::WordSearchStatus& rStatus );
// Query/Set the Character for the Quote substitution
sal_Unicode GetStartSingleQuote() const { return cStartSQuote; }
sal_Unicode GetEndSingleQuote() const { return cEndSQuote; }
sal_Unicode GetStartDoubleQuote() const { return cStartDQuote; }
sal_Unicode GetEndDoubleQuote() const { return cEndDQuote; }
// Load, Set, Get - the replacement list
SvxAutocorrWordList* LoadAutocorrWordList( LanguageType eLang )
{ return GetLanguageList_( eLang ).LoadAutocorrWordList(); }
// Save word substitutions: // Save these directly in the storage. The word list is updated // accordingly! // - pure Text bool PutText( const OUString& rShort, const OUString& rLong, LanguageType eLang ); // - Text with attribution (only in the SWG - SWG format!) void PutText( const OUString& rShort, SfxObjectShell& rShell, LanguageType eLang )
{ GetLanguageList_( eLang ).PutText(rShort, rShell ); }
// Load, Set, Get - the exception list for capital letters at the // beginning of a sentence void SaveCplSttExceptList( LanguageType eLang );
SvStringsISortDtor* LoadCplSttExceptList(LanguageType eLang)
{ return GetLanguageList_( eLang ).LoadCplSttExceptList(); } const SvStringsISortDtor* GetCplSttExceptList( LanguageType eLang )
{ return GetLanguageList_( eLang ).GetCplSttExceptList(); }
// Adds a single word. The list will be immediately written to the file! bool AddCplSttException( const OUString& rNew, LanguageType eLang );
// Load, Set, Get the exception list for TWo INitial CApitals or sMALL iNITIAL void SaveWordStartExceptList( LanguageType eLang );
SvStringsISortDtor* LoadWordStartExceptList( LanguageType eLang )
{ return GetLanguageList_( eLang ).LoadWordStartExceptList(); } const SvStringsISortDtor* GetWordStartExceptList( LanguageType eLang )
{ return GetLanguageList_( eLang ).GetWordStartExceptList(); } // Adds a single word. The list will be immediately written to the file! bool AddWordStartException( const OUString& rNew, LanguageType eLang);
// Search through the Languages for the entry bool FindInWordStartExceptList( LanguageType eLang, const OUString& sWord ); bool FindInCplSttExceptList( LanguageType eLang, const OUString& sWord, bool bAbbreviation = false);
// Methods for the auto-correction void FnCapitalStartWord( SvxAutoCorrDoc&, const OUString&,
sal_Int32 nSttPos, sal_Int32 nEndPos,
LanguageType eLang ); bool FnChgOrdinalNumber( SvxAutoCorrDoc&, const OUString&,
sal_Int32 nSttPos, sal_Int32 nEndPos,
LanguageType eLang ); bool FnChgToEnEmDash( SvxAutoCorrDoc&, const OUString&,
sal_Int32 nSttPos, sal_Int32 nEndPos,
LanguageType eLang ); // Returns an updated position, at which the insertion/removal happened. It may be // a smaller value, if leading spaces were removed. If unsuccessful, returns -1.
sal_Int32 FnAddNonBrkSpace( SvxAutoCorrDoc&, std::u16string_view,
sal_Int32 nEndPos,
LanguageType eLang, bool& io_bNbspRunNext ); bool FnSetINetAttr( SvxAutoCorrDoc&, const OUString&,
sal_Int32 nSttPos, sal_Int32 nEndPos,
LanguageType eLang ); bool FnSetDOIAttr( SvxAutoCorrDoc&, std::u16string_view,
sal_Int32 nSttPos, sal_Int32 nEndPos,
LanguageType eLang ); bool FnChgWeightUnderl( SvxAutoCorrDoc&, const OUString&,
sal_Int32 nEndPos ); void FnCapitalStartSentence( SvxAutoCorrDoc&, const OUString&, bool bNormalPos,
sal_Int32 nSttPos, sal_Int32 nEndPos,
LanguageType eLang); bool FnCorrectCapsLock( SvxAutoCorrDoc&, const OUString&,
sal_Int32 nSttPos, sal_Int32 nEndPos,
LanguageType eLang );
static ACFlags GetDefaultFlags();
// returns sal_True for characters where the function // 'SvxAutoCorrect::AutoCorrect' should be called. // (used to avoid occasional 'collisions' with (Thai) input-sequence-checking) staticbool IsAutoCorrectChar( sal_Unicode cChar );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.