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 .
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>
32 class SvxThesaurusDialog
;
34 class LookUpComboBox
: public ComboBox
37 Selection m_aSelection
;
38 SvxThesaurusDialog
* m_pDialog
;
40 /// disable copy ctor and assignment operator
41 LookUpComboBox( const LookUpComboBox
& );
42 LookUpComboBox
& operator = ( const LookUpComboBox
& );
45 LookUpComboBox(Window
*pParent
);
46 virtual ~LookUpComboBox();
48 DECL_LINK( ModifyTimer_Hdl
, Timer
* );
50 void init(SvxThesaurusDialog
*pDialog
);
53 virtual void Modify();
56 class AlternativesExtraData
62 AlternativesExtraData() : bHeader( false ) {}
63 AlternativesExtraData( const String
&rText
, bool 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
& );
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
106 /// disable copy ctor and assignment operator
107 ReplaceEdit( const ReplaceEdit
& );
108 ReplaceEdit
& operator = ( const ReplaceEdit
& );
111 ReplaceEdit(Window
*pParent
);
112 virtual ~ReplaceEdit();
114 void init(Button
*pBtn
) { m_pBtn
= pBtn
; }
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
;
132 css::uno::Reference
< css::linguistic2::XThesaurus
> xThesaurus
;
133 OUString aLookUpText
;
134 LanguageType nLookUpLanguage
;
135 std::stack
< OUString
> aLookUpHistory
;
139 bool WordFound() const { return m_bWordFound
; }
140 OUString
getErrStr() const { return m_aErrStr
; }
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
);
159 virtual void Apply();
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
);
169 sal_uInt16
GetLanguage() const;
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */