bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / svdraw / svdoutlinercache.cxx
blobc715a4dbb765e5e8d6436b9cc73ce1daa481a883
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "svdoutlinercache.hxx"
21 #include <svx/svdoutl.hxx>
22 #include <svx/svdmodel.hxx>
23 #include <svx/svdetc.hxx>
25 SdrOutlinerCache::SdrOutlinerCache( SdrModel* pModel )
26 : mpModel( pModel ),
27 mpModeOutline( NULL ),
28 mpModeText( NULL )
32 SdrOutliner* SdrOutlinerCache::createOutliner( sal_uInt16 nOutlinerMode )
34 SdrOutliner* pOutliner = NULL;
36 if( (OUTLINERMODE_OUTLINEOBJECT == nOutlinerMode) && mpModeOutline )
38 pOutliner = mpModeOutline;
39 mpModeOutline = NULL;
41 else if( (OUTLINERMODE_TEXTOBJECT == nOutlinerMode) && mpModeText )
43 pOutliner = mpModeText;
44 mpModeText = NULL;
46 else
48 pOutliner = SdrMakeOutliner(nOutlinerMode, *mpModel);
49 Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
50 pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
51 maActiveOutliners.push_back(pOutliner);
54 return pOutliner;
57 SdrOutlinerCache::~SdrOutlinerCache()
59 if( mpModeOutline )
61 delete mpModeOutline;
62 mpModeOutline = NULL;
65 if( mpModeText )
67 delete mpModeText;
68 mpModeText = NULL;
72 void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner )
74 if( pOutliner )
76 sal_uInt16 nOutlMode = pOutliner->GetOutlinerMode();
78 if( (OUTLINERMODE_OUTLINEOBJECT == nOutlMode) && (NULL == mpModeOutline) )
80 mpModeOutline = pOutliner;
81 pOutliner->Clear();
82 pOutliner->SetVertical( false );
84 // Deregister on outliner, might be reused from outliner cache
85 pOutliner->SetNotifyHdl( Link<>() );
87 else if( (OUTLINERMODE_TEXTOBJECT == nOutlMode) && (NULL == mpModeText) )
89 mpModeText = pOutliner;
90 pOutliner->Clear();
91 pOutliner->SetVertical( false );
93 // Deregister on outliner, might be reused from outliner cache
94 pOutliner->SetNotifyHdl( Link<>() );
96 else
98 maActiveOutliners.erase(std::remove(maActiveOutliners.begin(), maActiveOutliners.end(), pOutliner), maActiveOutliners.end());
99 delete pOutliner;
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */