diff options
author | Thomas Lange <tl@openoffice.org> | 2009-09-28 10:46:54 +0000 |
---|---|---|
committer | Thomas Lange <tl@openoffice.org> | 2009-09-28 10:46:54 +0000 |
commit | 47889e229cd51dd8a019d41dace6572e84771d18 (patch) | |
tree | 4e310b93a5b5c80cce183a139003be86f86121c4 /starmath/inc | |
parent | 46f1a498f70bbed831ae1e01a3a016a26f298eba (diff) |
158766 avoid duplicating symbols in the catalog
Diffstat (limited to 'starmath/inc')
-rw-r--r-- | starmath/inc/dialog.hxx | 85 | ||||
-rw-r--r-- | starmath/inc/smmod.hxx | 5 | ||||
-rw-r--r-- | starmath/inc/symbol.hxx | 176 |
3 files changed, 101 insertions, 165 deletions
diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx index a2814082a9e5..aefc11a60d8a 100644 --- a/starmath/inc/dialog.hxx +++ b/starmath/inc/dialog.hxx @@ -303,7 +303,7 @@ public: class SmShowSymbolSet : public Control { - SmSymSet aSymbolSet; + SymbolPtrVec_t aSymbolSet; ScrollBar aVScrollBar; Size aOutputSize; Link aSelectHdlLink; @@ -321,7 +321,7 @@ class SmShowSymbolSet : public Control public: SmShowSymbolSet(Window *pParent, const ResId& rResId); - void SetSymbolSet(const SmSymSet& rSymbolSet); + void SetSymbolSet(const SymbolPtrVec_t& rSymbolSet); void SelectSymbol(USHORT nSymbol); USHORT GetSelectSymbol() const { return nSelectSymbol; } @@ -363,8 +363,10 @@ class SmSymbolDialog : public ModalDialog PushButton aEditBtn; SmViewShell &rViewSh; - SmSymSetManager &rSymSetMgr; - const SmSymSet *pSymSet; + SmSymbolManager &rSymbolMgr; + + String aSymbolSetName; + SymbolPtrVec_t aSymbolSet; OutputDevice *pFontListDev; @@ -376,7 +378,7 @@ class SmSymbolDialog : public ModalDialog DECL_LINK(GetClickHdl, Button *); void FillSymbolSets(BOOL bDeleteText = TRUE); - void SetSymbolSetManager(SmSymSetManager &rMgr); + void SetSymbolSetManager(SmSymbolManager &rMgr); const SmSym *GetSymbol() const; void InitColor_Impl(); @@ -384,7 +386,7 @@ class SmSymbolDialog : public ModalDialog public: SmSymbolDialog(Window * pParent, OutputDevice *pFntListDevice, - SmSymSetManager &rSymSetMgr, SmViewShell &rViewShell, BOOL bFreeRes = TRUE); + SmSymbolManager &rSymbolMgr, SmViewShell &rViewShell, BOOL bFreeRes = TRUE); virtual ~SmSymbolDialog(); BOOL SelectSymbolSet(const XubString &rSymbolSetName); @@ -442,8 +444,8 @@ class SmSymDefineDialog : public ModalDialog Image aRigthArrow_Im; Image aRigthArrow_Im_HC; // hi-contrast version - SmSymSetManager aSymSetMgrCopy, - &rSymSetMgr; + SmSymbolManager aSymbolMgrCopy, + &rSymbolMgr; const SmSym *pOrigSymbol; const SubsetMap *pSubsetMap; @@ -465,7 +467,7 @@ class SmSymDefineDialog : public ModalDialog void FillFonts(BOOL bDeleteText = TRUE); void FillStyles(BOOL bDeleteText = TRUE); - void SetSymbolSetManager(const SmSymSetManager &rMgr); + void SetSymbolSetManager(const SmSymbolManager &rMgr); void SetFont(const XubString &rFontName, const XubString &rStyleName); void SetOrigSymbol(const SmSym *pSymbol, const XubString &rSymbolSetName); void UpdateButtons(); @@ -477,18 +479,18 @@ class SmSymDefineDialog : public ModalDialog BOOL SelectFont(const XubString &rFontName, BOOL bApplyFont); BOOL SelectStyle(const XubString &rStyleName, BOOL bApplyFont); - - SmSymSet *GetSymbolSet(const ComboBox &rComboBox); - inline const SmSymSet *GetSymbolSet(const ComboBox &rComboBox) const; - SmSym *GetSymbol(const ComboBox &rComboBox); - inline const SmSym *GetSymbol(const ComboBox &rComboBox) const; + SmSym * GetSymbol(const ComboBox &rComboBox); + const SmSym * GetSymbol(const ComboBox &rComboBox) const + { + return ((SmSymDefineDialog *) this)->GetSymbol(rComboBox); + } void InitColor_Impl(); virtual void DataChanged( const DataChangedEvent& rDCEvt ); public: - SmSymDefineDialog(Window *pParent, OutputDevice *pFntListDevice, SmSymSetManager &rMgr, BOOL bFreeRes = TRUE); + SmSymDefineDialog(Window *pParent, OutputDevice *pFntListDevice, SmSymbolManager &rMgr, BOOL bFreeRes = TRUE); ~SmSymDefineDialog(); using OutputDevice::SetFont; @@ -496,44 +498,31 @@ public: // Dialog virtual short Execute(); - inline BOOL SelectOldSymbolSet(const XubString &rSymbolSetName); - inline BOOL SelectOldSymbol(const XubString &rSymbolName); - inline BOOL SelectSymbolSet(const XubString &rSymbolSetName); - inline BOOL SelectSymbol(const XubString &rSymbolName); - BOOL SelectFont(const XubString &rFontName) { return SelectFont(rFontName, TRUE); } - BOOL SelectStyle(const XubString &rStyleName) { return SelectStyle(rStyleName, TRUE); }; - void SelectChar(xub_Unicode cChar); -}; - -inline const SmSymSet * SmSymDefineDialog::GetSymbolSet(const ComboBox &rComboBox) const -{ - return ((SmSymDefineDialog *) this)->GetSymbolSet(rComboBox); -} + BOOL SmSymDefineDialog::SelectOldSymbolSet(const XubString &rSymbolSetName) + { + return SelectSymbolSet(aOldSymbolSets, rSymbolSetName, FALSE); + } -inline const SmSym * SmSymDefineDialog::GetSymbol(const ComboBox &rComboBox) const -{ - return ((SmSymDefineDialog *) this)->GetSymbol(rComboBox); -} + BOOL SmSymDefineDialog::SelectOldSymbol(const XubString &rSymbolName) + { + return SelectSymbol(aOldSymbols, rSymbolName, FALSE); + } -inline BOOL SmSymDefineDialog::SelectOldSymbolSet(const XubString &rSymbolSetName) -{ - return SelectSymbolSet(aOldSymbolSets, rSymbolSetName, FALSE); -} + BOOL SmSymDefineDialog::SelectSymbolSet(const XubString &rSymbolSetName) + { + return SelectSymbolSet(aSymbolSets, rSymbolSetName, FALSE); + } -inline BOOL SmSymDefineDialog::SelectOldSymbol(const XubString &rSymbolName) -{ - return SelectSymbol(aOldSymbols, rSymbolName, FALSE); -} + BOOL SmSymDefineDialog::SelectSymbol(const XubString &rSymbolName) + { + return SelectSymbol(aSymbols, rSymbolName, FALSE); + } -inline BOOL SmSymDefineDialog::SelectSymbolSet(const XubString &rSymbolSetName) -{ - return SelectSymbolSet(aSymbolSets, rSymbolSetName, FALSE); -} + BOOL SelectFont(const XubString &rFontName) { return SelectFont(rFontName, TRUE); } + BOOL SelectStyle(const XubString &rStyleName) { return SelectStyle(rStyleName, TRUE); }; + void SelectChar(xub_Unicode cChar); +}; -inline BOOL SmSymDefineDialog::SelectSymbol(const XubString &rSymbolName) -{ - return SelectSymbol(aSymbols, rSymbolName, FALSE); -} #endif diff --git a/starmath/inc/smmod.hxx b/starmath/inc/smmod.hxx index 4b493c0cbca7..914c4d46cf0c 100644 --- a/starmath/inc/smmod.hxx +++ b/starmath/inc/smmod.hxx @@ -48,7 +48,7 @@ class SvxErrorHandler; class SfxObjectFactory; class SmConfig; class SmModule; -class SmSymSetManager; +class SmSymbolManager; /************************************************************************* |* @@ -151,7 +151,7 @@ public: svtools::ColorConfig & GetColorConfig(); SmConfig * GetConfig(); - SmSymSetManager & GetSymSetManager(); + SmSymbolManager & GetSymbolManager(); SmLocalizedSymbolData & GetLocSymbolData() const; @@ -178,7 +178,6 @@ public: }; #define SM_MOD() ( *(SmModule**) GetAppData(SHL_SM) ) -#define SM_MOD1() ( *(SmModule**) GetAppData(SHL_SM) ) #endif // _SDMOD_HXX diff --git a/starmath/inc/symbol.hxx b/starmath/inc/symbol.hxx index d39376c30ed0..ce4c0611d368 100644 --- a/starmath/inc/symbol.hxx +++ b/starmath/inc/symbol.hxx @@ -31,198 +31,146 @@ #define SYMBOL_HXX #include <vos/refernce.hxx> -#ifndef _FONT_HXX //autogen #include <vcl/font.hxx> -#endif #include <tools/list.hxx> #include <tools/debug.hxx> #include <tools/dynary.hxx> #include <svtools/lstner.hxx> #include <svtools/svarray.hxx> + +#include <map> +#include <vector> +#include <set> + #include "utility.hxx" -#include <smmod.hxx> +#include "smmod.hxx" -#define SS_ATTR_ACCESS 0x80 #define SYMBOLSET_NONE 0xFFFF #define SYMBOL_NONE 0xFFFF -class SmSymSetManager; //////////////////////////////////////////////////////////////////////////////// inline const String GetExportSymbolName( const String &rUiSymbolName ) { - return SM_MOD1()->GetLocSymbolData().GetExportSymbolName( rUiSymbolName ); + return SM_MOD()->GetLocSymbolData().GetExportSymbolName( rUiSymbolName ); } inline const String GetUiSymbolName( const String &rExportSymbolName ) { - return SM_MOD1()->GetLocSymbolData().GetUiSymbolName( rExportSymbolName ); + return SM_MOD()->GetLocSymbolData().GetUiSymbolName( rExportSymbolName ); } inline const String GetExportSymbolSetName( const String &rUiSymbolSetName ) { - return SM_MOD1()->GetLocSymbolData().GetExportSymbolSetName( rUiSymbolSetName ); + return SM_MOD()->GetLocSymbolData().GetExportSymbolSetName( rUiSymbolSetName ); } inline const String GetUiSymbolSetName( const String &rExportSymbolSetName ) { - return SM_MOD1()->GetLocSymbolData().GetUiSymbolSetName( rExportSymbolSetName ); + return SM_MOD()->GetLocSymbolData().GetUiSymbolSetName( rExportSymbolSetName ); } //////////////////////////////////////////////////////////////////////////////// class SmSym { - friend class SmSymSetManager; - - SmFace Face; - String Name; - String aExportName; - String aSetName; - SmSym *pHashNext; - SmSymSetManager *pSymSetManager; - sal_Unicode Character; - BYTE Attribut; - BOOL bPredefined; - BOOL bDocSymbol; + SmFace m_aFace; + String m_aName; + String m_aExportName; + String m_aSetName; + sal_Unicode m_cChar; + BOOL m_bPredefined; + BOOL m_bDocSymbol; public: SmSym(); - SmSym(const SmSym& rSymbol); SmSym(const String& rName, const Font& rFont, sal_Unicode cChar, const String& rSet, BOOL bIsPredefined = FALSE); + SmSym(const SmSym& rSymbol); SmSym& operator = (const SmSym& rSymbol); - const Font& GetFace() const { return Face; } - sal_Unicode GetCharacter() const { return Character; } - const String& GetName() const { return Name; } + const Font& GetFace() const { return m_aFace; } + sal_Unicode GetCharacter() const { return m_cChar; } + const String& GetName() const { return m_aName; } - void SetFace( const Font& rFont ) { Face = rFont; } - void SetCharacter( sal_Unicode cChar ) { Character = cChar; } - void SetName( const String &rTxt ) { Name = rTxt; } + void SetFace( const Font& rFont ) { m_aFace = rFont; } + void SetCharacter( sal_Unicode cChar ) { m_cChar = cChar; } - BOOL IsPredefined() const { return bPredefined; } - const String & GetSetName() const { return aSetName; } - void SetSetName( const String &rName ) { aSetName = rName; } - const String & GetExportName() const { return aExportName; } - void SetExportName( const String &rName ) { aExportName = rName; } +//! since the symbol name is also used as key in the map it should not be possible to change the name +//! because ten the key would not be the same as its supposed copy here +// void SetName( const String &rTxt ) { m_aName = rTxt; } - BOOL IsDocSymbol() const { return bDocSymbol; } - void SetDocSymbol( BOOL bVal ) { bDocSymbol = bVal; } -}; + BOOL IsPredefined() const { return m_bPredefined; } + const String & GetSymbolSetName() const { return m_aSetName; } + void SetSymbolSetName( const String &rName ) { m_aSetName = rName; } + const String & GetExportName() const { return m_aExportName; } + void SetExportName( const String &rName ) { m_aExportName = rName; } + + BOOL IsDocSymbol() const { return m_bDocSymbol; } + void SetDocSymbol( BOOL bVal ) { m_bDocSymbol = bVal; } -DECLARE_LIST(SmListSym, SmSym *) -SV_DECL_PTRARR( SymbolArray, SmSym *, 32, 32 ) + // true if rSymbol has the same name, font and character + bool IsEqualInUI( const SmSym& rSymbol ) const; +}; /**************************************************************************/ -class SmSymSet +struct lt_String { - friend class SmSymSetManager; - - SmListSym SymbolList; - String Name; - SmSymSetManager *pSymSetManager; - -public: - SmSymSet(); - SmSymSet(const SmSymSet& rSymbolSet); - SmSymSet(const String& rName); - ~SmSymSet(); - - SmSymSet& operator = (const SmSymSet& rSymbolSet); - - const String& GetName() const { return Name; } - USHORT GetCount() const { return (USHORT) SymbolList.Count(); } - - const SmSym& GetSymbol(USHORT SymbolNo) const + bool operator()( const String &r1, const String &r2 ) const { - DBG_ASSERT(SymbolList.GetObject(SymbolNo), "Symbol nicht vorhanden"); - return *SymbolList.GetObject(SymbolNo); + // r1 < r2 ? + return r1.CompareTo( r2 ) == COMPARE_LESS; } - - USHORT AddSymbol(SmSym* pSymbol); - void DeleteSymbol(USHORT SymbolNo); - SmSym * RemoveSymbol(USHORT SymbolNo); - USHORT GetSymbolPos(const String& rName); }; -DECLARE_DYNARRAY(SmArraySymSet, SmSymSet *) - -/**************************************************************************/ - -class SmSymbolDialog; - - -struct SmSymSetManager_Impl -{ - SmArraySymSet SymbolSets; - SmSymSetManager & rSymSetMgr; - SmSym** HashEntries; - USHORT NoSymbolSets; - USHORT NoHashEntries; - BOOL Modified; - - SmSymSetManager_Impl( SmSymSetManager &rMgr, USHORT HashTableSize ); - ~SmSymSetManager_Impl(); - SmSymSetManager_Impl & operator = ( const SmSymSetManager_Impl &rImpl ); -}; +// type of the actual container to hold the symbols +typedef std::map< String, SmSym, lt_String > SymbolMap_t; +// vector of pointers to the actual symbols in the above container +typedef std::vector< const SmSym * > SymbolPtrVec_t; -class SmSymSetManager : public SfxListener +class SmSymbolManager : public SfxListener { - friend struct SmSymSetManager_Impl; - - SmSymSetManager_Impl *pImpl; + SymbolMap_t m_aSymbols; + bool m_bModified; virtual void SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType, const SfxHint& rHint, const TypeId& rHintType); - UINT32 GetHashIndex(const String& rSymbolName); - void EnterHashTable(SmSym& rSymbol); - void EnterHashTable(SmSymSet& rSymbolSet); - void FillHashTable(); void Init(); void Exit(); public: - SmSymSetManager(USHORT HashTableSize = 137); - SmSymSetManager(const SmSymSetManager& rSymbolSetManager); - ~SmSymSetManager(); + SmSymbolManager(); + SmSymbolManager(const SmSymbolManager& rSymbolSetManager); + ~SmSymbolManager(); - SmSymSetManager& operator = (const SmSymSetManager& rSymbolSetManager); + SmSymbolManager & operator = (const SmSymbolManager& rSymbolSetManager); - void GetSymbols( std::vector< SmSym > &rSymbols ) const; + // symbol sets are for UI purpose only, thus we assemble them here + std::set< String > GetSymbolSetNames() const; + const SymbolPtrVec_t GetSymbolSet( const String& rSymbolSetName ); - - USHORT AddSymbolSet(SmSymSet* pSymbolSet); - void ChangeSymbolSet(SmSymSet* pSymbolSet); - void DeleteSymbolSet(USHORT SymbolSetNo); - USHORT GetSymbolSetPos(const String& rSymbolSetName) const; - USHORT GetSymbolSetCount() const { return pImpl->NoSymbolSets; } - SmSymSet *GetSymbolSet(USHORT SymbolSetNo) const - { - return pImpl->SymbolSets.Get(SymbolSetNo); - } + USHORT GetSymbolCount() const { return static_cast< USHORT >(m_aSymbols.size()); } + const SymbolPtrVec_t GetSymbols() const; + bool AddOrReplaceSymbol( const SmSym & rSymbol, bool bForceChange = false ); + void RemoveSymbol( const String & rSymbolName ); SmSym * GetSymbolByName(const String& rSymbolName); const SmSym * GetSymbolByName(const String& rSymbolName) const { - return ((SmSymSetManager *) this)->GetSymbolByName(rSymbolName); + return ((SmSymbolManager *) this)->GetSymbolByName(rSymbolName); } - void AddReplaceSymbol( const SmSym & rSymbol ); - USHORT GetSymbolCount() const; - const SmSym * GetSymbolByPos( USHORT nPos ) const; - - BOOL IsModified() const { return pImpl->Modified; } - void SetModified(BOOL Modify) { pImpl->Modified = Modify; } + bool IsModified() const { return m_bModified; } + void SetModified(bool bModify) { m_bModified = bModify; } void Load(); void Save(); |