Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / oox / ole / olehelper.hxx
bloba2810460bcd333ef3bb2869244898f4f900fa729
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 <rtl/ustring.hxx>
29 #include <sal/types.h>
30 #include <tools/ref.hxx>
31 #include <memory>
33 namespace com::sun::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; }
42 class SotStorage;
43 class SotStorageStream;
44 class SvGlobalName;
46 namespace oox {
47 class BinaryInputStream;
48 class BinaryOutputStream;
51 namespace oox::ole {
52 class ControlModelBase;
53 class EmbeddedControl;
56 #define OLE_GUID_STDFONT "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"
57 #define OLE_GUID_STDPIC "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"
60 const sal_uInt16 OLE_STDFONT_NORMAL = 400;
61 const sal_uInt16 OLE_STDFONT_BOLD = 700;
63 const sal_uInt8 OLE_STDFONT_ITALIC = 0x02;
64 const sal_uInt8 OLE_STDFONT_UNDERLINE = 0x04;
65 const sal_uInt8 OLE_STDFONT_STRIKE = 0x08;
67 /** Stores data about a StdFont font structure. */
68 struct StdFontInfo
70 OUString maName; ///< Font name.
71 sal_uInt32 mnHeight; ///< Font height (1/10,000 points).
72 sal_uInt16 mnWeight; ///< Font weight (normal/bold).
73 sal_uInt16 mnCharSet; ///< Font charset.
74 sal_uInt8 mnFlags; ///< Font flags.
76 explicit StdFontInfo();
77 explicit StdFontInfo(
78 OUString aName,
79 sal_uInt32 nHeight );
83 /** Stores data about a StdHlink hyperlink. */
84 struct StdHlinkInfo
86 OUString maTarget;
87 OUString maLocation;
88 OUString maDisplay;
92 /** Static helper functions for OLE import/export. */
93 namespace OleHelper
95 /** Returns the UNO RGB color from the passed encoded OLE color.
97 @param bDefaultColorBgr
98 True = OLE default color type is treated as BGR color.
99 False = OLE default color type is treated as palette color.
101 OOX_DLLPUBLIC ::Color decodeOleColor(
102 const GraphicHelper& rGraphicHelper,
103 sal_uInt32 nOleColor,
104 bool bDefaultColorBgr );
106 /** Returns the OLE color from the passed UNO RGB color.
108 OOX_DLLPUBLIC sal_uInt32 encodeOleColor( sal_Int32 nRgbColor );
109 inline sal_uInt32 encodeOleColor( Color nRgbColor ) { return 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 );
133 class OOX_DLLPUBLIC OleFormCtrlExportHelper final
135 std::unique_ptr<::oox::ole::EmbeddedControl> mpControl;
136 ::oox::ole::ControlModelBase* mpModel;
137 ::oox::GraphicHelper maGrfHelper;
138 css::uno::Reference< css::frame::XModel > mxDocModel;
139 css::uno::Reference< css::awt::XControlModel > mxControlModel;
141 OUString maName;
142 OUString maTypeName;
143 OUString maFullName;
144 OUString maGUID;
145 public:
146 OleFormCtrlExportHelper( const css::uno::Reference< css::uno::XComponentContext >& rxCtx, const css::uno::Reference< css::frame::XModel >& xDocModel, const css::uno::Reference< css::awt::XControlModel >& xModel );
147 ~OleFormCtrlExportHelper();
149 std::u16string_view getGUID() const
151 std::u16string_view sResult;
152 if ( maGUID.getLength() > 2 )
153 sResult = maGUID.subView(1, maGUID.getLength() - 2 );
154 return sResult;
156 const OUString& getFullName() const { return maFullName; }
157 const OUString& getTypeName() const { return maTypeName; }
158 const OUString& getName() const { return maName; }
159 bool isValid() const { return mpModel != nullptr; }
160 void exportName( const css::uno::Reference< css::io::XOutputStream >& rxOut );
161 void exportCompObj( const css::uno::Reference< css::io::XOutputStream >& rxOut );
162 void exportControl( const css::uno::Reference< css::io::XOutputStream >& rxOut, const css::awt::Size& rSize, bool bAutoClose = false );
165 // ideally it would be great to get rid of SvxMSConvertOCXControls
166 // however msfilter/source/msfilter/svdfppt.cxx still uses
167 // SvxMSConvertOCXControls as a base class, unfortunately oox depends on
168 // msfilter. Probably the solution would be to move the svdfppt.cxx
169 // implementation into the sd module itself.
170 class OOX_DLLPUBLIC MSConvertOCXControls : public SvxMSConvertOCXControls
172 css::uno::Reference< css::uno::XComponentContext > mxCtx;
173 ::oox::GraphicHelper maGrfHelper;
175 protected:
176 bool importControlFromStream( ::oox::BinaryInputStream& rInStrm,
177 css::uno::Reference< css::form::XFormComponent > & rxFormComp,
178 std::u16string_view rGuidString );
179 bool importControlFromStream( ::oox::BinaryInputStream& rInStrm,
180 css::uno::Reference< css::form::XFormComponent > & rxFormComp,
181 const OUString& rGuidString,
182 sal_Int32 nSize );
183 public:
184 MSConvertOCXControls( const css::uno::Reference< css::frame::XModel >& rxModel );
185 virtual ~MSConvertOCXControls() override;
186 bool ReadOCXStorage( tools::SvRef<SotStorage> const & rSrc1, css::uno::Reference< css::form::XFormComponent > & rxFormComp );
187 bool ReadOCXCtlsStream(tools::SvRef<SotStorageStream> const & rSrc1, css::uno::Reference< css::form::XFormComponent > & rxFormComp,
188 sal_Int32 nPos, sal_Int32 nSize );
189 static bool WriteOCXStream( const css::uno::Reference< css::frame::XModel >& rxModel, tools::SvRef<SotStorage> const &rSrc1, const css::uno::Reference< css::awt::XControlModel > &rControlModel, const css::awt::Size& rSize,OUString &rName);
190 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);
194 } // namespace oox::ole
196 #endif
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */