LCOV - code coverage report
Current view: top level - libreoffice/cui/source/options - optjsearch.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 262 0.4 %
Date: 2012-12-27 Functions: 2 10 20.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <tools/shl.hxx>
      21             : #include <unotools/searchopt.hxx>
      22             : #include <com/sun/star/i18n/TransliterationModules.hpp>
      23             : #include <cuires.hrc>
      24             : #include <dialmgr.hxx>
      25             : #include <optjsearch.hxx>
      26             : #include "optjsearch.hrc"
      27             : 
      28             : using namespace com::sun::star::i18n;
      29             : 
      30             : //////////////////////////////////////////////////////////////////////
      31             : 
      32           0 : SvxJSearchOptionsPage::SvxJSearchOptionsPage( Window* pParent, const SfxItemSet& rSet ) :
      33           0 :     SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_JSEARCH_OPTIONS ), rSet ),
      34             : 
      35           0 :     aTreatAsEqual               ( this, CUI_RES( FL_TREAT_AS_EQUAL ) ),
      36           0 :     aMatchCase                  ( this, CUI_RES( CB_MATCH_CASE ) ),
      37           0 :     aMatchFullHalfWidth         ( this, CUI_RES( CB_MATCH_FULL_HALF_WIDTH ) ),
      38           0 :     aMatchHiraganaKatakana      ( this, CUI_RES( CB_MATCH_HIRAGANA_KATAKANA ) ),
      39           0 :     aMatchContractions          ( this, CUI_RES( CB_MATCH_CONTRACTIONS ) ),
      40           0 :     aMatchMinusDashChoon        ( this, CUI_RES( CB_MATCH_MINUS_DASH_CHOON ) ),
      41           0 :     aMatchRepeatCharMarks       ( this, CUI_RES( CB_MATCH_REPEAT_CHAR_MARKS ) ),
      42           0 :     aMatchVariantFormKanji      ( this, CUI_RES( CB_MATCH_VARIANT_FORM_KANJI ) ),
      43           0 :     aMatchOldKanaForms          ( this, CUI_RES( CB_MATCH_OLD_KANA_FORMS ) ),
      44           0 :     aMatchDiziDuzu              ( this, CUI_RES( CB_MATCH_DIZI_DUZU ) ),
      45           0 :     aMatchBavaHafa              ( this, CUI_RES( CB_MATCH_BAVA_HAFA ) ),
      46           0 :     aMatchTsithichiDhizi        ( this, CUI_RES( CB_MATCH_TSITHICHI_DHIZI ) ),
      47           0 :     aMatchHyuiyuByuvyu          ( this, CUI_RES( CB_MATCH_HYUFYU_BYUVYU ) ),
      48           0 :     aMatchSesheZeje             ( this, CUI_RES( CB_MATCH_SESHE_ZEJE ) ),
      49           0 :     aMatchIaiya                 ( this, CUI_RES( CB_MATCH_IAIYA ) ),
      50           0 :     aMatchKiku                  ( this, CUI_RES( CB_MATCH_KIKU ) ),
      51           0 :     aMatchProlongedSoundMark    ( this, CUI_RES( CB_MATCH_PROLONGED_SOUNDMARK ) ),
      52           0 :     aIgnore                     ( this, CUI_RES( FL_IGNORE ) ),
      53           0 :     aIgnorePunctuation          ( this, CUI_RES( CB_IGNORE_PUNCTUATION ) ),
      54           0 :     aIgnoreWhitespace           ( this, CUI_RES( CB_IGNORE_WHITESPACES ) ),
      55           0 :     aIgnoreMiddleDot            ( this, CUI_RES( CB_IGNORE_MIDDLE_DOT ) )
      56             : {
      57           0 :     FreeResource();
      58           0 :     bSaveOptions = sal_True;
      59           0 :     nTransliterationFlags = 0x00000000;
      60           0 : }
      61             : 
      62             : 
      63           0 : SvxJSearchOptionsPage::~SvxJSearchOptionsPage()
      64             : {
      65           0 : }
      66             : 
      67             : 
      68           0 : SfxTabPage*  SvxJSearchOptionsPage::Create( Window* pParent, const SfxItemSet& rSet )
      69             : {
      70           0 :     return new SvxJSearchOptionsPage( pParent, rSet );
      71             : }
      72             : 
      73             : 
      74           0 : void SvxJSearchOptionsPage::SetTransliterationFlags( sal_Int32 nSettings )
      75             : {
      76           0 :     sal_Bool  bVal = 0 != (nSettings & TransliterationModules_IGNORE_CASE);
      77           0 :     aMatchCase               .Check( bVal );    //! treat as equal uppercase/lowercase
      78           0 :     bVal = 0 != (nSettings & TransliterationModules_IGNORE_WIDTH);
      79           0 :     aMatchFullHalfWidth      .Check( bVal );
      80           0 :     bVal = 0 != (nSettings & TransliterationModules_IGNORE_KANA);
      81           0 :     aMatchHiraganaKatakana   .Check( bVal );
      82           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreSize_ja_JP);
      83           0 :     aMatchContractions       .Check( bVal );
      84           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreMinusSign_ja_JP);
      85           0 :     aMatchMinusDashChoon     .Check( bVal );
      86           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreIterationMark_ja_JP);
      87           0 :     aMatchRepeatCharMarks    .Check( bVal );
      88           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreTraditionalKanji_ja_JP);
      89           0 :     aMatchVariantFormKanji   .Check( bVal );
      90           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreTraditionalKana_ja_JP);
      91           0 :     aMatchOldKanaForms       .Check( bVal );
      92           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreZiZu_ja_JP);
      93           0 :     aMatchDiziDuzu           .Check( bVal );
      94           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreBaFa_ja_JP);
      95           0 :     aMatchBavaHafa           .Check( bVal );
      96           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreTiJi_ja_JP);
      97           0 :     aMatchTsithichiDhizi     .Check( bVal );
      98           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreHyuByu_ja_JP);
      99           0 :     aMatchHyuiyuByuvyu       .Check( bVal );
     100           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreSeZe_ja_JP);
     101           0 :     aMatchSesheZeje          .Check( bVal );
     102           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreIandEfollowedByYa_ja_JP);
     103           0 :     aMatchIaiya              .Check( bVal );
     104           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreKiKuFollowedBySa_ja_JP);
     105           0 :     aMatchKiku               .Check( bVal );
     106           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreSeparator_ja_JP);
     107           0 :     aIgnorePunctuation       .Check( bVal );
     108           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreSpace_ja_JP);
     109           0 :     aIgnoreWhitespace        .Check( bVal );
     110           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreProlongedSoundMark_ja_JP);
     111           0 :     aMatchProlongedSoundMark.Check( bVal );
     112           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreMiddleDot_ja_JP);
     113           0 :     aIgnoreMiddleDot         .Check( bVal );
     114             : 
     115           0 :     nTransliterationFlags = nSettings;
     116           0 : }
     117             : 
     118             : 
     119           0 : sal_Int32 SvxJSearchOptionsPage::GetTransliterationFlags_Impl()
     120             : {
     121           0 :     sal_Int32 nTmp = 0;
     122           0 :     if (aMatchCase.IsChecked()) //! treat as equal uppercase/lowercase
     123           0 :         nTmp |= TransliterationModules_IGNORE_CASE;
     124           0 :     if (aMatchFullHalfWidth.IsChecked())
     125           0 :         nTmp |= TransliterationModules_IGNORE_WIDTH;
     126           0 :     if (aMatchHiraganaKatakana.IsChecked())
     127           0 :         nTmp |= TransliterationModules_IGNORE_KANA;
     128           0 :     if (aMatchContractions.IsChecked())
     129           0 :         nTmp |= TransliterationModules_ignoreSize_ja_JP;
     130           0 :     if (aMatchMinusDashChoon.IsChecked())
     131           0 :         nTmp |= TransliterationModules_ignoreMinusSign_ja_JP;
     132           0 :     if (aMatchRepeatCharMarks.IsChecked())
     133           0 :         nTmp |= TransliterationModules_ignoreIterationMark_ja_JP;
     134           0 :     if (aMatchVariantFormKanji.IsChecked())
     135           0 :         nTmp |= TransliterationModules_ignoreTraditionalKanji_ja_JP;
     136           0 :     if (aMatchOldKanaForms.IsChecked())
     137           0 :         nTmp |= TransliterationModules_ignoreTraditionalKana_ja_JP;
     138           0 :     if (aMatchDiziDuzu.IsChecked())
     139           0 :         nTmp |= TransliterationModules_ignoreZiZu_ja_JP;
     140           0 :     if (aMatchBavaHafa.IsChecked())
     141           0 :         nTmp |= TransliterationModules_ignoreBaFa_ja_JP;
     142           0 :     if (aMatchTsithichiDhizi.IsChecked())
     143           0 :         nTmp |= TransliterationModules_ignoreTiJi_ja_JP;
     144           0 :     if (aMatchHyuiyuByuvyu.IsChecked())
     145           0 :         nTmp |= TransliterationModules_ignoreHyuByu_ja_JP;
     146           0 :     if (aMatchSesheZeje.IsChecked())
     147           0 :         nTmp |= TransliterationModules_ignoreSeZe_ja_JP;
     148           0 :     if (aMatchIaiya.IsChecked())
     149           0 :         nTmp |= TransliterationModules_ignoreIandEfollowedByYa_ja_JP;
     150           0 :     if (aMatchKiku.IsChecked())
     151           0 :         nTmp |= TransliterationModules_ignoreKiKuFollowedBySa_ja_JP;
     152           0 :     if (aIgnorePunctuation.IsChecked())
     153           0 :         nTmp |= TransliterationModules_ignoreSeparator_ja_JP;
     154           0 :     if (aIgnoreWhitespace.IsChecked())
     155           0 :         nTmp |= TransliterationModules_ignoreSpace_ja_JP;
     156           0 :     if (aMatchProlongedSoundMark.IsChecked())
     157           0 :         nTmp |= TransliterationModules_ignoreProlongedSoundMark_ja_JP;
     158           0 :     if (aIgnoreMiddleDot.IsChecked())
     159           0 :         nTmp |= TransliterationModules_ignoreMiddleDot_ja_JP;
     160             : 
     161           0 :     nTransliterationFlags = nTmp;
     162           0 :     return nTransliterationFlags;
     163             : }
     164             : 
     165             : 
     166           0 : void SvxJSearchOptionsPage::Reset( const SfxItemSet& )
     167             : {
     168           0 :     SvtSearchOptions aOpt;
     169             : 
     170             :     // read settings from configuration
     171           0 :     aMatchCase               .Check(!aOpt.IsMatchCase() );  //! treat as equal uppercase/lowercase
     172           0 :     aMatchFullHalfWidth      .Check( aOpt.IsMatchFullHalfWidthForms() );
     173           0 :     aMatchHiraganaKatakana   .Check( aOpt.IsMatchHiraganaKatakana() );
     174           0 :     aMatchContractions       .Check( aOpt.IsMatchContractions() );
     175           0 :     aMatchMinusDashChoon     .Check( aOpt.IsMatchMinusDashChoon() );
     176           0 :     aMatchRepeatCharMarks    .Check( aOpt.IsMatchRepeatCharMarks() );
     177           0 :     aMatchVariantFormKanji   .Check( aOpt.IsMatchVariantFormKanji() );
     178           0 :     aMatchOldKanaForms       .Check( aOpt.IsMatchOldKanaForms() );
     179           0 :     aMatchDiziDuzu           .Check( aOpt.IsMatchDiziDuzu() );
     180           0 :     aMatchBavaHafa           .Check( aOpt.IsMatchBavaHafa() );
     181           0 :     aMatchTsithichiDhizi     .Check( aOpt.IsMatchTsithichiDhizi() );
     182           0 :     aMatchHyuiyuByuvyu       .Check( aOpt.IsMatchHyuiyuByuvyu() );
     183           0 :     aMatchSesheZeje          .Check( aOpt.IsMatchSesheZeje() );
     184           0 :     aMatchIaiya              .Check( aOpt.IsMatchIaiya() );
     185           0 :     aMatchKiku               .Check( aOpt.IsMatchKiku() );
     186           0 :     aIgnorePunctuation       .Check( aOpt.IsIgnorePunctuation() );
     187           0 :     aIgnoreWhitespace        .Check( aOpt.IsIgnoreWhitespace() );
     188           0 :     aMatchProlongedSoundMark .Check( aOpt.IsIgnoreProlongedSoundMark() );
     189           0 :     aIgnoreMiddleDot         .Check( aOpt.IsIgnoreMiddleDot() );
     190             : 
     191           0 :     nTransliterationFlags = GetTransliterationFlags_Impl();
     192             :     DBG_ASSERT( nTransliterationFlags == aOpt.GetTransliterationFlags(),
     193             :             "Transliteration settings different" );
     194             : 
     195           0 :     aMatchCase               .SaveValue();
     196           0 :     aMatchFullHalfWidth      .SaveValue();
     197           0 :     aMatchHiraganaKatakana   .SaveValue();
     198           0 :     aMatchContractions       .SaveValue();
     199           0 :     aMatchMinusDashChoon     .SaveValue();
     200           0 :     aMatchRepeatCharMarks    .SaveValue();
     201           0 :     aMatchVariantFormKanji   .SaveValue();
     202           0 :     aMatchOldKanaForms       .SaveValue();
     203           0 :     aMatchDiziDuzu           .SaveValue();
     204           0 :     aMatchBavaHafa           .SaveValue();
     205           0 :     aMatchTsithichiDhizi     .SaveValue();
     206           0 :     aMatchHyuiyuByuvyu       .SaveValue();
     207           0 :     aMatchSesheZeje          .SaveValue();
     208           0 :     aMatchIaiya              .SaveValue();
     209           0 :     aMatchKiku               .SaveValue();
     210           0 :     aIgnorePunctuation       .SaveValue();
     211           0 :     aIgnoreWhitespace        .SaveValue();
     212           0 :     aMatchProlongedSoundMark .SaveValue();
     213           0 :     aIgnoreMiddleDot         .SaveValue();
     214           0 : }
     215             : 
     216             : 
     217           0 : sal_Bool SvxJSearchOptionsPage::FillItemSet( SfxItemSet& )
     218             : {
     219           0 :     sal_Bool bModified = sal_False;
     220             : 
     221           0 :     sal_Int32 nOldVal = nTransliterationFlags;
     222           0 :     nTransliterationFlags = GetTransliterationFlags_Impl();
     223           0 :     bModified = nOldVal != nTransliterationFlags;
     224             : 
     225           0 :     if (!IsSaveOptions())
     226           0 :         return bModified;
     227             : 
     228           0 :     bModified = sal_False;
     229           0 :     SvtSearchOptions aOpt;
     230             :     sal_Bool bNewVal, bChanged;
     231             : 
     232           0 :     bNewVal  = aMatchCase.IsChecked();  //! treat as equal uppercase/lowercase
     233           0 :     bChanged = bNewVal != aMatchCase.GetSavedValue();
     234           0 :     if (bChanged)
     235             :     {
     236           0 :         aOpt.SetMatchCase(!bNewVal );
     237           0 :         bModified = sal_True;
     238             :     }
     239           0 :     bNewVal  = aMatchFullHalfWidth.IsChecked();
     240           0 :     bChanged = bNewVal != aMatchFullHalfWidth.GetSavedValue();
     241           0 :     if (bChanged)
     242             :     {
     243           0 :         aOpt.SetMatchFullHalfWidthForms( bNewVal );
     244           0 :         bModified = sal_True;
     245             :     }
     246           0 :     bNewVal  = aMatchHiraganaKatakana.IsChecked();
     247           0 :     bChanged = bNewVal != aMatchHiraganaKatakana.GetSavedValue();
     248           0 :     if (bChanged)
     249             :     {
     250           0 :         aOpt.SetMatchHiraganaKatakana( bNewVal );
     251           0 :         bModified = sal_True;
     252             :     }
     253           0 :     bNewVal  = aMatchContractions.IsChecked();
     254           0 :     bChanged = bNewVal != aMatchContractions.GetSavedValue();
     255           0 :     if (bChanged)
     256             :     {
     257           0 :         aOpt.SetMatchContractions( bNewVal );
     258           0 :         bModified = sal_True;
     259             :     }
     260           0 :     bNewVal  = aMatchMinusDashChoon.IsChecked();
     261           0 :     bChanged = bNewVal != aMatchMinusDashChoon.GetSavedValue();
     262           0 :     if (bChanged)
     263             :     {
     264           0 :         aOpt.SetMatchMinusDashChoon( bNewVal );
     265           0 :         bModified = sal_True;
     266             :     }
     267           0 :     bNewVal  = aMatchRepeatCharMarks.IsChecked();
     268           0 :     bChanged = bNewVal != aMatchRepeatCharMarks.GetSavedValue();
     269           0 :     if (bChanged)
     270             :     {
     271           0 :         aOpt.SetMatchRepeatCharMarks( bNewVal );
     272           0 :         bModified = sal_True;
     273             :     }
     274           0 :     bNewVal  = aMatchVariantFormKanji.IsChecked();
     275           0 :     bChanged = bNewVal != aMatchVariantFormKanji.GetSavedValue();
     276           0 :     if (bChanged)
     277             :     {
     278           0 :         aOpt.SetMatchVariantFormKanji( bNewVal );
     279           0 :         bModified = sal_True;
     280             :     }
     281           0 :     bNewVal  = aMatchOldKanaForms.IsChecked();
     282           0 :     bChanged = bNewVal != aMatchOldKanaForms.GetSavedValue();
     283           0 :     if (bChanged)
     284             :     {
     285           0 :         aOpt.SetMatchOldKanaForms( bNewVal );
     286           0 :         bModified = sal_True;
     287             :     }
     288           0 :     bNewVal  = aMatchDiziDuzu.IsChecked();
     289           0 :     bChanged = bNewVal != aMatchDiziDuzu.GetSavedValue();
     290           0 :     if (bChanged)
     291             :     {
     292           0 :         aOpt.SetMatchDiziDuzu( bNewVal );
     293           0 :         bModified = sal_True;
     294             :     }
     295           0 :     bNewVal  = aMatchBavaHafa.IsChecked();
     296           0 :     bChanged = bNewVal != aMatchBavaHafa.GetSavedValue();
     297           0 :     if (bChanged)
     298             :     {
     299           0 :         aOpt.SetMatchBavaHafa( bNewVal );
     300           0 :         bModified = sal_True;
     301             :     }
     302           0 :     bNewVal  = aMatchTsithichiDhizi.IsChecked();
     303           0 :     bChanged = bNewVal != aMatchTsithichiDhizi.GetSavedValue();
     304           0 :     if (bChanged)
     305             :     {
     306           0 :         aOpt.SetMatchTsithichiDhizi( bNewVal );
     307           0 :         bModified = sal_True;
     308             :     }
     309           0 :     bNewVal  = aMatchHyuiyuByuvyu.IsChecked();
     310           0 :     bChanged = bNewVal != aMatchHyuiyuByuvyu.GetSavedValue();
     311           0 :     if (bChanged)
     312             :     {
     313           0 :         aOpt.SetMatchHyuiyuByuvyu( bNewVal );
     314           0 :         bModified = sal_True;
     315             :     }
     316           0 :     bNewVal  = aMatchSesheZeje.IsChecked();
     317           0 :     bChanged = bNewVal != aMatchSesheZeje.GetSavedValue();
     318           0 :     if (bChanged)
     319             :     {
     320           0 :         aOpt.SetMatchSesheZeje( bNewVal );
     321           0 :         bModified = sal_True;
     322             :     }
     323           0 :     bNewVal  = aMatchIaiya.IsChecked();
     324           0 :     bChanged = bNewVal != aMatchIaiya.GetSavedValue();
     325           0 :     if (bChanged)
     326             :     {
     327           0 :         aOpt.SetMatchIaiya( bNewVal );
     328           0 :         bModified = sal_True;
     329             :     }
     330           0 :     bNewVal  = aMatchKiku.IsChecked();
     331           0 :     bChanged = bNewVal != aMatchKiku.GetSavedValue();
     332           0 :     if (bChanged)
     333             :     {
     334           0 :         aOpt.SetMatchKiku( bNewVal );
     335           0 :         bModified = sal_True;
     336             :     }
     337           0 :     bNewVal  = aIgnorePunctuation.IsChecked();
     338           0 :     bChanged = bNewVal != aIgnorePunctuation.GetSavedValue();
     339           0 :     if (bChanged)
     340             :     {
     341           0 :         aOpt.SetIgnorePunctuation( bNewVal );
     342           0 :         bModified = sal_True;
     343             :     }
     344           0 :     bNewVal  = aIgnoreWhitespace.IsChecked();
     345           0 :     bChanged = bNewVal != aIgnoreWhitespace.GetSavedValue();
     346           0 :     if (bChanged)
     347             :     {
     348           0 :         aOpt.SetIgnoreWhitespace( bNewVal );
     349           0 :         bModified = sal_True;
     350             :     }
     351           0 :     bNewVal  = aMatchProlongedSoundMark.IsChecked();
     352           0 :     bChanged = bNewVal != aMatchProlongedSoundMark.GetSavedValue();
     353           0 :     if (bChanged)
     354             :     {
     355           0 :         aOpt.SetIgnoreProlongedSoundMark( bNewVal );
     356           0 :         bModified = sal_True;
     357             :     }
     358           0 :     bNewVal  = aIgnoreMiddleDot.IsChecked();
     359           0 :     bChanged = bNewVal != aIgnoreMiddleDot.GetSavedValue();
     360           0 :     if (bChanged)
     361             :     {
     362           0 :         aOpt.SetIgnoreMiddleDot( bNewVal );
     363           0 :         bModified = sal_True;
     364             :     }
     365             : 
     366           0 :     return bModified;
     367           3 : }
     368             : 
     369             : 
     370             : //////////////////////////////////////////////////////////////////////
     371             : 
     372             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10