Update ooo320-m1
[ooovba.git] / sc / source / ui / unoobj / drdefuno.cxx
blob60673bcd02acec0da4f3893f898fd5b466b7d1ee
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: drdefuno.cxx,v $
10 * $Revision: 1.6 $
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"
36 #include "drdefuno.hxx"
37 #include "docsh.hxx"
38 #include "drwlayer.hxx"
40 using namespace ::com::sun::star;
42 //------------------------------------------------------------------------
44 ScDrawDefaultsObj::ScDrawDefaultsObj(ScDocShell* pDocSh) :
45 SvxUnoDrawPool( NULL ),
46 pDocShell( pDocSh )
48 // SvxUnoDrawPool is initialized without model,
49 // draw layer is created on demand in getModelPool
51 pDocShell->GetDocument()->AddUnoObject(*this);
54 ScDrawDefaultsObj::~ScDrawDefaultsObj() throw ()
56 if (pDocShell)
57 pDocShell->GetDocument()->RemoveUnoObject(*this);
60 void ScDrawDefaultsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
62 if ( rHint.ISA( SfxSimpleHint ) &&
63 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
65 pDocShell = NULL; // document gone
69 SfxItemPool* ScDrawDefaultsObj::getModelPool( sal_Bool bReadOnly ) throw()
71 SfxItemPool* pRet = NULL;
72 if ( pDocShell )
74 ScDrawLayer* pModel = bReadOnly ?
75 pDocShell->GetDocument()->GetDrawLayer() :
76 pDocShell->MakeDrawLayer();
77 if ( pModel )
78 pRet = &pModel->GetItemPool();
80 if ( !pRet )
81 pRet = SvxUnoDrawPool::getModelPool( bReadOnly ); // uses default pool
83 return pRet;