LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdotextdecomposition.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 276 578 47.8 %
Date: 2014-11-03 Functions: 17 37 45.9 %
Legend: Lines: hit not hit

          Line data    Source code
       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 <basegfx/vector/b2dvector.hxx>
      26             : #include <sdr/primitive2d/sdrtextprimitive2d.hxx>
      27             : #include <drawinglayer/primitive2d/textprimitive2d.hxx>
      28             : #include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
      29             : #include <basegfx/range/b2drange.hxx>
      30             : #include <editeng/editstat.hxx>
      31             : #include <tools/helpers.hxx>
      32             : #include <svx/sdtfchim.hxx>
      33             : #include <svl/itemset.hxx>
      34             : #include <basegfx/polygon/b2dpolygontools.hxx>
      35             : #include <basegfx/polygon/b2dpolygon.hxx>
      36             : #include <drawinglayer/animation/animationtiming.hxx>
      37             : #include <basegfx/color/bcolor.hxx>
      38             : #include <vcl/svapp.hxx>
      39             : #include <editeng/eeitemid.hxx>
      40             : #include <editeng/escapementitem.hxx>
      41             : #include <editeng/svxenum.hxx>
      42             : #include <editeng/flditem.hxx>
      43             : #include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx>
      44             : #include <vcl/metaact.hxx>
      45             : #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
      46             : #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
      47             : #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
      48             : #include <svx/unoapi.hxx>
      49             : #include <drawinglayer/geometry/viewinformation2d.hxx>
      50             : #include <editeng/outlobj.hxx>
      51             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      52             : 
      53             : using namespace com::sun::star;
      54             : 
      55             : // helpers
      56             : 
      57             : namespace
      58             : {
      59       48409 :     drawinglayer::primitive2d::Primitive2DSequence impConvertVectorToPrimitive2DSequence(const std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rPrimitiveVector)
      60             :     {
      61       48409 :         const sal_Int32 nCount(rPrimitiveVector.size());
      62       48409 :         drawinglayer::primitive2d::Primitive2DSequence aRetval(nCount);
      63             : 
      64      103854 :         for(sal_Int32 a(0L); a < nCount; a++)
      65             :         {
      66       55445 :             aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(rPrimitiveVector[a]);
      67             :         }
      68             : 
      69       48409 :         return aRetval;
      70             :     }
      71             : 
      72       13266 :     class impTextBreakupHandler
      73             :     {
      74             :     private:
      75             :         std::vector< drawinglayer::primitive2d::BasePrimitive2D* >  maTextPortionPrimitives;
      76             :         std::vector< drawinglayer::primitive2d::BasePrimitive2D* >  maLinePrimitives;
      77             :         std::vector< drawinglayer::primitive2d::BasePrimitive2D* >  maParagraphPrimitives;
      78             : 
      79             :         SdrOutliner&                                                mrOutliner;
      80             :         basegfx::B2DHomMatrix                                       maNewTransformA;
      81             :         basegfx::B2DHomMatrix                                       maNewTransformB;
      82             : 
      83             :         // the visible area for contour text decomposition
      84             :         basegfx::B2DVector                                          maScale;
      85             : 
      86             :         // ClipRange for BlockText decomposition; only text portions completely
      87             :         // inside are to be accepted, so this is different from geometric clipping
      88             :         // (which would allow e.g. upper parts of portions to remain). Only used for
      89             :         // BlockText (see there)
      90             :         basegfx::B2DRange                                           maClipRange;
      91             : 
      92             :         DECL_LINK(decomposeContourTextPrimitive, DrawPortionInfo* );
      93             :         DECL_LINK(decomposeBlockTextPrimitive, DrawPortionInfo* );
      94             :         DECL_LINK(decomposeStretchTextPrimitive, DrawPortionInfo* );
      95             : 
      96             :         DECL_LINK(decomposeContourBulletPrimitive, DrawBulletInfo* );
      97             :         DECL_LINK(decomposeBlockBulletPrimitive, DrawBulletInfo* );
      98             :         DECL_LINK(decomposeStretchBulletPrimitive, DrawBulletInfo* );
      99             : 
     100             :         bool impIsUnderlineAbove(const vcl::Font& rFont) const;
     101             :         void impCreateTextPortionPrimitive(const DrawPortionInfo& rInfo);
     102             :         drawinglayer::primitive2d::BasePrimitive2D* impCheckFieldPrimitive(drawinglayer::primitive2d::BasePrimitive2D* pPrimitive, const DrawPortionInfo& rInfo) const;
     103             :         void impFlushTextPortionPrimitivesToLinePrimitives();
     104             :         void impFlushLinePrimitivesToParagraphPrimitives();
     105             :         void impHandleDrawPortionInfo(const DrawPortionInfo& rInfo);
     106             :         void impHandleDrawBulletInfo(const DrawBulletInfo& rInfo);
     107             : 
     108             :     public:
     109       13266 :         impTextBreakupHandler(SdrOutliner& rOutliner)
     110             :         :   maTextPortionPrimitives(),
     111             :             maLinePrimitives(),
     112             :             maParagraphPrimitives(),
     113             :             mrOutliner(rOutliner),
     114             :             maNewTransformA(),
     115             :             maNewTransformB(),
     116             :             maScale(),
     117       13266 :             maClipRange()
     118             :         {
     119       13266 :         }
     120             : 
     121           0 :         void decomposeContourTextPrimitive(const basegfx::B2DHomMatrix& rNewTransformA, const basegfx::B2DHomMatrix& rNewTransformB, const basegfx::B2DVector& rScale)
     122             :         {
     123           0 :             maScale = rScale;
     124           0 :             maNewTransformA = rNewTransformA;
     125           0 :             maNewTransformB = rNewTransformB;
     126           0 :             mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decomposeContourTextPrimitive));
     127           0 :             mrOutliner.SetDrawBulletHdl(LINK(this, impTextBreakupHandler, decomposeContourBulletPrimitive));
     128           0 :             mrOutliner.StripPortions();
     129           0 :             mrOutliner.SetDrawPortionHdl(Link());
     130           0 :             mrOutliner.SetDrawBulletHdl(Link());
     131           0 :         }
     132             : 
     133       13266 :         void decomposeBlockTextPrimitive(
     134             :             const basegfx::B2DHomMatrix& rNewTransformA,
     135             :             const basegfx::B2DHomMatrix& rNewTransformB,
     136             :             const basegfx::B2DRange& rClipRange)
     137             :         {
     138       13266 :             maNewTransformA = rNewTransformA;
     139       13266 :             maNewTransformB = rNewTransformB;
     140       13266 :             maClipRange = rClipRange;
     141       13266 :             mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decomposeBlockTextPrimitive));
     142       13266 :             mrOutliner.SetDrawBulletHdl(LINK(this, impTextBreakupHandler, decomposeBlockBulletPrimitive));
     143       13266 :             mrOutliner.StripPortions();
     144       13266 :             mrOutliner.SetDrawPortionHdl(Link());
     145       13266 :             mrOutliner.SetDrawBulletHdl(Link());
     146       13266 :         }
     147             : 
     148           0 :         void decomposeStretchTextPrimitive(const basegfx::B2DHomMatrix& rNewTransformA, const basegfx::B2DHomMatrix& rNewTransformB)
     149             :         {
     150           0 :             maNewTransformA = rNewTransformA;
     151           0 :             maNewTransformB = rNewTransformB;
     152           0 :             mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decomposeStretchTextPrimitive));
     153           0 :             mrOutliner.SetDrawBulletHdl(LINK(this, impTextBreakupHandler, decomposeStretchBulletPrimitive));
     154           0 :             mrOutliner.StripPortions();
     155           0 :             mrOutliner.SetDrawPortionHdl(Link());
     156           0 :             mrOutliner.SetDrawBulletHdl(Link());
     157           0 :         }
     158             : 
     159             :         drawinglayer::primitive2d::Primitive2DSequence getPrimitive2DSequence();
     160             :     };
     161             : 
     162        1998 :     bool impTextBreakupHandler::impIsUnderlineAbove(const vcl::Font& rFont) const
     163             :     {
     164        1998 :         if(!rFont.IsVertical())
     165             :         {
     166        1998 :             return false;
     167             :         }
     168             : 
     169           0 :         if((LANGUAGE_JAPANESE == rFont.GetLanguage()) || (LANGUAGE_JAPANESE == rFont.GetCJKContextLanguage()))
     170             :         {
     171             :             // the underline is right for Japanese only
     172           0 :             return true;
     173             :         }
     174             : 
     175           0 :         return false;
     176             :     }
     177             : 
     178       21652 :     void impTextBreakupHandler::impCreateTextPortionPrimitive(const DrawPortionInfo& rInfo)
     179             :     {
     180       21652 :         if(!rInfo.maText.isEmpty() && rInfo.mnTextLen)
     181             :         {
     182       20302 :             OUString caseMappedText = rInfo.mrFont.CalcCaseMap( rInfo.maText );
     183       40604 :             basegfx::B2DVector aFontScaling;
     184             :             drawinglayer::attribute::FontAttribute aFontAttribute(
     185             :                 drawinglayer::primitive2d::getFontAttributeFromVclFont(
     186             :                     aFontScaling,
     187             :                     rInfo.mrFont,
     188       20302 :                     rInfo.IsRTL(),
     189       40604 :                     false));
     190       40604 :             basegfx::B2DHomMatrix aNewTransform;
     191             : 
     192             :             // add font scale to new transform
     193       20302 :             aNewTransform.scale(aFontScaling.getX(), aFontScaling.getY());
     194             : 
     195             :             // look for proportional font scaling, if necessary, scale accordingly
     196       20302 :             if(100 != rInfo.mrFont.GetPropr())
     197             :             {
     198           0 :                 const double fFactor(rInfo.mrFont.GetPropr() / 100.0);
     199           0 :                 aNewTransform.scale(fFactor, fFactor);
     200             :             }
     201             : 
     202             :             // apply font rotate
     203       20302 :             if(rInfo.mrFont.GetOrientation())
     204             :             {
     205           4 :                 aNewTransform.rotate(-rInfo.mrFont.GetOrientation() * F_PI1800);
     206             :             }
     207             : 
     208             :             // look for escapement, if necessary, translate accordingly
     209       20302 :             if(rInfo.mrFont.GetEscapement())
     210             :             {
     211        1895 :                 sal_Int16 nEsc(rInfo.mrFont.GetEscapement());
     212             : 
     213        1895 :                 if(DFLT_ESC_AUTO_SUPER == nEsc)
     214             :                 {
     215           0 :                     nEsc = 33;
     216             :                 }
     217        1895 :                 else if(DFLT_ESC_AUTO_SUB == nEsc)
     218             :                 {
     219           0 :                     nEsc = -20;
     220             :                 }
     221             : 
     222        1895 :                 if(nEsc > 100)
     223             :                 {
     224           0 :                     nEsc = 100;
     225             :                 }
     226        1895 :                 else if(nEsc < -100)
     227             :                 {
     228           0 :                     nEsc = -100;
     229             :                 }
     230             : 
     231        1895 :                 const double fEscapement(nEsc / -100.0);
     232        1895 :                 aNewTransform.translate(0.0, fEscapement * aFontScaling.getY());
     233             :             }
     234             : 
     235             :             // apply transformA
     236       20302 :             aNewTransform *= maNewTransformA;
     237             : 
     238             :             // apply local offset
     239       20302 :             aNewTransform.translate(rInfo.mrStartPos.X(), rInfo.mrStartPos.Y());
     240             : 
     241             :             // also apply embedding object's transform
     242       20302 :             aNewTransform *= maNewTransformB;
     243             : 
     244             :             // prepare DXArray content. To make it independent from font size (and such from
     245             :             // the text transformation), scale it to unit coordinates
     246       40604 :             ::std::vector< double > aDXArray;
     247             :             static bool bDisableTextArray(false);
     248             : 
     249       20302 :             if(!bDisableTextArray && rInfo.mpDXArray && rInfo.mnTextLen)
     250             :             {
     251       20302 :                 aDXArray.reserve(rInfo.mnTextLen);
     252             : 
     253      169292 :                 for(sal_Int32 a=0; a < rInfo.mnTextLen; a++)
     254             :                 {
     255      148990 :                     aDXArray.push_back((double)rInfo.mpDXArray[a]);
     256             :                 }
     257             :             }
     258             : 
     259             :             // create complex text primitive and append
     260       20302 :             const Color aFontColor(rInfo.mrFont.GetColor());
     261       40604 :             const basegfx::BColor aBFontColor(aFontColor.getBColor());
     262             : 
     263       20302 :             const Color aTextFillColor(rInfo.mrFont.GetFillColor());
     264             : 
     265             :             // prepare wordLineMode (for underline and strikeout)
     266             :             // NOT for bullet texts. It is set (this may be an error by itself), but needs to be suppressed to hinder e.g. '1)'
     267             :             // to be split which would not look like the original
     268       20302 :             const bool bWordLineMode(rInfo.mrFont.IsWordLineMode() && !rInfo.mbEndOfBullet);
     269             : 
     270             :             // prepare new primitive
     271       20302 :             drawinglayer::primitive2d::BasePrimitive2D* pNewPrimitive = 0;
     272             :             const bool bDecoratedIsNeeded(
     273       20302 :                    UNDERLINE_NONE != rInfo.mrFont.GetOverline()
     274       19087 :                 || UNDERLINE_NONE != rInfo.mrFont.GetUnderline()
     275       18269 :                 || STRIKEOUT_NONE != rInfo.mrFont.GetStrikeout()
     276       18265 :                 || EMPHASISMARK_NONE != (rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_STYLE)
     277       18257 :                 || RELIEF_NONE != rInfo.mrFont.GetRelief()
     278       18257 :                 || rInfo.mrFont.IsShadow()
     279       38559 :                 || bWordLineMode);
     280             : 
     281       20302 :             if(bDecoratedIsNeeded)
     282             :             {
     283             :                 // TextDecoratedPortionPrimitive2D needed, prepare some more data
     284             :                 // get overline and underline color. If it's on automatic (0xffffffff) use FontColor instead
     285        2045 :                 const Color aUnderlineColor(rInfo.maTextLineColor);
     286        2045 :                 const basegfx::BColor aBUnderlineColor((0xffffffff == aUnderlineColor.GetColor()) ? aBFontColor : aUnderlineColor.getBColor());
     287        2045 :                 const Color aOverlineColor(rInfo.maOverlineColor);
     288        4090 :                 const basegfx::BColor aBOverlineColor((0xffffffff == aOverlineColor.GetColor()) ? aBFontColor : aOverlineColor.getBColor());
     289             : 
     290             :                 // prepare overline and underline data
     291             :                 const drawinglayer::primitive2d::TextLine eFontOverline(
     292        2045 :                     drawinglayer::primitive2d::mapFontUnderlineToTextLine(rInfo.mrFont.GetOverline()));
     293             :                 const drawinglayer::primitive2d::TextLine eFontUnderline(
     294        2045 :                     drawinglayer::primitive2d::mapFontUnderlineToTextLine(rInfo.mrFont.GetUnderline()));
     295             : 
     296             :                 // check UnderlineAbove
     297             :                 const bool bUnderlineAbove(
     298        2045 :                     drawinglayer::primitive2d::TEXT_LINE_NONE != eFontUnderline && impIsUnderlineAbove(rInfo.mrFont));
     299             : 
     300             :                 // prepare strikeout data
     301             :                 const drawinglayer::primitive2d::TextStrikeout eTextStrikeout(
     302        2045 :                     drawinglayer::primitive2d::mapFontStrikeoutToTextStrikeout(rInfo.mrFont.GetStrikeout()));
     303             : 
     304             :                 // prepare emphasis mark data
     305        2045 :                 drawinglayer::primitive2d::TextEmphasisMark eTextEmphasisMark(drawinglayer::primitive2d::TEXT_EMPHASISMARK_NONE);
     306             : 
     307        2045 :                 switch(rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_STYLE)
     308             :                 {
     309         767 :                     case EMPHASISMARK_DOT : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_DOT; break;
     310         714 :                     case EMPHASISMARK_CIRCLE : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_CIRCLE; break;
     311         277 :                     case EMPHASISMARK_DISC : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_DISC; break;
     312          24 :                     case EMPHASISMARK_ACCENT : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_ACCENT; break;
     313             :                 }
     314             : 
     315        2045 :                 const bool bEmphasisMarkAbove(rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_POS_ABOVE);
     316        2045 :                 const bool bEmphasisMarkBelow(rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_POS_BELOW);
     317             : 
     318             :                 // prepare font relief data
     319        2045 :                 drawinglayer::primitive2d::TextRelief eTextRelief(drawinglayer::primitive2d::TEXT_RELIEF_NONE);
     320             : 
     321        2045 :                 switch(rInfo.mrFont.GetRelief())
     322             :                 {
     323        1388 :                     case RELIEF_EMBOSSED : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_EMBOSSED; break;
     324           0 :                     case RELIEF_ENGRAVED : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_ENGRAVED; break;
     325         657 :                     default : break; // RELIEF_NONE, FontRelief_FORCE_EQUAL_SIZE
     326             :                 }
     327             : 
     328             :                 // prepare shadow/outline data
     329        2045 :                 const bool bShadow(rInfo.mrFont.IsShadow());
     330             : 
     331             :                 // TextDecoratedPortionPrimitive2D is needed, create one
     332             :                 pNewPrimitive = new drawinglayer::primitive2d::TextDecoratedPortionPrimitive2D(
     333             : 
     334             :                     // attributes for TextSimplePortionPrimitive2D
     335             :                     aNewTransform,
     336             :                     caseMappedText,
     337             :                     rInfo.mnTextStart,
     338             :                     rInfo.mnTextLen,
     339             :                     aDXArray,
     340             :                     aFontAttribute,
     341             :                     rInfo.mpLocale ? *rInfo.mpLocale : ::com::sun::star::lang::Locale(),
     342             :                     aBFontColor,
     343             :                     aTextFillColor,
     344             : 
     345             :                     // attributes for TextDecoratedPortionPrimitive2D
     346             :                     aBOverlineColor,
     347             :                     aBUnderlineColor,
     348             :                     eFontOverline,
     349             :                     eFontUnderline,
     350             :                     bUnderlineAbove,
     351             :                     eTextStrikeout,
     352             :                     bWordLineMode,
     353             :                     eTextEmphasisMark,
     354             :                     bEmphasisMarkAbove,
     355             :                     bEmphasisMarkBelow,
     356             :                     eTextRelief,
     357        4090 :                     bShadow);
     358             :             }
     359             :             else
     360             :             {
     361             :                 // TextSimplePortionPrimitive2D is enough
     362             :                 pNewPrimitive = new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
     363             :                     aNewTransform,
     364             :                     caseMappedText,
     365             :                     rInfo.mnTextStart,
     366             :                     rInfo.mnTextLen,
     367             :                     aDXArray,
     368             :                     aFontAttribute,
     369             :                     rInfo.mpLocale ? *rInfo.mpLocale : ::com::sun::star::lang::Locale(),
     370             :                     aBFontColor,
     371             :                     rInfo.mbFilled,
     372             :                     rInfo.mnWidthToFill,
     373       18257 :                     aTextFillColor);
     374             :             }
     375             : 
     376       20302 :             if(rInfo.mbEndOfBullet)
     377             :             {
     378             :                 // embed in TextHierarchyBulletPrimitive2D
     379        1051 :                 const drawinglayer::primitive2d::Primitive2DReference aNewReference(pNewPrimitive);
     380        2102 :                 const drawinglayer::primitive2d::Primitive2DSequence aNewSequence(&aNewReference, 1);
     381        2102 :                 pNewPrimitive = new drawinglayer::primitive2d::TextHierarchyBulletPrimitive2D(aNewSequence);
     382             :             }
     383             : 
     384       20302 :             if(rInfo.mpFieldData)
     385             :             {
     386        1793 :                 pNewPrimitive = impCheckFieldPrimitive(pNewPrimitive, rInfo);
     387             :             }
     388             : 
     389       20302 :             maTextPortionPrimitives.push_back(pNewPrimitive);
     390             : 
     391             :             // support for WrongSpellVector. Create WrongSpellPrimitives as needed
     392       20302 :             if(rInfo.mpWrongSpellVector && !aDXArray.empty())
     393             :             {
     394           0 :                 const sal_Int32 nSize(rInfo.mpWrongSpellVector->size());
     395           0 :                 const sal_Int32 nDXCount(aDXArray.size());
     396           0 :                 const basegfx::BColor aSpellColor(1.0, 0.0, 0.0); // red, hard coded
     397             : 
     398           0 :                 for(sal_Int32 a(0); a < nSize; a++)
     399             :                 {
     400           0 :                     const EEngineData::WrongSpellClass& rCandidate = (*rInfo.mpWrongSpellVector)[a];
     401             : 
     402           0 :                     if(rCandidate.nStart >= rInfo.mnTextStart && rCandidate.nEnd >= rInfo.mnTextStart && rCandidate.nEnd > rCandidate.nStart)
     403             :                     {
     404           0 :                         const sal_Int32 nStart(rCandidate.nStart - rInfo.mnTextStart);
     405           0 :                         const sal_Int32 nEnd(rCandidate.nEnd - rInfo.mnTextStart);
     406           0 :                         double fStart(0.0);
     407           0 :                         double fEnd(0.0);
     408             : 
     409           0 :                         if(nStart > 0 && nStart - 1 < nDXCount)
     410             :                         {
     411           0 :                             fStart = aDXArray[nStart - 1];
     412             :                         }
     413             : 
     414           0 :                         if(nEnd > 0 && nEnd - 1 < nDXCount)
     415             :                         {
     416           0 :                             fEnd = aDXArray[nEnd - 1];
     417             :                         }
     418             : 
     419           0 :                         if(!basegfx::fTools::equal(fStart, fEnd))
     420             :                         {
     421           0 :                             if(rInfo.IsRTL())
     422             :                             {
     423             :                                 // #i98523#
     424             :                                 // When the portion is RTL, mirror the redlining using the
     425             :                                 // full portion width
     426           0 :                                 const double fTextWidth(aDXArray[aDXArray.size() - 1]);
     427             : 
     428           0 :                                 fStart = fTextWidth - fStart;
     429           0 :                                 fEnd = fTextWidth - fEnd;
     430             :                             }
     431             : 
     432             :                             // need to take FontScaling out of values; it's already part of
     433             :                             // aNewTransform and would be double applied
     434           0 :                             const double fFontScaleX(aFontScaling.getX());
     435             : 
     436           0 :                             if(!basegfx::fTools::equal(fFontScaleX, 1.0)
     437           0 :                                 && !basegfx::fTools::equalZero(fFontScaleX))
     438             :                             {
     439           0 :                                 fStart /= fFontScaleX;
     440           0 :                                 fEnd /= fFontScaleX;
     441             :                             }
     442             : 
     443             :                             maTextPortionPrimitives.push_back(new drawinglayer::primitive2d::WrongSpellPrimitive2D(
     444             :                                 aNewTransform,
     445             :                                 fStart,
     446             :                                 fEnd,
     447           0 :                                 aSpellColor));
     448             :                         }
     449             :                     }
     450           0 :                 }
     451       20302 :             }
     452             :         }
     453       21652 :     }
     454             : 
     455        1793 :     drawinglayer::primitive2d::BasePrimitive2D* impTextBreakupHandler::impCheckFieldPrimitive(drawinglayer::primitive2d::BasePrimitive2D* pPrimitive, const DrawPortionInfo& rInfo) const
     456             :     {
     457        1793 :         if(rInfo.mpFieldData)
     458             :         {
     459             :             // Support for FIELD_SEQ_BEGIN, FIELD_SEQ_END. If used, create a TextHierarchyFieldPrimitive2D
     460             :             // which holds the field type and, if applicable, the URL
     461        1793 :             const SvxURLField* pURLField = dynamic_cast< const SvxURLField* >(rInfo.mpFieldData);
     462        1793 :             const SvxPageField* pPageField = dynamic_cast< const SvxPageField* >(rInfo.mpFieldData);
     463             : 
     464             :             // embed current primitive to a sequence
     465        1793 :             drawinglayer::primitive2d::Primitive2DSequence aSequence;
     466             : 
     467        1793 :             if(pPrimitive)
     468             :             {
     469        1793 :                 aSequence.realloc(1);
     470        1793 :                 aSequence[0] = drawinglayer::primitive2d::Primitive2DReference(pPrimitive);
     471             :             }
     472             : 
     473        1793 :             if(pURLField)
     474             :             {
     475           2 :                 pPrimitive = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_URL, pURLField->GetURL());
     476             :             }
     477        1791 :             else if(pPageField)
     478             :             {
     479         449 :                 pPrimitive = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_PAGE, "");
     480             :             }
     481             :             else
     482             :             {
     483        1342 :                 pPrimitive = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_COMMON, "");
     484        1793 :             }
     485             :         }
     486             : 
     487        1793 :         return pPrimitive;
     488             :     }
     489             : 
     490       20302 :     void impTextBreakupHandler::impFlushTextPortionPrimitivesToLinePrimitives()
     491             :     {
     492             :         // only create a line primitive when we had content; there is no need for
     493             :         // empty line primitives (contrary to paragraphs, see below).
     494       20302 :         if(!maTextPortionPrimitives.empty())
     495             :         {
     496       18960 :             drawinglayer::primitive2d::Primitive2DSequence aLineSequence(impConvertVectorToPrimitive2DSequence(maTextPortionPrimitives));
     497       18960 :             maTextPortionPrimitives.clear();
     498       18960 :             maLinePrimitives.push_back(new drawinglayer::primitive2d::TextHierarchyLinePrimitive2D(aLineSequence));
     499             :         }
     500       20302 :     }
     501             : 
     502       16183 :     void impTextBreakupHandler::impFlushLinePrimitivesToParagraphPrimitives()
     503             :     {
     504             :         // ALWAYS create a paragraph primitive, even when no content was added. This is done to
     505             :         // have the correct paragraph count even with empty paragraphs. Those paragraphs will
     506             :         // have an empty sub-PrimitiveSequence.
     507       16183 :         drawinglayer::primitive2d::Primitive2DSequence aParagraphSequence(impConvertVectorToPrimitive2DSequence(maLinePrimitives));
     508       16183 :         maLinePrimitives.clear();
     509       16183 :         maParagraphPrimitives.push_back(new drawinglayer::primitive2d::TextHierarchyParagraphPrimitive2D(aParagraphSequence));
     510       16183 :     }
     511             : 
     512       21652 :     void impTextBreakupHandler::impHandleDrawPortionInfo(const DrawPortionInfo& rInfo)
     513             :     {
     514       21652 :         impCreateTextPortionPrimitive(rInfo);
     515             : 
     516       21652 :         if(rInfo.mbEndOfLine || rInfo.mbEndOfParagraph)
     517             :         {
     518       20302 :             impFlushTextPortionPrimitivesToLinePrimitives();
     519             :         }
     520             : 
     521       21652 :         if(rInfo.mbEndOfParagraph)
     522             :         {
     523       16183 :             impFlushLinePrimitivesToParagraphPrimitives();
     524             :         }
     525       21652 :     }
     526             : 
     527           0 :     void impTextBreakupHandler::impHandleDrawBulletInfo(const DrawBulletInfo& rInfo)
     528             :     {
     529           0 :         basegfx::B2DHomMatrix aNewTransform;
     530             : 
     531             :         // add size to new transform
     532           0 :         aNewTransform.scale(rInfo.maBulletSize.getWidth(), rInfo.maBulletSize.getHeight());
     533             : 
     534             :         // apply transformA
     535           0 :         aNewTransform *= maNewTransformA;
     536             : 
     537             :         // apply local offset
     538           0 :         aNewTransform.translate(rInfo.maBulletPosition.X(), rInfo.maBulletPosition.Y());
     539             : 
     540             :         // also apply embedding object's transform
     541           0 :         aNewTransform *= maNewTransformB;
     542             : 
     543             :         // prepare empty GraphicAttr
     544           0 :         const GraphicAttr aGraphicAttr;
     545             : 
     546             :         // create GraphicPrimitive2D
     547             :         const drawinglayer::primitive2d::Primitive2DReference aNewReference(new drawinglayer::primitive2d::GraphicPrimitive2D(
     548             :             aNewTransform,
     549             :             rInfo.maBulletGraphicObject,
     550           0 :             aGraphicAttr));
     551             : 
     552             :         // embed in TextHierarchyBulletPrimitive2D
     553           0 :         const drawinglayer::primitive2d::Primitive2DSequence aNewSequence(&aNewReference, 1);
     554           0 :         drawinglayer::primitive2d::BasePrimitive2D* pNewPrimitive = new drawinglayer::primitive2d::TextHierarchyBulletPrimitive2D(aNewSequence);
     555             : 
     556             :         // add to output
     557           0 :         maTextPortionPrimitives.push_back(pNewPrimitive);
     558           0 :     }
     559             : 
     560           0 :     IMPL_LINK(impTextBreakupHandler, decomposeContourTextPrimitive, DrawPortionInfo*, pInfo)
     561             :     {
     562             :         // for contour text, ignore (clip away) all portions which are below
     563             :         // the visible area given by maScale
     564           0 :         if(pInfo && (double)pInfo->mrStartPos.Y() < maScale.getY())
     565             :         {
     566           0 :             impHandleDrawPortionInfo(*pInfo);
     567             :         }
     568             : 
     569           0 :         return 0;
     570             :     }
     571             : 
     572       43304 :     IMPL_LINK(impTextBreakupHandler, decomposeBlockTextPrimitive, DrawPortionInfo*, pInfo)
     573             :     {
     574       21652 :         if(pInfo)
     575             :         {
     576             :             // Is clipping wanted? This is text clipping; only accept a portion
     577             :             // if it's completely in the range
     578       21652 :             if(!maClipRange.isEmpty())
     579             :             {
     580             :                 // Test start position first; this allows to not get the text range at
     581             :                 // all if text is far outside
     582           0 :                 const basegfx::B2DPoint aStartPosition(pInfo->mrStartPos.X(), pInfo->mrStartPos.Y());
     583             : 
     584           0 :                 if(!maClipRange.isInside(aStartPosition))
     585             :                 {
     586           0 :                     return 0;
     587             :                 }
     588             : 
     589             :                 // Start position is inside. Get TextBoundRect and TopLeft next
     590           0 :                 drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice;
     591           0 :                 aTextLayouterDevice.setFont(pInfo->mrFont);
     592             : 
     593             :                 const basegfx::B2DRange aTextBoundRect(
     594             :                     aTextLayouterDevice.getTextBoundRect(
     595           0 :                         pInfo->maText, pInfo->mnTextStart, pInfo->mnTextLen));
     596           0 :                 const basegfx::B2DPoint aTopLeft(aTextBoundRect.getMinimum() + aStartPosition);
     597             : 
     598           0 :                 if(!maClipRange.isInside(aTopLeft))
     599             :                 {
     600           0 :                     return 0;
     601             :                 }
     602             : 
     603             :                 // TopLeft is inside. Get BottomRight and check
     604           0 :                 const basegfx::B2DPoint aBottomRight(aTextBoundRect.getMaximum() + aStartPosition);
     605             : 
     606           0 :                 if(!maClipRange.isInside(aBottomRight))
     607             :                 {
     608           0 :                     return 0;
     609           0 :                 }
     610             : 
     611             :                 // all inside, clip was successful
     612             :             }
     613       21652 :             impHandleDrawPortionInfo(*pInfo);
     614             :         }
     615             : 
     616       21652 :         return 0;
     617             :     }
     618             : 
     619           0 :     IMPL_LINK(impTextBreakupHandler, decomposeStretchTextPrimitive, DrawPortionInfo*, pInfo)
     620             :     {
     621           0 :         if(pInfo)
     622             :         {
     623           0 :             impHandleDrawPortionInfo(*pInfo);
     624             :         }
     625             : 
     626           0 :         return 0;
     627             :     }
     628             : 
     629           0 :     IMPL_LINK(impTextBreakupHandler, decomposeContourBulletPrimitive, DrawBulletInfo*, pInfo)
     630             :     {
     631           0 :         if(pInfo)
     632             :         {
     633           0 :             impHandleDrawBulletInfo(*pInfo);
     634             :         }
     635             : 
     636           0 :         return 0;
     637             :     }
     638             : 
     639           0 :     IMPL_LINK(impTextBreakupHandler, decomposeBlockBulletPrimitive, DrawBulletInfo*, pInfo)
     640             :     {
     641           0 :         if(pInfo)
     642             :         {
     643           0 :             impHandleDrawBulletInfo(*pInfo);
     644             :         }
     645             : 
     646           0 :         return 0;
     647             :     }
     648             : 
     649           0 :     IMPL_LINK(impTextBreakupHandler, decomposeStretchBulletPrimitive, DrawBulletInfo*, pInfo)
     650             :     {
     651           0 :         if(pInfo)
     652             :         {
     653           0 :             impHandleDrawBulletInfo(*pInfo);
     654             :         }
     655             : 
     656           0 :         return 0;
     657             :     }
     658             : 
     659       13266 :     drawinglayer::primitive2d::Primitive2DSequence impTextBreakupHandler::getPrimitive2DSequence()
     660             :     {
     661       13266 :         if(!maTextPortionPrimitives.empty())
     662             :         {
     663             :             // collect non-closed lines
     664           0 :             impFlushTextPortionPrimitivesToLinePrimitives();
     665             :         }
     666             : 
     667       13266 :         if(!maLinePrimitives.empty())
     668             :         {
     669             :             // collect non-closed paragraphs
     670           0 :             impFlushLinePrimitivesToParagraphPrimitives();
     671             :         }
     672             : 
     673       13266 :         return impConvertVectorToPrimitive2DSequence(maParagraphPrimitives);
     674             :     }
     675             : } // end of anonymous namespace
     676             : 
     677             : 
     678             : // primitive decompositions
     679             : 
     680           0 : void SdrTextObj::impDecomposeContourTextPrimitive(
     681             :     drawinglayer::primitive2d::Primitive2DSequence& rTarget,
     682             :     const drawinglayer::primitive2d::SdrContourTextPrimitive2D& rSdrContourTextPrimitive,
     683             :     const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
     684             : {
     685             :     // decompose matrix to have position and size of text
     686           0 :     basegfx::B2DVector aScale, aTranslate;
     687             :     double fRotate, fShearX;
     688           0 :     rSdrContourTextPrimitive.getObjectTransform().decompose(aScale, aTranslate, fRotate, fShearX);
     689             : 
     690             :     // prepare contour polygon, force to non-mirrored for laying out
     691           0 :     basegfx::B2DPolyPolygon aPolyPolygon(rSdrContourTextPrimitive.getUnitPolyPolygon());
     692           0 :     aPolyPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(fabs(aScale.getX()), fabs(aScale.getY())));
     693             : 
     694             :     // prepare outliner
     695           0 :     SdrOutliner& rOutliner = ImpGetDrawOutliner();
     696           0 :     const Size aNullSize;
     697           0 :     rOutliner.SetPaperSize(aNullSize);
     698           0 :     rOutliner.SetPolygon(aPolyPolygon);
     699           0 :     rOutliner.SetUpdateMode(true);
     700           0 :     rOutliner.SetText(rSdrContourTextPrimitive.getOutlinerParaObject());
     701             : 
     702             :     // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
     703           0 :     rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
     704             : 
     705             :     // prepare matrices to apply to newly created primitives
     706           0 :     basegfx::B2DHomMatrix aNewTransformA;
     707             : 
     708             :     // mirroring. We are now in the polygon sizes. When mirroring in X and Y,
     709             :     // move the null point which was top left to bottom right.
     710           0 :     const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
     711           0 :     const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
     712             : 
     713             :     // in-between the translations of the single primitives will take place. Afterwards,
     714             :     // the object's transformations need to be applied
     715             :     const basegfx::B2DHomMatrix aNewTransformB(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
     716             :         bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
     717           0 :         fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
     718             : 
     719             :     // now break up text primitives.
     720           0 :     impTextBreakupHandler aConverter(rOutliner);
     721           0 :     aConverter.decomposeContourTextPrimitive(aNewTransformA, aNewTransformB, aScale);
     722             : 
     723             :     // cleanup outliner
     724           0 :     rOutliner.Clear();
     725           0 :     rOutliner.setVisualizedPage(0);
     726             : 
     727           0 :     rTarget = aConverter.getPrimitive2DSequence();
     728           0 : }
     729             : 
     730          73 : void SdrTextObj::impDecomposeAutoFitTextPrimitive(
     731             :     drawinglayer::primitive2d::Primitive2DSequence& rTarget,
     732             :     const drawinglayer::primitive2d::SdrAutoFitTextPrimitive2D& rSdrAutofitTextPrimitive,
     733             :     const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
     734             : {
     735             :     // decompose matrix to have position and size of text
     736         146 :     basegfx::B2DVector aScale, aTranslate;
     737             :     double fRotate, fShearX;
     738          73 :     rSdrAutofitTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
     739             : 
     740             :     // use B2DRange aAnchorTextRange for calculations
     741          73 :     basegfx::B2DRange aAnchorTextRange(aTranslate);
     742          73 :     aAnchorTextRange.expand(aTranslate + aScale);
     743             : 
     744             :     // prepare outliner
     745          73 :     const SfxItemSet& rTextItemSet = rSdrAutofitTextPrimitive.getSdrText()->GetItemSet();
     746          73 :     SdrOutliner& rOutliner = ImpGetDrawOutliner();
     747          73 :     SdrTextVertAdjust eVAdj = GetTextVerticalAdjust(rTextItemSet);
     748          73 :     SdrTextHorzAdjust eHAdj = GetTextHorizontalAdjust(rTextItemSet);
     749          73 :     const sal_uInt32 nOriginalControlWord(rOutliner.GetControlWord());
     750          73 :     const Size aNullSize;
     751             : 
     752             :     // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
     753          73 :     rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
     754             : 
     755          73 :     rOutliner.SetControlWord(nOriginalControlWord|EE_CNTRL_AUTOPAGESIZE|EE_CNTRL_STRETCHING);
     756          73 :     rOutliner.SetMinAutoPaperSize(aNullSize);
     757          73 :     rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
     758             : 
     759             :     // add one to rage sizes to get back to the old Rectangle and outliner measurements
     760          73 :     const sal_uInt32 nAnchorTextWidth(FRound(aAnchorTextRange.getWidth() + 1L));
     761          73 :     const sal_uInt32 nAnchorTextHeight(FRound(aAnchorTextRange.getHeight() + 1L));
     762          73 :     const OutlinerParaObject* pOutlinerParaObject = rSdrAutofitTextPrimitive.getSdrText()->GetOutlinerParaObject();
     763             :     OSL_ENSURE(pOutlinerParaObject, "impDecomposeBlockTextPrimitive used with no OutlinerParaObject (!)");
     764          73 :     const bool bVerticalWritintg(pOutlinerParaObject->IsVertical());
     765          73 :     const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
     766             : 
     767          73 :     if((rSdrAutofitTextPrimitive.getWordWrap() || IsTextFrame()))
     768             :     {
     769          73 :         rOutliner.SetMaxAutoPaperSize(aAnchorTextSize);
     770             :     }
     771             : 
     772          73 :     if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !bVerticalWritintg)
     773             :     {
     774          73 :         rOutliner.SetMinAutoPaperSize(Size(nAnchorTextWidth, 0));
     775             :     }
     776             : 
     777          73 :     if(SDRTEXTVERTADJUST_BLOCK == eVAdj && bVerticalWritintg)
     778             :     {
     779           0 :         rOutliner.SetMinAutoPaperSize(Size(0, nAnchorTextHeight));
     780             :     }
     781             : 
     782          73 :     rOutliner.SetPaperSize(aNullSize);
     783          73 :     rOutliner.SetUpdateMode(true);
     784          73 :     rOutliner.SetText(*pOutlinerParaObject);
     785          73 :     ImpAutoFitText(rOutliner,aAnchorTextSize,bVerticalWritintg);
     786             : 
     787             :     // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
     788          73 :     rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
     789             : 
     790             :     // now get back the layouted text size from outliner
     791          73 :     const Size aOutlinerTextSize(rOutliner.GetPaperSize());
     792         146 :     const basegfx::B2DVector aOutlinerScale(aOutlinerTextSize.Width(), aOutlinerTextSize.Height());
     793         146 :     basegfx::B2DVector aAdjustTranslate(0.0, 0.0);
     794             : 
     795             :     // correct horizontal translation using the now known text size
     796          73 :     if(SDRTEXTHORZADJUST_CENTER == eHAdj || SDRTEXTHORZADJUST_RIGHT == eHAdj)
     797             :     {
     798           0 :         const double fFree(aAnchorTextRange.getWidth() - aOutlinerScale.getX());
     799             : 
     800           0 :         if(SDRTEXTHORZADJUST_CENTER == eHAdj)
     801             :         {
     802           0 :             aAdjustTranslate.setX(fFree / 2.0);
     803             :         }
     804             : 
     805           0 :         if(SDRTEXTHORZADJUST_RIGHT == eHAdj)
     806             :         {
     807           0 :             aAdjustTranslate.setX(fFree);
     808             :         }
     809             :     }
     810             : 
     811             :     // correct vertical translation using the now known text size
     812          73 :     if(SDRTEXTVERTADJUST_CENTER == eVAdj || SDRTEXTVERTADJUST_BOTTOM == eVAdj)
     813             :     {
     814           0 :         const double fFree(aAnchorTextRange.getHeight() - aOutlinerScale.getY());
     815             : 
     816           0 :         if(SDRTEXTVERTADJUST_CENTER == eVAdj)
     817             :         {
     818           0 :             aAdjustTranslate.setY(fFree / 2.0);
     819             :         }
     820             : 
     821           0 :         if(SDRTEXTVERTADJUST_BOTTOM == eVAdj)
     822             :         {
     823           0 :             aAdjustTranslate.setY(fFree);
     824             :         }
     825             :     }
     826             : 
     827             :     // prepare matrices to apply to newly created primitives. aNewTransformA
     828             :     // will get coordinates in aOutlinerScale size and positive in X, Y.
     829         146 :     basegfx::B2DHomMatrix aNewTransformA;
     830         146 :     basegfx::B2DHomMatrix aNewTransformB;
     831             : 
     832             :     // translate relative to given primitive to get same rotation and shear
     833             :     // as the master shape we are working on. For vertical, use the top-right
     834             :     // corner
     835          73 :     const double fStartInX(bVerticalWritintg ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
     836          73 :     aNewTransformA.translate(fStartInX, aAdjustTranslate.getY());
     837             : 
     838             :     // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
     839             :     // move the null point which was top left to bottom right.
     840          73 :     const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
     841          73 :     const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
     842          73 :     aNewTransformB.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0);
     843             : 
     844             :     // in-between the translations of the single primitives will take place. Afterwards,
     845             :     // the object's transformations need to be applied
     846          73 :     aNewTransformB.shearX(fShearX);
     847          73 :     aNewTransformB.rotate(fRotate);
     848          73 :     aNewTransformB.translate(aTranslate.getX(), aTranslate.getY());
     849             : 
     850          73 :     basegfx::B2DRange aClipRange;
     851             : 
     852             :     // now break up text primitives.
     853         146 :     impTextBreakupHandler aConverter(rOutliner);
     854          73 :     aConverter.decomposeBlockTextPrimitive(aNewTransformA, aNewTransformB, aClipRange);
     855             : 
     856             :     // cleanup outliner
     857          73 :     rOutliner.Clear();
     858          73 :     rOutliner.setVisualizedPage(0);
     859          73 :     rOutliner.SetControlWord(nOriginalControlWord);
     860             : 
     861         146 :     rTarget = aConverter.getPrimitive2DSequence();
     862          73 : }
     863             : 
     864       13193 : void SdrTextObj::impDecomposeBlockTextPrimitive(
     865             :     drawinglayer::primitive2d::Primitive2DSequence& rTarget,
     866             :     const drawinglayer::primitive2d::SdrBlockTextPrimitive2D& rSdrBlockTextPrimitive,
     867             :     const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
     868             : {
     869             :     // decompose matrix to have position and size of text
     870       26386 :     basegfx::B2DVector aScale, aTranslate;
     871             :     double fRotate, fShearX;
     872       13193 :     rSdrBlockTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
     873             : 
     874             :     // use B2DRange aAnchorTextRange for calculations
     875       13193 :     basegfx::B2DRange aAnchorTextRange(aTranslate);
     876       13193 :     aAnchorTextRange.expand(aTranslate + aScale);
     877             : 
     878             :     // prepare outliner
     879       13193 :     const bool bIsCell(rSdrBlockTextPrimitive.getCellText());
     880       13193 :     SdrOutliner& rOutliner = ImpGetDrawOutliner();
     881       13193 :     SdrTextHorzAdjust eHAdj = rSdrBlockTextPrimitive.getSdrTextHorzAdjust();
     882       13193 :     SdrTextVertAdjust eVAdj = rSdrBlockTextPrimitive.getSdrTextVertAdjust();
     883       13193 :     const sal_uInt32 nOriginalControlWord(rOutliner.GetControlWord());
     884       13193 :     const Size aNullSize;
     885             : 
     886             :     // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
     887       13193 :     rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
     888       13193 :     rOutliner.SetFixedCellHeight(rSdrBlockTextPrimitive.isFixedCellHeight());
     889       13193 :     rOutliner.SetControlWord(nOriginalControlWord|EE_CNTRL_AUTOPAGESIZE);
     890       13193 :     rOutliner.SetMinAutoPaperSize(aNullSize);
     891       13193 :     rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
     892             : 
     893             :     // Resolves: fdo#35779 set background color of this shape as the editeng background if there
     894             :     // is one. Check the shape itself, then the host page, then that page's master page.
     895             :     // That color needs to be restored on leaving this method
     896       13193 :     Color aOriginalBackColor(rOutliner.GetBackgroundColor());
     897       13193 :     const SfxItemSet* pBackgroundFillSet = &GetObjectItemSet();
     898             : 
     899       13193 :     if (drawing::FillStyle_NONE == static_cast<const XFillStyleItem&>(pBackgroundFillSet->Get(XATTR_FILLSTYLE)).GetValue())
     900             :     {
     901       11638 :         SdrPage *pOwnerPage = GetPage();
     902       11638 :         if (pOwnerPage)
     903             :         {
     904       11096 :             pBackgroundFillSet = &pOwnerPage->getSdrPageProperties().GetItemSet();
     905             : 
     906       11096 :             if (drawing::FillStyle_NONE == static_cast<const XFillStyleItem&>(pBackgroundFillSet->Get(XATTR_FILLSTYLE)).GetValue())
     907             :             {
     908        9688 :                 if (!pOwnerPage->IsMasterPage() && pOwnerPage->TRG_HasMasterPage())
     909             :                 {
     910        1439 :                     pBackgroundFillSet = &pOwnerPage->TRG_GetMasterPage().getSdrPageProperties().GetItemSet();
     911             :                 }
     912             :             }
     913             :         }
     914             :     }
     915             : 
     916       13193 :     if (drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(pBackgroundFillSet->Get(XATTR_FILLSTYLE)).GetValue())
     917             :     {
     918        3527 :         Color aColor(rOutliner.GetBackgroundColor());
     919        3527 :         GetDraftFillColor(*pBackgroundFillSet, aColor);
     920        3527 :         rOutliner.SetBackgroundColor(aColor);
     921             :     }
     922             : 
     923             :     // add one to rage sizes to get back to the old Rectangle and outliner measurements
     924       13193 :     const sal_uInt32 nAnchorTextWidth(FRound(aAnchorTextRange.getWidth() + 1L));
     925       13193 :     const sal_uInt32 nAnchorTextHeight(FRound(aAnchorTextRange.getHeight() + 1L));
     926       13193 :     const bool bVerticalWritintg(rSdrBlockTextPrimitive.getOutlinerParaObject().IsVertical());
     927       13193 :     const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
     928             : 
     929       13193 :     if(bIsCell)
     930             :     {
     931             :         // cell text is formated neither like a text object nor like a object
     932             :         // text, so use a special setup here
     933           0 :         rOutliner.SetMaxAutoPaperSize(aAnchorTextSize);
     934             : 
     935             :         // #i106214# To work with an unchangeable PaperSize (CellSize in
     936             :         // this case) Set(Min|Max)AutoPaperSize and SetPaperSize have to be used.
     937             :         // #i106214# This was not completely correct; to still measure the real
     938             :         // text height to allow vertical adjust (and vice versa for VerticalWritintg)
     939             :         // only one aspect has to be set, but the other one to zero
     940           0 :         if(bVerticalWritintg)
     941             :         {
     942             :             // measure the horizontal text size
     943           0 :             rOutliner.SetMinAutoPaperSize(Size(0, aAnchorTextSize.Height()));
     944             :         }
     945             :         else
     946             :         {
     947             :             // measure the vertical text size
     948           0 :             rOutliner.SetMinAutoPaperSize(Size(aAnchorTextSize.Width(), 0));
     949             :         }
     950             : 
     951           0 :         rOutliner.SetPaperSize(aAnchorTextSize);
     952           0 :         rOutliner.SetUpdateMode(true);
     953           0 :         rOutliner.SetText(rSdrBlockTextPrimitive.getOutlinerParaObject());
     954             :     }
     955             :     else
     956             :     {
     957             :         // check if block text is used (only one of them can be true)
     958       13193 :         const bool bHorizontalIsBlock(SDRTEXTHORZADJUST_BLOCK == eHAdj && !bVerticalWritintg);
     959       13193 :         const bool bVerticalIsBlock(SDRTEXTVERTADJUST_BLOCK == eVAdj && bVerticalWritintg);
     960             : 
     961             :         // set minimal paper size horizontally/vertically if needed
     962       13193 :         if(bHorizontalIsBlock)
     963             :         {
     964        5995 :             rOutliner.SetMinAutoPaperSize(Size(nAnchorTextWidth, 0));
     965             :         }
     966        7198 :         else if(bVerticalIsBlock)
     967             :         {
     968           0 :             rOutliner.SetMinAutoPaperSize(Size(0, nAnchorTextHeight));
     969             :         }
     970             : 
     971       13193 :         if((rSdrBlockTextPrimitive.getWordWrap() || IsTextFrame()) && !rSdrBlockTextPrimitive.getUnlimitedPage())
     972             :         {
     973             :             // #i103454# maximal paper size hor/ver needs to be limited to text
     974             :             // frame size. If it's block text, still allow the 'other' direction
     975             :             // to grow to get a correct real text size when using GetPaperSize().
     976             :             // When just using aAnchorTextSize as maximum, GetPaperSize()
     977             :             // would just return aAnchorTextSize again: this means, the wanted
     978             :             // 'measurement' of the real size of block text would not work
     979       13112 :             Size aMaxAutoPaperSize(aAnchorTextSize);
     980             : 
     981       13112 :             if(bHorizontalIsBlock)
     982             :             {
     983             :                 // allow to grow vertical for horizontal blocks
     984        5931 :                 aMaxAutoPaperSize.setHeight(1000000);
     985             :             }
     986        7181 :             else if(bVerticalIsBlock)
     987             :             {
     988             :                 // allow to grow horizontal for vertical blocks
     989           0 :                 aMaxAutoPaperSize.setWidth(1000000);
     990             :             }
     991             : 
     992       13112 :             rOutliner.SetMaxAutoPaperSize(aMaxAutoPaperSize);
     993             :         }
     994             : 
     995       13193 :         rOutliner.SetPaperSize(aNullSize);
     996       13193 :         rOutliner.SetUpdateMode(true);
     997       13193 :         rOutliner.SetText(rSdrBlockTextPrimitive.getOutlinerParaObject());
     998             :     }
     999             : 
    1000       13193 :     rOutliner.SetControlWord(nOriginalControlWord);
    1001             : 
    1002             :     // now get back the layouted text size from outliner
    1003       13193 :     const Size aOutlinerTextSize(rOutliner.GetPaperSize());
    1004       26386 :     const basegfx::B2DVector aOutlinerScale(aOutlinerTextSize.Width(), aOutlinerTextSize.Height());
    1005       26386 :     basegfx::B2DVector aAdjustTranslate(0.0, 0.0);
    1006             : 
    1007             :     // For draw objects containing text correct hor/ver alignment if text is bigger
    1008             :     // than the object itself. Without that correction, the text would always be
    1009             :     // formatted to the left edge (or top edge when vertical) of the draw object.
    1010       13193 :     if(!IsTextFrame() && !bIsCell)
    1011             :     {
    1012        1211 :         if(aAnchorTextRange.getWidth() < aOutlinerScale.getX() && !bVerticalWritintg)
    1013             :         {
    1014             :             // Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK,
    1015             :             // else the alignment is wanted.
    1016        1186 :             if(SDRTEXTHORZADJUST_BLOCK == eHAdj)
    1017             :             {
    1018        1182 :                 eHAdj = SDRTEXTHORZADJUST_CENTER;
    1019             :             }
    1020             :         }
    1021             : 
    1022        1211 :         if(aAnchorTextRange.getHeight() < aOutlinerScale.getY() && bVerticalWritintg)
    1023             :         {
    1024             :             // Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK,
    1025             :             // else the alignment is wanted.
    1026           0 :             if(SDRTEXTVERTADJUST_BLOCK == eVAdj)
    1027             :             {
    1028           0 :                 eVAdj = SDRTEXTVERTADJUST_CENTER;
    1029             :             }
    1030             :         }
    1031             :     }
    1032             : 
    1033             :     // correct horizontal translation using the now known text size
    1034       13193 :     if(SDRTEXTHORZADJUST_CENTER == eHAdj || SDRTEXTHORZADJUST_RIGHT == eHAdj)
    1035             :     {
    1036        6872 :         const double fFree(aAnchorTextRange.getWidth() - aOutlinerScale.getX());
    1037             : 
    1038        6872 :         if(SDRTEXTHORZADJUST_CENTER == eHAdj)
    1039             :         {
    1040        4354 :             aAdjustTranslate.setX(fFree / 2.0);
    1041             :         }
    1042             : 
    1043        6872 :         if(SDRTEXTHORZADJUST_RIGHT == eHAdj)
    1044             :         {
    1045        2518 :             aAdjustTranslate.setX(fFree);
    1046             :         }
    1047             :     }
    1048             : 
    1049             :     // correct vertical translation using the now known text size
    1050       13193 :     if(SDRTEXTVERTADJUST_CENTER == eVAdj || SDRTEXTVERTADJUST_BOTTOM == eVAdj)
    1051             :     {
    1052        5700 :         const double fFree(aAnchorTextRange.getHeight() - aOutlinerScale.getY());
    1053             : 
    1054        5700 :         if(SDRTEXTVERTADJUST_CENTER == eVAdj)
    1055             :         {
    1056        4088 :             aAdjustTranslate.setY(fFree / 2.0);
    1057             :         }
    1058             : 
    1059        5700 :         if(SDRTEXTVERTADJUST_BOTTOM == eVAdj)
    1060             :         {
    1061        1612 :             aAdjustTranslate.setY(fFree);
    1062             :         }
    1063             :     }
    1064             : 
    1065             :     // prepare matrices to apply to newly created primitives. aNewTransformA
    1066             :     // will get coordinates in aOutlinerScale size and positive in X, Y.
    1067             :     // Translate relative to given primitive to get same rotation and shear
    1068             :     // as the master shape we are working on. For vertical, use the top-right
    1069             :     // corner
    1070       13193 :     const double fStartInX(bVerticalWritintg ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
    1071       26386 :     const basegfx::B2DTuple aAdjOffset(fStartInX, aAdjustTranslate.getY());
    1072       26386 :     basegfx::B2DHomMatrix aNewTransformA(basegfx::tools::createTranslateB2DHomMatrix(aAdjOffset.getX(), aAdjOffset.getY()));
    1073             : 
    1074             :     // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
    1075             :     // move the null point which was top left to bottom right.
    1076       13193 :     const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
    1077       13193 :     const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
    1078             : 
    1079             :     // in-between the translations of the single primitives will take place. Afterwards,
    1080             :     // the object's transformations need to be applied
    1081             :     const basegfx::B2DHomMatrix aNewTransformB(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
    1082             :         bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
    1083       26386 :         fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
    1084             : 
    1085             :     // create ClipRange (if needed)
    1086       13193 :     basegfx::B2DRange aClipRange;
    1087             : 
    1088       13193 :     if(rSdrBlockTextPrimitive.getClipOnBounds())
    1089             :     {
    1090           0 :         aClipRange.expand(-aAdjOffset);
    1091           0 :         aClipRange.expand(basegfx::B2DTuple(aAnchorTextSize.Width(), aAnchorTextSize.Height()) - aAdjOffset);
    1092             :     }
    1093             : 
    1094             :     // now break up text primitives.
    1095       26386 :     impTextBreakupHandler aConverter(rOutliner);
    1096       13193 :     aConverter.decomposeBlockTextPrimitive(aNewTransformA, aNewTransformB, aClipRange);
    1097             : 
    1098             :     // cleanup outliner
    1099       13193 :     rOutliner.SetBackgroundColor(aOriginalBackColor);
    1100       13193 :     rOutliner.Clear();
    1101       13193 :     rOutliner.setVisualizedPage(0);
    1102             : 
    1103       26386 :     rTarget = aConverter.getPrimitive2DSequence();
    1104       13193 : }
    1105             : 
    1106           0 : void SdrTextObj::impDecomposeStretchTextPrimitive(
    1107             :     drawinglayer::primitive2d::Primitive2DSequence& rTarget,
    1108             :     const drawinglayer::primitive2d::SdrStretchTextPrimitive2D& rSdrStretchTextPrimitive,
    1109             :     const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
    1110             : {
    1111             :     // decompose matrix to have position and size of text
    1112           0 :     basegfx::B2DVector aScale, aTranslate;
    1113             :     double fRotate, fShearX;
    1114           0 :     rSdrStretchTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
    1115             : 
    1116             :     // use non-mirrored B2DRange aAnchorTextRange for calculations
    1117           0 :     basegfx::B2DRange aAnchorTextRange(aTranslate);
    1118           0 :     aAnchorTextRange.expand(aTranslate + aScale);
    1119             : 
    1120             :     // prepare outliner
    1121           0 :     SdrOutliner& rOutliner = ImpGetDrawOutliner();
    1122           0 :     const sal_uInt32 nOriginalControlWord(rOutliner.GetControlWord());
    1123           0 :     const Size aNullSize;
    1124             : 
    1125           0 :     rOutliner.SetControlWord(nOriginalControlWord|EE_CNTRL_STRETCHING|EE_CNTRL_AUTOPAGESIZE);
    1126           0 :     rOutliner.SetFixedCellHeight(rSdrStretchTextPrimitive.isFixedCellHeight());
    1127           0 :     rOutliner.SetMinAutoPaperSize(aNullSize);
    1128           0 :     rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
    1129           0 :     rOutliner.SetPaperSize(aNullSize);
    1130           0 :     rOutliner.SetUpdateMode(true);
    1131           0 :     rOutliner.SetText(rSdrStretchTextPrimitive.getOutlinerParaObject());
    1132             : 
    1133             :     // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
    1134           0 :     rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
    1135             : 
    1136             :     // now get back the laid out text size from outliner
    1137           0 :     const Size aOutlinerTextSize(rOutliner.CalcTextSize());
    1138             :     const basegfx::B2DVector aOutlinerScale(
    1139           0 :         basegfx::fTools::equalZero(aOutlinerTextSize.Width()) ? 1.0 : aOutlinerTextSize.Width(),
    1140           0 :         basegfx::fTools::equalZero(aOutlinerTextSize.Height()) ? 1.0 : aOutlinerTextSize.Height());
    1141             : 
    1142             :     // prepare matrices to apply to newly created primitives
    1143           0 :     basegfx::B2DHomMatrix aNewTransformA;
    1144             : 
    1145             :     // #i101957# Check for vertical text. If used, aNewTransformA
    1146             :     // needs to translate the text initially around object width to orient
    1147             :     // it relative to the topper right instead of the topper left
    1148           0 :     const bool bVertical(rSdrStretchTextPrimitive.getOutlinerParaObject().IsVertical());
    1149             : 
    1150           0 :     if(bVertical)
    1151             :     {
    1152           0 :         aNewTransformA.translate(aScale.getX(), 0.0);
    1153             :     }
    1154             : 
    1155             :     // calculate global char stretching scale parameters. Use non-mirrored sizes
    1156             :     // to layout without mirroring
    1157           0 :     const double fScaleX(fabs(aScale.getX()) / aOutlinerScale.getX());
    1158           0 :     const double fScaleY(fabs(aScale.getY()) / aOutlinerScale.getY());
    1159           0 :     rOutliner.SetGlobalCharStretching((sal_Int16)FRound(fScaleX * 100.0), (sal_Int16)FRound(fScaleY * 100.0));
    1160             : 
    1161             :     // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
    1162             :     // move the null point which was top left to bottom right.
    1163           0 :     const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
    1164           0 :     const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
    1165             : 
    1166             :     // in-between the translations of the single primitives will take place. Afterwards,
    1167             :     // the object's transformations need to be applied
    1168             :     const basegfx::B2DHomMatrix aNewTransformB(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
    1169             :         bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
    1170           0 :         fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
    1171             : 
    1172             :     // now break up text primitives.
    1173           0 :     impTextBreakupHandler aConverter(rOutliner);
    1174           0 :     aConverter.decomposeStretchTextPrimitive(aNewTransformA, aNewTransformB);
    1175             : 
    1176             :     // cleanup outliner
    1177           0 :     rOutliner.SetControlWord(nOriginalControlWord);
    1178           0 :     rOutliner.Clear();
    1179           0 :     rOutliner.setVisualizedPage(0);
    1180             : 
    1181           0 :     rTarget = aConverter.getPrimitive2DSequence();
    1182           0 : }
    1183             : 
    1184             : 
    1185             : // timing generators
    1186             : #define ENDLESS_LOOP    (0xffffffff)
    1187             : #define ENDLESS_TIME    ((double)0xffffffff)
    1188             : #define PIXEL_DPI       (96.0)
    1189             : 
    1190           0 : void SdrTextObj::impGetBlinkTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList) const
    1191             : {
    1192           0 :     if(SDRTEXTANI_BLINK == GetTextAniKind())
    1193             :     {
    1194             :         // get values
    1195           0 :         const SfxItemSet& rSet = GetObjectItemSet();
    1196           0 :         const sal_uInt32 nRepeat((sal_uInt32)static_cast<const SdrTextAniCountItem&>(rSet.Get(SDRATTR_TEXT_ANICOUNT)).GetValue());
    1197           0 :         bool bVisisbleWhenStopped(static_cast<const SdrTextAniStopInsideItem&>(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE)).GetValue());
    1198           0 :         double fDelay((double)static_cast<const SdrTextAniDelayItem&>(rSet.Get(SDRATTR_TEXT_ANIDELAY)).GetValue());
    1199             : 
    1200           0 :         if(0.0 == fDelay)
    1201             :         {
    1202             :             // use default
    1203           0 :             fDelay = 250.0;
    1204             :         }
    1205             : 
    1206             :         // prepare loop and add
    1207           0 :         drawinglayer::animation::AnimationEntryLoop  aLoop(nRepeat ? nRepeat : ENDLESS_LOOP);
    1208           0 :         drawinglayer::animation::AnimationEntryFixed aStart(fDelay, 0.0);
    1209           0 :         aLoop.append(aStart);
    1210           0 :         drawinglayer::animation::AnimationEntryFixed aEnd(fDelay, 1.0);
    1211           0 :         aLoop.append(aEnd);
    1212           0 :         rAnimList.append(aLoop);
    1213             : 
    1214             :         // add stopped state if loop is not endless
    1215           0 :         if(0L != nRepeat)
    1216             :         {
    1217           0 :             drawinglayer::animation::AnimationEntryFixed aStop(ENDLESS_TIME, bVisisbleWhenStopped ? 0.0 : 1.0);
    1218           0 :             rAnimList.append(aStop);
    1219           0 :         }
    1220             :     }
    1221           0 : }
    1222             : 
    1223           0 : void impCreateScrollTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, bool bForward, double fTimeFullPath, double fFrequency)
    1224             : {
    1225           0 :     bool bVisisbleWhenStopped(static_cast<const SdrTextAniStopInsideItem&>(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE)).GetValue());
    1226           0 :     bool bVisisbleWhenStarted(static_cast<const SdrTextAniStartInsideItem&>(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE )).GetValue());
    1227           0 :     const sal_uInt32 nRepeat(static_cast<const SdrTextAniCountItem&>(rSet.Get(SDRATTR_TEXT_ANICOUNT)).GetValue());
    1228             : 
    1229           0 :     if(bVisisbleWhenStarted)
    1230             :     {
    1231             :         // move from center to outside
    1232           0 :         drawinglayer::animation::AnimationEntryLinear aInOut(fTimeFullPath * 0.5, fFrequency, 0.5, bForward ? 1.0 : 0.0);
    1233           0 :         rAnimList.append(aInOut);
    1234             :     }
    1235             : 
    1236             :     // loop. In loop, move through
    1237           0 :     drawinglayer::animation::AnimationEntryLoop aLoop(nRepeat ? nRepeat : ENDLESS_LOOP);
    1238           0 :     drawinglayer::animation::AnimationEntryLinear aThrough(fTimeFullPath, fFrequency, bForward ? 0.0 : 1.0, bForward ? 1.0 : 0.0);
    1239           0 :     aLoop.append(aThrough);
    1240           0 :     rAnimList.append(aLoop);
    1241             : 
    1242           0 :     if(0L != nRepeat && bVisisbleWhenStopped)
    1243             :     {
    1244             :         // move from outside to center
    1245           0 :         drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, bForward ? 0.0 : 1.0, 0.5);
    1246           0 :         rAnimList.append(aOutIn);
    1247             : 
    1248             :         // add timing for staying at the end
    1249           0 :         drawinglayer::animation::AnimationEntryFixed aEnd(ENDLESS_TIME, 0.5);
    1250           0 :         rAnimList.append(aEnd);
    1251           0 :     }
    1252           0 : }
    1253             : 
    1254           0 : void impCreateAlternateTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, double fRelativeTextLength, bool bForward, double fTimeFullPath, double fFrequency)
    1255             : {
    1256           0 :     if(basegfx::fTools::more(fRelativeTextLength, 0.5))
    1257             :     {
    1258             :         // this is the case when fTextLength > fFrameLength, text is bigger than animation frame.
    1259             :         // In that case, correct direction
    1260           0 :         bForward = !bForward;
    1261             :     }
    1262             : 
    1263           0 :     const double fStartPosition(bForward ? fRelativeTextLength : 1.0 - fRelativeTextLength);
    1264           0 :     const double fEndPosition(bForward ? 1.0 - fRelativeTextLength : fRelativeTextLength);
    1265           0 :     bool bVisisbleWhenStopped(static_cast<const SdrTextAniStopInsideItem&>(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE)).GetValue());
    1266           0 :     bool bVisisbleWhenStarted(static_cast<const SdrTextAniStartInsideItem&>(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE )).GetValue());
    1267           0 :     const sal_uInt32 nRepeat(static_cast<const SdrTextAniCountItem&>(rSet.Get(SDRATTR_TEXT_ANICOUNT)).GetValue());
    1268             : 
    1269           0 :     if(!bVisisbleWhenStarted)
    1270             :     {
    1271             :         // move from outside to center
    1272           0 :         drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, bForward ? 0.0 : 1.0, 0.5);
    1273           0 :         rAnimList.append(aOutIn);
    1274             :     }
    1275             : 
    1276             :     // loop. In loop, move out and in again. fInnerMovePath may be negative when text is bigger then frame,
    1277             :     // so use absolute value
    1278           0 :     const double fInnerMovePath(fabs(1.0 - (fRelativeTextLength * 2.0)));
    1279           0 :     const double fTimeForInnerPath(fTimeFullPath * fInnerMovePath);
    1280           0 :     const double fHalfInnerPath(fTimeForInnerPath * 0.5);
    1281           0 :     const sal_uInt32 nDoubleRepeat(nRepeat / 2L);
    1282             : 
    1283           0 :     if(nDoubleRepeat || 0L == nRepeat)
    1284             :     {
    1285             :         // double forth and back loop
    1286           0 :         drawinglayer::animation::AnimationEntryLoop aLoop(nDoubleRepeat ? nDoubleRepeat : ENDLESS_LOOP);
    1287           0 :         drawinglayer::animation::AnimationEntryLinear aTime0(fHalfInnerPath, fFrequency, 0.5, fEndPosition);
    1288           0 :         aLoop.append(aTime0);
    1289           0 :         drawinglayer::animation::AnimationEntryLinear aTime1(fTimeForInnerPath, fFrequency, fEndPosition, fStartPosition);
    1290           0 :         aLoop.append(aTime1);
    1291           0 :         drawinglayer::animation::AnimationEntryLinear aTime2(fHalfInnerPath, fFrequency, fStartPosition, 0.5);
    1292           0 :         aLoop.append(aTime2);
    1293           0 :         rAnimList.append(aLoop);
    1294             :     }
    1295             : 
    1296           0 :     if(nRepeat % 2L)
    1297             :     {
    1298             :         // repeat is uneven, so we need one more forth and back to center
    1299           0 :         drawinglayer::animation::AnimationEntryLinear aTime0(fHalfInnerPath, fFrequency, 0.5, fEndPosition);
    1300           0 :         rAnimList.append(aTime0);
    1301           0 :         drawinglayer::animation::AnimationEntryLinear aTime1(fHalfInnerPath, fFrequency, fEndPosition, 0.5);
    1302           0 :         rAnimList.append(aTime1);
    1303             :     }
    1304             : 
    1305           0 :     if(0L != nRepeat)
    1306             :     {
    1307           0 :         if(bVisisbleWhenStopped)
    1308             :         {
    1309             :             // add timing for staying at the end
    1310           0 :             drawinglayer::animation::AnimationEntryFixed aEnd(ENDLESS_TIME, 0.5);
    1311           0 :             rAnimList.append(aEnd);
    1312             :         }
    1313             :         else
    1314             :         {
    1315             :             // move from center to outside
    1316           0 :             drawinglayer::animation::AnimationEntryLinear aInOut(fTimeFullPath * 0.5, fFrequency, 0.5, bForward ? 1.0 : 0.0);
    1317           0 :             rAnimList.append(aInOut);
    1318             :         }
    1319             :     }
    1320           0 : }
    1321             : 
    1322           0 : void impCreateSlideTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, bool bForward, double fTimeFullPath, double fFrequency)
    1323             : {
    1324             :     // move in from outside, start outside
    1325           0 :     const double fStartPosition(bForward ? 0.0 : 1.0);
    1326           0 :     const sal_uInt32 nRepeat(static_cast<const SdrTextAniCountItem&>(rSet.Get(SDRATTR_TEXT_ANICOUNT)).GetValue());
    1327             : 
    1328             :     // move from outside to center
    1329           0 :     drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, fStartPosition, 0.5);
    1330           0 :     rAnimList.append(aOutIn);
    1331             : 
    1332             :     // loop. In loop, move out and in again
    1333           0 :     if(nRepeat > 1L || 0L == nRepeat)
    1334             :     {
    1335           0 :         drawinglayer::animation::AnimationEntryLoop aLoop(nRepeat ? nRepeat - 1L : ENDLESS_LOOP);
    1336           0 :         drawinglayer::animation::AnimationEntryLinear aTime0(fTimeFullPath * 0.5, fFrequency, 0.5, fStartPosition);
    1337           0 :         aLoop.append(aTime0);
    1338           0 :         drawinglayer::animation::AnimationEntryLinear aTime1(fTimeFullPath * 0.5, fFrequency, fStartPosition, 0.5);
    1339           0 :         aLoop.append(aTime1);
    1340           0 :         rAnimList.append(aLoop);
    1341             :     }
    1342             : 
    1343             :     // always visible when stopped, so add timing for staying at the end when not endless
    1344           0 :     if(0L != nRepeat)
    1345             :     {
    1346           0 :         drawinglayer::animation::AnimationEntryFixed aEnd(ENDLESS_TIME, 0.5);
    1347           0 :         rAnimList.append(aEnd);
    1348           0 :     }
    1349           0 : }
    1350             : 
    1351           0 : void SdrTextObj::impGetScrollTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList, double fFrameLength, double fTextLength) const
    1352             : {
    1353           0 :     const SdrTextAniKind eAniKind(GetTextAniKind());
    1354             : 
    1355           0 :     if(SDRTEXTANI_SCROLL == eAniKind || SDRTEXTANI_ALTERNATE == eAniKind || SDRTEXTANI_SLIDE == eAniKind)
    1356             :     {
    1357             :         // get data. Goal is to calculate fTimeFullPath which is the time needed to
    1358             :         // move animation from (0.0) to (1.0) state
    1359           0 :         const SfxItemSet& rSet = GetObjectItemSet();
    1360           0 :         double fAnimationDelay((double)static_cast<const SdrTextAniDelayItem&>(rSet.Get(SDRATTR_TEXT_ANIDELAY)).GetValue());
    1361           0 :         double fSingleStepWidth((double)static_cast<const SdrTextAniAmountItem&>(rSet.Get(SDRATTR_TEXT_ANIAMOUNT)).GetValue());
    1362           0 :         const SdrTextAniDirection eDirection(GetTextAniDirection());
    1363           0 :         const bool bForward(SDRTEXTANI_RIGHT == eDirection || SDRTEXTANI_DOWN == eDirection);
    1364             : 
    1365           0 :         if(basegfx::fTools::equalZero(fAnimationDelay))
    1366             :         {
    1367             :             // default to 1/20 second
    1368           0 :             fAnimationDelay = 50.0;
    1369             :         }
    1370             : 
    1371           0 :         if(basegfx::fTools::less(fSingleStepWidth, 0.0))
    1372             :         {
    1373             :             // data is in pixels, convert to logic. Imply PIXEL_DPI dpi.
    1374             :             // It makes no sense to keep the view-transformation centered
    1375             :             // definitions, so get rid of them here.
    1376           0 :             fSingleStepWidth = (-fSingleStepWidth * (2540.0 / PIXEL_DPI));
    1377             :         }
    1378             : 
    1379           0 :         if(basegfx::fTools::equalZero(fSingleStepWidth))
    1380             :         {
    1381             :             // default to 1 millimeter
    1382           0 :             fSingleStepWidth = 100.0;
    1383             :         }
    1384             : 
    1385             :         // use the length of the full animation path and the number of steps
    1386             :         // to get the full path time
    1387           0 :         const double fFullPathLength(fFrameLength + fTextLength);
    1388           0 :         const double fNumberOfSteps(fFullPathLength / fSingleStepWidth);
    1389           0 :         double fTimeFullPath(fNumberOfSteps * fAnimationDelay);
    1390             : 
    1391           0 :         if(fTimeFullPath < fAnimationDelay)
    1392             :         {
    1393           0 :             fTimeFullPath = fAnimationDelay;
    1394             :         }
    1395             : 
    1396           0 :         switch(eAniKind)
    1397             :         {
    1398             :             case SDRTEXTANI_SCROLL :
    1399             :             {
    1400           0 :                 impCreateScrollTiming(rSet, rAnimList, bForward, fTimeFullPath, fAnimationDelay);
    1401           0 :                 break;
    1402             :             }
    1403             :             case SDRTEXTANI_ALTERNATE :
    1404             :             {
    1405           0 :                 double fRelativeTextLength(fTextLength / (fFrameLength + fTextLength));
    1406           0 :                 impCreateAlternateTiming(rSet, rAnimList, fRelativeTextLength, bForward, fTimeFullPath, fAnimationDelay);
    1407           0 :                 break;
    1408             :             }
    1409             :             case SDRTEXTANI_SLIDE :
    1410             :             {
    1411           0 :                 impCreateSlideTiming(rSet, rAnimList, bForward, fTimeFullPath, fAnimationDelay);
    1412           0 :                 break;
    1413             :             }
    1414           0 :             default : break; // SDRTEXTANI_NONE, SDRTEXTANI_BLINK
    1415             :         }
    1416             :     }
    1417         651 : }
    1418             : 
    1419             : 
    1420             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10