LCOV - code coverage report
Current view: top level - cui/source/options - optjsearch.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 283 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 11 0.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 <unotools/searchopt.hxx>
      21             : #include <com/sun/star/i18n/TransliterationModules.hpp>
      22             : #include <cuires.hrc>
      23             : #include <dialmgr.hxx>
      24             : #include <optjsearch.hxx>
      25             : 
      26             : using namespace com::sun::star::i18n;
      27             : 
      28             : 
      29             : 
      30           0 : SvxJSearchOptionsPage::SvxJSearchOptionsPage( vcl::Window* pParent, const SfxItemSet& rSet ) :
      31           0 :     SfxTabPage( pParent, "OptJSearchPage", "cui/ui/optjsearchpage.ui", &rSet )
      32             : {
      33           0 :     get( m_pMatchCase, "matchcase");
      34           0 :     get( m_pMatchFullHalfWidth, "matchfullhalfwidth");
      35           0 :     get( m_pMatchHiraganaKatakana, "matchhiraganakatakana");
      36           0 :     get( m_pMatchContractions, "matchcontractions");
      37           0 :     get( m_pMatchMinusDashChoon, "matchminusdashchoon");
      38           0 :     get( m_pMatchRepeatCharMarks, "matchrepeatcharmarks");
      39           0 :     get( m_pMatchVariantFormKanji, "matchvariantformkanji");
      40           0 :     get( m_pMatchOldKanaForms, "matcholdkanaforms");
      41           0 :     get( m_pMatchDiziDuzu, "matchdiziduzu");
      42           0 :     get( m_pMatchBavaHafa, "matchbavahafa");
      43           0 :     get( m_pMatchTsithichiDhizi, "matchtsithichidhizi");
      44           0 :     get( m_pMatchHyuiyuByuvyu, "matchhyuiyubyuvyu");
      45           0 :     get( m_pMatchSesheZeje, "matchseshezeje");
      46           0 :     get( m_pMatchIaiya, "matchiaiya");
      47           0 :     get( m_pMatchKiku, "matchkiku");
      48           0 :     get( m_pMatchProlongedSoundMark, "matchprolongedsoundmark");
      49             : 
      50           0 :     get( m_pIgnorePunctuation, "ignorepunctuation");
      51           0 :     get( m_pIgnoreWhitespace, "ignorewhitespace");
      52           0 :     get( m_pIgnoreMiddleDot, "ignoremiddledot");
      53             : 
      54           0 :     bSaveOptions = true;
      55           0 :     nTransliterationFlags = 0x00000000;
      56           0 : }
      57             : 
      58           0 : SvxJSearchOptionsPage::~SvxJSearchOptionsPage()
      59             : {
      60           0 :     disposeOnce();
      61           0 : }
      62             : 
      63           0 : void SvxJSearchOptionsPage::dispose()
      64             : {
      65           0 :     m_pMatchCase.clear();
      66           0 :     m_pMatchFullHalfWidth.clear();
      67           0 :     m_pMatchHiraganaKatakana.clear();
      68           0 :     m_pMatchContractions.clear();
      69           0 :     m_pMatchMinusDashChoon.clear();
      70           0 :     m_pMatchRepeatCharMarks.clear();
      71           0 :     m_pMatchVariantFormKanji.clear();
      72           0 :     m_pMatchOldKanaForms.clear();
      73           0 :     m_pMatchDiziDuzu.clear();
      74           0 :     m_pMatchBavaHafa.clear();
      75           0 :     m_pMatchTsithichiDhizi.clear();
      76           0 :     m_pMatchHyuiyuByuvyu.clear();
      77           0 :     m_pMatchSesheZeje.clear();
      78           0 :     m_pMatchIaiya.clear();
      79           0 :     m_pMatchKiku.clear();
      80           0 :     m_pMatchProlongedSoundMark.clear();
      81           0 :     m_pIgnorePunctuation.clear();
      82           0 :     m_pIgnoreWhitespace.clear();
      83           0 :     m_pIgnoreMiddleDot.clear();
      84           0 :     SfxTabPage::dispose();
      85           0 : }
      86             : 
      87           0 : VclPtr<SfxTabPage> SvxJSearchOptionsPage::Create( vcl::Window* pParent, const SfxItemSet* rSet )
      88             : {
      89           0 :     return VclPtr<SvxJSearchOptionsPage>::Create( pParent, *rSet );
      90             : }
      91             : 
      92             : 
      93           0 : void SvxJSearchOptionsPage::SetTransliterationFlags( sal_Int32 nSettings )
      94             : {
      95           0 :     bool  bVal = 0 != (nSettings & TransliterationModules_IGNORE_CASE);
      96           0 :     m_pMatchCase              ->Check( bVal );    //! treat as equal uppercase/lowercase
      97           0 :     bVal = 0 != (nSettings & TransliterationModules_IGNORE_WIDTH);
      98           0 :     m_pMatchFullHalfWidth     ->Check( bVal );
      99           0 :     bVal = 0 != (nSettings & TransliterationModules_IGNORE_KANA);
     100           0 :     m_pMatchHiraganaKatakana  ->Check( bVal );
     101           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreSize_ja_JP);
     102           0 :     m_pMatchContractions      ->Check( bVal );
     103           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreMinusSign_ja_JP);
     104           0 :     m_pMatchMinusDashChoon    ->Check( bVal );
     105           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreIterationMark_ja_JP);
     106           0 :     m_pMatchRepeatCharMarks   ->Check( bVal );
     107           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreTraditionalKanji_ja_JP);
     108           0 :     m_pMatchVariantFormKanji  ->Check( bVal );
     109           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreTraditionalKana_ja_JP);
     110           0 :     m_pMatchOldKanaForms      ->Check( bVal );
     111           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreZiZu_ja_JP);
     112           0 :     m_pMatchDiziDuzu          ->Check( bVal );
     113           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreBaFa_ja_JP);
     114           0 :     m_pMatchBavaHafa          ->Check( bVal );
     115           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreTiJi_ja_JP);
     116           0 :     m_pMatchTsithichiDhizi    ->Check( bVal );
     117           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreHyuByu_ja_JP);
     118           0 :     m_pMatchHyuiyuByuvyu      ->Check( bVal );
     119           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreSeZe_ja_JP);
     120           0 :     m_pMatchSesheZeje         ->Check( bVal );
     121           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreIandEfollowedByYa_ja_JP);
     122           0 :     m_pMatchIaiya             ->Check( bVal );
     123           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreKiKuFollowedBySa_ja_JP);
     124           0 :     m_pMatchKiku              ->Check( bVal );
     125           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreSeparator_ja_JP);
     126           0 :     m_pIgnorePunctuation      ->Check( bVal );
     127           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreSpace_ja_JP);
     128           0 :     m_pIgnoreWhitespace       ->Check( bVal );
     129           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreProlongedSoundMark_ja_JP);
     130           0 :     m_pMatchProlongedSoundMark->Check( bVal );
     131           0 :     bVal = 0 != (nSettings & TransliterationModules_ignoreMiddleDot_ja_JP);
     132           0 :     m_pIgnoreMiddleDot        ->Check( bVal );
     133             : 
     134           0 :     nTransliterationFlags = nSettings;
     135           0 : }
     136             : 
     137             : 
     138           0 : sal_Int32 SvxJSearchOptionsPage::GetTransliterationFlags_Impl()
     139             : {
     140           0 :     sal_Int32 nTmp = 0;
     141           0 :     if (m_pMatchCase->IsChecked()) //! treat as equal uppercase/lowercase
     142           0 :         nTmp |= TransliterationModules_IGNORE_CASE;
     143           0 :     if (m_pMatchFullHalfWidth->IsChecked())
     144           0 :         nTmp |= TransliterationModules_IGNORE_WIDTH;
     145           0 :     if (m_pMatchHiraganaKatakana->IsChecked())
     146           0 :         nTmp |= TransliterationModules_IGNORE_KANA;
     147           0 :     if (m_pMatchContractions->IsChecked())
     148           0 :         nTmp |= TransliterationModules_ignoreSize_ja_JP;
     149           0 :     if (m_pMatchMinusDashChoon->IsChecked())
     150           0 :         nTmp |= TransliterationModules_ignoreMinusSign_ja_JP;
     151           0 :     if (m_pMatchRepeatCharMarks->IsChecked())
     152           0 :         nTmp |= TransliterationModules_ignoreIterationMark_ja_JP;
     153           0 :     if (m_pMatchVariantFormKanji->IsChecked())
     154           0 :         nTmp |= TransliterationModules_ignoreTraditionalKanji_ja_JP;
     155           0 :     if (m_pMatchOldKanaForms->IsChecked())
     156           0 :         nTmp |= TransliterationModules_ignoreTraditionalKana_ja_JP;
     157           0 :     if (m_pMatchDiziDuzu->IsChecked())
     158           0 :         nTmp |= TransliterationModules_ignoreZiZu_ja_JP;
     159           0 :     if (m_pMatchBavaHafa->IsChecked())
     160           0 :         nTmp |= TransliterationModules_ignoreBaFa_ja_JP;
     161           0 :     if (m_pMatchTsithichiDhizi->IsChecked())
     162           0 :         nTmp |= TransliterationModules_ignoreTiJi_ja_JP;
     163           0 :     if (m_pMatchHyuiyuByuvyu->IsChecked())
     164           0 :         nTmp |= TransliterationModules_ignoreHyuByu_ja_JP;
     165           0 :     if (m_pMatchSesheZeje->IsChecked())
     166           0 :         nTmp |= TransliterationModules_ignoreSeZe_ja_JP;
     167           0 :     if (m_pMatchIaiya->IsChecked())
     168           0 :         nTmp |= TransliterationModules_ignoreIandEfollowedByYa_ja_JP;
     169           0 :     if (m_pMatchKiku->IsChecked())
     170           0 :         nTmp |= TransliterationModules_ignoreKiKuFollowedBySa_ja_JP;
     171           0 :     if (m_pIgnorePunctuation->IsChecked())
     172           0 :         nTmp |= TransliterationModules_ignoreSeparator_ja_JP;
     173           0 :     if (m_pIgnoreWhitespace->IsChecked())
     174           0 :         nTmp |= TransliterationModules_ignoreSpace_ja_JP;
     175           0 :     if (m_pMatchProlongedSoundMark->IsChecked())
     176           0 :         nTmp |= TransliterationModules_ignoreProlongedSoundMark_ja_JP;
     177           0 :     if (m_pIgnoreMiddleDot->IsChecked())
     178           0 :         nTmp |= TransliterationModules_ignoreMiddleDot_ja_JP;
     179             : 
     180           0 :     nTransliterationFlags = nTmp;
     181           0 :     return nTransliterationFlags;
     182             : }
     183             : 
     184             : 
     185           0 : void SvxJSearchOptionsPage::Reset( const SfxItemSet* )
     186             : {
     187           0 :     SvtSearchOptions aOpt;
     188             : 
     189             :     // read settings from configuration
     190           0 :     m_pMatchCase               ->Check(!aOpt.IsMatchCase() );  //! treat as equal uppercase/lowercase
     191           0 :     m_pMatchFullHalfWidth      ->Check( aOpt.IsMatchFullHalfWidthForms() );
     192           0 :     m_pMatchHiraganaKatakana   ->Check( aOpt.IsMatchHiraganaKatakana() );
     193           0 :     m_pMatchContractions       ->Check( aOpt.IsMatchContractions() );
     194           0 :     m_pMatchMinusDashChoon     ->Check( aOpt.IsMatchMinusDashChoon() );
     195           0 :     m_pMatchRepeatCharMarks    ->Check( aOpt.IsMatchRepeatCharMarks() );
     196           0 :     m_pMatchVariantFormKanji   ->Check( aOpt.IsMatchVariantFormKanji() );
     197           0 :     m_pMatchOldKanaForms       ->Check( aOpt.IsMatchOldKanaForms() );
     198           0 :     m_pMatchDiziDuzu           ->Check( aOpt.IsMatchDiziDuzu() );
     199           0 :     m_pMatchBavaHafa           ->Check( aOpt.IsMatchBavaHafa() );
     200           0 :     m_pMatchTsithichiDhizi     ->Check( aOpt.IsMatchTsithichiDhizi() );
     201           0 :     m_pMatchHyuiyuByuvyu       ->Check( aOpt.IsMatchHyuiyuByuvyu() );
     202           0 :     m_pMatchSesheZeje          ->Check( aOpt.IsMatchSesheZeje() );
     203           0 :     m_pMatchIaiya              ->Check( aOpt.IsMatchIaiya() );
     204           0 :     m_pMatchKiku               ->Check( aOpt.IsMatchKiku() );
     205           0 :     m_pIgnorePunctuation       ->Check( aOpt.IsIgnorePunctuation() );
     206           0 :     m_pIgnoreWhitespace        ->Check( aOpt.IsIgnoreWhitespace() );
     207           0 :     m_pMatchProlongedSoundMark ->Check( aOpt.IsIgnoreProlongedSoundMark() );
     208           0 :     m_pIgnoreMiddleDot         ->Check( aOpt.IsIgnoreMiddleDot() );
     209             : 
     210           0 :     nTransliterationFlags = GetTransliterationFlags_Impl();
     211             :     DBG_ASSERT( nTransliterationFlags == aOpt.GetTransliterationFlags(),
     212             :             "Transliteration settings different" );
     213             : 
     214           0 :     m_pMatchCase               ->SaveValue();
     215           0 :     m_pMatchFullHalfWidth      ->SaveValue();
     216           0 :     m_pMatchHiraganaKatakana   ->SaveValue();
     217           0 :     m_pMatchContractions       ->SaveValue();
     218           0 :     m_pMatchMinusDashChoon     ->SaveValue();
     219           0 :     m_pMatchRepeatCharMarks    ->SaveValue();
     220           0 :     m_pMatchVariantFormKanji   ->SaveValue();
     221           0 :     m_pMatchOldKanaForms       ->SaveValue();
     222           0 :     m_pMatchDiziDuzu           ->SaveValue();
     223           0 :     m_pMatchBavaHafa           ->SaveValue();
     224           0 :     m_pMatchTsithichiDhizi     ->SaveValue();
     225           0 :     m_pMatchHyuiyuByuvyu       ->SaveValue();
     226           0 :     m_pMatchSesheZeje          ->SaveValue();
     227           0 :     m_pMatchIaiya              ->SaveValue();
     228           0 :     m_pMatchKiku               ->SaveValue();
     229           0 :     m_pIgnorePunctuation       ->SaveValue();
     230           0 :     m_pIgnoreWhitespace        ->SaveValue();
     231           0 :     m_pMatchProlongedSoundMark ->SaveValue();
     232           0 :     m_pIgnoreMiddleDot         ->SaveValue();
     233           0 : }
     234             : 
     235             : 
     236           0 : bool SvxJSearchOptionsPage::FillItemSet( SfxItemSet* )
     237             : {
     238           0 :     sal_Int32 nOldVal = nTransliterationFlags;
     239           0 :     nTransliterationFlags = GetTransliterationFlags_Impl();
     240           0 :     bool bModified = nOldVal != nTransliterationFlags;
     241             : 
     242           0 :     if (!IsSaveOptions())
     243           0 :         return bModified;
     244             : 
     245           0 :     bModified = false;
     246           0 :     SvtSearchOptions aOpt;
     247             :     bool bNewVal, bChanged;
     248             : 
     249           0 :     bNewVal  = m_pMatchCase->IsChecked();  //! treat as equal uppercase/lowercase
     250           0 :     bChanged = m_pMatchCase->IsValueChangedFromSaved();
     251           0 :     if (bChanged)
     252             :     {
     253           0 :         aOpt.SetMatchCase(!bNewVal );
     254           0 :         bModified = true;
     255             :     }
     256           0 :     bNewVal  = m_pMatchFullHalfWidth->IsChecked();
     257           0 :     bChanged = m_pMatchFullHalfWidth->IsValueChangedFromSaved();
     258           0 :     if (bChanged)
     259             :     {
     260           0 :         aOpt.SetMatchFullHalfWidthForms( bNewVal );
     261           0 :         bModified = true;
     262             :     }
     263           0 :     bNewVal  = m_pMatchHiraganaKatakana->IsChecked();
     264           0 :     bChanged = m_pMatchHiraganaKatakana->IsValueChangedFromSaved();
     265           0 :     if (bChanged)
     266             :     {
     267           0 :         aOpt.SetMatchHiraganaKatakana( bNewVal );
     268           0 :         bModified = true;
     269             :     }
     270           0 :     bNewVal  = m_pMatchContractions->IsChecked();
     271           0 :     bChanged = m_pMatchContractions->IsValueChangedFromSaved();
     272           0 :     if (bChanged)
     273             :     {
     274           0 :         aOpt.SetMatchContractions( bNewVal );
     275           0 :         bModified = true;
     276             :     }
     277           0 :     bNewVal  = m_pMatchMinusDashChoon->IsChecked();
     278           0 :     bChanged = m_pMatchMinusDashChoon->IsValueChangedFromSaved();
     279           0 :     if (bChanged)
     280             :     {
     281           0 :         aOpt.SetMatchMinusDashChoon( bNewVal );
     282           0 :         bModified = true;
     283             :     }
     284           0 :     bNewVal  = m_pMatchRepeatCharMarks->IsChecked();
     285           0 :     bChanged = m_pMatchRepeatCharMarks->IsValueChangedFromSaved();
     286           0 :     if (bChanged)
     287             :     {
     288           0 :         aOpt.SetMatchRepeatCharMarks( bNewVal );
     289           0 :         bModified = true;
     290             :     }
     291           0 :     bNewVal  = m_pMatchVariantFormKanji->IsChecked();
     292           0 :     bChanged = m_pMatchVariantFormKanji->IsValueChangedFromSaved();
     293           0 :     if (bChanged)
     294             :     {
     295           0 :         aOpt.SetMatchVariantFormKanji( bNewVal );
     296           0 :         bModified = true;
     297             :     }
     298           0 :     bNewVal  = m_pMatchOldKanaForms->IsChecked();
     299           0 :     bChanged = m_pMatchOldKanaForms->IsValueChangedFromSaved();
     300           0 :     if (bChanged)
     301             :     {
     302           0 :         aOpt.SetMatchOldKanaForms( bNewVal );
     303           0 :         bModified = true;
     304             :     }
     305           0 :     bNewVal  = m_pMatchDiziDuzu->IsChecked();
     306           0 :     bChanged = m_pMatchDiziDuzu->IsValueChangedFromSaved();
     307           0 :     if (bChanged)
     308             :     {
     309           0 :         aOpt.SetMatchDiziDuzu( bNewVal );
     310           0 :         bModified = true;
     311             :     }
     312           0 :     bNewVal  = m_pMatchBavaHafa->IsChecked();
     313           0 :     bChanged = m_pMatchBavaHafa->IsValueChangedFromSaved();
     314           0 :     if (bChanged)
     315             :     {
     316           0 :         aOpt.SetMatchBavaHafa( bNewVal );
     317           0 :         bModified = true;
     318             :     }
     319           0 :     bNewVal  = m_pMatchTsithichiDhizi->IsChecked();
     320           0 :     bChanged = m_pMatchTsithichiDhizi->IsValueChangedFromSaved();
     321           0 :     if (bChanged)
     322             :     {
     323           0 :         aOpt.SetMatchTsithichiDhizi( bNewVal );
     324           0 :         bModified = true;
     325             :     }
     326           0 :     bNewVal  = m_pMatchHyuiyuByuvyu->IsChecked();
     327           0 :     bChanged = m_pMatchHyuiyuByuvyu->IsValueChangedFromSaved();
     328           0 :     if (bChanged)
     329             :     {
     330           0 :         aOpt.SetMatchHyuiyuByuvyu( bNewVal );
     331           0 :         bModified = true;
     332             :     }
     333           0 :     bNewVal  = m_pMatchSesheZeje->IsChecked();
     334           0 :     bChanged = m_pMatchSesheZeje->IsValueChangedFromSaved();
     335           0 :     if (bChanged)
     336             :     {
     337           0 :         aOpt.SetMatchSesheZeje( bNewVal );
     338           0 :         bModified = true;
     339             :     }
     340           0 :     bNewVal  = m_pMatchIaiya->IsChecked();
     341           0 :     bChanged = m_pMatchIaiya->IsValueChangedFromSaved();
     342           0 :     if (bChanged)
     343             :     {
     344           0 :         aOpt.SetMatchIaiya( bNewVal );
     345           0 :         bModified = true;
     346             :     }
     347           0 :     bNewVal  = m_pMatchKiku->IsChecked();
     348           0 :     bChanged = m_pMatchKiku->IsValueChangedFromSaved();
     349           0 :     if (bChanged)
     350             :     {
     351           0 :         aOpt.SetMatchKiku( bNewVal );
     352           0 :         bModified = true;
     353             :     }
     354           0 :     bNewVal  = m_pIgnorePunctuation->IsChecked();
     355           0 :     bChanged = m_pIgnorePunctuation->IsValueChangedFromSaved();
     356           0 :     if (bChanged)
     357             :     {
     358           0 :         aOpt.SetIgnorePunctuation( bNewVal );
     359           0 :         bModified = true;
     360             :     }
     361           0 :     bNewVal  = m_pIgnoreWhitespace->IsChecked();
     362           0 :     bChanged = m_pIgnoreWhitespace->IsValueChangedFromSaved();
     363           0 :     if (bChanged)
     364             :     {
     365           0 :         aOpt.SetIgnoreWhitespace( bNewVal );
     366           0 :         bModified = true;
     367             :     }
     368           0 :     bNewVal  = m_pMatchProlongedSoundMark->IsChecked();
     369           0 :     bChanged = m_pMatchProlongedSoundMark->IsValueChangedFromSaved();
     370           0 :     if (bChanged)
     371             :     {
     372           0 :         aOpt.SetIgnoreProlongedSoundMark( bNewVal );
     373           0 :         bModified = true;
     374             :     }
     375           0 :     bNewVal  = m_pIgnoreMiddleDot->IsChecked();
     376           0 :     bChanged = m_pIgnoreMiddleDot->IsValueChangedFromSaved();
     377           0 :     if (bChanged)
     378             :     {
     379           0 :         aOpt.SetIgnoreMiddleDot( bNewVal );
     380           0 :         bModified = true;
     381             :     }
     382             : 
     383           0 :     if (bModified)
     384           0 :         aOpt.Commit();
     385             : 
     386           0 :     return bModified;
     387           0 : }
     388             : 
     389             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11