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