1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 
32 #include "svdoutlinercache.hxx"
33 #include <svx/svdoutl.hxx>
34 #include <svx/svdmodel.hxx>
35 
36 extern SdrOutliner* SdrMakeOutliner( sal_uInt16 nOutlinerMode, SdrModel* pModel );
37 
38 SdrOutlinerCache::SdrOutlinerCache( SdrModel* pModel )
39 :	mpModel( pModel ),
40 	mpModeOutline( NULL ),
41 	mpModeText( NULL )
42 {
43 }
44 
45 SdrOutliner* SdrOutlinerCache::createOutliner( sal_uInt16 nOutlinerMode )
46 {
47 	SdrOutliner* pOutliner = NULL;
48 
49 	if( (OUTLINERMODE_OUTLINEOBJECT == nOutlinerMode) && mpModeOutline )
50 	{
51 		pOutliner = mpModeOutline;
52 		mpModeOutline = NULL;
53 	}
54 	else if( (OUTLINERMODE_TEXTOBJECT == nOutlinerMode) && mpModeText )
55 	{
56 		pOutliner = mpModeText;
57 		mpModeText = NULL;
58 	}
59 	else
60 	{
61 		pOutliner = SdrMakeOutliner( nOutlinerMode, mpModel );
62 		Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
63 		pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
64 	}
65 
66 	return pOutliner;
67 }
68 
69 SdrOutlinerCache::~SdrOutlinerCache()
70 {
71 	if( mpModeOutline )
72 	{
73 		delete mpModeOutline;
74 		mpModeOutline = NULL;
75 	}
76 
77 	if( mpModeText )
78 	{
79 		delete mpModeText;
80 		mpModeText = NULL;
81 	}
82 }
83 
84 void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner )
85 {
86 	if( pOutliner )
87 	{
88 		sal_uInt16 nOutlMode = pOutliner->GetOutlinerMode();
89 
90 		if( (OUTLINERMODE_OUTLINEOBJECT == nOutlMode) && (NULL == mpModeOutline) )
91 		{
92 			mpModeOutline = pOutliner;
93 			pOutliner->Clear();
94 			pOutliner->SetVertical( false );
95 
96 			// #101088# Deregister on outliner, might be reused from outliner cache
97 			pOutliner->SetNotifyHdl( Link() );
98 		}
99 		else if( (OUTLINERMODE_TEXTOBJECT == nOutlMode) && (NULL == mpModeText) )
100 		{
101 			mpModeText = pOutliner;
102 			pOutliner->Clear();
103 			pOutliner->SetVertical( false );
104 
105 			// #101088# Deregister on outliner, might be reused from outliner cache
106 			pOutliner->SetNotifyHdl( Link() );
107 		}
108 		else
109 		{
110 			delete pOutliner;
111 		}
112 	}
113 }
114 
115 
116