1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_editeng.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <algorithm> 32*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 33*cdf0e10cSrcweir #include <com/sun/star/i18n/WordType.hpp> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <svl/itemset.hxx> 36*cdf0e10cSrcweir #include <editeng/editeng.hxx> 37*cdf0e10cSrcweir #include <editeng/editview.hxx> 38*cdf0e10cSrcweir #include <editeng/unoedhlp.hxx> 39*cdf0e10cSrcweir #include <editeng/editdata.hxx> 40*cdf0e10cSrcweir #include <editeng/outliner.hxx> 41*cdf0e10cSrcweir #include <editeng/editobj.hxx> // nur fuer die GetText-Kruecke 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include <editeng/unofored.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir using namespace ::com::sun::star; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir //------------------------------------------------------------------------ 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir SvxEditEngineForwarder::SvxEditEngineForwarder( EditEngine& rEngine ) : 50*cdf0e10cSrcweir rEditEngine( rEngine ) 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir } 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir SvxEditEngineForwarder::~SvxEditEngineForwarder() 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir // die EditEngine muss ggf. von aussen geloescht werden 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir sal_uInt16 SvxEditEngineForwarder::GetParagraphCount() const 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir return rEditEngine.GetParagraphCount(); 62*cdf0e10cSrcweir } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir sal_uInt16 SvxEditEngineForwarder::GetTextLen( sal_uInt16 nParagraph ) const 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir return rEditEngine.GetTextLen( nParagraph ); 67*cdf0e10cSrcweir } 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir String SvxEditEngineForwarder::GetText( const ESelection& rSel ) const 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir String aRet = rEditEngine.GetText( rSel, LINEEND_LF ); 72*cdf0e10cSrcweir aRet.ConvertLineEnd(); 73*cdf0e10cSrcweir return aRet; 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir SfxItemSet SvxEditEngineForwarder::GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib ) const 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir if( rSel.nStartPara == rSel.nEndPara ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir sal_uInt8 nFlags = 0; 81*cdf0e10cSrcweir switch( bOnlyHardAttrib ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir case EditEngineAttribs_All: 84*cdf0e10cSrcweir nFlags = GETATTRIBS_ALL; 85*cdf0e10cSrcweir break; 86*cdf0e10cSrcweir case EditEngineAttribs_HardAndPara: 87*cdf0e10cSrcweir nFlags = GETATTRIBS_PARAATTRIBS|GETATTRIBS_CHARATTRIBS; 88*cdf0e10cSrcweir break; 89*cdf0e10cSrcweir case EditEngineAttribs_OnlyHard: 90*cdf0e10cSrcweir nFlags = GETATTRIBS_CHARATTRIBS; 91*cdf0e10cSrcweir break; 92*cdf0e10cSrcweir default: 93*cdf0e10cSrcweir DBG_ERROR("unknown flags for SvxOutlinerForwarder::GetAttribs"); 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir return rEditEngine.GetAttribs( rSel.nStartPara, rSel.nStartPos, rSel.nEndPos, nFlags ); 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir else 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir return rEditEngine.GetAttribs( rSel, bOnlyHardAttrib ); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir SfxItemSet SvxEditEngineForwarder::GetParaAttribs( sal_uInt16 nPara ) const 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir SfxItemSet aSet( rEditEngine.GetParaAttribs( nPara ) ); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir sal_uInt16 nWhich = EE_PARA_START; 109*cdf0e10cSrcweir while( nWhich <= EE_PARA_END ) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir if( aSet.GetItemState( nWhich, sal_True ) != SFX_ITEM_ON ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir if( rEditEngine.HasParaAttrib( nPara, nWhich ) ) 114*cdf0e10cSrcweir aSet.Put( rEditEngine.GetParaAttrib( nPara, nWhich ) ); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir nWhich++; 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir return aSet; 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir void SvxEditEngineForwarder::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir rEditEngine.SetParaAttribs( nPara, rSet ); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir void SvxEditEngineForwarder::RemoveAttribs( const ESelection& rSelection, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich ) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir rEditEngine.RemoveAttribs( rSelection, bRemoveParaAttribs, nWhich ); 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir SfxItemPool* SvxEditEngineForwarder::GetPool() const 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir return rEditEngine.GetEmptyItemSet().GetPool(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir void SvxEditEngineForwarder::GetPortions( sal_uInt16 nPara, SvUShorts& rList ) const 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir rEditEngine.GetPortions( nPara, rList ); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir void SvxEditEngineForwarder::QuickInsertText( const String& rText, const ESelection& rSel ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir rEditEngine.QuickInsertText( rText, rSel ); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir void SvxEditEngineForwarder::QuickInsertLineBreak( const ESelection& rSel ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir rEditEngine.QuickInsertLineBreak( rSel ); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir void SvxEditEngineForwarder::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel ) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir rEditEngine.QuickInsertField( rFld, rSel ); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir void SvxEditEngineForwarder::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir rEditEngine.QuickSetAttribs( rSet, rSel ); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir sal_Bool SvxEditEngineForwarder::IsValid() const 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir // cannot reliably query EditEngine state 165*cdf0e10cSrcweir // while in the middle of an update 166*cdf0e10cSrcweir return rEditEngine.GetUpdateMode(); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir XubString SvxEditEngineForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor ) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir return rEditEngine.CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir void SvxEditEngineForwarder::FieldClicked( const SvxFieldItem& rField, sal_uInt16 nPara, xub_StrLen nPos ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir rEditEngine.FieldClicked( rField, nPara, nPos ); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir sal_uInt16 GetSvxEditEngineItemState( EditEngine& rEditEngine, const ESelection& rSel, sal_uInt16 nWhich ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir EECharAttribArray aAttribs; 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir const SfxPoolItem* pLastItem = NULL; 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir SfxItemState eState = SFX_ITEM_DEFAULT; 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir // check all paragraphs inside the selection 188*cdf0e10cSrcweir for( sal_uInt16 nPara = rSel.nStartPara; nPara <= rSel.nEndPara; nPara++ ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir SfxItemState eParaState = SFX_ITEM_DEFAULT; 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir // calculate start and endpos for this paragraph 193*cdf0e10cSrcweir sal_uInt16 nPos = 0; 194*cdf0e10cSrcweir if( rSel.nStartPara == nPara ) 195*cdf0e10cSrcweir nPos = rSel.nStartPos; 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir sal_uInt16 nEndPos = rSel.nEndPos; 198*cdf0e10cSrcweir if( rSel.nEndPara != nPara ) 199*cdf0e10cSrcweir nEndPos = rEditEngine.GetTextLen( nPara ); 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir // get list of char attribs 203*cdf0e10cSrcweir rEditEngine.GetCharAttribs( nPara, aAttribs ); 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir sal_Bool bEmpty = sal_True; // we found no item inside the selektion of this paragraph 206*cdf0e10cSrcweir sal_Bool bGaps = sal_False; // we found items but theire gaps between them 207*cdf0e10cSrcweir sal_uInt16 nLastEnd = nPos; 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir const SfxPoolItem* pParaItem = NULL; 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir for( sal_uInt16 nAttrib = 0; nAttrib < aAttribs.Count(); nAttrib++ ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir struct EECharAttrib aAttrib = aAttribs.GetObject( nAttrib ); 214*cdf0e10cSrcweir DBG_ASSERT( aAttrib.pAttr, "GetCharAttribs gives corrupt data" ); 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir const sal_Bool bEmptyPortion = aAttrib.nStart == aAttrib.nEnd; 217*cdf0e10cSrcweir if( (!bEmptyPortion && (aAttrib.nStart >= nEndPos)) || (bEmptyPortion && (aAttrib.nStart > nEndPos)) ) 218*cdf0e10cSrcweir break; // break if we are already behind our selektion 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir if( (!bEmptyPortion && (aAttrib.nEnd <= nPos)) || (bEmptyPortion && (aAttrib.nEnd < nPos)) ) 221*cdf0e10cSrcweir continue; // or if the attribute ends before our selektion 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir if( aAttrib.pAttr->Which() != nWhich ) 224*cdf0e10cSrcweir continue; // skip if is not the searched item 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir // if we already found an item 227*cdf0e10cSrcweir if( pParaItem ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir // ... and its different to this one than the state is dont care 230*cdf0e10cSrcweir if( *pParaItem != *aAttrib.pAttr ) 231*cdf0e10cSrcweir return SFX_ITEM_DONTCARE; 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir else 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir pParaItem = aAttrib.pAttr; 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir if( bEmpty ) 239*cdf0e10cSrcweir bEmpty = sal_False; 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir if( !bGaps && aAttrib.nStart > nLastEnd ) 242*cdf0e10cSrcweir bGaps = sal_True; 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir nLastEnd = aAttrib.nEnd; 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir if( !bEmpty && !bGaps && nLastEnd < ( nEndPos - 1 ) ) 248*cdf0e10cSrcweir bGaps = sal_True; 249*cdf0e10cSrcweir /* 250*cdf0e10cSrcweir // since we have no portion with our item or if there were gaps 251*cdf0e10cSrcweir if( bEmpty || bGaps ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir // we need to check the paragraph item 254*cdf0e10cSrcweir const SfxItemSet& rParaSet = rEditEngine.GetParaAttribs( nPara ); 255*cdf0e10cSrcweir if( rParaSet.GetItemState( nWhich ) == SFX_ITEM_SET ) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir eState = SFX_ITEM_SET; 258*cdf0e10cSrcweir // get item from the paragraph 259*cdf0e10cSrcweir const SfxPoolItem* pTempItem = rParaSet.GetItem( nWhich ); 260*cdf0e10cSrcweir if( pParaItem ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir if( *pParaItem != *pTempItem ) 263*cdf0e10cSrcweir return SFX_ITEM_DONTCARE; 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir else 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir pParaItem = pTempItem; 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir // set if theres no last item or if its the same 271*cdf0e10cSrcweir eParaState = SFX_ITEM_SET; 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir else if( bEmpty ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir eParaState = SFX_ITEM_DEFAULT; 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir else if( bGaps ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir // gaps and item not set in paragraph, thats a dont care 280*cdf0e10cSrcweir return SFX_ITEM_DONTCARE; 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir else 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir eParaState = SFX_ITEM_SET; 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir */ 288*cdf0e10cSrcweir if( bEmpty ) 289*cdf0e10cSrcweir eParaState = SFX_ITEM_DEFAULT; 290*cdf0e10cSrcweir else if( bGaps ) 291*cdf0e10cSrcweir eParaState = SFX_ITEM_DONTCARE; 292*cdf0e10cSrcweir else 293*cdf0e10cSrcweir eParaState = SFX_ITEM_SET; 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir // if we already found an item check if we found the same 296*cdf0e10cSrcweir if( pLastItem ) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir if( (pParaItem == NULL) || (*pLastItem != *pParaItem) ) 299*cdf0e10cSrcweir return SFX_ITEM_DONTCARE; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir else 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir pLastItem = pParaItem; 304*cdf0e10cSrcweir eState = eParaState; 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir return eState; 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir sal_uInt16 SvxEditEngineForwarder::GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir return GetSvxEditEngineItemState( rEditEngine, rSel, nWhich ); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir sal_uInt16 SvxEditEngineForwarder::GetItemState( sal_uInt16 nPara, sal_uInt16 nWhich ) const 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir const SfxItemSet& rSet = rEditEngine.GetParaAttribs( nPara ); 319*cdf0e10cSrcweir return rSet.GetItemState( nWhich ); 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir LanguageType SvxEditEngineForwarder::GetLanguage( sal_uInt16 nPara, sal_uInt16 nIndex ) const 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir return rEditEngine.GetLanguage(nPara, nIndex); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir sal_uInt16 SvxEditEngineForwarder::GetFieldCount( sal_uInt16 nPara ) const 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir return rEditEngine.GetFieldCount(nPara); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir EFieldInfo SvxEditEngineForwarder::GetFieldInfo( sal_uInt16 nPara, sal_uInt16 nField ) const 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir return rEditEngine.GetFieldInfo( nPara, nField ); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir EBulletInfo SvxEditEngineForwarder::GetBulletInfo( sal_uInt16 ) const 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir return EBulletInfo(); 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir Rectangle SvxEditEngineForwarder::GetCharBounds( sal_uInt16 nPara, sal_uInt16 nIndex ) const 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir // #101701# 345*cdf0e10cSrcweir // EditEngine's 'internal' methods like GetCharacterBounds() 346*cdf0e10cSrcweir // don't rotate for vertical text. 347*cdf0e10cSrcweir Size aSize( rEditEngine.CalcTextWidth(), rEditEngine.GetTextHeight() ); 348*cdf0e10cSrcweir ::std::swap( aSize.Width(), aSize.Height() ); 349*cdf0e10cSrcweir bool bIsVertical( rEditEngine.IsVertical() == sal_True ); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir // #108900# Handle virtual position one-past-the end of the string 352*cdf0e10cSrcweir if( nIndex >= rEditEngine.GetTextLen(nPara) ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir Rectangle aLast; 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir if( nIndex ) 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir // use last character, if possible 359*cdf0e10cSrcweir aLast = rEditEngine.GetCharacterBounds( EPosition(nPara, nIndex-1) ); 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir // move at end of this last character, make one pixel wide 362*cdf0e10cSrcweir aLast.Move( aLast.Right() - aLast.Left(), 0 ); 363*cdf0e10cSrcweir aLast.SetSize( Size(1, aLast.GetHeight()) ); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir // take care for CTL 366*cdf0e10cSrcweir aLast = SvxEditSourceHelper::EEToUserSpace( aLast, aSize, bIsVertical ); 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir else 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir // #109864# Bounds must lie within the paragraph 371*cdf0e10cSrcweir aLast = GetParaBounds( nPara ); 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir // #109151# Don't use paragraph height, but line height 374*cdf0e10cSrcweir // instead. aLast is already CTL-correct 375*cdf0e10cSrcweir if( bIsVertical) 376*cdf0e10cSrcweir aLast.SetSize( Size( rEditEngine.GetLineHeight(nPara,0), 1 ) ); 377*cdf0e10cSrcweir else 378*cdf0e10cSrcweir aLast.SetSize( Size( 1, rEditEngine.GetLineHeight(nPara,0) ) ); 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir return aLast; 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir else 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir return SvxEditSourceHelper::EEToUserSpace( rEditEngine.GetCharacterBounds( EPosition(nPara, nIndex) ), 386*cdf0e10cSrcweir aSize, bIsVertical ); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir Rectangle SvxEditEngineForwarder::GetParaBounds( sal_uInt16 nPara ) const 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir const Point aPnt = rEditEngine.GetDocPosTopLeft( nPara ); 393*cdf0e10cSrcweir sal_uLong nWidth; 394*cdf0e10cSrcweir sal_uLong nHeight; 395*cdf0e10cSrcweir sal_uLong nTextWidth; 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir if( rEditEngine.IsVertical() ) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir // #101701# 400*cdf0e10cSrcweir // Hargl. EditEngine's 'external' methods return the rotated 401*cdf0e10cSrcweir // dimensions, 'internal' methods like GetTextHeight( n ) 402*cdf0e10cSrcweir // don't rotate. 403*cdf0e10cSrcweir nWidth = rEditEngine.GetTextHeight( nPara ); 404*cdf0e10cSrcweir nHeight = rEditEngine.GetTextHeight(); 405*cdf0e10cSrcweir nTextWidth = rEditEngine.GetTextHeight(); 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir return Rectangle( nTextWidth - aPnt.Y() - nWidth, 0, nTextWidth - aPnt.Y(), nHeight ); 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir else 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir nWidth = rEditEngine.CalcTextWidth(); 412*cdf0e10cSrcweir nHeight = rEditEngine.GetTextHeight( nPara ); 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir return Rectangle( 0, aPnt.Y(), nWidth, aPnt.Y() + nHeight ); 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir MapMode SvxEditEngineForwarder::GetMapMode() const 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir return rEditEngine.GetRefMapMode(); 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir OutputDevice* SvxEditEngineForwarder::GetRefDevice() const 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir return rEditEngine.GetRefDevice(); 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir sal_Bool SvxEditEngineForwarder::GetIndexAtPoint( const Point& rPos, sal_uInt16& nPara, sal_uInt16& nIndex ) const 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir // #101701# 431*cdf0e10cSrcweir Size aSize( rEditEngine.CalcTextWidth(), rEditEngine.GetTextHeight() ); 432*cdf0e10cSrcweir ::std::swap( aSize.Width(), aSize.Height() ); 433*cdf0e10cSrcweir Point aEEPos( SvxEditSourceHelper::UserSpaceToEE( rPos, 434*cdf0e10cSrcweir aSize, 435*cdf0e10cSrcweir rEditEngine.IsVertical() == sal_True )); 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir EPosition aDocPos = rEditEngine.FindDocPosition( aEEPos ); 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir nPara = aDocPos.nPara; 440*cdf0e10cSrcweir nIndex = aDocPos.nIndex; 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir return sal_True; 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir sal_Bool SvxEditEngineForwarder::GetWordIndices( sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir ESelection aRes = rEditEngine.GetWord( ESelection(nPara, nIndex, nPara, nIndex), com::sun::star::i18n::WordType::DICTIONARY_WORD ); 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir if( aRes.nStartPara == nPara && 450*cdf0e10cSrcweir aRes.nStartPara == aRes.nEndPara ) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir nStart = aRes.nStartPos; 453*cdf0e10cSrcweir nEnd = aRes.nEndPos; 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir return sal_True; 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir return sal_False; 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir sal_Bool SvxEditEngineForwarder::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_uInt16 nPara, sal_uInt16 nIndex ) const 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir return SvxEditSourceHelper::GetAttributeRun( nStartIndex, nEndIndex, rEditEngine, nPara, nIndex ); 464*cdf0e10cSrcweir } 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir sal_uInt16 SvxEditEngineForwarder::GetLineCount( sal_uInt16 nPara ) const 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir return rEditEngine.GetLineCount(nPara); 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir sal_uInt16 SvxEditEngineForwarder::GetLineLen( sal_uInt16 nPara, sal_uInt16 nLine ) const 472*cdf0e10cSrcweir { 473*cdf0e10cSrcweir return rEditEngine.GetLineLen(nPara, nLine); 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir void SvxEditEngineForwarder::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt16 nPara, sal_uInt16 nLine ) const 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir rEditEngine.GetLineBoundaries(rStart, rEnd, nPara, nLine); 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir sal_uInt16 SvxEditEngineForwarder::GetLineNumberAtIndex( sal_uInt16 nPara, sal_uInt16 nIndex ) const 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir return rEditEngine.GetLineNumberAtIndex(nPara, nIndex); 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir sal_Bool SvxEditEngineForwarder::QuickFormatDoc( sal_Bool ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir rEditEngine.QuickFormatDoc(); 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir return sal_True; 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir sal_Bool SvxEditEngineForwarder::Delete( const ESelection& rSelection ) 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir rEditEngine.QuickDelete( rSelection ); 497*cdf0e10cSrcweir rEditEngine.QuickFormatDoc(); 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir return sal_True; 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir sal_Bool SvxEditEngineForwarder::InsertText( const String& rStr, const ESelection& rSelection ) 503*cdf0e10cSrcweir { 504*cdf0e10cSrcweir rEditEngine.QuickInsertText( rStr, rSelection ); 505*cdf0e10cSrcweir rEditEngine.QuickFormatDoc(); 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir return sal_True; 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir sal_Int16 SvxEditEngineForwarder::GetDepth( sal_uInt16 ) const 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir // EditEngine does not support outline depth 513*cdf0e10cSrcweir return -1; 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir sal_Bool SvxEditEngineForwarder::SetDepth( sal_uInt16, sal_Int16 nNewDepth ) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir // EditEngine does not support outline depth 519*cdf0e10cSrcweir return nNewDepth == -1 ? sal_True : sal_False; 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir const SfxItemSet * SvxEditEngineForwarder::GetEmptyItemSetPtr() 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir return &rEditEngine.GetEmptyItemSet(); 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir void SvxEditEngineForwarder::AppendParagraph() 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir rEditEngine.InsertParagraph( rEditEngine.GetParagraphCount(), String::EmptyString() ); 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir xub_StrLen SvxEditEngineForwarder::AppendTextPortion( sal_uInt16 nPara, const String &rText, const SfxItemSet & /*rSet*/ ) 533*cdf0e10cSrcweir { 534*cdf0e10cSrcweir xub_StrLen nLen = 0; 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir sal_uInt16 nParaCount = rEditEngine.GetParagraphCount(); 537*cdf0e10cSrcweir DBG_ASSERT( nPara < nParaCount, "paragraph index out of bounds" ); 538*cdf0e10cSrcweir if (/*0 <= nPara && */nPara < nParaCount) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir nLen = rEditEngine.GetTextLen( nPara ); 541*cdf0e10cSrcweir rEditEngine.QuickInsertText( rText, ESelection( nPara, nLen, nPara, nLen ) ); 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir return nLen; 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir void SvxEditEngineForwarder::CopyText(const SvxTextForwarder& rSource) 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir const SvxEditEngineForwarder* pSourceForwarder = dynamic_cast< const SvxEditEngineForwarder* >( &rSource ); 550*cdf0e10cSrcweir if( !pSourceForwarder ) 551*cdf0e10cSrcweir return; 552*cdf0e10cSrcweir EditTextObject* pNewTextObject = pSourceForwarder->rEditEngine.CreateTextObject(); 553*cdf0e10cSrcweir rEditEngine.SetText( *pNewTextObject ); 554*cdf0e10cSrcweir delete pNewTextObject; 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir //------------------------------------------------------------------------ 558