1*3334a7e6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*3334a7e6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*3334a7e6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*3334a7e6SAndrew Rist * distributed with this work for additional information 6*3334a7e6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*3334a7e6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*3334a7e6SAndrew Rist * "License"); you may not use this file except in compliance 9*3334a7e6SAndrew Rist * with the License. You may obtain a copy of the License at 10*3334a7e6SAndrew Rist * 11*3334a7e6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*3334a7e6SAndrew Rist * 13*3334a7e6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*3334a7e6SAndrew Rist * software distributed under the License is distributed on an 15*3334a7e6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*3334a7e6SAndrew Rist * KIND, either express or implied. See the License for the 17*3334a7e6SAndrew Rist * specific language governing permissions and limitations 18*3334a7e6SAndrew Rist * under the License. 19*3334a7e6SAndrew Rist * 20*3334a7e6SAndrew Rist *************************************************************/ 21*3334a7e6SAndrew Rist 22*3334a7e6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HXX 25cdf0e10cSrcweir #define _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vcl/dialog.hxx> 28cdf0e10cSrcweir // header for class FixedLine 29cdf0e10cSrcweir #include <vcl/fixed.hxx> 30cdf0e10cSrcweir // header for class RadioButton 31cdf0e10cSrcweir #ifndef _SV_BUTTON_HXX 32cdf0e10cSrcweir #include <vcl/button.hxx> 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir // header for class Edit 35cdf0e10cSrcweir #include <vcl/edit.hxx> 36cdf0e10cSrcweir // header for class ListBox 37cdf0e10cSrcweir #include <vcl/lstbox.hxx> 38cdf0e10cSrcweir // header for class SvHeaderTabListBox 39cdf0e10cSrcweir #include <svtools/svtabbx.hxx> 40cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 41cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp> 42cdf0e10cSrcweir #include <com/sun/star/linguistic2/XConversionDictionary.hpp> 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include <vector> 45cdf0e10cSrcweir 46cdf0e10cSrcweir //............................................................................. 47cdf0e10cSrcweir namespace textconversiondlgs 48cdf0e10cSrcweir { 49cdf0e10cSrcweir //............................................................................. 50cdf0e10cSrcweir 51cdf0e10cSrcweir //----------------------------------------------------------------------------- 52cdf0e10cSrcweir /** 53cdf0e10cSrcweir */ 54cdf0e10cSrcweir 55cdf0e10cSrcweir struct DictionaryEntry 56cdf0e10cSrcweir { 57cdf0e10cSrcweir DictionaryEntry( const rtl::OUString& rTerm, const rtl::OUString& rMapping 58cdf0e10cSrcweir , sal_Int16 nConversionPropertyType //linguistic2::ConversionPropertyType 59cdf0e10cSrcweir , sal_Bool bNewEntry = sal_False ); 60cdf0e10cSrcweir 61cdf0e10cSrcweir virtual ~DictionaryEntry(); 62cdf0e10cSrcweir 63cdf0e10cSrcweir bool operator==( const DictionaryEntry& rE ) const; 64cdf0e10cSrcweir 65cdf0e10cSrcweir rtl::OUString m_aTerm; 66cdf0e10cSrcweir rtl::OUString m_aMapping; 67cdf0e10cSrcweir sal_Int16 m_nConversionPropertyType; //linguistic2::ConversionPropertyType 68cdf0e10cSrcweir 69cdf0e10cSrcweir sal_Bool m_bNewEntry; 70cdf0e10cSrcweir }; 71cdf0e10cSrcweir 72cdf0e10cSrcweir class DictionaryList : public SvHeaderTabListBox 73cdf0e10cSrcweir { 74cdf0e10cSrcweir public: 75cdf0e10cSrcweir DictionaryList( Window* pParent, const ResId& ); 76cdf0e10cSrcweir DictionaryList( Window* pParent ); 77cdf0e10cSrcweir virtual ~DictionaryList(); 78cdf0e10cSrcweir 79cdf0e10cSrcweir HeaderBar* createHeaderBar( const String& rColumn1, const String& rColumn2, const String& rColumn3 80cdf0e10cSrcweir , long nWidth1, long nWidth2, long nWidth3 ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir void initDictionaryControl( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XConversionDictionary>& xDictionary 83cdf0e10cSrcweir , ListBox* pPropertyTypeNameListBox ); 84cdf0e10cSrcweir void activate( HeaderBar* pHeaderBar ); 85cdf0e10cSrcweir void deleteAll(); 86cdf0e10cSrcweir void refillFromDictionary( sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ ); 87cdf0e10cSrcweir void save(); 88cdf0e10cSrcweir 89cdf0e10cSrcweir DictionaryEntry* getTermEntry( const rtl::OUString& rTerm ) const; 90cdf0e10cSrcweir bool hasTerm( const rtl::OUString& rTerm ) const; 91cdf0e10cSrcweir 92cdf0e10cSrcweir void addEntry( const rtl::OUString& rTerm, const rtl::OUString& rMapping 93cdf0e10cSrcweir , sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/, sal_uIntPtr nPos = LIST_APPEND ); 94cdf0e10cSrcweir sal_uIntPtr deleteEntries( const rtl::OUString& rTerm ); //return lowest position of deleted entries or LIST_APPEND if no entry was deleted 95cdf0e10cSrcweir void deleteEntryOnPos( sal_Int32 nPos ); 96cdf0e10cSrcweir DictionaryEntry* getEntryOnPos( sal_Int32 nPos ) const; 97cdf0e10cSrcweir DictionaryEntry* getFirstSelectedEntry() const; 98cdf0e10cSrcweir 99cdf0e10cSrcweir void sortByColumn( sal_uInt16 nSortColumnIndex, bool bSortAtoZ ); 100cdf0e10cSrcweir sal_uInt16 getSortColumn() const; 101cdf0e10cSrcweir 102cdf0e10cSrcweir virtual void Resize(); 103cdf0e10cSrcweir 104cdf0e10cSrcweir private: 105cdf0e10cSrcweir String getPropertyTypeName( sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/ ) const; 106cdf0e10cSrcweir String makeTabString( const DictionaryEntry& rEntry ) const; 107cdf0e10cSrcweir 108cdf0e10cSrcweir DECL_LINK( CompareHdl, SvSortData* ); 109cdf0e10cSrcweir StringCompare ColumnCompare( SvLBoxEntry* pLeft, SvLBoxEntry* pRight ); 110cdf0e10cSrcweir SvLBoxItem* getItemAtColumn( SvLBoxEntry* pEntry, sal_uInt16 nColumn ) const; 111cdf0e10cSrcweir 112cdf0e10cSrcweir public: 113cdf0e10cSrcweir ::com::sun::star::uno::Reference< 114cdf0e10cSrcweir ::com::sun::star::linguistic2::XConversionDictionary> m_xDictionary; 115cdf0e10cSrcweir 116cdf0e10cSrcweir private: 117cdf0e10cSrcweir HeaderBar* m_pHeaderBar; 118cdf0e10cSrcweir ListBox* m_pPropertyTypeNameListBox; 119cdf0e10cSrcweir 120cdf0e10cSrcweir std::vector< DictionaryEntry* > m_aToBeDeleted; 121cdf0e10cSrcweir 122cdf0e10cSrcweir sal_uInt16 m_nSortColumnIndex; 123cdf0e10cSrcweir }; 124cdf0e10cSrcweir 125cdf0e10cSrcweir class ChineseDictionaryDialog : public ModalDialog 126cdf0e10cSrcweir { 127cdf0e10cSrcweir public: 128cdf0e10cSrcweir ChineseDictionaryDialog( Window* pParent ); 129cdf0e10cSrcweir virtual ~ChineseDictionaryDialog(); 130cdf0e10cSrcweir 131cdf0e10cSrcweir //this method should be called once before calling execute 132cdf0e10cSrcweir void setDirectionAndTextConversionOptions( bool bDirectionToSimplified, sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ ); 133cdf0e10cSrcweir 134cdf0e10cSrcweir virtual short Execute(); 135cdf0e10cSrcweir 136cdf0e10cSrcweir private: 137cdf0e10cSrcweir DECL_LINK( DirectionHdl, void* ); 138cdf0e10cSrcweir DECL_LINK( EditFieldsHdl, Control* ); 139cdf0e10cSrcweir DECL_LINK( MappingSelectHdl, void* ); 140cdf0e10cSrcweir DECL_LINK( AddHdl, void* ); 141cdf0e10cSrcweir DECL_LINK( ModifyHdl, void* ); 142cdf0e10cSrcweir DECL_LINK( DeleteHdl, void* ); 143cdf0e10cSrcweir DECL_LINK( HeaderBarClick, void* ); 144cdf0e10cSrcweir 145cdf0e10cSrcweir void updateAfterDirectionChange(); 146cdf0e10cSrcweir void updateButtons(); 147cdf0e10cSrcweir 148cdf0e10cSrcweir bool isEditFieldsHaveContent() const; 149cdf0e10cSrcweir bool isEditFieldsContentEqualsSelectedListContent() const; 150cdf0e10cSrcweir 151cdf0e10cSrcweir DictionaryList& getActiveDictionary(); 152cdf0e10cSrcweir DictionaryList& getReverseDictionary(); 153cdf0e10cSrcweir 154cdf0e10cSrcweir const DictionaryList& getActiveDictionary() const; 155cdf0e10cSrcweir const DictionaryList& getReverseDictionary() const; 156cdf0e10cSrcweir 157cdf0e10cSrcweir private: 158cdf0e10cSrcweir sal_Int32 m_nTextConversionOptions; //i18n::TextConversionOption 159cdf0e10cSrcweir 160cdf0e10cSrcweir RadioButton m_aRB_To_Simplified; 161cdf0e10cSrcweir RadioButton m_aRB_To_Traditional; 162cdf0e10cSrcweir 163cdf0e10cSrcweir CheckBox m_aCB_Reverse; 164cdf0e10cSrcweir 165cdf0e10cSrcweir FixedText m_aFT_Term; 166cdf0e10cSrcweir Edit m_aED_Term; 167cdf0e10cSrcweir 168cdf0e10cSrcweir FixedText m_aFT_Mapping; 169cdf0e10cSrcweir Edit m_aED_Mapping; 170cdf0e10cSrcweir 171cdf0e10cSrcweir FixedText m_aFT_Property; 172cdf0e10cSrcweir ListBox m_aLB_Property; 173cdf0e10cSrcweir 174cdf0e10cSrcweir HeaderBar* m_pHeaderBar; 175cdf0e10cSrcweir DictionaryList m_aCT_DictionaryToSimplified; 176cdf0e10cSrcweir DictionaryList m_aCT_DictionaryToTraditional; 177cdf0e10cSrcweir 178cdf0e10cSrcweir PushButton m_aPB_Add; 179cdf0e10cSrcweir PushButton m_aPB_Modify; 180cdf0e10cSrcweir PushButton m_aPB_Delete; 181cdf0e10cSrcweir 182cdf0e10cSrcweir FixedLine m_aFL_Bottomline; 183cdf0e10cSrcweir 184cdf0e10cSrcweir OKButton m_aBP_OK; 185cdf0e10cSrcweir CancelButton m_aBP_Cancel; 186cdf0e10cSrcweir HelpButton m_aBP_Help; 187cdf0e10cSrcweir 188cdf0e10cSrcweir ::com::sun::star::uno::Reference< 189cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext > m_xContext; 190cdf0e10cSrcweir ::com::sun::star::uno::Reference< 191cdf0e10cSrcweir ::com::sun::star::lang::XMultiComponentFactory> m_xFactory; 192cdf0e10cSrcweir }; 193cdf0e10cSrcweir 194cdf0e10cSrcweir //............................................................................. 195cdf0e10cSrcweir } //end namespace 196cdf0e10cSrcweir //............................................................................. 197cdf0e10cSrcweir #endif 198