fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / starcalc / scfobj.cxx
blob6216c845601b596d6e7fe5efe8e8f441228ff417
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/XEmbeddedObject.hpp>
21 #include <com/sun/star/embed/XVisualObject.hpp>
22 #include <com/sun/star/embed/Aspects.hpp>
24 using namespace com::sun::star;
26 #include <unotools/moduleoptions.hxx>
27 #include <svx/charthelper.hxx>
28 #include <svx/svdoole2.hxx>
29 #include <svx/svdpage.hxx>
30 #include <svtools/embedhlp.hxx>
31 #include <sfx2/objsh.hxx>
32 #include <sot/storage.hxx>
33 #include <sfx2/app.hxx>
34 #include <comphelper/classids.hxx>
35 #include "address.hxx"
37 #include "scfobj.hxx"
38 #include "document.hxx"
39 #include "drwlayer.hxx"
40 #include "chartarr.hxx"
42 // STATIC DATA -----------------------------------------------------------
44 void Sc10InsertObject::InsertChart( ScDocument* pDoc, SCTAB nDestTab, const Rectangle& rRect,
45 SCTAB nSrcTab, sal_uInt16 nX1, sal_uInt16 nY1, sal_uInt16 nX2, sal_uInt16 nY2 )
47 // if Chart is not installed, SCH_MOD cannot be used!
48 if ( !SvtModuleOptions().IsChart() )
49 return;
51 OUString aName;
52 uno::Reference < embed::XEmbeddedObject > xObj = pDoc->GetDocumentShell()->
53 GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID ).GetByteSequence(), aName );
54 if ( xObj.is() )
56 SdrOle2Obj* pSdrOle2Obj = new SdrOle2Obj( ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), aName, rRect );
58 ScDrawLayer* pModel = pDoc->GetDrawLayer();
59 if (!pModel)
61 pDoc->InitDrawLayer();
62 pModel = pDoc->GetDrawLayer();
63 OSL_ENSURE(pModel,"Draw Layer ?");
66 SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nDestTab));
67 OSL_ENSURE(pPage,"Page ?");
68 pPage->InsertObject(pSdrOle2Obj);
70 pSdrOle2Obj->SetLogicRect(rRect); // only after InsertObject !!!
71 awt::Size aSz;
72 aSz.Width = rRect.GetSize().Width();
73 aSz.Height = rRect.GetSize().Height();
74 xObj->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, aSz );
76 // #i121334# This call will change the chart's default background fill from white to transparent.
77 // Add here again if this is wanted (see task description for details)
78 // ChartHelper::AdaptDefaultsForChart( xObj );
80 // Cannot set source of chart here yet as formulas are not calculated yet.
81 // Thus push into ChartCollection; the data is set in Sc10Import dtor.
83 ScChartCollection* pColl = pDoc->GetChartCollection();
84 pColl->push_back( new ScChartArray( pDoc, nSrcTab, static_cast<SCCOL>(nX1), static_cast<SCROW>(nY1), static_cast<SCCOL>(nX2), static_cast<SCROW>(nY2), aName ) );
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */