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