23 #include <osl/diagnose.h>
41 #include <com/sun/star/awt/Point.hpp>
42 #include <com/sun/star/awt/Size.hpp>
43 #include <com/sun/star/awt/XWindow.hpp>
45 #include <com/sun/star/chart2/data/XDataProvider.hpp>
46 #include <com/sun/star/frame/XModel.hpp>
47 #include <com/sun/star/lang/XInitialization.hpp>
48 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
49 #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
59 OSL_ENSURE( pParentWin,
"Window not found" );
70 bool bCenterHor =
false;
86 bool bFitLeft = ( aObjAbs.
Left() - aDesktop.
Left() >= rDialogSize.
Width() + aSpace.
Width() );
89 if ( bFitLeft || bFitRight )
92 bool bPutRight = bFitRight && ( bLayoutRTL || !bFitLeft );
96 aRet.setX( aObjAbs.
Left() - rDialogSize.
Width() - aSpace.
Width() );
112 if ( aRet.X() + rDialogSize.
Width() - 1 > aDesktop.
Right() )
113 aRet.setX( aDesktop.
Right() - rDialogSize.
Width() + 1 );
114 if ( aRet.X() < aDesktop.
Left() )
115 aRet.setX( aDesktop.
Left() );
116 if ( aRet.Y() + rDialogSize.
Height() - 1 > aDesktop.
Bottom() )
117 aRet.setY( aDesktop.
Bottom() - rDialogSize.
Height() + 1 );
118 if ( aRet.Y() < aDesktop.
Top() )
119 aRet.setY( aDesktop.
Top() );
131 uno::Reference< chart2::data::XDataProvider > xDataProvider;
132 uno::Reference< frame::XModel > xChartModel;
133 OUString aRangeString;
154 xChartModel.set(
SwTableFUNC( &rWrtShell ).InsertChart( xDataProvider, xDataProvider.is(), aRangeString, &pFlyFrameFormat ));
158 uno::Reference< uno::XComponentContext > xContext(
160 if( !(xContext.is() && xChartModel.is() && xDataProvider.is()))
163 uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
167 uno::Reference< ui::dialogs::XAsynchronousExecutableDialog > xDialog(
168 xMCF->createInstanceWithContext(
169 "com.sun.star.comp.chart2.WizardDialog", xContext),
171 uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY );
177 {
"ParentWindow",
uno::Any(uno::Reference< awt::XWindow >())},
178 {
"ChartModel",
uno::Any(xChartModel)}
180 xInit->initialize( aSeq );
183 uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY );
184 if ( xDialogProps.is() )
189 awt::Size aDialogAWTSize;
190 if( xDialogProps->getPropertyValue(
"Size")
193 Size aDialogSize( aDialogAWTSize.Width, aDialogAWTSize.Height );
202 xDialogProps->setPropertyValue(
"Position",
203 uno::Any( awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) );
207 catch (
const uno::Exception&)
209 OSL_FAIL(
"Chart wizard couldn't be positioned automatically" );
214 pListener->SetDialogClosedLink( rLink );
216 xDialog->startExecuteModal( pListener );
220 uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY );
222 xComponent->dispose();
SfxViewFrame * GetViewFrame() const
SfxDispatcher * GetDispatcher()
tools::Rectangle GetDesktopRectPixel() const
Of course Writer needs its own rectangles.
SwWrtShell & GetWrtShell() const
Used by the UI to modify the document model.
Point SwGetChartDialogPos(const vcl::Window *pParentWin, const Size &rDialogSize, const tools::Rectangle &rLogicChart)
constexpr tools::Long Width() const
const SwView & GetView() const
#define FN_TABLE_SELECT_ALL
bool IsTableRightToLeft() const
const SwTableNode * IsCursorInTable() const
Point LogicToPixel(const Point &rLogicPt) const
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
virtual SwChartDataProvider * GetChartDataProvider(bool bCreate=false) const =0
returns or creates the data-provider for chart
const MapMode & GetMapMode() const
const SwRect & GetObjRectWithSpaces() const
method to determine object area inclusive its spacing
CPPUHELPER_DLLPUBLIC css::uno::Reference< css::uno::XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext()
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
OUString GetBoxNms() const
SwDocShell * GetDocShell()
SwFrameFormat * GetTableFormat()
tools::Rectangle SVRect() const
constexpr tools::Long Height() const
IDocumentChartDataProviderAccess & getIDocumentChartDataProviderAccess()
Sequence< sal_Int8 > aSeq
SwInsertChart(const Link< css::ui::dialogs::DialogClosedEvent *, void > &rLink)
bool IsTableComplexForChart()