Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2008 by Sun Microsystems, Inc.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVX_THESDLG_IMPL_HXX
30 : : #define _SVX_THESDLG_IMPL_HXX
31 : :
32 : : #include "thesdlg.hxx"
33 : :
34 : : #include <svtools/ehdl.hxx>
35 : : #include <svx/checklbx.hxx>
36 : : #include <vcl/button.hxx>
37 : : #include <vcl/combobox.hxx>
38 : : #include <vcl/edit.hxx>
39 : : #include <vcl/fixed.hxx>
40 : : #include <vcl/image.hxx>
41 : : #include <vcl/lstbox.hxx>
42 : : #include <vcl/menubtn.hxx>
43 : : #include <vcl/msgbox.hxx>
44 : : #include <vcl/svapp.hxx>
45 : : #include <vcl/timer.hxx>
46 : : #include <vcl/wrkwin.hxx>
47 : :
48 : : #include <com/sun/star/linguistic2/XThesaurus.hpp>
49 : : #include <com/sun/star/linguistic2/XMeaning.hpp>
50 : :
51 : : #include <stack>
52 : : #include <map>
53 : : #include <algorithm>
54 : :
55 : : using namespace ::com::sun::star;
56 : : using ::rtl::OUString;
57 : :
58 : : class SvLBoxEntry;
59 : : class ThesaurusAlternativesCtrl_Impl;
60 : :
61 : :
62 : : // class LookUpComboBox_Impl --------------------------------------------------
63 : :
64 : : class LookUpComboBox_Impl : public ComboBox
65 : : {
66 : : Timer m_aModifyTimer;
67 : : Selection m_aSelection;
68 : : Button * m_pBtn;
69 : : SvxThesaurusDialog_Impl & m_rDialogImpl;
70 : :
71 : : /// disable copy ctor and assignment operator
72 : : LookUpComboBox_Impl( const LookUpComboBox_Impl & );
73 : : LookUpComboBox_Impl & operator = ( const LookUpComboBox_Impl & );
74 : :
75 : : public:
76 : : LookUpComboBox_Impl( Window *pParent, const ResId &rResId, SvxThesaurusDialog_Impl &rImpl );
77 : : virtual ~LookUpComboBox_Impl();
78 : :
79 : : DECL_LINK( ModifyTimer_Hdl, Timer * );
80 : :
81 : : void SetButton( Button *pBtn ) { m_pBtn = pBtn; }
82 : :
83 : : // ComboBox
84 : : virtual void Modify();
85 : : };
86 : :
87 : : // class ReplaceEdit_Impl --------------------------------------------------
88 : :
89 : : class ReplaceEdit_Impl : public Edit
90 : : {
91 : : Button * m_pBtn;
92 : :
93 : : /// disable copy ctor and assignment operator
94 : : ReplaceEdit_Impl( const ReplaceEdit_Impl & );
95 : : ReplaceEdit_Impl & operator = ( const ReplaceEdit_Impl & );
96 : :
97 : : public:
98 : : ReplaceEdit_Impl( Window *pParent, const ResId &rResId );
99 : : virtual ~ReplaceEdit_Impl();
100 : :
101 : 0 : void SetButton( Button *pBtn ) { m_pBtn = pBtn; }
102 : :
103 : : // Edit
104 : : virtual void Modify();
105 : : virtual void SetText( const XubString& rStr );
106 : : virtual void SetText( const XubString& rStr, const Selection& rNewSelection );
107 : : };
108 : :
109 : : // class ThesaurusAlternativesCtrl_Impl ----------------------------------
110 : :
111 : 0 : class AlternativesExtraData
112 : : {
113 : : String sText;
114 : : bool bHeader;
115 : :
116 : : public:
117 : 0 : AlternativesExtraData() : bHeader( false ) {}
118 : 0 : AlternativesExtraData( const String &rText, bool bIsHeader ) :
119 : : sText(rText),
120 : 0 : bHeader(bIsHeader)
121 : : {
122 : 0 : }
123 : :
124 : 0 : bool IsHeader() const { return bHeader; }
125 : 0 : const String& GetText() const { return sText; }
126 : : };
127 : :
128 : :
129 [ # # ]: 0 : class AlternativesString_Impl : public SvLBoxString
130 : : {
131 : : ThesaurusAlternativesCtrl_Impl & m_rControlImpl;
132 : : public:
133 : :
134 : : AlternativesString_Impl( ThesaurusAlternativesCtrl_Impl &rControl,
135 : : SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& rStr );
136 : :
137 : : virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry);
138 : : };
139 : :
140 : :
141 : : class ThesaurusAlternativesCtrl_Impl :
142 : : public SvxCheckListBox
143 : : {
144 : : SvxThesaurusDialog_Impl & m_rDialogImpl;
145 : :
146 : : typedef std::map< const SvLBoxEntry *, AlternativesExtraData > UserDataMap_t;
147 : : UserDataMap_t m_aUserData;
148 : :
149 : : /// disable copy ctor and assignment operator
150 : : ThesaurusAlternativesCtrl_Impl( const ThesaurusAlternativesCtrl_Impl & );
151 : : ThesaurusAlternativesCtrl_Impl & operator = ( const ThesaurusAlternativesCtrl_Impl & );
152 : :
153 : : public:
154 : : ThesaurusAlternativesCtrl_Impl( Window* pParent, SvxThesaurusDialog_Impl &rImpl );
155 : : virtual ~ThesaurusAlternativesCtrl_Impl();
156 : :
157 : :
158 : : SvLBoxEntry * AddEntry( sal_Int32 nVal, const String &rText, bool bIsHeader );
159 : :
160 : : void ClearExtraData();
161 : : void SetExtraData( const SvLBoxEntry *pEntry, const AlternativesExtraData &rData );
162 : : AlternativesExtraData * GetExtraData( const SvLBoxEntry *pEntry );
163 : :
164 : : virtual void KeyInput( const KeyEvent& rKEvt );
165 : : virtual void Paint( const Rectangle& rRect );
166 : : };
167 : :
168 : :
169 : : // struct SvxThesaurusDialog_Impl ----------------------------------------
170 : :
171 : : struct SvxThesaurusDialog_Impl
172 : : {
173 : : SvxThesaurusDialog * m_pDialog;
174 : :
175 : : FixedImage aVendorImageFI;
176 : : ImageButton aLeftBtn;
177 : : FixedText aWordText;
178 : : LookUpComboBox_Impl aWordCB;
179 : : FixedText m_aAlternativesText;
180 : : boost::shared_ptr< ThesaurusAlternativesCtrl_Impl > m_pAlternativesCT;
181 : : FixedText aReplaceText;
182 : : ReplaceEdit_Impl aReplaceEdit;
183 : : FixedLine aFL;
184 : : HelpButton aHelpBtn;
185 : : MenuButton aLangMBtn;
186 : : OKButton aReplaceBtn;
187 : : CancelButton aCancelBtn;
188 : :
189 : : String aErrStr;
190 : : Image aVendorDefaultImage;
191 : :
192 : : uno::Reference< linguistic2::XThesaurus > xThesaurus;
193 : : OUString aLookUpText;
194 : : LanguageType nLookUpLanguage;
195 : : std::stack< OUString > aLookUpHistory;
196 : : bool m_bWordFound;
197 : :
198 : :
199 : : // Handler
200 : : DECL_LINK( LeftBtnHdl_Impl, Button * );
201 : : DECL_LINK( LanguageHdl_Impl, MenuButton * );
202 : : DECL_LINK( LookUpHdl_Impl, Button * );
203 : : DECL_LINK( WordSelectHdl_Impl, ComboBox * );
204 : : DECL_LINK( AlternativesSelectHdl_Impl, SvxCheckListBox * );
205 : : DECL_LINK( AlternativesDoubleClickHdl_Impl, SvxCheckListBox * );
206 : :
207 : : DECL_STATIC_LINK( SvxThesaurusDialog_Impl, SelectFirstHdl_Impl, SvxCheckListBox * );
208 : : DECL_STATIC_LINK( SvxThesaurusDialog_Impl, VendorImageInitHdl, SvxThesaurusDialog_Impl * );
209 : :
210 : :
211 : : SvxThesaurusDialog_Impl( SvxThesaurusDialog * pDialog );
212 : : ~SvxThesaurusDialog_Impl();
213 : :
214 : : uno::Sequence< uno::Reference< linguistic2::XMeaning > > SAL_CALL
215 : : queryMeanings_Impl( ::rtl::OUString& rTerm, const lang::Locale& rLocale, const beans::PropertyValues& rProperties ) throw(lang::IllegalArgumentException, uno::RuntimeException);
216 : :
217 : : bool UpdateAlternativesBox_Impl();
218 : : void UpdateVendorImage();
219 : : void LookUp( const String &rText );
220 : : void LookUp_Impl();
221 : : };
222 : :
223 : : #endif
224 : :
225 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|