LibreOffice Module svx (master) 1
svdotextdecomposition.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 <svx/compatflags.hxx>
21#include <svx/svdetc.hxx>
22#include <svx/svdoutl.hxx>
23#include <svx/svdpage.hxx>
24#include <svx/svdotext.hxx>
25#include <svx/svdmodel.hxx>
26#include <svx/sdasitm.hxx>
27#include <textchain.hxx>
28#include <textchainflow.hxx>
29#include <svx/sdtacitm.hxx>
30#include <svx/sdtayitm.hxx>
31#include <svx/sdtaiitm.hxx>
32#include <svx/sdtaaitm.hxx>
33#include <svx/xfillit0.hxx>
34#include <svx/xbtmpit.hxx>
40#include <editeng/eeitem.hxx>
41#include <editeng/editstat.hxx>
42#include <tools/helpers.hxx>
43#include <svl/itemset.hxx>
46#include <vcl/svapp.hxx>
48#include <editeng/svxenum.hxx>
49#include <editeng/flditem.hxx>
56#include <svx/unoapi.hxx>
58#include <editeng/outlobj.hxx>
60#include <sal/log.hxx>
61#include <osl/diagnose.h>
62
63using namespace com::sun::star;
64
65// helpers
66
67namespace
68{
69 class impTextBreakupHandler
70 {
71 private:
75
76 SdrOutliner& mrOutliner;
77 basegfx::B2DHomMatrix maNewTransformA;
78 basegfx::B2DHomMatrix maNewTransformB;
79
80 // the visible area for contour text decomposition
81 basegfx::B2DVector maScale;
82
83 // ClipRange for BlockText decomposition; only text portions completely
84 // inside are to be accepted, so this is different from geometric clipping
85 // (which would allow e.g. upper parts of portions to remain). Only used for
86 // BlockText (see there)
87 basegfx::B2DRange maClipRange;
88
89 DECL_LINK(decomposeContourTextPrimitive, DrawPortionInfo*, void);
90 DECL_LINK(decomposeBlockTextPrimitive, DrawPortionInfo*, void);
91 DECL_LINK(decomposeStretchTextPrimitive, DrawPortionInfo*, void);
92
93 DECL_LINK(decomposeContourBulletPrimitive, DrawBulletInfo*, void);
94 DECL_LINK(decomposeBlockBulletPrimitive, DrawBulletInfo*, void);
95 DECL_LINK(decomposeStretchBulletPrimitive, DrawBulletInfo*, void);
96
97 void impCreateTextPortionPrimitive(const DrawPortionInfo& rInfo);
99 void impFlushTextPortionPrimitivesToLinePrimitives();
100 void impFlushLinePrimitivesToParagraphPrimitives(sal_Int32 nPara);
101 void impHandleDrawPortionInfo(const DrawPortionInfo& rInfo);
102 void impHandleDrawBulletInfo(const DrawBulletInfo& rInfo);
103
104 public:
105 explicit impTextBreakupHandler(SdrOutliner& rOutliner)
106 : mrOutliner(rOutliner)
107 {
108 }
109
110 void decomposeContourTextPrimitive(const basegfx::B2DHomMatrix& rNewTransformA, const basegfx::B2DHomMatrix& rNewTransformB, const basegfx::B2DVector& rScale)
111 {
112 maScale = rScale;
113 maNewTransformA = rNewTransformA;
114 maNewTransformB = rNewTransformB;
115 mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decomposeContourTextPrimitive));
116 mrOutliner.SetDrawBulletHdl(LINK(this, impTextBreakupHandler, decomposeContourBulletPrimitive));
117 mrOutliner.StripPortions();
120 }
121
122 void decomposeBlockTextPrimitive(
123 const basegfx::B2DHomMatrix& rNewTransformA,
124 const basegfx::B2DHomMatrix& rNewTransformB,
125 const basegfx::B2DRange& rClipRange)
126 {
127 maNewTransformA = rNewTransformA;
128 maNewTransformB = rNewTransformB;
129 maClipRange = rClipRange;
130 mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decomposeBlockTextPrimitive));
131 mrOutliner.SetDrawBulletHdl(LINK(this, impTextBreakupHandler, decomposeBlockBulletPrimitive));
132 mrOutliner.StripPortions();
135 }
136
137 void decomposeStretchTextPrimitive(const basegfx::B2DHomMatrix& rNewTransformA, const basegfx::B2DHomMatrix& rNewTransformB)
138 {
139 maNewTransformA = rNewTransformA;
140 maNewTransformB = rNewTransformB;
141 mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decomposeStretchTextPrimitive));
142 mrOutliner.SetDrawBulletHdl(LINK(this, impTextBreakupHandler, decomposeStretchBulletPrimitive));
143 mrOutliner.StripPortions();
146 }
147
148 drawinglayer::primitive2d::Primitive2DContainer extractPrimitive2DSequence();
149 };
150
151 void impTextBreakupHandler::impCreateTextPortionPrimitive(const DrawPortionInfo& rInfo)
152 {
153 if(rInfo.maText.isEmpty() || !rInfo.mnTextLen)
154 return;
155
156 OUString caseMappedText = rInfo.mrFont.CalcCaseMap( rInfo.maText );
157 basegfx::B2DVector aFontScaling;
160 aFontScaling,
161 rInfo.mrFont,
162 rInfo.IsRTL(),
163 false));
164 basegfx::B2DHomMatrix aNewTransform;
165
166 // add font scale to new transform
167 aNewTransform.scale(aFontScaling.getX(), aFontScaling.getY());
168
169 // look for proportional font scaling, if necessary, scale accordingly
170 sal_Int8 nPropr(rInfo.mrFont.GetPropr());
171 if(100 != nPropr)
172 {
173 const double fFactor(rInfo.mrFont.GetPropr() / 100.0);
174 aNewTransform.scale(fFactor, fFactor);
175 }
176
177 // apply font rotate
178 if(rInfo.mrFont.GetOrientation())
179 {
180 aNewTransform.rotate(-toRadians(rInfo.mrFont.GetOrientation()));
181 }
182
183 // look for escapement, if necessary, translate accordingly
184 if(rInfo.mrFont.GetEscapement())
185 {
186 sal_Int16 nEsc(rInfo.mrFont.GetEscapement());
187
188 if(DFLT_ESC_AUTO_SUPER == nEsc)
189 {
190 nEsc = .8 * (100 - nPropr);
191 assert (nEsc == DFLT_ESC_SUPER && "I'm sure this formula needs to be changed, but how to confirm that???");
192 nEsc = DFLT_ESC_SUPER;
193 }
194 else if(DFLT_ESC_AUTO_SUB == nEsc)
195 {
196 nEsc = .2 * -(100 - nPropr);
197 assert (nEsc == -20 && "I'm sure this formula needs to be changed, but how to confirm that???");
198 nEsc = -20;
199 }
200
201 if(nEsc > MAX_ESC_POS)
202 {
203 nEsc = MAX_ESC_POS;
204 }
205 else if(nEsc < -MAX_ESC_POS)
206 {
207 nEsc = -MAX_ESC_POS;
208 }
209
210 const double fEscapement(nEsc / -100.0);
211 aNewTransform.translate(0.0, fEscapement * aFontScaling.getY());
212 }
213
214 // apply transformA
215 aNewTransform *= maNewTransformA;
216
217 // apply local offset
218 aNewTransform.translate(rInfo.mrStartPos.X(), rInfo.mrStartPos.Y());
219
220 // also apply embedding object's transform
221 aNewTransform *= maNewTransformB;
222
223 // prepare DXArray content. To make it independent from font size (and such from
224 // the text transformation), scale it to unit coordinates
225 ::std::vector< double > aDXArray;
226
227 if(!rInfo.mpDXArray.empty() && rInfo.mnTextLen)
228 {
229 aDXArray.reserve(rInfo.mnTextLen);
230
231 for(sal_Int32 a=0; a < rInfo.mnTextLen; a++)
232 {
233 aDXArray.push_back(static_cast<double>(rInfo.mpDXArray[a]));
234 }
235 }
236
237 ::std::vector< sal_Bool > aKashidaArray;
238
239 if(!rInfo.mpKashidaArray.empty() && rInfo.mnTextLen)
240 {
241 aKashidaArray.reserve(rInfo.mnTextLen);
242
243 for(sal_Int32 a=0; a < rInfo.mnTextLen; a++)
244 {
245 aKashidaArray.push_back(rInfo.mpKashidaArray[a]);
246 }
247 }
248
249 // create complex text primitive and append
250 const Color aFontColor(rInfo.mrFont.GetColor());
251 const basegfx::BColor aBFontColor(aFontColor.getBColor());
252
253 const Color aTextFillColor(rInfo.mrFont.GetFillColor());
254
255 // prepare wordLineMode (for underline and strikeout)
256 // NOT for bullet texts. It is set (this may be an error by itself), but needs to be suppressed to hinder e.g. '1)'
257 // to be split which would not look like the original
258 const bool bWordLineMode(rInfo.mrFont.IsWordLineMode() && !rInfo.mbEndOfBullet);
259
260 // prepare new primitive
262 const bool bDecoratedIsNeeded(
263 LINESTYLE_NONE != rInfo.mrFont.GetOverline()
264 || LINESTYLE_NONE != rInfo.mrFont.GetUnderline()
265 || STRIKEOUT_NONE != rInfo.mrFont.GetStrikeout()
266 || FontEmphasisMark::NONE != (rInfo.mrFont.GetEmphasisMark() & FontEmphasisMark::Style)
267 || FontRelief::NONE != rInfo.mrFont.GetRelief()
268 || rInfo.mrFont.IsShadow()
269 || bWordLineMode);
270
271 if(bDecoratedIsNeeded)
272 {
273 // TextDecoratedPortionPrimitive2D needed, prepare some more data
274 // get overline and underline color. If it's on automatic (0xffffffff) use FontColor instead
275 const Color aUnderlineColor(rInfo.maTextLineColor);
276 const basegfx::BColor aBUnderlineColor((aUnderlineColor == COL_AUTO) ? aBFontColor : aUnderlineColor.getBColor());
277 const Color aOverlineColor(rInfo.maOverlineColor);
278 const basegfx::BColor aBOverlineColor((aOverlineColor == COL_AUTO) ? aBFontColor : aOverlineColor.getBColor());
279
280 // prepare overline and underline data
281 const drawinglayer::primitive2d::TextLine eFontOverline(
283 const drawinglayer::primitive2d::TextLine eFontLineStyle(
285
286 // check UnderlineAbove
287 const bool bUnderlineAbove(
288 drawinglayer::primitive2d::TEXT_LINE_NONE != eFontLineStyle && rInfo.mrFont.IsUnderlineAbove());
289
290 // prepare strikeout data
291 const drawinglayer::primitive2d::TextStrikeout eTextStrikeout(
293
294 // prepare emphasis mark data
296
297 switch(rInfo.mrFont.GetEmphasisMark() & FontEmphasisMark::Style)
298 {
299 case FontEmphasisMark::Dot : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_FONT_EMPHASIS_MARK_DOT; break;
300 case FontEmphasisMark::Circle : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_FONT_EMPHASIS_MARK_CIRCLE; break;
301 case FontEmphasisMark::Disc : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_FONT_EMPHASIS_MARK_DISC; break;
302 case FontEmphasisMark::Accent : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_FONT_EMPHASIS_MARK_ACCENT; break;
303 default: break;
304 }
305
306 const bool bEmphasisMarkAbove(rInfo.mrFont.GetEmphasisMark() & FontEmphasisMark::PosAbove);
307 const bool bEmphasisMarkBelow(rInfo.mrFont.GetEmphasisMark() & FontEmphasisMark::PosBelow);
308
309 // prepare font relief data
311
312 switch(rInfo.mrFont.GetRelief())
313 {
314 case FontRelief::Embossed : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_EMBOSSED; break;
315 case FontRelief::Engraved : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_ENGRAVED; break;
316 default : break; // RELIEF_NONE, FontRelief_FORCE_EQUAL_SIZE
317 }
318
319 // prepare shadow/outline data
320 const bool bShadow(rInfo.mrFont.IsShadow());
321
322 // TextDecoratedPortionPrimitive2D is needed, create one
324
325 // attributes for TextSimplePortionPrimitive2D
326 aNewTransform,
327 caseMappedText,
328 rInfo.mnTextStart,
329 rInfo.mnTextLen,
330 std::vector(aDXArray),
331 std::vector(aKashidaArray),
332 aFontAttribute,
333 rInfo.mpLocale ? *rInfo.mpLocale : css::lang::Locale(),
334 aBFontColor,
335 aTextFillColor,
336
337 // attributes for TextDecoratedPortionPrimitive2D
338 aBOverlineColor,
339 aBUnderlineColor,
340 eFontOverline,
341 eFontLineStyle,
342 bUnderlineAbove,
343 eTextStrikeout,
344 bWordLineMode,
345 eTextEmphasisMark,
346 bEmphasisMarkAbove,
347 bEmphasisMarkBelow,
348 eTextRelief,
349 bShadow);
350 }
351 else
352 {
353 // TextSimplePortionPrimitive2D is enough
355 aNewTransform,
356 caseMappedText,
357 rInfo.mnTextStart,
358 rInfo.mnTextLen,
359 std::vector(aDXArray),
360 std::vector(aKashidaArray),
361 std::move(aFontAttribute),
362 rInfo.mpLocale ? *rInfo.mpLocale : css::lang::Locale(),
363 aBFontColor,
364 rInfo.mbFilled,
365 rInfo.mnWidthToFill,
366 aTextFillColor);
367 }
368
369 if (aFontColor.IsTransparent())
370 {
371 // Handle semi-transparent text for both the decorated and simple case here.
374 (255 - aFontColor.GetAlpha()) / 255.0);
375 }
376
377 if(rInfo.mbEndOfBullet)
378 {
379 // embed in TextHierarchyBulletPrimitive2D
380 drawinglayer::primitive2d::Primitive2DReference aNewReference(pNewPrimitive);
381 drawinglayer::primitive2d::Primitive2DContainer aNewSequence { aNewReference } ;
382 pNewPrimitive = new drawinglayer::primitive2d::TextHierarchyBulletPrimitive2D(std::move(aNewSequence));
383 }
384
385 if(rInfo.mpFieldData)
386 {
387 pNewPrimitive = impCheckFieldPrimitive(pNewPrimitive.get(), rInfo);
388 }
389
390 maTextPortionPrimitives.push_back(pNewPrimitive);
391
392 // support for WrongSpellVector. Create WrongSpellPrimitives as needed
393 if(!rInfo.mpWrongSpellVector || aDXArray.empty())
394 return;
395
396 const sal_Int32 nSize(rInfo.mpWrongSpellVector->size());
397 const sal_Int32 nDXCount(aDXArray.size());
398 const basegfx::BColor aSpellColor(1.0, 0.0, 0.0); // red, hard coded
399
400 for(sal_Int32 a(0); a < nSize; a++)
401 {
402 const EEngineData::WrongSpellClass& rCandidate = (*rInfo.mpWrongSpellVector)[a];
403
404 if(rCandidate.nStart >= rInfo.mnTextStart && rCandidate.nEnd >= rInfo.mnTextStart && rCandidate.nEnd > rCandidate.nStart)
405 {
406 const sal_Int32 nStart(rCandidate.nStart - rInfo.mnTextStart);
407 const sal_Int32 nEnd(rCandidate.nEnd - rInfo.mnTextStart);
408 double fStart(0.0);
409 double fEnd(0.0);
410
411 if(nStart > 0 && nStart - 1 < nDXCount)
412 {
413 fStart = aDXArray[nStart - 1];
414 }
415
416 if(nEnd > 0 && nEnd - 1 < nDXCount)
417 {
418 fEnd = aDXArray[nEnd - 1];
419 }
420
421 if(!basegfx::fTools::equal(fStart, fEnd))
422 {
423 if(rInfo.IsRTL())
424 {
425 // #i98523#
426 // When the portion is RTL, mirror the redlining using the
427 // full portion width
428 const double fTextWidth(aDXArray[aDXArray.size() - 1]);
429
430 fStart = fTextWidth - fStart;
431 fEnd = fTextWidth - fEnd;
432 }
433
434 // need to take FontScaling out of values; it's already part of
435 // aNewTransform and would be double applied
436 const double fFontScaleX(aFontScaling.getX());
437
438 if(!basegfx::fTools::equal(fFontScaleX, 1.0)
439 && !basegfx::fTools::equalZero(fFontScaleX))
440 {
441 fStart /= fFontScaleX;
442 fEnd /= fFontScaleX;
443 }
444
445 maTextPortionPrimitives.push_back(new drawinglayer::primitive2d::WrongSpellPrimitive2D(
446 aNewTransform,
447 fStart,
448 fEnd,
449 aSpellColor));
450 }
451 }
452 }
453 }
454
455 rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> impTextBreakupHandler::impCheckFieldPrimitive(drawinglayer::primitive2d::BasePrimitive2D* pPrimitive, const DrawPortionInfo& rInfo)
456 {
458 if(rInfo.mpFieldData)
459 {
460 // Support for FIELD_SEQ_BEGIN, FIELD_SEQ_END. If used, create a TextHierarchyFieldPrimitive2D
461 // which holds the field type and, if applicable, the URL
462 const SvxURLField* pURLField = dynamic_cast< const SvxURLField* >(rInfo.mpFieldData);
463 const SvxPageField* pPageField = dynamic_cast< const SvxPageField* >(rInfo.mpFieldData);
464
465 // embed current primitive to a sequence
467
468 if(pPrimitive)
469 {
470 aSequence.resize(1);
471 aSequence[0] = drawinglayer::primitive2d::Primitive2DReference(pPrimitive);
472 }
473
474 if(pURLField)
475 {
476 // extended this to hold more of the contents of the original
477 // SvxURLField since that stuff is still used in HitTest and e.g. Calc
478 std::vector< std::pair< OUString, OUString>> meValues;
479 meValues.emplace_back("URL", pURLField->GetURL());
480 meValues.emplace_back("Representation", pURLField->GetRepresentation());
481 meValues.emplace_back("TargetFrame", pURLField->GetTargetFrame());
482 meValues.emplace_back("SvxURLFormat", OUString::number(static_cast<sal_uInt16>(pURLField->GetFormat())));
484 }
485 else if(pPageField)
486 {
488 }
489 else
490 {
492 }
493 }
494
495 return xRet;
496 }
497
498 void impTextBreakupHandler::impFlushTextPortionPrimitivesToLinePrimitives()
499 {
500 // only create a line primitive when we had content; there is no need for
501 // empty line primitives (contrary to paragraphs, see below).
502 if(!maTextPortionPrimitives.empty())
503 {
504 maLinePrimitives.push_back(new drawinglayer::primitive2d::TextHierarchyLinePrimitive2D(std::move(maTextPortionPrimitives)));
505 }
506 }
507
508 void impTextBreakupHandler::impFlushLinePrimitivesToParagraphPrimitives(sal_Int32 nPara)
509 {
510 sal_Int16 nDepth = mrOutliner.GetDepth(nPara);
511 EBulletInfo eInfo = mrOutliner.GetBulletInfo(nPara);
512 // Pass -1 to signal VclMetafileProcessor2D that there is no active
513 // bullets/numbering in this paragraph (i.e. this is normal text)
514 const sal_Int16 nOutlineLevel( eInfo.bVisible ? nDepth : -1);
515
516 // ALWAYS create a paragraph primitive, even when no content was added. This is done to
517 // have the correct paragraph count even with empty paragraphs. Those paragraphs will
518 // have an empty sub-PrimitiveSequence.
519 maParagraphPrimitives.push_back(
521 std::move(maLinePrimitives),
522 nOutlineLevel));
523 }
524
525 void impTextBreakupHandler::impHandleDrawPortionInfo(const DrawPortionInfo& rInfo)
526 {
527 impCreateTextPortionPrimitive(rInfo);
528
529 if(rInfo.mbEndOfLine || rInfo.mbEndOfParagraph)
530 {
531 impFlushTextPortionPrimitivesToLinePrimitives();
532 }
533
534 if(rInfo.mbEndOfParagraph)
535 {
536 impFlushLinePrimitivesToParagraphPrimitives(rInfo.mnPara);
537 }
538 }
539
540 void impTextBreakupHandler::impHandleDrawBulletInfo(const DrawBulletInfo& rInfo)
541 {
542 basegfx::B2DHomMatrix aNewTransform;
543
544 // add size to new transform
545 aNewTransform.scale(rInfo.maBulletSize.getWidth(), rInfo.maBulletSize.getHeight());
546
547 // apply transformA
548 aNewTransform *= maNewTransformA;
549
550 // apply local offset
551 aNewTransform.translate(rInfo.maBulletPosition.X(), rInfo.maBulletPosition.Y());
552
553 // also apply embedding object's transform
554 aNewTransform *= maNewTransformB;
555
556 // prepare empty GraphicAttr
557 const GraphicAttr aGraphicAttr;
558
559 // create GraphicPrimitive2D
561 aNewTransform,
563 aGraphicAttr));
564
565 // embed in TextHierarchyBulletPrimitive2D
566 drawinglayer::primitive2d::Primitive2DContainer aNewSequence { aNewReference };
568
569 // add to output
570 maTextPortionPrimitives.push_back(pNewPrimitive);
571 }
572
573 IMPL_LINK(impTextBreakupHandler, decomposeContourTextPrimitive, DrawPortionInfo*, pInfo, void)
574 {
575 // for contour text, ignore (clip away) all portions which are below
576 // the visible area given by maScale
577 if(pInfo && static_cast<double>(pInfo->mrStartPos.Y()) < maScale.getY())
578 {
579 impHandleDrawPortionInfo(*pInfo);
580 }
581 }
582
583 IMPL_LINK(impTextBreakupHandler, decomposeBlockTextPrimitive, DrawPortionInfo*, pInfo, void)
584 {
585 if(!pInfo)
586 return;
587
588 // Is clipping wanted? This is text clipping; only accept a portion
589 // if it's completely in the range
590 if(!maClipRange.isEmpty())
591 {
592 // Test start position first; this allows to not get the text range at
593 // all if text is far outside
594 const basegfx::B2DPoint aStartPosition(pInfo->mrStartPos.X(), pInfo->mrStartPos.Y());
595
596 if(!maClipRange.isInside(aStartPosition))
597 {
598 return;
599 }
600
601 // Start position is inside. Get TextBoundRect and TopLeft next
603 aTextLayouterDevice.setFont(pInfo->mrFont);
604
605 const basegfx::B2DRange aTextBoundRect(
606 aTextLayouterDevice.getTextBoundRect(
607 pInfo->maText, pInfo->mnTextStart, pInfo->mnTextLen));
608 const basegfx::B2DPoint aTopLeft(aTextBoundRect.getMinimum() + aStartPosition);
609
610 if(!maClipRange.isInside(aTopLeft))
611 {
612 return;
613 }
614
615 // TopLeft is inside. Get BottomRight and check
616 const basegfx::B2DPoint aBottomRight(aTextBoundRect.getMaximum() + aStartPosition);
617
618 if(!maClipRange.isInside(aBottomRight))
619 {
620 return;
621 }
622
623 // all inside, clip was successful
624 }
625 impHandleDrawPortionInfo(*pInfo);
626 }
627
628 IMPL_LINK(impTextBreakupHandler, decomposeStretchTextPrimitive, DrawPortionInfo*, pInfo, void)
629 {
630 if(pInfo)
631 {
632 impHandleDrawPortionInfo(*pInfo);
633 }
634 }
635
636 IMPL_LINK(impTextBreakupHandler, decomposeContourBulletPrimitive, DrawBulletInfo*, pInfo, void)
637 {
638 if(pInfo)
639 {
640 impHandleDrawBulletInfo(*pInfo);
641 }
642 }
643
644 IMPL_LINK(impTextBreakupHandler, decomposeBlockBulletPrimitive, DrawBulletInfo*, pInfo, void)
645 {
646 if(pInfo)
647 {
648 impHandleDrawBulletInfo(*pInfo);
649 }
650 }
651
652 IMPL_LINK(impTextBreakupHandler, decomposeStretchBulletPrimitive, DrawBulletInfo*, pInfo, void)
653 {
654 if(pInfo)
655 {
656 impHandleDrawBulletInfo(*pInfo);
657 }
658 }
659
660 drawinglayer::primitive2d::Primitive2DContainer impTextBreakupHandler::extractPrimitive2DSequence()
661 {
662 if(!maTextPortionPrimitives.empty())
663 {
664 // collect non-closed lines
665 impFlushTextPortionPrimitivesToLinePrimitives();
666 }
667
668 if(!maLinePrimitives.empty())
669 {
670 // collect non-closed paragraphs
671 impFlushLinePrimitivesToParagraphPrimitives(mrOutliner.GetParagraphCount() - 1);
672 }
673
674 return std::move(maParagraphPrimitives);
675 }
676} // end of anonymous namespace
677
678
679// primitive decompositions
680
683 const drawinglayer::primitive2d::SdrContourTextPrimitive2D& rSdrContourTextPrimitive,
684 const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
685{
686 // decompose matrix to have position and size of text
687 basegfx::B2DVector aScale, aTranslate;
688 double fRotate, fShearX;
689 rSdrContourTextPrimitive.getObjectTransform().decompose(aScale, aTranslate, fRotate, fShearX);
690
691 // prepare contour polygon, force to non-mirrored for laying out
692 basegfx::B2DPolyPolygon aPolyPolygon(rSdrContourTextPrimitive.getUnitPolyPolygon());
693 aPolyPolygon.transform(basegfx::utils::createScaleB2DHomMatrix(fabs(aScale.getX()), fabs(aScale.getY())));
694
695 // prepare outliner
696 SolarMutexGuard aSolarGuard;
697 SdrOutliner& rOutliner = ImpGetDrawOutliner();
698 const Size aNullSize;
699 rOutliner.SetPaperSize(aNullSize);
700 rOutliner.SetPolygon(aPolyPolygon);
701 rOutliner.SetUpdateLayout(true);
702 rOutliner.SetText(rSdrContourTextPrimitive.getOutlinerParaObject());
703
704 // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
705 rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
706
707 // prepare matrices to apply to newly created primitives
708 basegfx::B2DHomMatrix aNewTransformA;
709
710 // mirroring. We are now in the polygon sizes. When mirroring in X and Y,
711 // move the null point which was top left to bottom right.
712 const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
713 const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
714
715 // in-between the translations of the single primitives will take place. Afterwards,
716 // the object's transformations need to be applied
718 bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
719 fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
720
721 // now break up text primitives.
722 impTextBreakupHandler aConverter(rOutliner);
723 aConverter.decomposeContourTextPrimitive(aNewTransformA, aNewTransformB, aScale);
724
725 // cleanup outliner
726 rOutliner.Clear();
727 rOutliner.setVisualizedPage(nullptr);
728
729 rTarget = aConverter.extractPrimitive2DSequence();
730}
731
734 const drawinglayer::primitive2d::SdrAutoFitTextPrimitive2D& rSdrAutofitTextPrimitive,
735 const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
736{
737 // decompose matrix to have position and size of text
738 basegfx::B2DVector aScale, aTranslate;
739 double fRotate, fShearX;
740 rSdrAutofitTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
741
742 // use B2DRange aAnchorTextRange for calculations
743 basegfx::B2DRange aAnchorTextRange(aTranslate);
744 aAnchorTextRange.expand(aTranslate + aScale);
745
746 // prepare outliner
747 const SfxItemSet& rTextItemSet = rSdrAutofitTextPrimitive.getSdrText()->GetItemSet();
748 SolarMutexGuard aSolarGuard;
749 SdrOutliner& rOutliner = ImpGetDrawOutliner();
750 SdrTextVertAdjust eVAdj = GetTextVerticalAdjust(rTextItemSet);
751 SdrTextHorzAdjust eHAdj = GetTextHorizontalAdjust(rTextItemSet);
752 const EEControlBits nOriginalControlWord(rOutliner.GetControlWord());
753 const Size aNullSize;
754
755 // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
756 rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
757
758 rOutliner.SetControlWord(nOriginalControlWord|EEControlBits::AUTOPAGESIZE|EEControlBits::STRETCHING);
759 rOutliner.SetMinAutoPaperSize(aNullSize);
760 rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
761
762 // That color needs to be restored on leaving this method
763 Color aOriginalBackColor(rOutliner.GetBackgroundColor());
764 setSuitableOutlinerBg(rOutliner);
765
766 // add one to range sizes to get back to the old Rectangle and outliner measurements
767 const sal_uInt32 nAnchorTextWidth(FRound(aAnchorTextRange.getWidth() + 1));
768 const sal_uInt32 nAnchorTextHeight(FRound(aAnchorTextRange.getHeight() + 1));
769 const OutlinerParaObject* pOutlinerParaObject = rSdrAutofitTextPrimitive.getSdrText()->GetOutlinerParaObject();
770 OSL_ENSURE(pOutlinerParaObject, "impDecomposeBlockTextPrimitive used with no OutlinerParaObject (!)");
771 const bool bVerticalWriting(pOutlinerParaObject->IsEffectivelyVertical());
772 const bool bTopToBottom(pOutlinerParaObject->IsTopToBottom());
773 const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
774
775 if(rSdrAutofitTextPrimitive.getWordWrap() || IsTextFrame())
776 {
777 rOutliner.SetMaxAutoPaperSize(aAnchorTextSize);
778 }
779
780 if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !bVerticalWriting)
781 {
782 rOutliner.SetMinAutoPaperSize(Size(nAnchorTextWidth, 0));
783 rOutliner.SetMinColumnWrapHeight(nAnchorTextHeight);
784 }
785
786 if(SDRTEXTVERTADJUST_BLOCK == eVAdj && bVerticalWriting)
787 {
788 rOutliner.SetMinAutoPaperSize(Size(0, nAnchorTextHeight));
789 rOutliner.SetMinColumnWrapHeight(nAnchorTextWidth);
790 }
791
792 rOutliner.SetPaperSize(aNullSize);
793 rOutliner.SetUpdateLayout(true);
794 rOutliner.SetText(*pOutlinerParaObject);
795 ImpAutoFitText(rOutliner,aAnchorTextSize,bVerticalWriting);
796
797 // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
798 rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
799
800 // now get back the layouted text size from outliner
801 const Size aOutlinerTextSize(rOutliner.GetPaperSize());
802 const basegfx::B2DVector aOutlinerScale(aOutlinerTextSize.Width(), aOutlinerTextSize.Height());
803 basegfx::B2DVector aAdjustTranslate(0.0, 0.0);
804
805 // correct horizontal translation using the now known text size
807 {
808 const double fFree(aAnchorTextRange.getWidth() - aOutlinerScale.getX());
809
810 if(SDRTEXTHORZADJUST_CENTER == eHAdj)
811 {
812 aAdjustTranslate.setX(fFree / 2.0);
813 }
814
815 if(SDRTEXTHORZADJUST_RIGHT == eHAdj)
816 {
817 aAdjustTranslate.setX(fFree);
818 }
819 }
820
821 // correct vertical translation using the now known text size
823 {
824 const double fFree(aAnchorTextRange.getHeight() - aOutlinerScale.getY());
825
826 if(SDRTEXTVERTADJUST_CENTER == eVAdj)
827 {
828 aAdjustTranslate.setY(fFree / 2.0);
829 }
830
831 if(SDRTEXTVERTADJUST_BOTTOM == eVAdj)
832 {
833 aAdjustTranslate.setY(fFree);
834 }
835 }
836
837 // prepare matrices to apply to newly created primitives. aNewTransformA
838 // will get coordinates in aOutlinerScale size and positive in X, Y.
839 basegfx::B2DHomMatrix aNewTransformA;
840 basegfx::B2DHomMatrix aNewTransformB;
841
842 // translate relative to given primitive to get same rotation and shear
843 // as the master shape we are working on. For vertical, use the top-right
844 // corner
845 const double fStartInX(bVerticalWriting && bTopToBottom ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
846 const double fStartInY(bVerticalWriting && !bTopToBottom ? aAdjustTranslate.getY() + aOutlinerScale.getY() : aAdjustTranslate.getY());
847 aNewTransformA.translate(fStartInX, fStartInY);
848
849 // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
850 // move the null point which was top left to bottom right.
851 const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
852 const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
853 aNewTransformB.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0);
854
855 // in-between the translations of the single primitives will take place. Afterwards,
856 // the object's transformations need to be applied
857 aNewTransformB.shearX(fShearX);
858 aNewTransformB.rotate(fRotate);
859 aNewTransformB.translate(aTranslate.getX(), aTranslate.getY());
860
861 basegfx::B2DRange aClipRange;
862
863 // now break up text primitives.
864 impTextBreakupHandler aConverter(rOutliner);
865 aConverter.decomposeBlockTextPrimitive(aNewTransformA, aNewTransformB, aClipRange);
866
867 // cleanup outliner
868 rOutliner.SetBackgroundColor(aOriginalBackColor);
869 rOutliner.Clear();
870 rOutliner.setVisualizedPage(nullptr);
871 rOutliner.SetControlWord(nOriginalControlWord);
872
873 rTarget = aConverter.extractPrimitive2DSequence();
874}
875
876// Resolves: fdo#35779 set background color of this shape as the editeng background if there
877// is one. Check the shape itself, then the host page, then that page's master page.
879{
880 const SfxItemSet* pBackgroundFillSet = getBackgroundFillSet();
881 if (drawing::FillStyle_NONE != pBackgroundFillSet->Get(XATTR_FILLSTYLE).GetValue())
882 {
883 Color aColor(rOutliner.GetBackgroundColor());
884 GetDraftFillColor(*pBackgroundFillSet, aColor);
885 rOutliner.SetBackgroundColor(aColor);
886 return true;
887 }
888 return false;
889}
890
892{
893 const SfxItemSet* pBackgroundFillSet = &GetObjectItemSet();
894
895 if (drawing::FillStyle_NONE == pBackgroundFillSet->Get(XATTR_FILLSTYLE).GetValue())
896 {
897 SdrPage* pOwnerPage(getSdrPageFromSdrObject());
898 if (pOwnerPage)
899 {
900 pBackgroundFillSet = &pOwnerPage->getSdrPageProperties().GetItemSet();
901
902 if (drawing::FillStyle_NONE == pBackgroundFillSet->Get(XATTR_FILLSTYLE).GetValue())
903 {
904 if (!pOwnerPage->IsMasterPage() && pOwnerPage->TRG_HasMasterPage())
905 {
906 pBackgroundFillSet = &pOwnerPage->TRG_GetMasterPage().getSdrPageProperties().GetItemSet();
907 }
908 }
909 }
910 }
911 return pBackgroundFillSet;
912}
913
915{
916 if(IsGroupObject()) // Doesn't make sense, and GetObjectItemSet() asserts.
917 return nullptr;
918 const SfxItemSet* pBackgroundFillSet = getBackgroundFillSet();
919 if (drawing::FillStyle_BITMAP != pBackgroundFillSet->Get(XATTR_FILLSTYLE).GetValue())
920 return nullptr;
921 return &pBackgroundFillSet->Get(XATTR_FILLBITMAP).GetGraphicObject().GetGraphic();
922}
923
926 const drawinglayer::primitive2d::SdrBlockTextPrimitive2D& rSdrBlockTextPrimitive,
927 const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
928{
929 // decompose matrix to have position and size of text
930 basegfx::B2DVector aScale, aTranslate;
931 double fRotate, fShearX;
932 rSdrBlockTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
933
934 // use B2DRange aAnchorTextRange for calculations
935 basegfx::B2DRange aAnchorTextRange(aTranslate);
936 aAnchorTextRange.expand(aTranslate + aScale);
937
938 // prepare outliner
939 const bool bIsCell(rSdrBlockTextPrimitive.getCellText());
940 SolarMutexGuard aSolarGuard;
941 SdrOutliner& rOutliner = ImpGetDrawOutliner();
942 SdrTextHorzAdjust eHAdj = rSdrBlockTextPrimitive.getSdrTextHorzAdjust();
943 SdrTextVertAdjust eVAdj = rSdrBlockTextPrimitive.getSdrTextVertAdjust();
944 const EEControlBits nOriginalControlWord(rOutliner.GetControlWord());
945 const Size aNullSize;
946
947 // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
948 rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
949 rOutliner.SetFixedCellHeight(rSdrBlockTextPrimitive.isFixedCellHeight());
950 rOutliner.SetControlWord(nOriginalControlWord|EEControlBits::AUTOPAGESIZE);
951 rOutliner.SetMinAutoPaperSize(aNullSize);
952 rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
953
954 // That color needs to be restored on leaving this method
955 Color aOriginalBackColor(rOutliner.GetBackgroundColor());
956 setSuitableOutlinerBg(rOutliner);
957
958 // add one to range sizes to get back to the old Rectangle and outliner measurements
959 const sal_uInt32 nAnchorTextWidth(FRound(aAnchorTextRange.getWidth() + 1));
960 const sal_uInt32 nAnchorTextHeight(FRound(aAnchorTextRange.getHeight() + 1));
961 const bool bVerticalWriting(rSdrBlockTextPrimitive.getOutlinerParaObject().IsEffectivelyVertical());
962 const bool bTopToBottom(rSdrBlockTextPrimitive.getOutlinerParaObject().IsTopToBottom());
963 const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
964
965 if(bIsCell)
966 {
967 // cell text is formatted neither like a text object nor like an object
968 // text, so use a special setup here
969 rOutliner.SetMaxAutoPaperSize(aAnchorTextSize);
970
971 // #i106214# To work with an unchangeable PaperSize (CellSize in
972 // this case) Set(Min|Max)AutoPaperSize and SetPaperSize have to be used.
973 // #i106214# This was not completely correct; to still measure the real
974 // text height to allow vertical adjust (and vice versa for VerticalWritintg)
975 // only one aspect has to be set, but the other one to zero
976 if(bVerticalWriting)
977 {
978 // measure the horizontal text size
979 rOutliner.SetMinAutoPaperSize(Size(0, aAnchorTextSize.Height()));
980 }
981 else
982 {
983 // measure the vertical text size
984 rOutliner.SetMinAutoPaperSize(Size(aAnchorTextSize.Width(), 0));
985 }
986
987 rOutliner.SetPaperSize(aAnchorTextSize);
988 rOutliner.SetUpdateLayout(true);
989 rOutliner.SetText(rSdrBlockTextPrimitive.getOutlinerParaObject());
990 }
991 else
992 {
993 // check if block text is used (only one of them can be true)
994 const bool bHorizontalIsBlock(SDRTEXTHORZADJUST_BLOCK == eHAdj && !bVerticalWriting);
995 const bool bVerticalIsBlock(SDRTEXTVERTADJUST_BLOCK == eVAdj && bVerticalWriting);
996
997 // set minimal paper size horizontally/vertically if needed
998 if(bHorizontalIsBlock)
999 {
1000 rOutliner.SetMinAutoPaperSize(Size(nAnchorTextWidth, 0));
1001 rOutliner.SetMinColumnWrapHeight(nAnchorTextHeight);
1002 }
1003 else if(bVerticalIsBlock)
1004 {
1005 rOutliner.SetMinAutoPaperSize(Size(0, nAnchorTextHeight));
1006 rOutliner.SetMinColumnWrapHeight(nAnchorTextWidth);
1007 }
1008
1009 if((rSdrBlockTextPrimitive.getWordWrap() || IsTextFrame()) && !rSdrBlockTextPrimitive.getUnlimitedPage())
1010 {
1011 // #i103454# maximal paper size hor/ver needs to be limited to text
1012 // frame size. If it's block text, still allow the 'other' direction
1013 // to grow to get a correct real text size when using GetPaperSize().
1014 // When just using aAnchorTextSize as maximum, GetPaperSize()
1015 // would just return aAnchorTextSize again: this means, the wanted
1016 // 'measurement' of the real size of block text would not work
1017 Size aMaxAutoPaperSize(aAnchorTextSize);
1018
1019 // Usual processing - always grow in one of directions
1020 bool bAllowGrowVertical = !bVerticalWriting;
1021 bool bAllowGrowHorizontal = bVerticalWriting;
1022
1023 // Compatibility mode for tdf#99729
1024 if (getSdrModelFromSdrObject().GetCompatibilityFlag(
1026 {
1027 bAllowGrowVertical = bHorizontalIsBlock;
1028 bAllowGrowHorizontal = bVerticalIsBlock;
1029 }
1030
1031 if (bAllowGrowVertical)
1032 {
1033 // allow to grow vertical for horizontal texts
1034 aMaxAutoPaperSize.setHeight(1000000);
1035 }
1036 else if (bAllowGrowHorizontal)
1037 {
1038 // allow to grow horizontal for vertical texts
1039 aMaxAutoPaperSize.setWidth(1000000);
1040 }
1041
1042 rOutliner.SetMaxAutoPaperSize(aMaxAutoPaperSize);
1043 }
1044
1045 rOutliner.SetPaperSize(aNullSize);
1046 rOutliner.SetUpdateLayout(true);
1047 rOutliner.SetText(rSdrBlockTextPrimitive.getOutlinerParaObject());
1048 }
1049
1050 rOutliner.SetControlWord(nOriginalControlWord);
1051
1052 // now get back the layouted text size from outliner
1053 const Size aOutlinerTextSize(rOutliner.GetPaperSize());
1054 const basegfx::B2DVector aOutlinerScale(aOutlinerTextSize.Width(), aOutlinerTextSize.Height());
1055 basegfx::B2DVector aAdjustTranslate(0.0, 0.0);
1056
1057 // For draw objects containing text correct hor/ver alignment if text is bigger
1058 // than the object itself. Without that correction, the text would always be
1059 // formatted to the left edge (or top edge when vertical) of the draw object.
1060 if(!IsTextFrame() && !bIsCell)
1061 {
1062 if(aAnchorTextRange.getWidth() < aOutlinerScale.getX() && !bVerticalWriting)
1063 {
1064 // Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK,
1065 // else the alignment is wanted.
1066 if(SDRTEXTHORZADJUST_BLOCK == eHAdj)
1067 {
1068 SvxAdjust eAdjust = GetObjectItemSet().Get(EE_PARA_JUST).GetAdjust();
1069 switch(eAdjust)
1070 {
1071 case SvxAdjust::Left: eHAdj = SDRTEXTHORZADJUST_LEFT; break;
1072 case SvxAdjust::Right: eHAdj = SDRTEXTHORZADJUST_RIGHT; break;
1073 case SvxAdjust::Center: eHAdj = SDRTEXTHORZADJUST_CENTER; break;
1074 default: break;
1075 }
1076 }
1077 }
1078
1079 if(aAnchorTextRange.getHeight() < aOutlinerScale.getY() && bVerticalWriting)
1080 {
1081 // Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK,
1082 // else the alignment is wanted.
1083 if(SDRTEXTVERTADJUST_BLOCK == eVAdj)
1084 {
1086 }
1087 }
1088 }
1089
1090 // correct horizontal translation using the now known text size
1091 if(SDRTEXTHORZADJUST_CENTER == eHAdj || SDRTEXTHORZADJUST_RIGHT == eHAdj)
1092 {
1093 const double fFree(aAnchorTextRange.getWidth() - aOutlinerScale.getX());
1094
1095 if(SDRTEXTHORZADJUST_CENTER == eHAdj)
1096 {
1097 aAdjustTranslate.setX(fFree / 2.0);
1098 }
1099
1100 if(SDRTEXTHORZADJUST_RIGHT == eHAdj)
1101 {
1102 aAdjustTranslate.setX(fFree);
1103 }
1104 }
1105
1106 const double fFreeVerticalSpace(aAnchorTextRange.getHeight() - aOutlinerScale.getY());
1107 bool bClipVerticalTextOverflow = fFreeVerticalSpace < 0
1109 // correct vertical translation using the now known text size
1110 if((SDRTEXTVERTADJUST_CENTER == eVAdj || SDRTEXTVERTADJUST_BOTTOM == eVAdj)
1111 && !bClipVerticalTextOverflow)
1112 {
1113 if(SDRTEXTVERTADJUST_CENTER == eVAdj)
1114 {
1115 aAdjustTranslate.setY(fFreeVerticalSpace / 2.0);
1116 }
1117
1118 if(SDRTEXTVERTADJUST_BOTTOM == eVAdj)
1119 {
1120 aAdjustTranslate.setY(fFreeVerticalSpace);
1121 }
1122 }
1123
1124 // prepare matrices to apply to newly created primitives. aNewTransformA
1125 // will get coordinates in aOutlinerScale size and positive in X, Y.
1126 // Translate relative to given primitive to get same rotation and shear
1127 // as the master shape we are working on. For vertical, use the top-right
1128 // corner
1129 const double fStartInX(bVerticalWriting && bTopToBottom ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
1130 const double fStartInY(bVerticalWriting && !bTopToBottom ? aAdjustTranslate.getY() + aOutlinerScale.getY() : aAdjustTranslate.getY());
1131 basegfx::B2DHomMatrix aNewTransformA(basegfx::utils::createTranslateB2DHomMatrix(fStartInX, fStartInY));
1132
1133 // Apply the camera rotation. It have to be applied after adjustment of
1134 // the text (top, bottom, center, left, right).
1135 if(GetCameraZRotation() != 0)
1136 {
1137 // First find the text rect.
1138 basegfx::B2DRange aTextRectangle(/*x1=*/aTranslate.getX() + aAdjustTranslate.getX(),
1139 /*y1=*/aTranslate.getY() + aAdjustTranslate.getY(),
1140 /*x2=*/aTranslate.getX() + aOutlinerScale.getX() - aAdjustTranslate.getX(),
1141 /*y2=*/aTranslate.getY() + aOutlinerScale.getY() - aAdjustTranslate.getY());
1142
1143 // Rotate the text from the center point.
1144 basegfx::B2DVector aTranslateToCenter(aTextRectangle.getWidth() / 2, aTextRectangle.getHeight() / 2);
1145 aNewTransformA.translate(-aTranslateToCenter.getX(), -aTranslateToCenter.getY());
1146 aNewTransformA.rotate(basegfx::deg2rad(360.0 - GetCameraZRotation() ));
1147 aNewTransformA.translate(aTranslateToCenter.getX(), aTranslateToCenter.getY());
1148 }
1149
1150 // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
1151 // move the null point which was top left to bottom right.
1152 const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
1153 const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
1154
1155 // in-between the translations of the single primitives will take place. Afterwards,
1156 // the object's transformations need to be applied
1158 bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
1159 fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
1160
1161
1162 // create ClipRange (if needed)
1163 basegfx::B2DRange aClipRange;
1164 if(bClipVerticalTextOverflow)
1165 aClipRange = {0, 0, std::numeric_limits<double>::max(), aAnchorTextRange.getHeight()};
1166
1167 // now break up text primitives.
1168 impTextBreakupHandler aConverter(rOutliner);
1169 aConverter.decomposeBlockTextPrimitive(aNewTransformA, aNewTransformB, aClipRange);
1170
1171 // cleanup outliner
1172 rOutliner.SetBackgroundColor(aOriginalBackColor);
1173 rOutliner.Clear();
1174 rOutliner.setVisualizedPage(nullptr);
1175
1176 rTarget = aConverter.extractPrimitive2DSequence();
1177}
1178
1181 const drawinglayer::primitive2d::SdrStretchTextPrimitive2D& rSdrStretchTextPrimitive,
1182 const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
1183{
1184 // decompose matrix to have position and size of text
1185 basegfx::B2DVector aScale, aTranslate;
1186 double fRotate, fShearX;
1187 rSdrStretchTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
1188
1189 // prepare outliner
1190 SolarMutexGuard aSolarGuard;
1191 SdrOutliner& rOutliner = ImpGetDrawOutliner();
1192 const EEControlBits nOriginalControlWord(rOutliner.GetControlWord());
1193 const Size aNullSize;
1194
1195 rOutliner.SetControlWord(nOriginalControlWord|EEControlBits::STRETCHING|EEControlBits::AUTOPAGESIZE);
1196 rOutliner.SetFixedCellHeight(rSdrStretchTextPrimitive.isFixedCellHeight());
1197 rOutliner.SetMinAutoPaperSize(aNullSize);
1198 rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
1199 rOutliner.SetPaperSize(aNullSize);
1200 rOutliner.SetUpdateLayout(true);
1201 rOutliner.SetText(rSdrStretchTextPrimitive.getOutlinerParaObject());
1202
1203 // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
1204 rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
1205
1206 // now get back the laid out text size from outliner
1207 const Size aOutlinerTextSize(rOutliner.CalcTextSize());
1208 const basegfx::B2DVector aOutlinerScale(
1209 aOutlinerTextSize.Width() == tools::Long(0) ? 1.0 : aOutlinerTextSize.Width(),
1210 aOutlinerTextSize.Height() == tools::Long(0) ? 1.0 : aOutlinerTextSize.Height());
1211
1212 // prepare matrices to apply to newly created primitives
1213 basegfx::B2DHomMatrix aNewTransformA;
1214
1215 // #i101957# Check for vertical text. If used, aNewTransformA
1216 // needs to translate the text initially around object width to orient
1217 // it relative to the topper right instead of the topper left
1218 const bool bVertical(rSdrStretchTextPrimitive.getOutlinerParaObject().IsEffectivelyVertical());
1219 const bool bTopToBottom(rSdrStretchTextPrimitive.getOutlinerParaObject().IsTopToBottom());
1220
1221 if(bVertical)
1222 {
1223 if(bTopToBottom)
1224 aNewTransformA.translate(aScale.getX(), 0.0);
1225 else
1226 aNewTransformA.translate(0.0, aScale.getY());
1227 }
1228
1229 // calculate global char stretching scale parameters. Use non-mirrored sizes
1230 // to layout without mirroring
1231 const double fScaleX(fabs(aScale.getX()) / aOutlinerScale.getX());
1232 const double fScaleY(fabs(aScale.getY()) / aOutlinerScale.getY());
1233 rOutliner.setGlobalScale(fScaleX * 100.0, fScaleY * 100.0, 100.0, 100.0);
1234
1235 // When mirroring in X and Y,
1236 // move the null point which was top left to bottom right.
1237 const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
1238 const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
1239
1240 // in-between the translations of the single primitives will take place. Afterwards,
1241 // the object's transformations need to be applied
1243 bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
1244 fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
1245
1246 // now break up text primitives.
1247 impTextBreakupHandler aConverter(rOutliner);
1248 aConverter.decomposeStretchTextPrimitive(aNewTransformA, aNewTransformB);
1249
1250 // cleanup outliner
1251 rOutliner.SetControlWord(nOriginalControlWord);
1252 rOutliner.Clear();
1253 rOutliner.setVisualizedPage(nullptr);
1254
1255 rTarget = aConverter.extractPrimitive2DSequence();
1256}
1257
1258
1259// timing generators
1260#define ENDLESS_LOOP (0xffffffff)
1261#define ENDLESS_TIME (double(0xffffffff))
1262#define PIXEL_DPI (96.0)
1263
1265{
1267 return;
1268
1269 // get values
1270 const SfxItemSet& rSet = GetObjectItemSet();
1271 const sal_uInt32 nRepeat(static_cast<sal_uInt32>(rSet.Get(SDRATTR_TEXT_ANICOUNT).GetValue()));
1272 double fDelay(static_cast<double>(rSet.Get(SDRATTR_TEXT_ANIDELAY).GetValue()));
1273
1274 if(0.0 == fDelay)
1275 {
1276 // use default
1277 fDelay = 250.0;
1278 }
1279
1280 // prepare loop and add
1283 aLoop.append(aStart);
1285 aLoop.append(aEnd);
1286 rAnimList.append(aLoop);
1287
1288 // add stopped state if loop is not endless
1289 if(0 != nRepeat)
1290 {
1291 bool bVisibleWhenStopped(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE).GetValue());
1292 drawinglayer::animation::AnimationEntryFixed aStop(ENDLESS_TIME, bVisibleWhenStopped ? 0.0 : 1.0);
1293 rAnimList.append(aStop);
1294 }
1295}
1296
1297static void impCreateScrollTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, bool bForward, double fTimeFullPath, double fFrequency)
1298{
1299 bool bVisibleWhenStopped(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE).GetValue());
1300 bool bVisibleWhenStarted(rSet.Get(SDRATTR_TEXT_ANISTARTINSIDE).GetValue());
1301 const sal_uInt32 nRepeat(rSet.Get(SDRATTR_TEXT_ANICOUNT).GetValue());
1302
1303 if(bVisibleWhenStarted)
1304 {
1305 // move from center to outside
1306 drawinglayer::animation::AnimationEntryLinear aInOut(fTimeFullPath * 0.5, fFrequency, 0.5, bForward ? 1.0 : 0.0);
1307 rAnimList.append(aInOut);
1308 }
1309
1310 // loop. In loop, move through
1312 drawinglayer::animation::AnimationEntryLinear aThrough(fTimeFullPath, fFrequency, bForward ? 0.0 : 1.0, bForward ? 1.0 : 0.0);
1313 aLoop.append(aThrough);
1314 rAnimList.append(aLoop);
1315
1316 if(0 != nRepeat && bVisibleWhenStopped)
1317 {
1318 // move from outside to center
1319 drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, bForward ? 0.0 : 1.0, 0.5);
1320 rAnimList.append(aOutIn);
1321
1322 // add timing for staying at the end
1324 rAnimList.append(aEnd);
1325 }
1326}
1327
1328static void impCreateAlternateTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, double fRelativeTextLength, bool bForward, double fTimeFullPath, double fFrequency)
1329{
1330 if(basegfx::fTools::more(fRelativeTextLength, 0.5))
1331 {
1332 // this is the case when fTextLength > fFrameLength, text is bigger than animation frame.
1333 // In that case, correct direction
1334 bForward = !bForward;
1335 }
1336
1337 const double fStartPosition(bForward ? fRelativeTextLength : 1.0 - fRelativeTextLength);
1338 const double fEndPosition(bForward ? 1.0 - fRelativeTextLength : fRelativeTextLength);
1339 bool bVisibleWhenStarted(rSet.Get(SDRATTR_TEXT_ANISTARTINSIDE).GetValue());
1340 const sal_uInt32 nRepeat(rSet.Get(SDRATTR_TEXT_ANICOUNT).GetValue());
1341
1342 if(!bVisibleWhenStarted)
1343 {
1344 // move from outside to center
1345 drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, bForward ? 0.0 : 1.0, 0.5);
1346 rAnimList.append(aOutIn);
1347 }
1348
1349 // loop. In loop, move out and in again. fInnerMovePath may be negative when text is bigger then frame,
1350 // so use absolute value
1351 const double fInnerMovePath(fabs(1.0 - (fRelativeTextLength * 2.0)));
1352 const double fTimeForInnerPath(fTimeFullPath * fInnerMovePath);
1353 const double fHalfInnerPath(fTimeForInnerPath * 0.5);
1354 const sal_uInt32 nDoubleRepeat(nRepeat / 2L);
1355
1356 if(nDoubleRepeat || 0 == nRepeat)
1357 {
1358 // double forth and back loop
1359 drawinglayer::animation::AnimationEntryLoop aLoop(nDoubleRepeat ? nDoubleRepeat : ENDLESS_LOOP);
1360 drawinglayer::animation::AnimationEntryLinear aTime0(fHalfInnerPath, fFrequency, 0.5, fEndPosition);
1361 aLoop.append(aTime0);
1362 drawinglayer::animation::AnimationEntryLinear aTime1(fTimeForInnerPath, fFrequency, fEndPosition, fStartPosition);
1363 aLoop.append(aTime1);
1364 drawinglayer::animation::AnimationEntryLinear aTime2(fHalfInnerPath, fFrequency, fStartPosition, 0.5);
1365 aLoop.append(aTime2);
1366 rAnimList.append(aLoop);
1367 }
1368
1369 if(nRepeat % 2L)
1370 {
1371 // repeat is uneven, so we need one more forth and back to center
1372 drawinglayer::animation::AnimationEntryLinear aTime0(fHalfInnerPath, fFrequency, 0.5, fEndPosition);
1373 rAnimList.append(aTime0);
1374 drawinglayer::animation::AnimationEntryLinear aTime1(fHalfInnerPath, fFrequency, fEndPosition, 0.5);
1375 rAnimList.append(aTime1);
1376 }
1377
1378 if(0 == nRepeat)
1379 return;
1380
1381 bool bVisibleWhenStopped(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE).GetValue());
1382 if(bVisibleWhenStopped)
1383 {
1384 // add timing for staying at the end
1386 rAnimList.append(aEnd);
1387 }
1388 else
1389 {
1390 // move from center to outside
1391 drawinglayer::animation::AnimationEntryLinear aInOut(fTimeFullPath * 0.5, fFrequency, 0.5, bForward ? 1.0 : 0.0);
1392 rAnimList.append(aInOut);
1393 }
1394}
1395
1396static void impCreateSlideTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, bool bForward, double fTimeFullPath, double fFrequency)
1397{
1398 // move in from outside, start outside
1399 const double fStartPosition(bForward ? 0.0 : 1.0);
1400 const sal_uInt32 nRepeat(rSet.Get(SDRATTR_TEXT_ANICOUNT).GetValue());
1401
1402 // move from outside to center
1403 drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, fStartPosition, 0.5);
1404 rAnimList.append(aOutIn);
1405
1406 // loop. In loop, move out and in again
1407 if(nRepeat > 1 || 0 == nRepeat)
1408 {
1409 drawinglayer::animation::AnimationEntryLoop aLoop(nRepeat ? nRepeat - 1 : ENDLESS_LOOP);
1410 drawinglayer::animation::AnimationEntryLinear aTime0(fTimeFullPath * 0.5, fFrequency, 0.5, fStartPosition);
1411 aLoop.append(aTime0);
1412 drawinglayer::animation::AnimationEntryLinear aTime1(fTimeFullPath * 0.5, fFrequency, fStartPosition, 0.5);
1413 aLoop.append(aTime1);
1414 rAnimList.append(aLoop);
1415 }
1416
1417 // always visible when stopped, so add timing for staying at the end when not endless
1418 if(0 != nRepeat)
1419 {
1421 rAnimList.append(aEnd);
1422 }
1423}
1424
1425void SdrTextObj::impGetScrollTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList, double fFrameLength, double fTextLength) const
1426{
1427 const SdrTextAniKind eAniKind(GetTextAniKind());
1428
1429 if(SdrTextAniKind::Scroll != eAniKind && SdrTextAniKind::Alternate != eAniKind && SdrTextAniKind::Slide != eAniKind)
1430 return;
1431
1432 // get data. Goal is to calculate fTimeFullPath which is the time needed to
1433 // move animation from (0.0) to (1.0) state
1434 const SfxItemSet& rSet = GetObjectItemSet();
1435 double fAnimationDelay(static_cast<double>(rSet.Get(SDRATTR_TEXT_ANIDELAY).GetValue()));
1436 double fSingleStepWidth(static_cast<double>(rSet.Get(SDRATTR_TEXT_ANIAMOUNT).GetValue()));
1437 const SdrTextAniDirection eDirection(GetTextAniDirection());
1438 const bool bForward(SdrTextAniDirection::Right == eDirection || SdrTextAniDirection::Down == eDirection);
1439
1440 if(basegfx::fTools::equalZero(fAnimationDelay))
1441 {
1442 // default to 1/20 second
1443 fAnimationDelay = 50.0;
1444 }
1445
1446 if(basegfx::fTools::less(fSingleStepWidth, 0.0))
1447 {
1448 // data is in pixels, convert to logic. Imply PIXEL_DPI dpi.
1449 // It makes no sense to keep the view-transformation centered
1450 // definitions, so get rid of them here.
1451 fSingleStepWidth = (-fSingleStepWidth * (2540.0 / PIXEL_DPI));
1452 }
1453
1454 if(basegfx::fTools::equalZero(fSingleStepWidth))
1455 {
1456 // default to 1 millimeter
1457 fSingleStepWidth = 100.0;
1458 }
1459
1460 // use the length of the full animation path and the number of steps
1461 // to get the full path time
1462 const double fFullPathLength(fFrameLength + fTextLength);
1463 const double fNumberOfSteps(fFullPathLength / fSingleStepWidth);
1464 double fTimeFullPath(fNumberOfSteps * fAnimationDelay);
1465
1466 if(fTimeFullPath < fAnimationDelay)
1467 {
1468 fTimeFullPath = fAnimationDelay;
1469 }
1470
1471 switch(eAniKind)
1472 {
1474 {
1475 impCreateScrollTiming(rSet, rAnimList, bForward, fTimeFullPath, fAnimationDelay);
1476 break;
1477 }
1479 {
1480 double fRelativeTextLength(fTextLength / (fFrameLength + fTextLength));
1481 impCreateAlternateTiming(rSet, rAnimList, fRelativeTextLength, bForward, fTimeFullPath, fAnimationDelay);
1482 break;
1483 }
1485 {
1486 impCreateSlideTiming(rSet, rAnimList, bForward, fTimeFullPath, fAnimationDelay);
1487 break;
1488 }
1489 default : break; // SdrTextAniKind::NONE, SdrTextAniKind::Blink
1490 }
1491}
1492
1494{
1495 if (GetTextChain()->GetNilChainingEvent(this))
1496 return;
1497
1498 GetTextChain()->SetNilChainingEvent(this, true);
1499
1500 TextChainFlow aTxtChainFlow(const_cast<SdrTextObj*>(this));
1501 bool bIsOverflow;
1502
1503#ifdef DBG_UTIL
1504 // Some debug output
1505 size_t nObjCount(getSdrPageFromSdrObject()->GetObjCount());
1506 for (size_t i = 0; i < nObjCount; i++)
1507 {
1509 if(pCurObj == this)
1510 {
1511 SAL_INFO("svx.chaining", "Working on TextBox " << i);
1512 break;
1513 }
1514 }
1515#endif
1516
1517 aTxtChainFlow.CheckForFlowEvents(&rOutliner);
1518
1519 if (aTxtChainFlow.IsUnderflow() && !IsInEditMode())
1520 {
1521 // underflow-induced overflow
1522 aTxtChainFlow.ExecuteUnderflow(&rOutliner);
1523 bIsOverflow = aTxtChainFlow.IsOverflow();
1524 } else {
1525 // standard overflow (no underflow before)
1526 bIsOverflow = aTxtChainFlow.IsOverflow();
1527 }
1528
1529 if (bIsOverflow && !IsInEditMode()) {
1530 // Initialize Chaining Outliner
1531 SdrOutliner &rChainingOutl(getSdrModelFromSdrObject().GetChainingOutliner(this));
1532 ImpInitDrawOutliner( rChainingOutl );
1533 rChainingOutl.SetUpdateLayout(true);
1534 // We must pass the chaining outliner otherwise we would mess up decomposition
1535 aTxtChainFlow.ExecuteOverflow(&rOutliner, &rChainingOutl);
1536 }
1537
1538 GetTextChain()->SetNilChainingEvent(this, false);
1539}
1540
1543 const drawinglayer::primitive2d::SdrChainedTextPrimitive2D& rSdrChainedTextPrimitive,
1544 const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
1545{
1546 // decompose matrix to have position and size of text
1547 basegfx::B2DVector aScale, aTranslate;
1548 double fRotate, fShearX;
1549 rSdrChainedTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
1550
1551 // use B2DRange aAnchorTextRange for calculations
1552 basegfx::B2DRange aAnchorTextRange(aTranslate);
1553 aAnchorTextRange.expand(aTranslate + aScale);
1554
1555 // prepare outliner
1556 const SfxItemSet& rTextItemSet = rSdrChainedTextPrimitive.getSdrText()->GetItemSet();
1557 SolarMutexGuard aSolarGuard;
1558 SdrOutliner& rOutliner = ImpGetDrawOutliner();
1559
1560 SdrTextVertAdjust eVAdj = GetTextVerticalAdjust(rTextItemSet);
1561 SdrTextHorzAdjust eHAdj = GetTextHorizontalAdjust(rTextItemSet);
1562 const EEControlBits nOriginalControlWord(rOutliner.GetControlWord());
1563 const Size aNullSize;
1564
1565 // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
1566 rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
1567
1568 rOutliner.SetControlWord(nOriginalControlWord|EEControlBits::AUTOPAGESIZE|EEControlBits::STRETCHING);
1569 rOutliner.SetMinAutoPaperSize(aNullSize);
1570 rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
1571
1572 // add one to range sizes to get back to the old Rectangle and outliner measurements
1573 const sal_uInt32 nAnchorTextWidth(FRound(aAnchorTextRange.getWidth() + 1));
1574 const sal_uInt32 nAnchorTextHeight(FRound(aAnchorTextRange.getHeight() + 1));
1575
1576 // Text
1577 const OutlinerParaObject* pOutlinerParaObject = rSdrChainedTextPrimitive.getSdrText()->GetOutlinerParaObject();
1578 OSL_ENSURE(pOutlinerParaObject, "impDecomposeBlockTextPrimitive used with no OutlinerParaObject (!)");
1579
1580 const bool bVerticalWriting(pOutlinerParaObject->IsEffectivelyVertical());
1581 const bool bTopToBottom(pOutlinerParaObject->IsTopToBottom());
1582 const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
1583
1584 if(IsTextFrame())
1585 {
1586 rOutliner.SetMaxAutoPaperSize(aAnchorTextSize);
1587 }
1588
1589 if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !bVerticalWriting)
1590 {
1591 rOutliner.SetMinAutoPaperSize(Size(nAnchorTextWidth, 0));
1592 }
1593
1594 if(SDRTEXTVERTADJUST_BLOCK == eVAdj && bVerticalWriting)
1595 {
1596 rOutliner.SetMinAutoPaperSize(Size(0, nAnchorTextHeight));
1597 }
1598
1599 rOutliner.SetPaperSize(aNullSize);
1600 rOutliner.SetUpdateLayout(true);
1601 // Sets original text
1602 rOutliner.SetText(*pOutlinerParaObject);
1603
1604 /* Begin overflow/underflow handling */
1605
1607
1608 /* End overflow/underflow handling */
1609
1610 // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
1611 rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
1612
1613 // now get back the layouted text size from outliner
1614 const Size aOutlinerTextSize(rOutliner.GetPaperSize());
1615 const basegfx::B2DVector aOutlinerScale(aOutlinerTextSize.Width(), aOutlinerTextSize.Height());
1616 basegfx::B2DVector aAdjustTranslate(0.0, 0.0);
1617
1618 // correct horizontal translation using the now known text size
1619 if(SDRTEXTHORZADJUST_CENTER == eHAdj || SDRTEXTHORZADJUST_RIGHT == eHAdj)
1620 {
1621 const double fFree(aAnchorTextRange.getWidth() - aOutlinerScale.getX());
1622
1623 if(SDRTEXTHORZADJUST_CENTER == eHAdj)
1624 {
1625 aAdjustTranslate.setX(fFree / 2.0);
1626 }
1627
1628 if(SDRTEXTHORZADJUST_RIGHT == eHAdj)
1629 {
1630 aAdjustTranslate.setX(fFree);
1631 }
1632 }
1633
1634 // correct vertical translation using the now known text size
1635 if(SDRTEXTVERTADJUST_CENTER == eVAdj || SDRTEXTVERTADJUST_BOTTOM == eVAdj)
1636 {
1637 const double fFree(aAnchorTextRange.getHeight() - aOutlinerScale.getY());
1638
1639 if(SDRTEXTVERTADJUST_CENTER == eVAdj)
1640 {
1641 aAdjustTranslate.setY(fFree / 2.0);
1642 }
1643
1644 if(SDRTEXTVERTADJUST_BOTTOM == eVAdj)
1645 {
1646 aAdjustTranslate.setY(fFree);
1647 }
1648 }
1649
1650 // prepare matrices to apply to newly created primitives. aNewTransformA
1651 // will get coordinates in aOutlinerScale size and positive in X, Y.
1652 basegfx::B2DHomMatrix aNewTransformA;
1653 basegfx::B2DHomMatrix aNewTransformB;
1654
1655 // translate relative to given primitive to get same rotation and shear
1656 // as the master shape we are working on. For vertical, use the top-right
1657 // corner
1658 const double fStartInX(bVerticalWriting && bTopToBottom ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
1659 const double fStartInY(bVerticalWriting && !bTopToBottom ? aAdjustTranslate.getY() + aOutlinerScale.getY() : aAdjustTranslate.getY());
1660 aNewTransformA.translate(fStartInX, fStartInY);
1661
1662 // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
1663 // move the null point which was top left to bottom right.
1664 const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
1665 const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
1666 aNewTransformB.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0);
1667
1668 // in-between the translations of the single primitives will take place. Afterwards,
1669 // the object's transformations need to be applied
1670 aNewTransformB.shearX(fShearX);
1671 aNewTransformB.rotate(fRotate);
1672 aNewTransformB.translate(aTranslate.getX(), aTranslate.getY());
1673
1674 basegfx::B2DRange aClipRange;
1675
1676 // now break up text primitives.
1677 impTextBreakupHandler aConverter(rOutliner);
1678 aConverter.decomposeBlockTextPrimitive(aNewTransformA, aNewTransformB, aClipRange);
1679
1680 // cleanup outliner
1681 rOutliner.Clear();
1682 rOutliner.setVisualizedPage(nullptr);
1683 rOutliner.SetControlWord(nOriginalControlWord);
1684
1685 rTarget = aConverter.extractPrimitive2DSequence();
1686}
1687
1688// Direct decomposer for text visualization when you already have a prepared
1689// Outliner containing all the needed information
1692 SdrOutliner& rOutliner,
1693 const basegfx::B2DHomMatrix& rNewTransformA,
1694 const basegfx::B2DHomMatrix& rNewTransformB,
1695 const basegfx::B2DRange& rClipRange)
1696{
1697 impTextBreakupHandler aConverter(rOutliner);
1698 aConverter.decomposeBlockTextPrimitive(rNewTransformA, rNewTransformB, rClipRange);
1699 rTarget.append(aConverter.extractPrimitive2DSequence());
1700}
1701
1703{
1704 const css::uno::Any* pAny;
1705 double fTextCameraZRotateAngle = 0.0;
1706 const SfxItemSet& rSet = GetObjectItemSet();
1708
1709 pAny = rGeometryItem.GetPropertyValueByName("TextCameraZRotateAngle");
1710
1711 if ( pAny )
1712 *pAny >>= fTextCameraZRotateAngle;
1713
1714 return fTextCameraZRotateAngle;
1715}
1716
1717/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPL_LINK(MaskData, PipetteHdl, const OUString &, rId, void)
Definition: _bmpmask.cxx:192
const GraphicObject maBulletGraphicObject
Point maBulletPosition
o3tl::span< const sal_Bool > mpKashidaArray
const Point & mrStartPos
const SvxFieldData * mpFieldData
sal_Int32 mnTextLen
const Color maOverlineColor
const EEngineData::WrongSpellVector * mpWrongSpellVector
sal_Int32 mnPara
const SvxFont & mrFont
const Color maTextLineColor
bool IsRTL() const
tools::Long mnWidthToFill
const css::lang::Locale * mpLocale
const OUString maText
o3tl::span< const sal_Int32 > mpDXArray
sal_Int32 mnTextStart
bool IsTopToBottom() const
bool IsEffectivelyVertical() const
void SetMaxAutoPaperSize(const Size &rSz)
void SetText(const OutlinerParaObject &)
const Size & GetPaperSize() const
void SetDrawPortionHdl(const Link< DrawPortionInfo *, void > &rLink)
void SetMinColumnWrapHeight(tools::Long nVal)
void SetMinAutoPaperSize(const Size &rSz)
void SetPaperSize(const Size &rSize)
void Clear()
sal_Int16 GetDepth(sal_Int32 nPara) const
bool SetUpdateLayout(bool bUpdate)
void SetDrawBulletHdl(const Link< DrawBulletInfo *, void > &rLink)
void SetFixedCellHeight(bool bUseFixedCellHeight)
void StripPortions()
EEControlBits GetControlWord() const
EBulletInfo GetBulletInfo(sal_Int32 nPara)
Color const & GetBackgroundColor() const
void SetControlWord(EEControlBits nWord)
void SetPolygon(const basegfx::B2DPolyPolygon &rPolyPolygon)
Size CalcTextSize()
void setGlobalScale(double rFontX=100.0, double rFontY=100.0, double rSpacingX=100.0, double rSpacingY=100.0)
void SetBackgroundColor(const Color &rColor)
sal_Int32 GetParagraphCount() const
css::uno::Any * GetPropertyValueByName(const OUString &rPropName)
bool setSuitableOutlinerBg(Outliner &rOutliner) const
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:289
const Graphic * getFillGraphic() const
bool IsGroupObject() const
Definition: svdobj.cxx:712
SdrPage * getSdrPageFromSdrObject() const
Definition: svdobj.cxx:279
const SfxItemSet * getBackgroundFillSet() const
const SfxItemSet & GetObjectItemSet() const
Definition: svdobj.cxx:1935
void setVisualizedPage(const SdrPage *pPage)
Definition: svdoutl.hxx:44
const SfxItemSet & GetItemSet() const
Definition: svdpage.hxx:340
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:377
SdrPage & TRG_GetMasterPage() const
Definition: svdpage.cxx:1643
bool IsMasterPage() const
Definition: svdpage.hxx:462
bool TRG_HasMasterPage() const
Definition: svdpage.hxx:498
SdrPageProperties & getSdrPageProperties()
Definition: svdpage.cxx:1864
SdrTextHorzAdjust GetTextHorizontalAdjust() const
Definition: svdotext.cxx:346
double GetCameraZRotation() const
SdrOutliner & ImpGetDrawOutliner() const
Definition: svdotext.cxx:1194
bool IsInEditMode() const
Definition: svdotext.hxx:339
void impDecomposeContourTextPrimitive(drawinglayer::primitive2d::Primitive2DContainer &rTarget, const drawinglayer::primitive2d::SdrContourTextPrimitive2D &rSdrContourTextPrimitive, const drawinglayer::geometry::ViewInformation2D &aViewInformation) const
void impDecomposeBlockTextPrimitive(drawinglayer::primitive2d::Primitive2DContainer &rTarget, const drawinglayer::primitive2d::SdrBlockTextPrimitive2D &rSdrBlockTextPrimitive, const drawinglayer::geometry::ViewInformation2D &aViewInformation) const
void impDecomposeStretchTextPrimitive(drawinglayer::primitive2d::Primitive2DContainer &rTarget, const drawinglayer::primitive2d::SdrStretchTextPrimitive2D &rSdrStretchTextPrimitive, const drawinglayer::geometry::ViewInformation2D &aViewInformation) const
void impDecomposeChainedTextPrimitive(drawinglayer::primitive2d::Primitive2DContainer &rTarget, const drawinglayer::primitive2d::SdrChainedTextPrimitive2D &rSdrChainedTextPrimitive, const drawinglayer::geometry::ViewInformation2D &aViewInformation) const
void ImpAutoFitText(SdrOutliner &rOutliner) const
Definition: svdotext.cxx:1263
SVX_DLLPRIVATE void ImpInitDrawOutliner(SdrOutliner &rOutl) const
Definition: svdotext.cxx:1174
SdrTextAniDirection GetTextAniDirection() const
Definition: svdotext.cxx:1844
void impGetScrollTextTiming(drawinglayer::animation::AnimationEntryList &rAnimList, double fFrameLength, double fTextLength) const
void impDecomposeAutoFitTextPrimitive(drawinglayer::primitive2d::Primitive2DContainer &rTarget, const drawinglayer::primitive2d::SdrAutoFitTextPrimitive2D &rSdrAutofitTextPrimitive, const drawinglayer::geometry::ViewInformation2D &aViewInformation) const
static void impDecomposeBlockTextPrimitiveDirect(drawinglayer::primitive2d::Primitive2DContainer &rTarget, SdrOutliner &rOutliner, const basegfx::B2DHomMatrix &rNewTransformA, const basegfx::B2DHomMatrix &rNewTransformB, const basegfx::B2DRange &rClipRange)
bool IsTextFrame() const
Definition: svdotext.hxx:359
SdrTextVertAdjust GetTextVerticalAdjust() const
Definition: svdotext.cxx:378
TextChain * GetTextChain() const
Definition: svdotext.cxx:1544
SdrTextAniKind GetTextAniKind() const
Definition: svdotext.cxx:1839
void impGetBlinkTextTiming(drawinglayer::animation::AnimationEntryList &rAnimList) const
void impHandleChainingEventsDuringDecomposition(SdrOutliner &rOutliner) const
OutlinerParaObject * GetOutlinerParaObject()
Definition: svdtext.cxx:78
const SfxItemSet & GetItemSet() const
Definition: svdtext.cxx:67
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
sal_uInt8 GetPropr() const
short GetEscapement() const
OUString CalcCaseMap(const OUString &rTxt) const
const OUString & GetRepresentation() const
SvxURLFormat GetFormat() const
const OUString & GetTargetFrame() const
const OUString & GetURL() const
bool IsOverflow() const
bool IsUnderflow() const
void ExecuteUnderflow(SdrOutliner *)
void ExecuteOverflow(SdrOutliner *, SdrOutliner *)
virtual void CheckForFlowEvents(SdrOutliner *)
void SetNilChainingEvent(const SdrTextObj *, bool)
Definition: textchain.cxx:43
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
void shearX(double fSx)
void rotate(double fRadiant)
void translate(double fX, double fY)
void scale(double fX, double fY)
void transform(const basegfx::B2DHomMatrix &rMatrix)
TYPE getWidth() const
void expand(const Tuple2D< TYPE > &rTuple)
bool isInside(const Tuple2D< TYPE > &rTuple) const
bool isEmpty() const
TYPE getHeight() const
TYPE getX() const
void setY(TYPE fY)
TYPE getY() const
void setX(TYPE fX)
void append(const AnimationEntry &rCandidate)
const css::uno::Reference< css::drawing::XDrawPage > & getVisualizedPage() const
const basegfx::B2DHomMatrix & getTextRangeTransform() const
const basegfx::B2DHomMatrix & getTextRangeTransform() const
const basegfx::B2DHomMatrix & getTextRangeTransform() const
const basegfx::B2DPolyPolygon & getUnitPolyPolygon() const
const basegfx::B2DHomMatrix & getObjectTransform() const
const basegfx::B2DHomMatrix & getTextRangeTransform() const
const OutlinerParaObject & getOutlinerParaObject() const
basegfx::B2DRange getTextBoundRect(const OUString &rText, sal_uInt32 nIndex, sal_uInt32 nLength) const
void setFont(const vcl::Font &rFont)
constexpr bool empty() const noexcept
@ AnchoredTextOverflowLegacy
for tdf#99729
double toRadians(D x)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
EEControlBits
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
#define DFLT_ESC_SUPER
#define MAX_ESC_POS
FilterGroup & rTarget
tools::Long FRound(double fVal)
uno_Any a
#define SAL_INFO(area, stream)
bool more(const T &rfValA, const T &rfValB)
bool equalZero(const T &rfVal)
bool equal(T const &rfValA, T const &rfValB)
bool less(const T &rfValA, const T &rfValB)
B2DHomMatrix createScaleB2DHomMatrix(double fScaleX, double fScaleY)
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
B2DHomMatrix createScaleShearXRotateTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fShearX, double fRadiant, double fTranslateX, double fTranslateY)
constexpr double deg2rad(double v)
rtl::Reference< BasePrimitive2D > Primitive2DReference
TextLine mapFontLineStyleToTextLine(FontLineStyle eLineStyle)
TextStrikeout mapFontStrikeoutToTextStrikeout(FontStrikeout eFontStrikeout)
attribute::FontAttribute getFontAttributeFromVclFont(basegfx::B2DVector &o_rSize, const vcl::Font &rFont, bool bRTL, bool bBiDiStrong)
int i
long Long
SdrTextAniDirection
Definition: sdtaditm.hxx:30
SdrTextVertAdjust
Definition: sdtaitm.hxx:29
@ SDRTEXTVERTADJUST_BOTTOM
Definition: sdtaitm.hxx:31
@ SDRTEXTVERTADJUST_BLOCK
Definition: sdtaitm.hxx:32
@ SDRTEXTVERTADJUST_CENTER
Definition: sdtaitm.hxx:30
SdrTextHorzAdjust
Definition: sdtaitm.hxx:53
@ SDRTEXTHORZADJUST_LEFT
Definition: sdtaitm.hxx:53
@ SDRTEXTHORZADJUST_BLOCK
Definition: sdtaitm.hxx:56
@ SDRTEXTHORZADJUST_CENTER
Definition: sdtaitm.hxx:54
@ SDRTEXTHORZADJUST_RIGHT
Definition: sdtaitm.hxx:55
SdrTextAniKind
Animation type for text frame.
Definition: sdtakitm.hxx:29
@ Scroll
blinking
@ Slide
scroll back and forth
@ Alternate
scroll through
@ Blink
no animation
static SfxItemSet & rSet
constexpr TypedWhichId< SdrTextAniDelayItem > SDRATTR_TEXT_ANIDELAY(SDRATTR_MISC_FIRST+19)
constexpr TypedWhichId< SdrOnOffItem > SDRATTR_TEXT_CLIPVERTOVERFLOW(SDRATTR_MISC_FIRST+26)
constexpr TypedWhichId< SdrTextAniStartInsideItem > SDRATTR_TEXT_ANISTARTINSIDE(SDRATTR_MISC_FIRST+16)
constexpr TypedWhichId< SdrTextAniStopInsideItem > SDRATTR_TEXT_ANISTOPINSIDE(SDRATTR_MISC_FIRST+17)
constexpr TypedWhichId< SdrTextAniCountItem > SDRATTR_TEXT_ANICOUNT(SDRATTR_MISC_FIRST+18)
constexpr TypedWhichId< SdrTextAniAmountItem > SDRATTR_TEXT_ANIAMOUNT(SDRATTR_MISC_FIRST+20)
constexpr TypedWhichId< SdrCustomShapeGeometryItem > SDRATTR_CUSTOMSHAPE_GEOMETRY(SDRATTR_CUSTOMSHAPE_FIRST+2)
bool GetDraftFillColor(const SfxItemSet &rSet, Color &rCol)
Returns a replacement for an XFillStyle.
Definition: svdetc.cxx:240
SdrTextObj * DynCastSdrTextObj(SdrObject *pObj)
Definition: svdobj.cxx:3178
static void impCreateSlideTiming(const SfxItemSet &rSet, drawinglayer::animation::AnimationEntryList &rAnimList, bool bForward, double fTimeFullPath, double fFrequency)
static void impCreateAlternateTiming(const SfxItemSet &rSet, drawinglayer::animation::AnimationEntryList &rAnimList, double fRelativeTextLength, bool bForward, double fTimeFullPath, double fFrequency)
#define ENDLESS_LOOP
#define ENDLESS_TIME
#define PIXEL_DPI
static void impCreateScrollTiming(const SfxItemSet &rSet, drawinglayer::animation::AnimationEntryList &rAnimList, bool bForward, double fTimeFullPath, double fFrequency)
SvxAdjust
signed char sal_Int8
SdrPage * GetSdrPageFromXDrawPage(const uno::Reference< drawing::XDrawPage > &xDrawPage) noexcept
returns the SdrObject from the given StarOffice API wrapper
Definition: unopage.cxx:886
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)