1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HXX 29 #define _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HXX 30 31 #include <vcl/dialog.hxx> 32 // header for class FixedLine 33 #include <vcl/fixed.hxx> 34 // header for class RadioButton 35 #ifndef _SV_BUTTON_HXX 36 #include <vcl/button.hxx> 37 #endif 38 // header for class Edit 39 #include <vcl/edit.hxx> 40 // header for class ListBox 41 #include <vcl/lstbox.hxx> 42 // header for class SvHeaderTabListBox 43 #include <svtools/svtabbx.hxx> 44 #include <com/sun/star/uno/XComponentContext.hpp> 45 #include <com/sun/star/lang/XMultiComponentFactory.hpp> 46 #include <com/sun/star/linguistic2/XConversionDictionary.hpp> 47 48 #include <vector> 49 50 //............................................................................. 51 namespace textconversiondlgs 52 { 53 //............................................................................. 54 55 //----------------------------------------------------------------------------- 56 /** 57 */ 58 59 struct DictionaryEntry 60 { 61 DictionaryEntry( const rtl::OUString& rTerm, const rtl::OUString& rMapping 62 , sal_Int16 nConversionPropertyType //linguistic2::ConversionPropertyType 63 , sal_Bool bNewEntry = sal_False ); 64 65 virtual ~DictionaryEntry(); 66 67 bool operator==( const DictionaryEntry& rE ) const; 68 69 rtl::OUString m_aTerm; 70 rtl::OUString m_aMapping; 71 sal_Int16 m_nConversionPropertyType; //linguistic2::ConversionPropertyType 72 73 sal_Bool m_bNewEntry; 74 }; 75 76 class DictionaryList : public SvHeaderTabListBox 77 { 78 public: 79 DictionaryList( Window* pParent, const ResId& ); 80 DictionaryList( Window* pParent ); 81 virtual ~DictionaryList(); 82 83 HeaderBar* createHeaderBar( const String& rColumn1, const String& rColumn2, const String& rColumn3 84 , long nWidth1, long nWidth2, long nWidth3 ); 85 86 void initDictionaryControl( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XConversionDictionary>& xDictionary 87 , ListBox* pPropertyTypeNameListBox ); 88 void activate( HeaderBar* pHeaderBar ); 89 void deleteAll(); 90 void refillFromDictionary( sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ ); 91 void save(); 92 93 DictionaryEntry* getTermEntry( const rtl::OUString& rTerm ) const; 94 bool hasTerm( const rtl::OUString& rTerm ) const; 95 96 void addEntry( const rtl::OUString& rTerm, const rtl::OUString& rMapping 97 , sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/, sal_uIntPtr nPos = LIST_APPEND ); 98 sal_uIntPtr deleteEntries( const rtl::OUString& rTerm ); //return lowest position of deleted entries or LIST_APPEND if no entry was deleted 99 void deleteEntryOnPos( sal_Int32 nPos ); 100 DictionaryEntry* getEntryOnPos( sal_Int32 nPos ) const; 101 DictionaryEntry* getFirstSelectedEntry() const; 102 103 void sortByColumn( sal_uInt16 nSortColumnIndex, bool bSortAtoZ ); 104 sal_uInt16 getSortColumn() const; 105 106 virtual void Resize(); 107 108 private: 109 String getPropertyTypeName( sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/ ) const; 110 String makeTabString( const DictionaryEntry& rEntry ) const; 111 112 DECL_LINK( CompareHdl, SvSortData* ); 113 StringCompare ColumnCompare( SvLBoxEntry* pLeft, SvLBoxEntry* pRight ); 114 SvLBoxItem* getItemAtColumn( SvLBoxEntry* pEntry, sal_uInt16 nColumn ) const; 115 116 public: 117 ::com::sun::star::uno::Reference< 118 ::com::sun::star::linguistic2::XConversionDictionary> m_xDictionary; 119 120 private: 121 HeaderBar* m_pHeaderBar; 122 ListBox* m_pPropertyTypeNameListBox; 123 124 std::vector< DictionaryEntry* > m_aToBeDeleted; 125 126 sal_uInt16 m_nSortColumnIndex; 127 }; 128 129 class ChineseDictionaryDialog : public ModalDialog 130 { 131 public: 132 ChineseDictionaryDialog( Window* pParent ); 133 virtual ~ChineseDictionaryDialog(); 134 135 //this method should be called once before calling execute 136 void setDirectionAndTextConversionOptions( bool bDirectionToSimplified, sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ ); 137 138 virtual short Execute(); 139 140 private: 141 DECL_LINK( DirectionHdl, void* ); 142 DECL_LINK( EditFieldsHdl, Control* ); 143 DECL_LINK( MappingSelectHdl, void* ); 144 DECL_LINK( AddHdl, void* ); 145 DECL_LINK( ModifyHdl, void* ); 146 DECL_LINK( DeleteHdl, void* ); 147 DECL_LINK( HeaderBarClick, void* ); 148 149 void updateAfterDirectionChange(); 150 void updateButtons(); 151 152 bool isEditFieldsHaveContent() const; 153 bool isEditFieldsContentEqualsSelectedListContent() const; 154 155 DictionaryList& getActiveDictionary(); 156 DictionaryList& getReverseDictionary(); 157 158 const DictionaryList& getActiveDictionary() const; 159 const DictionaryList& getReverseDictionary() const; 160 161 private: 162 sal_Int32 m_nTextConversionOptions; //i18n::TextConversionOption 163 164 RadioButton m_aRB_To_Simplified; 165 RadioButton m_aRB_To_Traditional; 166 167 CheckBox m_aCB_Reverse; 168 169 FixedText m_aFT_Term; 170 Edit m_aED_Term; 171 172 FixedText m_aFT_Mapping; 173 Edit m_aED_Mapping; 174 175 FixedText m_aFT_Property; 176 ListBox m_aLB_Property; 177 178 HeaderBar* m_pHeaderBar; 179 DictionaryList m_aCT_DictionaryToSimplified; 180 DictionaryList m_aCT_DictionaryToTraditional; 181 182 PushButton m_aPB_Add; 183 PushButton m_aPB_Modify; 184 PushButton m_aPB_Delete; 185 186 FixedLine m_aFL_Bottomline; 187 188 OKButton m_aBP_OK; 189 CancelButton m_aBP_Cancel; 190 HelpButton m_aBP_Help; 191 192 ::com::sun::star::uno::Reference< 193 ::com::sun::star::uno::XComponentContext > m_xContext; 194 ::com::sun::star::uno::Reference< 195 ::com::sun::star::lang::XMultiComponentFactory> m_xFactory; 196 }; 197 198 //............................................................................. 199 } //end namespace 200 //............................................................................. 201 #endif 202