1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove
25*b1cdbd2cSJim Jagielski #include "precompiled_svx.hxx"
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski #include <svx/svdotext.hxx>
28*b1cdbd2cSJim Jagielski #include <svx/svdoutl.hxx>
29*b1cdbd2cSJim Jagielski #include <basegfx/vector/b2dvector.hxx>
30*b1cdbd2cSJim Jagielski #include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
31*b1cdbd2cSJim Jagielski #include <basegfx/range/b2drange.hxx>
32*b1cdbd2cSJim Jagielski #include <vcl/salbtype.hxx>
33*b1cdbd2cSJim Jagielski #include <svl/itemset.hxx>
34*b1cdbd2cSJim Jagielski #include <basegfx/polygon/b2dpolygontools.hxx>
35*b1cdbd2cSJim Jagielski #include <basegfx/polygon/b2dpolygon.hxx>
36*b1cdbd2cSJim Jagielski #include <algorithm>
37*b1cdbd2cSJim Jagielski #include <svx/xtextit.hxx>
38*b1cdbd2cSJim Jagielski #include <svx/xftshtit.hxx>
39*b1cdbd2cSJim Jagielski #include <vcl/virdev.hxx>
40*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41*b1cdbd2cSJim Jagielski #include <com/sun/star/i18n/ScriptType.hdl>
42*b1cdbd2cSJim Jagielski #include <com/sun/star/i18n/XBreakIterator.hpp>
43*b1cdbd2cSJim Jagielski #include <comphelper/processfactory.hxx>
44*b1cdbd2cSJim Jagielski #include <com/sun/star/i18n/CharacterIteratorMode.hdl>
45*b1cdbd2cSJim Jagielski #include <editeng/unolingu.hxx>
46*b1cdbd2cSJim Jagielski #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
47*b1cdbd2cSJim Jagielski #include <drawinglayer/primitive2d/textprimitive2d.hxx>
48*b1cdbd2cSJim Jagielski #include <basegfx/color/bcolor.hxx>
49*b1cdbd2cSJim Jagielski
50*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
51*b1cdbd2cSJim Jagielski // primitive decomposition helpers
52*b1cdbd2cSJim Jagielski
53*b1cdbd2cSJim Jagielski #include <basegfx/polygon/b2dlinegeometry.hxx>
54*b1cdbd2cSJim Jagielski #include <drawinglayer/attribute/strokeattribute.hxx>
55*b1cdbd2cSJim Jagielski #include <svx/xlnclit.hxx>
56*b1cdbd2cSJim Jagielski #include <svx/xlntrit.hxx>
57*b1cdbd2cSJim Jagielski #include <svx/xlnwtit.hxx>
58*b1cdbd2cSJim Jagielski #include <svx/xlinjoit.hxx>
59*b1cdbd2cSJim Jagielski #include <svx/xlndsit.hxx>
60*b1cdbd2cSJim Jagielski #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
61*b1cdbd2cSJim Jagielski #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
62*b1cdbd2cSJim Jagielski #include <editeng/editstat.hxx>
63*b1cdbd2cSJim Jagielski #include <svx/unoapi.hxx>
64*b1cdbd2cSJim Jagielski #include <drawinglayer/geometry/viewinformation2d.hxx>
65*b1cdbd2cSJim Jagielski #include <svx/sdr/attribute/sdrformtextoutlineattribute.hxx>
66*b1cdbd2cSJim Jagielski
67*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
68*b1cdbd2cSJim Jagielski
69*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::uno;
70*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::lang;
71*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::i18n;
72*b1cdbd2cSJim Jagielski
73*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
74*b1cdbd2cSJim Jagielski // PathTextPortion helper
75*b1cdbd2cSJim Jagielski
76*b1cdbd2cSJim Jagielski namespace
77*b1cdbd2cSJim Jagielski {
78*b1cdbd2cSJim Jagielski class impPathTextPortion
79*b1cdbd2cSJim Jagielski {
80*b1cdbd2cSJim Jagielski basegfx::B2DVector maOffset;
81*b1cdbd2cSJim Jagielski String maText;
82*b1cdbd2cSJim Jagielski xub_StrLen mnTextStart;
83*b1cdbd2cSJim Jagielski xub_StrLen mnTextLength;
84*b1cdbd2cSJim Jagielski sal_uInt16 mnParagraph;
85*b1cdbd2cSJim Jagielski xub_StrLen mnIndex;
86*b1cdbd2cSJim Jagielski SvxFont maFont;
87*b1cdbd2cSJim Jagielski ::std::vector< double > maDblDXArray; // double DXArray, font size independent -> unit coordinate system
88*b1cdbd2cSJim Jagielski ::com::sun::star::lang::Locale maLocale;
89*b1cdbd2cSJim Jagielski
90*b1cdbd2cSJim Jagielski // bitfield
91*b1cdbd2cSJim Jagielski unsigned mbRTL : 1;
92*b1cdbd2cSJim Jagielski
93*b1cdbd2cSJim Jagielski public:
impPathTextPortion(DrawPortionInfo & rInfo)94*b1cdbd2cSJim Jagielski impPathTextPortion(DrawPortionInfo& rInfo)
95*b1cdbd2cSJim Jagielski : maOffset(rInfo.mrStartPos.X(), rInfo.mrStartPos.Y()),
96*b1cdbd2cSJim Jagielski maText(rInfo.mrText),
97*b1cdbd2cSJim Jagielski mnTextStart(rInfo.mnTextStart),
98*b1cdbd2cSJim Jagielski mnTextLength(rInfo.mnTextLen),
99*b1cdbd2cSJim Jagielski mnParagraph(rInfo.mnPara),
100*b1cdbd2cSJim Jagielski mnIndex(rInfo.mnIndex),
101*b1cdbd2cSJim Jagielski maFont(rInfo.mrFont),
102*b1cdbd2cSJim Jagielski maDblDXArray(),
103*b1cdbd2cSJim Jagielski maLocale(rInfo.mpLocale ? *rInfo.mpLocale : ::com::sun::star::lang::Locale()),
104*b1cdbd2cSJim Jagielski mbRTL(rInfo.mrFont.IsVertical() ? false : rInfo.IsRTL())
105*b1cdbd2cSJim Jagielski {
106*b1cdbd2cSJim Jagielski if(mnTextLength && rInfo.mpDXArray)
107*b1cdbd2cSJim Jagielski {
108*b1cdbd2cSJim Jagielski maDblDXArray.reserve(mnTextLength);
109*b1cdbd2cSJim Jagielski
110*b1cdbd2cSJim Jagielski for(xub_StrLen a(0); a < mnTextLength; a++)
111*b1cdbd2cSJim Jagielski {
112*b1cdbd2cSJim Jagielski maDblDXArray.push_back((double)rInfo.mpDXArray[a]);
113*b1cdbd2cSJim Jagielski }
114*b1cdbd2cSJim Jagielski }
115*b1cdbd2cSJim Jagielski }
116*b1cdbd2cSJim Jagielski
117*b1cdbd2cSJim Jagielski // for ::std::sort
operator <(const impPathTextPortion & rComp) const118*b1cdbd2cSJim Jagielski bool operator<(const impPathTextPortion& rComp) const
119*b1cdbd2cSJim Jagielski {
120*b1cdbd2cSJim Jagielski if(mnParagraph < rComp.mnParagraph)
121*b1cdbd2cSJim Jagielski {
122*b1cdbd2cSJim Jagielski return true;
123*b1cdbd2cSJim Jagielski }
124*b1cdbd2cSJim Jagielski
125*b1cdbd2cSJim Jagielski if(maOffset.getX() < rComp.maOffset.getX())
126*b1cdbd2cSJim Jagielski {
127*b1cdbd2cSJim Jagielski return true;
128*b1cdbd2cSJim Jagielski }
129*b1cdbd2cSJim Jagielski
130*b1cdbd2cSJim Jagielski return (maOffset.getY() < rComp.maOffset.getY());
131*b1cdbd2cSJim Jagielski }
132*b1cdbd2cSJim Jagielski
getOffset() const133*b1cdbd2cSJim Jagielski const basegfx::B2DVector& getOffset() const { return maOffset; }
getText() const134*b1cdbd2cSJim Jagielski const String& getText() const { return maText; }
getTextStart() const135*b1cdbd2cSJim Jagielski xub_StrLen getTextStart() const { return mnTextStart; }
getTextLength() const136*b1cdbd2cSJim Jagielski xub_StrLen getTextLength() const { return mnTextLength; }
getParagraph() const137*b1cdbd2cSJim Jagielski sal_uInt16 getParagraph() const { return mnParagraph; }
getIndex() const138*b1cdbd2cSJim Jagielski xub_StrLen getIndex() const { return mnIndex; }
getFont() const139*b1cdbd2cSJim Jagielski const SvxFont& getFont() const { return maFont; }
isRTL() const140*b1cdbd2cSJim Jagielski bool isRTL() const { return mbRTL; }
getDoubleDXArray() const141*b1cdbd2cSJim Jagielski const ::std::vector< double >& getDoubleDXArray() const { return maDblDXArray; }
getLocale() const142*b1cdbd2cSJim Jagielski const ::com::sun::star::lang::Locale& getLocale() const { return maLocale; }
143*b1cdbd2cSJim Jagielski
getPortionIndex(xub_StrLen nIndex,xub_StrLen nLength) const144*b1cdbd2cSJim Jagielski xub_StrLen getPortionIndex(xub_StrLen nIndex, xub_StrLen nLength) const
145*b1cdbd2cSJim Jagielski {
146*b1cdbd2cSJim Jagielski if(mbRTL)
147*b1cdbd2cSJim Jagielski {
148*b1cdbd2cSJim Jagielski return (mnTextStart + (mnTextLength - (nIndex + nLength)));
149*b1cdbd2cSJim Jagielski }
150*b1cdbd2cSJim Jagielski else
151*b1cdbd2cSJim Jagielski {
152*b1cdbd2cSJim Jagielski return (mnTextStart + nIndex);
153*b1cdbd2cSJim Jagielski }
154*b1cdbd2cSJim Jagielski }
155*b1cdbd2cSJim Jagielski
getDisplayLength(xub_StrLen nIndex,xub_StrLen nLength) const156*b1cdbd2cSJim Jagielski double getDisplayLength(xub_StrLen nIndex, xub_StrLen nLength) const
157*b1cdbd2cSJim Jagielski {
158*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
159*b1cdbd2cSJim Jagielski double fRetval(0.0);
160*b1cdbd2cSJim Jagielski
161*b1cdbd2cSJim Jagielski if(maFont.IsVertical())
162*b1cdbd2cSJim Jagielski {
163*b1cdbd2cSJim Jagielski fRetval = aTextLayouter.getTextHeight() * (double)nLength;
164*b1cdbd2cSJim Jagielski }
165*b1cdbd2cSJim Jagielski else
166*b1cdbd2cSJim Jagielski {
167*b1cdbd2cSJim Jagielski fRetval = aTextLayouter.getTextWidth(maText, getPortionIndex(nIndex, nLength), nLength);
168*b1cdbd2cSJim Jagielski }
169*b1cdbd2cSJim Jagielski
170*b1cdbd2cSJim Jagielski return fRetval;
171*b1cdbd2cSJim Jagielski }
172*b1cdbd2cSJim Jagielski };
173*b1cdbd2cSJim Jagielski } // end of anonymous namespace
174*b1cdbd2cSJim Jagielski
175*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
176*b1cdbd2cSJim Jagielski // TextBreakup helper
177*b1cdbd2cSJim Jagielski
178*b1cdbd2cSJim Jagielski namespace
179*b1cdbd2cSJim Jagielski {
180*b1cdbd2cSJim Jagielski class impTextBreakupHandler
181*b1cdbd2cSJim Jagielski {
182*b1cdbd2cSJim Jagielski SdrOutliner& mrOutliner;
183*b1cdbd2cSJim Jagielski ::std::vector< impPathTextPortion > maPathTextPortions;
184*b1cdbd2cSJim Jagielski
185*b1cdbd2cSJim Jagielski DECL_LINK(decompositionPathTextPrimitive, DrawPortionInfo* );
186*b1cdbd2cSJim Jagielski
187*b1cdbd2cSJim Jagielski public:
impTextBreakupHandler(SdrOutliner & rOutliner)188*b1cdbd2cSJim Jagielski impTextBreakupHandler(SdrOutliner& rOutliner)
189*b1cdbd2cSJim Jagielski : mrOutliner(rOutliner)
190*b1cdbd2cSJim Jagielski {
191*b1cdbd2cSJim Jagielski }
192*b1cdbd2cSJim Jagielski
decompositionPathTextPrimitive()193*b1cdbd2cSJim Jagielski const ::std::vector< impPathTextPortion >& decompositionPathTextPrimitive()
194*b1cdbd2cSJim Jagielski {
195*b1cdbd2cSJim Jagielski // strip portions to maPathTextPortions
196*b1cdbd2cSJim Jagielski mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decompositionPathTextPrimitive));
197*b1cdbd2cSJim Jagielski mrOutliner.StripPortions();
198*b1cdbd2cSJim Jagielski
199*b1cdbd2cSJim Jagielski if(!maPathTextPortions.empty())
200*b1cdbd2cSJim Jagielski {
201*b1cdbd2cSJim Jagielski // sort portions by paragraph, x and y
202*b1cdbd2cSJim Jagielski ::std::sort(maPathTextPortions.begin(), maPathTextPortions.end());
203*b1cdbd2cSJim Jagielski }
204*b1cdbd2cSJim Jagielski
205*b1cdbd2cSJim Jagielski return maPathTextPortions;
206*b1cdbd2cSJim Jagielski }
207*b1cdbd2cSJim Jagielski };
208*b1cdbd2cSJim Jagielski
IMPL_LINK(impTextBreakupHandler,decompositionPathTextPrimitive,DrawPortionInfo *,pInfo)209*b1cdbd2cSJim Jagielski IMPL_LINK(impTextBreakupHandler, decompositionPathTextPrimitive, DrawPortionInfo*, pInfo)
210*b1cdbd2cSJim Jagielski {
211*b1cdbd2cSJim Jagielski maPathTextPortions.push_back(impPathTextPortion(*pInfo));
212*b1cdbd2cSJim Jagielski return 0;
213*b1cdbd2cSJim Jagielski }
214*b1cdbd2cSJim Jagielski } // end of anonymous namespace
215*b1cdbd2cSJim Jagielski
216*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
217*b1cdbd2cSJim Jagielski // TextBreakup one poly and one paragraph helper
218*b1cdbd2cSJim Jagielski
219*b1cdbd2cSJim Jagielski namespace
220*b1cdbd2cSJim Jagielski {
221*b1cdbd2cSJim Jagielski class impPolygonParagraphHandler
222*b1cdbd2cSJim Jagielski {
223*b1cdbd2cSJim Jagielski const drawinglayer::attribute::SdrFormTextAttribute maSdrFormTextAttribute; // FormText parameters
224*b1cdbd2cSJim Jagielski std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& mrDecomposition; // destination primitive list
225*b1cdbd2cSJim Jagielski std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& mrShadowDecomposition; // destination primitive list for shadow
226*b1cdbd2cSJim Jagielski Reference < com::sun::star::i18n::XBreakIterator > mxBreak; // break iterator
227*b1cdbd2cSJim Jagielski
getParagraphTextLength(const::std::vector<const impPathTextPortion * > & rTextPortions)228*b1cdbd2cSJim Jagielski double getParagraphTextLength(const ::std::vector< const impPathTextPortion* >& rTextPortions)
229*b1cdbd2cSJim Jagielski {
230*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
231*b1cdbd2cSJim Jagielski double fRetval(0.0);
232*b1cdbd2cSJim Jagielski
233*b1cdbd2cSJim Jagielski for(sal_uInt32 a(0L); a < rTextPortions.size(); a++)
234*b1cdbd2cSJim Jagielski {
235*b1cdbd2cSJim Jagielski const impPathTextPortion* pCandidate = rTextPortions[a];
236*b1cdbd2cSJim Jagielski
237*b1cdbd2cSJim Jagielski if(pCandidate && pCandidate->getTextLength())
238*b1cdbd2cSJim Jagielski {
239*b1cdbd2cSJim Jagielski aTextLayouter.setFont(pCandidate->getFont());
240*b1cdbd2cSJim Jagielski fRetval += pCandidate->getDisplayLength(0L, pCandidate->getTextLength());
241*b1cdbd2cSJim Jagielski }
242*b1cdbd2cSJim Jagielski }
243*b1cdbd2cSJim Jagielski
244*b1cdbd2cSJim Jagielski return fRetval;
245*b1cdbd2cSJim Jagielski }
246*b1cdbd2cSJim Jagielski
getNextGlyphLen(const impPathTextPortion * pCandidate,xub_StrLen nPosition,const::com::sun::star::lang::Locale & rFontLocale)247*b1cdbd2cSJim Jagielski xub_StrLen getNextGlyphLen(const impPathTextPortion* pCandidate, xub_StrLen nPosition, const ::com::sun::star::lang::Locale& rFontLocale)
248*b1cdbd2cSJim Jagielski {
249*b1cdbd2cSJim Jagielski xub_StrLen nNextGlyphLen(1);
250*b1cdbd2cSJim Jagielski
251*b1cdbd2cSJim Jagielski if(mxBreak.is())
252*b1cdbd2cSJim Jagielski {
253*b1cdbd2cSJim Jagielski sal_Int32 nDone(0L);
254*b1cdbd2cSJim Jagielski nNextGlyphLen = (xub_StrLen)mxBreak->nextCharacters(pCandidate->getText(), nPosition,
255*b1cdbd2cSJim Jagielski rFontLocale, CharacterIteratorMode::SKIPCELL, 1, nDone) - nPosition;
256*b1cdbd2cSJim Jagielski }
257*b1cdbd2cSJim Jagielski
258*b1cdbd2cSJim Jagielski return nNextGlyphLen;
259*b1cdbd2cSJim Jagielski }
260*b1cdbd2cSJim Jagielski
261*b1cdbd2cSJim Jagielski public:
impPolygonParagraphHandler(const drawinglayer::attribute::SdrFormTextAttribute & rSdrFormTextAttribute,std::vector<drawinglayer::primitive2d::BasePrimitive2D * > & rDecomposition,std::vector<drawinglayer::primitive2d::BasePrimitive2D * > & rShadowDecomposition)262*b1cdbd2cSJim Jagielski impPolygonParagraphHandler(
263*b1cdbd2cSJim Jagielski const drawinglayer::attribute::SdrFormTextAttribute& rSdrFormTextAttribute,
264*b1cdbd2cSJim Jagielski std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rDecomposition,
265*b1cdbd2cSJim Jagielski std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rShadowDecomposition)
266*b1cdbd2cSJim Jagielski : maSdrFormTextAttribute(rSdrFormTextAttribute),
267*b1cdbd2cSJim Jagielski mrDecomposition(rDecomposition),
268*b1cdbd2cSJim Jagielski mrShadowDecomposition(rShadowDecomposition)
269*b1cdbd2cSJim Jagielski {
270*b1cdbd2cSJim Jagielski // prepare BreakIterator
271*b1cdbd2cSJim Jagielski Reference < XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
272*b1cdbd2cSJim Jagielski Reference < XInterface > xInterface = xMSF->createInstance(::rtl::OUString::createFromAscii("com.sun.star.i18n.BreakIterator"));
273*b1cdbd2cSJim Jagielski
274*b1cdbd2cSJim Jagielski if(xInterface.is())
275*b1cdbd2cSJim Jagielski {
276*b1cdbd2cSJim Jagielski Any x = xInterface->queryInterface(::getCppuType((const Reference< XBreakIterator >*)0));
277*b1cdbd2cSJim Jagielski x >>= mxBreak;
278*b1cdbd2cSJim Jagielski }
279*b1cdbd2cSJim Jagielski }
280*b1cdbd2cSJim Jagielski
HandlePair(const basegfx::B2DPolygon rPolygonCandidate,const::std::vector<const impPathTextPortion * > & rTextPortions)281*b1cdbd2cSJim Jagielski void HandlePair(const basegfx::B2DPolygon rPolygonCandidate, const ::std::vector< const impPathTextPortion* >& rTextPortions)
282*b1cdbd2cSJim Jagielski {
283*b1cdbd2cSJim Jagielski // prepare polygon geometry, take into account as many parameters as possible
284*b1cdbd2cSJim Jagielski basegfx::B2DPolygon aPolygonCandidate(rPolygonCandidate);
285*b1cdbd2cSJim Jagielski const double fPolyLength(basegfx::tools::getLength(aPolygonCandidate));
286*b1cdbd2cSJim Jagielski double fPolyEnd(fPolyLength);
287*b1cdbd2cSJim Jagielski double fPolyStart(0.0);
288*b1cdbd2cSJim Jagielski double fAutosizeScaleFactor(1.0);
289*b1cdbd2cSJim Jagielski bool bAutosizeScale(false);
290*b1cdbd2cSJim Jagielski
291*b1cdbd2cSJim Jagielski if(maSdrFormTextAttribute.getFormTextMirror())
292*b1cdbd2cSJim Jagielski {
293*b1cdbd2cSJim Jagielski aPolygonCandidate.flip();
294*b1cdbd2cSJim Jagielski }
295*b1cdbd2cSJim Jagielski
296*b1cdbd2cSJim Jagielski if(maSdrFormTextAttribute.getFormTextStart()
297*b1cdbd2cSJim Jagielski && (XFT_LEFT == maSdrFormTextAttribute.getFormTextAdjust()
298*b1cdbd2cSJim Jagielski || XFT_RIGHT == maSdrFormTextAttribute.getFormTextAdjust()))
299*b1cdbd2cSJim Jagielski {
300*b1cdbd2cSJim Jagielski if(XFT_LEFT == maSdrFormTextAttribute.getFormTextAdjust())
301*b1cdbd2cSJim Jagielski {
302*b1cdbd2cSJim Jagielski fPolyStart += maSdrFormTextAttribute.getFormTextStart();
303*b1cdbd2cSJim Jagielski
304*b1cdbd2cSJim Jagielski if(fPolyStart > fPolyEnd)
305*b1cdbd2cSJim Jagielski {
306*b1cdbd2cSJim Jagielski fPolyStart = fPolyEnd;
307*b1cdbd2cSJim Jagielski }
308*b1cdbd2cSJim Jagielski }
309*b1cdbd2cSJim Jagielski else
310*b1cdbd2cSJim Jagielski {
311*b1cdbd2cSJim Jagielski fPolyEnd -= maSdrFormTextAttribute.getFormTextStart();
312*b1cdbd2cSJim Jagielski
313*b1cdbd2cSJim Jagielski if(fPolyEnd < fPolyStart)
314*b1cdbd2cSJim Jagielski {
315*b1cdbd2cSJim Jagielski fPolyEnd = fPolyStart;
316*b1cdbd2cSJim Jagielski }
317*b1cdbd2cSJim Jagielski }
318*b1cdbd2cSJim Jagielski }
319*b1cdbd2cSJim Jagielski
320*b1cdbd2cSJim Jagielski if(XFT_LEFT != maSdrFormTextAttribute.getFormTextAdjust())
321*b1cdbd2cSJim Jagielski {
322*b1cdbd2cSJim Jagielski // calculate total text length of this paragraph, some layout needs to be done
323*b1cdbd2cSJim Jagielski const double fParagraphTextLength(getParagraphTextLength(rTextPortions));
324*b1cdbd2cSJim Jagielski
325*b1cdbd2cSJim Jagielski // check if text is too long for paragraph. If yes, handle as if left aligned (default),
326*b1cdbd2cSJim Jagielski // but still take care of XFT_AUTOSIZE in that case
327*b1cdbd2cSJim Jagielski const bool bTextTooLong(fParagraphTextLength > (fPolyEnd - fPolyStart));
328*b1cdbd2cSJim Jagielski
329*b1cdbd2cSJim Jagielski if(XFT_RIGHT == maSdrFormTextAttribute.getFormTextAdjust())
330*b1cdbd2cSJim Jagielski {
331*b1cdbd2cSJim Jagielski if(!bTextTooLong)
332*b1cdbd2cSJim Jagielski {
333*b1cdbd2cSJim Jagielski // if right aligned, add difference to polygon start
334*b1cdbd2cSJim Jagielski fPolyStart += ((fPolyEnd - fPolyStart) - fParagraphTextLength);
335*b1cdbd2cSJim Jagielski }
336*b1cdbd2cSJim Jagielski }
337*b1cdbd2cSJim Jagielski else if(XFT_CENTER == maSdrFormTextAttribute.getFormTextAdjust())
338*b1cdbd2cSJim Jagielski {
339*b1cdbd2cSJim Jagielski if(!bTextTooLong)
340*b1cdbd2cSJim Jagielski {
341*b1cdbd2cSJim Jagielski // if centered, add half of difference to polygon start
342*b1cdbd2cSJim Jagielski fPolyStart += ((fPolyEnd - fPolyStart) - fParagraphTextLength) / 2.0;
343*b1cdbd2cSJim Jagielski }
344*b1cdbd2cSJim Jagielski }
345*b1cdbd2cSJim Jagielski else if(XFT_AUTOSIZE == maSdrFormTextAttribute.getFormTextAdjust())
346*b1cdbd2cSJim Jagielski {
347*b1cdbd2cSJim Jagielski // if scale, prepare scale factor between curve length and text length
348*b1cdbd2cSJim Jagielski if(0.0 != fParagraphTextLength)
349*b1cdbd2cSJim Jagielski {
350*b1cdbd2cSJim Jagielski fAutosizeScaleFactor = (fPolyEnd - fPolyStart) / fParagraphTextLength;
351*b1cdbd2cSJim Jagielski bAutosizeScale = true;
352*b1cdbd2cSJim Jagielski }
353*b1cdbd2cSJim Jagielski }
354*b1cdbd2cSJim Jagielski }
355*b1cdbd2cSJim Jagielski
356*b1cdbd2cSJim Jagielski // handle text portions for this paragraph
357*b1cdbd2cSJim Jagielski for(sal_uInt32 a(0L); a < rTextPortions.size() && fPolyStart < fPolyEnd; a++)
358*b1cdbd2cSJim Jagielski {
359*b1cdbd2cSJim Jagielski const impPathTextPortion* pCandidate = rTextPortions[a];
360*b1cdbd2cSJim Jagielski basegfx::B2DVector aFontScaling;
361*b1cdbd2cSJim Jagielski const drawinglayer::attribute::FontAttribute aCandidateFontAttribute(
362*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::getFontAttributeFromVclFont(
363*b1cdbd2cSJim Jagielski aFontScaling,
364*b1cdbd2cSJim Jagielski pCandidate->getFont(),
365*b1cdbd2cSJim Jagielski pCandidate->isRTL(),
366*b1cdbd2cSJim Jagielski false));
367*b1cdbd2cSJim Jagielski
368*b1cdbd2cSJim Jagielski if(pCandidate && pCandidate->getTextLength())
369*b1cdbd2cSJim Jagielski {
370*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
371*b1cdbd2cSJim Jagielski aTextLayouter.setFont(pCandidate->getFont());
372*b1cdbd2cSJim Jagielski xub_StrLen nUsedTextLength(0);
373*b1cdbd2cSJim Jagielski
374*b1cdbd2cSJim Jagielski while(nUsedTextLength < pCandidate->getTextLength() && fPolyStart < fPolyEnd)
375*b1cdbd2cSJim Jagielski {
376*b1cdbd2cSJim Jagielski xub_StrLen nNextGlyphLen(getNextGlyphLen(pCandidate, pCandidate->getTextStart() + nUsedTextLength, pCandidate->getLocale()));
377*b1cdbd2cSJim Jagielski
378*b1cdbd2cSJim Jagielski // prepare portion length. Takes RTL sections into account.
379*b1cdbd2cSJim Jagielski double fPortionLength(pCandidate->getDisplayLength(nUsedTextLength, nNextGlyphLen));
380*b1cdbd2cSJim Jagielski
381*b1cdbd2cSJim Jagielski if(bAutosizeScale)
382*b1cdbd2cSJim Jagielski {
383*b1cdbd2cSJim Jagielski // when autosize scaling, expand portion length
384*b1cdbd2cSJim Jagielski fPortionLength *= fAutosizeScaleFactor;
385*b1cdbd2cSJim Jagielski }
386*b1cdbd2cSJim Jagielski
387*b1cdbd2cSJim Jagielski // create transformation
388*b1cdbd2cSJim Jagielski basegfx::B2DHomMatrix aNewTransformA, aNewTransformB, aNewShadowTransform;
389*b1cdbd2cSJim Jagielski basegfx::B2DPoint aStartPos(basegfx::tools::getPositionAbsolute(aPolygonCandidate, fPolyStart, fPolyLength));
390*b1cdbd2cSJim Jagielski basegfx::B2DPoint aEndPos(aStartPos);
391*b1cdbd2cSJim Jagielski
392*b1cdbd2cSJim Jagielski // add font scaling
393*b1cdbd2cSJim Jagielski aNewTransformA.scale(aFontScaling.getX(), aFontScaling.getY());
394*b1cdbd2cSJim Jagielski
395*b1cdbd2cSJim Jagielski // prepare scaling of text primitive
396*b1cdbd2cSJim Jagielski if(bAutosizeScale)
397*b1cdbd2cSJim Jagielski {
398*b1cdbd2cSJim Jagielski // when autosize scaling, expand text primitive scaling to it
399*b1cdbd2cSJim Jagielski aNewTransformA.scale(fAutosizeScaleFactor, fAutosizeScaleFactor);
400*b1cdbd2cSJim Jagielski }
401*b1cdbd2cSJim Jagielski
402*b1cdbd2cSJim Jagielski // eventually create shadow primitives from aDecomposition and add to rDecomposition
403*b1cdbd2cSJim Jagielski const bool bShadow(XFTSHADOW_NONE != maSdrFormTextAttribute.getFormTextShadow());
404*b1cdbd2cSJim Jagielski
405*b1cdbd2cSJim Jagielski if(bShadow)
406*b1cdbd2cSJim Jagielski {
407*b1cdbd2cSJim Jagielski if(XFTSHADOW_NORMAL == maSdrFormTextAttribute.getFormTextShadow())
408*b1cdbd2cSJim Jagielski {
409*b1cdbd2cSJim Jagielski aNewShadowTransform.translate(
410*b1cdbd2cSJim Jagielski maSdrFormTextAttribute.getFormTextShdwXVal(),
411*b1cdbd2cSJim Jagielski -maSdrFormTextAttribute.getFormTextShdwYVal());
412*b1cdbd2cSJim Jagielski }
413*b1cdbd2cSJim Jagielski else // XFTSHADOW_SLANT
414*b1cdbd2cSJim Jagielski {
415*b1cdbd2cSJim Jagielski double fScaleValue(maSdrFormTextAttribute.getFormTextShdwYVal() / 100.0);
416*b1cdbd2cSJim Jagielski double fShearValue(-maSdrFormTextAttribute.getFormTextShdwXVal() * F_PI1800);
417*b1cdbd2cSJim Jagielski
418*b1cdbd2cSJim Jagielski aNewShadowTransform.scale(1.0, fScaleValue);
419*b1cdbd2cSJim Jagielski aNewShadowTransform.shearX(sin(fShearValue));
420*b1cdbd2cSJim Jagielski aNewShadowTransform.scale(1.0, cos(fShearValue));
421*b1cdbd2cSJim Jagielski }
422*b1cdbd2cSJim Jagielski }
423*b1cdbd2cSJim Jagielski
424*b1cdbd2cSJim Jagielski switch(maSdrFormTextAttribute.getFormTextStyle())
425*b1cdbd2cSJim Jagielski {
426*b1cdbd2cSJim Jagielski case XFT_ROTATE :
427*b1cdbd2cSJim Jagielski {
428*b1cdbd2cSJim Jagielski aEndPos = basegfx::tools::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
429*b1cdbd2cSJim Jagielski const basegfx::B2DVector aDirection(aEndPos - aStartPos);
430*b1cdbd2cSJim Jagielski aNewTransformB.rotate(atan2(aDirection.getY(), aDirection.getX()));
431*b1cdbd2cSJim Jagielski aNewTransformB.translate(aStartPos.getX(), aStartPos.getY());
432*b1cdbd2cSJim Jagielski
433*b1cdbd2cSJim Jagielski break;
434*b1cdbd2cSJim Jagielski }
435*b1cdbd2cSJim Jagielski case XFT_UPRIGHT :
436*b1cdbd2cSJim Jagielski {
437*b1cdbd2cSJim Jagielski aNewTransformB.translate(aStartPos.getX() - (fPortionLength / 2.0), aStartPos.getY());
438*b1cdbd2cSJim Jagielski
439*b1cdbd2cSJim Jagielski break;
440*b1cdbd2cSJim Jagielski }
441*b1cdbd2cSJim Jagielski case XFT_SLANTX :
442*b1cdbd2cSJim Jagielski {
443*b1cdbd2cSJim Jagielski aEndPos = basegfx::tools::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
444*b1cdbd2cSJim Jagielski const basegfx::B2DVector aDirection(aEndPos - aStartPos);
445*b1cdbd2cSJim Jagielski const double fShearValue(atan2(aDirection.getY(), aDirection.getX()));
446*b1cdbd2cSJim Jagielski const double fSin(sin(fShearValue));
447*b1cdbd2cSJim Jagielski const double fCos(cos(fShearValue));
448*b1cdbd2cSJim Jagielski
449*b1cdbd2cSJim Jagielski aNewTransformB.shearX(-fSin);
450*b1cdbd2cSJim Jagielski
451*b1cdbd2cSJim Jagielski // Scale may lead to objects without height since fCos == 0.0 is possible.
452*b1cdbd2cSJim Jagielski // Renderers need to handle that, it's not a forbidden value and does not
453*b1cdbd2cSJim Jagielski // need to be avoided
454*b1cdbd2cSJim Jagielski aNewTransformB.scale(1.0, fCos);
455*b1cdbd2cSJim Jagielski aNewTransformB.translate(aStartPos.getX() - (fPortionLength / 2.0), aStartPos.getY());
456*b1cdbd2cSJim Jagielski
457*b1cdbd2cSJim Jagielski break;
458*b1cdbd2cSJim Jagielski }
459*b1cdbd2cSJim Jagielski case XFT_SLANTY :
460*b1cdbd2cSJim Jagielski {
461*b1cdbd2cSJim Jagielski aEndPos = basegfx::tools::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
462*b1cdbd2cSJim Jagielski const basegfx::B2DVector aDirection(aEndPos - aStartPos);
463*b1cdbd2cSJim Jagielski const double fShearValue(atan2(aDirection.getY(), aDirection.getX()));
464*b1cdbd2cSJim Jagielski const double fCos(cos(fShearValue));
465*b1cdbd2cSJim Jagielski const double fTan(tan(fShearValue));
466*b1cdbd2cSJim Jagielski
467*b1cdbd2cSJim Jagielski // shear to 'stand' on the curve
468*b1cdbd2cSJim Jagielski aNewTransformB.shearY(fTan);
469*b1cdbd2cSJim Jagielski
470*b1cdbd2cSJim Jagielski // scale in X to make as tight as needed. As with XFT_SLANT_X, this may
471*b1cdbd2cSJim Jagielski // lead to primitives without width which the renderers will handle
472*b1cdbd2cSJim Jagielski aNewTransformA.scale(fCos, 1.0);
473*b1cdbd2cSJim Jagielski
474*b1cdbd2cSJim Jagielski aNewTransformB.translate(aStartPos.getX(), aStartPos.getY());
475*b1cdbd2cSJim Jagielski
476*b1cdbd2cSJim Jagielski break;
477*b1cdbd2cSJim Jagielski }
478*b1cdbd2cSJim Jagielski default : break; // XFT_NONE
479*b1cdbd2cSJim Jagielski }
480*b1cdbd2cSJim Jagielski
481*b1cdbd2cSJim Jagielski // distance from path?
482*b1cdbd2cSJim Jagielski if(maSdrFormTextAttribute.getFormTextDistance())
483*b1cdbd2cSJim Jagielski {
484*b1cdbd2cSJim Jagielski if(aEndPos.equal(aStartPos))
485*b1cdbd2cSJim Jagielski {
486*b1cdbd2cSJim Jagielski aEndPos = basegfx::tools::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
487*b1cdbd2cSJim Jagielski }
488*b1cdbd2cSJim Jagielski
489*b1cdbd2cSJim Jagielski // use back vector (aStartPos - aEndPos) here to get mirrored perpendicular as in old stuff
490*b1cdbd2cSJim Jagielski const basegfx::B2DVector aPerpendicular(
491*b1cdbd2cSJim Jagielski basegfx::getNormalizedPerpendicular(aStartPos - aEndPos) *
492*b1cdbd2cSJim Jagielski maSdrFormTextAttribute.getFormTextDistance());
493*b1cdbd2cSJim Jagielski aNewTransformB.translate(aPerpendicular.getX(), aPerpendicular.getY());
494*b1cdbd2cSJim Jagielski }
495*b1cdbd2cSJim Jagielski
496*b1cdbd2cSJim Jagielski if(pCandidate->getText().Len() && nNextGlyphLen)
497*b1cdbd2cSJim Jagielski {
498*b1cdbd2cSJim Jagielski const xub_StrLen nPortionIndex(pCandidate->getPortionIndex(nUsedTextLength, nNextGlyphLen));
499*b1cdbd2cSJim Jagielski ::std::vector< double > aNewDXArray;
500*b1cdbd2cSJim Jagielski
501*b1cdbd2cSJim Jagielski if(nNextGlyphLen > 1 && pCandidate->getDoubleDXArray().size())
502*b1cdbd2cSJim Jagielski {
503*b1cdbd2cSJim Jagielski // copy DXArray for portion
504*b1cdbd2cSJim Jagielski aNewDXArray.insert(
505*b1cdbd2cSJim Jagielski aNewDXArray.begin(),
506*b1cdbd2cSJim Jagielski pCandidate->getDoubleDXArray().begin() + nPortionIndex,
507*b1cdbd2cSJim Jagielski pCandidate->getDoubleDXArray().begin() + (nPortionIndex + nNextGlyphLen));
508*b1cdbd2cSJim Jagielski
509*b1cdbd2cSJim Jagielski if(nPortionIndex > 0)
510*b1cdbd2cSJim Jagielski {
511*b1cdbd2cSJim Jagielski // adapt to portion start
512*b1cdbd2cSJim Jagielski double fDXOffset= *(pCandidate->getDoubleDXArray().begin() + (nPortionIndex - 1));
513*b1cdbd2cSJim Jagielski ::std::transform(
514*b1cdbd2cSJim Jagielski aNewDXArray.begin(), aNewDXArray.end(),
515*b1cdbd2cSJim Jagielski aNewDXArray.begin(), ::std::bind2nd(::std::minus<double>(), fDXOffset));
516*b1cdbd2cSJim Jagielski }
517*b1cdbd2cSJim Jagielski
518*b1cdbd2cSJim Jagielski if(bAutosizeScale)
519*b1cdbd2cSJim Jagielski {
520*b1cdbd2cSJim Jagielski // when autosize scaling, adapt to DXArray, too
521*b1cdbd2cSJim Jagielski ::std::transform(
522*b1cdbd2cSJim Jagielski aNewDXArray.begin(), aNewDXArray.end(),
523*b1cdbd2cSJim Jagielski aNewDXArray.begin(), ::std::bind2nd(::std::multiplies<double>(), fAutosizeScaleFactor));
524*b1cdbd2cSJim Jagielski }
525*b1cdbd2cSJim Jagielski }
526*b1cdbd2cSJim Jagielski
527*b1cdbd2cSJim Jagielski if(bShadow)
528*b1cdbd2cSJim Jagielski {
529*b1cdbd2cSJim Jagielski // shadow primitive creation
530*b1cdbd2cSJim Jagielski const Color aShadowColor(maSdrFormTextAttribute.getFormTextShdwColor());
531*b1cdbd2cSJim Jagielski const basegfx::BColor aRGBShadowColor(aShadowColor.getBColor());
532*b1cdbd2cSJim Jagielski
533*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pNew =
534*b1cdbd2cSJim Jagielski new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
535*b1cdbd2cSJim Jagielski aNewTransformB * aNewShadowTransform * aNewTransformA,
536*b1cdbd2cSJim Jagielski pCandidate->getText(),
537*b1cdbd2cSJim Jagielski nPortionIndex,
538*b1cdbd2cSJim Jagielski nNextGlyphLen,
539*b1cdbd2cSJim Jagielski aNewDXArray,
540*b1cdbd2cSJim Jagielski aCandidateFontAttribute,
541*b1cdbd2cSJim Jagielski pCandidate->getLocale(),
542*b1cdbd2cSJim Jagielski aRGBShadowColor);
543*b1cdbd2cSJim Jagielski
544*b1cdbd2cSJim Jagielski mrShadowDecomposition.push_back(pNew);
545*b1cdbd2cSJim Jagielski }
546*b1cdbd2cSJim Jagielski
547*b1cdbd2cSJim Jagielski {
548*b1cdbd2cSJim Jagielski // primitive creation
549*b1cdbd2cSJim Jagielski const Color aColor(pCandidate->getFont().GetColor());
550*b1cdbd2cSJim Jagielski const basegfx::BColor aRGBColor(aColor.getBColor());
551*b1cdbd2cSJim Jagielski
552*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pNew =
553*b1cdbd2cSJim Jagielski new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
554*b1cdbd2cSJim Jagielski aNewTransformB * aNewTransformA,
555*b1cdbd2cSJim Jagielski pCandidate->getText(),
556*b1cdbd2cSJim Jagielski nPortionIndex,
557*b1cdbd2cSJim Jagielski nNextGlyphLen,
558*b1cdbd2cSJim Jagielski aNewDXArray,
559*b1cdbd2cSJim Jagielski aCandidateFontAttribute,
560*b1cdbd2cSJim Jagielski pCandidate->getLocale(),
561*b1cdbd2cSJim Jagielski aRGBColor);
562*b1cdbd2cSJim Jagielski
563*b1cdbd2cSJim Jagielski mrDecomposition.push_back(pNew);
564*b1cdbd2cSJim Jagielski }
565*b1cdbd2cSJim Jagielski }
566*b1cdbd2cSJim Jagielski
567*b1cdbd2cSJim Jagielski // consume from portion // no += here, xub_StrLen is sal_uInt16 and the compiler will gererate a warning here
568*b1cdbd2cSJim Jagielski nUsedTextLength = nUsedTextLength + nNextGlyphLen;
569*b1cdbd2cSJim Jagielski
570*b1cdbd2cSJim Jagielski // consume from polygon
571*b1cdbd2cSJim Jagielski fPolyStart += fPortionLength;
572*b1cdbd2cSJim Jagielski }
573*b1cdbd2cSJim Jagielski }
574*b1cdbd2cSJim Jagielski }
575*b1cdbd2cSJim Jagielski }
576*b1cdbd2cSJim Jagielski };
577*b1cdbd2cSJim Jagielski } // end of anonymous namespace
578*b1cdbd2cSJim Jagielski
579*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
580*b1cdbd2cSJim Jagielski // primitive decomposition helpers
581*b1cdbd2cSJim Jagielski
582*b1cdbd2cSJim Jagielski namespace
583*b1cdbd2cSJim Jagielski {
impAddPolygonStrokePrimitives(const basegfx::B2DPolyPolygonVector & rB2DPolyPolyVector,const basegfx::B2DHomMatrix & rTransform,const drawinglayer::attribute::LineAttribute & rLineAttribute,const drawinglayer::attribute::StrokeAttribute & rStrokeAttribute,std::vector<drawinglayer::primitive2d::BasePrimitive2D * > & rTarget)584*b1cdbd2cSJim Jagielski void impAddPolygonStrokePrimitives(
585*b1cdbd2cSJim Jagielski const basegfx::B2DPolyPolygonVector& rB2DPolyPolyVector,
586*b1cdbd2cSJim Jagielski const basegfx::B2DHomMatrix& rTransform,
587*b1cdbd2cSJim Jagielski const drawinglayer::attribute::LineAttribute& rLineAttribute,
588*b1cdbd2cSJim Jagielski const drawinglayer::attribute::StrokeAttribute& rStrokeAttribute,
589*b1cdbd2cSJim Jagielski std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rTarget)
590*b1cdbd2cSJim Jagielski {
591*b1cdbd2cSJim Jagielski for(basegfx::B2DPolyPolygonVector::const_iterator aPolygon(rB2DPolyPolyVector.begin()); aPolygon != rB2DPolyPolyVector.end(); aPolygon++)
592*b1cdbd2cSJim Jagielski {
593*b1cdbd2cSJim Jagielski // prepare PolyPolygons
594*b1cdbd2cSJim Jagielski basegfx::B2DPolyPolygon aB2DPolyPolygon = *aPolygon;
595*b1cdbd2cSJim Jagielski aB2DPolyPolygon.transform(rTransform);
596*b1cdbd2cSJim Jagielski
597*b1cdbd2cSJim Jagielski for(sal_uInt32 a(0L); a < aB2DPolyPolygon.count(); a++)
598*b1cdbd2cSJim Jagielski {
599*b1cdbd2cSJim Jagielski // create one primitive per polygon
600*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::PolygonStrokePrimitive2D* pNew =
601*b1cdbd2cSJim Jagielski new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
602*b1cdbd2cSJim Jagielski aB2DPolyPolygon.getB2DPolygon(a), rLineAttribute, rStrokeAttribute);
603*b1cdbd2cSJim Jagielski rTarget.push_back(pNew);
604*b1cdbd2cSJim Jagielski }
605*b1cdbd2cSJim Jagielski }
606*b1cdbd2cSJim Jagielski }
607*b1cdbd2cSJim Jagielski
impAddPathTextOutlines(const std::vector<drawinglayer::primitive2d::BasePrimitive2D * > & rSource,const drawinglayer::attribute::SdrFormTextOutlineAttribute & rOutlineAttribute)608*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::Primitive2DSequence impAddPathTextOutlines(
609*b1cdbd2cSJim Jagielski const std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rSource,
610*b1cdbd2cSJim Jagielski const drawinglayer::attribute::SdrFormTextOutlineAttribute& rOutlineAttribute)
611*b1cdbd2cSJim Jagielski {
612*b1cdbd2cSJim Jagielski std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aNewPrimitives;
613*b1cdbd2cSJim Jagielski
614*b1cdbd2cSJim Jagielski for(sal_uInt32 a(0L); a < rSource.size(); a++)
615*b1cdbd2cSJim Jagielski {
616*b1cdbd2cSJim Jagielski const drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pTextCandidate = dynamic_cast< const drawinglayer::primitive2d::TextSimplePortionPrimitive2D* >(rSource[a]);
617*b1cdbd2cSJim Jagielski
618*b1cdbd2cSJim Jagielski if(pTextCandidate)
619*b1cdbd2cSJim Jagielski {
620*b1cdbd2cSJim Jagielski basegfx::B2DPolyPolygonVector aB2DPolyPolyVector;
621*b1cdbd2cSJim Jagielski basegfx::B2DHomMatrix aPolygonTransform;
622*b1cdbd2cSJim Jagielski
623*b1cdbd2cSJim Jagielski // get text outlines and their object transformation
624*b1cdbd2cSJim Jagielski pTextCandidate->getTextOutlinesAndTransformation(aB2DPolyPolyVector, aPolygonTransform);
625*b1cdbd2cSJim Jagielski
626*b1cdbd2cSJim Jagielski if(!aB2DPolyPolyVector.empty())
627*b1cdbd2cSJim Jagielski {
628*b1cdbd2cSJim Jagielski // create stroke primitives
629*b1cdbd2cSJim Jagielski std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aStrokePrimitives;
630*b1cdbd2cSJim Jagielski impAddPolygonStrokePrimitives(
631*b1cdbd2cSJim Jagielski aB2DPolyPolyVector,
632*b1cdbd2cSJim Jagielski aPolygonTransform,
633*b1cdbd2cSJim Jagielski rOutlineAttribute.getLineAttribute(),
634*b1cdbd2cSJim Jagielski rOutlineAttribute.getStrokeAttribute(),
635*b1cdbd2cSJim Jagielski aStrokePrimitives);
636*b1cdbd2cSJim Jagielski const sal_uInt32 nStrokeCount(aStrokePrimitives.size());
637*b1cdbd2cSJim Jagielski
638*b1cdbd2cSJim Jagielski if(nStrokeCount)
639*b1cdbd2cSJim Jagielski {
640*b1cdbd2cSJim Jagielski if(rOutlineAttribute.getTransparence())
641*b1cdbd2cSJim Jagielski {
642*b1cdbd2cSJim Jagielski // create UnifiedTransparencePrimitive2D
643*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::Primitive2DSequence aStrokePrimitiveSequence(nStrokeCount);
644*b1cdbd2cSJim Jagielski
645*b1cdbd2cSJim Jagielski for(sal_uInt32 b(0L); b < nStrokeCount; b++)
646*b1cdbd2cSJim Jagielski {
647*b1cdbd2cSJim Jagielski aStrokePrimitiveSequence[b] = drawinglayer::primitive2d::Primitive2DReference(aStrokePrimitives[b]);
648*b1cdbd2cSJim Jagielski }
649*b1cdbd2cSJim Jagielski
650*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::UnifiedTransparencePrimitive2D* pNew2 =
651*b1cdbd2cSJim Jagielski new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
652*b1cdbd2cSJim Jagielski aStrokePrimitiveSequence,
653*b1cdbd2cSJim Jagielski (double)rOutlineAttribute.getTransparence() / 100.0);
654*b1cdbd2cSJim Jagielski aNewPrimitives.push_back(pNew2);
655*b1cdbd2cSJim Jagielski }
656*b1cdbd2cSJim Jagielski else
657*b1cdbd2cSJim Jagielski {
658*b1cdbd2cSJim Jagielski // add polygons to rDecomposition as polygonStrokePrimitives
659*b1cdbd2cSJim Jagielski aNewPrimitives.insert(aNewPrimitives.end(), aStrokePrimitives.begin(), aStrokePrimitives.end());
660*b1cdbd2cSJim Jagielski }
661*b1cdbd2cSJim Jagielski }
662*b1cdbd2cSJim Jagielski }
663*b1cdbd2cSJim Jagielski }
664*b1cdbd2cSJim Jagielski }
665*b1cdbd2cSJim Jagielski
666*b1cdbd2cSJim Jagielski const sal_uInt32 nNewCount(aNewPrimitives.size());
667*b1cdbd2cSJim Jagielski
668*b1cdbd2cSJim Jagielski if(nNewCount)
669*b1cdbd2cSJim Jagielski {
670*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::Primitive2DSequence aRetval(nNewCount);
671*b1cdbd2cSJim Jagielski
672*b1cdbd2cSJim Jagielski for(sal_uInt32 a(0L); a < nNewCount; a++)
673*b1cdbd2cSJim Jagielski {
674*b1cdbd2cSJim Jagielski aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(aNewPrimitives[a]);
675*b1cdbd2cSJim Jagielski }
676*b1cdbd2cSJim Jagielski
677*b1cdbd2cSJim Jagielski return aRetval;
678*b1cdbd2cSJim Jagielski }
679*b1cdbd2cSJim Jagielski else
680*b1cdbd2cSJim Jagielski {
681*b1cdbd2cSJim Jagielski return drawinglayer::primitive2d::Primitive2DSequence();
682*b1cdbd2cSJim Jagielski }
683*b1cdbd2cSJim Jagielski }
684*b1cdbd2cSJim Jagielski } // end of anonymous namespace
685*b1cdbd2cSJim Jagielski
686*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
687*b1cdbd2cSJim Jagielski // primitive decomposition
688*b1cdbd2cSJim Jagielski
impDecomposePathTextPrimitive(drawinglayer::primitive2d::Primitive2DSequence & rTarget,const drawinglayer::primitive2d::SdrPathTextPrimitive2D & rSdrPathTextPrimitive,const drawinglayer::geometry::ViewInformation2D & aViewInformation) const689*b1cdbd2cSJim Jagielski void SdrTextObj::impDecomposePathTextPrimitive(
690*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::Primitive2DSequence& rTarget,
691*b1cdbd2cSJim Jagielski const drawinglayer::primitive2d::SdrPathTextPrimitive2D& rSdrPathTextPrimitive,
692*b1cdbd2cSJim Jagielski const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
693*b1cdbd2cSJim Jagielski {
694*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::Primitive2DSequence aRetvalA;
695*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::Primitive2DSequence aRetvalB;
696*b1cdbd2cSJim Jagielski
697*b1cdbd2cSJim Jagielski // prepare outliner
698*b1cdbd2cSJim Jagielski SdrOutliner& rOutliner = ImpGetDrawOutliner();
699*b1cdbd2cSJim Jagielski rOutliner.SetUpdateMode(true);
700*b1cdbd2cSJim Jagielski rOutliner.Clear();
701*b1cdbd2cSJim Jagielski rOutliner.SetPaperSize(Size(LONG_MAX,LONG_MAX));
702*b1cdbd2cSJim Jagielski rOutliner.SetText(rSdrPathTextPrimitive.getOutlinerParaObject());
703*b1cdbd2cSJim Jagielski
704*b1cdbd2cSJim Jagielski // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
705*b1cdbd2cSJim Jagielski rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
706*b1cdbd2cSJim Jagielski
707*b1cdbd2cSJim Jagielski // now break up to text portions
708*b1cdbd2cSJim Jagielski impTextBreakupHandler aConverter(rOutliner);
709*b1cdbd2cSJim Jagielski const ::std::vector< impPathTextPortion > rPathTextPortions = aConverter.decompositionPathTextPrimitive();
710*b1cdbd2cSJim Jagielski
711*b1cdbd2cSJim Jagielski if(!rPathTextPortions.empty())
712*b1cdbd2cSJim Jagielski {
713*b1cdbd2cSJim Jagielski // get FormText and polygon values
714*b1cdbd2cSJim Jagielski const drawinglayer::attribute::SdrFormTextAttribute& rFormTextAttribute = rSdrPathTextPrimitive.getSdrFormTextAttribute();
715*b1cdbd2cSJim Jagielski const basegfx::B2DPolyPolygon& rPathPolyPolygon(rSdrPathTextPrimitive.getPathPolyPolygon());
716*b1cdbd2cSJim Jagielski
717*b1cdbd2cSJim Jagielski // get loop count
718*b1cdbd2cSJim Jagielski sal_uInt32 nLoopCount(rPathPolyPolygon.count());
719*b1cdbd2cSJim Jagielski
720*b1cdbd2cSJim Jagielski if(rOutliner.GetParagraphCount() < nLoopCount)
721*b1cdbd2cSJim Jagielski {
722*b1cdbd2cSJim Jagielski nLoopCount = rOutliner.GetParagraphCount();
723*b1cdbd2cSJim Jagielski }
724*b1cdbd2cSJim Jagielski
725*b1cdbd2cSJim Jagielski if(nLoopCount)
726*b1cdbd2cSJim Jagielski {
727*b1cdbd2cSJim Jagielski // prepare common decomposition stuff
728*b1cdbd2cSJim Jagielski std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aRegularDecomposition;
729*b1cdbd2cSJim Jagielski std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aShadowDecomposition;
730*b1cdbd2cSJim Jagielski impPolygonParagraphHandler aPolygonParagraphHandler(
731*b1cdbd2cSJim Jagielski rFormTextAttribute,
732*b1cdbd2cSJim Jagielski aRegularDecomposition,
733*b1cdbd2cSJim Jagielski aShadowDecomposition);
734*b1cdbd2cSJim Jagielski sal_uInt32 a;
735*b1cdbd2cSJim Jagielski
736*b1cdbd2cSJim Jagielski for(a = 0L; a < nLoopCount; a++)
737*b1cdbd2cSJim Jagielski {
738*b1cdbd2cSJim Jagielski // filter text portions for this paragraph
739*b1cdbd2cSJim Jagielski ::std::vector< const impPathTextPortion* > aParagraphTextPortions;
740*b1cdbd2cSJim Jagielski
741*b1cdbd2cSJim Jagielski for(sal_uInt32 b(0L); b < rPathTextPortions.size(); b++)
742*b1cdbd2cSJim Jagielski {
743*b1cdbd2cSJim Jagielski const impPathTextPortion& rCandidate = rPathTextPortions[b];
744*b1cdbd2cSJim Jagielski
745*b1cdbd2cSJim Jagielski if(rCandidate.getParagraph() == a)
746*b1cdbd2cSJim Jagielski {
747*b1cdbd2cSJim Jagielski aParagraphTextPortions.push_back(&rCandidate);
748*b1cdbd2cSJim Jagielski }
749*b1cdbd2cSJim Jagielski }
750*b1cdbd2cSJim Jagielski
751*b1cdbd2cSJim Jagielski // handle data pair polygon/ParagraphTextPortions
752*b1cdbd2cSJim Jagielski if(!aParagraphTextPortions.empty())
753*b1cdbd2cSJim Jagielski {
754*b1cdbd2cSJim Jagielski aPolygonParagraphHandler.HandlePair(rPathPolyPolygon.getB2DPolygon(a), aParagraphTextPortions);
755*b1cdbd2cSJim Jagielski }
756*b1cdbd2cSJim Jagielski }
757*b1cdbd2cSJim Jagielski
758*b1cdbd2cSJim Jagielski const sal_uInt32 nShadowCount(aShadowDecomposition.size());
759*b1cdbd2cSJim Jagielski const sal_uInt32 nRegularCount(aRegularDecomposition.size());
760*b1cdbd2cSJim Jagielski
761*b1cdbd2cSJim Jagielski if(nShadowCount)
762*b1cdbd2cSJim Jagielski {
763*b1cdbd2cSJim Jagielski // add shadow primitives to decomposition
764*b1cdbd2cSJim Jagielski aRetvalA.realloc(nShadowCount);
765*b1cdbd2cSJim Jagielski
766*b1cdbd2cSJim Jagielski for(a = 0L; a < nShadowCount; a++)
767*b1cdbd2cSJim Jagielski {
768*b1cdbd2cSJim Jagielski aRetvalA[a] = drawinglayer::primitive2d::Primitive2DReference(aShadowDecomposition[a]);
769*b1cdbd2cSJim Jagielski }
770*b1cdbd2cSJim Jagielski
771*b1cdbd2cSJim Jagielski // evtl. add shadow outlines
772*b1cdbd2cSJim Jagielski if(rFormTextAttribute.getFormTextOutline()
773*b1cdbd2cSJim Jagielski && !rFormTextAttribute.getShadowOutline().isDefault())
774*b1cdbd2cSJim Jagielski {
775*b1cdbd2cSJim Jagielski const drawinglayer::primitive2d::Primitive2DSequence aOutlines(
776*b1cdbd2cSJim Jagielski impAddPathTextOutlines(
777*b1cdbd2cSJim Jagielski aShadowDecomposition,
778*b1cdbd2cSJim Jagielski rFormTextAttribute.getShadowOutline()));
779*b1cdbd2cSJim Jagielski
780*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aRetvalA, aOutlines);
781*b1cdbd2cSJim Jagielski }
782*b1cdbd2cSJim Jagielski }
783*b1cdbd2cSJim Jagielski
784*b1cdbd2cSJim Jagielski if(nRegularCount)
785*b1cdbd2cSJim Jagielski {
786*b1cdbd2cSJim Jagielski // add normal primitives to decomposition
787*b1cdbd2cSJim Jagielski aRetvalB.realloc(nRegularCount);
788*b1cdbd2cSJim Jagielski
789*b1cdbd2cSJim Jagielski for(a = 0L; a < nRegularCount; a++)
790*b1cdbd2cSJim Jagielski {
791*b1cdbd2cSJim Jagielski aRetvalB[a] = drawinglayer::primitive2d::Primitive2DReference(aRegularDecomposition[a]);
792*b1cdbd2cSJim Jagielski }
793*b1cdbd2cSJim Jagielski
794*b1cdbd2cSJim Jagielski // evtl. add outlines
795*b1cdbd2cSJim Jagielski if(rFormTextAttribute.getFormTextOutline()
796*b1cdbd2cSJim Jagielski && !rFormTextAttribute.getOutline().isDefault())
797*b1cdbd2cSJim Jagielski {
798*b1cdbd2cSJim Jagielski const drawinglayer::primitive2d::Primitive2DSequence aOutlines(
799*b1cdbd2cSJim Jagielski impAddPathTextOutlines(
800*b1cdbd2cSJim Jagielski aRegularDecomposition,
801*b1cdbd2cSJim Jagielski rFormTextAttribute.getOutline()));
802*b1cdbd2cSJim Jagielski
803*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aRetvalB, aOutlines);
804*b1cdbd2cSJim Jagielski }
805*b1cdbd2cSJim Jagielski }
806*b1cdbd2cSJim Jagielski }
807*b1cdbd2cSJim Jagielski }
808*b1cdbd2cSJim Jagielski
809*b1cdbd2cSJim Jagielski // cleanup outliner
810*b1cdbd2cSJim Jagielski rOutliner.SetDrawPortionHdl(Link());
811*b1cdbd2cSJim Jagielski rOutliner.Clear();
812*b1cdbd2cSJim Jagielski rOutliner.setVisualizedPage(0);
813*b1cdbd2cSJim Jagielski
814*b1cdbd2cSJim Jagielski // concatenate all results
815*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aRetvalA);
816*b1cdbd2cSJim Jagielski drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aRetvalB);
817*b1cdbd2cSJim Jagielski }
818*b1cdbd2cSJim Jagielski
819*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
820*b1cdbd2cSJim Jagielski // eof
821