Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_CUI_SOURCE_INC_THESDLG_HXX
20 : #define INCLUDED_CUI_SOURCE_INC_THESDLG_HXX
21 :
22 : #include <com/sun/star/linguistic2/XThesaurus.hpp>
23 :
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>
30 :
31 : #include <memory>
32 :
33 : class SvxThesaurusDialog;
34 :
35 : class LookUpComboBox : public ComboBox
36 : {
37 : Idle m_aModifyIdle;
38 : VclPtr<SvxThesaurusDialog> m_pDialog;
39 :
40 : LookUpComboBox( const LookUpComboBox & ) SAL_DELETED_FUNCTION;
41 : LookUpComboBox& operator = ( const LookUpComboBox & ) SAL_DELETED_FUNCTION;
42 :
43 : public:
44 : LookUpComboBox(vcl::Window *pParent);
45 : virtual ~LookUpComboBox();
46 : virtual void dispose() SAL_OVERRIDE;
47 :
48 : DECL_LINK_TYPED( ModifyTimer_Hdl, Idle *, void );
49 :
50 : void init(SvxThesaurusDialog *pDialog);
51 :
52 : // ComboBox
53 : virtual void Modify() SAL_OVERRIDE;
54 : };
55 :
56 0 : class AlternativesExtraData
57 : {
58 : OUString sText;
59 : bool bHeader;
60 :
61 : public:
62 0 : AlternativesExtraData() : bHeader( false ) {}
63 0 : AlternativesExtraData( const OUString &rText, bool bIsHeader ) :
64 : sText(rText),
65 0 : bHeader(bIsHeader)
66 : {
67 0 : }
68 :
69 0 : bool IsHeader() const { return bHeader; }
70 0 : const OUString& GetText() const { return sText; }
71 : };
72 :
73 : class ThesaurusAlternativesCtrl
74 : : public SvxCheckListBox
75 : {
76 : VclPtr<SvxThesaurusDialog> m_pDialog;
77 :
78 : typedef std::map< const SvTreeListEntry *, AlternativesExtraData > UserDataMap_t;
79 : UserDataMap_t m_aUserData;
80 :
81 : ThesaurusAlternativesCtrl( const ThesaurusAlternativesCtrl & ) SAL_DELETED_FUNCTION;
82 : ThesaurusAlternativesCtrl & operator = ( const ThesaurusAlternativesCtrl & ) SAL_DELETED_FUNCTION;
83 :
84 : public:
85 : ThesaurusAlternativesCtrl(vcl::Window* pParent);
86 :
87 : void init(SvxThesaurusDialog *pDialog);
88 : virtual ~ThesaurusAlternativesCtrl();
89 : virtual void dispose() SAL_OVERRIDE;
90 :
91 : SvTreeListEntry * AddEntry( sal_Int32 nVal, const OUString &rText, bool bIsHeader );
92 :
93 : void ClearExtraData();
94 : void SetExtraData( const SvTreeListEntry *pEntry, const AlternativesExtraData &rData );
95 : AlternativesExtraData * GetExtraData( const SvTreeListEntry *pEntry );
96 :
97 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
98 : virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
99 : };
100 :
101 : class ReplaceEdit : public Edit
102 : {
103 : VclPtr<Button> m_pBtn;
104 :
105 : ReplaceEdit( const ReplaceEdit & ) SAL_DELETED_FUNCTION;
106 : ReplaceEdit & operator = ( const ReplaceEdit & ) SAL_DELETED_FUNCTION;
107 :
108 : public:
109 : ReplaceEdit(vcl::Window *pParent);
110 : virtual ~ReplaceEdit();
111 : virtual void dispose() SAL_OVERRIDE;
112 :
113 0 : void init(Button *pBtn) { m_pBtn = pBtn; }
114 :
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;
119 : };
120 :
121 : class SvxThesaurusDialog : public SvxStandardDialog
122 : {
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;
128 :
129 : OUString m_aErrStr;
130 :
131 : css::uno::Reference< css::linguistic2::XThesaurus > xThesaurus;
132 : OUString aLookUpText;
133 : LanguageType nLookUpLanguage;
134 : std::stack< OUString > aLookUpHistory;
135 : bool m_bWordFound;
136 :
137 : public:
138 : virtual ~SvxThesaurusDialog();
139 : virtual void dispose() SAL_OVERRIDE;
140 :
141 0 : bool WordFound() const { return m_bWordFound; }
142 0 : OUString getErrStr() const { return m_aErrStr; }
143 :
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 * );
152 :
153 : DECL_STATIC_LINK( SvxThesaurusDialog, SelectFirstHdl_Impl, SvxCheckListBox * );
154 :
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);
157 :
158 : bool UpdateAlternativesBox_Impl();
159 : void LookUp( const OUString &rText );
160 : void LookUp_Impl();
161 : virtual void Apply() SAL_OVERRIDE;
162 :
163 : public:
164 : SvxThesaurusDialog( vcl::Window* pParent,
165 : css::uno::Reference< css::linguistic2::XThesaurus > xThesaurus,
166 : const OUString &rWord, LanguageType nLanguage );
167 :
168 : void SetWindowTitle( LanguageType nLanguage );
169 : OUString GetWord();
170 0 : sal_uInt16 GetLanguage() const { return nLookUpLanguage;}
171 : };
172 :
173 : #endif
174 :
175 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|