LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/editeng/source/editeng - editview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 130 709 18.3 %
Date: 2013-07-09 Functions: 38 92 41.3 %
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             : 
      21             : #include <sal/macros.h>
      22             : #include <vcl/wrkwin.hxx>
      23             : #include <vcl/dialog.hxx>
      24             : #include <vcl/msgbox.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : 
      27             : #include <com/sun/star/i18n/WordType.hpp>
      28             : #include <com/sun/star/i18n/ScriptType.hpp>
      29             : #include <vcl/metric.hxx>
      30             : 
      31             : #include <i18nlangtag/languagetag.hxx>
      32             : #include <i18nlangtag/mslangid.hxx>
      33             : #include <svl/languageoptions.hxx>
      34             : #include <svtools/ctrltool.hxx>
      35             : #include <svtools/langtab.hxx>
      36             : #include <vcl/graphicfilter.hxx>
      37             : 
      38             : #include <svl/srchitem.hxx>
      39             : 
      40             : #include <impedit.hxx>
      41             : #include <editeng/editeng.hxx>
      42             : #include <editeng/editview.hxx>
      43             : #include <editeng/flditem.hxx>
      44             : #include <editeng/svxacorr.hxx>
      45             : #include <editeng/langitem.hxx>
      46             : #include <editeng/fhgtitem.hxx>
      47             : #include <editeng/eerdll.hxx>
      48             : #include <eerdll2.hxx>
      49             : #include <editeng.hrc>
      50             : #include <helpid.hrc>
      51             : #include <i18nlangtag/lang.h>
      52             : #include <vcl/menu.hxx>
      53             : #include <vcl/window.hxx>
      54             : #include <editeng/acorrcfg.hxx>
      55             : #include <editeng/unolingu.hxx>
      56             : #include <editeng/fontitem.hxx>
      57             : #include <unotools/lingucfg.hxx>
      58             : #include <osl/file.hxx>
      59             : 
      60             : #include <com/sun/star/frame/XStorable.hpp>
      61             : #include <com/sun/star/beans/PropertyValues.hpp>
      62             : #include <com/sun/star/lang/Locale.hpp>
      63             : #include <linguistic/lngprops.hxx>
      64             : #include <vcl/settings.hxx>
      65             : 
      66             : #include <com/sun/star/lang/XServiceInfo.hpp>
      67             : 
      68             : #define PIMPEE pImpEditView->pEditEngine->pImpEditEngine
      69             : 
      70             : using namespace com::sun::star;
      71             : using namespace com::sun::star::uno;
      72             : using namespace com::sun::star::beans;
      73             : 
      74             : 
      75             : DBG_NAME( EditView )
      76             : 
      77             : 
      78             : // static
      79           0 : LanguageType EditView::CheckLanguage(
      80             :         const OUString &rText,
      81             :         Reference< linguistic2::XSpellChecker1 > xSpell,
      82             :         Reference< linguistic2::XLanguageGuessing > xLangGuess,
      83             :         bool bIsParaText )
      84             : {
      85           0 :     LanguageType nLang = LANGUAGE_NONE;
      86           0 :     if (bIsParaText)    // check longer texts with language-guessing...
      87             :     {
      88           0 :         if (!xLangGuess.is())
      89           0 :             return nLang;
      90             : 
      91           0 :         LanguageTag aGuessTag( xLangGuess->guessPrimaryLanguage( rText, 0, rText.getLength()) );
      92             : 
      93             :         // If the result from language guessing does not provide a 'Country'
      94             :         // part, try to get it by looking up the locale setting of the office,
      95             :         // "Tools/Options - Language Settings - Languages: Locale setting", if
      96             :         // the language matches.
      97           0 :         if ( aGuessTag.getCountry().isEmpty() )
      98             :         {
      99           0 :             const LanguageTag& rAppLocaleTag = Application::GetSettings().GetLanguageTag();
     100           0 :             if (rAppLocaleTag.getLanguage() == aGuessTag.getLanguage())
     101           0 :                 nLang = rAppLocaleTag.getLanguageType();
     102             :         }
     103           0 :         if (nLang == LANGUAGE_NONE) // language not found by looking up the sytem language...
     104           0 :             nLang = aGuessTag.makeFallback().getLanguageType();     // best known locale match
     105           0 :         if (nLang == LANGUAGE_SYSTEM)
     106           0 :             nLang = Application::GetSettings().GetLanguageTag().getLanguageType();
     107           0 :         if (nLang == LANGUAGE_DONTKNOW)
     108           0 :             nLang = LANGUAGE_NONE;
     109             :     }
     110             :     else    // check single word
     111             :     {
     112           0 :             if (!xSpell.is())
     113           0 :             return nLang;
     114             : 
     115             :         //
     116             :         // build list of languages to check
     117             :         //
     118             :         LanguageType aLangList[4];
     119           0 :         const AllSettings& rSettings  = Application::GetSettings();
     120           0 :         SvtLinguOptions aLinguOpt;
     121           0 :         SvtLinguConfig().GetOptions( aLinguOpt );
     122             :         // The default document language from "Tools/Options - Language Settings - Languages: Western"
     123             :         aLangList[0] = MsLangId::resolveSystemLanguageByScriptType( aLinguOpt.nDefaultLanguage,
     124           0 :                 ::com::sun::star::i18n::ScriptType::LATIN);
     125             :         // The one from "Tools/Options - Language Settings - Languages: User interface"
     126           0 :         aLangList[1] = rSettings.GetUILanguageTag().getLanguageType();
     127             :         // The one from "Tools/Options - Language Settings - Languages: Locale setting"
     128           0 :         aLangList[2] = rSettings.GetLanguageTag().getLanguageType();
     129             :         // en-US
     130           0 :         aLangList[3] = LANGUAGE_ENGLISH_US;
     131             : #ifdef DEBUG
     132             :         lang::Locale a0( LanguageTag( aLangList[0] ).getLocale() );
     133             :         lang::Locale a1( LanguageTag( aLangList[1] ).getLocale() );
     134             :         lang::Locale a2( LanguageTag( aLangList[2] ).getLocale() );
     135             :         lang::Locale a3( LanguageTag( aLangList[3] ).getLocale() );
     136             : #endif
     137             : 
     138           0 :         sal_Int32 nCount = sizeof (aLangList) / sizeof (aLangList[0]);
     139           0 :         for (sal_Int32 i = 0;  i < nCount;  i++)
     140             :         {
     141           0 :             sal_Int16 nTmpLang = aLangList[i];
     142           0 :             if (nTmpLang != LANGUAGE_NONE  &&  nTmpLang != LANGUAGE_DONTKNOW)
     143             :             {
     144           0 :                 if (xSpell->hasLanguage( nTmpLang ) &&
     145           0 :                     xSpell->isValid( rText, nTmpLang, Sequence< PropertyValue >() ))
     146             :                 {
     147           0 :                     nLang = nTmpLang;
     148           0 :                     break;
     149             :                 }
     150             :             }
     151           0 :         }
     152             :     }
     153             : 
     154           0 :     return nLang;
     155             : }
     156             : 
     157             : 
     158             : // ----------------------------------------------------------------------
     159             : // class EditView
     160             : // ----------------------------------------------------------------------
     161         257 : EditView::EditView( EditEngine* pEng, Window* pWindow )
     162             : {
     163             :     DBG_CTOR( EditView, 0 );
     164         257 :     pImpEditView = new ImpEditView( this, pEng, pWindow );
     165         257 : }
     166             : 
     167         771 : EditView::~EditView()
     168             : {
     169             :     DBG_DTOR( EditView, 0 );
     170         257 :     delete pImpEditView;
     171         514 : }
     172             : 
     173          27 : ImpEditEngine* EditView::GetImpEditEngine() const
     174             : {
     175             :     DBG_CHKTHIS( EditView, 0 );
     176          27 :     return pImpEditView->pEditEngine->pImpEditEngine;
     177             : }
     178             : 
     179         701 : EditEngine* EditView::GetEditEngine() const
     180             : {
     181             :     DBG_CHKTHIS( EditView, 0 );
     182             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     183         701 :     return pImpEditView->pEditEngine;
     184             : }
     185             : 
     186         279 : void EditView::Invalidate()
     187             : {
     188             :     DBG_CHKTHIS( EditView, 0 );
     189             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     190         279 :     if ( !pImpEditView->DoInvalidateMore() )
     191         279 :         pImpEditView->GetWindow()->Invalidate( pImpEditView->aOutArea );
     192             :     else
     193             :     {
     194           0 :         Rectangle aRect( pImpEditView->aOutArea );
     195           0 :         long nMore = pImpEditView->GetWindow()->PixelToLogic( Size( pImpEditView->GetInvalidateMore(), 0 ) ).Width();
     196           0 :         aRect.Left() -= nMore;
     197           0 :         aRect.Right() += nMore;
     198           0 :         aRect.Top() -= nMore;
     199           0 :         aRect.Bottom() += nMore;
     200           0 :         pImpEditView->GetWindow()->Invalidate( aRect );
     201             :     }
     202         279 : }
     203             : 
     204          33 : void EditView::SetReadOnly( sal_Bool bReadOnly )
     205             : {
     206             :     DBG_CHKTHIS( EditView, 0 );
     207          33 :     pImpEditView->bReadOnly = bReadOnly;
     208          33 : }
     209             : 
     210          24 : sal_Bool EditView::IsReadOnly() const
     211             : {
     212             :     DBG_CHKTHIS( EditView, 0 );
     213          24 :     return pImpEditView->bReadOnly;
     214             : }
     215             : 
     216          51 : void EditView::SetSelection( const ESelection& rESel )
     217             : {
     218             :     DBG_CHKTHIS( EditView, 0 );
     219             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     220             : 
     221             :     // If someone has just left an empty attribute, and then the outliner
     222             :     // manipulates the selection:
     223          51 :     if ( !pImpEditView->GetEditSelection().HasRange() )
     224             :     {
     225          50 :         ContentNode* pNode = pImpEditView->GetEditSelection().Max().GetNode();
     226          50 :         PIMPE->CursorMoved( pNode );
     227             :     }
     228          51 :     EditSelection aNewSelection( PIMPEE->ConvertSelection( rESel.nStartPara, rESel.nStartPos, rESel.nEndPara, rESel.nEndPos ) );
     229             : 
     230             :     // If the selection is manipulated after a KeyInput:
     231          51 :     PIMPE->CheckIdleFormatter();
     232             : 
     233             :     // Selection may not start/end at an invisible paragraph:
     234          51 :     const ParaPortion* pPortion = PIMPE->FindParaPortion( aNewSelection.Min().GetNode() );
     235          51 :     if ( !pPortion->IsVisible() )
     236             :     {
     237           0 :         pPortion = PIMPE->GetPrevVisPortion( pPortion );
     238           0 :         ContentNode* pNode = pPortion ? pPortion->GetNode() : PIMPE->GetEditDoc().GetObject( 0 );
     239           0 :         aNewSelection.Min() = EditPaM( pNode, pNode->Len() );
     240             :     }
     241          51 :     pPortion = PIMPE->FindParaPortion( aNewSelection.Max().GetNode() );
     242          51 :     if ( !pPortion->IsVisible() )
     243             :     {
     244           0 :         pPortion = PIMPE->GetPrevVisPortion( pPortion );
     245           0 :         ContentNode* pNode = pPortion ? pPortion->GetNode() : PIMPE->GetEditDoc().GetObject( 0 );
     246           0 :         aNewSelection.Max() = EditPaM( pNode, pNode->Len() );
     247             :     }
     248             : 
     249          51 :     pImpEditView->DrawSelection();
     250          51 :     pImpEditView->SetEditSelection( aNewSelection );
     251          51 :     pImpEditView->DrawSelection();
     252          51 :     sal_Bool bGotoCursor = pImpEditView->DoAutoScroll();
     253          51 :     ShowCursor( bGotoCursor );
     254          51 : }
     255             : 
     256          65 : ESelection EditView::GetSelection() const
     257             : {
     258             :     DBG_CHKTHIS( EditView, 0 );
     259             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     260             : 
     261          65 :     ESelection aSelection;
     262             : 
     263          65 :     aSelection.nStartPara = PIMPE->GetEditDoc().GetPos( pImpEditView->GetEditSelection().Min().GetNode() );
     264          65 :     aSelection.nEndPara = PIMPE->GetEditDoc().GetPos( pImpEditView->GetEditSelection().Max().GetNode() );
     265             : 
     266          65 :     aSelection.nStartPos = pImpEditView->GetEditSelection().Min().GetIndex();
     267          65 :     aSelection.nEndPos = pImpEditView->GetEditSelection().Max().GetIndex();
     268             : 
     269          65 :     return aSelection;
     270             : }
     271             : 
     272         367 : sal_Bool EditView::HasSelection() const
     273             : {
     274             :     DBG_CHKTHIS( EditView, 0 );
     275         367 :     return pImpEditView->HasSelection();
     276             : }
     277             : 
     278           3 : void EditView::DeleteSelected()
     279             : {
     280             :     DBG_CHKTHIS( EditView, 0 );
     281             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     282           3 :     pImpEditView->DeleteSelected();
     283           3 : }
     284             : 
     285           0 : sal_uInt16 EditView::GetSelectedScriptType() const
     286             : {
     287             :     DBG_CHKTHIS( EditView, 0 );
     288             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     289           0 :     return PIMPE->GetScriptType( pImpEditView->GetEditSelection() );
     290             : }
     291             : 
     292         542 : void EditView::Paint( const Rectangle& rRect, OutputDevice* pTargetDevice )
     293             : {
     294             :     DBG_CHKTHIS( EditView, 0 );
     295             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     296         542 :     PIMPEE->Paint( pImpEditView, rRect, pTargetDevice );
     297         542 : }
     298             : 
     299           0 : void EditView::SetEditEngine( EditEngine* pEditEng )
     300             : {
     301             :     DBG_CHKTHIS( EditView, 0 );
     302             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     303           0 :     pImpEditView->pEditEngine = pEditEng;
     304           0 :     EditSelection aStartSel;
     305           0 :     aStartSel = PIMPE->GetEditDoc().GetStartPaM();
     306           0 :     pImpEditView->SetEditSelection( aStartSel );
     307           0 : }
     308             : 
     309           9 : void EditView::SetWindow( Window* pWin )
     310             : {
     311             :     DBG_CHKTHIS( EditView, 0 );
     312           9 :     pImpEditView->pOutWin = pWin;
     313           9 :     PIMPEE->GetSelEngine().Reset();
     314           9 : }
     315             : 
     316         187 : Window* EditView::GetWindow() const
     317             : {
     318             :     DBG_CHKTHIS( EditView, 0 );
     319         187 :     return pImpEditView->pOutWin;
     320             : }
     321             : 
     322          49 : void EditView::SetVisArea( const Rectangle& rRect )
     323             : {
     324             :     DBG_CHKTHIS( EditView, 0 );
     325          49 :     pImpEditView->SetVisDocStartPos( rRect.TopLeft() );
     326          49 : }
     327             : 
     328        1482 : const Rectangle& EditView::GetVisArea() const
     329             : {
     330             :     DBG_CHKTHIS( EditView, 0 );
     331             :     // Change return value to Rectangle in next incompatible build !!!
     332        1482 :     static Rectangle aRect;
     333        1482 :     aRect = pImpEditView->GetVisDocArea();
     334        1482 :     return aRect;
     335             : }
     336             : 
     337         297 : void EditView::SetOutputArea( const Rectangle& rRect )
     338             : {
     339             :     DBG_CHKTHIS( EditView, 0 );
     340         297 :     pImpEditView->SetOutputArea( rRect );
     341             : 
     342             :     // the rest here only if it is an API call:
     343         297 :     pImpEditView->CalcAnchorPoint();
     344         297 :     if ( PIMPEE->GetStatus().AutoPageSize() )
     345           0 :         pImpEditView->RecalcOutputArea();
     346         297 :     pImpEditView->ShowCursor( sal_False, sal_False );
     347         297 : }
     348             : 
     349         119 : const Rectangle& EditView::GetOutputArea() const
     350             : {
     351             :     DBG_CHKTHIS( EditView, 0 );
     352         119 :     return pImpEditView->GetOutputArea();
     353             : }
     354             : 
     355          45 : const Pointer& EditView::GetPointer() const
     356             : {
     357             :     DBG_CHKTHIS( EditView, 0 );
     358          45 :     return pImpEditView->GetPointer();
     359             : }
     360             : 
     361          19 : Cursor* EditView::GetCursor() const
     362             : {
     363             :     DBG_CHKTHIS( EditView, 0 );
     364          19 :     return pImpEditView->pCursor;
     365             : }
     366             : 
     367           7 : void EditView::InsertText( const XubString& rStr, sal_Bool bSelect )
     368             : {
     369             :     DBG_CHKTHIS( EditView, 0 );
     370             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     371             : 
     372           7 :     EditEngine* pEE = PIMPE;
     373           7 :     pImpEditView->DrawSelection();
     374             : 
     375           7 :     EditPaM aPaM1;
     376           7 :     if ( bSelect )
     377             :     {
     378           0 :         EditSelection aTmpSel( pImpEditView->GetEditSelection() );
     379           0 :         aTmpSel.Adjust( pEE->GetEditDoc() );
     380           0 :         aPaM1 = aTmpSel.Min();
     381             :     }
     382             : 
     383           7 :     pEE->UndoActionStart( EDITUNDO_INSERT );
     384           7 :     EditPaM aPaM2( pEE->InsertText( pImpEditView->GetEditSelection(), rStr ) );
     385           7 :     pEE->UndoActionEnd( EDITUNDO_INSERT );
     386             : 
     387           7 :     if ( bSelect )
     388             :     {
     389             :         DBG_ASSERT( !aPaM1.DbgIsBuggy( pEE->GetEditDoc() ), "Insert: PaM broken" );
     390           0 :         pImpEditView->SetEditSelection( EditSelection( aPaM1, aPaM2 ) );
     391             :     }
     392             :     else
     393           7 :         pImpEditView->SetEditSelection( EditSelection( aPaM2, aPaM2 ) );
     394             : 
     395           7 :     pEE->FormatAndUpdate( this );
     396           7 : }
     397             : 
     398           0 : sal_Bool EditView::PostKeyEvent( const KeyEvent& rKeyEvent, Window* pFrameWin )
     399             : {
     400             :     DBG_CHKTHIS( EditView, 0 );
     401             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     402           0 :     return pImpEditView->PostKeyEvent( rKeyEvent, pFrameWin );
     403             : }
     404             : 
     405           0 : sal_Bool EditView::MouseButtonUp( const MouseEvent& rMouseEvent )
     406             : {
     407             :     DBG_CHKTHIS( EditView, 0 );
     408             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     409           0 :     return pImpEditView->MouseButtonUp( rMouseEvent );
     410             : }
     411             : 
     412           0 : sal_Bool EditView::MouseButtonDown( const MouseEvent& rMouseEvent )
     413             : {
     414             :     DBG_CHKTHIS( EditView, 0 );
     415             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     416           0 :     return pImpEditView->MouseButtonDown( rMouseEvent );
     417             : }
     418             : 
     419           0 : sal_Bool EditView::MouseMove( const MouseEvent& rMouseEvent )
     420             : {
     421             :     DBG_CHKTHIS( EditView, 0 );
     422             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     423           0 :     return pImpEditView->MouseMove( rMouseEvent );
     424             : }
     425             : 
     426           0 : void EditView::Command( const CommandEvent& rCEvt )
     427             : {
     428             :     DBG_CHKTHIS( EditView, 0 );
     429             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     430           0 :     pImpEditView->Command( rCEvt );
     431           0 : }
     432             : 
     433         901 : void EditView::ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor )
     434             : {
     435             :     DBG_CHKTHIS( EditView, 0 );
     436             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     437             : 
     438         901 :     if ( pImpEditView->pEditEngine->HasView( this ) )
     439             :     {
     440             :         // The control word is more important:
     441         901 :         if ( !pImpEditView->DoAutoScroll() )
     442           0 :             bGotoCursor = sal_False;
     443         901 :         pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor );
     444             :     }
     445         901 : }
     446             : 
     447         459 : void EditView::HideCursor()
     448             : {
     449             :     DBG_CHKTHIS( EditView, 0 );
     450         459 :     pImpEditView->GetCursor()->Hide();
     451         459 : }
     452             : 
     453         108 : Pair EditView::Scroll( long ndX, long ndY, sal_uInt8 nRangeCheck )
     454             : {
     455             :     DBG_CHKTHIS( EditView, 0 );
     456             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     457         108 :     return pImpEditView->Scroll( ndX, ndY, nRangeCheck );
     458             : }
     459             : 
     460           0 : const SfxItemSet& EditView::GetEmptyItemSet()
     461             : {
     462             :     DBG_CHKTHIS( EditView, 0 );
     463             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     464           0 :     return PIMPE->GetEmptyItemSet();
     465             : }
     466             : 
     467          22 : void EditView::SetAttribs( const SfxItemSet& rSet )
     468             : {
     469             :     DBG_CHKTHIS( EditView, 0 );
     470             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     471             :     DBG_ASSERT( !pImpEditView->aEditSelection.IsInvalid(), "Blind Selection in ...." );
     472             : 
     473          22 :     pImpEditView->DrawSelection();
     474          22 :     PIMPE->SetAttribs( pImpEditView->GetEditSelection(), rSet, ATTRSPECIAL_WHOLEWORD );
     475          22 :     PIMPE->FormatAndUpdate( this );
     476          22 : }
     477             : 
     478           0 : void EditView::RemoveAttribsKeepLanguages( sal_Bool bRemoveParaAttribs )
     479             : {
     480             :     DBG_CHKTHIS( EditView, 0 );
     481             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     482             : 
     483           0 :     pImpEditView->DrawSelection();
     484           0 :     PIMPE->UndoActionStart( EDITUNDO_RESETATTRIBS );
     485           0 :     EditSelection aSelection( pImpEditView->GetEditSelection() );
     486             : 
     487           0 :     for (sal_uInt16 nWID = EE_ITEMS_START; nWID <= EE_ITEMS_END; ++nWID)
     488             :     {
     489           0 :         bool bIsLang =  EE_CHAR_LANGUAGE     == nWID ||
     490           0 :                         EE_CHAR_LANGUAGE_CJK == nWID ||
     491           0 :                         EE_CHAR_LANGUAGE_CTL == nWID;
     492           0 :         if (!bIsLang)
     493           0 :             PIMPE->RemoveCharAttribs( aSelection, bRemoveParaAttribs, nWID );
     494             :     }
     495             : 
     496           0 :     PIMPE->UndoActionEnd( EDITUNDO_RESETATTRIBS );
     497           0 :     PIMPE->FormatAndUpdate( this );
     498           0 : }
     499             : 
     500           0 : void EditView::RemoveAttribs( sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich )
     501             : {
     502             :     DBG_CHKTHIS( EditView, 0 );
     503             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     504             : 
     505           0 :     pImpEditView->DrawSelection();
     506           0 :     PIMPE->UndoActionStart( EDITUNDO_RESETATTRIBS );
     507           0 :     PIMPE->RemoveCharAttribs( pImpEditView->GetEditSelection(), bRemoveParaAttribs, nWhich  );
     508           0 :     PIMPE->UndoActionEnd( EDITUNDO_RESETATTRIBS );
     509           0 :     PIMPE->FormatAndUpdate( this );
     510           0 : }
     511             : 
     512           0 : void EditView::RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich )
     513             : {
     514             :     DBG_CHKTHIS( EditView, 0 );
     515             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     516           0 :     PIMPE->UndoActionStart( EDITUNDO_RESETATTRIBS );
     517           0 :     PIMPE->RemoveCharAttribs( nPara, nWhich );
     518           0 :     PIMPE->UndoActionEnd( EDITUNDO_RESETATTRIBS );
     519           0 :     PIMPE->FormatAndUpdate( this );
     520           0 : }
     521             : 
     522           9 : SfxItemSet EditView::GetAttribs()
     523             : {
     524             :     DBG_CHKTHIS( EditView, 0 );
     525             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     526             :     DBG_ASSERT( !pImpEditView->aEditSelection.IsInvalid(), "Blind Selection in ...." );
     527           9 :     return PIMPEE->GetAttribs( pImpEditView->GetEditSelection() );
     528             : }
     529             : 
     530           0 : void EditView::Undo()
     531             : {
     532             :     DBG_CHKTHIS( EditView, 0 );
     533             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     534           0 :     PIMPE->Undo( this );
     535           0 : }
     536             : 
     537           0 : void EditView::Redo()
     538             : {
     539             :     DBG_CHKTHIS( EditView, 0 );
     540             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     541           0 :     PIMPE->Redo( this );
     542           0 : }
     543             : 
     544           0 : sal_uLong EditView::Read( SvStream& rInput, const String& rBaseURL, EETextFormat eFormat, sal_Bool bSelect, SvKeyValueIterator* pHTTPHeaderAttrs )
     545             : {
     546             :     DBG_CHKTHIS( EditView, 0 );
     547             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     548           0 :     EditSelection aOldSel( pImpEditView->GetEditSelection() );
     549           0 :     pImpEditView->DrawSelection();
     550           0 :     PIMPEE->UndoActionStart( EDITUNDO_READ );
     551           0 :     EditPaM aEndPaM = PIMPEE->Read( rInput, rBaseURL, eFormat, aOldSel, pHTTPHeaderAttrs );
     552           0 :     PIMPEE->UndoActionEnd( EDITUNDO_READ );
     553           0 :     EditSelection aNewSel( aEndPaM, aEndPaM );
     554           0 :     if ( bSelect )
     555             :     {
     556           0 :         aOldSel.Adjust( PIMPE->GetEditDoc() );
     557           0 :         aNewSel.Min() = aOldSel.Min();
     558             :     }
     559             : 
     560           0 :     pImpEditView->SetEditSelection( aNewSel );
     561           0 :     sal_Bool bGotoCursor = pImpEditView->DoAutoScroll();
     562           0 :     ShowCursor( bGotoCursor );
     563             : 
     564           0 :     return rInput.GetError();
     565             : }
     566             : 
     567           0 : void EditView::Cut()
     568             : {
     569             :     DBG_CHKTHIS( EditView, 0 );
     570           0 :     Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetClipboard());
     571           0 :     pImpEditView->CutCopy( aClipBoard, sal_True );
     572           0 : }
     573             : 
     574           0 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > EditView::GetTransferable()
     575             : {
     576             :     uno::Reference< datatransfer::XTransferable > xData =
     577           0 :         GetEditEngine()->CreateTransferable( pImpEditView->GetEditSelection() );
     578           0 :     return xData;
     579             : }
     580             : 
     581           0 : void EditView::Copy()
     582             : {
     583             :     DBG_CHKTHIS( EditView, 0 );
     584           0 :     Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetClipboard());
     585           0 :     pImpEditView->CutCopy( aClipBoard, sal_False );
     586           0 : }
     587             : 
     588           0 : void EditView::Paste()
     589             : {
     590             :     DBG_CHKTHIS( EditView, 0 );
     591           0 :     Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetClipboard());
     592           0 :     pImpEditView->Paste( aClipBoard, sal_False );
     593           0 : }
     594             : 
     595           0 : void EditView::PasteSpecial()
     596             : {
     597             :     DBG_CHKTHIS( EditView, 0 );
     598           0 :     Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetClipboard());
     599           0 :     pImpEditView->Paste(aClipBoard, sal_True );
     600           0 : }
     601             : 
     602           0 : Point EditView::GetWindowPosTopLeft( sal_Int32 nParagraph )
     603             : {
     604             :     DBG_CHKTHIS( EditView, 0 );
     605             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     606           0 :     Point aDocPos( pImpEditView->pEditEngine->GetDocPosTopLeft( nParagraph ) );
     607           0 :     return pImpEditView->GetWindowPos( aDocPos );
     608             : }
     609             : 
     610          22 : void EditView::SetSelectionMode( EESelectionMode eMode )
     611             : {
     612             :     DBG_CHKTHIS( EditView, 0 );
     613          22 :     pImpEditView->SetSelectionMode( eMode );
     614          22 : }
     615             : 
     616           0 : XubString EditView::GetSelected()
     617             : {
     618             :     DBG_CHKTHIS( EditView, 0 );
     619             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     620           0 :     return PIMPEE->GetSelected( pImpEditView->GetEditSelection() );
     621             : }
     622             : 
     623           0 : void EditView::MoveParagraphs( Range aParagraphs, sal_Int32 nNewPos )
     624             : {
     625             :     DBG_CHKTHIS( EditView, 0 );
     626             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     627           0 :     PIMPEE->UndoActionStart( EDITUNDO_MOVEPARAS );
     628           0 :     PIMPEE->MoveParagraphs( aParagraphs, nNewPos, this );
     629           0 :     PIMPEE->UndoActionEnd( EDITUNDO_MOVEPARAS );
     630           0 : }
     631             : 
     632           0 : void EditView::MoveParagraphs( long nDiff )
     633             : {
     634             :     DBG_CHKTHIS( EditView, 0 );
     635             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     636           0 :     ESelection aSel = GetSelection();
     637           0 :     Range aRange( aSel.nStartPara, aSel.nEndPara );
     638           0 :     aRange.Justify();
     639           0 :     long nDest = ( nDiff > 0  ? aRange.Max() : aRange.Min() ) + nDiff;
     640           0 :     if ( nDiff > 0 )
     641           0 :         nDest++;
     642             :     DBG_ASSERT( ( nDest >= 0 ) && ( nDest <= pImpEditView->pEditEngine->GetParagraphCount() ), "MoveParagraphs - wrong Parameters!" );
     643           0 :     MoveParagraphs( aRange, sal::static_int_cast< sal_Int32 >( nDest ) );
     644           0 : }
     645             : 
     646           9 : void EditView::SetBackgroundColor( const Color& rColor )
     647             : {
     648             :     DBG_CHKTHIS( EditView, 0 );
     649             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     650           9 :     pImpEditView->SetBackgroundColor( rColor );
     651           9 : }
     652             : 
     653           0 : Color EditView::GetBackgroundColor() const
     654             : {
     655             :     DBG_CHKTHIS( EditView, 0 );
     656             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     657           0 :     return pImpEditView->GetBackgroundColor();
     658             : }
     659             : 
     660         223 : void EditView::SetControlWord( sal_uInt32 nWord )
     661             : {
     662             :     DBG_CHKTHIS( EditView, 0 );
     663         223 :     pImpEditView->nControl = nWord;
     664         223 : }
     665             : 
     666         223 : sal_uInt32 EditView::GetControlWord() const
     667             : {
     668             :     DBG_CHKTHIS( EditView, 0 );
     669         223 :     return pImpEditView->nControl;
     670             : }
     671             : 
     672           0 : EditTextObject* EditView::CreateTextObject()
     673             : {
     674             :     DBG_CHKTHIS( EditView, 0 );
     675             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     676           0 :     return PIMPEE->CreateTextObject( pImpEditView->GetEditSelection() );
     677             : }
     678             : 
     679           0 : void EditView::InsertText( const EditTextObject& rTextObject )
     680             : {
     681             :     DBG_CHKTHIS( EditView, 0 );
     682             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     683           0 :     pImpEditView->DrawSelection();
     684             : 
     685           0 :     PIMPE->UndoActionStart( EDITUNDO_INSERT );
     686           0 :     EditSelection aTextSel( PIMPE->InsertText( rTextObject, pImpEditView->GetEditSelection() ) );
     687           0 :     PIMPE->UndoActionEnd( EDITUNDO_INSERT );
     688             : 
     689           0 :     aTextSel.Min() = aTextSel.Max();    // Selection not retained.
     690           0 :     pImpEditView->SetEditSelection( aTextSel );
     691           0 :     PIMPE->FormatAndUpdate( this );
     692           0 : }
     693             : 
     694           0 : void EditView::InsertText( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xDataObj, const String& rBaseURL, sal_Bool bUseSpecial )
     695             : {
     696             :     DBG_CHKTHIS( EditView, 0 );
     697             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     698             : 
     699           0 :     PIMPE->UndoActionStart( EDITUNDO_INSERT );
     700           0 :     pImpEditView->DeleteSelected();
     701             :     EditSelection aTextSel =
     702           0 :         PIMPE->InsertText(xDataObj, rBaseURL, pImpEditView->GetEditSelection().Max(), bUseSpecial);
     703           0 :     PIMPE->UndoActionEnd( EDITUNDO_INSERT );
     704             : 
     705           0 :     aTextSel.Min() = aTextSel.Max();    // Selection not retained.
     706           0 :     pImpEditView->SetEditSelection( aTextSel );
     707           0 :     PIMPE->FormatAndUpdate( this );
     708           0 : }
     709             : 
     710          22 : void EditView::SetEditEngineUpdateMode( sal_Bool bUpdate )
     711             : {
     712             :     DBG_CHKTHIS( EditView, 0 );
     713             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     714          22 :     PIMPEE->SetUpdateMode( bUpdate, this );
     715          22 : }
     716             : 
     717         116 : void EditView::ForceUpdate()
     718             : {
     719             :     DBG_CHKTHIS( EditView, 0 );
     720             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     721         116 :     PIMPEE->SetUpdateMode( sal_True, this, sal_True );
     722         116 : }
     723             : 
     724           0 : SfxStyleSheet* EditView::GetStyleSheet()
     725             : {
     726             :     DBG_CHKTHIS( EditView, 0 );
     727             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     728             : 
     729             : 
     730           0 :     EditSelection aSel( pImpEditView->GetEditSelection() );
     731           0 :     aSel.Adjust( PIMPE->GetEditDoc() );
     732           0 :     sal_Int32 nStartPara = PIMPE->GetEditDoc().GetPos( aSel.Min().GetNode() );
     733           0 :     sal_Int32 nEndPara = PIMPE->GetEditDoc().GetPos( aSel.Max().GetNode() );
     734             : 
     735           0 :     SfxStyleSheet* pStyle = NULL;
     736           0 :     for ( sal_Int32 n = nStartPara; n <= nEndPara; n++ )
     737             :     {
     738           0 :         SfxStyleSheet* pTmpStyle = PIMPE->GetStyleSheet( n );
     739           0 :         if ( ( n != nStartPara ) && ( pStyle != pTmpStyle ) )
     740           0 :             return NULL;    // Not unique.
     741           0 :         pStyle = pTmpStyle;
     742             :     }
     743           0 :     return pStyle;
     744             : }
     745             : 
     746           0 : const SfxStyleSheet* EditView::GetStyleSheet() const
     747             : {
     748           0 :     return const_cast< EditView* >( this )->GetStyleSheet();
     749             : }
     750             : 
     751          47 : sal_Bool EditView::IsInsertMode() const
     752             : {
     753             :     DBG_CHKTHIS( EditView, 0 );
     754          47 :     return pImpEditView->IsInsertMode();
     755             : }
     756             : 
     757         203 : void EditView::SetInsertMode( sal_Bool bInsert )
     758             : {
     759             :     DBG_CHKTHIS( EditView, 0 );
     760         203 :     pImpEditView->SetInsertMode( bInsert );
     761         203 : }
     762             : 
     763           0 : void EditView::SetAnchorMode( EVAnchorMode eMode )
     764             : {
     765             :     DBG_CHKTHIS( EditView, 0 );
     766           0 :     pImpEditView->SetAnchorMode( eMode );
     767           0 : }
     768             : 
     769           0 : EVAnchorMode EditView::GetAnchorMode() const
     770             : {
     771             :     DBG_CHKTHIS( EditView, 0 );
     772           0 :     return pImpEditView->GetAnchorMode();
     773             : }
     774             : 
     775           0 : void EditView::TransliterateText( sal_Int32 nTransliterationMode )
     776             : {
     777             :     DBG_CHKTHIS( EditView, 0 );
     778           0 :     EditSelection aOldSel( pImpEditView->GetEditSelection() );
     779           0 :     EditSelection aNewSel = PIMPE->TransliterateText( pImpEditView->GetEditSelection(), nTransliterationMode );
     780           0 :     if ( aNewSel != aOldSel )
     781             :     {
     782           0 :         pImpEditView->DrawSelection();
     783           0 :         pImpEditView->SetEditSelection( aNewSel );
     784           0 :         pImpEditView->DrawSelection();
     785             :     }
     786           0 : }
     787             : 
     788           0 : void EditView::CompleteAutoCorrect( Window* pFrameWin )
     789             : {
     790             :     DBG_CHKTHIS( EditView, 0 );
     791             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     792           0 :     if ( !pImpEditView->HasSelection() && PIMPEE->GetStatus().DoAutoCorrect() )
     793             :     {
     794           0 :         pImpEditView->DrawSelection();
     795           0 :         EditSelection aSel = pImpEditView->GetEditSelection();
     796           0 :         aSel = PIMPE->EndOfWord( aSel.Max() );
     797           0 :         aSel = PIMPEE->AutoCorrect( aSel, 0, !IsInsertMode(), pFrameWin );
     798           0 :         pImpEditView->SetEditSelection( aSel );
     799           0 :         if ( PIMPE->IsModified() )
     800           0 :             PIMPE->FormatAndUpdate( this );
     801             :     }
     802           0 : }
     803             : 
     804           9 : EESpellState EditView::StartSpeller( sal_Bool bMultipleDoc )
     805             : {
     806             :     DBG_CHKTHIS( EditView, 0 );
     807             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     808           9 :     if ( !PIMPEE->GetSpeller().is() )
     809           0 :         return EE_SPELL_NOSPELLER;
     810             : 
     811           9 :     return PIMPEE->Spell( this, bMultipleDoc );
     812             : }
     813             : 
     814           0 : EESpellState EditView::StartThesaurus()
     815             : {
     816             :     DBG_CHKTHIS( EditView, 0 );
     817             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     818           0 :     if ( !PIMPEE->GetSpeller().is() )
     819           0 :         return EE_SPELL_NOSPELLER;
     820             : 
     821           0 :     return PIMPEE->StartThesaurus( this );
     822             : }
     823             : 
     824             : 
     825           0 : void EditView::StartTextConversion(
     826             :         LanguageType nSrcLang, LanguageType nDestLang, const Font *pDestFont,
     827             :         sal_Int32 nOptions, sal_Bool bIsInteractive, sal_Bool bMultipleDoc )
     828             : {
     829             :     DBG_CHKTHIS( EditView, 0 );
     830             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     831           0 :     PIMPEE->Convert( this, nSrcLang, nDestLang, pDestFont, nOptions, bIsInteractive, bMultipleDoc );
     832           0 : }
     833             : 
     834             : 
     835           0 : sal_uInt16 EditView::StartSearchAndReplace( const SvxSearchItem& rSearchItem )
     836             : {
     837             :     DBG_CHKTHIS( EditView, 0 );
     838             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     839           0 :     return PIMPEE->StartSearchAndReplace( this, rSearchItem );
     840             : }
     841             : 
     842           0 : sal_Bool EditView::IsCursorAtWrongSpelledWord( sal_Bool bMarkIfWrong )
     843             : {
     844             :     DBG_CHKTHIS( EditView, 0 );
     845             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     846           0 :     sal_Bool bIsWrong = sal_False;
     847           0 :     if ( !HasSelection() )
     848             :     {
     849           0 :         EditPaM aPaM = pImpEditView->GetEditSelection().Max();
     850           0 :         bIsWrong = pImpEditView->IsWrongSpelledWord( aPaM, bMarkIfWrong );
     851             :     }
     852           0 :     return bIsWrong;
     853             : }
     854             : 
     855           0 : sal_Bool EditView::IsWrongSpelledWordAtPos( const Point& rPosPixel, sal_Bool bMarkIfWrong )
     856             : {
     857             :     DBG_CHKTHIS( EditView, 0 );
     858             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     859           0 :     Point aPos ( pImpEditView->GetWindow()->PixelToLogic( rPosPixel ) );
     860           0 :     aPos = pImpEditView->GetDocPos( aPos );
     861           0 :     EditPaM aPaM = pImpEditView->pEditEngine->GetPaM(aPos, false);
     862           0 :     return pImpEditView->IsWrongSpelledWord( aPaM , bMarkIfWrong );
     863             : }
     864             : 
     865             : 
     866           0 : static Image lcl_GetImageFromPngUrl( const OUString &rFileUrl )
     867             : {
     868           0 :     Image aRes;
     869           0 :     OUString aTmp;
     870           0 :     osl::FileBase::getSystemPathFromFileURL( rFileUrl, aTmp );
     871             : //    OString aPath = OString( aTmp.getStr(), aTmp.getLength(), osl_getThreadTextEncoding() );
     872             : #if defined(WNT)
     873             : //    aTmp = lcl_Win_GetShortPathName( aTmp );
     874             : #endif
     875           0 :     Graphic aGraphic;
     876           0 :     const String aFilterName(  IMP_PNG  );
     877           0 :     if( GRFILTER_OK == GraphicFilter::LoadGraphic( aTmp, aFilterName, aGraphic ) )
     878             :     {
     879           0 :         aRes = Image( aGraphic.GetBitmapEx() );
     880             :     }
     881           0 :     return aRes;
     882             : }
     883             : 
     884             : 
     885           0 : void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack )
     886             : {
     887             :     DBG_CHKTHIS( EditView, 0 );
     888             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
     889             : 
     890           0 :     Point aPos ( pImpEditView->GetWindow()->PixelToLogic( rPosPixel ) );
     891           0 :     aPos = pImpEditView->GetDocPos( aPos );
     892           0 :     EditPaM aPaM = pImpEditView->pEditEngine->GetPaM(aPos, false);
     893           0 :     Reference< linguistic2::XSpellChecker1 >  xSpeller( PIMPEE->GetSpeller() );
     894           0 :     ESelection aOldSel = GetSelection();
     895           0 :     if ( xSpeller.is() && pImpEditView->IsWrongSpelledWord( aPaM, sal_True ) )
     896             :     {
     897           0 :         PopupMenu aPopupMenu( EditResId( RID_MENU_SPELL ) );
     898           0 :         PopupMenu *pAutoMenu = aPopupMenu.GetPopupMenu( MN_AUTOCORR );
     899           0 :         PopupMenu *pInsertMenu = aPopupMenu.GetPopupMenu( MN_INSERT );  // add word to user-dictionaries
     900           0 :         pInsertMenu->SetMenuFlags( MENU_FLAG_NOAUTOMNEMONICS );         //! necessary to retrieve the correct dictionary names later
     901             : 
     902           0 :         EditPaM aPaM2( aPaM );
     903           0 :         aPaM2.GetIndex()++;
     904             : 
     905             :         // Are there any replace suggestions?
     906           0 :         String aSelected( GetSelected() );
     907             :         //
     908             :         // restrict the maximal number of suggestions displayed
     909             :         // in the context menu.
     910             :         // Note: That could of course be done by clipping the
     911             :         // resulting sequence but the current third party
     912             :         // implementations result differs greatly if the number of
     913             :         // suggestions to be retuned gets changed. Statistically
     914             :         // it gets much better if told to return e.g. only 7 strings
     915             :         // than returning e.g. 16 suggestions and using only the
     916             :         // first 7. Thus we hand down the value to use to that
     917             :         // implementation here by providing an additional parameter.
     918           0 :         Sequence< PropertyValue > aPropVals(1);
     919           0 :         PropertyValue &rVal = aPropVals.getArray()[0];
     920           0 :         rVal.Name = OUString( UPN_MAX_NUMBER_OF_SUGGESTIONS );
     921           0 :         rVal.Value <<= (sal_Int16) 7;
     922             :         //
     923             :         // Are there any replace suggestions?
     924             :         Reference< linguistic2::XSpellAlternatives >  xSpellAlt =
     925           0 :                 xSpeller->spell( aSelected, PIMPEE->GetLanguage( aPaM2 ), aPropVals );
     926             : 
     927           0 :         Reference< linguistic2::XLanguageGuessing >  xLangGuesser( EE_DLL().GetGlobalData()->GetLanguageGuesser() );
     928             : 
     929             :         // check if text might belong to a different language...
     930           0 :         LanguageType nGuessLangWord = LANGUAGE_NONE;
     931           0 :         LanguageType nGuessLangPara = LANGUAGE_NONE;
     932           0 :         if (xSpellAlt.is() && xLangGuesser.is())
     933             :         {
     934           0 :             String aParaText;
     935           0 :             ContentNode *pNode = aPaM.GetNode();
     936           0 :             if (pNode)
     937             :             {
     938           0 :                 aParaText = pNode->GetString();
     939             :             }
     940             :             else
     941             :             {
     942             :                 OSL_FAIL( "content node is NULL" );
     943             :             }
     944             : 
     945           0 :             nGuessLangWord = CheckLanguage( xSpellAlt->getWord(), xSpeller, xLangGuesser, false );
     946           0 :             nGuessLangPara = CheckLanguage( aParaText, xSpeller, xLangGuesser, true );
     947             :         }
     948           0 :         if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
     949             :         {
     950             :             // make sure LANGUAGE_NONE gets not used as menu entry
     951           0 :             if (nGuessLangWord == LANGUAGE_NONE)
     952           0 :                 nGuessLangWord = nGuessLangPara;
     953           0 :             if (nGuessLangPara == LANGUAGE_NONE)
     954           0 :                 nGuessLangPara = nGuessLangWord;
     955             : 
     956           0 :             aPopupMenu.InsertSeparator();
     957           0 :             String aTmpWord( SvtLanguageTable::GetLanguageString( nGuessLangWord ) );
     958           0 :             String aTmpPara( SvtLanguageTable::GetLanguageString( nGuessLangPara ) );
     959           0 :             String aWordStr( EE_RESSTR( RID_STR_WORD ) );
     960           0 :             aWordStr.SearchAndReplace( String(  "%x"  ), aTmpWord );
     961           0 :             String aParaStr( EE_RESSTR( RID_STR_PARAGRAPH ) );
     962           0 :             aParaStr.SearchAndReplace( String(  "%x"  ), aTmpPara );
     963           0 :             aPopupMenu.InsertItem( MN_WORDLANGUAGE, aWordStr );
     964           0 :             aPopupMenu.SetHelpId( MN_WORDLANGUAGE, HID_EDITENG_SPELLER_WORDLANGUAGE );
     965           0 :             aPopupMenu.InsertItem( MN_PARALANGUAGE, aParaStr );
     966           0 :             aPopupMenu.SetHelpId( MN_PARALANGUAGE, HID_EDITENG_SPELLER_PARALANGUAGE );
     967             :         }
     968             : 
     969             :         // ## Create mnemonics here
     970           0 :         if ( Application::IsAutoMnemonicEnabled() )
     971             :         {
     972           0 :             aPopupMenu.CreateAutoMnemonics();
     973           0 :             aPopupMenu.SetMenuFlags( aPopupMenu.GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS );
     974             :         }
     975             : 
     976             :         // Replace suggestions...
     977           0 :         Sequence< OUString > aAlt;
     978           0 :         if (xSpellAlt.is())
     979           0 :             aAlt = xSpellAlt->getAlternatives();
     980           0 :         const OUString *pAlt = aAlt.getConstArray();
     981           0 :         sal_uInt16 nWords = (sal_uInt16) aAlt.getLength();
     982           0 :         if ( nWords )
     983             :         {
     984           0 :             for ( sal_uInt16 nW = 0; nW < nWords; nW++ )
     985             :             {
     986           0 :                 String aAlternate( pAlt[nW] );
     987           0 :                 aPopupMenu.InsertItem( MN_ALTSTART+nW, aAlternate, 0, OString(), nW );
     988           0 :                 pAutoMenu->InsertItem( MN_AUTOSTART+nW, aAlternate, 0, OString(), nW );
     989           0 :             }
     990           0 :             aPopupMenu.InsertSeparator(OString(), nWords);
     991             :         }
     992             :         else
     993           0 :             aPopupMenu.RemoveItem( MN_AUTOCORR );   // delete?
     994             : 
     995           0 :         SvtLinguConfig aCfg;
     996             : 
     997           0 :         Reference< linguistic2::XSearchableDictionaryList >  xDicList( SvxGetDictionaryList() );
     998           0 :         Sequence< Reference< linguistic2::XDictionary >  > aDics;
     999           0 :         if (xDicList.is())
    1000             :         {
    1001           0 :             const Reference< linguistic2::XDictionary >  *pDic = NULL;
    1002             :             // add the default positive dictionary to dic-list (if not already done).
    1003             :             // This is to ensure that there is at least one dictionary to which
    1004             :             // words could be added.
    1005           0 :             uno::Reference< linguistic2::XDictionary >  xDic( SvxGetOrCreatePosDic( xDicList ) );
    1006           0 :             if (xDic.is())
    1007           0 :                 xDic->setActive( sal_True );
    1008             : 
    1009           0 :             aDics = xDicList->getDictionaries();
    1010           0 :             pDic  = aDics.getConstArray();
    1011           0 :             sal_uInt16 nCheckedLanguage = PIMPEE->GetLanguage( aPaM2 );
    1012           0 :             sal_uInt16 nDicCount = (sal_uInt16)aDics.getLength();
    1013           0 :             for (sal_uInt16 i = 0; i < nDicCount; i++)
    1014             :             {
    1015           0 :                 uno::Reference< linguistic2::XDictionary >  xDicTmp( pDic[i], uno::UNO_QUERY );
    1016           0 :                 if (!xDicTmp.is() || SvxGetIgnoreAllList() == xDicTmp)
    1017           0 :                     continue;
    1018             : 
    1019           0 :                 uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
    1020           0 :                 LanguageType nActLanguage = LanguageTag( xDicTmp->getLocale() ).getLanguageType();
    1021           0 :                 if( xDicTmp->isActive()
    1022           0 :                     &&  xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
    1023           0 :                     && (nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage )
    1024           0 :                     && (!xStor.is() || !xStor->isReadonly()) )
    1025             :                 {
    1026             :                     // the extra 1 is because of the (possible) external
    1027             :                     // linguistic entry above
    1028           0 :                     sal_uInt16 nPos = MN_DICTSTART + i;
    1029           0 :                     pInsertMenu->InsertItem( nPos, xDicTmp->getName() );
    1030           0 :                     aDicNameSingle = xDicTmp->getName();
    1031             : 
    1032           0 :                     uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
    1033           0 :                     if (xSvcInfo.is())
    1034             :                     {
    1035             :                         OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage(
    1036           0 :                                 xSvcInfo->getImplementationName()) );
    1037           0 :                         if (!aDictionaryImageUrl.isEmpty() )
    1038             :                         {
    1039           0 :                             Image aImage( lcl_GetImageFromPngUrl( aDictionaryImageUrl ) );
    1040           0 :                             pInsertMenu->SetItemImage( nPos, aImage );
    1041           0 :                         }
    1042           0 :                     }
    1043             :                 }
    1044           0 :             }
    1045             :         }
    1046           0 :         if ( pInsertMenu->GetItemCount() != 1)
    1047           0 :             aPopupMenu.EnableItem( MN_INSERT_SINGLE, sal_False );
    1048           0 :         if ( pInsertMenu->GetItemCount() < 2 )
    1049           0 :             aPopupMenu.EnableItem( MN_INSERT, sal_False );
    1050             : 
    1051           0 :         aPopupMenu.RemoveDisabledEntries( sal_True, sal_True );
    1052             : 
    1053           0 :         Rectangle aTempRect = PIMPEE->PaMtoEditCursor( aPaM, GETCRSR_TXTONLY );
    1054           0 :         Point aScreenPos = pImpEditView->GetWindowPos( aTempRect.TopLeft() );
    1055           0 :         aScreenPos = pImpEditView->GetWindow()->OutputToScreenPixel( aScreenPos );
    1056           0 :         aTempRect = pImpEditView->GetWindow()->LogicToPixel( Rectangle(aScreenPos, aTempRect.GetSize() ));
    1057             : 
    1058           0 :         sal_uInt16 nId = aPopupMenu.Execute( pImpEditView->GetWindow(), aTempRect, POPUPMENU_NOMOUSEUPCLOSE );
    1059           0 :         if ( nId == MN_IGNORE )
    1060             :         {
    1061           0 :             String aWord = pImpEditView->SpellIgnoreOrAddWord( sal_False );
    1062           0 :             if ( pCallBack )
    1063             :             {
    1064           0 :                 SpellCallbackInfo aInf( SPELLCMD_IGNOREWORD, aWord );
    1065           0 :                 pCallBack->Call( &aInf );
    1066             :             }
    1067           0 :             SetSelection( aOldSel );
    1068             :         }
    1069           0 :         else if ( ( nId == MN_WORDLANGUAGE ) || ( nId == MN_PARALANGUAGE ) )
    1070             :         {
    1071           0 :             LanguageType nLangToUse = (nId == MN_WORDLANGUAGE) ? nGuessLangWord : nGuessLangPara;
    1072           0 :             sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse );
    1073             : 
    1074           0 :             SfxItemSet aAttrs = GetEditEngine()->GetEmptyItemSet();
    1075           0 :             if (nScriptType == SCRIPTTYPE_LATIN)
    1076           0 :                 aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) );
    1077           0 :             if (nScriptType == SCRIPTTYPE_COMPLEX)
    1078           0 :                 aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) );
    1079           0 :             if (nScriptType == SCRIPTTYPE_ASIAN)
    1080           0 :                 aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) );
    1081           0 :             if ( nId == MN_PARALANGUAGE )
    1082             :             {
    1083           0 :                 ESelection aSel = GetSelection();
    1084           0 :                 aSel.nStartPos = 0;
    1085           0 :                 aSel.nEndPos = EE_TEXTPOS_ALL;
    1086           0 :                 SetSelection( aSel );
    1087             :             }
    1088           0 :             SetAttribs( aAttrs );
    1089           0 :             PIMPEE->StartOnlineSpellTimer();
    1090             : 
    1091           0 :             if ( pCallBack )
    1092             :             {
    1093           0 :                 SpellCallbackInfo aInf( ( nId == MN_WORDLANGUAGE ) ? SPELLCMD_WORDLANGUAGE : SPELLCMD_PARALANGUAGE, nLangToUse );
    1094           0 :                 pCallBack->Call( &aInf );
    1095             :             }
    1096           0 :             SetSelection( aOldSel );
    1097             :         }
    1098           0 :         else if ( nId == MN_SPELLING )
    1099             :         {
    1100           0 :             if ( !pCallBack )
    1101             :             {
    1102             :                 // Set Cursor before word...
    1103           0 :                 EditPaM aCursor = pImpEditView->GetEditSelection().Min();
    1104           0 :                 pImpEditView->DrawSelection();
    1105           0 :                 pImpEditView->SetEditSelection( EditSelection( aCursor, aCursor ) );
    1106           0 :                 pImpEditView->DrawSelection();
    1107             :                 // Crashes when no SfxApp
    1108           0 :                 PIMPEE->Spell( this, sal_False );
    1109             :             }
    1110             :             else
    1111             :             {
    1112           0 :                 SpellCallbackInfo aInf( SPELLCMD_STARTSPELLDLG, String() );
    1113           0 :                 pCallBack->Call( &aInf );
    1114             :             }
    1115             :         }
    1116           0 :         else if ( nId >= MN_DICTSTART || nId == MN_INSERT_SINGLE )
    1117             :         {
    1118           0 :             String aDicName;
    1119           0 :             if (nId >= MN_DICTSTART)
    1120           0 :                 aDicName = pInsertMenu->GetItemText(nId);
    1121             :             else
    1122           0 :                 aDicName = aDicNameSingle;
    1123             : 
    1124           0 :             uno::Reference< linguistic2::XDictionary >      xDic;
    1125           0 :             if (xDicList.is())
    1126           0 :                 xDic = xDicList->getDictionaryByName( aDicName );
    1127             : 
    1128           0 :             if (xDic.is())
    1129           0 :                 xDic->add( aSelected, sal_False, String() );
    1130             :             // save modified user-dictionary if it is persistent
    1131           0 :             Reference< frame::XStorable >  xSavDic( xDic, UNO_QUERY );
    1132           0 :             if (xSavDic.is())
    1133           0 :                 xSavDic->store();
    1134             : 
    1135           0 :             aPaM.GetNode()->GetWrongList()->GetInvalidStart() = 0;
    1136           0 :             aPaM.GetNode()->GetWrongList()->GetInvalidEnd() = aPaM.GetNode()->Len();
    1137           0 :             PIMPEE->StartOnlineSpellTimer();
    1138             : 
    1139           0 :             if ( pCallBack )
    1140             :             {
    1141           0 :                 SpellCallbackInfo aInf( SPELLCMD_ADDTODICTIONARY, aSelected );
    1142           0 :                 pCallBack->Call( &aInf );
    1143             :             }
    1144           0 :             SetSelection( aOldSel );
    1145             :         }
    1146           0 :         else if ( nId >= MN_AUTOSTART )
    1147             :         {
    1148             :             DBG_ASSERT(nId - MN_AUTOSTART < aAlt.getLength(), "index out of range");
    1149           0 :             String aWord = pAlt[nId - MN_AUTOSTART];
    1150           0 :             SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
    1151           0 :             if ( pAutoCorrect )
    1152           0 :                 pAutoCorrect->PutText( aSelected, aWord, PIMPEE->GetLanguage( aPaM2 ) );
    1153           0 :             InsertText( aWord );
    1154             :         }
    1155           0 :         else if ( nId >= MN_ALTSTART )  // Replace
    1156             :         {
    1157             :             DBG_ASSERT(nId - MN_ALTSTART < aAlt.getLength(), "index out of range");
    1158           0 :             String aWord = pAlt[nId - MN_ALTSTART];
    1159           0 :             InsertText( aWord );
    1160             :         }
    1161             :         else
    1162             :         {
    1163           0 :             SetSelection( aOldSel );
    1164           0 :         }
    1165           0 :     }
    1166           0 : }
    1167             : 
    1168           0 : sal_Bool EditView::SelectCurrentWord( sal_Int16 nWordType )
    1169             : {
    1170             :     DBG_CHKTHIS( EditView, 0 );
    1171             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
    1172           0 :     EditSelection aCurSel( pImpEditView->GetEditSelection() );
    1173           0 :     pImpEditView->DrawSelection();
    1174           0 :     aCurSel = PIMPE->SelectWord(aCurSel.Max(), nWordType);
    1175           0 :     pImpEditView->SetEditSelection( aCurSel );
    1176           0 :     pImpEditView->DrawSelection();
    1177           0 :     ShowCursor( sal_True, sal_False );
    1178           0 :     return aCurSel.HasRange() ? sal_True : sal_False;
    1179             : }
    1180             : 
    1181           0 : void EditView::InsertField( const SvxFieldItem& rFld )
    1182             : {
    1183             :     DBG_CHKTHIS( EditView, 0 );
    1184             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
    1185             : 
    1186           0 :     EditEngine* pEE = PIMPE;
    1187           0 :     pImpEditView->DrawSelection();
    1188           0 :     pEE->UndoActionStart( EDITUNDO_INSERT );
    1189           0 :     EditPaM aPaM( pEE->InsertField( pImpEditView->GetEditSelection(), rFld ) );
    1190           0 :     pEE->UndoActionEnd( EDITUNDO_INSERT );
    1191           0 :     pImpEditView->SetEditSelection( EditSelection( aPaM, aPaM ) );
    1192           0 :     pEE->UpdateFields();
    1193           0 :     pEE->FormatAndUpdate( this );
    1194           0 : }
    1195             : 
    1196           0 : const SvxFieldItem* EditView::GetFieldUnderMousePointer() const
    1197             : {
    1198             :     DBG_CHKTHIS( EditView, 0 );
    1199             :     sal_Int32 nPara;
    1200             :     sal_uInt16 nPos;
    1201           0 :     return GetFieldUnderMousePointer( nPara, nPos );
    1202             : }
    1203             : 
    1204           0 : const SvxFieldItem* EditView::GetField( const Point& rPos, sal_Int32* pPara, sal_uInt16* pPos ) const
    1205             : {
    1206             :     DBG_CHKTHIS( EditView, 0 );
    1207             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
    1208           0 :     return pImpEditView->GetField( rPos, pPara, pPos );
    1209             : }
    1210             : 
    1211           0 : const SvxFieldItem* EditView::GetFieldUnderMousePointer( sal_Int32& nPara, sal_uInt16& nPos ) const
    1212             : {
    1213             :     DBG_CHKTHIS( EditView, 0 );
    1214             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
    1215           0 :     Point aPos = pImpEditView->GetWindow()->GetPointerPosPixel();
    1216           0 :     aPos = pImpEditView->GetWindow()->PixelToLogic( aPos );
    1217           0 :     return GetField( aPos, &nPara, &nPos );
    1218             : }
    1219             : 
    1220           0 : const SvxFieldItem* EditView::GetFieldAtSelection() const
    1221             : {
    1222           0 :     EditSelection aSel( pImpEditView->GetEditSelection() );
    1223           0 :     aSel.Adjust( pImpEditView->pEditEngine->GetEditDoc() );
    1224             :     // Only when cursor is in font of field, no selection,
    1225             :     // or only selecting field
    1226           0 :     if ( ( aSel.Min().GetNode() == aSel.Max().GetNode() ) &&
    1227           0 :          ( ( aSel.Max().GetIndex() == aSel.Min().GetIndex() ) ||
    1228           0 :            ( aSel.Max().GetIndex() == aSel.Min().GetIndex()+1 ) ) )
    1229             :     {
    1230           0 :         EditPaM aPaM = aSel.Min();
    1231           0 :         const CharAttribList::AttribsType& rAttrs = aPaM.GetNode()->GetCharAttribs().GetAttribs();
    1232           0 :         sal_uInt16 nXPos = aPaM.GetIndex();
    1233           0 :         for (size_t nAttr = rAttrs.size(); nAttr; )
    1234             :         {
    1235           0 :             const EditCharAttrib& rAttr = rAttrs[--nAttr];
    1236           0 :             if (rAttr.GetStart() == nXPos)
    1237           0 :                 if (rAttr.Which() == EE_FEATURE_FIELD)
    1238             :                 {
    1239             :                     DBG_ASSERT(rAttr.GetItem()->ISA( SvxFieldItem ), "No FeldItem...");
    1240           0 :                     return static_cast<const SvxFieldItem*>(rAttr.GetItem());
    1241             :                 }
    1242             :         }
    1243             :     }
    1244           0 :     return 0;
    1245             : }
    1246             : 
    1247           0 : void EditView::SetInvalidateMore( sal_uInt16 nPixel )
    1248             : {
    1249             :     DBG_CHKTHIS( EditView, 0 );
    1250           0 :     pImpEditView->SetInvalidateMore( nPixel );
    1251           0 : }
    1252             : 
    1253           0 : sal_uInt16 EditView::GetInvalidateMore() const
    1254             : {
    1255             :     DBG_CHKTHIS( EditView, 0 );
    1256           0 :     return (sal_uInt16)pImpEditView->GetInvalidateMore();
    1257             : }
    1258             : 
    1259           0 : static void ChangeFontSizeImpl( EditView* pEditView, bool bGrow, const ESelection& rSel, const FontList* pFontList )
    1260             : {
    1261           0 :     pEditView->SetSelection( rSel );
    1262             : 
    1263           0 :     SfxItemSet aSet( pEditView->GetAttribs() );
    1264           0 :     if( EditView::ChangeFontSize( bGrow, aSet, pFontList ) )
    1265             :     {
    1266           0 :         SfxItemSet aNewSet( pEditView->GetEmptyItemSet() );
    1267           0 :         aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT ), EE_CHAR_FONTHEIGHT );
    1268           0 :         aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT_CJK ), EE_CHAR_FONTHEIGHT_CJK );
    1269           0 :         aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT_CTL ), EE_CHAR_FONTHEIGHT_CTL );
    1270           0 :         pEditView->SetAttribs( aNewSet );
    1271           0 :     }
    1272           0 : }
    1273             : 
    1274           0 : void EditView::ChangeFontSize( bool bGrow, const FontList* pFontList )
    1275             : {
    1276             :     DBG_CHKTHIS( EditView, 0 );
    1277             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
    1278             : 
    1279           0 :     EditEngine& rEditEngine = *pImpEditView->pEditEngine;
    1280             : 
    1281           0 :     ESelection aSel( GetSelection() );
    1282           0 :     ESelection aOldSelection( aSel );
    1283           0 :     aSel.Adjust();
    1284             : 
    1285           0 :     if( !aSel.HasRange() )
    1286             :     {
    1287           0 :         aSel = rEditEngine.GetWord( aSel, com::sun::star::i18n::WordType::DICTIONARY_WORD );
    1288             :     }
    1289             : 
    1290           0 :     if( aSel.HasRange() )
    1291             :     {
    1292           0 :         for( sal_Int32 nPara = aSel.nStartPara; nPara <= aSel.nEndPara; nPara++ )
    1293             :         {
    1294           0 :             std::vector<sal_uInt16> aPortions;
    1295           0 :             rEditEngine.GetPortions( nPara, aPortions );
    1296             : 
    1297           0 :             if( aPortions.empty() )
    1298           0 :                 aPortions.push_back( rEditEngine.GetTextLen(nPara) );
    1299             : 
    1300           0 :             const sal_uInt16 nBeginPos = (nPara == aSel.nStartPara) ? aSel.nStartPos : 0;
    1301           0 :             const sal_uInt16 nEndPos = (nPara == aSel.nEndPara) ? aSel.nEndPos : EE_TEXTPOS_ALL;
    1302             : 
    1303           0 :             for ( size_t nPos = 0; nPos < aPortions.size(); ++nPos )
    1304             :             {
    1305           0 :                 sal_uInt16 nPortionEnd   = aPortions[ nPos ];
    1306           0 :                 sal_uInt16 nPortionStart = nPos > 0 ? aPortions[ nPos - 1 ] : 0;
    1307             : 
    1308           0 :                 if( (nPortionEnd < nBeginPos) || (nPortionStart > nEndPos) )
    1309           0 :                     continue;
    1310             : 
    1311           0 :                 if( nPortionStart < nBeginPos )
    1312           0 :                     nPortionStart = nBeginPos;
    1313           0 :                 if( nPortionEnd > nEndPos )
    1314           0 :                     nPortionEnd = nEndPos;
    1315             : 
    1316           0 :                 if( nPortionStart == nPortionEnd )
    1317           0 :                     continue;
    1318             : 
    1319           0 :                 ESelection aPortionSel( nPara, nPortionStart, nPara, nPortionEnd );
    1320           0 :                 ChangeFontSizeImpl( this, bGrow, aPortionSel, pFontList );
    1321             :             }
    1322           0 :         }
    1323             :     }
    1324             :     else
    1325             :     {
    1326           0 :         ChangeFontSizeImpl( this, bGrow, aSel, pFontList );
    1327             :     }
    1328             : 
    1329           0 :     SetSelection( aOldSelection );
    1330           0 : }
    1331             : 
    1332           0 : bool EditView::ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFontList )
    1333             : {
    1334             :     static const sal_uInt16 gFontSizeWichMap[] = { EE_CHAR_FONTHEIGHT, EE_CHAR_FONTHEIGHT_CJK, EE_CHAR_FONTHEIGHT_CTL, 0 };
    1335             : 
    1336           0 :     const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(&rSet.Get( EE_CHAR_FONTINFO ));
    1337           0 :     if( !pFontItem || !pFontList )
    1338           0 :         return false;
    1339             : 
    1340           0 :     bool bRet = false;
    1341             : 
    1342           0 :     const sal_uInt16* pWhich = gFontSizeWichMap;
    1343           0 :     while( *pWhich )
    1344             :     {
    1345           0 :         SvxFontHeightItem aFontHeightItem( static_cast<const SvxFontHeightItem&>(rSet.Get( *pWhich )) );
    1346           0 :         long nHeight = aFontHeightItem.GetHeight();
    1347           0 :         const SfxMapUnit eUnit = rSet.GetPool()->GetMetric( *pWhich );
    1348           0 :         nHeight = OutputDevice::LogicToLogic( nHeight * 10, (MapUnit)eUnit, MAP_POINT );
    1349             : 
    1350           0 :         FontInfo aFontInfo = pFontList->Get( pFontItem->GetFamilyName(), pFontItem->GetStyleName() );
    1351           0 :         const sal_IntPtr* pAry = pFontList->GetSizeAry( aFontInfo );
    1352             : 
    1353           0 :         if( bGrow )
    1354             :         {
    1355           0 :             while( *pAry )
    1356             :             {
    1357           0 :                 if( *pAry > nHeight )
    1358             :                 {
    1359           0 :                     nHeight = *pAry;
    1360           0 :                     break;
    1361             :                 }
    1362           0 :                 pAry++;
    1363             :             }
    1364             : 
    1365           0 :             if( *pAry == 0 )
    1366             :             {
    1367           0 :                 nHeight += (nHeight + 5) / 10;
    1368           0 :                 if( nHeight > 9999 )
    1369           0 :                     nHeight = 9999;
    1370             :             }
    1371             : 
    1372             :         }
    1373           0 :         else if( *pAry )
    1374             :         {
    1375           0 :             bool bFound = false;
    1376           0 :             if( *pAry < nHeight )
    1377             :             {
    1378           0 :                 pAry++;
    1379           0 :                 while( *pAry )
    1380             :                 {
    1381           0 :                     if( *pAry >= nHeight )
    1382             :                     {
    1383           0 :                         nHeight = pAry[-1];
    1384           0 :                         bFound = true;
    1385           0 :                         break;
    1386             :                     }
    1387           0 :                     pAry++;
    1388             :                 }
    1389             :             }
    1390             : 
    1391           0 :             if( !bFound )
    1392             :             {
    1393           0 :                 nHeight -= (nHeight + 5) / 10;
    1394           0 :                 if( nHeight < 2 )
    1395           0 :                     nHeight = 2;
    1396             :             }
    1397             :         }
    1398             : 
    1399           0 :         if( (nHeight >= 2) && (nHeight <= 9999 ) )
    1400             :         {
    1401           0 :             nHeight = OutputDevice::LogicToLogic( nHeight, MAP_POINT, (MapUnit)eUnit  ) / 10;
    1402             : 
    1403           0 :             if( nHeight != (long)aFontHeightItem.GetHeight() )
    1404             :             {
    1405           0 :                 aFontHeightItem.SetHeight( nHeight );
    1406           0 :                 rSet.Put( aFontHeightItem, *pWhich );
    1407           0 :                 bRet = true;
    1408             :             }
    1409             :         }
    1410           0 :         pWhich++;
    1411           0 :     }
    1412           0 :     return bRet;
    1413             : }
    1414             : 
    1415           0 : String EditView::GetSurroundingText() const
    1416             : {
    1417             :     DBG_CHKTHIS( EditView, 0 );
    1418             :     DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
    1419             : 
    1420           0 :     EditSelection aSel( pImpEditView->GetEditSelection() );
    1421           0 :     aSel.Adjust( PIMPE->GetEditDoc() );
    1422             : 
    1423           0 :     if( HasSelection() )
    1424             :     {
    1425           0 :         String aStr = PIMPE->GetSelected(aSel);
    1426             : 
    1427             :         // Stop reconversion if the selected text includes a line break.
    1428           0 :         if ( aStr.Search( 0x0A ) == STRING_NOTFOUND )
    1429           0 :         return aStr;
    1430             :         else
    1431           0 :         return String();
    1432             :     }
    1433             :     else
    1434             :     {
    1435           0 :         aSel.Min().SetIndex( 0 );
    1436           0 :         aSel.Max().SetIndex( aSel.Max().GetNode()->Len() );
    1437           0 :         return PIMPE->GetSelected(aSel);
    1438             :     }
    1439             : }
    1440             : 
    1441           0 : Selection EditView::GetSurroundingTextSelection() const
    1442             : {
    1443             :     DBG_CHKTHIS( EditView, 0 );
    1444             : 
    1445           0 :     ESelection aSelection( GetSelection() );
    1446           0 :     aSelection.Adjust();
    1447             : 
    1448           0 :     if( HasSelection() )
    1449             :     {
    1450           0 :         EditSelection aSel( pImpEditView->GetEditSelection() );
    1451           0 :         aSel.Adjust( PIMPE->GetEditDoc() );
    1452           0 :         String aStr = PIMPE->GetSelected(aSel);
    1453             : 
    1454             :         // Stop reconversion if the selected text includes a line break.
    1455           0 :         if ( aStr.Search( 0x0A ) == STRING_NOTFOUND )
    1456           0 :         return Selection( 0, aSelection.nEndPos - aSelection.nStartPos );
    1457             :         else
    1458           0 :         return Selection( 0, 0 );
    1459             :     }
    1460             :     else
    1461             :     {
    1462           0 :         return Selection( aSelection.nStartPos, aSelection.nEndPos );
    1463             :     }
    1464         267 : }
    1465             : 
    1466             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10