1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SVX_THESDLG_IMPL_HXX 25 #define _SVX_THESDLG_IMPL_HXX 26 27 #include "thesdlg.hxx" 28 29 #include <svtools/ehdl.hxx> 30 #include <svx/checklbx.hxx> 31 #include <vcl/button.hxx> 32 #include <vcl/combobox.hxx> 33 #include <vcl/edit.hxx> 34 #include <vcl/fixed.hxx> 35 #include <vcl/image.hxx> 36 #include <vcl/lstbox.hxx> 37 #include <vcl/menubtn.hxx> 38 #include <vcl/msgbox.hxx> 39 #include <vcl/svapp.hxx> 40 #include <vcl/timer.hxx> 41 #include <vcl/wrkwin.hxx> 42 43 #include <com/sun/star/linguistic2/XThesaurus.hpp> 44 #include <com/sun/star/linguistic2/XMeaning.hpp> 45 46 #include <stack> 47 #include <map> 48 #include <algorithm> 49 50 using namespace ::com::sun::star; 51 using ::rtl::OUString; 52 53 class SvLBoxEntry; 54 class ThesaurusAlternativesCtrl_Impl; 55 56 57 // class LookUpComboBox_Impl -------------------------------------------------- 58 59 class LookUpComboBox_Impl : public ComboBox 60 { 61 Timer m_aModifyTimer; 62 Selection m_aSelection; 63 Button * m_pBtn; 64 SvxThesaurusDialog_Impl & m_rDialogImpl; 65 66 // disable copy c-tor and assignment operator 67 LookUpComboBox_Impl( const LookUpComboBox_Impl & ); 68 LookUpComboBox_Impl & operator = ( const LookUpComboBox_Impl & ); 69 70 public: 71 LookUpComboBox_Impl( Window *pParent, const ResId &rResId, SvxThesaurusDialog_Impl &rImpl ); 72 virtual ~LookUpComboBox_Impl(); 73 74 DECL_LINK( ModifyTimer_Hdl, Timer * ); 75 76 void SetButton( Button *pBtn ) { m_pBtn = pBtn; } 77 78 // ComboBox 79 virtual void Modify(); 80 }; 81 82 // class ReplaceEdit_Impl -------------------------------------------------- 83 84 class ReplaceEdit_Impl : public Edit 85 { 86 Button * m_pBtn; 87 88 // disable copy c-tor and assignment operator 89 ReplaceEdit_Impl( const ReplaceEdit_Impl & ); 90 ReplaceEdit_Impl & operator = ( const ReplaceEdit_Impl & ); 91 92 public: 93 ReplaceEdit_Impl( Window *pParent, const ResId &rResId ); 94 virtual ~ReplaceEdit_Impl(); 95 96 void SetButton( Button *pBtn ) { m_pBtn = pBtn; } 97 98 // Edit 99 virtual void Modify(); 100 virtual void SetText( const XubString& rStr ); 101 virtual void SetText( const XubString& rStr, const Selection& rNewSelection ); 102 }; 103 104 // class ThesaurusAlternativesCtrl_Impl ---------------------------------- 105 106 class AlternativesExtraData 107 { 108 String sText; 109 bool bHeader; 110 111 public: 112 AlternativesExtraData() : bHeader( false ) {} 113 AlternativesExtraData( const String &rText, bool bIsHeader ) : 114 sText(rText), 115 bHeader(bIsHeader) 116 { 117 } 118 119 bool IsHeader() const { return bHeader; } 120 const String& GetText() const { return sText; } 121 }; 122 123 124 class AlternativesString_Impl : public SvLBoxString 125 { 126 ThesaurusAlternativesCtrl_Impl & m_rControlImpl; 127 public: 128 129 AlternativesString_Impl( ThesaurusAlternativesCtrl_Impl &rControl, 130 SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& rStr ); 131 132 virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry); 133 }; 134 135 136 class ThesaurusAlternativesCtrl_Impl : 137 public SvxCheckListBox 138 { 139 SvxThesaurusDialog_Impl & m_rDialogImpl; 140 141 typedef std::map< const SvLBoxEntry *, AlternativesExtraData > UserDataMap_t; 142 UserDataMap_t m_aUserData; 143 144 // disable copy c-tor and assignment operator 145 ThesaurusAlternativesCtrl_Impl( const ThesaurusAlternativesCtrl_Impl & ); 146 ThesaurusAlternativesCtrl_Impl & operator = ( const ThesaurusAlternativesCtrl_Impl & ); 147 148 public: 149 ThesaurusAlternativesCtrl_Impl( Window* pParent, SvxThesaurusDialog_Impl &rImpl ); 150 virtual ~ThesaurusAlternativesCtrl_Impl(); 151 152 153 SvLBoxEntry * AddEntry( sal_Int32 nVal, const String &rText, bool bIsHeader ); 154 155 void ClearExtraData(); 156 void SetExtraData( const SvLBoxEntry *pEntry, const AlternativesExtraData &rData ); 157 AlternativesExtraData * GetExtraData( const SvLBoxEntry *pEntry ); 158 159 virtual void KeyInput( const KeyEvent& rKEvt ); 160 virtual void Paint( const Rectangle& rRect ); 161 }; 162 163 164 // struct SvxThesaurusDialog_Impl ---------------------------------------- 165 166 struct SvxThesaurusDialog_Impl 167 { 168 SvxThesaurusDialog * m_pDialog; 169 170 FixedImage aVendorImageFI; 171 ImageButton aLeftBtn; 172 FixedText aWordText; 173 LookUpComboBox_Impl aWordCB; 174 FixedText m_aAlternativesText; 175 boost::shared_ptr< ThesaurusAlternativesCtrl_Impl > m_pAlternativesCT; 176 FixedText aReplaceText; 177 ReplaceEdit_Impl aReplaceEdit; 178 FixedLine aFL; 179 HelpButton aHelpBtn; 180 MenuButton aLangMBtn; 181 OKButton aReplaceBtn; 182 CancelButton aCancelBtn; 183 184 String aErrStr; 185 Image aVendorDefaultImage; 186 Image aVendorDefaultImageHC; 187 188 uno::Reference< linguistic2::XThesaurus > xThesaurus; 189 OUString aLookUpText; 190 LanguageType nLookUpLanguage; 191 std::stack< OUString > aLookUpHistory; 192 bool m_bWordFound; 193 194 195 // Handler 196 DECL_LINK( LeftBtnHdl_Impl, Button * ); 197 DECL_LINK( LanguageHdl_Impl, MenuButton * ); 198 DECL_LINK( LookUpHdl_Impl, Button * ); 199 DECL_LINK( WordSelectHdl_Impl, ComboBox * ); 200 DECL_LINK( AlternativesSelectHdl_Impl, SvxCheckListBox * ); 201 DECL_LINK( AlternativesDoubleClickHdl_Impl, SvxCheckListBox * ); 202 203 DECL_STATIC_LINK( SvxThesaurusDialog_Impl, SelectFirstHdl_Impl, SvxCheckListBox * ); 204 DECL_STATIC_LINK( SvxThesaurusDialog_Impl, VendorImageInitHdl, SvxThesaurusDialog_Impl * ); 205 206 207 SvxThesaurusDialog_Impl( SvxThesaurusDialog * pDialog ); 208 ~SvxThesaurusDialog_Impl(); 209 210 uno::Sequence< uno::Reference< linguistic2::XMeaning > > SAL_CALL 211 queryMeanings_Impl( ::rtl::OUString& rTerm, const lang::Locale& rLocale, const beans::PropertyValues& rProperties ) throw(lang::IllegalArgumentException, uno::RuntimeException); 212 213 bool UpdateAlternativesBox_Impl(); 214 void UpdateVendorImage(); 215 void LookUp( const String &rText ); 216 void LookUp_Impl(); 217 }; 218 219 #endif 220 221