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 28*cdf0e10cSrcweir #ifndef _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HXX 29*cdf0e10cSrcweir #define _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <vcl/dialog.hxx> 32*cdf0e10cSrcweir // header for class FixedLine 33*cdf0e10cSrcweir #include <vcl/fixed.hxx> 34*cdf0e10cSrcweir // header for class RadioButton 35*cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX 36*cdf0e10cSrcweir #include <vcl/button.hxx> 37*cdf0e10cSrcweir #endif 38*cdf0e10cSrcweir // header for class Edit 39*cdf0e10cSrcweir #include <vcl/edit.hxx> 40*cdf0e10cSrcweir // header for class ListBox 41*cdf0e10cSrcweir #include <vcl/lstbox.hxx> 42*cdf0e10cSrcweir // header for class SvHeaderTabListBox 43*cdf0e10cSrcweir #include <svtools/svtabbx.hxx> 44*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XConversionDictionary.hpp> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include <vector> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir //............................................................................. 51*cdf0e10cSrcweir namespace textconversiondlgs 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir //............................................................................. 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir //----------------------------------------------------------------------------- 56*cdf0e10cSrcweir /** 57*cdf0e10cSrcweir */ 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir struct DictionaryEntry 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir DictionaryEntry( const rtl::OUString& rTerm, const rtl::OUString& rMapping 62*cdf0e10cSrcweir , sal_Int16 nConversionPropertyType //linguistic2::ConversionPropertyType 63*cdf0e10cSrcweir , sal_Bool bNewEntry = sal_False ); 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir virtual ~DictionaryEntry(); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir bool operator==( const DictionaryEntry& rE ) const; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir rtl::OUString m_aTerm; 70*cdf0e10cSrcweir rtl::OUString m_aMapping; 71*cdf0e10cSrcweir sal_Int16 m_nConversionPropertyType; //linguistic2::ConversionPropertyType 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir sal_Bool m_bNewEntry; 74*cdf0e10cSrcweir }; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir class DictionaryList : public SvHeaderTabListBox 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir public: 79*cdf0e10cSrcweir DictionaryList( Window* pParent, const ResId& ); 80*cdf0e10cSrcweir DictionaryList( Window* pParent ); 81*cdf0e10cSrcweir virtual ~DictionaryList(); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir HeaderBar* createHeaderBar( const String& rColumn1, const String& rColumn2, const String& rColumn3 84*cdf0e10cSrcweir , long nWidth1, long nWidth2, long nWidth3 ); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir void initDictionaryControl( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XConversionDictionary>& xDictionary 87*cdf0e10cSrcweir , ListBox* pPropertyTypeNameListBox ); 88*cdf0e10cSrcweir void activate( HeaderBar* pHeaderBar ); 89*cdf0e10cSrcweir void deleteAll(); 90*cdf0e10cSrcweir void refillFromDictionary( sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ ); 91*cdf0e10cSrcweir void save(); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir DictionaryEntry* getTermEntry( const rtl::OUString& rTerm ) const; 94*cdf0e10cSrcweir bool hasTerm( const rtl::OUString& rTerm ) const; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir void addEntry( const rtl::OUString& rTerm, const rtl::OUString& rMapping 97*cdf0e10cSrcweir , sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/, sal_uIntPtr nPos = LIST_APPEND ); 98*cdf0e10cSrcweir sal_uIntPtr deleteEntries( const rtl::OUString& rTerm ); //return lowest position of deleted entries or LIST_APPEND if no entry was deleted 99*cdf0e10cSrcweir void deleteEntryOnPos( sal_Int32 nPos ); 100*cdf0e10cSrcweir DictionaryEntry* getEntryOnPos( sal_Int32 nPos ) const; 101*cdf0e10cSrcweir DictionaryEntry* getFirstSelectedEntry() const; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir void sortByColumn( sal_uInt16 nSortColumnIndex, bool bSortAtoZ ); 104*cdf0e10cSrcweir sal_uInt16 getSortColumn() const; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir virtual void Resize(); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir private: 109*cdf0e10cSrcweir String getPropertyTypeName( sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/ ) const; 110*cdf0e10cSrcweir String makeTabString( const DictionaryEntry& rEntry ) const; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir DECL_LINK( CompareHdl, SvSortData* ); 113*cdf0e10cSrcweir StringCompare ColumnCompare( SvLBoxEntry* pLeft, SvLBoxEntry* pRight ); 114*cdf0e10cSrcweir SvLBoxItem* getItemAtColumn( SvLBoxEntry* pEntry, sal_uInt16 nColumn ) const; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir public: 117*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 118*cdf0e10cSrcweir ::com::sun::star::linguistic2::XConversionDictionary> m_xDictionary; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir private: 121*cdf0e10cSrcweir HeaderBar* m_pHeaderBar; 122*cdf0e10cSrcweir ListBox* m_pPropertyTypeNameListBox; 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir std::vector< DictionaryEntry* > m_aToBeDeleted; 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir sal_uInt16 m_nSortColumnIndex; 127*cdf0e10cSrcweir }; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir class ChineseDictionaryDialog : public ModalDialog 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir public: 132*cdf0e10cSrcweir ChineseDictionaryDialog( Window* pParent ); 133*cdf0e10cSrcweir virtual ~ChineseDictionaryDialog(); 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir //this method should be called once before calling execute 136*cdf0e10cSrcweir void setDirectionAndTextConversionOptions( bool bDirectionToSimplified, sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ ); 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir virtual short Execute(); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir private: 141*cdf0e10cSrcweir DECL_LINK( DirectionHdl, void* ); 142*cdf0e10cSrcweir DECL_LINK( EditFieldsHdl, Control* ); 143*cdf0e10cSrcweir DECL_LINK( MappingSelectHdl, void* ); 144*cdf0e10cSrcweir DECL_LINK( AddHdl, void* ); 145*cdf0e10cSrcweir DECL_LINK( ModifyHdl, void* ); 146*cdf0e10cSrcweir DECL_LINK( DeleteHdl, void* ); 147*cdf0e10cSrcweir DECL_LINK( HeaderBarClick, void* ); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir void updateAfterDirectionChange(); 150*cdf0e10cSrcweir void updateButtons(); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir bool isEditFieldsHaveContent() const; 153*cdf0e10cSrcweir bool isEditFieldsContentEqualsSelectedListContent() const; 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir DictionaryList& getActiveDictionary(); 156*cdf0e10cSrcweir DictionaryList& getReverseDictionary(); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir const DictionaryList& getActiveDictionary() const; 159*cdf0e10cSrcweir const DictionaryList& getReverseDictionary() const; 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir private: 162*cdf0e10cSrcweir sal_Int32 m_nTextConversionOptions; //i18n::TextConversionOption 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir RadioButton m_aRB_To_Simplified; 165*cdf0e10cSrcweir RadioButton m_aRB_To_Traditional; 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir CheckBox m_aCB_Reverse; 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir FixedText m_aFT_Term; 170*cdf0e10cSrcweir Edit m_aED_Term; 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir FixedText m_aFT_Mapping; 173*cdf0e10cSrcweir Edit m_aED_Mapping; 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir FixedText m_aFT_Property; 176*cdf0e10cSrcweir ListBox m_aLB_Property; 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir HeaderBar* m_pHeaderBar; 179*cdf0e10cSrcweir DictionaryList m_aCT_DictionaryToSimplified; 180*cdf0e10cSrcweir DictionaryList m_aCT_DictionaryToTraditional; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir PushButton m_aPB_Add; 183*cdf0e10cSrcweir PushButton m_aPB_Modify; 184*cdf0e10cSrcweir PushButton m_aPB_Delete; 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir FixedLine m_aFL_Bottomline; 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir OKButton m_aBP_OK; 189*cdf0e10cSrcweir CancelButton m_aBP_Cancel; 190*cdf0e10cSrcweir HelpButton m_aBP_Help; 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 193*cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext > m_xContext; 194*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 195*cdf0e10cSrcweir ::com::sun::star::lang::XMultiComponentFactory> m_xFactory; 196*cdf0e10cSrcweir }; 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir //............................................................................. 199*cdf0e10cSrcweir } //end namespace 200*cdf0e10cSrcweir //............................................................................. 201*cdf0e10cSrcweir #endif 202