LibreOffice Module svx (master)  1
svdoutlinercache.cxx
Go to the documentation of this file.
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 
26 : mpModel( pModel )
27 {
28 }
29 
30 std::unique_ptr<SdrOutliner> SdrOutlinerCache::createOutliner( OutlinerMode nOutlinerMode )
31 {
32  std::unique_ptr<SdrOutliner> pOutliner;
33 
34  if( (OutlinerMode::OutlineObject == nOutlinerMode) && !maModeOutline.empty() )
35  {
36  pOutliner = std::move(maModeOutline.back());
37  maModeOutline.pop_back();
38  }
39  else if( (OutlinerMode::TextObject == nOutlinerMode) && !maModeText.empty() )
40  {
41  pOutliner = std::move(maModeText.back());
42  maModeText.pop_back();
43  }
44  else
45  {
46  pOutliner = SdrMakeOutliner(nOutlinerMode, *mpModel);
47  Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
48  pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
49  maActiveOutliners.insert(pOutliner.get());
50  }
51 
52  return pOutliner;
53 }
54 
56 {
57 }
58 
59 void SdrOutlinerCache::disposeOutliner( std::unique_ptr<SdrOutliner> pOutliner )
60 {
61  if( !pOutliner )
62  return;
63 
64  OutlinerMode nOutlMode = pOutliner->GetOutlinerMode();
65 
66  if( OutlinerMode::OutlineObject == nOutlMode )
67  {
68  pOutliner->Clear();
69  pOutliner->SetVertical( false );
70 
71  // Deregister on outliner, might be reused from outliner cache
72  pOutliner->SetNotifyHdl( Link<EENotify&,void>() );
73  maModeOutline.emplace_back(std::move(pOutliner));
74  }
75  else if( OutlinerMode::TextObject == nOutlMode )
76  {
77  pOutliner->Clear();
78  pOutliner->SetVertical( false );
79 
80  // Deregister on outliner, might be reused from outliner cache
81  pOutliner->SetNotifyHdl( Link<EENotify&,void>() );
82  maModeText.emplace_back(std::move(pOutliner));
83  }
84  else
85  {
86  maActiveOutliners.erase(pOutliner.get());
87  }
88 }
89 
90 std::vector< SdrOutliner* > SdrOutlinerCache::GetActiveOutliners() const
91 {
92  return std::vector< SdrOutliner* >(maActiveOutliners.begin(), maActiveOutliners.end());
93 }
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdrOutliner & GetDrawOutliner(const SdrTextObj *pObj=nullptr) const
Definition: svdmodel.cxx:648
OutlinerMode
std::vector< std::unique_ptr< SdrOutliner > > maModeText
void disposeOutliner(std::unique_ptr< SdrOutliner > pOutliner)
std::unique_ptr< SdrOutliner > createOutliner(OutlinerMode nOutlinerMode)
void SetCalcFieldValueHdl(const Link< EditFieldInfo *, void > &rLink)
const_iterator end() const
std::vector< SdrOutliner * > GetActiveOutliners() const
const_iterator begin() const
std::vector< std::unique_ptr< SdrOutliner > > maModeOutline
SdrOutlinerCache(SdrModel *pModel)
o3tl::sorted_vector< SdrOutliner * > maActiveOutliners
std::unique_ptr< SdrOutliner > SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel &rModel)
Create an Outliner with the engine-global default settings on the heap.
Definition: svdetc.cxx:333
const Link< EditFieldInfo *, void > & GetCalcFieldValueHdl() const
std::pair< const_iterator, bool > insert(Value &&x)
size_type erase(const Value &x)