Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / oox / ole / olehelper.hxx
blobd848cc492fcbbfe9e8b65c46f9d62575b4d8b21d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_OOX_OLE_OLEHELPER_HXX
21 #define INCLUDED_OOX_OLE_OLEHELPER_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <filter/msfilter/msocximex.hxx>
25 #include <oox/dllapi.h>
26 #include <oox/helper/binarystreambase.hxx>
27 #include <oox/helper/graphichelper.hxx>
28 #include <oox/helper/helper.hxx>
29 #include <rtl/ustring.hxx>
30 #include <sal/types.h>
31 #include <tools/ref.hxx>
33 namespace com { namespace sun { namespace star {
34 namespace awt { class XControlModel; }
35 namespace awt { struct Size; }
36 namespace form { class XFormComponent; }
37 namespace frame { class XModel; }
38 namespace io { class XOutputStream; }
39 namespace uno { class XComponentContext; }
40 } } }
42 class SotStorage;
43 class SotStorageStream;
44 class SvGlobalName;
46 namespace oox {
47 class BinaryInputStream;
48 class BinaryOutputStream;
51 namespace oox {
54 namespace ole {
57 #define OLE_GUID_STDFONT "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"
58 #define OLE_GUID_STDPIC "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"
61 const sal_uInt16 OLE_STDFONT_NORMAL = 400;
62 const sal_uInt16 OLE_STDFONT_BOLD = 700;
64 const sal_uInt8 OLE_STDFONT_ITALIC = 0x02;
65 const sal_uInt8 OLE_STDFONT_UNDERLINE = 0x04;
66 const sal_uInt8 OLE_STDFONT_STRIKE = 0x08;
68 /** Stores data about a StdFont font structure. */
69 struct StdFontInfo
71 OUString maName; ///< Font name.
72 sal_uInt32 mnHeight; ///< Font height (1/10,000 points).
73 sal_uInt16 mnWeight; ///< Font weight (normal/bold).
74 sal_uInt16 mnCharSet; ///< Font charset.
75 sal_uInt8 mnFlags; ///< Font flags.
77 explicit StdFontInfo();
78 explicit StdFontInfo(
79 const OUString& rName,
80 sal_uInt32 nHeight,
81 sal_uInt16 nWeight = OLE_STDFONT_NORMAL,
82 sal_uInt16 nCharSet = WINDOWS_CHARSET_ANSI,
83 sal_uInt8 nFlags = 0 );
87 /** Stores data about a StdHlink hyperlink. */
88 struct StdHlinkInfo
90 OUString maTarget;
91 OUString maLocation;
92 OUString maDisplay;
96 /** Static helper functions for OLE import/export. */
97 namespace OleHelper
99 /** Returns the UNO RGB color from the passed encoded OLE color.
101 @param bDefaultColorBgr
102 True = OLE default color type is treated as BGR color.
103 False = OLE default color type is treated as palette color.
105 OOX_DLLPUBLIC sal_Int32 decodeOleColor(
106 const GraphicHelper& rGraphicHelper,
107 sal_uInt32 nOleColor,
108 bool bDefaultColorBgr = true );
110 /** Returns the OLE color from the passed UNO RGB color.
112 OOX_DLLPUBLIC sal_uInt32 encodeOleColor( sal_Int32 nRgbColor );
114 /** Imports a GUID from the passed binary stream and returns its string
115 representation (in uppercase characters).
117 OOX_DLLPUBLIC OUString importGuid( BinaryInputStream& rInStrm );
118 OOX_DLLPUBLIC void exportGuid( BinaryOutputStream& rOutStrm, const SvGlobalName& rId );
120 /** Imports an OLE StdFont font structure from the current position of the
121 passed binary stream.
123 OOX_DLLPUBLIC bool importStdFont(
124 StdFontInfo& orFontInfo,
125 BinaryInputStream& rInStrm,
126 bool bWithGuid );
128 /** Imports an OLE StdPic picture from the current position of the passed
129 binary stream.
131 OOX_DLLPUBLIC bool importStdPic(
132 StreamDataSequence& orGraphicData,
133 BinaryInputStream& rInStrm,
134 bool bWithGuid );
137 // ideally it would be great to get rid of SvxMSConvertOCXControls
138 // however msfilter/source/msfilter/svdfppt.cxx still uses
139 // SvxMSConvertOCXControls as a base class, unfortunately oox depends on
140 // msfilter. Probably the solution would be to move the svdfppt.cxx
141 // implementation into the sd module itself.
142 class OOX_DLLPUBLIC MSConvertOCXControls : public SvxMSConvertOCXControls
144 protected:
145 css::uno::Reference< css::uno::XComponentContext > mxCtx;
146 ::oox::GraphicHelper maGrfHelper;
148 bool importControlFromStream( ::oox::BinaryInputStream& rInStrm,
149 css::uno::Reference< css::form::XFormComponent > & rxFormComp,
150 const OUString& rGuidString );
151 bool importControlFromStream( ::oox::BinaryInputStream& rInStrm,
152 css::uno::Reference< css::form::XFormComponent > & rxFormComp,
153 const OUString& rGuidString,
154 sal_Int32 nSize );
155 public:
156 MSConvertOCXControls( const css::uno::Reference< css::frame::XModel >& rxModel );
157 virtual ~MSConvertOCXControls();
158 bool ReadOCXStorage( tools::SvRef<SotStorage>& rSrc1, css::uno::Reference< css::form::XFormComponent > & rxFormComp );
159 bool ReadOCXCtlsStream(tools::SvRef<SotStorageStream>& rSrc1, css::uno::Reference< css::form::XFormComponent > & rxFormComp,
160 sal_Int32 nPos, sal_Int32 nSize );
161 static bool WriteOCXStream( const css::uno::Reference< css::frame::XModel >& rxModel, tools::SvRef<SotStorage> &rSrc1, const css::uno::Reference< css::awt::XControlModel > &rControlModel, const css::awt::Size& rSize,OUString &rName);
162 static bool WriteOCXExcelKludgeStream( const css::uno::Reference< css::frame::XModel >& rxModel, const css::uno::Reference< css::io::XOutputStream >& xOutStrm, const css::uno::Reference< css::awt::XControlModel > &rControlModel, const css::awt::Size& rSize,OUString &rName);
166 } // namespace ole
167 } // namespace oox
169 #endif
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */