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 31*cdf0e10cSrcweir #include <svl/style.hxx> 32*cdf0e10cSrcweir #include <svx/svdotext.hxx> 33*cdf0e10cSrcweir #include "svx/svditext.hxx" 34*cdf0e10cSrcweir #include <svx/svdmodel.hxx> // fuer GetMaxObjSize und GetStyleSheetPool 35*cdf0e10cSrcweir #include <svx/svdoutl.hxx> 36*cdf0e10cSrcweir #include <svx/svdorect.hxx> // fuer SetDirty bei NbcAdjustTextFrameWidthAndHeight 37*cdf0e10cSrcweir #include <svx/svdocapt.hxx> // fuer SetDirty bei NbcAdjustTextFrameWidthAndHeight 38*cdf0e10cSrcweir #include <svx/svdetc.hxx> 39*cdf0e10cSrcweir #include <editeng/writingmodeitem.hxx> 40*cdf0e10cSrcweir #include <editeng/editeng.hxx> 41*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 42*cdf0e10cSrcweir #include <editeng/flditem.hxx> 43*cdf0e10cSrcweir #include <svx/sdtfchim.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <editeng/editview.hxx> 47*cdf0e10cSrcweir #include <svl/smplhint.hxx> 48*cdf0e10cSrcweir #include <svl/whiter.hxx> 49*cdf0e10cSrcweir #include <editeng/outlobj.hxx> 50*cdf0e10cSrcweir #include <editeng/outliner.hxx> 51*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 52*cdf0e10cSrcweir #include <editeng/editobj.hxx> 53*cdf0e10cSrcweir #include <editeng/fhgtitem.hxx> 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #include <editeng/charscaleitem.hxx> 56*cdf0e10cSrcweir #include <svl/style.hxx> 57*cdf0e10cSrcweir #include <svl/itemiter.hxx> 58*cdf0e10cSrcweir #include <editeng/lrspitem.hxx> 59*cdf0e10cSrcweir #include <svl/itempool.hxx> 60*cdf0e10cSrcweir #include <editeng/numitem.hxx> 61*cdf0e10cSrcweir #include <editeng/editeng.hxx> 62*cdf0e10cSrcweir #include <editeng/postitem.hxx> 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 65*cdf0e10cSrcweir // 66*cdf0e10cSrcweir // @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@ @@@@@ @@@@@@ 67*cdf0e10cSrcweir // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ 68*cdf0e10cSrcweir // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@ 69*cdf0e10cSrcweir // @@ @@@@ @@@ @@ @@ @@ @@@@@ @@ 70*cdf0e10cSrcweir // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@ 71*cdf0e10cSrcweir // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@ 72*cdf0e10cSrcweir // @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@ 73*cdf0e10cSrcweir // 74*cdf0e10cSrcweir // Attribute, StyleSheets und AutoGrow 75*cdf0e10cSrcweir // 76*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir FASTBOOL SdrTextObj::AdjustTextFrameWidthAndHeight(Rectangle& rR, FASTBOOL bHgt, FASTBOOL bWdt) const 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir if (bTextFrame && pModel!=NULL && !rR.IsEmpty()) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir SdrFitToSizeType eFit=GetFitToSize(); 83*cdf0e10cSrcweir FASTBOOL bFitToSize=(eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES); 84*cdf0e10cSrcweir FASTBOOL bWdtGrow=bWdt && IsAutoGrowWidth(); 85*cdf0e10cSrcweir FASTBOOL bHgtGrow=bHgt && IsAutoGrowHeight(); 86*cdf0e10cSrcweir SdrTextAniKind eAniKind=GetTextAniKind(); 87*cdf0e10cSrcweir SdrTextAniDirection eAniDir=GetTextAniDirection(); 88*cdf0e10cSrcweir FASTBOOL bScroll=eAniKind==SDRTEXTANI_SCROLL || eAniKind==SDRTEXTANI_ALTERNATE || eAniKind==SDRTEXTANI_SLIDE; 89*cdf0e10cSrcweir FASTBOOL bHScroll=bScroll && (eAniDir==SDRTEXTANI_LEFT || eAniDir==SDRTEXTANI_RIGHT); 90*cdf0e10cSrcweir FASTBOOL bVScroll=bScroll && (eAniDir==SDRTEXTANI_UP || eAniDir==SDRTEXTANI_DOWN); 91*cdf0e10cSrcweir if (!bFitToSize && (bWdtGrow || bHgtGrow)) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir Rectangle aR0(rR); 94*cdf0e10cSrcweir long nHgt=0,nMinHgt=0,nMaxHgt=0; 95*cdf0e10cSrcweir long nWdt=0,nMinWdt=0,nMaxWdt=0; 96*cdf0e10cSrcweir Size aSiz(rR.GetSize()); aSiz.Width()--; aSiz.Height()--; 97*cdf0e10cSrcweir Size aMaxSiz(100000,100000); 98*cdf0e10cSrcweir Size aTmpSiz(pModel->GetMaxObjSize()); 99*cdf0e10cSrcweir if (aTmpSiz.Width()!=0) aMaxSiz.Width()=aTmpSiz.Width(); 100*cdf0e10cSrcweir if (aTmpSiz.Height()!=0) aMaxSiz.Height()=aTmpSiz.Height(); 101*cdf0e10cSrcweir if (bWdtGrow) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir nMinWdt=GetMinTextFrameWidth(); 104*cdf0e10cSrcweir nMaxWdt=GetMaxTextFrameWidth(); 105*cdf0e10cSrcweir if (nMaxWdt==0 || nMaxWdt>aMaxSiz.Width()) nMaxWdt=aMaxSiz.Width(); 106*cdf0e10cSrcweir if (nMinWdt<=0) nMinWdt=1; 107*cdf0e10cSrcweir aSiz.Width()=nMaxWdt; 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir if (bHgtGrow) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir nMinHgt=GetMinTextFrameHeight(); 112*cdf0e10cSrcweir nMaxHgt=GetMaxTextFrameHeight(); 113*cdf0e10cSrcweir if (nMaxHgt==0 || nMaxHgt>aMaxSiz.Height()) nMaxHgt=aMaxSiz.Height(); 114*cdf0e10cSrcweir if (nMinHgt<=0) nMinHgt=1; 115*cdf0e10cSrcweir aSiz.Height()=nMaxHgt; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir long nHDist=GetTextLeftDistance()+GetTextRightDistance(); 118*cdf0e10cSrcweir long nVDist=GetTextUpperDistance()+GetTextLowerDistance(); 119*cdf0e10cSrcweir aSiz.Width()-=nHDist; 120*cdf0e10cSrcweir aSiz.Height()-=nVDist; 121*cdf0e10cSrcweir if (aSiz.Width()<2) aSiz.Width()=2; // Mindestgroesse 2 122*cdf0e10cSrcweir if (aSiz.Height()<2) aSiz.Height()=2; // Mindestgroesse 2 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir // #101684# 125*cdf0e10cSrcweir sal_Bool bInEditMode = IsInEditMode(); 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir if(!bInEditMode) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir if (bHScroll) aSiz.Width()=0x0FFFFFFF; // Laufschrift nicht umbrechen 130*cdf0e10cSrcweir if (bVScroll) aSiz.Height()=0x0FFFFFFF; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir if(pEdtOutl) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir pEdtOutl->SetMaxAutoPaperSize(aSiz); 136*cdf0e10cSrcweir if (bWdtGrow) { 137*cdf0e10cSrcweir Size aSiz2(pEdtOutl->CalcTextSize()); 138*cdf0e10cSrcweir nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz 139*cdf0e10cSrcweir if (bHgtGrow) nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz 140*cdf0e10cSrcweir } else { 141*cdf0e10cSrcweir nHgt=pEdtOutl->GetTextHeight()+1; // lieber etwas Tolleranz 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir } else { 144*cdf0e10cSrcweir Outliner& rOutliner=ImpGetDrawOutliner(); 145*cdf0e10cSrcweir rOutliner.SetPaperSize(aSiz); 146*cdf0e10cSrcweir rOutliner.SetUpdateMode(sal_True); 147*cdf0e10cSrcweir // !!! hier sollte ich wohl auch noch mal die Optimierung mit 148*cdf0e10cSrcweir // bPortionInfoChecked usw einbauen 149*cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); 150*cdf0e10cSrcweir if ( pOutlinerParaObject != NULL ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir rOutliner.SetText(*pOutlinerParaObject); 153*cdf0e10cSrcweir rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue()); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir if (bWdtGrow) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir Size aSiz2(rOutliner.CalcTextSize()); 158*cdf0e10cSrcweir nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz 159*cdf0e10cSrcweir if (bHgtGrow) nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz 160*cdf0e10cSrcweir } else { 161*cdf0e10cSrcweir nHgt=rOutliner.GetTextHeight()+1; // lieber etwas Tolleranz 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir rOutliner.Clear(); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir if (nWdt<nMinWdt) nWdt=nMinWdt; 166*cdf0e10cSrcweir if (nWdt>nMaxWdt) nWdt=nMaxWdt; 167*cdf0e10cSrcweir nWdt+=nHDist; 168*cdf0e10cSrcweir if (nWdt<1) nWdt=1; // nHDist kann auch negativ sein 169*cdf0e10cSrcweir if (nHgt<nMinHgt) nHgt=nMinHgt; 170*cdf0e10cSrcweir if (nHgt>nMaxHgt) nHgt=nMaxHgt; 171*cdf0e10cSrcweir nHgt+=nVDist; 172*cdf0e10cSrcweir if (nHgt<1) nHgt=1; // nVDist kann auch negativ sein 173*cdf0e10cSrcweir long nWdtGrow=nWdt-(rR.Right()-rR.Left()); 174*cdf0e10cSrcweir long nHgtGrow=nHgt-(rR.Bottom()-rR.Top()); 175*cdf0e10cSrcweir if (nWdtGrow==0) bWdtGrow=sal_False; 176*cdf0e10cSrcweir if (nHgtGrow==0) bHgtGrow=sal_False; 177*cdf0e10cSrcweir if (bWdtGrow || bHgtGrow) { 178*cdf0e10cSrcweir if (bWdtGrow) { 179*cdf0e10cSrcweir SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust(); 180*cdf0e10cSrcweir if (eHAdj==SDRTEXTHORZADJUST_LEFT) rR.Right()+=nWdtGrow; 181*cdf0e10cSrcweir else if (eHAdj==SDRTEXTHORZADJUST_RIGHT) rR.Left()-=nWdtGrow; 182*cdf0e10cSrcweir else { 183*cdf0e10cSrcweir long nWdtGrow2=nWdtGrow/2; 184*cdf0e10cSrcweir rR.Left()-=nWdtGrow2; 185*cdf0e10cSrcweir rR.Right()=rR.Left()+nWdt; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir if (bHgtGrow) { 189*cdf0e10cSrcweir SdrTextVertAdjust eVAdj=GetTextVerticalAdjust(); 190*cdf0e10cSrcweir if (eVAdj==SDRTEXTVERTADJUST_TOP) rR.Bottom()+=nHgtGrow; 191*cdf0e10cSrcweir else if (eVAdj==SDRTEXTVERTADJUST_BOTTOM) rR.Top()-=nHgtGrow; 192*cdf0e10cSrcweir else { 193*cdf0e10cSrcweir long nHgtGrow2=nHgtGrow/2; 194*cdf0e10cSrcweir rR.Top()-=nHgtGrow2; 195*cdf0e10cSrcweir rR.Bottom()=rR.Top()+nHgt; 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir if (aGeo.nDrehWink!=0) { 199*cdf0e10cSrcweir Point aD1(rR.TopLeft()); 200*cdf0e10cSrcweir aD1-=aR0.TopLeft(); 201*cdf0e10cSrcweir Point aD2(aD1); 202*cdf0e10cSrcweir RotatePoint(aD2,Point(),aGeo.nSin,aGeo.nCos); 203*cdf0e10cSrcweir aD2-=aD1; 204*cdf0e10cSrcweir rR.Move(aD2.X(),aD2.Y()); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir return sal_True; 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir return sal_False; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir FASTBOOL SdrTextObj::NbcAdjustTextFrameWidthAndHeight(FASTBOOL bHgt, FASTBOOL bWdt) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir FASTBOOL bRet=AdjustTextFrameWidthAndHeight(aRect,bHgt,bWdt); 216*cdf0e10cSrcweir if (bRet) { 217*cdf0e10cSrcweir SetRectsDirty(); 218*cdf0e10cSrcweir if (HAS_BASE(SdrRectObj,this)) { // mal wieder 'nen Hack 219*cdf0e10cSrcweir ((SdrRectObj*)this)->SetXPolyDirty(); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir if (HAS_BASE(SdrCaptionObj,this)) { // mal wieder 'nen Hack 222*cdf0e10cSrcweir ((SdrCaptionObj*)this)->ImpRecalcTail(); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir return bRet; 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir FASTBOOL SdrTextObj::AdjustTextFrameWidthAndHeight(FASTBOOL bHgt, FASTBOOL bWdt) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir Rectangle aNeuRect(aRect); 231*cdf0e10cSrcweir FASTBOOL bRet=AdjustTextFrameWidthAndHeight(aNeuRect,bHgt,bWdt); 232*cdf0e10cSrcweir if (bRet) { 233*cdf0e10cSrcweir Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); 234*cdf0e10cSrcweir // #110094#-14 SendRepaintBroadcast(); 235*cdf0e10cSrcweir aRect=aNeuRect; 236*cdf0e10cSrcweir SetRectsDirty(); 237*cdf0e10cSrcweir if (HAS_BASE(SdrRectObj,this)) { // mal wieder 'nen Hack 238*cdf0e10cSrcweir ((SdrRectObj*)this)->SetXPolyDirty(); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir if (HAS_BASE(SdrCaptionObj,this)) { // mal wieder 'nen Hack 241*cdf0e10cSrcweir ((SdrCaptionObj*)this)->ImpRecalcTail(); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir SetChanged(); 244*cdf0e10cSrcweir BroadcastObjectChange(); 245*cdf0e10cSrcweir SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir return bRet; 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir void SdrTextObj::ImpSetTextStyleSheetListeners() 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir SfxStyleSheetBasePool* pStylePool=pModel!=NULL ? pModel->GetStyleSheetPool() : NULL; 253*cdf0e10cSrcweir if (pStylePool!=NULL) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir Container aStyles(1024,64,64); 256*cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); 257*cdf0e10cSrcweir if (pOutlinerParaObject!=NULL) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir // Zunaechst werden alle im ParaObject enthaltenen StyleSheets 260*cdf0e10cSrcweir // im Container aStyles gesammelt. Dazu wird die Family jeweils 261*cdf0e10cSrcweir // ans Ende des StyleSheet-Namen drangehaengt. 262*cdf0e10cSrcweir const EditTextObject& rTextObj=pOutlinerParaObject->GetTextObject(); 263*cdf0e10cSrcweir XubString aStyleName; 264*cdf0e10cSrcweir SfxStyleFamily eStyleFam; 265*cdf0e10cSrcweir sal_uInt16 nParaAnz=rTextObj.GetParagraphCount(); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir for(sal_uInt16 nParaNum(0); nParaNum < nParaAnz; nParaNum++) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir rTextObj.GetStyleSheet(nParaNum, aStyleName, eStyleFam); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir if(aStyleName.Len()) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir XubString aFam = UniString::CreateFromInt32((sal_uInt16)eStyleFam); 274*cdf0e10cSrcweir aFam.Expand(5); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir aStyleName += sal_Unicode('|'); 277*cdf0e10cSrcweir aStyleName += aFam; 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir sal_Bool bFnd(sal_False); 280*cdf0e10cSrcweir sal_uInt32 nNum(aStyles.Count()); 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir while(!bFnd && nNum > 0) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir // kein StyleSheet doppelt! 285*cdf0e10cSrcweir nNum--; 286*cdf0e10cSrcweir bFnd = (aStyleName.Equals(*(XubString*)aStyles.GetObject(nNum))); 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir if(!bFnd) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir aStyles.Insert(new XubString(aStyleName), CONTAINER_APPEND); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir // nun die Strings im Container durch StyleSheet* ersetzten 298*cdf0e10cSrcweir sal_uIntPtr nNum=aStyles.Count(); 299*cdf0e10cSrcweir while (nNum>0) { 300*cdf0e10cSrcweir nNum--; 301*cdf0e10cSrcweir XubString* pName=(XubString*)aStyles.GetObject(nNum); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir // UNICODE: String aFam(pName->Cut(pName->Len()-6)); 304*cdf0e10cSrcweir String aFam = pName->Copy(0, pName->Len() - 6); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir aFam.Erase(0,1); 307*cdf0e10cSrcweir aFam.EraseTrailingChars(); 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir // UNICODE: sal_uInt16 nFam=sal_uInt16(aFam); 310*cdf0e10cSrcweir sal_uInt16 nFam = (sal_uInt16)aFam.ToInt32(); 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir SfxStyleFamily eFam=(SfxStyleFamily)nFam; 313*cdf0e10cSrcweir SfxStyleSheetBase* pStyleBase=pStylePool->Find(*pName,eFam); 314*cdf0e10cSrcweir SfxStyleSheet* pStyle=PTR_CAST(SfxStyleSheet,pStyleBase); 315*cdf0e10cSrcweir delete pName; 316*cdf0e10cSrcweir if (pStyle!=NULL && pStyle!=GetStyleSheet()) { 317*cdf0e10cSrcweir aStyles.Replace(pStyle,nNum); 318*cdf0e10cSrcweir } else { 319*cdf0e10cSrcweir aStyles.Remove(nNum); 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir // jetzt alle ueberfluessigen StyleSheets entfernen 323*cdf0e10cSrcweir nNum=GetBroadcasterCount(); 324*cdf0e10cSrcweir while (nNum>0) { 325*cdf0e10cSrcweir nNum--; 326*cdf0e10cSrcweir SfxBroadcaster* pBroadcast=GetBroadcasterJOE((sal_uInt16)nNum); 327*cdf0e10cSrcweir SfxStyleSheet* pStyle=PTR_CAST(SfxStyleSheet,pBroadcast); 328*cdf0e10cSrcweir if (pStyle!=NULL && pStyle!=GetStyleSheet()) { // Sonderbehandlung fuer den StyleSheet des Objekts 329*cdf0e10cSrcweir if (aStyles.GetPos(pStyle)==CONTAINER_ENTRY_NOTFOUND) { 330*cdf0e10cSrcweir EndListening(*pStyle); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir // und schliesslich alle in aStyles enthaltenen StyleSheets mit den vorhandenen Broadcastern mergen 335*cdf0e10cSrcweir nNum=aStyles.Count(); 336*cdf0e10cSrcweir while (nNum>0) { 337*cdf0e10cSrcweir nNum--; 338*cdf0e10cSrcweir SfxStyleSheet* pStyle=(SfxStyleSheet*)aStyles.GetObject(nNum); 339*cdf0e10cSrcweir // StartListening soll selbst nachsehen, ob hier nicht evtl. schon gehorcht wird 340*cdf0e10cSrcweir StartListening(*pStyle,sal_True); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir void SdrTextObj::NbcResizeTextAttributes(const Fraction& xFact, const Fraction& yFact) 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); 348*cdf0e10cSrcweir if (pOutlinerParaObject!=NULL && xFact.IsValid() && yFact.IsValid()) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir Fraction n100(100,1); 351*cdf0e10cSrcweir long nX=long(xFact*n100); 352*cdf0e10cSrcweir long nY=long(yFact*n100); 353*cdf0e10cSrcweir if (nX<0) nX=-nX; 354*cdf0e10cSrcweir if (nX<1) nX=1; 355*cdf0e10cSrcweir if (nX>0xFFFF) nX=0xFFFF; 356*cdf0e10cSrcweir if (nY<0) nY=-nY; 357*cdf0e10cSrcweir if (nY<1) nY=1; 358*cdf0e10cSrcweir if (nY>0xFFFF) nY=0xFFFF; 359*cdf0e10cSrcweir if (nX!=100 || nY!=100) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir // Rahmenattribute 362*cdf0e10cSrcweir const SfxItemSet& rSet = GetObjectItemSet(); 363*cdf0e10cSrcweir const SvxCharScaleWidthItem& rOldWdt=(SvxCharScaleWidthItem&)rSet.Get(EE_CHAR_FONTWIDTH); 364*cdf0e10cSrcweir const SvxFontHeightItem& rOldHgt=(SvxFontHeightItem&)rSet.Get(EE_CHAR_FONTHEIGHT); 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir // erstmal die alten Werte holen 367*cdf0e10cSrcweir long nRelWdt=rOldWdt.GetValue(); 368*cdf0e10cSrcweir long nAbsHgt=rOldHgt.GetHeight(); 369*cdf0e10cSrcweir long nRelHgt=rOldHgt.GetProp(); 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir // Relative Breite aendern 372*cdf0e10cSrcweir nRelWdt*=nX; 373*cdf0e10cSrcweir nRelWdt/=nY; 374*cdf0e10cSrcweir if (nRelWdt<0) nRelWdt=-nRelWdt; // nicht negativ 375*cdf0e10cSrcweir if (nRelWdt<=0) nRelWdt=1; // und mind. 1% 376*cdf0e10cSrcweir if (nRelWdt>0xFFFF) nRelWdt=0xFFFF; 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir // Absolute Hoehe aendern 379*cdf0e10cSrcweir nAbsHgt*=nY; 380*cdf0e10cSrcweir nAbsHgt/=100; 381*cdf0e10cSrcweir if (nAbsHgt<0) nAbsHgt=-nAbsHgt; // nicht negativ 382*cdf0e10cSrcweir if (nAbsHgt<=0) nAbsHgt=1; // und mind. 1 383*cdf0e10cSrcweir if (nAbsHgt>0xFFFF) nAbsHgt=0xFFFF; 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir // und nun attributieren 386*cdf0e10cSrcweir SetObjectItem(SvxCharScaleWidthItem( (sal_uInt16) nRelWdt, EE_CHAR_FONTWIDTH)); 387*cdf0e10cSrcweir SetObjectItem(SvxFontHeightItem(nAbsHgt,(sal_uInt16)nRelHgt, EE_CHAR_FONTHEIGHT)); 388*cdf0e10cSrcweir // Zeichen- und Absatzattribute innerhalb des OutlinerParaObjects 389*cdf0e10cSrcweir Outliner& rOutliner=ImpGetDrawOutliner(); 390*cdf0e10cSrcweir rOutliner.SetPaperSize(Size(LONG_MAX,LONG_MAX)); 391*cdf0e10cSrcweir rOutliner.SetText(*pOutlinerParaObject); 392*cdf0e10cSrcweir rOutliner.DoStretchChars((sal_uInt16)nX,(sal_uInt16)nY); 393*cdf0e10cSrcweir OutlinerParaObject* pNewPara=rOutliner.CreateParaObject(); 394*cdf0e10cSrcweir NbcSetOutlinerParaObject(pNewPara); 395*cdf0e10cSrcweir rOutliner.Clear(); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir /** #103836# iterates over the paragraphs of a given SdrObject and removes all 401*cdf0e10cSrcweir hard set character attributes with the which ids contained in the 402*cdf0e10cSrcweir given vector 403*cdf0e10cSrcweir */ 404*cdf0e10cSrcweir void SdrTextObj::RemoveOutlinerCharacterAttribs( const std::vector<sal_uInt16>& rCharWhichIds ) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir sal_Int32 nText = getTextCount(); 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir while( --nText >= 0 ) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir SdrText* pText = getText( nText ); 411*cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = pText ? pText->GetOutlinerParaObject() : 0; 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir if(pOutlinerParaObject) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir Outliner* pOutliner = 0; 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir if( pEdtOutl || (pText == getActiveText()) ) 418*cdf0e10cSrcweir pOutliner = pEdtOutl; 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir if(!pOutliner) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir pOutliner = &ImpGetDrawOutliner(); 423*cdf0e10cSrcweir pOutliner->SetText(*pOutlinerParaObject); 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir ESelection aSelAll( 0, 0, 0xffff, 0xffff ); 427*cdf0e10cSrcweir std::vector<sal_uInt16>::const_iterator aIter( rCharWhichIds.begin() ); 428*cdf0e10cSrcweir while( aIter != rCharWhichIds.end() ) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir pOutliner->RemoveAttribs( aSelAll, false, (*aIter++) ); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir if(!pEdtOutl || (pText != getActiveText()) ) 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir const sal_uInt32 nParaCount = pOutliner->GetParagraphCount(); 436*cdf0e10cSrcweir OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount); 437*cdf0e10cSrcweir pOutliner->Clear(); 438*cdf0e10cSrcweir NbcSetOutlinerParaObjectForText(pTemp, pText); 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir bool SdrTextObj::HasText() const 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir if( pEdtOutl ) 447*cdf0e10cSrcweir return HasEditText(); 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir OutlinerParaObject* pOPO = GetOutlinerParaObject(); 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir bool bHasText = false; 452*cdf0e10cSrcweir if( pOPO ) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir const EditTextObject& rETO = pOPO->GetTextObject(); 455*cdf0e10cSrcweir sal_uInt16 nParaCount = rETO.GetParagraphCount(); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir if( nParaCount > 0 ) 458*cdf0e10cSrcweir bHasText = (nParaCount > 1) || (rETO.GetText( 0 ).Len() != 0); 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir return bHasText; 462*cdf0e10cSrcweir } 463