LibreOffice Module svx (master)  1
svdotextpathdecomposition.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <sal/config.h>
21 
22 #include <o3tl/safeint.hxx>
23 #include <svx/svdotext.hxx>
24 #include <svx/svdoutl.hxx>
29 #include <algorithm>
30 #include <com/sun/star/i18n/ScriptType.hpp>
31 #include <com/sun/star/i18n/BreakIterator.hpp>
33 #include <com/sun/star/i18n/CharacterIteratorMode.hpp>
36 #include <basegfx/color/bcolor.hxx>
37 
38 
39 // primitive decomposition helpers
40 
44 #include <svx/unoapi.hxx>
47 
48 
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::lang;
51 using namespace ::com::sun::star::i18n;
52 
53 
54 // PathTextPortion helper
55 
56 namespace
57 {
58  class impPathTextPortion
59  {
60  basegfx::B2DVector maOffset;
61  OUString maText;
62  sal_Int32 mnTextStart;
63  sal_Int32 mnTextLength;
64  sal_Int32 mnParagraph;
65  SvxFont maFont;
66  ::std::vector< double > maDblDXArray; // double DXArray, font size independent -> unit coordinate system
67  css::lang::Locale maLocale;
68 
69  bool mbRTL : 1;
70 
71  public:
72  explicit impPathTextPortion(DrawPortionInfo& rInfo)
73  : maOffset(rInfo.mrStartPos.X(), rInfo.mrStartPos.Y()),
74  maText(rInfo.maText),
75  mnTextStart(rInfo.mnTextStart),
76  mnTextLength(rInfo.mnTextLen),
77  mnParagraph(rInfo.mnPara),
78  maFont(rInfo.mrFont),
79  maDblDXArray(),
80  maLocale(rInfo.mpLocale ? *rInfo.mpLocale : css::lang::Locale()),
81  mbRTL(!rInfo.mrFont.IsVertical() && rInfo.IsRTL())
82  {
83  if(mnTextLength && rInfo.mpDXArray)
84  {
85  maDblDXArray.reserve(mnTextLength);
86 
87  for(sal_Int32 a=0; a < mnTextLength; a++)
88  {
89  maDblDXArray.push_back(static_cast<double>(rInfo.mpDXArray[a]));
90  }
91  }
92  }
93 
94  // for ::std::sort
95  bool operator<(const impPathTextPortion& rComp) const
96  {
97  if(mnParagraph < rComp.mnParagraph)
98  {
99  return true;
100  }
101 
102  if(maOffset.getX() < rComp.maOffset.getX())
103  {
104  return true;
105  }
106 
107  return (maOffset.getY() < rComp.maOffset.getY());
108  }
109 
110  const OUString& getText() const { return maText; }
111  sal_Int32 getTextStart() const { return mnTextStart; }
112  sal_Int32 getTextLength() const { return mnTextLength; }
113  sal_Int32 getParagraph() const { return mnParagraph; }
114  const SvxFont& getFont() const { return maFont; }
115  bool isRTL() const { return mbRTL; }
116  const ::std::vector< double >& getDoubleDXArray() const { return maDblDXArray; }
117  const css::lang::Locale& getLocale() const { return maLocale; }
118 
119  sal_Int32 getPortionIndex(sal_Int32 nIndex, sal_Int32 nLength) const
120  {
121  if(mbRTL)
122  {
123  return (mnTextStart + (mnTextLength - (nIndex + nLength)));
124  }
125  else
126  {
127  return (mnTextStart + nIndex);
128  }
129  }
130 
131  double getDisplayLength(sal_Int32 nIndex, sal_Int32 nLength) const
132  {
134  double fRetval(0.0);
135 
136  if(maFont.IsVertical())
137  {
138  fRetval = aTextLayouter.getTextHeight() * static_cast<double>(nLength);
139  }
140  else
141  {
142  fRetval = aTextLayouter.getTextWidth(maText, getPortionIndex(nIndex, nLength), nLength);
143  }
144 
145  return fRetval;
146  }
147  };
148 } // end of anonymous namespace
149 
150 
151 // TextBreakup helper
152 
153 namespace
154 {
155  class impTextBreakupHandler
156  {
157  SdrOutliner& mrOutliner;
158  ::std::vector< impPathTextPortion > maPathTextPortions;
159 
160  DECL_LINK(decompositionPathTextPrimitive, DrawPortionInfo*, void );
161 
162  public:
163  explicit impTextBreakupHandler(SdrOutliner& rOutliner)
164  : mrOutliner(rOutliner)
165  {
166  }
167 
168  const ::std::vector< impPathTextPortion >& decompositionPathTextPrimitive()
169  {
170  // strip portions to maPathTextPortions
171  mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decompositionPathTextPrimitive));
172  mrOutliner.StripPortions();
173 
174  if(!maPathTextPortions.empty())
175  {
176  // sort portions by paragraph, x and y
177  ::std::sort(maPathTextPortions.begin(), maPathTextPortions.end());
178  }
179 
180  return maPathTextPortions;
181  }
182  };
183 
184  IMPL_LINK(impTextBreakupHandler, decompositionPathTextPrimitive, DrawPortionInfo*, pInfo, void)
185  {
186  maPathTextPortions.emplace_back(*pInfo);
187  }
188 } // end of anonymous namespace
189 
190 
191 // TextBreakup one poly and one paragraph helper
192 
193 namespace
194 {
195  class impPolygonParagraphHandler
196  {
197  const drawinglayer::attribute::SdrFormTextAttribute maSdrFormTextAttribute; // FormText parameters
198  std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& mrDecomposition; // destination primitive list
199  std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& mrShadowDecomposition; // destination primitive list for shadow
200  Reference < css::i18n::XBreakIterator > mxBreak; // break iterator
201 
202  static double getParagraphTextLength(const ::std::vector< const impPathTextPortion* >& rTextPortions)
203  {
205  double fRetval(0.0);
206 
207  for(const impPathTextPortion* pCandidate : rTextPortions)
208  {
209  if(pCandidate && pCandidate->getTextLength())
210  {
211  aTextLayouter.setFont(pCandidate->getFont());
212  fRetval += pCandidate->getDisplayLength(0, pCandidate->getTextLength());
213  }
214  }
215 
216  return fRetval;
217  }
218 
219  sal_Int32 getNextGlyphLen(const impPathTextPortion* pCandidate, sal_Int32 nPosition, const css::lang::Locale& rFontLocale)
220  {
221  sal_Int32 nNextGlyphLen(1);
222 
223  if(mxBreak.is())
224  {
225  sal_Int32 nDone(0);
226  nNextGlyphLen = mxBreak->nextCharacters(pCandidate->getText(), nPosition,
227  rFontLocale, CharacterIteratorMode::SKIPCELL, 1, nDone) - nPosition;
228  }
229 
230  return nNextGlyphLen;
231  }
232 
233  public:
234  impPolygonParagraphHandler(
235  const drawinglayer::attribute::SdrFormTextAttribute& rSdrFormTextAttribute,
236  std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rDecomposition,
237  std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rShadowDecomposition)
238  : maSdrFormTextAttribute(rSdrFormTextAttribute),
239  mrDecomposition(rDecomposition),
240  mrShadowDecomposition(rShadowDecomposition)
241  {
242  // prepare BreakIterator
243  Reference < XComponentContext > xContext = ::comphelper::getProcessComponentContext();
244  mxBreak = css::i18n::BreakIterator::create(xContext);
245  }
246 
247  void HandlePair(const basegfx::B2DPolygon& rPolygonCandidate, const ::std::vector< const impPathTextPortion* >& rTextPortions)
248  {
249  // prepare polygon geometry, take into account as many parameters as possible
250  basegfx::B2DPolygon aPolygonCandidate(rPolygonCandidate);
251  const double fPolyLength(basegfx::utils::getLength(aPolygonCandidate));
252  double fPolyEnd(fPolyLength);
253  double fPolyStart(0.0);
254  double fAutosizeScaleFactor(1.0);
255  bool bAutosizeScale(false);
256 
257  if(maSdrFormTextAttribute.getFormTextMirror())
258  {
259  aPolygonCandidate.flip();
260  }
261 
262  if(maSdrFormTextAttribute.getFormTextStart()
263  && (XFormTextAdjust::Left == maSdrFormTextAttribute.getFormTextAdjust()
264  || XFormTextAdjust::Right == maSdrFormTextAttribute.getFormTextAdjust()))
265  {
266  if(XFormTextAdjust::Left == maSdrFormTextAttribute.getFormTextAdjust())
267  {
268  fPolyStart += maSdrFormTextAttribute.getFormTextStart();
269 
270  if(fPolyStart > fPolyEnd)
271  {
272  fPolyStart = fPolyEnd;
273  }
274  }
275  else
276  {
277  fPolyEnd -= maSdrFormTextAttribute.getFormTextStart();
278 
279  if(fPolyEnd < fPolyStart)
280  {
281  fPolyEnd = fPolyStart;
282  }
283  }
284  }
285 
286  if(XFormTextAdjust::Left != maSdrFormTextAttribute.getFormTextAdjust())
287  {
288  // calculate total text length of this paragraph, some layout needs to be done
289  const double fParagraphTextLength(getParagraphTextLength(rTextPortions));
290 
291  // check if text is too long for paragraph. If yes, handle as if left aligned (default),
292  // but still take care of XFormTextAdjust::AutoSize in that case
293  const bool bTextTooLong(fParagraphTextLength > (fPolyEnd - fPolyStart));
294 
295  if(XFormTextAdjust::Right == maSdrFormTextAttribute.getFormTextAdjust())
296  {
297  if(!bTextTooLong)
298  {
299  // if right aligned, add difference to polygon start
300  fPolyStart += ((fPolyEnd - fPolyStart) - fParagraphTextLength);
301  }
302  }
303  else if(XFormTextAdjust::Center == maSdrFormTextAttribute.getFormTextAdjust())
304  {
305  if(!bTextTooLong)
306  {
307  // if centered, add half of difference to polygon start
308  fPolyStart += ((fPolyEnd - fPolyStart) - fParagraphTextLength) / 2.0;
309  }
310  }
311  else if(XFormTextAdjust::AutoSize == maSdrFormTextAttribute.getFormTextAdjust())
312  {
313  // if scale, prepare scale factor between curve length and text length
314  if(0.0 != fParagraphTextLength)
315  {
316  fAutosizeScaleFactor = (fPolyEnd - fPolyStart) / fParagraphTextLength;
317  bAutosizeScale = true;
318  }
319  }
320  }
321 
322  // handle text portions for this paragraph
323  for(auto a = rTextPortions.begin(); a != rTextPortions.end() && fPolyStart < fPolyEnd; ++a)
324  {
325  const impPathTextPortion* pCandidate = *a;
326  basegfx::B2DVector aFontScaling;
327 
328  if(pCandidate && pCandidate->getTextLength())
329  {
330  const drawinglayer::attribute::FontAttribute aCandidateFontAttribute(
332  aFontScaling,
333  pCandidate->getFont(),
334  pCandidate->isRTL(),
335  false));
336 
338  aTextLayouter.setFont(pCandidate->getFont());
339  sal_Int32 nUsedTextLength(0);
340 
341  while(nUsedTextLength < pCandidate->getTextLength() && fPolyStart < fPolyEnd)
342  {
343  sal_Int32 nNextGlyphLen(getNextGlyphLen(pCandidate, pCandidate->getTextStart() + nUsedTextLength, pCandidate->getLocale()));
344 
345  // prepare portion length. Takes RTL sections into account.
346  double fPortionLength(pCandidate->getDisplayLength(nUsedTextLength, nNextGlyphLen));
347 
348  if(bAutosizeScale)
349  {
350  // when autosize scaling, expand portion length
351  fPortionLength *= fAutosizeScaleFactor;
352  }
353 
354  // create transformation
355  basegfx::B2DHomMatrix aNewTransformA, aNewTransformB, aNewShadowTransform;
356  basegfx::B2DPoint aStartPos(basegfx::utils::getPositionAbsolute(aPolygonCandidate, fPolyStart, fPolyLength));
357  basegfx::B2DPoint aEndPos(aStartPos);
358 
359  // add font scaling
360  aNewTransformA.scale(aFontScaling.getX(), aFontScaling.getY());
361 
362  // prepare scaling of text primitive
363  if(bAutosizeScale)
364  {
365  // when autosize scaling, expand text primitive scaling to it
366  aNewTransformA.scale(fAutosizeScaleFactor, fAutosizeScaleFactor);
367  }
368 
369  // eventually create shadow primitives from aDecomposition and add to rDecomposition
370  const bool bShadow(XFormTextShadow::NONE != maSdrFormTextAttribute.getFormTextShadow());
371 
372  if(bShadow)
373  {
374  if(XFormTextShadow::Normal == maSdrFormTextAttribute.getFormTextShadow())
375  {
376  aNewShadowTransform.translate(
377  maSdrFormTextAttribute.getFormTextShdwXVal(),
378  -maSdrFormTextAttribute.getFormTextShdwYVal());
379  }
380  else // XFormTextShadow::Slant
381  {
382  double fScaleValue(maSdrFormTextAttribute.getFormTextShdwYVal() / 100.0);
383  double fShearValue(-maSdrFormTextAttribute.getFormTextShdwXVal() * F_PI1800);
384 
385  aNewShadowTransform.scale(1.0, fScaleValue);
386  aNewShadowTransform.shearX(sin(fShearValue));
387  aNewShadowTransform.scale(1.0, cos(fShearValue));
388  }
389  }
390 
391  switch(maSdrFormTextAttribute.getFormTextStyle())
392  {
394  {
395  aEndPos = basegfx::utils::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
396  const basegfx::B2DVector aDirection(aEndPos - aStartPos);
397  aNewTransformB.rotate(atan2(aDirection.getY(), aDirection.getX()));
398  aNewTransformB.translate(aStartPos.getX(), aStartPos.getY());
399 
400  break;
401  }
403  {
404  aNewTransformB.translate(aStartPos.getX() - (fPortionLength / 2.0), aStartPos.getY());
405 
406  break;
407  }
409  {
410  aEndPos = basegfx::utils::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
411  const basegfx::B2DVector aDirection(aEndPos - aStartPos);
412  const double fShearValue(atan2(aDirection.getY(), aDirection.getX()));
413  const double fSin(sin(fShearValue));
414  const double fCos(cos(fShearValue));
415 
416  aNewTransformB.shearX(-fSin);
417 
418  // Scale may lead to objects without height since fCos == 0.0 is possible.
419  // Renderers need to handle that, it's not a forbidden value and does not
420  // need to be avoided
421  aNewTransformB.scale(1.0, fCos);
422  aNewTransformB.translate(aStartPos.getX() - (fPortionLength / 2.0), aStartPos.getY());
423 
424  break;
425  }
427  {
428  aEndPos = basegfx::utils::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
429  const basegfx::B2DVector aDirection(aEndPos - aStartPos);
430  const double fShearValue(atan2(aDirection.getY(), aDirection.getX()));
431  const double fCos(cos(fShearValue));
432  const double fTan(tan(fShearValue));
433 
434  // shear to 'stand' on the curve
435  aNewTransformB.shearY(fTan);
436 
437  // scale in X to make as tight as needed. As with XFT_SLANT_X, this may
438  // lead to primitives without width which the renderers will handle
439  aNewTransformA.scale(fCos, 1.0);
440 
441  aNewTransformB.translate(aStartPos.getX(), aStartPos.getY());
442 
443  break;
444  }
445  default : break; // XFormTextStyle::NONE
446  }
447 
448  // distance from path?
449  if(maSdrFormTextAttribute.getFormTextDistance())
450  {
451  if(aEndPos.equal(aStartPos))
452  {
453  aEndPos = basegfx::utils::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
454  }
455 
456  // use back vector (aStartPos - aEndPos) here to get mirrored perpendicular as in old stuff
457  const basegfx::B2DVector aPerpendicular(
458  basegfx::getNormalizedPerpendicular(aStartPos - aEndPos) *
459  maSdrFormTextAttribute.getFormTextDistance());
460  aNewTransformB.translate(aPerpendicular.getX(), aPerpendicular.getY());
461  }
462 
463  if(!pCandidate->getText().isEmpty() && nNextGlyphLen)
464  {
465  const sal_Int32 nPortionIndex(pCandidate->getPortionIndex(nUsedTextLength, nNextGlyphLen));
466  ::std::vector< double > aNewDXArray;
467 
468  if(nNextGlyphLen > 1 && !pCandidate->getDoubleDXArray().empty())
469  {
470  // copy DXArray for portion
471  aNewDXArray.insert(
472  aNewDXArray.begin(),
473  pCandidate->getDoubleDXArray().begin() + nPortionIndex,
474  pCandidate->getDoubleDXArray().begin() + (nPortionIndex + nNextGlyphLen));
475 
476  if(nPortionIndex > 0)
477  {
478  // adapt to portion start
479  double fDXOffset= *(pCandidate->getDoubleDXArray().begin() + (nPortionIndex - 1));
480  ::std::transform(
481  aNewDXArray.begin(), aNewDXArray.end(),
482  aNewDXArray.begin(), [fDXOffset](double x) { return x - fDXOffset; });
483  }
484 
485  if(bAutosizeScale)
486  {
487  // when autosize scaling, adapt to DXArray, too
488  ::std::transform(
489  aNewDXArray.begin(), aNewDXArray.end(),
490  aNewDXArray.begin(), [fAutosizeScaleFactor](double x) { return x * fAutosizeScaleFactor; });
491  }
492  }
493 
494  if(bShadow)
495  {
496  // shadow primitive creation
497  const Color aShadowColor(maSdrFormTextAttribute.getFormTextShdwColor());
498  const basegfx::BColor aRGBShadowColor(aShadowColor.getBColor());
499 
502  aNewTransformB * aNewShadowTransform * aNewTransformA,
503  pCandidate->getText(),
504  nPortionIndex,
505  nNextGlyphLen,
506  aNewDXArray,
507  aCandidateFontAttribute,
508  pCandidate->getLocale(),
509  aRGBShadowColor);
510 
511  mrShadowDecomposition.push_back(pNew);
512  }
513 
514  {
515  // primitive creation
516  const Color aColor(pCandidate->getFont().GetColor());
517  const basegfx::BColor aRGBColor(aColor.getBColor());
518 
521  aNewTransformB * aNewTransformA,
522  pCandidate->getText(),
523  nPortionIndex,
524  nNextGlyphLen,
525  aNewDXArray,
526  aCandidateFontAttribute,
527  pCandidate->getLocale(),
528  aRGBColor);
529 
530  mrDecomposition.push_back(pNew);
531  }
532  }
533 
534  // consume from portion
535  nUsedTextLength += nNextGlyphLen;
536 
537  // consume from polygon
538  fPolyStart += fPortionLength;
539  }
540  }
541  }
542  }
543  };
544 } // end of anonymous namespace
545 
546 
547 // primitive decomposition helpers
548 
549 namespace
550 {
551  void impAddPolygonStrokePrimitives(
552  const basegfx::B2DPolyPolygonVector& rB2DPolyPolyVector,
553  const basegfx::B2DHomMatrix& rTransform,
554  const drawinglayer::attribute::LineAttribute& rLineAttribute,
555  const drawinglayer::attribute::StrokeAttribute& rStrokeAttribute,
556  std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rTarget)
557  {
558  for(const auto& rB2DPolyPolygon : rB2DPolyPolyVector)
559  {
560  // prepare PolyPolygons
561  basegfx::B2DPolyPolygon aB2DPolyPolygon = rB2DPolyPolygon;
562  aB2DPolyPolygon.transform(rTransform);
563 
564  for(auto const& rPolygon : aB2DPolyPolygon)
565  {
566  // create one primitive per polygon
569  rPolygon, rLineAttribute, rStrokeAttribute);
570  rTarget.push_back(pNew);
571  }
572  }
573  }
574 
576  const std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rSource,
578  {
579  std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aNewPrimitives;
580 
582  {
584 
585  if(pTextCandidate)
586  {
587  basegfx::B2DPolyPolygonVector aB2DPolyPolyVector;
588  basegfx::B2DHomMatrix aPolygonTransform;
589 
590  // get text outlines and their object transformation
591  pTextCandidate->getTextOutlinesAndTransformation(aB2DPolyPolyVector, aPolygonTransform);
592 
593  if(!aB2DPolyPolyVector.empty())
594  {
595  // create stroke primitives
596  std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aStrokePrimitives;
597  impAddPolygonStrokePrimitives(
598  aB2DPolyPolyVector,
599  aPolygonTransform,
600  rOutlineAttribute.getLineAttribute(),
601  rOutlineAttribute.getStrokeAttribute(),
602  aStrokePrimitives);
603  const sal_uInt32 nStrokeCount(aStrokePrimitives.size());
604 
605  if(nStrokeCount)
606  {
607  if(rOutlineAttribute.getTransparence())
608  {
609  // create UnifiedTransparencePrimitive2D
610  drawinglayer::primitive2d::Primitive2DContainer aStrokePrimitiveSequence(nStrokeCount);
611 
612  for(sal_uInt32 b(0); b < nStrokeCount; b++)
613  {
614  aStrokePrimitiveSequence[b] = drawinglayer::primitive2d::Primitive2DReference(aStrokePrimitives[b]);
615  }
616 
619  aStrokePrimitiveSequence,
620  static_cast<double>(rOutlineAttribute.getTransparence()) / 100.0);
621  aNewPrimitives.push_back(pNew2);
622  }
623  else
624  {
625  // add polygons to rDecomposition as polygonStrokePrimitives
626  aNewPrimitives.insert(aNewPrimitives.end(), aStrokePrimitives.begin(), aStrokePrimitives.end());
627  }
628  }
629  }
630  }
631  }
632 
633  const sal_uInt32 nNewCount(aNewPrimitives.size());
634 
635  if(nNewCount)
636  {
638 
639  for(sal_uInt32 a(0); a < nNewCount; a++)
640  {
641  aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(aNewPrimitives[a]);
642  }
643 
644  return aRetval;
645  }
646  else
647  {
649  }
650  }
651 } // end of anonymous namespace
652 
653 
654 // primitive decomposition
655 
658  const drawinglayer::primitive2d::SdrPathTextPrimitive2D& rSdrPathTextPrimitive,
659  const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
660 {
663 
664  // prepare outliner
665  SdrOutliner& rOutliner = ImpGetDrawOutliner();
666  rOutliner.SetUpdateMode(true);
667  rOutliner.Clear();
668  rOutliner.SetPaperSize(Size(LONG_MAX,LONG_MAX));
669  rOutliner.SetText(rSdrPathTextPrimitive.getOutlinerParaObject());
670 
671  // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
672  rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
673 
674  // now break up to text portions
675  impTextBreakupHandler aConverter(rOutliner);
676  const ::std::vector< impPathTextPortion > rPathTextPortions = aConverter.decompositionPathTextPrimitive();
677 
678  if(!rPathTextPortions.empty())
679  {
680  // get FormText and polygon values
681  const drawinglayer::attribute::SdrFormTextAttribute& rFormTextAttribute = rSdrPathTextPrimitive.getSdrFormTextAttribute();
682  const basegfx::B2DPolyPolygon& rPathPolyPolygon(rSdrPathTextPrimitive.getPathPolyPolygon());
683 
684  // get loop count
685  sal_uInt32 nLoopCount(rPathPolyPolygon.count());
686 
687  if(o3tl::make_unsigned(rOutliner.GetParagraphCount()) < nLoopCount)
688  {
689  nLoopCount = rOutliner.GetParagraphCount();
690  }
691 
692  if(nLoopCount)
693  {
694  // prepare common decomposition stuff
695  std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aRegularDecomposition;
696  std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aShadowDecomposition;
697  impPolygonParagraphHandler aPolygonParagraphHandler(
698  rFormTextAttribute,
699  aRegularDecomposition,
700  aShadowDecomposition);
701  sal_uInt32 a;
702 
703  for(a = 0; a < nLoopCount; a++)
704  {
705  // filter text portions for this paragraph
706  ::std::vector< const impPathTextPortion* > aParagraphTextPortions;
707 
708  for(const auto & rCandidate : rPathTextPortions)
709  {
710  if(static_cast<sal_uInt32>(rCandidate.getParagraph()) == a)
711  {
712  aParagraphTextPortions.push_back(&rCandidate);
713  }
714  }
715 
716  // handle data pair polygon/ParagraphTextPortions
717  if(!aParagraphTextPortions.empty())
718  {
719  aPolygonParagraphHandler.HandlePair(rPathPolyPolygon.getB2DPolygon(a), aParagraphTextPortions);
720  }
721  }
722 
723  const sal_uInt32 nShadowCount(aShadowDecomposition.size());
724  const sal_uInt32 nRegularCount(aRegularDecomposition.size());
725 
726  if(nShadowCount)
727  {
728  // add shadow primitives to decomposition
729  aRetvalA.resize(nShadowCount);
730 
731  for(a = 0; a < nShadowCount; a++)
732  {
733  aRetvalA[a] = drawinglayer::primitive2d::Primitive2DReference(aShadowDecomposition[a]);
734  }
735 
736  // if necessary, add shadow outlines
737  if(rFormTextAttribute.getFormTextOutline()
738  && !rFormTextAttribute.getShadowOutline().isDefault())
739  {
741  impAddPathTextOutlines(
742  aShadowDecomposition,
743  rFormTextAttribute.getShadowOutline()));
744 
745  aRetvalA.append(aOutlines);
746  }
747  }
748 
749  if(nRegularCount)
750  {
751  // add normal primitives to decomposition
752  aRetvalB.resize(nRegularCount);
753 
754  for(a = 0; a < nRegularCount; a++)
755  {
756  aRetvalB[a] = drawinglayer::primitive2d::Primitive2DReference(aRegularDecomposition[a]);
757  }
758 
759  // if necessary, add outlines
760  if(rFormTextAttribute.getFormTextOutline()
761  && !rFormTextAttribute.getOutline().isDefault())
762  {
764  impAddPathTextOutlines(
765  aRegularDecomposition,
766  rFormTextAttribute.getOutline()));
767 
768  aRetvalB.append(aOutlines);
769  }
770  }
771  }
772  }
773 
774  // clean up outliner
776  rOutliner.Clear();
777  rOutliner.setVisualizedPage(nullptr);
778 
779  // concatenate all results
780  rTarget.append(aRetvalA);
781  rTarget.append(aRetvalB);
782 }
783 
784 
785 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double getTextWidth(const OUString &rText, sal_uInt32 nIndex, sal_uInt32 nLength) const
const long * mpDXArray
void setVisualizedPage(const SdrPage *pPage)
Definition: svdoutl.hxx:43
const OutlinerParaObject & getOutlinerParaObject() const
IMPL_LINK(MaskData, PipetteHdl, const OString &, rId, void)
Definition: _bmpmask.cxx:192
SdrPage * GetSdrPageFromXDrawPage(const uno::Reference< drawing::XDrawPage > &xDrawPage)
returns the SdrObject from the given StarOffice API wrapper
Definition: unopage.cxx:888
void SetPaperSize(const Size &rSize)
#define F_PI1800
double getX() const
double getY() const
sal_Int32 GetParagraphCount() const
void shearY(double fSy)
float x
attribute::FontAttribute getFontAttributeFromVclFont(basegfx::B2DVector &o_rSize, const vcl::Font &rFont, bool bRTL, bool bBiDiStrong)
#define X
const css::uno::Reference< css::drawing::XDrawPage > & getVisualizedPage() const
const attribute::SdrFormTextAttribute & getSdrFormTextAttribute() const
void shearX(double fSx)
void SetText(const OutlinerParaObject &)
uno_Any a
css::drawing::Direction3D aDirection
void rotate(double fRadiant)
const basegfx::B2DPolyPolygon & getPathPolyPolygon() const
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void scale(double fX, double fY)
void transform(const basegfx::B2DHomMatrix &rMatrix)
virtual void append(const Primitive2DReference &) override
void StripPortions()
const long LONG_MAX
#define Y
void SetDrawPortionHdl(const Link< DrawPortionInfo *, void > &rLink)
void impDecomposePathTextPrimitive(drawinglayer::primitive2d::Primitive2DContainer &rTarget, const drawinglayer::primitive2d::SdrPathTextPrimitive2D &rSdrPathTextPrimitive, const drawinglayer::geometry::ViewInformation2D &aViewInformation) const
const LanguageTag & getLocale()
const SdrFormTextOutlineAttribute & getShadowOutline() const
css::uno::Reference< css::graphic::XPrimitive2D > Primitive2DReference
Text maText
bool operator<(const Subset &rLHS, const Subset &rRHS)
Definition: ucsubset.hxx:49
exports com.sun.star. lang
void getTextOutlinesAndTransformation(basegfx::B2DPolyPolygonVector &rTarget, basegfx::B2DHomMatrix &rTransformation) const
double getLength(const B2DPolygon &rCandidate)
void SetUpdateMode(bool bUpdate)
void translate(double fX, double fY)
void Clear()
B2DVector getNormalizedPerpendicular(const B2DVector &rVec)
SdrOutliner & ImpGetDrawOutliner() const
Definition: svdotext.cxx:1144
B2DPoint getPositionAbsolute(const B2DPolygon &rCandidate, double fDistance, double fLength)
void setFont(const vcl::Font &rFont)
const SdrFormTextOutlineAttribute & getOutline() const
::std::vector< B2DPolyPolygon > B2DPolyPolygonVector