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 .
24 #include <filter/msfilter/escherex.hxx>
26 #include <unotools/tempfile.hxx>
28 namespace com::sun::star::awt
{ class XControlModel
; }
30 class XclEscherExGlobal
: public EscherExGlobal
, protected XclExpRoot
33 explicit XclEscherExGlobal( const XclExpRoot
& rRoot
);
36 /** Override to create a new temporary file and return its stream. */
37 virtual SvStream
* ImplQueryPictureStream() override
;
40 ::std::unique_ptr
< ::utl::TempFileFast
> mxPicTempFile
;
45 class XclExpDffAnchorBase
;
46 class XclEscherHostAppData
;
47 class XclEscherClientData
;
48 class XclEscherClientTextbox
;
49 class XclExpOcxControlObj
;
50 class XclExpTbxControlObj
;
52 class ShapeInteractionHelper
55 static XclExpShapeObj
* CreateShapeObj( XclExpObjectManager
& rObjMgr
, const css::uno::Reference
<
56 css::drawing::XShape
>& xShape
, ScDocument
* pDoc
);
57 static void PopulateShapeInteractionInfo( const XclExpObjectManager
& rObjMgr
, const css::uno::Reference
< css::drawing::XShape
>& xShape
, EscherExHostAppData
& rHostAppData
);
60 class XclEscherEx
: public EscherEx
, protected XclExpRoot
64 const XclExpRoot
& rRoot
,
65 XclExpObjectManager
& rObjMgr
,
67 const XclEscherEx
* pParent
= nullptr );
68 virtual ~XclEscherEx() override
;
70 /** Called by MSODRAWING record constructors to initialize the DFF stream
71 fragment they will own. returns the DFF fragment identifier. */
72 sal_uInt32
InitNextDffFragment();
73 /** Called after some data has been written to the DFF stream, to update
74 the end position of the DFF fragment owned by an MSODRAWING record. */
75 void UpdateDffFragmentEnd();
77 /** Returns the position of the specified DFF stream fragment. */
78 sal_uInt32
GetDffFragmentPos( sal_uInt32 nFragmentKey
);
79 /** Returns the size of the specified DFF stream fragment. */
80 sal_uInt32
GetDffFragmentSize( sal_uInt32 nFragmentKey
);
81 /** Returns true, if there is more data left in the DFF stream than owned
82 by the last MSODRAWING record. */
83 bool HasPendingDffData();
85 /** Creates a new DFF client anchor object and calculates the anchor
86 position of the passed object. Caller takes ownership! */
87 XclExpDffAnchorBase
* CreateDffAnchor( const SdrObject
& rSdrObj
) const;
89 virtual EscherExHostAppData
* StartShape(
90 const css::uno::Reference
< css::drawing::XShape
>& rxShape
,
91 const tools::Rectangle
* pChildAnchor
) override
;
92 virtual void EndShape( sal_uInt16 nShapeType
, sal_uInt32 nShapeID
) override
;
93 virtual EscherExHostAppData
* EnterAdditionalTextGroup() override
;
95 /// Flush and merge PicStream into EscherStream
97 /** Creates an OCX form control OBJ record from the passed form control.
98 @descr Writes the form control data to the 'Ctls' stream. */
99 std::unique_ptr
<XclExpOcxControlObj
> CreateOCXCtrlObj(
100 css::uno::Reference
< css::drawing::XShape
> const & xShape
,
101 const tools::Rectangle
* pChildAnchor
);
104 tools::SvRef
<SotStorageStream
> mxCtlsStrm
; /// The 'Ctls' stream.
105 /** Creates a TBX form control OBJ record from the passed form control. */
106 std::unique_ptr
<XclExpTbxControlObj
> CreateTBXCtrlObj(
107 css::uno::Reference
< css::drawing::XShape
> const & xShape
,
108 const tools::Rectangle
* pChildAnchor
);
111 /** Tries to get the name of a Basic macro from a control. */
112 void ConvertTbxMacro(
113 XclExpTbxControlObj
& rTbxCtrlObj
,
114 css::uno::Reference
< css::awt::XControlModel
> const & xCtrlModel
);
116 void DeleteCurrAppData();
119 XclExpObjectManager
& mrObjMgr
;
120 std::stack
< std::pair
< XclObj
*, std::unique_ptr
<XclEscherHostAppData
> > > aStack
;
122 std::unique_ptr
<XclEscherHostAppData
> pCurrAppData
;
123 std::unique_ptr
<XclEscherClientData
> pTheClientData
; // always the same
124 XclEscherClientTextbox
* pAdditionalText
;
125 sal_uInt16 nAdditionalText
;
126 sal_uInt32 mnNextKey
;
130 // --- class XclEscherHostAppData ------------------------------------
132 class XclEscherHostAppData
: public EscherExHostAppData
138 XclEscherHostAppData() : bStackedGroup( false )
140 void SetStackedGroup( bool b
) { bStackedGroup
= b
; }
141 bool IsStackedGroup() const { return bStackedGroup
; }
144 // --- class XclEscherClientData -------------------------------------
146 class XclEscherClientData
: public EscherExClientRecord_Base
149 XclEscherClientData() {}
150 virtual void WriteData( EscherEx
& rEx
) const override
;
153 // --- class XclEscherClientTextbox ----------------------------------
157 class XclEscherClientTextbox
: public EscherExClientRecord_Base
, protected XclExpRoot
160 const SdrTextObj
& rTextObj
;
164 XclEscherClientTextbox(
165 const XclExpRoot
& rRoot
,
166 const SdrTextObj
& rObj
,
169 //! ONLY for the AdditionalText mimic
170 void SetXclObj( XclObj
* p
) { pXclObj
= p
; }
172 virtual void WriteData( EscherEx
& rEx
) const override
;
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */