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 #include "xiescher.hxx"
22 #include <com/sun/star/beans/NamedValue.hpp>
23 #include <com/sun/star/container/XIndexContainer.hpp>
24 #include <com/sun/star/container/XNameContainer.hpp>
25 #include <com/sun/star/embed/Aspects.hpp>
26 #include <com/sun/star/embed/XEmbeddedObject.hpp>
27 #include <com/sun/star/embed/XEmbedPersist.hpp>
28 #include <com/sun/star/awt/PushButtonType.hpp>
29 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
30 #include <com/sun/star/awt/VisualEffect.hpp>
31 #include <com/sun/star/style/HorizontalAlignment.hpp>
32 #include <com/sun/star/style/VerticalAlignment.hpp>
33 #include <com/sun/star/drawing/XControlShape.hpp>
34 #include <com/sun/star/form/XForm.hpp>
35 #include <com/sun/star/form/XFormsSupplier.hpp>
36 #include <com/sun/star/form/binding/XBindableValue.hpp>
37 #include <com/sun/star/form/binding/XValueBinding.hpp>
38 #include <com/sun/star/form/binding/XListEntrySink.hpp>
39 #include <com/sun/star/form/binding/XListEntrySource.hpp>
40 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
41 #include <com/sun/star/script/XEventAttacherManager.hpp>
42 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <sfx2/objsh.hxx>
45 #include <unotools/moduleoptions.hxx>
46 #include <unotools/fltrcfg.hxx>
47 #include <vcl/dibtools.hxx>
48 #include <vcl/wmf.hxx>
49 #include <comphelper/types.hxx>
50 #include <comphelper/classids.hxx>
51 #include <toolkit/helper/vclunohelper.hxx>
52 #include <basegfx/point/b2dpoint.hxx>
53 #include <basegfx/polygon/b2dpolygon.hxx>
55 #include <svx/svdopath.hxx>
56 #include <svx/svdocirc.hxx>
57 #include <svx/svdoedge.hxx>
58 #include <svx/svdogrp.hxx>
59 #include <svx/svdoashp.hxx>
60 #include <svx/svdograf.hxx>
61 #include <svx/svdoole2.hxx>
62 #include <svx/svdocapt.hxx>
63 #include <svx/svdouno.hxx>
64 #include <svx/svdpage.hxx>
65 #include <editeng/editobj.hxx>
66 #include <editeng/outliner.hxx>
67 #include <editeng/outlobj.hxx>
68 #include <svx/unoapi.hxx>
69 #include <svx/svditer.hxx>
70 #include <editeng/writingmodeitem.hxx>
71 #include <svx/charthelper.hxx>
73 #include "scitems.hxx"
74 #include <editeng/eeitem.hxx>
75 #include <editeng/colritem.hxx>
76 #include <svx/xflclit.hxx>
77 #include <sal/macros.h>
78 #include <editeng/adjustitem.hxx>
79 #include <svx/xlineit.hxx>
80 #include <svx/xlinjoit.hxx>
81 #include <svx/xlntrit.hxx>
82 #include <svx/xbtmpit.hxx>
83 #include <svx/xbitmap.hxx>
84 #include <svtools/embedhlp.hxx>
86 #include "document.hxx"
87 #include "drwlayer.hxx"
88 #include "userdat.hxx"
89 #include "chartarr.hxx"
90 #include "detfunc.hxx"
91 #include "unonames.hxx"
92 #include "convuno.hxx"
94 #include "globstr.hrc"
96 #include "fprogressbar.hxx"
97 #include "xltracer.hxx"
98 #include "xistream.hxx"
99 #include "xihelper.hxx"
100 #include "xiformula.hxx"
101 #include "xilink.hxx"
102 #include "xistyle.hxx"
103 #include "xipage.hxx"
104 #include "xichart.hxx"
105 #include "xicontent.hxx"
106 #include "scextopt.hxx"
108 #include "namebuff.hxx"
109 #include <boost/scoped_ptr.hpp>
110 #include <boost/shared_ptr.hpp>
111 #include <sfx2/docfile.hxx>
113 using namespace com::sun::star
;
114 using ::com::sun::star::uno::makeAny
;
115 using ::com::sun::star::uno::Any
;
116 using ::com::sun::star::beans::XPropertySet
;
117 using ::com::sun::star::uno::makeAny
;
118 using ::com::sun::star::uno::Exception
;
119 using ::com::sun::star::uno::Reference
;
120 using ::com::sun::star::uno::Sequence
;
121 using ::com::sun::star::uno::UNO_QUERY
;
122 using ::com::sun::star::uno::UNO_QUERY_THROW
;
123 using ::com::sun::star::uno::UNO_SET_THROW
;
124 using ::com::sun::star::uno::XComponentContext
;
125 using ::com::sun::star::beans::NamedValue
;
126 using ::com::sun::star::lang::XMultiServiceFactory
;
127 using ::com::sun::star::container::XIndexContainer
;
128 using ::com::sun::star::container::XNameContainer
;
129 using ::com::sun::star::frame::XModel
;
130 using ::com::sun::star::awt::XControlModel
;
131 using ::com::sun::star::embed::XEmbeddedObject
;
132 using ::com::sun::star::embed::XEmbedPersist
;
133 using ::com::sun::star::drawing::XControlShape
;
134 using ::com::sun::star::drawing::XShape
;
135 using ::com::sun::star::form::XForm
;
136 using ::com::sun::star::form::XFormComponent
;
137 using ::com::sun::star::form::XFormsSupplier
;
138 using ::com::sun::star::form::binding::XBindableValue
;
139 using ::com::sun::star::form::binding::XValueBinding
;
140 using ::com::sun::star::form::binding::XListEntrySink
;
141 using ::com::sun::star::form::binding::XListEntrySource
;
142 using ::com::sun::star::script::ScriptEventDescriptor
;
143 using ::com::sun::star::script::XEventAttacherManager
;
144 using ::com::sun::star::table::CellAddress
;
145 using ::com::sun::star::table::CellRangeAddress
;
149 struct SdrObjectFree
{
150 void operator ()(SdrObject
* obj
) { SdrObject::Free(obj
); }
153 typedef std::unique_ptr
<SdrObject
, SdrObjectFree
> SdrObjectPtr
;
157 // Drawing objects ============================================================
159 XclImpDrawObjBase::XclImpDrawObjBase( const XclImpRoot
& rRoot
) :
161 mnObjId( EXC_OBJ_INVALID_ID
),
163 mnObjType( EXC_OBJTYPE_UNKNOWN
),
166 mbHasAnchor( false ),
171 mbAutoMargin( true ),
172 mbSimpleMacro( true ),
173 mbProcessSdr( true ),
179 XclImpDrawObjBase::~XclImpDrawObjBase()
183 XclImpDrawObjRef
XclImpDrawObjBase::ReadObj3( const XclImpRoot
& rRoot
, XclImpStream
& rStrm
)
185 XclImpDrawObjRef xDrawObj
;
187 if( rStrm
.GetRecLeft() >= 30 )
191 nObjType
= rStrm
.ReaduInt16();
194 case EXC_OBJTYPE_GROUP
: xDrawObj
.reset( new XclImpGroupObj( rRoot
) ); break;
195 case EXC_OBJTYPE_LINE
: xDrawObj
.reset( new XclImpLineObj( rRoot
) ); break;
196 case EXC_OBJTYPE_RECTANGLE
: xDrawObj
.reset( new XclImpRectObj( rRoot
) ); break;
197 case EXC_OBJTYPE_OVAL
: xDrawObj
.reset( new XclImpOvalObj( rRoot
) ); break;
198 case EXC_OBJTYPE_ARC
: xDrawObj
.reset( new XclImpArcObj( rRoot
) ); break;
199 case EXC_OBJTYPE_CHART
: xDrawObj
.reset( new XclImpChartObj( rRoot
) ); break;
200 case EXC_OBJTYPE_TEXT
: xDrawObj
.reset( new XclImpTextObj( rRoot
) ); break;
201 case EXC_OBJTYPE_BUTTON
: xDrawObj
.reset( new XclImpButtonObj( rRoot
) ); break;
202 case EXC_OBJTYPE_PICTURE
: xDrawObj
.reset( new XclImpPictureObj( rRoot
) ); break;
204 OSL_TRACE( "XclImpDrawObjBase::ReadObj3 - unknown object type 0x%04hX", nObjType
);
205 rRoot
.GetTracer().TraceUnsupportedObjects();
211 xDrawObj
.reset(new XclImpPhObj(rRoot
));
214 xDrawObj
->mnTab
= rRoot
.GetCurrScTab();
215 xDrawObj
->ImplReadObj3( rStrm
);
219 XclImpDrawObjRef
XclImpDrawObjBase::ReadObj4( const XclImpRoot
& rRoot
, XclImpStream
& rStrm
)
221 XclImpDrawObjRef xDrawObj
;
223 if( rStrm
.GetRecLeft() >= 30 )
227 nObjType
= rStrm
.ReaduInt16();
230 case EXC_OBJTYPE_GROUP
: xDrawObj
.reset( new XclImpGroupObj( rRoot
) ); break;
231 case EXC_OBJTYPE_LINE
: xDrawObj
.reset( new XclImpLineObj( rRoot
) ); break;
232 case EXC_OBJTYPE_RECTANGLE
: xDrawObj
.reset( new XclImpRectObj( rRoot
) ); break;
233 case EXC_OBJTYPE_OVAL
: xDrawObj
.reset( new XclImpOvalObj( rRoot
) ); break;
234 case EXC_OBJTYPE_ARC
: xDrawObj
.reset( new XclImpArcObj( rRoot
) ); break;
235 case EXC_OBJTYPE_CHART
: xDrawObj
.reset( new XclImpChartObj( rRoot
) ); break;
236 case EXC_OBJTYPE_TEXT
: xDrawObj
.reset( new XclImpTextObj( rRoot
) ); break;
237 case EXC_OBJTYPE_BUTTON
: xDrawObj
.reset( new XclImpButtonObj( rRoot
) ); break;
238 case EXC_OBJTYPE_PICTURE
: xDrawObj
.reset( new XclImpPictureObj( rRoot
) ); break;
239 case EXC_OBJTYPE_POLYGON
: xDrawObj
.reset( new XclImpPolygonObj( rRoot
) ); break;
241 OSL_TRACE( "XclImpDrawObjBase::ReadObj4 - unknown object type 0x%04hX", nObjType
);
242 rRoot
.GetTracer().TraceUnsupportedObjects();
248 xDrawObj
.reset(new XclImpPhObj(rRoot
));
251 xDrawObj
->mnTab
= rRoot
.GetCurrScTab();
252 xDrawObj
->ImplReadObj4( rStrm
);
256 XclImpDrawObjRef
XclImpDrawObjBase::ReadObj5( const XclImpRoot
& rRoot
, XclImpStream
& rStrm
)
258 XclImpDrawObjRef xDrawObj
;
260 if( rStrm
.GetRecLeft() >= 34 )
262 sal_uInt16
nObjType(EXC_OBJTYPE_UNKNOWN
);
264 nObjType
= rStrm
.ReaduInt16();
267 case EXC_OBJTYPE_GROUP
: xDrawObj
.reset( new XclImpGroupObj( rRoot
) ); break;
268 case EXC_OBJTYPE_LINE
: xDrawObj
.reset( new XclImpLineObj( rRoot
) ); break;
269 case EXC_OBJTYPE_RECTANGLE
: xDrawObj
.reset( new XclImpRectObj( rRoot
) ); break;
270 case EXC_OBJTYPE_OVAL
: xDrawObj
.reset( new XclImpOvalObj( rRoot
) ); break;
271 case EXC_OBJTYPE_ARC
: xDrawObj
.reset( new XclImpArcObj( rRoot
) ); break;
272 case EXC_OBJTYPE_CHART
: xDrawObj
.reset( new XclImpChartObj( rRoot
) ); break;
273 case EXC_OBJTYPE_TEXT
: xDrawObj
.reset( new XclImpTextObj( rRoot
) ); break;
274 case EXC_OBJTYPE_BUTTON
: xDrawObj
.reset( new XclImpButtonObj( rRoot
) ); break;
275 case EXC_OBJTYPE_PICTURE
: xDrawObj
.reset( new XclImpPictureObj( rRoot
) ); break;
276 case EXC_OBJTYPE_POLYGON
: xDrawObj
.reset( new XclImpPolygonObj( rRoot
) ); break;
277 case EXC_OBJTYPE_CHECKBOX
: xDrawObj
.reset( new XclImpCheckBoxObj( rRoot
) ); break;
278 case EXC_OBJTYPE_OPTIONBUTTON
: xDrawObj
.reset( new XclImpOptionButtonObj( rRoot
) ); break;
279 case EXC_OBJTYPE_EDIT
: xDrawObj
.reset( new XclImpEditObj( rRoot
) ); break;
280 case EXC_OBJTYPE_LABEL
: xDrawObj
.reset( new XclImpLabelObj( rRoot
) ); break;
281 case EXC_OBJTYPE_DIALOG
: xDrawObj
.reset( new XclImpDialogObj( rRoot
) ); break;
282 case EXC_OBJTYPE_SPIN
: xDrawObj
.reset( new XclImpSpinButtonObj( rRoot
) ); break;
283 case EXC_OBJTYPE_SCROLLBAR
: xDrawObj
.reset( new XclImpScrollBarObj( rRoot
) ); break;
284 case EXC_OBJTYPE_LISTBOX
: xDrawObj
.reset( new XclImpListBoxObj( rRoot
) ); break;
285 case EXC_OBJTYPE_GROUPBOX
: xDrawObj
.reset( new XclImpGroupBoxObj( rRoot
) ); break;
286 case EXC_OBJTYPE_DROPDOWN
: xDrawObj
.reset( new XclImpDropDownObj( rRoot
) ); break;
288 OSL_TRACE( "XclImpDrawObjBase::ReadObj5 - unknown object type 0x%04hX", nObjType
);
289 rRoot
.GetTracer().TraceUnsupportedObjects();
290 xDrawObj
.reset( new XclImpPhObj( rRoot
) );
294 OSL_ENSURE(xDrawObj
, "object import failed");
298 xDrawObj
->mnTab
= rRoot
.GetCurrScTab();
299 xDrawObj
->ImplReadObj5( rStrm
);
304 XclImpDrawObjRef
XclImpDrawObjBase::ReadObj8( const XclImpRoot
& rRoot
, XclImpStream
& rStrm
)
306 XclImpDrawObjRef xDrawObj
;
308 if( rStrm
.GetRecLeft() >= 10 )
310 sal_uInt16
nSubRecId(0), nSubRecSize(0), nObjType(0);
311 nSubRecId
= rStrm
.ReaduInt16();
312 nSubRecSize
= rStrm
.ReaduInt16();
313 nObjType
= rStrm
.ReaduInt16();
314 OSL_ENSURE( nSubRecId
== EXC_ID_OBJCMO
, "XclImpDrawObjBase::ReadObj8 - OBJCMO subrecord expected" );
315 if( (nSubRecId
== EXC_ID_OBJCMO
) && (nSubRecSize
>= 6) )
319 // in BIFF8, all simple objects support text
320 case EXC_OBJTYPE_LINE
:
321 case EXC_OBJTYPE_ARC
:
322 xDrawObj
.reset( new XclImpTextObj( rRoot
) );
323 // lines and arcs may be 2-dimensional
324 xDrawObj
->SetAreaObj( false );
327 // in BIFF8, all simple objects support text
328 case EXC_OBJTYPE_RECTANGLE
:
329 case EXC_OBJTYPE_OVAL
:
330 case EXC_OBJTYPE_POLYGON
:
331 case EXC_OBJTYPE_DRAWING
:
332 case EXC_OBJTYPE_TEXT
:
333 xDrawObj
.reset( new XclImpTextObj( rRoot
) );
336 case EXC_OBJTYPE_GROUP
: xDrawObj
.reset( new XclImpGroupObj( rRoot
) ); break;
337 case EXC_OBJTYPE_CHART
: xDrawObj
.reset( new XclImpChartObj( rRoot
) ); break;
338 case EXC_OBJTYPE_BUTTON
: xDrawObj
.reset( new XclImpButtonObj( rRoot
) ); break;
339 case EXC_OBJTYPE_PICTURE
: xDrawObj
.reset( new XclImpPictureObj( rRoot
) ); break;
340 case EXC_OBJTYPE_CHECKBOX
: xDrawObj
.reset( new XclImpCheckBoxObj( rRoot
) ); break;
341 case EXC_OBJTYPE_OPTIONBUTTON
: xDrawObj
.reset( new XclImpOptionButtonObj( rRoot
) ); break;
342 case EXC_OBJTYPE_EDIT
: xDrawObj
.reset( new XclImpEditObj( rRoot
) ); break;
343 case EXC_OBJTYPE_LABEL
: xDrawObj
.reset( new XclImpLabelObj( rRoot
) ); break;
344 case EXC_OBJTYPE_DIALOG
: xDrawObj
.reset( new XclImpDialogObj( rRoot
) ); break;
345 case EXC_OBJTYPE_SPIN
: xDrawObj
.reset( new XclImpSpinButtonObj( rRoot
) ); break;
346 case EXC_OBJTYPE_SCROLLBAR
: xDrawObj
.reset( new XclImpScrollBarObj( rRoot
) ); break;
347 case EXC_OBJTYPE_LISTBOX
: xDrawObj
.reset( new XclImpListBoxObj( rRoot
) ); break;
348 case EXC_OBJTYPE_GROUPBOX
: xDrawObj
.reset( new XclImpGroupBoxObj( rRoot
) ); break;
349 case EXC_OBJTYPE_DROPDOWN
: xDrawObj
.reset( new XclImpDropDownObj( rRoot
) ); break;
350 case EXC_OBJTYPE_NOTE
: xDrawObj
.reset( new XclImpNoteObj( rRoot
) ); break;
353 OSL_TRACE( "XclImpDrawObjBase::ReadObj8 - unknown object type 0x%04hX", nObjType
);
354 rRoot
.GetTracer().TraceUnsupportedObjects();
359 if (!xDrawObj
) //ensure placeholder for unknown or broken records
361 SAL_WARN( "sc", "XclImpDrawObjBase::ReadObj8 import failed, substituting placeholder");
362 xDrawObj
.reset( new XclImpPhObj( rRoot
) );
365 xDrawObj
->mnTab
= rRoot
.GetCurrScTab();
366 xDrawObj
->ImplReadObj8( rStrm
);
370 void XclImpDrawObjBase::SetAnchor( const XclObjAnchor
& rAnchor
)
376 void XclImpDrawObjBase::SetDffData(
377 const DffObjData
& rDffObjData
, const OUString
& rObjName
, const OUString
& rHyperlink
,
378 bool bVisible
, bool bAutoMargin
)
380 mnDffShapeId
= rDffObjData
.nShapeId
;
381 mnDffFlags
= rDffObjData
.nSpFlags
;
382 maObjName
= rObjName
;
383 maHyperlink
= rHyperlink
;
384 mbVisible
= bVisible
;
385 mbAutoMargin
= bAutoMargin
;
388 OUString
XclImpDrawObjBase::GetObjName() const
390 /* #i51348# Always return a non-empty name. Create English
391 default names depending on the object type. This is not implemented as
392 virtual functions in derived classes, as class type and object type may
394 return maObjName
.isEmpty() ? GetObjectManager().GetDefaultObjName(*this) : maObjName
;
397 const XclObjAnchor
* XclImpDrawObjBase::GetAnchor() const
399 return mbHasAnchor
? &maAnchor
: 0;
402 bool XclImpDrawObjBase::IsValidSize( const Rectangle
& rAnchorRect
) const
404 // XclObjAnchor rounds up the width, width of 3 is the result of an Excel width of 0
406 ((rAnchorRect
.GetWidth() > 3) && (rAnchorRect
.GetHeight() > 1)) :
407 ((rAnchorRect
.GetWidth() > 3) || (rAnchorRect
.GetHeight() > 1));
410 ScRange
XclImpDrawObjBase::GetUsedArea( SCTAB nScTab
) const
412 ScRange
aScUsedArea( ScAddress::INITIALIZE_INVALID
);
413 // #i44077# object inserted -> update used area for OLE object import
414 if( mbHasAnchor
&& GetAddressConverter().ConvertRange( aScUsedArea
, maAnchor
, nScTab
, nScTab
, false ) )
416 // reduce range, if object ends directly on borders between two columns or rows
417 if( (maAnchor
.mnRX
== 0) && (aScUsedArea
.aStart
.Col() < aScUsedArea
.aEnd
.Col()) )
418 aScUsedArea
.aEnd
.IncCol( -1 );
419 if( (maAnchor
.mnBY
== 0) && (aScUsedArea
.aStart
.Row() < aScUsedArea
.aEnd
.Row()) )
420 aScUsedArea
.aEnd
.IncRow( -1 );
425 sal_Size
XclImpDrawObjBase::GetProgressSize() const
427 return DoGetProgressSize();
430 SdrObject
* XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter
& rDffConv
, const Rectangle
& rAnchorRect
, bool bIsDff
) const
432 SdrObjectPtr xSdrObj
;
433 if( bIsDff
&& !mbCustomDff
)
435 rDffConv
.Progress( GetProgressSize() );
439 xSdrObj
.reset( DoCreateSdrObj( rDffConv
, rAnchorRect
) );
441 xSdrObj
->SetModel( rDffConv
.GetModel() );
442 //added for exporting OCX control
443 /* mnObjType value set should be as below table:
444 0x0000 Group 0x0001 Line
445 0x0002 Rectangle 0x0003 Oval
446 0x0004 Arc 0x0005 Chart
447 0x0006 Text 0x0009 Polygon
448 +-----------------------------------------------------+
449 OCX ==>| 0x0008 Picture |
450 +-----------------------------------------------------+
452 | 0x000B Checkbox 0x000C Radio button |
453 | 0x000D Edit box 0x000E Label |
454 TBX ==> | 0x000F Dialog box 0x0010 Spin control |
455 | 0x0011 Scrollbar 0x0012 List |
456 | 0x0013 Group box 0x0014 Dropdown list |
457 +-----------------------------------------------------+
458 0x0019 Note 0x001E OfficeArt object
460 if( xSdrObj
&& xSdrObj
->IsUnoObj() &&
461 ( (mnObjType
< 25 && mnObjType
> 10) || mnObjType
== 7 || mnObjType
== 8 ) )
463 SdrUnoObj
* pSdrUnoObj
= dynamic_cast< SdrUnoObj
* >( xSdrObj
.get() );
464 if( pSdrUnoObj
!= NULL
)
466 Reference
< XControlModel
> xCtrlModel
= pSdrUnoObj
->GetUnoControlModel();
467 Reference
< XPropertySet
> xPropSet(xCtrlModel
,UNO_QUERY
);
468 const static rtl::OUString
sPropertyName("ControlTypeinMSO");
470 enum { eCreateFromOffice
= 0, eCreateFromMSTBXControl
, eCreateFromMSOCXControl
};
472 if( mnObjType
== 7 || (mnObjType
< 25 && mnObjType
> 10) )//TBX
474 //Need summary type for export. Detail type(checkbox, button ...) has been contained by mnObjType
475 const sal_Int16 nTBXControlType
= eCreateFromMSTBXControl
;
477 aAny
<<= nTBXControlType
;
480 xPropSet
->setPropertyValue(sPropertyName
, aAny
);
482 catch(const Exception
&)
484 OSL_TRACE("XclImpDrawObjBase::CreateSdrObject, this control can't be set the property ControlTypeinMSO!");
487 if( mnObjType
== 8 )//OCX
489 //Need summary type for export
490 const static rtl::OUString
sObjIdPropertyName("ObjIDinMSO");
491 const XclImpPictureObj
* const pObj
= dynamic_cast< const XclImpPictureObj
* const >(this);
492 if( pObj
!= NULL
&& pObj
->IsOcxControl() )
494 const sal_Int16 nOCXControlType
= eCreateFromMSOCXControl
;
498 aAny
<<= nOCXControlType
;
499 xPropSet
->setPropertyValue(sPropertyName
, aAny
);
500 //Detail type(checkbox, button ...)
502 xPropSet
->setPropertyValue(sObjIdPropertyName
, aAny
);
504 catch(const Exception
&)
506 OSL_TRACE("XclImpDrawObjBase::CreateSdrObject, this control can't be set the property ObjIDinMSO!");
514 return xSdrObj
.release();
517 void XclImpDrawObjBase::PreProcessSdrObject( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const
519 // default: front layer, derived classes may have to set other layer in DoPreProcessSdrObj()
520 rSdrObj
.NbcSetLayer( SC_LAYER_FRONT
);
522 // set object name (GetObjName() will always return a non-empty name)
523 rSdrObj
.SetName( GetObjName() );
525 // #i39167# full width for all objects regardless of horizontal alignment
526 rSdrObj
.SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK
) );
528 // automatic text margin
531 sal_Int32 nMargin
= rDffConv
.GetDefaultTextMargin();
532 rSdrObj
.SetMergedItem( makeSdrTextLeftDistItem( nMargin
) );
533 rSdrObj
.SetMergedItem( makeSdrTextRightDistItem( nMargin
) );
534 rSdrObj
.SetMergedItem( makeSdrTextUpperDistItem( nMargin
) );
535 rSdrObj
.SetMergedItem( makeSdrTextLowerDistItem( nMargin
) );
538 // macro and hyperlink
539 // removed oracle/sun check for mbSimpleMacro ( no idea what its for )
540 if (!maMacroName
.isEmpty() || !maHyperlink
.isEmpty())
542 if( ScMacroInfo
* pInfo
= ScDrawLayer::GetMacroInfo( &rSdrObj
, true ) )
544 pInfo
->SetMacro( XclTools::GetSbMacroUrl( maMacroName
, GetDocShell() ) );
545 pInfo
->SetHlink( maHyperlink
);
549 // call virtual function for object type specific processing
550 DoPreProcessSdrObj( rDffConv
, rSdrObj
);
553 void XclImpDrawObjBase::PostProcessSdrObject( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const
555 // call virtual function for object type specific processing
556 DoPostProcessSdrObj( rDffConv
, rSdrObj
);
559 // protected ------------------------------------------------------------------
561 void XclImpDrawObjBase::ReadName5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
)
566 // name length field is repeated before the name
567 maObjName
= rStrm
.ReadByteString( false );
568 // skip padding byte for word boundaries
569 if( rStrm
.GetRecPos() & 1 ) rStrm
.Ignore( 1 );
573 void XclImpDrawObjBase::ReadMacro3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
576 rStrm
.Ignore( nMacroSize
);
577 // skip padding byte for word boundaries, not contained in nMacroSize
578 if( rStrm
.GetRecPos() & 1 ) rStrm
.Ignore( 1 );
581 void XclImpDrawObjBase::ReadMacro4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
584 rStrm
.Ignore( nMacroSize
);
587 void XclImpDrawObjBase::ReadMacro5( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
590 rStrm
.Ignore( nMacroSize
);
593 void XclImpDrawObjBase::ReadMacro8( XclImpStream
& rStrm
)
596 if( rStrm
.GetRecLeft() > 6 )
598 // macro is stored in a tNameXR token containing a link to a defined name
599 sal_uInt16 nFmlaSize
;
600 nFmlaSize
= rStrm
.ReaduInt16();
602 OSL_ENSURE( nFmlaSize
== 7, "XclImpDrawObjBase::ReadMacro - unexpected formula size" );
606 sal_uInt16 nExtSheet
, nExtName
;
607 nTokenId
= rStrm
.ReaduInt8();
608 nExtSheet
= rStrm
.ReaduInt16();
609 nExtName
= rStrm
.ReaduInt16();
610 OSL_ENSURE( nTokenId
== XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX
, EXC_TOKCLASS_REF
),
611 "XclImpDrawObjBase::ReadMacro - tNameXR token expected" );
612 if( nTokenId
== XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX
, EXC_TOKCLASS_REF
) )
613 maMacroName
= GetLinkManager().GetMacroName( nExtSheet
, nExtName
);
618 void XclImpDrawObjBase::ConvertLineStyle( SdrObject
& rSdrObj
, const XclObjLineData
& rLineData
) const
620 if( rLineData
.IsAuto() )
622 XclObjLineData aAutoData
;
623 aAutoData
.mnAuto
= 0;
624 ConvertLineStyle( rSdrObj
, aAutoData
);
628 long nLineWidth
= 35 * ::std::min( rLineData
.mnWidth
, EXC_OBJ_LINE_THICK
);
629 rSdrObj
.SetMergedItem( XLineWidthItem( nLineWidth
) );
630 rSdrObj
.SetMergedItem( XLineColorItem( EMPTY_OUSTRING
, GetPalette().GetColor( rLineData
.mnColorIdx
) ) );
631 rSdrObj
.SetMergedItem( XLineJointItem( com::sun::star::drawing::LineJoint_MITER
) );
633 sal_uLong nDotLen
= ::std::max
< sal_uLong
>( 70 * rLineData
.mnWidth
, 35 );
634 sal_uLong nDashLen
= 3 * nDotLen
;
635 sal_uLong nDist
= 2 * nDotLen
;
637 switch( rLineData
.mnStyle
)
640 case EXC_OBJ_LINE_SOLID
:
641 rSdrObj
.SetMergedItem( XLineStyleItem( drawing::LineStyle_SOLID
) );
643 case EXC_OBJ_LINE_DASH
:
644 rSdrObj
.SetMergedItem( XLineStyleItem( drawing::LineStyle_DASH
) );
645 rSdrObj
.SetMergedItem( XLineDashItem( EMPTY_OUSTRING
, XDash( css::drawing::DashStyle_RECT
, 0, nDotLen
, 1, nDashLen
, nDist
) ) );
647 case EXC_OBJ_LINE_DOT
:
648 rSdrObj
.SetMergedItem( XLineStyleItem( drawing::LineStyle_DASH
) );
649 rSdrObj
.SetMergedItem( XLineDashItem( EMPTY_OUSTRING
, XDash( css::drawing::DashStyle_RECT
, 1, nDotLen
, 0, nDashLen
, nDist
) ) );
651 case EXC_OBJ_LINE_DASHDOT
:
652 rSdrObj
.SetMergedItem( XLineStyleItem( drawing::LineStyle_DASH
) );
653 rSdrObj
.SetMergedItem( XLineDashItem( EMPTY_OUSTRING
, XDash( css::drawing::DashStyle_RECT
, 1, nDotLen
, 1, nDashLen
, nDist
) ) );
655 case EXC_OBJ_LINE_DASHDOTDOT
:
656 rSdrObj
.SetMergedItem( XLineStyleItem( drawing::LineStyle_DASH
) );
657 rSdrObj
.SetMergedItem( XLineDashItem( EMPTY_OUSTRING
, XDash( css::drawing::DashStyle_RECT
, 2, nDotLen
, 1, nDashLen
, nDist
) ) );
659 case EXC_OBJ_LINE_MEDTRANS
:
660 rSdrObj
.SetMergedItem( XLineStyleItem( drawing::LineStyle_SOLID
) );
661 rSdrObj
.SetMergedItem( XLineTransparenceItem( 50 ) );
663 case EXC_OBJ_LINE_DARKTRANS
:
664 rSdrObj
.SetMergedItem( XLineStyleItem( drawing::LineStyle_SOLID
) );
665 rSdrObj
.SetMergedItem( XLineTransparenceItem( 25 ) );
667 case EXC_OBJ_LINE_LIGHTTRANS
:
668 rSdrObj
.SetMergedItem( XLineStyleItem( drawing::LineStyle_SOLID
) );
669 rSdrObj
.SetMergedItem( XLineTransparenceItem( 75 ) );
671 case EXC_OBJ_LINE_NONE
:
672 rSdrObj
.SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE
) );
678 void XclImpDrawObjBase::ConvertFillStyle( SdrObject
& rSdrObj
, const XclObjFillData
& rFillData
) const
680 if( rFillData
.IsAuto() )
682 XclObjFillData aAutoData
;
683 aAutoData
.mnAuto
= 0;
684 ConvertFillStyle( rSdrObj
, aAutoData
);
686 else if( rFillData
.mnPattern
== EXC_PATT_NONE
)
688 rSdrObj
.SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE
) );
692 Color aPattColor
= GetPalette().GetColor( rFillData
.mnPattColorIdx
);
693 Color aBackColor
= GetPalette().GetColor( rFillData
.mnBackColorIdx
);
694 if( (rFillData
.mnPattern
== EXC_PATT_SOLID
) || (aPattColor
== aBackColor
) )
696 rSdrObj
.SetMergedItem( XFillStyleItem( drawing::FillStyle_SOLID
) );
697 rSdrObj
.SetMergedItem( XFillColorItem( EMPTY_OUSTRING
, aPattColor
) );
701 static const sal_uInt8 sppnPatterns
[][ 8 ] =
703 { 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55 },
704 { 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD },
705 { 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22 },
706 { 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00 },
707 { 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC },
708 { 0x33, 0x66, 0xCC, 0x99, 0x33, 0x66, 0xCC, 0x99 },
709 { 0xCC, 0x66, 0x33, 0x99, 0xCC, 0x66, 0x33, 0x99 },
710 { 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33 },
711 { 0xCC, 0xFF, 0x33, 0xFF, 0xCC, 0xFF, 0x33, 0xFF },
712 { 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00 },
713 { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 },
714 { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 },
715 { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 },
716 { 0xFF, 0x11, 0x11, 0x11, 0xFF, 0x11, 0x11, 0x11 },
717 { 0xAA, 0x44, 0xAA, 0x11, 0xAA, 0x44, 0xAA, 0x11 },
718 { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 },
719 { 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x08, 0x00 }
721 const sal_uInt8
* const pnPattern
= sppnPatterns
[ ::std::min
< size_t >( rFillData
.mnPattern
- 2, SAL_N_ELEMENTS( sppnPatterns
) ) ];
722 // create 2-colored 8x8 DIB
723 SvMemoryStream aMemStrm
;
724 aMemStrm
.WriteUInt32( 12 ).WriteInt16( 8 ).WriteInt16( 8 ).WriteUInt16( 1 ).WriteUInt16( 1 );
725 aMemStrm
.WriteUChar( 0xFF ).WriteUChar( 0xFF ).WriteUChar( 0xFF );
726 aMemStrm
.WriteUChar( 0x00 ).WriteUChar( 0x00 ).WriteUChar( 0x00 );
727 for( size_t nIdx
= 0; nIdx
< 8; ++nIdx
)
728 aMemStrm
.WriteUInt32( pnPattern
[ nIdx
] ); // 32-bit little-endian
729 aMemStrm
.Seek( STREAM_SEEK_TO_BEGIN
);
731 ReadDIB(aBitmap
, aMemStrm
, false);
733 XOBitmap
aXOBitmap( aBitmap
);
734 aXOBitmap
.Bitmap2Array();
735 aXOBitmap
.SetBitmapType( XBITMAP_8X8
);
736 if( aXOBitmap
.GetBackgroundColor().GetColor() == COL_BLACK
)
737 ::std::swap( aPattColor
, aBackColor
);
738 aXOBitmap
.SetPixelColor( aPattColor
);
739 aXOBitmap
.SetBackgroundColor( aBackColor
);
740 aXOBitmap
.Array2Bitmap();
741 aBitmap
= aXOBitmap
.GetBitmap();
743 rSdrObj
.SetMergedItem(XFillStyleItem(drawing::FillStyle_BITMAP
));
744 rSdrObj
.SetMergedItem(XFillBitmapItem(EMPTY_OUSTRING
, Graphic(aBitmap
)));
749 void XclImpDrawObjBase::ConvertFrameStyle( SdrObject
& rSdrObj
, sal_uInt16 nFrameFlags
) const
751 if( ::get_flag( nFrameFlags
, EXC_OBJ_FRAME_SHADOW
) )
753 rSdrObj
.SetMergedItem( makeSdrShadowItem( true ) );
754 rSdrObj
.SetMergedItem( makeSdrShadowXDistItem( 35 ) );
755 rSdrObj
.SetMergedItem( makeSdrShadowYDistItem( 35 ) );
756 rSdrObj
.SetMergedItem( makeSdrShadowColorItem( GetPalette().GetColor( EXC_COLOR_WINDOWTEXT
) ) );
760 Color
XclImpDrawObjBase::GetSolidLineColor( const XclObjLineData
& rLineData
) const
762 Color
aColor( COL_TRANSPARENT
);
763 if( rLineData
.IsAuto() )
765 XclObjLineData aAutoData
;
766 aAutoData
.mnAuto
= 0;
767 aColor
= GetSolidLineColor( aAutoData
);
769 else if( rLineData
.mnStyle
!= EXC_OBJ_LINE_NONE
)
771 aColor
= GetPalette().GetColor( rLineData
.mnColorIdx
);
776 Color
XclImpDrawObjBase::GetSolidFillColor( const XclObjFillData
& rFillData
) const
778 Color
aColor( COL_TRANSPARENT
);
779 if( rFillData
.IsAuto() )
781 XclObjFillData aAutoData
;
782 aAutoData
.mnAuto
= 0;
783 aColor
= GetSolidFillColor( aAutoData
);
785 else if( rFillData
.mnPattern
!= EXC_PATT_NONE
)
787 Color aPattColor
= GetPalette().GetColor( rFillData
.mnPattColorIdx
);
788 Color aBackColor
= GetPalette().GetColor( rFillData
.mnBackColorIdx
);
789 aColor
= XclTools::GetPatternColor( aPattColor
, aBackColor
, rFillData
.mnPattern
);
794 void XclImpDrawObjBase::DoReadObj3( XclImpStream
&, sal_uInt16
)
798 void XclImpDrawObjBase::DoReadObj4( XclImpStream
&, sal_uInt16
)
802 void XclImpDrawObjBase::DoReadObj5( XclImpStream
&, sal_uInt16
, sal_uInt16
)
806 void XclImpDrawObjBase::DoReadObj8SubRec( XclImpStream
&, sal_uInt16
, sal_uInt16
)
810 sal_Size
XclImpDrawObjBase::DoGetProgressSize() const
815 SdrObject
* XclImpDrawObjBase::DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const Rectangle
& ) const
817 rDffConv
.Progress( GetProgressSize() );
821 void XclImpDrawObjBase::DoPreProcessSdrObj( XclImpDffConverter
&, SdrObject
& ) const
823 // trace if object is not printable
825 GetTracer().TraceObjectNotPrintable();
828 void XclImpDrawObjBase::DoPostProcessSdrObj( XclImpDffConverter
&, SdrObject
& ) const
832 void XclImpDrawObjBase::ImplReadObj3( XclImpStream
& rStrm
)
834 // back to offset 4 (ignore object count field)
837 sal_uInt16 nObjFlags
, nMacroSize
;
838 mnObjType
= rStrm
.ReaduInt16();
839 mnObjId
= rStrm
.ReaduInt16();
840 nObjFlags
= rStrm
.ReaduInt16();
842 nMacroSize
= rStrm
.ReaduInt16();
846 mbHidden
= ::get_flag( nObjFlags
, EXC_OBJ_HIDDEN
);
847 mbVisible
= ::get_flag( nObjFlags
, EXC_OBJ_VISIBLE
);
848 DoReadObj3( rStrm
, nMacroSize
);
851 void XclImpDrawObjBase::ImplReadObj4( XclImpStream
& rStrm
)
853 // back to offset 4 (ignore object count field)
856 sal_uInt16 nObjFlags
, nMacroSize
;
857 mnObjType
= rStrm
.ReaduInt16();
858 mnObjId
= rStrm
.ReaduInt16();
859 nObjFlags
= rStrm
.ReaduInt16();
861 nMacroSize
= rStrm
.ReaduInt16();
865 mbHidden
= ::get_flag( nObjFlags
, EXC_OBJ_HIDDEN
);
866 mbVisible
= ::get_flag( nObjFlags
, EXC_OBJ_VISIBLE
);
867 mbPrintable
= ::get_flag( nObjFlags
, EXC_OBJ_PRINTABLE
);
868 DoReadObj4( rStrm
, nMacroSize
);
871 void XclImpDrawObjBase::ImplReadObj5( XclImpStream
& rStrm
)
873 // back to offset 4 (ignore object count field)
876 sal_uInt16 nObjFlags
, nMacroSize
, nNameLen
;
877 mnObjType
= rStrm
.ReaduInt16();
878 mnObjId
= rStrm
.ReaduInt16();
879 nObjFlags
= rStrm
.ReaduInt16();
881 nMacroSize
= rStrm
.ReaduInt16();
883 nNameLen
= rStrm
.ReaduInt16();
887 mbHidden
= ::get_flag( nObjFlags
, EXC_OBJ_HIDDEN
);
888 mbVisible
= ::get_flag( nObjFlags
, EXC_OBJ_VISIBLE
);
889 mbPrintable
= ::get_flag( nObjFlags
, EXC_OBJ_PRINTABLE
);
890 DoReadObj5( rStrm
, nNameLen
, nMacroSize
);
893 void XclImpDrawObjBase::ImplReadObj8( XclImpStream
& rStrm
)
896 rStrm
.Seek( EXC_REC_SEEK_TO_BEGIN
);
899 while( bLoop
&& (rStrm
.GetRecLeft() >= 4) )
901 sal_uInt16 nSubRecId
, nSubRecSize
;
902 nSubRecId
= rStrm
.ReaduInt16();
903 nSubRecSize
= rStrm
.ReaduInt16();
904 rStrm
.PushPosition();
905 // sometimes the last subrecord has an invalid length (OBJLBSDATA) -> min()
906 nSubRecSize
= static_cast< sal_uInt16
>( ::std::min
< sal_Size
>( nSubRecSize
, rStrm
.GetRecLeft() ) );
911 OSL_ENSURE( rStrm
.GetRecPos() == 4, "XclImpDrawObjBase::ImplReadObj8 - unexpected OBJCMO subrecord" );
912 if( (rStrm
.GetRecPos() == 4) && (nSubRecSize
>= 6) )
914 sal_uInt16 nObjFlags
;
915 mnObjType
= rStrm
.ReaduInt16();
916 mnObjId
= rStrm
.ReaduInt16( );
917 nObjFlags
= rStrm
.ReaduInt16( );
918 mbPrintable
= ::get_flag( nObjFlags
, EXC_OBJCMO_PRINTABLE
);
921 case EXC_ID_OBJMACRO
:
928 DoReadObj8SubRec( rStrm
, nSubRecId
, nSubRecSize
);
932 rStrm
.Ignore( nSubRecSize
);
935 /* Call DoReadObj8SubRec() with EXC_ID_OBJEND for further stream
936 processing (e.g. charts), even if the OBJEND subrecord is missing. */
937 DoReadObj8SubRec( rStrm
, EXC_ID_OBJEND
, 0 );
939 /* Pictures that Excel reads from BIFF5 and writes to BIFF8 still have the
940 IMGDATA record following the OBJ record (but they use the image data
941 stored in DFF). The IMGDATA record may be continued by several CONTINUE
942 records. But the last CONTINUE record may be in fact an MSODRAWING
943 record that contains the DFF data of the next drawing object! So we
944 have to skip just enough CONTINUE records to look at the next
945 MSODRAWING/CONTINUE record. */
946 if( (rStrm
.GetNextRecId() == EXC_ID3_IMGDATA
) && rStrm
.StartNextRecord() )
948 sal_uInt32 nDataSize
;
950 nDataSize
= rStrm
.ReaduInt32();
951 nDataSize
-= rStrm
.GetRecLeft();
952 // skip following CONTINUE records until IMGDATA ends
953 while( (nDataSize
> 0) && (rStrm
.GetNextRecId() == EXC_ID_CONT
) && rStrm
.StartNextRecord() )
955 OSL_ENSURE( nDataSize
>= rStrm
.GetRecLeft(), "XclImpDrawObjBase::ImplReadObj8 - CONTINUE too long" );
956 nDataSize
-= ::std::min
< sal_uInt32
>( rStrm
.GetRecLeft(), nDataSize
);
958 OSL_ENSURE( nDataSize
== 0, "XclImpDrawObjBase::ImplReadObj8 - missing CONTINUE records" );
959 // next record may be MSODRAWING or CONTINUE or anything else
963 void XclImpDrawObjVector::InsertGrouped( XclImpDrawObjRef xDrawObj
)
966 if( XclImpGroupObj
* pGroupObj
= dynamic_cast< XclImpGroupObj
* >( mObjs
.back().get() ) )
967 if( pGroupObj
->TryInsert( xDrawObj
) )
969 mObjs
.push_back( xDrawObj
);
972 sal_Size
XclImpDrawObjVector::GetProgressSize() const
974 sal_Size nProgressSize
= 0;
975 for( ::std::vector
< XclImpDrawObjRef
>::const_iterator aIt
= mObjs
.begin(), aEnd
= mObjs
.end(); aIt
!= aEnd
; ++aIt
)
976 nProgressSize
+= (*aIt
)->GetProgressSize();
977 return nProgressSize
;
980 XclImpPhObj::XclImpPhObj( const XclImpRoot
& rRoot
) :
981 XclImpDrawObjBase( rRoot
)
983 SetProcessSdrObj( false );
986 XclImpGroupObj::XclImpGroupObj( const XclImpRoot
& rRoot
) :
987 XclImpDrawObjBase( rRoot
),
988 mnFirstUngrouped( 0 )
992 bool XclImpGroupObj::TryInsert( XclImpDrawObjRef xDrawObj
)
994 if( xDrawObj
->GetObjId() == mnFirstUngrouped
)
996 // insert into own list or into nested group
997 maChildren
.InsertGrouped( xDrawObj
);
1001 void XclImpGroupObj::DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1004 mnFirstUngrouped
= rStrm
.ReaduInt16();
1006 ReadMacro3( rStrm
, nMacroSize
);
1009 void XclImpGroupObj::DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1012 mnFirstUngrouped
= rStrm
.ReaduInt16();
1014 ReadMacro4( rStrm
, nMacroSize
);
1017 void XclImpGroupObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
)
1020 mnFirstUngrouped
= rStrm
.ReaduInt16();
1022 ReadName5( rStrm
, nNameLen
);
1023 ReadMacro5( rStrm
, nMacroSize
);
1026 sal_Size
XclImpGroupObj::DoGetProgressSize() const
1028 return XclImpDrawObjBase::DoGetProgressSize() + maChildren
.GetProgressSize();
1031 SdrObject
* XclImpGroupObj::DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const Rectangle
& /*rAnchorRect*/ ) const
1033 std::unique_ptr
<SdrObjGroup
, SdrObjectFree
> xSdrObj( new SdrObjGroup
);
1034 // child objects in BIFF2-BIFF5 have absolute size, not needed to pass own anchor rectangle
1035 SdrObjList
& rObjList
= *xSdrObj
->GetSubList(); // SdrObjGroup always returns existing sublist
1036 for( ::std::vector
< XclImpDrawObjRef
>::const_iterator aIt
= maChildren
.begin(), aEnd
= maChildren
.end(); aIt
!= aEnd
; ++aIt
)
1037 rDffConv
.ProcessObject( rObjList
, **aIt
);
1038 rDffConv
.Progress();
1039 return xSdrObj
.release();
1042 XclImpLineObj::XclImpLineObj( const XclImpRoot
& rRoot
) :
1043 XclImpDrawObjBase( rRoot
),
1045 mnStartPoint( EXC_OBJ_LINE_TL
)
1047 SetAreaObj( false );
1050 void XclImpLineObj::DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1052 rStrm
>> maLineData
;
1053 mnArrows
= rStrm
.ReaduInt16();
1054 mnStartPoint
= rStrm
.ReaduInt8();
1056 ReadMacro3( rStrm
, nMacroSize
);
1059 void XclImpLineObj::DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1061 rStrm
>> maLineData
;
1062 mnArrows
= rStrm
.ReaduInt16();
1063 mnStartPoint
= rStrm
.ReaduInt8();
1065 ReadMacro4( rStrm
, nMacroSize
);
1068 void XclImpLineObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
)
1070 rStrm
>> maLineData
;
1071 mnArrows
= rStrm
.ReaduInt16();
1072 mnStartPoint
= rStrm
.ReaduInt8();
1074 ReadName5( rStrm
, nNameLen
);
1075 ReadMacro5( rStrm
, nMacroSize
);
1078 SdrObject
* XclImpLineObj::DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const Rectangle
& rAnchorRect
) const
1080 ::basegfx::B2DPolygon aB2DPolygon
;
1081 switch( mnStartPoint
)
1084 case EXC_OBJ_LINE_TL
:
1085 aB2DPolygon
.append( ::basegfx::B2DPoint( rAnchorRect
.Left(), rAnchorRect
.Top() ) );
1086 aB2DPolygon
.append( ::basegfx::B2DPoint( rAnchorRect
.Right(), rAnchorRect
.Bottom() ) );
1088 case EXC_OBJ_LINE_TR
:
1089 aB2DPolygon
.append( ::basegfx::B2DPoint( rAnchorRect
.Right(), rAnchorRect
.Top() ) );
1090 aB2DPolygon
.append( ::basegfx::B2DPoint( rAnchorRect
.Left(), rAnchorRect
.Bottom() ) );
1092 case EXC_OBJ_LINE_BR
:
1093 aB2DPolygon
.append( ::basegfx::B2DPoint( rAnchorRect
.Right(), rAnchorRect
.Bottom() ) );
1094 aB2DPolygon
.append( ::basegfx::B2DPoint( rAnchorRect
.Left(), rAnchorRect
.Top() ) );
1096 case EXC_OBJ_LINE_BL
:
1097 aB2DPolygon
.append( ::basegfx::B2DPoint( rAnchorRect
.Left(), rAnchorRect
.Bottom() ) );
1098 aB2DPolygon
.append( ::basegfx::B2DPoint( rAnchorRect
.Right(), rAnchorRect
.Top() ) );
1101 SdrObjectPtr
xSdrObj( new SdrPathObj( OBJ_LINE
, ::basegfx::B2DPolyPolygon( aB2DPolygon
) ) );
1102 ConvertLineStyle( *xSdrObj
, maLineData
);
1105 sal_uInt8 nArrowType
= ::extract_value
< sal_uInt8
>( mnArrows
, 0, 4 );
1106 bool bLineStart
= false;
1107 bool bLineEnd
= false;
1108 bool bFilled
= false;
1109 switch( nArrowType
)
1111 case EXC_OBJ_ARROW_OPEN
: bLineStart
= false; bLineEnd
= true; bFilled
= false; break;
1112 case EXC_OBJ_ARROW_OPENBOTH
: bLineStart
= true; bLineEnd
= true; bFilled
= false; break;
1113 case EXC_OBJ_ARROW_FILLED
: bLineStart
= false; bLineEnd
= true; bFilled
= true; break;
1114 case EXC_OBJ_ARROW_FILLEDBOTH
: bLineStart
= true; bLineEnd
= true; bFilled
= true; break;
1116 if( bLineStart
|| bLineEnd
)
1118 sal_uInt8 nArrowWidth
= ::extract_value
< sal_uInt8
>( mnArrows
, 4, 4 );
1119 double fArrowWidth
= 3.0;
1120 switch( nArrowWidth
)
1122 case EXC_OBJ_ARROW_NARROW
: fArrowWidth
= 2.0; break;
1123 case EXC_OBJ_ARROW_MEDIUM
: fArrowWidth
= 3.0; break;
1124 case EXC_OBJ_ARROW_WIDE
: fArrowWidth
= 5.0; break;
1127 sal_uInt8 nArrowLength
= ::extract_value
< sal_uInt8
>( mnArrows
, 8, 4 );
1128 double fArrowLength
= 3.0;
1129 switch( nArrowLength
)
1131 case EXC_OBJ_ARROW_NARROW
: fArrowLength
= 2.5; break;
1132 case EXC_OBJ_ARROW_MEDIUM
: fArrowLength
= 3.5; break;
1133 case EXC_OBJ_ARROW_WIDE
: fArrowLength
= 6.0; break;
1136 ::basegfx::B2DPolygon aArrowPoly
;
1137 #define EXC_ARROW_POINT( x, y ) ::basegfx::B2DPoint( fArrowWidth * (x), fArrowLength * (y) )
1140 aArrowPoly
.append( EXC_ARROW_POINT( 0, 100 ) );
1141 aArrowPoly
.append( EXC_ARROW_POINT( 50, 0 ) );
1142 aArrowPoly
.append( EXC_ARROW_POINT( 100, 100 ) );
1146 sal_uInt8 nLineWidth
= ::limit_cast
< sal_uInt8
>( maLineData
.mnWidth
, EXC_OBJ_LINE_THIN
, EXC_OBJ_LINE_THICK
);
1147 aArrowPoly
.append( EXC_ARROW_POINT( 50, 0 ) );
1148 aArrowPoly
.append( EXC_ARROW_POINT( 100, 100 - 3 * nLineWidth
) );
1149 aArrowPoly
.append( EXC_ARROW_POINT( 100 - 5 * nLineWidth
, 100 ) );
1150 aArrowPoly
.append( EXC_ARROW_POINT( 50, 12 * nLineWidth
) );
1151 aArrowPoly
.append( EXC_ARROW_POINT( 5 * nLineWidth
, 100 ) );
1152 aArrowPoly
.append( EXC_ARROW_POINT( 0, 100 - 3 * nLineWidth
) );
1154 #undef EXC_ARROW_POINT
1156 ::basegfx::B2DPolyPolygon
aArrowPolyPoly( aArrowPoly
);
1157 long nWidth
= static_cast< long >( 125 * fArrowWidth
);
1160 xSdrObj
->SetMergedItem( XLineStartItem( EMPTY_OUSTRING
, aArrowPolyPoly
) );
1161 xSdrObj
->SetMergedItem( XLineStartWidthItem( nWidth
) );
1162 xSdrObj
->SetMergedItem( XLineStartCenterItem( false ) );
1166 xSdrObj
->SetMergedItem( XLineEndItem( EMPTY_OUSTRING
, aArrowPolyPoly
) );
1167 xSdrObj
->SetMergedItem( XLineEndWidthItem( nWidth
) );
1168 xSdrObj
->SetMergedItem( XLineEndCenterItem( false ) );
1171 rDffConv
.Progress();
1172 return xSdrObj
.release();
1175 XclImpRectObj::XclImpRectObj( const XclImpRoot
& rRoot
) :
1176 XclImpDrawObjBase( rRoot
),
1182 void XclImpRectObj::ReadFrameData( XclImpStream
& rStrm
)
1184 rStrm
>> maFillData
>> maLineData
;
1185 mnFrameFlags
= rStrm
.ReaduInt16();
1188 void XclImpRectObj::ConvertRectStyle( SdrObject
& rSdrObj
) const
1190 ConvertLineStyle( rSdrObj
, maLineData
);
1191 ConvertFillStyle( rSdrObj
, maFillData
);
1192 ConvertFrameStyle( rSdrObj
, mnFrameFlags
);
1195 void XclImpRectObj::DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1197 ReadFrameData( rStrm
);
1198 ReadMacro3( rStrm
, nMacroSize
);
1201 void XclImpRectObj::DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1203 ReadFrameData( rStrm
);
1204 ReadMacro4( rStrm
, nMacroSize
);
1207 void XclImpRectObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
)
1209 ReadFrameData( rStrm
);
1210 ReadName5( rStrm
, nNameLen
);
1211 ReadMacro5( rStrm
, nMacroSize
);
1214 SdrObject
* XclImpRectObj::DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const Rectangle
& rAnchorRect
) const
1216 SdrObjectPtr
xSdrObj( new SdrRectObj( rAnchorRect
) );
1217 ConvertRectStyle( *xSdrObj
);
1218 rDffConv
.Progress();
1219 return xSdrObj
.release();
1222 XclImpOvalObj::XclImpOvalObj( const XclImpRoot
& rRoot
) :
1223 XclImpRectObj( rRoot
)
1227 SdrObject
* XclImpOvalObj::DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const Rectangle
& rAnchorRect
) const
1229 SdrObjectPtr
xSdrObj( new SdrCircObj( OBJ_CIRC
, rAnchorRect
) );
1230 ConvertRectStyle( *xSdrObj
);
1231 rDffConv
.Progress();
1232 return xSdrObj
.release();
1235 XclImpArcObj::XclImpArcObj( const XclImpRoot
& rRoot
) :
1236 XclImpDrawObjBase( rRoot
),
1237 mnQuadrant( EXC_OBJ_ARC_TR
)
1239 SetAreaObj( false ); // arc may be 2-dimensional
1242 void XclImpArcObj::DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1244 rStrm
>> maFillData
>> maLineData
;
1245 mnQuadrant
= rStrm
.ReaduInt8();
1247 ReadMacro3( rStrm
, nMacroSize
);
1250 void XclImpArcObj::DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1252 rStrm
>> maFillData
>> maLineData
;
1253 mnQuadrant
= rStrm
.ReaduInt8();
1255 ReadMacro4( rStrm
, nMacroSize
);
1258 void XclImpArcObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
)
1260 rStrm
>> maFillData
>> maLineData
;
1261 mnQuadrant
= rStrm
.ReaduInt8();
1263 ReadName5( rStrm
, nNameLen
);
1264 ReadMacro5( rStrm
, nMacroSize
);
1267 SdrObject
* XclImpArcObj::DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const Rectangle
& rAnchorRect
) const
1269 Rectangle aNewRect
= rAnchorRect
;
1270 long nStartAngle
= 0;
1272 switch( mnQuadrant
)
1275 case EXC_OBJ_ARC_TR
:
1278 aNewRect
.Left() -= rAnchorRect
.GetWidth();
1279 aNewRect
.Bottom() += rAnchorRect
.GetHeight();
1281 case EXC_OBJ_ARC_TL
:
1284 aNewRect
.Right() += rAnchorRect
.GetWidth();
1285 aNewRect
.Bottom() += rAnchorRect
.GetHeight();
1287 case EXC_OBJ_ARC_BL
:
1288 nStartAngle
= 18000;
1290 aNewRect
.Right() += rAnchorRect
.GetWidth();
1291 aNewRect
.Top() -= rAnchorRect
.GetHeight();
1293 case EXC_OBJ_ARC_BR
:
1294 nStartAngle
= 27000;
1296 aNewRect
.Left() -= rAnchorRect
.GetWidth();
1297 aNewRect
.Top() -= rAnchorRect
.GetHeight();
1300 SdrObjKind eObjKind
= maFillData
.IsFilled() ? OBJ_SECT
: OBJ_CARC
;
1301 SdrObjectPtr
xSdrObj( new SdrCircObj( eObjKind
, aNewRect
, nStartAngle
, nEndAngle
) );
1302 ConvertFillStyle( *xSdrObj
, maFillData
);
1303 ConvertLineStyle( *xSdrObj
, maLineData
);
1304 rDffConv
.Progress();
1305 return xSdrObj
.release();
1308 XclImpPolygonObj::XclImpPolygonObj( const XclImpRoot
& rRoot
) :
1309 XclImpRectObj( rRoot
),
1313 SetAreaObj( false ); // polygon may be 2-dimensional
1316 void XclImpPolygonObj::ReadCoordList( XclImpStream
& rStrm
)
1318 if( (rStrm
.GetNextRecId() == EXC_ID_COORDLIST
) && rStrm
.StartNextRecord() )
1320 OSL_ENSURE( rStrm
.GetRecLeft() / 4 == mnPointCount
, "XclImpPolygonObj::ReadCoordList - wrong polygon point count" );
1321 while( rStrm
.GetRecLeft() >= 4 )
1324 nX
= rStrm
.ReaduInt16();
1325 nY
= rStrm
.ReaduInt16();
1326 maCoords
.push_back( Point( nX
, nY
) );
1331 void XclImpPolygonObj::DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1333 ReadFrameData( rStrm
);
1334 mnPolyFlags
= rStrm
.ReaduInt16();
1336 mnPointCount
= rStrm
.ReaduInt16();
1338 ReadMacro4( rStrm
, nMacroSize
);
1339 ReadCoordList( rStrm
);
1342 void XclImpPolygonObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
)
1344 ReadFrameData( rStrm
);
1345 mnPolyFlags
= rStrm
.ReaduInt16();
1347 mnPointCount
= rStrm
.ReaduInt16();
1349 ReadName5( rStrm
, nNameLen
);
1350 ReadMacro5( rStrm
, nMacroSize
);
1351 ReadCoordList( rStrm
);
1356 ::basegfx::B2DPoint
lclGetPolyPoint( const Rectangle
& rAnchorRect
, const Point
& rPoint
)
1358 return ::basegfx::B2DPoint(
1359 rAnchorRect
.Left() + static_cast< sal_Int32
>( ::std::min
< double >( rPoint
.X(), 16384.0 ) / 16384.0 * rAnchorRect
.GetWidth() + 0.5 ),
1360 rAnchorRect
.Top() + static_cast< sal_Int32
>( ::std::min
< double >( rPoint
.Y(), 16384.0 ) / 16384.0 * rAnchorRect
.GetHeight() + 0.5 ) );
1365 SdrObject
* XclImpPolygonObj::DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const Rectangle
& rAnchorRect
) const
1367 SdrObjectPtr xSdrObj
;
1368 if( maCoords
.size() >= 2 )
1370 // create the polygon
1371 ::basegfx::B2DPolygon aB2DPolygon
;
1372 for( PointVector::const_iterator aIt
= maCoords
.begin(), aEnd
= maCoords
.end(); aIt
!= aEnd
; ++aIt
)
1373 aB2DPolygon
.append( lclGetPolyPoint( rAnchorRect
, *aIt
) );
1374 // close polygon if specified
1375 if( ::get_flag( mnPolyFlags
, EXC_OBJ_POLY_CLOSED
) && (maCoords
.front() != maCoords
.back()) )
1376 aB2DPolygon
.append( lclGetPolyPoint( rAnchorRect
, maCoords
.front() ) );
1377 // create the SdrObject
1378 SdrObjKind eObjKind
= maFillData
.IsFilled() ? OBJ_PATHPOLY
: OBJ_PATHPLIN
;
1379 xSdrObj
.reset( new SdrPathObj( eObjKind
, ::basegfx::B2DPolyPolygon( aB2DPolygon
) ) );
1380 ConvertRectStyle( *xSdrObj
);
1382 rDffConv
.Progress();
1383 return xSdrObj
.release();
1386 void XclImpObjTextData::ReadByteString( XclImpStream
& rStrm
)
1389 if( maData
.mnTextLen
> 0 )
1391 mxString
.reset( new XclImpString( rStrm
.ReadRawByteString( maData
.mnTextLen
) ) );
1392 // skip padding byte for word boundaries
1393 if( rStrm
.GetRecPos() & 1 ) rStrm
.Ignore( 1 );
1397 void XclImpObjTextData::ReadFormats( XclImpStream
& rStrm
)
1400 mxString
->ReadObjFormats( rStrm
, maData
.mnFormatSize
);
1402 rStrm
.Ignore( maData
.mnFormatSize
);
1405 XclImpTextObj::XclImpTextObj( const XclImpRoot
& rRoot
) :
1406 XclImpRectObj( rRoot
)
1410 void XclImpTextObj::DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1412 ReadFrameData( rStrm
);
1413 maTextData
.maData
.ReadObj3( rStrm
);
1414 ReadMacro3( rStrm
, nMacroSize
);
1415 maTextData
.ReadByteString( rStrm
);
1416 maTextData
.ReadFormats( rStrm
);
1419 void XclImpTextObj::DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1421 ReadFrameData( rStrm
);
1422 maTextData
.maData
.ReadObj3( rStrm
);
1423 ReadMacro4( rStrm
, nMacroSize
);
1424 maTextData
.ReadByteString( rStrm
);
1425 maTextData
.ReadFormats( rStrm
);
1428 void XclImpTextObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
)
1430 ReadFrameData( rStrm
);
1431 maTextData
.maData
.ReadObj5( rStrm
);
1432 ReadName5( rStrm
, nNameLen
);
1433 ReadMacro5( rStrm
, nMacroSize
);
1434 maTextData
.ReadByteString( rStrm
);
1435 rStrm
.Ignore( maTextData
.maData
.mnLinkSize
); // ignore text link formula
1436 maTextData
.ReadFormats( rStrm
);
1439 SdrObject
* XclImpTextObj::DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const Rectangle
& rAnchorRect
) const
1441 std::unique_ptr
<SdrObjCustomShape
, SdrObjectFree
> xSdrObj( new SdrObjCustomShape
);
1442 xSdrObj
->NbcSetSnapRect( rAnchorRect
);
1443 OUString aRectType
= "rectangle";
1444 xSdrObj
->MergeDefaultAttributes( &aRectType
);
1445 ConvertRectStyle( *xSdrObj
);
1446 bool bAutoSize
= ::get_flag( maTextData
.maData
.mnFlags
, EXC_OBJ_TEXT_AUTOSIZE
);
1447 xSdrObj
->SetMergedItem( makeSdrTextAutoGrowWidthItem( bAutoSize
) );
1448 xSdrObj
->SetMergedItem( makeSdrTextAutoGrowHeightItem( bAutoSize
) );
1449 xSdrObj
->SetMergedItem( makeSdrTextWordWrapItem( true ) );
1450 rDffConv
.Progress();
1451 return xSdrObj
.release();
1454 void XclImpTextObj::DoPreProcessSdrObj( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const
1457 if( SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( &rSdrObj
) )
1459 if( maTextData
.mxString
)
1461 if( maTextData
.mxString
->IsRich() )
1464 boost::scoped_ptr
< EditTextObject
> xEditObj(
1465 XclImpStringHelper::CreateTextObject( GetRoot(), *maTextData
.mxString
) );
1466 OutlinerParaObject
* pOutlineObj
= new OutlinerParaObject( *xEditObj
);
1467 pOutlineObj
->SetOutlinerMode( OUTLINERMODE_TEXTOBJECT
);
1468 // text object takes ownership of the outliner object
1469 pTextObj
->NbcSetOutlinerParaObject( pOutlineObj
);
1474 pTextObj
->NbcSetText( maTextData
.mxString
->GetText() );
1477 /* #i96858# Do not apply any formatting if there is no text.
1478 SdrObjCustomShape::SetVerticalWriting (initiated from
1479 SetMergedItem) calls SdrTextObj::ForceOutlinerParaObject which
1480 ensures that we can erroneously write a ClientTextbox record
1481 (with no content) while exporting to XLS, which can cause a
1482 corrupted exported document. */
1484 SvxAdjust eHorAlign
= SVX_ADJUST_LEFT
;
1485 SdrTextVertAdjust eVerAlign
= SDRTEXTVERTADJUST_TOP
;
1487 // orientation (this is only a fake, drawing does not support real text orientation)
1488 namespace csst
= ::com::sun::star::text
;
1489 csst::WritingMode eWriteMode
= csst::WritingMode_LR_TB
;
1490 switch( maTextData
.maData
.mnOrient
)
1493 case EXC_OBJ_ORIENT_NONE
:
1495 eWriteMode
= csst::WritingMode_LR_TB
;
1496 switch( maTextData
.maData
.GetHorAlign() )
1498 case EXC_OBJ_HOR_LEFT
: eHorAlign
= SVX_ADJUST_LEFT
; break;
1499 case EXC_OBJ_HOR_CENTER
: eHorAlign
= SVX_ADJUST_CENTER
; break;
1500 case EXC_OBJ_HOR_RIGHT
: eHorAlign
= SVX_ADJUST_RIGHT
; break;
1501 case EXC_OBJ_HOR_JUSTIFY
: eHorAlign
= SVX_ADJUST_BLOCK
; break;
1503 switch( maTextData
.maData
.GetVerAlign() )
1505 case EXC_OBJ_VER_TOP
: eVerAlign
= SDRTEXTVERTADJUST_TOP
; break;
1506 case EXC_OBJ_VER_CENTER
: eVerAlign
= SDRTEXTVERTADJUST_CENTER
; break;
1507 case EXC_OBJ_VER_BOTTOM
: eVerAlign
= SDRTEXTVERTADJUST_BOTTOM
; break;
1508 case EXC_OBJ_VER_JUSTIFY
: eVerAlign
= SDRTEXTVERTADJUST_BLOCK
; break;
1513 case EXC_OBJ_ORIENT_90CCW
:
1515 if( SdrObjCustomShape
* pObjCustomShape
= dynamic_cast< SdrObjCustomShape
* >( &rSdrObj
) )
1517 double fAngle
= 180.0;
1518 com::sun::star::beans::PropertyValue aTextRotateAngle
;
1519 aTextRotateAngle
.Name
= "TextRotateAngle";
1520 aTextRotateAngle
.Value
<<= fAngle
;
1521 SdrCustomShapeGeometryItem
aGeometryItem(static_cast<const SdrCustomShapeGeometryItem
&>(pObjCustomShape
->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY
)));
1522 aGeometryItem
.SetPropertyValue( aTextRotateAngle
);
1523 pObjCustomShape
->SetMergedItem( aGeometryItem
);
1525 eWriteMode
= csst::WritingMode_TB_RL
;
1526 switch( maTextData
.maData
.GetHorAlign() )
1528 case EXC_OBJ_HOR_LEFT
: eVerAlign
= SDRTEXTVERTADJUST_TOP
; break;
1529 case EXC_OBJ_HOR_CENTER
: eVerAlign
= SDRTEXTVERTADJUST_CENTER
; break;
1530 case EXC_OBJ_HOR_RIGHT
: eVerAlign
= SDRTEXTVERTADJUST_BOTTOM
; break;
1531 case EXC_OBJ_HOR_JUSTIFY
: eVerAlign
= SDRTEXTVERTADJUST_BLOCK
; break;
1533 MSO_Anchor eTextAnchor
= (MSO_Anchor
)rDffConv
.GetPropertyValue( DFF_Prop_anchorText
, mso_anchorTop
);
1534 switch( eTextAnchor
)
1536 case mso_anchorTopCentered
:
1537 case mso_anchorMiddleCentered
:
1538 case mso_anchorBottomCentered
:
1540 eHorAlign
= SVX_ADJUST_CENTER
;
1546 switch( maTextData
.maData
.GetVerAlign() )
1548 case EXC_OBJ_VER_TOP
: eHorAlign
= SVX_ADJUST_RIGHT
; break;
1549 case EXC_OBJ_VER_CENTER
: eHorAlign
= SVX_ADJUST_CENTER
; break;
1550 case EXC_OBJ_VER_BOTTOM
: eHorAlign
= SVX_ADJUST_LEFT
; break;
1551 case EXC_OBJ_VER_JUSTIFY
: eHorAlign
= SVX_ADJUST_BLOCK
; break;
1558 case EXC_OBJ_ORIENT_STACKED
: // PASSTHROUGH INTENDED
1560 // sj: STACKED is not supported, maybe it can be optimized here a bit
1562 case EXC_OBJ_ORIENT_90CW
:
1564 eWriteMode
= csst::WritingMode_TB_RL
;
1565 switch( maTextData
.maData
.GetHorAlign() )
1567 case EXC_OBJ_HOR_LEFT
: eVerAlign
= SDRTEXTVERTADJUST_BOTTOM
; break;
1568 case EXC_OBJ_HOR_CENTER
: eVerAlign
= SDRTEXTVERTADJUST_CENTER
; break;
1569 case EXC_OBJ_HOR_RIGHT
: eVerAlign
= SDRTEXTVERTADJUST_TOP
; break;
1570 case EXC_OBJ_HOR_JUSTIFY
: eVerAlign
= SDRTEXTVERTADJUST_BLOCK
; break;
1572 MSO_Anchor eTextAnchor
= (MSO_Anchor
)rDffConv
.GetPropertyValue( DFF_Prop_anchorText
, mso_anchorTop
);
1573 switch ( eTextAnchor
)
1575 case mso_anchorTopCentered
:
1576 case mso_anchorMiddleCentered
:
1577 case mso_anchorBottomCentered
:
1579 eHorAlign
= SVX_ADJUST_CENTER
;
1585 switch( maTextData
.maData
.GetVerAlign() )
1587 case EXC_OBJ_VER_TOP
: eHorAlign
= SVX_ADJUST_LEFT
; break;
1588 case EXC_OBJ_VER_CENTER
: eHorAlign
= SVX_ADJUST_CENTER
; break;
1589 case EXC_OBJ_VER_BOTTOM
: eHorAlign
= SVX_ADJUST_RIGHT
; break;
1590 case EXC_OBJ_VER_JUSTIFY
: eHorAlign
= SVX_ADJUST_BLOCK
; break;
1597 rSdrObj
.SetMergedItem( SvxAdjustItem( eHorAlign
, EE_PARA_JUST
) );
1598 rSdrObj
.SetMergedItem( SdrTextVertAdjustItem( eVerAlign
) );
1599 rSdrObj
.SetMergedItem( SvxWritingModeItem( eWriteMode
, SDRATTR_TEXTDIRECTION
) );
1602 // base class processing
1603 XclImpRectObj::DoPreProcessSdrObj( rDffConv
, rSdrObj
);
1606 XclImpChartObj::XclImpChartObj( const XclImpRoot
& rRoot
, bool bOwnTab
) :
1607 XclImpRectObj( rRoot
),
1610 SetSimpleMacro( false );
1611 SetCustomDffObj( true );
1614 void XclImpChartObj::ReadChartSubStream( XclImpStream
& rStrm
)
1616 /* If chart is read from a chartsheet (mbOwnTab == true), the BOF record
1617 has already been read. If chart is embedded as object, the next record
1618 has to be the BOF record. */
1621 /* #i109800# The input stream may point somewhere inside the chart
1622 substream and not exactly to the leading BOF record. To read this
1623 record correctly in the following, the stream has to rewind it, so
1624 that the next call to StartNextRecord() will find it correctly. */
1625 if( rStrm
.GetRecId() != EXC_ID5_BOF
)
1626 rStrm
.RewindRecord();
1630 if( (rStrm
.GetNextRecId() == EXC_ID5_BOF
) && rStrm
.StartNextRecord() )
1632 sal_uInt16 nBofType
;
1634 nBofType
= rStrm
.ReaduInt16();
1635 SAL_WARN_IF( nBofType
!= EXC_BOF_CHART
, "sc.filter", "XclImpChartObj::ReadChartSubStream - no chart BOF record" );
1639 SAL_INFO("sc.filter", "XclImpChartObj::ReadChartSubStream - missing chart substream");
1644 // read chart, even if BOF record contains wrong substream identifier
1645 mxChart
.reset( new XclImpChart( GetRoot(), mbOwnTab
) );
1646 mxChart
->ReadChartSubStream( rStrm
);
1651 void XclImpChartObj::DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1653 // read OBJ record and the following chart substream
1654 ReadFrameData( rStrm
);
1656 ReadMacro3( rStrm
, nMacroSize
);
1657 // set frame format from OBJ record, it is used if chart itself is transparent
1659 mxChart
->UpdateObjFrame( maLineData
, maFillData
);
1662 void XclImpChartObj::DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
1664 // read OBJ record and the following chart substream
1665 ReadFrameData( rStrm
);
1667 ReadMacro4( rStrm
, nMacroSize
);
1668 // set frame format from OBJ record, it is used if chart itself is transparent
1670 mxChart
->UpdateObjFrame( maLineData
, maFillData
);
1673 void XclImpChartObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
)
1675 // read OBJ record and the following chart substream
1676 ReadFrameData( rStrm
);
1678 ReadName5( rStrm
, nNameLen
);
1679 ReadMacro5( rStrm
, nMacroSize
);
1680 ReadChartSubStream( rStrm
);
1681 // set frame format from OBJ record, it is used if chart itself is transparent
1683 mxChart
->UpdateObjFrame( maLineData
, maFillData
);
1686 void XclImpChartObj::DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16
/*nSubRecSize*/ )
1688 // read the following chart substream
1689 if( nSubRecId
== EXC_ID_OBJEND
)
1691 // enable CONTINUE handling for the entire chart substream
1692 rStrm
.ResetRecord( true );
1693 ReadChartSubStream( rStrm
);
1694 /* disable CONTINUE handling again to be able to read
1695 following CONTINUE records as MSODRAWING records. */
1696 rStrm
.ResetRecord( false );
1700 sal_Size
XclImpChartObj::DoGetProgressSize() const
1702 return mxChart
? mxChart
->GetProgressSize() : 1;
1705 SdrObject
* XclImpChartObj::DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const Rectangle
& rAnchorRect
) const
1707 SdrObjectPtr xSdrObj
;
1708 SfxObjectShell
* pDocShell
= GetDocShell();
1709 if( rDffConv
.SupportsOleObjects() && SvtModuleOptions().IsChart() && pDocShell
&& mxChart
&& !mxChart
->IsPivotChart() )
1711 // create embedded chart object
1712 OUString aEmbObjName
;
1713 Reference
< XEmbeddedObject
> xEmbObj
= pDocShell
->GetEmbeddedObjectContainer().
1714 CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID
).GetByteSequence(), aEmbObjName
);
1716 /* Set the size to the embedded object, this prevents that font sizes
1717 of text objects are changed in the chart when the object is
1718 inserted into the draw page. */
1719 sal_Int64 nAspect
= ::com::sun::star::embed::Aspects::MSOLE_CONTENT
;
1720 MapUnit aUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xEmbObj
->getMapUnit( nAspect
) );
1721 Size
aSize( vcl::Window::LogicToLogic( rAnchorRect
.GetSize(), MapMode( MAP_100TH_MM
), MapMode( aUnit
) ) );
1722 ::com::sun::star::awt::Size
aAwtSize( aSize
.Width(), aSize
.Height() );
1723 xEmbObj
->setVisualAreaSize( nAspect
, aAwtSize
);
1725 // #i121334# This call will change the chart's default background fill from white to transparent.
1726 // Add here again if this is wanted (see task description for details)
1727 // ChartHelper::AdaptDefaultsForChart( xEmbObj );
1729 // create the container OLE object
1730 xSdrObj
.reset( new SdrOle2Obj( svt::EmbeddedObjectRef( xEmbObj
, nAspect
), aEmbObjName
, rAnchorRect
) );
1733 return xSdrObj
.release();
1736 void XclImpChartObj::DoPostProcessSdrObj( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const
1738 const SdrOle2Obj
* pSdrOleObj
= dynamic_cast< const SdrOle2Obj
* >( &rSdrObj
);
1739 if( mxChart
&& pSdrOleObj
)
1741 Reference
< XEmbeddedObject
> xEmbObj
= pSdrOleObj
->GetObjRef();
1742 if( xEmbObj
.is() && ::svt::EmbeddedObjectRef::TryRunningState( xEmbObj
) ) try
1744 Reference
< XEmbedPersist
> xPersist( xEmbObj
, UNO_QUERY_THROW
);
1745 Reference
< XModel
> xModel( xEmbObj
->getComponent(), UNO_QUERY_THROW
);
1746 mxChart
->Convert( xModel
, rDffConv
, xPersist
->getEntryName(), rSdrObj
.GetLogicRect() );
1748 catch( const Exception
& )
1754 void XclImpChartObj::FinalizeTabChart()
1756 /* #i44077# Calculate and store DFF anchor for sheet charts.
1757 Needed to get used area if this chart is inserted as OLE object. */
1758 OSL_ENSURE( mbOwnTab
, "XclImpChartObj::FinalizeTabChart - not allowed for embedded chart objects" );
1760 // set uninitialized page to landscape
1761 if( !GetPageSettings().GetPageData().mbValid
)
1762 GetPageSettings().SetPaperSize( EXC_PAPERSIZE_DEFAULT
, false );
1764 // calculate size of the chart object
1765 const XclPageData
& rPageData
= GetPageSettings().GetPageData();
1766 Size aPaperSize
= rPageData
.GetScPaperSize();
1768 long nWidth
= XclTools::GetHmmFromTwips( aPaperSize
.Width() );
1769 long nHeight
= XclTools::GetHmmFromTwips( aPaperSize
.Height() );
1771 // subtract page margins, give some more extra space
1772 nWidth
-= (XclTools::GetHmmFromInch( rPageData
.mfLeftMargin
+ rPageData
.mfRightMargin
) + 2000);
1773 nHeight
-= (XclTools::GetHmmFromInch( rPageData
.mfTopMargin
+ rPageData
.mfBottomMargin
) + 1000);
1775 // print column/row headers?
1776 if( rPageData
.mbPrintHeadings
)
1782 // create the object anchor
1783 XclObjAnchor aAnchor
;
1784 aAnchor
.SetRect( GetRoot(), GetCurrScTab(), Rectangle( 1000, 500, nWidth
, nHeight
), MAP_100TH_MM
);
1785 SetAnchor( aAnchor
);
1788 XclImpNoteObj::XclImpNoteObj( const XclImpRoot
& rRoot
) :
1789 XclImpTextObj( rRoot
),
1790 maScPos( ScAddress::INITIALIZE_INVALID
),
1793 SetSimpleMacro( false );
1794 // caption object will be created manually
1795 SetInsertSdrObj( false );
1798 void XclImpNoteObj::SetNoteData( const ScAddress
& rScPos
, sal_uInt16 nNoteFlags
)
1801 mnNoteFlags
= nNoteFlags
;
1804 void XclImpNoteObj::DoPreProcessSdrObj( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const
1806 // create formatted text
1807 XclImpTextObj::DoPreProcessSdrObj( rDffConv
, rSdrObj
);
1808 OutlinerParaObject
* pOutlinerObj
= rSdrObj
.GetOutlinerParaObject();
1809 if( maScPos
.IsValid() && pOutlinerObj
)
1811 // create cell note with all data from drawing object
1812 ScNoteUtil::CreateNoteFromObjectData(
1814 rSdrObj
.GetMergedItemSet().Clone(), // new object on heap expected
1815 new OutlinerParaObject( *pOutlinerObj
), // new object on heap expected
1816 rSdrObj
.GetLogicRect(),
1817 ::get_flag( mnNoteFlags
, EXC_NOTE_VISIBLE
),
1822 XclImpControlHelper::XclImpControlHelper( const XclImpRoot
& rRoot
, XclCtrlBindMode eBindMode
) :
1824 meBindMode( eBindMode
)
1828 XclImpControlHelper::~XclImpControlHelper()
1832 SdrObject
* XclImpControlHelper::CreateSdrObjectFromShape(
1833 const Reference
< XShape
>& rxShape
, const Rectangle
& rAnchorRect
) const
1836 SdrObjectPtr
xSdrObj( SdrObject::getSdrObjectFromXShape( rxShape
) );
1839 xSdrObj
->NbcSetSnapRect( rAnchorRect
);
1840 // #i30543# insert into control layer
1841 xSdrObj
->NbcSetLayer( SC_LAYER_CONTROLS
);
1843 return xSdrObj
.release();
1846 void XclImpControlHelper::ApplySheetLinkProps() const
1849 Reference
< XControlModel
> xCtrlModel
= XclControlHelper::GetControlModel( mxShape
);
1850 if( !xCtrlModel
.is() )
1852 ScfPropertySet
aPropSet( xCtrlModel
);
1855 if( SfxObjectShell
* pDocShell
= mrRoot
.GetDocShell() )
1857 Reference
< XMultiServiceFactory
> xFactory( pDocShell
->GetModel(), UNO_QUERY
);
1861 if( mxCellLink
) try
1863 Reference
< XBindableValue
> xBindable( xCtrlModel
, UNO_QUERY_THROW
);
1865 // create argument sequence for createInstanceWithArguments()
1866 CellAddress aApiAddress
;
1867 ScUnoConversion::FillApiAddress( aApiAddress
, *mxCellLink
);
1870 aValue
.Name
= SC_UNONAME_BOUNDCELL
;
1871 aValue
.Value
<<= aApiAddress
;
1873 Sequence
< Any
> aArgs( 1 );
1874 aArgs
[ 0 ] <<= aValue
;
1876 // create the CellValueBinding instance and set at the control model
1877 OUString aServiceName
;
1878 switch( meBindMode
)
1880 case EXC_CTRL_BINDCONTENT
: aServiceName
= SC_SERVICENAME_VALBIND
; break;
1881 case EXC_CTRL_BINDPOSITION
: aServiceName
= SC_SERVICENAME_LISTCELLBIND
; break;
1883 Reference
< XValueBinding
> xBinding(
1884 xFactory
->createInstanceWithArguments( aServiceName
, aArgs
), UNO_QUERY_THROW
);
1885 xBindable
->setValueBinding( xBinding
);
1887 catch( const Exception
& )
1892 if( mxSrcRange
) try
1894 Reference
< XListEntrySink
> xEntrySink( xCtrlModel
, UNO_QUERY_THROW
);
1896 // create argument sequence for createInstanceWithArguments()
1897 CellRangeAddress aApiRange
;
1898 ScUnoConversion::FillApiRange( aApiRange
, *mxSrcRange
);
1901 aValue
.Name
= SC_UNONAME_CELLRANGE
;
1902 aValue
.Value
<<= aApiRange
;
1904 Sequence
< Any
> aArgs( 1 );
1905 aArgs
[ 0 ] <<= aValue
;
1907 // create the EntrySource instance and set at the control model
1908 Reference
< XListEntrySource
> xEntrySource( xFactory
->createInstanceWithArguments(
1909 SC_SERVICENAME_LISTSOURCE
, aArgs
), UNO_QUERY_THROW
);
1910 xEntrySink
->setListEntrySource( xEntrySource
);
1912 catch( const Exception
& )
1919 void XclImpControlHelper::ProcessControl( const XclImpDrawObjBase
& rDrawObj
) const
1921 Reference
< XControlModel
> xCtrlModel
= XclControlHelper::GetControlModel( mxShape
);
1922 if( !xCtrlModel
.is() )
1925 ApplySheetLinkProps();
1927 ScfPropertySet
aPropSet( xCtrlModel
);
1929 // #i51348# set object name at control model
1930 aPropSet
.SetStringProperty( "Name", rDrawObj
.GetObjName() );
1932 // control visible and printable?
1933 aPropSet
.SetBoolProperty( "EnableVisible", rDrawObj
.IsVisible() );
1934 aPropSet
.SetBoolProperty( "Printable", rDrawObj
.IsPrintable() );
1936 // virtual call for type specific processing
1937 DoProcessControl( aPropSet
);
1940 void XclImpControlHelper::ReadCellLinkFormula( XclImpStream
& rStrm
, bool bWithBoundSize
)
1942 ScRangeList aScRanges
;
1943 ReadRangeList( aScRanges
, rStrm
, bWithBoundSize
);
1944 // Use first cell of first range
1945 if ( !aScRanges
.empty() )
1947 const ScRange
* pScRange
= aScRanges
.front();
1948 mxCellLink
.reset( new ScAddress( pScRange
->aStart
) );
1952 void XclImpControlHelper::ReadSourceRangeFormula( XclImpStream
& rStrm
, bool bWithBoundSize
)
1954 ScRangeList aScRanges
;
1955 ReadRangeList( aScRanges
, rStrm
, bWithBoundSize
);
1957 if ( !aScRanges
.empty() )
1959 const ScRange
* pScRange
= aScRanges
.front();
1960 mxSrcRange
.reset( new ScRange( *pScRange
) );
1964 void XclImpControlHelper::DoProcessControl( ScfPropertySet
& ) const
1968 void XclImpControlHelper::ReadRangeList( ScRangeList
& rScRanges
, XclImpStream
& rStrm
)
1970 XclTokenArray aXclTokArr
;
1971 aXclTokArr
.ReadSize( rStrm
);
1973 aXclTokArr
.ReadArray( rStrm
);
1974 mrRoot
.GetFormulaCompiler().CreateRangeList( rScRanges
, EXC_FMLATYPE_CONTROL
, aXclTokArr
, rStrm
);
1977 void XclImpControlHelper::ReadRangeList( ScRangeList
& rScRanges
, XclImpStream
& rStrm
, bool bWithBoundSize
)
1979 if( bWithBoundSize
)
1982 nSize
= rStrm
.ReaduInt16();
1985 rStrm
.PushPosition();
1986 ReadRangeList( rScRanges
, rStrm
);
1987 rStrm
.PopPosition();
1988 rStrm
.Ignore( nSize
);
1993 ReadRangeList( rScRanges
, rStrm
);
1997 XclImpTbxObjBase::XclImpTbxObjBase( const XclImpRoot
& rRoot
) :
1998 XclImpTextObj( rRoot
),
1999 XclImpControlHelper( rRoot
, EXC_CTRL_BINDPOSITION
)
2001 SetSimpleMacro( false );
2002 SetCustomDffObj( true );
2007 void lclExtractColor( sal_uInt8
& rnColorIdx
, const DffPropSet
& rDffPropSet
, sal_uInt32 nPropId
)
2009 if( rDffPropSet
.IsProperty( nPropId
) )
2011 sal_uInt32 nColor
= rDffPropSet
.GetPropertyValue( nPropId
);
2012 if( (nColor
& 0xFF000000) == 0x08000000 )
2013 rnColorIdx
= ::extract_value
< sal_uInt8
>( nColor
, 0, 8 );
2019 void XclImpTbxObjBase::SetDffProperties( const DffPropSet
& rDffPropSet
)
2021 maFillData
.mnPattern
= rDffPropSet
.GetPropertyBool( DFF_Prop_fFilled
) ? EXC_PATT_SOLID
: EXC_PATT_NONE
;
2022 lclExtractColor( maFillData
.mnBackColorIdx
, rDffPropSet
, DFF_Prop_fillBackColor
);
2023 lclExtractColor( maFillData
.mnPattColorIdx
, rDffPropSet
, DFF_Prop_fillColor
);
2024 ::set_flag( maFillData
.mnAuto
, EXC_OBJ_LINE_AUTO
, false );
2026 maLineData
.mnStyle
= rDffPropSet
.GetPropertyBool( DFF_Prop_fLine
) ? EXC_OBJ_LINE_SOLID
: EXC_OBJ_LINE_NONE
;
2027 lclExtractColor( maLineData
.mnColorIdx
, rDffPropSet
, DFF_Prop_lineColor
);
2028 ::set_flag( maLineData
.mnAuto
, EXC_OBJ_FILL_AUTO
, false );
2031 bool XclImpTbxObjBase::FillMacroDescriptor( ScriptEventDescriptor
& rDescriptor
) const
2033 return XclControlHelper::FillMacroDescriptor( rDescriptor
, DoGetEventType(), GetMacroName(), GetDocShell() );
2036 void XclImpTbxObjBase::ConvertFont( ScfPropertySet
& rPropSet
) const
2038 if( maTextData
.mxString
)
2040 const XclFormatRunVec
& rFormatRuns
= maTextData
.mxString
->GetFormats();
2041 if( rFormatRuns
.empty() )
2042 GetFontBuffer().WriteDefaultCtrlFontProperties( rPropSet
);
2044 GetFontBuffer().WriteFontProperties( rPropSet
, EXC_FONTPROPSET_CONTROL
, rFormatRuns
.front().mnFontIdx
);
2048 void XclImpTbxObjBase::ConvertLabel( ScfPropertySet
& rPropSet
) const
2050 if( maTextData
.mxString
)
2052 OUString aLabel
= maTextData
.mxString
->GetText();
2053 if( maTextData
.maData
.mnShortcut
> 0 )
2055 sal_Int32 nPos
= aLabel
.indexOf( static_cast< sal_Unicode
>( maTextData
.maData
.mnShortcut
) );
2057 aLabel
= aLabel
.replaceAt( nPos
, 0, "~" );
2059 rPropSet
.SetStringProperty( "Label", aLabel
);
2061 //Excel Alt text <==> Aoo description
2062 //For TBX control, if user does not operate alt text, alt text will be set label text as default value in Excel.
2063 //In this case, DFF_Prop_wzDescription will not be set in excel file.
2064 //So In the end of SvxMSDffManager::ImportShape, description will not be set. But actually in excel,
2065 //the alt text is the label value. So here set description as label text first which is called before ImportShape.
2066 Reference
< ::com::sun::star::beans::XPropertySet
> xPropset( mxShape
, UNO_QUERY
);
2069 xPropset
->setPropertyValue( "Description", makeAny(::rtl::OUString(aLabel
)) );
2072 OSL_TRACE( " Can't set a default text for TBX Control ");
2075 ConvertFont( rPropSet
);
2078 SdrObject
* XclImpTbxObjBase::DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const Rectangle
& rAnchorRect
) const
2080 SdrObjectPtr
xSdrObj( rDffConv
.CreateSdrObject( *this, rAnchorRect
) );
2081 rDffConv
.Progress();
2082 return xSdrObj
.release();
2085 void XclImpTbxObjBase::DoPreProcessSdrObj( XclImpDffConverter
& /*rDffConv*/, SdrObject
& /*rSdrObj*/ ) const
2087 // do not call DoPreProcessSdrObj() from base class (to skip text processing)
2088 ProcessControl( *this );
2091 XclImpButtonObj::XclImpButtonObj( const XclImpRoot
& rRoot
) :
2092 XclImpTbxObjBase( rRoot
)
2096 void XclImpButtonObj::DoProcessControl( ScfPropertySet
& rPropSet
) const
2098 // label and text formatting
2099 ConvertLabel( rPropSet
);
2101 /* Horizontal text alignment. For unknown reason, the property type is a
2102 simple sal_Int16 and not a com.sun.star.style.HorizontalAlignment. */
2103 sal_Int16 nHorAlign
= 1;
2104 switch( maTextData
.maData
.GetHorAlign() )
2106 case EXC_OBJ_HOR_LEFT
: nHorAlign
= 0; break;
2107 case EXC_OBJ_HOR_CENTER
: nHorAlign
= 1; break;
2108 case EXC_OBJ_HOR_RIGHT
: nHorAlign
= 2; break;
2110 rPropSet
.SetProperty( "Align", nHorAlign
);
2112 // vertical text alignment
2113 namespace csss
= ::com::sun::star::style
;
2114 csss::VerticalAlignment eVerAlign
= csss::VerticalAlignment_MIDDLE
;
2115 switch( maTextData
.maData
.GetVerAlign() )
2117 case EXC_OBJ_VER_TOP
: eVerAlign
= csss::VerticalAlignment_TOP
; break;
2118 case EXC_OBJ_VER_CENTER
: eVerAlign
= csss::VerticalAlignment_MIDDLE
; break;
2119 case EXC_OBJ_VER_BOTTOM
: eVerAlign
= csss::VerticalAlignment_BOTTOM
; break;
2121 rPropSet
.SetProperty( "VerticalAlign", eVerAlign
);
2123 // always wrap text automatically
2124 rPropSet
.SetBoolProperty( "MultiLine", true );
2127 bool bDefButton
= ::get_flag( maTextData
.maData
.mnButtonFlags
, EXC_OBJ_BUTTON_DEFAULT
);
2128 rPropSet
.SetBoolProperty( "DefaultButton", bDefButton
);
2130 // button type (flags cannot be combined in OOo)
2131 namespace cssa
= ::com::sun::star::awt
;
2132 cssa::PushButtonType eButtonType
= cssa::PushButtonType_STANDARD
;
2133 if( ::get_flag( maTextData
.maData
.mnButtonFlags
, EXC_OBJ_BUTTON_CLOSE
) )
2134 eButtonType
= cssa::PushButtonType_OK
;
2135 else if( ::get_flag( maTextData
.maData
.mnButtonFlags
, EXC_OBJ_BUTTON_CANCEL
) )
2136 eButtonType
= cssa::PushButtonType_CANCEL
;
2137 else if( ::get_flag( maTextData
.maData
.mnButtonFlags
, EXC_OBJ_BUTTON_HELP
) )
2138 eButtonType
= cssa::PushButtonType_HELP
;
2139 // property type is short, not enum
2140 rPropSet
.SetProperty( "PushButtonType", sal_Int16( eButtonType
) );
2143 OUString
XclImpButtonObj::DoGetServiceName() const
2145 return OUString( "com.sun.star.form.component.CommandButton" );
2148 XclTbxEventType
XclImpButtonObj::DoGetEventType() const
2150 return EXC_TBX_EVENT_ACTION
;
2153 XclImpCheckBoxObj::XclImpCheckBoxObj( const XclImpRoot
& rRoot
) :
2154 XclImpTbxObjBase( rRoot
),
2155 mnState( EXC_OBJ_CHECKBOX_UNCHECKED
),
2156 mnCheckBoxFlags( 0 )
2160 void XclImpCheckBoxObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16
/*nMacroSize*/ )
2162 ReadFrameData( rStrm
);
2164 maTextData
.maData
.mnFlags
= rStrm
.ReaduInt16();
2166 ReadName5( rStrm
, nNameLen
);
2167 ReadMacro5( rStrm
, rStrm
.ReaduInt16() ); // fist macro size invalid and unused
2168 ReadCellLinkFormula( rStrm
, true );
2169 maTextData
.maData
.mnTextLen
= rStrm
.ReaduInt16();
2170 maTextData
.ReadByteString( rStrm
);
2171 mnState
= rStrm
.ReaduInt16();
2172 maTextData
.maData
.mnShortcut
= rStrm
.ReaduInt16();
2173 maTextData
.maData
.mnShortcutEA
= rStrm
.ReaduInt16();
2174 mnCheckBoxFlags
= rStrm
.ReaduInt16();
2177 void XclImpCheckBoxObj::DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
)
2181 case EXC_ID_OBJCBLS
:
2182 // do not read EXC_ID_OBJCBLSDATA, not written by OOo Excel export
2183 mnState
= rStrm
.ReaduInt16();
2185 maTextData
.maData
.mnShortcut
= rStrm
.ReaduInt16();
2186 maTextData
.maData
.mnShortcutEA
= rStrm
.ReaduInt16();
2187 mnCheckBoxFlags
= rStrm
.ReaduInt16();
2189 case EXC_ID_OBJCBLSFMLA
:
2190 ReadCellLinkFormula( rStrm
, false );
2193 XclImpTbxObjBase::DoReadObj8SubRec( rStrm
, nSubRecId
, nSubRecSize
);
2197 void XclImpCheckBoxObj::DoProcessControl( ScfPropertySet
& rPropSet
) const
2199 // label and text formatting
2200 ConvertLabel( rPropSet
);
2203 bool bSupportsTristate
= GetObjType() == EXC_OBJTYPE_CHECKBOX
;
2204 sal_Int16 nApiState
= 0;
2207 case EXC_OBJ_CHECKBOX_UNCHECKED
: nApiState
= 0; break;
2208 case EXC_OBJ_CHECKBOX_CHECKED
: nApiState
= 1; break;
2209 case EXC_OBJ_CHECKBOX_TRISTATE
: nApiState
= bSupportsTristate
? 2 : 1; break;
2211 if( bSupportsTristate
)
2212 rPropSet
.SetBoolProperty( "TriState", nApiState
== 2 );
2213 rPropSet
.SetProperty( "DefaultState", nApiState
);
2216 namespace AwtVisualEffect
= ::com::sun::star::awt::VisualEffect
;
2217 sal_Int16 nEffect
= ::get_flagvalue( mnCheckBoxFlags
, EXC_OBJ_CHECKBOX_FLAT
, AwtVisualEffect::FLAT
, AwtVisualEffect::LOOK3D
);
2218 rPropSet
.SetProperty( "VisualEffect", nEffect
);
2220 // do not wrap text automatically
2221 rPropSet
.SetBoolProperty( "MultiLine", false );
2223 // #i40279# always centered vertically
2224 namespace csss
= ::com::sun::star::style
;
2225 rPropSet
.SetProperty( "VerticalAlign", csss::VerticalAlignment_MIDDLE
);
2228 if( maFillData
.IsFilled() )
2230 sal_Int32 nColor
= static_cast< sal_Int32
>( GetSolidFillColor( maFillData
).GetColor() );
2231 rPropSet
.SetProperty( "BackgroundColor", nColor
);
2235 OUString
XclImpCheckBoxObj::DoGetServiceName() const
2237 return OUString( "com.sun.star.form.component.CheckBox" );
2240 XclTbxEventType
XclImpCheckBoxObj::DoGetEventType() const
2242 return EXC_TBX_EVENT_ACTION
;
2245 XclImpOptionButtonObj::XclImpOptionButtonObj( const XclImpRoot
& rRoot
) :
2246 XclImpCheckBoxObj( rRoot
),
2252 void XclImpOptionButtonObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16
/*nMacroSize*/ )
2254 ReadFrameData( rStrm
);
2256 maTextData
.maData
.mnFlags
= rStrm
.ReaduInt16();
2258 ReadName5( rStrm
, nNameLen
);
2259 ReadMacro5( rStrm
, rStrm
.ReaduInt16() ); // fist macro size invalid and unused
2260 ReadCellLinkFormula( rStrm
, true );
2261 maTextData
.maData
.mnTextLen
= rStrm
.ReaduInt16();
2262 maTextData
.ReadByteString( rStrm
);
2263 mnState
= rStrm
.ReaduInt16();
2264 maTextData
.maData
.mnShortcut
= rStrm
.ReaduInt16();
2265 maTextData
.maData
.mnShortcutEA
= rStrm
.ReaduInt16();
2266 mnCheckBoxFlags
= rStrm
.ReaduInt16();
2267 mnNextInGroup
= rStrm
.ReaduInt16();
2268 mnFirstInGroup
= rStrm
.ReaduInt16();
2271 void XclImpOptionButtonObj::DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
)
2275 case EXC_ID_OBJRBODATA
:
2276 mnNextInGroup
= rStrm
.ReaduInt16();
2277 mnFirstInGroup
= rStrm
.ReaduInt16();
2280 XclImpCheckBoxObj::DoReadObj8SubRec( rStrm
, nSubRecId
, nSubRecSize
);
2284 void XclImpOptionButtonObj::DoProcessControl( ScfPropertySet
& rPropSet
) const
2286 XclImpCheckBoxObj::DoProcessControl( rPropSet
);
2288 XclImpOptionButtonObj
* pTbxObj
= dynamic_cast< XclImpOptionButtonObj
* >( GetObjectManager().GetSheetDrawing( GetTab() ).FindDrawObj( mnNextInGroup
).get() );
2289 if ( ( pTbxObj
&& pTbxObj
->mnFirstInGroup
) )
2291 // Group has terminated
2292 // traverse each RadioButton in group and
2293 // a) apply the groupname
2294 // b) propagate the linked cell from the lead radiobutton
2295 // c) apply the correct Ref value
2296 XclImpOptionButtonObj
* pLeader
= pTbxObj
;
2298 sal_Int32 nRefVal
= 1;
2299 OSL_TRACE( "0x%x start group ", pLeader
->GetObjId()/*.mnObjId */);
2303 Reference
< XControlModel
> xCtrlModel
= XclControlHelper::GetControlModel( pTbxObj
->mxShape
);
2304 if ( xCtrlModel
.is() )
2306 ScfPropertySet
aProps( xCtrlModel
);
2307 OUString sGroupName
= OUString::number( pLeader
->GetDffShapeId() );
2309 aProps
.SetStringProperty( "GroupName", sGroupName
);
2310 aProps
.SetStringProperty( "RefValue", OUString::number( nRefVal
++ ) );
2311 if ( pLeader
->HasCellLink() && !pTbxObj
->HasCellLink() )
2313 // propagate cell link info
2314 pTbxObj
->mxCellLink
.reset( new ScAddress( *pLeader
->mxCellLink
.get() ) );
2315 pTbxObj
->ApplySheetLinkProps();
2317 pTbxObj
= dynamic_cast< XclImpOptionButtonObj
* >( GetObjectManager().GetSheetDrawing( GetTab() ).FindDrawObj( pTbxObj
->mnNextInGroup
).get() );
2321 } while ( pTbxObj
&& !( pTbxObj
->mnFirstInGroup
== 1 ) );
2325 // not the leader? try and find it
2329 OUString
XclImpOptionButtonObj::DoGetServiceName() const
2331 return OUString( "com.sun.star.form.component.RadioButton" );
2334 XclTbxEventType
XclImpOptionButtonObj::DoGetEventType() const
2336 return EXC_TBX_EVENT_ACTION
;
2339 XclImpLabelObj::XclImpLabelObj( const XclImpRoot
& rRoot
) :
2340 XclImpTbxObjBase( rRoot
)
2344 void XclImpLabelObj::DoProcessControl( ScfPropertySet
& rPropSet
) const
2346 // label and text formatting
2347 ConvertLabel( rPropSet
);
2349 // text alignment (always top/left aligned)
2350 rPropSet
.SetProperty( "Align", sal_Int16( 0 ) );
2351 namespace csss
= ::com::sun::star::style
;
2352 rPropSet
.SetProperty( "VerticalAlign", csss::VerticalAlignment_TOP
);
2354 // always wrap text automatically
2355 rPropSet
.SetBoolProperty( "MultiLine", true );
2358 OUString
XclImpLabelObj::DoGetServiceName() const
2360 return OUString( "com.sun.star.form.component.FixedText" );
2363 XclTbxEventType
XclImpLabelObj::DoGetEventType() const
2365 return EXC_TBX_EVENT_MOUSE
;
2368 XclImpGroupBoxObj::XclImpGroupBoxObj( const XclImpRoot
& rRoot
) :
2369 XclImpTbxObjBase( rRoot
),
2370 mnGroupBoxFlags( 0 )
2374 void XclImpGroupBoxObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16
/*nMacroSize*/ )
2376 ReadFrameData( rStrm
);
2378 maTextData
.maData
.mnFlags
= rStrm
.ReaduInt16();
2380 ReadName5( rStrm
, nNameLen
);
2381 ReadMacro5( rStrm
, rStrm
.ReaduInt16() ); // fist macro size invalid and unused
2382 maTextData
.maData
.mnTextLen
= rStrm
.ReaduInt16();
2383 maTextData
.ReadByteString( rStrm
);
2384 maTextData
.maData
.mnShortcut
= rStrm
.ReaduInt16();
2385 maTextData
.maData
.mnShortcutEA
= rStrm
.ReaduInt16( );
2386 mnGroupBoxFlags
= rStrm
.ReaduInt16();
2389 void XclImpGroupBoxObj::DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
)
2393 case EXC_ID_OBJGBODATA
:
2394 maTextData
.maData
.mnShortcut
= rStrm
.ReaduInt16();
2395 maTextData
.maData
.mnShortcutEA
= rStrm
.ReaduInt16();
2396 mnGroupBoxFlags
= rStrm
.ReaduInt16();
2399 XclImpTbxObjBase::DoReadObj8SubRec( rStrm
, nSubRecId
, nSubRecSize
);
2403 void XclImpGroupBoxObj::DoProcessControl( ScfPropertySet
& rPropSet
) const
2405 // label and text formatting
2406 ConvertLabel( rPropSet
);
2409 OUString
XclImpGroupBoxObj::DoGetServiceName() const
2411 return OUString( "com.sun.star.form.component.GroupBox" );
2414 XclTbxEventType
XclImpGroupBoxObj::DoGetEventType() const
2416 return EXC_TBX_EVENT_MOUSE
;
2419 XclImpDialogObj::XclImpDialogObj( const XclImpRoot
& rRoot
) :
2420 XclImpTbxObjBase( rRoot
)
2424 void XclImpDialogObj::DoProcessControl( ScfPropertySet
& rPropSet
) const
2426 // label and text formatting
2427 ConvertLabel( rPropSet
);
2430 OUString
XclImpDialogObj::DoGetServiceName() const
2432 // dialog frame faked by a groupbox
2433 return OUString( "com.sun.star.form.component.GroupBox" );
2436 XclTbxEventType
XclImpDialogObj::DoGetEventType() const
2438 return EXC_TBX_EVENT_MOUSE
;
2441 XclImpEditObj::XclImpEditObj( const XclImpRoot
& rRoot
) :
2442 XclImpTbxObjBase( rRoot
),
2443 mnContentType( EXC_OBJ_EDIT_TEXT
),
2450 bool XclImpEditObj::IsNumeric() const
2452 return (mnContentType
== EXC_OBJ_EDIT_INTEGER
) || (mnContentType
== EXC_OBJ_EDIT_DOUBLE
);
2455 void XclImpEditObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16
/*nMacroSize*/ )
2457 ReadFrameData( rStrm
);
2459 maTextData
.maData
.mnFlags
= rStrm
.ReaduInt16();
2461 ReadName5( rStrm
, nNameLen
);
2462 ReadMacro5( rStrm
, rStrm
.ReaduInt16() ); // fist macro size invalid and unused
2463 maTextData
.maData
.mnTextLen
= rStrm
.ReaduInt16();
2464 maTextData
.ReadByteString( rStrm
);
2465 mnContentType
= rStrm
.ReaduInt16();
2466 mnMultiLine
= rStrm
.ReaduInt16();
2467 mnScrollBar
= rStrm
.ReaduInt16();
2468 mnListBoxObjId
= rStrm
.ReaduInt16();
2471 void XclImpEditObj::DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
)
2475 case EXC_ID_OBJEDODATA
:
2476 mnContentType
= rStrm
.ReaduInt16();
2477 mnMultiLine
= rStrm
.ReaduInt16();
2478 mnScrollBar
= rStrm
.ReaduInt16();
2479 mnListBoxObjId
= rStrm
.ReaduInt16();
2482 XclImpTbxObjBase::DoReadObj8SubRec( rStrm
, nSubRecId
, nSubRecSize
);
2486 void XclImpEditObj::DoProcessControl( ScfPropertySet
& rPropSet
) const
2488 if( maTextData
.mxString
)
2490 OUString aText
= maTextData
.mxString
->GetText();
2493 // TODO: OUString::toDouble() does not handle local decimal separator
2494 rPropSet
.SetProperty( "DefaultValue", aText
.toDouble() );
2495 rPropSet
.SetBoolProperty( "Spin", mnScrollBar
!= 0 );
2499 rPropSet
.SetProperty( "DefaultText", aText
);
2500 rPropSet
.SetBoolProperty( "MultiLine", mnMultiLine
!= 0 );
2501 rPropSet
.SetBoolProperty( "VScroll", mnScrollBar
!= 0 );
2504 ConvertFont( rPropSet
);
2507 OUString
XclImpEditObj::DoGetServiceName() const
2509 return IsNumeric() ?
2510 OUString( "com.sun.star.form.component.NumericField" ) :
2511 OUString( "com.sun.star.form.component.TextField" );
2514 XclTbxEventType
XclImpEditObj::DoGetEventType() const
2516 return EXC_TBX_EVENT_TEXT
;
2519 XclImpTbxObjScrollableBase::XclImpTbxObjScrollableBase( const XclImpRoot
& rRoot
) :
2520 XclImpTbxObjBase( rRoot
),
2532 void XclImpTbxObjScrollableBase::ReadSbs( XclImpStream
& rStrm
)
2535 mnValue
= rStrm
.ReaduInt16();
2536 mnMin
= rStrm
.ReaduInt16();
2537 mnMax
= rStrm
.ReaduInt16();
2538 mnStep
= rStrm
.ReaduInt16();
2539 mnPageStep
= rStrm
.ReaduInt16();
2540 mnOrient
= rStrm
.ReaduInt16();
2541 mnThumbWidth
= rStrm
.ReaduInt16();
2542 mnScrollFlags
= rStrm
.ReaduInt16();
2545 void XclImpTbxObjScrollableBase::DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
)
2552 case EXC_ID_OBJSBSFMLA
:
2553 ReadCellLinkFormula( rStrm
, false );
2556 XclImpTbxObjBase::DoReadObj8SubRec( rStrm
, nSubRecId
, nSubRecSize
);
2560 XclImpSpinButtonObj::XclImpSpinButtonObj( const XclImpRoot
& rRoot
) :
2561 XclImpTbxObjScrollableBase( rRoot
)
2565 void XclImpSpinButtonObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16
/*nMacroSize*/ )
2567 ReadFrameData( rStrm
);
2569 ReadName5( rStrm
, nNameLen
);
2570 ReadMacro5( rStrm
, rStrm
.ReaduInt16() ); // fist macro size invalid and unused
2571 ReadCellLinkFormula( rStrm
, true );
2574 void XclImpSpinButtonObj::DoProcessControl( ScfPropertySet
& rPropSet
) const
2576 // Calc's "Border" property is not the 3D/flat style effect in Excel (#i34712#)
2577 rPropSet
.SetProperty( "Border", ::com::sun::star::awt::VisualEffect::NONE
);
2578 rPropSet
.SetProperty
< sal_Int32
>( "DefaultSpinValue", mnValue
);
2579 rPropSet
.SetProperty
< sal_Int32
>( "SpinValueMin", mnMin
);
2580 rPropSet
.SetProperty
< sal_Int32
>( "SpinValueMax", mnMax
);
2581 rPropSet
.SetProperty
< sal_Int32
>( "SpinIncrement", mnStep
);
2583 // Excel spin buttons always vertical
2584 rPropSet
.SetProperty( "Orientation", ::com::sun::star::awt::ScrollBarOrientation::VERTICAL
);
2587 OUString
XclImpSpinButtonObj::DoGetServiceName() const
2589 return OUString( "com.sun.star.form.component.SpinButton" );
2592 XclTbxEventType
XclImpSpinButtonObj::DoGetEventType() const
2594 return EXC_TBX_EVENT_VALUE
;
2597 XclImpScrollBarObj::XclImpScrollBarObj( const XclImpRoot
& rRoot
) :
2598 XclImpTbxObjScrollableBase( rRoot
)
2602 void XclImpScrollBarObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16
/*nMacroSize*/ )
2604 ReadFrameData( rStrm
);
2606 ReadName5( rStrm
, nNameLen
);
2607 ReadMacro5( rStrm
, rStrm
.ReaduInt16() ); // fist macro size invalid and unused
2608 ReadCellLinkFormula( rStrm
, true );
2611 void XclImpScrollBarObj::DoProcessControl( ScfPropertySet
& rPropSet
) const
2613 // Calc's "Border" property is not the 3D/flat style effect in Excel (#i34712#)
2614 rPropSet
.SetProperty( "Border", ::com::sun::star::awt::VisualEffect::NONE
);
2615 rPropSet
.SetProperty
< sal_Int32
>( "DefaultScrollValue", mnValue
);
2616 rPropSet
.SetProperty
< sal_Int32
>( "ScrollValueMin", mnMin
);
2617 rPropSet
.SetProperty
< sal_Int32
>( "ScrollValueMax", mnMax
);
2618 rPropSet
.SetProperty
< sal_Int32
>( "LineIncrement", mnStep
);
2619 rPropSet
.SetProperty
< sal_Int32
>( "BlockIncrement", mnPageStep
);
2620 rPropSet
.SetProperty( "VisibleSize", ::std::min
< sal_Int32
>( mnPageStep
, 1 ) );
2622 namespace AwtScrollOrient
= ::com::sun::star::awt::ScrollBarOrientation
;
2623 sal_Int32 nApiOrient
= ::get_flagvalue( mnOrient
, EXC_OBJ_SCROLLBAR_HOR
, AwtScrollOrient::HORIZONTAL
, AwtScrollOrient::VERTICAL
);
2624 rPropSet
.SetProperty( "Orientation", nApiOrient
);
2627 OUString
XclImpScrollBarObj::DoGetServiceName() const
2629 return OUString( "com.sun.star.form.component.ScrollBar" );
2632 XclTbxEventType
XclImpScrollBarObj::DoGetEventType() const
2634 return EXC_TBX_EVENT_VALUE
;
2637 XclImpTbxObjListBase::XclImpTbxObjListBase( const XclImpRoot
& rRoot
) :
2638 XclImpTbxObjScrollableBase( rRoot
),
2643 mbHasDefFontIdx( false )
2647 void XclImpTbxObjListBase::ReadLbsData( XclImpStream
& rStrm
)
2649 ReadSourceRangeFormula( rStrm
, true );
2650 mnEntryCount
= rStrm
.ReaduInt16();
2651 mnSelEntry
= rStrm
.ReaduInt16();
2652 mnListFlags
= rStrm
.ReaduInt16();
2653 mnEditObjId
= rStrm
.ReaduInt16();
2656 void XclImpTbxObjListBase::SetBoxFormatting( ScfPropertySet
& rPropSet
) const
2659 namespace AwtVisualEffect
= ::com::sun::star::awt::VisualEffect
;
2660 sal_Int16 nApiBorder
= ::get_flagvalue( mnListFlags
, EXC_OBJ_LISTBOX_FLAT
, AwtVisualEffect::FLAT
, AwtVisualEffect::LOOK3D
);
2661 rPropSet
.SetProperty( "Border", nApiBorder
);
2664 if( mbHasDefFontIdx
)
2665 GetFontBuffer().WriteFontProperties( rPropSet
, EXC_FONTPROPSET_CONTROL
, maTextData
.maData
.mnDefFontIdx
);
2667 GetFontBuffer().WriteDefaultCtrlFontProperties( rPropSet
);
2670 XclImpListBoxObj::XclImpListBoxObj( const XclImpRoot
& rRoot
) :
2671 XclImpTbxObjListBase( rRoot
)
2675 void XclImpListBoxObj::ReadFullLbsData( XclImpStream
& rStrm
, sal_Size nRecLeft
)
2677 sal_Size nRecEnd
= rStrm
.GetRecPos() + nRecLeft
;
2678 ReadLbsData( rStrm
);
2679 OSL_ENSURE( (rStrm
.GetRecPos() == nRecEnd
) || (rStrm
.GetRecPos() + mnEntryCount
== nRecEnd
),
2680 "XclImpListBoxObj::ReadFullLbsData - invalid size of OBJLBSDATA record" );
2681 while( rStrm
.IsValid() && (rStrm
.GetRecPos() < nRecEnd
) )
2682 maSelection
.push_back( rStrm
.ReaduInt8() );
2685 void XclImpListBoxObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16
/*nMacroSize*/ )
2687 ReadFrameData( rStrm
);
2690 maTextData
.maData
.mnDefFontIdx
= rStrm
.ReaduInt16();
2692 ReadName5( rStrm
, nNameLen
);
2693 ReadMacro5( rStrm
, rStrm
.ReaduInt16() ); // fist macro size invalid and unused
2694 ReadCellLinkFormula( rStrm
, true );
2695 ReadFullLbsData( rStrm
, rStrm
.GetRecLeft() );
2696 mbHasDefFontIdx
= true;
2699 void XclImpListBoxObj::DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
)
2703 case EXC_ID_OBJLBSDATA
:
2704 ReadFullLbsData( rStrm
, nSubRecSize
);
2707 XclImpTbxObjListBase::DoReadObj8SubRec( rStrm
, nSubRecId
, nSubRecSize
);
2711 void XclImpListBoxObj::DoProcessControl( ScfPropertySet
& rPropSet
) const
2713 // listbox formatting
2714 SetBoxFormatting( rPropSet
);
2717 sal_uInt8 nSelType
= ::extract_value
< sal_uInt8
>( mnListFlags
, 4, 2 );
2718 bool bMultiSel
= nSelType
!= EXC_OBJ_LISTBOX_SINGLE
;
2719 rPropSet
.SetBoolProperty( "MultiSelection", bMultiSel
);
2721 // selection (do not set, if listbox is linked to a cell)
2722 if( !HasCellLink() )
2724 ScfInt16Vec aSelVec
;
2726 // multi selection: API expects sequence of list entry indexes
2729 for( ScfUInt8Vec::const_iterator aBeg
= maSelection
.begin(), aIt
= aBeg
, aEnd
= maSelection
.end(); aIt
!= aEnd
; ++aIt
)
2731 aSelVec
.push_back( static_cast< sal_Int16
>( aIt
- aBeg
) );
2733 // single selection: mnSelEntry is one-based, API expects zero-based
2734 else if( mnSelEntry
> 0 )
2735 aSelVec
.push_back( static_cast< sal_Int16
>( mnSelEntry
- 1 ) );
2737 if( !aSelVec
.empty() )
2739 Sequence
< sal_Int16
> aSelSeq( &aSelVec
.front(), static_cast< sal_Int32
>( aSelVec
.size() ) );
2740 rPropSet
.SetProperty( "DefaultSelection", aSelSeq
);
2745 OUString
XclImpListBoxObj::DoGetServiceName() const
2747 return OUString( "com.sun.star.form.component.ListBox" );
2750 XclTbxEventType
XclImpListBoxObj::DoGetEventType() const
2752 return EXC_TBX_EVENT_CHANGE
;
2755 XclImpDropDownObj::XclImpDropDownObj( const XclImpRoot
& rRoot
) :
2756 XclImpTbxObjListBase( rRoot
),
2761 mnDropDownFlags( 0 ),
2767 sal_uInt16
XclImpDropDownObj::GetDropDownType() const
2769 return ::extract_value
< sal_uInt8
>( mnDropDownFlags
, 0, 2 );
2772 void XclImpDropDownObj::ReadFullLbsData( XclImpStream
& rStrm
)
2774 ReadLbsData( rStrm
);
2775 mnDropDownFlags
= rStrm
.ReaduInt16();
2776 mnLineCount
= rStrm
.ReaduInt16();
2777 mnMinWidth
= rStrm
.ReaduInt16();
2778 maTextData
.maData
.mnTextLen
= rStrm
.ReaduInt16();
2779 maTextData
.ReadByteString( rStrm
);
2780 // dropdowns of auto-filters have 'simple' style, they don't have a text area
2781 if( GetDropDownType() == EXC_OBJ_DROPDOWN_SIMPLE
)
2782 SetProcessSdrObj( false );
2785 void XclImpDropDownObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16
/*nMacroSize*/ )
2787 ReadFrameData( rStrm
);
2790 maTextData
.maData
.mnDefFontIdx
= rStrm
.ReaduInt16();
2792 mnLeft
= rStrm
.ReaduInt16();
2793 mnTop
= rStrm
.ReaduInt16();
2794 mnRight
= rStrm
.ReaduInt16();
2795 mnBottom
= rStrm
.ReaduInt16();
2797 ReadName5( rStrm
, nNameLen
);
2798 ReadMacro5( rStrm
, rStrm
.ReaduInt16() ); // fist macro size invalid and unused
2799 ReadCellLinkFormula( rStrm
, true );
2800 ReadFullLbsData( rStrm
);
2801 mbHasDefFontIdx
= true;
2804 void XclImpDropDownObj::DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
)
2808 case EXC_ID_OBJLBSDATA
:
2809 ReadFullLbsData( rStrm
);
2812 XclImpTbxObjListBase::DoReadObj8SubRec( rStrm
, nSubRecId
, nSubRecSize
);
2816 void XclImpDropDownObj::DoProcessControl( ScfPropertySet
& rPropSet
) const
2818 // dropdown listbox formatting
2819 SetBoxFormatting( rPropSet
);
2820 // enable dropdown button
2821 rPropSet
.SetBoolProperty( "Dropdown", true );
2822 // dropdown line count
2823 rPropSet
.SetProperty( "LineCount", mnLineCount
);
2825 if( GetDropDownType() == EXC_OBJ_DROPDOWN_COMBOBOX
)
2827 // text of editable combobox
2828 if( maTextData
.mxString
)
2829 rPropSet
.SetStringProperty( "DefaultText", maTextData
.mxString
->GetText() );
2833 // selection (do not set, if dropdown is linked to a cell)
2834 if( !HasCellLink() && (mnSelEntry
> 0) )
2836 Sequence
< sal_Int16
> aSelSeq( 1 );
2837 aSelSeq
[ 0 ] = mnSelEntry
- 1;
2838 rPropSet
.SetProperty( "DefaultSelection", aSelSeq
);
2843 OUString
XclImpDropDownObj::DoGetServiceName() const
2845 return (GetDropDownType() == EXC_OBJ_DROPDOWN_COMBOBOX
) ?
2846 OUString( "com.sun.star.form.component.ComboBox" ) :
2847 OUString( "com.sun.star.form.component.ListBox" );
2850 XclTbxEventType
XclImpDropDownObj::DoGetEventType() const
2852 return (GetDropDownType() == EXC_OBJ_DROPDOWN_COMBOBOX
) ? EXC_TBX_EVENT_TEXT
: EXC_TBX_EVENT_CHANGE
;
2855 XclImpPictureObj::XclImpPictureObj( const XclImpRoot
& rRoot
) :
2856 XclImpRectObj( rRoot
),
2857 XclImpControlHelper( rRoot
, EXC_CTRL_BINDCONTENT
),
2860 mnCtlsStrmSize( 0 ),
2861 mbEmbedded( false ),
2865 mbUseCtlsStrm( false )
2868 SetSimpleMacro( true );
2869 SetCustomDffObj( true );
2872 OUString
XclImpPictureObj::GetOleStorageName() const
2875 if( (mbEmbedded
|| mbLinked
) && !mbControl
&& (mnStorageId
> 0) )
2877 aStrgName
= mbEmbedded
? OUString(EXC_STORAGE_OLE_EMBEDDED
) : OUString(EXC_STORAGE_OLE_LINKED
);
2878 static const sal_Char spcHexChars
[] = "0123456789ABCDEF";
2879 for( sal_uInt8 nIndex
= 32; nIndex
> 0; nIndex
-= 4 )
2880 aStrgName
+= OUString( sal_Unicode( spcHexChars
[ ::extract_value
< sal_uInt8
>( mnStorageId
, nIndex
- 4, 4 ) ] ) );
2885 void XclImpPictureObj::DoReadObj3( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
2887 sal_uInt16 nLinkSize
;
2888 ReadFrameData( rStrm
);
2890 nLinkSize
= rStrm
.ReaduInt16();
2892 ReadFlags3( rStrm
);
2893 ReadMacro3( rStrm
, nMacroSize
);
2894 ReadPictFmla( rStrm
, nLinkSize
);
2896 if( (rStrm
.GetNextRecId() == EXC_ID3_IMGDATA
) && rStrm
.StartNextRecord() )
2897 maGraphic
= XclImpDrawing::ReadImgData( GetRoot(), rStrm
);
2900 void XclImpPictureObj::DoReadObj4( XclImpStream
& rStrm
, sal_uInt16 nMacroSize
)
2902 sal_uInt16 nLinkSize
;
2903 ReadFrameData( rStrm
);
2905 nLinkSize
= rStrm
.ReaduInt16();
2907 ReadFlags3( rStrm
);
2908 ReadMacro4( rStrm
, nMacroSize
);
2909 ReadPictFmla( rStrm
, nLinkSize
);
2911 if( (rStrm
.GetNextRecId() == EXC_ID3_IMGDATA
) && rStrm
.StartNextRecord() )
2912 maGraphic
= XclImpDrawing::ReadImgData( GetRoot(), rStrm
);
2915 void XclImpPictureObj::DoReadObj5( XclImpStream
& rStrm
, sal_uInt16 nNameLen
, sal_uInt16 nMacroSize
)
2917 sal_uInt16 nLinkSize
;
2918 ReadFrameData( rStrm
);
2920 nLinkSize
= rStrm
.ReaduInt16();
2922 ReadFlags3( rStrm
);
2924 ReadName5( rStrm
, nNameLen
);
2925 ReadMacro5( rStrm
, nMacroSize
);
2926 ReadPictFmla( rStrm
, nLinkSize
);
2928 if( (rStrm
.GetNextRecId() == EXC_ID3_IMGDATA
) && rStrm
.StartNextRecord() )
2930 // page background is stored as hidden picture with name "__BkgndObj"
2931 if ( IsHidden() && (GetObjName() == "__BkgndObj") )
2932 GetPageSettings().ReadImgData( rStrm
);
2934 maGraphic
= XclImpDrawing::ReadImgData( GetRoot(), rStrm
);
2938 void XclImpPictureObj::DoReadObj8SubRec( XclImpStream
& rStrm
, sal_uInt16 nSubRecId
, sal_uInt16 nSubRecSize
)
2942 case EXC_ID_OBJFLAGS
:
2943 ReadFlags8( rStrm
);
2945 case EXC_ID_OBJPICTFMLA
:
2946 ReadPictFmla( rStrm
, rStrm
.ReaduInt16() );
2949 XclImpDrawObjBase::DoReadObj8SubRec( rStrm
, nSubRecId
, nSubRecSize
);
2953 SdrObject
* XclImpPictureObj::DoCreateSdrObj( XclImpDffConverter
& rDffConv
, const Rectangle
& rAnchorRect
) const
2955 // try to create an OLE object or form control
2956 SdrObjectPtr
xSdrObj( rDffConv
.CreateSdrObject( *this, rAnchorRect
) );
2958 // insert a graphic replacement for unsupported ole object ( if none already
2959 // exists ) Hmm ok, it's possibly that there has been some imported
2960 // graphic at a base level but unlikely, normally controls have a valid
2961 // preview in the IMGDATA record ( see below )
2962 // It might be possible to push such an imported graphic up to this
2963 // XclImpPictureObj instance but there are somany layers of indirection I
2964 // don't see an easy way. This way at least ensures that we can
2965 // avoid a 'blank' shape that can result from a failed control import
2966 if ( !xSdrObj
&& IsOcxControl() && maGraphic
.GetType() == GRAPHIC_NONE
)
2968 const_cast< XclImpPictureObj
* >( this )->maGraphic
=
2969 SdrOle2Obj::GetEmptyOLEReplacementGraphic();
2971 // no OLE - create a plain picture from IMGDATA record data
2972 if( !xSdrObj
&& (maGraphic
.GetType() != GRAPHIC_NONE
) )
2974 xSdrObj
.reset( new SdrGrafObj( maGraphic
, rAnchorRect
) );
2975 ConvertRectStyle( *xSdrObj
);
2978 rDffConv
.Progress();
2979 return xSdrObj
.release();
2982 OUString
XclImpPictureObj::GetObjName() const
2984 if( IsOcxControl() )
2986 OUString
sName( GetObjectManager().GetOleNameOverride( GetTab(), GetObjId() ) );
2987 if (!sName
.isEmpty())
2990 return XclImpDrawObjBase::GetObjName();
2993 void XclImpPictureObj::DoPreProcessSdrObj( XclImpDffConverter
& rDffConv
, SdrObject
& rSdrObj
) const
2995 if( IsOcxControl() )
2997 // do not call XclImpRectObj::DoPreProcessSdrObj(), it would trace missing "printable" feature
2998 ProcessControl( *this );
3000 else if( mbEmbedded
|| mbLinked
)
3002 // trace missing "printable" feature
3003 XclImpRectObj::DoPreProcessSdrObj( rDffConv
, rSdrObj
);
3005 SfxObjectShell
* pDocShell
= GetDocShell();
3006 SdrOle2Obj
* pOleSdrObj
= dynamic_cast< SdrOle2Obj
* >( &rSdrObj
);
3007 if( pOleSdrObj
&& pDocShell
)
3009 comphelper::EmbeddedObjectContainer
& rEmbObjCont
= pDocShell
->GetEmbeddedObjectContainer();
3010 Reference
< XEmbeddedObject
> xEmbObj
= pOleSdrObj
->GetObjRef();
3011 OUString
aOldName( pOleSdrObj
->GetPersistName() );
3013 /* The object persistence should be already in the storage, but
3014 the object still might not be inserted into the container. */
3015 if( rEmbObjCont
.HasEmbeddedObject( aOldName
) )
3017 if( !rEmbObjCont
.HasEmbeddedObject( xEmbObj
) )
3018 // filter code is allowed to call the following method
3019 rEmbObjCont
.AddEmbeddedObject( xEmbObj
, aOldName
);
3023 /* If the object is still not in container it must be inserted
3024 there, the name must be generated in this case. */
3026 rEmbObjCont
.InsertEmbeddedObject( xEmbObj
, aNewName
);
3027 if( aOldName
!= aNewName
)
3028 // SetPersistName, not SetName
3029 pOleSdrObj
->SetPersistName( aNewName
);
3035 void XclImpPictureObj::ReadFlags3( XclImpStream
& rStrm
)
3038 nFlags
= rStrm
.ReaduInt16();
3039 mbSymbol
= ::get_flag( nFlags
, EXC_OBJ_PIC_SYMBOL
);
3042 void XclImpPictureObj::ReadFlags8( XclImpStream
& rStrm
)
3045 nFlags
= rStrm
.ReaduInt16();
3046 mbSymbol
= ::get_flag( nFlags
, EXC_OBJ_PIC_SYMBOL
);
3047 mbControl
= ::get_flag( nFlags
, EXC_OBJ_PIC_CONTROL
);
3048 mbUseCtlsStrm
= ::get_flag( nFlags
, EXC_OBJ_PIC_CTLSSTREAM
);
3049 OSL_ENSURE( mbControl
|| !mbUseCtlsStrm
, "XclImpPictureObj::ReadFlags8 - CTLS stream for controls only" );
3050 SetProcessSdrObj( mbControl
|| !mbUseCtlsStrm
);
3053 void XclImpPictureObj::ReadPictFmla( XclImpStream
& rStrm
, sal_uInt16 nLinkSize
)
3055 sal_Size nLinkEnd
= rStrm
.GetRecPos() + nLinkSize
;
3056 if( nLinkSize
>= 6 )
3058 sal_uInt16 nFmlaSize
;
3059 nFmlaSize
= rStrm
.ReaduInt16();
3060 OSL_ENSURE( nFmlaSize
> 0, "XclImpPictureObj::ReadPictFmla - missing link formula" );
3061 // BIFF3/BIFF4 do not support storages, nothing to do here
3062 if( (nFmlaSize
> 0) && (GetBiff() >= EXC_BIFF5
) )
3066 nToken
= rStrm
.ReaduInt8();
3068 // different processing for linked vs. embedded OLE objects
3069 if( nToken
== XclTokenArrayHelper::GetTokenId( EXC_TOKID_NAMEX
, EXC_TOKCLASS_REF
) )
3077 sal_uInt16 nNameIdx
;
3078 nRefIdx
= rStrm
.ReadInt16();
3080 nNameIdx
= rStrm
.ReaduInt16();
3082 const ExtName
* pExtName
= GetOldRoot().pExtNameBuff
->GetNameByIndex( nRefIdx
, nNameIdx
);
3083 if( pExtName
&& pExtName
->IsOLE() )
3084 mnStorageId
= pExtName
->nStorageId
;
3089 sal_uInt16 nXti
, nExtName
;
3090 nXti
= rStrm
.ReaduInt16();
3091 nExtName
= rStrm
.ReaduInt16();
3092 const XclImpExtName
* pExtName
= GetLinkManager().GetExternName( nXti
, nExtName
);
3093 if( pExtName
&& (pExtName
->GetType() == xlExtOLE
) )
3094 mnStorageId
= pExtName
->GetStorageId();
3101 else if( nToken
== XclTokenArrayHelper::GetTokenId( EXC_TOKID_TBL
, EXC_TOKCLASS_NONE
) )
3104 OSL_ENSURE( nFmlaSize
== 5, "XclImpPictureObj::ReadPictFmla - unexpected formula size" );
3105 rStrm
.Ignore( nFmlaSize
- 1 ); // token ID already read
3107 rStrm
.Ignore( 1 ); // padding byte
3109 // a class name may follow inside the picture link
3110 if( rStrm
.GetRecPos() + 2 <= nLinkEnd
)
3113 nLen
= rStrm
.ReaduInt16();
3115 maClassName
= (GetBiff() == EXC_BIFF8
) ? rStrm
.ReadUniString( nLen
) : rStrm
.ReadRawByteString( nLen
);
3118 // else: ignore other formulas, e.g. pictures linked to cell ranges
3122 // seek behind picture link data
3123 rStrm
.Seek( nLinkEnd
);
3125 // read additional data for embedded OLE objects following the picture link
3126 if( IsOcxControl() )
3128 // #i26521# form controls to be ignored
3129 if( maClassName
== "Forms.HTML:Hidden.1" )
3131 SetProcessSdrObj( false );
3135 if( rStrm
.GetRecLeft() <= 8 ) return;
3137 // position and size of control data in 'Ctls' stream
3138 mnCtlsStrmPos
= static_cast< sal_Size
>( rStrm
.ReaduInt32() );
3139 mnCtlsStrmSize
= static_cast< sal_Size
>( rStrm
.ReaduInt32() );
3141 if( rStrm
.GetRecLeft() <= 8 ) return;
3143 // additional string (16-bit characters), e.g. for progress bar control
3144 sal_uInt32 nAddStrSize
;
3145 nAddStrSize
= rStrm
.ReaduInt32();
3146 OSL_ENSURE( rStrm
.GetRecLeft() >= nAddStrSize
+ 4, "XclImpPictureObj::ReadPictFmla - missing data" );
3147 if( rStrm
.GetRecLeft() >= nAddStrSize
+ 4 )
3149 rStrm
.Ignore( nAddStrSize
);
3150 // cell link and source range
3151 ReadCellLinkFormula( rStrm
, true );
3152 ReadSourceRangeFormula( rStrm
, true );
3155 else if( mbEmbedded
&& (rStrm
.GetRecLeft() >= 4) )
3157 mnStorageId
= rStrm
.ReaduInt32();
3161 // DFF stream conversion ======================================================
3163 void XclImpSolverContainer::InsertSdrObjectInfo( SdrObject
& rSdrObj
, sal_uInt32 nDffShapeId
, sal_uInt32 nDffFlags
)
3165 if( nDffShapeId
> 0 )
3167 maSdrInfoMap
[ nDffShapeId
].Set( &rSdrObj
, nDffFlags
);
3168 maSdrObjMap
[ &rSdrObj
] = nDffShapeId
;
3172 void XclImpSolverContainer::RemoveSdrObjectInfo( SdrObject
& rSdrObj
)
3174 // remove info of passed object from the maps
3175 XclImpSdrObjMap::iterator aIt
= maSdrObjMap
.find( &rSdrObj
);
3176 if( aIt
!= maSdrObjMap
.end() )
3178 maSdrInfoMap
.erase( aIt
->second
);
3179 maSdrObjMap
.erase( aIt
);
3182 // remove info of all child objects of a group object
3183 if( SdrObjGroup
* pGroupObj
= dynamic_cast< SdrObjGroup
* >( &rSdrObj
) )
3185 if( SdrObjList
* pSubList
= pGroupObj
->GetSubList() )
3187 // iterate flat over the list because this function already works recursively
3188 SdrObjListIter
aObjIt( *pSubList
, IM_FLAT
);
3189 for( SdrObject
* pChildObj
= aObjIt
.Next(); pChildObj
; pChildObj
= aObjIt
.Next() )
3190 RemoveSdrObjectInfo( *pChildObj
);
3195 void XclImpSolverContainer::UpdateConnectorRules()
3197 for ( size_t i
= 0, n
= aCList
.size(); i
< n
; ++i
)
3199 SvxMSDffConnectorRule
* pRule
= aCList
[ i
];
3200 UpdateConnection( pRule
->nShapeA
, pRule
->pAObj
, &pRule
->nSpFlagsA
);
3201 UpdateConnection( pRule
->nShapeB
, pRule
->pBObj
, &pRule
->nSpFlagsB
);
3202 UpdateConnection( pRule
->nShapeC
, pRule
->pCObj
);
3206 void XclImpSolverContainer::RemoveConnectorRules()
3208 // base class from SVX uses plain untyped tools/List
3209 for ( size_t i
= 0, n
= aCList
.size(); i
< n
; ++i
) {
3213 maSdrInfoMap
.clear();
3214 maSdrObjMap
.clear();
3217 void XclImpSolverContainer::UpdateConnection( sal_uInt32 nDffShapeId
, SdrObject
*& rpSdrObj
, sal_uInt32
* pnDffFlags
)
3219 XclImpSdrInfoMap::const_iterator aIt
= maSdrInfoMap
.find( nDffShapeId
);
3220 if( aIt
!= maSdrInfoMap
.end() )
3222 rpSdrObj
= aIt
->second
.mpSdrObj
;
3224 *pnDffFlags
= aIt
->second
.mnDffFlags
;
3228 XclImpSimpleDffConverter::XclImpSimpleDffConverter( const XclImpRoot
& rRoot
, SvStream
& rDffStrm
) :
3229 SvxMSDffManager( rDffStrm
, rRoot
.GetBasePath(), 0, 0, rRoot
.GetDoc().GetDrawLayer(), 1440, COL_DEFAULT
, 24, 0 ),
3232 SetSvxMSDffSettings( SVXMSDFF_SETTINGS_CROP_BITMAPS
| SVXMSDFF_SETTINGS_IMPORT_EXCEL
);
3235 XclImpSimpleDffConverter::~XclImpSimpleDffConverter()
3239 bool XclImpSimpleDffConverter::GetColorFromPalette( sal_uInt16 nIndex
, Color
& rColor
) const
3241 ColorData nColor
= GetPalette().GetColorData( static_cast< sal_uInt16
>( nIndex
) );
3243 if( nColor
== COL_AUTO
)
3246 rColor
.SetColor( nColor
);
3250 XclImpDffConverter::XclImpDffConvData::XclImpDffConvData(
3251 XclImpDrawing
& rDrawing
, SdrModel
& rSdrModel
, SdrPage
& rSdrPage
) :
3252 mrDrawing( rDrawing
),
3253 mrSdrModel( rSdrModel
),
3254 mrSdrPage( rSdrPage
),
3255 mnLastCtrlIndex( -1 ),
3256 mbHasCtrlForm( false )
3260 XclImpDffConverter::XclImpDffConverter( const XclImpRoot
& rRoot
, SvStream
& rDffStrm
) :
3261 XclImpSimpleDffConverter( rRoot
, rDffStrm
),
3262 oox::ole::MSConvertOCXControls( rRoot
.GetDocShell()->GetModel() ),
3263 maStdFormName( "Standard" ),
3266 const SvtFilterOptions
& rFilterOpt
= SvtFilterOptions::Get();
3267 if( rFilterOpt
.IsMathType2Math() )
3268 mnOleImpFlags
|= OLE_MATHTYPE_2_STARMATH
;
3269 if( rFilterOpt
.IsWinWord2Writer() )
3270 mnOleImpFlags
|= OLE_WINWORD_2_STARWRITER
;
3271 if( rFilterOpt
.IsPowerPoint2Impress() )
3272 mnOleImpFlags
|= OLE_POWERPOINT_2_STARIMPRESS
;
3274 // try to open the 'Ctls' storage stream containing OCX control properties
3275 mxCtlsStrm
= OpenStream( EXC_STREAM_CTLS
);
3277 // default text margin (convert EMU to drawing layer units)
3278 mnDefTextMargin
= EXC_OBJ_TEXT_MARGIN
;
3279 ScaleEmu( mnDefTextMargin
);
3282 XclImpDffConverter::~XclImpDffConverter()
3286 OUString
XclImpObjectManager::GetOleNameOverride( SCTAB nTab
, sal_uInt16 nObjId
)
3289 OUString sCodeName
= GetExtDocOptions().GetCodeName( nTab
);
3291 if (mxOleCtrlNameOverride
.is() && mxOleCtrlNameOverride
->hasByName(sCodeName
))
3293 Reference
< XIndexContainer
> xIdToOleName
;
3294 mxOleCtrlNameOverride
->getByName( sCodeName
) >>= xIdToOleName
;
3295 xIdToOleName
->getByIndex( nObjId
) >>= sOleName
;
3297 OSL_TRACE("XclImpObjectManager::GetOleNameOverride tab %d, ( module %s ) object id ( %d ) is %s", nTab
,
3298 OUStringToOString( sCodeName
, RTL_TEXTENCODING_UTF8
).getStr(), nObjId
,
3299 OUStringToOString( sOleName
, RTL_TEXTENCODING_UTF8
).getStr() );
3304 void XclImpDffConverter::StartProgressBar( sal_Size nProgressSize
)
3306 mxProgress
.reset( new ScfProgressBar( GetDocShell(), STR_PROGRESS_CALCULATING
) );
3307 mxProgress
->AddSegment( nProgressSize
);
3308 mxProgress
->Activate();
3311 void XclImpDffConverter::Progress( sal_Size nDelta
)
3313 OSL_ENSURE( mxProgress
, "XclImpDffConverter::Progress - invalid call, no progress bar" );
3314 mxProgress
->Progress( nDelta
);
3317 void XclImpDffConverter::InitializeDrawing( XclImpDrawing
& rDrawing
, SdrModel
& rSdrModel
, SdrPage
& rSdrPage
)
3319 XclImpDffConvDataRef
xConvData( new XclImpDffConvData( rDrawing
, rSdrModel
, rSdrPage
) );
3320 maDataStack
.push_back( xConvData
);
3321 SetModel( &xConvData
->mrSdrModel
, 1440 );
3324 void XclImpDffConverter::ProcessObject( SdrObjList
& rObjList
, const XclImpDrawObjBase
& rDrawObj
)
3326 if( rDrawObj
.IsProcessSdrObj() )
3328 if( const XclObjAnchor
* pAnchor
= rDrawObj
.GetAnchor() )
3330 Rectangle aAnchorRect
= GetConvData().mrDrawing
.CalcAnchorRect( *pAnchor
, false );
3331 if( rDrawObj
.IsValidSize( aAnchorRect
) )
3333 // CreateSdrObject() recursively creates embedded child objects
3334 SdrObjectPtr
xSdrObj( rDrawObj
.CreateSdrObject( *this, aAnchorRect
, false ) );
3336 rDrawObj
.PreProcessSdrObject( *this, *xSdrObj
);
3337 // call InsertSdrObject() also, if SdrObject is missing
3338 InsertSdrObject( rObjList
, rDrawObj
, xSdrObj
.release() );
3344 void XclImpDffConverter::ProcessDrawing( const XclImpDrawObjVector
& rDrawObjs
)
3346 SdrPage
& rSdrPage
= GetConvData().mrSdrPage
;
3347 for( ::std::vector
< XclImpDrawObjRef
>::const_iterator aIt
= rDrawObjs
.begin(), aEnd
= rDrawObjs
.end(); aIt
!= aEnd
; ++aIt
)
3348 ProcessObject( rSdrPage
, **aIt
);
3351 void XclImpDffConverter::ProcessDrawing( SvStream
& rDffStrm
)
3353 rDffStrm
.Seek( STREAM_SEEK_TO_END
);
3354 if( rDffStrm
.Tell() > 0 )
3356 rDffStrm
.Seek( STREAM_SEEK_TO_BEGIN
);
3357 DffRecordHeader aHeader
;
3358 ReadDffRecordHeader( rDffStrm
, aHeader
);
3359 OSL_ENSURE( aHeader
.nRecType
== DFF_msofbtDgContainer
, "XclImpDffConverter::ProcessDrawing - unexpected record" );
3360 if( aHeader
.nRecType
== DFF_msofbtDgContainer
)
3361 ProcessDgContainer( rDffStrm
, aHeader
);
3365 void XclImpDffConverter::FinalizeDrawing()
3367 OSL_ENSURE( !maDataStack
.empty(), "XclImpDffConverter::FinalizeDrawing - no drawing manager on stack" );
3368 maDataStack
.pop_back();
3369 // restore previous model at core DFF converter
3370 if( !maDataStack
.empty() )
3371 SetModel( &maDataStack
.back()->mrSdrModel
, 1440 );
3374 SdrObject
* XclImpDffConverter::CreateSdrObject( const XclImpTbxObjBase
& rTbxObj
, const Rectangle
& rAnchorRect
)
3376 SdrObjectPtr xSdrObj
;
3378 OUString aServiceName
= rTbxObj
.GetServiceName();
3379 if( SupportsOleObjects() && !aServiceName
.isEmpty() ) try
3381 // create the form control from scratch
3382 Reference
< XFormComponent
> xFormComp( ScfApiHelper::CreateInstance( GetDocShell(), aServiceName
), UNO_QUERY_THROW
);
3383 // set controls form, needed in virtual function InsertControl()
3385 // try to insert the control into the form
3386 ::com::sun::star::awt::Size aDummySize
;
3387 Reference
< XShape
> xShape
;
3388 XclImpDffConvData
& rConvData
= GetConvData();
3389 if( rConvData
.mxCtrlForm
.is() && InsertControl( xFormComp
, aDummySize
, &xShape
, true ) )
3391 xSdrObj
.reset( rTbxObj
.CreateSdrObjectFromShape( xShape
, rAnchorRect
) );
3392 // try to attach a macro to the control
3393 ScriptEventDescriptor aDescriptor
;
3394 if( (rConvData
.mnLastCtrlIndex
>= 0) && rTbxObj
.FillMacroDescriptor( aDescriptor
) )
3396 Reference
< XEventAttacherManager
> xEventMgr( rConvData
.mxCtrlForm
, UNO_QUERY_THROW
);
3397 xEventMgr
->registerScriptEvent( rConvData
.mnLastCtrlIndex
, aDescriptor
);
3401 catch( const Exception
& )
3405 return xSdrObj
.release();
3408 SdrObject
* XclImpDffConverter::CreateSdrObject( const XclImpPictureObj
& rPicObj
, const Rectangle
& rAnchorRect
)
3410 SdrObjectPtr xSdrObj
;
3412 if( SupportsOleObjects() )
3414 if( rPicObj
.IsOcxControl() )
3416 if( mxCtlsStrm
.Is() ) try
3418 /* set controls form, needed in virtual function InsertControl()
3419 called from ReadOCXExcelKludgeStream() */
3422 // read from mxCtlsStrm into xShape, insert the control model into the form
3423 Reference
< XShape
> xShape
;
3424 if( GetConvData().mxCtrlForm
.is() )
3426 Reference
< XFormComponent
> xFComp
;
3427 com::sun::star::awt::Size aSz
; // not used in import
3428 ReadOCXCtlsStream( mxCtlsStrm
, xFComp
, rPicObj
.GetCtlsStreamPos(), rPicObj
.GetCtlsStreamSize() );
3429 // recreate the method formally known as
3430 // ReadOCXExcelKludgeStream( )
3433 ScfPropertySet
aPropSet( xFComp
);
3434 aPropSet
.SetStringProperty( "Name", rPicObj
.GetObjName() );
3435 InsertControl( xFComp
, aSz
,&xShape
,true);
3436 xSdrObj
.reset( rPicObj
.CreateSdrObjectFromShape( xShape
, rAnchorRect
) );
3440 catch( const Exception
& )
3446 SfxObjectShell
* pDocShell
= GetDocShell();
3447 tools::SvRef
<SotStorage
> xSrcStrg
= GetRootStorage();
3448 OUString aStrgName
= rPicObj
.GetOleStorageName();
3449 if( pDocShell
&& xSrcStrg
.Is() && (!aStrgName
.isEmpty()) )
3451 // first try to resolve graphic from DFF storage
3454 if( !GetBLIP( GetPropertyValue( DFF_Prop_pib
), aGraphic
, &aVisArea
) )
3456 // if not found, use graphic from object (imported from IMGDATA record)
3457 aGraphic
= rPicObj
.GetGraphic();
3458 aVisArea
= rPicObj
.GetVisArea();
3460 if( aGraphic
.GetType() != GRAPHIC_NONE
)
3462 ErrCode nError
= ERRCODE_NONE
;
3463 namespace cssea
= ::com::sun::star::embed::Aspects
;
3464 sal_Int64 nAspects
= rPicObj
.IsSymbol() ? cssea::MSOLE_ICON
: cssea::MSOLE_CONTENT
;
3465 xSdrObj
.reset( CreateSdrOLEFromStorage(
3466 aStrgName
, xSrcStrg
, pDocShell
->GetStorage(), aGraphic
,
3467 rAnchorRect
, aVisArea
, 0, nError
, mnOleImpFlags
, nAspects
) );
3473 return xSdrObj
.release();
3476 bool XclImpDffConverter::SupportsOleObjects() const
3478 return GetConvData().mrDrawing
.SupportsOleObjects();
3481 // virtual functions ----------------------------------------------------------
3483 void XclImpDffConverter::ProcessClientAnchor2( SvStream
& rDffStrm
,
3484 DffRecordHeader
& rHeader
, void* /*pClientData*/, DffObjData
& rObjData
)
3486 // find the OBJ record data related to the processed shape
3487 XclImpDffConvData
& rConvData
= GetConvData();
3488 if( XclImpDrawObjBase
* pDrawObj
= rConvData
.mrDrawing
.FindDrawObj( rObjData
.rSpHd
).get() )
3490 OSL_ENSURE( rHeader
.nRecType
== DFF_msofbtClientAnchor
, "XclImpDffConverter::ProcessClientAnchor2 - no client anchor record" );
3491 XclObjAnchor aAnchor
;
3492 rHeader
.SeekToContent( rDffStrm
);
3493 sal_uInt8
nFlags(0);
3494 rDffStrm
.ReadUChar( nFlags
);
3495 rDffStrm
.SeekRel( 1 ); // flags
3496 rDffStrm
>> aAnchor
; // anchor format equal to BIFF5 OBJ records
3498 pDrawObj
->SetAnchor( aAnchor
);
3499 rObjData
.aChildAnchor
= rConvData
.mrDrawing
.CalcAnchorRect( aAnchor
, true );
3500 rObjData
.bChildAnchor
= true;
3501 // page anchoring is the best approximation we have if mbMove
3503 rObjData
.bPageAnchor
= ( nFlags
& 0x1 );
3507 SdrObject
* XclImpDffConverter::ProcessObj( SvStream
& rDffStrm
, DffObjData
& rDffObjData
,
3508 void* pClientData
, Rectangle
& /*rTextRect*/, SdrObject
* pOldSdrObj
)
3510 XclImpDffConvData
& rConvData
= GetConvData();
3512 /* pOldSdrObj passes a generated SdrObject. This function owns this object
3513 and can modify it. The function has either to return it back to caller
3514 or to delete it by itself. */
3515 SdrObjectPtr
xSdrObj( pOldSdrObj
);
3517 // find the OBJ record data related to the processed shape
3518 XclImpDrawObjRef xDrawObj
= rConvData
.mrDrawing
.FindDrawObj( rDffObjData
.rSpHd
);
3519 const Rectangle
& rAnchorRect
= rDffObjData
.aChildAnchor
;
3521 // Do not process the global page group shape (flag SP_FPATRIARCH)
3522 bool bGlobalPageGroup
= ::get_flag
< sal_uInt32
>( rDffObjData
.nSpFlags
, SP_FPATRIARCH
);
3523 if( !xDrawObj
|| !xDrawObj
->IsProcessSdrObj() || bGlobalPageGroup
)
3524 return 0; // simply return, xSdrObj will be destroyed
3526 /* Pass pointer to top-level object back to caller. If the processed
3527 object is embedded in a group, the pointer is already set to the
3528 top-level parent object. */
3529 XclImpDrawObjBase
** ppTopLevelObj
= static_cast< XclImpDrawObjBase
** >( pClientData
);
3530 bool bIsTopLevel
= !ppTopLevelObj
|| !*ppTopLevelObj
;
3531 if( ppTopLevelObj
&& bIsTopLevel
)
3532 *ppTopLevelObj
= xDrawObj
.get();
3534 // connectors don't have to be area objects
3535 if( dynamic_cast< SdrEdgeObj
* >( xSdrObj
.get() ) )
3536 xDrawObj
->SetAreaObj( false );
3538 /* Check for valid size for all objects. Needed to ignore lots of invisible
3539 phantom objects from deleted rows or columns (for performance reasons).
3540 #i30816# Include objects embedded in groups.
3541 #i58780# Ignore group shapes, size is not initialized. */
3542 bool bEmbeddedGroup
= !bIsTopLevel
&& dynamic_cast< SdrObjGroup
* >( xSdrObj
.get() );
3543 if( !bEmbeddedGroup
&& !xDrawObj
->IsValidSize( rAnchorRect
) )
3544 return 0; // simply return, xSdrObj will be destroyed
3546 // set shape information from DFF stream
3547 OUString aObjName
= GetPropertyString( DFF_Prop_wzName
, rDffStrm
);
3548 OUString aHyperlink
= ReadHlinkProperty( rDffStrm
);
3549 bool bVisible
= !GetPropertyBool( DFF_Prop_fHidden
);
3550 bool bAutoMargin
= GetPropertyBool( DFF_Prop_AutoTextMargin
);
3551 xDrawObj
->SetDffData( rDffObjData
, aObjName
, aHyperlink
, bVisible
, bAutoMargin
);
3553 /* Connect textbox data (string, alignment, text orientation) to object.
3554 don't ask for a text-ID, DFF export doesn't set one. */
3555 if( XclImpTextObj
* pTextObj
= dynamic_cast< XclImpTextObj
* >( xDrawObj
.get() ) )
3556 if( const XclImpObjTextData
* pTextData
= rConvData
.mrDrawing
.FindTextData( rDffObjData
.rSpHd
) )
3557 pTextObj
->SetTextData( *pTextData
);
3559 // copy line and fill formatting of TBX form controls from DFF properties
3560 if( XclImpTbxObjBase
* pTbxObj
= dynamic_cast< XclImpTbxObjBase
* >( xDrawObj
.get() ) )
3561 pTbxObj
->SetDffProperties( *this );
3563 // try to create a custom SdrObject that overwrites the passed object
3564 SdrObjectPtr
xNewSdrObj( xDrawObj
->CreateSdrObject( *this, rAnchorRect
, true ) );
3566 xSdrObj
.reset( xNewSdrObj
.release() );
3568 // process the SdrObject
3572 if ( !rDffObjData
.bPageAnchor
)
3573 ScDrawLayer::SetCellAnchoredFromPosition( *xSdrObj
, GetDoc(), xDrawObj
->GetTab() );
3575 // filled without color -> set system window color
3576 if( GetPropertyBool( DFF_Prop_fFilled
) && !IsProperty( DFF_Prop_fillColor
) )
3577 xSdrObj
->SetMergedItem( XFillColorItem( EMPTY_OUSTRING
, GetPalette().GetColor( EXC_COLOR_WINDOWBACK
) ) );
3579 // additional processing on the SdrObject
3580 xDrawObj
->PreProcessSdrObject( *this, *xSdrObj
);
3582 /* If the SdrObject will not be inserted into the draw page, delete it
3583 here. Happens e.g. for notes: The PreProcessSdrObject() call above
3584 has inserted the note into the document, and the SdrObject is not
3586 if( !xDrawObj
->IsInsertSdrObj() )
3592 /* Store the relation between shape ID and SdrObject for connectors.
3593 Must be done here (and not in InsertSdrObject() function),
3594 otherwise all SdrObjects embedded in groups would be lost. */
3595 rConvData
.maSolverCont
.InsertSdrObjectInfo( *xSdrObj
, xDrawObj
->GetDffShapeId(), xDrawObj
->GetDffFlags() );
3597 /* If the drawing object is embedded in a group object, call
3598 PostProcessSdrObject() here. For top-level objects this will be
3599 done automatically in InsertSdrObject() but grouped shapes are
3600 inserted into their groups somewhere in the SvxMSDffManager base
3601 class without chance of notification. Unfortunately, now this is
3602 called before the object is really inserted into its group object,
3603 but that should not have any effect for grouped objects. */
3605 xDrawObj
->PostProcessSdrObject( *this, *xSdrObj
);
3608 return xSdrObj
.release();
3611 bool XclImpDffConverter::InsertControl( const Reference
< XFormComponent
>& rxFormComp
,
3612 const ::com::sun::star::awt::Size
& /*rSize*/, Reference
< XShape
>* pxShape
,
3613 bool /*bFloatingCtrl*/ )
3615 if( GetDocShell() ) try
3617 XclImpDffConvData
& rConvData
= GetConvData();
3618 Reference
< XIndexContainer
> xFormIC( rConvData
.mxCtrlForm
, UNO_QUERY_THROW
);
3619 Reference
< XControlModel
> xCtrlModel( rxFormComp
, UNO_QUERY_THROW
);
3621 // create the control shape
3622 Reference
< XShape
> xShape( ScfApiHelper::CreateInstance( GetDocShell(), "com.sun.star.drawing.ControlShape" ), UNO_QUERY_THROW
);
3623 Reference
< XControlShape
> xCtrlShape( xShape
, UNO_QUERY_THROW
);
3625 // insert the new control into the form
3626 sal_Int32 nNewIndex
= xFormIC
->getCount();
3627 xFormIC
->insertByIndex( nNewIndex
, Any( rxFormComp
) );
3628 // on success: store new index of the control for later use (macro events)
3629 rConvData
.mnLastCtrlIndex
= nNewIndex
;
3631 // set control model at control shape and pass back shape to caller
3632 xCtrlShape
->setControl( xCtrlModel
);
3633 if( pxShape
) *pxShape
= xShape
;
3636 catch( const Exception
& )
3638 OSL_FAIL( "XclImpDffConverter::InsertControl - cannot create form control" );
3644 // private --------------------------------------------------------------------
3646 XclImpDffConverter::XclImpDffConvData
& XclImpDffConverter::GetConvData()
3648 OSL_ENSURE( !maDataStack
.empty(), "XclImpDffConverter::GetConvData - no drawing manager on stack" );
3649 return *maDataStack
.back();
3652 const XclImpDffConverter::XclImpDffConvData
& XclImpDffConverter::GetConvData() const
3654 OSL_ENSURE( !maDataStack
.empty(), "XclImpDffConverter::GetConvData - no drawing manager on stack" );
3655 return *maDataStack
.back();
3658 OUString
XclImpDffConverter::ReadHlinkProperty( SvStream
& rDffStrm
) const
3660 /* Reads hyperlink data from a complex DFF property. Contents of this
3661 property are equal to the HLINK record, import of this record is
3662 implemented in class XclImpHyperlink. This function has to create an
3663 instance of the XclImpStream class to be able to reuse the
3664 functionality of XclImpHyperlink. */
3666 sal_uInt32 nBufferSize
= GetPropertyValue( DFF_Prop_pihlShape
);
3667 if( (0 < nBufferSize
) && (nBufferSize
<= 0xFFFF) && SeekToContent( DFF_Prop_pihlShape
, rDffStrm
) )
3669 // create a faked BIFF record that can be read by XclImpStream class
3670 SvMemoryStream aMemStream
;
3671 aMemStream
.WriteUInt16( 0 ).WriteUInt16( nBufferSize
);
3673 // copy from DFF stream to memory stream
3674 ::std::vector
< sal_uInt8
> aBuffer( nBufferSize
);
3675 sal_uInt8
* pnData
= &aBuffer
.front();
3676 if( rDffStrm
.Read( pnData
, nBufferSize
) == nBufferSize
)
3678 aMemStream
.Write( pnData
, nBufferSize
);
3680 // create BIFF import stream to be able to use XclImpHyperlink class
3681 XclImpStream
aXclStrm( aMemStream
, GetRoot() );
3682 if( aXclStrm
.StartNextRecord() )
3683 aString
= XclImpHyperlink::ReadEmbeddedData( aXclStrm
);
3689 void XclImpDffConverter::ProcessDgContainer( SvStream
& rDffStrm
, const DffRecordHeader
& rDgHeader
)
3691 sal_Size nEndPos
= rDgHeader
.GetRecEndFilePos();
3692 while( rDffStrm
.Tell() < nEndPos
)
3694 DffRecordHeader aHeader
;
3695 ReadDffRecordHeader( rDffStrm
, aHeader
);
3696 switch( aHeader
.nRecType
)
3698 case DFF_msofbtSolverContainer
:
3699 ProcessSolverContainer( rDffStrm
, aHeader
);
3701 case DFF_msofbtSpgrContainer
:
3702 ProcessShGrContainer( rDffStrm
, aHeader
);
3705 aHeader
.SeekToEndOfRecord( rDffStrm
);
3708 // seek to end of drawing page container
3709 rDgHeader
.SeekToEndOfRecord( rDffStrm
);
3711 // #i12638# #i37900# connector rules
3712 XclImpSolverContainer
& rSolverCont
= GetConvData().maSolverCont
;
3713 rSolverCont
.UpdateConnectorRules();
3714 SolveSolver( rSolverCont
);
3715 rSolverCont
.RemoveConnectorRules();
3718 void XclImpDffConverter::ProcessShGrContainer( SvStream
& rDffStrm
, const DffRecordHeader
& rShGrHeader
)
3720 sal_Size nEndPos
= rShGrHeader
.GetRecEndFilePos();
3721 while( rDffStrm
.Tell() < nEndPos
)
3723 DffRecordHeader aHeader
;
3724 ReadDffRecordHeader( rDffStrm
, aHeader
);
3725 switch( aHeader
.nRecType
)
3727 case DFF_msofbtSpgrContainer
:
3728 case DFF_msofbtSpContainer
:
3729 ProcessShContainer( rDffStrm
, aHeader
);
3732 aHeader
.SeekToEndOfRecord( rDffStrm
);
3735 // seek to end of shape group container
3736 rShGrHeader
.SeekToEndOfRecord( rDffStrm
);
3739 void XclImpDffConverter::ProcessSolverContainer( SvStream
& rDffStrm
, const DffRecordHeader
& rSolverHeader
)
3741 // solver container wants to read the solver container header again
3742 rSolverHeader
.SeekToBegOfRecord( rDffStrm
);
3743 // read the entire solver container
3744 ReadSvxMSDffSolverContainer( rDffStrm
, GetConvData().maSolverCont
);
3745 // seek to end of solver container
3746 rSolverHeader
.SeekToEndOfRecord( rDffStrm
);
3749 void XclImpDffConverter::ProcessShContainer( SvStream
& rDffStrm
, const DffRecordHeader
& rShHeader
)
3751 rShHeader
.SeekToBegOfRecord( rDffStrm
);
3753 const XclImpDrawObjBase
* pDrawObj
= 0;
3754 /* The call to ImportObj() creates and returns a new SdrObject for the
3755 processed shape. We take ownership of the returned object here. If the
3756 shape is a group object, all embedded objects are created recursively,
3757 and the returned group object contains them all. ImportObj() calls the
3758 virtual functions ProcessClientAnchor2() and ProcessObj() and writes
3759 the pointer to the related draw object data (OBJ record) into pDrawObj. */
3760 SdrObjectPtr
xSdrObj( ImportObj( rDffStrm
, &pDrawObj
, aDummy
, aDummy
, 0, 0 ) );
3761 if( pDrawObj
&& xSdrObj
)
3762 InsertSdrObject( GetConvData().mrSdrPage
, *pDrawObj
, xSdrObj
.release() );
3763 rShHeader
.SeekToEndOfRecord( rDffStrm
);
3766 void XclImpDffConverter::InsertSdrObject( SdrObjList
& rObjList
, const XclImpDrawObjBase
& rDrawObj
, SdrObject
* pSdrObj
)
3768 XclImpDffConvData
& rConvData
= GetConvData();
3769 /* Take ownership of the passed object. If insertion fails (e.g. rDrawObj
3770 states to skip insertion), the object is automatically deleted. */
3771 SdrObjectPtr
xSdrObj( pSdrObj
);
3772 if( xSdrObj
&& rDrawObj
.IsInsertSdrObj() )
3774 rObjList
.NbcInsertObject( xSdrObj
.release() );
3775 // callback to drawing manager for e.g. tracking of used sheet area
3776 rConvData
.mrDrawing
.OnObjectInserted( rDrawObj
);
3777 // callback to drawing object for post processing (use pSdrObj, xSdrObj already released)
3778 rDrawObj
.PostProcessSdrObject( *this, *pSdrObj
);
3780 /* SdrObject still here? Insertion failed, remove data from shape ID map.
3781 The SdrObject will be destructed then. */
3783 rConvData
.maSolverCont
.RemoveSdrObjectInfo( *xSdrObj
);
3786 void XclImpDffConverter::InitControlForm()
3788 XclImpDffConvData
& rConvData
= GetConvData();
3789 if( rConvData
.mbHasCtrlForm
)
3792 rConvData
.mbHasCtrlForm
= true;
3793 if( SupportsOleObjects() ) try
3795 Reference
< XFormsSupplier
> xFormsSupplier( rConvData
.mrSdrPage
.getUnoPage(), UNO_QUERY_THROW
);
3796 Reference
< XNameContainer
> xFormsNC( xFormsSupplier
->getForms(), UNO_SET_THROW
);
3797 // find or create the Standard form used to insert the imported controls
3798 if( xFormsNC
->hasByName( maStdFormName
) )
3800 xFormsNC
->getByName( maStdFormName
) >>= rConvData
.mxCtrlForm
;
3802 else if( SfxObjectShell
* pDocShell
= GetDocShell() )
3804 rConvData
.mxCtrlForm
.set( ScfApiHelper::CreateInstance( pDocShell
, "com.sun.star.form.component.Form" ), UNO_QUERY_THROW
);
3805 xFormsNC
->insertByName( maStdFormName
, Any( rConvData
.mxCtrlForm
) );
3808 catch( const Exception
& )
3813 // Drawing manager ============================================================
3815 XclImpDrawing::XclImpDrawing( const XclImpRoot
& rRoot
, bool bOleObjects
) :
3816 XclImpRoot( rRoot
),
3817 mbOleObjs( bOleObjects
)
3821 XclImpDrawing::~XclImpDrawing()
3825 Graphic
XclImpDrawing::ReadImgData( const XclImpRoot
& rRoot
, XclImpStream
& rStrm
)
3828 sal_uInt16 nFormat
= rStrm
.ReaduInt16();
3829 rStrm
.Ignore( 2 );//nEnv
3830 sal_uInt32 nDataSize
= rStrm
.ReaduInt32();
3831 if( nDataSize
<= rStrm
.GetRecLeft() )
3835 case EXC_IMGDATA_WMF
: ReadWmf( aGraphic
, rRoot
, rStrm
); break;
3836 case EXC_IMGDATA_BMP
: ReadBmp( aGraphic
, rRoot
, rStrm
); break;
3837 default: OSL_FAIL( "XclImpDrawing::ReadImgData - unknown image format" );
3843 void XclImpDrawing::ReadObj( XclImpStream
& rStrm
)
3845 XclImpDrawObjRef xDrawObj
;
3847 /* #i61786# In BIFF8 streams, OBJ records may occur without MSODRAWING
3848 records. In this case, the OBJ records are in BIFF5 format. Do a sanity
3849 check here that there is no DFF data loaded before. */
3850 OSL_ENSURE( maDffStrm
.Tell() == 0, "XclImpDrawing::ReadObj - unexpected DFF stream data, OBJ will be ignored" );
3851 if( maDffStrm
.Tell() == 0 ) switch( GetBiff() )
3854 xDrawObj
= XclImpDrawObjBase::ReadObj3( GetRoot(), rStrm
);
3857 xDrawObj
= XclImpDrawObjBase::ReadObj4( GetRoot(), rStrm
);
3861 xDrawObj
= XclImpDrawObjBase::ReadObj5( GetRoot(), rStrm
);
3869 // insert into maRawObjs or into the last open group object
3870 maRawObjs
.InsertGrouped( xDrawObj
);
3871 // to be able to find objects by ID
3872 maObjMapId
[ xDrawObj
->GetObjId() ] = xDrawObj
;
3876 void XclImpDrawing::ReadMsoDrawing( XclImpStream
& rStrm
)
3878 OSL_ENSURE_BIFF( GetBiff() == EXC_BIFF8
);
3879 // disable internal CONTINUE handling
3880 rStrm
.ResetRecord( false );
3881 // read leading MSODRAWING record
3882 ReadDffRecord( rStrm
);
3884 // read following drawing records, but do not start following unrelated record
3886 while( bLoop
) switch( rStrm
.GetNextRecId() )
3888 case EXC_ID_MSODRAWING
:
3889 case EXC_ID_MSODRAWINGSEL
:
3891 rStrm
.StartNextRecord();
3892 ReadDffRecord( rStrm
);
3895 rStrm
.StartNextRecord();
3899 rStrm
.StartNextRecord();
3906 // re-enable internal CONTINUE handling
3907 rStrm
.ResetRecord( true );
3910 XclImpDrawObjRef
XclImpDrawing::FindDrawObj( const DffRecordHeader
& rHeader
) const
3912 /* maObjMap stores objects by position of the client data (OBJ record) in
3913 the DFF stream, which is always behind shape start position of the
3914 passed header. The function upper_bound() finds the first element in
3915 the map whose key is greater than the start position of the header. Its
3916 end position is used to test whether the found object is really related
3918 XclImpDrawObjRef xDrawObj
;
3919 XclImpObjMap::const_iterator aIt
= maObjMap
.upper_bound( rHeader
.GetRecBegFilePos() );
3920 if( (aIt
!= maObjMap
.end()) && (aIt
->first
<= rHeader
.GetRecEndFilePos()) )
3921 xDrawObj
= aIt
->second
;
3925 XclImpDrawObjRef
XclImpDrawing::FindDrawObj( sal_uInt16 nObjId
) const
3927 XclImpDrawObjRef xDrawObj
;
3928 XclImpObjMapById::const_iterator aIt
= maObjMapId
.find( nObjId
);
3929 if( aIt
!= maObjMapId
.end() )
3930 xDrawObj
= aIt
->second
;
3934 const XclImpObjTextData
* XclImpDrawing::FindTextData( const DffRecordHeader
& rHeader
) const
3936 /* maTextMap stores textbox data by position of the client data (TXO
3937 record) in the DFF stream, which is always behind shape start position
3938 of the passed header. The function upper_bound() finds the first
3939 element in the map whose key is greater than the start position of the
3940 header. Its end position is used to test whether the found object is
3941 really related to the shape. */
3942 XclImpObjTextMap::const_iterator aIt
= maTextMap
.upper_bound( rHeader
.GetRecBegFilePos() );
3943 if( (aIt
!= maTextMap
.end()) && (aIt
->first
<= rHeader
.GetRecEndFilePos()) )
3944 return aIt
->second
.get();
3948 void XclImpDrawing::SetSkipObj( sal_uInt16 nObjId
)
3950 maSkipObjs
.push_back( nObjId
);
3953 sal_Size
XclImpDrawing::GetProgressSize() const
3955 sal_Size nProgressSize
= maRawObjs
.GetProgressSize();
3956 for( XclImpObjMap::const_iterator aIt
= maObjMap
.begin(), aEnd
= maObjMap
.end(); aIt
!= aEnd
; ++aIt
)
3957 nProgressSize
+= aIt
->second
->GetProgressSize();
3958 return nProgressSize
;
3961 void XclImpDrawing::ImplConvertObjects( XclImpDffConverter
& rDffConv
, SdrModel
& rSdrModel
, SdrPage
& rSdrPage
)
3963 //rhbz#636521, disable undo during conversion. faster, smaller and stops
3964 //temp objects being inserted into the undo list
3965 bool bOrigUndoStatus
= rSdrModel
.IsUndoEnabled();
3966 rSdrModel
.EnableUndo(false);
3967 // register this drawing manager at the passed (global) DFF manager
3968 rDffConv
.InitializeDrawing( *this, rSdrModel
, rSdrPage
);
3969 // process list of objects to be skipped
3970 for( ScfUInt16Vec::const_iterator aIt
= maSkipObjs
.begin(), aEnd
= maSkipObjs
.end(); aIt
!= aEnd
; ++aIt
)
3971 if( XclImpDrawObjBase
* pDrawObj
= FindDrawObj( *aIt
).get() )
3972 pDrawObj
->SetProcessSdrObj( false );
3973 // process drawing objects without DFF data
3974 rDffConv
.ProcessDrawing( maRawObjs
);
3975 // process all objects in the DFF stream
3976 rDffConv
.ProcessDrawing( maDffStrm
);
3977 // unregister this drawing manager at the passed (global) DFF manager
3978 rDffConv
.FinalizeDrawing();
3979 rSdrModel
.EnableUndo(bOrigUndoStatus
);
3982 // protected ------------------------------------------------------------------
3984 void XclImpDrawing::AppendRawObject( const XclImpDrawObjRef
& rxDrawObj
)
3986 OSL_ENSURE( rxDrawObj
, "XclImpDrawing::AppendRawObject - unexpected empty reference" );
3987 maRawObjs
.push_back( rxDrawObj
);
3990 // private --------------------------------------------------------------------
3992 void XclImpDrawing::ReadWmf( Graphic
& rGraphic
, const XclImpRoot
&, XclImpStream
& rStrm
) // static helper
3994 // extract graphic data from IMGDATA and following CONTINUE records
3996 SvMemoryStream aMemStrm
;
3997 rStrm
.CopyToStream( aMemStrm
, rStrm
.GetRecLeft() );
3998 aMemStrm
.Seek( STREAM_SEEK_TO_BEGIN
);
3999 // import the graphic from memory stream
4000 GDIMetaFile aGDIMetaFile
;
4001 if( ::ReadWindowMetafile( aMemStrm
, aGDIMetaFile
, 0 ) )
4002 rGraphic
= aGDIMetaFile
;
4005 void XclImpDrawing::ReadBmp( Graphic
& rGraphic
, const XclImpRoot
& rRoot
, XclImpStream
& rStrm
) // static helper
4007 // extract graphic data from IMGDATA and following CONTINUE records
4008 SvMemoryStream aMemStrm
;
4010 /* Excel 3 and 4 seem to write broken BMP data. Usually they write a
4011 DIBCOREHEADER (12 bytes) containing width, height, planes = 1, and
4012 pixel depth = 32 bit. After that, 3 unused bytes are added before the
4013 actual pixel data. This does even confuse Excel 5 and later, which
4014 cannot read the image data correctly. */
4015 if( rRoot
.GetBiff() <= EXC_BIFF4
)
4017 rStrm
.PushPosition();
4018 sal_uInt32 nHdrSize
;
4019 sal_uInt16 nWidth
, nHeight
, nPlanes
, nDepth
;
4020 nHdrSize
= rStrm
.ReaduInt32();
4021 nWidth
= rStrm
.ReaduInt16();
4022 nHeight
= rStrm
.ReaduInt16();
4023 nPlanes
= rStrm
.ReaduInt16();
4024 nDepth
= rStrm
.ReaduInt16();
4025 if( (nHdrSize
== 12) && (nPlanes
== 1) && (nDepth
== 32) )
4028 aMemStrm
.SetEndian( SvStreamEndian::LITTLE
);
4029 aMemStrm
.WriteUInt32( nHdrSize
).WriteUInt16( nWidth
).WriteUInt16( nHeight
).WriteUInt16( nPlanes
).WriteUInt16( nDepth
);
4030 rStrm
.CopyToStream( aMemStrm
, rStrm
.GetRecLeft() );
4032 rStrm
.PopPosition();
4035 // no special handling above -> just copy the remaining record data
4036 if( aMemStrm
.Tell() == 0 )
4037 rStrm
.CopyToStream( aMemStrm
, rStrm
.GetRecLeft() );
4039 // import the graphic from memory stream
4040 aMemStrm
.Seek( STREAM_SEEK_TO_BEGIN
);
4042 if( ReadDIB(aBitmap
, aMemStrm
, false) ) // read DIB without file header
4046 void XclImpDrawing::ReadDffRecord( XclImpStream
& rStrm
)
4048 maDffStrm
.Seek( STREAM_SEEK_TO_END
);
4049 rStrm
.CopyRecordToStream( maDffStrm
);
4052 void XclImpDrawing::ReadObj8( XclImpStream
& rStrm
)
4054 XclImpDrawObjRef xDrawObj
= XclImpDrawObjBase::ReadObj8( GetRoot(), rStrm
);
4055 // store the new object in the internal containers
4056 maObjMap
[ maDffStrm
.Tell() ] = xDrawObj
;
4057 maObjMapId
[ xDrawObj
->GetObjId() ] = xDrawObj
;
4060 void XclImpDrawing::ReadTxo( XclImpStream
& rStrm
)
4062 XclImpObjTextRef
xTextData( new XclImpObjTextData
);
4063 maTextMap
[ maDffStrm
.Tell() ] = xTextData
;
4065 // 1) read the TXO record
4066 xTextData
->maData
.ReadTxo8( rStrm
);
4068 // 2) first CONTINUE with string
4069 xTextData
->mxString
.reset();
4071 if( xTextData
->maData
.mnTextLen
> 0 )
4073 bValid
= (rStrm
.GetNextRecId() == EXC_ID_CONT
) && rStrm
.StartNextRecord();
4074 OSL_ENSURE( bValid
, "XclImpDrawing::ReadTxo - missing CONTINUE record" );
4076 xTextData
->mxString
.reset( new XclImpString( rStrm
.ReadUniString( xTextData
->maData
.mnTextLen
) ) );
4079 // 3) second CONTINUE with formatting runs
4080 if( xTextData
->maData
.mnFormatSize
> 0 )
4082 bValid
= (rStrm
.GetNextRecId() == EXC_ID_CONT
) && rStrm
.StartNextRecord();
4083 OSL_ENSURE( bValid
, "XclImpDrawing::ReadTxo - missing CONTINUE record" );
4085 xTextData
->ReadFormats( rStrm
);
4089 XclImpSheetDrawing::XclImpSheetDrawing( const XclImpRoot
& rRoot
, SCTAB nScTab
) :
4090 XclImpDrawing( rRoot
, true ),
4091 maScUsedArea( ScAddress::INITIALIZE_INVALID
)
4093 maScUsedArea
.aStart
.SetTab( nScTab
);
4094 maScUsedArea
.aEnd
.SetTab( nScTab
);
4097 void XclImpSheetDrawing::ReadNote( XclImpStream
& rStrm
)
4115 void XclImpSheetDrawing::ReadTabChart( XclImpStream
& rStrm
)
4117 OSL_ENSURE_BIFF( GetBiff() >= EXC_BIFF5
);
4118 boost::shared_ptr
< XclImpChartObj
> xChartObj( new XclImpChartObj( GetRoot(), true ) );
4119 xChartObj
->ReadChartSubStream( rStrm
);
4120 // insert the chart as raw object without connected DFF data
4121 AppendRawObject( xChartObj
);
4124 void XclImpSheetDrawing::ConvertObjects( XclImpDffConverter
& rDffConv
)
4126 if( SdrModel
* pSdrModel
= GetDoc().GetDrawLayer() )
4127 if( SdrPage
* pSdrPage
= GetSdrPage( maScUsedArea
.aStart
.Tab() ) )
4128 ImplConvertObjects( rDffConv
, *pSdrModel
, *pSdrPage
);
4131 Rectangle
XclImpSheetDrawing::CalcAnchorRect( const XclObjAnchor
& rAnchor
, bool /*bDffAnchor*/ ) const
4133 return rAnchor
.GetRect( GetRoot(), maScUsedArea
.aStart
.Tab(), MAP_100TH_MM
);
4136 void XclImpSheetDrawing::OnObjectInserted( const XclImpDrawObjBase
& rDrawObj
)
4138 ScRange aScObjArea
= rDrawObj
.GetUsedArea( maScUsedArea
.aStart
.Tab() );
4139 if( aScObjArea
.IsValid() )
4140 maScUsedArea
.ExtendTo( aScObjArea
);
4143 // private --------------------------------------------------------------------
4145 void XclImpSheetDrawing::ReadNote3( XclImpStream
& rStrm
)
4148 sal_uInt16 nTotalLen
;
4150 nTotalLen
= rStrm
.ReaduInt16();
4152 ScAddress
aScNotePos( ScAddress::UNINITIALIZED
);
4153 if( GetAddressConverter().ConvertAddress( aScNotePos
, aXclPos
, maScUsedArea
.aStart
.Tab(), true ) )
4155 sal_uInt16 nPartLen
= ::std::min( nTotalLen
, static_cast< sal_uInt16
>( rStrm
.GetRecLeft() ) );
4156 OUString aNoteText
= rStrm
.ReadRawByteString( nPartLen
);
4157 nTotalLen
= nTotalLen
- nPartLen
;
4158 while( (nTotalLen
> 0) && (rStrm
.GetNextRecId() == EXC_ID_NOTE
) && rStrm
.StartNextRecord() )
4161 nPartLen
= rStrm
.ReaduInt16();
4162 OSL_ENSURE( aXclPos
.mnRow
== 0xFFFF, "XclImpObjectManager::ReadNote3 - missing continuation NOTE record" );
4163 if( aXclPos
.mnRow
== 0xFFFF )
4165 OSL_ENSURE( nPartLen
<= nTotalLen
, "XclImpObjectManager::ReadNote3 - string too long" );
4166 aNoteText
+= rStrm
.ReadRawByteString( nPartLen
);
4167 nTotalLen
= nTotalLen
- ::std::min( nTotalLen
, nPartLen
);
4171 // seems to be a new note, record already started -> load the note
4172 rStrm
.Seek( EXC_REC_SEEK_TO_BEGIN
);
4177 ScNoteUtil::CreateNoteFromString( GetDoc(), aScNotePos
, aNoteText
, false, false );
4181 void XclImpSheetDrawing::ReadNote8( XclImpStream
& rStrm
)
4184 sal_uInt16 nFlags
, nObjId
;
4186 nFlags
= rStrm
.ReaduInt16();
4187 nObjId
= rStrm
.ReaduInt16();
4189 ScAddress
aScNotePos( ScAddress::UNINITIALIZED
);
4190 if( GetAddressConverter().ConvertAddress( aScNotePos
, aXclPos
, maScUsedArea
.aStart
.Tab(), true ) )
4191 if( nObjId
!= EXC_OBJ_INVALID_ID
)
4192 if( XclImpNoteObj
* pNoteObj
= dynamic_cast< XclImpNoteObj
* >( FindDrawObj( nObjId
).get() ) )
4193 pNoteObj
->SetNoteData( aScNotePos
, nFlags
);
4196 // The object manager =========================================================
4198 XclImpObjectManager::XclImpObjectManager( const XclImpRoot
& rRoot
) :
4201 maDefObjNames
[ EXC_OBJTYPE_GROUP
] = "Group";
4202 maDefObjNames
[ EXC_OBJTYPE_LINE
] = ScGlobal::GetRscString( STR_SHAPE_LINE
);
4203 maDefObjNames
[ EXC_OBJTYPE_RECTANGLE
] = ScGlobal::GetRscString( STR_SHAPE_RECTANGLE
);
4204 maDefObjNames
[ EXC_OBJTYPE_OVAL
] = ScGlobal::GetRscString( STR_SHAPE_OVAL
);
4205 maDefObjNames
[ EXC_OBJTYPE_ARC
] = "Arc";
4206 maDefObjNames
[ EXC_OBJTYPE_CHART
] = "Chart";
4207 maDefObjNames
[ EXC_OBJTYPE_TEXT
] = "Text";
4208 maDefObjNames
[ EXC_OBJTYPE_BUTTON
] = ScGlobal::GetRscString( STR_FORM_BUTTON
);
4209 maDefObjNames
[ EXC_OBJTYPE_PICTURE
] = "Picture";
4210 maDefObjNames
[ EXC_OBJTYPE_POLYGON
] = "Freeform";
4211 maDefObjNames
[ EXC_OBJTYPE_CHECKBOX
] = ScGlobal::GetRscString( STR_FORM_CHECKBOX
);
4212 maDefObjNames
[ EXC_OBJTYPE_OPTIONBUTTON
] = ScGlobal::GetRscString( STR_FORM_OPTIONBUTTON
);
4213 maDefObjNames
[ EXC_OBJTYPE_EDIT
] = "Edit Box";
4214 maDefObjNames
[ EXC_OBJTYPE_LABEL
] = ScGlobal::GetRscString( STR_FORM_LABEL
);
4215 maDefObjNames
[ EXC_OBJTYPE_DIALOG
] = "Dialog Frame";
4216 maDefObjNames
[ EXC_OBJTYPE_SPIN
] = ScGlobal::GetRscString( STR_FORM_SPINNER
);
4217 maDefObjNames
[ EXC_OBJTYPE_SCROLLBAR
] = ScGlobal::GetRscString( STR_FORM_SCROLLBAR
);
4218 maDefObjNames
[ EXC_OBJTYPE_LISTBOX
] = ScGlobal::GetRscString( STR_FORM_LISTBOX
);
4219 maDefObjNames
[ EXC_OBJTYPE_GROUPBOX
] = ScGlobal::GetRscString( STR_FORM_GROUPBOX
);
4220 maDefObjNames
[ EXC_OBJTYPE_DROPDOWN
] = ScGlobal::GetRscString( STR_FORM_DROPDOWN
);
4221 maDefObjNames
[ EXC_OBJTYPE_NOTE
] = "Comment";
4222 maDefObjNames
[ EXC_OBJTYPE_DRAWING
] = ScGlobal::GetRscString( STR_SHAPE_AUTOSHAPE
);
4225 XclImpObjectManager::~XclImpObjectManager()
4229 void XclImpObjectManager::ReadMsoDrawingGroup( XclImpStream
& rStrm
)
4231 OSL_ENSURE_BIFF( GetBiff() == EXC_BIFF8
);
4232 // Excel continues this record with MSODRAWINGGROUP and CONTINUE records, hmm.
4233 rStrm
.ResetRecord( true, EXC_ID_MSODRAWINGGROUP
);
4234 maDggStrm
.Seek( STREAM_SEEK_TO_END
);
4235 rStrm
.CopyRecordToStream( maDggStrm
);
4238 XclImpSheetDrawing
& XclImpObjectManager::GetSheetDrawing( SCTAB nScTab
)
4240 XclImpSheetDrawingRef
& rxDrawing
= maSheetDrawings
[ nScTab
];
4242 rxDrawing
.reset( new XclImpSheetDrawing( GetRoot(), nScTab
) );
4246 void XclImpObjectManager::ConvertObjects()
4248 // do nothing if the document does not contain a drawing layer
4249 if( !GetDoc().GetDrawLayer() )
4252 // get total progress bar size for all sheet drawing managers
4253 sal_Size nProgressSize
= 0;
4254 for( XclImpSheetDrawingMap::iterator aIt
= maSheetDrawings
.begin(), aEnd
= maSheetDrawings
.end(); aIt
!= aEnd
; ++aIt
)
4255 nProgressSize
+= aIt
->second
->GetProgressSize();
4256 // nothing to do if progress bar is zero (no objects present)
4257 if( nProgressSize
== 0 )
4260 XclImpDffConverter
aDffConv( GetRoot(), maDggStrm
);
4261 aDffConv
.StartProgressBar( nProgressSize
);
4262 for( XclImpSheetDrawingMap::iterator aIt
= maSheetDrawings
.begin(), aEnd
= maSheetDrawings
.end(); aIt
!= aEnd
; ++aIt
)
4263 aIt
->second
->ConvertObjects( aDffConv
);
4265 // #i112436# don't call ScChartListenerCollection::SetDirty here,
4266 // instead use InterpretDirtyCells in ScDocument::CalcAfterLoad.
4269 OUString
XclImpObjectManager::GetDefaultObjName( const XclImpDrawObjBase
& rDrawObj
) const
4271 OUStringBuffer aDefName
;
4272 DefObjNameMap::const_iterator aIt
= maDefObjNames
.find( rDrawObj
.GetObjType() );
4273 if( aIt
!= maDefObjNames
.end() )
4274 aDefName
.append(aIt
->second
);
4275 return aDefName
.append(' ').append(static_cast<sal_Int32
>(rDrawObj
.GetObjId())).makeStringAndClear();
4278 ScRange
XclImpObjectManager::GetUsedArea( SCTAB nScTab
) const
4280 XclImpSheetDrawingMap::const_iterator aIt
= maSheetDrawings
.find( nScTab
);
4281 if( aIt
!= maSheetDrawings
.end() )
4282 return aIt
->second
->GetUsedArea();
4283 return ScRange( ScAddress::INITIALIZE_INVALID
);
4286 // DFF property set helper ====================================================
4288 XclImpDffPropSet::XclImpDffPropSet( const XclImpRoot
& rRoot
) :
4289 XclImpRoot( rRoot
),
4290 maDffConv( rRoot
, maDummyStrm
)
4294 void XclImpDffPropSet::Read( XclImpStream
& rStrm
)
4296 sal_uInt32 nPropSetSize
;
4298 rStrm
.PushPosition();
4300 nPropSetSize
= rStrm
.ReaduInt32();
4301 rStrm
.PopPosition();
4303 mxMemStrm
.reset( new SvMemoryStream
);
4304 rStrm
.CopyToStream( *mxMemStrm
, 8 + nPropSetSize
);
4305 mxMemStrm
->Seek( STREAM_SEEK_TO_BEGIN
);
4306 maDffConv
.ReadPropSet( *mxMemStrm
, 0 );
4309 sal_uInt32
XclImpDffPropSet::GetPropertyValue( sal_uInt16 nPropId
, sal_uInt32 nDefault
) const
4311 return maDffConv
.GetPropertyValue( nPropId
, nDefault
);
4314 void XclImpDffPropSet::FillToItemSet( SfxItemSet
& rItemSet
) const
4316 if( mxMemStrm
.get() )
4317 maDffConv
.ApplyAttributes( *mxMemStrm
, rItemSet
);
4320 XclImpStream
& operator>>( XclImpStream
& rStrm
, XclImpDffPropSet
& rPropSet
)
4322 rPropSet
.Read( rStrm
);
4326 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */