Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / inc / xcl97rec.hxx
blob78d173568e97f2cce506f80ec61743952999b34e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <memory>
23 #include "excrecds.hxx"
24 #include "xlescher.hxx"
25 #include "xestring.hxx"
26 #include <tabprotection.hxx>
27 #include <svx/svdobj.hxx>
28 #include <oox/export/drawingml.hxx>
30 class XclObj;
31 class XclExpMsoDrawing;
32 class SdrCaptionObj;
33 class SdrTextObj;
34 class XclTxo;
35 class XclEscherEx;
37 class ScURLTransformer : public oox::drawingml::URLTransformer
39 public:
40 explicit ScURLTransformer(ScDocument& rDoc);
42 virtual OUString getTransformedString(const OUString& rURL) const override;
44 virtual bool isExternalURL(const OUString& rURL) const override;
46 private:
47 ScDocument& mrDoc;
50 class XclExpObjList : public ExcEmptyRec, protected XclExpRoot
52 public:
54 typedef std::vector<std::unique_ptr<XclObj>>::iterator iterator;
56 explicit XclExpObjList( const XclExpRoot& rRoot, XclEscherEx& rEscherEx );
57 virtual ~XclExpObjList() override;
59 /// return: 1-based ObjId
60 ///! count>=0xFFFF: Obj will be deleted, return 0
61 sal_uInt16 Add( std::unique_ptr<XclObj> );
63 /**
64 * @brief Remove last element in the list.
66 std::unique_ptr<XclObj> pop_back ();
68 bool empty () const { return maObjs.empty(); }
70 size_t size () const { return maObjs.size(); }
72 iterator begin () { return maObjs.begin(); }
74 iterator end () { return maObjs.end(); }
76 XclExpMsoDrawing* GetMsodrawingPerSheet() { return pMsodrawingPerSheet.get(); }
78 /// close groups and DgContainer opened in ctor
79 void EndSheet();
81 virtual void Save( XclExpStream& rStrm ) override;
82 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
84 private:
85 SCTAB mnScTab;
87 XclEscherEx& mrEscherEx;
88 std::unique_ptr<XclExpMsoDrawing> pMsodrawingPerSheet;
89 std::unique_ptr<XclExpMsoDrawing> pSolverContainer;
91 std::vector<std::unique_ptr<XclObj>> maObjs;
94 // --- class XclObj --------------------------------------------------
96 class XclObj : public XclExpRecord
98 protected:
99 XclEscherEx& mrEscherEx;
100 XclExpMsoDrawing* pMsodrawing;
101 std::unique_ptr<XclExpMsoDrawing> pClientTextbox;
102 std::unique_ptr<XclTxo> pTxo;
103 sal_uInt16 mnObjType;
104 sal_uInt16 nObjId;
105 sal_uInt16 nGrbit;
106 SCTAB mnScTab;
107 bool bFirstOnSheet;
109 bool mbOwnEscher; /// true = Escher part created on the fly.
111 /** @param bOwnEscher If set to true, this object will create its escher data.
112 See SetOwnEscher() for details. */
113 explicit XclObj( XclExpObjectManager& rObjMgr, sal_uInt16 nObjType, bool bOwnEscher = false );
115 void ImplWriteAnchor( const SdrObject* pSdrObj, const tools::Rectangle* pChildAnchor );
117 // overwritten for writing MSODRAWING record
118 virtual void WriteBody( XclExpStream& rStrm ) override;
119 virtual void WriteSubRecs( XclExpStream& rStrm );
120 void SaveTextRecs( XclExpStream& rStrm );
122 public:
123 virtual ~XclObj() override;
125 sal_uInt16 GetObjType() const { return mnObjType; }
127 void SetId( sal_uInt16 nId ) { nObjId = nId; }
129 void SetTab( SCTAB nScTab ) { mnScTab = nScTab; }
130 SCTAB GetTab() const { return mnScTab; }
132 void SetLocked( bool b ) { SetGrBit(b, 0x0001); }
133 void SetPrintable( bool b ) { SetGrBit(b, 0x0010); }
134 void SetAutoFill( bool b ) { SetGrBit(b, 0x2000); }
135 void SetAutoLine( bool b ) { SetGrBit(b, 0x4000); }
136 void SetGrBit( bool b, int f )
138 if (b)
139 nGrbit |= f;
140 else
141 nGrbit &= ~f;
144 // set corresponding Excel object type in OBJ/ftCmo
145 void SetEscherShapeType( sal_uInt16 nType );
146 void SetEscherShapeTypeGroup() { mnObjType = EXC_OBJTYPE_GROUP; }
148 /** If set to true, this object has created its own escher data.
149 @descr This causes the function EscherEx::EndShape() to not post process
150 this object. This is used i.e. for form controls. They are not handled in
151 the svx base code, so the XclExpEscherOcxCtrl c'tor creates the escher data
152 itself. The svx base code does not receive the correct shape ID after the
153 EscherEx::StartShape() call, which would result in deleting the object in
154 EscherEx::EndShape(). */
155 /** Returns true, if the object has created the escher data itself.
156 @descr See SetOwnEscher() for details. */
157 bool IsOwnEscher() const { return mbOwnEscher; }
159 //! actually writes ESCHER_ClientTextbox
160 void SetText( const XclExpRoot& rRoot, const SdrTextObj& rObj );
162 virtual void Save( XclExpStream& rStrm ) override;
165 // --- class XclObjComment -------------------------------------------
167 class XclObjComment : public XclObj
169 ScAddress maScPos;
171 // no need to use std::unique_ptr< SdrCaptionObj >
172 SdrCaptionObj* mpCaption;
174 bool mbVisible;
175 tools::Rectangle maFrom;
176 tools::Rectangle maTo;
178 public:
179 XclObjComment( XclExpObjectManager& rObjMgr,
180 const tools::Rectangle& rRect, const EditTextObject& rEditObj, SdrCaptionObj* pCaption, bool bVisible, const ScAddress& rAddress, const tools::Rectangle &rFrom, const tools::Rectangle &To );
181 virtual ~XclObjComment() override;
183 /** c'tor process for formatted text objects above .
184 @descr used to construct the MSODRAWING Escher object properties. */
185 void ProcessEscherObj( const XclExpRoot& rRoot,
186 const tools::Rectangle& rRect, SdrObject* pCaption, bool bVisible );
188 virtual void Save( XclExpStream& rStrm ) override;
189 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
192 // --- class XclObjDropDown ------------------------------------------
194 class XclObjDropDown : public XclObj
196 private:
197 bool bIsFiltered;
199 virtual void WriteSubRecs( XclExpStream& rStrm ) override;
201 protected:
202 public:
203 XclObjDropDown( XclExpObjectManager& rObjMgr, const ScAddress& rPos, bool bFilt );
204 virtual ~XclObjDropDown() override;
207 // --- class XclTxo --------------------------------------------------
209 class XclTxo : public ExcRecord
211 public:
212 XclTxo( const OUString& rString, sal_uInt16 nFontIx );
213 XclTxo( const XclExpRoot& rRoot, const SdrTextObj& rEditObj );
214 XclTxo( const XclExpRoot& rRoot, const EditTextObject& rEditObj, SdrObject* pCaption );
216 void SetHorAlign( sal_uInt8 nHorAlign ) { mnHorAlign = nHorAlign; }
217 void SetVerAlign( sal_uInt8 nVerAlign ) { mnVerAlign = nVerAlign; }
219 virtual void Save( XclExpStream& rStrm ) override;
221 virtual sal_uInt16 GetNum() const override;
222 virtual std::size_t GetLen() const override;
224 private:
225 virtual void SaveCont( XclExpStream& rStrm ) override;
227 private:
228 XclExpStringRef mpString; /// Text and formatting data.
229 sal_uInt16 mnRotation; /// Text rotation.
230 sal_uInt8 mnHorAlign; /// Horizontal alignment.
231 sal_uInt8 mnVerAlign; /// Vertical alignment.
234 // --- class XclObjOle -----------------------------------------------
236 class XclObjOle : public XclObj
238 private:
240 const SdrObject& rOleObj;
241 SotStorage* pRootStorage;
243 virtual void WriteSubRecs( XclExpStream& rStrm ) override;
245 public:
246 XclObjOle( XclExpObjectManager& rObjMgr, const SdrObject& rObj );
247 virtual ~XclObjOle() override;
249 virtual void Save( XclExpStream& rStrm ) override;
252 // --- class XclObjAny -----------------------------------------------
254 class XclObjAny : public XclObj
256 protected:
257 virtual void WriteSubRecs( XclExpStream& rStrm ) override;
259 public:
260 XclObjAny( XclExpObjectManager& rObjMgr,
261 const css::uno::Reference< css::drawing::XShape >& rShape,
262 ScDocument* pDoc);
263 virtual ~XclObjAny() override;
265 const css::uno::Reference< css::drawing::XShape >&
266 GetShape() const { return mxShape; }
268 virtual void Save( XclExpStream& rStrm ) override;
269 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
270 static void WriteFromTo( XclExpXmlStream& rStrm, const XclObjAny& rObj );
271 static void WriteFromTo( XclExpXmlStream& rStrm, const css::uno::Reference< css::drawing::XShape >& rShape, SCTAB nTab );
273 private:
274 css::uno::Reference< css::drawing::XShape >
275 mxShape;
276 ScDocument* mpDoc;
279 // --- class ExcBof8_Base --------------------------------------------
281 class ExcBof8_Base : public ExcBof_Base
283 protected:
284 virtual void SaveCont( XclExpStream& rStrm ) override;
286 public:
287 ExcBof8_Base();
289 virtual sal_uInt16 GetNum() const override;
290 virtual std::size_t GetLen() const override;
293 // --- class ExcBofW8 ------------------------------------------------
294 // Header Record for WORKBOOKS
296 class ExcBofW8 : public ExcBof8_Base
298 public:
299 ExcBofW8();
302 // --- class ExcBof8 -------------------------------------------------
303 // Header Record for WORKSHEETS
305 class ExcBof8 : public ExcBof8_Base
307 public:
308 ExcBof8();
311 // --- class ExcBundlesheet8 -----------------------------------------
313 class ExcBundlesheet8 : public ExcBundlesheetBase
315 private:
316 OUString sUnicodeName;
317 XclExpString GetName() const { return XclExpString( sUnicodeName, XclStrFlags::EightBitLength );}
319 virtual void SaveCont( XclExpStream& rStrm ) override;
321 public:
322 ExcBundlesheet8( const RootData& rRootData, SCTAB nTab );
323 ExcBundlesheet8( OUString aString );
325 virtual std::size_t GetLen() const override;
327 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
330 // --- class XclObproj -----------------------------------------------
332 class XclObproj : public ExcRecord
334 public:
335 virtual sal_uInt16 GetNum() const override;
336 virtual std::size_t GetLen() const override;
339 // ---- class XclCodename --------------------------------------------
341 class XclCodename : public ExcRecord
343 private:
344 XclExpString aName;
345 virtual void SaveCont( XclExpStream& rStrm ) override;
346 public:
347 XclCodename( const OUString& );
349 virtual sal_uInt16 GetNum() const override;
350 virtual std::size_t GetLen() const override;
353 // ---- Scenarios ----------------------------------------------------
354 // - ExcEScenarioCell a cell of a scenario range
355 // - ExcEScenario all ranges of a scenario table
356 // - ExcEScenarioManager list of scenario tables
358 class ExcEScenarioCell
360 private:
361 sal_uInt16 nCol;
362 sal_uInt16 nRow;
363 XclExpString sText;
365 protected:
366 public:
367 ExcEScenarioCell( sal_uInt16 nC, sal_uInt16 nR, const OUString& rTxt );
369 std::size_t GetStringBytes() const
370 { return sText.GetSize(); }
372 void WriteAddress( XclExpStream& rStrm ) const ;
373 void WriteText( XclExpStream& rStrm ) const;
375 void SaveXml( XclExpXmlStream& rStrm ) const;
378 class ExcEScenario : public ExcRecord
380 private:
381 std::size_t nRecLen;
382 XclExpString sName;
383 XclExpString sComment;
384 XclExpString sUserName;
385 bool bProtected;
387 std::vector<ExcEScenarioCell> aCells;
389 bool Append( sal_uInt16 nCol, sal_uInt16 nRow, const OUString& rTxt );
391 virtual void SaveCont( XclExpStream& rStrm ) override;
393 protected:
394 public:
395 ExcEScenario( const XclExpRoot& rRoot, SCTAB nTab );
397 virtual sal_uInt16 GetNum() const override;
398 virtual std::size_t GetLen() const override;
400 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
403 class ExcEScenarioManager : public ExcRecord
405 private:
406 sal_uInt16 nActive;
407 std::vector<ExcEScenario> aScenes;
409 virtual void SaveCont( XclExpStream& rStrm ) override;
411 protected:
412 public:
413 ExcEScenarioManager( const XclExpRoot& rRoot, SCTAB nTab );
414 virtual ~ExcEScenarioManager() override;
416 virtual void Save( XclExpStream& rStrm ) override;
417 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
419 virtual sal_uInt16 GetNum() const override;
420 virtual std::size_t GetLen() const override;
423 /** Represents a FEATHDR (SHEETPROTECTION) record that stores sheet protection
424 options. Note that a sheet still needs to save its sheet protection
425 options even when it's not protected. */
426 class XclExpSheetProtectOptions : public XclExpRecord
428 public:
429 explicit XclExpSheetProtectOptions( const XclExpRoot& rRoot, SCTAB nTab );
431 private:
432 virtual void WriteBody( XclExpStream& rStrm ) override;
434 private:
435 sal_uInt16 mnOptions; /// Encoded sheet protection options.
438 /** Represents one EnhancedProtection feature in a FEAT record.
439 To be written only if such feature exists. */
440 class XclExpSheetEnhancedProtection : public XclExpRecord
442 public:
443 explicit XclExpSheetEnhancedProtection( const XclExpRoot& rRoot, ScEnhancedProtection aProt );
445 private:
446 virtual void WriteBody( XclExpStream& rStrm ) override;
448 private:
449 const XclExpRoot& mrRoot;
450 ScEnhancedProtection maEnhancedProtection;
453 class XclCalccount : public ExcRecord
455 private:
456 sal_uInt16 nCount;
457 protected:
458 virtual void SaveCont( XclExpStream& rStrm ) override;
459 public:
460 XclCalccount( const ScDocument& );
462 virtual sal_uInt16 GetNum() const override;
463 virtual std::size_t GetLen() const override;
465 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
468 class XclIteration : public ExcRecord
470 private:
471 sal_uInt16 nIter;
472 protected:
473 virtual void SaveCont( XclExpStream& rStrm ) override;
474 public:
475 XclIteration( const ScDocument& );
477 virtual sal_uInt16 GetNum() const override;
478 virtual std::size_t GetLen() const override;
480 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
483 class XclDelta : public ExcRecord
485 private:
486 double fDelta;
487 protected:
488 virtual void SaveCont( XclExpStream& rStrm ) override;
489 public:
490 XclDelta( const ScDocument& );
492 virtual sal_uInt16 GetNum() const override;
493 virtual std::size_t GetLen() const override;
495 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
498 class XclRefmode : public XclExpBoolRecord
500 public:
501 XclRefmode( const ScDocument& );
503 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
506 class XclExpFileEncryption : public XclExpRecord
508 public:
509 explicit XclExpFileEncryption( const XclExpRoot& rRoot );
510 virtual ~XclExpFileEncryption() override;
512 private:
513 virtual void WriteBody( XclExpStream& rStrm ) override;
515 private:
516 const XclExpRoot& mrRoot;
519 /** Beginning of User Interface Records */
520 class XclExpInterfaceHdr : public XclExpUInt16Record
522 public:
523 explicit XclExpInterfaceHdr( sal_uInt16 nCodePage );
525 private:
526 virtual void WriteBody( XclExpStream& rStrm ) override;
529 /** End of User Interface Records */
530 class XclExpInterfaceEnd : public XclExpRecord
532 public:
533 explicit XclExpInterfaceEnd();
534 virtual ~XclExpInterfaceEnd() override;
536 private:
537 virtual void WriteBody( XclExpStream& rStrm ) override;
540 /** Write Access User Name - This record contains the user name, which is
541 the name you type when you install Excel. */
542 class XclExpWriteAccess : public XclExpRecord
544 public:
545 explicit XclExpWriteAccess();
546 virtual ~XclExpWriteAccess() override;
548 private:
549 virtual void WriteBody( XclExpStream& rStrm ) override;
552 class XclExpFileSharing : public XclExpRecord
554 public:
555 explicit XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash, bool bRecommendReadOnly );
557 virtual void Save( XclExpStream& rStrm ) override;
559 private:
560 virtual void WriteBody( XclExpStream& rStrm ) override;
562 private:
563 XclExpString maUserName;
564 sal_uInt16 mnPasswordHash;
565 bool mbRecommendReadOnly;
568 class XclExpProt4Rev : public XclExpRecord
570 public:
571 explicit XclExpProt4Rev();
572 virtual ~XclExpProt4Rev() override;
574 private:
575 virtual void WriteBody( XclExpStream& rStrm ) override;
578 class XclExpProt4RevPass : public XclExpRecord
580 public:
581 explicit XclExpProt4RevPass();
582 virtual ~XclExpProt4RevPass() override;
584 private:
585 virtual void WriteBody( XclExpStream& rStrm ) override;
588 class XclExpRecalcId : public XclExpDummyRecord
590 public:
591 explicit XclExpRecalcId();
594 class XclExpBookExt : public XclExpDummyRecord
596 public:
597 explicit XclExpBookExt();
600 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */