1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "chinese_dictionarydialog.hxx"
22 #include <cppuhelper/bootstrap.hxx>
23 #include <com/sun/star/i18n/TextConversionOption.hpp>
24 #include <com/sun/star/linguistic2/ConversionDictionaryType.hpp>
25 #include <com/sun/star/linguistic2/ConversionPropertyType.hpp>
26 #include <com/sun/star/linguistic2/ConversionDictionaryList.hpp>
27 #include <com/sun/star/linguistic2/XConversionPropertyType.hpp>
28 #include <com/sun/star/util/XFlushable.hpp>
29 #include <com/sun/star/lang/Locale.hpp>
30 #include <unotools/lingucfg.hxx>
31 #include <unotools/linguprops.hxx>
32 #include <osl/diagnose.h>
34 namespace textconversiondlgs
37 using namespace ::com::sun::star
;
38 using namespace ::com::sun::star::uno
;
40 DictionaryList::DictionaryList(std::unique_ptr
<weld::TreeView
> xControl
)
41 : m_xControl(std::move(xControl
))
42 , m_xIter(m_xControl
->make_iterator())
44 , m_pED_Mapping(nullptr)
45 , m_pLB_Property(nullptr)
48 m_xControl
->make_sorted();
51 OUString
DictionaryList::getPropertyTypeName( sal_Int16 nConversionPropertyType
) const
53 if (!m_pLB_Property
|| !m_pLB_Property
->get_count())
56 sal_uInt16 nPos
= static_cast<sal_uInt16
>( nConversionPropertyType
)-1;
57 if (nPos
< m_pLB_Property
->get_count())
58 return m_pLB_Property
->get_text(nPos
);
59 return m_pLB_Property
->get_text(0);
62 void DictionaryList::save()
64 if (!m_xDictionary
.is())
67 Reference
< linguistic2::XConversionPropertyType
> xPropertyType( m_xDictionary
, uno::UNO_QUERY
);
72 for( nN
= m_aToBeDeleted
.size(); nN
--; )
74 pE
= m_aToBeDeleted
[nN
];
75 m_xDictionary
->removeEntry( pE
->m_aTerm
, pE
->m_aMapping
);
77 int nRowCount
= m_xControl
->n_children();
78 for( nN
= nRowCount
; nN
--; )
80 pE
= getEntryOnPos( nN
);
85 m_xDictionary
->addEntry( pE
->m_aTerm
, pE
->m_aMapping
);
86 xPropertyType
->setPropertyType( pE
->m_aTerm
, pE
->m_aMapping
, pE
->m_nConversionPropertyType
);
88 catch( uno::Exception
& )
94 Reference
< util::XFlushable
> xFlush( m_xDictionary
, uno::UNO_QUERY
);
99 void DictionaryList::deleteAll()
102 int nRowCount
= m_xControl
->n_children();
103 for( nN
= nRowCount
; nN
--; )
104 deleteEntryOnPos( nN
);
105 for( nN
= m_aToBeDeleted
.size(); nN
--; )
107 DictionaryEntry
* pE
= m_aToBeDeleted
[nN
];
110 m_aToBeDeleted
.clear();
113 void DictionaryList::refillFromDictionary( sal_Int32 nTextConversionOptions
)
117 if(!m_xDictionary
.is())
120 const Sequence
< OUString
> aLeftList( m_xDictionary
->getConversionEntries( linguistic2::ConversionDirection_FROM_LEFT
) );
122 Reference
< linguistic2::XConversionPropertyType
> xPropertyType( m_xDictionary
, uno::UNO_QUERY
);
125 sal_Int16 nConversionPropertyType
;
127 for(const OUString
& aLeft
: aLeftList
)
129 Sequence
< OUString
> aRightList( m_xDictionary
->getConversions(
130 aLeft
, 0, aLeft
.getLength()
131 , linguistic2::ConversionDirection_FROM_LEFT
, nTextConversionOptions
) );
133 if(aRightList
.getLength()!=1)
135 OSL_FAIL("The Chinese Translation Dictionary should have exactly one Mapping for each term.");
139 aRight
= aRightList
[0];
140 nConversionPropertyType
= linguistic2::ConversionPropertyType::OTHER
;
141 if(xPropertyType
.is())
142 nConversionPropertyType
= xPropertyType
->getPropertyType(aLeft
, aRight
);
144 DictionaryEntry
* pEntry
= new DictionaryEntry( aLeft
, aRight
, nConversionPropertyType
);
146 m_xControl
->append(m_xIter
.get());
147 m_xControl
->set_text(*m_xIter
, pEntry
->m_aTerm
, 0);
148 m_xControl
->set_text(*m_xIter
, pEntry
->m_aMapping
, 1);
149 m_xControl
->set_text(*m_xIter
, getPropertyTypeName(pEntry
->m_nConversionPropertyType
), 2);
150 m_xControl
->set_id(*m_xIter
, OUString::number(reinterpret_cast<sal_Int64
>(pEntry
)));
154 DictionaryEntry
* DictionaryList::getFirstSelectedEntry() const
156 DictionaryEntry
* pRet
=nullptr;
157 int nN
= m_xControl
->get_selected_index();
159 pRet
= getEntryOnPos( nN
);
163 DictionaryEntry
* DictionaryList::getEntryOnPos(sal_Int32 nPos
) const
165 OUString sLBEntry
= m_xControl
->get_id(nPos
);
166 return reinterpret_cast<DictionaryEntry
*>(sLBEntry
.toInt64());
169 DictionaryEntry
* DictionaryList::getTermEntry( std::u16string_view rTerm
) const
171 int nRowCount
= m_xControl
->n_children();
172 for( sal_Int32 nN
= nRowCount
; nN
--; )
174 DictionaryEntry
* pE
= getEntryOnPos( nN
);
175 if( pE
&& rTerm
== pE
->m_aTerm
)
181 bool DictionaryList::hasTerm( std::u16string_view rTerm
) const
183 return getTermEntry(rTerm
) !=nullptr ;
186 void DictionaryList::addEntry(const OUString
& rTerm
, const OUString
& rMapping
,
187 sal_Int16 nConversionPropertyType
, int nPos
)
189 if( hasTerm( rTerm
) )
192 DictionaryEntry
* pEntry
= new DictionaryEntry( rTerm
, rMapping
, nConversionPropertyType
, true );
193 m_xControl
->insert(nPos
, m_xIter
.get());
194 m_xControl
->set_text(*m_xIter
, pEntry
->m_aTerm
, 0);
195 m_xControl
->set_text(*m_xIter
, pEntry
->m_aMapping
, 1);
196 m_xControl
->set_text(*m_xIter
, getPropertyTypeName(pEntry
->m_nConversionPropertyType
), 2);
197 m_xControl
->set_id(*m_xIter
, OUString::number(reinterpret_cast<sal_Int64
>(pEntry
)));
198 m_xControl
->select(*m_xIter
);
201 void DictionaryList::deleteEntryOnPos( sal_Int32 nPos
)
203 DictionaryEntry
* pEntry
= getEntryOnPos( nPos
);
204 m_xControl
->remove(nPos
);
207 if( pEntry
->m_bNewEntry
)
210 m_aToBeDeleted
.push_back( pEntry
);
214 int DictionaryList::deleteEntries( std::u16string_view rTerm
)
217 int nRowCount
= m_xControl
->n_children();
218 for (sal_Int32 nN
= nRowCount
; nN
--;)
220 DictionaryEntry
* pCurEntry
= getEntryOnPos( nN
);
221 if( rTerm
== pCurEntry
->m_aTerm
)
224 m_xControl
->remove(nN
);
225 if( pCurEntry
->m_bNewEntry
)
228 m_aToBeDeleted
.push_back( pCurEntry
);
234 DictionaryEntry::DictionaryEntry( const OUString
& rTerm
, const OUString
& rMapping
235 , sal_Int16 nConversionPropertyType
238 , m_aMapping( rMapping
)
239 , m_nConversionPropertyType( nConversionPropertyType
)
240 , m_bNewEntry( bNewEntry
)
242 if( m_nConversionPropertyType
== 0 )
243 m_nConversionPropertyType
= 1;
246 DictionaryEntry::~DictionaryEntry()
250 IMPL_LINK_NOARG(ChineseDictionaryDialog
, SizeAllocHdl
, const Size
&, void)
252 DictionaryList
* pControl
= m_xCT_DictionaryToTraditional
->get_visible() ?
253 m_xCT_DictionaryToTraditional
.get() :
254 m_xCT_DictionaryToSimplified
.get();
255 std::vector
<int> aWidths
;
256 int x1
, x2
, y
, width
, height
;
257 if (!m_xED_Mapping
->get_extents_relative_to(pControl
->get_widget(), x1
, y
, width
, height
))
259 aWidths
.push_back(x1
);
260 if (!m_xLB_Property
->get_extents_relative_to(pControl
->get_widget(), x2
, y
, width
, height
))
262 aWidths
.push_back(x2
- x1
);
263 m_xCT_DictionaryToTraditional
->get_widget().set_column_fixed_widths(aWidths
);
264 m_xCT_DictionaryToSimplified
->get_widget().set_column_fixed_widths(aWidths
);
267 void DictionaryList::init(const Reference
< linguistic2::XConversionDictionary
>& xDictionary
,
268 weld::Entry
*pED_Term
, weld::Entry
*pED_Mapping
, weld::ComboBox
*pLB_Property
)
270 if (m_xDictionary
.is())
273 m_xDictionary
= xDictionary
;
275 m_pED_Term
= pED_Term
;
276 m_pED_Mapping
= pED_Mapping
;
277 m_pLB_Property
= pLB_Property
;
279 m_xControl
->set_sort_column(0);
280 m_xControl
->set_sort_indicator(TRISTATE_TRUE
, 0);
282 std::vector
<int> aWidths
;
283 aWidths
.push_back(m_pED_Term
->get_preferred_size().Width());
284 aWidths
.push_back(m_pED_Mapping
->get_preferred_size().Width());
285 m_xControl
->set_column_fixed_widths(aWidths
);
288 void ChineseDictionaryDialog::initDictionaryControl(DictionaryList
*pList
,
289 const Reference
< linguistic2::XConversionDictionary
>& xDictionary
)
291 //set widgets to track the width of for columns
292 pList
->init(xDictionary
,
293 m_xED_Term
.get(), m_xED_Mapping
.get(), m_xLB_Property
.get());
296 ChineseDictionaryDialog::ChineseDictionaryDialog(weld::Window
* pParent
)
297 : GenericDialogController(pParent
, "svx/ui/chinesedictionary.ui", "ChineseDictionaryDialog")
298 , m_nTextConversionOptions(i18n::TextConversionOption::NONE
)
299 , m_xRB_To_Simplified(m_xBuilder
->weld_radio_button("tradtosimple"))
300 , m_xRB_To_Traditional(m_xBuilder
->weld_radio_button("simpletotrad"))
301 , m_xCB_Reverse(m_xBuilder
->weld_check_button("reverse"))
302 , m_xFT_Term(m_xBuilder
->weld_label("termft"))
303 , m_xED_Term(m_xBuilder
->weld_entry("term"))
304 , m_xFT_Mapping(m_xBuilder
->weld_label("mappingft"))
305 , m_xED_Mapping(m_xBuilder
->weld_entry("mapping"))
306 , m_xFT_Property(m_xBuilder
->weld_label("propertyft"))
307 , m_xLB_Property(m_xBuilder
->weld_combo_box("property"))
308 , m_xCT_DictionaryToSimplified(new DictionaryList(m_xBuilder
->weld_tree_view("tradtosimpleview")))
309 , m_xCT_DictionaryToTraditional(new DictionaryList(m_xBuilder
->weld_tree_view("simpletotradview")))
310 , m_xPB_Add(m_xBuilder
->weld_button("add"))
311 , m_xPB_Modify(m_xBuilder
->weld_button("modify"))
312 , m_xPB_Delete(m_xBuilder
->weld_button("delete"))
314 m_xCT_DictionaryToSimplified
->set_size_request(-1, m_xCT_DictionaryToSimplified
->get_height_rows(8));
315 m_xCT_DictionaryToTraditional
->set_size_request(-1, m_xCT_DictionaryToTraditional
->get_height_rows(8));
317 SvtLinguConfig aLngCfg
;
319 Any
aAny( aLngCfg
.GetProperty( UPN_IS_REVERSE_MAPPING
) );
320 if( aAny
>>= bValue
)
321 m_xCB_Reverse
->set_active( bValue
);
323 m_xLB_Property
->set_active(0);
325 Reference
< linguistic2::XConversionDictionary
> xDictionary_To_Simplified
;
326 Reference
< linguistic2::XConversionDictionary
> xDictionary_To_Traditional
;
330 m_xContext
.set( ::cppu::defaultBootstrap_InitialComponentContext() );
333 Reference
< linguistic2::XConversionDictionaryList
> xDictionaryList
= linguistic2::ConversionDictionaryList::create(m_xContext
);
334 Reference
< container::XNameContainer
> xContainer( xDictionaryList
->getDictionaryContainer() );
339 OUString
aNameTo_Simplified("ChineseT2S");
340 OUString
aNameTo_Traditional("ChineseS2T");
341 lang::Locale aLocale
;
342 aLocale
.Language
= "zh";
344 if( xContainer
->hasByName( aNameTo_Simplified
) )
345 xDictionary_To_Simplified
.set(
346 xContainer
->getByName( aNameTo_Simplified
), UNO_QUERY
);
349 aLocale
.Country
= "TW";
350 xDictionary_To_Simplified
=
351 xDictionaryList
->addNewDictionary( aNameTo_Simplified
352 , aLocale
, linguistic2::ConversionDictionaryType::SCHINESE_TCHINESE
355 if (xDictionary_To_Simplified
.is())
356 xDictionary_To_Simplified
->setActive( true );
359 if( xContainer
->hasByName( aNameTo_Traditional
) )
360 xDictionary_To_Traditional
.set(
361 xContainer
->getByName( aNameTo_Traditional
), UNO_QUERY
);
364 aLocale
.Country
= "CN";
365 xDictionary_To_Traditional
=
366 xDictionaryList
->addNewDictionary( aNameTo_Traditional
367 ,aLocale
, linguistic2::ConversionDictionaryType::SCHINESE_TCHINESE
);
369 if (xDictionary_To_Traditional
.is())
370 xDictionary_To_Traditional
->setActive( true );
373 catch(const uno::Exception
& )
380 //init dictionary controls
381 initDictionaryControl(m_xCT_DictionaryToSimplified
.get(), xDictionary_To_Simplified
);
382 initDictionaryControl(m_xCT_DictionaryToTraditional
.get(), xDictionary_To_Traditional
);
385 m_xCT_DictionaryToSimplified
->connect_column_clicked(LINK(this, ChineseDictionaryDialog
, ToSimplifiedHeaderBarClick
));
386 m_xCT_DictionaryToTraditional
->connect_column_clicked(LINK(this, ChineseDictionaryDialog
, ToTraditionalHeaderBarClick
));
388 updateAfterDirectionChange();
390 m_xED_Term
->connect_changed( LINK( this, ChineseDictionaryDialog
, EditFieldsHdl
) );
391 m_xED_Mapping
->connect_changed( LINK( this, ChineseDictionaryDialog
, EditFieldsHdl
) );
392 m_xLB_Property
->connect_changed( LINK( this, ChineseDictionaryDialog
, EditFieldsListBoxHdl
) );
394 m_xRB_To_Simplified
->connect_toggled( LINK( this, ChineseDictionaryDialog
, DirectionHdl
) );
396 m_xCT_DictionaryToSimplified
->connect_changed( LINK( this, ChineseDictionaryDialog
, MappingSelectHdl
));
397 m_xCT_DictionaryToTraditional
->connect_changed( LINK( this, ChineseDictionaryDialog
, MappingSelectHdl
));
399 m_xPB_Add
->connect_clicked( LINK( this, ChineseDictionaryDialog
, AddHdl
) );
400 m_xPB_Modify
->connect_clicked( LINK( this, ChineseDictionaryDialog
, ModifyHdl
) );
401 m_xPB_Delete
->connect_clicked( LINK( this, ChineseDictionaryDialog
, DeleteHdl
) );
403 m_xED_Mapping
->connect_size_allocate(LINK(this, ChineseDictionaryDialog
, SizeAllocHdl
));
404 m_xLB_Property
->connect_size_allocate(LINK(this, ChineseDictionaryDialog
, SizeAllocHdl
));
407 ChineseDictionaryDialog::~ChineseDictionaryDialog()
411 void ChineseDictionaryDialog::setDirectionAndTextConversionOptions( bool bDirectionToSimplified
, sal_Int32 nTextConversionOptions
/*i18n::TextConversionOption*/ )
413 if( bDirectionToSimplified
== m_xRB_To_Simplified
->get_active()
414 && nTextConversionOptions
== m_nTextConversionOptions
)
417 m_nTextConversionOptions
= nTextConversionOptions
;
419 if (bDirectionToSimplified
)
420 m_xRB_To_Simplified
->set_active(true);
422 m_xRB_To_Traditional
->set_active(true);
423 updateAfterDirectionChange();
426 IMPL_LINK_NOARG(ChineseDictionaryDialog
, DirectionHdl
, weld::Toggleable
&, void)
428 updateAfterDirectionChange();
431 void ChineseDictionaryDialog::updateAfterDirectionChange()
433 Reference
< linguistic2::XConversionDictionary
> xDictionary
;
435 if (m_xRB_To_Simplified
->get_active())
437 m_xCT_DictionaryToTraditional
->hide();
438 m_xCT_DictionaryToSimplified
->show();
439 xDictionary
= m_xCT_DictionaryToSimplified
->m_xDictionary
;
443 m_xCT_DictionaryToSimplified
->hide();
444 m_xCT_DictionaryToTraditional
->show();
445 xDictionary
= m_xCT_DictionaryToTraditional
->m_xDictionary
;
451 IMPL_LINK_NOARG(ChineseDictionaryDialog
, EditFieldsListBoxHdl
, weld::ComboBox
&, void)
456 IMPL_LINK_NOARG(ChineseDictionaryDialog
, EditFieldsHdl
, weld::Entry
&, void)
461 IMPL_LINK_NOARG(ChineseDictionaryDialog
, MappingSelectHdl
, weld::TreeView
&, void)
463 DictionaryEntry
* pE
= getActiveDictionary().getFirstSelectedEntry();
466 m_xED_Term
->set_text( pE
->m_aTerm
);
467 m_xED_Mapping
->set_text( pE
->m_aMapping
);
468 sal_Int16 nPos
= pE
->m_nConversionPropertyType
-1;
469 if (nPos
<0 || nPos
>=m_xLB_Property
->get_count())
471 if (m_xLB_Property
->get_count())
472 m_xLB_Property
->set_active(nPos
);
478 bool ChineseDictionaryDialog::isEditFieldsHaveContent() const
480 return !m_xED_Term
->get_text().isEmpty() && !m_xED_Mapping
->get_text().isEmpty();
483 bool ChineseDictionaryDialog::isEditFieldsContentEqualsSelectedListContent() const
485 DictionaryEntry
* pE
= getActiveDictionary().getFirstSelectedEntry();
488 if (pE
->m_aTerm
!= m_xED_Term
->get_text())
490 if (pE
->m_aMapping
!= m_xED_Mapping
->get_text())
492 if (pE
->m_nConversionPropertyType
!= m_xLB_Property
->get_active() + 1)
499 const DictionaryList
& ChineseDictionaryDialog::getActiveDictionary() const
501 if( m_xRB_To_Traditional
->get_active() )
502 return *m_xCT_DictionaryToTraditional
;
503 return *m_xCT_DictionaryToSimplified
;
506 DictionaryList
& ChineseDictionaryDialog::getActiveDictionary()
508 if( m_xRB_To_Traditional
->get_active() )
509 return *m_xCT_DictionaryToTraditional
;
510 return *m_xCT_DictionaryToSimplified
;
513 const DictionaryList
& ChineseDictionaryDialog::getReverseDictionary() const
515 if( m_xRB_To_Traditional
->get_active() )
516 return *m_xCT_DictionaryToSimplified
;
517 return *m_xCT_DictionaryToTraditional
;
520 DictionaryList
& ChineseDictionaryDialog::getReverseDictionary()
522 if( m_xRB_To_Traditional
->get_active() )
523 return *m_xCT_DictionaryToSimplified
;
524 return *m_xCT_DictionaryToTraditional
;
527 void ChineseDictionaryDialog::updateButtons()
529 bool bAdd
= isEditFieldsHaveContent() && !getActiveDictionary().hasTerm(m_xED_Term
->get_text());
530 m_xPB_Add
->set_sensitive( bAdd
);
532 m_xPB_Delete
->set_sensitive(!bAdd
&& getActiveDictionary().get_selected_index() != -1);
534 bool bModify
= false;
536 DictionaryEntry
* pFirstSelectedEntry
= getActiveDictionary().getFirstSelectedEntry();
537 bModify
= !bAdd
&& pFirstSelectedEntry
&& pFirstSelectedEntry
->m_aTerm
== m_xED_Term
->get_text();
538 if( bModify
&& isEditFieldsContentEqualsSelectedListContent() )
541 m_xPB_Modify
->set_sensitive( bModify
);
544 IMPL_LINK_NOARG(ChineseDictionaryDialog
, AddHdl
, weld::Button
&, void)
546 if( !isEditFieldsHaveContent() )
549 sal_Int16 nConversionPropertyType
= m_xLB_Property
->get_active() + 1;
551 getActiveDictionary().addEntry( m_xED_Term
->get_text(), m_xED_Mapping
->get_text(), nConversionPropertyType
);
553 if( m_xCB_Reverse
->get_active() )
555 getReverseDictionary().deleteEntries( m_xED_Mapping
->get_text() );
556 getReverseDictionary().addEntry( m_xED_Mapping
->get_text(), m_xED_Term
->get_text(), nConversionPropertyType
);
562 IMPL_LINK_NOARG(ChineseDictionaryDialog
, ModifyHdl
, weld::Button
&, void)
564 OUString
aTerm( m_xED_Term
->get_text() );
565 OUString
aMapping( m_xED_Mapping
->get_text() );
566 sal_Int16 nConversionPropertyType
= m_xLB_Property
->get_active() + 1;
568 DictionaryList
& rActive
= getActiveDictionary();
569 DictionaryList
& rReverse
= getReverseDictionary();
571 DictionaryEntry
* pE
= rActive
.getFirstSelectedEntry();
572 if( pE
&& pE
->m_aTerm
!= aTerm
)
577 if( pE
->m_aMapping
!= aMapping
|| pE
->m_nConversionPropertyType
!= nConversionPropertyType
)
579 if( m_xCB_Reverse
->get_active() )
581 rReverse
.deleteEntries( pE
->m_aMapping
);
582 int nPos
= rReverse
.deleteEntries( aMapping
);
583 rReverse
.addEntry( aMapping
, aTerm
, nConversionPropertyType
, nPos
);
586 int nPos
= rActive
.deleteEntries( aTerm
);
587 rActive
.addEntry( aTerm
, aMapping
, nConversionPropertyType
, nPos
);
594 IMPL_LINK_NOARG(ChineseDictionaryDialog
, DeleteHdl
, weld::Button
&, void)
596 DictionaryList
& rActive
= getActiveDictionary();
597 DictionaryList
& rReverse
= getReverseDictionary();
599 int nEntry
= rActive
.get_selected_index();
602 DictionaryEntry
* pEntry
= rActive
.getEntryOnPos(nEntry
);
605 OUString aMapping
= pEntry
->m_aMapping
;
606 rActive
.deleteEntryOnPos(nEntry
);
607 if (m_xCB_Reverse
->get_active())
608 rReverse
.deleteEntries(aMapping
);
615 short ChineseDictionaryDialog::run()
617 sal_Int32 nTextConversionOptions
= m_nTextConversionOptions
;
618 if(m_nTextConversionOptions
& i18n::TextConversionOption::USE_CHARACTER_VARIANTS
)
619 nTextConversionOptions
= nTextConversionOptions
^i18n::TextConversionOption::USE_CHARACTER_VARIANTS
;
621 m_xCT_DictionaryToSimplified
->refillFromDictionary( nTextConversionOptions
);
622 m_xCT_DictionaryToTraditional
->refillFromDictionary( m_nTextConversionOptions
);
624 short nRet
= GenericDialogController::run();
628 //save settings to configuration
629 SvtLinguConfig aLngCfg
;
630 aLngCfg
.SetProperty( UPN_IS_REVERSE_MAPPING
, uno::Any(m_xCB_Reverse
->get_active()) );
632 m_xCT_DictionaryToSimplified
->save();
633 m_xCT_DictionaryToTraditional
->save();
636 m_xCT_DictionaryToSimplified
->deleteAll();
637 m_xCT_DictionaryToTraditional
->deleteAll();
642 void ChineseDictionaryDialog::HeaderBarClick(DictionaryList
& rList
, int nColumn
)
644 bool bSortAtoZ
= rList
.get_sort_order();
646 //set new arrow positions in headerbar
647 if (nColumn
== rList
.get_sort_column())
649 bSortAtoZ
= !bSortAtoZ
;
650 rList
.set_sort_order(bSortAtoZ
);
654 rList
.set_sort_indicator(TRISTATE_INDET
, rList
.get_sort_column());
655 rList
.set_sort_column(nColumn
);
659 rList
.set_sort_indicator(bSortAtoZ
? TRISTATE_TRUE
: TRISTATE_FALSE
, nColumn
);
662 IMPL_LINK(ChineseDictionaryDialog
, ToSimplifiedHeaderBarClick
, int, nColumn
, void)
664 HeaderBarClick(*m_xCT_DictionaryToSimplified
, nColumn
);
667 IMPL_LINK(ChineseDictionaryDialog
, ToTraditionalHeaderBarClick
, int, nColumn
, void)
669 HeaderBarClick(*m_xCT_DictionaryToTraditional
, nColumn
);
674 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */