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 "svdoutlinercache.hxx"
21 : #include <svx/svdoutl.hxx>
22 : #include <svx/svdmodel.hxx>
23 : #include <svx/svdetc.hxx>
24 :
25 1237 : SdrOutlinerCache::SdrOutlinerCache( SdrModel* pModel )
26 : : mpModel( pModel ),
27 : mpModeOutline( NULL ),
28 1237 : mpModeText( NULL )
29 : {
30 1237 : }
31 :
32 21575 : SdrOutliner* SdrOutlinerCache::createOutliner( sal_uInt16 nOutlinerMode )
33 : {
34 21575 : SdrOutliner* pOutliner = NULL;
35 :
36 21575 : if( (OUTLINERMODE_OUTLINEOBJECT == nOutlinerMode) && mpModeOutline )
37 : {
38 2 : pOutliner = mpModeOutline;
39 2 : mpModeOutline = NULL;
40 : }
41 21573 : else if( (OUTLINERMODE_TEXTOBJECT == nOutlinerMode) && mpModeText )
42 : {
43 6811 : pOutliner = mpModeText;
44 6811 : mpModeText = NULL;
45 : }
46 : else
47 : {
48 14762 : pOutliner = SdrMakeOutliner(nOutlinerMode, *mpModel);
49 14762 : Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
50 14762 : pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
51 14762 : maActiveOutliners.push_back(pOutliner);
52 : }
53 :
54 21575 : return pOutliner;
55 : }
56 :
57 2420 : SdrOutlinerCache::~SdrOutlinerCache()
58 : {
59 1210 : if( mpModeOutline )
60 : {
61 44 : delete mpModeOutline;
62 44 : mpModeOutline = NULL;
63 : }
64 :
65 1210 : if( mpModeText )
66 : {
67 1210 : delete mpModeText;
68 1210 : mpModeText = NULL;
69 : }
70 1210 : }
71 :
72 21327 : void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner )
73 : {
74 21327 : if( pOutliner )
75 : {
76 21327 : sal_uInt16 nOutlMode = pOutliner->GetOutlinerMode();
77 :
78 21327 : if( (OUTLINERMODE_OUTLINEOBJECT == nOutlMode) && (NULL == mpModeOutline) )
79 : {
80 46 : mpModeOutline = pOutliner;
81 46 : pOutliner->Clear();
82 46 : pOutliner->SetVertical( false );
83 :
84 : // Deregister on outliner, might be reused from outliner cache
85 46 : pOutliner->SetNotifyHdl( Link() );
86 : }
87 21281 : else if( (OUTLINERMODE_TEXTOBJECT == nOutlMode) && (NULL == mpModeText) )
88 : {
89 8027 : mpModeText = pOutliner;
90 8027 : pOutliner->Clear();
91 8027 : pOutliner->SetVertical( false );
92 :
93 : // Deregister on outliner, might be reused from outliner cache
94 8027 : pOutliner->SetNotifyHdl( Link() );
95 : }
96 : else
97 : {
98 13254 : maActiveOutliners.erase(std::remove(maActiveOutliners.begin(), maActiveOutliners.end(), pOutliner), maActiveOutliners.end());
99 13254 : delete pOutliner;
100 : }
101 : }
102 21978 : }
103 :
104 :
105 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|