Update ooo320-m1
[ooovba.git] / sc / source / filter / starcalc / scfobj.cxx
blob642e19fc60d1c18606850e1cd06426a968d71d84
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: scfobj.cxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
35 #include <com/sun/star/embed/XEmbeddedObject.hpp>
36 #include <com/sun/star/embed/XVisualObject.hpp>
37 #include <com/sun/star/embed/Aspects.hpp>
40 using namespace com::sun::star;
42 // INCLUDE ---------------------------------------------------------------
44 #include <svtools/moduleoptions.hxx>
45 #include <svx/svdoole2.hxx>
46 #include <svx/svdpage.hxx>
47 #include <sfx2/objsh.hxx>
48 #include <sot/storage.hxx>
49 #include <sfx2/app.hxx>
50 #include <sot/clsids.hxx>
51 #include "address.hxx"
53 #include "scfobj.hxx"
54 #include "document.hxx"
55 #include "drwlayer.hxx"
56 #include "chartarr.hxx"
59 // STATIC DATA -----------------------------------------------------------
62 //==================================================================
64 void Sc10InsertObject::InsertChart( ScDocument* pDoc, SCTAB nDestTab, const Rectangle& rRect,
65 SCTAB nSrcTab, USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2 )
67 // wenn Chart nicht installiert ist, darf nicht auf SCH_MOD zugegriffen werden!
68 if ( !SvtModuleOptions().IsChart() )
69 return;
71 ::rtl::OUString aName;
72 uno::Reference < embed::XEmbeddedObject > xObj = pDoc->GetDocumentShell()->
73 GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID ).GetByteSequence(), aName );
74 if ( xObj.is() )
76 SdrOle2Obj* pSdrOle2Obj = new SdrOle2Obj( ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), aName, rRect );
78 ScDrawLayer* pModel = pDoc->GetDrawLayer();
79 if (!pModel)
81 pDoc->InitDrawLayer();
82 pModel = pDoc->GetDrawLayer();
83 DBG_ASSERT(pModel,"Draw Layer ?");
86 SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nDestTab));
87 DBG_ASSERT(pPage,"Page ?");
88 pPage->InsertObject(pSdrOle2Obj);
90 pSdrOle2Obj->SetLogicRect(rRect); // erst nach InsertObject !!!
91 awt::Size aSz;
92 aSz.Width = rRect.GetSize().Width();
93 aSz.Height = rRect.GetSize().Height();
94 xObj->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, aSz );
96 // hier kann das Chart noch nicht mit Daten gefuettert werden,
97 // weil die Formeln noch nicht berechnet sind.
98 // Deshalb in die ChartCollection, die Daten werden dann im
99 // Sc10Import dtor geholt.
101 ScChartCollection* pColl = pDoc->GetChartCollection();
102 pColl->Insert( new ScChartArray( pDoc, nSrcTab, static_cast<SCCOL>(nX1), static_cast<SCROW>(nY1), static_cast<SCCOL>(nX2), static_cast<SCROW>(nY2), aName ) );