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 OOX_OLE_OLEHELPER_HXX 25 #define OOX_OLE_OLEHELPER_HXX 26 27 #include <rtl/ustring.hxx> 28 #include "oox/helper/binarystreambase.hxx" 29 30 namespace oox { 31 class BinaryInputStream; 32 class GraphicHelper; 33 } 34 35 namespace oox { 36 namespace ole { 37 38 // ============================================================================ 39 40 const sal_Char* const OLE_GUID_STDFONT = "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"; 41 const sal_Char* const OLE_GUID_STDPIC = "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"; 42 const sal_Char* const OLE_GUID_STDHLINK = "{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}"; 43 44 // ============================================================================ 45 46 const sal_uInt16 OLE_STDFONT_NORMAL = 400; 47 const sal_uInt16 OLE_STDFONT_BOLD = 700; 48 49 const sal_uInt8 OLE_STDFONT_ITALIC = 0x02; 50 const sal_uInt8 OLE_STDFONT_UNDERLINE = 0x04; 51 const sal_uInt8 OLE_STDFONT_STRIKE = 0x08; 52 53 /** Stores data about a StdFont font structure. */ 54 struct StdFontInfo 55 { 56 ::rtl::OUString maName; /// Font name. 57 sal_uInt32 mnHeight; /// Font height (1/10,000 points). 58 sal_uInt16 mnWeight; /// Font weight (normal/bold). 59 sal_uInt16 mnCharSet; /// Font charset. 60 sal_uInt8 mnFlags; /// Font flags. 61 62 explicit StdFontInfo(); 63 explicit StdFontInfo( 64 const ::rtl::OUString& rName, 65 sal_uInt32 nHeight, 66 sal_uInt16 nWeight = OLE_STDFONT_NORMAL, 67 sal_uInt16 nCharSet = WINDOWS_CHARSET_ANSI, 68 sal_uInt8 nFlags = 0 ); 69 }; 70 71 // ============================================================================ 72 73 /** Stores data about a StdHlink hyperlink. */ 74 struct StdHlinkInfo 75 { 76 ::rtl::OUString maTarget; 77 ::rtl::OUString maLocation; 78 ::rtl::OUString maDisplay; 79 ::rtl::OUString maFrame; 80 }; 81 82 // ============================================================================ 83 84 /** Static helper functions for OLE import/export. */ 85 class OleHelper 86 { 87 public: 88 /** Returns the UNO RGB color from the passed encoded OLE color. 89 90 @param bDefaultColorBgr 91 True = OLE default color type is treated as BGR color. 92 False = OLE default color type is treated as palette color. 93 */ 94 static sal_Int32 decodeOleColor( 95 const GraphicHelper& rGraphicHelper, 96 sal_uInt32 nOleColor, 97 bool bDefaultColorBgr = true ); 98 99 /** Returns the OLE color from the passed UNO RGB color. 100 */ 101 static sal_uInt32 encodeOleColor( sal_Int32 nRgbColor ); 102 103 /** Imports a GUID from the passed binary stream and returns its string 104 representation (in uppercase characters). 105 */ 106 static ::rtl::OUString importGuid( BinaryInputStream& rInStrm ); 107 108 /** Imports an OLE StdFont font structure from the current position of the 109 passed binary stream. 110 */ 111 static bool importStdFont( 112 StdFontInfo& orFontInfo, 113 BinaryInputStream& rInStrm, 114 bool bWithGuid ); 115 116 /** Imports an OLE StdPic picture from the current position of the passed 117 binary stream. 118 */ 119 static bool importStdPic( 120 StreamDataSequence& orGraphicData, 121 BinaryInputStream& rInStrm, 122 bool bWithGuid ); 123 124 /** Imports an OLE StdHlink from the current position of the passed binary 125 stream. 126 */ 127 static bool importStdHlink( 128 StdHlinkInfo& orHlinkInfo, 129 BinaryInputStream& rInStrm, 130 bool bWithGuid ); 131 132 private: 133 OleHelper(); // not implemented 134 ~OleHelper(); // not implemented 135 }; 136 137 // ============================================================================ 138 139 } // namespace ole 140 } // namespace oox 141 142 #endif 143