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