diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-07-25 12:07:33 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-07-25 14:13:46 +0200 |
commit | 0031210b26bfae38be4243f9c92d90fa213b9eb0 (patch) | |
tree | 13fd775310b614741146d0ad9673044ac947f8d1 /editeng | |
parent | 70d9e9bfcdad5f3b18487a87d0bfe2a2a6213b19 (diff) |
autocomplete: replace horrible use of SvStringsISortDtor...
... to store not Strings but derived SwAutoCompleteStrings with
something far saner: an abstract base class with virtual dtor.
Change-Id: I7d966f385dd41154ee1c4cdb43b56ff1aace9b5e
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/inc/editeng/swafopt.hxx | 44 | ||||
-rw-r--r-- | editeng/source/misc/swafopt.cxx | 4 |
2 files changed, 42 insertions, 6 deletions
diff --git a/editeng/inc/editeng/swafopt.hxx b/editeng/inc/editeng/swafopt.hxx index 38072e699d9e..684a1838c731 100644 --- a/editeng/inc/editeng/swafopt.hxx +++ b/editeng/inc/editeng/swafopt.hxx @@ -16,21 +16,57 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef _SVXSWAFOPT_HXX -#define _SVXSWAFOPT_HXX + +#ifndef EE_SVXSWAFOPT_HXX +#define EE_SVXSWAFOPT_HXX + +#include <o3tl/sorted_vector.hxx> + +#include <tools/string.hxx> #include <vcl/font.hxx> #include "editeng/editengdllapi.h" -class SvStringsISortDtor; class SmartTagMgr; +namespace editeng { + +class EDITENG_DLLPUBLIC IAutoCompleteString +{ +private: + String m_String; +public: + explicit IAutoCompleteString(String const& rString) : m_String(rString) {} + virtual ~IAutoCompleteString() {} + String const& GetAutoCompleteString() const { return m_String; } +}; + +struct CompareAutoCompleteString +{ + bool operator()(IAutoCompleteString *const& lhs, + IAutoCompleteString *const& rhs) const + { + return lhs->GetAutoCompleteString().CompareIgnoreCaseToAscii( + rhs->GetAutoCompleteString()) == COMPARE_LESS; + } +}; + +class SortedAutoCompleteStrings + : public o3tl::sorted_vector<IAutoCompleteString*, CompareAutoCompleteString> +{ +public: + ~SortedAutoCompleteStrings() { DeleteAndDestroyAll(); } +}; + +} // namespace editeng + // Class of options for AutoFormat struct EDITENG_DLLPUBLIC SvxSwAutoFmtFlags { Font aBulletFont; Font aByInputBulletFont; - const SvStringsISortDtor* pAutoCmpltList; // only valid inside the Dialog!!! + /// only valid inside the Dialog!!! + const editeng::SortedAutoCompleteStrings * m_pAutoCompleteList; SmartTagMgr* pSmartTagMgr; sal_Unicode cBullet; diff --git a/editeng/source/misc/swafopt.cxx b/editeng/source/misc/swafopt.cxx index 3bdf5730b28f..00f1a832c674 100644 --- a/editeng/source/misc/swafopt.cxx +++ b/editeng/source/misc/swafopt.cxx @@ -86,7 +86,7 @@ SvxSwAutoFmtFlags::SvxSwAutoFmtFlags() nAutoCmpltWordLen = 10; nAutoCmpltListLen = 500; - pAutoCmpltList = 0; + m_pAutoCompleteList = 0; pSmartTagMgr = 0; } @@ -140,7 +140,7 @@ SvxSwAutoFmtFlags& SvxSwAutoFmtFlags::operator=( const SvxSwAutoFmtFlags& rAFFla bAutoCmpltEndless = rAFFlags.bAutoCmpltEndless; bAutoCmpltAppendBlanc = rAFFlags.bAutoCmpltAppendBlanc; bAutoCmpltShowAsTip = rAFFlags.bAutoCmpltShowAsTip; - pAutoCmpltList = rAFFlags.pAutoCmpltList; + m_pAutoCompleteList = rAFFlags.m_pAutoCompleteList; pSmartTagMgr = rAFFlags.pSmartTagMgr; nAutoCmpltExpandKey = rAFFlags.nAutoCmpltExpandKey; |