1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svx/svdotext.hxx> 28cdf0e10cSrcweir #include "svx/svditext.hxx" 29cdf0e10cSrcweir #include <svx/svdtrans.hxx> 30cdf0e10cSrcweir #include <svx/svdogrp.hxx> 31cdf0e10cSrcweir #include <svx/svdopath.hxx> 32cdf0e10cSrcweir #include <svx/svdoutl.hxx> 33cdf0e10cSrcweir #include <svx/svdpage.hxx> // fuer Convert 34cdf0e10cSrcweir #include <svx/svdmodel.hxx> // fuer Convert 35cdf0e10cSrcweir #include <editeng/outliner.hxx> 36cdf0e10cSrcweir #include <svx/sdr/properties/itemsettools.hxx> 37cdf0e10cSrcweir #include <svx/sdr/properties/properties.hxx> 38cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx> 39cdf0e10cSrcweir #include <svl/itemset.hxx> 40cdf0e10cSrcweir #include <svx/svditer.hxx> 41cdf0e10cSrcweir #include <drawinglayer/processor2d/textaspolygonextractor2d.hxx> 42cdf0e10cSrcweir #include <svx/sdr/contact/viewcontact.hxx> 43cdf0e10cSrcweir #include <svx/xflclit.hxx> 44cdf0e10cSrcweir #include <svx/xlnclit.hxx> 45cdf0e10cSrcweir #include <svx/xlnwtit.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 48cdf0e10cSrcweir // 49cdf0e10cSrcweir // @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@ @@@@@ @@@@@@ 50cdf0e10cSrcweir // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ 51cdf0e10cSrcweir // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@ 52cdf0e10cSrcweir // @@ @@@@ @@@ @@ @@ @@ @@@@@ @@ 53cdf0e10cSrcweir // @@ @@ @@@@@ @@ @@ @@ @@ @@ @@ 54cdf0e10cSrcweir // @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@ 55cdf0e10cSrcweir // @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@ 56cdf0e10cSrcweir // 57cdf0e10cSrcweir // Transformationen 58cdf0e10cSrcweir // 59cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////////////////// 60cdf0e10cSrcweir 61cdf0e10cSrcweir void SdrTextObj::NbcSetSnapRect(const Rectangle& rRect) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) { 64cdf0e10cSrcweir Rectangle aSR0(GetSnapRect()); 65cdf0e10cSrcweir long nWdt0=aSR0.Right()-aSR0.Left(); 66cdf0e10cSrcweir long nHgt0=aSR0.Bottom()-aSR0.Top(); 67cdf0e10cSrcweir long nWdt1=rRect.Right()-rRect.Left(); 68cdf0e10cSrcweir long nHgt1=rRect.Bottom()-rRect.Top(); 69cdf0e10cSrcweir SdrTextObj::NbcResize(maSnapRect.TopLeft(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0)); 70cdf0e10cSrcweir SdrTextObj::NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top())); 71cdf0e10cSrcweir } else { 72cdf0e10cSrcweir long nHDist=GetTextLeftDistance()+GetTextRightDistance(); 73cdf0e10cSrcweir long nVDist=GetTextUpperDistance()+GetTextLowerDistance(); 74cdf0e10cSrcweir long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0; 75cdf0e10cSrcweir long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0; 76cdf0e10cSrcweir long nTWdt1=rRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0; 77cdf0e10cSrcweir long nTHgt1=rRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0; 78cdf0e10cSrcweir aRect=rRect; 79cdf0e10cSrcweir ImpJustifyRect(aRect); 80cdf0e10cSrcweir if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize())) { // #51139# 81cdf0e10cSrcweir if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1); 82cdf0e10cSrcweir if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1); 83cdf0e10cSrcweir if (GetFitToSize()==SDRTEXTFIT_RESIZEATTR) { 84cdf0e10cSrcweir NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0)); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir NbcAdjustTextFrameWidthAndHeight(); 87cdf0e10cSrcweir } 88cdf0e10cSrcweir ImpCheckShear(); 89cdf0e10cSrcweir SetRectsDirty(); 90cdf0e10cSrcweir } 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir const Rectangle& SdrTextObj::GetLogicRect() const 94cdf0e10cSrcweir { 95cdf0e10cSrcweir return aRect; 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir void SdrTextObj::NbcSetLogicRect(const Rectangle& rRect) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir long nHDist=GetTextLeftDistance()+GetTextRightDistance(); 101cdf0e10cSrcweir long nVDist=GetTextUpperDistance()+GetTextLowerDistance(); 102cdf0e10cSrcweir long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0; 103cdf0e10cSrcweir long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0; 104cdf0e10cSrcweir long nTWdt1=rRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0; 105cdf0e10cSrcweir long nTHgt1=rRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0; 106cdf0e10cSrcweir aRect=rRect; 107cdf0e10cSrcweir ImpJustifyRect(aRect); 108cdf0e10cSrcweir if (bTextFrame) { 109cdf0e10cSrcweir if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1); 110cdf0e10cSrcweir if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1); 111cdf0e10cSrcweir if (GetFitToSize()==SDRTEXTFIT_RESIZEATTR) { 112cdf0e10cSrcweir NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0)); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir NbcAdjustTextFrameWidthAndHeight(); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir SetRectsDirty(); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir long SdrTextObj::GetRotateAngle() const 120cdf0e10cSrcweir { 121cdf0e10cSrcweir return aGeo.nDrehWink; 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir long SdrTextObj::GetShearAngle(FASTBOOL /*bVertical*/) const 125cdf0e10cSrcweir { 126cdf0e10cSrcweir return aGeo.nShearWink; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir void SdrTextObj::NbcMove(const Size& rSiz) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir MoveRect(aRect,rSiz); 132cdf0e10cSrcweir MoveRect(aOutRect,rSiz); 133cdf0e10cSrcweir MoveRect(maSnapRect,rSiz); 134cdf0e10cSrcweir SetRectsDirty(sal_True); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir FASTBOOL bNoShearMerk=aGeo.nShearWink==0; 140cdf0e10cSrcweir FASTBOOL bRota90Merk=bNoShearMerk && aGeo.nDrehWink % 9000 ==0; 141cdf0e10cSrcweir long nHDist=GetTextLeftDistance()+GetTextRightDistance(); 142cdf0e10cSrcweir long nVDist=GetTextUpperDistance()+GetTextLowerDistance(); 143cdf0e10cSrcweir long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0; 144cdf0e10cSrcweir long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0; 145cdf0e10cSrcweir FASTBOOL bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); 146cdf0e10cSrcweir FASTBOOL bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); 147cdf0e10cSrcweir if (bXMirr || bYMirr) { 148cdf0e10cSrcweir Point aRef1(GetSnapRect().Center()); 149cdf0e10cSrcweir if (bXMirr) { 150cdf0e10cSrcweir Point aRef2(aRef1); 151cdf0e10cSrcweir aRef2.Y()++; 152cdf0e10cSrcweir NbcMirrorGluePoints(aRef1,aRef2); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir if (bYMirr) { 155cdf0e10cSrcweir Point aRef2(aRef1); 156cdf0e10cSrcweir aRef2.X()++; 157cdf0e10cSrcweir NbcMirrorGluePoints(aRef1,aRef2); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir if (aGeo.nDrehWink==0 && aGeo.nShearWink==0) { 162cdf0e10cSrcweir ResizeRect(aRect,rRef,xFact,yFact); 163cdf0e10cSrcweir if (bYMirr) { 164cdf0e10cSrcweir aRect.Justify(); 165cdf0e10cSrcweir aRect.Move(aRect.Right()-aRect.Left(),aRect.Bottom()-aRect.Top()); 166cdf0e10cSrcweir aGeo.nDrehWink=18000; 167cdf0e10cSrcweir aGeo.RecalcSinCos(); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir } 170cdf0e10cSrcweir else 171cdf0e10cSrcweir { 172cdf0e10cSrcweir // #100663# aRect is NOT initialized for lines (polgon objects with two 173cdf0e10cSrcweir // exceptionally handled points). Thus, after this call the text rotaion is 174cdf0e10cSrcweir // gone. This error must be present since day one of this old drawing layer. 175cdf0e10cSrcweir // It's astonishing that noone discovered it earlier. 176cdf0e10cSrcweir // Polygon aPol(Rect2Poly(aRect,aGeo)); 177cdf0e10cSrcweir // Polygon aPol(Rect2Poly(GetSnapRect(), aGeo)); 178cdf0e10cSrcweir 179cdf0e10cSrcweir // #101412# go back to old method, side effects are impossible 180cdf0e10cSrcweir // to calculate. 181cdf0e10cSrcweir Polygon aPol(Rect2Poly(aRect,aGeo)); 182cdf0e10cSrcweir 183cdf0e10cSrcweir for(sal_uInt16 a(0); a < aPol.GetSize(); a++) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir ResizePoint(aPol[a], rRef, xFact, yFact); 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir if(bXMirr != bYMirr) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir // Polygon wenden und etwas schieben 191cdf0e10cSrcweir Polygon aPol0(aPol); 192cdf0e10cSrcweir 193cdf0e10cSrcweir aPol[0] = aPol0[1]; 194cdf0e10cSrcweir aPol[1] = aPol0[0]; 195cdf0e10cSrcweir aPol[2] = aPol0[3]; 196cdf0e10cSrcweir aPol[3] = aPol0[2]; 197cdf0e10cSrcweir aPol[4] = aPol0[1]; 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir Poly2Rect(aPol, aRect, aGeo); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir if (bRota90Merk) { 204cdf0e10cSrcweir FASTBOOL bRota90=aGeo.nDrehWink % 9000 ==0; 205cdf0e10cSrcweir if (!bRota90) { // Scheinbar Rundungsfehler: Korregieren 206cdf0e10cSrcweir long a=NormAngle360(aGeo.nDrehWink); 207cdf0e10cSrcweir if (a<4500) a=0; 208cdf0e10cSrcweir else if (a<13500) a=9000; 209cdf0e10cSrcweir else if (a<22500) a=18000; 210cdf0e10cSrcweir else if (a<31500) a=27000; 211cdf0e10cSrcweir else a=0; 212cdf0e10cSrcweir aGeo.nDrehWink=a; 213cdf0e10cSrcweir aGeo.RecalcSinCos(); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir if (bNoShearMerk!=(aGeo.nShearWink==0)) { // Shear ggf. korregieren wg. Rundungsfehler 216cdf0e10cSrcweir aGeo.nShearWink=0; 217cdf0e10cSrcweir aGeo.RecalcTan(); 218cdf0e10cSrcweir } 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir ImpJustifyRect(aRect); 222cdf0e10cSrcweir long nTWdt1=aRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0; 223cdf0e10cSrcweir long nTHgt1=aRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0; 224cdf0e10cSrcweir if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize())) { // #51139# 225cdf0e10cSrcweir if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1); 226cdf0e10cSrcweir if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1); 227cdf0e10cSrcweir if (GetFitToSize()==SDRTEXTFIT_RESIZEATTR) { 228cdf0e10cSrcweir NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0)); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir NbcAdjustTextFrameWidthAndHeight(); 231cdf0e10cSrcweir } 232cdf0e10cSrcweir ImpCheckShear(); 233cdf0e10cSrcweir SetRectsDirty(); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir void SdrTextObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir SetGlueReallyAbsolute(sal_True); 239cdf0e10cSrcweir long dx=aRect.Right()-aRect.Left(); 240cdf0e10cSrcweir long dy=aRect.Bottom()-aRect.Top(); 241cdf0e10cSrcweir Point aP(aRect.TopLeft()); 242cdf0e10cSrcweir RotatePoint(aP,rRef,sn,cs); 243cdf0e10cSrcweir aRect.Left()=aP.X(); 244cdf0e10cSrcweir aRect.Top()=aP.Y(); 245cdf0e10cSrcweir aRect.Right()=aRect.Left()+dx; 246cdf0e10cSrcweir aRect.Bottom()=aRect.Top()+dy; 247cdf0e10cSrcweir if (aGeo.nDrehWink==0) { 248cdf0e10cSrcweir aGeo.nDrehWink=NormAngle360(nWink); 249cdf0e10cSrcweir aGeo.nSin=sn; 250cdf0e10cSrcweir aGeo.nCos=cs; 251cdf0e10cSrcweir } else { 252cdf0e10cSrcweir aGeo.nDrehWink=NormAngle360(aGeo.nDrehWink+nWink); 253cdf0e10cSrcweir aGeo.RecalcSinCos(); 254cdf0e10cSrcweir } 255cdf0e10cSrcweir SetRectsDirty(); 256cdf0e10cSrcweir NbcRotateGluePoints(rRef,nWink,sn,cs); 257cdf0e10cSrcweir SetGlueReallyAbsolute(sal_False); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir void SdrTextObj::NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir SetGlueReallyAbsolute(sal_True); 263cdf0e10cSrcweir 264cdf0e10cSrcweir // #75889# when this is a SdrPathObj aRect maybe not initialized 265cdf0e10cSrcweir Polygon aPol(Rect2Poly(aRect.IsEmpty() ? GetSnapRect() : aRect, aGeo)); 266cdf0e10cSrcweir 267cdf0e10cSrcweir sal_uInt16 nPointCount=aPol.GetSize(); 268cdf0e10cSrcweir for (sal_uInt16 i=0; i<nPointCount; i++) { 269cdf0e10cSrcweir ShearPoint(aPol[i],rRef,tn,bVShear); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir Poly2Rect(aPol,aRect,aGeo); 272cdf0e10cSrcweir ImpJustifyRect(aRect); 273cdf0e10cSrcweir if (bTextFrame) { 274cdf0e10cSrcweir NbcAdjustTextFrameWidthAndHeight(); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir ImpCheckShear(); 277cdf0e10cSrcweir SetRectsDirty(); 278cdf0e10cSrcweir NbcShearGluePoints(rRef,nWink,tn,bVShear); 279cdf0e10cSrcweir SetGlueReallyAbsolute(sal_False); 280cdf0e10cSrcweir } 281cdf0e10cSrcweir 282cdf0e10cSrcweir void SdrTextObj::NbcMirror(const Point& rRef1, const Point& rRef2) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir SetGlueReallyAbsolute(sal_True); 285cdf0e10cSrcweir FASTBOOL bNoShearMerk=aGeo.nShearWink==0; 286cdf0e10cSrcweir FASTBOOL bRota90Merk=sal_False; 287cdf0e10cSrcweir if (bNoShearMerk && 288cdf0e10cSrcweir (rRef1.X()==rRef2.X() || rRef1.Y()==rRef2.Y() || 289cdf0e10cSrcweir Abs(rRef1.X()-rRef2.X())==Abs(rRef1.Y()-rRef2.Y()))) { 290cdf0e10cSrcweir bRota90Merk=aGeo.nDrehWink % 9000 ==0; 291cdf0e10cSrcweir } 292cdf0e10cSrcweir Polygon aPol(Rect2Poly(aRect,aGeo)); 293cdf0e10cSrcweir sal_uInt16 i; 294cdf0e10cSrcweir sal_uInt16 nPntAnz=aPol.GetSize(); 295cdf0e10cSrcweir for (i=0; i<nPntAnz; i++) { 296cdf0e10cSrcweir MirrorPoint(aPol[i],rRef1,rRef2); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir // Polygon wenden und etwas schieben 299cdf0e10cSrcweir Polygon aPol0(aPol); 300cdf0e10cSrcweir aPol[0]=aPol0[1]; 301cdf0e10cSrcweir aPol[1]=aPol0[0]; 302cdf0e10cSrcweir aPol[2]=aPol0[3]; 303cdf0e10cSrcweir aPol[3]=aPol0[2]; 304cdf0e10cSrcweir aPol[4]=aPol0[1]; 305cdf0e10cSrcweir Poly2Rect(aPol,aRect,aGeo); 306cdf0e10cSrcweir 307cdf0e10cSrcweir if (bRota90Merk) { 308cdf0e10cSrcweir FASTBOOL bRota90=aGeo.nDrehWink % 9000 ==0; 309cdf0e10cSrcweir if (bRota90Merk && !bRota90) { // Scheinbar Rundungsfehler: Korregieren 310cdf0e10cSrcweir long a=NormAngle360(aGeo.nDrehWink); 311cdf0e10cSrcweir if (a<4500) a=0; 312cdf0e10cSrcweir else if (a<13500) a=9000; 313cdf0e10cSrcweir else if (a<22500) a=18000; 314cdf0e10cSrcweir else if (a<31500) a=27000; 315cdf0e10cSrcweir else a=0; 316cdf0e10cSrcweir aGeo.nDrehWink=a; 317cdf0e10cSrcweir aGeo.RecalcSinCos(); 318cdf0e10cSrcweir } 319cdf0e10cSrcweir } 320cdf0e10cSrcweir if (bNoShearMerk!=(aGeo.nShearWink==0)) { // Shear ggf. korregieren wg. Rundungsfehler 321cdf0e10cSrcweir aGeo.nShearWink=0; 322cdf0e10cSrcweir aGeo.RecalcTan(); 323cdf0e10cSrcweir } 324cdf0e10cSrcweir 325cdf0e10cSrcweir ImpJustifyRect(aRect); 326cdf0e10cSrcweir if (bTextFrame) { 327cdf0e10cSrcweir NbcAdjustTextFrameWidthAndHeight(); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir ImpCheckShear(); 330cdf0e10cSrcweir SetRectsDirty(); 331cdf0e10cSrcweir NbcMirrorGluePoints(rRef1,rRef2); 332cdf0e10cSrcweir SetGlueReallyAbsolute(sal_False); 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 336cdf0e10cSrcweir 337cdf0e10cSrcweir SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const 338cdf0e10cSrcweir { 339cdf0e10cSrcweir SdrObject* pRetval = 0; 340cdf0e10cSrcweir 341cdf0e10cSrcweir if(!ImpCanConvTextToCurve()) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir // suppress HelpTexts from PresObj's 344cdf0e10cSrcweir return 0; 345cdf0e10cSrcweir } 346cdf0e10cSrcweir 347cdf0e10cSrcweir // get primitives 348cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DSequence xSequence(GetViewContact().getViewIndependentPrimitive2DSequence()); 349cdf0e10cSrcweir 350cdf0e10cSrcweir if(xSequence.hasElements()) 351cdf0e10cSrcweir { 352cdf0e10cSrcweir // create an extractor with neutral ViewInformation 353cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation2D aViewInformation2D; 354cdf0e10cSrcweir drawinglayer::processor2d::TextAsPolygonExtractor2D aExtractor(aViewInformation2D); 355cdf0e10cSrcweir 356cdf0e10cSrcweir // extract text as polygons 357cdf0e10cSrcweir aExtractor.process(xSequence); 358cdf0e10cSrcweir 359cdf0e10cSrcweir // get results 360cdf0e10cSrcweir const drawinglayer::processor2d::TextAsPolygonDataNodeVector& rResult = aExtractor.getTarget(); 361cdf0e10cSrcweir const sal_uInt32 nResultCount(rResult.size()); 362cdf0e10cSrcweir 363cdf0e10cSrcweir if(nResultCount) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir // prepare own target 366cdf0e10cSrcweir SdrObjGroup* pGroup = new SdrObjGroup(); 367cdf0e10cSrcweir SdrObjList* pObjectList = pGroup->GetSubList(); 368cdf0e10cSrcweir 369cdf0e10cSrcweir // process results 370cdf0e10cSrcweir for(sal_uInt32 a(0); a < nResultCount; a++) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir const drawinglayer::processor2d::TextAsPolygonDataNode& rCandidate = rResult[a]; 373cdf0e10cSrcweir basegfx::B2DPolyPolygon aPolyPolygon(rCandidate.getB2DPolyPolygon()); 374cdf0e10cSrcweir 375cdf0e10cSrcweir if(aPolyPolygon.count()) 376cdf0e10cSrcweir { 377cdf0e10cSrcweir // take care of wanted polygon type 378cdf0e10cSrcweir if(bToPoly) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir if(aPolyPolygon.areControlPointsUsed()) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir aPolyPolygon = basegfx::tools::adaptiveSubdivideByAngle(aPolyPolygon); 383cdf0e10cSrcweir } 384cdf0e10cSrcweir } 385cdf0e10cSrcweir else 386cdf0e10cSrcweir { 387cdf0e10cSrcweir if(!aPolyPolygon.areControlPointsUsed()) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir aPolyPolygon = basegfx::tools::expandToCurve(aPolyPolygon); 390cdf0e10cSrcweir } 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393cdf0e10cSrcweir // create ItemSet with object attributes 394cdf0e10cSrcweir SfxItemSet aAttributeSet(GetObjectItemSet()); 395cdf0e10cSrcweir SdrPathObj* pPathObj = 0; 396cdf0e10cSrcweir 397cdf0e10cSrcweir // always clear objectshadow; this is included in the extraction 398cdf0e10cSrcweir aAttributeSet.Put(SdrShadowItem(false)); 399cdf0e10cSrcweir 400cdf0e10cSrcweir if(rCandidate.getIsFilled()) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir // set needed items 403cdf0e10cSrcweir aAttributeSet.Put(XFillColorItem(String(), Color(rCandidate.getBColor()))); 404cdf0e10cSrcweir aAttributeSet.Put(XLineStyleItem(XLINE_NONE)); 405cdf0e10cSrcweir aAttributeSet.Put(XFillStyleItem(XFILL_SOLID)); 406cdf0e10cSrcweir 407cdf0e10cSrcweir // create filled SdrPathObj 408cdf0e10cSrcweir pPathObj = new SdrPathObj(OBJ_PATHFILL, aPolyPolygon); 409cdf0e10cSrcweir } 410cdf0e10cSrcweir else 411cdf0e10cSrcweir { 412cdf0e10cSrcweir // set needed items 413cdf0e10cSrcweir aAttributeSet.Put(XLineColorItem(String(), Color(rCandidate.getBColor()))); 414cdf0e10cSrcweir aAttributeSet.Put(XLineStyleItem(XLINE_SOLID)); 415cdf0e10cSrcweir aAttributeSet.Put(XLineWidthItem(0)); 416cdf0e10cSrcweir aAttributeSet.Put(XFillStyleItem(XFILL_NONE)); 417cdf0e10cSrcweir 418cdf0e10cSrcweir // create line SdrPathObj 419cdf0e10cSrcweir pPathObj = new SdrPathObj(OBJ_PATHLINE, aPolyPolygon); 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir // copy basic information from original 423cdf0e10cSrcweir pPathObj->ImpSetAnchorPos(GetAnchorPos()); 424cdf0e10cSrcweir pPathObj->NbcSetLayer(GetLayer()); 425cdf0e10cSrcweir 426cdf0e10cSrcweir if(GetModel()) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir pPathObj->SetModel(GetModel()); 429cdf0e10cSrcweir pPathObj->NbcSetStyleSheet(GetStyleSheet(), true); 430cdf0e10cSrcweir } 431cdf0e10cSrcweir 432cdf0e10cSrcweir // apply prepared ItemSet and add to target 433cdf0e10cSrcweir pPathObj->SetMergedItemSet(aAttributeSet); 434cdf0e10cSrcweir pObjectList->InsertObject(pPathObj); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir // postprocess; if no result and/or only one object, simplify 439cdf0e10cSrcweir if(!pObjectList->GetObjCount()) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir delete pGroup; 442cdf0e10cSrcweir } 443cdf0e10cSrcweir else if(1 == pObjectList->GetObjCount()) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir pRetval = pObjectList->RemoveObject(0); 446cdf0e10cSrcweir delete pGroup; 447cdf0e10cSrcweir } 448cdf0e10cSrcweir else 449cdf0e10cSrcweir { 450cdf0e10cSrcweir pRetval = pGroup; 451cdf0e10cSrcweir } 452cdf0e10cSrcweir } 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir return pRetval; 456cdf0e10cSrcweir } 457cdf0e10cSrcweir 458cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 459cdf0e10cSrcweir 460a5258243SPedro Giffuni SdrObject* SdrTextObj::DoConvertToPolyObj(sal_Bool bBezier, bool bAddText) const 461a5258243SPedro Giffuni { 462a5258243SPedro Giffuni if(bAddText) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir return ImpConvertContainedTextToSdrPathObjs(!bBezier); 465cdf0e10cSrcweir } 466cdf0e10cSrcweir 467a5258243SPedro Giffuni return 0; 468a5258243SPedro Giffuni } 469a5258243SPedro Giffuni 470cdf0e10cSrcweir bool SdrTextObj::ImpCanConvTextToCurve() const 471cdf0e10cSrcweir { 472cdf0e10cSrcweir return !IsOutlText(); 473cdf0e10cSrcweir } 474cdf0e10cSrcweir 475cdf0e10cSrcweir SdrObject* SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPolygon, sal_Bool bClosed, sal_Bool bBezier, sal_Bool bNoSetAttr) const 476cdf0e10cSrcweir { 477cdf0e10cSrcweir SdrObjKind ePathKind = bClosed ? OBJ_PATHFILL : OBJ_PATHLINE; 478cdf0e10cSrcweir basegfx::B2DPolyPolygon aB2DPolyPolygon(rPolyPolygon); 479cdf0e10cSrcweir 480cdf0e10cSrcweir // #i37011# 481cdf0e10cSrcweir if(!bBezier) 482cdf0e10cSrcweir { 483cdf0e10cSrcweir aB2DPolyPolygon = basegfx::tools::adaptiveSubdivideByAngle(aB2DPolyPolygon); 484cdf0e10cSrcweir ePathKind = bClosed ? OBJ_POLY : OBJ_PLIN; 485cdf0e10cSrcweir } 486cdf0e10cSrcweir 487cdf0e10cSrcweir SdrPathObj* pPathObj = new SdrPathObj(ePathKind, aB2DPolyPolygon); 488cdf0e10cSrcweir 489cdf0e10cSrcweir if(bBezier) 490cdf0e10cSrcweir { 491cdf0e10cSrcweir // create bezier curves 492cdf0e10cSrcweir pPathObj->SetPathPoly(basegfx::tools::expandToCurve(pPathObj->GetPathPoly())); 493cdf0e10cSrcweir } 494cdf0e10cSrcweir 495cdf0e10cSrcweir if(pPathObj) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir pPathObj->ImpSetAnchorPos(aAnchor); 498cdf0e10cSrcweir pPathObj->NbcSetLayer(SdrLayerID(GetLayer())); 499cdf0e10cSrcweir 500cdf0e10cSrcweir if(pModel) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir pPathObj->SetModel(pModel); 503cdf0e10cSrcweir 504cdf0e10cSrcweir if(!bNoSetAttr) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir sdr::properties::ItemChangeBroadcaster aC(*pPathObj); 507cdf0e10cSrcweir 508cdf0e10cSrcweir pPathObj->ClearMergedItem(); 509cdf0e10cSrcweir pPathObj->SetMergedItemSet(GetObjectItemSet()); 510cdf0e10cSrcweir pPathObj->GetProperties().BroadcastItemChange(aC); 511cdf0e10cSrcweir pPathObj->NbcSetStyleSheet(GetStyleSheet(), sal_True); 512cdf0e10cSrcweir } 513cdf0e10cSrcweir } 514cdf0e10cSrcweir } 515cdf0e10cSrcweir 516cdf0e10cSrcweir return pPathObj; 517cdf0e10cSrcweir } 518cdf0e10cSrcweir 519cdf0e10cSrcweir SdrObject* SdrTextObj::ImpConvertAddText(SdrObject* pObj, FASTBOOL bBezier) const 520cdf0e10cSrcweir { 521cdf0e10cSrcweir if(!ImpCanConvTextToCurve()) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir return pObj; 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir SdrObject* pText = ImpConvertContainedTextToSdrPathObjs(!bBezier); 527cdf0e10cSrcweir 528cdf0e10cSrcweir if(!pText) 529cdf0e10cSrcweir { 530cdf0e10cSrcweir return pObj; 531cdf0e10cSrcweir } 532cdf0e10cSrcweir 533cdf0e10cSrcweir if(!pObj) 534cdf0e10cSrcweir { 535cdf0e10cSrcweir return pText; 536cdf0e10cSrcweir } 537cdf0e10cSrcweir 538cdf0e10cSrcweir if(pText->IsGroupObject()) 539cdf0e10cSrcweir { 540cdf0e10cSrcweir // is already group object, add partial shape in front 541cdf0e10cSrcweir SdrObjList* pOL=pText->GetSubList(); 542cdf0e10cSrcweir pOL->InsertObject(pObj,0); 543cdf0e10cSrcweir 544cdf0e10cSrcweir return pText; 545cdf0e10cSrcweir } 546cdf0e10cSrcweir else 547cdf0e10cSrcweir { 548cdf0e10cSrcweir // not yet a group, create one and add partial and new shapes 549cdf0e10cSrcweir SdrObjGroup* pGrp=new SdrObjGroup; 550cdf0e10cSrcweir SdrObjList* pOL=pGrp->GetSubList(); 551cdf0e10cSrcweir pOL->InsertObject(pObj); 552cdf0e10cSrcweir pOL->InsertObject(pText); 553cdf0e10cSrcweir 554cdf0e10cSrcweir return pGrp; 555cdf0e10cSrcweir } 556cdf0e10cSrcweir } 557cdf0e10cSrcweir 558cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 559cdf0e10cSrcweir // eof 560