1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #ifndef SVX_HANGUL_HANJA_DLG_HXX 28*cdf0e10cSrcweir #define SVX_HANGUL_HANJA_DLG_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <vcl/dialog.hxx> 31*cdf0e10cSrcweir #include <vcl/button.hxx> 32*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 33*cdf0e10cSrcweir #include <vcl/combobox.hxx> 34*cdf0e10cSrcweir #include <vcl/fixed.hxx> 35*cdf0e10cSrcweir #include <vcl/scrbar.hxx> 36*cdf0e10cSrcweir #include <svx/checklbx.hxx> 37*cdf0e10cSrcweir #include <editeng/hangulhanja.hxx> 38*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 39*cdf0e10cSrcweir #include <editeng/unolingu.hxx> 40*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XConversionDictionaryList.hpp> 41*cdf0e10cSrcweir #include <svtools/valueset.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <vector> 44*cdf0e10cSrcweir #include <memory> // for auto_ptr 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir class SvxCommonLinguisticControl; 47*cdf0e10cSrcweir //............................................................................. 48*cdf0e10cSrcweir namespace svx 49*cdf0e10cSrcweir { 50*cdf0e10cSrcweir //............................................................................. 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir //========================================================================= 53*cdf0e10cSrcweir //= HangulHanjaConversionDialog 54*cdf0e10cSrcweir //========================================================================= 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir class SuggestionSet : public ValueSet 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir public: 59*cdf0e10cSrcweir SuggestionSet( Window* pParent ); 60*cdf0e10cSrcweir virtual ~SuggestionSet(); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir virtual void UserDraw( const UserDrawEvent& rUDEvt ); 63*cdf0e10cSrcweir void ClearSet(); 64*cdf0e10cSrcweir }; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir class SuggestionDisplay : public Control 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir public: 69*cdf0e10cSrcweir SuggestionDisplay( Window* pParent, const ResId& rResId ); 70*cdf0e10cSrcweir virtual ~SuggestionDisplay(); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir void DisplayListBox( bool bDisplayListBox ); 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir void SetSelectHdl( const Link& rLink ); 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir void Clear(); 77*cdf0e10cSrcweir void InsertEntry( const XubString& rStr ); 78*cdf0e10cSrcweir void SelectEntryPos( sal_uInt16 nPos ); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir sal_uInt16 GetEntryCount() const; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir XubString GetEntry( sal_uInt16 nPos ) const; 83*cdf0e10cSrcweir XubString GetSelectEntry() const; 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir virtual void StateChanged( StateChangedType nStateChange ); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir virtual void KeyInput( const KeyEvent& rKEvt ); 88*cdf0e10cSrcweir virtual void KeyUp( const KeyEvent& rKEvt ); 89*cdf0e10cSrcweir virtual void Activate(); 90*cdf0e10cSrcweir virtual void Deactivate(); 91*cdf0e10cSrcweir virtual void GetFocus(); 92*cdf0e10cSrcweir virtual void LoseFocus(); 93*cdf0e10cSrcweir virtual void Command( const CommandEvent& rCEvt ); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir DECL_LINK( SelectSuggestionHdl, Control* ); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir void SetHelpIds(); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir private: 100*cdf0e10cSrcweir void implUpdateDisplay(); 101*cdf0e10cSrcweir Control& implGetCurrentControl(); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir private: 104*cdf0e10cSrcweir bool m_bDisplayListBox;//otherwise ValueSet 105*cdf0e10cSrcweir SuggestionSet m_aValueSet; 106*cdf0e10cSrcweir ListBox m_aListBox; 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir Link m_aSelectLink; 109*cdf0e10cSrcweir bool m_bInSelectionUpdate; 110*cdf0e10cSrcweir }; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir class HangulHanjaConversionDialog : public ModalDialog 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir private: 115*cdf0e10cSrcweir ::std::auto_ptr< SvxCommonLinguisticControl > 116*cdf0e10cSrcweir m_pPlayground; // order matters: before all other controls! 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir PushButton m_aFind; 119*cdf0e10cSrcweir SuggestionDisplay m_aSuggestions; 120*cdf0e10cSrcweir FixedText m_aFormat; 121*cdf0e10cSrcweir RadioButton m_aSimpleConversion; 122*cdf0e10cSrcweir RadioButton m_aHangulBracketed; 123*cdf0e10cSrcweir RadioButton m_aHanjaBracketed; 124*cdf0e10cSrcweir ::std::auto_ptr< RadioButton > m_pHanjaAbove; 125*cdf0e10cSrcweir ::std::auto_ptr< RadioButton > m_pHanjaBelow; 126*cdf0e10cSrcweir ::std::auto_ptr< RadioButton > m_pHangulAbove; 127*cdf0e10cSrcweir ::std::auto_ptr< RadioButton > m_pHangulBelow; 128*cdf0e10cSrcweir FixedText m_aConversion; 129*cdf0e10cSrcweir CheckBox m_aHangulOnly; 130*cdf0e10cSrcweir CheckBox m_aHanjaOnly; 131*cdf0e10cSrcweir CheckBox m_aReplaceByChar; 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir CheckBox* m_pIgnoreNonPrimary; 134*cdf0e10cSrcweir bool m_bDocumentMode; 135*cdf0e10cSrcweir // are we working for a document? This is normally true, but in case 136*cdf0e10cSrcweir // the user uses the "find" functionality, we switch to working 137*cdf0e10cSrcweir // with what the user entered, which then does not have any relation to 138*cdf0e10cSrcweir // the document anymore. Some functionality must be disabled then 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir Link m_aOptionsChangedLink; 141*cdf0e10cSrcweir Link m_aClickByCharacterLink; 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir public: 144*cdf0e10cSrcweir HangulHanjaConversionDialog( 145*cdf0e10cSrcweir Window* _pParent, 146*cdf0e10cSrcweir editeng::HangulHanjaConversion::ConversionDirection _ePrimaryDirection ); 147*cdf0e10cSrcweir ~HangulHanjaConversionDialog( ); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir public: 150*cdf0e10cSrcweir void SetOptionsChangedHdl( const Link& _rHdl ); 151*cdf0e10cSrcweir void SetIgnoreHdl( const Link& _rHdl ); 152*cdf0e10cSrcweir void SetIgnoreAllHdl( const Link& _rHdl ); 153*cdf0e10cSrcweir void SetChangeHdl( const Link& _rHdl ); 154*cdf0e10cSrcweir void SetChangeAllHdl( const Link& _rHdl ); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir void SetClickByCharacterHdl( const Link& _rHdl ); 157*cdf0e10cSrcweir void SetConversionFormatChangedHdl( const Link& _rHdl ); 158*cdf0e10cSrcweir void SetFindHdl( const Link& _rHdl ); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir String GetCurrentString( ) const; 161*cdf0e10cSrcweir void SetCurrentString( 162*cdf0e10cSrcweir const String& _rNewString, 163*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rSuggestions, 164*cdf0e10cSrcweir bool _bOriginatesFromDocument = true 165*cdf0e10cSrcweir ); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir void FocusSuggestion( ); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir // retrieves the current suggestion 170*cdf0e10cSrcweir String GetCurrentSuggestion( ) const; 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir void SetConversionFormat( editeng::HangulHanjaConversion::ConversionFormat _eType ); 173*cdf0e10cSrcweir editeng::HangulHanjaConversion::ConversionFormat GetConversionFormat( ) const; 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir void SetByCharacter( sal_Bool _bByCharacter ); 176*cdf0e10cSrcweir void SetConversionDirectionState( sal_Bool _bTryBothDirections, editeng::HangulHanjaConversion::ConversionDirection _ePrimaryConversionDirection ); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir // should text which does not match the primary conversion direction be ignored? 179*cdf0e10cSrcweir sal_Bool GetUseBothDirections( ) const; 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir // get current conversion direction to use 182*cdf0e10cSrcweir // (return argument if GetUseBothDirections is true) 183*cdf0e10cSrcweir editeng::HangulHanjaConversion::ConversionDirection GetDirection( editeng::HangulHanjaConversion::ConversionDirection eDefaultDirection ) const; 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir // enables or disbales the checkboxes for ruby formatted replacements 186*cdf0e10cSrcweir void EnableRubySupport( sal_Bool bVal ); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir private: 189*cdf0e10cSrcweir DECL_LINK( OnClose, void* ); 190*cdf0e10cSrcweir DECL_LINK( OnOption, void* ); 191*cdf0e10cSrcweir DECL_LINK( OnSuggestionModified, void* ); 192*cdf0e10cSrcweir DECL_LINK( OnSuggestionSelected, void* ); 193*cdf0e10cSrcweir DECL_LINK( OnConversionDirectionClicked, CheckBox* ); 194*cdf0e10cSrcweir DECL_LINK( ClickByCharacterHdl, CheckBox* ); 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir // fill the suggestion list box with suggestions for the actual input 197*cdf0e10cSrcweir void FillSuggestions( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rSuggestions ); 198*cdf0e10cSrcweir }; 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XConversionDictionary > > HHDictList; 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir class HangulHanjaOptionsDialog : public ModalDialog 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir private: 206*cdf0e10cSrcweir FixedText m_aUserdefdictFT; 207*cdf0e10cSrcweir SvxCheckListBox m_aDictsLB; 208*cdf0e10cSrcweir FixedLine m_aOptionsFL; 209*cdf0e10cSrcweir CheckBox m_aIgnorepostCB; 210*cdf0e10cSrcweir CheckBox m_aShowrecentlyfirstCB; 211*cdf0e10cSrcweir CheckBox m_aAutoreplaceuniqueCB; 212*cdf0e10cSrcweir PushButton m_aNewPB; 213*cdf0e10cSrcweir PushButton m_aEditPB; 214*cdf0e10cSrcweir PushButton m_aDeletePB; 215*cdf0e10cSrcweir OKButton m_aOkPB; 216*cdf0e10cSrcweir CancelButton m_aCancelPB; 217*cdf0e10cSrcweir HelpButton m_aHelpPB; 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir SvLBoxButtonData* m_pCheckButtonData; 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir HHDictList m_aDictList; 222*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XConversionDictionaryList > m_xConversionDictionaryList; 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir DECL_LINK( OkHdl, void* ); 225*cdf0e10cSrcweir DECL_LINK( OnNew, void* ); 226*cdf0e10cSrcweir DECL_LINK( OnEdit, void* ); 227*cdf0e10cSrcweir DECL_LINK( OnDelete, void* ); 228*cdf0e10cSrcweir DECL_LINK( DictsLB_SelectHdl, void* ); 229*cdf0e10cSrcweir DECL_LINK( NewDictHdl, void* ); 230*cdf0e10cSrcweir DECL_LINK( EditDictHdl, void* ); 231*cdf0e10cSrcweir DECL_LINK( DeleteDictHdl, void* ); 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir void Init( void ); // reads settings from core and init controls 234*cdf0e10cSrcweir public: 235*cdf0e10cSrcweir HangulHanjaOptionsDialog( Window* _pParent ); 236*cdf0e10cSrcweir virtual ~HangulHanjaOptionsDialog(); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir void AddDict( const String& _rName, bool _bChecked ); 239*cdf0e10cSrcweir }; 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir class HangulHanjaNewDictDialog : public ModalDialog 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir private: 245*cdf0e10cSrcweir FixedLine m_aNewDictFL; 246*cdf0e10cSrcweir FixedText m_aDictNameFT; 247*cdf0e10cSrcweir Edit m_aDictNameED; 248*cdf0e10cSrcweir OKButton m_aOkBtn; 249*cdf0e10cSrcweir CancelButton m_aCancelBtn; 250*cdf0e10cSrcweir HelpButton m_aHelpBtn; 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir bool m_bEntered; 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir DECL_LINK( OKHdl, void* ); 255*cdf0e10cSrcweir DECL_LINK( ModifyHdl, void* ); 256*cdf0e10cSrcweir protected: 257*cdf0e10cSrcweir public: 258*cdf0e10cSrcweir HangulHanjaNewDictDialog( Window* _pParent ); 259*cdf0e10cSrcweir virtual ~HangulHanjaNewDictDialog(); 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir bool GetName( String& _rRetName ) const; 262*cdf0e10cSrcweir }; 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir class SuggestionList; 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir class SuggestionEdit : public Edit 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir private: 270*cdf0e10cSrcweir SuggestionEdit* m_pPrev; 271*cdf0e10cSrcweir SuggestionEdit* m_pNext; 272*cdf0e10cSrcweir ScrollBar& m_rScrollBar; 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir bool ShouldScroll( bool _bUp ) const; 275*cdf0e10cSrcweir void DoJump( bool _bUp ); 276*cdf0e10cSrcweir public: 277*cdf0e10cSrcweir SuggestionEdit( Window* pParent, const ResId& rResId, 278*cdf0e10cSrcweir ScrollBar& _rScrollBar, 279*cdf0e10cSrcweir SuggestionEdit* _pPrev, SuggestionEdit* _pNext ); 280*cdf0e10cSrcweir virtual ~SuggestionEdit(); 281*cdf0e10cSrcweir virtual long PreNotify( NotifyEvent& rNEvt ); 282*cdf0e10cSrcweir }; 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir class HangulHanjaEditDictDialog : public ModalDialog 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir private: 288*cdf0e10cSrcweir const String m_aEditHintText; 289*cdf0e10cSrcweir HHDictList& m_rDictList; 290*cdf0e10cSrcweir sal_uInt32 m_nCurrentDict; 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir String m_aOriginal; 293*cdf0e10cSrcweir SuggestionList* m_pSuggestions; 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir FixedText m_aBookFT; 296*cdf0e10cSrcweir ListBox m_aBookLB; 297*cdf0e10cSrcweir FixedText m_aOriginalFT; 298*cdf0e10cSrcweir ComboBox m_aOriginalLB; 299*cdf0e10cSrcweir FixedText m_aSuggestionsFT; 300*cdf0e10cSrcweir SuggestionEdit m_aEdit1; 301*cdf0e10cSrcweir SuggestionEdit m_aEdit2; 302*cdf0e10cSrcweir SuggestionEdit m_aEdit3; 303*cdf0e10cSrcweir SuggestionEdit m_aEdit4; 304*cdf0e10cSrcweir ScrollBar m_aScrollSB; 305*cdf0e10cSrcweir PushButton m_aNewPB; 306*cdf0e10cSrcweir PushButton m_aDeletePB; 307*cdf0e10cSrcweir HelpButton m_aHelpPB; 308*cdf0e10cSrcweir CancelButton m_aClosePB; 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir sal_uInt16 m_nTopPos; 311*cdf0e10cSrcweir bool m_bModifiedSuggestions; 312*cdf0e10cSrcweir bool m_bModifiedOriginal; 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir DECL_LINK( OriginalModifyHdl, void* ); 315*cdf0e10cSrcweir DECL_LINK( ScrollHdl, void* ); 316*cdf0e10cSrcweir DECL_LINK( EditModifyHdl1, Edit* ); 317*cdf0e10cSrcweir DECL_LINK( EditModifyHdl2, Edit* ); 318*cdf0e10cSrcweir DECL_LINK( EditModifyHdl3, Edit* ); 319*cdf0e10cSrcweir DECL_LINK( EditModifyHdl4, Edit* ); 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir DECL_LINK( BookLBSelectHdl, void* ); 322*cdf0e10cSrcweir DECL_LINK( NewPBPushHdl, void* ); 323*cdf0e10cSrcweir DECL_LINK( DeletePBPushHdl, void* ); 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir void InitEditDictDialog( sal_uInt32 _nSelDict ); 326*cdf0e10cSrcweir void UpdateOriginalLB( void ); 327*cdf0e10cSrcweir void UpdateSuggestions( void ); 328*cdf0e10cSrcweir void UpdateButtonStates(); 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir void SetEditText( Edit& _rEdit, sal_uInt16 _nEntryNum ); 331*cdf0e10cSrcweir void EditModify( Edit* _pEdit, sal_uInt8 _nEntryOffset ); 332*cdf0e10cSrcweir void EditFocusLost( Edit* _pEdit, sal_uInt8 _nEntryOffset ); 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir bool DeleteEntryFromDictionary( const ::rtl::OUString& rEntry, const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XConversionDictionary >& xDict ); 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir public: 337*cdf0e10cSrcweir HangulHanjaEditDictDialog( Window* _pParent, HHDictList& _rDictList, sal_uInt32 _nSelDict ); 338*cdf0e10cSrcweir ~HangulHanjaEditDictDialog(); 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir void UpdateScrollbar( void ); 341*cdf0e10cSrcweir }; 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir //............................................................................. 344*cdf0e10cSrcweir } // namespace svx 345*cdf0e10cSrcweir //............................................................................. 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir #endif // SVX_HANGUL_HANJA_HXX 348