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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XCL97ESC_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XCL97ESC_HXX
25 #include <filter/msfilter/escherex.hxx>
27 #include <unotools/tempfile.hxx>
29 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ class XControlModel
; } } } }
31 class XclEscherExGlobal
: public EscherExGlobal
, protected XclExpRoot
34 explicit XclEscherExGlobal( const XclExpRoot
& rRoot
);
37 /** Override to create a new temporary file and return its stream. */
38 virtual SvStream
* ImplQueryPictureStream() override
;
41 ::std::unique_ptr
< ::utl::TempFile
> mxPicTempFile
;
42 ::std::unique_ptr
< SvStream
> mxPicStrm
;
46 class XclExpDffAnchorBase
;
47 class XclEscherHostAppData
;
48 class XclEscherClientData
;
49 class XclEscherClientTextbox
;
50 class XclExpOcxControlObj
;
51 class XclExpTbxControlObj
;
53 class ShapeInteractionHelper
56 static XclExpShapeObj
* CreateShapeObj( XclExpObjectManager
& rObjMgr
, const css::uno::Reference
<
57 css::drawing::XShape
>& xShape
, ScDocument
* pDoc
);
58 static void PopulateShapeInteractionInfo( const XclExpObjectManager
& rObjMgr
, const css::uno::Reference
< css::drawing::XShape
>& xShape
, EscherExHostAppData
& rHostAppData
);
61 class XclEscherEx
: public EscherEx
, protected XclExpRoot
65 const XclExpRoot
& rRoot
,
66 XclExpObjectManager
& rObjMgr
,
68 const XclEscherEx
* pParent
= nullptr );
69 virtual ~XclEscherEx() override
;
71 /** Called by MSODRAWING record constructors to initialize the DFF stream
72 fragment they will own. returns the DFF fragment identifier. */
73 sal_uInt32
InitNextDffFragment();
74 /** Called after some data has been written to the DFF stream, to update
75 the end position of the DFF fragment owned by an MSODRAWING record. */
76 void UpdateDffFragmentEnd();
78 /** Returns the position of the specified DFF stream fragment. */
79 sal_uInt32
GetDffFragmentPos( sal_uInt32 nFragmentKey
);
80 /** Returns the size of the specified DFF stream fragment. */
81 sal_uInt32
GetDffFragmentSize( sal_uInt32 nFragmentKey
);
82 /** Returns true, if there is more data left in the DFF stream than owned
83 by the last MSODRAWING record. */
84 bool HasPendingDffData();
86 /** Creates a new DFF client anchor object and calculates the anchor
87 position of the passed object. Caller takes ownership! */
88 XclExpDffAnchorBase
* CreateDffAnchor( const SdrObject
& rSdrObj
) const;
90 virtual EscherExHostAppData
* StartShape(
91 const css::uno::Reference
< css::drawing::XShape
>& rxShape
,
92 const tools::Rectangle
* pChildAnchor
) override
;
93 virtual void EndShape( sal_uInt16 nShapeType
, sal_uInt32 nShapeID
) override
;
94 virtual EscherExHostAppData
* EnterAdditionalTextGroup() override
;
96 /// Flush and merge PicStream into EscherStream
98 /** Creates an OCX form control OBJ record from the passed form control.
99 @descr Writes the form control data to the 'Ctls' stream. */
100 std::unique_ptr
<XclExpOcxControlObj
> CreateOCXCtrlObj(
101 css::uno::Reference
< css::drawing::XShape
> const & xShape
,
102 const tools::Rectangle
* pChildAnchor
);
105 tools::SvRef
<SotStorageStream
> mxCtlsStrm
; /// The 'Ctls' stream.
106 /** Creates a TBX form control OBJ record from the passed form control. */
107 std::unique_ptr
<XclExpTbxControlObj
> CreateTBXCtrlObj(
108 css::uno::Reference
< css::drawing::XShape
> const & xShape
,
109 const tools::Rectangle
* pChildAnchor
);
112 /** Tries to get the name of a Basic macro from a control. */
113 void ConvertTbxMacro(
114 XclExpTbxControlObj
& rTbxCtrlObj
,
115 css::uno::Reference
< css::awt::XControlModel
> const & xCtrlModel
);
117 void DeleteCurrAppData();
120 XclExpObjectManager
& mrObjMgr
;
121 std::stack
< std::pair
< XclObj
*, std::unique_ptr
<XclEscherHostAppData
> > > aStack
;
123 std::unique_ptr
<XclEscherHostAppData
> pCurrAppData
;
124 std::unique_ptr
<XclEscherClientData
> pTheClientData
; // always the same
125 XclEscherClientTextbox
* pAdditionalText
;
126 sal_uInt16 nAdditionalText
;
127 sal_uInt32 mnNextKey
;
128 bool const mbIsRootDff
;
131 // --- class XclEscherHostAppData ------------------------------------
133 class XclEscherHostAppData
: public EscherExHostAppData
139 XclEscherHostAppData() : bStackedGroup( false )
141 void SetStackedGroup( bool b
) { bStackedGroup
= b
; }
142 bool IsStackedGroup() const { return bStackedGroup
; }
145 // --- class XclEscherClientData -------------------------------------
147 class XclEscherClientData
: public EscherExClientRecord_Base
150 XclEscherClientData() {}
151 virtual void WriteData( EscherEx
& rEx
) const override
;
154 // --- class XclEscherClientTextbox ----------------------------------
158 class XclEscherClientTextbox
: public EscherExClientRecord_Base
, protected XclExpRoot
161 const SdrTextObj
& rTextObj
;
165 XclEscherClientTextbox(
166 const XclExpRoot
& rRoot
,
167 const SdrTextObj
& rObj
,
170 //! ONLY for the AdditionalText mimic
171 void SetXclObj( XclObj
* p
) { pXclObj
= p
; }
173 virtual void WriteData( EscherEx
& rEx
) const override
;
176 #endif // _XCL97ESC_HXX
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */