LCOV - code coverage report
Current view: top level - editeng/source/misc - splwrap.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 68 251 27.1 %
Date: 2012-08-25 Functions: 8 28 28.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 62 546 11.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include<rtl/ustring.hxx>
      30                 :            : #include <tools/shl.hxx>
      31                 :            : #include <vcl/wrkwin.hxx>
      32                 :            : #include <vcl/svapp.hxx>
      33                 :            : #include <vcl/msgbox.hxx>
      34                 :            : #include <svtools/langtab.hxx>
      35                 :            : 
      36                 :            : #ifndef __RSC
      37                 :            : #include <tools/errinf.hxx>
      38                 :            : #endif
      39                 :            : #include <editeng/unolingu.hxx>
      40                 :            : #include <linguistic/lngprops.hxx>
      41                 :            : #include <com/sun/star/frame/XStorable.hpp>
      42                 :            : 
      43                 :            : #include <map>
      44                 :            : 
      45                 :            : #include <editeng/svxenum.hxx>
      46                 :            : #include <editeng/splwrap.hxx>
      47                 :            : #include <editeng/edtdlg.hxx>
      48                 :            : #include <editeng/eerdll.hxx>
      49                 :            : #include <editeng/editrids.hrc>
      50                 :            : #include <editeng/editids.hrc>
      51                 :            : #include <editeng/editerr.hxx>
      52                 :            : 
      53                 :            : #define WAIT_ON() if(pWin != NULL) { pWin->EnterWait(); }
      54                 :            : 
      55                 :            : #define WAIT_OFF() if(pWin != NULL) { pWin->LeaveWait(); }
      56                 :            : 
      57                 :            : using namespace ::com::sun::star;
      58                 :            : using namespace ::com::sun::star::uno;
      59                 :            : using namespace ::com::sun::star::beans;
      60                 :            : using namespace ::com::sun::star::linguistic2;
      61                 :            : 
      62                 :            : 
      63                 :            : // misc functions ---------------------------------------------
      64                 :            : 
      65                 :          0 : void SvxPrepareAutoCorrect( String &rOldText, String &rNewText )
      66                 :            : {
      67                 :            :     // This function should be used to strip (or add) trailing '.' from
      68                 :            :     // the strings before passing them on to the autocorrect function in
      69                 :            :     // order that the autocorrect function will hopefully
      70                 :            :     // works properly with normal words and abbreviations (with trailing '.')
      71                 :            :     // independ of if they are at the end of the sentence or not.
      72                 :            :     //
      73                 :            :     // rOldText: text to be replaced
      74                 :            :     // rNewText: replacement text
      75                 :            : 
      76                 :          0 :     xub_StrLen  nOldLen = rOldText.Len(),
      77                 :          0 :                 nNewLen = rNewText.Len();
      78 [ #  # ][ #  # ]:          0 :     if (nOldLen && nNewLen)
      79                 :            :     {
      80                 :          0 :         sal_Bool bOldHasDot = sal_Unicode( '.' ) == rOldText.GetChar( nOldLen - 1 ),
      81                 :          0 :              bNewHasDot = sal_Unicode( '.' ) == rNewText.GetChar( nNewLen - 1 );
      82 [ #  # ][ #  # ]:          0 :         if (bOldHasDot && !bNewHasDot
      83                 :            :             /*this is: !(bOldHasDot && bNewHasDot) && bOldHasDot*/)
      84                 :          0 :             rOldText.Erase( nOldLen - 1 );
      85                 :            :     }
      86                 :          0 : }
      87                 :            : 
      88                 :            : #define SVX_LANG_NEED_CHECK         0
      89                 :            : #define SVX_LANG_OK                 1
      90                 :            : #define SVX_LANG_MISSING            2
      91                 :            : #define SVX_LANG_MISSING_DO_WARN    3
      92                 :            : 
      93                 :            : struct lt_LanguageType
      94                 :            : {
      95                 :          0 :     bool operator()( LanguageType n1, LanguageType n2 ) const
      96                 :            :     {
      97                 :          0 :         return n1 < n2;
      98                 :            :     }
      99                 :            : };
     100                 :            : 
     101                 :            : typedef std::map< LanguageType, sal_uInt16, lt_LanguageType >   LangCheckState_map_t;
     102                 :            : 
     103                 :         36 : static LangCheckState_map_t & GetLangCheckState()
     104                 :            : {
     105 [ +  + ][ +  - ]:         36 :     static LangCheckState_map_t aLangCheckState;
         [ +  - ][ #  # ]
     106                 :         36 :     return aLangCheckState;
     107                 :            : }
     108                 :            : 
     109                 :         36 : void SvxSpellWrapper::ShowLanguageErrors()
     110                 :            : {
     111                 :            :     // display message boxes for languages not available for
     112                 :            :     // spellchecking or hyphenation
     113         [ +  - ]:         36 :     LangCheckState_map_t &rLCS = GetLangCheckState();
     114                 :         36 :     LangCheckState_map_t::iterator aIt( rLCS.begin() );
     115 [ +  - ][ -  + ]:         36 :     while (aIt != rLCS.end())
     116                 :            :     {
     117         [ #  # ]:          0 :         LanguageType nLang = aIt->first;
     118         [ #  # ]:          0 :         sal_uInt16   nVal  = aIt->second;
     119                 :          0 :         sal_uInt16 nTmpSpell = nVal & 0x00FF;
     120                 :          0 :         sal_uInt16 nTmpHyph  = (nVal >> 8) & 0x00FF;
     121                 :            : 
     122         [ #  # ]:          0 :         if (SVX_LANG_MISSING_DO_WARN == nTmpSpell)
     123                 :            :         {
     124         [ #  # ]:          0 :             String aErr( SvtLanguageTable::GetLanguageString( nLang ) );
     125                 :            :             ErrorHandler::HandleError(
     126 [ #  # ][ #  # ]:          0 :                 *new StringErrorInfo( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aErr ) );
         [ #  # ][ #  # ]
     127         [ #  # ]:          0 :             nTmpSpell = SVX_LANG_MISSING;
     128                 :            :         }
     129         [ #  # ]:          0 :         if (SVX_LANG_MISSING_DO_WARN == nTmpHyph)
     130                 :            :         {
     131         [ #  # ]:          0 :             String aErr( SvtLanguageTable::GetLanguageString( nLang ) );
     132                 :            :             ErrorHandler::HandleError(
     133 [ #  # ][ #  # ]:          0 :                 *new StringErrorInfo( ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aErr ) );
         [ #  # ][ #  # ]
     134         [ #  # ]:          0 :             nTmpHyph = SVX_LANG_MISSING;
     135                 :            :         }
     136                 :            : 
     137         [ #  # ]:          0 :         rLCS[ nLang ] = (nTmpHyph << 8) | nTmpSpell;
     138         [ #  # ]:          0 :         ++aIt;
     139                 :            :     }
     140                 :            : 
     141                 :         36 : }
     142                 :            : 
     143                 :         18 : SvxSpellWrapper::~SvxSpellWrapper()
     144                 :            : {
     145         [ -  + ]:         18 : }
     146                 :            : 
     147                 :            : /*--------------------------------------------------------------------
     148                 :            :  *  Description: Constructor, the test sequence is determined
     149                 :            :  *
     150                 :            :  *  !bStart && !bOtherCntnt:    BODY_END,   BODY_START, OTHER
     151                 :            :  *  !bStart && bOtherCntnt:     OTHER,      BODY
     152                 :            :  *  bStart && !bOtherCntnt:     BODY_END,   OTHER
     153                 :            :  *  bStart && bOtherCntnt:      OTHER
     154                 :            :  *
     155                 :            :  --------------------------------------------------------------------*/
     156                 :            : 
     157                 :         18 : SvxSpellWrapper::SvxSpellWrapper( Window* pWn,
     158                 :            :     Reference< XSpellChecker1 >  &xSpellChecker,
     159                 :            :     const sal_Bool bStart, const sal_Bool bIsAllRight,
     160                 :            :     const sal_Bool bOther, const sal_Bool bRevAllow ) :
     161                 :            : 
     162                 :            :     pWin        ( pWn ),
     163                 :            :     xSpell      ( xSpellChecker ),
     164                 :            :     bOtherCntnt ( bOther ),
     165                 :            :     bDialog     ( sal_False ),
     166                 :            :     bHyphen     ( sal_False ),
     167                 :            :     bAuto       ( sal_False ),
     168                 :            :     bStartChk   ( bOther ),
     169                 :            :     bRevAllowed ( bRevAllow ),
     170                 :         18 :     bAllRight   ( bIsAllRight )
     171                 :            : {
     172         [ +  - ]:         18 :     Reference< beans::XPropertySet >  xProp( SvxGetLinguPropertySet() );
     173                 :         18 :     sal_Bool bWrapReverse = xProp.is() ?
     174         [ #  # ]:          0 :         *(sal_Bool*)xProp->getPropertyValue(
     175 [ #  # ][ -  + ]:         18 :             ::rtl::OUString(UPN_IS_WRAP_REVERSE) ).getValue()
         [ -  + ][ -  + ]
           [ #  #  #  #  
                   #  # ]
     176         [ -  + ]:         18 :         : sal_False;
     177 [ +  - ][ -  + ]:         18 :     bReverse = bRevAllow && bWrapReverse;
     178 [ +  - ][ +  - ]:         18 :     bStartDone = bOther || ( !bReverse && bStart );
                 [ +  - ]
     179 [ -  + ][ #  # ]:         18 :     bEndDone   = bReverse && bStart && !bOther;
                 [ #  # ]
     180                 :         18 : }
     181                 :            : 
     182                 :            : // -----------------------------------------------------------------------
     183                 :            : 
     184                 :          0 : SvxSpellWrapper::SvxSpellWrapper( Window* pWn,
     185                 :            :         Reference< XHyphenator >  &xHyphenator,
     186                 :            :         const sal_Bool bStart, const sal_Bool bOther ) :
     187                 :            :     pWin        ( pWn ),
     188                 :            :     xHyph       ( xHyphenator ),
     189                 :            :     bOtherCntnt ( bOther ),
     190                 :            :     bDialog     ( sal_False ),
     191                 :            :     bHyphen     ( sal_False ),
     192                 :            :     bAuto       ( sal_False ),
     193                 :            :     bReverse    ( sal_False ),
     194                 :          0 :     bStartDone  ( bOther || ( !bReverse && bStart ) ),
     195                 :            :     bEndDone    ( bReverse && bStart && !bOther ),
     196                 :            :     bStartChk   ( bOther ),
     197                 :            :     bRevAllowed ( sal_False ),
     198 [ #  # ][ #  # ]:          0 :     bAllRight   ( sal_True )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     199                 :            : {
     200                 :          0 : }
     201                 :            : 
     202                 :            : // -----------------------------------------------------------------------
     203                 :            : 
     204                 :          0 : sal_Int16 SvxSpellWrapper::CheckSpellLang(
     205                 :            :         Reference< XSpellChecker1 > xSpell, sal_Int16 nLang)
     206                 :            : {
     207         [ #  # ]:          0 :     LangCheckState_map_t &rLCS = GetLangCheckState();
     208                 :            : 
     209         [ #  # ]:          0 :     LangCheckState_map_t::iterator aIt( rLCS.find( nLang ) );
     210 [ #  # ][ #  # ]:          0 :     sal_uInt16 nVal = aIt == rLCS.end() ? SVX_LANG_NEED_CHECK : aIt->second;
                 [ #  # ]
     211                 :            : 
     212 [ #  # ][ #  # ]:          0 :     if (aIt == rLCS.end())
     213         [ #  # ]:          0 :         rLCS[ nLang ] = nVal;
     214                 :            : 
     215         [ #  # ]:          0 :     if (SVX_LANG_NEED_CHECK == (nVal & 0x00FF))
     216                 :            :     {
     217                 :          0 :         sal_uInt16 nTmpVal = SVX_LANG_MISSING_DO_WARN;
     218 [ #  # ][ #  # ]:          0 :         if (xSpell.is()  &&  xSpell->hasLanguage( nLang ))
         [ #  # ][ #  # ]
                 [ #  # ]
     219                 :          0 :             nTmpVal = SVX_LANG_OK;
     220                 :          0 :         nVal &= 0xFF00;
     221                 :          0 :         nVal |= nTmpVal;
     222                 :            : 
     223         [ #  # ]:          0 :         rLCS[ nLang ] = nVal;
     224                 :            :     }
     225                 :            : 
     226                 :          0 :     return (sal_Int16) nVal;
     227                 :            : }
     228                 :            : 
     229                 :          0 : sal_Int16 SvxSpellWrapper::CheckHyphLang(
     230                 :            :         Reference< XHyphenator >  xHyph, sal_Int16 nLang)
     231                 :            : {
     232         [ #  # ]:          0 :     LangCheckState_map_t &rLCS = GetLangCheckState();
     233                 :            : 
     234         [ #  # ]:          0 :     LangCheckState_map_t::iterator aIt( rLCS.find( nLang ) );
     235 [ #  # ][ #  # ]:          0 :     sal_uInt16 nVal = aIt == rLCS.end() ? 0 : aIt->second;
                 [ #  # ]
     236                 :            : 
     237 [ #  # ][ #  # ]:          0 :     if (aIt == rLCS.end())
     238         [ #  # ]:          0 :         rLCS[ nLang ] = nVal;
     239                 :            : 
     240         [ #  # ]:          0 :     if (SVX_LANG_NEED_CHECK == ((nVal >> 8) & 0x00FF))
     241                 :            :     {
     242                 :          0 :         sal_uInt16 nTmpVal = SVX_LANG_MISSING_DO_WARN;
     243 [ #  # ][ #  # ]:          0 :         if (xHyph.is()  &&  xHyph->hasLocale( SvxCreateLocale( nLang ) ))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     244                 :          0 :             nTmpVal = SVX_LANG_OK;
     245                 :          0 :         nVal &= 0x00FF;
     246                 :          0 :         nVal |= nTmpVal << 8;
     247                 :            : 
     248         [ #  # ]:          0 :         rLCS[ nLang ] = nVal;
     249                 :            :     }
     250                 :            : 
     251                 :          0 :     return (sal_Int16) nVal;
     252                 :            : }
     253                 :            : 
     254                 :            : // -----------------------------------------------------------------------
     255                 :            : 
     256                 :            : 
     257                 :          0 : void SvxSpellWrapper::SpellStart( SvxSpellArea /*eSpell*/ )
     258                 :            : { // Here, the necessary preparations be made for SpellContinue in the
     259                 :          0 : } // given area.
     260                 :            : 
     261                 :            : // -----------------------------------------------------------------------
     262                 :            : 
     263                 :            : 
     264                 :          0 : sal_Bool SvxSpellWrapper::HasOtherCnt()
     265                 :            : {
     266                 :          0 :     return sal_False; // Is there a special area?
     267                 :            : }
     268                 :            : 
     269                 :            : // -----------------------------------------------------------------------
     270                 :            : 
     271                 :            : 
     272                 :          0 : sal_Bool SvxSpellWrapper::SpellMore()
     273                 :            : {
     274                 :          0 :     return sal_False; // Should additional documents be examined?
     275                 :            : }
     276                 :            : 
     277                 :            : // -----------------------------------------------------------------------
     278                 :            : 
     279                 :            : 
     280                 :         18 : void SvxSpellWrapper::SpellEnd()
     281                 :            : {   // Area is complete, tidy up if necessary
     282                 :            : 
     283                 :            :     // display error for last language not found
     284                 :         18 :     ShowLanguageErrors();
     285                 :         18 : }
     286                 :            : 
     287                 :            : // -----------------------------------------------------------------------
     288                 :            : 
     289                 :            : 
     290                 :          0 : sal_Bool SvxSpellWrapper::SpellContinue()
     291                 :            : {
     292                 :          0 :     return sal_False;
     293                 :            : }
     294                 :            : 
     295                 :            : // -----------------------------------------------------------------------
     296                 :            : 
     297                 :          0 : void SvxSpellWrapper::AutoCorrect( const String&, const String& )
     298                 :            : {
     299                 :          0 : }
     300                 :            : 
     301                 :            : // -----------------------------------------------------------------------
     302                 :            : 
     303                 :            : 
     304                 :          0 : void SvxSpellWrapper::ScrollArea()
     305                 :            : {   // Set Scroll area
     306                 :          0 : }
     307                 :            : 
     308                 :            : // -----------------------------------------------------------------------
     309                 :            : 
     310                 :            : 
     311                 :          0 : void SvxSpellWrapper::ChangeWord( const String&, const sal_uInt16 )
     312                 :            : {   // Insert Word
     313                 :          0 : }
     314                 :            : 
     315                 :            : // -----------------------------------------------------------------------
     316                 :            : 
     317                 :            : 
     318                 :          0 : String SvxSpellWrapper::GetThesWord()
     319                 :            : {
     320                 :            :     // What word should be looked up?
     321                 :          0 :     return String();
     322                 :            : }
     323                 :            : 
     324                 :            : // -----------------------------------------------------------------------
     325                 :            : 
     326                 :            : 
     327                 :          0 : void SvxSpellWrapper::ChangeThesWord( const String& )
     328                 :            : {
     329                 :            :     // replace word due to Thesaurus.
     330                 :          0 : }
     331                 :            : 
     332                 :            : // -----------------------------------------------------------------------
     333                 :            : 
     334                 :          0 : void SvxSpellWrapper::StartThesaurus( const String &rWord, sal_uInt16 nLanguage )
     335                 :            : {
     336         [ #  # ]:          0 :     Reference< XThesaurus >  xThes( SvxGetThesaurus() );
     337         [ #  # ]:          0 :     if (!xThes.is())
     338                 :            :     {
     339 [ #  # ][ #  # ]:          0 :         InfoBox( pWin, EE_RESSTR( RID_SVXSTR_HMERR_THESAURUS ) ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     340                 :          0 :         return;
     341                 :            :     }
     342                 :            : 
     343 [ #  # ][ #  # ]:          0 :     WAIT_ON();  // while looking up for initial word
     344         [ #  # ]:          0 :     EditAbstractDialogFactory* pFact = EditAbstractDialogFactory::Create();
     345         [ #  # ]:          0 :     AbstractThesaurusDialog* pDlg = pFact->CreateThesaurusDialog( pWin, xThes, rWord, nLanguage );
     346 [ #  # ][ #  # ]:          0 :     WAIT_OFF();
     347 [ #  # ][ #  # ]:          0 :     if ( pDlg->Execute()== RET_OK )
     348                 :            :     {
     349 [ #  # ][ #  # ]:          0 :         ChangeThesWord( pDlg->GetWord() );
                 [ #  # ]
     350                 :            :     }
     351 [ #  # ][ #  # ]:          0 :     delete pDlg;
                 [ #  # ]
     352                 :            : }
     353                 :            : 
     354                 :            : // -----------------------------------------------------------------------
     355                 :            : 
     356                 :          0 : void SvxSpellWrapper::ReplaceAll( const String &, sal_Int16 )
     357                 :            : {   // Replace Word from the the Replace list
     358                 :          0 : }
     359                 :            : 
     360                 :            : // -----------------------------------------------------------------------
     361                 :            : 
     362                 :            : 
     363                 :          0 : void SvxSpellWrapper::SetLanguage( const sal_uInt16 )
     364                 :            : {   // Set Language
     365                 :          0 : }
     366                 :            : 
     367                 :            : // -----------------------------------------------------------------------
     368                 :            : 
     369                 :            : 
     370                 :          0 : void SvxSpellWrapper::InsertHyphen( const sal_uInt16 )
     371                 :            : {   // inserting and deleting Hyphae
     372                 :          0 : }
     373                 :            : 
     374                 :            : // -----------------------------------------------------------------------
     375                 :            : // Testing of the document areas in the order specified by the flags
     376                 :            : 
     377                 :            : 
     378                 :         18 : void SvxSpellWrapper::SpellDocument( )
     379                 :            : {
     380         [ -  + ]:         18 :     if ( bOtherCntnt )
     381                 :            :     {
     382                 :          0 :         bReverse = sal_False;
     383                 :          0 :         SpellStart( SVX_SPELL_OTHER );
     384                 :            :     }
     385                 :            :     else
     386                 :            :     {
     387                 :         18 :         bStartChk = bReverse;
     388         [ -  + ]:         18 :         SpellStart( bReverse ? SVX_SPELL_BODY_START : SVX_SPELL_BODY_END );
     389                 :            :     }
     390                 :            : 
     391         [ -  + ]:         18 :     if ( FindSpellError() )
     392                 :            :     {
     393 [ #  # ][ #  # ]:          0 :         Reference< XSpellAlternatives >     xAlt( GetLast(), UNO_QUERY );
     394 [ #  # ][ #  # ]:          0 :         Reference< XHyphenatedWord >        xHyphWord( GetLast(), UNO_QUERY );
     395                 :            : 
     396                 :          0 :         Window *pOld = pWin;
     397                 :          0 :         bDialog = sal_True;
     398         [ #  # ]:          0 :         if (xHyphWord.is())
     399                 :            :         {
     400         [ #  # ]:          0 :             EditAbstractDialogFactory* pFact = EditAbstractDialogFactory::Create();
     401                 :            :             AbstractHyphenWordDialog* pDlg = pFact->CreateHyphenWordDialog( pWin,
     402         [ #  # ]:          0 :                             xHyphWord->getWord(),
     403 [ #  # ][ #  # ]:          0 :                             SvxLocaleToLanguage( xHyphWord->getLocale() ),
                 [ #  # ]
     404 [ #  # ][ #  # ]:          0 :                             xHyph, this );
         [ #  # ][ #  # ]
     405         [ #  # ]:          0 :             pWin = pDlg->GetWindow();
     406         [ #  # ]:          0 :             pDlg->Execute();
     407 [ #  # ][ #  # ]:          0 :             delete pDlg;
     408                 :            :         }
     409                 :          0 :         bDialog = sal_False;
     410                 :          0 :         pWin = pOld;
     411                 :            :     };
     412                 :         18 : }
     413                 :            : 
     414                 :            : // -----------------------------------------------------------------------
     415                 :            : // Select the next area
     416                 :            : 
     417                 :            : 
     418                 :         18 : sal_Bool SvxSpellWrapper::SpellNext( )
     419                 :            : {
     420         [ +  - ]:         18 :     Reference< beans::XPropertySet >  xProp( SvxGetLinguPropertySet() );
     421                 :         18 :     sal_Bool bWrapReverse = xProp.is() ?
     422         [ #  # ]:          0 :             *(sal_Bool*)xProp->getPropertyValue(
     423 [ #  # ][ -  + ]:         18 :                 ::rtl::OUString(UPN_IS_WRAP_REVERSE) ).getValue()
         [ -  + ][ -  + ]
           [ #  #  #  #  
                   #  # ]
     424         [ -  + ]:         18 :             : sal_False;
     425 [ +  - ][ -  + ]:         18 :     sal_Bool bActRev = bRevAllowed && bWrapReverse;
     426                 :            : 
     427                 :            :     // bActRev is the direction after Spell checking, bReverse is the one
     428                 :            :     // at the beginning.
     429         [ +  - ]:         18 :     if( bActRev == bReverse )
     430                 :            :     {                           // No change of direction, thus is the
     431         [ -  + ]:         18 :         if( bStartChk )         // desired area ( bStartChk )
     432                 :          0 :             bStartDone = sal_True;  // completely processed.
     433                 :            :         else
     434                 :         18 :             bEndDone = sal_True;
     435                 :            :     }
     436         [ #  # ]:          0 :     else if( bReverse == bStartChk ) //For a change of direction, an area can
     437                 :            :     {                          // be processed during certain circumstances
     438         [ #  # ]:          0 :         if( bStartChk )        // If the firdt part is spell checked in backwards
     439                 :          0 :             bEndDone = sal_True;   // and this is reversed in the process, then
     440                 :            :         else                   // then the end part is processed (and vice-versa).
     441                 :          0 :             bStartDone = sal_True;
     442                 :            :     }
     443                 :            : 
     444                 :         18 :     bReverse = bActRev;
     445 [ -  + ][ #  # ]:         18 :     if( bOtherCntnt && bStartDone && bEndDone ) // Document has been fully checked?
                 [ #  # ]
     446                 :            :     {
     447 [ #  # ][ #  # ]:          0 :         if ( SpellMore() )  // spell check another document?
     448                 :            :         {
     449                 :          0 :             bOtherCntnt = sal_False;
     450                 :          0 :             bStartDone = !bReverse;
     451                 :          0 :             bEndDone  = bReverse;
     452         [ #  # ]:          0 :             SpellStart( SVX_SPELL_BODY );
     453                 :          0 :             return sal_True;
     454                 :            :         }
     455                 :          0 :         return sal_False;
     456                 :            :     }
     457                 :            : 
     458                 :         18 :     sal_Bool bGoOn = sal_False;
     459                 :            : 
     460         [ -  + ]:         18 :     if ( bOtherCntnt )
     461                 :            :     {
     462                 :          0 :         bStartChk = sal_False;
     463         [ #  # ]:          0 :         SpellStart( SVX_SPELL_BODY );
     464                 :          0 :         bGoOn = sal_True;
     465                 :            :     }
     466 [ +  - ][ +  - ]:         18 :     else if ( bStartDone && bEndDone )
     467                 :            :     {
     468                 :         18 :         sal_Bool bIsSpellSpecial = xProp.is() ?
     469         [ #  # ]:          0 :             *(sal_Bool*)xProp->getPropertyValue(
     470 [ #  # ][ -  + ]:         18 :                 ::rtl::OUString(UPN_IS_SPELL_SPECIAL) ).getValue()
         [ -  + ][ -  + ]
           [ #  #  #  #  
                   #  # ]
     471         [ -  + ]:         18 :             : sal_False;
     472                 :            :         // Body area done, ask for special area
     473 [ +  - ][ -  + ]:         18 :         if( !IsHyphen() && bIsSpellSpecial && HasOtherCnt() )
         [ #  # ][ #  # ]
                 [ -  + ]
     474                 :            :         {
     475         [ #  # ]:          0 :             SpellStart( SVX_SPELL_OTHER );
     476                 :          0 :             bOtherCntnt = bGoOn = sal_True;
     477                 :            :         }
     478 [ +  - ][ -  + ]:         18 :         else if ( SpellMore() )  // check another document?
     479                 :            :         {
     480                 :          0 :             bOtherCntnt = sal_False;
     481                 :          0 :             bStartDone = !bReverse;
     482                 :          0 :             bEndDone  = bReverse;
     483         [ #  # ]:          0 :             SpellStart( SVX_SPELL_BODY );
     484                 :          0 :             return sal_True;
     485                 :         18 :         }
     486                 :            :     }
     487                 :            :     else
     488                 :            :     {
     489                 :            :         // a BODY_area done, ask for the other BODY_area
     490 [ #  # ][ #  # ]:          0 :         WAIT_OFF();
     491                 :            : 
     492         [ #  # ]:          0 :         sal_uInt16 nResId = bReverse ? RID_SVXQB_BW_CONTINUE : RID_SVXQB_CONTINUE;
     493 [ #  # ][ #  # ]:          0 :         QueryBox aBox( pWin, EditResId( nResId ) );
     494 [ #  # ][ #  # ]:          0 :         if ( aBox.Execute() != RET_YES )
     495                 :            :         {
     496                 :            :             // sacrifice the other area if necessary ask for special area
     497 [ #  # ][ #  # ]:          0 :             WAIT_ON();
     498                 :          0 :             bStartDone = bEndDone = sal_True;
     499         [ #  # ]:          0 :             return SpellNext();
     500                 :            :         }
     501                 :            :         else
     502                 :            :         {
     503                 :          0 :             bStartChk = !bStartDone;
     504 [ #  # ][ #  # ]:          0 :             SpellStart( bStartChk ? SVX_SPELL_BODY_START : SVX_SPELL_BODY_END );
     505                 :          0 :             bGoOn = sal_True;
     506                 :            :         }
     507 [ #  # ][ #  # ]:          0 :         WAIT_ON();
         [ #  # ][ #  # ]
     508                 :            :     }
     509                 :         18 :     return bGoOn;
     510                 :            : }
     511                 :            : 
     512                 :            : // -----------------------------------------------------------------------
     513                 :            : 
     514                 :          0 : Reference< XDictionary >  SvxSpellWrapper::GetAllRightDic() const
     515                 :            : {
     516                 :          0 :     Reference< XDictionary >  xDic;
     517                 :            : 
     518         [ #  # ]:          0 :     Reference< XDictionaryList >  xDicList( SvxGetDictionaryList() );
     519         [ #  # ]:          0 :     if (xDicList.is())
     520                 :            :     {
     521 [ #  # ][ #  # ]:          0 :         Sequence< Reference< XDictionary >  > aDics( xDicList->getDictionaries() );
     522                 :          0 :         const Reference< XDictionary >  *pDic = aDics.getConstArray();
     523                 :          0 :         sal_Int32 nCount = aDics.getLength();
     524                 :            : 
     525                 :          0 :         sal_Int32 i = 0;
     526 [ #  # ][ #  # ]:          0 :         while (!xDic.is()  &&  i < nCount)
                 [ #  # ]
     527                 :            :         {
     528         [ #  # ]:          0 :             Reference< XDictionary >  xTmp( pDic[i], UNO_QUERY );
     529         [ #  # ]:          0 :             if (xTmp.is())
     530                 :            :             {
     531 [ #  # ][ #  # ]:          0 :                 if ( xTmp->isActive() &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     532 [ #  # ][ #  # ]:          0 :                      xTmp->getDictionaryType() != DictionaryType_NEGATIVE &&
     533 [ #  # ][ #  # ]:          0 :                      SvxLocaleToLanguage( xTmp->getLocale() ) == LANGUAGE_NONE )
         [ #  # ][ #  # ]
                 [ #  # ]
     534                 :            :                 {
     535         [ #  # ]:          0 :                     Reference< frame::XStorable >  xStor( xTmp, UNO_QUERY );
     536 [ #  # ][ #  # ]:          0 :                     if (xStor.is() && xStor->hasLocation() && !xStor->isReadonly())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     537                 :            :                     {
     538         [ #  # ]:          0 :                         xDic = xTmp;
     539                 :          0 :                     }
     540                 :            :                 }
     541                 :            :             }
     542                 :          0 :             ++i;
     543                 :          0 :         }
     544                 :            : 
     545         [ #  # ]:          0 :         if (!xDic.is())
     546                 :            :         {
     547 [ #  # ][ #  # ]:          0 :             xDic = SvxGetOrCreatePosDic( xDicList );
     548         [ #  # ]:          0 :             if (xDic.is())
     549 [ #  # ][ #  # ]:          0 :                 xDic->setActive( sal_True );
     550         [ #  # ]:          0 :         }
     551                 :            :     }
     552                 :            : 
     553                 :          0 :     return xDic;
     554                 :            : }
     555                 :            : 
     556                 :            : // -----------------------------------------------------------------------
     557                 :            : 
     558                 :         18 : sal_Bool SvxSpellWrapper::FindSpellError()
     559                 :            : {
     560         [ +  - ]:         18 :     ShowLanguageErrors();
     561                 :            : 
     562                 :         18 :      Reference< XInterface >    xRef;
     563                 :            : 
     564 [ +  - ][ +  - ]:         18 :     WAIT_ON();
     565                 :         18 :     sal_Bool bSpell = sal_True;
     566                 :            : 
     567                 :         18 :     Reference< XDictionary >  xAllRightDic;
     568         [ -  + ]:         18 :     if (IsAllRight())
     569 [ #  # ][ #  # ]:          0 :         xAllRightDic = GetAllRightDic();
     570                 :            : 
     571         [ +  + ]:         36 :     while ( bSpell )
     572                 :            :     {
     573         [ +  - ]:         18 :         SpellContinue();
     574                 :            : 
     575 [ +  - ][ +  - ]:         18 :         Reference< XSpellAlternatives >     xAlt( GetLast(), UNO_QUERY );
     576 [ +  - ][ +  - ]:         18 :         Reference< XHyphenatedWord >        xHyphWord( GetLast(), UNO_QUERY );
     577                 :            : 
     578         [ -  + ]:         18 :         if (xAlt.is())
     579                 :            :         {
     580 [ #  # ][ #  # ]:          0 :             if (IsAllRight() && xAllRightDic.is())
                 [ #  # ]
     581                 :            :             {
     582 [ #  # ][ #  # ]:          0 :                 xAllRightDic->add( xAlt->getWord(), sal_False, ::rtl::OUString() );
         [ #  # ][ #  # ]
     583                 :            :             }
     584                 :            :             else
     585                 :            :             {
     586                 :            :                 // look up in ChangeAllList for misspelled word
     587                 :            :                 Reference< XDictionary >    xChangeAllList(
     588 [ #  # ][ #  # ]:          0 :                         SvxGetChangeAllList(), UNO_QUERY );
     589                 :          0 :                 Reference< XDictionaryEntry >   xEntry;
     590         [ #  # ]:          0 :                 if (xChangeAllList.is())
     591 [ #  # ][ #  # ]:          0 :                     xEntry = xChangeAllList->getEntry( xAlt->getWord() );
         [ #  # ][ #  # ]
                 [ #  # ]
     592                 :            : 
     593         [ #  # ]:          0 :                 if (xEntry.is())
     594                 :            :                 {
     595                 :            :                     // replace word without asking
     596         [ #  # ]:          0 :                     ReplaceAll( xEntry->getReplacementText(),
     597 [ #  # ][ #  # ]:          0 :                                 SvxLocaleToLanguage( xAlt->getLocale() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     598                 :            :                 }
     599                 :            :                 else
     600                 :          0 :                     bSpell = sal_False;
     601                 :            :             }
     602                 :            :         }
     603         [ -  + ]:         18 :         else if (xHyphWord.is())
     604                 :          0 :             bSpell = sal_False;
     605                 :            :         else
     606                 :            :         {
     607         [ +  - ]:         18 :             SpellEnd();
     608         [ +  - ]:         18 :             bSpell = SpellNext();
     609                 :            :         }
     610                 :         18 :     }
     611 [ +  - ][ +  - ]:         18 :     WAIT_OFF();
     612         [ +  - ]:         18 :     return GetLast().is();
     613                 :            : }
     614                 :            : 
     615                 :            : 
     616                 :            : 
     617                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10