xref: /aoo41x/main/oox/inc/oox/ole/olehelper.hxx (revision cdf0e10c)
1  /*************************************************************************
2   *
3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4   *
5   * Copyright 2000, 2010 Oracle and/or its affiliates.
6   *
7   * OpenOffice.org - a multi-platform office productivity suite
8   *
9   * This file is part of OpenOffice.org.
10   *
11   * OpenOffice.org is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Lesser General Public License version 3
13   * only, as published by the Free Software Foundation.
14   *
15   * OpenOffice.org is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   * GNU Lesser General Public License version 3 for more details
19   * (a copy is included in the LICENSE file that accompanied this code).
20   *
21   * You should have received a copy of the GNU Lesser General Public License
22   * version 3 along with OpenOffice.org.  If not, see
23   * <http://www.openoffice.org/license.html>
24   * for a copy of the LGPLv3 License.
25   *
26   ************************************************************************/
27  
28  #ifndef OOX_OLE_OLEHELPER_HXX
29  #define OOX_OLE_OLEHELPER_HXX
30  
31  #include <rtl/ustring.hxx>
32  #include "oox/helper/binarystreambase.hxx"
33  
34  namespace oox {
35      class BinaryInputStream;
36      class GraphicHelper;
37  }
38  
39  namespace oox {
40  namespace ole {
41  
42  // ============================================================================
43  
44  const sal_Char* const OLE_GUID_STDFONT      = "{0BE35203-8F91-11CE-9DE3-00AA004BB851}";
45  const sal_Char* const OLE_GUID_STDPIC       = "{0BE35204-8F91-11CE-9DE3-00AA004BB851}";
46  const sal_Char* const OLE_GUID_STDHLINK     = "{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}";
47  
48  // ============================================================================
49  
50  const sal_uInt16 OLE_STDFONT_NORMAL     = 400;
51  const sal_uInt16 OLE_STDFONT_BOLD       = 700;
52  
53  const sal_uInt8 OLE_STDFONT_ITALIC      = 0x02;
54  const sal_uInt8 OLE_STDFONT_UNDERLINE   = 0x04;
55  const sal_uInt8 OLE_STDFONT_STRIKE      = 0x08;
56  
57  /** Stores data about a StdFont font structure. */
58  struct StdFontInfo
59  {
60      ::rtl::OUString     maName;         /// Font name.
61      sal_uInt32          mnHeight;       /// Font height (1/10,000 points).
62      sal_uInt16          mnWeight;       /// Font weight (normal/bold).
63      sal_uInt16          mnCharSet;      /// Font charset.
64      sal_uInt8           mnFlags;        /// Font flags.
65  
66      explicit            StdFontInfo();
67      explicit            StdFontInfo(
68                              const ::rtl::OUString& rName,
69                              sal_uInt32 nHeight,
70                              sal_uInt16 nWeight = OLE_STDFONT_NORMAL,
71                              sal_uInt16 nCharSet = WINDOWS_CHARSET_ANSI,
72                              sal_uInt8 nFlags = 0 );
73  };
74  
75  // ============================================================================
76  
77  /** Stores data about a StdHlink hyperlink. */
78  struct StdHlinkInfo
79  {
80      ::rtl::OUString     maTarget;
81      ::rtl::OUString     maLocation;
82      ::rtl::OUString     maDisplay;
83      ::rtl::OUString     maFrame;
84  };
85  
86  // ============================================================================
87  
88  /** Static helper functions for OLE import/export. */
89  class OleHelper
90  {
91  public:
92      /** Returns the UNO RGB color from the passed encoded OLE color.
93  
94          @param bDefaultColorBgr
95              True = OLE default color type is treated as BGR color.
96              False = OLE default color type is treated as palette color.
97       */
98      static sal_Int32    decodeOleColor(
99                              const GraphicHelper& rGraphicHelper,
100                              sal_uInt32 nOleColor,
101                              bool bDefaultColorBgr = true );
102  
103      /** Returns the OLE color from the passed UNO RGB color.
104       */
105      static sal_uInt32   encodeOleColor( sal_Int32 nRgbColor );
106  
107      /** Imports a GUID from the passed binary stream and returns its string
108          representation (in uppercase characters).
109       */
110      static ::rtl::OUString importGuid( BinaryInputStream& rInStrm );
111  
112      /** Imports an OLE StdFont font structure from the current position of the
113          passed binary stream.
114       */
115      static bool         importStdFont(
116                              StdFontInfo& orFontInfo,
117                              BinaryInputStream& rInStrm,
118                              bool bWithGuid );
119  
120      /** Imports an OLE StdPic picture from the current position of the passed
121          binary stream.
122       */
123      static bool         importStdPic(
124                              StreamDataSequence& orGraphicData,
125                              BinaryInputStream& rInStrm,
126                              bool bWithGuid );
127  
128      /** Imports an OLE StdHlink from the current position of the passed binary
129          stream.
130       */
131      static bool         importStdHlink(
132                              StdHlinkInfo& orHlinkInfo,
133                              BinaryInputStream& rInStrm,
134                              bool bWithGuid );
135  
136  private:
137                          OleHelper();        // not implemented
138                          ~OleHelper();       // not implemented
139  };
140  
141  // ============================================================================
142  
143  } // namespace ole
144  } // namespace oox
145  
146  #endif
147