tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / svx / source / unodialogs / textconversiondlgs / chinese_dictionarydialog.hxx
blob87aae3dc45436b6c4c3372f13296439ce40b7652
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 #pragma once
22 #include <vcl/weld.hxx>
23 #include <com/sun/star/uno/XComponentContext.hpp>
24 #include <com/sun/star/linguistic2/XConversionDictionary.hpp>
26 #include <vector>
28 namespace textconversiondlgs
31 struct DictionaryEntry final
33 DictionaryEntry( OUString rTerm, OUString aMapping
34 , sal_Int16 nConversionPropertyType //linguistic2::ConversionPropertyType
35 , bool bNewEntry = false );
37 ~DictionaryEntry();
39 OUString m_aTerm;
40 OUString m_aMapping;
41 sal_Int16 m_nConversionPropertyType; //linguistic2::ConversionPropertyType
43 bool m_bNewEntry;
46 class DictionaryList
48 public:
49 DictionaryList(std::unique_ptr<weld::TreeView> xTreeView);
51 void init(const css::uno::Reference< css::linguistic2::XConversionDictionary>& xDictionary,
52 weld::Entry *pED_Term, weld::Entry *pED_Mapping, weld::ComboBox *pLB_Property);
54 void deleteAll();
55 void refillFromDictionary( sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
56 void save();
58 DictionaryEntry* getTermEntry( std::u16string_view rTerm ) const;
59 bool hasTerm( std::u16string_view rTerm ) const;
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;
66 DictionaryEntry* getFirstSelectedEntry() const;
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)
73 m_xControl->connect_selection_changed(rLink);
75 void connect_column_clicked(const Link<int, void>& rLink) { m_xControl->connect_column_clicked(rLink); }
76 bool get_sort_order() const { return m_xControl->get_sort_order(); }
77 void set_sort_order(bool bAscending) { return m_xControl->set_sort_order(bAscending); }
78 void set_sort_column(int nColumn) { return m_xControl->set_sort_column(nColumn); }
79 int get_sort_column() const { return m_xControl->get_sort_column(); }
80 int get_selected_index() const { return m_xControl->get_selected_index(); }
81 int get_height_rows(int nRows) const { return m_xControl->get_height_rows(nRows); }
82 bool get_visible() const { return m_xControl->get_visible(); }
83 void set_sort_indicator(TriState eState, int nColumn) { m_xControl->set_sort_indicator(eState, nColumn); }
84 weld::TreeView& get_widget() const { return *m_xControl; }
86 private:
87 OUString getPropertyTypeName( sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/ ) const;
89 public:
90 css::uno::Reference<css::linguistic2::XConversionDictionary> m_xDictionary;
92 private:
93 std::unique_ptr<weld::TreeView> m_xControl;
94 std::unique_ptr<weld::TreeIter> m_xIter;
95 weld::Entry* m_pED_Term;
96 weld::Entry* m_pED_Mapping;
97 weld::ComboBox* m_pLB_Property;
99 std::vector< DictionaryEntry* > m_aToBeDeleted;
102 class ChineseDictionaryDialog : public weld::GenericDialogController
104 public:
105 explicit ChineseDictionaryDialog(weld::Window* pParent);
106 virtual ~ChineseDictionaryDialog() override;
108 //this method should be called once before calling execute
109 void setDirectionAndTextConversionOptions( bool bDirectionToSimplified, sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
111 virtual short run() override;
113 private:
114 DECL_LINK( DirectionHdl, weld::Toggleable&, void );
115 DECL_LINK( EditFieldsHdl, weld::Entry&, void );
116 DECL_LINK( EditFieldsListBoxHdl, weld::ComboBox&, void );
117 DECL_LINK( MappingSelectHdl, weld::TreeView&, void );
118 DECL_LINK( AddHdl, weld::Button&, void );
119 DECL_LINK( ModifyHdl, weld::Button&, void );
120 DECL_LINK( DeleteHdl, weld::Button&, void );
121 static void HeaderBarClick(DictionaryList& rList, int nColumn);
122 DECL_LINK(ToSimplifiedHeaderBarClick, int, void);
123 DECL_LINK(ToTraditionalHeaderBarClick, int, void);
124 DECL_LINK(SizeAllocHdl, const Size&, void);
126 void initDictionaryControl(DictionaryList *pList,
127 const css::uno::Reference< css::linguistic2::XConversionDictionary>& xDictionary);
129 void updateAfterDirectionChange();
130 void updateButtons();
132 bool isEditFieldsHaveContent() const;
133 bool isEditFieldsContentEqualsSelectedListContent() const;
135 DictionaryList& getActiveDictionary();
136 DictionaryList& getReverseDictionary();
138 const DictionaryList& getActiveDictionary() const;
139 const DictionaryList& getReverseDictionary() const;
141 private:
142 sal_Int32 m_nTextConversionOptions; //i18n::TextConversionOption
144 css::uno::Reference<css::uno::XComponentContext> m_xContext;
146 std::unique_ptr<weld::RadioButton> m_xRB_To_Simplified;
147 std::unique_ptr<weld::RadioButton> m_xRB_To_Traditional;
149 std::unique_ptr<weld::CheckButton> m_xCB_Reverse;
151 std::unique_ptr<weld::Entry> m_xED_Term;
153 std::unique_ptr<weld::Entry> m_xED_Mapping;
155 std::unique_ptr<weld::ComboBox> m_xLB_Property;
157 std::unique_ptr<DictionaryList> m_xCT_DictionaryToSimplified;
158 std::unique_ptr<DictionaryList> m_xCT_DictionaryToTraditional;
160 std::unique_ptr<weld::Button> m_xPB_Add;
161 std::unique_ptr<weld::Button> m_xPB_Modify;
162 std::unique_ptr<weld::Button> m_xPB_Delete;
166 } //end namespace
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */