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 <com/sun/star/embed/NoVisualAreaSizeException.hpp>
21 #include <com/sun/star/embed/Aspects.hpp>
22 #include <com/sun/star/embed/XEmbeddedObject.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <toolkit/helper/vclunohelper.hxx>
27 #include <sot/exchange.hxx>
28 #include <svl/globalnameitem.hxx>
29 #include <sfx2/viewfrm.hxx>
30 #include <svl/stritem.hxx>
31 #include <svx/svdoole2.hxx>
32 #include <unotools/moduleoptions.hxx>
33 #include <svtools/insdlg.hxx>
34 #include <svtools/embedhlp.hxx>
35 #include <svtools/strings.hrc>
36 #include <svtools/svtresid.hxx>
37 #include <svx/svxdlg.hxx>
38 #include <comphelper/classids.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <svx/svdpage.hxx>
41 #include <svx/svdundo.hxx>
42 #include <sfx2/msgpool.hxx>
43 #include <sfx2/msg.hxx>
45 #include <sal/log.hxx>
46 #include <comphelper/diagnose_ex.hxx>
47 #include <vcl/weldutils.hxx>
49 #include <comphelper/lok.hxx>
50 #include <comphelper/storagehelper.hxx>
51 #include <comphelper/propertysequence.hxx>
52 #include <com/sun/star/embed/EmbedVerbs.hpp>
53 #include <com/sun/star/beans/PropertyValue.hpp>
54 #include <com/sun/star/chart2/data/XDataReceiver.hpp>
55 #include <com/sun/star/chart2/XChartDocument.hpp>
56 #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
57 #include <com/sun/star/lang/XInitialization.hpp>
58 #include <com/sun/star/frame/XModel.hpp>
59 #include <com/sun/star/chart/ChartDataRowSource.hpp>
60 #include <cppuhelper/bootstrap.hxx>
61 #include <svtools/dialogclosedlistener.hxx>
62 #include <officecfg/Office/Common.hxx>
64 #include <PivotTableDataProvider.hxx>
65 #include <chart2uno.hxx>
66 #include <fuinsert.hxx>
67 #include <tabvwsh.hxx>
69 #include <chartpos.hxx>
71 #include <document.hxx>
72 #include <undotab.hxx>
73 #include <uiitems.hxx>
74 #include <drawview.hxx>
75 #include <markdata.hxx>
76 #include <dpobject.hxx>
84 void lcl_ChartInit(const uno::Reference
<embed::XEmbeddedObject
>& xObj
, ScViewData
* pViewData
,
85 const OUString
& rRangeParam
, bool bRangeIsPivotTable
)
87 ScDocShell
* pDocShell
= pViewData
->GetDocShell();
88 ScDocument
& rScDoc
= pDocShell
->GetDocument();
90 OUString
aRangeString(rRangeParam
);
92 if (aRangeString
.isEmpty() && !bRangeIsPivotTable
)
101 ScMarkData
& rMark
= pViewData
->GetMarkData();
102 if ( !rMark
.IsMarked() )
103 pViewData
->GetView()->MarkDataArea();
105 if ( pViewData
->GetSimpleArea( nCol1
,nRow1
,nTab1
, nCol2
,nRow2
,nTab2
) == SC_MARK_SIMPLE
)
107 PutInOrder( nCol1
, nCol2
);
108 PutInOrder( nRow1
, nRow2
);
109 if (nCol2
>= nCol1
|| nRow2
>= nRow1
)
111 ScDocument
& rDoc
= pViewData
->GetDocument();
112 rDoc
.LimitChartArea( nTab1
, nCol1
,nRow1
, nCol2
,nRow2
);
114 ScRange
aRange( nCol1
, nRow1
, nTab1
, nCol2
, nRow2
, nTab2
);
115 aRangeString
= aRange
.Format(rScDoc
, ScRefFlags::RANGE_ABS_3D
, rScDoc
.GetAddressConvention());
120 if (aRangeString
.isEmpty())
123 // connect to Calc data (if no range string, leave chart alone, with its own data)
125 uno::Reference
< css::chart2::data::XDataReceiver
> xReceiver
;
127 xReceiver
.set( xObj
->getComponent(), uno::UNO_QUERY
);
128 OSL_ASSERT( xReceiver
.is());
129 if( !xReceiver
.is() )
132 uno::Reference
<chart2::data::XDataProvider
> xDataProvider
;
133 if (bRangeIsPivotTable
)
135 rtl::Reference
<sc::PivotTableDataProvider
> pPivotTableDataProvider(new sc::PivotTableDataProvider(rScDoc
));
136 pPivotTableDataProvider
->setPivotTableName(aRangeString
);
137 xDataProvider
= pPivotTableDataProvider
;
141 xDataProvider
.set(new ScChart2DataProvider(&rScDoc
));
144 xReceiver
->attachDataProvider(xDataProvider
);
146 uno::Reference
< util::XNumberFormatsSupplier
> xNumberFormatsSupplier( getXWeak(pDocShell
->GetModel()), uno::UNO_QUERY
);
147 xReceiver
->attachNumberFormatsSupplier( xNumberFormatsSupplier
);
149 // Same behavior as with old chart: Always assume data series in columns
150 chart::ChartDataRowSource eDataRowSource
= chart::ChartDataRowSource_COLUMNS
;
151 bool bHasCategories
= false;
152 bool bFirstCellAsLabel
= false;
154 // use ScChartPositioner to auto-detect column/row headers (like ScChartArray in old version)
155 ScRangeListRef
aRangeListRef( new ScRangeList
);
156 aRangeListRef
->Parse( aRangeString
, rScDoc
, rScDoc
.GetAddressConvention() );
157 if ( !aRangeListRef
->empty() )
159 rScDoc
.LimitChartIfAll( aRangeListRef
); // limit whole columns/rows to used area
161 // update string from modified ranges. The ranges must be in the current formula syntax.
163 aRangeListRef
->Format( aTmpStr
, ScRefFlags::RANGE_ABS_3D
, rScDoc
, rScDoc
.GetAddressConvention() );
164 aRangeString
= aTmpStr
;
166 ScChartPositioner
aChartPositioner( rScDoc
, std::move(aRangeListRef
) );
167 const ScChartPositionMap
* pPositionMap( aChartPositioner
.GetPositionMap() );
170 SCSIZE nRowCount
= pPositionMap
->GetRowCount();
172 eDataRowSource
= chart::ChartDataRowSource_ROWS
;
174 if ( eDataRowSource
== chart::ChartDataRowSource_COLUMNS
)
176 bHasCategories
= aChartPositioner
.HasRowHeaders();
177 bFirstCellAsLabel
= aChartPositioner
.HasColHeaders();
179 else // in case the default is changed
181 bHasCategories
= aChartPositioner
.HasColHeaders();
182 bFirstCellAsLabel
= aChartPositioner
.HasRowHeaders();
186 uno::Sequence
< beans::PropertyValue
> aArgs
{
187 beans::PropertyValue(
188 u
"CellRangeRepresentation"_ustr
, -1,
189 uno::Any( aRangeString
), beans::PropertyState_DIRECT_VALUE
),
190 beans::PropertyValue(
191 u
"HasCategories"_ustr
, -1,
192 uno::Any( bHasCategories
), beans::PropertyState_DIRECT_VALUE
),
193 beans::PropertyValue(
194 u
"FirstCellAsLabel"_ustr
, -1,
195 uno::Any( bFirstCellAsLabel
), beans::PropertyState_DIRECT_VALUE
),
196 beans::PropertyValue(
197 u
"DataRowSource"_ustr
, -1,
198 uno::Any( eDataRowSource
), beans::PropertyState_DIRECT_VALUE
)
203 xReceiver
->setArguments( aArgs
);
205 catch (const lang::IllegalArgumentException
&)
207 // Can happen for invalid aRangeString, in which case a Chart
208 // will be created nevertheless and the range string can be
210 TOOLS_WARN_EXCEPTION("sc.ui",
211 "lcl_ChartInit - caught IllegalArgumentException might be due to aRangeString: " << aRangeString
);
214 // don't create chart listener here (range may be modified in chart dialog)
219 FuInsertOLE::FuInsertOLE(ScTabViewShell
& rViewSh
, vcl::Window
* pWin
, ScDrawView
* pViewP
,
220 SdrModel
* pDoc
, SfxRequest
& rReq
)
221 : FuPoor(rViewSh
, pWin
, pViewP
, pDoc
, rReq
)
226 //! initialize DLLs here, so that the factories exist?
228 uno::Reference
< embed::XEmbeddedObject
> xObj
;
229 uno::Reference
< embed::XStorage
> xStorage
= comphelper::OStorageHelper::GetTemporaryStorage();
230 bool bIsFromFile
= false;
233 sal_Int64 nAspect
= embed::Aspects::MSOLE_CONTENT
;
234 OUString aIconMediaType
;
235 uno::Reference
< io::XInputStream
> xIconMetaFile
;
237 const sal_uInt16 nSlot
= rReq
.GetSlot();
238 const SfxGlobalNameItem
* pNameItem
= rReq
.GetArg
<SfxGlobalNameItem
>(SID_INSERT_OBJECT
);
239 if ( nSlot
== SID_INSERT_OBJECT
&& pNameItem
)
241 const SvGlobalName
& aClassName
= pNameItem
->GetValue();
242 xObj
= rViewShell
.GetViewFrame().GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName
.GetByteSequence(), aName
);
244 else if ( nSlot
== SID_INSERT_SMATH
)
246 if ( SvtModuleOptions().IsMathInstalled() )
248 xObj
= rViewShell
.GetViewFrame().GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SM_CLASSID_60
).GetByteSequence(), aName
);
249 rReq
.AppendItem( SfxGlobalNameItem( SID_INSERT_OBJECT
, SvGlobalName( SO3_SM_CLASSID_60
) ) );
254 SvObjectServerList aServerLst
;
257 case SID_INSERT_OBJECT
:
258 if (officecfg::Office::Common::Security::Scripting::DisableActiveContent::get())
260 std::unique_ptr
<weld::MessageDialog
> xError(Application::CreateMessageDialog(
261 nullptr, VclMessageType::Warning
, VclButtonsType::Ok
,
262 SvtResId(STR_WARNING_ACTIVE_CONTENT_DISABLED
)));
266 aServerLst
.FillInsertObjects();
267 aServerLst
.Remove( ScDocShell::Factory().GetClassId() ); // Do not show Starcalc
268 //TODO/LATER: currently no inserting of ClassId into SfxRequest!
269 [[fallthrough
]]; //TODO ???
270 case SID_INSERT_FLOATINGFRAME
:
272 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
273 ScopedVclPtr
<SfxAbstractInsertObjectDialog
> pDlg(
274 pFact
->CreateInsertObjectDialog( rViewShell
.GetFrameWeld(), ScModule::get()->GetSlotPool()->GetSlot(nSlot
)->GetCommand(),
275 xStorage
, &aServerLst
));
279 xObj
= pDlg
->GetObject();
281 xIconMetaFile
= pDlg
->GetIconIfIconified( &aIconMediaType
);
282 if ( xIconMetaFile
.is() )
283 nAspect
= embed::Aspects::MSOLE_ICON
;
286 rViewSh
.GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj
, aName
);
287 // to activate DrawShell (no need to activate Object)
288 bIsFromFile
= !pDlg
->IsCreateNew();
296 // SvInsertObjectDialog (everything in one Dialog) are not used anymore
303 ::svt::EmbeddedObjectRef
aObjRef( xObj
, nAspect
);
305 MapMode
aMap100( MapUnit::Map100thMM
);
306 MapUnit aMapUnit
= MapUnit::Map100thMM
;
308 if ( nAspect
== embed::Aspects::MSOLE_ICON
)
310 aObjRef
.SetGraphicStream( xIconMetaFile
, aIconMediaType
);
311 aSize
= aObjRef
.GetSize( &aMap100
);
318 aSz
= xObj
->getVisualAreaSize( nAspect
);
320 catch( embed::NoVisualAreaSizeException
& )
322 // the default size will be set later
325 aSize
= Size( aSz
.Width
, aSz
.Height
);
327 aMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( nAspect
) );
330 // rectangle with balanced edge ratio
331 aSize
.setWidth( 5000 );
332 aSize
.setHeight( 5000 );
333 Size aTmp
= OutputDevice::LogicToLogic(aSize
, MapMode(MapUnit::Map100thMM
), MapMode(aMapUnit
));
334 aSz
.Width
= aTmp
.Width();
335 aSz
.Height
= aTmp
.Height();
336 xObj
->setVisualAreaSize( nAspect
, aSz
);
338 // re-convert aSize to 1/100th mm to avoid rounding errors in comparison below
339 aSize
= OutputDevice::LogicToLogic( aTmp
,
340 MapMode( aMapUnit
), aMap100
);
343 aSize
= OutputDevice::LogicToLogic( aSize
,
344 MapMode( aMapUnit
), aMap100
);
347 // initialize chart ?
348 if ( SvtModuleOptions().IsChartInstalled() && SotExchange::IsChart( SvGlobalName( xObj
->getClassID() ) ) )
349 lcl_ChartInit(xObj
, &rViewSh
.GetViewData(), OUString(), false);
351 ScViewData
& rData
= rViewSh
.GetViewData();
353 Point aPnt
= rViewSh
.GetInsertPos();
354 if ( rData
.GetDocument().IsNegativePage( rData
.GetTabNo() ) )
355 aPnt
.AdjustX( -(aSize
.Width()) ); // move position to left edge
356 tools::Rectangle
aRect (aPnt
, aSize
);
357 rtl::Reference
<SdrOle2Obj
> pObj
= new SdrOle2Obj(
358 *pDoc
, // TTTT should be reference
362 SdrPageView
* pPV
= pView
->GetSdrPageView();
363 bool bSuccess
= pView
->InsertObjectAtView(pObj
.get(), *pPV
);
365 if (bSuccess
&& nAspect
!= embed::Aspects::MSOLE_ICON
)
367 // Math objects change their object size during InsertObject.
368 // New size must be set in SdrObject, or a wrong scale will be set at
373 awt::Size aSz
= xObj
->getVisualAreaSize( nAspect
);
375 Size
aNewSize( aSz
.Width
, aSz
.Height
);
376 aNewSize
= OutputDevice::LogicToLogic(aNewSize
, MapMode(aMapUnit
), MapMode(MapUnit::Map100thMM
));
378 if ( aNewSize
!= aSize
)
380 aRect
.SetSize( aNewSize
);
381 pObj
->SetLogicRect( aRect
);
384 catch( embed::NoVisualAreaSizeException
& )
390 // XXX Activate from macro is deadly !!! ???
393 // Object selected, activate Draw-Shell
394 rViewShell
.SetDrawShell( true );
398 rViewShell
.ActivateObject(pObj
.get(), embed::EmbedVerbs::MS_OLEVERB_SHOW
);
404 catch( uno::Exception
& )
406 OSL_FAIL( "May need error handling here!" );
413 FuInsertChart::FuInsertChart(ScTabViewShell
& rViewSh
, vcl::Window
* pWin
, ScDrawView
* pViewP
,
414 SdrModel
* pDoc
, SfxRequest
& rReq
, const Link
<css::ui::dialogs::DialogClosedEvent
*, void>& rLink
)
415 : FuPoor(rViewSh
, pWin
, pViewP
, pDoc
, rReq
)
417 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
422 if (!SvtModuleOptions().IsChartInstalled())
428 OUString aRangeString
;
429 bool bRangeIsPivotTable
= false;
430 ScRange aPositionRange
; // cell range for chart positioning
431 ScMarkData aMark
= rViewSh
.GetViewData().GetMarkData();
434 const SfxPoolItem
* pItem
;
435 if( pReqArgs
->HasItem( FN_PARAM_5
, &pItem
) )
436 aRangeString
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
438 aPositionRange
= rViewSh
.GetViewData().GetCurPos();
442 ScDocument
& rDocument
= rViewSh
.GetViewData().GetDocument();
443 ScDPObject
* pObject
= rDocument
.GetDPAtCursor(rViewSh
.GetViewData().GetCurX(),
444 rViewSh
.GetViewData().GetCurY(),
445 rViewSh
.GetViewData().GetTabNo());
448 aRangeString
= pObject
->GetName();
449 bRangeIsPivotTable
= true;
453 bool bAutomaticMark
= false;
454 if ( !aMark
.IsMarked() && !aMark
.IsMultiMarked() )
456 rViewSh
.GetViewData().GetView()->MarkDataArea();
457 bAutomaticMark
= true;
460 ScMarkData
aMultiMark(std::move(aMark
));
461 aMultiMark
.MarkToMulti();
464 aMultiMark
.FillRangeListWithMarks( &aRanges
, false );
466 aRanges
.Format( aStr
, ScRefFlags::RANGE_ABS_3D
, rDocument
, rDocument
.GetAddressConvention() );
469 // get "total" range for positioning
470 if ( !aRanges
.empty() )
472 aPositionRange
= aRanges
[ 0 ];
473 for ( size_t i
= 1, nCount
= aRanges
.size(); i
< nCount
; ++i
)
475 aPositionRange
.ExtendTo( aRanges
[ i
] );
480 rViewSh
.GetViewData().GetView()->Unmark();
488 const sal_Int64 nAspect
= embed::Aspects::MSOLE_CONTENT
;
490 uno::Reference
< embed::XEmbeddedObject
> xObj
=
491 rViewShell
.GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID_60
).GetByteSequence(), aName
);
493 uno::Reference
< css::chart2::data::XDataReceiver
> xReceiver
;
495 xReceiver
.set( xObj
->getComponent(), uno::UNO_QUERY
);
497 uno::Reference
<chart2::XChartDocument
> xChartDoc(xReceiver
, uno::UNO_QUERY
);
499 xChartDoc
->createDefaultChart();
501 // lock the model to suppress any internal updates
502 uno::Reference
< frame::XModel
> xChartModel( xReceiver
, uno::UNO_QUERY
);
503 if( xChartModel
.is() )
504 xChartModel
->lockControllers();
507 awt::Size aSz
= xObj
->getVisualAreaSize( nAspect
);
508 Size
aSize( aSz
.Width
, aSz
.Height
);
510 MapUnit aMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj
->getMapUnit( nAspect
) );
512 bool bSizeCh
= false;
515 aSize
.setWidth( 5000 );
516 aSize
.setHeight( 5000 );
521 aSize
= OutputDevice::LogicToLogic( aSize
, MapMode( MapUnit::Map100thMM
), MapMode( aMapUnit
) );
522 aSz
.Width
= aSize
.Width();
523 aSz
.Height
= aSize
.Height();
524 xObj
->setVisualAreaSize( nAspect
, aSz
);
527 ScViewData
& rData
= rViewSh
.GetViewData();
528 ScDocShell
* pScDocSh
= rData
.GetDocShell();
529 ScDocument
& rScDoc
= pScDocSh
->GetDocument();
530 bool bUndo (rScDoc
.IsUndoEnabled());
534 const SfxPoolItem
* pItem
;
535 sal_uInt16 nToTable
= 0;
537 if( pReqArgs
->HasItem( FN_PARAM_4
, &pItem
) )
539 if ( auto pUInt16Item
= dynamic_cast<const SfxUInt16Item
*>( pItem
) )
540 nToTable
= pUInt16Item
->GetValue();
541 else if ( auto pBoolItem
= dynamic_cast<const SfxBoolItem
*>( pItem
) )
543 // In IDL for Basic FN_PARAM_4 means SfxBoolItem
544 // -> if set new table, else current table
546 if ( pBoolItem
->GetValue() )
547 nToTable
= static_cast<sal_uInt16
>(rScDoc
.GetTableCount());
549 nToTable
= static_cast<sal_uInt16
>(rData
.GetTabNo());
554 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_4
, nToTable
) );
557 // Output on new table?
558 if ( nToTable
== rScDoc
.GetTableCount() )
562 SCTAB nNewTab
= rScDoc
.GetTableCount();
564 rScDoc
.CreateValidTabName( aTabName
);
566 if ( rScDoc
.InsertTab( nNewTab
, aTabName
) )
570 pScDocSh
->GetUndoManager()->AddUndoAction(
571 std::make_unique
<ScUndoInsertTab
>( pScDocSh
, nNewTab
,
572 true/*bAppend*/, aTabName
) );
575 pScDocSh
->Broadcast( ScTablesHint( SC_TAB_INSERTED
, nNewTab
) );
576 rViewSh
.SetTabNo( nNewTab
, true );
577 pScDocSh
->PostPaintExtras(); //! done afterwards ???
581 OSL_FAIL( "Could not create new table :-/" );
584 else if ( nToTable
!= rData
.GetTabNo() )
586 rViewSh
.SetTabNo( nToTable
, true );
590 lcl_ChartInit(xObj
, &rData
, aRangeString
, bRangeIsPivotTable
); // set source range, auto-detect column/row headers
594 // get chart position (from window size and data range)
595 Point aStart
= rViewSh
.GetChartInsertPos( aSize
, aPositionRange
);
597 tools::Rectangle
aRect (aStart
, aSize
);
598 rtl::Reference
<SdrOle2Obj
> pObj
= new SdrOle2Obj(
599 *pDoc
, // TTTT should be reference
600 svt::EmbeddedObjectRef(xObj
, nAspect
),
603 SdrPageView
* pPV
= pView
->GetSdrPageView();
605 // #i121334# This call will change the chart's default background fill from white to transparent.
606 // Add here again if this is wanted (see task description for details)
607 // ChartHelper::AdaptDefaultsForChart( xObj );
609 // pView->InsertObjectAtView(pObj, *pPV);//this call leads to an immediate redraw and asks the chart for a visual representation
611 // use the page instead of the view to insert, so no undo action is created yet
612 SdrPage
* pPage
= pPV
->GetPage();
613 pPage
->InsertObject( pObj
.get() );
614 pView
->UnmarkAllObj();
615 pView
->MarkObj( pObj
.get(), pPV
);
619 if( xChartModel
.is() )
620 xChartModel
->unlockControllers();
622 else if (!rViewSh
.isLOKMobilePhone())
624 //the controller will be unlocked by the dialog when the dialog is told to do so
626 // only activate object if not called via API (e.g. macro)
627 if (!comphelper::LibreOfficeKit::isActive())
628 rViewShell
.ActivateObject(pObj
.get(), embed::EmbedVerbs::MS_OLEVERB_SHOW
);
631 //@todo get context from calc if that has one
632 uno::Reference
< uno::XComponentContext
> xContext(
633 ::cppu::defaultBootstrap_InitialComponentContext() );
636 uno::Reference
< lang::XMultiComponentFactory
> xMCF( xContext
->getServiceManager() );
639 css::uno::Reference
<css::ui::dialogs::XAsynchronousExecutableDialog
> xDialog(
640 xMCF
->createInstanceWithContext(
641 u
"com.sun.star.comp.chart2.WizardDialog"_ustr
642 , xContext
), uno::UNO_QUERY
);
643 uno::Reference
< lang::XInitialization
> xInit( xDialog
, uno::UNO_QUERY
);
644 if( xChartModel
.is() && xInit
.is() )
646 css::uno::Reference
< css::awt::XWindow
> xParent
647 = new weld::TransportAsXWindow(pWin
->GetFrameWeld());
648 uno::Sequence
<uno::Any
> aSeq(comphelper::InitAnyPropertySequence(
650 {"ParentWindow", uno::Any(xParent
)},
651 {"ChartModel", uno::Any(xChartModel
)}
653 xInit
->initialize( aSeq
);
655 // try to set the dialog's position so it doesn't hide the chart
656 uno::Reference
< beans::XPropertySet
> xDialogProps( xDialog
, uno::UNO_QUERY
);
657 if ( xDialogProps
.is() )
662 awt::Size aDialogAWTSize
;
663 if( xDialogProps
->getPropertyValue(u
"Size"_ustr
)
666 Size
aDialogSize( aDialogAWTSize
.Width
, aDialogAWTSize
.Height
);
667 if ( !aDialogSize
.IsEmpty() )
669 //calculate and set new position
670 Point aDialogPos
= rViewShell
.GetChartDialogPos( aDialogSize
, aRect
);
671 xDialogProps
->setPropertyValue(u
"Position"_ustr
,
672 uno::Any( awt::Point(aDialogPos
.getX(),aDialogPos
.getY()) ) );
675 //tell the dialog to unlock controller
676 xDialogProps
->setPropertyValue(u
"UnlockControllersOnExecute"_ustr
,
680 catch( uno::Exception
& )
682 OSL_FAIL( "Chart wizard couldn't be positioned automatically" );
686 pView
->AddUndo(std::make_unique
<SdrUndoNewObj
>(*pObj
));
687 rViewSh
.SetInsertWizardUndoMark();
688 rtl::Reference
<::svt::DialogClosedListener
> pListener
= new ::svt::DialogClosedListener();
689 pListener
->SetDialogClosedLink( rLink
);
691 xDialog
->startExecuteModal( pListener
);
695 uno::Reference
< lang::XComponent
> xComponent( xDialog
, uno::UNO_QUERY
);
697 xComponent
->dispose();
704 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */