merge the formfield patch from ooo-build
[ooovba.git] / sc / source / filter / inc / xeescher.hxx
blob8b3f9a69b4507925faedac6c47e937871e4d9b52
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: xeescher.hxx,v $
10 * $Revision: 1.10.128.1 $
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_XEESCHER_HXX
32 #define SC_XEESCHER_HXX
34 #include <vcl/graph.hxx>
35 #include "xcl97rec.hxx"
36 #include "xlescher.hxx"
38 namespace com { namespace sun { namespace star {
39 namespace script { struct ScriptEventDescriptor; }
40 } } }
42 // ============================================================================
44 /** Provides export of bitmap data to an IMGDATA record. */
45 class XclExpImgData : public XclExpRecordBase
47 public:
48 explicit XclExpImgData( const Graphic& rGraphic, sal_uInt16 nRecId );
50 /** Writes the BITMAP record. */
51 virtual void Save( XclExpStream& rStrm );
53 private:
54 Graphic maGraphic; /// The VCL graphic.
55 sal_uInt16 mnRecId; /// Record identifier for the IMGDATA record.
58 // ============================================================================
60 /** Helper class for form controils to manage spreadsheet links . */
61 class XclExpControlHelper : protected XclExpRoot
63 public:
64 explicit XclExpControlHelper( const XclExpRoot& rRoot );
65 virtual ~XclExpControlHelper();
67 protected:
68 /** Tries to get spreadsheet cell link and source range link from the passed shape. */
69 void ConvertSheetLinks(
70 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
73 /** Returns the Excel token array of the cell link, or 0, if no link present. */
74 inline const XclTokenArray* GetCellLinkTokArr() const { return mxCellLink.get(); }
75 /** Returns the Excel token array of the source range, or 0, if no link present. */
76 inline const XclTokenArray* GetSourceRangeTokArr() const { return mxSrcRange.get(); }
77 /** Returns the number of entries in the source range, or 0, if no source set. */
78 inline sal_uInt16 GetSourceEntryCount() const { return mnEntryCount; }
80 /** Writes a formula with special style only valid in OBJ records. */
81 void WriteFormula( XclExpStream& rStrm, const XclTokenArray& rTokArr ) const;
82 /** Writes a formula subrecord with special style only valid in OBJ records. */
83 void WriteFormulaSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId, const XclTokenArray& rTokArr ) const;
85 private:
86 XclTokenArrayRef mxCellLink; /// Formula for linked cell.
87 XclTokenArrayRef mxSrcRange; /// Formula for source data range.
88 sal_uInt16 mnEntryCount; /// Number of entries in source range.
91 class XclMacroHelper : public XclExpControlHelper
93 protected:
94 XclTokenArrayRef mxMacroLink; /// Token array containing a link to an attached macro.
96 public:
97 explicit XclMacroHelper( const XclExpRoot& rRoot );
98 virtual ~XclMacroHelper();
99 /** Writes an ftMacro subrecord containing a macro link, or nothing, if no macro present. */
100 void WriteMacroSubRec( XclExpStream& rStrm );
101 /** Sets the name of a macro for object of passed type
102 @return true = The passed event descriptor was valid, macro name has been found. */
103 bool SetMacroLink( const ::com::sun::star::script::ScriptEventDescriptor& rEvent, const XclTbxEventType& nEventType );
105 /** Sets the name of a macro
106 @return true = The passed macro name has been found. */
107 bool SetMacroLink( const String& rMacro );
110 class XclExpShapeObj : public XclObjAny, public XclMacroHelper
112 public:
113 explicit XclExpShapeObj( const XclExpRoot& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
114 virtual ~XclExpShapeObj();
115 private:
116 virtual void WriteSubRecs( XclExpStream& rStrm );
119 // ----------------------------------------------------------------------------
121 #if EXC_EXP_OCX_CTRL
123 /** Represents an OBJ record for an OCX form control. */
124 class XclExpOcxControlObj : public XclObj, public XclExpControlHelper
126 public:
127 explicit XclExpOcxControlObj(
128 const XclExpRoot& rRoot,
129 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
130 const String& rClassName,
131 sal_uInt32 nStrmStart, sal_uInt32 nStrmSize );
133 private:
134 virtual void WriteSubRecs( XclExpStream& rStrm );
136 private:
137 String maClassName; /// Class name of the control.
138 sal_uInt32 mnStrmStart; /// Start position in 'Ctls' stream.
139 sal_uInt32 mnStrmSize; /// Size in 'Ctls' stream.
142 #else
144 /** Represents an OBJ record for an TBX form control. */
145 class XclExpTbxControlObj : public XclObj, public XclMacroHelper
147 public:
148 explicit XclExpTbxControlObj(
149 const XclExpRoot& rRoot,
150 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
152 /** Sets the name of a macro attached to this control.
153 @return true = The passed event descriptor was valid, macro name has been found. */
154 bool SetMacroLink( const ::com::sun::star::script::ScriptEventDescriptor& rEvent );
156 private:
157 virtual void WriteSubRecs( XclExpStream& rStrm );
159 /** Writes a subrecord containing a cell link, or nothing, if no link present. */
160 void WriteCellLinkSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId );
161 /** Writes the ftSbs sub structure containing scrollbar data. */
162 void WriteSbs( XclExpStream& rStrm );
164 private:
165 ScfInt16Vec maMultiSel; /// Indexes of all selected entries in a multi selection.
166 XclTbxEventType meEventType; /// Type of supported macro event.
167 sal_Int32 mnHeight; /// Height of the control.
168 sal_uInt16 mnState; /// Checked/unchecked state.
169 sal_Int16 mnLineCount; /// Combobox dropdown line count.
170 sal_Int16 mnSelEntry; /// Selected entry in combobox (1-based).
171 sal_uInt16 mnScrollValue; /// Scrollbar: Current value.
172 sal_uInt16 mnScrollMin; /// Scrollbar: Minimum value.
173 sal_uInt16 mnScrollMax; /// Scrollbar: Maximum value.
174 sal_uInt16 mnScrollStep; /// Scrollbar: Single step.
175 sal_uInt16 mnScrollPage; /// Scrollbar: Page step.
176 bool mbFlatButton; /// False = 3D button style; True = Flat button style.
177 bool mbFlatBorder; /// False = 3D border style; True = Flat border style.
178 bool mbMultiSel; /// true = Multi selection in listbox.
179 bool mbScrollHor; /// Scrollbar: true = horizontal.
182 #endif
184 // ----------------------------------------------------------------------------
186 class XclExpChart;
188 /** A chart object. This is the drawing object wrapper for the chart data. */
189 class XclExpChartObj : public XclObj, protected XclExpRoot
191 public:
192 typedef ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > XShapeRef;
194 public:
195 explicit XclExpChartObj( const XclExpRoot& rRoot, XShapeRef xShape );
196 virtual ~XclExpChartObj();
198 /** Writes the OBJ record and the entire chart substream. */
199 virtual void Save( XclExpStream& rStrm );
201 private:
202 typedef ScfRef< XclExpChart > XclExpChartRef;
203 XclExpChartRef mxChart; /// The chart itself (BOF/EOF substream data).
206 // ============================================================================
208 /** Represents a NOTE record containing the relevant data of a cell note.
210 NOTE records differ significantly in various BIFF versions. This class
211 encapsulates all needed actions for each supported BIFF version.
212 BIFF5/BIFF7: Stores the note text and generates a single or multiple NOTE
213 records on saving.
214 BIFF8: Creates the Escher object containing the drawing information and the
215 note text.
217 class XclExpNote : public XclExpRecord
219 public:
220 /** Constructs a NOTE record from the passed note object and/or the text.
221 @descr The additional text will be separated from the note text with
222 an empty line.
223 @param rScPos The Calc cell address of the note.
224 @param pScNote The Calc note object. May be 0 to create a note from rAddText only.
225 @param rAddText Additional text appended to the note text. */
226 explicit XclExpNote(
227 const XclExpRoot& rRoot,
228 const ScAddress& rScPos,
229 const ScPostIt* pScNote,
230 const String& rAddText );
232 /** Writes the NOTE record, if the respective Escher object is present. */
233 virtual void Save( XclExpStream& rStrm );
235 void WriteXml( sal_Int32 nAuthorId, XclExpXmlStream& rStrm );
237 const XclExpString& GetAuthor() const { return maAuthor; }
238 private:
239 /** Writes the body of the NOTE record. */
240 virtual void WriteBody( XclExpStream& rStrm );
242 private:
243 XclExpString maAuthor; /// Name of the author.
244 String maOrigNoteText; /// Original main text of the note.
245 ByteString maNoteText; /// Main text of the note (<=BIFF7).
246 ScAddress maScPos; /// Calc cell address of the note.
247 sal_uInt16 mnObjId; /// Escher object ID (BIFF8).
248 bool mbVisible; /// true = permanently visible.
251 // ============================================================================
253 class XclExpComments : public XclExpRecord
255 public:
256 typedef XclExpRecordList< XclExpNote >
257 XclExpNoteList;
259 XclExpComments( SCTAB nTab, XclExpNoteList& rNotes );
261 virtual void SaveXml( XclExpXmlStream& rStrm );
263 private:
264 SCTAB mnTab;
265 XclExpNoteList& mrNotes;
268 // ============================================================================
270 #endif