Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / svdraw / svdoutlinercache.cxx
blob0fc6fc9730ce6f6c8b893a869d27d1ff02950492
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 )
30 std::unique_ptr<SdrOutliner> SdrOutlinerCache::createOutliner( OutlinerMode nOutlinerMode )
32 std::unique_ptr<SdrOutliner> pOutliner;
34 if( (OutlinerMode::OutlineObject == nOutlinerMode) && !maModeOutline.empty() )
36 pOutliner = std::move(maModeOutline.back());
37 maModeOutline.pop_back();
39 else if( (OutlinerMode::TextObject == nOutlinerMode) && !maModeText.empty() )
41 pOutliner = std::move(maModeText.back());
42 maModeText.pop_back();
44 else
46 pOutliner = SdrMakeOutliner(nOutlinerMode, *mpModel);
47 Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
48 pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
49 maActiveOutliners.insert(pOutliner.get());
52 return pOutliner;
55 SdrOutlinerCache::~SdrOutlinerCache()
59 void SdrOutlinerCache::disposeOutliner( std::unique_ptr<SdrOutliner> pOutliner )
61 if( !pOutliner )
62 return;
64 OutlinerMode nOutlMode = pOutliner->GetOutlinerMode();
66 if( OutlinerMode::OutlineObject == nOutlMode )
68 pOutliner->Clear();
69 pOutliner->SetVertical( false );
71 // Deregister on outliner, might be reused from outliner cache
72 pOutliner->SetNotifyHdl( Link<EENotify&,void>() );
73 maModeOutline.emplace_back(std::move(pOutliner));
75 else if( OutlinerMode::TextObject == nOutlMode )
77 pOutliner->Clear();
78 pOutliner->SetVertical( false );
80 // Deregister on outliner, might be reused from outliner cache
81 pOutliner->SetNotifyHdl( Link<EENotify&,void>() );
82 maModeText.emplace_back(std::move(pOutliner));
84 else
86 maActiveOutliners.erase(pOutliner.get());
90 std::vector< SdrOutliner* > SdrOutlinerCache::GetActiveOutliners() const
92 return std::vector< SdrOutliner* >(maActiveOutliners.begin(), maActiveOutliners.end());
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */