Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / filter / inc / scenariobuffer.hxx
blobb0e7dc889d6fcb4b4cd71e0cc70ef5d4e8936d5f
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 #ifndef OOX_XLS_SCENARIOBUFFER_HXX
21 #define OOX_XLS_SCENARIOBUFFER_HXX
23 #include <com/sun/star/table/CellAddress.hpp>
24 #include "oox/helper/refmap.hxx"
25 #include "oox/helper/refvector.hxx"
26 #include "workbookhelper.hxx"
28 namespace oox {
29 namespace xls {
31 // ============================================================================
33 struct ScenarioCellModel
35 ::com::sun::star::table::CellAddress maPos;
36 OUString maValue;
37 sal_Int32 mnNumFmtId;
38 bool mbDeleted;
40 explicit ScenarioCellModel();
43 // ----------------------------------------------------------------------------
45 struct ScenarioModel
47 OUString maName; /// Name of the scenario.
48 OUString maComment; /// Comment.
49 OUString maUser; /// Name of user created the scenario.
50 bool mbLocked; /// True = input cell values locked.
51 bool mbHidden; /// True = scenario is hidden.
53 explicit ScenarioModel();
56 // ----------------------------------------------------------------------------
58 class Scenario : public WorkbookHelper
60 public:
61 explicit Scenario( const WorkbookHelper& rHelper, sal_Int16 nSheet );
63 /** Imports a scenario definition from a scenario element. */
64 void importScenario( const AttributeList& rAttribs );
65 /** Imports a new cell for this scenario from a inputCells element. */
66 void importInputCells( const AttributeList& rAttribs );
68 /** Imports a scenario definition from a SCENARIO record. */
69 void importScenario( SequenceInputStream& rStrm );
70 /** Imports a new cell for this scenario from a INPUTCELLS record. */
71 void importInputCells( SequenceInputStream& rStrm );
73 /** Creates the scenario in the Calc document. */
74 void finalizeImport();
76 private:
77 typedef ::std::vector< ScenarioCellModel > ScenarioCellVector;
79 ScenarioCellVector maCells; /// Scenario cells.
80 ScenarioModel maModel; /// Scenario model data.
81 sal_Int16 mnSheet; /// Index of the sheet this scenario is based on.
84 // ============================================================================
86 struct SheetScenariosModel
88 sal_Int32 mnCurrent; /// Selected scenario.
89 sal_Int32 mnShown; /// Visible scenario.
91 explicit SheetScenariosModel();
94 // ----------------------------------------------------------------------------
96 class SheetScenarios : public WorkbookHelper
98 public:
99 explicit SheetScenarios( const WorkbookHelper& rHelper, sal_Int16 nSheet );
101 /** Imports sheet scenario settings from a scenarios element. */
102 void importScenarios( const AttributeList& rAttribs );
103 /** Imports sheet scenario settings from a SCENARIOS record. */
104 void importScenarios( SequenceInputStream& rStrm );
106 /** Creates and returns a new scenario in this collection. */
107 Scenario& createScenario();
109 /** Creates all scenarios in the Calc sheet. */
110 void finalizeImport();
112 private:
113 typedef RefVector< Scenario > ScenarioVector;
114 ScenarioVector maScenarios;
115 SheetScenariosModel maModel;
116 sal_Int16 mnSheet;
119 // ============================================================================
121 class ScenarioBuffer : public WorkbookHelper
123 public:
124 explicit ScenarioBuffer( const WorkbookHelper& rHelper );
126 /** Creates and returns a scenario collection for the passed sheet. */
127 SheetScenarios& createSheetScenarios( sal_Int16 nSheet );
129 /** Creates all scenarios in the Calc document. */
130 void finalizeImport();
132 private:
133 typedef RefMap< sal_Int16, SheetScenarios, ::std::greater< sal_Int16 > > SheetScenariosMap;
134 SheetScenariosMap maSheetScenarios;
137 // ============================================================================
139 } // namespace xls
140 } // namespace oox
142 #endif
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */