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
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().IsAnchoredTextOverflowLegacy())
1025 {
1026 bAllowGrowVertical = bHorizontalIsBlock;
1027 bAllowGrowHorizontal = bVerticalIsBlock;
1028 }
1029
1030 if (bAllowGrowVertical)
1031 {
1032 // allow to grow vertical for horizontal texts
1033 aMaxAutoPaperSize.setHeight(1000000);
1034 }
1035 else if (bAllowGrowHorizontal)
1036 {
1037 // allow to grow horizontal for vertical texts
1038 aMaxAutoPaperSize.setWidth(1000000);
1039 }
1040
1041 rOutliner.SetMaxAutoPaperSize(aMaxAutoPaperSize);
1042 }
1043
1044 rOutliner.SetPaperSize(aNullSize);
1045 rOutliner.SetUpdateLayout(true);
1046 rOutliner.SetText(rSdrBlockTextPrimitive.getOutlinerParaObject());
1047 }
1048
1049 rOutliner.SetControlWord(nOriginalControlWord);
1050
1051 // now get back the layouted text size from outliner
1052 const Size aOutlinerTextSize(rOutliner.GetPaperSize());
1053 const basegfx::B2DVector aOutlinerScale(aOutlinerTextSize.Width(), aOutlinerTextSize.Height());
1054 basegfx::B2DVector aAdjustTranslate(0.0, 0.0);
1055
1056 // For draw objects containing text correct hor/ver alignment if text is bigger
1057 // than the object itself. Without that correction, the text would always be
1058 // formatted to the left edge (or top edge when vertical) of the draw object.
1059 if(!IsTextFrame() && !bIsCell)
1060 {
1061 if(aAnchorTextRange.getWidth() < aOutlinerScale.getX() && !bVerticalWriting)
1062 {
1063 // Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK,
1064 // else the alignment is wanted.
1065 if(SDRTEXTHORZADJUST_BLOCK == eHAdj)
1066 {
1067 SvxAdjust eAdjust = GetObjectItemSet().Get(EE_PARA_JUST).GetAdjust();
1068 switch(eAdjust)
1069 {
1070 case SvxAdjust::Left: eHAdj = SDRTEXTHORZADJUST_LEFT; break;
1071 case SvxAdjust::Right: eHAdj = SDRTEXTHORZADJUST_RIGHT; break;
1072 case SvxAdjust::Center: eHAdj = SDRTEXTHORZADJUST_CENTER; break;
1073 default: break;
1074 }
1075 }
1076 }
1077
1078 if(aAnchorTextRange.getHeight() < aOutlinerScale.getY() && bVerticalWriting)
1079 {
1080 // Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK,
1081 // else the alignment is wanted.
1082 if(SDRTEXTVERTADJUST_BLOCK == eVAdj)
1083 {
1085 }
1086 }
1087 }
1088
1089 // correct horizontal translation using the now known text size
1090 if(SDRTEXTHORZADJUST_CENTER == eHAdj || SDRTEXTHORZADJUST_RIGHT == eHAdj)
1091 {
1092 const double fFree(aAnchorTextRange.getWidth() - aOutlinerScale.getX());
1093
1094 if(SDRTEXTHORZADJUST_CENTER == eHAdj)
1095 {
1096 aAdjustTranslate.setX(fFree / 2.0);
1097 }
1098
1099 if(SDRTEXTHORZADJUST_RIGHT == eHAdj)
1100 {
1101 aAdjustTranslate.setX(fFree);
1102 }
1103 }
1104
1105 // correct vertical translation using the now known text size
1106 if(SDRTEXTVERTADJUST_CENTER == eVAdj || SDRTEXTVERTADJUST_BOTTOM == eVAdj)
1107 {
1108 const double fFree(aAnchorTextRange.getHeight() - aOutlinerScale.getY());
1109
1110 if(SDRTEXTVERTADJUST_CENTER == eVAdj)
1111 {
1112 aAdjustTranslate.setY(fFree / 2.0);
1113 }
1114
1115 if(SDRTEXTVERTADJUST_BOTTOM == eVAdj)
1116 {
1117 aAdjustTranslate.setY(fFree);
1118 }
1119 }
1120
1121 // prepare matrices to apply to newly created primitives. aNewTransformA
1122 // will get coordinates in aOutlinerScale size and positive in X, Y.
1123 // Translate relative to given primitive to get same rotation and shear
1124 // as the master shape we are working on. For vertical, use the top-right
1125 // corner
1126 const double fStartInX(bVerticalWriting && bTopToBottom ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
1127 const double fStartInY(bVerticalWriting && !bTopToBottom ? aAdjustTranslate.getY() + aOutlinerScale.getY() : aAdjustTranslate.getY());
1128 basegfx::B2DHomMatrix aNewTransformA(basegfx::utils::createTranslateB2DHomMatrix(fStartInX, fStartInY));
1129
1130 // Apply the camera rotation. It have to be applied after adjustment of
1131 // the text (top, bottom, center, left, right).
1132 if(GetCameraZRotation() != 0)
1133 {
1134 // First find the text rect.
1135 basegfx::B2DRange aTextRectangle(/*x1=*/aTranslate.getX() + aAdjustTranslate.getX(),
1136 /*y1=*/aTranslate.getY() + aAdjustTranslate.getY(),
1137 /*x2=*/aTranslate.getX() + aOutlinerScale.getX() - aAdjustTranslate.getX(),
1138 /*y2=*/aTranslate.getY() + aOutlinerScale.getY() - aAdjustTranslate.getY());
1139
1140 // Rotate the text from the center point.
1141 basegfx::B2DVector aTranslateToCenter(aTextRectangle.getWidth() / 2, aTextRectangle.getHeight() / 2);
1142 aNewTransformA.translate(-aTranslateToCenter.getX(), -aTranslateToCenter.getY());
1143 aNewTransformA.rotate(basegfx::deg2rad(360.0 - GetCameraZRotation() ));
1144 aNewTransformA.translate(aTranslateToCenter.getX(), aTranslateToCenter.getY());
1145 }
1146
1147 // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
1148 // move the null point which was top left to bottom right.
1149 const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
1150 const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
1151
1152 // in-between the translations of the single primitives will take place. Afterwards,
1153 // the object's transformations need to be applied
1155 bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
1156 fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
1157
1158
1159 // create ClipRange (if needed)
1160 basegfx::B2DRange aClipRange;
1161
1162 // now break up text primitives.
1163 impTextBreakupHandler aConverter(rOutliner);
1164 aConverter.decomposeBlockTextPrimitive(aNewTransformA, aNewTransformB, aClipRange);
1165
1166 // cleanup outliner
1167 rOutliner.SetBackgroundColor(aOriginalBackColor);
1168 rOutliner.Clear();
1169 rOutliner.setVisualizedPage(nullptr);
1170
1171 rTarget = aConverter.extractPrimitive2DSequence();
1172}
1173
1176 const drawinglayer::primitive2d::SdrStretchTextPrimitive2D& rSdrStretchTextPrimitive,
1177 const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
1178{
1179 // decompose matrix to have position and size of text
1180 basegfx::B2DVector aScale, aTranslate;
1181 double fRotate, fShearX;
1182 rSdrStretchTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
1183
1184 // prepare outliner
1185 SolarMutexGuard aSolarGuard;
1186 SdrOutliner& rOutliner = ImpGetDrawOutliner();
1187 const EEControlBits nOriginalControlWord(rOutliner.GetControlWord());
1188 const Size aNullSize;
1189
1190 rOutliner.SetControlWord(nOriginalControlWord|EEControlBits::STRETCHING|EEControlBits::AUTOPAGESIZE);
1191 rOutliner.SetFixedCellHeight(rSdrStretchTextPrimitive.isFixedCellHeight());
1192 rOutliner.SetMinAutoPaperSize(aNullSize);
1193 rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
1194 rOutliner.SetPaperSize(aNullSize);
1195 rOutliner.SetUpdateLayout(true);
1196 rOutliner.SetText(rSdrStretchTextPrimitive.getOutlinerParaObject());
1197
1198 // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
1199 rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
1200
1201 // now get back the laid out text size from outliner
1202 const Size aOutlinerTextSize(rOutliner.CalcTextSize());
1203 const basegfx::B2DVector aOutlinerScale(
1204 aOutlinerTextSize.Width() == tools::Long(0) ? 1.0 : aOutlinerTextSize.Width(),
1205 aOutlinerTextSize.Height() == tools::Long(0) ? 1.0 : aOutlinerTextSize.Height());
1206
1207 // prepare matrices to apply to newly created primitives
1208 basegfx::B2DHomMatrix aNewTransformA;
1209
1210 // #i101957# Check for vertical text. If used, aNewTransformA
1211 // needs to translate the text initially around object width to orient
1212 // it relative to the topper right instead of the topper left
1213 const bool bVertical(rSdrStretchTextPrimitive.getOutlinerParaObject().IsEffectivelyVertical());
1214 const bool bTopToBottom(rSdrStretchTextPrimitive.getOutlinerParaObject().IsTopToBottom());
1215
1216 if(bVertical)
1217 {
1218 if(bTopToBottom)
1219 aNewTransformA.translate(aScale.getX(), 0.0);
1220 else
1221 aNewTransformA.translate(0.0, aScale.getY());
1222 }
1223
1224 // calculate global char stretching scale parameters. Use non-mirrored sizes
1225 // to layout without mirroring
1226 const double fScaleX(fabs(aScale.getX()) / aOutlinerScale.getX());
1227 const double fScaleY(fabs(aScale.getY()) / aOutlinerScale.getY());
1228 rOutliner.SetGlobalCharStretching(fScaleX * 100.0, fScaleY * 100.0);
1229
1230 // When mirroring in X and Y,
1231 // move the null point which was top left to bottom right.
1232 const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
1233 const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
1234
1235 // in-between the translations of the single primitives will take place. Afterwards,
1236 // the object's transformations need to be applied
1238 bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
1239 fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
1240
1241 // now break up text primitives.
1242 impTextBreakupHandler aConverter(rOutliner);
1243 aConverter.decomposeStretchTextPrimitive(aNewTransformA, aNewTransformB);
1244
1245 // cleanup outliner
1246 rOutliner.SetControlWord(nOriginalControlWord);
1247 rOutliner.Clear();
1248 rOutliner.setVisualizedPage(nullptr);
1249
1250 rTarget = aConverter.extractPrimitive2DSequence();
1251}
1252
1253
1254// timing generators
1255#define ENDLESS_LOOP (0xffffffff)
1256#define ENDLESS_TIME (double(0xffffffff))
1257#define PIXEL_DPI (96.0)
1258
1260{
1262 return;
1263
1264 // get values
1265 const SfxItemSet& rSet = GetObjectItemSet();
1266 const sal_uInt32 nRepeat(static_cast<sal_uInt32>(rSet.Get(SDRATTR_TEXT_ANICOUNT).GetValue()));
1267 double fDelay(static_cast<double>(rSet.Get(SDRATTR_TEXT_ANIDELAY).GetValue()));
1268
1269 if(0.0 == fDelay)
1270 {
1271 // use default
1272 fDelay = 250.0;
1273 }
1274
1275 // prepare loop and add
1278 aLoop.append(aStart);
1280 aLoop.append(aEnd);
1281 rAnimList.append(aLoop);
1282
1283 // add stopped state if loop is not endless
1284 if(0 != nRepeat)
1285 {
1286 bool bVisibleWhenStopped(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE).GetValue());
1287 drawinglayer::animation::AnimationEntryFixed aStop(ENDLESS_TIME, bVisibleWhenStopped ? 0.0 : 1.0);
1288 rAnimList.append(aStop);
1289 }
1290}
1291
1292static void impCreateScrollTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, bool bForward, double fTimeFullPath, double fFrequency)
1293{
1294 bool bVisibleWhenStopped(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE).GetValue());
1295 bool bVisibleWhenStarted(rSet.Get(SDRATTR_TEXT_ANISTARTINSIDE).GetValue());
1296 const sal_uInt32 nRepeat(rSet.Get(SDRATTR_TEXT_ANICOUNT).GetValue());
1297
1298 if(bVisibleWhenStarted)
1299 {
1300 // move from center to outside
1301 drawinglayer::animation::AnimationEntryLinear aInOut(fTimeFullPath * 0.5, fFrequency, 0.5, bForward ? 1.0 : 0.0);
1302 rAnimList.append(aInOut);
1303 }
1304
1305 // loop. In loop, move through
1307 drawinglayer::animation::AnimationEntryLinear aThrough(fTimeFullPath, fFrequency, bForward ? 0.0 : 1.0, bForward ? 1.0 : 0.0);
1308 aLoop.append(aThrough);
1309 rAnimList.append(aLoop);
1310
1311 if(0 != nRepeat && bVisibleWhenStopped)
1312 {
1313 // move from outside to center
1314 drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, bForward ? 0.0 : 1.0, 0.5);
1315 rAnimList.append(aOutIn);
1316
1317 // add timing for staying at the end
1319 rAnimList.append(aEnd);
1320 }
1321}
1322
1323static void impCreateAlternateTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, double fRelativeTextLength, bool bForward, double fTimeFullPath, double fFrequency)
1324{
1325 if(basegfx::fTools::more(fRelativeTextLength, 0.5))
1326 {
1327 // this is the case when fTextLength > fFrameLength, text is bigger than animation frame.
1328 // In that case, correct direction
1329 bForward = !bForward;
1330 }
1331
1332 const double fStartPosition(bForward ? fRelativeTextLength : 1.0 - fRelativeTextLength);
1333 const double fEndPosition(bForward ? 1.0 - fRelativeTextLength : fRelativeTextLength);
1334 bool bVisibleWhenStarted(rSet.Get(SDRATTR_TEXT_ANISTARTINSIDE).GetValue());
1335 const sal_uInt32 nRepeat(rSet.Get(SDRATTR_TEXT_ANICOUNT).GetValue());
1336
1337 if(!bVisibleWhenStarted)
1338 {
1339 // move from outside to center
1340 drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, bForward ? 0.0 : 1.0, 0.5);
1341 rAnimList.append(aOutIn);
1342 }
1343
1344 // loop. In loop, move out and in again. fInnerMovePath may be negative when text is bigger then frame,
1345 // so use absolute value
1346 const double fInnerMovePath(fabs(1.0 - (fRelativeTextLength * 2.0)));
1347 const double fTimeForInnerPath(fTimeFullPath * fInnerMovePath);
1348 const double fHalfInnerPath(fTimeForInnerPath * 0.5);
1349 const sal_uInt32 nDoubleRepeat(nRepeat / 2L);
1350
1351 if(nDoubleRepeat || 0 == nRepeat)
1352 {
1353 // double forth and back loop
1354 drawinglayer::animation::AnimationEntryLoop aLoop(nDoubleRepeat ? nDoubleRepeat : ENDLESS_LOOP);
1355 drawinglayer::animation::AnimationEntryLinear aTime0(fHalfInnerPath, fFrequency, 0.5, fEndPosition);
1356 aLoop.append(aTime0);
1357 drawinglayer::animation::AnimationEntryLinear aTime1(fTimeForInnerPath, fFrequency, fEndPosition, fStartPosition);
1358 aLoop.append(aTime1);
1359 drawinglayer::animation::AnimationEntryLinear aTime2(fHalfInnerPath, fFrequency, fStartPosition, 0.5);
1360 aLoop.append(aTime2);
1361 rAnimList.append(aLoop);
1362 }
1363
1364 if(nRepeat % 2L)
1365 {
1366 // repeat is uneven, so we need one more forth and back to center
1367 drawinglayer::animation::AnimationEntryLinear aTime0(fHalfInnerPath, fFrequency, 0.5, fEndPosition);
1368 rAnimList.append(aTime0);
1369 drawinglayer::animation::AnimationEntryLinear aTime1(fHalfInnerPath, fFrequency, fEndPosition, 0.5);
1370 rAnimList.append(aTime1);
1371 }
1372
1373 if(0 == nRepeat)
1374 return;
1375
1376 bool bVisibleWhenStopped(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE).GetValue());
1377 if(bVisibleWhenStopped)
1378 {
1379 // add timing for staying at the end
1381 rAnimList.append(aEnd);
1382 }
1383 else
1384 {
1385 // move from center to outside
1386 drawinglayer::animation::AnimationEntryLinear aInOut(fTimeFullPath * 0.5, fFrequency, 0.5, bForward ? 1.0 : 0.0);
1387 rAnimList.append(aInOut);
1388 }
1389}
1390
1391static void impCreateSlideTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, bool bForward, double fTimeFullPath, double fFrequency)
1392{
1393 // move in from outside, start outside
1394 const double fStartPosition(bForward ? 0.0 : 1.0);
1395 const sal_uInt32 nRepeat(rSet.Get(SDRATTR_TEXT_ANICOUNT).GetValue());
1396
1397 // move from outside to center
1398 drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, fStartPosition, 0.5);
1399 rAnimList.append(aOutIn);
1400
1401 // loop. In loop, move out and in again
1402 if(nRepeat > 1 || 0 == nRepeat)
1403 {
1404 drawinglayer::animation::AnimationEntryLoop aLoop(nRepeat ? nRepeat - 1 : ENDLESS_LOOP);
1405 drawinglayer::animation::AnimationEntryLinear aTime0(fTimeFullPath * 0.5, fFrequency, 0.5, fStartPosition);
1406 aLoop.append(aTime0);
1407 drawinglayer::animation::AnimationEntryLinear aTime1(fTimeFullPath * 0.5, fFrequency, fStartPosition, 0.5);
1408 aLoop.append(aTime1);
1409 rAnimList.append(aLoop);
1410 }
1411
1412 // always visible when stopped, so add timing for staying at the end when not endless
1413 if(0 != nRepeat)
1414 {
1416 rAnimList.append(aEnd);
1417 }
1418}
1419
1420void SdrTextObj::impGetScrollTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList, double fFrameLength, double fTextLength) const
1421{
1422 const SdrTextAniKind eAniKind(GetTextAniKind());
1423
1424 if(SdrTextAniKind::Scroll != eAniKind && SdrTextAniKind::Alternate != eAniKind && SdrTextAniKind::Slide != eAniKind)
1425 return;
1426
1427 // get data. Goal is to calculate fTimeFullPath which is the time needed to
1428 // move animation from (0.0) to (1.0) state
1429 const SfxItemSet& rSet = GetObjectItemSet();
1430 double fAnimationDelay(static_cast<double>(rSet.Get(SDRATTR_TEXT_ANIDELAY).GetValue()));
1431 double fSingleStepWidth(static_cast<double>(rSet.Get(SDRATTR_TEXT_ANIAMOUNT).GetValue()));
1432 const SdrTextAniDirection eDirection(GetTextAniDirection());
1433 const bool bForward(SdrTextAniDirection::Right == eDirection || SdrTextAniDirection::Down == eDirection);
1434
1435 if(basegfx::fTools::equalZero(fAnimationDelay))
1436 {
1437 // default to 1/20 second
1438 fAnimationDelay = 50.0;
1439 }
1440
1441 if(basegfx::fTools::less(fSingleStepWidth, 0.0))
1442 {
1443 // data is in pixels, convert to logic. Imply PIXEL_DPI dpi.
1444 // It makes no sense to keep the view-transformation centered
1445 // definitions, so get rid of them here.
1446 fSingleStepWidth = (-fSingleStepWidth * (2540.0 / PIXEL_DPI));
1447 }
1448
1449 if(basegfx::fTools::equalZero(fSingleStepWidth))
1450 {
1451 // default to 1 millimeter
1452 fSingleStepWidth = 100.0;
1453 }
1454
1455 // use the length of the full animation path and the number of steps
1456 // to get the full path time
1457 const double fFullPathLength(fFrameLength + fTextLength);
1458 const double fNumberOfSteps(fFullPathLength / fSingleStepWidth);
1459 double fTimeFullPath(fNumberOfSteps * fAnimationDelay);
1460
1461 if(fTimeFullPath < fAnimationDelay)
1462 {
1463 fTimeFullPath = fAnimationDelay;
1464 }
1465
1466 switch(eAniKind)
1467 {
1469 {
1470 impCreateScrollTiming(rSet, rAnimList, bForward, fTimeFullPath, fAnimationDelay);
1471 break;
1472 }
1474 {
1475 double fRelativeTextLength(fTextLength / (fFrameLength + fTextLength));
1476 impCreateAlternateTiming(rSet, rAnimList, fRelativeTextLength, bForward, fTimeFullPath, fAnimationDelay);
1477 break;
1478 }
1480 {
1481 impCreateSlideTiming(rSet, rAnimList, bForward, fTimeFullPath, fAnimationDelay);
1482 break;
1483 }
1484 default : break; // SdrTextAniKind::NONE, SdrTextAniKind::Blink
1485 }
1486}
1487
1489{
1490 if (GetTextChain()->GetNilChainingEvent(this))
1491 return;
1492
1493 GetTextChain()->SetNilChainingEvent(this, true);
1494
1495 TextChainFlow aTxtChainFlow(const_cast<SdrTextObj*>(this));
1496 bool bIsOverflow;
1497
1498#ifdef DBG_UTIL
1499 // Some debug output
1500 size_t nObjCount(getSdrPageFromSdrObject()->GetObjCount());
1501 for (size_t i = 0; i < nObjCount; i++)
1502 {
1504 if(pCurObj == this)
1505 {
1506 SAL_INFO("svx.chaining", "Working on TextBox " << i);
1507 break;
1508 }
1509 }
1510#endif
1511
1512 aTxtChainFlow.CheckForFlowEvents(&rOutliner);
1513
1514 if (aTxtChainFlow.IsUnderflow() && !IsInEditMode())
1515 {
1516 // underflow-induced overflow
1517 aTxtChainFlow.ExecuteUnderflow(&rOutliner);
1518 bIsOverflow = aTxtChainFlow.IsOverflow();
1519 } else {
1520 // standard overflow (no underflow before)
1521 bIsOverflow = aTxtChainFlow.IsOverflow();
1522 }
1523
1524 if (bIsOverflow && !IsInEditMode()) {
1525 // Initialize Chaining Outliner
1526 SdrOutliner &rChainingOutl(getSdrModelFromSdrObject().GetChainingOutliner(this));
1527 ImpInitDrawOutliner( rChainingOutl );
1528 rChainingOutl.SetUpdateLayout(true);
1529 // We must pass the chaining outliner otherwise we would mess up decomposition
1530 aTxtChainFlow.ExecuteOverflow(&rOutliner, &rChainingOutl);
1531 }
1532
1533 GetTextChain()->SetNilChainingEvent(this, false);
1534}
1535
1538 const drawinglayer::primitive2d::SdrChainedTextPrimitive2D& rSdrChainedTextPrimitive,
1539 const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
1540{
1541 // decompose matrix to have position and size of text
1542 basegfx::B2DVector aScale, aTranslate;
1543 double fRotate, fShearX;
1544 rSdrChainedTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
1545
1546 // use B2DRange aAnchorTextRange for calculations
1547 basegfx::B2DRange aAnchorTextRange(aTranslate);
1548 aAnchorTextRange.expand(aTranslate + aScale);
1549
1550 // prepare outliner
1551 const SfxItemSet& rTextItemSet = rSdrChainedTextPrimitive.getSdrText()->GetItemSet();
1552 SolarMutexGuard aSolarGuard;
1553 SdrOutliner& rOutliner = ImpGetDrawOutliner();
1554
1555 SdrTextVertAdjust eVAdj = GetTextVerticalAdjust(rTextItemSet);
1556 SdrTextHorzAdjust eHAdj = GetTextHorizontalAdjust(rTextItemSet);
1557 const EEControlBits nOriginalControlWord(rOutliner.GetControlWord());
1558 const Size aNullSize;
1559
1560 // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
1561 rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
1562
1563 rOutliner.SetControlWord(nOriginalControlWord|EEControlBits::AUTOPAGESIZE|EEControlBits::STRETCHING);
1564 rOutliner.SetMinAutoPaperSize(aNullSize);
1565 rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
1566
1567 // add one to range sizes to get back to the old Rectangle and outliner measurements
1568 const sal_uInt32 nAnchorTextWidth(FRound(aAnchorTextRange.getWidth() + 1));
1569 const sal_uInt32 nAnchorTextHeight(FRound(aAnchorTextRange.getHeight() + 1));
1570
1571 // Text
1572 const OutlinerParaObject* pOutlinerParaObject = rSdrChainedTextPrimitive.getSdrText()->GetOutlinerParaObject();
1573 OSL_ENSURE(pOutlinerParaObject, "impDecomposeBlockTextPrimitive used with no OutlinerParaObject (!)");
1574
1575 const bool bVerticalWriting(pOutlinerParaObject->IsEffectivelyVertical());
1576 const bool bTopToBottom(pOutlinerParaObject->IsTopToBottom());
1577 const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
1578
1579 if(IsTextFrame())
1580 {
1581 rOutliner.SetMaxAutoPaperSize(aAnchorTextSize);
1582 }
1583
1584 if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !bVerticalWriting)
1585 {
1586 rOutliner.SetMinAutoPaperSize(Size(nAnchorTextWidth, 0));
1587 }
1588
1589 if(SDRTEXTVERTADJUST_BLOCK == eVAdj && bVerticalWriting)
1590 {
1591 rOutliner.SetMinAutoPaperSize(Size(0, nAnchorTextHeight));
1592 }
1593
1594 rOutliner.SetPaperSize(aNullSize);
1595 rOutliner.SetUpdateLayout(true);
1596 // Sets original text
1597 rOutliner.SetText(*pOutlinerParaObject);
1598
1599 /* Begin overflow/underflow handling */
1600
1602
1603 /* End overflow/underflow handling */
1604
1605 // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
1606 rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
1607
1608 // now get back the layouted text size from outliner
1609 const Size aOutlinerTextSize(rOutliner.GetPaperSize());
1610 const basegfx::B2DVector aOutlinerScale(aOutlinerTextSize.Width(), aOutlinerTextSize.Height());
1611 basegfx::B2DVector aAdjustTranslate(0.0, 0.0);
1612
1613 // correct horizontal translation using the now known text size
1614 if(SDRTEXTHORZADJUST_CENTER == eHAdj || SDRTEXTHORZADJUST_RIGHT == eHAdj)
1615 {
1616 const double fFree(aAnchorTextRange.getWidth() - aOutlinerScale.getX());
1617
1618 if(SDRTEXTHORZADJUST_CENTER == eHAdj)
1619 {
1620 aAdjustTranslate.setX(fFree / 2.0);
1621 }
1622
1623 if(SDRTEXTHORZADJUST_RIGHT == eHAdj)
1624 {
1625 aAdjustTranslate.setX(fFree);
1626 }
1627 }
1628
1629 // correct vertical translation using the now known text size
1630 if(SDRTEXTVERTADJUST_CENTER == eVAdj || SDRTEXTVERTADJUST_BOTTOM == eVAdj)
1631 {
1632 const double fFree(aAnchorTextRange.getHeight() - aOutlinerScale.getY());
1633
1634 if(SDRTEXTVERTADJUST_CENTER == eVAdj)
1635 {
1636 aAdjustTranslate.setY(fFree / 2.0);
1637 }
1638
1639 if(SDRTEXTVERTADJUST_BOTTOM == eVAdj)
1640 {
1641 aAdjustTranslate.setY(fFree);
1642 }
1643 }
1644
1645 // prepare matrices to apply to newly created primitives. aNewTransformA
1646 // will get coordinates in aOutlinerScale size and positive in X, Y.
1647 basegfx::B2DHomMatrix aNewTransformA;
1648 basegfx::B2DHomMatrix aNewTransformB;
1649
1650 // translate relative to given primitive to get same rotation and shear
1651 // as the master shape we are working on. For vertical, use the top-right
1652 // corner
1653 const double fStartInX(bVerticalWriting && bTopToBottom ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
1654 const double fStartInY(bVerticalWriting && !bTopToBottom ? aAdjustTranslate.getY() + aOutlinerScale.getY() : aAdjustTranslate.getY());
1655 aNewTransformA.translate(fStartInX, fStartInY);
1656
1657 // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
1658 // move the null point which was top left to bottom right.
1659 const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
1660 const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
1661 aNewTransformB.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0);
1662
1663 // in-between the translations of the single primitives will take place. Afterwards,
1664 // the object's transformations need to be applied
1665 aNewTransformB.shearX(fShearX);
1666 aNewTransformB.rotate(fRotate);
1667 aNewTransformB.translate(aTranslate.getX(), aTranslate.getY());
1668
1669 basegfx::B2DRange aClipRange;
1670
1671 // now break up text primitives.
1672 impTextBreakupHandler aConverter(rOutliner);
1673 aConverter.decomposeBlockTextPrimitive(aNewTransformA, aNewTransformB, aClipRange);
1674
1675 // cleanup outliner
1676 rOutliner.Clear();
1677 rOutliner.setVisualizedPage(nullptr);
1678 rOutliner.SetControlWord(nOriginalControlWord);
1679
1680 rTarget = aConverter.extractPrimitive2DSequence();
1681}
1682
1683// Direct decomposer for text visualization when you already have a prepared
1684// Outliner containing all the needed information
1687 SdrOutliner& rOutliner,
1688 const basegfx::B2DHomMatrix& rNewTransformA,
1689 const basegfx::B2DHomMatrix& rNewTransformB,
1690 const basegfx::B2DRange& rClipRange)
1691{
1692 impTextBreakupHandler aConverter(rOutliner);
1693 aConverter.decomposeBlockTextPrimitive(rNewTransformA, rNewTransformB, rClipRange);
1694 rTarget.append(aConverter.extractPrimitive2DSequence());
1695}
1696
1698{
1699 const css::uno::Any* pAny;
1700 double fTextCameraZRotateAngle = 0.0;
1701 const SfxItemSet& rSet = GetObjectItemSet();
1703
1704 pAny = rGeometryItem.GetPropertyValueByName("TextCameraZRotateAngle");
1705
1706 if ( pAny )
1707 *pAny >>= fTextCameraZRotateAngle;
1708
1709 return fTextCameraZRotateAngle;
1710}
1711
1712/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPL_LINK(MaskData, PipetteHdl, const OString &, 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 SetGlobalCharStretching(double nX=100.0, double nY=100.0)
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 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:710
SdrPage * getSdrPageFromSdrObject() const
Definition: svdobj.cxx:279
const SfxItemSet * getBackgroundFillSet() const
const SfxItemSet & GetObjectItemSet() const
Definition: svdobj.cxx:1972
void setVisualizedPage(const SdrPage *pPage)
Definition: svdoutl.hxx:42
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:1666
bool IsMasterPage() const
Definition: svdpage.hxx:462
bool TRG_HasMasterPage() const
Definition: svdpage.hxx:498
SdrPageProperties & getSdrPageProperties()
Definition: svdpage.cxx:1887
SdrTextHorzAdjust GetTextHorizontalAdjust() const
Definition: svdotext.cxx:340
double GetCameraZRotation() const
SdrOutliner & ImpGetDrawOutliner() const
Definition: svdotext.cxx:1179
bool IsInEditMode() const
Definition: svdotext.hxx:312
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:1237
SVX_DLLPRIVATE void ImpInitDrawOutliner(SdrOutliner &rOutl) const
Definition: svdotext.cxx:1160
SdrTextAniDirection GetTextAniDirection() const
Definition: svdotext.cxx:1776
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:332
SdrTextVertAdjust GetTextVerticalAdjust() const
Definition: svdotext.cxx:372
TextChain * GetTextChain() const
Definition: svdotext.cxx:1476
SdrTextAniKind GetTextAniKind() const
Definition: svdotext.cxx:1771
void impGetBlinkTextTiming(drawinglayer::animation::AnimationEntryList &rAnimList) const
void impHandleChainingEventsDuringDecomposition(SdrOutliner &rOutliner) const
OutlinerParaObject * GetOutlinerParaObject()
Definition: svdtext.cxx:88
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
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< 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:248
SdrTextObj * DynCastSdrTextObj(SdrObject *pObj)
Definition: svdobj.cxx:3217
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)