1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
31 class XclExpMsoDrawing
;
37 class ScURLTransformer
: public oox::drawingml::URLTransformer
40 explicit ScURLTransformer(ScDocument
& rDoc
);
42 virtual OUString
getTransformedString(const OUString
& rURL
) const override
;
44 virtual bool isExternalURL(const OUString
& rURL
) const override
;
50 class XclExpObjList
: public ExcEmptyRec
, protected XclExpRoot
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
> );
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
81 virtual void Save( XclExpStream
& rStrm
) override
;
82 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
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
99 XclEscherEx
& mrEscherEx
;
100 XclExpMsoDrawing
* pMsodrawing
;
101 std::unique_ptr
<XclExpMsoDrawing
> pClientTextbox
;
102 std::unique_ptr
<XclTxo
> pTxo
;
103 sal_uInt16 mnObjType
;
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
);
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
)
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
171 // no need to use std::unique_ptr< SdrCaptionObj >
172 SdrCaptionObj
* mpCaption
;
175 tools::Rectangle maFrom
;
176 tools::Rectangle maTo
;
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
199 virtual void WriteSubRecs( XclExpStream
& rStrm
) override
;
203 XclObjDropDown( XclExpObjectManager
& rObjMgr
, const ScAddress
& rPos
, bool bFilt
);
204 virtual ~XclObjDropDown() override
;
207 // --- class XclTxo --------------------------------------------------
209 class XclTxo
: public ExcRecord
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
;
225 virtual void SaveCont( XclExpStream
& rStrm
) override
;
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
240 const SdrObject
& rOleObj
;
241 SotStorage
* pRootStorage
;
243 virtual void WriteSubRecs( XclExpStream
& rStrm
) override
;
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
257 virtual void WriteSubRecs( XclExpStream
& rStrm
) override
;
260 XclObjAny( XclExpObjectManager
& rObjMgr
,
261 const css::uno::Reference
< css::drawing::XShape
>& rShape
,
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
);
274 css::uno::Reference
< css::drawing::XShape
>
279 // --- class ExcBof8_Base --------------------------------------------
281 class ExcBof8_Base
: public ExcBof_Base
284 virtual void SaveCont( XclExpStream
& rStrm
) override
;
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
302 // --- class ExcBof8 -------------------------------------------------
303 // Header Record for WORKSHEETS
305 class ExcBof8
: public ExcBof8_Base
311 // --- class ExcBundlesheet8 -----------------------------------------
313 class ExcBundlesheet8
: public ExcBundlesheetBase
316 OUString sUnicodeName
;
317 XclExpString
GetName() const { return XclExpString( sUnicodeName
, XclStrFlags::EightBitLength
);}
319 virtual void SaveCont( XclExpStream
& rStrm
) override
;
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
335 virtual sal_uInt16
GetNum() const override
;
336 virtual std::size_t GetLen() const override
;
339 // ---- class XclCodename --------------------------------------------
341 class XclCodename
: public ExcRecord
345 virtual void SaveCont( XclExpStream
& rStrm
) override
;
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
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
383 XclExpString sComment
;
384 XclExpString sUserName
;
387 std::vector
<ExcEScenarioCell
> aCells
;
389 bool Append( sal_uInt16 nCol
, sal_uInt16 nRow
, const OUString
& rTxt
);
391 virtual void SaveCont( XclExpStream
& rStrm
) override
;
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
407 std::vector
<ExcEScenario
> aScenes
;
409 virtual void SaveCont( XclExpStream
& rStrm
) override
;
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
429 explicit XclExpSheetProtectOptions( const XclExpRoot
& rRoot
, SCTAB nTab
);
432 virtual void WriteBody( XclExpStream
& rStrm
) override
;
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
443 explicit XclExpSheetEnhancedProtection( const XclExpRoot
& rRoot
, ScEnhancedProtection aProt
);
446 virtual void WriteBody( XclExpStream
& rStrm
) override
;
449 const XclExpRoot
& mrRoot
;
450 ScEnhancedProtection maEnhancedProtection
;
453 class XclCalccount
: public ExcRecord
458 virtual void SaveCont( XclExpStream
& rStrm
) override
;
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
473 virtual void SaveCont( XclExpStream
& rStrm
) override
;
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
488 virtual void SaveCont( XclExpStream
& rStrm
) override
;
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
501 XclRefmode( const ScDocument
& );
503 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
506 class XclExpFileEncryption
: public XclExpRecord
509 explicit XclExpFileEncryption( const XclExpRoot
& rRoot
);
510 virtual ~XclExpFileEncryption() override
;
513 virtual void WriteBody( XclExpStream
& rStrm
) override
;
516 const XclExpRoot
& mrRoot
;
519 /** Beginning of User Interface Records */
520 class XclExpInterfaceHdr
: public XclExpUInt16Record
523 explicit XclExpInterfaceHdr( sal_uInt16 nCodePage
);
526 virtual void WriteBody( XclExpStream
& rStrm
) override
;
529 /** End of User Interface Records */
530 class XclExpInterfaceEnd
: public XclExpRecord
533 explicit XclExpInterfaceEnd();
534 virtual ~XclExpInterfaceEnd() override
;
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
545 explicit XclExpWriteAccess();
546 virtual ~XclExpWriteAccess() override
;
549 virtual void WriteBody( XclExpStream
& rStrm
) override
;
552 class XclExpFileSharing
: public XclExpRecord
555 explicit XclExpFileSharing( const XclExpRoot
& rRoot
, sal_uInt16 nPasswordHash
, bool bRecommendReadOnly
);
557 virtual void Save( XclExpStream
& rStrm
) override
;
560 virtual void WriteBody( XclExpStream
& rStrm
) override
;
563 XclExpString maUserName
;
564 sal_uInt16 mnPasswordHash
;
565 bool mbRecommendReadOnly
;
568 class XclExpProt4Rev
: public XclExpRecord
571 explicit XclExpProt4Rev();
572 virtual ~XclExpProt4Rev() override
;
575 virtual void WriteBody( XclExpStream
& rStrm
) override
;
578 class XclExpProt4RevPass
: public XclExpRecord
581 explicit XclExpProt4RevPass();
582 virtual ~XclExpProt4RevPass() override
;
585 virtual void WriteBody( XclExpStream
& rStrm
) override
;
588 class XclExpRecalcId
: public XclExpDummyRecord
591 explicit XclExpRecalcId();
594 class XclExpBookExt
: public XclExpDummyRecord
597 explicit XclExpBookExt();
600 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */