Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / unodialogs / textconversiondlgs / chinese_dictionarydialog.hxx
blob182c4984ad925a10368eb7e84968fe3a6c4e8a83
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_SOURCE_UNODIALOGS_TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDIALOG_HXX
21 #define INCLUDED_SVX_SOURCE_UNODIALOGS_TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDIALOG_HXX
23 #include <vcl/dialog.hxx>
24 #include <vcl/fixed.hxx>
25 #include <vcl/button.hxx>
26 #include <vcl/edit.hxx>
27 #include <vcl/lstbox.hxx>
28 #include <svtools/simptabl.hxx>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/linguistic2/XConversionDictionary.hpp>
32 #include <vector>
35 namespace textconversiondlgs
40 /**
43 struct DictionaryEntry
45 DictionaryEntry( const OUString& rTerm, const OUString& rMapping
46 , sal_Int16 nConversionPropertyType //linguistic2::ConversionPropertyType
47 , bool bNewEntry = false );
49 virtual ~DictionaryEntry();
51 bool operator==( const DictionaryEntry& rE ) const;
53 OUString m_aTerm;
54 OUString m_aMapping;
55 sal_Int16 m_nConversionPropertyType; //linguistic2::ConversionPropertyType
57 bool m_bNewEntry;
60 class DictionaryList : public SvSimpleTable
62 public:
63 DictionaryList(SvSimpleTableContainer& rParent, WinBits nBits);
65 void init(const css::uno::Reference< css::linguistic2::XConversionDictionary>& xDictionary,
66 Window *pED_Term, Window *pED_Mapping, ListBox *pLB_Property,
67 Window *pFT_Term, Window *pFT_Mapping, Window *pFT_Property);
69 void deleteAll();
70 void refillFromDictionary( sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
71 void save();
73 DictionaryEntry* getTermEntry( const OUString& rTerm ) const;
74 bool hasTerm( const OUString& rTerm ) const;
76 void addEntry( const OUString& rTerm, const OUString& rMapping
77 , sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/, sal_uIntPtr nPos = TREELIST_APPEND );
78 sal_uIntPtr deleteEntries( const OUString& rTerm ); //return lowest position of deleted entries or LIST_APPEND if no entry was deleted
79 void deleteEntryOnPos( sal_Int32 nPos );
80 DictionaryEntry* getEntryOnPos( sal_Int32 nPos ) const;
81 DictionaryEntry* getFirstSelectedEntry() const;
83 void sortByColumn( sal_uInt16 nSortColumnIndex, bool bSortAtoZ );
84 sal_uInt16 getSortColumn() const;
86 private:
87 OUString getPropertyTypeName( sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/ ) const;
88 OUString makeTabString( const DictionaryEntry& rEntry ) const;
90 DECL_LINK( CompareHdl, SvSortData* );
91 sal_Int32 ColumnCompare( SvTreeListEntry* pLeft, SvTreeListEntry* pRight );
92 SvLBoxItem* getItemAtColumn( SvTreeListEntry* pEntry, sal_uInt16 nColumn ) const;
94 void setColSizes();
96 virtual void Resize() SAL_OVERRIDE;
98 public:
99 css::uno::Reference<css::linguistic2::XConversionDictionary> m_xDictionary;
101 private:
102 Window* m_pED_Term;
103 Window* m_pED_Mapping;
104 ListBox* m_pLB_Property;
106 std::vector< DictionaryEntry* > m_aToBeDeleted;
108 sal_uInt16 m_nSortColumnIndex;
111 class ChineseDictionaryDialog : public ModalDialog
113 public:
114 ChineseDictionaryDialog( Window* pParent );
115 virtual ~ChineseDictionaryDialog();
117 //this method should be called once before calling execute
118 void setDirectionAndTextConversionOptions( bool bDirectionToSimplified, sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
120 virtual short Execute() SAL_OVERRIDE;
122 private:
123 DECL_LINK( DirectionHdl, void* );
124 DECL_LINK(EditFieldsHdl, void *);
125 DECL_LINK( MappingSelectHdl, void* );
126 DECL_LINK( AddHdl, void* );
127 DECL_LINK( ModifyHdl, void* );
128 DECL_LINK( DeleteHdl, void* );
129 DECL_LINK( HeaderBarClick, HeaderBar* );
131 void initDictionaryControl(DictionaryList *pList,
132 const css::uno::Reference< css::linguistic2::XConversionDictionary>& xDictionary);
134 void updateAfterDirectionChange();
135 void updateButtons();
137 bool isEditFieldsHaveContent() const;
138 bool isEditFieldsContentEqualsSelectedListContent() const;
140 DictionaryList& getActiveDictionary();
141 DictionaryList& getReverseDictionary();
143 const DictionaryList& getActiveDictionary() const;
144 const DictionaryList& getReverseDictionary() const;
146 private:
147 sal_Int32 m_nTextConversionOptions; //i18n::TextConversionOption
149 RadioButton* m_pRB_To_Simplified;
150 RadioButton* m_pRB_To_Traditional;
152 CheckBox* m_pCB_Reverse;
154 FixedText* m_pFT_Term;
155 Edit* m_pED_Term;
157 FixedText* m_pFT_Mapping;
158 Edit* m_pED_Mapping;
160 FixedText* m_pFT_Property;
161 ListBox* m_pLB_Property;
163 SvSimpleTableContainer* mpToSimplifiedContainer;
164 DictionaryList* m_pCT_DictionaryToSimplified;
165 SvSimpleTableContainer* mpToTraditionalContainer;
166 DictionaryList* m_pCT_DictionaryToTraditional;
168 PushButton* m_pPB_Add;
169 PushButton* m_pPB_Modify;
170 PushButton* m_pPB_Delete;
172 css::uno::Reference<css::uno::XComponentContext> m_xContext;
176 } //end namespace
178 #endif
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */