1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HXX
21 #define _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HXX
23 #include <vcl/dialog.hxx>
24 // header for class FixedLine
25 #include <vcl/fixed.hxx>
26 // header for class RadioButton
27 #include <vcl/button.hxx>
28 // header for class Edit
29 #include <vcl/edit.hxx>
30 // header for class ListBox
31 #include <vcl/lstbox.hxx>
32 // header for class SvHeaderTabListBox
33 #include <svtools/svtabbx.hxx>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <com/sun/star/linguistic2/XConversionDictionary.hpp>
39 //.............................................................................
40 namespace textconversiondlgs
42 //.............................................................................
44 //-----------------------------------------------------------------------------
48 struct DictionaryEntry
50 DictionaryEntry( const OUString
& rTerm
, const OUString
& rMapping
51 , sal_Int16 nConversionPropertyType
//linguistic2::ConversionPropertyType
52 , bool bNewEntry
= false );
54 virtual ~DictionaryEntry();
56 bool operator==( const DictionaryEntry
& rE
) const;
60 sal_Int16 m_nConversionPropertyType
; //linguistic2::ConversionPropertyType
65 class DictionaryList
: public SvHeaderTabListBox
68 DictionaryList( Window
* pParent
, const ResId
& );
69 DictionaryList( Window
* pParent
);
70 virtual ~DictionaryList();
72 HeaderBar
* createHeaderBar( const String
& rColumn1
, const String
& rColumn2
, const String
& rColumn3
73 , long nWidth1
, long nWidth2
, long nWidth3
);
75 void initDictionaryControl( const ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XConversionDictionary
>& xDictionary
76 , ListBox
* pPropertyTypeNameListBox
);
77 void activate( HeaderBar
* pHeaderBar
);
79 void refillFromDictionary( sal_Int32 nTextConversionOptions
/*i18n::TextConversionOption*/ );
82 DictionaryEntry
* getTermEntry( const OUString
& rTerm
) const;
83 bool hasTerm( const OUString
& rTerm
) const;
85 void addEntry( const OUString
& rTerm
, const OUString
& rMapping
86 , sal_Int16 nConversionPropertyType
/*linguistic2::ConversionPropertyType*/, sal_uIntPtr nPos
= LIST_APPEND
);
87 sal_uIntPtr
deleteEntries( const OUString
& rTerm
); //return lowest position of deleted entries or LIST_APPEND if no entry was deleted
88 void deleteEntryOnPos( sal_Int32 nPos
);
89 DictionaryEntry
* getEntryOnPos( sal_Int32 nPos
) const;
90 DictionaryEntry
* getFirstSelectedEntry() const;
92 void sortByColumn( sal_uInt16 nSortColumnIndex
, bool bSortAtoZ
);
93 sal_uInt16
getSortColumn() const;
95 virtual void Resize();
98 String
getPropertyTypeName( sal_Int16 nConversionPropertyType
/*linguistic2::ConversionPropertyType*/ ) const;
99 String
makeTabString( const DictionaryEntry
& rEntry
) const;
101 DECL_LINK( CompareHdl
, SvSortData
* );
102 StringCompare
ColumnCompare( SvTreeListEntry
* pLeft
, SvTreeListEntry
* pRight
);
103 SvLBoxItem
* getItemAtColumn( SvTreeListEntry
* pEntry
, sal_uInt16 nColumn
) const;
106 ::com::sun::star::uno::Reference
<
107 ::com::sun::star::linguistic2::XConversionDictionary
> m_xDictionary
;
110 HeaderBar
* m_pHeaderBar
;
111 ListBox
* m_pPropertyTypeNameListBox
;
113 std::vector
< DictionaryEntry
* > m_aToBeDeleted
;
115 sal_uInt16 m_nSortColumnIndex
;
118 class ChineseDictionaryDialog
: public ModalDialog
121 ChineseDictionaryDialog( Window
* pParent
);
122 virtual ~ChineseDictionaryDialog();
124 //this method should be called once before calling execute
125 void setDirectionAndTextConversionOptions( bool bDirectionToSimplified
, sal_Int32 nTextConversionOptions
/*i18n::TextConversionOption*/ );
127 virtual short Execute();
130 DECL_LINK( DirectionHdl
, void* );
131 DECL_LINK(EditFieldsHdl
, void *);
132 DECL_LINK( MappingSelectHdl
, void* );
133 DECL_LINK( AddHdl
, void* );
134 DECL_LINK( ModifyHdl
, void* );
135 DECL_LINK( DeleteHdl
, void* );
136 DECL_LINK( HeaderBarClick
, void* );
138 void updateAfterDirectionChange();
139 void updateButtons();
141 bool isEditFieldsHaveContent() const;
142 bool isEditFieldsContentEqualsSelectedListContent() const;
144 DictionaryList
& getActiveDictionary();
145 DictionaryList
& getReverseDictionary();
147 const DictionaryList
& getActiveDictionary() const;
148 const DictionaryList
& getReverseDictionary() const;
151 sal_Int32 m_nTextConversionOptions
; //i18n::TextConversionOption
153 RadioButton m_aRB_To_Simplified
;
154 RadioButton m_aRB_To_Traditional
;
156 CheckBox m_aCB_Reverse
;
158 FixedText m_aFT_Term
;
161 FixedText m_aFT_Mapping
;
164 FixedText m_aFT_Property
;
165 ListBox m_aLB_Property
;
167 HeaderBar
* m_pHeaderBar
;
168 DictionaryList m_aCT_DictionaryToSimplified
;
169 DictionaryList m_aCT_DictionaryToTraditional
;
171 PushButton m_aPB_Add
;
172 PushButton m_aPB_Modify
;
173 PushButton m_aPB_Delete
;
175 FixedLine m_aFL_Bottomline
;
178 CancelButton m_aBP_Cancel
;
179 HelpButton m_aBP_Help
;
181 ::com::sun::star::uno::Reference
<
182 ::com::sun::star::uno::XComponentContext
> m_xContext
;
185 //.............................................................................
187 //.............................................................................
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */