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
;
38 class ScURLTransformer
: public oox::drawingml::URLTransformer
41 explicit ScURLTransformer(ScDocument
& rDoc
);
43 virtual OUString
getTransformedString(const OUString
& rURL
) const override
;
45 virtual bool isExternalURL(const OUString
& rURL
) const override
;
51 class XclExpObjList
: public ExcEmptyRec
, protected XclExpRoot
55 typedef std::vector
<std::unique_ptr
<XclObj
>>::iterator iterator
;
57 explicit XclExpObjList( const XclExpRoot
& rRoot
, XclEscherEx
& rEscherEx
);
58 virtual ~XclExpObjList() override
;
60 /// return: 1-based ObjId
61 ///! count>=0xFFFF: Obj will be deleted, return 0
62 sal_uInt16
Add( std::unique_ptr
<XclObj
> );
65 * @brief Remove last element in the list.
67 std::unique_ptr
<XclObj
> pop_back ();
69 bool empty () const { return maObjs
.empty(); }
71 size_t size () const { return maObjs
.size(); }
73 iterator
begin () { return maObjs
.begin(); }
75 iterator
end () { return maObjs
.end(); }
77 XclExpMsoDrawing
* GetMsodrawingPerSheet() { return pMsodrawingPerSheet
.get(); }
79 /// close groups and DgContainer opened in ctor
82 virtual void Save( XclExpStream
& rStrm
) override
;
83 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
88 XclEscherEx
& mrEscherEx
;
89 std::unique_ptr
<XclExpMsoDrawing
> pMsodrawingPerSheet
;
90 std::unique_ptr
<XclExpMsoDrawing
> pSolverContainer
;
92 std::vector
<std::unique_ptr
<XclObj
>> maObjs
;
95 // --- class XclObj --------------------------------------------------
97 class XclObj
: public XclExpRecord
100 XclEscherEx
& mrEscherEx
;
101 XclExpMsoDrawing
* pMsodrawing
;
102 std::unique_ptr
<XclExpMsoDrawing
> pClientTextbox
;
103 std::unique_ptr
<XclTxo
> pTxo
;
104 sal_uInt16 mnObjType
;
110 bool mbOwnEscher
; /// true = Escher part created on the fly.
112 /** @param bOwnEscher If set to true, this object will create its escher data.
113 See SetOwnEscher() for details. */
114 explicit XclObj( XclExpObjectManager
& rObjMgr
, sal_uInt16 nObjType
, bool bOwnEscher
= false );
116 void ImplWriteAnchor( const SdrObject
* pSdrObj
, const tools::Rectangle
* pChildAnchor
);
118 // overwritten for writing MSODRAWING record
119 virtual void WriteBody( XclExpStream
& rStrm
) override
;
120 virtual void WriteSubRecs( XclExpStream
& rStrm
);
121 void SaveTextRecs( XclExpStream
& rStrm
);
124 virtual ~XclObj() override
;
126 sal_uInt16
GetObjType() const { return mnObjType
; }
128 void SetId( sal_uInt16 nId
) { nObjId
= nId
; }
130 void SetTab( SCTAB nScTab
) { mnScTab
= nScTab
; }
131 SCTAB
GetTab() const { return mnScTab
; }
133 void SetLocked( bool b
) { SetGrBit(b
, 0x0001); }
134 void SetPrintable( bool b
) { SetGrBit(b
, 0x0010); }
135 void SetAutoFill( bool b
) { SetGrBit(b
, 0x2000); }
136 void SetAutoLine( bool b
) { SetGrBit(b
, 0x4000); }
137 void SetGrBit( bool b
, int f
)
145 // set corresponding Excel object type in OBJ/ftCmo
146 void SetEscherShapeType( sal_uInt16 nType
);
147 void SetEscherShapeTypeGroup() { mnObjType
= EXC_OBJTYPE_GROUP
; }
149 /** If set to true, this object has created its own escher data.
150 @descr This causes the function EscherEx::EndShape() to not post process
151 this object. This is used i.e. for form controls. They are not handled in
152 the svx base code, so the XclExpEscherOcxCtrl c'tor creates the escher data
153 itself. The svx base code does not receive the correct shape ID after the
154 EscherEx::StartShape() call, which would result in deleting the object in
155 EscherEx::EndShape(). */
156 /** Returns true, if the object has created the escher data itself.
157 @descr See SetOwnEscher() for details. */
158 bool IsOwnEscher() const { return mbOwnEscher
; }
160 //! actually writes ESCHER_ClientTextbox
161 void SetText( const XclExpRoot
& rRoot
, const SdrTextObj
& rObj
);
163 virtual void Save( XclExpStream
& rStrm
) override
;
166 // --- class XclObjComment -------------------------------------------
168 class XclObjComment
: public XclObj
172 // no need to use std::unique_ptr< SdrCaptionObj >
173 SdrCaptionObj
* mpCaption
;
176 tools::Rectangle maFrom
;
177 tools::Rectangle maTo
;
180 XclObjComment( XclExpObjectManager
& rObjMgr
,
181 const tools::Rectangle
& rRect
, const EditTextObject
& rEditObj
, SdrCaptionObj
* pCaption
, bool bVisible
, const ScAddress
& rAddress
, const tools::Rectangle
&rFrom
, const tools::Rectangle
&To
);
182 virtual ~XclObjComment() override
;
184 /** c'tor process for formatted text objects above .
185 @descr used to construct the MSODRAWING Escher object properties. */
186 void ProcessEscherObj( const XclExpRoot
& rRoot
,
187 const tools::Rectangle
& rRect
, SdrObject
* pCaption
, bool bVisible
);
189 virtual void Save( XclExpStream
& rStrm
) override
;
190 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
193 // --- class XclObjDropDown ------------------------------------------
195 class XclObjDropDown
: public XclObj
200 virtual void WriteSubRecs( XclExpStream
& rStrm
) override
;
204 XclObjDropDown( XclExpObjectManager
& rObjMgr
, const ScAddress
& rPos
, bool bFilt
);
205 virtual ~XclObjDropDown() override
;
208 // --- class XclTxo --------------------------------------------------
210 class XclTxo
: public ExcRecord
213 XclTxo( const OUString
& rString
, sal_uInt16 nFontIx
);
214 XclTxo( const XclExpRoot
& rRoot
, const SdrTextObj
& rEditObj
);
215 XclTxo( const XclExpRoot
& rRoot
, const EditTextObject
& rEditObj
, SdrObject
* pCaption
);
217 void SetHorAlign( sal_uInt8 nHorAlign
) { mnHorAlign
= nHorAlign
; }
218 void SetVerAlign( sal_uInt8 nVerAlign
) { mnVerAlign
= nVerAlign
; }
220 virtual void Save( XclExpStream
& rStrm
) override
;
222 virtual sal_uInt16
GetNum() const override
;
223 virtual std::size_t GetLen() const override
;
226 virtual void SaveCont( XclExpStream
& rStrm
) override
;
229 XclExpStringRef mpString
; /// Text and formatting data.
230 sal_uInt16 mnRotation
; /// Text rotation.
231 sal_uInt8 mnHorAlign
; /// Horizontal alignment.
232 sal_uInt8 mnVerAlign
; /// Vertical alignment.
235 // --- class XclObjOle -----------------------------------------------
237 class XclObjOle
: public XclObj
241 const SdrOle2Obj
& rOleObj
;
242 SotStorage
* pRootStorage
;
244 virtual void WriteSubRecs( XclExpStream
& rStrm
) override
;
247 XclObjOle( XclExpObjectManager
& rObjMgr
, const SdrOle2Obj
& rObj
);
248 virtual ~XclObjOle() override
;
250 virtual void Save( XclExpStream
& rStrm
) override
;
253 // --- class XclObjAny -----------------------------------------------
255 class XclObjAny
: public XclObj
258 virtual void WriteSubRecs( XclExpStream
& rStrm
) override
;
261 XclObjAny( XclExpObjectManager
& rObjMgr
,
262 const css::uno::Reference
< css::drawing::XShape
>& rShape
,
264 virtual ~XclObjAny() override
;
266 const css::uno::Reference
< css::drawing::XShape
>&
267 GetShape() const { return mxShape
; }
269 virtual void Save( XclExpStream
& rStrm
) override
;
270 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
271 static void WriteFromTo( XclExpXmlStream
& rStrm
, const XclObjAny
& rObj
);
272 static void WriteFromTo( XclExpXmlStream
& rStrm
, const css::uno::Reference
< css::drawing::XShape
>& rShape
, SCTAB nTab
);
275 css::uno::Reference
< css::drawing::XShape
>
280 // --- class ExcBof8_Base --------------------------------------------
282 class ExcBof8_Base
: public ExcBof_Base
285 virtual void SaveCont( XclExpStream
& rStrm
) override
;
290 virtual sal_uInt16
GetNum() const override
;
291 virtual std::size_t GetLen() const override
;
294 // --- class ExcBofW8 ------------------------------------------------
295 // Header Record for WORKBOOKS
297 class ExcBofW8
: public ExcBof8_Base
303 // --- class ExcBof8 -------------------------------------------------
304 // Header Record for WORKSHEETS
306 class ExcBof8
: public ExcBof8_Base
312 // --- class ExcBundlesheet8 -----------------------------------------
314 class ExcBundlesheet8
: public ExcBundlesheetBase
317 OUString sUnicodeName
;
318 XclExpString
GetName() const { return XclExpString( sUnicodeName
, XclStrFlags::EightBitLength
);}
320 virtual void SaveCont( XclExpStream
& rStrm
) override
;
323 ExcBundlesheet8( const RootData
& rRootData
, SCTAB nTab
);
324 ExcBundlesheet8( OUString aString
);
326 virtual std::size_t GetLen() const override
;
328 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
331 // --- class XclObproj -----------------------------------------------
333 class XclObproj
: public ExcRecord
336 virtual sal_uInt16
GetNum() const override
;
337 virtual std::size_t GetLen() const override
;
340 // ---- class XclCodename --------------------------------------------
342 class XclCodename
: public ExcRecord
346 virtual void SaveCont( XclExpStream
& rStrm
) override
;
348 XclCodename( const OUString
& );
350 virtual sal_uInt16
GetNum() const override
;
351 virtual std::size_t GetLen() const override
;
354 // ---- Scenarios ----------------------------------------------------
355 // - ExcEScenarioCell a cell of a scenario range
356 // - ExcEScenario all ranges of a scenario table
357 // - ExcEScenarioManager list of scenario tables
359 class ExcEScenarioCell
368 ExcEScenarioCell( sal_uInt16 nC
, sal_uInt16 nR
, const OUString
& rTxt
);
370 std::size_t GetStringBytes() const
371 { return sText
.GetSize(); }
373 void WriteAddress( XclExpStream
& rStrm
) const ;
374 void WriteText( XclExpStream
& rStrm
) const;
376 void SaveXml( XclExpXmlStream
& rStrm
) const;
379 class ExcEScenario
: public ExcRecord
384 XclExpString sComment
;
385 XclExpString sUserName
;
388 std::vector
<ExcEScenarioCell
> aCells
;
390 bool Append( sal_uInt16 nCol
, sal_uInt16 nRow
, const OUString
& rTxt
);
392 virtual void SaveCont( XclExpStream
& rStrm
) override
;
396 ExcEScenario( const XclExpRoot
& rRoot
, SCTAB nTab
);
398 virtual sal_uInt16
GetNum() const override
;
399 virtual std::size_t GetLen() const override
;
401 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
404 class ExcEScenarioManager
: public ExcRecord
408 std::vector
<ExcEScenario
> aScenes
;
410 virtual void SaveCont( XclExpStream
& rStrm
) override
;
414 ExcEScenarioManager( const XclExpRoot
& rRoot
, SCTAB nTab
);
415 virtual ~ExcEScenarioManager() override
;
417 virtual void Save( XclExpStream
& rStrm
) override
;
418 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
420 virtual sal_uInt16
GetNum() const override
;
421 virtual std::size_t GetLen() const override
;
424 /** Represents a FEATHDR (SHEETPROTECTION) record that stores sheet protection
425 options. Note that a sheet still needs to save its sheet protection
426 options even when it's not protected. */
427 class XclExpSheetProtectOptions
: public XclExpRecord
430 explicit XclExpSheetProtectOptions( const XclExpRoot
& rRoot
, SCTAB nTab
);
433 virtual void WriteBody( XclExpStream
& rStrm
) override
;
436 sal_uInt16 mnOptions
; /// Encoded sheet protection options.
439 /** Represents one EnhancedProtection feature in a FEAT record.
440 To be written only if such feature exists. */
441 class XclExpSheetEnhancedProtection
: public XclExpRecord
444 explicit XclExpSheetEnhancedProtection( const XclExpRoot
& rRoot
, ScEnhancedProtection aProt
);
447 virtual void WriteBody( XclExpStream
& rStrm
) override
;
450 const XclExpRoot
& mrRoot
;
451 ScEnhancedProtection maEnhancedProtection
;
454 class XclCalccount
: public ExcRecord
459 virtual void SaveCont( XclExpStream
& rStrm
) override
;
461 XclCalccount( const ScDocument
& );
463 virtual sal_uInt16
GetNum() const override
;
464 virtual std::size_t GetLen() const override
;
466 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
469 class XclIteration
: public ExcRecord
474 virtual void SaveCont( XclExpStream
& rStrm
) override
;
476 XclIteration( const ScDocument
& );
478 virtual sal_uInt16
GetNum() const override
;
479 virtual std::size_t GetLen() const override
;
481 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
484 class XclDelta
: public ExcRecord
489 virtual void SaveCont( XclExpStream
& rStrm
) override
;
491 XclDelta( const ScDocument
& );
493 virtual sal_uInt16
GetNum() const override
;
494 virtual std::size_t GetLen() const override
;
496 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
499 class XclRefmode
: public XclExpBoolRecord
502 XclRefmode( const ScDocument
& );
504 virtual void SaveXml( XclExpXmlStream
& rStrm
) override
;
507 class XclExpFileEncryption
: public XclExpRecord
510 explicit XclExpFileEncryption( const XclExpRoot
& rRoot
);
511 virtual ~XclExpFileEncryption() override
;
514 virtual void WriteBody( XclExpStream
& rStrm
) override
;
517 const XclExpRoot
& mrRoot
;
520 /** Beginning of User Interface Records */
521 class XclExpInterfaceHdr
: public XclExpUInt16Record
524 explicit XclExpInterfaceHdr( sal_uInt16 nCodePage
);
527 virtual void WriteBody( XclExpStream
& rStrm
) override
;
530 /** End of User Interface Records */
531 class XclExpInterfaceEnd
: public XclExpRecord
534 explicit XclExpInterfaceEnd();
535 virtual ~XclExpInterfaceEnd() override
;
538 virtual void WriteBody( XclExpStream
& rStrm
) override
;
541 /** Write Access User Name - This record contains the user name, which is
542 the name you type when you install Excel. */
543 class XclExpWriteAccess
: public XclExpRecord
546 explicit XclExpWriteAccess();
547 virtual ~XclExpWriteAccess() override
;
550 virtual void WriteBody( XclExpStream
& rStrm
) override
;
553 class XclExpFileSharing
: public XclExpRecord
556 explicit XclExpFileSharing( const XclExpRoot
& rRoot
, sal_uInt16 nPasswordHash
, bool bRecommendReadOnly
);
558 virtual void Save( XclExpStream
& rStrm
) override
;
561 virtual void WriteBody( XclExpStream
& rStrm
) override
;
564 XclExpString maUserName
;
565 sal_uInt16 mnPasswordHash
;
566 bool mbRecommendReadOnly
;
569 class XclExpProt4Rev
: public XclExpRecord
572 explicit XclExpProt4Rev();
573 virtual ~XclExpProt4Rev() override
;
576 virtual void WriteBody( XclExpStream
& rStrm
) override
;
579 class XclExpProt4RevPass
: public XclExpRecord
582 explicit XclExpProt4RevPass();
583 virtual ~XclExpProt4RevPass() override
;
586 virtual void WriteBody( XclExpStream
& rStrm
) override
;
589 class XclExpRecalcId
: public XclExpDummyRecord
592 explicit XclExpRecalcId();
595 class XclExpBookExt
: public XclExpDummyRecord
598 explicit XclExpBookExt();
601 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */