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_svx.hxx" 30*cdf0e10cSrcweir #include <svx/sdr/properties/textproperties.hxx> 31*cdf0e10cSrcweir #include <svl/itemset.hxx> 32*cdf0e10cSrcweir #include <svl/style.hxx> 33*cdf0e10cSrcweir #include <svl/itemiter.hxx> 34*cdf0e10cSrcweir #include <svl/smplhint.hxx> 35*cdf0e10cSrcweir #include <svx/svddef.hxx> 36*cdf0e10cSrcweir #include <svx/svdotext.hxx> 37*cdf0e10cSrcweir #include <svx/svdoutl.hxx> 38*cdf0e10cSrcweir #include <editeng/writingmodeitem.hxx> 39*cdf0e10cSrcweir #include <svx/svdmodel.hxx> 40*cdf0e10cSrcweir #include <editeng/outlobj.hxx> 41*cdf0e10cSrcweir #include <svx/xflclit.hxx> 42*cdf0e10cSrcweir #include <editeng/adjitem.hxx> 43*cdf0e10cSrcweir #include <svx/svdetc.hxx> 44*cdf0e10cSrcweir #include <editeng/editeng.hxx> 45*cdf0e10cSrcweir #include <editeng/flditem.hxx> 46*cdf0e10cSrcweir #include <svx/xlnwtit.hxx> 47*cdf0e10cSrcweir #include <svx/svdpool.hxx> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir namespace sdr 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir namespace properties 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir SfxItemSet& TextProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir return *(new SfxItemSet(rPool, 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir // range from SdrAttrObj 60*cdf0e10cSrcweir SDRATTR_START, SDRATTR_SHADOW_LAST, 61*cdf0e10cSrcweir SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, 62*cdf0e10cSrcweir SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir // range from SdrTextObj 65*cdf0e10cSrcweir EE_ITEMS_START, EE_ITEMS_END, 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir // end 68*cdf0e10cSrcweir 0, 0)); 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir TextProperties::TextProperties(SdrObject& rObj) 72*cdf0e10cSrcweir : AttributeProperties(rObj), 73*cdf0e10cSrcweir maVersion(0) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir TextProperties::TextProperties(const TextProperties& rProps, SdrObject& rObj) 78*cdf0e10cSrcweir : AttributeProperties(rProps, rObj), 79*cdf0e10cSrcweir maVersion(rProps.getVersion()) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir TextProperties::~TextProperties() 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir BaseProperties& TextProperties::Clone(SdrObject& rObj) const 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir return *(new TextProperties(*this, rObj)); 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir void TextProperties::ItemSetChanged(const SfxItemSet& rSet) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); 95*cdf0e10cSrcweir sal_Int32 nText = rObj.getTextCount(); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir // #i101556# ItemSet has changed -> new version 98*cdf0e10cSrcweir maVersion++; 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir while( --nText >= 0 ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir SdrText* pText = rObj.getText( nText ); 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir if(pParaObj) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir const bool bTextEdit = rObj.IsTextEditActive() && (rObj.getActiveText() == pText); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir // handle outliner attributes 111*cdf0e10cSrcweir GetObjectItemSet(); 112*cdf0e10cSrcweir Outliner* pOutliner = rObj.GetTextEditOutliner(); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir if(!bTextEdit) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir pOutliner = &rObj.ImpGetDrawOutliner(); 117*cdf0e10cSrcweir pOutliner->SetText(*pParaObj); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir sal_uInt32 nParaCount(pOutliner->GetParagraphCount()); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir SfxItemSet aSet(pOutliner->GetParaAttribs(nPara)); 125*cdf0e10cSrcweir aSet.Put(rSet); 126*cdf0e10cSrcweir pOutliner->SetParaAttribs(nPara, aSet); 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir if(!bTextEdit) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir if(nParaCount) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir // force ItemSet 134*cdf0e10cSrcweir GetObjectItemSet(); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir SfxItemSet aNewSet(pOutliner->GetParaAttribs(0L)); 137*cdf0e10cSrcweir mpItemSet->Put(aNewSet); 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount); 141*cdf0e10cSrcweir pOutliner->Clear(); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir rObj.NbcSetOutlinerParaObjectForText(pTemp,pText); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir // Extra-Repaint for radical layout changes (#43139#) 149*cdf0e10cSrcweir if(SFX_ITEM_SET == rSet.GetItemState(SDRATTR_TEXT_CONTOURFRAME)) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir // Here only repaint wanted 152*cdf0e10cSrcweir rObj.ActionChanged(); 153*cdf0e10cSrcweir //rObj.BroadcastObjectChange(); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir // call parent 157*cdf0e10cSrcweir AttributeProperties::ItemSetChanged(rSet); 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir void TextProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir // #i25616# 165*cdf0e10cSrcweir sal_Int32 nOldLineWidth(0L); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange()) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir nOldLineWidth = ((const XLineWidthItem&)GetItem(XATTR_LINEWIDTH)).GetValue(); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich)) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir sal_Bool bVertical(com::sun::star::text::WritingMode_TB_RL == ((SvxWritingModeItem*)pNewItem)->GetValue()); 175*cdf0e10cSrcweir rObj.SetVerticalWriting(bVertical); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir // #95501# reset to default 179*cdf0e10cSrcweir if(!pNewItem && !nWhich && rObj.HasText() ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner(); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir sal_Int32 nCount = rObj.getTextCount(); 184*cdf0e10cSrcweir while( nCount-- ) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir SdrText* pText = rObj.getText( nCount ); 187*cdf0e10cSrcweir OutlinerParaObject* pParaObj = pText->GetOutlinerParaObject(); 188*cdf0e10cSrcweir if( pParaObj ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir rOutliner.SetText(*pParaObj); 191*cdf0e10cSrcweir sal_uInt32 nParaCount(rOutliner.GetParagraphCount()); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir if(nParaCount) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL); 196*cdf0e10cSrcweir rOutliner.RemoveAttribs(aSelection, sal_True, 0); 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount); 199*cdf0e10cSrcweir rOutliner.Clear(); 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir rObj.NbcSetOutlinerParaObjectForText( pTemp, pText ); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir // call parent 208*cdf0e10cSrcweir AttributeProperties::ItemChange( nWhich, pNewItem ); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir // #i25616# 211*cdf0e10cSrcweir if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange()) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir const sal_Int32 nNewLineWidth(((const XLineWidthItem&)GetItem(XATTR_LINEWIDTH)).GetValue()); 214*cdf0e10cSrcweir const sal_Int32 nDifference((nNewLineWidth - nOldLineWidth) / 2); 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir if(nDifference) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir const sal_Bool bLineVisible(XLINE_NONE != ((const XLineStyleItem&)(GetItem(XATTR_LINESTYLE))).GetValue()); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir if(bLineVisible) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir const sal_Int32 nLeftDist(((const SdrTextLeftDistItem&)GetItem(SDRATTR_TEXT_LEFTDIST)).GetValue()); 223*cdf0e10cSrcweir const sal_Int32 nRightDist(((const SdrTextRightDistItem&)GetItem(SDRATTR_TEXT_RIGHTDIST)).GetValue()); 224*cdf0e10cSrcweir const sal_Int32 nUpperDist(((const SdrTextUpperDistItem&)GetItem(SDRATTR_TEXT_UPPERDIST)).GetValue()); 225*cdf0e10cSrcweir const sal_Int32 nLowerDist(((const SdrTextLowerDistItem&)GetItem(SDRATTR_TEXT_LOWERDIST)).GetValue()); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir SetObjectItemDirect(SdrTextLeftDistItem(nLeftDist + nDifference)); 228*cdf0e10cSrcweir SetObjectItemDirect(SdrTextRightDistItem(nRightDist + nDifference)); 229*cdf0e10cSrcweir SetObjectItemDirect(SdrTextUpperDistItem(nUpperDist + nDifference)); 230*cdf0e10cSrcweir SetObjectItemDirect(SdrTextLowerDistItem(nLowerDist + nDifference)); 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir void TextProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir // call parent 241*cdf0e10cSrcweir AttributeProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir // #i101556# StyleSheet has changed -> new version 244*cdf0e10cSrcweir maVersion++; 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir if( rObj.GetModel() /*&& !rObj.IsTextEditActive()*/ && !rObj.IsLinkedText() ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner(); 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir sal_Int32 nText = rObj.getTextCount(); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir while( --nText >= 0 ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir SdrText* pText = rObj.getText( nText ); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0; 257*cdf0e10cSrcweir if( !pParaObj ) 258*cdf0e10cSrcweir continue; 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir // apply StyleSheet to all paragraphs 261*cdf0e10cSrcweir rOutliner.SetText(*pParaObj); 262*cdf0e10cSrcweir sal_uInt32 nParaCount(rOutliner.GetParagraphCount()); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir if(nParaCount) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir SfxItemSet* pTempSet = 0L; 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir // since setting the stylesheet removes all para attributes 271*cdf0e10cSrcweir if(bDontRemoveHardAttr) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir // we need to remember them if we want to keep them 274*cdf0e10cSrcweir pTempSet = new SfxItemSet(rOutliner.GetParaAttribs(nPara)); 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir if(GetStyleSheet()) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir if((OBJ_OUTLINETEXT == rObj.GetTextKind()) && (SdrInventor == rObj.GetObjInventor())) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir String aNewStyleSheetName(GetStyleSheet()->GetName()); 282*cdf0e10cSrcweir aNewStyleSheetName.Erase(aNewStyleSheetName.Len() - 1, 1); 283*cdf0e10cSrcweir sal_Int16 nDepth = rOutliner.GetDepth((sal_uInt16)nPara); 284*cdf0e10cSrcweir aNewStyleSheetName += String::CreateFromInt32( nDepth <= 0 ? 1 : nDepth + 1); 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir SdrModel* pModel = rObj.GetModel(); 287*cdf0e10cSrcweir SfxStyleSheetBasePool* pStylePool = (pModel != NULL) ? pModel->GetStyleSheetPool() : 0L; 288*cdf0e10cSrcweir SfxStyleSheet* pNewStyle = (SfxStyleSheet*)pStylePool->Find(aNewStyleSheetName, GetStyleSheet()->GetFamily()); 289*cdf0e10cSrcweir DBG_ASSERT( pNewStyle, "AutoStyleSheetName - Style not found!" ); 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir if(pNewStyle) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir rOutliner.SetStyleSheet(nPara, pNewStyle); 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir else 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir rOutliner.SetStyleSheet(nPara, GetStyleSheet()); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir else 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir // remove StyleSheet 304*cdf0e10cSrcweir rOutliner.SetStyleSheet(nPara, 0L); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir if(bDontRemoveHardAttr) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir if(pTempSet) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir // restore para attributes 312*cdf0e10cSrcweir rOutliner.SetParaAttribs(nPara, *pTempSet); 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir else 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir if(pNewStyleSheet) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir // remove all hard paragraph attributes 320*cdf0e10cSrcweir // which occur in StyleSheet, take care of 321*cdf0e10cSrcweir // parents (!) 322*cdf0e10cSrcweir SfxItemIter aIter(pNewStyleSheet->GetItemSet()); 323*cdf0e10cSrcweir const SfxPoolItem* pItem = aIter.FirstItem(); 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir while(pItem) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir if(!IsInvalidItem(pItem)) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir sal_uInt16 nW(pItem->Which()); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir if(nW >= EE_ITEMS_START && nW <= EE_ITEMS_END) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir rOutliner.QuickRemoveCharAttribs((sal_uInt16)nPara, nW); 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir pItem = aIter.NextItem(); 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir if(pTempSet) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir delete pTempSet; 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount); 348*cdf0e10cSrcweir rOutliner.Clear(); 349*cdf0e10cSrcweir rObj.NbcSetOutlinerParaObjectForText(pTemp, pText); 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir if(rObj.IsTextFrame()) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir rObj.NbcAdjustTextFrameWidthAndHeight(); 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir void TextProperties::ForceDefaultAttributes() 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir if( rObj.GetObjInventor() == SdrInventor ) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir const sal_uInt16 nSdrObjKind = rObj.GetObjIdentifier(); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir if( nSdrObjKind == OBJ_TITLETEXT || nSdrObjKind == OBJ_OUTLINETEXT ) 369*cdf0e10cSrcweir return; // no defaults for presentation objects 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir bool bTextFrame(rObj.IsTextFrame()); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir // force ItemSet 375*cdf0e10cSrcweir GetObjectItemSet(); 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir if(bTextFrame) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir mpItemSet->Put(XLineStyleItem(XLINE_NONE)); 380*cdf0e10cSrcweir mpItemSet->Put(XFillColorItem(String(), Color(COL_WHITE))); 381*cdf0e10cSrcweir mpItemSet->Put(XFillStyleItem(XFILL_NONE)); 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir else 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir mpItemSet->Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST)); 386*cdf0e10cSrcweir mpItemSet->Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); 387*cdf0e10cSrcweir mpItemSet->Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir void TextProperties::ForceStyleToHardAttributes() 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir // #i61284# call parent first to get the hard ObjectItemSet 394*cdf0e10cSrcweir AttributeProperties::ForceStyleToHardAttributes(); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir // #i61284# push hard ObjectItemSet to OutlinerParaObject attributes 397*cdf0e10cSrcweir // using existing functionality 398*cdf0e10cSrcweir GetObjectItemSet(); // force ItemSet 399*cdf0e10cSrcweir ItemSetChanged(*mpItemSet); 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir // now the standard TextProperties stuff 402*cdf0e10cSrcweir SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir if(rObj.GetModel() 405*cdf0e10cSrcweir && !rObj.IsTextEditActive() 406*cdf0e10cSrcweir && !rObj.IsLinkedText()) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir Outliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_OUTLINEOBJECT, rObj.GetModel()); 409*cdf0e10cSrcweir sal_Int32 nText = rObj.getTextCount(); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir while( --nText >= 0 ) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir SdrText* pText = rObj.getText( nText ); 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0; 416*cdf0e10cSrcweir if( !pParaObj ) 417*cdf0e10cSrcweir continue; 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir pOutliner->SetText(*pParaObj); 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir sal_uInt32 nParaCount(pOutliner->GetParagraphCount()); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir if(nParaCount) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir sal_Bool bBurnIn(sal_False); 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir SfxStyleSheet* pSheet = pOutliner->GetStyleSheet(nPara); 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir if(pSheet) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir SfxItemSet aParaSet(pOutliner->GetParaAttribs(nPara)); 434*cdf0e10cSrcweir SfxItemSet aSet(*aParaSet.GetPool()); 435*cdf0e10cSrcweir aSet.Put(pSheet->GetItemSet()); 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir /** the next code handles a special case for paragraphs that contain a 438*cdf0e10cSrcweir url field. The color for URL fields is either the system color for 439*cdf0e10cSrcweir urls or the char color attribute that formats the portion in which the 440*cdf0e10cSrcweir url field is contained. 441*cdf0e10cSrcweir When we set a char color attribute to the paragraphs item set from the 442*cdf0e10cSrcweir styles item set, we would have this char color attribute as an attribute 443*cdf0e10cSrcweir that is spanned over the complete paragraph after xml import due to some 444*cdf0e10cSrcweir problems in the xml import (using a XCursor on import so it does not know 445*cdf0e10cSrcweir the paragraphs and can't set char attributes to paragraphs ). 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir To avoid this, as soon as we try to set a char color attribute from the style 448*cdf0e10cSrcweir we 449*cdf0e10cSrcweir 1. check if we have at least one url field in this paragraph 450*cdf0e10cSrcweir 2. if we found at least one url field, we span the char color attribute over 451*cdf0e10cSrcweir all portions that are not url fields and remove the char color attribute 452*cdf0e10cSrcweir from the paragraphs item set 453*cdf0e10cSrcweir */ 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir sal_Bool bHasURL(sal_False); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir if(aSet.GetItemState(EE_CHAR_COLOR) == SFX_ITEM_SET) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir EditEngine* pEditEngine = const_cast<EditEngine*>(&(pOutliner->GetEditEngine())); 460*cdf0e10cSrcweir EECharAttribArray aAttribs; 461*cdf0e10cSrcweir pEditEngine->GetCharAttribs((sal_uInt16)nPara, aAttribs); 462*cdf0e10cSrcweir sal_uInt16 nAttrib; 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir for(nAttrib = 0; nAttrib < aAttribs.Count(); nAttrib++) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir struct EECharAttrib aAttrib(aAttribs.GetObject(nAttrib)); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir if(EE_FEATURE_FIELD == aAttrib.pAttr->Which()) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir if(aAttrib.pAttr) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir SvxFieldItem* pFieldItem = (SvxFieldItem*)aAttrib.pAttr; 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir if(pFieldItem) 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir const SvxFieldData* pData = pFieldItem->GetField(); 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir if(pData && pData->ISA(SvxURLField)) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir bHasURL = sal_True; 481*cdf0e10cSrcweir break; 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir } 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir if(bHasURL) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir SfxItemSet aColorSet(*aSet.GetPool(), EE_CHAR_COLOR, EE_CHAR_COLOR ); 491*cdf0e10cSrcweir aColorSet.Put(aSet, sal_False); 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir ESelection aSel((sal_uInt16)nPara, 0); 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir for(nAttrib = 0; nAttrib < aAttribs.Count(); nAttrib++) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir struct EECharAttrib aAttrib(aAttribs.GetObject(nAttrib)); 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir if(EE_FEATURE_FIELD == aAttrib.pAttr->Which()) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir aSel.nEndPos = aAttrib.nStart; 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir if(aSel.nStartPos != aSel.nEndPos) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir pEditEngine->QuickSetAttribs(aColorSet, aSel); 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir aSel.nStartPos = aAttrib.nEnd; 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir aSel.nEndPos = pEditEngine->GetTextLen((sal_uInt16)nPara); 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir if(aSel.nStartPos != aSel.nEndPos) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir pEditEngine->QuickSetAttribs( aColorSet, aSel ); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir aSet.Put(aParaSet, sal_False); 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir if(bHasURL) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir aSet.ClearItem(EE_CHAR_COLOR); 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir pOutliner->SetParaAttribs(nPara, aSet); 530*cdf0e10cSrcweir bBurnIn = sal_True; // #i51163# Flag was set wrong 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir if(bBurnIn) 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount); 537*cdf0e10cSrcweir rObj.NbcSetOutlinerParaObjectForText(pTemp,pText); 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir pOutliner->Clear(); 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir delete pOutliner; 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir void TextProperties::SetObjectItemNoBroadcast(const SfxPoolItem& rItem) 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir GetObjectItemSet(); 550*cdf0e10cSrcweir mpItemSet->Put(rItem); 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir void TextProperties::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir // call parent 557*cdf0e10cSrcweir AttributeProperties::Notify(rBC, rHint); 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); 560*cdf0e10cSrcweir if(rObj.HasText()) 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir if(HAS_BASE(SfxStyleSheet, &rBC)) 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir SfxSimpleHint* pSimple = PTR_CAST(SfxSimpleHint, &rHint); 565*cdf0e10cSrcweir sal_uInt32 nId(pSimple ? pSimple->GetId() : 0L); 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir if(SFX_HINT_DATACHANGED == nId) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir rObj.SetPortionInfoChecked(sal_False); 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir sal_Int32 nText = rObj.getTextCount(); 572*cdf0e10cSrcweir while( --nText > 0 ) 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject(); 575*cdf0e10cSrcweir if( pParaObj ) 576*cdf0e10cSrcweir pParaObj->ClearPortionInfo(); 577*cdf0e10cSrcweir } 578*cdf0e10cSrcweir rObj.SetTextSizeDirty(); 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir if(rObj.IsTextFrame() && rObj.NbcAdjustTextFrameWidthAndHeight()) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir // here only repaint wanted 583*cdf0e10cSrcweir rObj.ActionChanged(); 584*cdf0e10cSrcweir //rObj.BroadcastObjectChange(); 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir // #i101556# content of StyleSheet has changed -> new version 588*cdf0e10cSrcweir maVersion++; 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir if(SFX_HINT_DYING == nId) 592*cdf0e10cSrcweir { 593*cdf0e10cSrcweir rObj.SetPortionInfoChecked(sal_False); 594*cdf0e10cSrcweir sal_Int32 nText = rObj.getTextCount(); 595*cdf0e10cSrcweir while( --nText > 0 ) 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject(); 598*cdf0e10cSrcweir if( pParaObj ) 599*cdf0e10cSrcweir pParaObj->ClearPortionInfo(); 600*cdf0e10cSrcweir } 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir } 603*cdf0e10cSrcweir else if(HAS_BASE(SfxStyleSheetBasePool, &rBC)) 604*cdf0e10cSrcweir { 605*cdf0e10cSrcweir SfxStyleSheetHintExtended* pExtendedHint = PTR_CAST(SfxStyleSheetHintExtended, &rHint); 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir if(pExtendedHint 608*cdf0e10cSrcweir && SFX_STYLESHEET_MODIFIED == pExtendedHint->GetHint()) 609*cdf0e10cSrcweir { 610*cdf0e10cSrcweir String aOldName(pExtendedHint->GetOldName()); 611*cdf0e10cSrcweir String aNewName(pExtendedHint->GetStyleSheet()->GetName()); 612*cdf0e10cSrcweir SfxStyleFamily eFamily = pExtendedHint->GetStyleSheet()->GetFamily(); 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir if(!aOldName.Equals(aNewName)) 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir sal_Int32 nText = rObj.getTextCount(); 617*cdf0e10cSrcweir while( --nText > 0 ) 618*cdf0e10cSrcweir { 619*cdf0e10cSrcweir OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject(); 620*cdf0e10cSrcweir if( pParaObj ) 621*cdf0e10cSrcweir pParaObj->ChangeStyleSheetName(eFamily, aOldName, aNewName); 622*cdf0e10cSrcweir } 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir } 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir // #i101556# Handout version information 630*cdf0e10cSrcweir sal_uInt32 TextProperties::getVersion() const 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir return maVersion; 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir } // end of namespace properties 635*cdf0e10cSrcweir } // end of namespace sdr 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 638*cdf0e10cSrcweir // eof 639