bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / unodialogs / textconversiondlgs / chinese_dictionarydialog.hxx
blob50498b4d5d911170dbcf3d2808d155b0c64af83b
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);
64 virtual ~DictionaryList();
65 virtual void dispose() SAL_OVERRIDE;
67 void init(const css::uno::Reference< css::linguistic2::XConversionDictionary>& xDictionary,
68 vcl::Window *pED_Term, vcl::Window *pED_Mapping, ListBox *pLB_Property,
69 vcl::Window *pFT_Term, vcl::Window *pFT_Mapping, vcl::Window *pFT_Property);
71 void deleteAll();
72 void refillFromDictionary( sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
73 void save();
75 DictionaryEntry* getTermEntry( const OUString& rTerm ) const;
76 bool hasTerm( const OUString& rTerm ) const;
78 void addEntry( const OUString& rTerm, const OUString& rMapping
79 , sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/, sal_uIntPtr nPos = TREELIST_APPEND );
80 sal_uIntPtr deleteEntries( const OUString& rTerm ); //return lowest position of deleted entries or LIST_APPEND if no entry was deleted
81 void deleteEntryOnPos( sal_Int32 nPos );
82 DictionaryEntry* getEntryOnPos( sal_Int32 nPos ) const;
83 DictionaryEntry* getFirstSelectedEntry() const;
85 void sortByColumn( sal_uInt16 nSortColumnIndex, bool bSortAtoZ );
86 sal_uInt16 getSortColumn() const { return m_nSortColumnIndex;}
88 private:
89 OUString getPropertyTypeName( sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/ ) const;
90 OUString makeTabString( const DictionaryEntry& rEntry ) const;
92 DECL_LINK( CompareHdl, SvSortData* );
93 sal_Int32 ColumnCompare( SvTreeListEntry* pLeft, SvTreeListEntry* pRight );
94 SvLBoxItem* getItemAtColumn( SvTreeListEntry* pEntry, sal_uInt16 nColumn ) const;
96 void setColSizes();
98 virtual void Resize() SAL_OVERRIDE;
100 public:
101 css::uno::Reference<css::linguistic2::XConversionDictionary> m_xDictionary;
103 private:
104 VclPtr<vcl::Window> m_pED_Term;
105 VclPtr<vcl::Window> m_pED_Mapping;
106 VclPtr<ListBox> m_pLB_Property;
108 std::vector< DictionaryEntry* > m_aToBeDeleted;
110 sal_uInt16 m_nSortColumnIndex;
113 class ChineseDictionaryDialog : public ModalDialog
115 public:
116 ChineseDictionaryDialog( vcl::Window* pParent );
117 virtual ~ChineseDictionaryDialog();
118 virtual void dispose() SAL_OVERRIDE;
120 //this method should be called once before calling execute
121 void setDirectionAndTextConversionOptions( bool bDirectionToSimplified, sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
123 virtual short Execute() SAL_OVERRIDE;
125 private:
126 DECL_LINK( DirectionHdl, void* );
127 DECL_LINK(EditFieldsHdl, void *);
128 DECL_LINK( MappingSelectHdl, void* );
129 DECL_LINK( AddHdl, void* );
130 DECL_LINK( ModifyHdl, void* );
131 DECL_LINK( DeleteHdl, void* );
132 DECL_LINK( HeaderBarClick, HeaderBar* );
134 void initDictionaryControl(DictionaryList *pList,
135 const css::uno::Reference< css::linguistic2::XConversionDictionary>& xDictionary);
137 void updateAfterDirectionChange();
138 void updateButtons();
140 bool isEditFieldsHaveContent() const;
141 bool isEditFieldsContentEqualsSelectedListContent() const;
143 DictionaryList& getActiveDictionary();
144 DictionaryList& getReverseDictionary();
146 const DictionaryList& getActiveDictionary() const;
147 const DictionaryList& getReverseDictionary() const;
149 private:
150 sal_Int32 m_nTextConversionOptions; //i18n::TextConversionOption
152 VclPtr<RadioButton> m_pRB_To_Simplified;
153 VclPtr<RadioButton> m_pRB_To_Traditional;
155 VclPtr<CheckBox> m_pCB_Reverse;
157 VclPtr<FixedText> m_pFT_Term;
158 VclPtr<Edit> m_pED_Term;
160 VclPtr<FixedText> m_pFT_Mapping;
161 VclPtr<Edit> m_pED_Mapping;
163 VclPtr<FixedText> m_pFT_Property;
164 VclPtr<ListBox> m_pLB_Property;
166 VclPtr<SvSimpleTableContainer> mpToSimplifiedContainer;
167 VclPtr<DictionaryList> m_pCT_DictionaryToSimplified;
168 VclPtr<SvSimpleTableContainer> mpToTraditionalContainer;
169 VclPtr<DictionaryList> m_pCT_DictionaryToTraditional;
171 VclPtr<PushButton> m_pPB_Add;
172 VclPtr<PushButton> m_pPB_Modify;
173 VclPtr<PushButton> m_pPB_Delete;
175 css::uno::Reference<css::uno::XComponentContext> m_xContext;
179 } //end namespace
181 #endif
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */