1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
; }
43 class SotStorageStream
;
47 class BinaryInputStream
;
48 class BinaryOutputStream
;
55 class ControlModelBase
;
56 class EmbeddedControl
;
59 #define OLE_GUID_STDFONT "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"
60 #define OLE_GUID_STDPIC "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"
63 const sal_uInt16 OLE_STDFONT_NORMAL
= 400;
64 const sal_uInt16 OLE_STDFONT_BOLD
= 700;
66 const sal_uInt8 OLE_STDFONT_ITALIC
= 0x02;
67 const sal_uInt8 OLE_STDFONT_UNDERLINE
= 0x04;
68 const sal_uInt8 OLE_STDFONT_STRIKE
= 0x08;
70 /** Stores data about a StdFont font structure. */
73 OUString maName
; ///< Font name.
74 sal_uInt32 mnHeight
; ///< Font height (1/10,000 points).
75 sal_uInt16 mnWeight
; ///< Font weight (normal/bold).
76 sal_uInt16 mnCharSet
; ///< Font charset.
77 sal_uInt8 mnFlags
; ///< Font flags.
79 explicit StdFontInfo();
81 const OUString
& rName
,
86 /** Stores data about a StdHlink hyperlink. */
95 /** Static helper functions for OLE import/export. */
98 /** Returns the UNO RGB color from the passed encoded OLE color.
100 @param bDefaultColorBgr
101 True = OLE default color type is treated as BGR color.
102 False = OLE default color type is treated as palette color.
104 OOX_DLLPUBLIC ::Color
decodeOleColor(
105 const GraphicHelper
& rGraphicHelper
,
106 sal_uInt32 nOleColor
,
107 bool bDefaultColorBgr
);
109 /** Returns the OLE color from the passed UNO RGB color.
111 OOX_DLLPUBLIC sal_uInt32
encodeOleColor( sal_Int32 nRgbColor
);
112 inline sal_uInt32
encodeOleColor( Color nRgbColor
) { return 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
,
128 /** Imports an OLE StdPic picture from the current position of the passed
131 OOX_DLLPUBLIC
bool importStdPic(
132 StreamDataSequence
& orGraphicData
,
133 BinaryInputStream
& rInStrm
);
136 class OOX_DLLPUBLIC OleFormCtrlExportHelper final
138 std::unique_ptr
<::oox::ole::EmbeddedControl
> mpControl
;
139 ::oox::ole::ControlModelBase
* mpModel
;
140 ::oox::GraphicHelper
const maGrfHelper
;
141 css::uno::Reference
< css::frame::XModel
> mxDocModel
;
142 css::uno::Reference
< css::awt::XControlModel
> mxControlModel
;
149 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
);
150 ~OleFormCtrlExportHelper();
152 OUString
getGUID() const
155 if ( maGUID
.getLength() > 2 )
156 sResult
= maGUID
.copy(1, maGUID
.getLength() - 2 );
159 const OUString
& getFullName() const { return maFullName
; }
160 const OUString
& getTypeName() const { return maTypeName
; }
161 const OUString
& getName() const { return maName
; }
162 bool isValid() const { return mpModel
!= nullptr; }
163 void exportName( const css::uno::Reference
< css::io::XOutputStream
>& rxOut
);
164 void exportCompObj( const css::uno::Reference
< css::io::XOutputStream
>& rxOut
);
165 void exportControl( const css::uno::Reference
< css::io::XOutputStream
>& rxOut
, const css::awt::Size
& rSize
, bool bAutoClose
= false );
168 // ideally it would be great to get rid of SvxMSConvertOCXControls
169 // however msfilter/source/msfilter/svdfppt.cxx still uses
170 // SvxMSConvertOCXControls as a base class, unfortunately oox depends on
171 // msfilter. Probably the solution would be to move the svdfppt.cxx
172 // implementation into the sd module itself.
173 class OOX_DLLPUBLIC MSConvertOCXControls
: public SvxMSConvertOCXControls
176 css::uno::Reference
< css::uno::XComponentContext
> mxCtx
;
177 ::oox::GraphicHelper
const maGrfHelper
;
179 bool importControlFromStream( ::oox::BinaryInputStream
& rInStrm
,
180 css::uno::Reference
< css::form::XFormComponent
> & rxFormComp
,
181 const OUString
& rGuidString
);
182 bool importControlFromStream( ::oox::BinaryInputStream
& rInStrm
,
183 css::uno::Reference
< css::form::XFormComponent
> & rxFormComp
,
184 const OUString
& rGuidString
,
187 MSConvertOCXControls( const css::uno::Reference
< css::frame::XModel
>& rxModel
);
188 virtual ~MSConvertOCXControls() override
;
189 bool ReadOCXStorage( tools::SvRef
<SotStorage
> const & rSrc1
, css::uno::Reference
< css::form::XFormComponent
> & rxFormComp
);
190 bool ReadOCXCtlsStream(tools::SvRef
<SotStorageStream
> const & rSrc1
, css::uno::Reference
< css::form::XFormComponent
> & rxFormComp
,
191 sal_Int32 nPos
, sal_Int32 nSize
);
192 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
);
193 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
);
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */