LCOV - code coverage report
Current view: top level - sw/source/uibase/lingu - hyp.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 46 2.2 %
Date: 2015-06-13 12:38:46 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 "initui.hxx"
      21             : #include "view.hxx"
      22             : #include "edtwin.hxx"
      23             : #include "wrtsh.hxx"
      24             : #include "globals.hrc"
      25             : #include <vcl/msgbox.hxx>
      26             : #include <vcl/wrkwin.hxx>
      27             : #include <linguistic/lngprops.hxx>
      28             : #include <com/sun/star/beans/XPropertySet.hpp>
      29             : #include <com/sun/star/linguistic2/XLinguProperties.hpp>
      30             : #include <swwait.hxx>
      31             : 
      32             : #include "hyp.hxx"
      33             : #include "mdiexp.hxx"
      34             : #include "olmenu.hrc"
      35             : 
      36             : #include <unomid.h>
      37             : 
      38             : #include <boost/scoped_ptr.hpp>
      39             : 
      40             : #define PSH         (&pView->GetWrtShell())
      41             : 
      42             : using namespace ::com::sun::star;
      43             : 
      44             : // interactive separation
      45           0 : SwHyphWrapper::SwHyphWrapper( SwView* pVw,
      46             :             uno::Reference< linguistic2::XHyphenator >  &rxHyph,
      47             :             bool bStart, bool bOther, bool bSelect ) :
      48           0 :     SvxSpellWrapper( &pVw->GetEditWin(), rxHyph, bStart, bOther ),
      49             :     pView( pVw ),
      50             :     xHyph( rxHyph ),
      51             :     nPageCount( 0 ),
      52             :     nPageStart( 0 ),
      53             :     bInSelection( bSelect ),
      54           0 :     bInfoBox( false )
      55             : {
      56           0 :     uno::Reference< linguistic2::XLinguProperties >  xProp( GetLinguPropertySet() );
      57           0 :     bAutomatic = xProp.is() && xProp->getIsHyphAuto();
      58           0 :     SetHyphen();
      59           0 : }
      60             : 
      61           0 : void SwHyphWrapper::SpellStart( SvxSpellArea eSpell )
      62             : {
      63           0 :     if( SVX_SPELL_OTHER == eSpell && nPageCount )
      64             :     {
      65           0 :         ::EndProgress( pView->GetDocShell() );
      66           0 :         nPageCount = 0;
      67           0 :         nPageStart = 0;
      68             :     }
      69           0 :     pView->HyphStart( eSpell );
      70           0 : }
      71             : 
      72           0 : bool SwHyphWrapper::SpellContinue()
      73             : {
      74             :     // for automatic separation, make actions visible only at the end
      75           0 :     boost::scoped_ptr<SwWait> pWait;
      76           0 :     if( bAutomatic )
      77             :     {
      78           0 :         PSH->StartAllAction();
      79           0 :         pWait.reset(new SwWait( *pView->GetDocShell(), true ));
      80             :     }
      81             : 
      82             :         uno::Reference< uno::XInterface >  xHyphWord = bInSelection ?
      83           0 :                 PSH->HyphContinue( NULL, NULL ) :
      84           0 :                 PSH->HyphContinue( &nPageCount, &nPageStart );
      85           0 :         SetLast( xHyphWord );
      86             : 
      87             :     // for automatic separation, make actions visible only at the end
      88           0 :     if( bAutomatic )
      89             :     {
      90           0 :         PSH->EndAllAction();
      91           0 :         pWait.reset();
      92             :     }
      93             : 
      94           0 :     return GetLast().is();
      95             : }
      96             : 
      97           0 : void SwHyphWrapper::SpellEnd()
      98             : {
      99           0 :     PSH->HyphEnd();
     100           0 :     SvxSpellWrapper::SpellEnd();
     101           0 : }
     102             : 
     103           0 : bool SwHyphWrapper::SpellMore()
     104             : {
     105           0 :     PSH->Push();
     106           0 :     bInfoBox = true;
     107           0 :     PSH->Combine();
     108           0 :     return false;
     109             : }
     110             : 
     111           0 : void SwHyphWrapper::InsertHyphen( const sal_Int32 nPos )
     112             : {
     113           0 :     if( nPos)
     114           0 :         SwEditShell::InsertSoftHyph(nPos + 1); // does nPos == 1 really mean
     115             :                                         // insert hyphen after first char?
     116             :                                         // (instead of nPos == 0)
     117             :     else
     118           0 :         PSH->HyphIgnore();
     119           0 : }
     120             : 
     121           0 : SwHyphWrapper::~SwHyphWrapper()
     122             : {
     123           0 :     if( nPageCount )
     124           0 :         ::EndProgress( pView->GetDocShell() );
     125           0 :     if( bInfoBox )
     126           0 :         ScopedVclPtr<InfoBox>::Create( &pView->GetEditWin(), SW_RESSTR(STR_HYP_OK) )->Execute();
     127         177 : }
     128             : 
     129             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11