Line data Source code
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/XEmbeddedObject.hpp>
21 : #include <com/sun/star/embed/XVisualObject.hpp>
22 : #include <com/sun/star/embed/Aspects.hpp>
23 :
24 :
25 : using namespace com::sun::star;
26 :
27 : #include <unotools/moduleoptions.hxx>
28 : #include <svx/svdoole2.hxx>
29 : #include <svx/svdpage.hxx>
30 : #include <sfx2/objsh.hxx>
31 : #include <sot/storage.hxx>
32 : #include <sfx2/app.hxx>
33 : #include <sot/clsids.hxx>
34 : #include "address.hxx"
35 :
36 : #include "scfobj.hxx"
37 : #include "document.hxx"
38 : #include "drwlayer.hxx"
39 : #include "chartarr.hxx"
40 :
41 :
42 : // STATIC DATA -----------------------------------------------------------
43 :
44 :
45 : //==================================================================
46 :
47 0 : void Sc10InsertObject::InsertChart( ScDocument* pDoc, SCTAB nDestTab, const Rectangle& rRect,
48 : SCTAB nSrcTab, sal_uInt16 nX1, sal_uInt16 nY1, sal_uInt16 nX2, sal_uInt16 nY2 )
49 : {
50 : // wenn Chart nicht installiert ist, darf nicht auf SCH_MOD zugegriffen werden!
51 0 : if ( !SvtModuleOptions().IsChart() )
52 0 : return;
53 :
54 0 : ::rtl::OUString aName;
55 : uno::Reference < embed::XEmbeddedObject > xObj = pDoc->GetDocumentShell()->
56 0 : GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID ).GetByteSequence(), aName );
57 0 : if ( xObj.is() )
58 : {
59 0 : SdrOle2Obj* pSdrOle2Obj = new SdrOle2Obj( ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), aName, rRect );
60 :
61 0 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
62 0 : if (!pModel)
63 : {
64 0 : pDoc->InitDrawLayer();
65 0 : pModel = pDoc->GetDrawLayer();
66 : OSL_ENSURE(pModel,"Draw Layer ?");
67 : }
68 :
69 0 : SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nDestTab));
70 : OSL_ENSURE(pPage,"Page ?");
71 0 : pPage->InsertObject(pSdrOle2Obj);
72 :
73 0 : pSdrOle2Obj->SetLogicRect(rRect); // erst nach InsertObject !!!
74 0 : awt::Size aSz;
75 0 : aSz.Width = rRect.GetSize().Width();
76 0 : aSz.Height = rRect.GetSize().Height();
77 0 : xObj->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, aSz );
78 :
79 : // hier kann das Chart noch nicht mit Daten gefuettert werden,
80 : // weil die Formeln noch nicht berechnet sind.
81 : // Deshalb in die ChartCollection, die Daten werden dann im
82 : // Sc10Import dtor geholt.
83 :
84 0 : ScChartCollection* pColl = pDoc->GetChartCollection();
85 0 : pColl->push_back( new ScChartArray( pDoc, nSrcTab, static_cast<SCCOL>(nX1), static_cast<SCROW>(nY1), static_cast<SCCOL>(nX2), static_cast<SCROW>(nY2), aName ) );
86 0 : }
87 : }
88 :
89 :
90 :
91 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|