1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_SC_SOURCE_FILTER_INC_SCENARIOBUFFER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_SCENARIOBUFFER_HXX
23 #include <oox/helper/refmap.hxx>
24 #include <oox/helper/refvector.hxx>
25 #include "workbookhelper.hxx"
27 namespace oox
{ class AttributeList
; }
28 namespace oox
{ class SequenceInputStream
; }
33 struct ScenarioCellModel
40 explicit ScenarioCellModel();
45 OUString maName
; /// Name of the scenario.
46 OUString maComment
; /// Comment.
47 OUString maUser
; /// Name of user created the scenario.
48 bool mbLocked
; /// True = input cell values locked.
49 bool mbHidden
; /// True = scenario is hidden.
52 explicit ScenarioModel();
55 class Scenario
: public WorkbookHelper
58 explicit Scenario( const WorkbookHelper
& rHelper
, sal_Int16 nSheet
, bool bIsActive
);
60 /** Imports a scenario definition from a scenario element. */
61 void importScenario( const AttributeList
& rAttribs
);
62 /** Imports a new cell for this scenario from an inputCells element. */
63 void importInputCells( const AttributeList
& rAttribs
);
65 /** Imports a scenario definition from a SCENARIO record. */
66 void importScenario( SequenceInputStream
& rStrm
);
67 /** Imports a new cell for this scenario from an INPUTCELLS record. */
68 void importInputCells( SequenceInputStream
& rStrm
);
70 /** Creates the scenario in the Calc document. */
71 void finalizeImport();
74 typedef ::std::vector
< ScenarioCellModel
> ScenarioCellVector
;
76 ScenarioCellVector maCells
; /// Scenario cells.
77 ScenarioModel maModel
; /// Scenario model data.
78 sal_Int16
const mnSheet
; /// Index of the sheet this scenario is based on.
81 struct SheetScenariosModel
83 sal_Int32 mnCurrent
; /// Selected scenario.
84 sal_Int32 mnShown
; /// Visible scenario.
86 explicit SheetScenariosModel();
89 class SheetScenarios
: public WorkbookHelper
92 explicit SheetScenarios( const WorkbookHelper
& rHelper
, sal_Int16 nSheet
);
94 /** Imports sheet scenario settings from a scenarios element. */
95 void importScenarios( const AttributeList
& rAttribs
);
96 /** Imports sheet scenario settings from a SCENARIOS record. */
97 void importScenarios( SequenceInputStream
& rStrm
);
99 /** Creates and returns a new scenario in this collection. */
100 Scenario
& createScenario();
102 /** Creates all scenarios in the Calc sheet. */
103 void finalizeImport();
106 typedef RefVector
< Scenario
> ScenarioVector
;
107 ScenarioVector maScenarios
;
108 SheetScenariosModel maModel
;
109 sal_Int16
const mnSheet
;
112 class ScenarioBuffer
: public WorkbookHelper
115 explicit ScenarioBuffer( const WorkbookHelper
& rHelper
);
117 /** Creates and returns a scenario collection for the passed sheet. */
118 SheetScenarios
& createSheetScenarios( sal_Int16 nSheet
);
120 /** Creates all scenarios in the Calc document. */
121 void finalizeImport();
124 typedef RefMap
< sal_Int16
, SheetScenarios
, ::std::greater
< sal_Int16
> > SheetScenariosMap
;
125 SheetScenariosMap maSheetScenarios
;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */