Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / oox / ole / olehelper.hxx
bloba0fe764e19c55e02e38828bec39d0d3e58460600
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 );
84 /** Stores data about a StdHlink hyperlink. */
85 struct StdHlinkInfo
87 OUString maTarget;
88 OUString maLocation;
89 OUString maDisplay;
93 /** Static helper functions for OLE import/export. */
94 namespace OleHelper
96 /** Returns the UNO RGB color from the passed encoded OLE color.
98 @param bDefaultColorBgr
99 True = OLE default color type is treated as BGR color.
100 False = OLE default color type is treated as palette color.
102 OOX_DLLPUBLIC sal_Int32 decodeOleColor(
103 const GraphicHelper& rGraphicHelper,
104 sal_uInt32 nOleColor,
105 bool bDefaultColorBgr );
107 /** Returns the OLE color from the passed UNO RGB color.
109 OOX_DLLPUBLIC sal_uInt32 encodeOleColor( sal_Int32 nRgbColor );
111 /** Imports a GUID from the passed binary stream and returns its string
112 representation (in uppercase characters).
114 OOX_DLLPUBLIC OUString importGuid( BinaryInputStream& rInStrm );
115 OOX_DLLPUBLIC void exportGuid( BinaryOutputStream& rOutStrm, const SvGlobalName& rId );
117 /** Imports an OLE StdFont font structure from the current position of the
118 passed binary stream.
120 OOX_DLLPUBLIC bool importStdFont(
121 StdFontInfo& orFontInfo,
122 BinaryInputStream& rInStrm,
123 bool bWithGuid );
125 /** Imports an OLE StdPic picture from the current position of the passed
126 binary stream.
128 OOX_DLLPUBLIC bool importStdPic(
129 StreamDataSequence& orGraphicData,
130 BinaryInputStream& rInStrm,
131 bool bWithGuid );
134 // ideally it would be great to get rid of SvxMSConvertOCXControls
135 // however msfilter/source/msfilter/svdfppt.cxx still uses
136 // SvxMSConvertOCXControls as a base class, unfortunately oox depends on
137 // msfilter. Probably the solution would be to move the svdfppt.cxx
138 // implementation into the sd module itself.
139 class OOX_DLLPUBLIC MSConvertOCXControls : public SvxMSConvertOCXControls
141 protected:
142 css::uno::Reference< css::uno::XComponentContext > mxCtx;
143 ::oox::GraphicHelper maGrfHelper;
145 bool importControlFromStream( ::oox::BinaryInputStream& rInStrm,
146 css::uno::Reference< css::form::XFormComponent > & rxFormComp,
147 const OUString& rGuidString );
148 bool importControlFromStream( ::oox::BinaryInputStream& rInStrm,
149 css::uno::Reference< css::form::XFormComponent > & rxFormComp,
150 const OUString& rGuidString,
151 sal_Int32 nSize );
152 public:
153 MSConvertOCXControls( const css::uno::Reference< css::frame::XModel >& rxModel );
154 virtual ~MSConvertOCXControls() override;
155 bool ReadOCXStorage( tools::SvRef<SotStorage>& rSrc1, css::uno::Reference< css::form::XFormComponent > & rxFormComp );
156 bool ReadOCXCtlsStream(tools::SvRef<SotStorageStream>& rSrc1, css::uno::Reference< css::form::XFormComponent > & rxFormComp,
157 sal_Int32 nPos, sal_Int32 nSize );
158 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);
159 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);
163 } // namespace ole
164 } // namespace oox
166 #endif
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */