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