Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SVX_SOURCE_UNODIALOGS_TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDIALOG_HXX
21 : #define INCLUDED_SVX_SOURCE_UNODIALOGS_TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDIALOG_HXX
22 :
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>
31 :
32 : #include <vector>
33 :
34 :
35 : namespace textconversiondlgs
36 : {
37 :
38 :
39 :
40 : /**
41 : */
42 :
43 : struct DictionaryEntry
44 : {
45 : DictionaryEntry( const OUString& rTerm, const OUString& rMapping
46 : , sal_Int16 nConversionPropertyType //linguistic2::ConversionPropertyType
47 : , bool bNewEntry = false );
48 :
49 : virtual ~DictionaryEntry();
50 :
51 : bool operator==( const DictionaryEntry& rE ) const;
52 :
53 : OUString m_aTerm;
54 : OUString m_aMapping;
55 : sal_Int16 m_nConversionPropertyType; //linguistic2::ConversionPropertyType
56 :
57 : bool m_bNewEntry;
58 : };
59 :
60 : class DictionaryList : public SvSimpleTable
61 : {
62 : public:
63 : DictionaryList(SvSimpleTableContainer& rParent, WinBits nBits);
64 : virtual ~DictionaryList();
65 : virtual void dispose() SAL_OVERRIDE;
66 :
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);
70 :
71 : void deleteAll();
72 : void refillFromDictionary( sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
73 : void save();
74 :
75 : DictionaryEntry* getTermEntry( const OUString& rTerm ) const;
76 : bool hasTerm( const OUString& rTerm ) const;
77 :
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;
84 :
85 : void sortByColumn( sal_uInt16 nSortColumnIndex, bool bSortAtoZ );
86 0 : sal_uInt16 getSortColumn() const { return m_nSortColumnIndex;}
87 :
88 : private:
89 : OUString getPropertyTypeName( sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/ ) const;
90 : OUString makeTabString( const DictionaryEntry& rEntry ) const;
91 :
92 : DECL_LINK( CompareHdl, SvSortData* );
93 : sal_Int32 ColumnCompare( SvTreeListEntry* pLeft, SvTreeListEntry* pRight );
94 : SvLBoxItem* getItemAtColumn( SvTreeListEntry* pEntry, sal_uInt16 nColumn ) const;
95 :
96 : void setColSizes();
97 :
98 : virtual void Resize() SAL_OVERRIDE;
99 :
100 : public:
101 : css::uno::Reference<css::linguistic2::XConversionDictionary> m_xDictionary;
102 :
103 : private:
104 : VclPtr<vcl::Window> m_pED_Term;
105 : VclPtr<vcl::Window> m_pED_Mapping;
106 : VclPtr<ListBox> m_pLB_Property;
107 :
108 : std::vector< DictionaryEntry* > m_aToBeDeleted;
109 :
110 : sal_uInt16 m_nSortColumnIndex;
111 : };
112 :
113 : class ChineseDictionaryDialog : public ModalDialog
114 : {
115 : public:
116 : explicit ChineseDictionaryDialog( vcl::Window* pParent );
117 : virtual ~ChineseDictionaryDialog();
118 : virtual void dispose() SAL_OVERRIDE;
119 :
120 : //this method should be called once before calling execute
121 : void setDirectionAndTextConversionOptions( bool bDirectionToSimplified, sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
122 :
123 : virtual short Execute() SAL_OVERRIDE;
124 :
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* );
133 :
134 : void initDictionaryControl(DictionaryList *pList,
135 : const css::uno::Reference< css::linguistic2::XConversionDictionary>& xDictionary);
136 :
137 : void updateAfterDirectionChange();
138 : void updateButtons();
139 :
140 : bool isEditFieldsHaveContent() const;
141 : bool isEditFieldsContentEqualsSelectedListContent() const;
142 :
143 : DictionaryList& getActiveDictionary();
144 : DictionaryList& getReverseDictionary();
145 :
146 : const DictionaryList& getActiveDictionary() const;
147 : const DictionaryList& getReverseDictionary() const;
148 :
149 : private:
150 : sal_Int32 m_nTextConversionOptions; //i18n::TextConversionOption
151 :
152 : VclPtr<RadioButton> m_pRB_To_Simplified;
153 : VclPtr<RadioButton> m_pRB_To_Traditional;
154 :
155 : VclPtr<CheckBox> m_pCB_Reverse;
156 :
157 : VclPtr<FixedText> m_pFT_Term;
158 : VclPtr<Edit> m_pED_Term;
159 :
160 : VclPtr<FixedText> m_pFT_Mapping;
161 : VclPtr<Edit> m_pED_Mapping;
162 :
163 : VclPtr<FixedText> m_pFT_Property;
164 : VclPtr<ListBox> m_pLB_Property;
165 :
166 : VclPtr<SvSimpleTableContainer> mpToSimplifiedContainer;
167 : VclPtr<DictionaryList> m_pCT_DictionaryToSimplified;
168 : VclPtr<SvSimpleTableContainer> mpToTraditionalContainer;
169 : VclPtr<DictionaryList> m_pCT_DictionaryToTraditional;
170 :
171 : VclPtr<PushButton> m_pPB_Add;
172 : VclPtr<PushButton> m_pPB_Modify;
173 : VclPtr<PushButton> m_pPB_Delete;
174 :
175 : css::uno::Reference<css::uno::XComponentContext> m_xContext;
176 : };
177 :
178 :
179 : } //end namespace
180 :
181 : #endif
182 :
183 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|