LCOV - code coverage report
Current view: top level - filter/source/msfilter - util.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 207 364 56.9 %
Date: 2015-06-13 12:38:46 Functions: 18 22 81.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <rtl/ustring.hxx>
      11             : #include <rtl/strbuf.hxx>
      12             : #include <unotools/fontcvt.hxx>
      13             : #include <unotools/fontdefs.hxx>
      14             : #include <vcl/svapp.hxx>
      15             : #include <vcl/salbtype.hxx>
      16             : #include <filter/msfilter/util.hxx>
      17             : #include <boost/scoped_ptr.hpp>
      18             : #include <unordered_map>
      19             : 
      20             : namespace msfilter {
      21             : namespace util {
      22             : 
      23        1952 : rtl_TextEncoding getBestTextEncodingFromLocale(const ::com::sun::star::lang::Locale &rLocale)
      24             : {
      25             :     // Obviously not comprehensive, feel free to expand these, they're for ultimate fallbacks
      26             :     // in last-ditch broken-file-format cases to guess the right 8bit encodings
      27        1952 :     const OUString &rLanguage = rLocale.Language;
      28        1952 :     if (rLanguage == "cs" || rLanguage == "hu" || rLanguage == "pl")
      29          11 :         return RTL_TEXTENCODING_MS_1250;
      30        1941 :     if (rLanguage == "ru" || rLanguage == "uk")
      31           3 :         return RTL_TEXTENCODING_MS_1251;
      32        1938 :     if (rLanguage == "el")
      33           0 :         return RTL_TEXTENCODING_MS_1253;
      34        1938 :     if (rLanguage == "tr")
      35           0 :         return RTL_TEXTENCODING_MS_1254;
      36        1938 :     if (rLanguage == "lt")
      37           1 :         return RTL_TEXTENCODING_MS_1257;
      38        1937 :     if (rLanguage == "th")
      39           0 :         return RTL_TEXTENCODING_MS_874;
      40        1937 :     if (rLanguage == "vi")
      41           0 :         return RTL_TEXTENCODING_MS_1258;
      42        1937 :     return RTL_TEXTENCODING_MS_1252;
      43             : }
      44             : 
      45       10520 : sal_uInt32 BGRToRGB(sal_uInt32 nColor)
      46             : {
      47             :     sal_uInt8
      48       10520 :         r(static_cast<sal_uInt8>(nColor&0xFF)),
      49       10520 :         g(static_cast<sal_uInt8>(((nColor)>>8)&0xFF)),
      50       10520 :         b(static_cast<sal_uInt8>((nColor>>16)&0xFF)),
      51       10520 :         t(static_cast<sal_uInt8>((nColor>>24)&0xFF));
      52       10520 :     nColor = (t<<24) + (r<<16) + (g<<8) + b;
      53       10520 :     return nColor;
      54             : }
      55             : 
      56         162 : DateTime DTTM2DateTime( long lDTTM )
      57             : {
      58             :     /*
      59             :     mint    short   :6  0000003F    minutes (0-59)
      60             :     hr      short   :5  000007C0    hours (0-23)
      61             :     dom     short   :5  0000F800    days of month (1-31)
      62             :     mon     short   :4  000F0000    months (1-12)
      63             :     yr      short   :9  1FF00000    years (1900-2411)-1900
      64             :     wdy     short   :3  E0000000    weekday(Sunday=0
      65             :                                             Monday=1
      66             :     ( wdy can be ignored )                  Tuesday=2
      67             :                                             Wednesday=3
      68             :                                             Thursday=4
      69             :                                             Friday=5
      70             :                                             Saturday=6)
      71             :     */
      72         162 :     DateTime aDateTime(Date( 0 ), ::tools::Time( 0 ));
      73         162 :     if( lDTTM )
      74             :     {
      75          48 :         sal_uInt16 lMin = (sal_uInt16)(lDTTM & 0x0000003F);
      76          48 :         lDTTM >>= 6;
      77          48 :         sal_uInt16 lHour= (sal_uInt16)(lDTTM & 0x0000001F);
      78          48 :         lDTTM >>= 5;
      79          48 :         sal_uInt16 lDay = (sal_uInt16)(lDTTM & 0x0000001F);
      80          48 :         lDTTM >>= 5;
      81          48 :         sal_uInt16 lMon = (sal_uInt16)(lDTTM & 0x0000000F);
      82          48 :         lDTTM >>= 4;
      83          48 :         sal_uInt16 lYear= (sal_uInt16)(lDTTM & 0x000001FF) + 1900;
      84          48 :         aDateTime = DateTime(Date(lDay, lMon, lYear), tools::Time(lHour, lMin));
      85             :     }
      86         162 :     return aDateTime;
      87             : }
      88             : 
      89         236 : sal_Unicode bestFitOpenSymbolToMSFont(sal_Unicode cChar,
      90             :     rtl_TextEncoding& rChrSet, OUString& rFontName, bool bDisableUnicodeSupport)
      91             : {
      92         236 :     boost::scoped_ptr<StarSymbolToMSMultiFont> pConvert(CreateStarSymbolToMSMultiFont());
      93         472 :     OUString sFont = pConvert->ConvertChar(cChar);
      94         236 :     pConvert.reset();
      95         236 :     if (!sFont.isEmpty())
      96             :     {
      97         215 :         cChar = static_cast< sal_Unicode >(cChar | 0xF000);
      98         215 :         rFontName = sFont;
      99         215 :         rChrSet = RTL_TEXTENCODING_SYMBOL;
     100             :     }
     101          21 :     else if (!bDisableUnicodeSupport && (cChar < 0xE000 || cChar > 0xF8FF))
     102             :     {
     103             :         /*
     104             :           Ok we can't fit into a known windows unicode font, but
     105             :           we are not in the private area, so we are a
     106             :           standardized symbol, so turn off the symbol bit and
     107             :           let words own font substitution kick in
     108             :         */
     109          21 :         rChrSet = RTL_TEXTENCODING_UNICODE;
     110          21 :         sal_Int32 nIndex = 0;
     111          21 :         rFontName = ::GetNextFontToken(rFontName, nIndex);
     112             :     }
     113             :     else
     114             :     {
     115             :         /*
     116             :           Well we don't have an available substition, and we're
     117             :           in our private area, so give up and show a standard
     118             :           bullet symbol
     119             :         */
     120           0 :         rFontName = "Wingdings";
     121           0 :         cChar = static_cast< sal_Unicode >(0x6C);
     122             :     }
     123         472 :     return cChar;
     124             : }
     125             : 
     126             : /*
     127             :   http://social.msdn.microsoft.com/Forums/hu-HU/os_openXML-ecma/thread/1bf1f185-ee49-4314-94e7-f4e1563b5c00
     128             : 
     129             :   The following information is being submitted to the standards working group as
     130             :   a proposed resolution to a defect report and is not yet part of ISO 29500-1.
     131             :   ...
     132             :   For each Unicode character in DrawingML text, the font face can be any of four
     133             :   font "slots": latin ($21.1.2.3.7), cs ($21.1.2.3.1), ea ($21.1.2.3.3), or sym
     134             :   ($21.1.2.3.10), as specified in the following table. For all ranges not
     135             :   explicitly called out below, the ea font shall be used.
     136             : 
     137             :   U+0000-U+007F Use latin font
     138             :   U+0080-U+00A6 Use latin font
     139             :   U+00A9-U+00AF Use latin font
     140             :   U+00B2-U+00B3 Use latin font
     141             :   U+00B5-U+00D6 Use latin font
     142             :   U+00D8-U+00F6 Use latin font
     143             :   U+00F8-U+058F Use latin font
     144             :   U+0590-U+074F Use cs font
     145             :   U+0780-U+07BF Use cs font
     146             :   U+0900-U+109F Use cs font
     147             :   U+10A0-U+10FF Use latin font
     148             :   U+1200-U+137F Use latin font
     149             :   U+13A0-U+177F Use latin font
     150             :   U+1D00-U+1D7F Use latin font
     151             :   U+1E00-U+1FFF Use latin font
     152             :   U+1780-U+18AF Use cs font
     153             :   U+2000-U+200B Use latin font
     154             :   U+200C-U+200F Use cs font
     155             :   U+2010-U+2029 Use latin font Except, for the quote characters in the range
     156             :     2018 - 201E, use ea font if the text has one of the following language
     157             :     identifiers: ii-CN, ja-JP, ko-KR, zh-CN, zh-HK, zh-MO, zh-SG, zh-TW.
     158             :   U+202A-U+202F Use cs font
     159             :   U+2030-U+2046 Use latin font
     160             :   U+204A-U+245F Use latin font
     161             :   U+2670-U+2671 Use cs font
     162             :   U+27C0-U+2BFF Use latin font
     163             :   U+3099-U+309A Use ea font
     164             :   U+D835 Use latin font
     165             :   U+F000-U+F0FF Symbol, use sym font
     166             :   U+FB00-U+FB17 Use latin font
     167             :   U+FB1D-U+FB4F Use cs font
     168             :   U+FE50-U+FE6F Use latin font
     169             :   Otherwise Use ea font
     170             : */
     171           0 : TextCategory categorizeCodePoint(sal_uInt32 codePoint, const OUString &rBcp47LanguageTag)
     172             : {
     173           0 :     TextCategory eRet = ea;
     174           0 :     if (codePoint <= 0x007F)
     175           0 :         eRet = latin;
     176           0 :     else if (0x0080 <= codePoint && codePoint <= 0x00A6)
     177           0 :         eRet = latin;
     178           0 :     else if (0x00A9 <= codePoint && codePoint <= 0x00AF)
     179           0 :         eRet = latin;
     180           0 :     else if (0x00B2 <= codePoint && codePoint <= 0x00B3)
     181           0 :         eRet = latin;
     182           0 :     else if (0x00B5 <= codePoint && codePoint <= 0x00D6)
     183           0 :         eRet = latin;
     184           0 :     else if (0x00D8 <= codePoint && codePoint <= 0x00F6)
     185           0 :         eRet = latin;
     186           0 :     else if (0x00F8 <= codePoint && codePoint <= 0x058F)
     187           0 :         eRet = latin;
     188           0 :     else if (0x0590 <= codePoint && codePoint <= 0x074F)
     189           0 :         eRet = cs;
     190           0 :     else if (0x0780 <= codePoint && codePoint <= 0x07BF)
     191           0 :         eRet = cs;
     192           0 :     else if (0x0900 <= codePoint && codePoint <= 0x109F)
     193           0 :         eRet = cs;
     194           0 :     else if (0x10A0 <= codePoint && codePoint <= 0x10FF)
     195           0 :         eRet = latin;
     196           0 :     else if (0x1200 <= codePoint && codePoint <= 0x137F)
     197           0 :         eRet = latin;
     198           0 :     else if (0x13A0 <= codePoint && codePoint <= 0x177F)
     199           0 :         eRet = latin;
     200           0 :     else if (0x1D00 <= codePoint && codePoint <= 0x1D7F)
     201           0 :         eRet = latin;
     202           0 :     else if (0x1E00 <= codePoint && codePoint <= 0x1FFF)
     203           0 :         eRet = latin;
     204           0 :     else if (0x1780 <= codePoint && codePoint <= 0x18AF)
     205           0 :         eRet = cs;
     206           0 :     else if (0x2000 <= codePoint && codePoint <= 0x200B)
     207           0 :         eRet = latin;
     208           0 :     else if (0x200C <= codePoint && codePoint <= 0x200F)
     209           0 :         eRet = cs;
     210           0 :     else if (0x2010 <= codePoint && codePoint <= 0x2029)
     211             :     {
     212           0 :         eRet = latin;
     213           0 :         if (0x2018 <= codePoint && codePoint <= 0x201E)
     214             :         {
     215           0 :             if (rBcp47LanguageTag == "ii-CN" ||
     216           0 :                 rBcp47LanguageTag == "ja-JP" ||
     217           0 :                 rBcp47LanguageTag == "ko-KR" ||
     218           0 :                 rBcp47LanguageTag == "zh-CN" ||
     219           0 :                 rBcp47LanguageTag == "zh-HK" ||
     220           0 :                 rBcp47LanguageTag == "zh-MO" ||
     221           0 :                 rBcp47LanguageTag == "zh-SG" ||
     222           0 :                 rBcp47LanguageTag == "zh-TW")
     223             :             {
     224           0 :                 eRet = ea;
     225             :             }
     226             :         }
     227             :     }
     228           0 :     else if (0x202A <= codePoint && codePoint <= 0x202F)
     229           0 :         eRet = cs;
     230           0 :     else if (0x2030 <= codePoint && codePoint <= 0x2046)
     231           0 :         eRet = latin;
     232           0 :     else if (0x204A <= codePoint && codePoint <= 0x245F)
     233           0 :         eRet = latin;
     234           0 :     else if (0x2670 <= codePoint && codePoint <= 0x2671)
     235           0 :         eRet = latin;
     236           0 :     else if (0x27C0 <= codePoint && codePoint <= 0x2BFF)
     237           0 :         eRet = latin;
     238           0 :     else if (0x3099 <= codePoint && codePoint <= 0x309A)
     239           0 :         eRet = ea;
     240           0 :     else if (0xD835 == codePoint)
     241           0 :         eRet = latin;
     242           0 :     else if (0xF000 <= codePoint && codePoint <= 0xF0FF)
     243           0 :         eRet = sym;
     244           0 :     else if (0xFB00 <= codePoint && codePoint <= 0xFB17)
     245           0 :         eRet = latin;
     246           0 :     else if (0xFB1D <= codePoint && codePoint <= 0xFB4F)
     247           0 :         eRet = cs;
     248           0 :     else if (0xFE50 <= codePoint && codePoint <= 0xFE6F)
     249           0 :         eRet = latin;
     250           0 :     return eRet;
     251             : }
     252             : 
     253       74180 : OString ConvertColor( const Color &rColor, bool bAutoColor )
     254             : {
     255       74180 :     OString color( "auto" );
     256             : 
     257       74180 :     if (bAutoColor && rColor.GetColor() == OOXML_COLOR_AUTO)
     258       26916 :         return color;
     259             : 
     260       47264 :     if ( rColor.GetColor() != COL_AUTO )
     261             :     {
     262       45002 :         const char pHexDigits[] = "0123456789ABCDEF";
     263       45002 :         char pBuffer[] = "000000";
     264             : 
     265       45002 :         pBuffer[0] = pHexDigits[ ( rColor.GetRed()   >> 4 ) & 0x0F ];
     266       45002 :         pBuffer[1] = pHexDigits[   rColor.GetRed()          & 0x0F ];
     267       45002 :         pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ];
     268       45002 :         pBuffer[3] = pHexDigits[   rColor.GetGreen()        & 0x0F ];
     269       45002 :         pBuffer[4] = pHexDigits[ ( rColor.GetBlue()  >> 4 ) & 0x0F ];
     270       45002 :         pBuffer[5] = pHexDigits[   rColor.GetBlue()         & 0x0F ];
     271             : 
     272       45002 :         color = OString( pBuffer );
     273             :     }
     274       47264 :     return color;
     275             : }
     276             : 
     277             : #define IN2MM100( v )    static_cast< sal_Int32 >( (v) * 2540.0 + 0.5 )
     278             : #define MM2MM100( v )    static_cast< sal_Int32 >( (v) * 100.0 + 0.5 )
     279             : 
     280             : static const ApiPaperSize spPaperSizeTable[] =
     281             : {
     282             :     { 0, 0 },                                                //  0 - (undefined)
     283             :     { IN2MM100( 8.5 ),       IN2MM100( 11 )      },          //  1 - Letter paper
     284             :     { IN2MM100( 8.5 ),       IN2MM100( 11 )      },          //  2 - Letter small paper
     285             :     { IN2MM100( 11 ),        IN2MM100( 17 )      },          //  3 - Tabloid paper
     286             :     { IN2MM100( 17 ),        IN2MM100( 11 )      },          //  4 - Ledger paper
     287             :     { IN2MM100( 8.5 ),       IN2MM100( 14 )      },          //  5 - Legal paper
     288             :     { IN2MM100( 5.5 ),       IN2MM100( 8.5 )     },          //  6 - Statement paper
     289             :     { IN2MM100( 7.25 ),      IN2MM100( 10.5 )    },          //  7 - Executive paper
     290             :     { MM2MM100( 297 ),       MM2MM100( 420 )     },          //  8 - A3 paper
     291             :     { MM2MM100( 210 ),       MM2MM100( 297 )     },          //  9 - A4 paper
     292             :     { MM2MM100( 210 ),       MM2MM100( 297 )     },          // 10 - A4 small paper
     293             :     { MM2MM100( 148 ),       MM2MM100( 210 )     },          // 11 - A5 paper
     294             :     { MM2MM100( 250 ),       MM2MM100( 353 )     },          // 12 - B4 paper
     295             :     { MM2MM100( 176 ),       MM2MM100( 250 )     },          // 13 - B5 paper
     296             :     { IN2MM100( 8.5 ),       IN2MM100( 13 )      },          // 14 - Folio paper
     297             :     { MM2MM100( 215 ),       MM2MM100( 275 )     },          // 15 - Quarto paper
     298             :     { IN2MM100( 10 ),        IN2MM100( 14 )      },          // 16 - Standard paper
     299             :     { IN2MM100( 11 ),        IN2MM100( 17 )      },          // 17 - Standard paper
     300             :     { IN2MM100( 8.5 ),       IN2MM100( 11 )      },          // 18 - Note paper
     301             :     { IN2MM100( 3.875 ),     IN2MM100( 8.875 )   },          // 19 - #9 envelope
     302             :     { IN2MM100( 4.125 ),     IN2MM100( 9.5 )     },          // 20 - #10 envelope
     303             :     { IN2MM100( 4.5 ),       IN2MM100( 10.375 )  },          // 21 - #11 envelope
     304             :     { IN2MM100( 4.75 ),      IN2MM100( 11 )      },          // 22 - #12 envelope
     305             :     { IN2MM100( 5 ),         IN2MM100( 11.5 )    },          // 23 - #14 envelope
     306             :     { IN2MM100( 17 ),        IN2MM100( 22 )      },          // 24 - C paper
     307             :     { IN2MM100( 22 ),        IN2MM100( 34 )      },          // 25 - D paper
     308             :     { IN2MM100( 34 ),        IN2MM100( 44 )      },          // 26 - E paper
     309             :     { MM2MM100( 110 ),       MM2MM100( 220 )     },          // 27 - DL envelope
     310             :     { MM2MM100( 162 ),       MM2MM100( 229 )     },          // 28 - C5 envelope
     311             :     { MM2MM100( 324 ),       MM2MM100( 458 )     },          // 29 - C3 envelope
     312             :     { MM2MM100( 229 ),       MM2MM100( 324 )     },          // 30 - C4 envelope
     313             :     { MM2MM100( 114 ),       MM2MM100( 162 )     },          // 31 - C6 envelope
     314             :     { MM2MM100( 114 ),       MM2MM100( 229 )     },          // 32 - C65 envelope
     315             :     { MM2MM100( 250 ),       MM2MM100( 353 )     },          // 33 - B4 envelope
     316             :     { MM2MM100( 176 ),       MM2MM100( 250 )     },          // 34 - B5 envelope
     317             :     { MM2MM100( 176 ),       MM2MM100( 125 )     },          // 35 - B6 envelope
     318             :     { MM2MM100( 110 ),       MM2MM100( 230 )     },          // 36 - Italy envelope
     319             :     { IN2MM100( 3.875 ),     IN2MM100( 7.5 )     },          // 37 - Monarch envelope
     320             :     { IN2MM100( 3.625 ),     IN2MM100( 6.5 )     },          // 38 - 6 3/4 envelope
     321             :     { IN2MM100( 14.875 ),    IN2MM100( 11 )      },          // 39 - US standard fanfold
     322             :     { IN2MM100( 8.5 ),       IN2MM100( 12 )      },          // 40 - German standard fanfold
     323             :     { IN2MM100( 8.5 ),       IN2MM100( 13 )      },          // 41 - German legal fanfold
     324             :     { MM2MM100( 250 ),       MM2MM100( 353 )     },          // 42 - ISO B4
     325             :     { MM2MM100( 200 ),       MM2MM100( 148 )     },          // 43 - Japanese double postcard
     326             :     { IN2MM100( 9 ),         IN2MM100( 11 )      },          // 44 - Standard paper
     327             :     { IN2MM100( 10 ),        IN2MM100( 11 )      },          // 45 - Standard paper
     328             :     { IN2MM100( 15 ),        IN2MM100( 11 )      },          // 46 - Standard paper
     329             :     { MM2MM100( 220 ),       MM2MM100( 220 )     },          // 47 - Invite envelope
     330             :     { 0, 0 },                                                // 48 - (undefined)
     331             :     { 0, 0 },                                                // 49 - (undefined)
     332             :     { IN2MM100( 9.275 ),     IN2MM100( 12 )      },          // 50 - Letter extra paper
     333             :     { IN2MM100( 9.275 ),     IN2MM100( 15 )      },          // 51 - Legal extra paper
     334             :     { IN2MM100( 11.69 ),     IN2MM100( 18 )      },          // 52 - Tabloid extra paper
     335             :     { MM2MM100( 236 ),       MM2MM100( 322 )     },          // 53 - A4 extra paper
     336             :     { IN2MM100( 8.275 ),     IN2MM100( 11 )      },          // 54 - Letter transverse paper
     337             :     { MM2MM100( 210 ),       MM2MM100( 297 )     },          // 55 - A4 transverse paper
     338             :     { IN2MM100( 9.275 ),     IN2MM100( 12 )      },          // 56 - Letter extra transverse paper
     339             :     { MM2MM100( 227 ),       MM2MM100( 356 )     },          // 57 - SuperA/SuperA/A4 paper
     340             :     { MM2MM100( 305 ),       MM2MM100( 487 )     },          // 58 - SuperB/SuperB/A3 paper
     341             :     { IN2MM100( 8.5 ),       IN2MM100( 12.69 )   },          // 59 - Letter plus paper
     342             :     { MM2MM100( 210 ),       MM2MM100( 330 )     },          // 60 - A4 plus paper
     343             :     { MM2MM100( 148 ),       MM2MM100( 210 )     },          // 61 - A5 transverse paper
     344             :     { MM2MM100( 182 ),       MM2MM100( 257 )     },          // 62 - JIS B5 transverse paper
     345             :     { MM2MM100( 322 ),       MM2MM100( 445 )     },          // 63 - A3 extra paper
     346             :     { MM2MM100( 174 ),       MM2MM100( 235 )     },          // 64 - A5 extra paper
     347             :     { MM2MM100( 201 ),       MM2MM100( 276 )     },          // 65 - ISO B5 extra paper
     348             :     { MM2MM100( 420 ),       MM2MM100( 594 )     },          // 66 - A2 paper
     349             :     { MM2MM100( 297 ),       MM2MM100( 420 )     },          // 67 - A3 transverse paper
     350             :     { MM2MM100( 322 ),       MM2MM100( 445 )     }           // 68 - A3 extra transverse paper
     351             : };
     352             : 
     353           2 : sal_Int32 PaperSizeConv::getMSPaperSizeIndex( const com::sun::star::awt::Size& rSize )
     354             : {
     355           2 :     sal_Int32 nElems = SAL_N_ELEMENTS( spPaperSizeTable );
     356             :     // Need to find the best match for current size
     357           2 :     sal_Int32 nDeltaWidth = 0;
     358           2 :     sal_Int32 nDeltaHeight = 0;
     359             : 
     360           2 :     sal_Int32 nPaperSizeIndex = 0; // Undefined
     361           2 :     const ApiPaperSize* pItem = spPaperSizeTable;
     362           2 :     const ApiPaperSize* pEnd =  spPaperSizeTable + nElems;
     363         140 :     for ( ; pItem != pEnd; ++pItem )
     364             :     {
     365         138 :         sal_Int32 nCurDeltaHeight = std::abs( pItem->mnHeight - rSize.Height );
     366         138 :         sal_Int32 nCurDeltaWidth = std::abs( pItem->mnWidth - rSize.Width );
     367         138 :         if ( pItem == spPaperSizeTable ) // initialize delta with first item
     368             :         {
     369           2 :             nDeltaWidth = nCurDeltaWidth;
     370           2 :             nDeltaHeight = nCurDeltaHeight;
     371             :         }
     372             :         else
     373             :         {
     374         136 :             if ( nCurDeltaWidth < nDeltaWidth && nCurDeltaHeight < nDeltaHeight )
     375             :             {
     376           3 :                 nDeltaWidth = nCurDeltaWidth;
     377           3 :                 nDeltaHeight = nCurDeltaHeight;
     378           3 :                 nPaperSizeIndex = (pItem - spPaperSizeTable);
     379             :             }
     380             :         }
     381             :     }
     382           2 :     sal_Int32 nTol = 10; // hmm not sure is this the best way
     383           2 :     if ( nDeltaWidth <= nTol && nDeltaHeight <= nTol )
     384           2 :         return nPaperSizeIndex;
     385           0 :     return 0;
     386             : }
     387             : 
     388         115 : const ApiPaperSize& PaperSizeConv::getApiSizeForMSPaperSizeIndex( sal_Int32 nMSOPaperIndex )
     389             : {
     390         115 :     sal_Int32 nElems = SAL_N_ELEMENTS( spPaperSizeTable );
     391         115 :     if ( nMSOPaperIndex  < 0 || nMSOPaperIndex > nElems - 1 )
     392           0 :         return spPaperSizeTable[ 0 ];
     393         115 :     return spPaperSizeTable[ nMSOPaperIndex ];
     394             : }
     395             : 
     396         384 : OUString findQuotedText( const OUString& rCommand,
     397             :                 const sal_Char* cStartQuote, const sal_Unicode uEndQuote )
     398             : {
     399         384 :     OUString sRet;
     400         768 :     OUString sStartQuote( OUString::createFromAscii(cStartQuote) );
     401         384 :     sal_Int32 nStartIndex = rCommand.indexOf( sStartQuote );
     402         384 :     if( nStartIndex >= 0 )
     403             :     {
     404         249 :         sal_Int32 nStartLength = sStartQuote.getLength();
     405         249 :         sal_Int32 nEndIndex = rCommand.indexOf( uEndQuote, nStartIndex + nStartLength);
     406         249 :         if( nEndIndex > nStartIndex )
     407             :         {
     408         242 :             sRet = rCommand.copy( nStartIndex + nStartLength, nEndIndex - nStartIndex - nStartLength);
     409             :         }
     410             :     }
     411         768 :     return sRet;
     412             : 
     413             : }
     414             : 
     415          27 : WW8ReadFieldParams::WW8ReadFieldParams( const OUString& _rData )
     416             :     : aData( _rData )
     417             :     , nFnd( 0 )
     418             :     , nNext( 0 )
     419          27 :     , nSavPtr( 0 )
     420             : {
     421             : 
     422             :     /*
     423             :         First look for an opening bracket or a space or a quatation mark or a backslash, so that the field (i.e. INCLUDEPICTURE or EINFUEGENGRAFIK or...) gets oread over
     424             :     */
     425          27 :     const sal_Int32 nLen = aData.getLength();
     426             : 
     427          79 :     while ( nNext<nLen && aData[nNext]==' ' )
     428          25 :         ++nNext;
     429             : 
     430         234 :     while ( nNext<nLen )
     431             :     {
     432         206 :         const sal_Unicode c = aData[nNext];
     433         206 :         if ( c==' ' || c=='"' || c=='\\' || c==132 || c==0x201c )
     434             :             break;
     435         180 :         ++nNext;
     436             :     }
     437             : 
     438          27 :     nFnd      = nNext;
     439          27 :     nSavPtr   = nNext;
     440          27 : }
     441             : 
     442             : 
     443          27 : WW8ReadFieldParams::~WW8ReadFieldParams()
     444             : {
     445             : 
     446          27 : }
     447             : 
     448             : 
     449          25 : OUString WW8ReadFieldParams::GetResult() const
     450             : {
     451          25 :     if (nFnd<0 && nSavPtr>nFnd)
     452           0 :         return OUString();
     453             :     else
     454             :     {
     455          25 :         return nSavPtr < nFnd ? aData.copy(nFnd) : aData.copy(nFnd, nSavPtr-nFnd);
     456             :     }
     457             : }
     458             : 
     459             : 
     460           0 : bool WW8ReadFieldParams::GoToTokenParam()
     461             : {
     462           0 :     const sal_Int32 nOld = nNext;
     463           0 :     if( -2 == SkipToNextToken() )
     464           0 :         return GetTokenSttPtr()>=0;
     465           0 :     nNext = nOld;
     466           0 :     return false;
     467             : }
     468             : 
     469             : // ret: -2: NOT a '\' parameter but normal text
     470          86 : sal_Int32 WW8ReadFieldParams::SkipToNextToken()
     471             : {
     472          86 :     if ( nNext<0 || nNext>=aData.getLength() )
     473          18 :         return -1;
     474             : 
     475          68 :     nFnd = FindNextStringPiece(nNext);
     476          68 :     if ( nFnd<0 )
     477           8 :         return -1;
     478             : 
     479          60 :     nSavPtr = nNext;
     480             : 
     481          60 :     if (nFnd+1<aData.getLength() && aData[nFnd+1]!='\\' && aData[nFnd]=='\\')
     482             :     {
     483          21 :         const sal_Int32 nRet = aData[++nFnd];
     484          21 :         nNext = ++nFnd;             // and set after
     485          21 :         return nRet;
     486             :     }
     487             : 
     488          39 :     if ( nSavPtr>0 && (aData[nSavPtr-1]=='"' || aData[nSavPtr-1]==0x201d ) )
     489             :     {
     490           6 :         --nSavPtr;
     491             :     }
     492          39 :     return -2;
     493             : }
     494             : 
     495             : // FindNextPara searches the next backslash parameter or the next string
     496             : // until the next blank or "\" or closing quatation mark
     497             : // or the end of the string of pStr.
     498             : //
     499             : // Output ppNext (if ppNext != 0) Suchbeginn fuer naechsten Parameter bzw. 0
     500             : //
     501             : // Return value: 0 if end of string reached,
     502             : //             ansonsten Anfang des Paramters bzw. der Zeichenkette
     503             : //
     504          68 : sal_Int32 WW8ReadFieldParams::FindNextStringPiece(const sal_Int32 nStart)
     505             : {
     506          68 :     const sal_Int32 nLen = aData.getLength();
     507          68 :     sal_Int32  n = nStart<0  ? nFnd : nStart;  // start
     508             :     sal_Int32 n2;          // end
     509             : 
     510          68 :     nNext = -1;        // if not found -> Default
     511             : 
     512         208 :     while ( n<nLen && aData[n]==' ' )
     513          72 :         ++n;
     514             : 
     515          68 :     if ( n==nLen )
     516           8 :         return -1;
     517             : 
     518          60 :     if ( aData[n]==0x13 )
     519             :     {
     520             :         // Skip the nested field code since it's not supported
     521           0 :         while ( n<nLen && aData[n]!=0x14 )
     522           0 :             ++n;
     523           0 :         if ( n==nLen )
     524           0 :             return -1;
     525             :     }
     526             : 
     527             :     // quotation marks before paragraph?
     528          60 :     if ( aData[n]=='"' || aData[n]==0x201c || aData[n]==132 || aData[n]==0x14 )
     529             :     {
     530           6 :         n++;                        // read over quatation marks
     531           6 :         n2 = n;                     // search for the end from here on
     532         193 :         while(     (nLen > n2)
     533         187 :                 && (aData[n2] != '"')
     534         181 :                 && (aData[n2] != 0x201d)
     535         181 :                 && (aData[n2] != 147)
     536         368 :                 && (aData[n2] != 0x15) )
     537         181 :             n2++;                   // search for the end of the paragraph
     538             :     }
     539             :     else                        // no quotation mark
     540             :     {
     541          54 :         n2 = n;                     // search for the end from here on
     542         595 :         while ( n2<nLen && aData[n2]!=' ' ) // search for the end of the paragraph
     543             :         {
     544         508 :             if ( aData[n2]=='\\' )
     545             :             {
     546          21 :                 if ( n2+1<nLen && aData[n2+1]=='\\' )
     547           0 :                     n2 += 2;        // double backslash -> OK
     548             :                 else
     549             :                 {
     550          21 :                     if( n2 > n )
     551           0 :                         n2--;
     552          21 :                     break;          // single backslash -> end
     553             :                 }
     554             :             }
     555             :             else
     556         487 :                 n2++;               // no backslash -> OK
     557             :         }
     558             :     }
     559          60 :     if( nLen > n2 )
     560             :     {
     561          46 :         if (aData[n2]!=' ') ++n2;
     562          46 :         nNext = n2;
     563             :     }
     564          60 :     return n;
     565             : }
     566             : 
     567             : 
     568             : 
     569             : // read parameters "1-3" or 1-3 with both values between 1 and nMax
     570           0 : bool WW8ReadFieldParams::GetTokenSttFromTo(sal_Int32* pFrom, sal_Int32* pTo, sal_Int32 nMax)
     571             : {
     572           0 :     sal_Int32 nStart = 0;
     573           0 :     sal_Int32 nEnd   = 0;
     574           0 :     if ( GoToTokenParam() )
     575             :     {
     576             : 
     577           0 :         const OUString sParams( GetResult() );
     578             : 
     579           0 :         sal_Int32 nIndex = 0;
     580           0 :         const OUString sStart( sParams.getToken(0, '-', nIndex) );
     581           0 :         if (nIndex>=0)
     582             :         {
     583           0 :             nStart = sStart.toInt32();
     584           0 :             nEnd   = sParams.copy(nIndex).toInt32();
     585           0 :         }
     586             :     }
     587           0 :     if( pFrom ) *pFrom = nStart;
     588           0 :     if( pTo )   *pTo   = nEnd;
     589             : 
     590           0 :     return nStart && nEnd && (nMax >= nStart) && (nMax >= nEnd);
     591             : }
     592             : 
     593           0 : EquationResult Read_SubF_Combined(WW8ReadFieldParams& rReadParam)
     594             : {
     595           0 :     EquationResult aResult;
     596             : 
     597           0 :     OUString sCombinedCharacters;
     598           0 :     WW8ReadFieldParams aOriFldParam = rReadParam;
     599           0 :     const sal_Int32 cGetChar = rReadParam.SkipToNextToken();
     600           0 :     switch( cGetChar )
     601             :     {
     602             :     case 'a':
     603             :     case 'A':
     604           0 :         if ( !rReadParam.GetResult().startsWithIgnoreAsciiCase("d") )
     605             :         {
     606           0 :             break;
     607             :         }
     608           0 :         (void)rReadParam.SkipToNextToken();
     609             :         // intentional fall-through
     610             :     case -2:
     611             :         {
     612           0 :             if ( rReadParam.GetResult().startsWithIgnoreAsciiCase("(") )
     613             :             {
     614           0 :                 for (int i=0;i<2;i++)
     615             :                 {
     616           0 :                     if ('s' == rReadParam.SkipToNextToken())
     617             :                     {
     618           0 :                         const sal_Int32 cChar = rReadParam.SkipToNextToken();
     619           0 :                         if (-2 != rReadParam.SkipToNextToken())
     620           0 :                             break;
     621           0 :                         const OUString sF = rReadParam.GetResult();
     622           0 :                         if ((('u' == cChar) && sF.startsWithIgnoreAsciiCase("p"))
     623           0 :                             || (('d' == cChar) && sF.startsWithIgnoreAsciiCase("o")))
     624             :                         {
     625           0 :                             if (-2 == rReadParam.SkipToNextToken())
     626             :                             {
     627           0 :                                 OUString sPart = rReadParam.GetResult();
     628           0 :                                 sal_Int32 nBegin = sPart.indexOf('(');
     629             : 
     630             :                                 // Word disallows brackets in this field, which
     631             :                                 // aids figuring out the case of an end of )) vs )
     632           0 :                                 sal_Int32 nEnd = sPart.indexOf(')');
     633             : 
     634           0 :                                 if (nBegin != -1 && nEnd != -1)
     635             :                                 {
     636           0 :                                     sCombinedCharacters +=
     637           0 :                                         sPart.copy(nBegin+1,nEnd-nBegin-1);
     638           0 :                                 }
     639             :                             }
     640           0 :                         }
     641             :                     }
     642             :                 }
     643           0 :                 if (!sCombinedCharacters.isEmpty())
     644             :                 {
     645           0 :                     aResult.sType = "CombinedCharacters";
     646           0 :                     aResult.sResult = sCombinedCharacters;
     647             :                 }
     648             :                 else
     649             :                 {
     650           0 :                     const OUString sPart = aOriFldParam.GetResult();
     651           0 :                     sal_Int32 nBegin = sPart.indexOf('(');
     652           0 :                     sal_Int32 nEnd = sPart.indexOf(',');
     653           0 :                     if ( nEnd == -1 )
     654             :                     {
     655           0 :                         nEnd = sPart.indexOf(')');
     656             :                     }
     657           0 :                     if ( nBegin != -1 && nEnd != -1 )
     658             :                     {
     659             :                         // skip certain leading characters
     660           0 :                         for (int i = nBegin;i < nEnd-1;i++)
     661             :                         {
     662           0 :                             const sal_Unicode cC = sPart[nBegin+1];
     663           0 :                             if ( cC < 32 )
     664             :                             {
     665           0 :                                 nBegin++;
     666             :                             }
     667             :                             else
     668           0 :                                 break;
     669             :                         }
     670           0 :                         sCombinedCharacters = sPart.copy( nBegin+1, nEnd-nBegin-1 );
     671           0 :                         if ( !sCombinedCharacters.isEmpty() )
     672             :                         {
     673           0 :                             aResult.sType = "Input";
     674           0 :                             aResult.sResult = sCombinedCharacters;
     675             :                         }
     676           0 :                     }
     677             :                 }
     678             :             }
     679             :         }
     680             :     default:
     681           0 :         break;
     682             :     }
     683           0 :     return aResult;
     684             : }
     685             : 
     686           1 : EquationResult ParseCombinedChars(const OUString& rStr)
     687             : {
     688           1 :     EquationResult aResult;
     689           2 :     WW8ReadFieldParams aReadParam( rStr );
     690           1 :     const sal_Int32 cChar = aReadParam.SkipToNextToken();
     691           1 :     if ('o' == cChar || 'O' == cChar)
     692           0 :         aResult = Read_SubF_Combined(aReadParam);
     693           2 :     return aResult;
     694             : }
     695             : 
     696             : struct CustomShapeTypeTranslationTable
     697             : {
     698             :     const char* sOOo;
     699             :     const char* sMSO;
     700             : };
     701             : 
     702             : static const CustomShapeTypeTranslationTable pCustomShapeTypeTranslationTable[] =
     703             : {
     704             :     // { "non-primitive", mso_sptMin },
     705             :     { "frame", "frame" },
     706             :     { "rectangle", "rect" },
     707             :     { "round-rectangle", "roundRect" },
     708             :     { "ellipse", "ellipse" },
     709             :     { "diamond", "diamond" },
     710             :     { "isosceles-triangle", "triangle" },
     711             :     { "right-triangle", "rtTriangle" },
     712             :     { "parallelogram", "parallelogram" },
     713             :     { "trapezoid", "trapezoid" },
     714             :     { "hexagon", "hexagon" },
     715             :     { "octagon", "octagon" },
     716             :     { "cross", "plus" },
     717             :     { "star5", "star5" },
     718             :     { "right-arrow", "rightArrow" },
     719             :     // { "mso-spt14", mso_sptThickArrow },
     720             :     { "pentagon-right", "homePlate" },
     721             :     { "cube", "cube" },
     722             :     // { "mso-spt17", mso_sptBalloon },
     723             :     // { "mso-spt18", mso_sptSeal },
     724             :     { "mso-spt19", "arc" },
     725             :     { "mso-spt20", "line" },
     726             :     { "mso-spt21", "plaque" },
     727             :     { "can", "can" },
     728             :     { "ring", "donut" },
     729             :     { "mso-spt24", "textPlain" },
     730             :     { "mso-spt25", "textStop" },
     731             :     { "mso-spt26", "textTriangle" },
     732             :     { "mso-spt27", "textCanDown" },
     733             :     { "mso-spt28", "textWave1" },
     734             :     { "mso-spt29", "textArchUpPour" },
     735             :     { "mso-spt30", "textCanDown" },
     736             :     { "mso-spt31", "textArchUp" },
     737             :     { "mso-spt32", "straightConnector1" },
     738             :     { "mso-spt33", "bentConnector2" },
     739             :     { "mso-spt34", "bentConnector3" },
     740             :     { "mso-spt35", "bentConnector4" },
     741             :     { "mso-spt36", "bentConnector5" },
     742             :     { "mso-spt37", "curvedConnector2" },
     743             :     { "mso-spt38", "curvedConnector3" },
     744             :     { "mso-spt39", "curvedConnector4" },
     745             :     { "mso-spt40", "curvedConnector5" },
     746             :     { "mso-spt41", "callout1" },
     747             :     { "mso-spt42", "callout2" },
     748             :     { "mso-spt43", "callout3" },
     749             :     { "mso-spt44", "accentCallout1" },
     750             :     { "mso-spt45", "accentCallout2" },
     751             :     { "mso-spt46", "accentCallout3" },
     752             :     { "line-callout-1", "borderCallout1" },
     753             :     { "line-callout-2", "borderCallout2" },
     754             :     { "line-callout-3", "borderCallout3" },
     755             :     { "mso-spt49", "borderCallout3" },
     756             :     { "mso-spt50", "accentBorderCallout1" },
     757             :     { "mso-spt51", "accentBorderCallout2" },
     758             :     { "mso-spt52", "accentBorderCallout3" },
     759             :     { "mso-spt53", "ribbon" },
     760             :     { "mso-spt54", "ribbon2" },
     761             :     { "chevron", "chevron" },
     762             :     { "pentagon", "pentagon" },
     763             :     { "forbidden", "noSmoking" },
     764             :     { "star8", "star8" },
     765             :     { "mso-spt59", "star16" },
     766             :     { "mso-spt60", "star32" },
     767             :     { "rectangular-callout", "wedgeRectCallout" },
     768             :     { "round-rectangular-callout", "wedgeRoundRectCallout" },
     769             :     { "round-callout", "wedgeEllipseCallout" },
     770             :     { "mso-spt64", "wave" },
     771             :     { "paper", "foldedCorner" },
     772             :     { "left-arrow", "leftArrow" },
     773             :     { "down-arrow", "downArrow" },
     774             :     { "up-arrow", "upArrow" },
     775             :     { "left-right-arrow", "leftRightArrow" },
     776             :     { "up-down-arrow", "upDownArrow" },
     777             :     { "mso-spt71", "irregularSeal1" },
     778             :     { "bang", "irregularSeal2" },
     779             :     { "lightning", "lightningBolt" },
     780             :     { "heart", "heart" },
     781             :     { "quad-arrow", "quadArrow" },
     782             :     { "left-arrow-callout", "leftArrowCallout" },
     783             :     { "right-arrow-callout", "rightArrowCallout" },
     784             :     { "up-arrow-callout", "upArrowCallout" },
     785             :     { "down-arrow-callout", "downArrowCallout" },
     786             :     { "left-right-arrow-callout", "leftRightArrowCallout" },
     787             :     { "up-down-arrow-callout", "upDownArrowCallout" },
     788             :     { "quad-arrow-callout", "quadArrowCallout" },
     789             :     { "quad-bevel", "bevel" },
     790             :     { "left-bracket", "leftBracket" },
     791             :     { "right-bracket", "rightBracket" },
     792             :     { "left-brace", "leftBrace" },
     793             :     { "right-brace", "rightBrace" },
     794             :     { "mso-spt89", "leftUpArrow" },
     795             :     { "mso-spt90", "bentUpArrow" },
     796             :     { "mso-spt91", "bentArrow" },
     797             :     { "star24", "star24" },
     798             :     { "striped-right-arrow", "stripedRightArrow" },
     799             :     { "notched-right-arrow", "notchedRightArrow" },
     800             :     { "block-arc", "blockArc" },
     801             :     { "smiley", "smileyFace" },
     802             :     { "vertical-scroll", "verticalScroll" },
     803             :     { "horizontal-scroll", "horizontalScroll" },
     804             :     { "circular-arrow", "circularArrow" },
     805             :     { "mso-spt100", "pie" }, // looks like MSO_SPT is wrong here
     806             :     { "mso-spt101", "uturnArrow" },
     807             :     { "mso-spt102", "curvedRightArrow" },
     808             :     { "mso-spt103", "curvedLeftArrow" },
     809             :     { "mso-spt104", "curvedUpArrow" },
     810             :     { "mso-spt105", "curvedDownArrow" },
     811             :     { "cloud-callout", "cloudCallout" },
     812             :     { "mso-spt107", "ellipseRibbon" },
     813             :     { "mso-spt108", "ellipseRibbon2" },
     814             :     { "flowchart-process", "flowChartProcess" },
     815             :     { "flowchart-decision", "flowChartDecision" },
     816             :     { "flowchart-data", "flowChartInputOutput" },
     817             :     { "flowchart-predefined-process", "flowChartPredefinedProcess" },
     818             :     { "flowchart-internal-storage", "flowChartInternalStorage" },
     819             :     { "flowchart-document", "flowChartDocument" },
     820             :     { "flowchart-multidocument", "flowChartMultidocument" },
     821             :     { "flowchart-terminator", "flowChartTerminator" },
     822             :     { "flowchart-preparation", "flowChartPreparation" },
     823             :     { "flowchart-manual-input", "flowChartManualInput" },
     824             :     { "flowchart-manual-operation", "flowChartManualOperation" },
     825             :     { "flowchart-connector", "flowChartConnector" },
     826             :     { "flowchart-card", "flowChartPunchedCard" },
     827             :     { "flowchart-punched-tape", "flowChartPunchedTape" },
     828             :     { "flowchart-summing-junction", "flowChartSummingJunction" },
     829             :     { "flowchart-or", "flowChartOr" },
     830             :     { "flowchart-collate", "flowChartCollate" },
     831             :     { "flowchart-sort", "flowChartSort" },
     832             :     { "flowchart-extract", "flowChartExtract" },
     833             :     { "flowchart-merge", "flowChartMerge" },
     834             :     { "mso-spt129", "flowChartOfflineStorage" },
     835             :     { "flowchart-stored-data", "flowChartOnlineStorage" },
     836             :     { "flowchart-sequential-access", "flowChartMagneticTape" },
     837             :     { "flowchart-magnetic-disk", "flowChartMagneticDisk" },
     838             :     { "flowchart-direct-access-storage", "flowChartMagneticDrum" },
     839             :     { "flowchart-display", "flowChartDisplay" },
     840             :     { "flowchart-delay", "flowChartDelay" },
     841             :     // { "fontwork-plain-text", "textPlainText" },
     842             :     // { "fontwork-stop", "textStop" },
     843             :     // { "fontwork-triangle-up", "textTriangle" },
     844             :     // { "fontwork-triangle-down", "textTriangleInverted" },
     845             :     // { "fontwork-chevron-up", "textChevron" },
     846             :     // { "fontwork-chevron-down", "textChevronInverted" },
     847             :     // { "mso-spt142", "textRingInside" },
     848             :     // { "mso-spt143", "textRingOutside" },
     849             :     // { "fontwork-arch-up-curve", "textArchUpCurve" },
     850             :     // { "fontwork-arch-down-curve", "textArchDownCurve" },
     851             :     // { "fontwork-circle-curve", "textCircleCurve" },
     852             :     // { "fontwork-open-circle-curve", "textButtonCurve" },
     853             :     // { "fontwork-arch-up-pour", "textArchUpPour" },
     854             :     // { "fontwork-arch-down-pour", "textArchDownPour" },
     855             :     // { "fontwork-circle-pour", "textCirclePour" },
     856             :     // { "fontwork-open-circle-pour", "textButtonPour" },
     857             :     // { "fontwork-curve-up", "textCurveUp" },
     858             :     // { "fontwork-curve-down", "textCurveDown" },
     859             :     // { "fontwork-fade-up-and-right", "textCascadeUp" },
     860             :     // { "fontwork-fade-up-and-left", "textCascadeDown" },
     861             :     // { "fontwork-wave", "textWave1" },
     862             :     // { "mso-spt157", "textWave2" },
     863             :     // { "mso-spt158", "textWave3" },
     864             :     // { "mso-spt159", "textWave4" },
     865             :     // { "fontwork-inflate", "textInflate" },
     866             :     // { "mso-spt161", "textDeflate" },
     867             :     // { "mso-spt162", "textInflateBottom" },
     868             :     // { "mso-spt163", "textDeflateBottom" },
     869             :     // { "mso-spt164", "textInflateTop" },
     870             :     // { "mso-spt165", "textDeflateTop" },
     871             :     // { "mso-spt166", "textDeflateInflate" },
     872             :     // { "mso-spt167", "textDeflateInflateDeflate" },
     873             :     // { "fontwork-fade-right", "textFadeRight" },
     874             :     // { "fontwork-fade-left", "textFadeLeft" },
     875             :     // { "fontwork-fade-up", "textFadeUp" },
     876             :     // { "fontwork-fade-down", "textFadeDown" },
     877             :     // { "fontwork-slant-up", "textSlantUp" },
     878             :     // { "fontwork-slant-down", "textSlantDown" },
     879             :     // { "mso-spt174", "textCanUp" },
     880             :     // { "mso-spt175", "textCanDown" },
     881             :     { "flowchart-alternate-process", "flowChartAlternateProcess" },
     882             :     { "flowchart-off-page-connector", "flowChartOffpageConnector" },
     883             :     { "mso-spt178", "callout1" },
     884             :     { "mso-spt179", "accentCallout1" },
     885             :     { "mso-spt180", "borderCallout1" },
     886             :     { "mso-spt182", "leftRightUpArrow" },
     887             :     { "sun", "sun" },
     888             :     { "moon", "moon" },
     889             :     { "bracket-pair", "bracketPair" },
     890             :     { "brace-pair", "bracePair" },
     891             :     { "star4", "star4" },
     892             :     { "mso-spt188", "doubleWave" },
     893             :     { "mso-spt189", "actionButtonBlank" },
     894             :     { "mso-spt190", "actionButtonHome" },
     895             :     { "mso-spt191", "actionButtonHelp" },
     896             :     { "mso-spt192", "actionButtonInformation" },
     897             :     { "mso-spt193", "actionButtonForwardNext" },
     898             :     { "mso-spt194", "actionButtonBackPrevious" },
     899             :     { "mso-spt195", "actionButtonEnd" },
     900             :     { "mso-spt196", "actionButtonBeginning" },
     901             :     { "mso-spt197", "actionButtonReturn" },
     902             :     { "mso-spt198", "actionButtonDocument" },
     903             :     { "mso-spt199", "actionButtonSound" },
     904             :     { "mso-spt200", "actionButtonMovie" },
     905             :     // { "mso-spt201", "hostControl" },
     906             :     { "mso-spt202", "rect" },
     907             :     { "ooxml-actionButtonSound", "actionButtonSound" },
     908             :     { "ooxml-borderCallout1", "borderCallout1" },
     909             :     { "ooxml-plaqueTabs", "plaqueTabs" },
     910             :     { "ooxml-curvedLeftArrow", "curvedLeftArrow" },
     911             :     { "ooxml-octagon", "octagon" },
     912             :     { "ooxml-leftRightRibbon", "leftRightRibbon" },
     913             :     { "ooxml-actionButtonInformation", "actionButtonInformation" },
     914             :     { "ooxml-bentConnector5", "bentConnector5" },
     915             :     { "ooxml-circularArrow", "circularArrow" },
     916             :     { "ooxml-downArrowCallout", "downArrowCallout" },
     917             :     { "ooxml-mathMinus", "mathMinus" },
     918             :     { "ooxml-gear9", "gear9" },
     919             :     { "ooxml-round1Rect", "round1Rect" },
     920             :     { "ooxml-sun", "sun" },
     921             :     { "ooxml-plaque", "plaque" },
     922             :     { "ooxml-chevron", "chevron" },
     923             :     { "ooxml-flowChartPreparation", "flowChartPreparation" },
     924             :     { "ooxml-diagStripe", "diagStripe" },
     925             :     { "ooxml-pentagon", "pentagon" },
     926             :     { "ooxml-funnel", "funnel" },
     927             :     { "ooxml-chartStar", "chartStar" },
     928             :     { "ooxml-accentBorderCallout1", "accentBorderCallout1" },
     929             :     { "ooxml-notchedRightArrow", "notchedRightArrow" },
     930             :     { "ooxml-rightBracket", "rightBracket" },
     931             :     { "ooxml-flowChartOffpageConnector", "flowChartOffpageConnector" },
     932             :     { "ooxml-leftRightArrow", "leftRightArrow" },
     933             :     { "ooxml-decagon", "decagon" },
     934             :     { "ooxml-actionButtonHelp", "actionButtonHelp" },
     935             :     { "ooxml-star24", "star24" },
     936             :     { "ooxml-mathDivide", "mathDivide" },
     937             :     { "ooxml-curvedConnector4", "curvedConnector4" },
     938             :     { "ooxml-flowChartOr", "flowChartOr" },
     939             :     { "ooxml-borderCallout3", "borderCallout3" },
     940             :     { "ooxml-upDownArrowCallout", "upDownArrowCallout" },
     941             :     { "ooxml-flowChartDecision", "flowChartDecision" },
     942             :     { "ooxml-leftRightArrowCallout", "leftRightArrowCallout" },
     943             :     { "ooxml-flowChartManualOperation", "flowChartManualOperation" },
     944             :     { "ooxml-snipRoundRect", "snipRoundRect" },
     945             :     { "ooxml-mathPlus", "mathPlus" },
     946             :     { "ooxml-actionButtonForwardNext", "actionButtonForwardNext" },
     947             :     { "ooxml-can", "can" },
     948             :     { "ooxml-foldedCorner", "foldedCorner" },
     949             :     { "ooxml-star32", "star32" },
     950             :     { "ooxml-flowChartInternalStorage", "flowChartInternalStorage" },
     951             :     { "ooxml-upDownArrow", "upDownArrow" },
     952             :     { "ooxml-irregularSeal2", "irregularSeal2" },
     953             :     { "ooxml-mathEqual", "mathEqual" },
     954             :     { "ooxml-star12", "star12" },
     955             :     { "ooxml-uturnArrow", "uturnArrow" },
     956             :     { "ooxml-squareTabs", "squareTabs" },
     957             :     { "ooxml-leftRightUpArrow", "leftRightUpArrow" },
     958             :     { "ooxml-homePlate", "homePlate" },
     959             :     { "ooxml-dodecagon", "dodecagon" },
     960             :     { "ooxml-leftArrowCallout", "leftArrowCallout" },
     961             :     { "ooxml-chord", "chord" },
     962             :     { "ooxml-quadArrowCallout", "quadArrowCallout" },
     963             :     { "ooxml-actionButtonBeginning", "actionButtonBeginning" },
     964             :     { "ooxml-ellipse", "ellipse" },
     965             :     { "ooxml-actionButtonEnd", "actionButtonEnd" },
     966             :     { "ooxml-arc", "arc" },
     967             :     { "ooxml-star16", "star16" },
     968             :     { "ooxml-parallelogram", "parallelogram" },
     969             :     { "ooxml-bevel", "bevel" },
     970             :     { "ooxml-roundRect", "roundRect" },
     971             :     { "ooxml-accentCallout1", "accentCallout1" },
     972             :     { "ooxml-flowChartSort", "flowChartSort" },
     973             :     { "ooxml-star8", "star8" },
     974             :     { "ooxml-flowChartAlternateProcess", "flowChartAlternateProcess" },
     975             :     { "ooxml-moon", "moon" },
     976             :     { "ooxml-star6", "star6" },
     977             :     { "ooxml-round2SameRect", "round2SameRect" },
     978             :     { "ooxml-nonIsoscelesTrapezoid", "nonIsoscelesTrapezoid" },
     979             :     { "ooxml-diamond", "diamond" },
     980             :     { "ooxml-ellipseRibbon", "ellipseRibbon" },
     981             :     { "ooxml-callout2", "callout2" },
     982             :     { "ooxml-pie", "pie" },
     983             :     { "ooxml-star4", "star4" },
     984             :     { "ooxml-flowChartPredefinedProcess", "flowChartPredefinedProcess" },
     985             :     { "ooxml-flowChartPunchedTape", "flowChartPunchedTape" },
     986             :     { "ooxml-curvedConnector2", "curvedConnector2" },
     987             :     { "ooxml-bentConnector3", "bentConnector3" },
     988             :     { "ooxml-cornerTabs", "cornerTabs" },
     989             :     { "ooxml-hexagon", "hexagon" },
     990             :     { "ooxml-flowChartConnector", "flowChartConnector" },
     991             :     { "ooxml-flowChartMagneticDisk", "flowChartMagneticDisk" },
     992             :     { "ooxml-heart", "heart" },
     993             :     { "ooxml-ribbon2", "ribbon2" },
     994             :     { "ooxml-bracePair", "bracePair" },
     995             :     { "ooxml-flowChartExtract", "flowChartExtract" },
     996             :     { "ooxml-actionButtonHome", "actionButtonHome" },
     997             :     { "ooxml-accentBorderCallout3", "accentBorderCallout3" },
     998             :     { "ooxml-flowChartOfflineStorage", "flowChartOfflineStorage" },
     999             :     { "ooxml-irregularSeal1", "irregularSeal1" },
    1000             :     { "ooxml-quadArrow", "quadArrow" },
    1001             :     { "ooxml-leftBrace", "leftBrace" },
    1002             :     { "ooxml-leftBracket", "leftBracket" },
    1003             :     { "ooxml-blockArc", "blockArc" },
    1004             :     { "ooxml-curvedConnector3", "curvedConnector3" },
    1005             :     { "ooxml-wedgeRoundRectCallout", "wedgeRoundRectCallout" },
    1006             :     { "ooxml-actionButtonMovie", "actionButtonMovie" },
    1007             :     { "ooxml-flowChartOnlineStorage", "flowChartOnlineStorage" },
    1008             :     { "ooxml-gear6", "gear6" },
    1009             :     { "ooxml-halfFrame", "halfFrame" },
    1010             :     { "ooxml-snip2SameRect", "snip2SameRect" },
    1011             :     { "ooxml-triangle", "triangle" },
    1012             :     { "ooxml-teardrop", "teardrop" },
    1013             :     { "ooxml-flowChartDocument", "flowChartDocument" },
    1014             :     { "ooxml-rightArrowCallout", "rightArrowCallout" },
    1015             :     { "ooxml-rightBrace", "rightBrace" },
    1016             :     { "ooxml-chartPlus", "chartPlus" },
    1017             :     { "ooxml-flowChartManualInput", "flowChartManualInput" },
    1018             :     { "ooxml-flowChartMerge", "flowChartMerge" },
    1019             :     { "ooxml-line", "line" },
    1020             :     { "ooxml-downArrow", "downArrow" },
    1021             :     { "ooxml-upArrow", "upArrow" },
    1022             :     { "ooxml-curvedDownArrow", "curvedDownArrow" },
    1023             :     { "ooxml-actionButtonReturn", "actionButtonReturn" },
    1024             :     { "ooxml-flowChartInputOutput", "flowChartInputOutput" },
    1025             :     { "ooxml-bracketPair", "bracketPair" },
    1026             :     { "ooxml-smileyFace", "smileyFace" },
    1027             :     { "ooxml-actionButtonBlank", "actionButtonBlank" },
    1028             :     { "ooxml-wave", "wave" },
    1029             :     { "ooxml-swooshArrow", "swooshArrow" },
    1030             :     { "ooxml-flowChartSummingJunction", "flowChartSummingJunction" },
    1031             :     { "ooxml-lightningBolt", "lightningBolt" },
    1032             :     { "ooxml-flowChartDisplay", "flowChartDisplay" },
    1033             :     { "ooxml-actionButtonBackPrevious", "actionButtonBackPrevious" },
    1034             :     { "ooxml-frame", "frame" },
    1035             :     { "ooxml-rtTriangle", "rtTriangle" },
    1036             :     { "ooxml-flowChartMagneticTape", "flowChartMagneticTape" },
    1037             :     { "ooxml-curvedRightArrow", "curvedRightArrow" },
    1038             :     { "ooxml-leftUpArrow", "leftUpArrow" },
    1039             :     { "ooxml-wedgeEllipseCallout", "wedgeEllipseCallout" },
    1040             :     { "ooxml-doubleWave", "doubleWave" },
    1041             :     { "ooxml-bentArrow", "bentArrow" },
    1042             :     { "ooxml-star10", "star10" },
    1043             :     { "ooxml-leftArrow", "leftArrow" },
    1044             :     { "ooxml-curvedUpArrow", "curvedUpArrow" },
    1045             :     { "ooxml-snip1Rect", "snip1Rect" },
    1046             :     { "ooxml-ellipseRibbon2", "ellipseRibbon2" },
    1047             :     { "ooxml-plus", "plus" },
    1048             :     { "ooxml-accentCallout3", "accentCallout3" },
    1049             :     { "ooxml-leftCircularArrow", "leftCircularArrow" },
    1050             :     { "ooxml-rightArrow", "rightArrow" },
    1051             :     { "ooxml-flowChartPunchedCard", "flowChartPunchedCard" },
    1052             :     { "ooxml-snip2DiagRect", "snip2DiagRect" },
    1053             :     { "ooxml-verticalScroll", "verticalScroll" },
    1054             :     { "ooxml-star7", "star7" },
    1055             :     { "ooxml-chartX", "chartX" },
    1056             :     { "ooxml-cloud", "cloud" },
    1057             :     { "ooxml-cube", "cube" },
    1058             :     { "ooxml-round2DiagRect", "round2DiagRect" },
    1059             :     { "ooxml-flowChartMultidocument", "flowChartMultidocument" },
    1060             :     { "ooxml-actionButtonDocument", "actionButtonDocument" },
    1061             :     { "ooxml-flowChartTerminator", "flowChartTerminator" },
    1062             :     { "ooxml-flowChartDelay", "flowChartDelay" },
    1063             :     { "ooxml-curvedConnector5", "curvedConnector5" },
    1064             :     { "ooxml-horizontalScroll", "horizontalScroll" },
    1065             :     { "ooxml-bentConnector4", "bentConnector4" },
    1066             :     { "ooxml-leftRightCircularArrow", "leftRightCircularArrow" },
    1067             :     { "ooxml-wedgeRectCallout", "wedgeRectCallout" },
    1068             :     { "ooxml-accentCallout2", "accentCallout2" },
    1069             :     { "ooxml-flowChartMagneticDrum", "flowChartMagneticDrum" },
    1070             :     { "ooxml-corner", "corner" },
    1071             :     { "ooxml-borderCallout2", "borderCallout2" },
    1072             :     { "ooxml-donut", "donut" },
    1073             :     { "ooxml-flowChartCollate", "flowChartCollate" },
    1074             :     { "ooxml-mathNotEqual", "mathNotEqual" },
    1075             :     { "ooxml-bentConnector2", "bentConnector2" },
    1076             :     { "ooxml-mathMultiply", "mathMultiply" },
    1077             :     { "ooxml-heptagon", "heptagon" },
    1078             :     { "ooxml-rect", "rect" },
    1079             :     { "ooxml-accentBorderCallout2", "accentBorderCallout2" },
    1080             :     { "ooxml-pieWedge", "pieWedge" },
    1081             :     { "ooxml-upArrowCallout", "upArrowCallout" },
    1082             :     { "ooxml-flowChartProcess", "flowChartProcess" },
    1083             :     { "ooxml-star5", "star5" },
    1084             :     { "ooxml-lineInv", "lineInv" },
    1085             :     { "ooxml-straightConnector1", "straightConnector1" },
    1086             :     { "ooxml-stripedRightArrow", "stripedRightArrow" },
    1087             :     { "ooxml-callout3", "callout3" },
    1088             :     { "ooxml-bentUpArrow", "bentUpArrow" },
    1089             :     { "ooxml-noSmoking", "noSmoking" },
    1090             :     { "ooxml-trapezoid", "trapezoid" },
    1091             :     { "ooxml-cloudCallout", "cloudCallout" },
    1092             :     { "ooxml-callout1", "callout1" },
    1093             :     { "ooxml-ribbon", "ribbon" },
    1094             :     { "ooxml-rect", "rect" },
    1095             : };
    1096             : 
    1097             : static struct {
    1098             :     const char* sDML;
    1099             :     MSO_SPT nVML;
    1100             : } const pDMLToVMLTable[] = {
    1101             :     {"notPrimitive", mso_sptNotPrimitive},
    1102             :     {"rectangle", mso_sptRectangle},
    1103             :     {"roundRectangle", mso_sptRoundRectangle},
    1104             :     {"ellipse", mso_sptEllipse},
    1105             :     {"diamond", mso_sptDiamond},
    1106             :     {"triangle", mso_sptIsocelesTriangle},
    1107             :     {"rtTriangle", mso_sptRightTriangle},
    1108             :     {"parallelogram", mso_sptParallelogram},
    1109             :     {"trapezoid", mso_sptTrapezoid},
    1110             :     {"hexagon", mso_sptHexagon},
    1111             :     {"octagon", mso_sptOctagon},
    1112             :     {"plus", mso_sptPlus},
    1113             :     {"star5", mso_sptStar},
    1114             :     {"rightArrow", mso_sptArrow},
    1115             :     {"thickArrow", mso_sptThickArrow},
    1116             :     {"homePlate", mso_sptHomePlate},
    1117             :     {"cube", mso_sptCube},
    1118             :     {"wedgeRoundRectCallout", mso_sptBalloon},
    1119             :     {"star16", mso_sptSeal},
    1120             :     {"arc", mso_sptArc},
    1121             :     {"line", mso_sptLine},
    1122             :     {"plaque", mso_sptPlaque},
    1123             :     {"can", mso_sptCan},
    1124             :     {"donut", mso_sptDonut},
    1125             :     {"textPlain", mso_sptTextSimple},
    1126             :     {"textStop", mso_sptTextOctagon},
    1127             :     {"textTriangle", mso_sptTextHexagon},
    1128             :     {"textCanDown", mso_sptTextCurve},
    1129             :     {"textWave1", mso_sptTextWave},
    1130             :     {"textArchUpPour", mso_sptTextRing},
    1131             :     {"textCanDown", mso_sptTextOnCurve},
    1132             :     {"textArchUp", mso_sptTextOnRing},
    1133             :     {"straightConnector1", mso_sptStraightConnector1},
    1134             :     {"bentConnector2", mso_sptBentConnector2},
    1135             :     {"bentConnector3", mso_sptBentConnector3},
    1136             :     {"bentConnector4", mso_sptBentConnector4},
    1137             :     {"bentConnector5", mso_sptBentConnector5},
    1138             :     {"curvedConnector2", mso_sptCurvedConnector2},
    1139             :     {"curvedConnector3", mso_sptCurvedConnector3},
    1140             :     {"curvedConnector4", mso_sptCurvedConnector4},
    1141             :     {"curvedConnector5", mso_sptCurvedConnector5},
    1142             :     {"callout1", mso_sptCallout1},
    1143             :     {"callout2", mso_sptCallout2},
    1144             :     {"callout3", mso_sptCallout3},
    1145             :     {"accentCallout1", mso_sptAccentCallout1},
    1146             :     {"accentCallout2", mso_sptAccentCallout2},
    1147             :     {"accentCallout3", mso_sptAccentCallout3},
    1148             :     {"borderCallout1", mso_sptBorderCallout1},
    1149             :     {"borderCallout2", mso_sptBorderCallout2},
    1150             :     {"borderCallout3", mso_sptBorderCallout3},
    1151             :     {"accentBorderCallout1", mso_sptAccentBorderCallout1},
    1152             :     {"accentBorderCallout2", mso_sptAccentBorderCallout2},
    1153             :     {"accentBorderCallout3", mso_sptAccentBorderCallout3},
    1154             :     {"ribbon", mso_sptRibbon},
    1155             :     {"ribbon2", mso_sptRibbon2},
    1156             :     {"chevron", mso_sptChevron},
    1157             :     {"pentagon", mso_sptPentagon},
    1158             :     {"noSmoking", mso_sptNoSmoking},
    1159             :     {"star8", mso_sptSeal8},
    1160             :     {"star16", mso_sptSeal16},
    1161             :     {"star32", mso_sptSeal32},
    1162             :     {"wedgeRectCallout", mso_sptWedgeRectCallout},
    1163             :     {"wedgeRoundRectCallout", mso_sptWedgeRRectCallout},
    1164             :     {"wedgeEllipseCallout", mso_sptWedgeEllipseCallout},
    1165             :     {"wave", mso_sptWave},
    1166             :     {"foldedCorner", mso_sptFoldedCorner},
    1167             :     {"leftArrow", mso_sptLeftArrow},
    1168             :     {"downArrow", mso_sptDownArrow},
    1169             :     {"upArrow", mso_sptUpArrow},
    1170             :     {"leftRightArrow", mso_sptLeftRightArrow},
    1171             :     {"upDownArrow", mso_sptUpDownArrow},
    1172             :     {"irregularSeal1", mso_sptIrregularSeal1},
    1173             :     {"irregularSeal2", mso_sptIrregularSeal2},
    1174             :     {"lightningBolt", mso_sptLightningBolt},
    1175             :     {"heart", mso_sptHeart},
    1176             :     {"pictureFrame", mso_sptPictureFrame},
    1177             :     {"quadArrow", mso_sptQuadArrow},
    1178             :     {"leftArrowCallout", mso_sptLeftArrowCallout},
    1179             :     {"rightArrowCallout", mso_sptRightArrowCallout},
    1180             :     {"upArrowCallout", mso_sptUpArrowCallout},
    1181             :     {"downArrowCallout", mso_sptDownArrowCallout},
    1182             :     {"leftRightArrowCallout", mso_sptLeftRightArrowCallout},
    1183             :     {"upDownArrowCallout", mso_sptUpDownArrowCallout},
    1184             :     {"quadArrowCallout", mso_sptQuadArrowCallout},
    1185             :     {"bevel", mso_sptBevel},
    1186             :     {"leftBracket", mso_sptLeftBracket},
    1187             :     {"rightBracket", mso_sptRightBracket},
    1188             :     {"leftBrace", mso_sptLeftBrace},
    1189             :     {"rightBrace", mso_sptRightBrace},
    1190             :     {"leftUpArrow", mso_sptLeftUpArrow},
    1191             :     {"bentUpArrow", mso_sptBentUpArrow},
    1192             :     {"bentArrow", mso_sptBentArrow},
    1193             :     {"star24", mso_sptSeal24},
    1194             :     {"stripedRightArrow", mso_sptStripedRightArrow},
    1195             :     {"notchedRightArrow", mso_sptNotchedRightArrow},
    1196             :     {"blockArc", mso_sptBlockArc},
    1197             :     {"smileyFace", mso_sptSmileyFace},
    1198             :     {"verticalScroll", mso_sptVerticalScroll},
    1199             :     {"horizontalScroll", mso_sptHorizontalScroll},
    1200             :     {"circularArrow", mso_sptCircularArrow},
    1201             :     {"notchedCircularArrow", mso_sptNotchedCircularArrow},
    1202             :     {"uturnArrow", mso_sptUturnArrow},
    1203             :     {"curvedRightArrow", mso_sptCurvedRightArrow},
    1204             :     {"curvedLeftArrow", mso_sptCurvedLeftArrow},
    1205             :     {"curvedUpArrow", mso_sptCurvedUpArrow},
    1206             :     {"curvedDownArrow", mso_sptCurvedDownArrow},
    1207             :     {"cloudCallout", mso_sptCloudCallout},
    1208             :     {"ellipseRibbon", mso_sptEllipseRibbon},
    1209             :     {"ellipseRibbon2", mso_sptEllipseRibbon2},
    1210             :     {"flowChartProcess", mso_sptFlowChartProcess},
    1211             :     {"flowChartDecision", mso_sptFlowChartDecision},
    1212             :     {"flowChartInputOutput", mso_sptFlowChartInputOutput},
    1213             :     {"flowChartPredefinedProcess", mso_sptFlowChartPredefinedProcess},
    1214             :     {"flowChartInternalStorage", mso_sptFlowChartInternalStorage},
    1215             :     {"flowChartDocument", mso_sptFlowChartDocument},
    1216             :     {"flowChartMultidocument", mso_sptFlowChartMultidocument},
    1217             :     {"flowChartTerminator", mso_sptFlowChartTerminator},
    1218             :     {"flowChartPreparation", mso_sptFlowChartPreparation},
    1219             :     {"flowChartManualInput", mso_sptFlowChartManualInput},
    1220             :     {"flowChartManualOperation", mso_sptFlowChartManualOperation},
    1221             :     {"flowChartConnector", mso_sptFlowChartConnector},
    1222             :     {"flowChartPunchedCard", mso_sptFlowChartPunchedCard},
    1223             :     {"flowChartPunchedTape", mso_sptFlowChartPunchedTape},
    1224             :     {"flowChartSummingJunction", mso_sptFlowChartSummingJunction},
    1225             :     {"flowChartOr", mso_sptFlowChartOr},
    1226             :     {"flowChartCollate", mso_sptFlowChartCollate},
    1227             :     {"flowChartSort", mso_sptFlowChartSort},
    1228             :     {"flowChartExtract", mso_sptFlowChartExtract},
    1229             :     {"flowChartMerge", mso_sptFlowChartMerge},
    1230             :     {"flowChartOfflineStorage", mso_sptFlowChartOfflineStorage},
    1231             :     {"flowChartOnlineStorage", mso_sptFlowChartOnlineStorage},
    1232             :     {"flowChartMagneticTape", mso_sptFlowChartMagneticTape},
    1233             :     {"flowChartMagneticDisk", mso_sptFlowChartMagneticDisk},
    1234             :     {"flowChartMagneticDrum", mso_sptFlowChartMagneticDrum},
    1235             :     {"flowChartDisplay", mso_sptFlowChartDisplay},
    1236             :     {"flowChartDelay", mso_sptFlowChartDelay},
    1237             :     {"textPlain", mso_sptTextPlainText},
    1238             :     {"textStop", mso_sptTextStop},
    1239             :     {"textTriangle", mso_sptTextTriangle},
    1240             :     {"textTriangleInverted", mso_sptTextTriangleInverted},
    1241             :     {"textChevron", mso_sptTextChevron},
    1242             :     {"textChevronInverted", mso_sptTextChevronInverted},
    1243             :     {"textRingInside", mso_sptTextRingInside},
    1244             :     {"textRingOutside", mso_sptTextRingOutside},
    1245             :     {"textArchUp", mso_sptTextArchUpCurve},
    1246             :     {"textArchDown", mso_sptTextArchDownCurve},
    1247             :     {"textCircle", mso_sptTextCircleCurve},
    1248             :     {"textButton", mso_sptTextButtonCurve},
    1249             :     {"textArchUpPour", mso_sptTextArchUpPour},
    1250             :     {"textArchDownPour", mso_sptTextArchDownPour},
    1251             :     {"textCirclePour", mso_sptTextCirclePour},
    1252             :     {"textButtonPour", mso_sptTextButtonPour},
    1253             :     {"textCurveUp", mso_sptTextCurveUp},
    1254             :     {"textCurveDown", mso_sptTextCurveDown},
    1255             :     {"textCascadeUp", mso_sptTextCascadeUp},
    1256             :     {"textCascadeDown", mso_sptTextCascadeDown},
    1257             :     {"textWave1", mso_sptTextWave1},
    1258             :     {"textWave2", mso_sptTextWave2},
    1259             :     {"textWave3", mso_sptTextWave3},
    1260             :     {"textWave4", mso_sptTextWave4},
    1261             :     {"textInflate", mso_sptTextInflate},
    1262             :     {"textDeflate", mso_sptTextDeflate},
    1263             :     {"textInflateBottom", mso_sptTextInflateBottom},
    1264             :     {"textDeflateBottom", mso_sptTextDeflateBottom},
    1265             :     {"textInflateTop", mso_sptTextInflateTop},
    1266             :     {"textDeflateTop", mso_sptTextDeflateTop},
    1267             :     {"textDeflateInflate", mso_sptTextDeflateInflate},
    1268             :     {"textDeflateInflateDeflate", mso_sptTextDeflateInflateDeflate},
    1269             :     {"textFadeRight", mso_sptTextFadeRight},
    1270             :     {"textFadeLeft", mso_sptTextFadeLeft},
    1271             :     {"textFadeUp", mso_sptTextFadeUp},
    1272             :     {"textFadeDown", mso_sptTextFadeDown},
    1273             :     {"textSlantUp", mso_sptTextSlantUp},
    1274             :     {"textSlantDown", mso_sptTextSlantDown},
    1275             :     {"textCanUp", mso_sptTextCanUp},
    1276             :     {"textCanDown", mso_sptTextCanDown},
    1277             :     {"flowChartAlternateProcess", mso_sptFlowChartAlternateProcess},
    1278             :     {"flowChartOffpageConnector", mso_sptFlowChartOffpageConnector},
    1279             :     {"callout1", mso_sptCallout90},
    1280             :     {"accentCallout1", mso_sptAccentCallout90},
    1281             :     {"borderCallout1", mso_sptBorderCallout90},
    1282             :     {"accentBorderCallout1", mso_sptAccentBorderCallout90},
    1283             :     {"leftRightUpArrow", mso_sptLeftRightUpArrow},
    1284             :     {"sun", mso_sptSun},
    1285             :     {"moon", mso_sptMoon},
    1286             :     {"bracketPair", mso_sptBracketPair},
    1287             :     {"bracePair", mso_sptBracePair},
    1288             :     {"star4", mso_sptSeal4},
    1289             :     {"doubleWave", mso_sptDoubleWave},
    1290             :     {"actionButtonBlank", mso_sptActionButtonBlank},
    1291             :     {"actionButtonHome", mso_sptActionButtonHome},
    1292             :     {"actionButtonHelp", mso_sptActionButtonHelp},
    1293             :     {"actionButtonInformation", mso_sptActionButtonInformation},
    1294             :     {"actionButtonForwardNext", mso_sptActionButtonForwardNext},
    1295             :     {"actionButtonBackPrevious", mso_sptActionButtonBackPrevious},
    1296             :     {"actionButtonEnd", mso_sptActionButtonEnd},
    1297             :     {"actionButtonBeginning", mso_sptActionButtonBeginning},
    1298             :     {"actionButtonReturn", mso_sptActionButtonReturn},
    1299             :     {"actionButtonDocument", mso_sptActionButtonDocument},
    1300             :     {"actionButtonSound", mso_sptActionButtonSound},
    1301             :     {"actionButtonMovie", mso_sptActionButtonMovie},
    1302             :     {"hostControl", mso_sptHostControl},
    1303             :     {"textBox", mso_sptTextBox},
    1304             : };
    1305             : 
    1306             : typedef std::unordered_map< const char*, const char*, rtl::CStringHash, rtl::CStringEqual> CustomShapeTypeTranslationHashMap;
    1307             : static CustomShapeTypeTranslationHashMap* pCustomShapeTypeTranslationHashMap = NULL;
    1308             : 
    1309         805 : const char* GetOOXMLPresetGeometry( const char* sShapeType )
    1310             : {
    1311         805 :     if( pCustomShapeTypeTranslationHashMap == NULL )
    1312             :     {
    1313          14 :         pCustomShapeTypeTranslationHashMap = new CustomShapeTypeTranslationHashMap ();
    1314        4858 :         for( unsigned int i = 0; i < SAL_N_ELEMENTS(pCustomShapeTypeTranslationTable); ++i )
    1315             :         {
    1316        4844 :             (*pCustomShapeTypeTranslationHashMap)[ pCustomShapeTypeTranslationTable[ i ].sOOo ] = pCustomShapeTypeTranslationTable[ i ].sMSO;
    1317             :         }
    1318             :     }
    1319             :     CustomShapeTypeTranslationHashMap::iterator i(
    1320         805 :         pCustomShapeTypeTranslationHashMap->find(sShapeType));
    1321         805 :     return i == pCustomShapeTypeTranslationHashMap->end() ? "rect" : i->second;
    1322             : }
    1323             : 
    1324             : typedef std::unordered_map< const char*, MSO_SPT, rtl::CStringHash, rtl::CStringEqual> DMLToVMLTranslationHashMap;
    1325             : static DMLToVMLTranslationHashMap* pDMLToVMLMap;
    1326             : 
    1327         392 : MSO_SPT GETVMLShapeType(const OString& aType)
    1328             : {
    1329         392 :     const char* pDML = GetOOXMLPresetGeometry(aType.getStr());
    1330             : 
    1331         392 :     if (!pDMLToVMLMap)
    1332             :     {
    1333          11 :         pDMLToVMLMap = new DMLToVMLTranslationHashMap();
    1334        2244 :         for (size_t i = 0; i < SAL_N_ELEMENTS(pDMLToVMLTable); ++i)
    1335        2233 :             (*pDMLToVMLMap)[pDMLToVMLTable[i].sDML] = pDMLToVMLTable[i].nVML;
    1336             :     }
    1337             : 
    1338         392 :     DMLToVMLTranslationHashMap::iterator i(pDMLToVMLMap->find(pDML));
    1339         392 :     return i == pDMLToVMLMap->end() ? mso_sptNil : i->second;
    1340             : }
    1341             : 
    1342        1034 : bool HasTextBoxContent(sal_uInt32 nShapeType)
    1343             : {
    1344        1034 :     switch (nShapeType)
    1345             :     {
    1346             :     case ESCHER_ShpInst_TextPlainText:
    1347             :     case ESCHER_ShpInst_TextSlantUp:
    1348             :     case ESCHER_ShpInst_TextDeflateInflateDeflate:
    1349          22 :         return false;
    1350             :     default:
    1351        1012 :         return true;
    1352             :     }
    1353             : }
    1354             : 
    1355         653 : sal_uInt8 TransColToIco( const Color& rCol )
    1356             : {
    1357         653 :     sal_uInt8 nCol = 0;      // ->Auto
    1358         653 :     switch( rCol.GetColor() )
    1359             :     {
    1360         235 :     case COL_BLACK:         nCol = 1;   break;
    1361          11 :     case COL_BLUE:          nCol = 9;   break;
    1362           6 :     case COL_GREEN:         nCol = 11;  break;
    1363           6 :     case COL_CYAN:          nCol = 10;  break;
    1364           6 :     case COL_RED:           nCol = 13;  break;
    1365           6 :     case COL_MAGENTA:       nCol = 12;  break;
    1366           6 :     case COL_BROWN:         nCol = 14;  break;
    1367           6 :     case COL_GRAY:          nCol = 15;  break;
    1368           6 :     case COL_LIGHTGRAY:     nCol = 16;  break;
    1369           9 :     case COL_LIGHTBLUE:     nCol = 2;   break;
    1370           9 :     case COL_LIGHTGREEN:    nCol = 4;   break;
    1371           9 :     case COL_LIGHTCYAN:     nCol = 3;   break;
    1372          16 :     case COL_LIGHTRED:      nCol = 6;   break;
    1373           9 :     case COL_LIGHTMAGENTA:  nCol = 5;   break;
    1374          25 :     case COL_YELLOW:        nCol = 7;   break;
    1375          45 :     case COL_WHITE:         nCol = 8;   break;
    1376          76 :     case COL_AUTO:          nCol = 0;   break;
    1377             : 
    1378             :     default:
    1379             :         static const ColorData aColArr[ 16 ] = {
    1380             :             COL_BLACK,      COL_LIGHTBLUE,  COL_LIGHTCYAN,  COL_LIGHTGREEN,
    1381             :             COL_LIGHTMAGENTA,COL_LIGHTRED,  COL_YELLOW,     COL_WHITE,
    1382             :             COL_BLUE,       COL_CYAN,       COL_GREEN,      COL_MAGENTA,
    1383             :             COL_RED,        COL_BROWN,      COL_GRAY,       COL_LIGHTGRAY
    1384             :         };
    1385         167 :         BitmapPalette aBmpPal(16);
    1386        2839 :         for( sal_uInt16 i = 0; i < 16; ++i )
    1387        2672 :             aBmpPal[i] = Color( aColArr[ i ] );
    1388             : 
    1389         167 :         nCol = static_cast< sal_uInt8 >(aBmpPal.GetBestIndex( rCol ) + 1);
    1390         167 :         break;
    1391             :     }
    1392         653 :     return nCol;
    1393             : }
    1394             : 
    1395             : }
    1396             : }
    1397             : 
    1398             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11