xref: /trunk/main/sc/source/filter/excel/xeescher.cxx (revision b77af630)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b3f79822SAndrew Rist  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19b3f79822SAndrew Rist  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25*b77af630Sdamjan #include "precompiled_scfilt.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "xeescher.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
30cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
31cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp>
32cdf0e10cSrcweir #include <com/sun/star/awt/VisualEffect.hpp>
33cdf0e10cSrcweir #include <com/sun/star/awt/ScrollBarOrientation.hpp>
34cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
35cdf0e10cSrcweir #include <com/sun/star/form/binding/XBindableValue.hpp>
36cdf0e10cSrcweir #include <com/sun/star/form/binding/XValueBinding.hpp>
37cdf0e10cSrcweir #include <com/sun/star/form/binding/XListEntrySink.hpp>
38cdf0e10cSrcweir #include <com/sun/star/form/binding/XListEntrySource.hpp>
39cdf0e10cSrcweir #include <com/sun/star/script/ScriptEventDescriptor.hpp>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <set>
42cdf0e10cSrcweir #include <rtl/ustrbuf.h>
43cdf0e10cSrcweir #include <vcl/bmpacc.hxx>
44cdf0e10cSrcweir #include <svx/svdoole2.hxx>
45cdf0e10cSrcweir #include <svx/svdocapt.hxx>
46cdf0e10cSrcweir #include <editeng/outlobj.hxx>
47cdf0e10cSrcweir #include <editeng/editobj.hxx>
48cdf0e10cSrcweir #include <unotools/tempfile.hxx>
49cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include "editutil.hxx"
52cdf0e10cSrcweir #include "unonames.hxx"
53cdf0e10cSrcweir #include "convuno.hxx"
54cdf0e10cSrcweir #include "postit.hxx"
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include "fapihelper.hxx"
57cdf0e10cSrcweir #include "xechart.hxx"
58cdf0e10cSrcweir #include "xeformula.hxx"
59cdf0e10cSrcweir #include "xelink.hxx"
60cdf0e10cSrcweir #include "xename.hxx"
61cdf0e10cSrcweir #include "xestyle.hxx"
62cdf0e10cSrcweir 
63cdf0e10cSrcweir using namespace ::oox;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir using ::rtl::OString;
66cdf0e10cSrcweir using ::rtl::OUString;
67cdf0e10cSrcweir using ::rtl::OUStringBuffer;
68cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY;
69cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
70cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
71cdf0e10cSrcweir using ::com::sun::star::lang::XServiceInfo;
72cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet;
73cdf0e10cSrcweir using ::com::sun::star::drawing::XShape;
74cdf0e10cSrcweir using ::com::sun::star::drawing::XShapes;
75cdf0e10cSrcweir using ::com::sun::star::frame::XModel;
76cdf0e10cSrcweir using ::com::sun::star::embed::XEmbeddedObject;
77cdf0e10cSrcweir using ::com::sun::star::awt::XControlModel;
78cdf0e10cSrcweir using ::com::sun::star::form::binding::XBindableValue;
79cdf0e10cSrcweir using ::com::sun::star::form::binding::XValueBinding;
80cdf0e10cSrcweir using ::com::sun::star::form::binding::XListEntrySink;
81cdf0e10cSrcweir using ::com::sun::star::form::binding::XListEntrySource;
82cdf0e10cSrcweir using ::com::sun::star::script::ScriptEventDescriptor;
83cdf0e10cSrcweir using ::com::sun::star::table::CellAddress;
84cdf0e10cSrcweir using ::com::sun::star::table::CellRangeAddress;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir // Escher client anchor =======================================================
87cdf0e10cSrcweir 
XclExpDffAnchorBase(const XclExpRoot & rRoot,sal_uInt16 nFlags)88cdf0e10cSrcweir XclExpDffAnchorBase::XclExpDffAnchorBase( const XclExpRoot& rRoot, sal_uInt16 nFlags ) :
89cdf0e10cSrcweir     XclExpRoot( rRoot ),
90cdf0e10cSrcweir     mnFlags( nFlags )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
SetFlags(const SdrObject & rSdrObj)94cdf0e10cSrcweir void XclExpDffAnchorBase::SetFlags( const SdrObject& rSdrObj )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir     ImplSetFlags( rSdrObj );
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
SetSdrObject(const SdrObject & rSdrObj)99cdf0e10cSrcweir void XclExpDffAnchorBase::SetSdrObject( const SdrObject& rSdrObj )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     ImplSetFlags( rSdrObj );
102cdf0e10cSrcweir     ImplCalcAnchorRect( rSdrObj.GetCurrentBoundRect(), MAP_100TH_MM );
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
WriteDffData(EscherEx & rEscherEx) const105cdf0e10cSrcweir void XclExpDffAnchorBase::WriteDffData( EscherEx& rEscherEx ) const
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     rEscherEx.AddAtom( 18, ESCHER_ClientAnchor );
108cdf0e10cSrcweir     rEscherEx.GetStream() << mnFlags << maAnchor;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
WriteData(EscherEx & rEscherEx,const Rectangle & rRect)111cdf0e10cSrcweir void XclExpDffAnchorBase::WriteData( EscherEx& rEscherEx, const Rectangle& rRect )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir     // the passed rectangle is in twips
114cdf0e10cSrcweir     ImplCalcAnchorRect( rRect, MAP_TWIP );
115cdf0e10cSrcweir     WriteDffData( rEscherEx );
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
ImplSetFlags(const SdrObject &)118cdf0e10cSrcweir void XclExpDffAnchorBase::ImplSetFlags( const SdrObject& )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir     OSL_ENSURE( false, "XclExpDffAnchorBase::ImplSetFlags - not implemented" );
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
ImplCalcAnchorRect(const Rectangle &,MapUnit)123cdf0e10cSrcweir void XclExpDffAnchorBase::ImplCalcAnchorRect( const Rectangle&, MapUnit )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir     OSL_ENSURE( false, "XclExpDffAnchorBase::ImplCalcAnchorRect - not implemented" );
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir // ----------------------------------------------------------------------------
129cdf0e10cSrcweir 
XclExpDffSheetAnchor(const XclExpRoot & rRoot)130cdf0e10cSrcweir XclExpDffSheetAnchor::XclExpDffSheetAnchor( const XclExpRoot& rRoot ) :
131cdf0e10cSrcweir     XclExpDffAnchorBase( rRoot ),
132cdf0e10cSrcweir     mnScTab( rRoot.GetCurrScTab() )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
ImplSetFlags(const SdrObject & rSdrObj)136cdf0e10cSrcweir void XclExpDffSheetAnchor::ImplSetFlags( const SdrObject& rSdrObj )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir     // Special case "page anchor" (X==0,Y==1) -> lock pos and size.
139cdf0e10cSrcweir     const Point& rPos = rSdrObj.GetAnchorPos();
140cdf0e10cSrcweir     mnFlags = ((rPos.X() == 0) && (rPos.Y() == 1)) ? EXC_ESC_ANCHOR_LOCKED : 0;
141cdf0e10cSrcweir }
142cdf0e10cSrcweir 
ImplCalcAnchorRect(const Rectangle & rRect,MapUnit eMapUnit)143cdf0e10cSrcweir void XclExpDffSheetAnchor::ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir     maAnchor.SetRect( GetRoot(), mnScTab, rRect, eMapUnit );
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir // ----------------------------------------------------------------------------
149cdf0e10cSrcweir 
XclExpDffEmbeddedAnchor(const XclExpRoot & rRoot,const Size & rPageSize,sal_Int32 nScaleX,sal_Int32 nScaleY)150cdf0e10cSrcweir XclExpDffEmbeddedAnchor::XclExpDffEmbeddedAnchor( const XclExpRoot& rRoot,
151cdf0e10cSrcweir         const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY ) :
152cdf0e10cSrcweir     XclExpDffAnchorBase( rRoot ),
153cdf0e10cSrcweir     maPageSize( rPageSize ),
154cdf0e10cSrcweir     mnScaleX( nScaleX ),
155cdf0e10cSrcweir     mnScaleY( nScaleY )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
ImplSetFlags(const SdrObject &)159cdf0e10cSrcweir void XclExpDffEmbeddedAnchor::ImplSetFlags( const SdrObject& /*rSdrObj*/ )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     // TODO (unsupported feature): fixed size
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
ImplCalcAnchorRect(const Rectangle & rRect,MapUnit eMapUnit)164cdf0e10cSrcweir void XclExpDffEmbeddedAnchor::ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir     maAnchor.SetRect( maPageSize, mnScaleX, mnScaleY, rRect, eMapUnit, true );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir // ----------------------------------------------------------------------------
170cdf0e10cSrcweir 
XclExpDffNoteAnchor(const XclExpRoot & rRoot,const Rectangle & rRect)171cdf0e10cSrcweir XclExpDffNoteAnchor::XclExpDffNoteAnchor( const XclExpRoot& rRoot, const Rectangle& rRect ) :
172cdf0e10cSrcweir     XclExpDffAnchorBase( rRoot, EXC_ESC_ANCHOR_SIZELOCKED )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir     maAnchor.SetRect( rRoot, rRoot.GetCurrScTab(), rRect, MAP_100TH_MM );
175cdf0e10cSrcweir }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir // ----------------------------------------------------------------------------
178cdf0e10cSrcweir 
XclExpDffDropDownAnchor(const XclExpRoot & rRoot,const ScAddress & rScPos)179cdf0e10cSrcweir XclExpDffDropDownAnchor::XclExpDffDropDownAnchor( const XclExpRoot& rRoot, const ScAddress& rScPos ) :
180cdf0e10cSrcweir     XclExpDffAnchorBase( rRoot, EXC_ESC_ANCHOR_POSLOCKED )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir     GetAddressConverter().ConvertAddress( maAnchor.maFirst, rScPos, true );
183cdf0e10cSrcweir     maAnchor.maLast.mnCol = maAnchor.maFirst.mnCol + 1;
184cdf0e10cSrcweir     maAnchor.maLast.mnRow = maAnchor.maFirst.mnRow + 1;
185cdf0e10cSrcweir     maAnchor.mnLX = maAnchor.mnTY = maAnchor.mnRX = maAnchor.mnBY = 0;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir // MSODRAWING* records ========================================================
189cdf0e10cSrcweir 
XclExpMsoDrawingBase(XclEscherEx & rEscherEx,sal_uInt16 nRecId)190cdf0e10cSrcweir XclExpMsoDrawingBase::XclExpMsoDrawingBase( XclEscherEx& rEscherEx, sal_uInt16 nRecId ) :
191cdf0e10cSrcweir     XclExpRecord( nRecId ),
192cdf0e10cSrcweir     mrEscherEx( rEscherEx ),
193cdf0e10cSrcweir     mnFragmentKey( rEscherEx.InitNextDffFragment() )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
WriteBody(XclExpStream & rStrm)197cdf0e10cSrcweir void XclExpMsoDrawingBase::WriteBody( XclExpStream& rStrm )
198cdf0e10cSrcweir {
199cdf0e10cSrcweir     OSL_ENSURE( mrEscherEx.GetStreamPos() == mrEscherEx.GetDffFragmentPos( mnFragmentKey ),
200cdf0e10cSrcweir         "XclExpMsoDrawingBase::WriteBody - DFF stream position mismatch" );
201cdf0e10cSrcweir     rStrm.CopyFromStream( mrEscherEx.GetStream(), mrEscherEx.GetDffFragmentSize( mnFragmentKey ) );
202cdf0e10cSrcweir }
203cdf0e10cSrcweir 
204cdf0e10cSrcweir // ----------------------------------------------------------------------------
205cdf0e10cSrcweir 
XclExpMsoDrawingGroup(XclEscherEx & rEscherEx)206cdf0e10cSrcweir XclExpMsoDrawingGroup::XclExpMsoDrawingGroup( XclEscherEx& rEscherEx ) :
207cdf0e10cSrcweir     XclExpMsoDrawingBase( rEscherEx, EXC_ID_MSODRAWINGGROUP )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir     SvStream& rDffStrm = mrEscherEx.GetStream();
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     // write the DGGCONTAINER with some default settings
212cdf0e10cSrcweir     mrEscherEx.OpenContainer( ESCHER_DggContainer );
213cdf0e10cSrcweir 
214cdf0e10cSrcweir     // TODO: stuff the OPT atom with our own document defaults?
215cdf0e10cSrcweir     static const sal_uInt8 spnDffOpt[] = {
216cdf0e10cSrcweir         0xBF, 0x00, 0x08, 0x00, 0x08, 0x00, 0x81, 0x01,
217cdf0e10cSrcweir         0x09, 0x00, 0x00, 0x08, 0xC0, 0x01, 0x40, 0x00,
218cdf0e10cSrcweir         0x00, 0x08
219cdf0e10cSrcweir     };
220cdf0e10cSrcweir     mrEscherEx.AddAtom( sizeof( spnDffOpt ), ESCHER_OPT, 3, 3 );
221cdf0e10cSrcweir     rDffStrm.Write( spnDffOpt, sizeof( spnDffOpt ) );
222cdf0e10cSrcweir 
223cdf0e10cSrcweir     // SPLITMENUCOLORS contains colors in toolbar
224cdf0e10cSrcweir     static const sal_uInt8 spnDffSplitMenuColors[] = {
225cdf0e10cSrcweir         0x0D, 0x00, 0x00, 0x08, 0x0C, 0x00, 0x00, 0x08,
226cdf0e10cSrcweir         0x17, 0x00, 0x00, 0x08, 0xF7, 0x00, 0x00, 0x10
227cdf0e10cSrcweir     };
228cdf0e10cSrcweir     mrEscherEx.AddAtom( sizeof( spnDffSplitMenuColors ), ESCHER_SplitMenuColors, 0, 4 );
229cdf0e10cSrcweir     rDffStrm.Write( spnDffSplitMenuColors, sizeof( spnDffSplitMenuColors ) );
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     // close the DGGCONTAINER
232cdf0e10cSrcweir     mrEscherEx.CloseContainer();
233cdf0e10cSrcweir     mrEscherEx.UpdateDffFragmentEnd();
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir // ----------------------------------------------------------------------------
237cdf0e10cSrcweir 
XclExpMsoDrawing(XclEscherEx & rEscherEx)238cdf0e10cSrcweir XclExpMsoDrawing::XclExpMsoDrawing( XclEscherEx& rEscherEx ) :
239cdf0e10cSrcweir     XclExpMsoDrawingBase( rEscherEx, EXC_ID_MSODRAWING )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir }
242cdf0e10cSrcweir 
243cdf0e10cSrcweir // ============================================================================
244cdf0e10cSrcweir 
XclExpImgData(const Graphic & rGraphic,sal_uInt16 nRecId)245cdf0e10cSrcweir XclExpImgData::XclExpImgData( const Graphic& rGraphic, sal_uInt16 nRecId ) :
246cdf0e10cSrcweir     maGraphic( rGraphic ),
247cdf0e10cSrcweir     mnRecId( nRecId )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir }
250cdf0e10cSrcweir 
Save(XclExpStream & rStrm)251cdf0e10cSrcweir void XclExpImgData::Save( XclExpStream& rStrm )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir     Bitmap aBmp = maGraphic.GetBitmap();
254cdf0e10cSrcweir     if( aBmp.GetBitCount() != 24 )
255cdf0e10cSrcweir         aBmp.Convert( BMP_CONVERSION_24BIT );
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     if( BitmapReadAccess* pAccess = aBmp.AcquireReadAccess() )
258cdf0e10cSrcweir     {
259cdf0e10cSrcweir         sal_Int32 nWidth = ::std::min< sal_Int32 >( pAccess->Width(), 0xFFFF );
260cdf0e10cSrcweir         sal_Int32 nHeight = ::std::min< sal_Int32 >( pAccess->Height(), 0xFFFF );
261cdf0e10cSrcweir         if( (nWidth > 0) && (nHeight > 0) )
262cdf0e10cSrcweir         {
263cdf0e10cSrcweir             sal_uInt8 nPadding = static_cast< sal_uInt8 >( nWidth & 0x03 );
264cdf0e10cSrcweir             sal_uInt32 nTmpSize = static_cast< sal_uInt32 >( (nWidth * 3 + nPadding) * nHeight + 12 );
265cdf0e10cSrcweir 
266cdf0e10cSrcweir             rStrm.StartRecord( mnRecId, nTmpSize + 4 );
267cdf0e10cSrcweir 
268cdf0e10cSrcweir             rStrm   << EXC_IMGDATA_BMP                      // BMP format
269cdf0e10cSrcweir                     << EXC_IMGDATA_WIN                      // Windows
270cdf0e10cSrcweir                     << nTmpSize                             // size after _this_ field
271cdf0e10cSrcweir                     << sal_uInt32( 12 )                     // BITMAPCOREHEADER size
272cdf0e10cSrcweir                     << static_cast< sal_uInt16 >( nWidth )  // width
273cdf0e10cSrcweir                     << static_cast< sal_uInt16 >( nHeight ) // height
274cdf0e10cSrcweir                     << sal_uInt16( 1 )                      // planes
275cdf0e10cSrcweir                     << sal_uInt16( 24 );                    // bits per pixel
276cdf0e10cSrcweir 
277cdf0e10cSrcweir             for( sal_Int32 nY = nHeight - 1; nY >= 0; --nY )
278cdf0e10cSrcweir             {
279cdf0e10cSrcweir                 for( sal_Int32 nX = 0; nX < nWidth; ++nX )
280cdf0e10cSrcweir                 {
281cdf0e10cSrcweir                     const BitmapColor& rBmpColor = pAccess->GetPixel( nY, nX );
282cdf0e10cSrcweir                     rStrm << rBmpColor.GetBlue() << rBmpColor.GetGreen() << rBmpColor.GetRed();
283cdf0e10cSrcweir                 }
284cdf0e10cSrcweir                 rStrm.WriteZeroBytes( nPadding );
285cdf0e10cSrcweir             }
286cdf0e10cSrcweir 
287cdf0e10cSrcweir             rStrm.EndRecord();
288cdf0e10cSrcweir         }
289cdf0e10cSrcweir         aBmp.ReleaseAccess( pAccess );
290cdf0e10cSrcweir     }
291cdf0e10cSrcweir }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir // ============================================================================
294cdf0e10cSrcweir 
XclExpControlHelper(const XclExpRoot & rRoot)295cdf0e10cSrcweir XclExpControlHelper::XclExpControlHelper( const XclExpRoot& rRoot ) :
296cdf0e10cSrcweir     XclExpRoot( rRoot ),
297cdf0e10cSrcweir     mnEntryCount( 0 )
298cdf0e10cSrcweir {
299cdf0e10cSrcweir }
300cdf0e10cSrcweir 
~XclExpControlHelper()301cdf0e10cSrcweir XclExpControlHelper::~XclExpControlHelper()
302cdf0e10cSrcweir {
303cdf0e10cSrcweir }
304cdf0e10cSrcweir 
ConvertSheetLinks(Reference<XShape> xShape)305cdf0e10cSrcweir void XclExpControlHelper::ConvertSheetLinks( Reference< XShape > xShape )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir     mxCellLink.reset();
308cdf0e10cSrcweir     mxSrcRange.reset();
309cdf0e10cSrcweir     mnEntryCount = 0;
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     // get control model
312cdf0e10cSrcweir     Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( xShape );
313cdf0e10cSrcweir     if( !xCtrlModel.is() )
314cdf0e10cSrcweir         return;
315cdf0e10cSrcweir 
316cdf0e10cSrcweir     // *** cell link *** ------------------------------------------------------
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     Reference< XBindableValue > xBindable( xCtrlModel, UNO_QUERY );
319cdf0e10cSrcweir     if( xBindable.is() )
320cdf0e10cSrcweir     {
321cdf0e10cSrcweir         Reference< XServiceInfo > xServInfo( xBindable->getValueBinding(), UNO_QUERY );
322cdf0e10cSrcweir         if( xServInfo.is() && xServInfo->supportsService( CREATE_OUSTRING( SC_SERVICENAME_VALBIND ) ) )
323cdf0e10cSrcweir         {
324cdf0e10cSrcweir             ScfPropertySet aBindProp( xServInfo );
325cdf0e10cSrcweir             CellAddress aApiAddress;
326cdf0e10cSrcweir             if( aBindProp.GetProperty( aApiAddress, CREATE_OUSTRING( SC_UNONAME_BOUNDCELL ) ) )
327cdf0e10cSrcweir             {
328cdf0e10cSrcweir                 ScAddress aCellLink;
329cdf0e10cSrcweir                 ScUnoConversion::FillScAddress( aCellLink, aApiAddress );
330cdf0e10cSrcweir                 if( GetTabInfo().IsExportTab( aCellLink.Tab() ) )
331cdf0e10cSrcweir                     mxCellLink = GetFormulaCompiler().CreateFormula( EXC_FMLATYPE_CONTROL, aCellLink );
332cdf0e10cSrcweir             }
333cdf0e10cSrcweir         }
334cdf0e10cSrcweir     }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir     // *** source range *** ---------------------------------------------------
337cdf0e10cSrcweir 
338cdf0e10cSrcweir     Reference< XListEntrySink > xEntrySink( xCtrlModel, UNO_QUERY );
339cdf0e10cSrcweir     if( xEntrySink.is() )
340cdf0e10cSrcweir     {
341cdf0e10cSrcweir         Reference< XServiceInfo > xServInfo( xEntrySink->getListEntrySource(), UNO_QUERY );
342cdf0e10cSrcweir         if( xServInfo.is() && xServInfo->supportsService( CREATE_OUSTRING( SC_SERVICENAME_LISTSOURCE ) ) )
343cdf0e10cSrcweir         {
344cdf0e10cSrcweir             ScfPropertySet aSinkProp( xServInfo );
345cdf0e10cSrcweir             CellRangeAddress aApiRange;
346cdf0e10cSrcweir             if( aSinkProp.GetProperty( aApiRange, CREATE_OUSTRING( SC_UNONAME_CELLRANGE ) ) )
347cdf0e10cSrcweir             {
348cdf0e10cSrcweir                 ScRange aSrcRange;
349cdf0e10cSrcweir                 ScUnoConversion::FillScRange( aSrcRange, aApiRange );
350cdf0e10cSrcweir                 if( (aSrcRange.aStart.Tab() == aSrcRange.aEnd.Tab()) && GetTabInfo().IsExportTab( aSrcRange.aStart.Tab() ) )
351cdf0e10cSrcweir                     mxSrcRange = GetFormulaCompiler().CreateFormula( EXC_FMLATYPE_CONTROL, aSrcRange );
352cdf0e10cSrcweir                 mnEntryCount = static_cast< sal_uInt16 >( aSrcRange.aEnd.Col() - aSrcRange.aStart.Col() + 1 );
353cdf0e10cSrcweir             }
354cdf0e10cSrcweir         }
355cdf0e10cSrcweir     }
356cdf0e10cSrcweir }
357cdf0e10cSrcweir 
WriteFormula(XclExpStream & rStrm,const XclTokenArray & rTokArr) const358cdf0e10cSrcweir void XclExpControlHelper::WriteFormula( XclExpStream& rStrm, const XclTokenArray& rTokArr ) const
359cdf0e10cSrcweir {
360cdf0e10cSrcweir     sal_uInt16 nFmlaSize = rTokArr.GetSize();
361cdf0e10cSrcweir     rStrm << nFmlaSize << sal_uInt32( 0 );
362cdf0e10cSrcweir     rTokArr.WriteArray( rStrm );
363cdf0e10cSrcweir     if( nFmlaSize & 1 )             // pad to 16-bit
364cdf0e10cSrcweir         rStrm << sal_uInt8( 0 );
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
WriteFormulaSubRec(XclExpStream & rStrm,sal_uInt16 nSubRecId,const XclTokenArray & rTokArr) const367cdf0e10cSrcweir void XclExpControlHelper::WriteFormulaSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId, const XclTokenArray& rTokArr ) const
368cdf0e10cSrcweir {
369cdf0e10cSrcweir     rStrm.StartRecord( nSubRecId, (rTokArr.GetSize() + 5) & ~1 );
370cdf0e10cSrcweir     WriteFormula( rStrm, rTokArr );
371cdf0e10cSrcweir     rStrm.EndRecord();
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
374cdf0e10cSrcweir // ----------------------------------------------------------------------------
375cdf0e10cSrcweir 
3760de526bdSJianyuan Li //delete for exporting OCX
3770de526bdSJianyuan Li //#if EXC_EXP_OCX_CTRL
378cdf0e10cSrcweir 
XclExpOcxControlObj(XclExpObjectManager & rObjMgr,Reference<XShape> xShape,const Rectangle * pChildAnchor,const String & rClassName,sal_uInt32 nStrmStart,sal_uInt32 nStrmSize)379cdf0e10cSrcweir XclExpOcxControlObj::XclExpOcxControlObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape,
380cdf0e10cSrcweir         const Rectangle* pChildAnchor, const String& rClassName, sal_uInt32 nStrmStart, sal_uInt32 nStrmSize ) :
381cdf0e10cSrcweir     XclObj( rObjMgr, EXC_OBJTYPE_PICTURE, true ),
382cdf0e10cSrcweir     XclExpControlHelper( rObjMgr.GetRoot() ),
383cdf0e10cSrcweir     maClassName( rClassName ),
384cdf0e10cSrcweir     mnStrmStart( nStrmStart ),
385cdf0e10cSrcweir     mnStrmSize( nStrmSize )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir     ScfPropertySet aCtrlProp( XclControlHelper::GetControlModel( xShape ) );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir     // OBJ record flags
390cdf0e10cSrcweir     SetLocked( sal_True );
391cdf0e10cSrcweir     SetPrintable( aCtrlProp.GetBoolProperty( CREATE_OUSTRING( "Printable" ) ) );
392cdf0e10cSrcweir     SetAutoFill( sal_False );
393cdf0e10cSrcweir     SetAutoLine( sal_False );
394cdf0e10cSrcweir 
395cdf0e10cSrcweir     // fill DFF property set
396cdf0e10cSrcweir     mrEscherEx.OpenContainer( ESCHER_SpContainer );
397cdf0e10cSrcweir     mrEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVESPT | SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_OLESHAPE );
398cdf0e10cSrcweir     Rectangle aDummyRect;
3990de526bdSJianyuan Li     EscherPropertyContainer aPropOpt( mrEscherEx.GetGraphicProvider(), mrEscherEx.QueryPictureStream(), aDummyRect );
400cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape,    0x00080008 );   // bool field
401cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_lineColor,         0x08000040 );
402cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash,   0x00080000 );   // bool field
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     // #i51348# name of the control, may overwrite shape name
405cdf0e10cSrcweir     OUString aCtrlName;
406cdf0e10cSrcweir     if( aCtrlProp.GetProperty( aCtrlName, CREATE_OUSTRING( "Name" ) ) && (aCtrlName.getLength() > 0) )
407cdf0e10cSrcweir         aPropOpt.AddOpt( ESCHER_Prop_wzName, aCtrlName );
408cdf0e10cSrcweir 
409cdf0e10cSrcweir     // meta file
410cdf0e10cSrcweir     //! TODO - needs check
411cdf0e10cSrcweir     Reference< XPropertySet > xShapePS( xShape, UNO_QUERY );
412cdf0e10cSrcweir     if( xShapePS.is() && aPropOpt.CreateGraphicProperties( xShapePS, CREATE_STRING( "MetaFile" ), sal_False ) )
413cdf0e10cSrcweir     {
414cdf0e10cSrcweir         sal_uInt32 nBlipId;
415cdf0e10cSrcweir         if( aPropOpt.GetOpt( ESCHER_Prop_pib, nBlipId ) )
416cdf0e10cSrcweir             aPropOpt.AddOpt( ESCHER_Prop_pictureId, nBlipId );
417cdf0e10cSrcweir     }
418cdf0e10cSrcweir 
419cdf0e10cSrcweir     // write DFF property set to stream
420cdf0e10cSrcweir     aPropOpt.Commit( mrEscherEx.GetStream() );
421cdf0e10cSrcweir 
422cdf0e10cSrcweir     // anchor
423cdf0e10cSrcweir     ImplWriteAnchor( GetRoot(), SdrObject::getSdrObjectFromXShape( xShape ), pChildAnchor );
424cdf0e10cSrcweir 
425cdf0e10cSrcweir     mrEscherEx.AddAtom( 0, ESCHER_ClientData );                       // OBJ record
426cdf0e10cSrcweir     mrEscherEx.CloseContainer();  // ESCHER_SpContainer
427cdf0e10cSrcweir     mrEscherEx.UpdateDffFragmentEnd();
428cdf0e10cSrcweir 
429cdf0e10cSrcweir     // spreadsheet links
430cdf0e10cSrcweir     ConvertSheetLinks( xShape );
431cdf0e10cSrcweir }
432cdf0e10cSrcweir 
WriteSubRecs(XclExpStream & rStrm)433cdf0e10cSrcweir void XclExpOcxControlObj::WriteSubRecs( XclExpStream& rStrm )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir     // OBJCF - clipboard format
436cdf0e10cSrcweir     rStrm.StartRecord( EXC_ID_OBJCF, 2 );
437cdf0e10cSrcweir     rStrm << sal_uInt16( 2 );
438cdf0e10cSrcweir     rStrm.EndRecord();
439cdf0e10cSrcweir 
440cdf0e10cSrcweir     // OBJFLAGS
441cdf0e10cSrcweir     rStrm.StartRecord( EXC_ID_OBJFLAGS, 2 );
442cdf0e10cSrcweir     rStrm << sal_uInt16( 0x0031 );
443cdf0e10cSrcweir     rStrm.EndRecord();
444cdf0e10cSrcweir 
445cdf0e10cSrcweir     // OBJPICTFMLA
446cdf0e10cSrcweir     XclExpString aClass( maClassName );
447cdf0e10cSrcweir     sal_uInt16 nClassNameSize = static_cast< sal_uInt16 >( aClass.GetSize() );
448cdf0e10cSrcweir     sal_uInt16 nClassNamePad = nClassNameSize & 1;
449cdf0e10cSrcweir     sal_uInt16 nFirstPartSize = 12 + nClassNameSize + nClassNamePad;
450cdf0e10cSrcweir 
451cdf0e10cSrcweir     const XclTokenArray* pCellLink = GetCellLinkTokArr();
452cdf0e10cSrcweir     sal_uInt16 nCellLinkSize = pCellLink ? ((pCellLink->GetSize() + 7) & 0xFFFE) : 0;
453cdf0e10cSrcweir 
454cdf0e10cSrcweir     const XclTokenArray* pSrcRange = GetSourceRangeTokArr();
455cdf0e10cSrcweir     sal_uInt16 nSrcRangeSize = pSrcRange ? ((pSrcRange->GetSize() + 7) & 0xFFFE) : 0;
456cdf0e10cSrcweir 
457cdf0e10cSrcweir     sal_uInt16 nPictFmlaSize = nFirstPartSize + nCellLinkSize + nSrcRangeSize + 18;
458cdf0e10cSrcweir     rStrm.StartRecord( EXC_ID_OBJPICTFMLA, nPictFmlaSize );
459cdf0e10cSrcweir 
460cdf0e10cSrcweir     rStrm   << sal_uInt16( nFirstPartSize )             // size of first part
461cdf0e10cSrcweir             << sal_uInt16( 5 )                          // formula size
462cdf0e10cSrcweir             << sal_uInt32( 0 )                          // unknown ID
463cdf0e10cSrcweir             << sal_uInt8( 0x02 ) << sal_uInt32( 0 )     // tTbl token with unknown ID
464cdf0e10cSrcweir             << sal_uInt8( 3 )                           // pad to word
465cdf0e10cSrcweir             << aClass;                                  // "Forms.***.1"
466cdf0e10cSrcweir     rStrm.WriteZeroBytes( nClassNamePad );              // pad to word
467cdf0e10cSrcweir     rStrm   << mnStrmStart                              // start in 'Ctls' stream
468cdf0e10cSrcweir             << mnStrmSize                               // size in 'Ctls' stream
469cdf0e10cSrcweir             << sal_uInt32( 0 );                         // class ID size
470cdf0e10cSrcweir     // cell link
471cdf0e10cSrcweir     rStrm << nCellLinkSize;
472cdf0e10cSrcweir     if( pCellLink )
473cdf0e10cSrcweir         WriteFormula( rStrm, *pCellLink );
474cdf0e10cSrcweir     // list source range
475cdf0e10cSrcweir     rStrm << nSrcRangeSize;
476cdf0e10cSrcweir     if( pSrcRange )
477cdf0e10cSrcweir         WriteFormula( rStrm, *pSrcRange );
478cdf0e10cSrcweir 
479cdf0e10cSrcweir     rStrm.EndRecord();
480cdf0e10cSrcweir }
481cdf0e10cSrcweir 
4820de526bdSJianyuan Li //#else
483cdf0e10cSrcweir 
XclExpTbxControlObj(XclExpObjectManager & rObjMgr,Reference<XShape> xShape,const Rectangle * pChildAnchor)484cdf0e10cSrcweir XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape, const Rectangle* pChildAnchor ) :
485cdf0e10cSrcweir     XclObj( rObjMgr, EXC_OBJTYPE_UNKNOWN, true ),
486cdf0e10cSrcweir     XclExpControlHelper( rObjMgr.GetRoot() ),
487cdf0e10cSrcweir     mnHeight( 0 ),
488cdf0e10cSrcweir     mnState( 0 ),
489cdf0e10cSrcweir     mnLineCount( 0 ),
490cdf0e10cSrcweir     mnSelEntry( 0 ),
491cdf0e10cSrcweir     mnScrollValue( 0 ),
492cdf0e10cSrcweir     mnScrollMin( 0 ),
493cdf0e10cSrcweir     mnScrollMax( 100 ),
494cdf0e10cSrcweir     mnScrollStep( 1 ),
495cdf0e10cSrcweir     mnScrollPage( 10 ),
496cdf0e10cSrcweir     mbFlatButton( false ),
497cdf0e10cSrcweir     mbFlatBorder( false ),
498cdf0e10cSrcweir     mbMultiSel( false ),
499cdf0e10cSrcweir     mbScrollHor( false )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir     namespace FormCompType = ::com::sun::star::form::FormComponentType;
502cdf0e10cSrcweir     namespace AwtVisualEffect = ::com::sun::star::awt::VisualEffect;
503cdf0e10cSrcweir     namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
504cdf0e10cSrcweir 
505cdf0e10cSrcweir     ScfPropertySet aCtrlProp( XclControlHelper::GetControlModel( xShape ) );
506cdf0e10cSrcweir     if( !xShape.is() || !aCtrlProp.Is() )
507cdf0e10cSrcweir         return;
508cdf0e10cSrcweir 
509cdf0e10cSrcweir     mnHeight = xShape->getSize().Height;
510cdf0e10cSrcweir     if( mnHeight <= 0 )
511cdf0e10cSrcweir         return;
512cdf0e10cSrcweir 
513cdf0e10cSrcweir     // control type
514cdf0e10cSrcweir     sal_Int16 nClassId = 0;
515cdf0e10cSrcweir     if( aCtrlProp.GetProperty( nClassId, CREATE_OUSTRING( "ClassId" ) ) )
516cdf0e10cSrcweir     {
517cdf0e10cSrcweir         switch( nClassId )
518cdf0e10cSrcweir         {
519cdf0e10cSrcweir             case FormCompType::COMMANDBUTTON:   mnObjType = EXC_OBJTYPE_BUTTON;       meEventType = EXC_TBX_EVENT_ACTION; break;
520cdf0e10cSrcweir             case FormCompType::RADIOBUTTON:     mnObjType = EXC_OBJTYPE_OPTIONBUTTON; meEventType = EXC_TBX_EVENT_ACTION; break;
521cdf0e10cSrcweir             case FormCompType::CHECKBOX:        mnObjType = EXC_OBJTYPE_CHECKBOX;     meEventType = EXC_TBX_EVENT_ACTION; break;
522cdf0e10cSrcweir             case FormCompType::LISTBOX:         mnObjType = EXC_OBJTYPE_LISTBOX;      meEventType = EXC_TBX_EVENT_CHANGE; break;
523cdf0e10cSrcweir             case FormCompType::COMBOBOX:        mnObjType = EXC_OBJTYPE_DROPDOWN;     meEventType = EXC_TBX_EVENT_CHANGE; break;
524cdf0e10cSrcweir             case FormCompType::GROUPBOX:        mnObjType = EXC_OBJTYPE_GROUPBOX;     meEventType = EXC_TBX_EVENT_MOUSE;  break;
525cdf0e10cSrcweir             case FormCompType::FIXEDTEXT:       mnObjType = EXC_OBJTYPE_LABEL;        meEventType = EXC_TBX_EVENT_MOUSE;  break;
526cdf0e10cSrcweir             case FormCompType::SCROLLBAR:       mnObjType = EXC_OBJTYPE_SCROLLBAR;    meEventType = EXC_TBX_EVENT_VALUE;  break;
527cdf0e10cSrcweir             case FormCompType::SPINBUTTON:      mnObjType = EXC_OBJTYPE_SPIN;         meEventType = EXC_TBX_EVENT_VALUE;  break;
528cdf0e10cSrcweir         }
529cdf0e10cSrcweir     }
530cdf0e10cSrcweir     if( mnObjType == EXC_OBJTYPE_UNKNOWN )
531cdf0e10cSrcweir         return;
532cdf0e10cSrcweir 
533cdf0e10cSrcweir     // OBJ record flags
534cdf0e10cSrcweir     SetLocked( sal_True );
535cdf0e10cSrcweir     SetPrintable( aCtrlProp.GetBoolProperty( CREATE_OUSTRING( "Printable" ) ) );
536cdf0e10cSrcweir     SetAutoFill( sal_False );
537cdf0e10cSrcweir     SetAutoLine( sal_False );
538cdf0e10cSrcweir 
539cdf0e10cSrcweir     // fill DFF property set
540cdf0e10cSrcweir     mrEscherEx.OpenContainer( ESCHER_SpContainer );
541cdf0e10cSrcweir     mrEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
542cdf0e10cSrcweir     EscherPropertyContainer aPropOpt;
543cdf0e10cSrcweir     bool bVisible = aCtrlProp.GetBoolProperty( CREATE_OUSTRING( "EnableVisible" ) );
544cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_fPrint, bVisible ? 0x00080000 : 0x00080002 ); // visible flag
545cdf0e10cSrcweir 
546cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x01000100 ); // bool field
547cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_lTxid, 0 );                        // Text ID
548cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_WrapText, 0x00000001 );
549cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x001A0008 );      // bool field
550cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x00100000 );      // bool field
551cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080000 );     // bool field
552cdf0e10cSrcweir 
553cdf0e10cSrcweir     // #i51348# name of the control, may overwrite shape name
554cdf0e10cSrcweir     OUString aCtrlName;
555cdf0e10cSrcweir     if( aCtrlProp.GetProperty( aCtrlName, CREATE_OUSTRING( "Name" ) ) && (aCtrlName.getLength() > 0) )
556cdf0e10cSrcweir         aPropOpt.AddOpt( ESCHER_Prop_wzName, aCtrlName );
557cdf0e10cSrcweir 
5580154edadSAndre Fischer     //Export description as alt text
5590154edadSAndre Fischer 	if( SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape( xShape ) )
5600154edadSAndre Fischer 	{
5610154edadSAndre Fischer 		String  aAltTxt( pSdrObj->GetDescription(), 0, MSPROP_DESCRIPTION_MAX_LEN );
5620154edadSAndre Fischer 		aPropOpt.AddOpt( ESCHER_Prop_wzDescription, aAltTxt );
5630154edadSAndre Fischer 	}
5640154edadSAndre Fischer 
565cdf0e10cSrcweir     // write DFF property set to stream
566cdf0e10cSrcweir     aPropOpt.Commit( mrEscherEx.GetStream() );
567cdf0e10cSrcweir 
568cdf0e10cSrcweir     // anchor
569cdf0e10cSrcweir     ImplWriteAnchor( GetRoot(), SdrObject::getSdrObjectFromXShape( xShape ), pChildAnchor );
570cdf0e10cSrcweir 
571cdf0e10cSrcweir     mrEscherEx.AddAtom( 0, ESCHER_ClientData );                       // OBJ record
572cdf0e10cSrcweir     mrEscherEx.UpdateDffFragmentEnd();
573cdf0e10cSrcweir 
574cdf0e10cSrcweir     // control label
575cdf0e10cSrcweir     OUString aString;
576cdf0e10cSrcweir     if( aCtrlProp.GetProperty( aString, CREATE_OUSTRING( "Label" ) ) )
577cdf0e10cSrcweir     {
578cdf0e10cSrcweir         /*  Be sure to construct the MSODRAWING record containing the
579cdf0e10cSrcweir             ClientTextbox atom after the base OBJ's MSODRAWING record data is
580cdf0e10cSrcweir             completed. */
581cdf0e10cSrcweir         pClientTextbox = new XclExpMsoDrawing( mrEscherEx );
582cdf0e10cSrcweir         mrEscherEx.AddAtom( 0, ESCHER_ClientTextbox );  // TXO record
583cdf0e10cSrcweir         mrEscherEx.UpdateDffFragmentEnd();
584cdf0e10cSrcweir 
585cdf0e10cSrcweir         sal_uInt16 nXclFont = EXC_FONT_APP;
586cdf0e10cSrcweir         if( aString.getLength() > 0 )
587cdf0e10cSrcweir         {
588cdf0e10cSrcweir             XclFontData aFontData;
589cdf0e10cSrcweir             GetFontPropSetHelper().ReadFontProperties( aFontData, aCtrlProp, EXC_FONTPROPSET_CONTROL );
590cdf0e10cSrcweir             if( (aFontData.maName.Len() > 0) && (aFontData.mnHeight > 0) )
591cdf0e10cSrcweir                 nXclFont = GetFontBuffer().Insert( aFontData, EXC_COLOR_CTRLTEXT );
592cdf0e10cSrcweir         }
593cdf0e10cSrcweir 
594cdf0e10cSrcweir         pTxo = new XclTxo( aString, nXclFont );
595cdf0e10cSrcweir         pTxo->SetHorAlign( (mnObjType == EXC_OBJTYPE_BUTTON) ? EXC_OBJ_HOR_CENTER : EXC_OBJ_HOR_LEFT );
596cdf0e10cSrcweir         pTxo->SetVerAlign( EXC_OBJ_VER_CENTER );
597cdf0e10cSrcweir     }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir     mrEscherEx.CloseContainer();  // ESCHER_SpContainer
600cdf0e10cSrcweir 
601cdf0e10cSrcweir     // other properties
602cdf0e10cSrcweir     aCtrlProp.GetProperty( mnLineCount, CREATE_OUSTRING( "LineCount" ) );
603cdf0e10cSrcweir 
604cdf0e10cSrcweir     // border style
605cdf0e10cSrcweir     sal_Int16 nApiButton = AwtVisualEffect::LOOK3D;
606cdf0e10cSrcweir     sal_Int16 nApiBorder = AwtVisualEffect::LOOK3D;
607cdf0e10cSrcweir     switch( nClassId )
608cdf0e10cSrcweir     {
609cdf0e10cSrcweir         case FormCompType::LISTBOX:
610cdf0e10cSrcweir         case FormCompType::COMBOBOX:
611cdf0e10cSrcweir             aCtrlProp.GetProperty( nApiBorder, CREATE_OUSTRING( "Border" ) );
612cdf0e10cSrcweir         break;
613cdf0e10cSrcweir         case FormCompType::CHECKBOX:
614cdf0e10cSrcweir         case FormCompType::RADIOBUTTON:
615cdf0e10cSrcweir             aCtrlProp.GetProperty( nApiButton, CREATE_OUSTRING( "VisualEffect" ) );
616cdf0e10cSrcweir             nApiBorder = AwtVisualEffect::NONE;
617cdf0e10cSrcweir         break;
618cdf0e10cSrcweir         // Push button cannot be set to flat in Excel
619cdf0e10cSrcweir         case FormCompType::COMMANDBUTTON:
620cdf0e10cSrcweir             nApiBorder = AwtVisualEffect::LOOK3D;
621cdf0e10cSrcweir         break;
622cdf0e10cSrcweir         // Label does not support a border in Excel
623cdf0e10cSrcweir         case FormCompType::FIXEDTEXT:
624cdf0e10cSrcweir             nApiBorder = AwtVisualEffect::NONE;
625cdf0e10cSrcweir         break;
626cdf0e10cSrcweir         /*  Scroll bar and spin button have a "Border" property, but it is
627cdf0e10cSrcweir             really used for a border, and not for own 3D/flat look (#i34712#). */
628cdf0e10cSrcweir         case FormCompType::SCROLLBAR:
629cdf0e10cSrcweir         case FormCompType::SPINBUTTON:
630cdf0e10cSrcweir             nApiButton = AwtVisualEffect::LOOK3D;
631cdf0e10cSrcweir             nApiBorder = AwtVisualEffect::NONE;
632cdf0e10cSrcweir         break;
633cdf0e10cSrcweir         // Group box does not support flat style (#i34712#)
634cdf0e10cSrcweir         case FormCompType::GROUPBOX:
635cdf0e10cSrcweir             nApiBorder = AwtVisualEffect::LOOK3D;
636cdf0e10cSrcweir         break;
637cdf0e10cSrcweir     }
638cdf0e10cSrcweir     mbFlatButton = nApiButton != AwtVisualEffect::LOOK3D;
639cdf0e10cSrcweir     mbFlatBorder = nApiBorder != AwtVisualEffect::LOOK3D;
640cdf0e10cSrcweir 
641cdf0e10cSrcweir     // control state
642cdf0e10cSrcweir     sal_Int16 nApiState = 0;
643cdf0e10cSrcweir     if( aCtrlProp.GetProperty( nApiState, CREATE_OUSTRING( "State" ) ) )
644cdf0e10cSrcweir     {
645cdf0e10cSrcweir         switch( nApiState )
646cdf0e10cSrcweir         {
647cdf0e10cSrcweir             case 0: mnState = EXC_OBJ_CHECKBOX_UNCHECKED;  break;
648cdf0e10cSrcweir             case 1: mnState = EXC_OBJ_CHECKBOX_CHECKED;    break;
649cdf0e10cSrcweir             case 2: mnState = EXC_OBJ_CHECKBOX_TRISTATE;   break;
650cdf0e10cSrcweir         }
651cdf0e10cSrcweir     }
652cdf0e10cSrcweir 
653cdf0e10cSrcweir     // special control contents
654cdf0e10cSrcweir     switch( nClassId )
655cdf0e10cSrcweir     {
656cdf0e10cSrcweir         case FormCompType::LISTBOX:
657cdf0e10cSrcweir         {
658cdf0e10cSrcweir             mbMultiSel = aCtrlProp.GetBoolProperty( CREATE_OUSTRING( "MultiSelection" ) );
659cdf0e10cSrcweir             Sequence< sal_Int16 > aSelection;
660cdf0e10cSrcweir             if( aCtrlProp.GetProperty( aSelection, CREATE_OUSTRING( "SelectedItems" ) ) )
661cdf0e10cSrcweir             {
662cdf0e10cSrcweir                 sal_Int32 nLen = aSelection.getLength();
663cdf0e10cSrcweir                 if( nLen > 0 )
664cdf0e10cSrcweir                 {
665cdf0e10cSrcweir                     mnSelEntry = aSelection[ 0 ] + 1;
666cdf0e10cSrcweir                     maMultiSel.resize( nLen );
667cdf0e10cSrcweir                     const sal_Int16* pnBegin = aSelection.getConstArray();
668cdf0e10cSrcweir                     ::std::copy( pnBegin, pnBegin + nLen, maMultiSel.begin() );
669cdf0e10cSrcweir                 }
670cdf0e10cSrcweir             }
671cdf0e10cSrcweir 
672cdf0e10cSrcweir             // convert listbox with dropdown button to Excel dropdown
673cdf0e10cSrcweir             if( aCtrlProp.GetBoolProperty( CREATE_OUSTRING( "Dropdown" ) ) )
674cdf0e10cSrcweir                 mnObjType = EXC_OBJTYPE_DROPDOWN;
675cdf0e10cSrcweir         }
676cdf0e10cSrcweir         break;
677cdf0e10cSrcweir 
678cdf0e10cSrcweir         case FormCompType::COMBOBOX:
679cdf0e10cSrcweir         {
680cdf0e10cSrcweir             Sequence< OUString > aStringList;
681cdf0e10cSrcweir             OUString aDefText;
682cdf0e10cSrcweir             if( aCtrlProp.GetProperty( aStringList, CREATE_OUSTRING( "StringItemList" ) ) &&
683cdf0e10cSrcweir                 aCtrlProp.GetProperty( aDefText, CREATE_OUSTRING( "Text" ) ) &&
684cdf0e10cSrcweir                 aStringList.getLength() && aDefText.getLength() )
685cdf0e10cSrcweir             {
686cdf0e10cSrcweir                 const OUString* pBegin = aStringList.getConstArray();
687cdf0e10cSrcweir                 const OUString* pEnd = pBegin + aStringList.getLength();
688cdf0e10cSrcweir                 const OUString* pString = ::std::find( pBegin, pEnd, aDefText );
689cdf0e10cSrcweir                 if( pString != pEnd )
690cdf0e10cSrcweir                     mnSelEntry = static_cast< sal_Int16 >( pString - pBegin + 1 );  // 1-based
691cdf0e10cSrcweir                 if( mnSelEntry > 0 )
692cdf0e10cSrcweir                     maMultiSel.resize( 1, mnSelEntry - 1 );
693cdf0e10cSrcweir             }
694cdf0e10cSrcweir 
695cdf0e10cSrcweir             // convert combobox without dropdown button to Excel listbox
696cdf0e10cSrcweir             if( !aCtrlProp.GetBoolProperty( CREATE_OUSTRING( "Dropdown" ) ) )
697cdf0e10cSrcweir                 mnObjType = EXC_OBJTYPE_LISTBOX;
698cdf0e10cSrcweir         }
699cdf0e10cSrcweir         break;
700cdf0e10cSrcweir 
701cdf0e10cSrcweir         case FormCompType::SCROLLBAR:
702cdf0e10cSrcweir         {
703cdf0e10cSrcweir             sal_Int32 nApiValue = 0;
704cdf0e10cSrcweir             if( aCtrlProp.GetProperty( nApiValue, CREATE_OUSTRING( "ScrollValueMin" ) ) )
705cdf0e10cSrcweir                 mnScrollMin = limit_cast< sal_uInt16 >( nApiValue, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
706cdf0e10cSrcweir             if( aCtrlProp.GetProperty( nApiValue, CREATE_OUSTRING( "ScrollValueMax" ) ) )
707cdf0e10cSrcweir                 mnScrollMax = limit_cast< sal_uInt16 >( nApiValue, mnScrollMin, EXC_OBJ_SCROLLBAR_MIN );
708cdf0e10cSrcweir             if( aCtrlProp.GetProperty( nApiValue, CREATE_OUSTRING( "ScrollValue" ) ) )
709cdf0e10cSrcweir                 mnScrollValue = limit_cast< sal_uInt16 >( nApiValue, mnScrollMin, mnScrollMax );
710cdf0e10cSrcweir             if( aCtrlProp.GetProperty( nApiValue, CREATE_OUSTRING( "LineIncrement" ) ) )
711cdf0e10cSrcweir                 mnScrollStep = limit_cast< sal_uInt16 >( nApiValue, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
712cdf0e10cSrcweir             if( aCtrlProp.GetProperty( nApiValue, CREATE_OUSTRING( "BlockIncrement" ) ) )
713cdf0e10cSrcweir                 mnScrollPage = limit_cast< sal_uInt16 >( nApiValue, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
714cdf0e10cSrcweir             if( aCtrlProp.GetProperty( nApiValue, CREATE_OUSTRING( "Orientation" ) ) )
715cdf0e10cSrcweir                 mbScrollHor = nApiValue == AwtScrollOrient::HORIZONTAL;
716cdf0e10cSrcweir         }
717cdf0e10cSrcweir         break;
718cdf0e10cSrcweir 
719cdf0e10cSrcweir         case FormCompType::SPINBUTTON:
720cdf0e10cSrcweir         {
721cdf0e10cSrcweir             sal_Int32 nApiValue = 0;
722cdf0e10cSrcweir             if( aCtrlProp.GetProperty( nApiValue, CREATE_OUSTRING( "SpinValueMin" ) ) )
723cdf0e10cSrcweir                 mnScrollMin = limit_cast< sal_uInt16 >( nApiValue, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
724cdf0e10cSrcweir             if( aCtrlProp.GetProperty( nApiValue, CREATE_OUSTRING( "SpinValueMax" ) ) )
725cdf0e10cSrcweir                 mnScrollMax = limit_cast< sal_uInt16 >( nApiValue, mnScrollMin, EXC_OBJ_SCROLLBAR_MAX );
726cdf0e10cSrcweir             if( aCtrlProp.GetProperty( nApiValue, CREATE_OUSTRING( "SpinValue" ) ) )
727cdf0e10cSrcweir                 mnScrollValue = limit_cast< sal_uInt16 >( nApiValue, mnScrollMin, mnScrollMax );
728cdf0e10cSrcweir             if( aCtrlProp.GetProperty( nApiValue, CREATE_OUSTRING( "SpinIncrement" ) ) )
729cdf0e10cSrcweir                 mnScrollStep = limit_cast< sal_uInt16 >( nApiValue, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
730cdf0e10cSrcweir             if( aCtrlProp.GetProperty( nApiValue, CREATE_OUSTRING( "Orientation" ) ) )
731cdf0e10cSrcweir                 mbScrollHor = nApiValue == AwtScrollOrient::HORIZONTAL;
732cdf0e10cSrcweir         }
733cdf0e10cSrcweir         break;
734cdf0e10cSrcweir     }
735cdf0e10cSrcweir 
736cdf0e10cSrcweir     // spreadsheet links
737cdf0e10cSrcweir     ConvertSheetLinks( xShape );
738cdf0e10cSrcweir }
739cdf0e10cSrcweir 
SetMacroLink(const ScriptEventDescriptor & rEvent)740cdf0e10cSrcweir bool XclExpTbxControlObj::SetMacroLink( const ScriptEventDescriptor& rEvent )
741cdf0e10cSrcweir {
742cdf0e10cSrcweir     String aMacroName = XclControlHelper::ExtractFromMacroDescriptor( rEvent, meEventType );
743cdf0e10cSrcweir     if( aMacroName.Len() )
744cdf0e10cSrcweir     {
745cdf0e10cSrcweir         sal_uInt16 nExtSheet = GetLocalLinkManager().FindExtSheet( EXC_EXTSH_OWNDOC );
746cdf0e10cSrcweir         sal_uInt16 nNameIdx = GetNameManager().InsertMacroCall( aMacroName, true, false );
747cdf0e10cSrcweir         mxMacroLink = GetFormulaCompiler().CreateNameXFormula( nExtSheet, nNameIdx );
748cdf0e10cSrcweir         return true;
749cdf0e10cSrcweir     }
750cdf0e10cSrcweir     return false;
751cdf0e10cSrcweir }
752cdf0e10cSrcweir 
WriteSubRecs(XclExpStream & rStrm)753cdf0e10cSrcweir void XclExpTbxControlObj::WriteSubRecs( XclExpStream& rStrm )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir     switch( mnObjType )
756cdf0e10cSrcweir     {
757cdf0e10cSrcweir         // *** Push buttons, labels ***
758cdf0e10cSrcweir 
759cdf0e10cSrcweir         case EXC_OBJTYPE_BUTTON:
760cdf0e10cSrcweir         case EXC_OBJTYPE_LABEL:
761cdf0e10cSrcweir             // ftMacro - macro link
762cdf0e10cSrcweir             WriteMacroSubRec( rStrm );
763cdf0e10cSrcweir         break;
764cdf0e10cSrcweir 
765cdf0e10cSrcweir         // *** Check boxes, option buttons ***
766cdf0e10cSrcweir 
767cdf0e10cSrcweir         case EXC_OBJTYPE_CHECKBOX:
768cdf0e10cSrcweir         case EXC_OBJTYPE_OPTIONBUTTON:
769cdf0e10cSrcweir         {
770cdf0e10cSrcweir             // ftCbls - box properties
771cdf0e10cSrcweir             sal_uInt16 nStyle = 0;
772cdf0e10cSrcweir             ::set_flag( nStyle, EXC_OBJ_CHECKBOX_FLAT, mbFlatButton );
773cdf0e10cSrcweir 
774cdf0e10cSrcweir             rStrm.StartRecord( EXC_ID_OBJCBLS, 12 );
775cdf0e10cSrcweir             rStrm << mnState;
776cdf0e10cSrcweir             rStrm.WriteZeroBytes( 8 );
777cdf0e10cSrcweir             rStrm << nStyle;
778cdf0e10cSrcweir             rStrm.EndRecord();
779cdf0e10cSrcweir 
780cdf0e10cSrcweir             // ftMacro - macro link
781cdf0e10cSrcweir             WriteMacroSubRec( rStrm );
782cdf0e10cSrcweir             // ftCblsFmla subrecord - cell link
783cdf0e10cSrcweir             WriteCellLinkSubRec( rStrm, EXC_ID_OBJCBLSFMLA );
784cdf0e10cSrcweir 
785cdf0e10cSrcweir             // ftCblsData subrecord - box properties, again
786cdf0e10cSrcweir             rStrm.StartRecord( EXC_ID_OBJCBLS, 8 );
787cdf0e10cSrcweir             rStrm << mnState;
788cdf0e10cSrcweir             rStrm.WriteZeroBytes( 4 );
789cdf0e10cSrcweir             rStrm << nStyle;
790cdf0e10cSrcweir             rStrm.EndRecord();
791cdf0e10cSrcweir         }
792cdf0e10cSrcweir         break;
793cdf0e10cSrcweir 
794cdf0e10cSrcweir         // *** List boxes, combo boxes ***
795cdf0e10cSrcweir 
796cdf0e10cSrcweir         case EXC_OBJTYPE_LISTBOX:
797cdf0e10cSrcweir         case EXC_OBJTYPE_DROPDOWN:
798cdf0e10cSrcweir         {
799cdf0e10cSrcweir             sal_uInt16 nEntryCount = GetSourceEntryCount();
800cdf0e10cSrcweir 
801cdf0e10cSrcweir             // ftSbs subrecord - Scroll bars
802cdf0e10cSrcweir             sal_Int32 nLineHeight = XclTools::GetHmmFromTwips( 200 );   // always 10pt
803cdf0e10cSrcweir             if( mnObjType == EXC_OBJTYPE_LISTBOX )
804cdf0e10cSrcweir                 mnLineCount = static_cast< sal_uInt16 >( mnHeight / nLineHeight );
805cdf0e10cSrcweir             mnScrollValue = 0;
806cdf0e10cSrcweir             mnScrollMin = 0;
807cdf0e10cSrcweir             sal_uInt16 nInvisLines = (nEntryCount >= mnLineCount) ? (nEntryCount - mnLineCount) : 0;
808cdf0e10cSrcweir             mnScrollMax = limit_cast< sal_uInt16 >( nInvisLines, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
809cdf0e10cSrcweir             mnScrollStep = 1;
810cdf0e10cSrcweir             mnScrollPage = limit_cast< sal_uInt16 >( mnLineCount, EXC_OBJ_SCROLLBAR_MIN, EXC_OBJ_SCROLLBAR_MAX );
811cdf0e10cSrcweir             mbScrollHor = false;
812cdf0e10cSrcweir             WriteSbs( rStrm );
813cdf0e10cSrcweir 
814cdf0e10cSrcweir             // ftMacro - macro link
815cdf0e10cSrcweir             WriteMacroSubRec( rStrm );
816cdf0e10cSrcweir             // ftSbsFmla subrecord - cell link
817cdf0e10cSrcweir             WriteCellLinkSubRec( rStrm, EXC_ID_OBJSBSFMLA );
818cdf0e10cSrcweir 
819cdf0e10cSrcweir             // ftLbsData - source data range and box properties
820cdf0e10cSrcweir             sal_uInt16 nStyle = 0;
821cdf0e10cSrcweir             ::insert_value( nStyle, mbMultiSel ? EXC_OBJ_LISTBOX_MULTI : EXC_OBJ_LISTBOX_SINGLE, 4, 2 );
822cdf0e10cSrcweir             ::set_flag( nStyle, EXC_OBJ_LISTBOX_FLAT, mbFlatBorder );
823cdf0e10cSrcweir 
824cdf0e10cSrcweir             rStrm.StartRecord( EXC_ID_OBJLBSDATA, 0 );
825cdf0e10cSrcweir 
826cdf0e10cSrcweir             if( const XclTokenArray* pSrcRange = GetSourceRangeTokArr() )
827cdf0e10cSrcweir             {
828cdf0e10cSrcweir                 rStrm << static_cast< sal_uInt16 >( (pSrcRange->GetSize() + 7) & 0xFFFE );
829cdf0e10cSrcweir                 WriteFormula( rStrm, *pSrcRange );
830cdf0e10cSrcweir             }
831cdf0e10cSrcweir             else
832cdf0e10cSrcweir                 rStrm << sal_uInt16( 0 );
833cdf0e10cSrcweir 
834cdf0e10cSrcweir             rStrm << nEntryCount << mnSelEntry << nStyle << sal_uInt16( 0 );
835cdf0e10cSrcweir             if( mnObjType == EXC_OBJTYPE_LISTBOX )
836cdf0e10cSrcweir             {
837cdf0e10cSrcweir                 if( nEntryCount )
838cdf0e10cSrcweir                 {
839cdf0e10cSrcweir                     ScfUInt8Vec aSelEx( nEntryCount, 0 );
840cdf0e10cSrcweir                     for( ScfInt16Vec::const_iterator aIt = maMultiSel.begin(), aEnd = maMultiSel.end(); aIt != aEnd; ++aIt )
841cdf0e10cSrcweir                         if( *aIt < nEntryCount )
842cdf0e10cSrcweir                             aSelEx[ *aIt ] = 1;
843cdf0e10cSrcweir                     rStrm.Write( &aSelEx[ 0 ], aSelEx.size() );
844cdf0e10cSrcweir                 }
845cdf0e10cSrcweir             }
846cdf0e10cSrcweir             else if( mnObjType == EXC_OBJTYPE_DROPDOWN )
847cdf0e10cSrcweir             {
848cdf0e10cSrcweir                 rStrm << sal_uInt16( 0 ) << mnLineCount << sal_uInt16( 0 ) << sal_uInt16( 0 );
849cdf0e10cSrcweir             }
850cdf0e10cSrcweir 
851cdf0e10cSrcweir             rStrm.EndRecord();
852cdf0e10cSrcweir         }
853cdf0e10cSrcweir         break;
854cdf0e10cSrcweir 
855cdf0e10cSrcweir         // *** Spin buttons, scrollbars ***
856cdf0e10cSrcweir 
857cdf0e10cSrcweir         case EXC_OBJTYPE_SPIN:
858cdf0e10cSrcweir         case EXC_OBJTYPE_SCROLLBAR:
859cdf0e10cSrcweir         {
860cdf0e10cSrcweir             // ftSbs subrecord - scroll bars
861cdf0e10cSrcweir             WriteSbs( rStrm );
862cdf0e10cSrcweir             // ftMacro - macro link
863cdf0e10cSrcweir             WriteMacroSubRec( rStrm );
864cdf0e10cSrcweir             // ftSbsFmla subrecord - cell link
865cdf0e10cSrcweir             WriteCellLinkSubRec( rStrm, EXC_ID_OBJSBSFMLA );
866cdf0e10cSrcweir         }
867cdf0e10cSrcweir         break;
868cdf0e10cSrcweir 
869cdf0e10cSrcweir         // *** Group boxes ***
870cdf0e10cSrcweir 
871cdf0e10cSrcweir         case EXC_OBJTYPE_GROUPBOX:
872cdf0e10cSrcweir         {
873cdf0e10cSrcweir             // ftMacro - macro link
874cdf0e10cSrcweir             WriteMacroSubRec( rStrm );
875cdf0e10cSrcweir 
876cdf0e10cSrcweir             // ftGboData subrecord - group box properties
877cdf0e10cSrcweir             sal_uInt16 nStyle = 0;
878cdf0e10cSrcweir             ::set_flag( nStyle, EXC_OBJ_GROUPBOX_FLAT, mbFlatBorder );
879cdf0e10cSrcweir 
880cdf0e10cSrcweir             rStrm.StartRecord( EXC_ID_OBJGBODATA, 6 );
881cdf0e10cSrcweir             rStrm   << sal_uInt32( 0 )
882cdf0e10cSrcweir                     << nStyle;
883cdf0e10cSrcweir             rStrm.EndRecord();
884cdf0e10cSrcweir         }
885cdf0e10cSrcweir         break;
886cdf0e10cSrcweir     }
887cdf0e10cSrcweir }
888cdf0e10cSrcweir 
WriteMacroSubRec(XclExpStream & rStrm)889cdf0e10cSrcweir void XclExpTbxControlObj::WriteMacroSubRec( XclExpStream& rStrm )
890cdf0e10cSrcweir {
891cdf0e10cSrcweir     if( mxMacroLink.is() )
892cdf0e10cSrcweir         WriteFormulaSubRec( rStrm, EXC_ID_OBJMACRO, *mxMacroLink );
893cdf0e10cSrcweir }
894cdf0e10cSrcweir 
WriteCellLinkSubRec(XclExpStream & rStrm,sal_uInt16 nSubRecId)895cdf0e10cSrcweir void XclExpTbxControlObj::WriteCellLinkSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId )
896cdf0e10cSrcweir {
897cdf0e10cSrcweir     if( const XclTokenArray* pCellLink = GetCellLinkTokArr() )
898cdf0e10cSrcweir         WriteFormulaSubRec( rStrm, nSubRecId, *pCellLink );
899cdf0e10cSrcweir }
900cdf0e10cSrcweir 
WriteSbs(XclExpStream & rStrm)901cdf0e10cSrcweir void XclExpTbxControlObj::WriteSbs( XclExpStream& rStrm )
902cdf0e10cSrcweir {
903cdf0e10cSrcweir     sal_uInt16 nOrient = 0;
904cdf0e10cSrcweir     ::set_flag( nOrient, EXC_OBJ_SCROLLBAR_HOR, mbScrollHor );
905cdf0e10cSrcweir     sal_uInt16 nStyle = EXC_OBJ_SCROLLBAR_DEFFLAGS;
906cdf0e10cSrcweir     ::set_flag( nStyle, EXC_OBJ_SCROLLBAR_FLAT, mbFlatButton );
907cdf0e10cSrcweir 
908cdf0e10cSrcweir     rStrm.StartRecord( EXC_ID_OBJSBS, 20 );
909cdf0e10cSrcweir     rStrm   << sal_uInt32( 0 )              // reserved
910cdf0e10cSrcweir             << mnScrollValue                // thumb position
911cdf0e10cSrcweir             << mnScrollMin                  // thumb min pos
912cdf0e10cSrcweir             << mnScrollMax                  // thumb max pos
913cdf0e10cSrcweir             << mnScrollStep                 // line increment
914cdf0e10cSrcweir             << mnScrollPage                 // page increment
915cdf0e10cSrcweir             << nOrient                      // 0 = vertical, 1 = horizontal
916cdf0e10cSrcweir             << sal_uInt16( 15 )             // thumb width
917cdf0e10cSrcweir             << nStyle;                      // flags/style
918cdf0e10cSrcweir     rStrm.EndRecord();
919cdf0e10cSrcweir }
920cdf0e10cSrcweir 
9210de526bdSJianyuan Li //#endif
922cdf0e10cSrcweir 
923cdf0e10cSrcweir // ----------------------------------------------------------------------------
924cdf0e10cSrcweir 
XclExpChartObj(XclExpObjectManager & rObjMgr,Reference<XShape> xShape,const Rectangle * pChildAnchor)925cdf0e10cSrcweir XclExpChartObj::XclExpChartObj( XclExpObjectManager& rObjMgr, Reference< XShape > xShape, const Rectangle* pChildAnchor ) :
926cdf0e10cSrcweir     XclObj( rObjMgr, EXC_OBJTYPE_CHART ),
927cdf0e10cSrcweir     XclExpRoot( rObjMgr.GetRoot() )
928cdf0e10cSrcweir {
929cdf0e10cSrcweir     // create the MSODRAWING record contents for the chart object
930cdf0e10cSrcweir     mrEscherEx.OpenContainer( ESCHER_SpContainer );
931cdf0e10cSrcweir     mrEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
932cdf0e10cSrcweir     EscherPropertyContainer aPropOpt;
933cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x01040104 );
934cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x00080008 );
935cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_fillColor, 0x0800004E );
936cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0x0800004D );
937cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x00110010 );
938cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_lineColor, 0x0800004D );
939cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080008 );
940cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_fshadowObscured, 0x00020000 );
941cdf0e10cSrcweir     aPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x00080000 );
942cdf0e10cSrcweir     aPropOpt.Commit( mrEscherEx.GetStream() );
943cdf0e10cSrcweir 
944cdf0e10cSrcweir     // anchor
945cdf0e10cSrcweir     SdrObject* pSdrObj = SdrObject::getSdrObjectFromXShape( xShape );
946cdf0e10cSrcweir     ImplWriteAnchor( GetRoot(), pSdrObj, pChildAnchor );
947cdf0e10cSrcweir 
948cdf0e10cSrcweir     // client data (the following OBJ record)
949cdf0e10cSrcweir     mrEscherEx.AddAtom( 0, ESCHER_ClientData );
950cdf0e10cSrcweir     mrEscherEx.CloseContainer();  // ESCHER_SpContainer
951cdf0e10cSrcweir     mrEscherEx.UpdateDffFragmentEnd();
952cdf0e10cSrcweir 
953cdf0e10cSrcweir     // load the chart OLE object
954cdf0e10cSrcweir     if( SdrOle2Obj* pSdrOleObj = dynamic_cast< SdrOle2Obj* >( pSdrObj ) )
955cdf0e10cSrcweir         svt::EmbeddedObjectRef::TryRunningState( pSdrOleObj->GetObjRef() );
956cdf0e10cSrcweir 
957cdf0e10cSrcweir     // create the chart substream object
958cdf0e10cSrcweir     ScfPropertySet aShapeProp( xShape );
959cdf0e10cSrcweir     Reference< XModel > xModel;
960cdf0e10cSrcweir     aShapeProp.GetProperty( xModel, CREATE_OUSTRING( "Model" ) );
961cdf0e10cSrcweir     ::com::sun::star::awt::Rectangle aBoundRect;
962cdf0e10cSrcweir     aShapeProp.GetProperty( aBoundRect, CREATE_OUSTRING( "BoundRect" ) );
963cdf0e10cSrcweir     Rectangle aChartRect( Point( aBoundRect.X, aBoundRect.Y ), Size( aBoundRect.Width, aBoundRect.Height ) );
964cdf0e10cSrcweir     mxChart.reset( new XclExpChart( GetRoot(), xModel, aChartRect ) );
965cdf0e10cSrcweir }
966cdf0e10cSrcweir 
~XclExpChartObj()967cdf0e10cSrcweir XclExpChartObj::~XclExpChartObj()
968cdf0e10cSrcweir {
969cdf0e10cSrcweir }
970cdf0e10cSrcweir 
Save(XclExpStream & rStrm)971cdf0e10cSrcweir void XclExpChartObj::Save( XclExpStream& rStrm )
972cdf0e10cSrcweir {
973cdf0e10cSrcweir     // content of OBJ record
974cdf0e10cSrcweir     XclObj::Save( rStrm );
975cdf0e10cSrcweir     // chart substream
976cdf0e10cSrcweir     mxChart->Save( rStrm );
977cdf0e10cSrcweir }
978cdf0e10cSrcweir 
979cdf0e10cSrcweir // ============================================================================
980cdf0e10cSrcweir 
XclExpNote(const XclExpRoot & rRoot,const ScAddress & rScPos,const ScPostIt * pScNote,const String & rAddText)981cdf0e10cSrcweir XclExpNote::XclExpNote( const XclExpRoot& rRoot, const ScAddress& rScPos,
982cdf0e10cSrcweir         const ScPostIt* pScNote, const String& rAddText ) :
983cdf0e10cSrcweir     XclExpRecord( EXC_ID_NOTE ),
984cdf0e10cSrcweir     maScPos( rScPos ),
985cdf0e10cSrcweir     mnObjId( EXC_OBJ_INVALID_ID ),
986cdf0e10cSrcweir     mbVisible( pScNote && pScNote->IsCaptionShown() )
987cdf0e10cSrcweir {
988cdf0e10cSrcweir     // get the main note text
989cdf0e10cSrcweir     String aNoteText;
990cdf0e10cSrcweir     if( pScNote )
991cdf0e10cSrcweir         aNoteText = pScNote->GetText();
992cdf0e10cSrcweir     // append additional text
993cdf0e10cSrcweir     ScGlobal::AddToken( aNoteText, rAddText, '\n', 2 );
994cdf0e10cSrcweir     maOrigNoteText = aNoteText;
995cdf0e10cSrcweir 
996cdf0e10cSrcweir     // initialize record dependent on BIFF type
997cdf0e10cSrcweir     switch( rRoot.GetBiff() )
998cdf0e10cSrcweir     {
999cdf0e10cSrcweir         case EXC_BIFF5:
1000cdf0e10cSrcweir             maNoteText = ByteString( aNoteText, rRoot.GetTextEncoding() );
1001cdf0e10cSrcweir         break;
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir         case EXC_BIFF8:
1004cdf0e10cSrcweir         {
1005cdf0e10cSrcweir             // TODO: additional text
1006cdf0e10cSrcweir             if( pScNote )
1007cdf0e10cSrcweir                 if( SdrCaptionObj* pCaption = pScNote->GetOrCreateCaption( maScPos ) )
1008cdf0e10cSrcweir                     if( const OutlinerParaObject* pOPO = pCaption->GetOutlinerParaObject() )
1009cdf0e10cSrcweir                         mnObjId = rRoot.GetObjectManager().AddObj( new XclObjComment( rRoot.GetObjectManager(), pCaption->GetLogicRect(), pOPO->GetTextObject(), pCaption, mbVisible ) );
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir             SetRecSize( 9 + maAuthor.GetSize() );
1012cdf0e10cSrcweir         }
1013cdf0e10cSrcweir         break;
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir         default:    DBG_ERROR_BIFF();
1016cdf0e10cSrcweir     }
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir 
Save(XclExpStream & rStrm)1019cdf0e10cSrcweir void XclExpNote::Save( XclExpStream& rStrm )
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir     switch( rStrm.GetRoot().GetBiff() )
1022cdf0e10cSrcweir     {
1023cdf0e10cSrcweir         case EXC_BIFF5:
1024cdf0e10cSrcweir         {
1025cdf0e10cSrcweir             // write the NOTE record directly, there may be the need to create more than one
1026cdf0e10cSrcweir             const sal_Char* pcBuffer = maNoteText.GetBuffer();
1027cdf0e10cSrcweir             sal_uInt16 nCharsLeft = static_cast< sal_uInt16 >( maNoteText.Len() );
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir             while( nCharsLeft )
1030cdf0e10cSrcweir             {
1031cdf0e10cSrcweir                 sal_uInt16 nWriteChars = ::std::min( nCharsLeft, EXC_NOTE5_MAXLEN );
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir                 rStrm.StartRecord( EXC_ID_NOTE, 6 + nWriteChars );
1034cdf0e10cSrcweir                 if( pcBuffer == maNoteText.GetBuffer() )
1035cdf0e10cSrcweir                 {
1036cdf0e10cSrcweir                     // first record: row, col, length of complete text
1037cdf0e10cSrcweir                     rStrm   << static_cast< sal_uInt16 >( maScPos.Row() )
1038cdf0e10cSrcweir                             << static_cast< sal_uInt16 >( maScPos.Col() )
1039cdf0e10cSrcweir                             << nCharsLeft;  // still contains full length
1040cdf0e10cSrcweir                 }
1041cdf0e10cSrcweir                 else
1042cdf0e10cSrcweir                 {
1043cdf0e10cSrcweir                     // next records: -1, 0, length of current text segment
1044cdf0e10cSrcweir                     rStrm   << sal_uInt16( 0xFFFF )
1045cdf0e10cSrcweir                             << sal_uInt16( 0 )
1046cdf0e10cSrcweir                             << nWriteChars;
1047cdf0e10cSrcweir                 }
1048cdf0e10cSrcweir                 rStrm.Write( pcBuffer, nWriteChars );
1049cdf0e10cSrcweir                 rStrm.EndRecord();
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir                 pcBuffer += nWriteChars;
1052cdf0e10cSrcweir                 nCharsLeft = nCharsLeft - nWriteChars;
1053cdf0e10cSrcweir             }
1054cdf0e10cSrcweir         }
1055cdf0e10cSrcweir         break;
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir         case EXC_BIFF8:
1058cdf0e10cSrcweir             if( mnObjId != EXC_OBJ_INVALID_ID )
1059cdf0e10cSrcweir                 XclExpRecord::Save( rStrm );
1060cdf0e10cSrcweir         break;
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir         default:    DBG_ERROR_BIFF();
1063cdf0e10cSrcweir     }
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir 
WriteBody(XclExpStream & rStrm)1066cdf0e10cSrcweir void XclExpNote::WriteBody( XclExpStream& rStrm )
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir     // BIFF5/BIFF7 is written separately
1069cdf0e10cSrcweir     DBG_ASSERT_BIFF( rStrm.GetRoot().GetBiff() == EXC_BIFF8 );
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir     sal_uInt16 nFlags = 0;
1072cdf0e10cSrcweir     ::set_flag( nFlags, EXC_NOTE_VISIBLE, mbVisible );
1073cdf0e10cSrcweir 
1074cdf0e10cSrcweir     rStrm   << static_cast< sal_uInt16 >( maScPos.Row() )
1075cdf0e10cSrcweir             << static_cast< sal_uInt16 >( maScPos.Col() )
1076cdf0e10cSrcweir             << nFlags
1077cdf0e10cSrcweir             << mnObjId
1078cdf0e10cSrcweir             << maAuthor
1079cdf0e10cSrcweir             << sal_uInt8( 0 );
1080cdf0e10cSrcweir }
1081cdf0e10cSrcweir 
WriteXml(sal_Int32 nAuthorId,XclExpXmlStream & rStrm)1082cdf0e10cSrcweir void XclExpNote::WriteXml( sal_Int32 nAuthorId, XclExpXmlStream& rStrm )
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir     sax_fastparser::FSHelperPtr rComments = rStrm.GetCurrentStream();
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir     rComments->startElement( XML_comment,
1087cdf0e10cSrcweir             XML_ref,        XclXmlUtils::ToOString( maScPos ).getStr(),
1088cdf0e10cSrcweir             XML_authorId,   OString::valueOf( nAuthorId ).getStr(),
1089cdf0e10cSrcweir             // OOXTODO: XML_guid,
1090cdf0e10cSrcweir             FSEND );
1091cdf0e10cSrcweir     rComments->startElement( XML_text, FSEND );
1092cdf0e10cSrcweir     // OOXTODO: phoneticPr, rPh, r
1093cdf0e10cSrcweir     rComments->startElement( XML_t, FSEND );
1094cdf0e10cSrcweir     rComments->writeEscaped( XclXmlUtils::ToOUString( maOrigNoteText ) );
1095cdf0e10cSrcweir     rComments->endElement ( XML_t );
1096cdf0e10cSrcweir     rComments->endElement( XML_text );
1097cdf0e10cSrcweir     rComments->endElement( XML_comment );
1098cdf0e10cSrcweir }
1099cdf0e10cSrcweir 
1100cdf0e10cSrcweir // ============================================================================
1101cdf0e10cSrcweir 
XclExpComments(SCTAB nTab,XclExpRecordList<XclExpNote> & rNotes)1102cdf0e10cSrcweir XclExpComments::XclExpComments( SCTAB nTab, XclExpRecordList< XclExpNote >& rNotes )
1103cdf0e10cSrcweir     : mnTab( nTab ), mrNotes( rNotes )
1104cdf0e10cSrcweir {
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir struct OUStringLess : public std::binary_function<OUString, OUString, bool>
1108cdf0e10cSrcweir {
operator ()OUStringLess1109cdf0e10cSrcweir     bool operator()(const OUString& x, const OUString& y) const
1110cdf0e10cSrcweir     {
1111cdf0e10cSrcweir         return x.compareTo( y ) <= 0;
1112cdf0e10cSrcweir     }
1113cdf0e10cSrcweir };
1114cdf0e10cSrcweir 
SaveXml(XclExpXmlStream & rStrm)1115cdf0e10cSrcweir void XclExpComments::SaveXml( XclExpXmlStream& rStrm )
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir     if( mrNotes.IsEmpty() )
1118cdf0e10cSrcweir         return;
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir     sax_fastparser::FSHelperPtr rComments = rStrm.CreateOutputStream(
1121cdf0e10cSrcweir             XclXmlUtils::GetStreamName( "xl/", "comments", mnTab + 1 ),
1122cdf0e10cSrcweir             XclXmlUtils::GetStreamName( "../", "comments", mnTab + 1 ),
1123cdf0e10cSrcweir             rStrm.GetCurrentStream()->getOutputStream(),
1124cdf0e10cSrcweir             "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",
1125cdf0e10cSrcweir             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" );
1126cdf0e10cSrcweir     rStrm.PushStream( rComments );
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir     rComments->startElement( XML_comments,
1129cdf0e10cSrcweir             XML_xmlns, "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
1130cdf0e10cSrcweir             FSEND );
1131cdf0e10cSrcweir     rComments->startElement( XML_authors, FSEND );
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir     typedef std::set< OUString, OUStringLess > Authors;
1134cdf0e10cSrcweir     Authors aAuthors;
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir     size_t nNotes = mrNotes.GetSize();
1137cdf0e10cSrcweir     for( size_t i = 0; i < nNotes; ++i )
1138cdf0e10cSrcweir     {
1139cdf0e10cSrcweir         aAuthors.insert( XclXmlUtils::ToOUString( mrNotes.GetRecord( i )->GetAuthor() ) );
1140cdf0e10cSrcweir     }
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir     for( Authors::const_iterator b = aAuthors.begin(), e = aAuthors.end(); b != e; ++b )
1143cdf0e10cSrcweir     {
1144cdf0e10cSrcweir         rComments->startElement( XML_author, FSEND );
1145cdf0e10cSrcweir         rComments->writeEscaped( *b );
1146cdf0e10cSrcweir         rComments->endElement( XML_author );
1147cdf0e10cSrcweir     }
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir     rComments->endElement( XML_authors );
1150cdf0e10cSrcweir     rComments->startElement( XML_commentList, FSEND );
1151cdf0e10cSrcweir 
11526d3b264bSHerbert Dürr     Authors::const_iterator aAuthorsBegin = aAuthors.begin();
1153cdf0e10cSrcweir     for( size_t i = 0; i < nNotes; ++i )
1154cdf0e10cSrcweir     {
1155cdf0e10cSrcweir         XclExpNoteList::RecordRefType xNote = mrNotes.GetRecord( i );
1156cdf0e10cSrcweir         Authors::const_iterator aAuthor = aAuthors.find(
1157cdf0e10cSrcweir                 XclXmlUtils::ToOUString( xNote->GetAuthor() ) );
11586d3b264bSHerbert Dürr         sal_Int32 nAuthorId = distance( aAuthorsBegin, aAuthor );
1159cdf0e10cSrcweir         xNote->WriteXml( nAuthorId, rStrm );
1160cdf0e10cSrcweir     }
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir     rComments->endElement( XML_commentList );
1163cdf0e10cSrcweir     rComments->endElement( XML_comments );
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir     rStrm.PopStream();
1166cdf0e10cSrcweir }
1167cdf0e10cSrcweir 
1168cdf0e10cSrcweir // object manager =============================================================
1169cdf0e10cSrcweir 
XclExpObjectManager(const XclExpRoot & rRoot)1170cdf0e10cSrcweir XclExpObjectManager::XclExpObjectManager( const XclExpRoot& rRoot ) :
1171cdf0e10cSrcweir     XclExpRoot( rRoot )
1172cdf0e10cSrcweir {
1173cdf0e10cSrcweir     InitStream( true );
1174cdf0e10cSrcweir     mxEscherEx.reset( new XclEscherEx( GetRoot(), *this, *mxDffStrm ) );
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir 
XclExpObjectManager(const XclExpObjectManager & rParent)1177cdf0e10cSrcweir XclExpObjectManager::XclExpObjectManager( const XclExpObjectManager& rParent ) :
1178cdf0e10cSrcweir     XclExpRoot( rParent.GetRoot() )
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir     InitStream( false );
1181cdf0e10cSrcweir     mxEscherEx.reset( new XclEscherEx( GetRoot(), *this, *mxDffStrm, rParent.mxEscherEx.get() ) );
1182cdf0e10cSrcweir }
1183cdf0e10cSrcweir 
~XclExpObjectManager()1184cdf0e10cSrcweir XclExpObjectManager::~XclExpObjectManager()
1185cdf0e10cSrcweir {
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir 
CreateDffAnchor() const1188cdf0e10cSrcweir XclExpDffAnchorBase* XclExpObjectManager::CreateDffAnchor() const
1189cdf0e10cSrcweir {
1190cdf0e10cSrcweir     return new XclExpDffSheetAnchor( GetRoot() );
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir 
CreateDrawingGroup()1193cdf0e10cSrcweir ScfRef< XclExpRecordBase > XclExpObjectManager::CreateDrawingGroup()
1194cdf0e10cSrcweir {
1195cdf0e10cSrcweir     return ScfRef< XclExpRecordBase >( new XclExpMsoDrawingGroup( *mxEscherEx ) );
1196cdf0e10cSrcweir }
1197cdf0e10cSrcweir 
StartSheet()1198cdf0e10cSrcweir void XclExpObjectManager::StartSheet()
1199cdf0e10cSrcweir {
1200cdf0e10cSrcweir     mxObjList.reset( new XclExpObjList( GetRoot(), *mxEscherEx ) );
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir 
ProcessDrawing(SdrPage * pSdrPage)1203cdf0e10cSrcweir ScfRef< XclExpRecordBase > XclExpObjectManager::ProcessDrawing( SdrPage* pSdrPage )
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir     if( pSdrPage )
1206cdf0e10cSrcweir         mxEscherEx->AddSdrPage( *pSdrPage );
1207cdf0e10cSrcweir     // #106213# the first dummy object may still be open
1208cdf0e10cSrcweir     DBG_ASSERT( mxEscherEx->GetGroupLevel() <= 1, "XclExpObjectManager::ProcessDrawing - still groups open?" );
1209cdf0e10cSrcweir     while( mxEscherEx->GetGroupLevel() )
1210cdf0e10cSrcweir         mxEscherEx->LeaveGroup();
1211cdf0e10cSrcweir     mxObjList->EndSheet();
1212cdf0e10cSrcweir     return mxObjList;
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir 
ProcessDrawing(const Reference<XShapes> & rxShapes)1215cdf0e10cSrcweir ScfRef< XclExpRecordBase > XclExpObjectManager::ProcessDrawing( const Reference< XShapes >& rxShapes )
1216cdf0e10cSrcweir {
1217cdf0e10cSrcweir     if( rxShapes.is() )
1218cdf0e10cSrcweir         mxEscherEx->AddUnoShapes( rxShapes );
1219cdf0e10cSrcweir     // #106213# the first dummy object may still be open
1220cdf0e10cSrcweir     DBG_ASSERT( mxEscherEx->GetGroupLevel() <= 1, "XclExpObjectManager::ProcessDrawing - still groups open?" );
1221cdf0e10cSrcweir     while( mxEscherEx->GetGroupLevel() )
1222cdf0e10cSrcweir         mxEscherEx->LeaveGroup();
1223cdf0e10cSrcweir     mxObjList->EndSheet();
1224cdf0e10cSrcweir     return mxObjList;
1225cdf0e10cSrcweir }
1226cdf0e10cSrcweir 
EndDocument()1227cdf0e10cSrcweir void XclExpObjectManager::EndDocument()
1228cdf0e10cSrcweir {
1229cdf0e10cSrcweir     mxEscherEx->EndDocument();
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir 
GetMsodrawingPerSheet()1232cdf0e10cSrcweir XclExpMsoDrawing* XclExpObjectManager::GetMsodrawingPerSheet()
1233cdf0e10cSrcweir {
1234cdf0e10cSrcweir     return mxObjList->GetMsodrawingPerSheet();
1235cdf0e10cSrcweir }
1236cdf0e10cSrcweir 
HasObj() const1237cdf0e10cSrcweir bool XclExpObjectManager::HasObj() const
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir     return mxObjList->Count() > 0;
1240cdf0e10cSrcweir }
1241cdf0e10cSrcweir 
AddObj(XclObj * pObjRec)1242cdf0e10cSrcweir sal_uInt16 XclExpObjectManager::AddObj( XclObj* pObjRec )
1243cdf0e10cSrcweir {
1244cdf0e10cSrcweir     return mxObjList->Add( pObjRec );
1245cdf0e10cSrcweir }
1246cdf0e10cSrcweir 
RemoveLastObj()1247cdf0e10cSrcweir XclObj* XclExpObjectManager::RemoveLastObj()
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir     XclObj* pLastObj = static_cast< XclObj* >( mxObjList->Last() );
1250cdf0e10cSrcweir     mxObjList->Remove();    // remove current, which is the Last()
1251cdf0e10cSrcweir     return pLastObj;
1252cdf0e10cSrcweir }
1253cdf0e10cSrcweir 
InitStream(bool bTempFile)1254cdf0e10cSrcweir void XclExpObjectManager::InitStream( bool bTempFile )
1255cdf0e10cSrcweir {
1256cdf0e10cSrcweir     if( bTempFile )
1257cdf0e10cSrcweir     {
1258cdf0e10cSrcweir         mxTempFile.reset( new ::utl::TempFile );
1259cdf0e10cSrcweir         if( mxTempFile->IsValid() )
1260cdf0e10cSrcweir         {
1261cdf0e10cSrcweir             mxTempFile->EnableKillingFile();
1262cdf0e10cSrcweir             mxDffStrm.reset( ::utl::UcbStreamHelper::CreateStream( mxTempFile->GetURL(), STREAM_STD_READWRITE ) );
1263cdf0e10cSrcweir         }
1264cdf0e10cSrcweir     }
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir     if( !mxDffStrm.get() )
1267cdf0e10cSrcweir         mxDffStrm.reset( new SvMemoryStream );
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir     mxDffStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
1270cdf0e10cSrcweir }
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir // ----------------------------------------------------------------------------
1273cdf0e10cSrcweir 
XclExpEmbeddedObjectManager(const XclExpObjectManager & rParent,const Size & rPageSize,sal_Int32 nScaleX,sal_Int32 nScaleY)1274cdf0e10cSrcweir XclExpEmbeddedObjectManager::XclExpEmbeddedObjectManager(
1275cdf0e10cSrcweir         const XclExpObjectManager& rParent, const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY ) :
1276cdf0e10cSrcweir     XclExpObjectManager( rParent ),
1277cdf0e10cSrcweir     maPageSize( rPageSize ),
1278cdf0e10cSrcweir     mnScaleX( nScaleX ),
1279cdf0e10cSrcweir     mnScaleY( nScaleY )
1280cdf0e10cSrcweir {
1281cdf0e10cSrcweir }
1282cdf0e10cSrcweir 
CreateDffAnchor() const1283cdf0e10cSrcweir XclExpDffAnchorBase* XclExpEmbeddedObjectManager::CreateDffAnchor() const
1284cdf0e10cSrcweir {
1285cdf0e10cSrcweir     return new XclExpDffEmbeddedAnchor( GetRoot(), maPageSize, mnScaleX, mnScaleY );
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir // ============================================================================
1289cdf0e10cSrcweir 
1290