LibreOffice Module sc (master) 1
fuins2.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
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>
25
27#include <sot/exchange.hxx>
29#include <sfx2/viewfrm.hxx>
30#include <svl/stritem.hxx>
31#include <svx/svdoole2.hxx>
33#include <svtools/insdlg.hxx>
34#include <svtools/embedhlp.hxx>
35#include <svx/svxdlg.hxx>
37#include <svx/svdpagv.hxx>
38#include <svx/svdpage.hxx>
39#include <svx/svdundo.hxx>
40#include <sfx2/msgpool.hxx>
41#include <sfx2/msg.hxx>
42#include <scmod.hxx>
43#include <sal/log.hxx>
45
46#include <comphelper/lok.hxx>
49#include <com/sun/star/embed/EmbedVerbs.hpp>
50#include <com/sun/star/beans/PropertyValue.hpp>
51#include <com/sun/star/chart2/data/XDataReceiver.hpp>
52#include <com/sun/star/chart2/XChartDocument.hpp>
53#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
54#include <com/sun/star/lang/XInitialization.hpp>
55#include <com/sun/star/frame/XModel.hpp>
56#include <com/sun/star/chart/ChartDataRowSource.hpp>
59
61#include <chart2uno.hxx>
62#include <fuinsert.hxx>
63#include <tabvwsh.hxx>
64#include <sc.hrc>
65#include <chartpos.hxx>
66#include <docsh.hxx>
67#include <document.hxx>
68#include <undotab.hxx>
69#include <uiitems.hxx>
70#include <drawview.hxx>
71#include <markdata.hxx>
72#include <dpobject.hxx>
73#include <memory>
74
75using namespace css;
76
77namespace
78{
79
80void lcl_ChartInit(const uno::Reference <embed::XEmbeddedObject>& xObj, ScViewData* pViewData,
81 const OUString& rRangeParam, bool bRangeIsPivotTable)
82{
83 ScDocShell* pDocShell = pViewData->GetDocShell();
84 ScDocument& rScDoc = pDocShell->GetDocument();
85
86 OUString aRangeString(rRangeParam);
87
88 if (aRangeString.isEmpty() && !bRangeIsPivotTable)
89 {
90 SCCOL nCol1 = 0;
91 SCROW nRow1 = 0;
92 SCTAB nTab1 = 0;
93 SCCOL nCol2 = 0;
94 SCROW nRow2 = 0;
95 SCTAB nTab2 = 0;
96
97 ScMarkData& rMark = pViewData->GetMarkData();
98 if ( !rMark.IsMarked() )
99 pViewData->GetView()->MarkDataArea();
100
101 if ( pViewData->GetSimpleArea( nCol1,nRow1,nTab1, nCol2,nRow2,nTab2 ) == SC_MARK_SIMPLE )
102 {
103 PutInOrder( nCol1, nCol2 );
104 PutInOrder( nRow1, nRow2 );
105 if (nCol2 >= nCol1 || nRow2 >= nRow1)
106 {
107 ScDocument& rDoc = pViewData->GetDocument();
108 rDoc.LimitChartArea( nTab1, nCol1,nRow1, nCol2,nRow2 );
109
110 ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
111 aRangeString = aRange.Format(rScDoc, ScRefFlags::RANGE_ABS_3D, rScDoc.GetAddressConvention());
112 }
113 }
114 }
115
116 if (aRangeString.isEmpty())
117 return;
118
119 // connect to Calc data (if no range string, leave chart alone, with its own data)
120
121 uno::Reference< css::chart2::data::XDataReceiver > xReceiver;
122 if( xObj.is())
123 xReceiver.set( xObj->getComponent(), uno::UNO_QUERY );
124 OSL_ASSERT( xReceiver.is());
125 if( !xReceiver.is() )
126 return;
127
128 uno::Reference<chart2::data::XDataProvider> xDataProvider;
129 if (bRangeIsPivotTable)
130 {
132 pPivotTableDataProvider->setPivotTableName(aRangeString);
133 xDataProvider = pPivotTableDataProvider;
134 }
135 else
136 {
137 xDataProvider.set(new ScChart2DataProvider(&rScDoc));
138 }
139
140 xReceiver->attachDataProvider(xDataProvider);
141
142 uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( pDocShell->GetModel(), uno::UNO_QUERY );
143 xReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier );
144
145 // Same behavior as with old chart: Always assume data series in columns
146 chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
147 bool bHasCategories = false;
148 bool bFirstCellAsLabel = false;
149
150 // use ScChartPositioner to auto-detect column/row headers (like ScChartArray in old version)
151 ScRangeListRef aRangeListRef( new ScRangeList );
152 aRangeListRef->Parse( aRangeString, rScDoc, rScDoc.GetAddressConvention() );
153 if ( !aRangeListRef->empty() )
154 {
155 rScDoc.LimitChartIfAll( aRangeListRef ); // limit whole columns/rows to used area
156
157 // update string from modified ranges. The ranges must be in the current formula syntax.
158 OUString aTmpStr;
159 aRangeListRef->Format( aTmpStr, ScRefFlags::RANGE_ABS_3D, rScDoc, rScDoc.GetAddressConvention() );
160 aRangeString = aTmpStr;
161
162 ScChartPositioner aChartPositioner( rScDoc, aRangeListRef );
163 const ScChartPositionMap* pPositionMap( aChartPositioner.GetPositionMap() );
164 if( pPositionMap )
165 {
166 SCSIZE nRowCount = pPositionMap->GetRowCount();
167 if( 1==nRowCount )
168 eDataRowSource = chart::ChartDataRowSource_ROWS;
169 }
170 if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
171 {
172 bHasCategories = aChartPositioner.HasRowHeaders();
173 bFirstCellAsLabel = aChartPositioner.HasColHeaders();
174 }
175 else // in case the default is changed
176 {
177 bHasCategories = aChartPositioner.HasColHeaders();
178 bFirstCellAsLabel = aChartPositioner.HasRowHeaders();
179 }
180 }
181
182 uno::Sequence< beans::PropertyValue > aArgs{
183 beans::PropertyValue(
184 "CellRangeRepresentation", -1,
185 uno::Any( aRangeString ), beans::PropertyState_DIRECT_VALUE ),
186 beans::PropertyValue(
187 "HasCategories", -1,
188 uno::Any( bHasCategories ), beans::PropertyState_DIRECT_VALUE ),
189 beans::PropertyValue(
190 "FirstCellAsLabel", -1,
191 uno::Any( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE ),
192 beans::PropertyValue(
193 "DataRowSource", -1,
194 uno::Any( eDataRowSource ), beans::PropertyState_DIRECT_VALUE )
195 };
196
197 try
198 {
199 xReceiver->setArguments( aArgs );
200 }
201 catch (const lang::IllegalArgumentException&)
202 {
203 // Can happen for invalid aRangeString, in which case a Chart
204 // will be created nevertheless and the range string can be
205 // edited.
206 TOOLS_WARN_EXCEPTION("sc.ui",
207 "lcl_ChartInit - caught IllegalArgumentException might be due to aRangeString: " << aRangeString);
208 }
209
210 // don't create chart listener here (range may be modified in chart dialog)
211}
212
213}
214
216 SdrModel* pDoc, SfxRequest& rReq)
217 : FuPoor(rViewSh, pWin, pViewP, pDoc, rReq)
218{
219 if( ! rReq.IsAPI() )
220 rReq.Done();
221
223
224 uno::Reference < embed::XEmbeddedObject > xObj;
225 uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
226 bool bIsFromFile = false;
227 OUString aName;
228
229 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
230 OUString aIconMediaType;
231 uno::Reference< io::XInputStream > xIconMetaFile;
232
233 const sal_uInt16 nSlot = rReq.GetSlot();
234 const SfxGlobalNameItem* pNameItem = rReq.GetArg<SfxGlobalNameItem>(SID_INSERT_OBJECT);
235 if ( nSlot == SID_INSERT_OBJECT && pNameItem )
236 {
237 const SvGlobalName& aClassName = pNameItem->GetValue();
239 }
240 else if ( nSlot == SID_INSERT_SMATH )
241 {
242 if ( SvtModuleOptions().IsMath() )
243 {
245 rReq.AppendItem( SfxGlobalNameItem( SID_INSERT_OBJECT, SvGlobalName( SO3_SM_CLASSID_60 ) ) );
246 }
247 }
248 else
249 {
250 SvObjectServerList aServerLst;
251 switch ( nSlot )
252 {
253 case SID_INSERT_OBJECT :
254 aServerLst.FillInsertObjects();
255 aServerLst.Remove( ScDocShell::Factory().GetClassId() ); // Do not show Starcalc
256 //TODO/LATER: currently no inserting of ClassId into SfxRequest!
257 [[fallthrough]]; //TODO ???
258 case SID_INSERT_FLOATINGFRAME :
259 {
262 pFact->CreateInsertObjectDialog( rViewShell.GetFrameWeld(), SC_MOD()->GetSlotPool()->GetSlot(nSlot)->GetCommandString(),
263 xStorage, &aServerLst ));
264 if ( pDlg )
265 {
266 pDlg->Execute();
267 xObj = pDlg->GetObject();
268
269 xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType );
270 if ( xIconMetaFile.is() )
271 nAspect = embed::Aspects::MSOLE_ICON;
272
273 if ( xObj.is() )
275 // to activate DrawShell (no need to activate Object)
276 bIsFromFile = !pDlg->IsCreateNew();
277 }
278
279 break;
280 }
281 }
282 }
283
284 // SvInsertObjectDialog (everything in one Dialog) are not used anymore
285 if (xObj.is())
286 {
287 pView->UnmarkAll();
288
289 try
290 {
291 ::svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
292 Size aSize;
293 MapMode aMap100( MapUnit::Map100thMM );
294 MapUnit aMapUnit = MapUnit::Map100thMM;
295
296 if ( nAspect == embed::Aspects::MSOLE_ICON )
297 {
298 aObjRef.SetGraphicStream( xIconMetaFile, aIconMediaType );
299 aSize = aObjRef.GetSize( &aMap100 );
300 }
301 else
302 {
303 awt::Size aSz;
304 try
305 {
306 aSz = xObj->getVisualAreaSize( nAspect );
307 }
308 catch( embed::NoVisualAreaSizeException& )
309 {
310 // the default size will be set later
311 }
312
313 aSize = Size( aSz.Width, aSz.Height );
314
315 aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
316 if (aSize.IsEmpty())
317 {
318 // rectangle with balanced edge ratio
319 aSize.setWidth( 5000 );
320 aSize.setHeight( 5000 );
321 Size aTmp = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(aMapUnit));
322 aSz.Width = aTmp.Width();
323 aSz.Height = aTmp.Height();
324 xObj->setVisualAreaSize( nAspect, aSz );
325
326 // re-convert aSize to 1/100th mm to avoid rounding errors in comparison below
327 aSize = OutputDevice::LogicToLogic( aTmp,
328 MapMode( aMapUnit ), aMap100 );
329 }
330 else
331 aSize = OutputDevice::LogicToLogic( aSize,
332 MapMode( aMapUnit ), aMap100 );
333 }
334
335 // initialize chart ?
336 if ( SvtModuleOptions().IsChart() && SotExchange::IsChart( SvGlobalName( xObj->getClassID() ) ) )
337 lcl_ChartInit(xObj, &rViewSh.GetViewData(), OUString(), false);
338
339 ScViewData& rData = rViewSh.GetViewData();
340
341 Point aPnt = rViewSh.GetInsertPos();
342 if ( rData.GetDocument().IsNegativePage( rData.GetTabNo() ) )
343 aPnt.AdjustX( -(aSize.Width()) ); // move position to left edge
344 tools::Rectangle aRect (aPnt, aSize);
346 *pDoc, // TTTT should be reference
347 aObjRef,
348 aName,
349 aRect);
351 bool bSuccess = pView->InsertObjectAtView(pObj.get(), *pPV);
352
353 if (bSuccess && nAspect != embed::Aspects::MSOLE_ICON)
354 {
355 // Math objects change their object size during InsertObject.
356 // New size must be set in SdrObject, or a wrong scale will be set at
357 // ActivateObject.
358
359 try
360 {
361 awt::Size aSz = xObj->getVisualAreaSize( nAspect );
362
363 Size aNewSize( aSz.Width, aSz.Height );
364 aNewSize = OutputDevice::LogicToLogic(aNewSize, MapMode(aMapUnit), MapMode(MapUnit::Map100thMM));
365
366 if ( aNewSize != aSize )
367 {
368 aRect.SetSize( aNewSize );
369 pObj->SetLogicRect( aRect );
370 }
371 }
372 catch( embed::NoVisualAreaSizeException& )
373 {}
374 }
375
376 if ( !rReq.IsAPI() )
377 {
378 // XXX Activate from macro is deadly !!! ???
379 if (bIsFromFile)
380 {
381 // Object selected, activate Draw-Shell
382 rViewShell.SetDrawShell( true );
383 }
384 else if (bSuccess)
385 {
386 rViewShell.ActivateObject(pObj.get(), embed::EmbedVerbs::MS_OLEVERB_SHOW);
387 }
388 }
389
390 rReq.Done();
391 }
392 catch( uno::Exception& )
393 {
394 OSL_FAIL( "May need error handling here!" );
395 }
396 }
397 else
398 rReq.Ignore();
399}
400
403 : FuPoor(rViewSh, pWin, pViewP, pDoc, rReq)
404{
405 const SfxItemSet* pReqArgs = rReq.GetArgs();
406
407 if( ! rReq.IsAPI() )
408 rReq.Done();
409
410 if (!SvtModuleOptions().IsChart())
411 return;
412
413 // BM/IHA --
414
415 // get range
416 OUString aRangeString;
417 bool bRangeIsPivotTable = false;
418 ScRange aPositionRange; // cell range for chart positioning
419 ScMarkData aMark = rViewSh.GetViewData().GetMarkData();
420 if( pReqArgs )
421 {
422 const SfxPoolItem* pItem;
423 if( pReqArgs->HasItem( FN_PARAM_5, &pItem ) )
424 aRangeString = static_cast<const SfxStringItem*>(pItem)->GetValue();
425
426 aPositionRange = rViewSh.GetViewData().GetCurPos();
427 }
428 else
429 {
430 ScDocument& rDocument = rViewSh.GetViewData().GetDocument();
431 ScDPObject* pObject = rDocument.GetDPAtCursor(rViewSh.GetViewData().GetCurX(),
432 rViewSh.GetViewData().GetCurY(),
433 rViewSh.GetViewData().GetTabNo());
434 if (pObject)
435 {
436 aRangeString = pObject->GetName();
437 bRangeIsPivotTable = true;
438 }
439 else
440 {
441 bool bAutomaticMark = false;
442 if ( !aMark.IsMarked() && !aMark.IsMultiMarked() )
443 {
444 rViewSh.GetViewData().GetView()->MarkDataArea();
445 bAutomaticMark = true;
446 }
447
448 ScMarkData aMultiMark( aMark );
449 aMultiMark.MarkToMulti();
450
451 ScRangeList aRanges;
452 aMultiMark.FillRangeListWithMarks( &aRanges, false );
453 OUString aStr;
454 aRanges.Format( aStr, ScRefFlags::RANGE_ABS_3D, rDocument, rDocument.GetAddressConvention() );
455 aRangeString = aStr;
456
457 // get "total" range for positioning
458 if ( !aRanges.empty() )
459 {
460 aPositionRange = aRanges[ 0 ];
461 for ( size_t i = 1, nCount = aRanges.size(); i < nCount; ++i )
462 {
463 aPositionRange.ExtendTo( aRanges[ i ] );
464 }
465 }
466
467 if(bAutomaticMark)
468 rViewSh.GetViewData().GetView()->Unmark();
469 }
470 }
471
472 // adapted old code
473 pView->UnmarkAll();
474
475 OUString aName;
476 const sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
477
478 uno::Reference < embed::XEmbeddedObject > xObj =
480
481 uno::Reference< css::chart2::data::XDataReceiver > xReceiver;
482 if( xObj.is())
483 xReceiver.set( xObj->getComponent(), uno::UNO_QUERY );
484
485 uno::Reference<chart2::XChartDocument> xChartDoc(xReceiver, uno::UNO_QUERY);
486 if (xChartDoc.is())
487 xChartDoc->createDefaultChart();
488
489 // lock the model to suppress any internal updates
490 uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY );
491 if( xChartModel.is() )
492 xChartModel->lockControllers();
493
494 // object size
495 awt::Size aSz = xObj->getVisualAreaSize( nAspect );
496 Size aSize( aSz.Width, aSz.Height );
497
498 MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
499
500 bool bSizeCh = false;
501 if (aSize.IsEmpty())
502 {
503 aSize.setWidth( 5000 );
504 aSize.setHeight( 5000 );
505 bSizeCh = true;
506 }
507 if (bSizeCh)
508 {
509 aSize = OutputDevice::LogicToLogic( aSize, MapMode( MapUnit::Map100thMM ), MapMode( aMapUnit ) );
510 aSz.Width = aSize.Width();
511 aSz.Height = aSize.Height();
512 xObj->setVisualAreaSize( nAspect, aSz );
513 }
514
515 ScViewData& rData = rViewSh.GetViewData();
516 ScDocShell* pScDocSh = rData.GetDocShell();
517 ScDocument& rScDoc = pScDocSh->GetDocument();
518 bool bUndo (rScDoc.IsUndoEnabled());
519
520 if( pReqArgs )
521 {
522 const SfxPoolItem* pItem;
523 sal_uInt16 nToTable = 0;
524
525 if( pReqArgs->HasItem( FN_PARAM_4, &pItem ) )
526 {
527 if ( auto pUInt16Item = dynamic_cast<const SfxUInt16Item*>( pItem) )
528 nToTable = pUInt16Item->GetValue();
529 else if ( auto pBoolItem = dynamic_cast<const SfxBoolItem*>( pItem) )
530 {
531 // In IDL for Basic FN_PARAM_4 means SfxBoolItem
532 // -> if set new table, else current table
533
534 if ( pBoolItem->GetValue() )
535 nToTable = static_cast<sal_uInt16>(rScDoc.GetTableCount());
536 else
537 nToTable = static_cast<sal_uInt16>(rData.GetTabNo());
538 }
539 }
540 else
541 {
542 rReq.AppendItem( SfxUInt16Item( FN_PARAM_4, nToTable ) );
543 }
544
545 // Output on new table?
546 if ( nToTable == rScDoc.GetTableCount() )
547 {
548 // Let's go...
549 OUString aTabName;
550 SCTAB nNewTab = rScDoc.GetTableCount();
551
552 rScDoc.CreateValidTabName( aTabName );
553
554 if ( rScDoc.InsertTab( nNewTab, aTabName ) )
555 {
556 if (bUndo)
557 {
558 pScDocSh->GetUndoManager()->AddUndoAction(
559 std::make_unique<ScUndoInsertTab>( pScDocSh, nNewTab,
560 true/*bAppend*/, aTabName ) );
561 }
562
563 pScDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nNewTab ) );
564 rViewSh.SetTabNo( nNewTab, true );
565 pScDocSh->PostPaintExtras();
566 }
567 else
568 {
569 OSL_FAIL( "Could not create new table :-/" );
570 }
571 }
572 else if ( nToTable != rData.GetTabNo() )
573 {
574 rViewSh.SetTabNo( nToTable, true );
575 }
576 }
577
578 lcl_ChartInit(xObj, &rData, aRangeString, bRangeIsPivotTable); // set source range, auto-detect column/row headers
579
580 // object position
581
582 // get chart position (from window size and data range)
583 Point aStart = rViewSh.GetChartInsertPos( aSize, aPositionRange );
584
585 tools::Rectangle aRect (aStart, aSize);
587 *pDoc, // TTTT should be reference
588 svt::EmbeddedObjectRef(xObj, nAspect),
589 aName,
590 aRect);
592
593 // #i121334# This call will change the chart's default background fill from white to transparent.
594 // Add here again if this is wanted (see task description for details)
595 // ChartHelper::AdaptDefaultsForChart( xObj );
596
597// pView->InsertObjectAtView(pObj, *pPV);//this call leads to an immediate redraw and asks the chart for a visual representation
598
599 // use the page instead of the view to insert, so no undo action is created yet
600 SdrPage* pPage = pPV->GetPage();
601 pPage->InsertObject( pObj.get() );
603 pView->MarkObj( pObj.get(), pPV );
604
605 if (rReq.IsAPI())
606 {
607 if( xChartModel.is() )
608 xChartModel->unlockControllers();
609 }
610 else if (!rViewSh.isLOKMobilePhone())
611 {
612 //the controller will be unlocked by the dialog when the dialog is told to do so
613
614 // only activate object if not called via API (e.g. macro)
616 rViewShell.ActivateObject(pObj.get(), embed::EmbedVerbs::MS_OLEVERB_SHOW);
617
618 //open wizard
619 //@todo get context from calc if that has one
620 uno::Reference< uno::XComponentContext > xContext(
621 ::cppu::defaultBootstrap_InitialComponentContext() );
622 if(xContext.is())
623 {
624 uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
625 if(xMCF.is())
626 {
627 css::uno::Reference<css::ui::dialogs::XAsynchronousExecutableDialog> xDialog(
628 xMCF->createInstanceWithContext(
629 "com.sun.star.comp.chart2.WizardDialog"
630 , xContext), uno::UNO_QUERY);
631 uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY );
632 if( xChartModel.is() && xInit.is() )
633 {
634 uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence(
635 {
636 {"ParentWindow", uno::Any(uno::Reference< awt::XWindow >())},
637 {"ChartModel", uno::Any(xChartModel)}
638 }));
639 xInit->initialize( aSeq );
640
641 // try to set the dialog's position so it doesn't hide the chart
642 uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY );
643 if ( xDialogProps.is() )
644 {
645 try
646 {
647 //get dialog size:
648 awt::Size aDialogAWTSize;
649 if( xDialogProps->getPropertyValue("Size")
650 >>= aDialogAWTSize )
651 {
652 Size aDialogSize( aDialogAWTSize.Width, aDialogAWTSize.Height );
653 if ( !aDialogSize.IsEmpty() )
654 {
655 //calculate and set new position
656 Point aDialogPos = rViewShell.GetChartDialogPos( aDialogSize, aRect );
657 xDialogProps->setPropertyValue("Position",
658 uno::Any( awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) );
659 }
660 }
661 //tell the dialog to unlock controller
662 xDialogProps->setPropertyValue("UnlockControllersOnExecute",
663 uno::Any( true ) );
664
665 }
666 catch( uno::Exception& )
667 {
668 OSL_FAIL( "Chart wizard couldn't be positioned automatically" );
669 }
670 }
671
672 pView->AddUndo(std::make_unique<SdrUndoNewObj>(*pObj));
673 rtl::Reference<::svt::DialogClosedListener> pListener = new ::svt::DialogClosedListener();
674 pListener->SetDialogClosedLink( rLink );
675
676 xDialog->startExecuteModal( pListener );
677 }
678 else
679 {
680 uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY );
681 if( xComponent.is())
682 xComponent->dispose();
683 }
684 }
685 }
686 }
687}
688
689/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
void PutInOrder(T &nStart, T &nEnd)
Definition: address.hxx:150
FuInsertChart(ScTabViewShell &pViewSh, vcl::Window *pWin, ScDrawView *pView, SdrModel *pDoc, SfxRequest &rReq, const Link< css::ui::dialogs::DialogClosedEvent *, void > &rLink)
Definition: fuins2.cxx:401
FuInsertOLE(ScTabViewShell &rViewSh, vcl::Window *pWin, ScDrawView *pView, SdrModel *pDoc, SfxRequest &rReq)
Definition: fuins2.cxx:215
Base class for all functions.
Definition: fupoor.hxx:40
ScDrawView * pView
Definition: fupoor.hxx:42
ScTabViewShell & rViewShell
Definition: fupoor.hxx:43
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
void PostPaintExtras()
Definition: docsh3.cxx:198
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2945
SC_DLLPUBLIC bool InsertTab(SCTAB nPos, const OUString &rName, bool bExternalDocument=false, bool bUndoDeleteTab=false)
Definition: document.cxx:507
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:500
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
Definition: document.cxx:1006
void LimitChartArea(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow)
Definition: document.cxx:1119
void LimitChartIfAll(ScRangeListRef &rRangeList)
Definition: document.cxx:1127
SC_DLLPUBLIC void CreateValidTabName(OUString &rName) const
Definition: document.cxx:395
SC_DLLPUBLIC ScDPObject * GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: documen3.cxx:383
bool IsUndoEnabled() const
Definition: document.hxx:1593
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:317
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
bool IsMultiMarked() const
Definition: markdata.hxx:81
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
Definition: markdata.cxx:372
void MarkToMulti()
Definition: markdata.cxx:209
bool IsMarked() const
Definition: markdata.hxx:80
void Format(OUString &, ScRefFlags nFlags, const ScDocument &, formula::FormulaGrammar::AddressConvention eConv=formula::FormulaGrammar::CONV_OOO, sal_Unicode cDelimiter=0, bool bFullAddressNotation=false) const
Definition: rangelst.cxx:132
bool empty() const
Definition: rangelst.hxx:88
size_t size() const
Definition: rangelst.hxx:89
void ExtendTo(const ScRange &rRange)
Definition: address.cxx:1562
void ActivateObject(SdrOle2Obj *pObj, sal_Int32 nVerb)
Definition: tabvwshb.cxx:155
void SetDrawShell(bool bActive)
Definition: tabvwsh4.cxx:613
void MarkDataArea(bool bIncludeCursor=true)
Definition: tabview3.cxx:1680
Point GetChartInsertPos(const Size &rSize, const ScRange &rCellRange)
Definition: tabview.cxx:1685
Point GetChartDialogPos(const Size &rDialogSize, const tools::Rectangle &rLogicChart)
Definition: tabview.cxx:1813
Point GetInsertPos() const
Definition: tabview.cxx:1668
ScViewData & GetViewData()
Definition: tabview.hxx:335
void Unmark()
Definition: tabview3.cxx:1747
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1822
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3141
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
Definition: viewdata.cxx:1181
ScDBFunc * GetView() const
Definition: viewdata.cxx:863
ScAddress GetCurPos() const
Definition: viewdata.cxx:4127
SCROW GetCurY() const
Definition: viewdata.hxx:402
SCCOL GetCurX() const
Definition: viewdata.hxx:401
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
void UnmarkAllObj(SdrPageView const *pPV=nullptr)
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
SdrPage * GetPage() const
SdrPageView * GetSdrPageView() const
void UnmarkAll()
const SvGlobalName & GetValue() const
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
comphelper::EmbeddedObjectContainer & GetEmbeddedObjectContainer() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
sal_uInt16 GetSlot() const
void Ignore()
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
void AppendItem(const SfxPoolItem &)
bool IsAPI() const
void Done(bool bRemove=false)
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
virtual SfxObjectShell * GetObjectShell() override
bool isLOKMobilePhone() const
weld::Window * GetFrameWeld() const
SfxViewFrame * GetViewFrame() const
virtual SfxObjectShell * GetObjectShell() override
bool IsEmpty() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static sal_uInt16 IsChart(const SvGlobalName &rName)
css::uno::Sequence< sal_Int8 > GetByteSequence() const
void Remove(const SvGlobalName &)
bool IsMath() const
static SvxAbstractDialogFactory * Create()
static MapUnit UnoEmbed2VCLMapUnit(sal_Int32 nUnoEmbedMapUnit)
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, OUString &, OUString const *pBaseURL=nullptr)
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
static css::uno::Reference< css::embed::XStorage > GetTemporaryStorage(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
#define SO3_SM_CLASSID_60
#define SO3_SCH_CLASSID_60
void SetGraphicStream(const css::uno::Reference< css::io::XInputStream > &xInGrStream, const OUString &rMediaType)
Size GetSize(MapMode const *pTargetMapMode) const
void SetSize(const Size &)
int nCount
#define TOOLS_WARN_EXCEPTION(area, stream)
EmbeddedObjectRef * pObject
OUString aName
Sequence< sal_Int8 > aSeq
MapUnit
aStr
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
int i
const char GetValue[]
#define SC_MOD()
Definition: scmod.hxx:249
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
#define SC_TAB_INSERTED
Definition: uiitems.hxx:75
@ SC_MARK_SIMPLE
Definition: viewdata.hxx:65