Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / cui / source / inc / thesdlg.hxx
blobc27cf178b69120a82e11d6ee0ae3f9323bd2d7d2
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
23 #include <com/sun/star/linguistic2/XThesaurus.hpp>
25 #include <svx/checklbx.hxx>
26 #include <svx/stddlg.hxx>
27 #include <vcl/button.hxx>
28 #include <vcl/combobox.hxx>
29 #include <vcl/fixed.hxx>
30 #include <vcl/menubtn.hxx>
32 #include <memory>
34 using namespace ::com::sun::star;
36 class SvxThesaurusDialog;
38 class LookUpComboBox : public ComboBox
40 Timer m_aModifyTimer;
41 Selection m_aSelection;
42 SvxThesaurusDialog* m_pDialog;
44 /// disable copy ctor and assignment operator
45 LookUpComboBox( const LookUpComboBox & );
46 LookUpComboBox& operator = ( const LookUpComboBox & );
48 public:
49 LookUpComboBox(Window *pParent);
50 virtual ~LookUpComboBox();
52 DECL_LINK( ModifyTimer_Hdl, Timer * );
54 void init(SvxThesaurusDialog *pDialog);
56 // ComboBox
57 virtual void Modify();
60 class AlternativesExtraData
62 String sText;
63 bool bHeader;
65 public:
66 AlternativesExtraData() : bHeader( false ) {}
67 AlternativesExtraData( const String &rText, bool bIsHeader ) :
68 sText(rText),
69 bHeader(bIsHeader)
73 bool IsHeader() const { return bHeader; }
74 const String& GetText() const { return sText; }
77 class ThesaurusAlternativesCtrl
78 : public SvxCheckListBox
80 SvxThesaurusDialog* m_pDialog;
82 typedef std::map< const SvTreeListEntry *, AlternativesExtraData > UserDataMap_t;
83 UserDataMap_t m_aUserData;
85 /// disable copy ctor and assignment operator
86 ThesaurusAlternativesCtrl( const ThesaurusAlternativesCtrl & );
87 ThesaurusAlternativesCtrl & operator = ( const ThesaurusAlternativesCtrl & );
89 public:
90 ThesaurusAlternativesCtrl(Window* pParent);
92 void init(SvxThesaurusDialog *pDialog);
93 virtual ~ThesaurusAlternativesCtrl();
96 SvTreeListEntry * AddEntry( sal_Int32 nVal, const String &rText, bool bIsHeader );
98 void ClearExtraData();
99 void SetExtraData( const SvTreeListEntry *pEntry, const AlternativesExtraData &rData );
100 AlternativesExtraData * GetExtraData( const SvTreeListEntry *pEntry );
102 virtual void KeyInput( const KeyEvent& rKEvt );
103 virtual void Paint( const Rectangle& rRect );
106 class ReplaceEdit : public Edit
108 Button * m_pBtn;
110 /// disable copy ctor and assignment operator
111 ReplaceEdit( const ReplaceEdit & );
112 ReplaceEdit & operator = ( const ReplaceEdit & );
114 public:
115 ReplaceEdit(Window *pParent);
116 virtual ~ReplaceEdit();
118 void init(Button *pBtn) { m_pBtn = pBtn; }
120 // Edit
121 virtual void Modify();
122 virtual void SetText( const XubString& rStr );
123 virtual void SetText( const XubString& rStr, const Selection& rNewSelection );
126 class SvxThesaurusDialog : public SvxStandardDialog
128 PushButton* m_pLeftBtn;
129 LookUpComboBox* m_pWordCB;
130 ThesaurusAlternativesCtrl* m_pAlternativesCT;
131 ReplaceEdit* m_pReplaceEdit;
132 MenuButton* m_pLangMBtn;
134 OUString m_aErrStr;
136 uno::Reference< linguistic2::XThesaurus > xThesaurus;
137 OUString aLookUpText;
138 LanguageType nLookUpLanguage;
139 std::stack< OUString > aLookUpHistory;
140 bool m_bWordFound;
142 public:
143 bool WordFound() const { return m_bWordFound; }
144 OUString getErrStr() const { return m_aErrStr; }
146 // Handler
147 DECL_LINK( ReplaceBtnHdl_Impl, Button * );
148 DECL_LINK( LeftBtnHdl_Impl, Button * );
149 DECL_LINK( LanguageHdl_Impl, MenuButton * );
150 DECL_LINK( LookUpHdl_Impl, Button * );
151 DECL_LINK( WordSelectHdl_Impl, ComboBox * );
152 DECL_LINK( AlternativesSelectHdl_Impl, SvxCheckListBox * );
153 DECL_LINK( AlternativesDoubleClickHdl_Impl, SvxCheckListBox * );
155 DECL_STATIC_LINK( SvxThesaurusDialog, SelectFirstHdl_Impl, SvxCheckListBox * );
157 uno::Sequence< uno::Reference< linguistic2::XMeaning > >
158 queryMeanings_Impl( ::rtl::OUString& rTerm, const lang::Locale& rLocale, const beans::PropertyValues& rProperties ) throw(lang::IllegalArgumentException, uno::RuntimeException);
160 bool UpdateAlternativesBox_Impl();
161 void LookUp( const String &rText );
162 void LookUp_Impl();
163 virtual void Apply();
165 public:
166 SvxThesaurusDialog( Window* pParent,
167 uno::Reference< linguistic2::XThesaurus > xThesaurus,
168 const String &rWord, LanguageType nLanguage );
169 ~SvxThesaurusDialog();
171 void SetWindowTitle( LanguageType nLanguage );
172 String GetWord();
173 sal_uInt16 GetLanguage() const;
176 #endif
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */