1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svx.hxx" 26 27 #include <svx/svdotext.hxx> 28 #include "svx/svditext.hxx" 29 #include <svx/svdpagv.hxx> // fuer Abfrage im Paint, ob das 30 #include <svx/svdview.hxx> // Objekt gerade editiert wird 31 #include <svx/svdpage.hxx> // und fuer AnimationHandler (Laufschrift) 32 #include <svx/svdetc.hxx> 33 #include <svx/svdoutl.hxx> 34 #include <svx/svdmodel.hxx> // OutlinerDefaults 35 #include "svx/svdglob.hxx" // Stringcache 36 #include "svx/svdstr.hrc" // Objektname 37 #include <editeng/writingmodeitem.hxx> 38 #include <svx/sdtfchim.hxx> 39 #include <svtools/colorcfg.hxx> 40 #include <editeng/eeitem.hxx> 41 #include <editeng/editstat.hxx> 42 #include <editeng/outlobj.hxx> 43 #include <editeng/editobj.hxx> 44 #include <editeng/outliner.hxx> 45 #include <editeng/fhgtitem.hxx> 46 #include <svl/itempool.hxx> 47 #include <editeng/adjitem.hxx> 48 #include <editeng/flditem.hxx> 49 #include <svx/xftouit.hxx> 50 #include <vcl/salbtype.hxx> // FRound 51 #include <svx/xflgrit.hxx> 52 #include <svx/svdpool.hxx> 53 #include <svx/xflclit.hxx> 54 #include <svl/style.hxx> 55 #include <editeng/editeng.hxx> 56 #include <svl/itemiter.hxx> 57 #include <svx/sdr/properties/textproperties.hxx> 58 #include <vcl/metaact.hxx> 59 #include <svx/sdr/contact/viewcontactoftextobj.hxx> 60 #include <basegfx/tuple/b2dtuple.hxx> 61 #include <basegfx/matrix/b2dhommatrix.hxx> 62 #include <basegfx/polygon/b2dpolygon.hxx> 63 #include <drawinglayer/geometry/viewinformation2d.hxx> 64 #include <vcl/virdev.hxx> 65 #include <basegfx/matrix/b2dhommatrixtools.hxx> 66 67 ////////////////////////////////////////////////////////////////////////////// 68 69 using namespace com::sun::star; 70 71 ////////////////////////////////////////////////////////////////////////////// 72 // #104018# replace macros above with type-safe methods 73 inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); } 74 inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); } 75 76 //////////////////////////////////////////////////////////////////////////////////////////////////// 77 // 78 // @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@ @@@@@ @@@@@@ 79 // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ 80 // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@ 81 // @@ @@@@ @@@ @@ @@ @@ @@@@@ @@ 82 // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@ 83 // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@ 84 // @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@ 85 // 86 //////////////////////////////////////////////////////////////////////////////////////////////////// 87 88 ////////////////////////////////////////////////////////////////////////////// 89 // BaseProperties section 90 91 sdr::properties::BaseProperties* SdrTextObj::CreateObjectSpecificProperties() 92 { 93 return new sdr::properties::TextProperties(*this); 94 } 95 96 ////////////////////////////////////////////////////////////////////////////// 97 // DrawContact section 98 99 sdr::contact::ViewContact* SdrTextObj::CreateObjectSpecificViewContact() 100 { 101 return new sdr::contact::ViewContactOfTextObj(*this); 102 } 103 104 ////////////////////////////////////////////////////////////////////////////// 105 106 TYPEINIT1(SdrTextObj,SdrAttrObj); 107 108 SdrTextObj::SdrTextObj() 109 : SdrAttrObj(), 110 mpText(NULL), 111 pEdtOutl(NULL), 112 pFormTextBoundRect(NULL), 113 eTextKind(OBJ_TEXT) 114 { 115 bTextSizeDirty=sal_False; 116 bTextFrame=sal_False; 117 bNoShear=sal_False; 118 bNoRotate=sal_False; 119 bNoMirror=sal_False; 120 bDisableAutoWidthOnDragging=sal_False; 121 122 // #101684# 123 mbInEditMode = sal_False; 124 125 // #111096# 126 mbTextHidden = sal_False; 127 128 // #111096# 129 mbTextAnimationAllowed = sal_True; 130 131 // #108784# 132 maTextEditOffset = Point(0, 0); 133 134 // #i25616# 135 mbSupportTextIndentingOnLineWidthChange = sal_True; 136 } 137 138 SdrTextObj::SdrTextObj(const Rectangle& rNewRect) 139 : SdrAttrObj(), 140 aRect(rNewRect), 141 mpText(NULL), 142 pEdtOutl(NULL), 143 pFormTextBoundRect(NULL) 144 { 145 bTextSizeDirty=sal_False; 146 bTextFrame=sal_False; 147 bNoShear=sal_False; 148 bNoRotate=sal_False; 149 bNoMirror=sal_False; 150 bDisableAutoWidthOnDragging=sal_False; 151 ImpJustifyRect(aRect); 152 153 // #101684# 154 mbInEditMode = sal_False; 155 156 // #111096# 157 mbTextHidden = sal_False; 158 159 // #111096# 160 mbTextAnimationAllowed = sal_True; 161 162 // #108784# 163 maTextEditOffset = Point(0, 0); 164 165 // #i25616# 166 mbSupportTextIndentingOnLineWidthChange = sal_True; 167 } 168 169 SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind) 170 : SdrAttrObj(), 171 mpText(NULL), 172 pEdtOutl(NULL), 173 pFormTextBoundRect(NULL), 174 eTextKind(eNewTextKind) 175 { 176 bTextSizeDirty=sal_False; 177 bTextFrame=sal_True; 178 bNoShear=sal_True; 179 bNoRotate=sal_False; 180 bNoMirror=sal_True; 181 bDisableAutoWidthOnDragging=sal_False; 182 183 // #101684# 184 mbInEditMode = sal_False; 185 186 // #111096# 187 mbTextHidden = sal_False; 188 189 // #111096# 190 mbTextAnimationAllowed = sal_True; 191 192 // #108784# 193 maTextEditOffset = Point(0, 0); 194 195 // #i25616# 196 mbSupportTextIndentingOnLineWidthChange = sal_True; 197 } 198 199 SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const Rectangle& rNewRect) 200 : SdrAttrObj(), 201 aRect(rNewRect), 202 mpText(NULL), 203 pEdtOutl(NULL), 204 pFormTextBoundRect(NULL), 205 eTextKind(eNewTextKind) 206 { 207 bTextSizeDirty=sal_False; 208 bTextFrame=sal_True; 209 bNoShear=sal_True; 210 bNoRotate=sal_False; 211 bNoMirror=sal_True; 212 bDisableAutoWidthOnDragging=sal_False; 213 ImpJustifyRect(aRect); 214 215 // #101684# 216 mbInEditMode = sal_False; 217 218 // #111096# 219 mbTextHidden = sal_False; 220 221 // #111096# 222 mbTextAnimationAllowed = sal_True; 223 224 // #108784# 225 maTextEditOffset = Point(0, 0); 226 227 // #i25616# 228 mbSupportTextIndentingOnLineWidthChange = sal_True; 229 } 230 231 SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const Rectangle& rNewRect, SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat) 232 : SdrAttrObj(), 233 aRect(rNewRect), 234 mpText(NULL), 235 pEdtOutl(NULL), 236 pFormTextBoundRect(NULL), 237 eTextKind(eNewTextKind) 238 { 239 bTextSizeDirty=sal_False; 240 bTextFrame=sal_True; 241 bNoShear=sal_True; 242 bNoRotate=sal_False; 243 bNoMirror=sal_True; 244 bDisableAutoWidthOnDragging=sal_False; 245 ImpJustifyRect(aRect); 246 247 NbcSetText(rInput, rBaseURL, eFormat); 248 249 // #101684# 250 mbInEditMode = sal_False; 251 252 // #111096# 253 mbTextHidden = sal_False; 254 255 // #111096# 256 mbTextAnimationAllowed = sal_True; 257 258 // #108784# 259 maTextEditOffset = Point(0, 0); 260 261 // #i25616# 262 mbSupportTextIndentingOnLineWidthChange = sal_True; 263 } 264 265 SdrTextObj::~SdrTextObj() 266 { 267 if( pModel ) 268 { 269 SdrOutliner& rOutl = pModel->GetHitTestOutliner(); 270 if( rOutl.GetTextObj() == this ) 271 rOutl.SetTextObj( NULL ); 272 } 273 274 if(mpText!=NULL) 275 delete mpText; 276 277 if (pFormTextBoundRect!=NULL) 278 delete pFormTextBoundRect; 279 280 ImpLinkAbmeldung(); 281 } 282 283 void SdrTextObj::FitFrameToTextSize() 284 { 285 DBG_ASSERT(pModel!=NULL,"SdrTextObj::FitFrameToTextSize(): pModel=NULL!"); 286 ImpJustifyRect(aRect); 287 288 SdrText* pText = getActiveText(); 289 if( pText!=NULL && pText->GetOutlinerParaObject() && pModel!=NULL) 290 { 291 SdrOutliner& rOutliner=ImpGetDrawOutliner(); 292 rOutliner.SetPaperSize(Size(aRect.Right()-aRect.Left(),aRect.Bottom()-aRect.Top())); 293 rOutliner.SetUpdateMode(sal_True); 294 rOutliner.SetText(*pText->GetOutlinerParaObject()); 295 Rectangle aTextRect; 296 Size aNewSize(rOutliner.CalcTextSize()); 297 rOutliner.Clear(); 298 aNewSize.Width()++; // wegen evtl. Rundungsfehler 299 aNewSize.Width()+=GetTextLeftDistance()+GetTextRightDistance(); 300 aNewSize.Height()+=GetTextUpperDistance()+GetTextLowerDistance(); 301 Rectangle aNewRect(aRect); 302 aNewRect.SetSize(aNewSize); 303 ImpJustifyRect(aNewRect); 304 if (aNewRect!=aRect) { 305 SetLogicRect(aNewRect); 306 } 307 } 308 } 309 310 void SdrTextObj::NbcSetText(const XubString& rStr) 311 { 312 SdrOutliner& rOutliner=ImpGetDrawOutliner(); 313 rOutliner.SetStyleSheet( 0, GetStyleSheet()); 314 //OutputDevice* pRef1=rOutliner.GetRefDevice(); 315 rOutliner.SetUpdateMode(sal_True); 316 rOutliner.SetText(rStr,rOutliner.GetParagraph( 0 )); 317 OutlinerParaObject* pNewText=rOutliner.CreateParaObject(); 318 Size aSiz(rOutliner.CalcTextSize()); 319 //OutputDevice* pRef2=rOutliner.GetRefDevice(); 320 rOutliner.Clear(); 321 NbcSetOutlinerParaObject(pNewText); 322 aTextSize=aSiz; 323 bTextSizeDirty=sal_False; 324 } 325 326 void SdrTextObj::SetText(const XubString& rStr) 327 { 328 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); 329 // #110094#-14 SendRepaintBroadcast(); 330 NbcSetText(rStr); 331 SetChanged(); 332 BroadcastObjectChange(); 333 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); 334 //if (GetBoundRect()!=aBoundRect0) { 335 // SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); 336 //} 337 } 338 339 void SdrTextObj::NbcSetText(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat) 340 { 341 SdrOutliner& rOutliner=ImpGetDrawOutliner(); 342 rOutliner.SetStyleSheet( 0, GetStyleSheet()); 343 rOutliner.Read(rInput,rBaseURL,eFormat); 344 OutlinerParaObject* pNewText=rOutliner.CreateParaObject(); 345 rOutliner.SetUpdateMode(sal_True); 346 Size aSiz(rOutliner.CalcTextSize()); 347 rOutliner.Clear(); 348 NbcSetOutlinerParaObject(pNewText); 349 aTextSize=aSiz; 350 bTextSizeDirty=sal_False; 351 } 352 353 void SdrTextObj::SetText(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat) 354 { 355 Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); 356 // #110094#-14 SendRepaintBroadcast(); 357 NbcSetText(rInput,rBaseURL,eFormat); 358 SetChanged(); 359 BroadcastObjectChange(); 360 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); 361 } 362 363 const Size& SdrTextObj::GetTextSize() const 364 { 365 if (bTextSizeDirty) 366 { 367 Size aSiz; 368 SdrText* pText = getActiveText(); 369 if( pText && pText->GetOutlinerParaObject ()) 370 { 371 SdrOutliner& rOutliner=ImpGetDrawOutliner(); 372 rOutliner.SetText(*pText->GetOutlinerParaObject()); 373 rOutliner.SetUpdateMode(sal_True); 374 aSiz=rOutliner.CalcTextSize(); 375 rOutliner.Clear(); 376 } 377 // 2x casting auf nonconst 378 ((SdrTextObj*)this)->aTextSize=aSiz; 379 ((SdrTextObj*)this)->bTextSizeDirty=sal_False; 380 } 381 return aTextSize; 382 } 383 384 FASTBOOL SdrTextObj::IsAutoGrowHeight() const 385 { 386 if(!bTextFrame) 387 return sal_False; // AutoGrow nur bei TextFrames 388 389 const SfxItemSet& rSet = GetObjectItemSet(); 390 sal_Bool bRet = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue(); 391 392 if(bRet) 393 { 394 SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue(); 395 396 if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE) 397 { 398 SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue(); 399 400 if(eDirection == SDRTEXTANI_UP || eDirection == SDRTEXTANI_DOWN) 401 { 402 bRet = sal_False; 403 } 404 } 405 } 406 return bRet; 407 } 408 409 FASTBOOL SdrTextObj::IsAutoGrowWidth() const 410 { 411 if(!bTextFrame) 412 return sal_False; // AutoGrow nur bei TextFrames 413 414 const SfxItemSet& rSet = GetObjectItemSet(); 415 sal_Bool bRet = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWWIDTH))).GetValue(); 416 417 // #101684# 418 sal_Bool bInEditMOde = IsInEditMode(); 419 420 if(!bInEditMOde && bRet) 421 { 422 SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue(); 423 424 if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE) 425 { 426 SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue(); 427 428 if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT) 429 { 430 bRet = sal_False; 431 } 432 } 433 } 434 return bRet; 435 } 436 437 SdrTextHorzAdjust SdrTextObj::GetTextHorizontalAdjust() const 438 { 439 return GetTextHorizontalAdjust(GetObjectItemSet()); 440 } 441 442 SdrTextHorzAdjust SdrTextObj::GetTextHorizontalAdjust(const SfxItemSet& rSet) const 443 { 444 if(IsContourTextFrame()) 445 return SDRTEXTHORZADJUST_BLOCK; 446 447 SdrTextHorzAdjust eRet = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue(); 448 449 // #101684# 450 sal_Bool bInEditMode = IsInEditMode(); 451 452 if(!bInEditMode && eRet == SDRTEXTHORZADJUST_BLOCK) 453 { 454 SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue(); 455 456 if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE) 457 { 458 SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue(); 459 460 if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT) 461 { 462 eRet = SDRTEXTHORZADJUST_LEFT; 463 } 464 } 465 } 466 467 return eRet; 468 } // defaults: BLOCK fuer Textrahmen, CENTER fuer beschriftete Grafikobjekte 469 470 SdrTextVertAdjust SdrTextObj::GetTextVerticalAdjust() const 471 { 472 return GetTextVerticalAdjust(GetObjectItemSet()); 473 } 474 475 SdrTextVertAdjust SdrTextObj::GetTextVerticalAdjust(const SfxItemSet& rSet) const 476 { 477 if(IsContourTextFrame()) 478 return SDRTEXTVERTADJUST_TOP; 479 480 // #103516# Take care for vertical text animation here 481 SdrTextVertAdjust eRet = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue(); 482 sal_Bool bInEditMode = IsInEditMode(); 483 484 // #103516# Take care for vertical text animation here 485 if(!bInEditMode && eRet == SDRTEXTVERTADJUST_BLOCK) 486 { 487 SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue(); 488 489 if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE) 490 { 491 SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue(); 492 493 if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT) 494 { 495 eRet = SDRTEXTVERTADJUST_TOP; 496 } 497 } 498 } 499 500 return eRet; 501 } // defaults: TOP fuer Textrahmen, CENTER fuer beschriftete Grafikobjekte 502 503 void SdrTextObj::ImpJustifyRect(Rectangle& rRect) const 504 { 505 if (!rRect.IsEmpty()) { 506 rRect.Justify(); 507 if (rRect.Left()==rRect.Right()) rRect.Right()++; 508 if (rRect.Top()==rRect.Bottom()) rRect.Bottom()++; 509 } 510 } 511 512 void SdrTextObj::ImpCheckShear() 513 { 514 if (bNoShear && aGeo.nShearWink!=0) { 515 aGeo.nShearWink=0; 516 aGeo.nTan=0; 517 } 518 } 519 520 void SdrTextObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const 521 { 522 FASTBOOL bNoTextFrame=!IsTextFrame(); 523 rInfo.bResizeFreeAllowed=bNoTextFrame || aGeo.nDrehWink%9000==0; 524 rInfo.bResizePropAllowed=sal_True; 525 rInfo.bRotateFreeAllowed=sal_True; 526 rInfo.bRotate90Allowed =sal_True; 527 rInfo.bMirrorFreeAllowed=bNoTextFrame; 528 rInfo.bMirror45Allowed =bNoTextFrame; 529 rInfo.bMirror90Allowed =bNoTextFrame; 530 531 // allow transparence 532 rInfo.bTransparenceAllowed = sal_True; 533 534 // gradient depends on fillstyle 535 XFillStyle eFillStyle = ((XFillStyleItem&)(GetObjectItem(XATTR_FILLSTYLE))).GetValue(); 536 rInfo.bGradientAllowed = (eFillStyle == XFILL_GRADIENT); 537 rInfo.bShearAllowed =bNoTextFrame; 538 rInfo.bEdgeRadiusAllowed=sal_True; 539 FASTBOOL bCanConv=ImpCanConvTextToCurve(); 540 rInfo.bCanConvToPath =bCanConv; 541 rInfo.bCanConvToPoly =bCanConv; 542 rInfo.bCanConvToPathLineToArea=bCanConv; 543 rInfo.bCanConvToPolyLineToArea=bCanConv; 544 rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary()); 545 } 546 547 sal_uInt16 SdrTextObj::GetObjIdentifier() const 548 { 549 return sal_uInt16(eTextKind); 550 } 551 552 bool SdrTextObj::HasTextImpl( SdrOutliner* pOutliner ) 553 { 554 bool bRet=false; 555 if(pOutliner) 556 { 557 Paragraph* p1stPara=pOutliner->GetParagraph( 0 ); 558 sal_uIntPtr nParaAnz=pOutliner->GetParagraphCount(); 559 if(p1stPara==NULL) 560 nParaAnz=0; 561 562 if(nParaAnz==1) 563 { 564 // if it is only one paragraph, check if that paragraph is empty 565 XubString aStr(pOutliner->GetText(p1stPara)); 566 567 if(!aStr.Len()) 568 nParaAnz = 0; 569 } 570 571 bRet= nParaAnz!=0; 572 } 573 return bRet; 574 } 575 576 FASTBOOL SdrTextObj::HasEditText() const 577 { 578 return HasTextImpl( pEdtOutl ); 579 } 580 581 void SdrTextObj::SetPage(SdrPage* pNewPage) 582 { 583 FASTBOOL bRemove=pNewPage==NULL && pPage!=NULL; 584 FASTBOOL bInsert=pNewPage!=NULL && pPage==NULL; 585 FASTBOOL bLinked=IsLinkedText(); 586 587 if (bLinked && bRemove) { 588 ImpLinkAbmeldung(); 589 } 590 591 SdrAttrObj::SetPage(pNewPage); 592 593 if (bLinked && bInsert) { 594 ImpLinkAnmeldung(); 595 } 596 } 597 598 void SdrTextObj::SetModel(SdrModel* pNewModel) 599 { 600 SdrModel* pOldModel=pModel; 601 bool bLinked=IsLinkedText(); 602 bool bChg=pNewModel!=pModel; 603 604 if (bLinked && bChg) 605 { 606 ImpLinkAbmeldung(); 607 } 608 609 SdrAttrObj::SetModel(pNewModel); 610 611 if( bChg ) 612 { 613 if( pNewModel != 0 && pOldModel != 0 ) 614 SetTextSizeDirty(); 615 616 sal_Int32 nCount = getTextCount(); 617 for( sal_Int32 nText = 0; nText < nCount; nText++ ) 618 { 619 SdrText* pText = getText( nText ); 620 if( pText ) 621 pText->SetModel( pNewModel ); 622 } 623 } 624 625 if (bLinked && bChg) 626 { 627 ImpLinkAnmeldung(); 628 } 629 } 630 631 FASTBOOL SdrTextObj::NbcSetEckenradius(long nRad) 632 { 633 SetObjectItem(SdrEckenradiusItem(nRad)); 634 return sal_True; 635 } 636 637 FASTBOOL SdrTextObj::NbcSetAutoGrowHeight(bool bAuto) 638 { 639 if(bTextFrame) 640 { 641 SetObjectItem(SdrTextAutoGrowHeightItem(bAuto)); 642 return sal_True; 643 } 644 return sal_False; 645 } 646 647 // #115391# This implementation is based on the object size (aRect) and the 648 // states of IsAutoGrowWidth/Height to correctly set TextMinFrameWidth/Height 649 void SdrTextObj::AdaptTextMinSize() 650 { 651 if(bTextFrame && (!pModel || !pModel->IsPasteResize())) 652 { 653 const bool bW(IsAutoGrowWidth()); 654 const bool bH(IsAutoGrowHeight()); 655 656 if(bW || bH) 657 { 658 SfxItemSet aSet(GetObjectItemSet()); 659 660 if(bW) 661 { 662 const long nDist(GetTextLeftDistance() + GetTextRightDistance()); 663 const long nW(std::max(long(0), (long)(aRect.GetWidth() - 1 - nDist))); 664 665 aSet.Put(SdrTextMinFrameWidthItem(nW)); 666 667 if(!IsVerticalWriting() && bDisableAutoWidthOnDragging) 668 { 669 bDisableAutoWidthOnDragging = true; 670 aSet.Put(SdrTextAutoGrowWidthItem(false)); 671 } 672 } 673 674 if(bH) 675 { 676 const long nDist(GetTextUpperDistance() + GetTextLowerDistance()); 677 const long nH(std::max(long(0), (long)(aRect.GetHeight() - 1 - nDist))); 678 679 aSet.Put(SdrTextMinFrameHeightItem(nH)); 680 681 if(IsVerticalWriting() && bDisableAutoWidthOnDragging) 682 { 683 bDisableAutoWidthOnDragging = false; 684 aSet.Put(SdrTextAutoGrowHeightItem(false)); 685 } 686 } 687 688 SetObjectItemSet(aSet); 689 NbcAdjustTextFrameWidthAndHeight(); 690 } 691 } 692 } 693 694 FASTBOOL SdrTextObj::NbcSetMaxTextFrameHeight(long nHgt) 695 { 696 if(bTextFrame) 697 { 698 SetObjectItem(SdrTextMaxFrameHeightItem(nHgt)); 699 return sal_True; 700 } 701 return sal_False; 702 } 703 704 FASTBOOL SdrTextObj::NbcSetAutoGrowWidth(bool bAuto) 705 { 706 if(bTextFrame) 707 { 708 SetObjectItem(SdrTextAutoGrowWidthItem(bAuto)); 709 return sal_True; 710 } 711 return sal_False; 712 } 713 714 FASTBOOL SdrTextObj::NbcSetMaxTextFrameWidth(long nWdt) 715 { 716 if(bTextFrame) 717 { 718 SetObjectItem(SdrTextMaxFrameWidthItem(nWdt)); 719 return sal_True; 720 } 721 return sal_False; 722 } 723 724 FASTBOOL SdrTextObj::NbcSetFitToSize(SdrFitToSizeType eFit) 725 { 726 if(bTextFrame) 727 { 728 SetObjectItem(SdrTextFitToSizeTypeItem(eFit)); 729 return sal_True; 730 } 731 return sal_False; 732 } 733 734 void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, Rectangle& rAnchorRect, sal_Bool bLineWidth ) const 735 { 736 basegfx::B2DPolyPolygon aXorPolyPolygon(TakeXorPoly()); 737 basegfx::B2DPolyPolygon* pContourPolyPolygon = 0L; 738 basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix( 739 -rAnchorRect.Left(), -rAnchorRect.Top())); 740 741 if(aGeo.nDrehWink) 742 { 743 // Unrotate! 744 aMatrix.rotate(-aGeo.nDrehWink * nPi180); 745 } 746 747 aXorPolyPolygon.transform(aMatrix); 748 749 if( bLineWidth ) 750 { 751 // Strichstaerke beruecksichtigen 752 // Beim Hittest muss das unterbleiben (Performance!) 753 pContourPolyPolygon = new basegfx::B2DPolyPolygon(); 754 755 // #86258# test if shadow needs to be avoided for TakeContour() 756 const SfxItemSet& rSet = GetObjectItemSet(); 757 sal_Bool bShadowOn = ((SdrShadowItem&)(rSet.Get(SDRATTR_SHADOW))).GetValue(); 758 759 // #i33696# 760 // Remember TextObject currently set at the DrawOutliner, it WILL be 761 // replaced during calculating the outline since it uses an own paint 762 // and that one uses the DrawOutliner, too. 763 const SdrTextObj* pLastTextObject = rOutliner.GetTextObj(); 764 765 if(bShadowOn) 766 { 767 // #86258# force shadow off 768 SdrObject* pCopy = Clone(); 769 pCopy->SetMergedItem(SdrShadowItem(sal_False)); 770 *pContourPolyPolygon = pCopy->TakeContour(); 771 SdrObject::Free( pCopy ); 772 } 773 else 774 { 775 *pContourPolyPolygon = TakeContour(); 776 } 777 778 // #i33696# 779 // restore remembered text object 780 if(pLastTextObject != rOutliner.GetTextObj()) 781 { 782 rOutliner.SetTextObj(pLastTextObject); 783 } 784 785 pContourPolyPolygon->transform(aMatrix); 786 } 787 788 rOutliner.SetPolygon(aXorPolyPolygon, pContourPolyPolygon); 789 } 790 791 void SdrTextObj::TakeUnrotatedSnapRect(Rectangle& rRect) const 792 { 793 rRect=aRect; 794 } 795 796 void SdrTextObj::TakeTextAnchorRect(Rectangle& rAnchorRect) const 797 { 798 long nLeftDist=GetTextLeftDistance(); 799 long nRightDist=GetTextRightDistance(); 800 long nUpperDist=GetTextUpperDistance(); 801 long nLowerDist=GetTextLowerDistance(); 802 Rectangle aAnkRect(aRect); // Rect innerhalb dem geankert wird 803 FASTBOOL bFrame=IsTextFrame(); 804 if (!bFrame) { 805 TakeUnrotatedSnapRect(aAnkRect); 806 } 807 Point aRotateRef(aAnkRect.TopLeft()); 808 aAnkRect.Left()+=nLeftDist; 809 aAnkRect.Top()+=nUpperDist; 810 aAnkRect.Right()-=nRightDist; 811 aAnkRect.Bottom()-=nLowerDist; 812 813 // #108816# 814 // Since sizes may be bigger than the object bounds it is necessary to 815 // justify the rect now. 816 ImpJustifyRect(aAnkRect); 817 818 if (bFrame) { 819 // !!! hier noch etwas verfeinern !!! 820 if (aAnkRect.GetWidth()<2) aAnkRect.Right()=aAnkRect.Left()+1; // Mindestgroesse 2 821 if (aAnkRect.GetHeight()<2) aAnkRect.Bottom()=aAnkRect.Top()+1; // Mindestgroesse 2 822 } 823 if (aGeo.nDrehWink!=0) { 824 Point aTmpPt(aAnkRect.TopLeft()); 825 RotatePoint(aTmpPt,aRotateRef,aGeo.nSin,aGeo.nCos); 826 aTmpPt-=aAnkRect.TopLeft(); 827 aAnkRect.Move(aTmpPt.X(),aTmpPt.Y()); 828 } 829 rAnchorRect=aAnkRect; 830 } 831 832 void SdrTextObj::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, FASTBOOL bNoEditText, 833 Rectangle* pAnchorRect, sal_Bool bLineWidth ) const 834 { 835 Rectangle aAnkRect; // Rect innerhalb dem geankert wird 836 TakeTextAnchorRect(aAnkRect); 837 SdrTextVertAdjust eVAdj=GetTextVerticalAdjust(); 838 SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust(); 839 SdrTextAniKind eAniKind=GetTextAniKind(); 840 SdrTextAniDirection eAniDirection=GetTextAniDirection(); 841 842 SdrFitToSizeType eFit=GetFitToSize(); 843 FASTBOOL bFitToSize=(eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES); 844 FASTBOOL bContourFrame=IsContourTextFrame(); 845 846 FASTBOOL bFrame=IsTextFrame(); 847 sal_uIntPtr nStat0=rOutliner.GetControlWord(); 848 Size aNullSize; 849 if (!bContourFrame) 850 { 851 rOutliner.SetControlWord(nStat0|EE_CNTRL_AUTOPAGESIZE); 852 rOutliner.SetMinAutoPaperSize(aNullSize); 853 rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000)); 854 } 855 856 if (!bFitToSize && !bContourFrame) 857 { 858 long nAnkWdt=aAnkRect.GetWidth(); 859 long nAnkHgt=aAnkRect.GetHeight(); 860 if (bFrame) 861 { 862 long nWdt=nAnkWdt; 863 long nHgt=nAnkHgt; 864 865 // #101684# 866 sal_Bool bInEditMode = IsInEditMode(); 867 868 if (!bInEditMode && (eAniKind==SDRTEXTANI_SCROLL || eAniKind==SDRTEXTANI_ALTERNATE || eAniKind==SDRTEXTANI_SLIDE)) 869 { 870 // Grenzenlose Papiergroesse fuer Laufschrift 871 if (eAniDirection==SDRTEXTANI_LEFT || eAniDirection==SDRTEXTANI_RIGHT) nWdt=1000000; 872 if (eAniDirection==SDRTEXTANI_UP || eAniDirection==SDRTEXTANI_DOWN) nHgt=1000000; 873 } 874 875 // #119885# Do not limit/force height to geometrical frame (vice versa for vertical writing) 876 if(IsVerticalWriting()) 877 { 878 nWdt = 1000000; 879 } 880 else 881 { 882 nHgt = 1000000; 883 } 884 885 rOutliner.SetMaxAutoPaperSize(Size(nWdt,nHgt)); 886 } 887 888 // #103516# New try with _BLOCK for hor and ver after completely 889 // supporting full width for vertical text. 890 if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting()) 891 { 892 rOutliner.SetMinAutoPaperSize(Size(nAnkWdt, 0)); 893 } 894 895 if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting()) 896 { 897 rOutliner.SetMinAutoPaperSize(Size(0, nAnkHgt)); 898 } 899 } 900 901 rOutliner.SetPaperSize(aNullSize); 902 if (bContourFrame) 903 ImpSetContourPolygon( rOutliner, aAnkRect, bLineWidth ); 904 905 // put text into the outliner, if available from the edit outliner 906 SdrText* pText = getActiveText(); 907 OutlinerParaObject* pOutlinerParaObject = pText ? pText->GetOutlinerParaObject() : 0; 908 OutlinerParaObject* pPara = (pEdtOutl && !bNoEditText) ? pEdtOutl->CreateParaObject() : pOutlinerParaObject; 909 910 if (pPara) 911 { 912 sal_Bool bHitTest = sal_False; 913 if( pModel ) 914 bHitTest = &pModel->GetHitTestOutliner() == &rOutliner; 915 916 const SdrTextObj* pTestObj = rOutliner.GetTextObj(); 917 if( !pTestObj || !bHitTest || pTestObj != this || 918 pTestObj->GetOutlinerParaObject() != pOutlinerParaObject ) 919 { 920 if( bHitTest ) // #i33696# take back fix #i27510# 921 { 922 rOutliner.SetTextObj( this ); 923 rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue()); 924 } 925 926 rOutliner.SetUpdateMode(sal_True); 927 rOutliner.SetText(*pPara); 928 } 929 } 930 else 931 { 932 rOutliner.SetTextObj( NULL ); 933 } 934 935 if (pEdtOutl && !bNoEditText && pPara) 936 delete pPara; 937 938 rOutliner.SetUpdateMode(sal_True); 939 rOutliner.SetControlWord(nStat0); 940 941 if( pText ) 942 pText->CheckPortionInfo(rOutliner); 943 944 Point aTextPos(aAnkRect.TopLeft()); 945 Size aTextSiz(rOutliner.GetPaperSize()); // GetPaperSize() hat etwas Toleranz drauf, oder? 946 947 // #106653# 948 // For draw objects containing text correct hor/ver alignment if text is bigger 949 // than the object itself. Without that correction, the text would always be 950 // formatted to the left edge (or top edge when vertical) of the draw object. 951 if(!IsTextFrame()) 952 { 953 if(aAnkRect.GetWidth() < aTextSiz.Width() && !IsVerticalWriting()) 954 { 955 // #110129# 956 // Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK, 957 // else the alignment is wanted. 958 if(SDRTEXTHORZADJUST_BLOCK == eHAdj) 959 { 960 eHAdj = SDRTEXTHORZADJUST_CENTER; 961 } 962 } 963 964 if(aAnkRect.GetHeight() < aTextSiz.Height() && IsVerticalWriting()) 965 { 966 // #110129# 967 // Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK, 968 // else the alignment is wanted. 969 if(SDRTEXTVERTADJUST_BLOCK == eVAdj) 970 { 971 eVAdj = SDRTEXTVERTADJUST_CENTER; 972 } 973 } 974 } 975 976 if (eHAdj==SDRTEXTHORZADJUST_CENTER || eHAdj==SDRTEXTHORZADJUST_RIGHT) 977 { 978 long nFreeWdt=aAnkRect.GetWidth()-aTextSiz.Width(); 979 if (eHAdj==SDRTEXTHORZADJUST_CENTER) 980 aTextPos.X()+=nFreeWdt/2; 981 if (eHAdj==SDRTEXTHORZADJUST_RIGHT) 982 aTextPos.X()+=nFreeWdt; 983 } 984 if (eVAdj==SDRTEXTVERTADJUST_CENTER || eVAdj==SDRTEXTVERTADJUST_BOTTOM) 985 { 986 long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height(); 987 if (eVAdj==SDRTEXTVERTADJUST_CENTER) 988 aTextPos.Y()+=nFreeHgt/2; 989 if (eVAdj==SDRTEXTVERTADJUST_BOTTOM) 990 aTextPos.Y()+=nFreeHgt; 991 } 992 if (aGeo.nDrehWink!=0) 993 RotatePoint(aTextPos,aAnkRect.TopLeft(),aGeo.nSin,aGeo.nCos); 994 995 if (pAnchorRect) 996 *pAnchorRect=aAnkRect; 997 998 // rTextRect ist bei ContourFrame in einigen Faellen nicht korrekt 999 rTextRect=Rectangle(aTextPos,aTextSiz); 1000 if (bContourFrame) 1001 rTextRect=aAnkRect; 1002 } 1003 1004 OutlinerParaObject* SdrTextObj::GetEditOutlinerParaObject() const 1005 { 1006 OutlinerParaObject* pPara=NULL; 1007 if( HasTextImpl( pEdtOutl ) ) 1008 { 1009 sal_uInt16 nParaAnz = static_cast< sal_uInt16 >( pEdtOutl->GetParagraphCount() ); 1010 pPara = pEdtOutl->CreateParaObject(0, nParaAnz); 1011 } 1012 return pPara; 1013 } 1014 1015 void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Rectangle& rTextRect, const Rectangle& rAnchorRect, Fraction& rFitXKorreg) const 1016 { 1017 OutputDevice* pOut = rOutliner.GetRefDevice(); 1018 sal_Bool bNoStretching(sal_False); 1019 1020 if(pOut && pOut->GetOutDevType() == OUTDEV_PRINTER) 1021 { 1022 // #35762#: Checken ob CharStretching ueberhaupt moeglich 1023 GDIMetaFile* pMtf = pOut->GetConnectMetaFile(); 1024 UniString aTestString(sal_Unicode('J')); 1025 1026 if(pMtf && (!pMtf->IsRecord() || pMtf->IsPause())) 1027 pMtf = NULL; 1028 1029 if(pMtf) 1030 pMtf->Pause(sal_True); 1031 1032 Font aFontMerk(pOut->GetFont()); 1033 Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_SERIF, LANGUAGE_SYSTEM, DEFAULTFONT_FLAGS_ONLYONE ) ); 1034 1035 aTmpFont.SetSize(Size(0,100)); 1036 pOut->SetFont(aTmpFont); 1037 Size aSize1(pOut->GetTextWidth(aTestString), pOut->GetTextHeight()); 1038 aTmpFont.SetSize(Size(800,100)); 1039 pOut->SetFont(aTmpFont); 1040 Size aSize2(pOut->GetTextWidth(aTestString), pOut->GetTextHeight()); 1041 pOut->SetFont(aFontMerk); 1042 1043 if(pMtf) 1044 pMtf->Pause(sal_False); 1045 1046 bNoStretching = (aSize1 == aSize2); 1047 1048 #ifdef WNT 1049 // #35762# Windows vergroessert bei Size(100,500) den Font proportional 1050 // Und das finden wir nicht so schoen. 1051 if(aSize2.Height() >= aSize1.Height() * 2) 1052 { 1053 bNoStretching = sal_True; 1054 } 1055 #endif 1056 } 1057 unsigned nLoopCount=0; 1058 FASTBOOL bNoMoreLoop=sal_False; 1059 long nXDiff0=0x7FFFFFFF; 1060 long nWantWdt=rAnchorRect.Right()-rAnchorRect.Left(); 1061 long nIsWdt=rTextRect.Right()-rTextRect.Left(); 1062 if (nIsWdt==0) nIsWdt=1; 1063 1064 long nWantHgt=rAnchorRect.Bottom()-rAnchorRect.Top(); 1065 long nIsHgt=rTextRect.Bottom()-rTextRect.Top(); 1066 if (nIsHgt==0) nIsHgt=1; 1067 1068 long nXTolPl=nWantWdt/100; // Toleranz +1% 1069 long nXTolMi=nWantWdt/25; // Toleranz -4% 1070 long nXKorr =nWantWdt/20; // Korrekturmasstab 5% 1071 1072 long nX=(nWantWdt*100) /nIsWdt; // X-Stretching berechnen 1073 long nY=(nWantHgt*100) /nIsHgt; // Y-Stretching berechnen 1074 FASTBOOL bChkX=sal_True; 1075 FASTBOOL bChkY=sal_True; 1076 if (bNoStretching) { // #35762# evtl. nur proportional moeglich 1077 if (nX>nY) { nX=nY; bChkX=sal_False; } 1078 else { nY=nX; bChkY=sal_False; } 1079 } 1080 1081 while (nLoopCount<5 && !bNoMoreLoop) { 1082 if (nX<0) nX=-nX; 1083 if (nX<1) { nX=1; bNoMoreLoop=sal_True; } 1084 if (nX>65535) { nX=65535; bNoMoreLoop=sal_True; } 1085 1086 if (nY<0) nY=-nY; 1087 if (nY<1) { nY=1; bNoMoreLoop=sal_True; } 1088 if (nY>65535) { nY=65535; bNoMoreLoop=sal_True; } 1089 1090 // exception, there is no text yet (horizontal case) 1091 if(nIsWdt <= 1) 1092 { 1093 nX = nY; 1094 bNoMoreLoop = sal_True; 1095 } 1096 1097 // #87877# exception, there is no text yet (vertical case) 1098 if(nIsHgt <= 1) 1099 { 1100 nY = nX; 1101 bNoMoreLoop = sal_True; 1102 } 1103 1104 rOutliner.SetGlobalCharStretching((sal_uInt16)nX,(sal_uInt16)nY); 1105 nLoopCount++; 1106 Size aSiz(rOutliner.CalcTextSize()); 1107 long nXDiff=aSiz.Width()-nWantWdt; 1108 rFitXKorreg=Fraction(nWantWdt,aSiz.Width()); 1109 if (((nXDiff>=nXTolMi || !bChkX) && nXDiff<=nXTolPl) || nXDiff==nXDiff0/*&& Abs(nYDiff)<=nYTol*/) { 1110 bNoMoreLoop=sal_True; 1111 } else { 1112 // Stretchingfaktoren korregieren 1113 long nMul=nWantWdt; 1114 long nDiv=aSiz.Width(); 1115 if (Abs(nXDiff)<=2*nXKorr) { 1116 if (nMul>nDiv) nDiv+=(nMul-nDiv)/2; // und zwar nur um die haelfte des berechneten 1117 else nMul+=(nDiv-nMul)/2; // weil die EE ja eh wieder falsch rechnet 1118 } 1119 nX=nX*nMul/nDiv; 1120 if (bNoStretching) nY=nX; 1121 } 1122 nXDiff0=nXDiff; 1123 } 1124 } 1125 1126 void SdrTextObj::StartTextAnimation(OutputDevice* /*pOutDev*/, const Point& /*rOffset*/, long /*nExtraData*/) 1127 { 1128 // #111096# 1129 // use new text animation 1130 SetTextAnimationAllowed(sal_True); 1131 } 1132 1133 void SdrTextObj::StopTextAnimation(OutputDevice* /*pOutDev*/, long /*nExtraData*/) 1134 { 1135 // #111096# 1136 // use new text animation 1137 SetTextAnimationAllowed(sal_False); 1138 } 1139 1140 void SdrTextObj::TakeObjNameSingul(XubString& rName) const 1141 { 1142 XubString aStr; 1143 1144 switch(eTextKind) 1145 { 1146 case OBJ_OUTLINETEXT: 1147 { 1148 aStr = ImpGetResStr(STR_ObjNameSingulOUTLINETEXT); 1149 break; 1150 } 1151 1152 case OBJ_TITLETEXT : 1153 { 1154 aStr = ImpGetResStr(STR_ObjNameSingulTITLETEXT); 1155 break; 1156 } 1157 1158 default: 1159 { 1160 if(IsLinkedText()) 1161 aStr = ImpGetResStr(STR_ObjNameSingulTEXTLNK); 1162 else 1163 aStr = ImpGetResStr(STR_ObjNameSingulTEXT); 1164 break; 1165 } 1166 } 1167 1168 OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); 1169 if(pOutlinerParaObject && eTextKind != OBJ_OUTLINETEXT) 1170 { 1171 // Macht bei OUTLINETEXT wohl derzeit noch etwas Probleme 1172 XubString aStr2(pOutlinerParaObject->GetTextObject().GetText(0)); 1173 aStr2.EraseLeadingChars(); 1174 1175 // #69446# avoid non expanded text portions in object name 1176 // (second condition is new) 1177 if(aStr2.Len() && aStr2.Search(sal_Unicode(255)) == STRING_NOTFOUND) 1178 { 1179 // #76681# space between ResStr and content text 1180 aStr += sal_Unicode(' '); 1181 1182 aStr += sal_Unicode('\''); 1183 1184 if(aStr2.Len() > 10) 1185 { 1186 aStr2.Erase(8); 1187 aStr2.AppendAscii("...", 3); 1188 } 1189 1190 aStr += aStr2; 1191 aStr += sal_Unicode('\''); 1192 } 1193 } 1194 1195 rName = aStr; 1196 1197 String aName( GetName() ); 1198 if(aName.Len()) 1199 { 1200 rName += sal_Unicode(' '); 1201 rName += sal_Unicode('\''); 1202 rName += aName; 1203 rName += sal_Unicode('\''); 1204 } 1205 1206 } 1207 1208 void SdrTextObj::TakeObjNamePlural(XubString& rName) const 1209 { 1210 switch (eTextKind) { 1211 case OBJ_OUTLINETEXT: rName=ImpGetResStr(STR_ObjNamePluralOUTLINETEXT); break; 1212 case OBJ_TITLETEXT : rName=ImpGetResStr(STR_ObjNamePluralTITLETEXT); break; 1213 default: { 1214 if (IsLinkedText()) { 1215 rName=ImpGetResStr(STR_ObjNamePluralTEXTLNK); 1216 } else { 1217 rName=ImpGetResStr(STR_ObjNamePluralTEXT); 1218 } 1219 } break; 1220 } // switch 1221 } 1222 1223 void SdrTextObj::operator=(const SdrObject& rObj) 1224 { 1225 // call parent 1226 SdrObject::operator=(rObj); 1227 1228 const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >( &rObj ); 1229 if (pTextObj!=NULL) 1230 { 1231 aRect =pTextObj->aRect; 1232 aGeo =pTextObj->aGeo; 1233 eTextKind =pTextObj->eTextKind; 1234 bTextFrame=pTextObj->bTextFrame; 1235 aTextSize=pTextObj->aTextSize; 1236 bTextSizeDirty=pTextObj->bTextSizeDirty; 1237 1238 // #101776# Not all of the necessary parameters were copied yet. 1239 bNoShear = pTextObj->bNoShear; 1240 bNoRotate = pTextObj->bNoRotate; 1241 bNoMirror = pTextObj->bNoMirror; 1242 bDisableAutoWidthOnDragging = pTextObj->bDisableAutoWidthOnDragging; 1243 1244 OutlinerParaObject* pNewOutlinerParaObject = 0; 1245 1246 SdrText* pText = getActiveText(); 1247 1248 if( pText && pTextObj->HasText() ) 1249 { 1250 const Outliner* pEO=pTextObj->pEdtOutl; 1251 if (pEO!=NULL) 1252 { 1253 pNewOutlinerParaObject = pEO->CreateParaObject(); 1254 } 1255 else 1256 { 1257 pNewOutlinerParaObject = new OutlinerParaObject(*pTextObj->getActiveText()->GetOutlinerParaObject()); 1258 } 1259 } 1260 1261 mpText->SetOutlinerParaObject( pNewOutlinerParaObject ); 1262 ImpSetTextStyleSheetListeners(); 1263 } 1264 } 1265 1266 basegfx::B2DPolyPolygon SdrTextObj::TakeXorPoly() const 1267 { 1268 Polygon aPol(aRect); 1269 if (aGeo.nShearWink!=0) ShearPoly(aPol,aRect.TopLeft(),aGeo.nTan); 1270 if (aGeo.nDrehWink!=0) RotatePoly(aPol,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); 1271 1272 basegfx::B2DPolyPolygon aRetval; 1273 aRetval.append(aPol.getB2DPolygon()); 1274 return aRetval; 1275 } 1276 1277 basegfx::B2DPolyPolygon SdrTextObj::TakeContour() const 1278 { 1279 basegfx::B2DPolyPolygon aRetval(SdrAttrObj::TakeContour()); 1280 1281 // und nun noch ggf. das BoundRect des Textes dazu 1282 if ( pModel && GetOutlinerParaObject() && !IsFontwork() && !IsContourTextFrame() ) 1283 { 1284 // #80328# using Clone()-Paint() strategy inside TakeContour() leaves a destroyed 1285 // SdrObject as pointer in DrawOutliner. Set *this again in fetching the outliner 1286 // in every case 1287 SdrOutliner& rOutliner=ImpGetDrawOutliner(); 1288 1289 Rectangle aAnchor2; 1290 Rectangle aR; 1291 TakeTextRect(rOutliner,aR,sal_False,&aAnchor2); 1292 rOutliner.Clear(); 1293 SdrFitToSizeType eFit=GetFitToSize(); 1294 FASTBOOL bFitToSize=(eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES); 1295 if (bFitToSize) aR=aAnchor2; 1296 Polygon aPol(aR); 1297 if (aGeo.nDrehWink!=0) RotatePoly(aPol,aR.TopLeft(),aGeo.nSin,aGeo.nCos); 1298 1299 aRetval.append(aPol.getB2DPolygon()); 1300 } 1301 1302 return aRetval; 1303 } 1304 1305 void SdrTextObj::RecalcSnapRect() 1306 { 1307 if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) { 1308 Polygon aPol(aRect); 1309 if (aGeo.nShearWink!=0) ShearPoly(aPol,aRect.TopLeft(),aGeo.nTan); 1310 if (aGeo.nDrehWink!=0) RotatePoly(aPol,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); 1311 maSnapRect=aPol.GetBoundRect(); 1312 } else { 1313 maSnapRect=aRect; 1314 } 1315 } 1316 1317 sal_uInt32 SdrTextObj::GetSnapPointCount() const 1318 { 1319 return 4L; 1320 } 1321 1322 Point SdrTextObj::GetSnapPoint(sal_uInt32 i) const 1323 { 1324 Point aP; 1325 switch (i) { 1326 case 0: aP=aRect.TopLeft(); break; 1327 case 1: aP=aRect.TopRight(); break; 1328 case 2: aP=aRect.BottomLeft(); break; 1329 case 3: aP=aRect.BottomRight(); break; 1330 default: aP=aRect.Center(); break; 1331 } 1332 if (aGeo.nShearWink!=0) ShearPoint(aP,aRect.TopLeft(),aGeo.nTan); 1333 if (aGeo.nDrehWink!=0) RotatePoint(aP,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); 1334 return aP; 1335 } 1336 1337 void SdrTextObj::ImpCheckMasterCachable() 1338 { 1339 bNotMasterCachable=sal_False; 1340 1341 OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); 1342 1343 if(!bNotVisibleAsMaster && pOutlinerParaObject && pOutlinerParaObject->IsEditDoc() ) 1344 { 1345 const EditTextObject& rText= pOutlinerParaObject->GetTextObject(); 1346 bNotMasterCachable=rText.HasField(SvxPageField::StaticType()); 1347 if( !bNotMasterCachable ) 1348 { 1349 bNotMasterCachable=rText.HasField(SvxHeaderField::StaticType()); 1350 if( !bNotMasterCachable ) 1351 { 1352 bNotMasterCachable=rText.HasField(SvxFooterField::StaticType()); 1353 if( !bNotMasterCachable ) 1354 { 1355 bNotMasterCachable=rText.HasField(SvxDateTimeField::StaticType()); 1356 } 1357 } 1358 } 1359 } 1360 } 1361 1362 // #101029#: Extracted from ImpGetDrawOutliner() 1363 void SdrTextObj::ImpInitDrawOutliner( SdrOutliner& rOutl ) const 1364 { 1365 rOutl.SetUpdateMode(sal_False); 1366 sal_uInt16 nOutlinerMode = OUTLINERMODE_OUTLINEOBJECT; 1367 if ( !IsOutlText() ) 1368 nOutlinerMode = OUTLINERMODE_TEXTOBJECT; 1369 rOutl.Init( nOutlinerMode ); 1370 1371 rOutl.SetGlobalCharStretching(100,100); 1372 sal_uIntPtr nStat=rOutl.GetControlWord(); 1373 nStat&=~(EE_CNTRL_STRETCHING|EE_CNTRL_AUTOPAGESIZE); 1374 rOutl.SetControlWord(nStat); 1375 Size aNullSize; 1376 Size aMaxSize(100000,100000); 1377 rOutl.SetMinAutoPaperSize(aNullSize); 1378 rOutl.SetMaxAutoPaperSize(aMaxSize); 1379 rOutl.SetPaperSize(aMaxSize); 1380 rOutl.ClearPolygon(); 1381 } 1382 1383 SdrOutliner& SdrTextObj::ImpGetDrawOutliner() const 1384 { 1385 SdrOutliner& rOutl=pModel->GetDrawOutliner(this); 1386 1387 // #101029#: Code extracted to ImpInitDrawOutliner() 1388 ImpInitDrawOutliner( rOutl ); 1389 1390 return rOutl; 1391 } 1392 1393 boost::shared_ptr< SdrOutliner > SdrTextObj::CreateDrawOutliner() 1394 { 1395 boost::shared_ptr< SdrOutliner > xDrawOutliner( pModel->CreateDrawOutliner(this) ); 1396 ImpInitDrawOutliner( *(xDrawOutliner.get()) ); 1397 return xDrawOutliner; 1398 } 1399 1400 // #101029#: Extracted from Paint() 1401 void SdrTextObj::ImpSetupDrawOutlinerForPaint( FASTBOOL bContourFrame, 1402 SdrOutliner& rOutliner, 1403 Rectangle& rTextRect, 1404 Rectangle& rAnchorRect, 1405 Rectangle& rPaintRect, 1406 Fraction& rFitXKorreg ) const 1407 { 1408 if (!bContourFrame) 1409 { 1410 // FitToSize erstmal nicht mit ContourFrame 1411 SdrFitToSizeType eFit=GetFitToSize(); 1412 if (eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES) 1413 { 1414 sal_uIntPtr nStat=rOutliner.GetControlWord(); 1415 nStat|=EE_CNTRL_STRETCHING|EE_CNTRL_AUTOPAGESIZE; 1416 rOutliner.SetControlWord(nStat); 1417 } 1418 } 1419 rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue()); 1420 TakeTextRect(rOutliner, rTextRect, sal_False, &rAnchorRect); 1421 rPaintRect = rTextRect; 1422 1423 if (!bContourFrame) 1424 { 1425 // FitToSize erstmal nicht mit ContourFrame 1426 SdrFitToSizeType eFit=GetFitToSize(); 1427 if (eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES) 1428 { 1429 ImpSetCharStretching(rOutliner,rTextRect,rAnchorRect,rFitXKorreg); 1430 rPaintRect=rAnchorRect; 1431 } 1432 } 1433 } 1434 1435 void SdrTextObj::SetupOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaintRect ) const 1436 { 1437 ImpInitDrawOutliner( rOutl ); 1438 UpdateOutlinerFormatting( rOutl, rPaintRect ); 1439 } 1440 1441 void SdrTextObj::UpdateOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaintRect ) const 1442 { 1443 Rectangle aTextRect; 1444 Rectangle aAnchorRect; 1445 Fraction aFitXKorreg(1,1); 1446 1447 FASTBOOL bContourFrame=IsContourTextFrame(); 1448 1449 if( GetModel() ) 1450 { 1451 MapMode aMapMode(GetModel()->GetScaleUnit(), Point(0,0), 1452 GetModel()->GetScaleFraction(), 1453 GetModel()->GetScaleFraction()); 1454 rOutl.SetRefMapMode(aMapMode); 1455 } 1456 1457 ImpSetupDrawOutlinerForPaint( bContourFrame, rOutl, aTextRect, aAnchorRect, rPaintRect, aFitXKorreg ); 1458 } 1459 1460 //////////////////////////////////////////////////////////////////////////////////////////////////// 1461 1462 OutlinerParaObject* SdrTextObj::GetOutlinerParaObject() const 1463 { 1464 SdrText* pText = getActiveText(); 1465 if( pText ) 1466 return pText->GetOutlinerParaObject(); 1467 else 1468 return 0; 1469 } 1470 1471 bool SdrTextObj::HasOutlinerParaObject() const 1472 { 1473 SdrText* pText = getActiveText(); 1474 if( pText && pText->GetOutlinerParaObject() ) 1475 return true; 1476 return false; 1477 } 1478 1479 void SdrTextObj::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) 1480 { 1481 NbcSetOutlinerParaObjectForText( pTextObject, getActiveText() ); 1482 } 1483 1484 void SdrTextObj::NbcSetOutlinerParaObjectForText( OutlinerParaObject* pTextObject, SdrText* pText ) 1485 { 1486 if( pText ) 1487 pText->SetOutlinerParaObject( pTextObject ); 1488 1489 if( pText->GetOutlinerParaObject() ) 1490 { 1491 SvxWritingModeItem aWritingMode(pText->GetOutlinerParaObject()->IsVertical() 1492 ? com::sun::star::text::WritingMode_TB_RL 1493 : com::sun::star::text::WritingMode_LR_TB, 1494 SDRATTR_TEXTDIRECTION); 1495 GetProperties().SetObjectItemDirect(aWritingMode); 1496 } 1497 1498 SetTextSizeDirty(); 1499 if (IsTextFrame() && (IsAutoGrowHeight() || IsAutoGrowWidth())) 1500 { // Textrahmen anpassen! 1501 NbcAdjustTextFrameWidthAndHeight(); 1502 } 1503 if (!IsTextFrame()) 1504 { 1505 // Das SnapRect behaelt seine Groesse bei 1506 SetRectsDirty(sal_True); 1507 } 1508 1509 // always invalidate BoundRect on change 1510 SetBoundRectDirty(); 1511 ActionChanged(); 1512 1513 ImpSetTextStyleSheetListeners(); 1514 ImpCheckMasterCachable(); 1515 } 1516 1517 void SdrTextObj::NbcReformatText() 1518 { 1519 SdrText* pText = getActiveText(); 1520 if( pText && pText->GetOutlinerParaObject() ) 1521 { 1522 pText->ReformatText(); 1523 if (bTextFrame) 1524 { 1525 NbcAdjustTextFrameWidthAndHeight(); 1526 } 1527 else 1528 { 1529 // Das SnapRect behaelt seine Groesse bei 1530 SetBoundRectDirty(); 1531 SetRectsDirty(sal_True); 1532 } 1533 SetTextSizeDirty(); 1534 ActionChanged(); 1535 // FME, AW: i22396 1536 // Necessary here since we have no compare operator at the outliner 1537 // para object which may detect changes regarding the combination 1538 // of outliner para data and configuration (e.g., change of 1539 // formatting of text numerals) 1540 GetViewContact().flushViewObjectContacts(false); 1541 } 1542 } 1543 1544 void SdrTextObj::ReformatText() 1545 { 1546 if(GetOutlinerParaObject()) 1547 { 1548 Rectangle aBoundRect0; 1549 if (pUserCall!=NULL) 1550 aBoundRect0=GetLastBoundRect(); 1551 1552 // #110094#-14 SendRepaintBroadcast(); 1553 NbcReformatText(); 1554 SetChanged(); 1555 BroadcastObjectChange(); 1556 SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); 1557 } 1558 } 1559 1560 SdrObjGeoData* SdrTextObj::NewGeoData() const 1561 { 1562 return new SdrTextObjGeoData; 1563 } 1564 1565 void SdrTextObj::SaveGeoData(SdrObjGeoData& rGeo) const 1566 { 1567 SdrAttrObj::SaveGeoData(rGeo); 1568 SdrTextObjGeoData& rTGeo=(SdrTextObjGeoData&)rGeo; 1569 rTGeo.aRect =aRect; 1570 rTGeo.aGeo =aGeo; 1571 } 1572 1573 void SdrTextObj::RestGeoData(const SdrObjGeoData& rGeo) 1574 { // RectsDirty wird von SdrObject gerufen 1575 SdrAttrObj::RestGeoData(rGeo); 1576 SdrTextObjGeoData& rTGeo=(SdrTextObjGeoData&)rGeo; 1577 aRect =rTGeo.aRect; 1578 aGeo =rTGeo.aGeo; 1579 SetTextSizeDirty(); 1580 } 1581 1582 SdrFitToSizeType SdrTextObj::GetFitToSize() const 1583 { 1584 SdrFitToSizeType eType = SDRTEXTFIT_NONE; 1585 1586 if(!IsAutoGrowWidth()) 1587 eType = ((SdrTextFitToSizeTypeItem&)(GetObjectItem(SDRATTR_TEXT_FITTOSIZE))).GetValue(); 1588 1589 return eType; 1590 } 1591 1592 void SdrTextObj::ForceOutlinerParaObject() 1593 { 1594 SdrText* pText = getActiveText(); 1595 if( pText && (pText->GetOutlinerParaObject() == 0) ) 1596 { 1597 sal_uInt16 nOutlMode = OUTLINERMODE_TEXTOBJECT; 1598 if( IsTextFrame() && eTextKind == OBJ_OUTLINETEXT ) 1599 nOutlMode = OUTLINERMODE_OUTLINEOBJECT; 1600 1601 pText->ForceOutlinerParaObject( nOutlMode ); 1602 } 1603 } 1604 1605 sal_Bool SdrTextObj::IsVerticalWriting() const 1606 { 1607 // #89459# 1608 if(pEdtOutl) 1609 { 1610 return pEdtOutl->IsVertical(); 1611 } 1612 1613 OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); 1614 if(pOutlinerParaObject) 1615 { 1616 return pOutlinerParaObject->IsVertical(); 1617 } 1618 1619 return sal_False; 1620 } 1621 1622 void SdrTextObj::SetVerticalWriting(sal_Bool bVertical) 1623 { 1624 OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); 1625 if( !pOutlinerParaObject && bVertical ) 1626 { 1627 // we only need to force a outliner para object if the default of 1628 // horizontal text is changed 1629 ForceOutlinerParaObject(); 1630 pOutlinerParaObject = GetOutlinerParaObject(); 1631 } 1632 1633 if( pOutlinerParaObject && (pOutlinerParaObject->IsVertical() != (bool)bVertical) ) 1634 { 1635 // get item settings 1636 const SfxItemSet& rSet = GetObjectItemSet(); 1637 sal_Bool bAutoGrowWidth = ((SdrTextAutoGrowWidthItem&)rSet.Get(SDRATTR_TEXT_AUTOGROWWIDTH)).GetValue(); 1638 sal_Bool bAutoGrowHeight = ((SdrTextAutoGrowHeightItem&)rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue(); 1639 1640 // #103516# Also exchange hor/ver adjust items 1641 SdrTextHorzAdjust eHorz = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue(); 1642 SdrTextVertAdjust eVert = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue(); 1643 1644 // rescue object size 1645 Rectangle aObjectRect = GetSnapRect(); 1646 1647 // prepare ItemSet to set exchanged width and height items 1648 SfxItemSet aNewSet(*rSet.GetPool(), 1649 SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT, 1650 // #103516# Expanded item ranges to also support hor and ver adjust. 1651 SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST, 1652 SDRATTR_TEXT_AUTOGROWWIDTH, SDRATTR_TEXT_HORZADJUST, 1653 0, 0); 1654 1655 aNewSet.Put(rSet); 1656 aNewSet.Put(SdrTextAutoGrowWidthItem(bAutoGrowHeight)); 1657 aNewSet.Put(SdrTextAutoGrowHeightItem(bAutoGrowWidth)); 1658 1659 // #103516# Exchange horz and vert adjusts 1660 switch(eVert) 1661 { 1662 case SDRTEXTVERTADJUST_TOP: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); break; 1663 case SDRTEXTVERTADJUST_CENTER: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); break; 1664 case SDRTEXTVERTADJUST_BOTTOM: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); break; 1665 case SDRTEXTVERTADJUST_BLOCK: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); break; 1666 } 1667 switch(eHorz) 1668 { 1669 case SDRTEXTHORZADJUST_LEFT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM)); break; 1670 case SDRTEXTHORZADJUST_CENTER: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); break; 1671 case SDRTEXTHORZADJUST_RIGHT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); break; 1672 case SDRTEXTHORZADJUST_BLOCK: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); break; 1673 } 1674 1675 SetObjectItemSet(aNewSet); 1676 1677 pOutlinerParaObject = GetOutlinerParaObject(); 1678 if( pOutlinerParaObject ) 1679 { 1680 // set ParaObject orientation accordingly 1681 pOutlinerParaObject->SetVertical(bVertical); 1682 } 1683 1684 // restore object size 1685 SetSnapRect(aObjectRect); 1686 } 1687 } 1688 1689 //////////////////////////////////////////////////////////////////////////////////////////////////// 1690 // 1691 // transformation interface for StarOfficeAPI. This implements support for 1692 // homogen 3x3 matrices containing the transformation of the SdrObject. At the 1693 // moment it contains a shearX, rotation and translation, but for setting all linear 1694 // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported. 1695 // 1696 //////////////////////////////////////////////////////////////////////////////////////////////////// 1697 // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon 1698 // with the base geometry and returns TRUE. Otherwise it returns FALSE. 1699 sal_Bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const 1700 { 1701 // get turn and shear 1702 double fRotate = (aGeo.nDrehWink / 100.0) * F_PI180; 1703 double fShearX = (aGeo.nShearWink / 100.0) * F_PI180; 1704 1705 // get aRect, this is the unrotated snaprect 1706 Rectangle aRectangle(aRect); 1707 1708 // fill other values 1709 basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight()); 1710 basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top()); 1711 1712 // position maybe relative to anchorpos, convert 1713 if( pModel && pModel->IsWriter() ) 1714 { 1715 if(GetAnchorPos().X() || GetAnchorPos().Y()) 1716 { 1717 aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y()); 1718 } 1719 } 1720 1721 // force MapUnit to 100th mm 1722 const SfxMapUnit eMapUnit(GetObjectMapUnit()); 1723 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 1724 { 1725 switch(eMapUnit) 1726 { 1727 case SFX_MAPUNIT_TWIP : 1728 { 1729 // postion 1730 aTranslate.setX(ImplTwipsToMM(aTranslate.getX())); 1731 aTranslate.setY(ImplTwipsToMM(aTranslate.getY())); 1732 1733 // size 1734 aScale.setX(ImplTwipsToMM(aScale.getX())); 1735 aScale.setY(ImplTwipsToMM(aScale.getY())); 1736 1737 break; 1738 } 1739 default: 1740 { 1741 DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!"); 1742 } 1743 } 1744 } 1745 1746 // build matrix 1747 rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( 1748 aScale, 1749 basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX), 1750 basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate, 1751 aTranslate); 1752 1753 return sal_False; 1754 } 1755 1756 // sets the base geometry of the object using infos contained in the homogen 3x3 matrix. 1757 // If it's an SdrPathObj it will use the provided geometry information. The Polygon has 1758 // to use (0,0) as upper left and will be scaled to the given size in the matrix. 1759 void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/) 1760 { 1761 // break up matrix 1762 basegfx::B2DTuple aScale; 1763 basegfx::B2DTuple aTranslate; 1764 double fRotate(0.0); 1765 double fShearX(0.0); 1766 rMatrix.decompose(aScale, aTranslate, fRotate, fShearX); 1767 1768 // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings 1769 // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly 1770 if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0)) 1771 { 1772 aScale.setX(fabs(aScale.getX())); 1773 aScale.setY(fabs(aScale.getY())); 1774 fRotate = fmod(fRotate + F_PI, F_2PI); 1775 } 1776 1777 // reset object shear and rotations 1778 aGeo.nDrehWink = 0; 1779 aGeo.RecalcSinCos(); 1780 aGeo.nShearWink = 0; 1781 aGeo.RecalcTan(); 1782 1783 // force metric to pool metric 1784 const SfxMapUnit eMapUnit(GetObjectMapUnit()); 1785 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 1786 { 1787 switch(eMapUnit) 1788 { 1789 case SFX_MAPUNIT_TWIP : 1790 { 1791 // position 1792 aTranslate.setX(ImplMMToTwips(aTranslate.getX())); 1793 aTranslate.setY(ImplMMToTwips(aTranslate.getY())); 1794 1795 // size 1796 aScale.setX(ImplMMToTwips(aScale.getX())); 1797 aScale.setY(ImplMMToTwips(aScale.getY())); 1798 1799 break; 1800 } 1801 default: 1802 { 1803 DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!"); 1804 } 1805 } 1806 } 1807 1808 // if anchor is used, make position relative to it 1809 if( pModel && pModel->IsWriter() ) 1810 { 1811 if(GetAnchorPos().X() || GetAnchorPos().Y()) 1812 { 1813 aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y()); 1814 } 1815 } 1816 1817 // build and set BaseRect (use scale) 1818 Point aPoint = Point(); 1819 Size aSize(FRound(aScale.getX()), FRound(aScale.getY())); 1820 Rectangle aBaseRect(aPoint, aSize); 1821 SetSnapRect(aBaseRect); 1822 1823 // shear? 1824 if(!basegfx::fTools::equalZero(fShearX)) 1825 { 1826 GeoStat aGeoStat; 1827 aGeoStat.nShearWink = FRound((atan(fShearX) / F_PI180) * 100.0); 1828 aGeoStat.RecalcTan(); 1829 Shear(Point(), aGeoStat.nShearWink, aGeoStat.nTan, sal_False); 1830 } 1831 1832 // rotation? 1833 if(!basegfx::fTools::equalZero(fRotate)) 1834 { 1835 GeoStat aGeoStat; 1836 1837 // #i78696# 1838 // fRotate is matematically correct, but aGeoStat.nDrehWink is 1839 // mirrored -> mirror value here 1840 aGeoStat.nDrehWink = NormAngle360(FRound(-fRotate / F_PI18000)); 1841 aGeoStat.RecalcSinCos(); 1842 Rotate(Point(), aGeoStat.nDrehWink, aGeoStat.nSin, aGeoStat.nCos); 1843 } 1844 1845 // translate? 1846 if(!aTranslate.equalZero()) 1847 { 1848 Move(Size(FRound(aTranslate.getX()), FRound(aTranslate.getY()))); 1849 } 1850 } 1851 1852 bool SdrTextObj::IsRealyEdited() const 1853 { 1854 return pEdtOutl && pEdtOutl->IsModified(); 1855 } 1856 1857 ///////////////////////////////////////////////////////////////////////////////////////////////// 1858 // moved inlines here form hxx 1859 1860 long SdrTextObj::GetEckenradius() const 1861 { 1862 return ((SdrEckenradiusItem&)(GetObjectItemSet().Get(SDRATTR_ECKENRADIUS))).GetValue(); 1863 } 1864 1865 long SdrTextObj::GetMinTextFrameHeight() const 1866 { 1867 return ((SdrTextMinFrameHeightItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MINFRAMEHEIGHT))).GetValue(); 1868 } 1869 1870 long SdrTextObj::GetMaxTextFrameHeight() const 1871 { 1872 return ((SdrTextMaxFrameHeightItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MAXFRAMEHEIGHT))).GetValue(); 1873 } 1874 1875 long SdrTextObj::GetMinTextFrameWidth() const 1876 { 1877 return ((SdrTextMinFrameWidthItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MINFRAMEWIDTH))).GetValue(); 1878 } 1879 1880 long SdrTextObj::GetMaxTextFrameWidth() const 1881 { 1882 return ((SdrTextMaxFrameWidthItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MAXFRAMEWIDTH))).GetValue(); 1883 } 1884 1885 FASTBOOL SdrTextObj::IsFontwork() const 1886 { 1887 return (bTextFrame) ? sal_False // Default ist FALSE 1888 : ((XFormTextStyleItem&)(GetObjectItemSet().Get(XATTR_FORMTXTSTYLE))).GetValue()!=XFT_NONE; 1889 } 1890 1891 FASTBOOL SdrTextObj::IsHideContour() const 1892 { 1893 return (bTextFrame) ? sal_False // Default ist: Nein, kein HideContour; HideContour nicht bei TextFrames 1894 : ((XFormTextHideFormItem&)(GetObjectItemSet().Get(XATTR_FORMTXTHIDEFORM))).GetValue(); 1895 } 1896 1897 FASTBOOL SdrTextObj::IsContourTextFrame() const 1898 { 1899 return (bTextFrame) ? sal_False // ContourFrame nicht bei normalen TextFrames 1900 : ((SdrTextContourFrameItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_CONTOURFRAME))).GetValue(); 1901 } 1902 1903 long SdrTextObj::GetTextLeftDistance() const 1904 { 1905 return ((SdrTextLeftDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_LEFTDIST))).GetValue(); 1906 } 1907 1908 long SdrTextObj::GetTextRightDistance() const 1909 { 1910 return ((SdrTextRightDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_RIGHTDIST))).GetValue(); 1911 } 1912 1913 long SdrTextObj::GetTextUpperDistance() const 1914 { 1915 return ((SdrTextUpperDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_UPPERDIST))).GetValue(); 1916 } 1917 1918 long SdrTextObj::GetTextLowerDistance() const 1919 { 1920 return ((SdrTextLowerDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_LOWERDIST))).GetValue(); 1921 } 1922 1923 SdrTextAniKind SdrTextObj::GetTextAniKind() const 1924 { 1925 return ((SdrTextAniKindItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_ANIKIND))).GetValue(); 1926 } 1927 1928 SdrTextAniDirection SdrTextObj::GetTextAniDirection() const 1929 { 1930 return ((SdrTextAniDirectionItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue(); 1931 } 1932 1933 // #111096# 1934 // Access to thext hidden flag 1935 sal_Bool SdrTextObj::GetTextHidden() const 1936 { 1937 return mbTextHidden; 1938 } 1939 1940 void SdrTextObj::NbcSetTextHidden(sal_Bool bNew) 1941 { 1942 if(bNew != mbTextHidden) 1943 { 1944 mbTextHidden = bNew; 1945 } 1946 } 1947 1948 // #111096# 1949 // Get necessary data for text scroll animation. ATM base it on a Text-Metafile and a 1950 // painting rectangle. Rotation is excluded from the returned values. 1951 GDIMetaFile* SdrTextObj::GetTextScrollMetaFileAndRectangle( 1952 Rectangle& rScrollRectangle, Rectangle& rPaintRectangle) 1953 { 1954 GDIMetaFile* pRetval = 0L; 1955 SdrOutliner& rOutliner = ImpGetDrawOutliner(); 1956 Rectangle aTextRect; 1957 Rectangle aAnchorRect; 1958 Rectangle aPaintRect; 1959 Fraction aFitXKorreg(1,1); 1960 bool bContourFrame(IsContourTextFrame()); 1961 1962 // get outliner set up. To avoid getting a somehow rotated MetaFile, 1963 // temporarily disable object rotation. 1964 sal_Int32 nAngle(aGeo.nDrehWink); 1965 aGeo.nDrehWink = 0L; 1966 ImpSetupDrawOutlinerForPaint( bContourFrame, rOutliner, aTextRect, aAnchorRect, aPaintRect, aFitXKorreg ); 1967 aGeo.nDrehWink = nAngle; 1968 1969 Rectangle aScrollFrameRect(aPaintRect); 1970 const SfxItemSet& rSet = GetObjectItemSet(); 1971 SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue(); 1972 1973 if(SDRTEXTANI_LEFT == eDirection || SDRTEXTANI_RIGHT == eDirection) 1974 { 1975 aScrollFrameRect.Left() = aAnchorRect.Left(); 1976 aScrollFrameRect.Right() = aAnchorRect.Right(); 1977 } 1978 1979 if(SDRTEXTANI_UP == eDirection || SDRTEXTANI_DOWN == eDirection) 1980 { 1981 aScrollFrameRect.Top() = aAnchorRect.Top(); 1982 aScrollFrameRect.Bottom() = aAnchorRect.Bottom(); 1983 } 1984 1985 // create the MetaFile 1986 pRetval = new GDIMetaFile; 1987 VirtualDevice aBlackHole; 1988 aBlackHole.EnableOutput(sal_False); 1989 pRetval->Record(&aBlackHole); 1990 Point aPaintPos = aPaintRect.TopLeft(); 1991 1992 rOutliner.Draw(&aBlackHole, aPaintPos); 1993 1994 pRetval->Stop(); 1995 pRetval->WindStart(); 1996 1997 // return PaintRectanglePixel and pRetval; 1998 rScrollRectangle = aScrollFrameRect; 1999 rPaintRectangle = aPaintRect; 2000 2001 return pRetval; 2002 } 2003 2004 // #111096# 2005 // Access to TextAnimationAllowed flag 2006 bool SdrTextObj::IsTextAnimationAllowed() const 2007 { 2008 return mbTextAnimationAllowed; 2009 } 2010 2011 void SdrTextObj::SetTextAnimationAllowed(sal_Bool bNew) 2012 { 2013 if(mbTextAnimationAllowed != bNew) 2014 { 2015 mbTextAnimationAllowed = bNew; 2016 ActionChanged(); 2017 } 2018 } 2019 2020 /** called from the SdrObjEditView during text edit when the status of the edit outliner changes */ 2021 void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus ) 2022 { 2023 const sal_uInt32 nStat = pEditStatus->GetStatusWord(); 2024 const bool bGrowX=(nStat & EE_STAT_TEXTWIDTHCHANGED) !=0; 2025 const bool bGrowY=(nStat & EE_STAT_TEXTHEIGHTCHANGED) !=0; 2026 if(bTextFrame && (bGrowX || bGrowY)) 2027 { 2028 const bool bAutoGrowHgt= bTextFrame && IsAutoGrowHeight(); 2029 const bool bAutoGrowWdt= bTextFrame && IsAutoGrowWidth(); 2030 2031 if ((bGrowX && bAutoGrowWdt) || (bGrowY && bAutoGrowHgt)) 2032 { 2033 AdjustTextFrameWidthAndHeight(); 2034 } 2035 } 2036 } 2037 2038 /** returns the currently active text. */ 2039 SdrText* SdrTextObj::getActiveText() const 2040 { 2041 if( !mpText ) 2042 return getText( 0 ); 2043 else 2044 return mpText; 2045 } 2046 2047 /** returns the nth available text. */ 2048 SdrText* SdrTextObj::getText( sal_Int32 nIndex ) const 2049 { 2050 if( nIndex == 0 ) 2051 { 2052 if( mpText == 0 ) 2053 const_cast< SdrTextObj* >(this)->mpText = new SdrText( *(const_cast< SdrTextObj* >(this)) ); 2054 return mpText; 2055 } 2056 else 2057 { 2058 return 0; 2059 } 2060 } 2061 2062 /** returns the number of texts available for this object. */ 2063 sal_Int32 SdrTextObj::getTextCount() const 2064 { 2065 return 1; 2066 } 2067 2068 /** changes the current active text */ 2069 void SdrTextObj::setActiveText( sal_Int32 /*nIndex*/ ) 2070 { 2071 } 2072 2073 /** returns the index of the text that contains the given point or -1 */ 2074 sal_Int32 SdrTextObj::CheckTextHit(const Point& /*rPnt*/) const 2075 { 2076 return 0; 2077 } 2078 2079 void SdrTextObj::SetObjectItemNoBroadcast(const SfxPoolItem& rItem) 2080 { 2081 static_cast< sdr::properties::TextProperties& >(GetProperties()).SetObjectItemNoBroadcast(rItem); 2082 } 2083 2084 ///////////////////////////////////////////////////////////////////////////////////////////////// 2085 // 2086 // Konzept des TextObjekts: 2087 // ~~~~~~~~~~~~~~~~~~~~~~~~ 2088 // Attribute/Varianten: 2089 // - sal_Bool Textrahmen / beschriftetes Zeichenobjekt 2090 // - sal_Bool FontWork (wenn nicht Textrahmen und nicht ContourTextFrame) 2091 // - sal_Bool ContourTextFrame (wenn nicht Textrahmen und nicht Fontwork) 2092 // - long Drehwinkel (wenn nicht FontWork) 2093 // - long Textrahmenabstaende (wenn nicht FontWork) 2094 // - sal_Bool FitToSize (wenn nicht FontWork) 2095 // - sal_Bool AutoGrowingWidth/Height (wenn nicht FitToSize und nicht FontWork) 2096 // - long Min/MaxFrameWidth/Height (wenn AutoGrowingWidth/Height) 2097 // - enum Horizontale Textverankerung Links,Mitte,Rechts,Block,Stretch(ni) 2098 // - enum Vertikale Textverankerung Oben,Mitte,Unten,Block,Stretch(ni) 2099 // - enum Laufschrift (wenn nicht FontWork) 2100 // 2101 // Jedes abgeleitete Objekt ist entweder ein Textrahmen (bTextFrame=sal_True) 2102 // oder ein beschriftetes Zeichenobjekt (bTextFrame=sal_False). 2103 // 2104 // Defaultverankerung von Textrahmen: 2105 // SDRTEXTHORZADJUST_BLOCK, SDRTEXTVERTADJUST_TOP 2106 // = statische Pooldefaults 2107 // Defaultverankerung von beschrifteten Zeichenobjekten: 2108 // SDRTEXTHORZADJUST_CENTER, SDRTEXTVERTADJUST_CENTER 2109 // durch harte Attributierung von SdrAttrObj 2110 // 2111 // Jedes vom SdrTextObj abgeleitete Objekt muss ein "UnrotatedSnapRect" 2112 // (->TakeUnrotatedSnapRect()) liefern (Drehreferenz ist TopLeft dieses 2113 // Rechtecks (aGeo.nDrehWink)), welches die Grundlage der Textverankerung 2114 // bildet. Von diesem werden dann ringsum die Textrahmenabstaende abgezogen; 2115 // das Ergebnis ist der Ankerbereich (->TakeTextAnchorRect()). Innerhalb 2116 // dieses Bereichs wird dann in Abhaengigkeit von der horizontalen und 2117 // vertikalen Ausrichtung (SdrTextVertAdjust,SdrTextHorzAdjust) der Ankerpunkt 2118 // sowie der Ausgabebereich bestimmt. Bei beschrifteten Grafikobjekten kann 2119 // der Ausgabebereich durchaus groesser als der Ankerbereich werden, bei 2120 // Textrahmen ist er stets kleiner oder gleich (ausser bei negativen Textrahmen- 2121 // abstaenden). 2122 // 2123 // FitToSize hat Prioritaet vor Textverankerung und AutoGrowHeight/Width. Der 2124 // Ausgabebereich ist bei FitToSize immer genau der Ankerbereich. Weiterhin 2125 // gibt es bei FitToSize keinen automatischen Zeilenumbruch. 2126 // 2127 // ContourTextFrame: 2128 // - long Drehwinkel 2129 // - long Textrahmenabstaende spaeter vielleicht 2130 // - sal_Bool FitToSize spaeter vielleicht 2131 // - sal_Bool AutoGrowingWidth/Height viel spaeter vielleicht 2132 // - long Min/MaxFrameWidth/Height viel spaeter vielleicht 2133 // - enum Horizontale Textverankerung spaeter vielleicht, erstmal Links, Absatz zentr. 2134 // - enum Vertikale Textverankerung spaeter vielleicht, erstmal oben 2135 // - enum Laufschrift spaeter vielleicht (evtl. sogar mit korrektem Clipping) 2136 // 2137 // Bei Aenderungen zu beachten: 2138 // - Paint 2139 // - HitTest 2140 // - ConvertToPoly 2141 // - Edit 2142 // - Drucken,Speichern, Paint in Nachbarview waerend Edit 2143 // - ModelChanged (z.B. durch NachbarView oder Lineale) waerend Edit 2144 // - FillColorChanged waerend Edit 2145 // - uvm... 2146 // 2147 ///////////////////////////////////////////////////////////////////////////////////////////////// 2148 2149