1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sdext.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "pdfiprocessor.hxx"
32*cdf0e10cSrcweir #include "xmlemitter.hxx"
33*cdf0e10cSrcweir #include "pdfihelper.hxx"
34*cdf0e10cSrcweir #include "imagecontainer.hxx"
35*cdf0e10cSrcweir #include "genericelements.hxx"
36*cdf0e10cSrcweir #include "style.hxx"
37*cdf0e10cSrcweir #include "treevisiting.hxx"
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <rtl/string.hxx>
40*cdf0e10cSrcweir #include <rtl/strbuf.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include <comphelper/sequence.hxx>
43*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
44*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygonclipper.hxx>
45*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
46*cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx>
47*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
48*cdf0e10cSrcweir #include <basegfx/range/b2irange.hxx>
49*cdf0e10cSrcweir #include <basegfx/range/b2drectangle.hxx>
50*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx>
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir #include <com/sun/star/rendering/XVolatileBitmap.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/geometry/RealSize2D.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/geometry/RealPoint2D.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/geometry/RealRectangle2D.hpp>
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir using namespace com::sun::star;
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir namespace pdfi
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir  PDFIProcessor::PDFIProcessor( const uno::Reference< task::XStatusIndicator >& xStat ,
65*cdf0e10cSrcweir             com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >  xContext) :
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir     m_xContext(xContext),
68*cdf0e10cSrcweir     fYPrevTextPosition(-10000.0),
69*cdf0e10cSrcweir     fPrevTextHeight(0.0),
70*cdf0e10cSrcweir     fXPrevTextPosition(0.0),
71*cdf0e10cSrcweir     fPrevTextWidth(0.0),
72*cdf0e10cSrcweir     m_pElFactory( new ElementFactory() ),
73*cdf0e10cSrcweir     m_pDocument( m_pElFactory->createDocumentElement() ),
74*cdf0e10cSrcweir     m_pCurPage(0),
75*cdf0e10cSrcweir     m_pCurElement(0),
76*cdf0e10cSrcweir     m_nNextFontId( 1 ),
77*cdf0e10cSrcweir     m_aIdToFont(),
78*cdf0e10cSrcweir     m_aFontToId(),
79*cdf0e10cSrcweir     m_aGCStack(),
80*cdf0e10cSrcweir     m_nNextGCId( 1 ),
81*cdf0e10cSrcweir     m_aIdToGC(),
82*cdf0e10cSrcweir     m_aGCToId(),
83*cdf0e10cSrcweir     m_aImages(),
84*cdf0e10cSrcweir     m_eTextDirection( LrTb ),
85*cdf0e10cSrcweir     m_nPages(0),
86*cdf0e10cSrcweir     m_nNextZOrder( 1 ),
87*cdf0e10cSrcweir     m_fWordSpace(0.0),
88*cdf0e10cSrcweir     m_bIsWhiteSpaceInLine( false ),
89*cdf0e10cSrcweir     m_xStatusIndicator( xStat ),
90*cdf0e10cSrcweir     m_bHaveTextOnDocLevel(false),
91*cdf0e10cSrcweir     m_bMirrorMapperTried(false)
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir     FontAttributes aDefFont;
94*cdf0e10cSrcweir     aDefFont.familyName = USTR("Helvetica");
95*cdf0e10cSrcweir     aDefFont.isBold     = false;
96*cdf0e10cSrcweir     aDefFont.isItalic   = false;
97*cdf0e10cSrcweir     aDefFont.size       = 10*PDFI_OUTDEV_RESOLUTION/72;
98*cdf0e10cSrcweir     m_aIdToFont[ 0 ]    = aDefFont;
99*cdf0e10cSrcweir     m_aFontToId[ aDefFont ] = 0;
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     GraphicsContext aDefGC;
102*cdf0e10cSrcweir     m_aGCStack.push_back( aDefGC );
103*cdf0e10cSrcweir     m_aIdToGC[ 0 ] = aDefGC;
104*cdf0e10cSrcweir     m_aGCToId[ aDefGC ] = 0;
105*cdf0e10cSrcweir }
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir void PDFIProcessor::enableToplevelText()
108*cdf0e10cSrcweir {
109*cdf0e10cSrcweir     m_bHaveTextOnDocLevel = true;
110*cdf0e10cSrcweir }
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir void PDFIProcessor::setPageNum( sal_Int32 nPages )
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir     m_nPages = nPages;
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir void PDFIProcessor::pushState()
119*cdf0e10cSrcweir {
120*cdf0e10cSrcweir     m_aGCStack.push_back( m_aGCStack.back() );
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir void PDFIProcessor::popState()
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir     m_aGCStack.pop_back();
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir void PDFIProcessor::setFlatness( double value )
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir     getCurrentContext().Flatness = value;
131*cdf0e10cSrcweir }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir void PDFIProcessor::setTransformation( const geometry::AffineMatrix2D& rMatrix )
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir     basegfx::unotools::homMatrixFromAffineMatrix(
136*cdf0e10cSrcweir         getCurrentContext().Transformation,
137*cdf0e10cSrcweir         rMatrix );
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir void PDFIProcessor::setLineDash( const uno::Sequence<double>& dashes,
141*cdf0e10cSrcweir                                  double                       /*start*/ )
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir     // TODO(F2): factor in start offset
144*cdf0e10cSrcweir     GraphicsContext& rContext( getCurrentContext() );
145*cdf0e10cSrcweir     comphelper::sequenceToContainer(rContext.DashArray,dashes);
146*cdf0e10cSrcweir }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir void PDFIProcessor::setLineJoin(sal_Int8 nJoin)
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir     getCurrentContext().LineJoin = nJoin;
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir void PDFIProcessor::setLineCap(sal_Int8 nCap)
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir     getCurrentContext().LineCap = nCap;
156*cdf0e10cSrcweir }
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir void PDFIProcessor::setMiterLimit(double)
159*cdf0e10cSrcweir {
160*cdf0e10cSrcweir     OSL_TRACE("PDFIProcessor::setMiterLimit(): not supported by ODF");
161*cdf0e10cSrcweir }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir void PDFIProcessor::setLineWidth(double nWidth)
164*cdf0e10cSrcweir {
165*cdf0e10cSrcweir     getCurrentContext().LineWidth = nWidth;
166*cdf0e10cSrcweir }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir void PDFIProcessor::setFillColor( const rendering::ARGBColor& rColor )
169*cdf0e10cSrcweir {
170*cdf0e10cSrcweir     getCurrentContext().FillColor = rColor;
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir void PDFIProcessor::setStrokeColor( const rendering::ARGBColor& rColor )
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir     getCurrentContext().LineColor = rColor;
176*cdf0e10cSrcweir }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir void PDFIProcessor::setBlendMode(sal_Int8)
179*cdf0e10cSrcweir {
180*cdf0e10cSrcweir     OSL_TRACE("PDFIProcessor::setBlendMode(): not supported by ODF");
181*cdf0e10cSrcweir }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir void PDFIProcessor::setFont( const FontAttributes& i_rFont )
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir     FontAttributes aChangedFont( i_rFont );
186*cdf0e10cSrcweir     GraphicsContext& rGC=getCurrentContext();
187*cdf0e10cSrcweir     // for text render modes, please see PDF reference manual
188*cdf0e10cSrcweir     aChangedFont.isOutline = ( (rGC.TextRenderMode == 1) || (rGC. TextRenderMode == 2) );
189*cdf0e10cSrcweir     FontToIdMap::const_iterator it = m_aFontToId.find( aChangedFont );
190*cdf0e10cSrcweir     if( it != m_aFontToId.end() )
191*cdf0e10cSrcweir 		rGC.FontId = it->second;
192*cdf0e10cSrcweir     else
193*cdf0e10cSrcweir     {
194*cdf0e10cSrcweir         m_aFontToId[ aChangedFont ] = m_nNextFontId;
195*cdf0e10cSrcweir         m_aIdToFont[ m_nNextFontId ] = aChangedFont;
196*cdf0e10cSrcweir         rGC.FontId = m_nNextFontId;
197*cdf0e10cSrcweir         m_nNextFontId++;
198*cdf0e10cSrcweir     }
199*cdf0e10cSrcweir }
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir void PDFIProcessor::setTextRenderMode( sal_Int32 i_nMode )
202*cdf0e10cSrcweir {
203*cdf0e10cSrcweir     GraphicsContext& rGC=getCurrentContext();
204*cdf0e10cSrcweir     rGC.TextRenderMode = i_nMode;
205*cdf0e10cSrcweir     IdToFontMap::iterator it = m_aIdToFont.find( rGC.FontId );
206*cdf0e10cSrcweir     if( it != m_aIdToFont.end() )
207*cdf0e10cSrcweir         setFont( it->second );
208*cdf0e10cSrcweir }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir sal_Int32 PDFIProcessor::getFontId( const FontAttributes& rAttr ) const
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir     const sal_Int32 nCurFont = getCurrentContext().FontId;
213*cdf0e10cSrcweir     const_cast<PDFIProcessor*>(this)->setFont( rAttr );
214*cdf0e10cSrcweir     const sal_Int32 nFont = getCurrentContext().FontId;
215*cdf0e10cSrcweir     const_cast<PDFIProcessor*>(this)->getCurrentContext().FontId = nCurFont;
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir     return nFont;
218*cdf0e10cSrcweir }
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir // line diagnose block - start
221*cdf0e10cSrcweir void PDFIProcessor::processGlyphLine()
222*cdf0e10cSrcweir {
223*cdf0e10cSrcweir 	if( m_GlyphsList.size()<1 )
224*cdf0e10cSrcweir 		return;
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     double fPreAvarageSpaceValue= 0.0;
227*cdf0e10cSrcweir     double fAvarageDiffCharSpaceValue= 0.0;
228*cdf0e10cSrcweir     double fMinPreSpaceValue= 0.0;
229*cdf0e10cSrcweir     double fMaxPreSpaceValue= 0.0;
230*cdf0e10cSrcweir     double fNullSpaceBreakerAvaregeSpaceValue = 0.0;
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     unsigned int    nSpaceCount( 0 );
233*cdf0e10cSrcweir     unsigned int    nDiffSpaceCount( 0 );
234*cdf0e10cSrcweir     unsigned int    nNullSpaceBreakerCount=0;
235*cdf0e10cSrcweir     bool preSpaceNull(true);
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir     for ( unsigned int i=0; i<m_GlyphsList.size()-1; i++ ) // i=1 because the first glyph doesn't have a prevGlyphSpace value
238*cdf0e10cSrcweir     {
239*cdf0e10cSrcweir         if( m_GlyphsList[i].getPrevGlyphsSpace()>0.0 )
240*cdf0e10cSrcweir         {
241*cdf0e10cSrcweir            if( fMinPreSpaceValue>m_GlyphsList[i].getPrevGlyphsSpace() )
242*cdf0e10cSrcweir                fMinPreSpaceValue=m_GlyphsList[i].getPrevGlyphsSpace();
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir            if( fMaxPreSpaceValue<m_GlyphsList[i].getPrevGlyphsSpace() )
245*cdf0e10cSrcweir                fMaxPreSpaceValue=m_GlyphsList[i].getPrevGlyphsSpace();
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir            fPreAvarageSpaceValue+= m_GlyphsList[i].getPrevGlyphsSpace();
248*cdf0e10cSrcweir            nSpaceCount++;
249*cdf0e10cSrcweir         }
250*cdf0e10cSrcweir     }
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir     if( nSpaceCount!=0 )
253*cdf0e10cSrcweir      fPreAvarageSpaceValue= fPreAvarageSpaceValue/( nSpaceCount );
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir     for ( unsigned int i=0; i<m_GlyphsList.size()-1; i++ ) // i=1 because the first glyph doesn't have a prevGlyphSpace value
256*cdf0e10cSrcweir     {
257*cdf0e10cSrcweir        if ( m_GlyphsList[i].getPrevGlyphsSpace()==0.0 )
258*cdf0e10cSrcweir        {
259*cdf0e10cSrcweir             if (
260*cdf0e10cSrcweir                  ( m_GlyphsList[i+1].getPrevGlyphsSpace()>0.0)&&
261*cdf0e10cSrcweir                  ( fPreAvarageSpaceValue>m_GlyphsList[i+1].getPrevGlyphsSpace())
262*cdf0e10cSrcweir                )
263*cdf0e10cSrcweir             {
264*cdf0e10cSrcweir               fNullSpaceBreakerAvaregeSpaceValue+=m_GlyphsList[i+1].getPrevGlyphsSpace();
265*cdf0e10cSrcweir               nNullSpaceBreakerCount++;
266*cdf0e10cSrcweir             }
267*cdf0e10cSrcweir         }
268*cdf0e10cSrcweir     }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir     if( ( fNullSpaceBreakerAvaregeSpaceValue!= 0.0 )&&
271*cdf0e10cSrcweir         ( fNullSpaceBreakerAvaregeSpaceValue < fPreAvarageSpaceValue )
272*cdf0e10cSrcweir       )
273*cdf0e10cSrcweir     {
274*cdf0e10cSrcweir         fPreAvarageSpaceValue = fNullSpaceBreakerAvaregeSpaceValue;
275*cdf0e10cSrcweir     }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir     for ( unsigned int i=0; i<m_GlyphsList.size()-1; i++ ) // i=1 cose the first Glypth dont have prevGlyphSpace value
278*cdf0e10cSrcweir     {
279*cdf0e10cSrcweir         if  ( ( m_GlyphsList[i].getPrevGlyphsSpace()>0.0 )
280*cdf0e10cSrcweir             )
281*cdf0e10cSrcweir         {
282*cdf0e10cSrcweir           if (
283*cdf0e10cSrcweir               ( m_GlyphsList[i].getPrevGlyphsSpace()  <= fPreAvarageSpaceValue )&&
284*cdf0e10cSrcweir               ( m_GlyphsList[i+1].getPrevGlyphsSpace()<= fPreAvarageSpaceValue )
285*cdf0e10cSrcweir              )
286*cdf0e10cSrcweir           {
287*cdf0e10cSrcweir                double temp= m_GlyphsList[i].getPrevGlyphsSpace()-m_GlyphsList[i+1].getPrevGlyphsSpace();
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir                if(temp!=0.0)
290*cdf0e10cSrcweir                {
291*cdf0e10cSrcweir                  if( temp< 0.0)
292*cdf0e10cSrcweir                   temp= temp* -1.0;
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir                  fAvarageDiffCharSpaceValue+=temp;
295*cdf0e10cSrcweir                  nDiffSpaceCount++;
296*cdf0e10cSrcweir                }
297*cdf0e10cSrcweir           }
298*cdf0e10cSrcweir         }
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir     }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir     if (
303*cdf0e10cSrcweir          ( nNullSpaceBreakerCount>0 )
304*cdf0e10cSrcweir        )
305*cdf0e10cSrcweir     {
306*cdf0e10cSrcweir        fNullSpaceBreakerAvaregeSpaceValue=fNullSpaceBreakerAvaregeSpaceValue/nNullSpaceBreakerCount;
307*cdf0e10cSrcweir     }
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir     if (
310*cdf0e10cSrcweir          ( nDiffSpaceCount>0 )&&(fAvarageDiffCharSpaceValue>0)
311*cdf0e10cSrcweir        )
312*cdf0e10cSrcweir     {
313*cdf0e10cSrcweir         fAvarageDiffCharSpaceValue= fAvarageDiffCharSpaceValue/ nDiffSpaceCount;
314*cdf0e10cSrcweir     }
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir     ParagraphElement* pPara= NULL ;
317*cdf0e10cSrcweir     FrameElement* pFrame= NULL ;
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir 	if(m_GlyphsList.size()>0)
320*cdf0e10cSrcweir 	{
321*cdf0e10cSrcweir 		pFrame = m_pElFactory->createFrameElement( m_GlyphsList[0].getCurElement(), getGCId( getTransformGlyphContext( m_GlyphsList[0])) );
322*cdf0e10cSrcweir 		pFrame->ZOrder = m_nNextZOrder++;
323*cdf0e10cSrcweir 		pPara = m_pElFactory->createParagraphElement( pFrame );
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir         processGlyph( 0,
328*cdf0e10cSrcweir                   m_GlyphsList[0],
329*cdf0e10cSrcweir                   pPara,
330*cdf0e10cSrcweir                   pFrame,
331*cdf0e10cSrcweir                   m_bIsWhiteSpaceInLine );
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir     }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir     preSpaceNull=false;
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir     for ( unsigned int i=1; i<m_GlyphsList.size()-1; i++ )
340*cdf0e10cSrcweir     {
341*cdf0e10cSrcweir         double fPrevDiffCharSpace= m_GlyphsList[i].getPrevGlyphsSpace()-m_GlyphsList[i-1].getPrevGlyphsSpace();
342*cdf0e10cSrcweir         double fPostDiffCharSpace= m_GlyphsList[i].getPrevGlyphsSpace()-m_GlyphsList[i+1].getPrevGlyphsSpace();
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir          if(
346*cdf0e10cSrcweir              preSpaceNull && (m_GlyphsList[i].getPrevGlyphsSpace()!= 0.0)
347*cdf0e10cSrcweir             )
348*cdf0e10cSrcweir          {
349*cdf0e10cSrcweir                preSpaceNull=false;
350*cdf0e10cSrcweir               if( fNullSpaceBreakerAvaregeSpaceValue > m_GlyphsList[i].getPrevGlyphsSpace() )
351*cdf0e10cSrcweir 			  {
352*cdf0e10cSrcweir                 processGlyph( 0,
353*cdf0e10cSrcweir                                       m_GlyphsList[i],
354*cdf0e10cSrcweir                               pPara,
355*cdf0e10cSrcweir                               pFrame,
356*cdf0e10cSrcweir                               m_bIsWhiteSpaceInLine );
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir 			  }
359*cdf0e10cSrcweir 			  else
360*cdf0e10cSrcweir 			  {
361*cdf0e10cSrcweir                 processGlyph( 1,
362*cdf0e10cSrcweir                               m_GlyphsList[i],
363*cdf0e10cSrcweir                               pPara,
364*cdf0e10cSrcweir                               pFrame,
365*cdf0e10cSrcweir                               m_bIsWhiteSpaceInLine );
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 			  }
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir          }
370*cdf0e10cSrcweir          else
371*cdf0e10cSrcweir          {
372*cdf0e10cSrcweir             if (
373*cdf0e10cSrcweir                 ( ( m_GlyphsList[i].getPrevGlyphsSpace()<= fPreAvarageSpaceValue )&&
374*cdf0e10cSrcweir                   ( fPrevDiffCharSpace<=fAvarageDiffCharSpaceValue )&&
375*cdf0e10cSrcweir                   ( fPostDiffCharSpace<=fAvarageDiffCharSpaceValue )
376*cdf0e10cSrcweir                 ) ||
377*cdf0e10cSrcweir                 ( m_GlyphsList[i].getPrevGlyphsSpace() == 0.0 )
378*cdf0e10cSrcweir             )
379*cdf0e10cSrcweir             {
380*cdf0e10cSrcweir                 preSpaceNull=true;
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir             processGlyph( 0,
383*cdf0e10cSrcweir                         m_GlyphsList[i],
384*cdf0e10cSrcweir                         pPara,
385*cdf0e10cSrcweir                         pFrame,
386*cdf0e10cSrcweir                         m_bIsWhiteSpaceInLine );
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir             }
389*cdf0e10cSrcweir             else
390*cdf0e10cSrcweir             {
391*cdf0e10cSrcweir                 processGlyph( 1,
392*cdf0e10cSrcweir                         m_GlyphsList[i],
393*cdf0e10cSrcweir                         pPara,
394*cdf0e10cSrcweir                         pFrame,
395*cdf0e10cSrcweir                         m_bIsWhiteSpaceInLine );
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir             }
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir          }
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir     }
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir     if(m_GlyphsList.size()>1)
404*cdf0e10cSrcweir      processGlyph( 0,
405*cdf0e10cSrcweir                   m_GlyphsList[m_GlyphsList.size()-1],
406*cdf0e10cSrcweir                   pPara,
407*cdf0e10cSrcweir                   pFrame,
408*cdf0e10cSrcweir                   m_bIsWhiteSpaceInLine );
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir     m_GlyphsList.clear();
411*cdf0e10cSrcweir }
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir void PDFIProcessor::processGlyph( double       fPreAvarageSpaceValue,
414*cdf0e10cSrcweir                                   CharGlyph&   aGlyph,
415*cdf0e10cSrcweir                                   ParagraphElement* pPara,
416*cdf0e10cSrcweir                                   FrameElement* pFrame,
417*cdf0e10cSrcweir                                   bool         bIsWhiteSpaceInLine
418*cdf0e10cSrcweir                                       )
419*cdf0e10cSrcweir {
420*cdf0e10cSrcweir     if( !bIsWhiteSpaceInLine )
421*cdf0e10cSrcweir     {
422*cdf0e10cSrcweir         bool flag=( 0 < fPreAvarageSpaceValue );
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir         drawCharGlyphs(  aGlyph.getGlyph(),
425*cdf0e10cSrcweir                          aGlyph.getRect(),
426*cdf0e10cSrcweir                          aGlyph.getFontMatrix(),
427*cdf0e10cSrcweir                          aGlyph.getGC(),
428*cdf0e10cSrcweir                          aGlyph.getCurElement(),
429*cdf0e10cSrcweir                          pPara,
430*cdf0e10cSrcweir                          pFrame,
431*cdf0e10cSrcweir                          flag);
432*cdf0e10cSrcweir     }
433*cdf0e10cSrcweir     else
434*cdf0e10cSrcweir     {
435*cdf0e10cSrcweir         drawCharGlyphs( aGlyph.getGlyph(),
436*cdf0e10cSrcweir                         aGlyph.getRect(),
437*cdf0e10cSrcweir                         aGlyph.getFontMatrix(),
438*cdf0e10cSrcweir                         aGlyph.getGC(),
439*cdf0e10cSrcweir                         aGlyph.getCurElement(),
440*cdf0e10cSrcweir                         pPara,
441*cdf0e10cSrcweir                         pFrame,
442*cdf0e10cSrcweir                         false );
443*cdf0e10cSrcweir     }
444*cdf0e10cSrcweir }
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir void PDFIProcessor::drawGlyphLine( const rtl::OUString&             rGlyphs,
447*cdf0e10cSrcweir                                    const geometry::RealRectangle2D& rRect,
448*cdf0e10cSrcweir                                    const geometry::Matrix2D&        rFontMatrix )
449*cdf0e10cSrcweir {
450*cdf0e10cSrcweir     double isFirstLine= fYPrevTextPosition+ fXPrevTextPosition+ fPrevTextHeight+ fPrevTextWidth ;
451*cdf0e10cSrcweir     if(
452*cdf0e10cSrcweir         (  ( ( fYPrevTextPosition!= rRect.Y1 ) ) ||
453*cdf0e10cSrcweir            ( ( fXPrevTextPosition > rRect.X2 ) ) ||
454*cdf0e10cSrcweir            ( ( fXPrevTextPosition+fPrevTextWidth*1.3)<rRect.X1 )
455*cdf0e10cSrcweir         )  && ( isFirstLine> 0.0 )
456*cdf0e10cSrcweir     )
457*cdf0e10cSrcweir     {
458*cdf0e10cSrcweir         processGlyphLine();
459*cdf0e10cSrcweir     }
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir     CharGlyph aGlyph;
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir     aGlyph.setGlyph ( rGlyphs );
464*cdf0e10cSrcweir     aGlyph.setRect  ( rRect );
465*cdf0e10cSrcweir     aGlyph.setFontMatrix ( rFontMatrix );
466*cdf0e10cSrcweir     aGlyph.setGraphicsContext ( getCurrentContext() );
467*cdf0e10cSrcweir     getGCId(getCurrentContext());
468*cdf0e10cSrcweir     aGlyph.setCurElement( m_pCurElement );
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir     aGlyph.setYPrevGlyphPosition( fYPrevTextPosition );
471*cdf0e10cSrcweir     aGlyph.setXPrevGlyphPosition( fXPrevTextPosition );
472*cdf0e10cSrcweir     aGlyph.setPrevGlyphHeight  ( fPrevTextHeight );
473*cdf0e10cSrcweir     aGlyph.setPrevGlyphWidth   ( fPrevTextWidth );
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir     m_GlyphsList.push_back( aGlyph );
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir     fYPrevTextPosition  = rRect.Y1;
478*cdf0e10cSrcweir     fXPrevTextPosition  = rRect.X2;
479*cdf0e10cSrcweir     fPrevTextHeight     = rRect.Y2-rRect.Y1;
480*cdf0e10cSrcweir     fPrevTextWidth      = rRect.X2-rRect.X1;
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir     if( !m_bIsWhiteSpaceInLine )
483*cdf0e10cSrcweir     {
484*cdf0e10cSrcweir         static rtl::OUString tempWhiteSpaceStr( 0x20 );
485*cdf0e10cSrcweir         static rtl::OUString tempWhiteSpaceNonBreakingStr( 0xa0 );
486*cdf0e10cSrcweir         m_bIsWhiteSpaceInLine=(rGlyphs.equals( tempWhiteSpaceStr ) || rGlyphs.equals( tempWhiteSpaceNonBreakingStr ));
487*cdf0e10cSrcweir     }
488*cdf0e10cSrcweir }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir GraphicsContext& PDFIProcessor::getTransformGlyphContext( CharGlyph& rGlyph )
491*cdf0e10cSrcweir {
492*cdf0e10cSrcweir     geometry::RealRectangle2D   rRect = rGlyph.getRect();
493*cdf0e10cSrcweir     geometry::Matrix2D          rFontMatrix = rGlyph.getFontMatrix();
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir     rtl::OUString tempStr( 32 );
496*cdf0e10cSrcweir     geometry::RealRectangle2D aRect(rRect);
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir     basegfx::B2DHomMatrix aFontMatrix;
499*cdf0e10cSrcweir     basegfx::unotools::homMatrixFromMatrix(
500*cdf0e10cSrcweir         aFontMatrix,
501*cdf0e10cSrcweir         rFontMatrix );
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir     FontAttributes aFontAttrs = m_aIdToFont[ rGlyph.getGC().FontId ];
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir     // add transformation to GC
506*cdf0e10cSrcweir     basegfx::B2DHomMatrix aFontTransform(basegfx::tools::createTranslateB2DHomMatrix(-rRect.X1, -rRect.Y1));
507*cdf0e10cSrcweir     aFontTransform *= aFontMatrix;
508*cdf0e10cSrcweir     aFontTransform.translate( rRect.X1, rRect.Y1 );
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir     rGlyph.getGC().Transformation = rGlyph.getGC().Transformation * aFontTransform;
512*cdf0e10cSrcweir     getGCId(rGlyph.getGC());
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir   return rGlyph.getGC();
515*cdf0e10cSrcweir }
516*cdf0e10cSrcweir void PDFIProcessor::drawCharGlyphs( rtl::OUString&             rGlyphs,
517*cdf0e10cSrcweir                                     geometry::RealRectangle2D& rRect,
518*cdf0e10cSrcweir                                     geometry::Matrix2D&         ,
519*cdf0e10cSrcweir                                     GraphicsContext aGC,
520*cdf0e10cSrcweir                                     Element*  ,
521*cdf0e10cSrcweir                                     ParagraphElement* pPara,
522*cdf0e10cSrcweir                                     FrameElement* pFrame,
523*cdf0e10cSrcweir                                     bool bSpaceFlag )
524*cdf0e10cSrcweir {
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir     rtl::OUString tempStr( 32 );
528*cdf0e10cSrcweir     geometry::RealRectangle2D aRect(rRect);
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir     ::basegfx::B2DRange aRect2;
531*cdf0e10cSrcweir     calcTransformedRectBounds( aRect2,
532*cdf0e10cSrcweir                                               ::basegfx::unotools::b2DRectangleFromRealRectangle2D(aRect),
533*cdf0e10cSrcweir                                               aGC.Transformation );
534*cdf0e10cSrcweir    // check whether there was a previous draw frame
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir     TextElement* pText = m_pElFactory->createTextElement( pPara,
537*cdf0e10cSrcweir                                                           getGCId(aGC),
538*cdf0e10cSrcweir                                                           aGC.FontId );
539*cdf0e10cSrcweir     if( bSpaceFlag )
540*cdf0e10cSrcweir         pText->Text.append( tempStr );
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 	pText->Text.append( rGlyphs );
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir     pText->x = aRect2.getMinX() ;
545*cdf0e10cSrcweir     pText->y = aRect2.getMinY() ;
546*cdf0e10cSrcweir     pText->w = 0.0;  // ToDO P2: 1.1 is a hack for solving of size auto-grow problem
547*cdf0e10cSrcweir     pText->h = aRect2.getHeight(); // ToDO P2: 1.1 is a hack for solving of size auto-grow problem
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir     pPara->updateGeometryWith( pText );
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir     if( pFrame )
552*cdf0e10cSrcweir       pFrame->updateGeometryWith( pPara );
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir }
555*cdf0e10cSrcweir void PDFIProcessor::drawGlyphs( const rtl::OUString&             rGlyphs,
556*cdf0e10cSrcweir                                 const geometry::RealRectangle2D& rRect,
557*cdf0e10cSrcweir                                 const geometry::Matrix2D&        rFontMatrix )
558*cdf0e10cSrcweir {
559*cdf0e10cSrcweir      drawGlyphLine( rGlyphs, rRect, rFontMatrix );
560*cdf0e10cSrcweir }
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir void PDFIProcessor::endText()
563*cdf0e10cSrcweir {
564*cdf0e10cSrcweir     TextElement* pText = dynamic_cast<TextElement*>(m_pCurElement);
565*cdf0e10cSrcweir     if( pText )
566*cdf0e10cSrcweir         m_pCurElement = pText->Parent;
567*cdf0e10cSrcweir }
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir void PDFIProcessor::setupImage(ImageId nImage)
570*cdf0e10cSrcweir {
571*cdf0e10cSrcweir     const GraphicsContext& rGC( getCurrentContext() );
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir     basegfx::B2DHomMatrix aTrans( rGC.Transformation );
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir     // check for rotation, which is the other way around in ODF
576*cdf0e10cSrcweir     basegfx::B2DTuple aScale, aTranslation;
577*cdf0e10cSrcweir     double fRotate, fShearX;
578*cdf0e10cSrcweir     rGC.Transformation.decompose( aScale, aTranslation, fRotate, fShearX );
579*cdf0e10cSrcweir     // TODDO(F4): correcting rotation when fShearX != 0 ?
580*cdf0e10cSrcweir     if( fRotate != 0.0 )
581*cdf0e10cSrcweir     {
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir         // try to create a Transformation that corrects for the wrong rotation
584*cdf0e10cSrcweir         aTrans.identity();
585*cdf0e10cSrcweir         aTrans.scale( aScale.getX(), aScale.getY() );
586*cdf0e10cSrcweir         aTrans.rotate( -fRotate );
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir         basegfx::B2DRange aRect( 0, 0, 1, 1 );
589*cdf0e10cSrcweir         aRect.transform( aTrans );
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir         // TODO(F3) treat translation correctly
592*cdf0e10cSrcweir         // the corrections below work for multiples of 90 degree
593*cdf0e10cSrcweir         // which is a common case (landscape/portrait/seascape)
594*cdf0e10cSrcweir         // we need a general solution here; however this needs to
595*cdf0e10cSrcweir         // work in sync with DrawXmlEmitter::fillFrameProps and WriterXmlEmitter::fillFrameProps
596*cdf0e10cSrcweir         // admittedly this is a lame workaround and fails for arbitrary rotation
597*cdf0e10cSrcweir         double fQuadrant = fmod( fRotate, 2.0*M_PI ) / M_PI_2;
598*cdf0e10cSrcweir         int nQuadrant = (int)fQuadrant;
599*cdf0e10cSrcweir         if( nQuadrant < 0 )
600*cdf0e10cSrcweir             nQuadrant += 4;
601*cdf0e10cSrcweir         if( nQuadrant == 1 )
602*cdf0e10cSrcweir         {
603*cdf0e10cSrcweir             aTranslation.setX( aTranslation.getX() + aRect.getHeight() + aRect.getWidth());
604*cdf0e10cSrcweir             aTranslation.setY( aTranslation.getY() + aRect.getHeight() );
605*cdf0e10cSrcweir         }
606*cdf0e10cSrcweir         if( nQuadrant == 3 )
607*cdf0e10cSrcweir             aTranslation.setX( aTranslation.getX() - aRect.getHeight() );
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir         aTrans.translate( aTranslation.getX(),
610*cdf0e10cSrcweir                           aTranslation.getY() );
611*cdf0e10cSrcweir     }
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir     bool bMirrorVertical = aScale.getY() > 0;
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir     // transform unit rect to determine view box
616*cdf0e10cSrcweir     basegfx::B2DRange aRect( 0, 0, 1, 1 );
617*cdf0e10cSrcweir     aRect.transform( aTrans );
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir     // TODO(F3): Handle clip
620*cdf0e10cSrcweir     const sal_Int32 nGCId = getGCId(rGC);
621*cdf0e10cSrcweir     FrameElement* pFrame = m_pElFactory->createFrameElement( m_pCurElement, nGCId );
622*cdf0e10cSrcweir     ImageElement* pImageElement = m_pElFactory->createImageElement( pFrame, nGCId, nImage );
623*cdf0e10cSrcweir     pFrame->x = pImageElement->x = aRect.getMinX();
624*cdf0e10cSrcweir     pFrame->y = pImageElement->y = aRect.getMinY();
625*cdf0e10cSrcweir     pFrame->w = pImageElement->w = aRect.getWidth();
626*cdf0e10cSrcweir     pFrame->h = pImageElement->h = aRect.getHeight();
627*cdf0e10cSrcweir     pFrame->ZOrder = m_nNextZOrder++;
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir     if( bMirrorVertical )
630*cdf0e10cSrcweir     {
631*cdf0e10cSrcweir         pFrame->MirrorVertical = pImageElement->MirrorVertical = true;
632*cdf0e10cSrcweir         pFrame->x        += aRect.getWidth();
633*cdf0e10cSrcweir         pImageElement->x += aRect.getWidth();
634*cdf0e10cSrcweir         pFrame->y        += aRect.getHeight();
635*cdf0e10cSrcweir         pImageElement->y += aRect.getHeight();
636*cdf0e10cSrcweir     }
637*cdf0e10cSrcweir }
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir void PDFIProcessor::drawMask(const uno::Sequence<beans::PropertyValue>& xBitmap,
640*cdf0e10cSrcweir                              bool                                       /*bInvert*/ )
641*cdf0e10cSrcweir {
642*cdf0e10cSrcweir     // TODO(F3): Handle mask and inversion
643*cdf0e10cSrcweir     setupImage( m_aImages.addImage(xBitmap) );
644*cdf0e10cSrcweir }
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir void PDFIProcessor::drawImage(const uno::Sequence<beans::PropertyValue>& xBitmap )
647*cdf0e10cSrcweir {
648*cdf0e10cSrcweir     setupImage( m_aImages.addImage(xBitmap) );
649*cdf0e10cSrcweir }
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir void PDFIProcessor::drawColorMaskedImage(const uno::Sequence<beans::PropertyValue>& xBitmap,
652*cdf0e10cSrcweir                                          const uno::Sequence<uno::Any>&             /*xMaskColors*/ )
653*cdf0e10cSrcweir {
654*cdf0e10cSrcweir     // TODO(F3): Handle mask colors
655*cdf0e10cSrcweir     setupImage( m_aImages.addImage(xBitmap) );
656*cdf0e10cSrcweir }
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir void PDFIProcessor::drawMaskedImage(const uno::Sequence<beans::PropertyValue>& xBitmap,
659*cdf0e10cSrcweir                                     const uno::Sequence<beans::PropertyValue>& /*xMask*/,
660*cdf0e10cSrcweir                                     bool                                       /*bInvertMask*/)
661*cdf0e10cSrcweir {
662*cdf0e10cSrcweir     // TODO(F3): Handle mask and inversion
663*cdf0e10cSrcweir     setupImage( m_aImages.addImage(xBitmap) );
664*cdf0e10cSrcweir }
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir void PDFIProcessor::drawAlphaMaskedImage(const uno::Sequence<beans::PropertyValue>& xBitmap,
667*cdf0e10cSrcweir                                          const uno::Sequence<beans::PropertyValue>& /*xMask*/)
668*cdf0e10cSrcweir {
669*cdf0e10cSrcweir     // TODO(F3): Handle mask
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir     setupImage( m_aImages.addImage(xBitmap) );
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir }
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir void PDFIProcessor::strokePath( const uno::Reference< rendering::XPolyPolygon2D >& rPath )
676*cdf0e10cSrcweir {
677*cdf0e10cSrcweir     basegfx::B2DPolyPolygon aPoly=basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(rPath);
678*cdf0e10cSrcweir     aPoly.transform(getCurrentContext().Transformation);
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir     PolyPolyElement* pPoly = m_pElFactory->createPolyPolyElement(
681*cdf0e10cSrcweir         m_pCurElement,
682*cdf0e10cSrcweir         getGCId(getCurrentContext()),
683*cdf0e10cSrcweir         aPoly,
684*cdf0e10cSrcweir         PATH_STROKE );
685*cdf0e10cSrcweir     pPoly->updateGeometry();
686*cdf0e10cSrcweir     pPoly->ZOrder = m_nNextZOrder++;
687*cdf0e10cSrcweir }
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir void PDFIProcessor::fillPath( const uno::Reference< rendering::XPolyPolygon2D >& rPath )
690*cdf0e10cSrcweir {
691*cdf0e10cSrcweir     basegfx::B2DPolyPolygon aPoly=basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(rPath);
692*cdf0e10cSrcweir     aPoly.transform(getCurrentContext().Transformation);
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir     PolyPolyElement* pPoly = m_pElFactory->createPolyPolyElement(
695*cdf0e10cSrcweir         m_pCurElement,
696*cdf0e10cSrcweir         getGCId(getCurrentContext()),
697*cdf0e10cSrcweir         aPoly,
698*cdf0e10cSrcweir         PATH_FILL );
699*cdf0e10cSrcweir     pPoly->updateGeometry();
700*cdf0e10cSrcweir     pPoly->ZOrder = m_nNextZOrder++;
701*cdf0e10cSrcweir }
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir void PDFIProcessor::eoFillPath( const uno::Reference< rendering::XPolyPolygon2D >& rPath )
704*cdf0e10cSrcweir {
705*cdf0e10cSrcweir     basegfx::B2DPolyPolygon aPoly=basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(rPath);
706*cdf0e10cSrcweir     aPoly.transform(getCurrentContext().Transformation);
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir     PolyPolyElement* pPoly = m_pElFactory->createPolyPolyElement(
709*cdf0e10cSrcweir         m_pCurElement,
710*cdf0e10cSrcweir         getGCId(getCurrentContext()),
711*cdf0e10cSrcweir         aPoly,
712*cdf0e10cSrcweir         PATH_EOFILL );
713*cdf0e10cSrcweir     pPoly->updateGeometry();
714*cdf0e10cSrcweir     pPoly->ZOrder = m_nNextZOrder++;
715*cdf0e10cSrcweir }
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir void PDFIProcessor::intersectClip(const uno::Reference< rendering::XPolyPolygon2D >& rPath)
718*cdf0e10cSrcweir {
719*cdf0e10cSrcweir     // TODO(F3): interpret fill mode
720*cdf0e10cSrcweir     basegfx::B2DPolyPolygon aNewClip = basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(rPath);
721*cdf0e10cSrcweir     aNewClip.transform(getCurrentContext().Transformation);
722*cdf0e10cSrcweir     basegfx::B2DPolyPolygon aCurClip = getCurrentContext().Clip;
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir     if( aCurClip.count() )  // #i92985# adapted API from (..., false, false) to (..., true, false)
725*cdf0e10cSrcweir         aNewClip = basegfx::tools::clipPolyPolygonOnPolyPolygon( aCurClip, aNewClip, true, false );
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir     getCurrentContext().Clip = aNewClip;
728*cdf0e10cSrcweir }
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir void PDFIProcessor::intersectEoClip(const uno::Reference< rendering::XPolyPolygon2D >& rPath)
731*cdf0e10cSrcweir {
732*cdf0e10cSrcweir     // TODO(F3): interpret fill mode
733*cdf0e10cSrcweir     basegfx::B2DPolyPolygon aNewClip = basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(rPath);
734*cdf0e10cSrcweir     aNewClip.transform(getCurrentContext().Transformation);
735*cdf0e10cSrcweir     basegfx::B2DPolyPolygon aCurClip = getCurrentContext().Clip;
736*cdf0e10cSrcweir 
737*cdf0e10cSrcweir     if( aCurClip.count() )  // #i92985# adapted API from (..., false, false) to (..., true, false)
738*cdf0e10cSrcweir         aNewClip = basegfx::tools::clipPolyPolygonOnPolyPolygon( aCurClip, aNewClip, true, false );
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir     getCurrentContext().Clip = aNewClip;
741*cdf0e10cSrcweir }
742*cdf0e10cSrcweir 
743*cdf0e10cSrcweir void PDFIProcessor::hyperLink( const geometry::RealRectangle2D& rBounds,
744*cdf0e10cSrcweir                                const ::rtl::OUString&           rURI )
745*cdf0e10cSrcweir {
746*cdf0e10cSrcweir     if( rURI.getLength() )
747*cdf0e10cSrcweir     {
748*cdf0e10cSrcweir         HyperlinkElement* pLink = m_pElFactory->createHyperlinkElement(
749*cdf0e10cSrcweir             &m_pCurPage->Hyperlinks,
750*cdf0e10cSrcweir             rURI );
751*cdf0e10cSrcweir         pLink->x = rBounds.X1;
752*cdf0e10cSrcweir         pLink->y = rBounds.Y1;
753*cdf0e10cSrcweir         pLink->w = rBounds.X2-rBounds.X1;
754*cdf0e10cSrcweir         pLink->h = rBounds.Y2-rBounds.Y1;
755*cdf0e10cSrcweir     }
756*cdf0e10cSrcweir }
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir const FontAttributes& PDFIProcessor::getFont( sal_Int32 nFontId ) const
759*cdf0e10cSrcweir {
760*cdf0e10cSrcweir     IdToFontMap::const_iterator it = m_aIdToFont.find( nFontId );
761*cdf0e10cSrcweir     if( it == m_aIdToFont.end() )
762*cdf0e10cSrcweir         it = m_aIdToFont.find( 0 );
763*cdf0e10cSrcweir     return it->second;
764*cdf0e10cSrcweir }
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir sal_Int32 PDFIProcessor::getGCId( const GraphicsContext& rGC )
767*cdf0e10cSrcweir {
768*cdf0e10cSrcweir     sal_Int32 nGCId = 0;
769*cdf0e10cSrcweir     GCToIdMap::const_iterator it = m_aGCToId.find( rGC );
770*cdf0e10cSrcweir     if( it != m_aGCToId.end() )
771*cdf0e10cSrcweir         nGCId = it->second;
772*cdf0e10cSrcweir     else
773*cdf0e10cSrcweir     {
774*cdf0e10cSrcweir         m_aGCToId[ rGC ] = m_nNextGCId;
775*cdf0e10cSrcweir         m_aIdToGC[ m_nNextGCId ] = rGC;
776*cdf0e10cSrcweir         nGCId = m_nNextGCId;
777*cdf0e10cSrcweir         m_nNextGCId++;
778*cdf0e10cSrcweir     }
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir     return nGCId;
781*cdf0e10cSrcweir }
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir const GraphicsContext& PDFIProcessor::getGraphicsContext( sal_Int32 nGCId ) const
784*cdf0e10cSrcweir {
785*cdf0e10cSrcweir     IdToGCMap::const_iterator it = m_aIdToGC.find( nGCId );
786*cdf0e10cSrcweir     if( it == m_aIdToGC.end() )
787*cdf0e10cSrcweir         it = m_aIdToGC.find( 0 );
788*cdf0e10cSrcweir     return it->second;
789*cdf0e10cSrcweir }
790*cdf0e10cSrcweir 
791*cdf0e10cSrcweir void PDFIProcessor::endPage()
792*cdf0e10cSrcweir {
793*cdf0e10cSrcweir 	processGlyphLine(); // draw last line
794*cdf0e10cSrcweir     if( m_xStatusIndicator.is()
795*cdf0e10cSrcweir         && m_pCurPage
796*cdf0e10cSrcweir         && m_pCurPage->PageNumber == m_nPages
797*cdf0e10cSrcweir     )
798*cdf0e10cSrcweir         m_xStatusIndicator->end();
799*cdf0e10cSrcweir }
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir void PDFIProcessor::startPage( const geometry::RealSize2D& rSize )
802*cdf0e10cSrcweir {
803*cdf0e10cSrcweir     // initial clip is to page bounds
804*cdf0e10cSrcweir     getCurrentContext().Clip = basegfx::B2DPolyPolygon(
805*cdf0e10cSrcweir         basegfx::tools::createPolygonFromRect(
806*cdf0e10cSrcweir             basegfx::B2DRange( 0, 0, rSize.Width, rSize.Height )));
807*cdf0e10cSrcweir 
808*cdf0e10cSrcweir     sal_Int32 nNextPageNr = m_pCurPage ? m_pCurPage->PageNumber+1 : 1;
809*cdf0e10cSrcweir     if( m_xStatusIndicator.is() )
810*cdf0e10cSrcweir     {
811*cdf0e10cSrcweir         if( nNextPageNr == 1 )
812*cdf0e10cSrcweir             startIndicator( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ) ) );
813*cdf0e10cSrcweir         m_xStatusIndicator->setValue( nNextPageNr );
814*cdf0e10cSrcweir     }
815*cdf0e10cSrcweir     m_pCurPage = m_pElFactory->createPageElement(m_pDocument.get(), nNextPageNr);
816*cdf0e10cSrcweir     m_pCurElement = m_pCurPage;
817*cdf0e10cSrcweir     m_pCurPage->w = rSize.Width;
818*cdf0e10cSrcweir     m_pCurPage->h = rSize.Height;
819*cdf0e10cSrcweir     m_nNextZOrder = 1;
820*cdf0e10cSrcweir 
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir }
823*cdf0e10cSrcweir 
824*cdf0e10cSrcweir void PDFIProcessor::emit( XmlEmitter&               rEmitter,
825*cdf0e10cSrcweir                           const TreeVisitorFactory& rVisitorFactory )
826*cdf0e10cSrcweir {
827*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
828*cdf0e10cSrcweir     m_pDocument->emitStructure( 0 );
829*cdf0e10cSrcweir #endif
830*cdf0e10cSrcweir 
831*cdf0e10cSrcweir     ElementTreeVisitorSharedPtr optimizingVisitor(
832*cdf0e10cSrcweir         rVisitorFactory.createOptimizingVisitor(*this));
833*cdf0e10cSrcweir     // FIXME: localization
834*cdf0e10cSrcweir     startIndicator( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " " ) ) );
835*cdf0e10cSrcweir     m_pDocument->visitedBy( *optimizingVisitor, std::list<Element*>::iterator());
836*cdf0e10cSrcweir 
837*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
838*cdf0e10cSrcweir     m_pDocument->emitStructure( 0 );
839*cdf0e10cSrcweir #endif
840*cdf0e10cSrcweir 
841*cdf0e10cSrcweir     // get styles
842*cdf0e10cSrcweir     StyleContainer aStyles;
843*cdf0e10cSrcweir     ElementTreeVisitorSharedPtr finalizingVisitor(
844*cdf0e10cSrcweir         rVisitorFactory.createStyleCollectingVisitor(aStyles,*this));
845*cdf0e10cSrcweir     // FIXME: localization
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir     m_pDocument->visitedBy( *finalizingVisitor, std::list<Element*>::iterator() );
848*cdf0e10cSrcweir 
849*cdf0e10cSrcweir     EmitContext aContext( rEmitter, aStyles, m_aImages, *this, m_xStatusIndicator, m_xContext );
850*cdf0e10cSrcweir     ElementTreeVisitorSharedPtr aEmittingVisitor(
851*cdf0e10cSrcweir         rVisitorFactory.createEmittingVisitor(aContext, *this));
852*cdf0e10cSrcweir 
853*cdf0e10cSrcweir     PropertyMap aProps;
854*cdf0e10cSrcweir     // document prolog
855*cdf0e10cSrcweir     #define OASIS_STR "urn:oasis:names:tc:opendocument:xmlns:"
856*cdf0e10cSrcweir     aProps[ USTR( "xmlns:office" ) ]      = USTR( OASIS_STR "office:1.0" );
857*cdf0e10cSrcweir     aProps[ USTR( "xmlns:style" ) ]       = USTR( OASIS_STR "style:1.0" );
858*cdf0e10cSrcweir     aProps[ USTR( "xmlns:text" ) ]        = USTR( OASIS_STR "text:1.0" );
859*cdf0e10cSrcweir     aProps[ USTR( "xmlns:svg" ) ]         = USTR( OASIS_STR "svg-compatible:1.0" );
860*cdf0e10cSrcweir     aProps[ USTR( "xmlns:table" ) ]       = USTR( OASIS_STR "table:1.0" );
861*cdf0e10cSrcweir     aProps[ USTR( "xmlns:draw" ) ]        = USTR( OASIS_STR "drawing:1.0" );
862*cdf0e10cSrcweir     aProps[ USTR( "xmlns:fo" ) ]          = USTR( OASIS_STR "xsl-fo-compatible:1.0" );
863*cdf0e10cSrcweir     aProps[ USTR( "xmlns:xlink" )]        = USTR( "http://www.w3.org/1999/xlink" );
864*cdf0e10cSrcweir     aProps[ USTR( "xmlns:dc" )]           = USTR( "http://purl.org/dc/elements/1.1/" );
865*cdf0e10cSrcweir     aProps[ USTR( "xmlns:number" )]       = USTR( OASIS_STR "datastyle:1.0" );
866*cdf0e10cSrcweir     aProps[ USTR( "xmlns:presentation" )] = USTR( OASIS_STR "presentation:1.0" );
867*cdf0e10cSrcweir     aProps[ USTR( "xmlns:math" )]         = USTR( "http://www.w3.org/1998/Math/MathML" );
868*cdf0e10cSrcweir     aProps[ USTR( "xmlns:form" )]         = USTR( OASIS_STR "form:1.0" );
869*cdf0e10cSrcweir     aProps[ USTR( "xmlns:script" )]       = USTR( OASIS_STR "script:1.0" );
870*cdf0e10cSrcweir     aProps[ USTR( "xmlns:dom" )]          = USTR( "http://www.w3.org/2001/xml-events" );
871*cdf0e10cSrcweir     aProps[ USTR( "xmlns:xforms" )]       = USTR( "http://www.w3.org/2002/xforms" );
872*cdf0e10cSrcweir     aProps[ USTR( "xmlns:xsd" )]          = USTR( "http://www.w3.org/2001/XMLSchema" );
873*cdf0e10cSrcweir     aProps[ USTR( "xmlns:xsi" )]          = USTR( "http://www.w3.org/2001/XMLSchema-instance" );
874*cdf0e10cSrcweir     aProps[ USTR( "office:version" ) ]    = USTR( "1.0" );
875*cdf0e10cSrcweir     aProps[ USTR( "office:version" ) ]    = USTR( "1.0" );
876*cdf0e10cSrcweir 
877*cdf0e10cSrcweir     aContext.rEmitter.beginTag( "office:document", aProps );
878*cdf0e10cSrcweir 
879*cdf0e10cSrcweir     // emit style list
880*cdf0e10cSrcweir     aStyles.emit( aContext, *aEmittingVisitor );
881*cdf0e10cSrcweir 
882*cdf0e10cSrcweir     m_pDocument->visitedBy( *aEmittingVisitor, std::list<Element*>::iterator() );
883*cdf0e10cSrcweir     aContext.rEmitter.endTag( "office:document" );
884*cdf0e10cSrcweir     endIndicator();
885*cdf0e10cSrcweir }
886*cdf0e10cSrcweir 
887*cdf0e10cSrcweir void PDFIProcessor::startIndicator( const rtl::OUString& rText, sal_Int32 nElements )
888*cdf0e10cSrcweir {
889*cdf0e10cSrcweir     if( nElements == -1 )
890*cdf0e10cSrcweir         nElements = m_nPages;
891*cdf0e10cSrcweir     if( m_xStatusIndicator.is() )
892*cdf0e10cSrcweir     {
893*cdf0e10cSrcweir         sal_Int32 nUnicodes = rText.getLength();
894*cdf0e10cSrcweir         rtl::OUStringBuffer aStr( nUnicodes*2 );
895*cdf0e10cSrcweir         const sal_Unicode* pText = rText.getStr();
896*cdf0e10cSrcweir         for( int i = 0; i < nUnicodes; i++ )
897*cdf0e10cSrcweir         {
898*cdf0e10cSrcweir             if( nUnicodes-i > 1&&
899*cdf0e10cSrcweir                 pText[i]   == '%' &&
900*cdf0e10cSrcweir                 pText[i+1] == 'd'
901*cdf0e10cSrcweir             )
902*cdf0e10cSrcweir             {
903*cdf0e10cSrcweir                 aStr.append( nElements );
904*cdf0e10cSrcweir                 i++;
905*cdf0e10cSrcweir             }
906*cdf0e10cSrcweir             else
907*cdf0e10cSrcweir                 aStr.append( pText[i] );
908*cdf0e10cSrcweir         }
909*cdf0e10cSrcweir         m_xStatusIndicator->start( aStr.makeStringAndClear(), nElements );
910*cdf0e10cSrcweir     }
911*cdf0e10cSrcweir }
912*cdf0e10cSrcweir 
913*cdf0e10cSrcweir void PDFIProcessor::endIndicator()
914*cdf0e10cSrcweir {
915*cdf0e10cSrcweir     if( m_xStatusIndicator.is() )
916*cdf0e10cSrcweir         m_xStatusIndicator->end();
917*cdf0e10cSrcweir }
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir void PDFIProcessor::sortDocument( bool bDeep )
920*cdf0e10cSrcweir {
921*cdf0e10cSrcweir     for( std::list< Element* >::iterator it = m_pDocument->Children.begin();
922*cdf0e10cSrcweir          it != m_pDocument->Children.end(); ++it )
923*cdf0e10cSrcweir     {
924*cdf0e10cSrcweir         if( dynamic_cast<PageElement*>(*it) != NULL )
925*cdf0e10cSrcweir             sortElements( *it, bDeep );
926*cdf0e10cSrcweir     }
927*cdf0e10cSrcweir }
928*cdf0e10cSrcweir 
929*cdf0e10cSrcweir static bool lr_tb_sort( Element* pLeft, Element* pRight )
930*cdf0e10cSrcweir {
931*cdf0e10cSrcweir     // first: top-bottom sorting
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir     // Note: allow for 10% overlap on text lines since text lines are usually
934*cdf0e10cSrcweir     // of the same order as font height whereas the real paint area
935*cdf0e10cSrcweir     // of text is usually smaller
936*cdf0e10cSrcweir     double fudge_factor = 1.0;
937*cdf0e10cSrcweir     if( dynamic_cast< TextElement* >(pLeft) || dynamic_cast< TextElement* >(pRight) )
938*cdf0e10cSrcweir         fudge_factor = 0.9;
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir     // if left's lower boundary is above right's upper boundary
941*cdf0e10cSrcweir     // then left is smaller
942*cdf0e10cSrcweir     if( pLeft->y+pLeft->h*fudge_factor < pRight->y )
943*cdf0e10cSrcweir         return true;
944*cdf0e10cSrcweir     // if right's lower boundary is above left's upper boundary
945*cdf0e10cSrcweir     // then left is definitely not smaller
946*cdf0e10cSrcweir     if( pRight->y+pRight->h*fudge_factor < pLeft->y )
947*cdf0e10cSrcweir         return false;
948*cdf0e10cSrcweir 
949*cdf0e10cSrcweir     // by now we have established that left and right are inside
950*cdf0e10cSrcweir     // a "line", that is they have vertical overlap
951*cdf0e10cSrcweir     // second: left-right sorting
952*cdf0e10cSrcweir     // if left's right boundary is left to right's left boundary
953*cdf0e10cSrcweir     // then left is smaller
954*cdf0e10cSrcweir     if( pLeft->x+pLeft->w < pRight->x )
955*cdf0e10cSrcweir         return true;
956*cdf0e10cSrcweir     // if right's right boundary is left to left's left boundary
957*cdf0e10cSrcweir     // then left is definitely not smaller
958*cdf0e10cSrcweir     if( pRight->x+pRight->w < pLeft->x )
959*cdf0e10cSrcweir         return false;
960*cdf0e10cSrcweir 
961*cdf0e10cSrcweir     // here we have established vertical and horizontal overlap
962*cdf0e10cSrcweir     // so sort left first, top second
963*cdf0e10cSrcweir     if( pLeft->x < pRight->x )
964*cdf0e10cSrcweir         return true;
965*cdf0e10cSrcweir     if( pRight->x < pLeft->x )
966*cdf0e10cSrcweir         return false;
967*cdf0e10cSrcweir     if( pLeft->y < pRight->y )
968*cdf0e10cSrcweir         return true;
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir     return false;
971*cdf0e10cSrcweir }
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir void PDFIProcessor::sortElements( Element* pEle, bool bDeep )
974*cdf0e10cSrcweir {
975*cdf0e10cSrcweir     if( pEle->Children.empty() )
976*cdf0e10cSrcweir         return;
977*cdf0e10cSrcweir 
978*cdf0e10cSrcweir     if( bDeep )
979*cdf0e10cSrcweir     {
980*cdf0e10cSrcweir         for( std::list< Element* >::iterator it = pEle->Children.begin();
981*cdf0e10cSrcweir              it != pEle->Children.end(); ++it )
982*cdf0e10cSrcweir         {
983*cdf0e10cSrcweir             sortElements( *it, bDeep );
984*cdf0e10cSrcweir         }
985*cdf0e10cSrcweir     }
986*cdf0e10cSrcweir     // HACK: the stable sort member on std::list that takes a
987*cdf0e10cSrcweir     // strict weak ordering requires member templates - which we
988*cdf0e10cSrcweir     // do not have on all compilers. so we need to use std::stable_sort
989*cdf0e10cSrcweir     // here - which does need random access iterators which the
990*cdf0e10cSrcweir     // list iterators are not.
991*cdf0e10cSrcweir     // so we need to copy the Element* to an array, stable sort that and
992*cdf0e10cSrcweir     // copy them back.
993*cdf0e10cSrcweir     std::vector<Element*> aChildren;
994*cdf0e10cSrcweir     while( ! pEle->Children.empty() )
995*cdf0e10cSrcweir     {
996*cdf0e10cSrcweir         aChildren.push_back( pEle->Children.front() );
997*cdf0e10cSrcweir         pEle->Children.pop_front();
998*cdf0e10cSrcweir     }
999*cdf0e10cSrcweir     switch( m_eTextDirection )
1000*cdf0e10cSrcweir     {
1001*cdf0e10cSrcweir         case LrTb:
1002*cdf0e10cSrcweir         default:
1003*cdf0e10cSrcweir         std::stable_sort( aChildren.begin(), aChildren.end(), lr_tb_sort );
1004*cdf0e10cSrcweir         break;
1005*cdf0e10cSrcweir     }
1006*cdf0e10cSrcweir     int nChildren = aChildren.size();
1007*cdf0e10cSrcweir     for( int i = 0; i < nChildren; i++ )
1008*cdf0e10cSrcweir         pEle->Children.push_back( aChildren[i] );
1009*cdf0e10cSrcweir }
1010*cdf0e10cSrcweir 
1011*cdf0e10cSrcweir 
1012*cdf0e10cSrcweir ::basegfx::B2DRange& PDFIProcessor::calcTransformedRectBounds( ::basegfx::B2DRange&			outRect,
1013*cdf0e10cSrcweir                                                         const ::basegfx::B2DRange&		inRect,
1014*cdf0e10cSrcweir                                                         const ::basegfx::B2DHomMatrix& 	transformation )
1015*cdf0e10cSrcweir         {
1016*cdf0e10cSrcweir             outRect.reset();
1017*cdf0e10cSrcweir 
1018*cdf0e10cSrcweir             if( inRect.isEmpty() )
1019*cdf0e10cSrcweir                 return outRect;
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir             // transform all four extremal points of the rectangle,
1022*cdf0e10cSrcweir             // take bounding rect of those.
1023*cdf0e10cSrcweir 
1024*cdf0e10cSrcweir             // transform left-top point
1025*cdf0e10cSrcweir             outRect.expand( transformation * inRect.getMinimum() );
1026*cdf0e10cSrcweir 
1027*cdf0e10cSrcweir             // transform bottom-right point
1028*cdf0e10cSrcweir             outRect.expand( transformation * inRect.getMaximum() );
1029*cdf0e10cSrcweir 
1030*cdf0e10cSrcweir             ::basegfx::B2DPoint aPoint;
1031*cdf0e10cSrcweir 
1032*cdf0e10cSrcweir             // transform top-right point
1033*cdf0e10cSrcweir             aPoint.setX( inRect.getMaxX() );
1034*cdf0e10cSrcweir             aPoint.setY( inRect.getMinY() );
1035*cdf0e10cSrcweir 
1036*cdf0e10cSrcweir             aPoint *= transformation;
1037*cdf0e10cSrcweir             outRect.expand( aPoint );
1038*cdf0e10cSrcweir 
1039*cdf0e10cSrcweir             // transform bottom-left point
1040*cdf0e10cSrcweir             aPoint.setX( inRect.getMinX() );
1041*cdf0e10cSrcweir             aPoint.setY( inRect.getMaxY() );
1042*cdf0e10cSrcweir 
1043*cdf0e10cSrcweir             aPoint *= transformation;
1044*cdf0e10cSrcweir             outRect.expand( aPoint );
1045*cdf0e10cSrcweir 
1046*cdf0e10cSrcweir             // over and out.
1047*cdf0e10cSrcweir             return outRect;
1048*cdf0e10cSrcweir         }
1049*cdf0e10cSrcweir 
1050*cdf0e10cSrcweir // helper method: get a mirrored string
1051*cdf0e10cSrcweir rtl::OUString PDFIProcessor::mirrorString( const rtl::OUString& i_rString )
1052*cdf0e10cSrcweir {
1053*cdf0e10cSrcweir     if( ! m_xMirrorMapper.is() && ! m_bMirrorMapperTried )
1054*cdf0e10cSrcweir     {
1055*cdf0e10cSrcweir     	m_bMirrorMapperTried = true;
1056*cdf0e10cSrcweir         uno::Reference< lang::XMultiComponentFactory > xMSF(  m_xContext->getServiceManager(), uno::UNO_SET_THROW );
1057*cdf0e10cSrcweir         uno::Reference < uno::XInterface > xInterface = xMSF->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.awt.StringMirror"), m_xContext);
1058*cdf0e10cSrcweir     	m_xMirrorMapper = uno::Reference< util::XStringMapping >( xInterface, uno::UNO_QUERY );
1059*cdf0e10cSrcweir         #if OSL_DEBUG_LEVEL > 1
1060*cdf0e10cSrcweir         if( m_xMirrorMapper.is() )
1061*cdf0e10cSrcweir             fprintf( stderr, "using mirror mapper service\n" );
1062*cdf0e10cSrcweir         #endif
1063*cdf0e10cSrcweir     }
1064*cdf0e10cSrcweir     if( m_xMirrorMapper.is() )
1065*cdf0e10cSrcweir     {
1066*cdf0e10cSrcweir         uno::Sequence< rtl::OUString > aSeq( 1 );
1067*cdf0e10cSrcweir         aSeq.getArray()[0] = i_rString;
1068*cdf0e10cSrcweir         m_xMirrorMapper->mapStrings( aSeq );
1069*cdf0e10cSrcweir         return  aSeq[0];
1070*cdf0e10cSrcweir     }
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir     prepareMirrorMap();
1073*cdf0e10cSrcweir     sal_Int32 nLen = i_rString.getLength();
1074*cdf0e10cSrcweir     rtl::OUStringBuffer aRet( nLen );
1075*cdf0e10cSrcweir     for(int i = nLen - 1; i >= 0; i--)
1076*cdf0e10cSrcweir     {
1077*cdf0e10cSrcweir         sal_Unicode cChar = i_rString[ i ];
1078*cdf0e10cSrcweir         aRet.append( m_aMirrorMap[cChar] );
1079*cdf0e10cSrcweir     }
1080*cdf0e10cSrcweir     return aRet.makeStringAndClear();
1081*cdf0e10cSrcweir }
1082*cdf0e10cSrcweir 
1083*cdf0e10cSrcweir void PDFIProcessor::prepareMirrorMap()
1084*cdf0e10cSrcweir {
1085*cdf0e10cSrcweir     if( m_aMirrorMap.empty() )
1086*cdf0e10cSrcweir     {
1087*cdf0e10cSrcweir         #if OSL_DEBUG_LEVEL > 1
1088*cdf0e10cSrcweir         fprintf( stderr, "falling back to static mirror list\n" );
1089*cdf0e10cSrcweir         #endif
1090*cdf0e10cSrcweir 
1091*cdf0e10cSrcweir         m_aMirrorMap.reserve( 0x10000 );
1092*cdf0e10cSrcweir         for( int i = 0; i < 0x10000; i++ )
1093*cdf0e10cSrcweir             m_aMirrorMap.push_back( sal_Unicode(i) );
1094*cdf0e10cSrcweir 
1095*cdf0e10cSrcweir         m_aMirrorMap[ 0x0028 ] = 0x0029; // LEFT PARENTHESIS
1096*cdf0e10cSrcweir         m_aMirrorMap[ 0x0029 ] = 0x0028; // RIGHT PARENTHESIS
1097*cdf0e10cSrcweir         m_aMirrorMap[ 0x003C ] = 0x003E; // LESS-THAN SIGN
1098*cdf0e10cSrcweir         m_aMirrorMap[ 0x003E ] = 0x003C; // GREATER-THAN SIGN
1099*cdf0e10cSrcweir         m_aMirrorMap[ 0x005B ] = 0x005D; // LEFT SQUARE BRACKET
1100*cdf0e10cSrcweir         m_aMirrorMap[ 0x005D ] = 0x005B; // RIGHT SQUARE BRACKET
1101*cdf0e10cSrcweir         m_aMirrorMap[ 0x007B ] = 0x007D; // LEFT CURLY BRACKET
1102*cdf0e10cSrcweir         m_aMirrorMap[ 0x007D ] = 0x007B; // RIGHT CURLY BRACKET
1103*cdf0e10cSrcweir         m_aMirrorMap[ 0x00AB ] = 0x00BB; // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
1104*cdf0e10cSrcweir         m_aMirrorMap[ 0x00BB ] = 0x00AB; // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
1105*cdf0e10cSrcweir         m_aMirrorMap[ 0x0F3A ] = 0x0F3B; // TIBETAN MARK GUG RTAGS GYON
1106*cdf0e10cSrcweir         m_aMirrorMap[ 0x0F3B ] = 0x0F3A; // TIBETAN MARK GUG RTAGS GYAS
1107*cdf0e10cSrcweir         m_aMirrorMap[ 0x0F3C ] = 0x0F3D; // TIBETAN MARK ANG KHANG GYON
1108*cdf0e10cSrcweir         m_aMirrorMap[ 0x0F3D ] = 0x0F3C; // TIBETAN MARK ANG KHANG GYAS
1109*cdf0e10cSrcweir         m_aMirrorMap[ 0x169B ] = 0x169C; // OGHAM FEATHER MARK
1110*cdf0e10cSrcweir         m_aMirrorMap[ 0x169C ] = 0x169B; // OGHAM REVERSED FEATHER MARK
1111*cdf0e10cSrcweir         m_aMirrorMap[ 0x2039 ] = 0x203A; // SINGLE LEFT-POINTING ANGLE QUOTATION MARK
1112*cdf0e10cSrcweir         m_aMirrorMap[ 0x203A ] = 0x2039; // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
1113*cdf0e10cSrcweir         m_aMirrorMap[ 0x2045 ] = 0x2046; // LEFT SQUARE BRACKET WITH QUILL
1114*cdf0e10cSrcweir         m_aMirrorMap[ 0x2046 ] = 0x2045; // RIGHT SQUARE BRACKET WITH QUILL
1115*cdf0e10cSrcweir         m_aMirrorMap[ 0x207D ] = 0x207E; // SUPERSCRIPT LEFT PARENTHESIS
1116*cdf0e10cSrcweir         m_aMirrorMap[ 0x207E ] = 0x207D; // SUPERSCRIPT RIGHT PARENTHESIS
1117*cdf0e10cSrcweir         m_aMirrorMap[ 0x208D ] = 0x208E; // SUBSCRIPT LEFT PARENTHESIS
1118*cdf0e10cSrcweir         m_aMirrorMap[ 0x208E ] = 0x208D; // SUBSCRIPT RIGHT PARENTHESIS
1119*cdf0e10cSrcweir         m_aMirrorMap[ 0x2208 ] = 0x220B; // ELEMENT OF
1120*cdf0e10cSrcweir         m_aMirrorMap[ 0x2209 ] = 0x220C; // NOT AN ELEMENT OF
1121*cdf0e10cSrcweir         m_aMirrorMap[ 0x220A ] = 0x220D; // SMALL ELEMENT OF
1122*cdf0e10cSrcweir         m_aMirrorMap[ 0x220B ] = 0x2208; // CONTAINS AS MEMBER
1123*cdf0e10cSrcweir         m_aMirrorMap[ 0x220C ] = 0x2209; // DOES NOT CONTAIN AS MEMBER
1124*cdf0e10cSrcweir         m_aMirrorMap[ 0x220D ] = 0x220A; // SMALL CONTAINS AS MEMBER
1125*cdf0e10cSrcweir         m_aMirrorMap[ 0x2215 ] = 0x29F5; // DIVISION SLASH
1126*cdf0e10cSrcweir         m_aMirrorMap[ 0x223C ] = 0x223D; // TILDE OPERATOR
1127*cdf0e10cSrcweir         m_aMirrorMap[ 0x223D ] = 0x223C; // REVERSED TILDE
1128*cdf0e10cSrcweir         m_aMirrorMap[ 0x2243 ] = 0x22CD; // ASYMPTOTICALLY EQUAL TO
1129*cdf0e10cSrcweir         m_aMirrorMap[ 0x2252 ] = 0x2253; // APPROXIMATELY EQUAL TO OR THE IMAGE OF
1130*cdf0e10cSrcweir         m_aMirrorMap[ 0x2253 ] = 0x2252; // IMAGE OF OR APPROXIMATELY EQUAL TO
1131*cdf0e10cSrcweir         m_aMirrorMap[ 0x2254 ] = 0x2255; // COLON EQUALS
1132*cdf0e10cSrcweir         m_aMirrorMap[ 0x2255 ] = 0x2254; // EQUALS COLON
1133*cdf0e10cSrcweir         m_aMirrorMap[ 0x2264 ] = 0x2265; // LESS-THAN OR EQUAL TO
1134*cdf0e10cSrcweir         m_aMirrorMap[ 0x2265 ] = 0x2264; // GREATER-THAN OR EQUAL TO
1135*cdf0e10cSrcweir         m_aMirrorMap[ 0x2266 ] = 0x2267; // LESS-THAN OVER EQUAL TO
1136*cdf0e10cSrcweir         m_aMirrorMap[ 0x2267 ] = 0x2266; // GREATER-THAN OVER EQUAL TO
1137*cdf0e10cSrcweir         m_aMirrorMap[ 0x2268 ] = 0x2269; // [BEST FIT] LESS-THAN BUT NOT EQUAL TO
1138*cdf0e10cSrcweir         m_aMirrorMap[ 0x2269 ] = 0x2268; // [BEST FIT] GREATER-THAN BUT NOT EQUAL TO
1139*cdf0e10cSrcweir         m_aMirrorMap[ 0x226A ] = 0x226B; // MUCH LESS-THAN
1140*cdf0e10cSrcweir         m_aMirrorMap[ 0x226B ] = 0x226A; // MUCH GREATER-THAN
1141*cdf0e10cSrcweir         m_aMirrorMap[ 0x226E ] = 0x226F; // [BEST FIT] NOT LESS-THAN
1142*cdf0e10cSrcweir         m_aMirrorMap[ 0x226F ] = 0x226E; // [BEST FIT] NOT GREATER-THAN
1143*cdf0e10cSrcweir         m_aMirrorMap[ 0x2270 ] = 0x2271; // [BEST FIT] NEITHER LESS-THAN NOR EQUAL TO
1144*cdf0e10cSrcweir         m_aMirrorMap[ 0x2271 ] = 0x2270; // [BEST FIT] NEITHER GREATER-THAN NOR EQUAL TO
1145*cdf0e10cSrcweir         m_aMirrorMap[ 0x2272 ] = 0x2273; // [BEST FIT] LESS-THAN OR EQUIVALENT TO
1146*cdf0e10cSrcweir         m_aMirrorMap[ 0x2273 ] = 0x2272; // [BEST FIT] GREATER-THAN OR EQUIVALENT TO
1147*cdf0e10cSrcweir         m_aMirrorMap[ 0x2274 ] = 0x2275; // [BEST FIT] NEITHER LESS-THAN NOR EQUIVALENT TO
1148*cdf0e10cSrcweir         m_aMirrorMap[ 0x2275 ] = 0x2274; // [BEST FIT] NEITHER GREATER-THAN NOR EQUIVALENT TO
1149*cdf0e10cSrcweir         m_aMirrorMap[ 0x2276 ] = 0x2277; // LESS-THAN OR GREATER-THAN
1150*cdf0e10cSrcweir         m_aMirrorMap[ 0x2277 ] = 0x2276; // GREATER-THAN OR LESS-THAN
1151*cdf0e10cSrcweir         m_aMirrorMap[ 0x2278 ] = 0x2279; // [BEST FIT] NEITHER LESS-THAN NOR GREATER-THAN
1152*cdf0e10cSrcweir         m_aMirrorMap[ 0x2279 ] = 0x2278; // [BEST FIT] NEITHER GREATER-THAN NOR LESS-THAN
1153*cdf0e10cSrcweir         m_aMirrorMap[ 0x227A ] = 0x227B; // PRECEDES
1154*cdf0e10cSrcweir         m_aMirrorMap[ 0x227B ] = 0x227A; // SUCCEEDS
1155*cdf0e10cSrcweir         m_aMirrorMap[ 0x227C ] = 0x227D; // PRECEDES OR EQUAL TO
1156*cdf0e10cSrcweir         m_aMirrorMap[ 0x227D ] = 0x227C; // SUCCEEDS OR EQUAL TO
1157*cdf0e10cSrcweir         m_aMirrorMap[ 0x227E ] = 0x227F; // [BEST FIT] PRECEDES OR EQUIVALENT TO
1158*cdf0e10cSrcweir         m_aMirrorMap[ 0x227F ] = 0x227E; // [BEST FIT] SUCCEEDS OR EQUIVALENT TO
1159*cdf0e10cSrcweir         m_aMirrorMap[ 0x2280 ] = 0x2281; // [BEST FIT] DOES NOT PRECEDE
1160*cdf0e10cSrcweir         m_aMirrorMap[ 0x2281 ] = 0x2280; // [BEST FIT] DOES NOT SUCCEED
1161*cdf0e10cSrcweir         m_aMirrorMap[ 0x2282 ] = 0x2283; // SUBSET OF
1162*cdf0e10cSrcweir         m_aMirrorMap[ 0x2283 ] = 0x2282; // SUPERSET OF
1163*cdf0e10cSrcweir         m_aMirrorMap[ 0x2284 ] = 0x2285; // [BEST FIT] NOT A SUBSET OF
1164*cdf0e10cSrcweir         m_aMirrorMap[ 0x2285 ] = 0x2284; // [BEST FIT] NOT A SUPERSET OF
1165*cdf0e10cSrcweir         m_aMirrorMap[ 0x2286 ] = 0x2287; // SUBSET OF OR EQUAL TO
1166*cdf0e10cSrcweir         m_aMirrorMap[ 0x2287 ] = 0x2286; // SUPERSET OF OR EQUAL TO
1167*cdf0e10cSrcweir         m_aMirrorMap[ 0x2288 ] = 0x2289; // [BEST FIT] NEITHER A SUBSET OF NOR EQUAL TO
1168*cdf0e10cSrcweir         m_aMirrorMap[ 0x2289 ] = 0x2288; // [BEST FIT] NEITHER A SUPERSET OF NOR EQUAL TO
1169*cdf0e10cSrcweir         m_aMirrorMap[ 0x228A ] = 0x228B; // [BEST FIT] SUBSET OF WITH NOT EQUAL TO
1170*cdf0e10cSrcweir         m_aMirrorMap[ 0x228B ] = 0x228A; // [BEST FIT] SUPERSET OF WITH NOT EQUAL TO
1171*cdf0e10cSrcweir         m_aMirrorMap[ 0x228F ] = 0x2290; // SQUARE IMAGE OF
1172*cdf0e10cSrcweir         m_aMirrorMap[ 0x2290 ] = 0x228F; // SQUARE ORIGINAL OF
1173*cdf0e10cSrcweir         m_aMirrorMap[ 0x2291 ] = 0x2292; // SQUARE IMAGE OF OR EQUAL TO
1174*cdf0e10cSrcweir         m_aMirrorMap[ 0x2292 ] = 0x2291; // SQUARE ORIGINAL OF OR EQUAL TO
1175*cdf0e10cSrcweir         m_aMirrorMap[ 0x2298 ] = 0x29B8; // CIRCLED DIVISION SLASH
1176*cdf0e10cSrcweir         m_aMirrorMap[ 0x22A2 ] = 0x22A3; // RIGHT TACK
1177*cdf0e10cSrcweir         m_aMirrorMap[ 0x22A3 ] = 0x22A2; // LEFT TACK
1178*cdf0e10cSrcweir         m_aMirrorMap[ 0x22A6 ] = 0x2ADE; // ASSERTION
1179*cdf0e10cSrcweir         m_aMirrorMap[ 0x22A8 ] = 0x2AE4; // TRUE
1180*cdf0e10cSrcweir         m_aMirrorMap[ 0x22A9 ] = 0x2AE3; // FORCES
1181*cdf0e10cSrcweir         m_aMirrorMap[ 0x22AB ] = 0x2AE5; // DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE
1182*cdf0e10cSrcweir         m_aMirrorMap[ 0x22B0 ] = 0x22B1; // PRECEDES UNDER RELATION
1183*cdf0e10cSrcweir         m_aMirrorMap[ 0x22B1 ] = 0x22B0; // SUCCEEDS UNDER RELATION
1184*cdf0e10cSrcweir         m_aMirrorMap[ 0x22B2 ] = 0x22B3; // NORMAL SUBGROUP OF
1185*cdf0e10cSrcweir         m_aMirrorMap[ 0x22B3 ] = 0x22B2; // CONTAINS AS NORMAL SUBGROUP
1186*cdf0e10cSrcweir         m_aMirrorMap[ 0x22B4 ] = 0x22B5; // NORMAL SUBGROUP OF OR EQUAL TO
1187*cdf0e10cSrcweir         m_aMirrorMap[ 0x22B5 ] = 0x22B4; // CONTAINS AS NORMAL SUBGROUP OR EQUAL TO
1188*cdf0e10cSrcweir         m_aMirrorMap[ 0x22B6 ] = 0x22B7; // ORIGINAL OF
1189*cdf0e10cSrcweir         m_aMirrorMap[ 0x22B7 ] = 0x22B6; // IMAGE OF
1190*cdf0e10cSrcweir         m_aMirrorMap[ 0x22C9 ] = 0x22CA; // LEFT NORMAL FACTOR SEMIDIRECT PRODUCT
1191*cdf0e10cSrcweir         m_aMirrorMap[ 0x22CA ] = 0x22C9; // RIGHT NORMAL FACTOR SEMIDIRECT PRODUCT
1192*cdf0e10cSrcweir         m_aMirrorMap[ 0x22CB ] = 0x22CC; // LEFT SEMIDIRECT PRODUCT
1193*cdf0e10cSrcweir         m_aMirrorMap[ 0x22CC ] = 0x22CB; // RIGHT SEMIDIRECT PRODUCT
1194*cdf0e10cSrcweir         m_aMirrorMap[ 0x22CD ] = 0x2243; // REVERSED TILDE EQUALS
1195*cdf0e10cSrcweir         m_aMirrorMap[ 0x22D0 ] = 0x22D1; // DOUBLE SUBSET
1196*cdf0e10cSrcweir         m_aMirrorMap[ 0x22D1 ] = 0x22D0; // DOUBLE SUPERSET
1197*cdf0e10cSrcweir         m_aMirrorMap[ 0x22D6 ] = 0x22D7; // LESS-THAN WITH DOT
1198*cdf0e10cSrcweir         m_aMirrorMap[ 0x22D7 ] = 0x22D6; // GREATER-THAN WITH DOT
1199*cdf0e10cSrcweir         m_aMirrorMap[ 0x22D8 ] = 0x22D9; // VERY MUCH LESS-THAN
1200*cdf0e10cSrcweir         m_aMirrorMap[ 0x22D9 ] = 0x22D8; // VERY MUCH GREATER-THAN
1201*cdf0e10cSrcweir         m_aMirrorMap[ 0x22DA ] = 0x22DB; // LESS-THAN EQUAL TO OR GREATER-THAN
1202*cdf0e10cSrcweir         m_aMirrorMap[ 0x22DB ] = 0x22DA; // GREATER-THAN EQUAL TO OR LESS-THAN
1203*cdf0e10cSrcweir         m_aMirrorMap[ 0x22DC ] = 0x22DD; // EQUAL TO OR LESS-THAN
1204*cdf0e10cSrcweir         m_aMirrorMap[ 0x22DD ] = 0x22DC; // EQUAL TO OR GREATER-THAN
1205*cdf0e10cSrcweir         m_aMirrorMap[ 0x22DE ] = 0x22DF; // EQUAL TO OR PRECEDES
1206*cdf0e10cSrcweir         m_aMirrorMap[ 0x22DF ] = 0x22DE; // EQUAL TO OR SUCCEEDS
1207*cdf0e10cSrcweir         m_aMirrorMap[ 0x22E0 ] = 0x22E1; // [BEST FIT] DOES NOT PRECEDE OR EQUAL
1208*cdf0e10cSrcweir         m_aMirrorMap[ 0x22E1 ] = 0x22E0; // [BEST FIT] DOES NOT SUCCEED OR EQUAL
1209*cdf0e10cSrcweir         m_aMirrorMap[ 0x22E2 ] = 0x22E3; // [BEST FIT] NOT SQUARE IMAGE OF OR EQUAL TO
1210*cdf0e10cSrcweir         m_aMirrorMap[ 0x22E3 ] = 0x22E2; // [BEST FIT] NOT SQUARE ORIGINAL OF OR EQUAL TO
1211*cdf0e10cSrcweir         m_aMirrorMap[ 0x22E4 ] = 0x22E5; // [BEST FIT] SQUARE IMAGE OF OR NOT EQUAL TO
1212*cdf0e10cSrcweir         m_aMirrorMap[ 0x22E5 ] = 0x22E4; // [BEST FIT] SQUARE ORIGINAL OF OR NOT EQUAL TO
1213*cdf0e10cSrcweir         m_aMirrorMap[ 0x22E6 ] = 0x22E7; // [BEST FIT] LESS-THAN BUT NOT EQUIVALENT TO
1214*cdf0e10cSrcweir         m_aMirrorMap[ 0x22E7 ] = 0x22E6; // [BEST FIT] GREATER-THAN BUT NOT EQUIVALENT TO
1215*cdf0e10cSrcweir         m_aMirrorMap[ 0x22E8 ] = 0x22E9; // [BEST FIT] PRECEDES BUT NOT EQUIVALENT TO
1216*cdf0e10cSrcweir         m_aMirrorMap[ 0x22E9 ] = 0x22E8; // [BEST FIT] SUCCEEDS BUT NOT EQUIVALENT TO
1217*cdf0e10cSrcweir         m_aMirrorMap[ 0x22EA ] = 0x22EB; // [BEST FIT] NOT NORMAL SUBGROUP OF
1218*cdf0e10cSrcweir         m_aMirrorMap[ 0x22EB ] = 0x22EA; // [BEST FIT] DOES NOT CONTAIN AS NORMAL SUBGROUP
1219*cdf0e10cSrcweir         m_aMirrorMap[ 0x22EC ] = 0x22ED; // [BEST FIT] NOT NORMAL SUBGROUP OF OR EQUAL TO
1220*cdf0e10cSrcweir         m_aMirrorMap[ 0x22ED ] = 0x22EC; // [BEST FIT] DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL
1221*cdf0e10cSrcweir         m_aMirrorMap[ 0x22F0 ] = 0x22F1; // UP RIGHT DIAGONAL ELLIPSIS
1222*cdf0e10cSrcweir         m_aMirrorMap[ 0x22F1 ] = 0x22F0; // DOWN RIGHT DIAGONAL ELLIPSIS
1223*cdf0e10cSrcweir         m_aMirrorMap[ 0x22F2 ] = 0x22FA; // ELEMENT OF WITH LONG HORIZONTAL STROKE
1224*cdf0e10cSrcweir         m_aMirrorMap[ 0x22F3 ] = 0x22FB; // ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE
1225*cdf0e10cSrcweir         m_aMirrorMap[ 0x22F4 ] = 0x22FC; // SMALL ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE
1226*cdf0e10cSrcweir         m_aMirrorMap[ 0x22F6 ] = 0x22FD; // ELEMENT OF WITH OVERBAR
1227*cdf0e10cSrcweir         m_aMirrorMap[ 0x22F7 ] = 0x22FE; // SMALL ELEMENT OF WITH OVERBAR
1228*cdf0e10cSrcweir         m_aMirrorMap[ 0x22FA ] = 0x22F2; // CONTAINS WITH LONG HORIZONTAL STROKE
1229*cdf0e10cSrcweir         m_aMirrorMap[ 0x22FB ] = 0x22F3; // CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE
1230*cdf0e10cSrcweir         m_aMirrorMap[ 0x22FC ] = 0x22F4; // SMALL CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE
1231*cdf0e10cSrcweir         m_aMirrorMap[ 0x22FD ] = 0x22F6; // CONTAINS WITH OVERBAR
1232*cdf0e10cSrcweir         m_aMirrorMap[ 0x22FE ] = 0x22F7; // SMALL CONTAINS WITH OVERBAR
1233*cdf0e10cSrcweir         m_aMirrorMap[ 0x2308 ] = 0x2309; // LEFT CEILING
1234*cdf0e10cSrcweir         m_aMirrorMap[ 0x2309 ] = 0x2308; // RIGHT CEILING
1235*cdf0e10cSrcweir         m_aMirrorMap[ 0x230A ] = 0x230B; // LEFT FLOOR
1236*cdf0e10cSrcweir         m_aMirrorMap[ 0x230B ] = 0x230A; // RIGHT FLOOR
1237*cdf0e10cSrcweir         m_aMirrorMap[ 0x2329 ] = 0x232A; // LEFT-POINTING ANGLE BRACKET
1238*cdf0e10cSrcweir         m_aMirrorMap[ 0x232A ] = 0x2329; // RIGHT-POINTING ANGLE BRACKET
1239*cdf0e10cSrcweir         m_aMirrorMap[ 0x2768 ] = 0x2769; // MEDIUM LEFT PARENTHESIS ORNAMENT
1240*cdf0e10cSrcweir         m_aMirrorMap[ 0x2769 ] = 0x2768; // MEDIUM RIGHT PARENTHESIS ORNAMENT
1241*cdf0e10cSrcweir         m_aMirrorMap[ 0x276A ] = 0x276B; // MEDIUM FLATTENED LEFT PARENTHESIS ORNAMENT
1242*cdf0e10cSrcweir         m_aMirrorMap[ 0x276B ] = 0x276A; // MEDIUM FLATTENED RIGHT PARENTHESIS ORNAMENT
1243*cdf0e10cSrcweir         m_aMirrorMap[ 0x276C ] = 0x276D; // MEDIUM LEFT-POINTING ANGLE BRACKET ORNAMENT
1244*cdf0e10cSrcweir         m_aMirrorMap[ 0x276D ] = 0x276C; // MEDIUM RIGHT-POINTING ANGLE BRACKET ORNAMENT
1245*cdf0e10cSrcweir         m_aMirrorMap[ 0x276E ] = 0x276F; // HEAVY LEFT-POINTING ANGLE QUOTATION MARK ORNAMENT
1246*cdf0e10cSrcweir         m_aMirrorMap[ 0x276F ] = 0x276E; // HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT
1247*cdf0e10cSrcweir         m_aMirrorMap[ 0x2770 ] = 0x2771; // HEAVY LEFT-POINTING ANGLE BRACKET ORNAMENT
1248*cdf0e10cSrcweir         m_aMirrorMap[ 0x2771 ] = 0x2770; // HEAVY RIGHT-POINTING ANGLE BRACKET ORNAMENT
1249*cdf0e10cSrcweir         m_aMirrorMap[ 0x2772 ] = 0x2773; // LIGHT LEFT TORTOISE SHELL BRACKET
1250*cdf0e10cSrcweir         m_aMirrorMap[ 0x2773 ] = 0x2772; // LIGHT RIGHT TORTOISE SHELL BRACKET
1251*cdf0e10cSrcweir         m_aMirrorMap[ 0x2774 ] = 0x2775; // MEDIUM LEFT CURLY BRACKET ORNAMENT
1252*cdf0e10cSrcweir         m_aMirrorMap[ 0x2775 ] = 0x2774; // MEDIUM RIGHT CURLY BRACKET ORNAMENT
1253*cdf0e10cSrcweir         m_aMirrorMap[ 0x27C3 ] = 0x27C4; // OPEN SUBSET
1254*cdf0e10cSrcweir         m_aMirrorMap[ 0x27C4 ] = 0x27C3; // OPEN SUPERSET
1255*cdf0e10cSrcweir         m_aMirrorMap[ 0x27C5 ] = 0x27C6; // LEFT S-SHAPED BAG DELIMITER
1256*cdf0e10cSrcweir         m_aMirrorMap[ 0x27C6 ] = 0x27C5; // RIGHT S-SHAPED BAG DELIMITER
1257*cdf0e10cSrcweir         m_aMirrorMap[ 0x27C8 ] = 0x27C9; // REVERSE SOLIDUS PRECEDING SUBSET
1258*cdf0e10cSrcweir         m_aMirrorMap[ 0x27C9 ] = 0x27C8; // SUPERSET PRECEDING SOLIDUS
1259*cdf0e10cSrcweir         m_aMirrorMap[ 0x27D5 ] = 0x27D6; // LEFT OUTER JOIN
1260*cdf0e10cSrcweir         m_aMirrorMap[ 0x27D6 ] = 0x27D5; // RIGHT OUTER JOIN
1261*cdf0e10cSrcweir         m_aMirrorMap[ 0x27DD ] = 0x27DE; // LONG RIGHT TACK
1262*cdf0e10cSrcweir         m_aMirrorMap[ 0x27DE ] = 0x27DD; // LONG LEFT TACK
1263*cdf0e10cSrcweir         m_aMirrorMap[ 0x27E2 ] = 0x27E3; // WHITE CONCAVE-SIDED DIAMOND WITH LEFTWARDS TICK
1264*cdf0e10cSrcweir         m_aMirrorMap[ 0x27E3 ] = 0x27E2; // WHITE CONCAVE-SIDED DIAMOND WITH RIGHTWARDS TICK
1265*cdf0e10cSrcweir         m_aMirrorMap[ 0x27E4 ] = 0x27E5; // WHITE SQUARE WITH LEFTWARDS TICK
1266*cdf0e10cSrcweir         m_aMirrorMap[ 0x27E5 ] = 0x27E4; // WHITE SQUARE WITH RIGHTWARDS TICK
1267*cdf0e10cSrcweir         m_aMirrorMap[ 0x27E6 ] = 0x27E7; // MATHEMATICAL LEFT WHITE SQUARE BRACKET
1268*cdf0e10cSrcweir         m_aMirrorMap[ 0x27E7 ] = 0x27E6; // MATHEMATICAL RIGHT WHITE SQUARE BRACKET
1269*cdf0e10cSrcweir         m_aMirrorMap[ 0x27E8 ] = 0x27E9; // MATHEMATICAL LEFT ANGLE BRACKET
1270*cdf0e10cSrcweir         m_aMirrorMap[ 0x27E9 ] = 0x27E8; // MATHEMATICAL RIGHT ANGLE BRACKET
1271*cdf0e10cSrcweir         m_aMirrorMap[ 0x27EA ] = 0x27EB; // MATHEMATICAL LEFT DOUBLE ANGLE BRACKET
1272*cdf0e10cSrcweir         m_aMirrorMap[ 0x27EB ] = 0x27EA; // MATHEMATICAL RIGHT DOUBLE ANGLE BRACKET
1273*cdf0e10cSrcweir         m_aMirrorMap[ 0x27EC ] = 0x27ED; // MATHEMATICAL LEFT WHITE TORTOISE SHELL BRACKET
1274*cdf0e10cSrcweir         m_aMirrorMap[ 0x27ED ] = 0x27EC; // MATHEMATICAL RIGHT WHITE TORTOISE SHELL BRACKET
1275*cdf0e10cSrcweir         m_aMirrorMap[ 0x27EE ] = 0x27EF; // MATHEMATICAL LEFT FLATTENED PARENTHESIS
1276*cdf0e10cSrcweir         m_aMirrorMap[ 0x27EF ] = 0x27EE; // MATHEMATICAL RIGHT FLATTENED PARENTHESIS
1277*cdf0e10cSrcweir         m_aMirrorMap[ 0x2983 ] = 0x2984; // LEFT WHITE CURLY BRACKET
1278*cdf0e10cSrcweir         m_aMirrorMap[ 0x2984 ] = 0x2983; // RIGHT WHITE CURLY BRACKET
1279*cdf0e10cSrcweir         m_aMirrorMap[ 0x2985 ] = 0x2986; // LEFT WHITE PARENTHESIS
1280*cdf0e10cSrcweir         m_aMirrorMap[ 0x2986 ] = 0x2985; // RIGHT WHITE PARENTHESIS
1281*cdf0e10cSrcweir         m_aMirrorMap[ 0x2987 ] = 0x2988; // Z NOTATION LEFT IMAGE BRACKET
1282*cdf0e10cSrcweir         m_aMirrorMap[ 0x2988 ] = 0x2987; // Z NOTATION RIGHT IMAGE BRACKET
1283*cdf0e10cSrcweir         m_aMirrorMap[ 0x2989 ] = 0x298A; // Z NOTATION LEFT BINDING BRACKET
1284*cdf0e10cSrcweir         m_aMirrorMap[ 0x298A ] = 0x2989; // Z NOTATION RIGHT BINDING BRACKET
1285*cdf0e10cSrcweir         m_aMirrorMap[ 0x298B ] = 0x298C; // LEFT SQUARE BRACKET WITH UNDERBAR
1286*cdf0e10cSrcweir         m_aMirrorMap[ 0x298C ] = 0x298B; // RIGHT SQUARE BRACKET WITH UNDERBAR
1287*cdf0e10cSrcweir         m_aMirrorMap[ 0x298D ] = 0x2990; // LEFT SQUARE BRACKET WITH TICK IN TOP CORNER
1288*cdf0e10cSrcweir         m_aMirrorMap[ 0x298E ] = 0x298F; // RIGHT SQUARE BRACKET WITH TICK IN BOTTOM CORNER
1289*cdf0e10cSrcweir         m_aMirrorMap[ 0x298F ] = 0x298E; // LEFT SQUARE BRACKET WITH TICK IN BOTTOM CORNER
1290*cdf0e10cSrcweir         m_aMirrorMap[ 0x2990 ] = 0x298D; // RIGHT SQUARE BRACKET WITH TICK IN TOP CORNER
1291*cdf0e10cSrcweir         m_aMirrorMap[ 0x2991 ] = 0x2992; // LEFT ANGLE BRACKET WITH DOT
1292*cdf0e10cSrcweir         m_aMirrorMap[ 0x2992 ] = 0x2991; // RIGHT ANGLE BRACKET WITH DOT
1293*cdf0e10cSrcweir         m_aMirrorMap[ 0x2993 ] = 0x2994; // LEFT ARC LESS-THAN BRACKET
1294*cdf0e10cSrcweir         m_aMirrorMap[ 0x2994 ] = 0x2993; // RIGHT ARC GREATER-THAN BRACKET
1295*cdf0e10cSrcweir         m_aMirrorMap[ 0x2995 ] = 0x2996; // DOUBLE LEFT ARC GREATER-THAN BRACKET
1296*cdf0e10cSrcweir         m_aMirrorMap[ 0x2996 ] = 0x2995; // DOUBLE RIGHT ARC LESS-THAN BRACKET
1297*cdf0e10cSrcweir         m_aMirrorMap[ 0x2997 ] = 0x2998; // LEFT BLACK TORTOISE SHELL BRACKET
1298*cdf0e10cSrcweir         m_aMirrorMap[ 0x2998 ] = 0x2997; // RIGHT BLACK TORTOISE SHELL BRACKET
1299*cdf0e10cSrcweir         m_aMirrorMap[ 0x29B8 ] = 0x2298; // CIRCLED REVERSE SOLIDUS
1300*cdf0e10cSrcweir         m_aMirrorMap[ 0x29C0 ] = 0x29C1; // CIRCLED LESS-THAN
1301*cdf0e10cSrcweir         m_aMirrorMap[ 0x29C1 ] = 0x29C0; // CIRCLED GREATER-THAN
1302*cdf0e10cSrcweir         m_aMirrorMap[ 0x29C4 ] = 0x29C5; // SQUARED RISING DIAGONAL SLASH
1303*cdf0e10cSrcweir         m_aMirrorMap[ 0x29C5 ] = 0x29C4; // SQUARED FALLING DIAGONAL SLASH
1304*cdf0e10cSrcweir         m_aMirrorMap[ 0x29CF ] = 0x29D0; // LEFT TRIANGLE BESIDE VERTICAL BAR
1305*cdf0e10cSrcweir         m_aMirrorMap[ 0x29D0 ] = 0x29CF; // VERTICAL BAR BESIDE RIGHT TRIANGLE
1306*cdf0e10cSrcweir         m_aMirrorMap[ 0x29D1 ] = 0x29D2; // BOWTIE WITH LEFT HALF BLACK
1307*cdf0e10cSrcweir         m_aMirrorMap[ 0x29D2 ] = 0x29D1; // BOWTIE WITH RIGHT HALF BLACK
1308*cdf0e10cSrcweir         m_aMirrorMap[ 0x29D4 ] = 0x29D5; // TIMES WITH LEFT HALF BLACK
1309*cdf0e10cSrcweir         m_aMirrorMap[ 0x29D5 ] = 0x29D4; // TIMES WITH RIGHT HALF BLACK
1310*cdf0e10cSrcweir         m_aMirrorMap[ 0x29D8 ] = 0x29D9; // LEFT WIGGLY FENCE
1311*cdf0e10cSrcweir         m_aMirrorMap[ 0x29D9 ] = 0x29D8; // RIGHT WIGGLY FENCE
1312*cdf0e10cSrcweir         m_aMirrorMap[ 0x29DA ] = 0x29DB; // LEFT DOUBLE WIGGLY FENCE
1313*cdf0e10cSrcweir         m_aMirrorMap[ 0x29DB ] = 0x29DA; // RIGHT DOUBLE WIGGLY FENCE
1314*cdf0e10cSrcweir         m_aMirrorMap[ 0x29F5 ] = 0x2215; // REVERSE SOLIDUS OPERATOR
1315*cdf0e10cSrcweir         m_aMirrorMap[ 0x29F8 ] = 0x29F9; // BIG SOLIDUS
1316*cdf0e10cSrcweir         m_aMirrorMap[ 0x29F9 ] = 0x29F8; // BIG REVERSE SOLIDUS
1317*cdf0e10cSrcweir         m_aMirrorMap[ 0x29FC ] = 0x29FD; // LEFT-POINTING CURVED ANGLE BRACKET
1318*cdf0e10cSrcweir         m_aMirrorMap[ 0x29FD ] = 0x29FC; // RIGHT-POINTING CURVED ANGLE BRACKET
1319*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A2B ] = 0x2A2C; // MINUS SIGN WITH FALLING DOTS
1320*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A2C ] = 0x2A2B; // MINUS SIGN WITH RISING DOTS
1321*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A2D ] = 0x2A2E; // PLUS SIGN IN LEFT HALF CIRCLE
1322*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A2E ] = 0x2A2D; // PLUS SIGN IN RIGHT HALF CIRCLE
1323*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A34 ] = 0x2A35; // MULTIPLICATION SIGN IN LEFT HALF CIRCLE
1324*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A35 ] = 0x2A34; // MULTIPLICATION SIGN IN RIGHT HALF CIRCLE
1325*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A3C ] = 0x2A3D; // INTERIOR PRODUCT
1326*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A3D ] = 0x2A3C; // RIGHTHAND INTERIOR PRODUCT
1327*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A64 ] = 0x2A65; // Z NOTATION DOMAIN ANTIRESTRICTION
1328*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A65 ] = 0x2A64; // Z NOTATION RANGE ANTIRESTRICTION
1329*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A79 ] = 0x2A7A; // LESS-THAN WITH CIRCLE INSIDE
1330*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A7A ] = 0x2A79; // GREATER-THAN WITH CIRCLE INSIDE
1331*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A7D ] = 0x2A7E; // LESS-THAN OR SLANTED EQUAL TO
1332*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A7E ] = 0x2A7D; // GREATER-THAN OR SLANTED EQUAL TO
1333*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A7F ] = 0x2A80; // LESS-THAN OR SLANTED EQUAL TO WITH DOT INSIDE
1334*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A80 ] = 0x2A7F; // GREATER-THAN OR SLANTED EQUAL TO WITH DOT INSIDE
1335*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A81 ] = 0x2A82; // LESS-THAN OR SLANTED EQUAL TO WITH DOT ABOVE
1336*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A82 ] = 0x2A81; // GREATER-THAN OR SLANTED EQUAL TO WITH DOT ABOVE
1337*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A83 ] = 0x2A84; // LESS-THAN OR SLANTED EQUAL TO WITH DOT ABOVE RIGHT
1338*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A84 ] = 0x2A83; // GREATER-THAN OR SLANTED EQUAL TO WITH DOT ABOVE LEFT
1339*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A8B ] = 0x2A8C; // LESS-THAN ABOVE DOUBLE-LINE EQUAL ABOVE GREATER-THAN
1340*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A8C ] = 0x2A8B; // GREATER-THAN ABOVE DOUBLE-LINE EQUAL ABOVE LESS-THAN
1341*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A91 ] = 0x2A92; // LESS-THAN ABOVE GREATER-THAN ABOVE DOUBLE-LINE EQUAL
1342*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A92 ] = 0x2A91; // GREATER-THAN ABOVE LESS-THAN ABOVE DOUBLE-LINE EQUAL
1343*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A93 ] = 0x2A94; // LESS-THAN ABOVE SLANTED EQUAL ABOVE GREATER-THAN ABOVE SLANTED EQUAL
1344*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A94 ] = 0x2A93; // GREATER-THAN ABOVE SLANTED EQUAL ABOVE LESS-THAN ABOVE SLANTED EQUAL
1345*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A95 ] = 0x2A96; // SLANTED EQUAL TO OR LESS-THAN
1346*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A96 ] = 0x2A95; // SLANTED EQUAL TO OR GREATER-THAN
1347*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A97 ] = 0x2A98; // SLANTED EQUAL TO OR LESS-THAN WITH DOT INSIDE
1348*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A98 ] = 0x2A97; // SLANTED EQUAL TO OR GREATER-THAN WITH DOT INSIDE
1349*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A99 ] = 0x2A9A; // DOUBLE-LINE EQUAL TO OR LESS-THAN
1350*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A9A ] = 0x2A99; // DOUBLE-LINE EQUAL TO OR GREATER-THAN
1351*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A9B ] = 0x2A9C; // DOUBLE-LINE SLANTED EQUAL TO OR LESS-THAN
1352*cdf0e10cSrcweir         m_aMirrorMap[ 0x2A9C ] = 0x2A9B; // DOUBLE-LINE SLANTED EQUAL TO OR GREATER-THAN
1353*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AA1 ] = 0x2AA2; // DOUBLE NESTED LESS-THAN
1354*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AA2 ] = 0x2AA1; // DOUBLE NESTED GREATER-THAN
1355*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AA6 ] = 0x2AA7; // LESS-THAN CLOSED BY CURVE
1356*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AA7 ] = 0x2AA6; // GREATER-THAN CLOSED BY CURVE
1357*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AA8 ] = 0x2AA9; // LESS-THAN CLOSED BY CURVE ABOVE SLANTED EQUAL
1358*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AA9 ] = 0x2AA8; // GREATER-THAN CLOSED BY CURVE ABOVE SLANTED EQUAL
1359*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AAA ] = 0x2AAB; // SMALLER THAN
1360*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AAB ] = 0x2AAA; // LARGER THAN
1361*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AAC ] = 0x2AAD; // SMALLER THAN OR EQUAL TO
1362*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AAD ] = 0x2AAC; // LARGER THAN OR EQUAL TO
1363*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AAF ] = 0x2AB0; // PRECEDES ABOVE SINGLE-LINE EQUALS SIGN
1364*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AB0 ] = 0x2AAF; // SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN
1365*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AB3 ] = 0x2AB4; // PRECEDES ABOVE EQUALS SIGN
1366*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AB4 ] = 0x2AB3; // SUCCEEDS ABOVE EQUALS SIGN
1367*cdf0e10cSrcweir         m_aMirrorMap[ 0x2ABB ] = 0x2ABC; // DOUBLE PRECEDES
1368*cdf0e10cSrcweir         m_aMirrorMap[ 0x2ABC ] = 0x2ABB; // DOUBLE SUCCEEDS
1369*cdf0e10cSrcweir         m_aMirrorMap[ 0x2ABD ] = 0x2ABE; // SUBSET WITH DOT
1370*cdf0e10cSrcweir         m_aMirrorMap[ 0x2ABE ] = 0x2ABD; // SUPERSET WITH DOT
1371*cdf0e10cSrcweir         m_aMirrorMap[ 0x2ABF ] = 0x2AC0; // SUBSET WITH PLUS SIGN BELOW
1372*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AC0 ] = 0x2ABF; // SUPERSET WITH PLUS SIGN BELOW
1373*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AC1 ] = 0x2AC2; // SUBSET WITH MULTIPLICATION SIGN BELOW
1374*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AC2 ] = 0x2AC1; // SUPERSET WITH MULTIPLICATION SIGN BELOW
1375*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AC3 ] = 0x2AC4; // SUBSET OF OR EQUAL TO WITH DOT ABOVE
1376*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AC4 ] = 0x2AC3; // SUPERSET OF OR EQUAL TO WITH DOT ABOVE
1377*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AC5 ] = 0x2AC6; // SUBSET OF ABOVE EQUALS SIGN
1378*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AC6 ] = 0x2AC5; // SUPERSET OF ABOVE EQUALS SIGN
1379*cdf0e10cSrcweir         m_aMirrorMap[ 0x2ACD ] = 0x2ACE; // SQUARE LEFT OPEN BOX OPERATOR
1380*cdf0e10cSrcweir         m_aMirrorMap[ 0x2ACE ] = 0x2ACD; // SQUARE RIGHT OPEN BOX OPERATOR
1381*cdf0e10cSrcweir         m_aMirrorMap[ 0x2ACF ] = 0x2AD0; // CLOSED SUBSET
1382*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AD0 ] = 0x2ACF; // CLOSED SUPERSET
1383*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AD1 ] = 0x2AD2; // CLOSED SUBSET OR EQUAL TO
1384*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AD2 ] = 0x2AD1; // CLOSED SUPERSET OR EQUAL TO
1385*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AD3 ] = 0x2AD4; // SUBSET ABOVE SUPERSET
1386*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AD4 ] = 0x2AD3; // SUPERSET ABOVE SUBSET
1387*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AD5 ] = 0x2AD6; // SUBSET ABOVE SUBSET
1388*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AD6 ] = 0x2AD5; // SUPERSET ABOVE SUPERSET
1389*cdf0e10cSrcweir         m_aMirrorMap[ 0x2ADE ] = 0x22A6; // SHORT LEFT TACK
1390*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AE3 ] = 0x22A9; // DOUBLE VERTICAL BAR LEFT TURNSTILE
1391*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AE4 ] = 0x22A8; // VERTICAL BAR DOUBLE LEFT TURNSTILE
1392*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AE5 ] = 0x22AB; // DOUBLE VERTICAL BAR DOUBLE LEFT TURNSTILE
1393*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AEC ] = 0x2AED; // DOUBLE STROKE NOT SIGN
1394*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AED ] = 0x2AEC; // REVERSED DOUBLE STROKE NOT SIGN
1395*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AF7 ] = 0x2AF8; // TRIPLE NESTED LESS-THAN
1396*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AF8 ] = 0x2AF7; // TRIPLE NESTED GREATER-THAN
1397*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AF9 ] = 0x2AFA; // DOUBLE-LINE SLANTED LESS-THAN OR EQUAL TO
1398*cdf0e10cSrcweir         m_aMirrorMap[ 0x2AFA ] = 0x2AF9; // DOUBLE-LINE SLANTED GREATER-THAN OR EQUAL TO
1399*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E02 ] = 0x2E03; // LEFT SUBSTITUTION BRACKET
1400*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E03 ] = 0x2E02; // RIGHT SUBSTITUTION BRACKET
1401*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E04 ] = 0x2E05; // LEFT DOTTED SUBSTITUTION BRACKET
1402*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E05 ] = 0x2E04; // RIGHT DOTTED SUBSTITUTION BRACKET
1403*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E09 ] = 0x2E0A; // LEFT TRANSPOSITION BRACKET
1404*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E0A ] = 0x2E09; // RIGHT TRANSPOSITION BRACKET
1405*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E0C ] = 0x2E0D; // LEFT RAISED OMISSION BRACKET
1406*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E0D ] = 0x2E0C; // RIGHT RAISED OMISSION BRACKET
1407*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E1C ] = 0x2E1D; // LEFT LOW PARAPHRASE BRACKET
1408*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E1D ] = 0x2E1C; // RIGHT LOW PARAPHRASE BRACKET
1409*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E20 ] = 0x2E21; // LEFT VERTICAL BAR WITH QUILL
1410*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E21 ] = 0x2E20; // RIGHT VERTICAL BAR WITH QUILL
1411*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E22 ] = 0x2E23; // TOP LEFT HALF BRACKET
1412*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E23 ] = 0x2E22; // TOP RIGHT HALF BRACKET
1413*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E24 ] = 0x2E25; // BOTTOM LEFT HALF BRACKET
1414*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E25 ] = 0x2E24; // BOTTOM RIGHT HALF BRACKET
1415*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E26 ] = 0x2E27; // LEFT SIDEWAYS U BRACKET
1416*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E27 ] = 0x2E26; // RIGHT SIDEWAYS U BRACKET
1417*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E28 ] = 0x2E29; // LEFT DOUBLE PARENTHESIS
1418*cdf0e10cSrcweir         m_aMirrorMap[ 0x2E29 ] = 0x2E28; // RIGHT DOUBLE PARENTHESIS
1419*cdf0e10cSrcweir         m_aMirrorMap[ 0x3008 ] = 0x3009; // LEFT ANGLE BRACKET
1420*cdf0e10cSrcweir         m_aMirrorMap[ 0x3009 ] = 0x3008; // RIGHT ANGLE BRACKET
1421*cdf0e10cSrcweir         m_aMirrorMap[ 0x300A ] = 0x300B; // LEFT DOUBLE ANGLE BRACKET
1422*cdf0e10cSrcweir         m_aMirrorMap[ 0x300B ] = 0x300A; // RIGHT DOUBLE ANGLE BRACKET
1423*cdf0e10cSrcweir         m_aMirrorMap[ 0x300C ] = 0x300D; // [BEST FIT] LEFT CORNER BRACKET
1424*cdf0e10cSrcweir         m_aMirrorMap[ 0x300D ] = 0x300C; // [BEST FIT] RIGHT CORNER BRACKET
1425*cdf0e10cSrcweir         m_aMirrorMap[ 0x300E ] = 0x300F; // [BEST FIT] LEFT WHITE CORNER BRACKET
1426*cdf0e10cSrcweir         m_aMirrorMap[ 0x300F ] = 0x300E; // [BEST FIT] RIGHT WHITE CORNER BRACKET
1427*cdf0e10cSrcweir         m_aMirrorMap[ 0x3010 ] = 0x3011; // LEFT BLACK LENTICULAR BRACKET
1428*cdf0e10cSrcweir         m_aMirrorMap[ 0x3011 ] = 0x3010; // RIGHT BLACK LENTICULAR BRACKET
1429*cdf0e10cSrcweir         m_aMirrorMap[ 0x3014 ] = 0x3015; // LEFT TORTOISE SHELL BRACKET
1430*cdf0e10cSrcweir         m_aMirrorMap[ 0x3015 ] = 0x3014; // RIGHT TORTOISE SHELL BRACKET
1431*cdf0e10cSrcweir         m_aMirrorMap[ 0x3016 ] = 0x3017; // LEFT WHITE LENTICULAR BRACKET
1432*cdf0e10cSrcweir         m_aMirrorMap[ 0x3017 ] = 0x3016; // RIGHT WHITE LENTICULAR BRACKET
1433*cdf0e10cSrcweir         m_aMirrorMap[ 0x3018 ] = 0x3019; // LEFT WHITE TORTOISE SHELL BRACKET
1434*cdf0e10cSrcweir         m_aMirrorMap[ 0x3019 ] = 0x3018; // RIGHT WHITE TORTOISE SHELL BRACKET
1435*cdf0e10cSrcweir         m_aMirrorMap[ 0x301A ] = 0x301B; // LEFT WHITE SQUARE BRACKET
1436*cdf0e10cSrcweir         m_aMirrorMap[ 0x301B ] = 0x301A; // RIGHT WHITE SQUARE BRACKET
1437*cdf0e10cSrcweir         m_aMirrorMap[ 0xFE59 ] = 0xFE5A; // SMALL LEFT PARENTHESIS
1438*cdf0e10cSrcweir         m_aMirrorMap[ 0xFE5A ] = 0xFE59; // SMALL RIGHT PARENTHESIS
1439*cdf0e10cSrcweir         m_aMirrorMap[ 0xFE5B ] = 0xFE5C; // SMALL LEFT CURLY BRACKET
1440*cdf0e10cSrcweir         m_aMirrorMap[ 0xFE5C ] = 0xFE5B; // SMALL RIGHT CURLY BRACKET
1441*cdf0e10cSrcweir         m_aMirrorMap[ 0xFE5D ] = 0xFE5E; // SMALL LEFT TORTOISE SHELL BRACKET
1442*cdf0e10cSrcweir         m_aMirrorMap[ 0xFE5E ] = 0xFE5D; // SMALL RIGHT TORTOISE SHELL BRACKET
1443*cdf0e10cSrcweir         m_aMirrorMap[ 0xFE64 ] = 0xFE65; // SMALL LESS-THAN SIGN
1444*cdf0e10cSrcweir         m_aMirrorMap[ 0xFE65 ] = 0xFE64; // SMALL GREATER-THAN SIGN
1445*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF08 ] = 0xFF09; // FULLWIDTH LEFT PARENTHESIS
1446*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF09 ] = 0xFF08; // FULLWIDTH RIGHT PARENTHESIS
1447*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF1C ] = 0xFF1E; // FULLWIDTH LESS-THAN SIGN
1448*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF1E ] = 0xFF1C; // FULLWIDTH GREATER-THAN SIGN
1449*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF3B ] = 0xFF3D; // FULLWIDTH LEFT SQUARE BRACKET
1450*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF3D ] = 0xFF3B; // FULLWIDTH RIGHT SQUARE BRACKET
1451*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF5B ] = 0xFF5D; // FULLWIDTH LEFT CURLY BRACKET
1452*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF5D ] = 0xFF5B; // FULLWIDTH RIGHT CURLY BRACKET
1453*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF5F ] = 0xFF60; // FULLWIDTH LEFT WHITE PARENTHESIS
1454*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF60 ] = 0xFF5F; // FULLWIDTH RIGHT WHITE PARENTHESIS
1455*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF62 ] = 0xFF63; // [BEST FIT] HALFWIDTH LEFT CORNER BRACKET
1456*cdf0e10cSrcweir         m_aMirrorMap[ 0xFF63 ] = 0xFF62; // [BEST FIT] HALFWIDTH RIGHT CORNER BRACKET
1457*cdf0e10cSrcweir     }
1458*cdf0e10cSrcweir }
1459*cdf0e10cSrcweir 
1460*cdf0e10cSrcweir }
1461