update credits
[LibreOffice.git] / cui / source / inc / thesdlg.hxx
bloba3b36dcb0fcffa689d984870a23ea69c71f28820
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 .
19 #ifndef _SVX_THESDLG_HXX
20 #define _SVX_THESDLG_HXX
22 #include <com/sun/star/linguistic2/XThesaurus.hpp>
24 #include <svx/checklbx.hxx>
25 #include <vcl/button.hxx>
26 #include <vcl/combobox.hxx>
27 #include <vcl/lstbox.hxx>
28 #include <svx/stddlg.hxx>
30 #include <memory>
32 class SvxThesaurusDialog;
34 class LookUpComboBox : public ComboBox
36 Timer m_aModifyTimer;
37 Selection m_aSelection;
38 SvxThesaurusDialog* m_pDialog;
40 /// disable copy ctor and assignment operator
41 LookUpComboBox( const LookUpComboBox & );
42 LookUpComboBox& operator = ( const LookUpComboBox & );
44 public:
45 LookUpComboBox(Window *pParent);
46 virtual ~LookUpComboBox();
48 DECL_LINK( ModifyTimer_Hdl, Timer * );
50 void init(SvxThesaurusDialog *pDialog);
52 // ComboBox
53 virtual void Modify();
56 class AlternativesExtraData
58 OUString sText;
59 bool bHeader;
61 public:
62 AlternativesExtraData() : bHeader( false ) {}
63 AlternativesExtraData( const String &rText, bool bIsHeader ) :
64 sText(rText),
65 bHeader(bIsHeader)
69 bool IsHeader() const { return bHeader; }
70 const OUString& GetText() const { return sText; }
73 class ThesaurusAlternativesCtrl
74 : public SvxCheckListBox
76 SvxThesaurusDialog* m_pDialog;
78 typedef std::map< const SvTreeListEntry *, AlternativesExtraData > UserDataMap_t;
79 UserDataMap_t m_aUserData;
81 /// disable copy ctor and assignment operator
82 ThesaurusAlternativesCtrl( const ThesaurusAlternativesCtrl & );
83 ThesaurusAlternativesCtrl & operator = ( const ThesaurusAlternativesCtrl & );
85 public:
86 ThesaurusAlternativesCtrl(Window* pParent);
88 void init(SvxThesaurusDialog *pDialog);
89 virtual ~ThesaurusAlternativesCtrl();
92 SvTreeListEntry * AddEntry( sal_Int32 nVal, const String &rText, bool bIsHeader );
94 void ClearExtraData();
95 void SetExtraData( const SvTreeListEntry *pEntry, const AlternativesExtraData &rData );
96 AlternativesExtraData * GetExtraData( const SvTreeListEntry *pEntry );
98 virtual void KeyInput( const KeyEvent& rKEvt );
99 virtual void Paint( const Rectangle& rRect );
102 class ReplaceEdit : public Edit
104 Button * m_pBtn;
106 /// disable copy ctor and assignment operator
107 ReplaceEdit( const ReplaceEdit & );
108 ReplaceEdit & operator = ( const ReplaceEdit & );
110 public:
111 ReplaceEdit(Window *pParent);
112 virtual ~ReplaceEdit();
114 void init(Button *pBtn) { m_pBtn = pBtn; }
116 // Edit
117 virtual void Modify();
118 virtual void SetText( const OUString& rStr );
119 virtual void SetText( const OUString& rStr, const Selection& rNewSelection );
122 class SvxThesaurusDialog : public SvxStandardDialog
124 PushButton* m_pLeftBtn;
125 LookUpComboBox* m_pWordCB;
126 ThesaurusAlternativesCtrl* m_pAlternativesCT;
127 ReplaceEdit* m_pReplaceEdit;
128 ListBox* m_pLangLB;
130 OUString m_aErrStr;
132 css::uno::Reference< css::linguistic2::XThesaurus > xThesaurus;
133 OUString aLookUpText;
134 LanguageType nLookUpLanguage;
135 std::stack< OUString > aLookUpHistory;
136 bool m_bWordFound;
138 public:
139 bool WordFound() const { return m_bWordFound; }
140 OUString getErrStr() const { return m_aErrStr; }
142 // Handler
143 DECL_LINK( ReplaceBtnHdl_Impl, Button * );
144 DECL_LINK( LeftBtnHdl_Impl, Button * );
145 DECL_LINK( LanguageHdl_Impl, ListBox * );
146 DECL_LINK( LookUpHdl_Impl, Button * );
147 DECL_LINK( WordSelectHdl_Impl, ComboBox * );
148 DECL_LINK( AlternativesSelectHdl_Impl, SvxCheckListBox * );
149 DECL_LINK( AlternativesDoubleClickHdl_Impl, SvxCheckListBox * );
151 DECL_STATIC_LINK( SvxThesaurusDialog, SelectFirstHdl_Impl, SvxCheckListBox * );
153 css::uno::Sequence< css::uno::Reference< css::linguistic2::XMeaning > >
154 queryMeanings_Impl( OUString& rTerm, const css::lang::Locale& rLocale, const css::beans::PropertyValues& rProperties ) throw(css::lang::IllegalArgumentException, css::uno::RuntimeException);
156 bool UpdateAlternativesBox_Impl();
157 void LookUp( const String &rText );
158 void LookUp_Impl();
159 virtual void Apply();
161 public:
162 SvxThesaurusDialog( Window* pParent,
163 css::uno::Reference< css::linguistic2::XThesaurus > xThesaurus,
164 const String &rWord, LanguageType nLanguage );
165 ~SvxThesaurusDialog();
167 void SetWindowTitle( LanguageType nLanguage );
168 String GetWord();
169 sal_uInt16 GetLanguage() const;
172 #endif
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */