Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sc / source / filter / inc / scenariobuffer.hxx
blob97ef44daa573f4fa59f063471c8e1099918f25a0
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 #pragma once
22 #include <oox/helper/refmap.hxx>
23 #include <oox/helper/refvector.hxx>
24 #include "workbookhelper.hxx"
26 namespace oox { class AttributeList; }
27 namespace oox { class SequenceInputStream; }
29 namespace oox::xls {
31 struct ScenarioCellModel
33 ScAddress maPos;
34 OUString maValue;
35 sal_Int32 mnNumFmtId;
36 bool mbDeleted;
38 explicit ScenarioCellModel();
41 struct ScenarioModel
43 OUString maName; /// Name of the scenario.
44 OUString maComment; /// Comment.
45 OUString maUser; /// Name of user created the scenario.
46 bool mbLocked; /// True = input cell values locked.
47 bool mbHidden; /// True = scenario is hidden.
48 bool mbActive;
50 explicit ScenarioModel();
53 class Scenario : public WorkbookHelper
55 public:
56 explicit Scenario( const WorkbookHelper& rHelper, sal_Int16 nSheet, bool bIsActive );
58 /** Imports a scenario definition from a scenario element. */
59 void importScenario( const AttributeList& rAttribs );
60 /** Imports a new cell for this scenario from an inputCells element. */
61 void importInputCells( const AttributeList& rAttribs );
63 /** Imports a scenario definition from a SCENARIO record. */
64 void importScenario( SequenceInputStream& rStrm );
65 /** Imports a new cell for this scenario from an INPUTCELLS record. */
66 void importInputCells( SequenceInputStream& rStrm );
68 /** Creates the scenario in the Calc document. */
69 void finalizeImport();
71 private:
72 std::vector< ScenarioCellModel > maCells; /// Scenario cells.
73 ScenarioModel maModel; /// Scenario model data.
74 sal_Int16 mnSheet; /// Index of the sheet this scenario is based on.
77 struct SheetScenariosModel
79 sal_Int32 mnCurrent; /// Selected scenario.
80 sal_Int32 mnShown; /// Visible scenario.
82 explicit SheetScenariosModel();
85 class SheetScenarios : public WorkbookHelper
87 public:
88 explicit SheetScenarios( const WorkbookHelper& rHelper, sal_Int16 nSheet );
90 /** Imports sheet scenario settings from a scenarios element. */
91 void importScenarios( const AttributeList& rAttribs );
92 /** Imports sheet scenario settings from a SCENARIOS record. */
93 void importScenarios( SequenceInputStream& rStrm );
95 /** Creates and returns a new scenario in this collection. */
96 Scenario& createScenario();
98 /** Creates all scenarios in the Calc sheet. */
99 void finalizeImport();
101 private:
102 typedef RefVector< Scenario > ScenarioVector;
103 ScenarioVector maScenarios;
104 SheetScenariosModel maModel;
105 sal_Int16 mnSheet;
108 class ScenarioBuffer : public WorkbookHelper
110 public:
111 explicit ScenarioBuffer( const WorkbookHelper& rHelper );
113 /** Creates and returns a scenario collection for the passed sheet. */
114 SheetScenarios& createSheetScenarios( sal_Int16 nSheet );
116 /** Creates all scenarios in the Calc document. */
117 void finalizeImport();
119 private:
120 typedef RefMap< sal_Int16, SheetScenarios, ::std::greater< sal_Int16 > > SheetScenariosMap;
121 SheetScenariosMap maSheetScenarios;
124 } // namespace oox::xls
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */