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_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "scitems.hxx" 34*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 35*cdf0e10cSrcweir #include <svx/svdpool.hxx> 36*cdf0e10cSrcweir #include <svx/svdobj.hxx> 37*cdf0e10cSrcweir #include <editeng/editeng.hxx> 38*cdf0e10cSrcweir #include <editeng/editobj.hxx> 39*cdf0e10cSrcweir #include <editeng/flditem.hxx> 40*cdf0e10cSrcweir #include <svx/unomid.hxx> 41*cdf0e10cSrcweir #include <editeng/unoprnms.hxx> 42*cdf0e10cSrcweir #include <editeng/unofored.hxx> 43*cdf0e10cSrcweir #include <rtl/uuid.h> 44*cdf0e10cSrcweir #include <vcl/virdev.hxx> 45*cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 48*cdf0e10cSrcweir #include <editeng/unoipset.hxx> 49*cdf0e10cSrcweir #include "textuno.hxx" 50*cdf0e10cSrcweir #include "fielduno.hxx" 51*cdf0e10cSrcweir #include "servuno.hxx" 52*cdf0e10cSrcweir #include "editsrc.hxx" 53*cdf0e10cSrcweir #include "docsh.hxx" 54*cdf0e10cSrcweir #include "editutil.hxx" 55*cdf0e10cSrcweir #include "unoguard.hxx" 56*cdf0e10cSrcweir #include "miscuno.hxx" 57*cdf0e10cSrcweir #include "cellsuno.hxx" 58*cdf0e10cSrcweir #include "hints.hxx" 59*cdf0e10cSrcweir #include "patattr.hxx" 60*cdf0e10cSrcweir #include "cell.hxx" 61*cdf0e10cSrcweir #include "docfunc.hxx" 62*cdf0e10cSrcweir #include "scmod.hxx" 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir using namespace com::sun::star; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir //------------------------------------------------------------------------ 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir const SvxItemPropertySet * lcl_GetHdFtPropertySet() 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir static SfxItemPropertyMapEntry aHdFtPropertyMap_Impl[] = 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir SVX_UNOEDIT_CHAR_PROPERTIES, 73*cdf0e10cSrcweir SVX_UNOEDIT_FONT_PROPERTIES, 74*cdf0e10cSrcweir SVX_UNOEDIT_PARA_PROPERTIES, 75*cdf0e10cSrcweir SVX_UNOEDIT_NUMBERING_PROPERTIE, // for completeness of service ParagraphProperties 76*cdf0e10cSrcweir {0,0,0,0,0,0} 77*cdf0e10cSrcweir }; 78*cdf0e10cSrcweir static sal_Bool bTwipsSet = sal_False; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir if (!bTwipsSet) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir // modify PropertyMap to include CONVERT_TWIPS flag for font height 83*cdf0e10cSrcweir // (headers/footers are in twips) 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir SfxItemPropertyMapEntry* pEntry = aHdFtPropertyMap_Impl; 86*cdf0e10cSrcweir while (pEntry->pName) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir if ( ( pEntry->nWID == EE_CHAR_FONTHEIGHT || 89*cdf0e10cSrcweir pEntry->nWID == EE_CHAR_FONTHEIGHT_CJK || 90*cdf0e10cSrcweir pEntry->nWID == EE_CHAR_FONTHEIGHT_CTL ) && 91*cdf0e10cSrcweir pEntry->nMemberId == MID_FONTHEIGHT ) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir pEntry->nMemberId |= CONVERT_TWIPS; 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir ++pEntry; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir bTwipsSet = sal_True; 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir static SvxItemPropertySet aHdFtPropertySet_Impl( aHdFtPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 101*cdf0e10cSrcweir return &aHdFtPropertySet_Impl; 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir //------------------------------------------------------------------------ 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScHeaderFooterContentObj, "ScHeaderFooterContentObj", "com.sun.star.sheet.HeaderFooterContent" ) 107*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScHeaderFooterTextObj, "ScHeaderFooterTextObj", "stardiv.one.Text.Text" ) 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir //------------------------------------------------------------------------ 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir ScHeaderFooterContentObj::ScHeaderFooterContentObj( const EditTextObject* pLeft, 112*cdf0e10cSrcweir const EditTextObject* pCenter, 113*cdf0e10cSrcweir const EditTextObject* pRight ) : 114*cdf0e10cSrcweir pLeftText ( NULL ), 115*cdf0e10cSrcweir pCenterText ( NULL ), 116*cdf0e10cSrcweir pRightText ( NULL ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir if ( pLeft ) 119*cdf0e10cSrcweir pLeftText = pLeft->Clone(); 120*cdf0e10cSrcweir if ( pCenter ) 121*cdf0e10cSrcweir pCenterText = pCenter->Clone(); 122*cdf0e10cSrcweir if ( pRight ) 123*cdf0e10cSrcweir pRightText = pRight->Clone(); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir ScHeaderFooterContentObj::~ScHeaderFooterContentObj() 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir delete pLeftText; 129*cdf0e10cSrcweir delete pCenterText; 130*cdf0e10cSrcweir delete pRightText; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir void ScHeaderFooterContentObj::AddListener( SfxListener& rListener ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir rListener.StartListening( aBC ); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir void ScHeaderFooterContentObj::RemoveListener( SfxListener& rListener ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir rListener.EndListening( aBC ); 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir void ScHeaderFooterContentObj::UpdateText( sal_uInt16 nPart, EditEngine& rSource ) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir EditTextObject* pNew = rSource.CreateTextObject(); 146*cdf0e10cSrcweir switch (nPart) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir case SC_HDFT_LEFT: 149*cdf0e10cSrcweir delete pLeftText; 150*cdf0e10cSrcweir pLeftText = pNew; 151*cdf0e10cSrcweir break; 152*cdf0e10cSrcweir case SC_HDFT_CENTER: 153*cdf0e10cSrcweir delete pCenterText; 154*cdf0e10cSrcweir pCenterText = pNew; 155*cdf0e10cSrcweir break; 156*cdf0e10cSrcweir default: // SC_HDFT_RIGHT 157*cdf0e10cSrcweir delete pRightText; 158*cdf0e10cSrcweir pRightText = pNew; 159*cdf0e10cSrcweir break; 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir aBC.Broadcast( ScHeaderFooterChangedHint( nPart ) ); 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir // XHeaderFooterContent 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir uno::Reference<text::XText> SAL_CALL ScHeaderFooterContentObj::getLeftText() 168*cdf0e10cSrcweir throw(uno::RuntimeException) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir ScUnoGuard aGuard; 171*cdf0e10cSrcweir return new ScHeaderFooterTextObj( *this, SC_HDFT_LEFT ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir uno::Reference<text::XText> SAL_CALL ScHeaderFooterContentObj::getCenterText() 175*cdf0e10cSrcweir throw(uno::RuntimeException) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir ScUnoGuard aGuard; 178*cdf0e10cSrcweir return new ScHeaderFooterTextObj( *this, SC_HDFT_CENTER ); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir uno::Reference<text::XText> SAL_CALL ScHeaderFooterContentObj::getRightText() 182*cdf0e10cSrcweir throw(uno::RuntimeException) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir ScUnoGuard aGuard; 185*cdf0e10cSrcweir return new ScHeaderFooterTextObj( *this, SC_HDFT_RIGHT ); 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir // XUnoTunnel 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir sal_Int64 SAL_CALL ScHeaderFooterContentObj::getSomething( 191*cdf0e10cSrcweir const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir if ( rId.getLength() == 16 && 194*cdf0e10cSrcweir 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 195*cdf0e10cSrcweir rId.getConstArray(), 16 ) ) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir return 0; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir // static 203*cdf0e10cSrcweir const uno::Sequence<sal_Int8>& ScHeaderFooterContentObj::getUnoTunnelId() 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir static uno::Sequence<sal_Int8> * pSeq = 0; 206*cdf0e10cSrcweir if( !pSeq ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 209*cdf0e10cSrcweir if( !pSeq ) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq( 16 ); 212*cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 213*cdf0e10cSrcweir pSeq = &aSeq; 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir return *pSeq; 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // static 220*cdf0e10cSrcweir ScHeaderFooterContentObj* ScHeaderFooterContentObj::getImplementation( 221*cdf0e10cSrcweir const uno::Reference<sheet::XHeaderFooterContent> xObj ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir ScHeaderFooterContentObj* pRet = NULL; 224*cdf0e10cSrcweir uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY ); 225*cdf0e10cSrcweir if (xUT.is()) 226*cdf0e10cSrcweir pRet = reinterpret_cast<ScHeaderFooterContentObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId()))); 227*cdf0e10cSrcweir return pRet; 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir //------------------------------------------------------------------------ 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir ScHeaderFooterTextData::ScHeaderFooterTextData( ScHeaderFooterContentObj& rContent, 234*cdf0e10cSrcweir sal_uInt16 nP ) : 235*cdf0e10cSrcweir rContentObj( rContent ), 236*cdf0e10cSrcweir nPart( nP ), 237*cdf0e10cSrcweir pEditEngine( NULL ), 238*cdf0e10cSrcweir pForwarder( NULL ), 239*cdf0e10cSrcweir bDataValid( sal_False ), 240*cdf0e10cSrcweir bInUpdate( sal_False ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir rContentObj.acquire(); // must not go away 243*cdf0e10cSrcweir rContentObj.AddListener( *this ); 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir ScHeaderFooterTextData::~ScHeaderFooterTextData() 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir ScUnoGuard aGuard; // needed for EditEngine dtor 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir rContentObj.RemoveListener( *this ); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir delete pForwarder; 253*cdf0e10cSrcweir delete pEditEngine; 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir rContentObj.release(); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir void ScHeaderFooterTextData::Notify( SfxBroadcaster&, const SfxHint& rHint ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir if ( rHint.ISA( ScHeaderFooterChangedHint ) ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir if ( ((const ScHeaderFooterChangedHint&)rHint).GetPart() == nPart ) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir if (!bInUpdate) // not for own updates 265*cdf0e10cSrcweir bDataValid = sal_False; // text has to be fetched again 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir SvxTextForwarder* ScHeaderFooterTextData::GetTextForwarder() 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir if (!pEditEngine) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir SfxItemPool* pEnginePool = EditEngine::CreatePool(); 275*cdf0e10cSrcweir pEnginePool->FreezeIdRanges(); 276*cdf0e10cSrcweir ScHeaderEditEngine* pHdrEngine = new ScHeaderEditEngine( pEnginePool, sal_True ); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir pHdrEngine->EnableUndo( sal_False ); 279*cdf0e10cSrcweir pHdrEngine->SetRefMapMode( MAP_TWIP ); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir // default font must be set, independently of document 282*cdf0e10cSrcweir // -> use global pool from module 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir SfxItemSet aDefaults( pHdrEngine->GetEmptyItemSet() ); 285*cdf0e10cSrcweir const ScPatternAttr& rPattern = (const ScPatternAttr&)SC_MOD()->GetPool().GetDefaultItem(ATTR_PATTERN); 286*cdf0e10cSrcweir rPattern.FillEditItemSet( &aDefaults ); 287*cdf0e10cSrcweir // FillEditItemSet adjusts font height to 1/100th mm, 288*cdf0e10cSrcweir // but for header/footer twips is needed, as in the PatternAttr: 289*cdf0e10cSrcweir aDefaults.Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT ); 290*cdf0e10cSrcweir aDefaults.Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK ); 291*cdf0e10cSrcweir aDefaults.Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL ); 292*cdf0e10cSrcweir pHdrEngine->SetDefaults( aDefaults ); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir ScHeaderFieldData aData; 295*cdf0e10cSrcweir ScHeaderFooterTextObj::FillDummyFieldData( aData ); 296*cdf0e10cSrcweir pHdrEngine->SetData( aData ); 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir pEditEngine = pHdrEngine; 299*cdf0e10cSrcweir pForwarder = new SvxEditEngineForwarder(*pEditEngine); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir if (bDataValid) 303*cdf0e10cSrcweir return pForwarder; 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir const EditTextObject* pData; 306*cdf0e10cSrcweir if (nPart == SC_HDFT_LEFT) 307*cdf0e10cSrcweir pData = rContentObj.GetLeftEditObject(); 308*cdf0e10cSrcweir else if (nPart == SC_HDFT_CENTER) 309*cdf0e10cSrcweir pData = rContentObj.GetCenterEditObject(); 310*cdf0e10cSrcweir else 311*cdf0e10cSrcweir pData = rContentObj.GetRightEditObject(); 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir if (pData) 314*cdf0e10cSrcweir pEditEngine->SetText(*pData); 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir bDataValid = sal_True; 317*cdf0e10cSrcweir return pForwarder; 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir void ScHeaderFooterTextData::UpdateData() 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir if ( pEditEngine ) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir bInUpdate = sal_True; // don't reset bDataValid during UpdateText 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir rContentObj.UpdateText( nPart, *pEditEngine ); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir bInUpdate = sal_False; 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir //------------------------------------------------------------------------ 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir ScHeaderFooterTextObj::ScHeaderFooterTextObj( ScHeaderFooterContentObj& rContent, 335*cdf0e10cSrcweir sal_uInt16 nP ) : 336*cdf0e10cSrcweir aTextData( rContent, nP ), 337*cdf0e10cSrcweir pUnoText( NULL ) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir // ScHeaderFooterTextData acquires rContent 340*cdf0e10cSrcweir // pUnoText is created on demand (getString/setString work without it) 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir void ScHeaderFooterTextObj::CreateUnoText_Impl() 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir if ( !pUnoText ) 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir // can't be aggregated because getString/setString is handled here 348*cdf0e10cSrcweir ScSharedHeaderFooterEditSource aEditSource( &aTextData ); 349*cdf0e10cSrcweir pUnoText = new SvxUnoText( &aEditSource, lcl_GetHdFtPropertySet(), uno::Reference<text::XText>() ); 350*cdf0e10cSrcweir pUnoText->acquire(); 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir ScHeaderFooterTextObj::~ScHeaderFooterTextObj() 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir if (pUnoText) 357*cdf0e10cSrcweir pUnoText->release(); 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir const SvxUnoText& ScHeaderFooterTextObj::GetUnoText() 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir if (!pUnoText) 363*cdf0e10cSrcweir CreateUnoText_Impl(); 364*cdf0e10cSrcweir return *pUnoText; 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir // XText 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir uno::Reference<text::XTextCursor> SAL_CALL ScHeaderFooterTextObj::createTextCursor() 370*cdf0e10cSrcweir throw(uno::RuntimeException) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir ScUnoGuard aGuard; 373*cdf0e10cSrcweir return new ScHeaderFooterTextCursor( *this ); 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir uno::Reference<text::XTextCursor> SAL_CALL ScHeaderFooterTextObj::createTextCursorByRange( 377*cdf0e10cSrcweir const uno::Reference<text::XTextRange>& aTextPosition ) 378*cdf0e10cSrcweir throw(uno::RuntimeException) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir ScUnoGuard aGuard; 381*cdf0e10cSrcweir if (!pUnoText) 382*cdf0e10cSrcweir CreateUnoText_Impl(); 383*cdf0e10cSrcweir return pUnoText->createTextCursorByRange(aTextPosition); 384*cdf0e10cSrcweir //! wie ScCellObj::createTextCursorByRange, wenn SvxUnoTextRange_getReflection verfuegbar 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir void ScHeaderFooterTextObj::FillDummyFieldData( ScHeaderFieldData& rData ) // static 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir String aDummy(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( "???" ))); 390*cdf0e10cSrcweir rData.aTitle = aDummy; 391*cdf0e10cSrcweir rData.aLongDocName = aDummy; 392*cdf0e10cSrcweir rData.aShortDocName = aDummy; 393*cdf0e10cSrcweir rData.aTabName = aDummy; 394*cdf0e10cSrcweir rData.nPageNo = 1; 395*cdf0e10cSrcweir rData.nTotalPages = 99; 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir rtl::OUString SAL_CALL ScHeaderFooterTextObj::getString() throw(uno::RuntimeException) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir ScUnoGuard aGuard; 401*cdf0e10cSrcweir rtl::OUString aRet; 402*cdf0e10cSrcweir const EditTextObject* pData; 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir sal_uInt16 nPart = aTextData.GetPart(); 405*cdf0e10cSrcweir ScHeaderFooterContentObj& rContentObj = aTextData.GetContentObj(); 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir if (nPart == SC_HDFT_LEFT) 408*cdf0e10cSrcweir pData = rContentObj.GetLeftEditObject(); 409*cdf0e10cSrcweir else if (nPart == SC_HDFT_CENTER) 410*cdf0e10cSrcweir pData = rContentObj.GetCenterEditObject(); 411*cdf0e10cSrcweir else 412*cdf0e10cSrcweir pData = rContentObj.GetRightEditObject(); 413*cdf0e10cSrcweir if (pData) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir // for pure text, no font info is needed in pool defaults 416*cdf0e10cSrcweir ScHeaderEditEngine aEditEngine( EditEngine::CreatePool(), sal_True ); 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir ScHeaderFieldData aData; 419*cdf0e10cSrcweir FillDummyFieldData( aData ); 420*cdf0e10cSrcweir aEditEngine.SetData( aData ); 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir aEditEngine.SetText(*pData); 423*cdf0e10cSrcweir aRet = ScEditUtil::GetSpaceDelimitedString( aEditEngine ); 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir return aRet; 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir void SAL_CALL ScHeaderFooterTextObj::setString( const rtl::OUString& aText ) throw(uno::RuntimeException) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir ScUnoGuard aGuard; 431*cdf0e10cSrcweir String aString(aText); 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir // for pure text, no font info is needed in pool defaults 434*cdf0e10cSrcweir ScHeaderEditEngine aEditEngine( EditEngine::CreatePool(), sal_True ); 435*cdf0e10cSrcweir aEditEngine.SetText( aString ); 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir aTextData.GetContentObj().UpdateText( aTextData.GetPart(), aEditEngine ); 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir void SAL_CALL ScHeaderFooterTextObj::insertString( const uno::Reference<text::XTextRange>& xRange, 441*cdf0e10cSrcweir const rtl::OUString& aString, sal_Bool bAbsorb ) 442*cdf0e10cSrcweir throw(uno::RuntimeException) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir ScUnoGuard aGuard; 445*cdf0e10cSrcweir if (!pUnoText) 446*cdf0e10cSrcweir CreateUnoText_Impl(); 447*cdf0e10cSrcweir pUnoText->insertString( xRange, aString, bAbsorb ); 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir void SAL_CALL ScHeaderFooterTextObj::insertControlCharacter( 451*cdf0e10cSrcweir const uno::Reference<text::XTextRange>& xRange, 452*cdf0e10cSrcweir sal_Int16 nControlCharacter, sal_Bool bAbsorb ) 453*cdf0e10cSrcweir throw(lang::IllegalArgumentException, uno::RuntimeException) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir ScUnoGuard aGuard; 456*cdf0e10cSrcweir if (!pUnoText) 457*cdf0e10cSrcweir CreateUnoText_Impl(); 458*cdf0e10cSrcweir pUnoText->insertControlCharacter( xRange, nControlCharacter, bAbsorb ); 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir void SAL_CALL ScHeaderFooterTextObj::insertTextContent( 462*cdf0e10cSrcweir const uno::Reference<text::XTextRange >& xRange, 463*cdf0e10cSrcweir const uno::Reference<text::XTextContent >& xContent, 464*cdf0e10cSrcweir sal_Bool bAbsorb ) 465*cdf0e10cSrcweir throw(lang::IllegalArgumentException, uno::RuntimeException) 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir ScUnoGuard aGuard; 468*cdf0e10cSrcweir if ( xContent.is() && xRange.is() ) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir ScHeaderFieldObj* pHeaderField = ScHeaderFieldObj::getImplementation( xContent ); 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir SvxUnoTextRangeBase* pTextRange = 473*cdf0e10cSrcweir ScHeaderFooterTextCursor::getImplementation( xRange ); 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir #if 0 476*cdf0e10cSrcweir if (!pTextRange) 477*cdf0e10cSrcweir pTextRange = (SvxUnoTextRange*)xRange->getImplementation( 478*cdf0e10cSrcweir SvxUnoTextRange_getReflection() ); 479*cdf0e10cSrcweir //! bei SvxUnoTextRange testen, ob in passendem Objekt !!! 480*cdf0e10cSrcweir #endif 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir if ( pHeaderField && !pHeaderField->IsInserted() && pTextRange ) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir SvxEditSource* pEditSource = pTextRange->GetEditSource(); 485*cdf0e10cSrcweir ESelection aSelection(pTextRange->GetSelection()); 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir if (!bAbsorb) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir // don't replace -> append at end 490*cdf0e10cSrcweir aSelection.Adjust(); 491*cdf0e10cSrcweir aSelection.nStartPara = aSelection.nEndPara; 492*cdf0e10cSrcweir aSelection.nStartPos = aSelection.nEndPos; 493*cdf0e10cSrcweir } 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir SvxFieldItem aItem(pHeaderField->CreateFieldItem()); 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder(); 498*cdf0e10cSrcweir pForwarder->QuickInsertField( aItem, aSelection ); 499*cdf0e10cSrcweir pEditSource->UpdateData(); 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir // neue Selektion: ein Zeichen 502*cdf0e10cSrcweir aSelection.Adjust(); 503*cdf0e10cSrcweir aSelection.nEndPara = aSelection.nStartPara; 504*cdf0e10cSrcweir aSelection.nEndPos = aSelection.nStartPos + 1; 505*cdf0e10cSrcweir pHeaderField->InitDoc( &aTextData.GetContentObj(), aTextData.GetPart(), aSelection ); 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir // #91431# for bAbsorb=sal_False, the new selection must be behind the inserted content 508*cdf0e10cSrcweir // (the xml filter relies on this) 509*cdf0e10cSrcweir if (!bAbsorb) 510*cdf0e10cSrcweir aSelection.nStartPos = aSelection.nEndPos; 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir pTextRange->SetSelection( aSelection ); 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir return; 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir if (!pUnoText) 519*cdf0e10cSrcweir CreateUnoText_Impl(); 520*cdf0e10cSrcweir pUnoText->insertTextContent( xRange, xContent, bAbsorb ); 521*cdf0e10cSrcweir } 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir void SAL_CALL ScHeaderFooterTextObj::removeTextContent( 524*cdf0e10cSrcweir const uno::Reference<text::XTextContent>& xContent ) 525*cdf0e10cSrcweir throw(container::NoSuchElementException, uno::RuntimeException) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir ScUnoGuard aGuard; 528*cdf0e10cSrcweir if ( xContent.is() ) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir ScHeaderFieldObj* pHeaderField = ScHeaderFieldObj::getImplementation( xContent ); 531*cdf0e10cSrcweir if ( pHeaderField && pHeaderField->IsInserted() ) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir //! Testen, ob das Feld in dieser Zelle ist 534*cdf0e10cSrcweir pHeaderField->DeleteField(); 535*cdf0e10cSrcweir return; 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir if (!pUnoText) 539*cdf0e10cSrcweir CreateUnoText_Impl(); 540*cdf0e10cSrcweir pUnoText->removeTextContent( xContent ); 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir uno::Reference<text::XText> SAL_CALL ScHeaderFooterTextObj::getText() throw(uno::RuntimeException) 544*cdf0e10cSrcweir { 545*cdf0e10cSrcweir ScUnoGuard aGuard; 546*cdf0e10cSrcweir if (!pUnoText) 547*cdf0e10cSrcweir CreateUnoText_Impl(); 548*cdf0e10cSrcweir return pUnoText->getText(); 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextObj::getStart() throw(uno::RuntimeException) 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir ScUnoGuard aGuard; 554*cdf0e10cSrcweir if (!pUnoText) 555*cdf0e10cSrcweir CreateUnoText_Impl(); 556*cdf0e10cSrcweir return pUnoText->getStart(); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextObj::getEnd() throw(uno::RuntimeException) 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir ScUnoGuard aGuard; 562*cdf0e10cSrcweir if (!pUnoText) 563*cdf0e10cSrcweir CreateUnoText_Impl(); 564*cdf0e10cSrcweir return pUnoText->getEnd(); 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir // XTextFieldsSupplier 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir uno::Reference<container::XEnumerationAccess> SAL_CALL ScHeaderFooterTextObj::getTextFields() 570*cdf0e10cSrcweir throw(uno::RuntimeException) 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir ScUnoGuard aGuard; 573*cdf0e10cSrcweir // all fields 574*cdf0e10cSrcweir return new ScHeaderFieldsObj( &aTextData.GetContentObj(), aTextData.GetPart(), SC_SERVICE_INVALID ); 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir uno::Reference<container::XNameAccess> SAL_CALL ScHeaderFooterTextObj::getTextFieldMasters() 578*cdf0e10cSrcweir throw(uno::RuntimeException) 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir // sowas gibts nicht im Calc (?) 581*cdf0e10cSrcweir return NULL; 582*cdf0e10cSrcweir } 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir // XTextRangeMover 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir void SAL_CALL ScHeaderFooterTextObj::moveTextRange( 587*cdf0e10cSrcweir const uno::Reference<text::XTextRange>& xRange, 588*cdf0e10cSrcweir sal_Int16 nParagraphs ) 589*cdf0e10cSrcweir throw(uno::RuntimeException) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir ScUnoGuard aGuard; 592*cdf0e10cSrcweir if (!pUnoText) 593*cdf0e10cSrcweir CreateUnoText_Impl(); 594*cdf0e10cSrcweir pUnoText->moveTextRange( xRange, nParagraphs ); 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir // XEnumerationAccess 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir uno::Reference<container::XEnumeration> SAL_CALL ScHeaderFooterTextObj::createEnumeration() 600*cdf0e10cSrcweir throw(uno::RuntimeException) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir ScUnoGuard aGuard; 603*cdf0e10cSrcweir if (!pUnoText) 604*cdf0e10cSrcweir CreateUnoText_Impl(); 605*cdf0e10cSrcweir return pUnoText->createEnumeration(); 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir // XElementAccess 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir uno::Type SAL_CALL ScHeaderFooterTextObj::getElementType() throw(uno::RuntimeException) 611*cdf0e10cSrcweir { 612*cdf0e10cSrcweir ScUnoGuard aGuard; 613*cdf0e10cSrcweir if (!pUnoText) 614*cdf0e10cSrcweir CreateUnoText_Impl(); 615*cdf0e10cSrcweir return pUnoText->getElementType(); 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir sal_Bool SAL_CALL ScHeaderFooterTextObj::hasElements() throw(uno::RuntimeException) 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir ScUnoGuard aGuard; 621*cdf0e10cSrcweir if (!pUnoText) 622*cdf0e10cSrcweir CreateUnoText_Impl(); 623*cdf0e10cSrcweir return pUnoText->hasElements(); 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir //------------------------------------------------------------------------ 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir ScCellTextCursor::ScCellTextCursor(const ScCellTextCursor& rOther) : 629*cdf0e10cSrcweir SvxUnoTextCursor( rOther ), 630*cdf0e10cSrcweir rTextObj( rOther.rTextObj ) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir rTextObj.acquire(); 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir ScCellTextCursor::ScCellTextCursor(ScCellObj& rText) : 636*cdf0e10cSrcweir SvxUnoTextCursor( rText.GetUnoText() ), 637*cdf0e10cSrcweir rTextObj( rText ) 638*cdf0e10cSrcweir { 639*cdf0e10cSrcweir rTextObj.acquire(); 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir ScCellTextCursor::~ScCellTextCursor() throw() 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir rTextObj.release(); 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir // SvxUnoTextCursor methods reimplemented here to return the right objects: 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir uno::Reference<text::XText> SAL_CALL ScCellTextCursor::getText() throw(uno::RuntimeException) 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir ScUnoGuard aGuard; 652*cdf0e10cSrcweir return &rTextObj; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir uno::Reference<text::XTextRange> SAL_CALL ScCellTextCursor::getStart() throw(uno::RuntimeException) 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir ScUnoGuard aGuard; 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir //! use other object for range than cursor? 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir ScCellTextCursor* pNew = new ScCellTextCursor( *this ); 662*cdf0e10cSrcweir uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir ESelection aNewSel(GetSelection()); 665*cdf0e10cSrcweir aNewSel.nEndPara = aNewSel.nStartPara; 666*cdf0e10cSrcweir aNewSel.nEndPos = aNewSel.nStartPos; 667*cdf0e10cSrcweir pNew->SetSelection( aNewSel ); 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir return xRange; 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir uno::Reference<text::XTextRange> SAL_CALL ScCellTextCursor::getEnd() throw(uno::RuntimeException) 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir ScUnoGuard aGuard; 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir //! use other object for range than cursor? 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir ScCellTextCursor* pNew = new ScCellTextCursor( *this ); 679*cdf0e10cSrcweir uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir ESelection aNewSel(GetSelection()); 682*cdf0e10cSrcweir aNewSel.nStartPara = aNewSel.nEndPara; 683*cdf0e10cSrcweir aNewSel.nStartPos = aNewSel.nEndPos; 684*cdf0e10cSrcweir pNew->SetSelection( aNewSel ); 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir return xRange; 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir // XUnoTunnel 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir sal_Int64 SAL_CALL ScCellTextCursor::getSomething( 692*cdf0e10cSrcweir const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException) 693*cdf0e10cSrcweir { 694*cdf0e10cSrcweir if ( rId.getLength() == 16 && 695*cdf0e10cSrcweir 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 696*cdf0e10cSrcweir rId.getConstArray(), 16 ) ) 697*cdf0e10cSrcweir { 698*cdf0e10cSrcweir return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); 699*cdf0e10cSrcweir } 700*cdf0e10cSrcweir return SvxUnoTextCursor::getSomething( rId ); 701*cdf0e10cSrcweir } 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir // static 704*cdf0e10cSrcweir const uno::Sequence<sal_Int8>& ScCellTextCursor::getUnoTunnelId() 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir static uno::Sequence<sal_Int8> * pSeq = 0; 707*cdf0e10cSrcweir if( !pSeq ) 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 710*cdf0e10cSrcweir if( !pSeq ) 711*cdf0e10cSrcweir { 712*cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq( 16 ); 713*cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 714*cdf0e10cSrcweir pSeq = &aSeq; 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir } 717*cdf0e10cSrcweir return *pSeq; 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir // static 721*cdf0e10cSrcweir ScCellTextCursor* ScCellTextCursor::getImplementation( const uno::Reference<uno::XInterface> xObj ) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir ScCellTextCursor* pRet = NULL; 724*cdf0e10cSrcweir uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY ); 725*cdf0e10cSrcweir if (xUT.is()) 726*cdf0e10cSrcweir pRet = reinterpret_cast<ScCellTextCursor*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId()))); 727*cdf0e10cSrcweir return pRet; 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir //------------------------------------------------------------------------ 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir ScHeaderFooterTextCursor::ScHeaderFooterTextCursor(const ScHeaderFooterTextCursor& rOther) : 733*cdf0e10cSrcweir SvxUnoTextCursor( rOther ), 734*cdf0e10cSrcweir rTextObj( rOther.rTextObj ) 735*cdf0e10cSrcweir { 736*cdf0e10cSrcweir rTextObj.acquire(); 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir ScHeaderFooterTextCursor::ScHeaderFooterTextCursor(ScHeaderFooterTextObj& rText) : 740*cdf0e10cSrcweir SvxUnoTextCursor( rText.GetUnoText() ), 741*cdf0e10cSrcweir rTextObj( rText ) 742*cdf0e10cSrcweir { 743*cdf0e10cSrcweir rTextObj.acquire(); 744*cdf0e10cSrcweir } 745*cdf0e10cSrcweir 746*cdf0e10cSrcweir ScHeaderFooterTextCursor::~ScHeaderFooterTextCursor() throw() 747*cdf0e10cSrcweir { 748*cdf0e10cSrcweir rTextObj.release(); 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir // SvxUnoTextCursor methods reimplemented here to return the right objects: 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir uno::Reference<text::XText> SAL_CALL ScHeaderFooterTextCursor::getText() throw(uno::RuntimeException) 754*cdf0e10cSrcweir { 755*cdf0e10cSrcweir ScUnoGuard aGuard; 756*cdf0e10cSrcweir return &rTextObj; 757*cdf0e10cSrcweir } 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextCursor::getStart() throw(uno::RuntimeException) 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir ScUnoGuard aGuard; 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir //! use other object for range than cursor? 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir ScHeaderFooterTextCursor* pNew = new ScHeaderFooterTextCursor( *this ); 766*cdf0e10cSrcweir uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir ESelection aNewSel(GetSelection()); 769*cdf0e10cSrcweir aNewSel.nEndPara = aNewSel.nStartPara; 770*cdf0e10cSrcweir aNewSel.nEndPos = aNewSel.nStartPos; 771*cdf0e10cSrcweir pNew->SetSelection( aNewSel ); 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir return xRange; 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextCursor::getEnd() throw(uno::RuntimeException) 777*cdf0e10cSrcweir { 778*cdf0e10cSrcweir ScUnoGuard aGuard; 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir //! use other object for range than cursor? 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir ScHeaderFooterTextCursor* pNew = new ScHeaderFooterTextCursor( *this ); 783*cdf0e10cSrcweir uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir ESelection aNewSel(GetSelection()); 786*cdf0e10cSrcweir aNewSel.nStartPara = aNewSel.nEndPara; 787*cdf0e10cSrcweir aNewSel.nStartPos = aNewSel.nEndPos; 788*cdf0e10cSrcweir pNew->SetSelection( aNewSel ); 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir return xRange; 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir // XUnoTunnel 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir sal_Int64 SAL_CALL ScHeaderFooterTextCursor::getSomething( 796*cdf0e10cSrcweir const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException) 797*cdf0e10cSrcweir { 798*cdf0e10cSrcweir if ( rId.getLength() == 16 && 799*cdf0e10cSrcweir 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 800*cdf0e10cSrcweir rId.getConstArray(), 16 ) ) 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir return SvxUnoTextCursor::getSomething( rId ); 805*cdf0e10cSrcweir } 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir // static 808*cdf0e10cSrcweir const uno::Sequence<sal_Int8>& ScHeaderFooterTextCursor::getUnoTunnelId() 809*cdf0e10cSrcweir { 810*cdf0e10cSrcweir static uno::Sequence<sal_Int8> * pSeq = 0; 811*cdf0e10cSrcweir if( !pSeq ) 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 814*cdf0e10cSrcweir if( !pSeq ) 815*cdf0e10cSrcweir { 816*cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq( 16 ); 817*cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 818*cdf0e10cSrcweir pSeq = &aSeq; 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir } 821*cdf0e10cSrcweir return *pSeq; 822*cdf0e10cSrcweir } 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir // static 825*cdf0e10cSrcweir ScHeaderFooterTextCursor* ScHeaderFooterTextCursor::getImplementation( 826*cdf0e10cSrcweir const uno::Reference<uno::XInterface> xObj ) 827*cdf0e10cSrcweir { 828*cdf0e10cSrcweir ScHeaderFooterTextCursor* pRet = NULL; 829*cdf0e10cSrcweir uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY ); 830*cdf0e10cSrcweir if (xUT.is()) 831*cdf0e10cSrcweir pRet = reinterpret_cast<ScHeaderFooterTextCursor*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId()))); 832*cdf0e10cSrcweir return pRet; 833*cdf0e10cSrcweir } 834*cdf0e10cSrcweir 835*cdf0e10cSrcweir //------------------------------------------------------------------------ 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir ScDrawTextCursor::ScDrawTextCursor(const ScDrawTextCursor& rOther) : 838*cdf0e10cSrcweir SvxUnoTextCursor( rOther ), 839*cdf0e10cSrcweir xParentText( rOther.xParentText ) 840*cdf0e10cSrcweir { 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir 843*cdf0e10cSrcweir ScDrawTextCursor::ScDrawTextCursor( const uno::Reference<text::XText>& xParent, 844*cdf0e10cSrcweir const SvxUnoTextBase& rText ) : 845*cdf0e10cSrcweir SvxUnoTextCursor( rText ), 846*cdf0e10cSrcweir xParentText( xParent ) 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir { 849*cdf0e10cSrcweir } 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir ScDrawTextCursor::~ScDrawTextCursor() throw() 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir } 854*cdf0e10cSrcweir 855*cdf0e10cSrcweir // SvxUnoTextCursor methods reimplemented here to return the right objects: 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir uno::Reference<text::XText> SAL_CALL ScDrawTextCursor::getText() throw(uno::RuntimeException) 858*cdf0e10cSrcweir { 859*cdf0e10cSrcweir ScUnoGuard aGuard; 860*cdf0e10cSrcweir return xParentText; 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir uno::Reference<text::XTextRange> SAL_CALL ScDrawTextCursor::getStart() throw(uno::RuntimeException) 864*cdf0e10cSrcweir { 865*cdf0e10cSrcweir ScUnoGuard aGuard; 866*cdf0e10cSrcweir 867*cdf0e10cSrcweir //! use other object for range than cursor? 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir ScDrawTextCursor* pNew = new ScDrawTextCursor( *this ); 870*cdf0e10cSrcweir uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); 871*cdf0e10cSrcweir 872*cdf0e10cSrcweir ESelection aNewSel(GetSelection()); 873*cdf0e10cSrcweir aNewSel.nEndPara = aNewSel.nStartPara; 874*cdf0e10cSrcweir aNewSel.nEndPos = aNewSel.nStartPos; 875*cdf0e10cSrcweir pNew->SetSelection( aNewSel ); 876*cdf0e10cSrcweir 877*cdf0e10cSrcweir return xRange; 878*cdf0e10cSrcweir } 879*cdf0e10cSrcweir 880*cdf0e10cSrcweir uno::Reference<text::XTextRange> SAL_CALL ScDrawTextCursor::getEnd() throw(uno::RuntimeException) 881*cdf0e10cSrcweir { 882*cdf0e10cSrcweir ScUnoGuard aGuard; 883*cdf0e10cSrcweir 884*cdf0e10cSrcweir //! use other object for range than cursor? 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir ScDrawTextCursor* pNew = new ScDrawTextCursor( *this ); 887*cdf0e10cSrcweir uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) ); 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir ESelection aNewSel(GetSelection()); 890*cdf0e10cSrcweir aNewSel.nStartPara = aNewSel.nEndPara; 891*cdf0e10cSrcweir aNewSel.nStartPos = aNewSel.nEndPos; 892*cdf0e10cSrcweir pNew->SetSelection( aNewSel ); 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir return xRange; 895*cdf0e10cSrcweir } 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir // XUnoTunnel 898*cdf0e10cSrcweir 899*cdf0e10cSrcweir sal_Int64 SAL_CALL ScDrawTextCursor::getSomething( 900*cdf0e10cSrcweir const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException) 901*cdf0e10cSrcweir { 902*cdf0e10cSrcweir if ( rId.getLength() == 16 && 903*cdf0e10cSrcweir 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 904*cdf0e10cSrcweir rId.getConstArray(), 16 ) ) 905*cdf0e10cSrcweir { 906*cdf0e10cSrcweir return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); 907*cdf0e10cSrcweir } 908*cdf0e10cSrcweir return SvxUnoTextCursor::getSomething( rId ); 909*cdf0e10cSrcweir } 910*cdf0e10cSrcweir 911*cdf0e10cSrcweir // static 912*cdf0e10cSrcweir const uno::Sequence<sal_Int8>& ScDrawTextCursor::getUnoTunnelId() 913*cdf0e10cSrcweir { 914*cdf0e10cSrcweir static uno::Sequence<sal_Int8> * pSeq = 0; 915*cdf0e10cSrcweir if( !pSeq ) 916*cdf0e10cSrcweir { 917*cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 918*cdf0e10cSrcweir if( !pSeq ) 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq( 16 ); 921*cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 922*cdf0e10cSrcweir pSeq = &aSeq; 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir } 925*cdf0e10cSrcweir return *pSeq; 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir // static 929*cdf0e10cSrcweir ScDrawTextCursor* ScDrawTextCursor::getImplementation( const uno::Reference<uno::XInterface> xObj ) 930*cdf0e10cSrcweir { 931*cdf0e10cSrcweir ScDrawTextCursor* pRet = NULL; 932*cdf0e10cSrcweir uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY ); 933*cdf0e10cSrcweir if (xUT.is()) 934*cdf0e10cSrcweir pRet = reinterpret_cast<ScDrawTextCursor*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId()))); 935*cdf0e10cSrcweir return pRet; 936*cdf0e10cSrcweir } 937*cdf0e10cSrcweir 938*cdf0e10cSrcweir //------------------------------------------------------------------------ 939*cdf0e10cSrcweir 940*cdf0e10cSrcweir ScSimpleEditSourceHelper::ScSimpleEditSourceHelper() 941*cdf0e10cSrcweir { 942*cdf0e10cSrcweir SfxItemPool* pEnginePool = EditEngine::CreatePool(); 943*cdf0e10cSrcweir pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); 944*cdf0e10cSrcweir pEnginePool->FreezeIdRanges(); 945*cdf0e10cSrcweir 946*cdf0e10cSrcweir pEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True ); // TRUE: become owner of pool 947*cdf0e10cSrcweir pForwarder = new SvxEditEngineForwarder( *pEditEngine ); 948*cdf0e10cSrcweir pOriginalSource = new ScSimpleEditSource( pForwarder ); 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir 951*cdf0e10cSrcweir ScSimpleEditSourceHelper::~ScSimpleEditSourceHelper() 952*cdf0e10cSrcweir { 953*cdf0e10cSrcweir ScUnoGuard aGuard; // needed for EditEngine dtor 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir delete pOriginalSource; 956*cdf0e10cSrcweir delete pForwarder; 957*cdf0e10cSrcweir delete pEditEngine; 958*cdf0e10cSrcweir } 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir ScEditEngineTextObj::ScEditEngineTextObj() : 961*cdf0e10cSrcweir SvxUnoText( GetOriginalSource(), ScCellObj::GetEditPropertySet(), uno::Reference<text::XText>() ) 962*cdf0e10cSrcweir { 963*cdf0e10cSrcweir } 964*cdf0e10cSrcweir 965*cdf0e10cSrcweir ScEditEngineTextObj::~ScEditEngineTextObj() throw() 966*cdf0e10cSrcweir { 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir void ScEditEngineTextObj::SetText( const EditTextObject& rTextObject ) 970*cdf0e10cSrcweir { 971*cdf0e10cSrcweir GetEditEngine()->SetText( rTextObject ); 972*cdf0e10cSrcweir 973*cdf0e10cSrcweir ESelection aSel; 974*cdf0e10cSrcweir ::GetSelection( aSel, GetEditSource()->GetTextForwarder() ); 975*cdf0e10cSrcweir SetSelection( aSel ); 976*cdf0e10cSrcweir } 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir EditTextObject* ScEditEngineTextObj::CreateTextObject() 979*cdf0e10cSrcweir { 980*cdf0e10cSrcweir return GetEditEngine()->CreateTextObject(); 981*cdf0e10cSrcweir } 982*cdf0e10cSrcweir 983*cdf0e10cSrcweir //------------------------------------------------------------------------ 984*cdf0e10cSrcweir 985*cdf0e10cSrcweir ScCellTextData::ScCellTextData(ScDocShell* pDocSh, const ScAddress& rP) : 986*cdf0e10cSrcweir pDocShell( pDocSh ), 987*cdf0e10cSrcweir aCellPos( rP ), 988*cdf0e10cSrcweir pEditEngine( NULL ), 989*cdf0e10cSrcweir pForwarder( NULL ), 990*cdf0e10cSrcweir pOriginalSource( NULL ), 991*cdf0e10cSrcweir bDataValid( sal_False ), 992*cdf0e10cSrcweir bInUpdate( sal_False ), 993*cdf0e10cSrcweir bDirty( sal_False ), 994*cdf0e10cSrcweir bDoUpdate( sal_True ) 995*cdf0e10cSrcweir { 996*cdf0e10cSrcweir if (pDocShell) 997*cdf0e10cSrcweir pDocShell->GetDocument()->AddUnoObject(*this); 998*cdf0e10cSrcweir } 999*cdf0e10cSrcweir 1000*cdf0e10cSrcweir ScCellTextData::~ScCellTextData() 1001*cdf0e10cSrcweir { 1002*cdf0e10cSrcweir ScUnoGuard aGuard; // needed for EditEngine dtor 1003*cdf0e10cSrcweir 1004*cdf0e10cSrcweir if (pDocShell) 1005*cdf0e10cSrcweir { 1006*cdf0e10cSrcweir pDocShell->GetDocument()->RemoveUnoObject(*this); 1007*cdf0e10cSrcweir pDocShell->GetDocument()->DisposeFieldEditEngine(pEditEngine); 1008*cdf0e10cSrcweir } 1009*cdf0e10cSrcweir else 1010*cdf0e10cSrcweir delete pEditEngine; 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir delete pForwarder; 1013*cdf0e10cSrcweir 1014*cdf0e10cSrcweir delete pOriginalSource; 1015*cdf0e10cSrcweir } 1016*cdf0e10cSrcweir 1017*cdf0e10cSrcweir ScSharedCellEditSource* ScCellTextData::GetOriginalSource() 1018*cdf0e10cSrcweir { 1019*cdf0e10cSrcweir if (!pOriginalSource) 1020*cdf0e10cSrcweir pOriginalSource = new ScSharedCellEditSource( this ); 1021*cdf0e10cSrcweir return pOriginalSource; 1022*cdf0e10cSrcweir } 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir void ScCellTextData::GetCellText(const ScAddress& rCellPos, String& rText) 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir if (pDocShell) 1027*cdf0e10cSrcweir { 1028*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1029*cdf0e10cSrcweir pDoc->GetInputString( rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), rText ); 1030*cdf0e10cSrcweir } 1031*cdf0e10cSrcweir } 1032*cdf0e10cSrcweir 1033*cdf0e10cSrcweir SvxTextForwarder* ScCellTextData::GetTextForwarder() 1034*cdf0e10cSrcweir { 1035*cdf0e10cSrcweir if (!pEditEngine) 1036*cdf0e10cSrcweir { 1037*cdf0e10cSrcweir if ( pDocShell ) 1038*cdf0e10cSrcweir { 1039*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1040*cdf0e10cSrcweir pEditEngine = pDoc->CreateFieldEditEngine(); 1041*cdf0e10cSrcweir } 1042*cdf0e10cSrcweir else 1043*cdf0e10cSrcweir { 1044*cdf0e10cSrcweir SfxItemPool* pEnginePool = EditEngine::CreatePool(); 1045*cdf0e10cSrcweir pEnginePool->FreezeIdRanges(); 1046*cdf0e10cSrcweir pEditEngine = new ScFieldEditEngine( pEnginePool, NULL, sal_True ); 1047*cdf0e10cSrcweir } 1048*cdf0e10cSrcweir // currently, GetPortions doesn't work if UpdateMode is sal_False, 1049*cdf0e10cSrcweir // this will be fixed (in EditEngine) by src600 1050*cdf0e10cSrcweir // pEditEngine->SetUpdateMode( sal_False ); 1051*cdf0e10cSrcweir pEditEngine->EnableUndo( sal_False ); 1052*cdf0e10cSrcweir if (pDocShell) 1053*cdf0e10cSrcweir pEditEngine->SetRefDevice(pDocShell->GetRefDevice()); 1054*cdf0e10cSrcweir else 1055*cdf0e10cSrcweir pEditEngine->SetRefMapMode( MAP_100TH_MM ); 1056*cdf0e10cSrcweir pForwarder = new SvxEditEngineForwarder(*pEditEngine); 1057*cdf0e10cSrcweir } 1058*cdf0e10cSrcweir 1059*cdf0e10cSrcweir if (bDataValid) 1060*cdf0e10cSrcweir return pForwarder; 1061*cdf0e10cSrcweir 1062*cdf0e10cSrcweir String aText; 1063*cdf0e10cSrcweir 1064*cdf0e10cSrcweir if (pDocShell) 1065*cdf0e10cSrcweir { 1066*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1067*cdf0e10cSrcweir 1068*cdf0e10cSrcweir SfxItemSet aDefaults( pEditEngine->GetEmptyItemSet() ); 1069*cdf0e10cSrcweir if( const ScPatternAttr* pPattern = 1070*cdf0e10cSrcweir pDoc->GetPattern( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab() ) ) 1071*cdf0e10cSrcweir { 1072*cdf0e10cSrcweir pPattern->FillEditItemSet( &aDefaults ); 1073*cdf0e10cSrcweir pPattern->FillEditParaItems( &aDefaults ); // including alignment etc. (for reading) 1074*cdf0e10cSrcweir } 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir const ScBaseCell* pCell = pDoc->GetCell( aCellPos ); 1077*cdf0e10cSrcweir if ( pCell && pCell->GetCellType() == CELLTYPE_EDIT ) 1078*cdf0e10cSrcweir pEditEngine->SetTextNewDefaults( *((const ScEditCell*)pCell)->GetData(), aDefaults ); 1079*cdf0e10cSrcweir else 1080*cdf0e10cSrcweir { 1081*cdf0e10cSrcweir GetCellText( aCellPos, aText ); 1082*cdf0e10cSrcweir if (aText.Len()) 1083*cdf0e10cSrcweir pEditEngine->SetTextNewDefaults( aText, aDefaults ); 1084*cdf0e10cSrcweir else 1085*cdf0e10cSrcweir pEditEngine->SetDefaults(aDefaults); 1086*cdf0e10cSrcweir } 1087*cdf0e10cSrcweir } 1088*cdf0e10cSrcweir 1089*cdf0e10cSrcweir bDataValid = sal_True; 1090*cdf0e10cSrcweir return pForwarder; 1091*cdf0e10cSrcweir } 1092*cdf0e10cSrcweir 1093*cdf0e10cSrcweir void ScCellTextData::UpdateData() 1094*cdf0e10cSrcweir { 1095*cdf0e10cSrcweir if ( bDoUpdate ) 1096*cdf0e10cSrcweir { 1097*cdf0e10cSrcweir DBG_ASSERT(pEditEngine != NULL, "no EditEngine for UpdateData()"); 1098*cdf0e10cSrcweir if ( pDocShell && pEditEngine ) 1099*cdf0e10cSrcweir { 1100*cdf0e10cSrcweir // during the own UpdateData call, bDataValid must not be reset, 1101*cdf0e10cSrcweir // or things like attributes after the text would be lost 1102*cdf0e10cSrcweir // (are not stored in the cell) 1103*cdf0e10cSrcweir 1104*cdf0e10cSrcweir bInUpdate = sal_True; // prevents bDataValid from being reset 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 1107*cdf0e10cSrcweir aFunc.PutData( aCellPos, *pEditEngine, sal_False, sal_True ); // always as text 1108*cdf0e10cSrcweir 1109*cdf0e10cSrcweir bInUpdate = sal_False; 1110*cdf0e10cSrcweir bDirty = sal_False; 1111*cdf0e10cSrcweir } 1112*cdf0e10cSrcweir } 1113*cdf0e10cSrcweir else 1114*cdf0e10cSrcweir bDirty = sal_True; 1115*cdf0e10cSrcweir } 1116*cdf0e10cSrcweir 1117*cdf0e10cSrcweir void ScCellTextData::Notify( SfxBroadcaster&, const SfxHint& rHint ) 1118*cdf0e10cSrcweir { 1119*cdf0e10cSrcweir if ( rHint.ISA( ScUpdateRefHint ) ) 1120*cdf0e10cSrcweir { 1121*cdf0e10cSrcweir // const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint; 1122*cdf0e10cSrcweir 1123*cdf0e10cSrcweir //! Ref-Update 1124*cdf0e10cSrcweir } 1125*cdf0e10cSrcweir else if ( rHint.ISA( SfxSimpleHint ) ) 1126*cdf0e10cSrcweir { 1127*cdf0e10cSrcweir sal_uLong nId = ((const SfxSimpleHint&)rHint).GetId(); 1128*cdf0e10cSrcweir if ( nId == SFX_HINT_DYING ) 1129*cdf0e10cSrcweir { 1130*cdf0e10cSrcweir pDocShell = NULL; // invalid now 1131*cdf0e10cSrcweir 1132*cdf0e10cSrcweir DELETEZ( pForwarder ); 1133*cdf0e10cSrcweir DELETEZ( pEditEngine ); // EditEngine uses document's pool 1134*cdf0e10cSrcweir } 1135*cdf0e10cSrcweir else if ( nId == SFX_HINT_DATACHANGED ) 1136*cdf0e10cSrcweir { 1137*cdf0e10cSrcweir if (!bInUpdate) // not for own UpdateData calls 1138*cdf0e10cSrcweir bDataValid = sal_False; // text has to be read from the cell again 1139*cdf0e10cSrcweir } 1140*cdf0e10cSrcweir } 1141*cdf0e10cSrcweir } 1142*cdf0e10cSrcweir 1143*cdf0e10cSrcweir ScCellTextObj::ScCellTextObj(ScDocShell* pDocSh, const ScAddress& rP) : 1144*cdf0e10cSrcweir ScCellTextData( pDocSh, rP ), 1145*cdf0e10cSrcweir SvxUnoText( GetOriginalSource(), ScCellObj::GetEditPropertySet(), uno::Reference<text::XText>() ) 1146*cdf0e10cSrcweir { 1147*cdf0e10cSrcweir } 1148*cdf0e10cSrcweir 1149*cdf0e10cSrcweir ScCellTextObj::~ScCellTextObj() throw() 1150*cdf0e10cSrcweir { 1151*cdf0e10cSrcweir } 1152*cdf0e10cSrcweir 1153