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 #ifndef _UNOTOOLS_FONTCVT_HXX 25 #define _UNOTOOLS_FONTCVT_HXX 26 27 #include <unotools/unotoolsdllapi.h> 28 #include <tools/string.hxx> 29 30 // ------------------ 31 // - FontToSubsFont - 32 // ------------------ 33 34 #define FONTTOSUBSFONT_IMPORT ((sal_uLong)0x00000001) 35 #define FONTTOSUBSFONT_EXPORT ((sal_uLong)0x00000002) 36 #define FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ((sal_uLong)0x00000004) 37 38 typedef void* FontToSubsFontConverter; 39 UNOTOOLS_DLLPUBLIC FontToSubsFontConverter CreateFontToSubsFontConverter( const String& rFontName, sal_uLong nFlags ); 40 UNOTOOLS_DLLPUBLIC void DestroyFontToSubsFontConverter( FontToSubsFontConverter hConverter ); 41 UNOTOOLS_DLLPUBLIC sal_Unicode ConvertFontToSubsFontChar( FontToSubsFontConverter hConverter, sal_Unicode c ); 42 UNOTOOLS_DLLPUBLIC String GetFontToSubsFontName( FontToSubsFontConverter hConverter ); 43 44 // --------------------------- 45 // - StarSymbolToMSMultiFont - 46 // --------------------------- 47 48 class UNOTOOLS_DLLPUBLIC StarSymbolToMSMultiFont 49 { 50 public: 51 //Returns the name of the best windows symbol font which this char can be 52 //mapped to. Sets rChar to the correct position for that font. If no 53 //match found, then no name is returned, and rChar is unchanged. If you 54 //want to convert a string, you don't want to use this. 55 virtual String ConvertChar(sal_Unicode &rChar) = 0; 56 57 //Starts converting the string at position rIndex. It converts as much of 58 //the string that can be converted to the same symbol font and returns the 59 //name of that font. rIndex is modified to the last index that was 60 //converted. Typically you call if continously until rIndex == 61 //rString.Len() and handle each section as seperate 8bit strings using 62 //seperate fonts. Will return an empty string for a continous section 63 //that has no possible mapping. 64 virtual String ConvertString(String &rString, xub_StrLen &rIndex) = 0; ~StarSymbolToMSMultiFont()65 virtual ~StarSymbolToMSMultiFont() {} 66 }; 67 68 //with bPerfect set the converter will only try and convert symbols which have 69 //perfect mappings to the windows symbols fonts. With it not set, it will 70 //allow somewhat more dubious transformations that are nevertheless 71 //recognizably similiar. Even in this mode there will be characters that fail. 72 //The users of this might want to make a distinction between failed characters 73 //which were inside and those outside the unicode private area. 74 UNOTOOLS_DLLPUBLIC StarSymbolToMSMultiFont *CreateStarSymbolToMSMultiFont(bool bPerfectOnly=false); 75 #endif // _UNOTOOLS_FONTCVT_HXX 76