Fix fdo#52204 add new feature ignore diacritics in search for CTL

Change-Id: Ie9044a35003217545bacea214ef59047bff3b8b1
This commit is contained in:
abdulmajeed ahmed
2013-06-21 11:07:34 +02:00
parent 832612bb6b
commit 448fa131b2
22 changed files with 162 additions and 22 deletions

View File

@@ -65,6 +65,7 @@
#include <dialmgr.hxx>
#include <svtools/helpopt.hxx>
#include <unotools/saveopt.hxx>
#include <unotools/searchopt.hxx>
#include <sal/macros.h>
#include <com/sun/star/configuration/theDefaultProvider.hpp>
@@ -1396,6 +1397,8 @@ sal_Bool OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet )
if ( m_pCTLSupportCB->GetSavedValue() != m_pCTLSupportCB->IsChecked() )
{
SvtSearchOptions aOpt;
aOpt.SetIgnoreDiacritics_CTL (true);
pLangConfig->aLanguageOptions.SetCTLFontEnabled( m_pCTLSupportCB->IsChecked() );
const sal_uInt16 STATE_COUNT = 1;

View File

@@ -93,6 +93,7 @@ $(eval $(call gb_Library_add_exception_objects,i18npool,\
i18npool/source/transliteration/ignoreTraditionalKanji_ja_JP \
i18npool/source/transliteration/ignoreWidth \
i18npool/source/transliteration/ignoreZiZu_ja_JP \
i18npool/source/transliteration/ignoreDiacritics_CTL \
i18npool/source/transliteration/katakanaToHiragana \
i18npool/source/transliteration/largeToSmall_ja_JP \
i18npool/source/transliteration/numtochar \

View File

@@ -113,6 +113,11 @@ TRANSLITERATION_IGNORE(TraditionalKanji_ja_JP)
#if defined( TRANSLITERATION_ZiZu_ja_JP ) || defined( TRANSLITERATION_ALL )
TRANSLITERATION_IGNORE(ZiZu_ja_JP)
#endif
#if defined( TRANSLITERATION_Diacritics_CTL ) || defined( TRANSLITERATION_ALL )
TRANSLITERATION_IGNORE(Diacritics_CTL)
#endif
#undef TRANSLITERATION_IGNORE
#define TRANSLITERATION_IGNORE( name ) \

View File

@@ -453,7 +453,7 @@
<DecimalPlaces>2</DecimalPlaces>
</Currency>
</LC_CURRENCY>
<LC_TRANSLITERATION ref="en_US"/>
<LC_TRANSLITERATION ref="ar_EG"/>
<LC_MISC ref="ar_EG"/>
<LC_NumberingLevel ref="ar_EG"/>
<LC_OutLineNumberingLevel ref="ar_EG"/>

View File

@@ -458,7 +458,15 @@
<DecimalPlaces>2</DecimalPlaces>
</Currency>
</LC_CURRENCY>
<LC_TRANSLITERATION ref="en_US"/>
<LC_TRANSLITERATION>
<Transliteration unoid="SENTENCE_CASE"/>
<Transliteration unoid="LOWERCASE_UPPERCASE"/>
<Transliteration unoid="UPPERCASE_LOWERCASE"/>
<Transliteration unoid="TITLE_CASE"/>
<Transliteration unoid="TOGGLE_CASE"/>
<Transliteration unoid="IGNORE_CASE"/>
<Transliteration unoid="ignoreDiacritics_CTL"/>
</LC_TRANSLITERATION>
<LC_MISC>
<ReservedWords>
<trueWord>صح</trueWord>

View File

@@ -300,7 +300,7 @@
<DecimalPlaces>2</DecimalPlaces>
</Currency>
</LC_CURRENCY>
<LC_TRANSLITERATION ref="en_US"/>
<LC_TRANSLITERATION ref="ar_EG"/>
<LC_MISC ref="ar_EG"/>
<LC_NumberingLevel ref="ar_EG"/>
<LC_OutLineNumberingLevel ref="ar_EG"/>

View File

@@ -341,11 +341,7 @@
<DecimalPlaces>2</DecimalPlaces>
</Currency>
</LC_CURRENCY>
<LC_TRANSLITERATION>
<Transliteration unoid="LOWERCASE_UPPERCASE"/>
<Transliteration unoid="UPPERCASE_LOWERCASE"/>
<Transliteration unoid="IGNORE_CASE"/>
</LC_TRANSLITERATION>
<LC_TRANSLITERATION ref="ar_EG"/>
<LC_MISC>
<ReservedWords>
<trueWord>صحيح</trueWord>

View File

@@ -300,7 +300,7 @@
<DecimalPlaces>2</DecimalPlaces>
</Currency>
</LC_CURRENCY>
<LC_TRANSLITERATION ref="en_US"/>
<LC_TRANSLITERATION ref="ar_EG"/>
<LC_MISC ref="ar_EG"/>
<LC_NumberingLevel ref="ar_EG"/>
<LC_OutLineNumberingLevel ref="ar_EG"/>

View File

@@ -300,7 +300,7 @@
<DecimalPlaces>3</DecimalPlaces>
</Currency>
</LC_CURRENCY>
<LC_TRANSLITERATION ref="en_US"/>
<LC_TRANSLITERATION ref="ar_EG"/>
<LC_MISC ref="ar_EG"/>
<LC_NumberingLevel ref="ar_EG"/>
<LC_OutLineNumberingLevel ref="ar_EG"/>

View File

@@ -190,6 +190,7 @@ IMPL_CREATEINSTANCE( ignoreSize_ja_JP)
IMPL_CREATEINSTANCE( ignoreProlongedSoundMark_ja_JP)
IMPL_CREATEINSTANCE( ignoreMiddleDot_ja_JP)
IMPL_CREATEINSTANCE( ignoreSpace_ja_JP)
IMPL_CREATEINSTANCE( ignoreDiacritics_CTL)
IMPL_CREATEINSTANCE( TextToChuyin_zh_TW )
IMPL_CREATEINSTANCE( TextToPinyin_zh_CN )
@@ -465,6 +466,7 @@ static const struct InstancesArray {
IMPL_TRANSLITERATION_ITEM (ignoreSpace_ja_JP),
IMPL_TRANSLITERATION_ITEM (TextToPinyin_zh_CN),
IMPL_TRANSLITERATION_ITEM (TextToChuyin_zh_TW),
IMPL_TRANSLITERATION_ITEM( ignoreDiacritics_CTL),
IMPL_TRANSLITERATION_ITEM (NumToCharUpper_zh_CN),
IMPL_TRANSLITERATION_ITEM (NumToCharLower_zh_CN),

View File

@@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#define TRANSLITERATION_Diacritics_CTL
#include <transliteration_Ignore.hxx>
namespace com { namespace sun { namespace star { namespace i18n {
sal_Unicode
ignoreDiacritics_CTL_translator (const sal_Unicode c)
{
switch (c) {
//Arabic Diacritics
case 0x064B:
case 0x064C:
case 0x064D:
case 0x064E:
case 0x064F:
case 0x0650:
case 0x0651:
case 0x0652:
// no break;
return 0xffff; // Skip this character
}
return c;
}
ignoreDiacritics_CTL::ignoreDiacritics_CTL()
{
func = ignoreDiacritics_CTL_translator;
table = 0;
map = 0;
transliterationName = "ignoreDiacritics_CTL";
implementationName = "com.sun.star.i18n.Transliteration.ignoreDiacritics_CTL";
}
} } } }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -23,6 +23,7 @@
#include <com/sun/star/i18n/LocaleData.hpp>
#include <com/sun/star/i18n/TransliterationType.hpp>
#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <comphelper/processfactory.hxx>
@@ -191,6 +192,12 @@ TransliterationImpl::loadModule( TransliterationModules modType, const Locale& r
bodyCascade[numCascade], rLocale))
numCascade++;
}
// additional transliterations from TranslationModuleExtra (we cannot extend TransliterationModule)
if (modType & TransliterationModulesExtra::ignoreDiacritics_CTL)
{
if (loadModuleByName(OUString("ignoreDiacritics_CTL"), bodyCascade[numCascade], rLocale))
numCascade++;
}
} else if (modType&TransliterationModules_NON_IGNORE_MASK) {
for (sal_Int16 i = 0; TMlist[i].tm; i++) {
if (TMlist[i].tm == modType) {

View File

@@ -472,4 +472,7 @@
<implementation name="com.sun.star.text.DefaultNumberingProvider">
<service name="com.sun.star.text.DefaultNumberingProvider"/>
</implementation>
<implementation name="com.sun.star.i18n.Transliteration.ignoreDiacritics_CTL">
<service name="com.sun.star.i18n.Transliteration.l10n"/>
</implementation>
</component>

View File

@@ -164,7 +164,7 @@ private:
CheckBox* m_pWordBtn;
PushButton* m_pCloseBtn;
CheckBox* m_pIgnoreDiacritics;
CheckBox* m_pSelectionBtn;
CheckBox* m_pBackwardsBtn;
CheckBox* m_pRegExpBtn;

View File

@@ -84,6 +84,7 @@ public:
sal_Bool IsIgnoreWhitespace() const;
sal_Bool IsIgnoreProlongedSoundMark() const;
sal_Bool IsIgnoreMiddleDot() const;
sal_Bool IsIgnoreDiacritics_CTL() const;
void SetMatchFullHalfWidthForms( sal_Bool bVal );
void SetMatchHiraganaKatakana( sal_Bool bVal );
@@ -103,6 +104,7 @@ public:
void SetIgnoreWhitespace( sal_Bool bVal );
void SetIgnoreProlongedSoundMark( sal_Bool bVal );
void SetIgnoreMiddleDot( sal_Bool bVal );
void SetIgnoreDiacritics_CTL( sal_Bool bVal );
};

View File

@@ -50,7 +50,8 @@ constants TransliterationModulesExtra
*/
const short TOGGLE_CASE = 202;
/// because we cannot extend TransliterationModule we used TranslationModuleExtra and it will act the same way
const long ignoreDiacritics_CTL = 0x40000000;
const long END_OF_MODULE = 0;
};

View File

@@ -5900,6 +5900,15 @@
</info>
<value>false</value>
</prop>
<prop oor:name="IsIgnoreDiacritics_CTL" oor:type="xs:boolean" oor:nillable="false">
<!-- OldPath: -->
<!-- OldLocation: -->
<!-- UIHints: Edit/Find & Replace -->
<info>
<desc>Specifies search with the use of CTL option.</desc>
</info>
<value>true</value>
</prop>
<prop oor:name="IsUseAsianOptions" oor:type="xs:boolean" oor:nillable="false">
<!-- OldPath: -->
<!-- OldLocation: -->

View File

@@ -952,6 +952,12 @@
</info>
<value>false</value>
</prop>
<prop oor:name="IsIgnoreDiacritics_CTL" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Specifies search with the use of CTL option.</desc>
</info>
<value>true</value>
</prop>
<prop oor:name="IsUseAsianOptions" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Specifies that the Asian options for search should be used.</desc>

View File

@@ -29,6 +29,7 @@
#include <com/sun/star/lang/Locale.hpp>
#include <svl/memberid.hrc>
#include <i18nlangtag/languagetag.hxx>
#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
using namespace utl;
using namespace com::sun::star::beans;
@@ -82,7 +83,8 @@ static Sequence< OUString > lcl_GetNotifyNames()
"Japanese/IsIgnorePunctuation", // 15
"Japanese/IsIgnoreWhitespace", // 16
"Japanese/IsIgnoreProlongedSoundMark", // 17
"Japanese/IsIgnoreMiddleDot" // 18
"Japanese/IsIgnoreMiddleDot", // 18
"IsIgnoreDiacritics_CTL" // 19
};
const int nCount = SAL_N_ELEMENTS( aTranslitNames );
@@ -141,6 +143,8 @@ SvxSearchItem::SvxSearchItem( const sal_uInt16 nId ) :
rFlags |= TransliterationModules_IGNORE_CASE;
if ( aOpt.IsMatchFullHalfWidthForms())
rFlags |= TransliterationModules_IGNORE_WIDTH;
if ( aOpt.IsIgnoreDiacritics_CTL())
rFlags |= TransliterationModulesExtra::ignoreDiacritics_CTL ;
if ( bAsianOptions )
{
if ( aOpt.IsMatchHiraganaKatakana())

View File

@@ -33,8 +33,10 @@
#include <sfx2/viewsh.hxx>
#include <sfx2/basedlgs.hxx>
#include <svl/cjkoptions.hxx>
#include <svl/ctloptions.hxx>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/i18n/TransliterationModules.hpp>
#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
@@ -298,6 +300,7 @@ SvxSearchDialog::SvxSearchDialog( Window* pParent, SfxChildWindow* pChildWin, Sf
get(m_pCloseBtn, "close");
get(m_pIgnoreDiacritics, "ignorediacritics");
get(m_pSelectionBtn, "selection");
get(m_pBackwardsBtn, "backwards");
get(m_pRegExpBtn, "regexp");
@@ -415,7 +418,12 @@ void SvxSearchDialog::Construct_Impl()
{
m_pJapMatchFullHalfWidthCB->Hide();
}
SvtCTLOptions aCTLOptions;
if(!aCTLOptions.IsCTLFontEnabled())
{
m_pIgnoreDiacritics->Check( sal_False );
m_pIgnoreDiacritics->Hide();
}
//component extension - show component search buttons if the commands
// vnd.sun.star::SearchViaComponent1 and 2 are supported
const uno::Reference< frame::XFrame >xFrame = rBindings.GetActiveFrame();
@@ -499,6 +507,7 @@ sal_Bool SvxSearchDialog::Close()
aOpt.SetSimilaritySearch ( m_pSimilarityBox->IsChecked() );
aOpt.SetUseAsianOptions ( m_pJapOptionsCB->IsChecked() );
aOpt.SetNotes ( m_pNotesBtn->IsChecked() );
aOpt.SetIgnoreDiacritics_CTL ( m_pIgnoreDiacritics->IsChecked() );
const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
rBindings.GetDispatcher()->Execute( FID_SEARCH_OFF, SFX_CALLMODE_SLOT, ppArgs );
@@ -602,7 +611,7 @@ void SvxSearchDialog::InitControls_Impl()
m_pSimilarityBox->SetClickHdl( aLink );
m_pJapOptionsCB->SetClickHdl( aLink );
m_pJapMatchFullHalfWidthCB->SetClickHdl( aLink );
m_pIgnoreDiacritics->SetClickHdl( aLink );
m_pLayoutBtn->SetClickHdl( LINK( this, SvxSearchDialog, TemplateHdl_Impl ) );
m_pFormatBtn->SetClickHdl( LINK( this, SvxSearchDialog, FormatHdl_Impl ) );
m_pNoFormatBtn->SetClickHdl(
@@ -638,7 +647,7 @@ void SvxSearchDialog::ShowOptionalControls_Impl()
DBG_ASSERT( pSearchItem, "no search item" );
SvtCJKOptions aCJKOptions;
SvtCTLOptions aCTLOptions;
SvtModuleOptions::EFactory eFactory = getModule(rBindings);
bool bDrawApp = eFactory == SvtModuleOptions::E_DRAW;
bool bWriterApp =
@@ -654,7 +663,7 @@ void SvxSearchDialog::ShowOptionalControls_Impl()
m_pSimilarityBox->Show();
m_pSimilarityBtn->Show();
m_pSelectionBtn->Show();
m_pIgnoreDiacritics->Show(aCTLOptions.IsCTLFontEnabled());
m_pJapMatchFullHalfWidthCB->Show(aCJKOptions.IsCJKFontEnabled());
m_pJapOptionsCB->Show(aCJKOptions.IsJapaneseFindEnabled());
m_pJapOptionsBtn->Show(aCJKOptions.IsJapaneseFindEnabled());
@@ -708,6 +717,7 @@ void SvxSearchDialog::Init_Impl( int bSearchPattern )
// We don't want to save any intermediate state to the module while the
// dialog is being initialized.
ToggleSaveToModule aNoModuleSave(*this, false);
SvtSearchOptions aOpt;
bWriter = ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_WRITER );
@@ -755,6 +765,8 @@ void SvxSearchDialog::Init_Impl( int bSearchPattern )
m_pSimilarityBox->Check( pSearchItem->IsLevenshtein() );
if( m_pJapOptionsCB->IsVisible() )
m_pJapOptionsCB->Check( pSearchItem->IsUseAsianOptions() );
if (m_pIgnoreDiacritics->IsVisible())
m_pIgnoreDiacritics->Check( aOpt.IsIgnoreDiacritics_CTL() );
ApplyTransliterationFlags_Impl( pSearchItem->GetTransliterationFlags() );
ShowOptionalControls_Impl();
@@ -1243,12 +1255,13 @@ IMPL_LINK( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn )
pSearchItem->SetNotes(GetCheckBoxValue(m_pNotesBtn));
pSearchItem->SetPattern(GetCheckBoxValue(m_pLayoutBtn));
pSearchItem->SetSelection(GetCheckBoxValue(m_pSelectionBtn));
pSearchItem->SetUseAsianOptions(GetCheckBoxValue(m_pJapOptionsCB));
sal_Int32 nFlags = GetTransliterationFlags();
if( !pSearchItem->IsUseAsianOptions())
nFlags &= (TransliterationModules_IGNORE_CASE |
TransliterationModules_IGNORE_WIDTH );
if (GetCheckBoxValue(m_pIgnoreDiacritics))
nFlags |= TransliterationModulesExtra::ignoreDiacritics_CTL;
pSearchItem->SetTransliterationFlags( nFlags );
if ( !bWriter )
@@ -2227,12 +2240,17 @@ void SvxSearchDialog::SaveToModule_Impl()
pSearchItem->SetNotes(GetCheckBoxValue(m_pNotesBtn));
pSearchItem->SetPattern(GetCheckBoxValue(m_pLayoutBtn));
pSearchItem->SetSelection(GetCheckBoxValue(m_pSelectionBtn));
pSearchItem->SetUseAsianOptions(GetCheckBoxValue(m_pJapOptionsCB));
SvtSearchOptions aOpt;
aOpt.SetIgnoreDiacritics_CTL(GetCheckBoxValue(m_pIgnoreDiacritics));
sal_Int32 nFlags = GetTransliterationFlags();
if( !pSearchItem->IsUseAsianOptions())
nFlags &= (TransliterationModules_IGNORE_CASE |
TransliterationModules_IGNORE_WIDTH );
if (GetCheckBoxValue(m_pIgnoreDiacritics))
nFlags |= TransliterationModulesExtra::ignoreDiacritics_CTL;
pSearchItem->SetTransliterationFlags( nFlags );
if ( !bWriter )

View File

@@ -746,6 +746,23 @@
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="ignorediacritics">
<property name="label" translatable="yes">Ignore diacritics CTL</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>

View File

@@ -23,6 +23,7 @@
#include <tools/debug.hxx>
#include <unotools/configitem.hxx>
#include <com/sun/star/i18n/TransliterationModules.hpp>
#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/Any.h>
#include <rtl/logfile.hxx>
@@ -34,7 +35,7 @@ using namespace com::sun::star::uno;
using namespace com::sun::star::i18n;
#define MAX_FLAGS_OFFSET 25
#define MAX_FLAGS_OFFSET 26
//////////////////////////////////////////////////////////////////////
@@ -159,7 +160,8 @@ Sequence< OUString > SvtSearchOptions_Impl::GetPropertyNames() const
"Japanese/IsIgnoreWhitespace", // 22
"Japanese/IsIgnoreProlongedSoundMark", // 23
"Japanese/IsIgnoreMiddleDot", // 24
"IsNotes" // 25
"IsNotes", // 25
"IsIgnoreDiacritics_CTL" // 26
};
const int nCount = SAL_N_ELEMENTS( aPropNames );
@@ -308,7 +310,8 @@ sal_Int32 SvtSearchOptions::GetTransliterationFlags() const
nRes |= TransliterationModules_ignoreProlongedSoundMark_ja_JP;
if ( IsIgnoreMiddleDot())
nRes |= TransliterationModules_ignoreMiddleDot_ja_JP;
if ( IsIgnoreDiacritics_CTL())
nRes |= TransliterationModulesExtra::ignoreDiacritics_CTL;
return nRes;
}
@@ -616,6 +619,16 @@ void SvtSearchOptions::SetNotes( sal_Bool bVal )
pImpl->SetFlag( 25, bVal );
}
sal_Bool SvtSearchOptions::IsIgnoreDiacritics_CTL() const
{
return pImpl->GetFlag( 26 );
}
void SvtSearchOptions::SetIgnoreDiacritics_CTL( sal_Bool bVal )
{
pImpl->SetFlag( 26, bVal );
}
//////////////////////////////////////////////////////////////////////
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */