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