Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / filter / inc / xcl97esc.hxx
bloba3895c7c5efcc62acfcb7ce9e9fc03d00ed977ec
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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XCL97ESC_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XCL97ESC_HXX
23 #include <memory>
24 #include <stack>
25 #include <filter/msfilter/escherex.hxx>
26 #include "xlescher.hxx"
27 #include "xeroot.hxx"
28 #include <vector>
30 namespace utl { class TempFile; }
32 class SvStream;
34 class XclEscherExGlobal : public EscherExGlobal, protected XclExpRoot
36 public:
37 explicit XclEscherExGlobal( const XclExpRoot& rRoot );
39 private:
40 /** Override to create a new temporary file and return its stream. */
41 virtual SvStream* ImplQueryPictureStream() override;
43 private:
44 ::std::unique_ptr< ::utl::TempFile > mxPicTempFile;
45 ::std::unique_ptr< SvStream > mxPicStrm;
48 class XclObj;
49 class XclExpDffAnchorBase;
50 class XclEscherHostAppData;
51 class XclEscherClientData;
52 class XclEscherClientTextbox;
53 class XclExpOcxControlObj;
54 class XclExpTbxControlObj;
55 class XclExpShapeObj;
56 class EscherExHostAppData;
57 class ShapeInteractionHelper
59 public:
60 static XclExpShapeObj* CreateShapeObj( XclExpObjectManager& rObjMgr, const css::uno::Reference<
61 css::drawing::XShape >& xShape, ScDocument* pDoc );
62 static void PopulateShapeInteractionInfo( XclExpObjectManager& rObjMgr, const css::uno::Reference< css::drawing::XShape >& xShape, EscherExHostAppData& rHostAppData );
65 class XclEscherEx : public EscherEx, protected XclExpRoot
67 public:
68 explicit XclEscherEx(
69 const XclExpRoot& rRoot,
70 XclExpObjectManager& rObjMgr,
71 SvStream& rStrm,
72 const XclEscherEx* pParent = nullptr );
73 virtual ~XclEscherEx();
75 /** Called by MSODRAWING record constructors to initialize the DFF stream
76 fragment they will own. returns the DFF fragment identifier. */
77 sal_uInt32 InitNextDffFragment();
78 /** Called after some data has been written to the DFF stream, to update
79 the end position of the DFF fragment owned by an MSODRAWING record. */
80 void UpdateDffFragmentEnd();
82 /** Returns the position of the specified DFF stream fragment. */
83 sal_uInt32 GetDffFragmentPos( sal_uInt32 nFragmentKey );
84 /** Returns the size of the specified DFF stream fragment. */
85 sal_uInt32 GetDffFragmentSize( sal_uInt32 nFragmentKey );
86 /** Returns true, if there is more data left in the DFF stream than owned
87 by the last MSODRAWING record. */
88 bool HasPendingDffData();
90 /** Creates a new DFF client anchor object and calculates the anchor
91 position of the passed object. Caller takes ownership! */
92 XclExpDffAnchorBase* CreateDffAnchor( const SdrObject& rSdrObj ) const;
94 virtual EscherExHostAppData* StartShape(
95 const css::uno::Reference< css::drawing::XShape>& rxShape,
96 const Rectangle* pChildAnchor ) override;
97 virtual void EndShape( sal_uInt16 nShapeType, sal_uInt32 nShapeID ) override;
98 virtual EscherExHostAppData* EnterAdditionalTextGroup() override;
100 /// Flush and merge PicStream into EscherStream
101 void EndDocument();
102 /** Creates an OCX form control OBJ record from the passed form control.
103 @descr Writes the form control data to the 'Ctls' stream. */
104 std::unique_ptr<XclExpOcxControlObj> CreateOCXCtrlObj(
105 css::uno::Reference< css::drawing::XShape > xShape,
106 const Rectangle* pChildAnchor );
108 private:
109 tools::SvRef<SotStorageStream> mxCtlsStrm; /// The 'Ctls' stream.
110 /** Creates a TBX form control OBJ record from the passed form control. */
111 std::unique_ptr<XclExpTbxControlObj> CreateTBXCtrlObj(
112 css::uno::Reference< css::drawing::XShape > xShape,
113 const Rectangle* pChildAnchor );
115 private:
116 /** Tries to get the name of a Basic macro from a control. */
117 void ConvertTbxMacro(
118 XclExpTbxControlObj& rTbxCtrlObj,
119 css::uno::Reference< css::awt::XControlModel > xCtrlModel );
121 void DeleteCurrAppData();
123 private:
124 XclExpObjectManager& mrObjMgr;
125 std::stack< std::pair< XclObj*, XclEscherHostAppData* > > aStack;
126 XclObj* pCurrXclObj;
127 XclEscherHostAppData* pCurrAppData;
128 XclEscherClientData* pTheClientData; // always the same
129 XclEscherClientTextbox* pAdditionalText;
130 sal_uInt16 nAdditionalText;
131 sal_uInt32 mnNextKey;
132 bool mbIsRootDff;
135 // --- class XclEscherHostAppData ------------------------------------
137 class XclEscherHostAppData : public EscherExHostAppData
139 private:
140 bool bStackedGroup;
142 public:
143 XclEscherHostAppData() : bStackedGroup( false )
145 inline void SetStackedGroup( bool b ) { bStackedGroup = b; }
146 inline bool IsStackedGroup() const { return bStackedGroup; }
149 // --- class XclEscherClientData -------------------------------------
151 class XclEscherClientData : public EscherExClientRecord_Base
153 public:
154 XclEscherClientData() {}
155 virtual void WriteData( EscherEx& rEx ) const override;
158 // --- class XclEscherClientTextbox ----------------------------------
160 class SdrTextObj;
162 class XclEscherClientTextbox : public EscherExClientRecord_Base, protected XclExpRoot
164 private:
165 const SdrTextObj& rTextObj;
166 XclObj* pXclObj;
168 public:
169 XclEscherClientTextbox(
170 const XclExpRoot& rRoot,
171 const SdrTextObj& rObj,
172 XclObj* pObj );
174 //! ONLY for the AdditionalText mimic
175 inline void SetXclObj( XclObj* p ) { pXclObj = p; }
177 virtual void WriteData( EscherEx& rEx ) const override;
180 #endif // _XCL97ESC_HXX
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */