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 
500  mrShadowDecomposition.push_back(
502  aNewTransformB * aNewShadowTransform * aNewTransformA,
503  pCandidate->getText(),
504  nPortionIndex,
505  nNextGlyphLen,
506  aNewDXArray,
507  aCandidateFontAttribute,
508  pCandidate->getLocale(),
509  aRGBShadowColor) );
510  }
511 
512  {
513  // primitive creation
514  const Color aColor(pCandidate->getFont().GetColor());
515  const basegfx::BColor aRGBColor(aColor.getBColor());
516 
517  mrDecomposition.push_back(
519  aNewTransformB * aNewTransformA,
520  pCandidate->getText(),
521  nPortionIndex,
522  nNextGlyphLen,
523  aNewDXArray,
524  aCandidateFontAttribute,
525  pCandidate->getLocale(),
526  aRGBColor) );
527  }
528  }
529 
530  // consume from portion
531  nUsedTextLength += nNextGlyphLen;
532 
533  // consume from polygon
534  fPolyStart += fPortionLength;
535  }
536  }
537  }
538  }
539  };
540 } // end of anonymous namespace
541 
542 
543 // primitive decomposition helpers
544 
545 namespace
546 {
547  void impAddPolygonStrokePrimitives(
548  const basegfx::B2DPolyPolygonVector& rB2DPolyPolyVector,
549  const basegfx::B2DHomMatrix& rTransform,
550  const drawinglayer::attribute::LineAttribute& rLineAttribute,
551  const drawinglayer::attribute::StrokeAttribute& rStrokeAttribute,
552  std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rTarget)
553  {
554  for(const auto& rB2DPolyPolygon : rB2DPolyPolyVector)
555  {
556  // prepare PolyPolygons
557  basegfx::B2DPolyPolygon aB2DPolyPolygon = rB2DPolyPolygon;
558  aB2DPolyPolygon.transform(rTransform);
559 
560  for(auto const& rPolygon : aB2DPolyPolygon)
561  {
562  // create one primitive per polygon
563  rTarget.push_back(
565  rPolygon, rLineAttribute, rStrokeAttribute) );
566  }
567  }
568  }
569 
571  const std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rSource,
573  {
574  std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aNewPrimitives;
575 
577  {
579 
580  if(pTextCandidate)
581  {
582  basegfx::B2DPolyPolygonVector aB2DPolyPolyVector;
583  basegfx::B2DHomMatrix aPolygonTransform;
584 
585  // get text outlines and their object transformation
586  pTextCandidate->getTextOutlinesAndTransformation(aB2DPolyPolyVector, aPolygonTransform);
587 
588  if(!aB2DPolyPolyVector.empty())
589  {
590  // create stroke primitives
591  std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aStrokePrimitives;
592  impAddPolygonStrokePrimitives(
593  aB2DPolyPolyVector,
594  aPolygonTransform,
595  rOutlineAttribute.getLineAttribute(),
596  rOutlineAttribute.getStrokeAttribute(),
597  aStrokePrimitives);
598  const sal_uInt32 nStrokeCount(aStrokePrimitives.size());
599 
600  if(nStrokeCount)
601  {
602  if(rOutlineAttribute.getTransparence())
603  {
604  // create UnifiedTransparencePrimitive2D
605  drawinglayer::primitive2d::Primitive2DContainer aStrokePrimitiveSequence(nStrokeCount);
606 
607  for(sal_uInt32 b(0); b < nStrokeCount; b++)
608  {
609  aStrokePrimitiveSequence[b] = drawinglayer::primitive2d::Primitive2DReference(aStrokePrimitives[b]);
610  }
611 
612  aNewPrimitives.push_back(
614  aStrokePrimitiveSequence,
615  static_cast<double>(rOutlineAttribute.getTransparence()) / 100.0) );
616  }
617  else
618  {
619  // add polygons to rDecomposition as polygonStrokePrimitives
620  aNewPrimitives.insert(aNewPrimitives.end(), aStrokePrimitives.begin(), aStrokePrimitives.end());
621  }
622  }
623  }
624  }
625  }
626 
627  const sal_uInt32 nNewCount(aNewPrimitives.size());
628 
629  if(nNewCount)
630  {
632 
633  for(sal_uInt32 a(0); a < nNewCount; a++)
634  {
635  aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(aNewPrimitives[a]);
636  }
637 
638  return aRetval;
639  }
640  else
641  {
643  }
644  }
645 } // end of anonymous namespace
646 
647 
648 // primitive decomposition
649 
652  const drawinglayer::primitive2d::SdrPathTextPrimitive2D& rSdrPathTextPrimitive,
653  const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
654 {
657 
658  // prepare outliner
659  SdrOutliner& rOutliner = ImpGetDrawOutliner();
660  rOutliner.SetUpdateMode(true);
661  rOutliner.Clear();
662  rOutliner.SetPaperSize(Size(LONG_MAX,LONG_MAX));
663  rOutliner.SetText(rSdrPathTextPrimitive.getOutlinerParaObject());
664 
665  // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
666  rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
667 
668  // now break up to text portions
669  impTextBreakupHandler aConverter(rOutliner);
670  const ::std::vector< impPathTextPortion > rPathTextPortions = aConverter.decompositionPathTextPrimitive();
671 
672  if(!rPathTextPortions.empty())
673  {
674  // get FormText and polygon values
675  const drawinglayer::attribute::SdrFormTextAttribute& rFormTextAttribute = rSdrPathTextPrimitive.getSdrFormTextAttribute();
676  const basegfx::B2DPolyPolygon& rPathPolyPolygon(rSdrPathTextPrimitive.getPathPolyPolygon());
677 
678  // get loop count
679  sal_uInt32 nLoopCount(rPathPolyPolygon.count());
680 
681  if(o3tl::make_unsigned(rOutliner.GetParagraphCount()) < nLoopCount)
682  {
683  nLoopCount = rOutliner.GetParagraphCount();
684  }
685 
686  if(nLoopCount)
687  {
688  // prepare common decomposition stuff
689  std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aRegularDecomposition;
690  std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aShadowDecomposition;
691  impPolygonParagraphHandler aPolygonParagraphHandler(
692  rFormTextAttribute,
693  aRegularDecomposition,
694  aShadowDecomposition);
695  sal_uInt32 a;
696 
697  for(a = 0; a < nLoopCount; a++)
698  {
699  // filter text portions for this paragraph
700  ::std::vector< const impPathTextPortion* > aParagraphTextPortions;
701 
702  for(const auto & rCandidate : rPathTextPortions)
703  {
704  if(static_cast<sal_uInt32>(rCandidate.getParagraph()) == a)
705  {
706  aParagraphTextPortions.push_back(&rCandidate);
707  }
708  }
709 
710  // handle data pair polygon/ParagraphTextPortions
711  if(!aParagraphTextPortions.empty())
712  {
713  aPolygonParagraphHandler.HandlePair(rPathPolyPolygon.getB2DPolygon(a), aParagraphTextPortions);
714  }
715  }
716 
717  const sal_uInt32 nShadowCount(aShadowDecomposition.size());
718  const sal_uInt32 nRegularCount(aRegularDecomposition.size());
719 
720  if(nShadowCount)
721  {
722  // add shadow primitives to decomposition
723  aRetvalA.resize(nShadowCount);
724 
725  for(a = 0; a < nShadowCount; a++)
726  {
727  aRetvalA[a] = drawinglayer::primitive2d::Primitive2DReference(aShadowDecomposition[a]);
728  }
729 
730  // if necessary, add shadow outlines
731  if(rFormTextAttribute.getFormTextOutline()
732  && !rFormTextAttribute.getShadowOutline().isDefault())
733  {
735  impAddPathTextOutlines(
736  aShadowDecomposition,
737  rFormTextAttribute.getShadowOutline()));
738 
739  aRetvalA.append(aOutlines);
740  }
741  }
742 
743  if(nRegularCount)
744  {
745  // add normal primitives to decomposition
746  aRetvalB.resize(nRegularCount);
747 
748  for(a = 0; a < nRegularCount; a++)
749  {
750  aRetvalB[a] = drawinglayer::primitive2d::Primitive2DReference(aRegularDecomposition[a]);
751  }
752 
753  // if necessary, add outlines
754  if(rFormTextAttribute.getFormTextOutline()
755  && !rFormTextAttribute.getOutline().isDefault())
756  {
758  impAddPathTextOutlines(
759  aRegularDecomposition,
760  rFormTextAttribute.getOutline()));
761 
762  aRetvalB.append(aOutlines);
763  }
764  }
765  }
766  }
767 
768  // clean up outliner
770  rOutliner.Clear();
771  rOutliner.setVisualizedPage(nullptr);
772 
773  // concatenate all results
774  rTarget.append(aRetvalA);
775  rTarget.append(aRetvalB);
776 }
777 
778 
779 /* 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)
void SetUpdateMode(bool bUpdate)
void translate(double fX, double fY)
double getX() const
void Clear()
B2DVector getNormalizedPerpendicular(const B2DVector &rVec)
SdrOutliner & ImpGetDrawOutliner() const
Definition: svdotext.cxx:1145
B2DPoint getPositionAbsolute(const B2DPolygon &rCandidate, double fDistance, double fLength)
void setFont(const vcl::Font &rFont)
const SdrFormTextOutlineAttribute & getOutline() const
::std::vector< B2DPolyPolygon > B2DPolyPolygonVector