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