Line data Source code
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 : #ifndef INCLUDED_SC_SOURCE_FILTER_INC_SCENARIOBUFFER_HXX
21 : #define INCLUDED_SC_SOURCE_FILTER_INC_SCENARIOBUFFER_HXX
22 :
23 : #include <com/sun/star/table/CellAddress.hpp>
24 : #include <oox/helper/refmap.hxx>
25 : #include <oox/helper/refvector.hxx>
26 : #include "workbookhelper.hxx"
27 :
28 : namespace oox {
29 : namespace xls {
30 :
31 0 : struct ScenarioCellModel
32 : {
33 : ::com::sun::star::table::CellAddress maPos;
34 : OUString maValue;
35 : sal_Int32 mnNumFmtId;
36 : bool mbDeleted;
37 :
38 : explicit ScenarioCellModel();
39 : };
40 :
41 0 : struct ScenarioModel
42 : {
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 :
49 : explicit ScenarioModel();
50 : };
51 :
52 0 : class Scenario : public WorkbookHelper
53 : {
54 : public:
55 : explicit Scenario( const WorkbookHelper& rHelper, sal_Int16 nSheet );
56 :
57 : /** Imports a scenario definition from a scenario element. */
58 : void importScenario( const AttributeList& rAttribs );
59 : /** Imports a new cell for this scenario from a inputCells element. */
60 : void importInputCells( const AttributeList& rAttribs );
61 :
62 : /** Imports a scenario definition from a SCENARIO record. */
63 : void importScenario( SequenceInputStream& rStrm );
64 : /** Imports a new cell for this scenario from a INPUTCELLS record. */
65 : void importInputCells( SequenceInputStream& rStrm );
66 :
67 : /** Creates the scenario in the Calc document. */
68 : void finalizeImport();
69 :
70 : private:
71 : typedef ::std::vector< ScenarioCellModel > ScenarioCellVector;
72 :
73 : ScenarioCellVector maCells; /// Scenario cells.
74 : ScenarioModel maModel; /// Scenario model data.
75 : sal_Int16 mnSheet; /// Index of the sheet this scenario is based on.
76 : };
77 :
78 : struct SheetScenariosModel
79 : {
80 : sal_Int32 mnCurrent; /// Selected scenario.
81 : sal_Int32 mnShown; /// Visible scenario.
82 :
83 : explicit SheetScenariosModel();
84 : };
85 :
86 0 : class SheetScenarios : public WorkbookHelper
87 : {
88 : public:
89 : explicit SheetScenarios( const WorkbookHelper& rHelper, sal_Int16 nSheet );
90 :
91 : /** Imports sheet scenario settings from a scenarios element. */
92 : void importScenarios( const AttributeList& rAttribs );
93 : /** Imports sheet scenario settings from a SCENARIOS record. */
94 : void importScenarios( SequenceInputStream& rStrm );
95 :
96 : /** Creates and returns a new scenario in this collection. */
97 : Scenario& createScenario();
98 :
99 : /** Creates all scenarios in the Calc sheet. */
100 : void finalizeImport();
101 :
102 : private:
103 : typedef RefVector< Scenario > ScenarioVector;
104 : ScenarioVector maScenarios;
105 : SheetScenariosModel maModel;
106 : sal_Int16 mnSheet;
107 : };
108 :
109 290 : class ScenarioBuffer : public WorkbookHelper
110 : {
111 : public:
112 : explicit ScenarioBuffer( const WorkbookHelper& rHelper );
113 :
114 : /** Creates and returns a scenario collection for the passed sheet. */
115 : SheetScenarios& createSheetScenarios( sal_Int16 nSheet );
116 :
117 : /** Creates all scenarios in the Calc document. */
118 : void finalizeImport();
119 :
120 : private:
121 : typedef RefMap< sal_Int16, SheetScenarios, ::std::greater< sal_Int16 > > SheetScenariosMap;
122 : SheetScenariosMap maSheetScenarios;
123 : };
124 :
125 : } // namespace xls
126 : } // namespace oox
127 :
128 : #endif
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|