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

Generated by: LCOV version 1.10