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 <rtl/ustring.hxx>
24 #include <tools/ref.hxx>
25 #include <oox/helper/binarystreambase.hxx>
26 #include <oox/helper/storagebase.hxx>
27 #include <oox/helper/graphichelper.hxx>
28 #include <com/sun/star/form/XFormComponent.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #include <com/sun/star/frame/XModel.hpp>
32 #include <com/sun/star/frame/XFrame.hpp>
33 #include <com/sun/star/drawing/XShapes.hpp>
34 #include <com/sun/star/awt/XControlModel.hpp>
35 #include <com/sun/star/io/XInputStream.hpp>
36 #include <com/sun/star/io/XOutputStream.hpp>
37 #include <com/sun/star/drawing/XDrawPage.hpp>
38 #include <com/sun/star/container/XIndexContainer.hpp>
39 #include <filter/msfilter/msocximex.hxx>
40 #include <oox/dllapi.h>
43 class SotStorageStream
;
47 class BinaryInputStream
;
48 class BinaryOutputStream
;
49 class BinaryXInputStream
;
61 #define OLE_GUID_STDFONT "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"
62 #define OLE_GUID_STDPIC "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"
66 const sal_uInt16 OLE_STDFONT_NORMAL
= 400;
67 const sal_uInt16 OLE_STDFONT_BOLD
= 700;
69 const sal_uInt8 OLE_STDFONT_ITALIC
= 0x02;
70 const sal_uInt8 OLE_STDFONT_UNDERLINE
= 0x04;
71 const sal_uInt8 OLE_STDFONT_STRIKE
= 0x08;
73 /** Stores data about a StdFont font structure. */
76 OUString maName
; ///< Font name.
77 sal_uInt32 mnHeight
; ///< Font height (1/10,000 points).
78 sal_uInt16 mnWeight
; ///< Font weight (normal/bold).
79 sal_uInt16 mnCharSet
; ///< Font charset.
80 sal_uInt8 mnFlags
; ///< Font flags.
82 explicit StdFontInfo();
84 const OUString
& rName
,
86 sal_uInt16 nWeight
= OLE_STDFONT_NORMAL
,
87 sal_uInt16 nCharSet
= WINDOWS_CHARSET_ANSI
,
88 sal_uInt8 nFlags
= 0 );
93 /** Stores data about a StdHlink hyperlink. */
104 /** Static helper functions for OLE import/export. */
107 /** Returns the UNO RGB color from the passed encoded OLE color.
109 @param bDefaultColorBgr
110 True = OLE default color type is treated as BGR color.
111 False = OLE default color type is treated as palette color.
113 OOX_DLLPUBLIC sal_Int32
decodeOleColor(
114 const GraphicHelper
& rGraphicHelper
,
115 sal_uInt32 nOleColor
,
116 bool bDefaultColorBgr
= true );
118 /** Returns the OLE color from the passed UNO RGB color.
120 OOX_DLLPUBLIC sal_uInt32
encodeOleColor( sal_Int32 nRgbColor
);
122 /** Imports a GUID from the passed binary stream and returns its string
123 representation (in uppercase characters).
125 OOX_DLLPUBLIC OUString
importGuid( BinaryInputStream
& rInStrm
);
126 OOX_DLLPUBLIC
void exportGuid( BinaryOutputStream
& rOutStrm
, const SvGlobalName
& rId
);
128 /** Imports an OLE StdFont font structure from the current position of the
129 passed binary stream.
131 OOX_DLLPUBLIC
bool importStdFont(
132 StdFontInfo
& orFontInfo
,
133 BinaryInputStream
& rInStrm
,
136 /** Imports an OLE StdPic picture from the current position of the passed
139 OOX_DLLPUBLIC
bool importStdPic(
140 StreamDataSequence
& orGraphicData
,
141 BinaryInputStream
& rInStrm
,
145 // ideally it would be great to get rid of SvxMSConvertOCXControls
146 // however msfilter/source/msfilter/svdfppt.cxx still uses
147 // SvxMSConvertOCXControls as a base class, unfortunately oox depends on
148 // msfilter. Probably the solution would be to move the svdfppt.cxx
149 // implementation into the sd module itself.
150 class OOX_DLLPUBLIC MSConvertOCXControls
: public SvxMSConvertOCXControls
153 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> mxCtx
;
154 ::oox::GraphicHelper maGrfHelper
;
156 bool importControlFromStream( ::oox::BinaryInputStream
& rInStrm
,
157 ::com::sun::star::uno::Reference
< com::sun::star::form::XFormComponent
> & rxFormComp
,
158 const OUString
& rGuidString
);
159 bool importControlFromStream( ::oox::BinaryInputStream
& rInStrm
,
160 ::com::sun::star::uno::Reference
< com::sun::star::form::XFormComponent
> & rxFormComp
,
161 const OUString
& rGuidString
,
164 MSConvertOCXControls( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& rxModel
);
165 virtual ~MSConvertOCXControls();
166 bool ReadOCXStorage( tools::SvRef
<SotStorage
>& rSrc1
, ::com::sun::star::uno::Reference
< com::sun::star::form::XFormComponent
> & rxFormComp
);
167 bool ReadOCXCtlsStream(tools::SvRef
<SotStorageStream
>& rSrc1
, ::com::sun::star::uno::Reference
< com::sun::star::form::XFormComponent
> & rxFormComp
,
168 sal_Int32 nPos
, sal_Int32 nSize
);
169 static bool WriteOCXStream( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& rxModel
, tools::SvRef
<SotStorage
> &rSrc1
, const com::sun::star::uno::Reference
< com::sun::star::awt::XControlModel
> &rControlModel
, const com::sun::star::awt::Size
& rSize
,OUString
&rName
);
170 static bool WriteOCXExcelKludgeStream( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& rxModel
, const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XOutputStream
>& xOutStrm
, const com::sun::star::uno::Reference
< com::sun::star::awt::XControlModel
> &rControlModel
, const com::sun::star::awt::Size
& rSize
,OUString
&rName
);
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */