1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xcl97esc.hxx,v $
10 * $Revision: 1.13.14.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_XCL97ESC_HXX
32 #define SC_XCL97ESC_HXX
34 #include <svx/escherex.hxx>
35 #include <tools/table.hxx>
36 #include <tools/stack.hxx>
37 #include "xlescher.hxx"
40 // 0 = Export TBX form controls, 1 = Export OCX form controls.
41 #define EXC_EXP_OCX_CTRL 0
43 namespace utl
{ class TempFile
; }
45 // --- class XclEscherEx ---------------------------------------------
49 class XclEscherHostAppData
;
50 class XclEscherClientData
;
51 class XclEscherClientTextbox
;
53 class XclExpOcxControlObj
;
55 class XclExpTbxControlObj
;
58 class EscherExHostAppData
;
59 class ShapeInteractionHelper
62 static XclExpShapeObj
* CreateShapeObj(const XclExpRoot
& rRoot
, const ::com::sun::star::uno::Reference
<
63 ::com::sun::star::drawing::XShape
>& xShape
);
64 static void PopulateShapeInteractionInfo( const XclExpRoot
& rRoot
, const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>& xShape
, EscherExHostAppData
& rHostAppData
);
67 class XclEscherEx
: public EscherEx
, protected XclExpRoot
72 utl::TempFile
* pPicTempFile
;
75 XclEscherHostAppData
* pCurrAppData
;
76 XclEscherClientData
* pTheClientData
; // always the same
77 XclEscherClientTextbox
* pAdditionalText
;
78 USHORT nAdditionalText
;
80 void DeleteCurrAppData();
83 XclEscherEx( const XclExpRoot
& rRoot
, SvStream
& rStrm
, UINT32 nDrawings
);
84 virtual ~XclEscherEx();
86 /// maintains OffsetMap
87 virtual void InsertAtCurrentPos( UINT32 nBytes
, BOOL bCont
= FALSE
);
89 virtual SvStream
* QueryPicStream();
90 virtual EscherExHostAppData
* StartShape( const com::sun::star::uno::Reference
<
91 com::sun::star::drawing::XShape
>& rShape
);
92 virtual void EndShape( UINT16 nShapeType
, UINT32 nShapeID
);
93 virtual EscherExHostAppData
* EnterAdditionalTextGroup();
95 /// appends stream offset to list and returns position in list
96 ULONG
AddCurrentOffsetToMap();
97 /// replaces position in list with current stream offset
98 void ReplaceCurrentOffsetInMap( ULONG nPos
);
99 /// returns stream offset for position in list
100 inline ULONG
GetOffsetFromMap( ULONG nPos
) const;
101 /// last position in list (count-1)
102 inline ULONG
GetLastOffsetMapPos() const;
104 /// Flush and merge PicStream into EscherStream
108 /** Creates an OCX form control OBJ record from the passed form control.
109 @descr Writes the form control data to the 'Ctls' stream. */
110 XclExpOcxControlObj
* CreateCtrlObj( ::com::sun::star::uno::Reference
<
111 ::com::sun::star::drawing::XShape
> xShape
);
114 SotStorageStreamRef mxCtlsStrm
; /// The 'Ctls' stream.
116 /** Creates a TBX form control OBJ record from the passed form control. */
117 XclExpTbxControlObj
* CreateCtrlObj( ::com::sun::star::uno::Reference
<
118 ::com::sun::star::drawing::XShape
> xShape
);
121 /** Tries to get the name of a Basic macro from a control. */
122 void ConvertTbxMacro(
123 XclExpTbxControlObj
& rTbxCtrlObj
,
124 ::com::sun::star::uno::Reference
<
125 ::com::sun::star::awt::XControlModel
> xCtrlModel
);
130 inline ULONG
XclEscherEx::GetOffsetFromMap( ULONG nPos
) const
132 return (ULONG
) aOffsetMap
.GetObject( nPos
);
136 inline ULONG
XclEscherEx::GetLastOffsetMapPos() const
138 return aOffsetMap
.Count() - 1;
142 // --- class XclEscher -----------------------------------------------
146 class XclEscher
: protected XclExpRoot
149 utl::TempFile
* pTempFile
;
154 XclEscher( const XclExpRoot
& rRoot
, UINT32 nDrawings
);
157 inline XclEscherEx
* GetEx() const { return pEx
; }
158 inline SvStream
& GetStrm() const { return *pStrm
; }
164 // --- class XclEscherHostAppData ------------------------------------
166 class XclEscherHostAppData
: public EscherExHostAppData
172 XclEscherHostAppData() : bStackedGroup( FALSE
)
174 inline void SetStackedGroup( BOOL b
) { bStackedGroup
= b
; }
175 inline BOOL
IsStackedGroup() const { return bStackedGroup
; }
179 // DFF client anchor ==========================================================
185 /** Represents the position (anchor) of an object in a Calc document. */
186 class XclExpDffAnchor
: public EscherExClientAnchor_Base
, protected XclExpRoot
189 /** Constructs a dummy client anchor. */
190 explicit XclExpDffAnchor( const XclExpRoot
& rRoot
, sal_uInt16 nFlags
= 0 );
191 /** Constructs a client anchor directly from an SdrObject. */
192 explicit XclExpDffAnchor( const XclExpRoot
& rRoot
, const SdrObject
& rSdrObj
);
194 /** Sets the flags according to the passed SdrObject. */
195 void SetFlags( const SdrObject
& rSdrObj
);
197 /** Called from SVX Escher exporter.
198 @param rRect The object anchor rectangle to be exported (in twips). */
199 virtual void WriteData( EscherEx
& rEx
, const Rectangle
& rRect
);
201 /** Writes the anchor structure with the current anchor position. */
202 void WriteData( EscherEx
& rEx
) const;
204 protected: // for access in derived classes
205 XclObjAnchor maAnchor
; /// The client anchor data.
206 sal_uInt16 mnFlags
; /// Flags for DFF stream export.
209 // ----------------------------------------------------------------------------
211 /** Represents the position (anchor) of a note object. */
212 class XclExpDffNoteAnchor
: public XclExpDffAnchor
215 explicit XclExpDffNoteAnchor( const XclExpRoot
& rRoot
, const Rectangle
& rRect
);
219 // ----------------------------------------------------------------------------
221 /** Represents the position (anchor) of a cell dropdown object. */
222 class XclExpDffDropDownAnchor
: public XclExpDffAnchor
225 explicit XclExpDffDropDownAnchor( const XclExpRoot
& rRoot
, const ScAddress
& rScPos
);
229 // ============================================================================
231 // --- class XclEscherClientData -------------------------------------
233 class XclEscherClientData
: public EscherExClientRecord_Base
236 XclEscherClientData() {}
237 virtual void WriteData( EscherEx
& rEx
) const;
241 // --- class XclEscherClientTextbox ----------------------------------
245 class XclEscherClientTextbox
: public EscherExClientRecord_Base
, protected XclExpRoot
248 const SdrTextObj
& rTextObj
;
252 XclEscherClientTextbox(
253 const XclExpRoot
& rRoot
,
254 const SdrTextObj
& rObj
,
258 //! ONLY for the AdditionalText mimic
259 inline void SetXclObj( XclObj
* p
) { pXclObj
= p
; }
261 virtual void WriteData( EscherEx
& rEx
) const;
266 #endif // _XCL97ESC_HXX