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