merge the formfield patch from ooo-build
[ooovba.git] / svx / source / svdraw / svdoutlinercache.cxx
blobb8f73bea43def1ef681d972d69c214cb755ab6ab
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: svdoutlinercache.cxx,v $
10 * $Revision: 1.7 $
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_svx.hxx"
35 #include "svdoutlinercache.hxx"
36 #include <svx/svdoutl.hxx>
37 #include <svx/svdmodel.hxx>
39 extern SdrOutliner* SdrMakeOutliner( USHORT nOutlinerMode, SdrModel* pModel );
41 SdrOutlinerCache::SdrOutlinerCache( SdrModel* pModel )
42 : mpModel( pModel ),
43 mpModeOutline( NULL ),
44 mpModeText( NULL )
48 SdrOutliner* SdrOutlinerCache::createOutliner( sal_uInt16 nOutlinerMode )
50 SdrOutliner* pOutliner = NULL;
52 if( (OUTLINERMODE_OUTLINEOBJECT == nOutlinerMode) && mpModeOutline )
54 pOutliner = mpModeOutline;
55 mpModeOutline = NULL;
57 else if( (OUTLINERMODE_TEXTOBJECT == nOutlinerMode) && mpModeText )
59 pOutliner = mpModeText;
60 mpModeText = NULL;
62 else
64 pOutliner = SdrMakeOutliner( nOutlinerMode, mpModel );
65 Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
66 pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
69 return pOutliner;
72 SdrOutlinerCache::~SdrOutlinerCache()
74 if( mpModeOutline )
76 delete mpModeOutline;
77 mpModeOutline = NULL;
80 if( mpModeText )
82 delete mpModeText;
83 mpModeText = NULL;
87 void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner )
89 if( pOutliner )
91 USHORT nOutlMode = pOutliner->GetOutlinerMode();
93 if( (OUTLINERMODE_OUTLINEOBJECT == nOutlMode) && (NULL == mpModeOutline) )
95 mpModeOutline = pOutliner;
96 pOutliner->Clear();
97 pOutliner->SetVertical( false );
99 // #101088# Deregister on outliner, might be reused from outliner cache
100 pOutliner->SetNotifyHdl( Link() );
102 else if( (OUTLINERMODE_TEXTOBJECT == nOutlMode) && (NULL == mpModeText) )
104 mpModeText = pOutliner;
105 pOutliner->Clear();
106 pOutliner->SetVertical( false );
108 // #101088# Deregister on outliner, might be reused from outliner cache
109 pOutliner->SetNotifyHdl( Link() );
111 else
113 delete pOutliner;