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