Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #ifndef OOX_OLE_OLEHELPER_HXX
21 : : #define OOX_OLE_OLEHELPER_HXX
22 : :
23 : : #include <rtl/ustring.hxx>
24 : : #include "oox/helper/binarystreambase.hxx"
25 : : #include "oox/helper/storagebase.hxx"
26 : : #include "oox/helper/graphichelper.hxx"
27 : : #include "com/sun/star/form/XFormComponent.hpp"
28 : : #include "com/sun/star/uno/XComponentContext.hpp"
29 : : #include "com/sun/star/lang/XMultiServiceFactory.hpp"
30 : : #include "com/sun/star/frame/XModel.hpp"
31 : : #include "com/sun/star/frame/XFrame.hpp"
32 : : #include "com/sun/star/drawing/XShapes.hpp"
33 : : #include "com/sun/star/awt/XControlModel.hpp"
34 : : #include "com/sun/star/io/XInputStream.hpp"
35 : : #include "com/sun/star/io/XOutputStream.hpp"
36 : : #include <com/sun/star/drawing/XDrawPage.hpp>
37 : : #include "com/sun/star/container/XIndexContainer.hpp"
38 : : #include <filter/msfilter/msocximex.hxx>
39 : : #include "oox/dllapi.h"
40 : : #include "sot/storage.hxx"
41 : :
42 : : namespace oox {
43 : : class BinaryInputStream;
44 : : class BinaryOutputStream;
45 : : class BinaryXInputStream;
46 : : class GraphicHelper;
47 : : }
48 : :
49 : : namespace oox {
50 : :
51 : : typedef ::boost::shared_ptr< oox::BinaryXInputStream > BinaryXInputStreamRef;
52 : :
53 : : namespace ole {
54 : :
55 : :
56 : : // ============================================================================
57 : :
58 : : #define OLE_GUID_STDFONT "{0BE35203-8F91-11CE-9DE3-00AA004BB851}"
59 : : #define OLE_GUID_STDPIC "{0BE35204-8F91-11CE-9DE3-00AA004BB851}"
60 : : #define OLE_GUID_STDHLINK "{79EAC9D0-BAF9-11CE-8C82-00AA004BA90B}"
61 : :
62 : : // ============================================================================
63 : :
64 : : const sal_uInt16 OLE_STDFONT_NORMAL = 400;
65 : : const sal_uInt16 OLE_STDFONT_BOLD = 700;
66 : :
67 : : const sal_uInt8 OLE_STDFONT_ITALIC = 0x02;
68 : : const sal_uInt8 OLE_STDFONT_UNDERLINE = 0x04;
69 : : const sal_uInt8 OLE_STDFONT_STRIKE = 0x08;
70 : :
71 : : /** Stores data about a StdFont font structure. */
72 : 0 : struct StdFontInfo
73 : : {
74 : : ::rtl::OUString maName; ///< Font name.
75 : : sal_uInt32 mnHeight; ///< Font height (1/10,000 points).
76 : : sal_uInt16 mnWeight; ///< Font weight (normal/bold).
77 : : sal_uInt16 mnCharSet; ///< Font charset.
78 : : sal_uInt8 mnFlags; ///< Font flags.
79 : :
80 : : explicit StdFontInfo();
81 : : explicit StdFontInfo(
82 : : const ::rtl::OUString& rName,
83 : : sal_uInt32 nHeight,
84 : : sal_uInt16 nWeight = OLE_STDFONT_NORMAL,
85 : : sal_uInt16 nCharSet = WINDOWS_CHARSET_ANSI,
86 : : sal_uInt8 nFlags = 0 );
87 : : };
88 : :
89 : : // ============================================================================
90 : :
91 : : /** Stores data about a StdHlink hyperlink. */
92 : 0 : struct StdHlinkInfo
93 : : {
94 : : ::rtl::OUString maTarget;
95 : : ::rtl::OUString maLocation;
96 : : ::rtl::OUString maDisplay;
97 : : ::rtl::OUString maFrame;
98 : : };
99 : :
100 : : // ============================================================================
101 : :
102 : : /** Static helper functions for OLE import/export. */
103 : : class OOX_DLLPUBLIC OleHelper
104 : : {
105 : : public:
106 : : /** Returns the UNO RGB color from the passed encoded OLE color.
107 : :
108 : : @param bDefaultColorBgr
109 : : True = OLE default color type is treated as BGR color.
110 : : False = OLE default color type is treated as palette color.
111 : : */
112 : : static sal_Int32 decodeOleColor(
113 : : const GraphicHelper& rGraphicHelper,
114 : : sal_uInt32 nOleColor,
115 : : bool bDefaultColorBgr = true );
116 : :
117 : : /** Returns the OLE color from the passed UNO RGB color.
118 : : */
119 : : static sal_uInt32 encodeOleColor( sal_Int32 nRgbColor );
120 : :
121 : : /** Imports a GUID from the passed binary stream and returns its string
122 : : representation (in uppercase characters).
123 : : */
124 : : static ::rtl::OUString importGuid( BinaryInputStream& rInStrm );
125 : :
126 : : /** Imports an OLE StdFont font structure from the current position of the
127 : : passed binary stream.
128 : : */
129 : : static bool importStdFont(
130 : : StdFontInfo& orFontInfo,
131 : : BinaryInputStream& rInStrm,
132 : : bool bWithGuid );
133 : :
134 : : /** Imports an OLE StdPic picture from the current position of the passed
135 : : binary stream.
136 : : */
137 : : static bool importStdPic(
138 : : StreamDataSequence& orGraphicData,
139 : : BinaryInputStream& rInStrm,
140 : : bool bWithGuid );
141 : :
142 : : private:
143 : : OleHelper(); // not implemented
144 : : ~OleHelper(); // not implemented
145 : : };
146 : :
147 : : // ideally it would be great to get rid of SvxMSConvertOCXControls
148 : : // however msfilter/source/msfilter/svdfppt.cxx still uses
149 : : // SvxMSConvertOCXControls as a base class, unfortunately oox depends on
150 : : // msfilter. Probably the solution would be to move the svdfppt.cxx
151 : : // implementation into the sd module itself.
152 : : class OOX_DLLPUBLIC MSConvertOCXControls : public SvxMSConvertOCXControls
153 : : {
154 : : #if SvxMSConvertOCXControlsRemoved
155 : : com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > mxShapes;
156 : : com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > mxDrawPage;
157 : : com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer > mxFormComps;
158 : : com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxServiceFactory;
159 : : #endif
160 : : protected:
161 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxCtx;
162 : : ::oox::GraphicHelper maGrfHelper;
163 : :
164 : : bool importControlFromStream( ::oox::BinaryInputStream& rInStrm,
165 : : ::com::sun::star::uno::Reference< com::sun::star::form::XFormComponent > & rxFormComp,
166 : : const ::rtl::OUString& rGuidString );
167 : : bool importControlFromStream( ::oox::BinaryInputStream& rInStrm,
168 : : ::com::sun::star::uno::Reference< com::sun::star::form::XFormComponent > & rxFormComp,
169 : : const ::rtl::OUString& rGuidString,
170 : : sal_Int32 nSize );
171 : : public:
172 : : MSConvertOCXControls( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel );
173 : : ~MSConvertOCXControls();
174 : : sal_Bool ReadOCXStorage( SotStorageRef& rSrc1, ::com::sun::star::uno::Reference< com::sun::star::form::XFormComponent > & rxFormComp );
175 : : sal_Bool ReadOCXCtlsStream(SotStorageStreamRef& rSrc1, ::com::sun::star::uno::Reference< com::sun::star::form::XFormComponent > & rxFormComp,
176 : : sal_Int32 nPos, sal_Int32 nSize );
177 : : static sal_Bool WriteOCXStream( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxModel, SotStorageRef &rSrc1, const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > &rControlModel, const com::sun::star::awt::Size& rSize,rtl::OUString &rName);
178 : :
179 : : #if SvxMSConvertOCXControlsRemoved
180 : : const com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > & GetShapes();
181 : : const com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer > & GetFormComps();
182 : : virtual const com::sun::star::uno::Reference<
183 : : com::sun::star::drawing::XDrawPage > & GetDrawPage();
184 : : const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & GetServiceFactory();
185 : : virtual sal_Bool InsertControl(
186 : : const com::sun::star::uno::Reference<
187 : : com::sun::star::form::XFormComponent >& /*rFComp*/,
188 : : const com::sun::star::awt::Size& /*rSize*/,
189 : : com::sun::star::uno::Reference<
190 : : com::sun::star::drawing::XShape >* /*pShape*/,
191 : : sal_Bool /*bFloatingCtrl*/ ) {return sal_False;}
192 : : #endif
193 : : };
194 : :
195 : :
196 : : // ============================================================================
197 : :
198 : : } // namespace ole
199 : : } // namespace oox
200 : :
201 : : #endif
202 : :
203 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|