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