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_XCL97ESC_HXX
21 : #define INCLUDED_SC_SOURCE_FILTER_INC_XCL97ESC_HXX
22 :
23 : #include <memory>
24 : #include <stack>
25 : #include <filter/msfilter/escherex.hxx>
26 : #include "xlescher.hxx"
27 : #include "xeroot.hxx"
28 : #include <vector>
29 :
30 : namespace utl { class TempFile; }
31 :
32 : class SvStream;
33 :
34 144 : class XclEscherExGlobal : public EscherExGlobal, protected XclExpRoot
35 : {
36 : public:
37 : explicit XclEscherExGlobal( const XclExpRoot& rRoot );
38 :
39 : private:
40 : /** Override to create a new temporary file and return its stream. */
41 : virtual SvStream* ImplQueryPictureStream() SAL_OVERRIDE;
42 :
43 : private:
44 : ::std::unique_ptr< ::utl::TempFile > mxPicTempFile;
45 : ::std::unique_ptr< SvStream > mxPicStrm;
46 : };
47 :
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
58 : {
59 : public:
60 : static XclExpShapeObj* CreateShapeObj( XclExpObjectManager& rObjMgr, const ::com::sun::star::uno::Reference<
61 : ::com::sun::star::drawing::XShape >& xShape, ScDocument* pDoc );
62 : static void PopulateShapeInteractionInfo( XclExpObjectManager& rObjMgr, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, EscherExHostAppData& rHostAppData );
63 : };
64 :
65 : class XclEscherEx : public EscherEx, protected XclExpRoot
66 : {
67 : public:
68 : explicit XclEscherEx(
69 : const XclExpRoot& rRoot,
70 : XclExpObjectManager& rObjMgr,
71 : SvStream& rStrm,
72 : const XclEscherEx* pParent = 0 );
73 : virtual ~XclEscherEx();
74 :
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();
81 :
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();
89 :
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;
93 :
94 : virtual EscherExHostAppData* StartShape(
95 : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& rxShape,
96 : const Rectangle* pChildAnchor ) SAL_OVERRIDE;
97 : virtual void EndShape( sal_uInt16 nShapeType, sal_uInt32 nShapeID ) SAL_OVERRIDE;
98 : virtual EscherExHostAppData* EnterAdditionalTextGroup() SAL_OVERRIDE;
99 :
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 : XclExpOcxControlObj* CreateOCXCtrlObj(
105 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
106 : const Rectangle* pChildAnchor );
107 :
108 : private:
109 : tools::SvRef<SotStorageStream> mxCtlsStrm; /// The 'Ctls' stream.
110 : /** Creates a TBX form control OBJ record from the passed form control. */
111 : XclExpTbxControlObj* CreateTBXCtrlObj(
112 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
113 : const Rectangle* pChildAnchor );
114 :
115 : private:
116 : /** Tries to get the name of a Basic macro from a control. */
117 : void ConvertTbxMacro(
118 : XclExpTbxControlObj& rTbxCtrlObj,
119 : ::com::sun::star::uno::Reference<
120 : ::com::sun::star::awt::XControlModel > xCtrlModel );
121 :
122 : void DeleteCurrAppData();
123 :
124 : private:
125 : XclExpObjectManager& mrObjMgr;
126 : std::stack< std::pair< XclObj*, XclEscherHostAppData* > > aStack;
127 : XclObj* pCurrXclObj;
128 : XclEscherHostAppData* pCurrAppData;
129 : XclEscherClientData* pTheClientData; // always the same
130 : XclEscherClientTextbox* pAdditionalText;
131 : sal_uInt16 nAdditionalText;
132 : sal_uInt32 mnNextKey;
133 : bool mbIsRootDff;
134 : };
135 :
136 : // --- class XclEscherHostAppData ------------------------------------
137 :
138 : class XclEscherHostAppData : public EscherExHostAppData
139 : {
140 : private:
141 : bool bStackedGroup;
142 :
143 : public:
144 58 : XclEscherHostAppData() : bStackedGroup( false )
145 58 : {}
146 0 : inline void SetStackedGroup( bool b ) { bStackedGroup = b; }
147 29 : inline bool IsStackedGroup() const { return bStackedGroup; }
148 : };
149 :
150 : // --- class XclEscherClientData -------------------------------------
151 :
152 144 : class XclEscherClientData : public EscherExClientRecord_Base
153 : {
154 : public:
155 72 : XclEscherClientData() {}
156 : virtual void WriteData( EscherEx& rEx ) const SAL_OVERRIDE;
157 : };
158 :
159 : // --- class XclEscherClientTextbox ----------------------------------
160 :
161 : class SdrTextObj;
162 :
163 18 : class XclEscherClientTextbox : public EscherExClientRecord_Base, protected XclExpRoot
164 : {
165 : private:
166 : const SdrTextObj& rTextObj;
167 : XclObj* pXclObj;
168 :
169 : public:
170 : XclEscherClientTextbox(
171 : const XclExpRoot& rRoot,
172 : const SdrTextObj& rObj,
173 : XclObj* pObj );
174 :
175 : //! ONLY for the AdditionalText mimic
176 0 : inline void SetXclObj( XclObj* p ) { pXclObj = p; }
177 :
178 : virtual void WriteData( EscherEx& rEx ) const SAL_OVERRIDE;
179 : };
180 :
181 : #endif // _XCL97ESC_HXX
182 :
183 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|