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