LibreOffice Module svx (master) 1
chinese_dictionarydialog.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <vcl/weld.hxx>
23#include <com/sun/star/uno/XComponentContext.hpp>
24#include <com/sun/star/linguistic2/XConversionDictionary.hpp>
25
26#include <vector>
27
28namespace textconversiondlgs
29{
30
31struct DictionaryEntry final
32{
33 DictionaryEntry( OUString rTerm, OUString aMapping
34 , sal_Int16 nConversionPropertyType //linguistic2::ConversionPropertyType
35 , bool bNewEntry = false );
36
38
39 OUString m_aTerm;
40 OUString m_aMapping;
41 sal_Int16 m_nConversionPropertyType; //linguistic2::ConversionPropertyType
42
44};
45
47{
48public:
49 DictionaryList(std::unique_ptr<weld::TreeView> xTreeView);
50
51 void init(const css::uno::Reference< css::linguistic2::XConversionDictionary>& xDictionary,
52 weld::Entry *pED_Term, weld::Entry *pED_Mapping, weld::ComboBox *pLB_Property);
53
54 void deleteAll();
55 void refillFromDictionary( sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
56 void save();
57
58 DictionaryEntry* getTermEntry( std::u16string_view rTerm ) const;
59 bool hasTerm( std::u16string_view rTerm ) const;
60
61 void addEntry( const OUString& rTerm, const OUString& rMapping
62 , sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/, int nPos = -1);
63 int deleteEntries( std::u16string_view rTerm ); //return lowest position of deleted entries or -1 if no entry was deleted
64 void deleteEntryOnPos( sal_Int32 nPos );
65 DictionaryEntry* getEntryOnPos( sal_Int32 nPos ) const;
67
68 void set_size_request(int nWidth, int nHeight) { m_xControl->set_size_request(nWidth, nHeight); }
69 void hide() { m_xControl->hide(); }
70 void show() { m_xControl->show(); }
71 void connect_changed(const Link<weld::TreeView&, void>& rLink) { m_xControl->connect_changed(rLink); }
72 void connect_column_clicked(const Link<int, void>& rLink) { m_xControl->connect_column_clicked(rLink); }
73 bool get_sort_order() const { return m_xControl->get_sort_order(); }
74 void set_sort_order(bool bAscending) { return m_xControl->set_sort_order(bAscending); }
75 void set_sort_column(int nColumn) { return m_xControl->set_sort_column(nColumn); }
76 int get_sort_column() const { return m_xControl->get_sort_column(); }
77 int get_selected_index() const { return m_xControl->get_selected_index(); }
78 int get_height_rows(int nRows) const { return m_xControl->get_height_rows(nRows); }
79 bool get_visible() const { return m_xControl->get_visible(); }
80 void set_sort_indicator(TriState eState, int nColumn) { m_xControl->set_sort_indicator(eState, nColumn); }
81 weld::TreeView& get_widget() const { return *m_xControl; }
82
83private:
84 OUString getPropertyTypeName( sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/ ) const;
85
86public:
87 css::uno::Reference<css::linguistic2::XConversionDictionary> m_xDictionary;
88
89private:
90 std::unique_ptr<weld::TreeView> m_xControl;
91 std::unique_ptr<weld::TreeIter> m_xIter;
95
96 std::vector< DictionaryEntry* > m_aToBeDeleted;
97};
98
100{
101public:
102 explicit ChineseDictionaryDialog(weld::Window* pParent);
103 virtual ~ChineseDictionaryDialog() override;
104
105 //this method should be called once before calling execute
106 void setDirectionAndTextConversionOptions( bool bDirectionToSimplified, sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
107
108 virtual short run() override;
109
110private:
111 DECL_LINK( DirectionHdl, weld::Toggleable&, void );
112 DECL_LINK( EditFieldsHdl, weld::Entry&, void );
113 DECL_LINK( EditFieldsListBoxHdl, weld::ComboBox&, void );
114 DECL_LINK( MappingSelectHdl, weld::TreeView&, void );
115 DECL_LINK( AddHdl, weld::Button&, void );
116 DECL_LINK( ModifyHdl, weld::Button&, void );
117 DECL_LINK( DeleteHdl, weld::Button&, void );
118 static void HeaderBarClick(DictionaryList& rList, int nColumn);
119 DECL_LINK(ToSimplifiedHeaderBarClick, int, void);
120 DECL_LINK(ToTraditionalHeaderBarClick, int, void);
121 DECL_LINK(SizeAllocHdl, const Size&, void);
122
124 const css::uno::Reference< css::linguistic2::XConversionDictionary>& xDictionary);
125
127 void updateButtons();
128
129 bool isEditFieldsHaveContent() const;
131
134
135 const DictionaryList& getActiveDictionary() const;
137
138private:
139 sal_Int32 m_nTextConversionOptions; //i18n::TextConversionOption
140
141 css::uno::Reference<css::uno::XComponentContext> m_xContext;
142
143 std::unique_ptr<weld::RadioButton> m_xRB_To_Simplified;
144 std::unique_ptr<weld::RadioButton> m_xRB_To_Traditional;
145
146 std::unique_ptr<weld::CheckButton> m_xCB_Reverse;
147
148 std::unique_ptr<weld::Entry> m_xED_Term;
149
150 std::unique_ptr<weld::Entry> m_xED_Mapping;
151
152 std::unique_ptr<weld::ComboBox> m_xLB_Property;
153
154 std::unique_ptr<DictionaryList> m_xCT_DictionaryToSimplified;
155 std::unique_ptr<DictionaryList> m_xCT_DictionaryToTraditional;
156
157 std::unique_ptr<weld::Button> m_xPB_Add;
158 std::unique_ptr<weld::Button> m_xPB_Modify;
159 std::unique_ptr<weld::Button> m_xPB_Delete;
160};
161
162
163} //end namespace
164
165/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DECL_LINK(SizeAllocHdl, const Size &, void)
DECL_LINK(DeleteHdl, weld::Button &, void)
std::unique_ptr< weld::RadioButton > m_xRB_To_Traditional
DECL_LINK(ModifyHdl, weld::Button &, void)
DECL_LINK(MappingSelectHdl, weld::TreeView &, void)
std::unique_ptr< DictionaryList > m_xCT_DictionaryToSimplified
std::unique_ptr< DictionaryList > m_xCT_DictionaryToTraditional
std::unique_ptr< weld::CheckButton > m_xCB_Reverse
DECL_LINK(ToTraditionalHeaderBarClick, int, void)
DECL_LINK(DirectionHdl, weld::Toggleable &, void)
DECL_LINK(EditFieldsHdl, weld::Entry &, void)
DECL_LINK(AddHdl, weld::Button &, void)
css::uno::Reference< css::uno::XComponentContext > m_xContext
std::unique_ptr< weld::RadioButton > m_xRB_To_Simplified
void initDictionaryControl(DictionaryList *pList, const css::uno::Reference< css::linguistic2::XConversionDictionary > &xDictionary)
void setDirectionAndTextConversionOptions(bool bDirectionToSimplified, sal_Int32 nTextConversionOptions)
DECL_LINK(ToSimplifiedHeaderBarClick, int, void)
DECL_LINK(EditFieldsListBoxHdl, weld::ComboBox &, void)
static void HeaderBarClick(DictionaryList &rList, int nColumn)
void addEntry(const OUString &rTerm, const OUString &rMapping, sal_Int16 nConversionPropertyType, int nPos=-1)
int deleteEntries(std::u16string_view rTerm)
void set_size_request(int nWidth, int nHeight)
DictionaryList(std::unique_ptr< weld::TreeView > xTreeView)
DictionaryEntry * getTermEntry(std::u16string_view rTerm) const
void set_sort_indicator(TriState eState, int nColumn)
void refillFromDictionary(sal_Int32 nTextConversionOptions)
DictionaryEntry * getEntryOnPos(sal_Int32 nPos) const
void init(const css::uno::Reference< css::linguistic2::XConversionDictionary > &xDictionary, weld::Entry *pED_Term, weld::Entry *pED_Mapping, weld::ComboBox *pLB_Property)
OUString getPropertyTypeName(sal_Int16 nConversionPropertyType) const
bool hasTerm(std::u16string_view rTerm) const
void connect_changed(const Link< weld::TreeView &, void > &rLink)
css::uno::Reference< css::linguistic2::XConversionDictionary > m_xDictionary
std::unique_ptr< weld::TreeView > m_xControl
std::vector< DictionaryEntry * > m_aToBeDeleted
void connect_column_clicked(const Link< int, void > &rLink)
std::unique_ptr< weld::TreeIter > m_xIter
TriState
sal_uInt16 nPos
DictionaryEntry(OUString rTerm, OUString aMapping, sal_Int16 nConversionPropertyType, bool bNewEntry=false)