1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26
27
28 #include "svdoutlinercache.hxx"
29 #include <svx/svdoutl.hxx>
30 #include <svx/svdmodel.hxx>
31
32 extern SdrOutliner* SdrMakeOutliner( sal_uInt16 nOutlinerMode, SdrModel* pModel );
33
SdrOutlinerCache(SdrModel * pModel)34 SdrOutlinerCache::SdrOutlinerCache( SdrModel* pModel )
35 : mpModel( pModel ),
36 mpModeOutline( NULL ),
37 mpModeText( NULL )
38 {
39 }
40
createOutliner(sal_uInt16 nOutlinerMode)41 SdrOutliner* SdrOutlinerCache::createOutliner( sal_uInt16 nOutlinerMode )
42 {
43 SdrOutliner* pOutliner = NULL;
44
45 if( (OUTLINERMODE_OUTLINEOBJECT == nOutlinerMode) && mpModeOutline )
46 {
47 pOutliner = mpModeOutline;
48 mpModeOutline = NULL;
49 }
50 else if( (OUTLINERMODE_TEXTOBJECT == nOutlinerMode) && mpModeText )
51 {
52 pOutliner = mpModeText;
53 mpModeText = NULL;
54 }
55 else
56 {
57 pOutliner = SdrMakeOutliner( nOutlinerMode, mpModel );
58 Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
59 pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
60 }
61
62 return pOutliner;
63 }
64
~SdrOutlinerCache()65 SdrOutlinerCache::~SdrOutlinerCache()
66 {
67 if( mpModeOutline )
68 {
69 delete mpModeOutline;
70 mpModeOutline = NULL;
71 }
72
73 if( mpModeText )
74 {
75 delete mpModeText;
76 mpModeText = NULL;
77 }
78 }
79
disposeOutliner(SdrOutliner * pOutliner)80 void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner )
81 {
82 if( pOutliner )
83 {
84 sal_uInt16 nOutlMode = pOutliner->GetOutlinerMode();
85
86 if( (OUTLINERMODE_OUTLINEOBJECT == nOutlMode) && (NULL == mpModeOutline) )
87 {
88 mpModeOutline = pOutliner;
89 pOutliner->Clear();
90 pOutliner->SetVertical( false );
91
92 // #101088# Deregister on outliner, might be reused from outliner cache
93 pOutliner->SetNotifyHdl( Link() );
94 }
95 else if( (OUTLINERMODE_TEXTOBJECT == nOutlMode) && (NULL == mpModeText) )
96 {
97 mpModeText = pOutliner;
98 pOutliner->Clear();
99 pOutliner->SetVertical( false );
100
101 // #101088# Deregister on outliner, might be reused from outliner cache
102 pOutliner->SetNotifyHdl( Link() );
103 }
104 else
105 {
106 delete pOutliner;
107 }
108 }
109 }
110
111
112