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_XCL97REC_HXX
21 : #define SC_XCL97REC_HXX
22 :
23 : #include "excrecds.hxx"
24 : #include "xcl97esc.hxx"
25 : #include "xlstyle.hxx"
26 : #include "tabprotection.hxx"
27 :
28 : class XclObj;
29 : class XclExpMsoDrawing;
30 : class SdrCaptionObj;
31 :
32 : class XclExpObjList : public ExcEmptyRec, protected XclExpRoot
33 : {
34 : public:
35 :
36 : typedef std::vector<XclObj*>::iterator iterator;
37 :
38 : explicit XclExpObjList( const XclExpRoot& rRoot, XclEscherEx& rEscherEx );
39 : virtual ~XclExpObjList();
40 :
41 : /// return: 1-based ObjId
42 : ///! count>=0xFFFF: Obj will be deleted, return 0
43 : sal_uInt16 Add( XclObj* );
44 :
45 0 : XclObj* back () { return maObjs.empty() ? NULL : maObjs.back(); }
46 :
47 : /**
48 : *
49 : * @brief Remove last element in the list.
50 : *
51 : */
52 :
53 : void pop_back ();
54 :
55 0 : inline bool empty () const { return maObjs.empty(); }
56 :
57 0 : inline size_t size () const { return maObjs.size(); }
58 :
59 0 : inline iterator begin () { return maObjs.begin(); }
60 :
61 0 : inline iterator end () { return maObjs.end(); }
62 :
63 0 : inline XclExpMsoDrawing* GetMsodrawingPerSheet() { return pMsodrawingPerSheet; }
64 :
65 : /// close groups and DgContainer opened in ctor
66 : void EndSheet();
67 :
68 : virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
69 : virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
70 :
71 : static void ResetCounters();
72 :
73 : private:
74 : static sal_Int32 mnDrawingMLCount, mnVmlCount;
75 : SCTAB mnScTab;
76 :
77 : XclEscherEx& mrEscherEx;
78 : XclExpMsoDrawing* pMsodrawingPerSheet;
79 : XclExpMsoDrawing* pSolverContainer;
80 :
81 : std::vector<XclObj*> maObjs;
82 : };
83 :
84 :
85 : // --- class XclObj --------------------------------------------------
86 :
87 : class XclTxo;
88 : class SdrTextObj;
89 :
90 : class XclObj : public XclExpRecord
91 : {
92 : protected:
93 : XclEscherEx& mrEscherEx;
94 : XclExpMsoDrawing* pMsodrawing;
95 : XclExpMsoDrawing* pClientTextbox;
96 : XclTxo* pTxo;
97 : sal_uInt16 mnObjType;
98 : sal_uInt16 nObjId;
99 : sal_uInt16 nGrbit;
100 : SCTAB mnScTab;
101 : bool bFirstOnSheet;
102 :
103 : bool mbOwnEscher; /// true = Escher part created on the fly.
104 :
105 : /** @param bOwnEscher If set to true, this object will create its escher data.
106 : See SetOwnEscher() for details. */
107 : explicit XclObj( XclExpObjectManager& rObjMgr, sal_uInt16 nObjType, bool bOwnEscher = false );
108 :
109 : void ImplWriteAnchor( const XclExpRoot& rRoot, const SdrObject* pSdrObj, const Rectangle* pChildAnchor );
110 :
111 : // overwritten for writing MSODRAWING record
112 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
113 : virtual void WriteSubRecs( XclExpStream& rStrm );
114 : void SaveTextRecs( XclExpStream& rStrm );
115 :
116 : public:
117 : virtual ~XclObj();
118 :
119 0 : inline sal_uInt16 GetObjType() const { return mnObjType; }
120 :
121 0 : inline void SetId( sal_uInt16 nId ) { nObjId = nId; }
122 : inline sal_uInt16 GetId() const { return nObjId; }
123 :
124 0 : inline void SetTab( SCTAB nScTab ) { mnScTab = nScTab; }
125 0 : inline SCTAB GetTab() const { return mnScTab; }
126 :
127 0 : inline void SetLocked( bool b )
128 0 : { b ? nGrbit |= 0x0001 : nGrbit &= ~0x0001; }
129 0 : inline void SetPrintable( bool b )
130 0 : { b ? nGrbit |= 0x0010 : nGrbit &= ~0x0010; }
131 0 : inline void SetAutoFill( bool b )
132 0 : { b ? nGrbit |= 0x2000 : nGrbit &= ~0x2000; }
133 0 : inline void SetAutoLine( bool b )
134 0 : { b ? nGrbit |= 0x4000 : nGrbit &= ~0x4000; }
135 :
136 : // set corresponding Excel object type in OBJ/ftCmo
137 : void SetEscherShapeType( sal_uInt16 nType );
138 0 : inline void SetEscherShapeTypeGroup() { mnObjType = EXC_OBJTYPE_GROUP; }
139 :
140 : /** If set to true, this object has created its own escher data.
141 : @descr This causes the function EscherEx::EndShape() to not post process
142 : this object. This is used i.e. for form controls. They are not handled in
143 : the svx base code, so the XclExpEscherOcxCtrl c'tor creates the escher data
144 : itself. The svx base code does not receive the correct shape ID after the
145 : EscherEx::StartShape() call, which would result in deleting the object in
146 : EscherEx::EndShape(). */
147 : inline void SetOwnEscher( bool bOwnEscher = true ) { mbOwnEscher = bOwnEscher; }
148 : /** Returns true, if the object has created the escher data itself.
149 : @descr See SetOwnEscher() for details. */
150 0 : inline bool IsOwnEscher() const { return mbOwnEscher; }
151 :
152 : //! actually writes ESCHER_ClientTextbox
153 : void SetText( const XclExpRoot& rRoot, const SdrTextObj& rObj );
154 :
155 : virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
156 : };
157 :
158 : // --- class XclObjComment -------------------------------------------
159 :
160 : class XclObjComment : public XclObj
161 : {
162 : ScAddress maScPos;
163 : std::auto_ptr< SdrCaptionObj >
164 : mpCaption;
165 : bool mbVisible;
166 : Rectangle maFrom;
167 : Rectangle maTo;
168 :
169 : public:
170 : XclObjComment( XclExpObjectManager& rObjMgr,
171 : const Rectangle& rRect, const EditTextObject& rEditObj, SdrCaptionObj* pCaption, bool bVisible, const ScAddress& rAddress, Rectangle &rFrom, Rectangle &To );
172 : virtual ~XclObjComment();
173 :
174 : /** c'tor process for formatted text objects above .
175 : @descr used to construct the MSODRAWING Escher object properties. */
176 : void ProcessEscherObj( const XclExpRoot& rRoot,
177 : const Rectangle& rRect, SdrObject* pCaption, bool bVisible );
178 :
179 :
180 : virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
181 : virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
182 : };
183 :
184 :
185 : // --- class XclObjDropDown ------------------------------------------
186 :
187 : class XclObjDropDown : public XclObj
188 : {
189 : private:
190 : bool bIsFiltered;
191 :
192 : virtual void WriteSubRecs( XclExpStream& rStrm ) SAL_OVERRIDE;
193 :
194 : protected:
195 : public:
196 : XclObjDropDown( XclExpObjectManager& rObjMgr, const ScAddress& rPos, bool bFilt );
197 : virtual ~XclObjDropDown();
198 : };
199 :
200 :
201 : // --- class XclTxo --------------------------------------------------
202 :
203 : class SdrTextObj;
204 :
205 0 : class XclTxo : public ExcRecord
206 : {
207 : public:
208 : XclTxo( const OUString& rString, sal_uInt16 nFontIx = EXC_FONT_APP );
209 : XclTxo( const XclExpRoot& rRoot, const SdrTextObj& rEditObj );
210 : XclTxo( const XclExpRoot& rRoot, const EditTextObject& rEditObj, SdrObject* pCaption );
211 :
212 0 : inline void SetHorAlign( sal_uInt8 nHorAlign ) { mnHorAlign = nHorAlign; }
213 0 : inline void SetVerAlign( sal_uInt8 nVerAlign ) { mnVerAlign = nVerAlign; }
214 :
215 : virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
216 :
217 : virtual sal_uInt16 GetNum() const SAL_OVERRIDE;
218 : virtual sal_Size GetLen() const SAL_OVERRIDE;
219 :
220 : private:
221 : virtual void SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
222 :
223 : private:
224 : XclExpStringRef mpString; /// Text and formatting data.
225 : sal_uInt16 mnRotation; /// Text rotation.
226 : sal_uInt8 mnHorAlign; /// Horizontal alignment.
227 : sal_uInt8 mnVerAlign; /// Vertical alignment.
228 : };
229 :
230 :
231 : // --- class XclObjOle -----------------------------------------------
232 :
233 : class XclObjOle : public XclObj
234 : {
235 : private:
236 :
237 : const SdrObject& rOleObj;
238 : SotStorage* pRootStorage;
239 :
240 : virtual void WriteSubRecs( XclExpStream& rStrm ) SAL_OVERRIDE;
241 :
242 : public:
243 : XclObjOle( XclExpObjectManager& rObjMgr, const SdrObject& rObj );
244 : virtual ~XclObjOle();
245 :
246 : virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
247 : };
248 :
249 :
250 : // --- class XclObjAny -----------------------------------------------
251 :
252 : class XclObjAny : public XclObj
253 : {
254 : protected:
255 : virtual void WriteSubRecs( XclExpStream& rStrm ) SAL_OVERRIDE;
256 :
257 : public:
258 : XclObjAny( XclExpObjectManager& rObjMgr,
259 : const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape );
260 : virtual ~XclObjAny();
261 :
262 : com::sun::star::uno::Reference< com::sun::star::drawing::XShape >
263 0 : GetShape() const { return mxShape; }
264 :
265 :
266 : virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
267 : virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
268 : static void WriteFromTo( XclExpXmlStream& rStrm, const XclObjAny& rObj );
269 : static void WriteFromTo( XclExpXmlStream& rStrm, const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape, SCTAB nTab );
270 :
271 : private:
272 : com::sun::star::uno::Reference< com::sun::star::drawing::XShape >
273 : mxShape;
274 : };
275 :
276 :
277 : // --- class ExcBof8_Base --------------------------------------------
278 :
279 0 : class ExcBof8_Base : public ExcBof_Base
280 : {
281 : protected:
282 : sal_uInt32 nFileHistory; // bfh
283 : sal_uInt32 nLowestBiffVer; // sfo
284 :
285 : virtual void SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
286 :
287 : public:
288 : ExcBof8_Base();
289 :
290 : virtual sal_uInt16 GetNum() const SAL_OVERRIDE;
291 : virtual sal_Size GetLen() const SAL_OVERRIDE;
292 : };
293 :
294 :
295 : // --- class ExcBofW8 ------------------------------------------------
296 : // Header Record fuer WORKBOOKS
297 :
298 0 : class ExcBofW8 : public ExcBof8_Base
299 : {
300 : public:
301 : ExcBofW8();
302 : };
303 :
304 :
305 : // --- class ExcBof8 -------------------------------------------------
306 : // Header Record fuer WORKSHEETS
307 :
308 0 : class ExcBof8 : public ExcBof8_Base
309 : {
310 : public:
311 : ExcBof8();
312 : };
313 :
314 :
315 : // --- class ExcBundlesheet8 -----------------------------------------
316 :
317 0 : class ExcBundlesheet8 : public ExcBundlesheetBase
318 : {
319 : private:
320 : OUString sUnicodeName;
321 : XclExpString GetName() const;
322 :
323 : virtual void SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
324 :
325 : public:
326 : ExcBundlesheet8( RootData& rRootData, SCTAB nTab );
327 : ExcBundlesheet8( const OUString& rString );
328 :
329 : virtual sal_Size GetLen() const SAL_OVERRIDE;
330 :
331 : virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
332 : };
333 :
334 :
335 : // --- class XclObproj -----------------------------------------------
336 :
337 0 : class XclObproj : public ExcRecord
338 : {
339 : public:
340 : virtual sal_uInt16 GetNum() const SAL_OVERRIDE;
341 : virtual sal_Size GetLen() const SAL_OVERRIDE;
342 : };
343 :
344 :
345 : // ---- class XclCodename --------------------------------------------
346 :
347 0 : class XclCodename : public ExcRecord
348 : {
349 : private:
350 : XclExpString aName;
351 : virtual void SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
352 : public:
353 : XclCodename( const OUString& );
354 :
355 : virtual sal_uInt16 GetNum() const SAL_OVERRIDE;
356 : virtual sal_Size GetLen() const SAL_OVERRIDE;
357 : };
358 :
359 :
360 : // ---- Scenarios ----------------------------------------------------
361 : // - ExcEScenarioCell a cell of a scenario range
362 : // - ExcEScenario all ranges of a scenario table
363 : // - ExcEScenarioManager list of scenario tables
364 :
365 0 : class ExcEScenarioCell
366 : {
367 : private:
368 : sal_uInt16 nCol;
369 : sal_uInt16 nRow;
370 : XclExpString sText;
371 :
372 : protected:
373 : public:
374 : ExcEScenarioCell( sal_uInt16 nC, sal_uInt16 nR, const OUString& rTxt );
375 :
376 0 : inline sal_Size GetStringBytes() const
377 0 : { return sText.GetSize(); }
378 :
379 : void WriteAddress( XclExpStream& rStrm ) const ;
380 : void WriteText( XclExpStream& rStrm ) const;
381 :
382 : void SaveXml( XclExpXmlStream& rStrm ) const;
383 : };
384 :
385 : class ExcEScenario : public ExcRecord
386 : {
387 : private:
388 : sal_Size nRecLen;
389 : XclExpString sName;
390 : XclExpString sComment;
391 : XclExpString sUserName;
392 : sal_uInt8 nProtected;
393 :
394 : std::vector<ExcEScenarioCell> aCells;
395 :
396 : bool Append( sal_uInt16 nCol, sal_uInt16 nRow, const OUString& rTxt );
397 :
398 : virtual void SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
399 :
400 : protected:
401 : public:
402 : ExcEScenario( const XclExpRoot& rRoot, SCTAB nTab );
403 : virtual ~ExcEScenario();
404 :
405 : virtual sal_uInt16 GetNum() const SAL_OVERRIDE;
406 : virtual sal_Size GetLen() const SAL_OVERRIDE;
407 :
408 : virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
409 : };
410 :
411 : class ExcEScenarioManager : public ExcRecord
412 : {
413 : private:
414 : sal_uInt16 nActive;
415 : std::vector<ExcEScenario*> aScenes;
416 :
417 : virtual void SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
418 :
419 : protected:
420 : public:
421 : ExcEScenarioManager( const XclExpRoot& rRoot, SCTAB nTab );
422 : virtual ~ExcEScenarioManager();
423 :
424 : virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
425 : virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
426 :
427 : virtual sal_uInt16 GetNum() const SAL_OVERRIDE;
428 : virtual sal_Size GetLen() const SAL_OVERRIDE;
429 : };
430 :
431 : /** Represents a FEATHDR (SHEETPROTECTION) record that stores sheet protection
432 : options. Note that a sheet still needs to save its sheet protection
433 : options even when it's not protected. */
434 0 : class XclExpSheetProtectOptions : public XclExpRecord
435 : {
436 : public:
437 : explicit XclExpSheetProtectOptions( const XclExpRoot& rRoot, SCTAB nTab );
438 :
439 : private:
440 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
441 :
442 : private:
443 : sal_uInt16 mnOptions; /// Encoded sheet protection options.
444 : };
445 :
446 :
447 : /** Represents one EnhancedProtection feature in a FEAT record.
448 : To be written only if such feature exists. */
449 0 : class XclExpSheetEnhancedProtection : public XclExpRecord
450 : {
451 : public:
452 : explicit XclExpSheetEnhancedProtection( const XclExpRoot& rRoot, const ScEnhancedProtection& rProt );
453 :
454 : private:
455 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
456 :
457 : private:
458 : const XclExpRoot& mrRoot;
459 : ScEnhancedProtection maEnhancedProtection;
460 : };
461 :
462 0 : class XclCalccount : public ExcRecord
463 : {
464 : private:
465 : sal_uInt16 nCount;
466 : protected:
467 : virtual void SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
468 : public:
469 : XclCalccount( const ScDocument& );
470 :
471 : virtual sal_uInt16 GetNum() const SAL_OVERRIDE;
472 : virtual sal_Size GetLen() const SAL_OVERRIDE;
473 :
474 : virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
475 : };
476 :
477 :
478 0 : class XclIteration : public ExcRecord
479 : {
480 : private:
481 : sal_uInt16 nIter;
482 : protected:
483 : virtual void SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
484 : public:
485 : XclIteration( const ScDocument& );
486 :
487 : virtual sal_uInt16 GetNum() const SAL_OVERRIDE;
488 : virtual sal_Size GetLen() const SAL_OVERRIDE;
489 :
490 : virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
491 : };
492 :
493 :
494 0 : class XclDelta : public ExcRecord
495 : {
496 : private:
497 : double fDelta;
498 : protected:
499 : virtual void SaveCont( XclExpStream& rStrm ) SAL_OVERRIDE;
500 : public:
501 : XclDelta( const ScDocument& );
502 :
503 : virtual sal_uInt16 GetNum() const SAL_OVERRIDE;
504 : virtual sal_Size GetLen() const SAL_OVERRIDE;
505 :
506 : virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
507 : };
508 :
509 :
510 0 : class XclRefmode : public XclExpBoolRecord
511 : {
512 : public:
513 : XclRefmode( const ScDocument& );
514 :
515 : virtual void SaveXml( XclExpXmlStream& rStrm ) SAL_OVERRIDE;
516 : };
517 :
518 : class XclExpFileEncryption : public XclExpRecord
519 : {
520 : public:
521 : explicit XclExpFileEncryption( const XclExpRoot& rRoot );
522 : virtual ~XclExpFileEncryption();
523 :
524 : private:
525 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
526 :
527 : private:
528 : const XclExpRoot& mrRoot;
529 : };
530 :
531 : /** Beginning of User Interface Records */
532 0 : class XclExpInterfaceHdr : public XclExpUInt16Record
533 : {
534 : public:
535 : explicit XclExpInterfaceHdr( sal_uInt16 nCodePage );
536 :
537 : private:
538 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
539 : };
540 :
541 : /** End of User Interface Records */
542 : class XclExpInterfaceEnd : public XclExpRecord
543 : {
544 : public:
545 : explicit XclExpInterfaceEnd();
546 : virtual ~XclExpInterfaceEnd();
547 :
548 : private:
549 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
550 : };
551 :
552 : /** Write Access User Name - This record contains the user name, which is
553 : the name you type when you install Excel. */
554 : class XclExpWriteAccess : public XclExpRecord
555 : {
556 : public:
557 : explicit XclExpWriteAccess();
558 : virtual ~XclExpWriteAccess();
559 :
560 : private:
561 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
562 : };
563 :
564 0 : class XclExpFileSharing : public XclExpRecord
565 : {
566 : public:
567 : explicit XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash, bool bRecommendReadOnly );
568 :
569 : virtual void Save( XclExpStream& rStrm ) SAL_OVERRIDE;
570 :
571 : private:
572 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
573 :
574 : private:
575 : XclExpString maUserName;
576 : sal_uInt16 mnPasswordHash;
577 : bool mbRecommendReadOnly;
578 : };
579 :
580 : class XclExpProt4Rev : public XclExpRecord
581 : {
582 : public:
583 : explicit XclExpProt4Rev();
584 : virtual ~XclExpProt4Rev();
585 :
586 : private:
587 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
588 : };
589 :
590 : class XclExpProt4RevPass : public XclExpRecord
591 : {
592 : public:
593 : explicit XclExpProt4RevPass();
594 : virtual ~XclExpProt4RevPass();
595 :
596 : private:
597 : virtual void WriteBody( XclExpStream& rStrm ) SAL_OVERRIDE;
598 : };
599 :
600 0 : class XclExpRecalcId : public XclExpDummyRecord
601 : {
602 : public:
603 : explicit XclExpRecalcId();
604 : };
605 :
606 0 : class XclExpBookExt : public XclExpDummyRecord
607 : {
608 : public:
609 : explicit XclExpBookExt();
610 : };
611 :
612 :
613 : #endif // _XCL97REC_HXX
614 :
615 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|