bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / inc / thesdlg.hxx
blob4f1ebe01e4eba8efe5ffdb4a0656b2d782320542
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 INCLUDED_CUI_SOURCE_INC_THESDLG_HXX
20 #define INCLUDED_CUI_SOURCE_INC_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 <vcl/idle.hxx>
29 #include <svx/stddlg.hxx>
31 #include <memory>
33 class SvxThesaurusDialog;
35 class LookUpComboBox : public ComboBox
37 Idle m_aModifyIdle;
38 VclPtr<SvxThesaurusDialog> m_pDialog;
40 LookUpComboBox( const LookUpComboBox & ) SAL_DELETED_FUNCTION;
41 LookUpComboBox& operator = ( const LookUpComboBox & ) SAL_DELETED_FUNCTION;
43 public:
44 LookUpComboBox(vcl::Window *pParent);
45 virtual ~LookUpComboBox();
46 virtual void dispose() SAL_OVERRIDE;
48 DECL_LINK_TYPED( ModifyTimer_Hdl, Idle *, void );
50 void init(SvxThesaurusDialog *pDialog);
52 // ComboBox
53 virtual void Modify() SAL_OVERRIDE;
56 class AlternativesExtraData
58 OUString sText;
59 bool bHeader;
61 public:
62 AlternativesExtraData() : bHeader( false ) {}
63 AlternativesExtraData( const OUString &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 VclPtr<SvxThesaurusDialog> m_pDialog;
78 typedef std::map< const SvTreeListEntry *, AlternativesExtraData > UserDataMap_t;
79 UserDataMap_t m_aUserData;
81 ThesaurusAlternativesCtrl( const ThesaurusAlternativesCtrl & ) SAL_DELETED_FUNCTION;
82 ThesaurusAlternativesCtrl & operator = ( const ThesaurusAlternativesCtrl & ) SAL_DELETED_FUNCTION;
84 public:
85 ThesaurusAlternativesCtrl(vcl::Window* pParent);
87 void init(SvxThesaurusDialog *pDialog);
88 virtual ~ThesaurusAlternativesCtrl();
89 virtual void dispose() SAL_OVERRIDE;
91 SvTreeListEntry * AddEntry( sal_Int32 nVal, const OUString &rText, bool bIsHeader );
93 void ClearExtraData();
94 void SetExtraData( const SvTreeListEntry *pEntry, const AlternativesExtraData &rData );
95 AlternativesExtraData * GetExtraData( const SvTreeListEntry *pEntry );
97 virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
98 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
101 class ReplaceEdit : public Edit
103 VclPtr<Button> m_pBtn;
105 ReplaceEdit( const ReplaceEdit & ) SAL_DELETED_FUNCTION;
106 ReplaceEdit & operator = ( const ReplaceEdit & ) SAL_DELETED_FUNCTION;
108 public:
109 ReplaceEdit(vcl::Window *pParent);
110 virtual ~ReplaceEdit();
111 virtual void dispose() SAL_OVERRIDE;
113 void init(Button *pBtn) { m_pBtn = pBtn; }
115 // Edit
116 virtual void Modify() SAL_OVERRIDE;
117 virtual void SetText( const OUString& rStr ) SAL_OVERRIDE;
118 virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) SAL_OVERRIDE;
121 class SvxThesaurusDialog : public SvxStandardDialog
123 VclPtr<PushButton> m_pLeftBtn;
124 VclPtr<LookUpComboBox> m_pWordCB;
125 VclPtr<ThesaurusAlternativesCtrl> m_pAlternativesCT;
126 VclPtr<ReplaceEdit> m_pReplaceEdit;
127 VclPtr<ListBox> m_pLangLB;
129 OUString m_aErrStr;
131 css::uno::Reference< css::linguistic2::XThesaurus > xThesaurus;
132 OUString aLookUpText;
133 LanguageType nLookUpLanguage;
134 std::stack< OUString > aLookUpHistory;
135 bool m_bWordFound;
137 public:
138 virtual ~SvxThesaurusDialog();
139 virtual void dispose() SAL_OVERRIDE;
141 bool WordFound() const { return m_bWordFound; }
142 OUString getErrStr() const { return m_aErrStr; }
144 // Handler
145 DECL_LINK( ReplaceBtnHdl_Impl, Button * );
146 DECL_LINK( LeftBtnHdl_Impl, Button * );
147 DECL_LINK( LanguageHdl_Impl, ListBox * );
148 DECL_LINK( LookUpHdl_Impl, Button * );
149 DECL_LINK( WordSelectHdl_Impl, ComboBox * );
150 DECL_LINK( AlternativesSelectHdl_Impl, SvxCheckListBox * );
151 DECL_LINK( AlternativesDoubleClickHdl_Impl, SvxCheckListBox * );
153 DECL_STATIC_LINK( SvxThesaurusDialog, SelectFirstHdl_Impl, SvxCheckListBox * );
155 css::uno::Sequence< css::uno::Reference< css::linguistic2::XMeaning > >
156 queryMeanings_Impl( OUString& rTerm, const css::lang::Locale& rLocale, const css::beans::PropertyValues& rProperties ) throw(css::lang::IllegalArgumentException, css::uno::RuntimeException);
158 bool UpdateAlternativesBox_Impl();
159 void LookUp( const OUString &rText );
160 void LookUp_Impl();
161 virtual void Apply() SAL_OVERRIDE;
163 public:
164 SvxThesaurusDialog( vcl::Window* pParent,
165 css::uno::Reference< css::linguistic2::XThesaurus > xThesaurus,
166 const OUString &rWord, LanguageType nLanguage );
168 void SetWindowTitle( LanguageType nLanguage );
169 OUString GetWord();
170 sal_uInt16 GetLanguage() const { return nLookUpLanguage;}
173 #endif
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */