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 SC_XCL97ESC_HXX
21 : #define SC_XCL97ESC_HXX
22 :
23 : #include <memory>
24 : #include <stack>
25 : #include <filter/msfilter/escherex.hxx>
26 : #include "xlescher.hxx"
27 : #include "xeroot.hxx"
28 : #include <vector>
29 :
30 : // 0 = Export TBX form controls, 1 = Export OCX form controls.
31 : #define EXC_EXP_OCX_CTRL 0
32 :
33 : namespace utl { class TempFile; }
34 :
35 : // ============================================================================
36 :
37 : class SvStream;
38 :
39 2 : class XclEscherExGlobal : public EscherExGlobal, protected XclExpRoot
40 : {
41 : public:
42 : explicit XclEscherExGlobal( const XclExpRoot& rRoot );
43 :
44 : private:
45 : /** Overloaded to create a new temporary file and return its stream. */
46 : virtual SvStream* ImplQueryPictureStream();
47 :
48 : private:
49 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
50 : ::std::auto_ptr< ::utl::TempFile > mxPicTempFile;
51 : ::std::auto_ptr< SvStream > mxPicStrm;
52 : SAL_WNODEPRECATED_DECLARATIONS_POP
53 : };
54 :
55 : // ============================================================================
56 :
57 : class XclObj;
58 : class XclExpDffAnchorBase;
59 : class XclEscherHostAppData;
60 : class XclEscherClientData;
61 : class XclEscherClientTextbox;
62 : #if EXC_EXP_OCX_CTRL
63 : class XclExpOcxControlObj;
64 : #else
65 : class XclExpTbxControlObj;
66 : #endif
67 : class XclExpShapeObj;
68 : class EscherExHostAppData;
69 : class ShapeInteractionHelper
70 : {
71 : public:
72 : static XclExpShapeObj* CreateShapeObj( XclExpObjectManager& rObjMgr, const ::com::sun::star::uno::Reference<
73 : ::com::sun::star::drawing::XShape >& xShape );
74 : static void PopulateShapeInteractionInfo( XclExpObjectManager& rObjMgr, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, EscherExHostAppData& rHostAppData );
75 : };
76 :
77 : class XclEscherEx : public EscherEx, protected XclExpRoot
78 : {
79 : public:
80 : explicit XclEscherEx(
81 : const XclExpRoot& rRoot,
82 : XclExpObjectManager& rObjMgr,
83 : SvStream& rStrm,
84 : const XclEscherEx* pParent = 0 );
85 : virtual ~XclEscherEx();
86 :
87 : /** Called by MSODRAWING record constructors to initialize the DFF stream
88 : fragment they will own. returns the DFF fragment identifier. */
89 : sal_uInt32 InitNextDffFragment();
90 : /** Called after some data has been written to the DFF stream, to update
91 : the end position of the DFF fragment owned by an MSODRAWING record. */
92 : void UpdateDffFragmentEnd();
93 :
94 : /** Returns the position of the specified DFF stream fragment. */
95 : sal_uInt32 GetDffFragmentPos( sal_uInt32 nFragmentKey );
96 : /** Returns the size of the specified DFF stream fragment. */
97 : sal_uInt32 GetDffFragmentSize( sal_uInt32 nFragmentKey );
98 : /** Returns true, if there is more data left in the DFF stream than owned
99 : by the last MSODRAWING record. */
100 : bool HasPendingDffData();
101 :
102 : /** Creates a new DFF client anchor object and calculates the anchor
103 : position of the passed object. Caller takes ownership! */
104 : XclExpDffAnchorBase* CreateDffAnchor( const SdrObject& rSdrObj ) const;
105 :
106 : virtual EscherExHostAppData* StartShape(
107 : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& rxShape,
108 : const Rectangle* pChildAnchor );
109 : virtual void EndShape( sal_uInt16 nShapeType, sal_uInt32 nShapeID );
110 : virtual EscherExHostAppData* EnterAdditionalTextGroup();
111 :
112 : /// Flush and merge PicStream into EscherStream
113 : void EndDocument();
114 :
115 : #if EXC_EXP_OCX_CTRL
116 : /** Creates an OCX form control OBJ record from the passed form control.
117 : @descr Writes the form control data to the 'Ctls' stream. */
118 : XclExpOcxControlObj* CreateCtrlObj(
119 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
120 : const Rectangle* pChildAnchor );
121 :
122 : private:
123 : SotStorageStreamRef mxCtlsStrm; /// The 'Ctls' stream.
124 : #else
125 : /** Creates a TBX form control OBJ record from the passed form control. */
126 : XclExpTbxControlObj* CreateCtrlObj(
127 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
128 : const Rectangle* pChildAnchor );
129 :
130 : private:
131 : /** Tries to get the name of a Basic macro from a control. */
132 : void ConvertTbxMacro(
133 : XclExpTbxControlObj& rTbxCtrlObj,
134 : ::com::sun::star::uno::Reference<
135 : ::com::sun::star::awt::XControlModel > xCtrlModel );
136 : #endif
137 :
138 : void DeleteCurrAppData();
139 :
140 : private:
141 : XclExpObjectManager& mrObjMgr;
142 : std::stack< std::pair< XclObj*, XclEscherHostAppData* > > aStack;
143 : XclObj* pCurrXclObj;
144 : XclEscherHostAppData* pCurrAppData;
145 : XclEscherClientData* pTheClientData; // always the same
146 : XclEscherClientTextbox* pAdditionalText;
147 : sal_uInt16 nAdditionalText;
148 : sal_uInt32 mnNextKey;
149 : bool mbIsRootDff;
150 : };
151 :
152 : // --- class XclEscherHostAppData ------------------------------------
153 :
154 : class XclEscherHostAppData : public EscherExHostAppData
155 : {
156 : private:
157 : sal_Bool bStackedGroup;
158 :
159 : public:
160 0 : XclEscherHostAppData() : bStackedGroup( false )
161 0 : {}
162 0 : inline void SetStackedGroup( sal_Bool b ) { bStackedGroup = b; }
163 0 : inline sal_Bool IsStackedGroup() const { return bStackedGroup; }
164 : };
165 :
166 :
167 :
168 : // ============================================================================
169 :
170 : // --- class XclEscherClientData -------------------------------------
171 :
172 2 : class XclEscherClientData : public EscherExClientRecord_Base
173 : {
174 : public:
175 1 : XclEscherClientData() {}
176 : virtual void WriteData( EscherEx& rEx ) const;
177 : };
178 :
179 :
180 : // --- class XclEscherClientTextbox ----------------------------------
181 :
182 : class SdrTextObj;
183 :
184 0 : class XclEscherClientTextbox : public EscherExClientRecord_Base, protected XclExpRoot
185 : {
186 : private:
187 : const SdrTextObj& rTextObj;
188 : XclObj* pXclObj;
189 :
190 : public:
191 : XclEscherClientTextbox(
192 : const XclExpRoot& rRoot,
193 : const SdrTextObj& rObj,
194 : XclObj* pObj );
195 :
196 : //! ONLY for the AdditionalText mimic
197 0 : inline void SetXclObj( XclObj* p ) { pXclObj = p; }
198 :
199 : virtual void WriteData( EscherEx& rEx ) const;
200 : };
201 :
202 :
203 :
204 : #endif // _XCL97ESC_HXX
205 :
206 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|