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 OOX_XLS_SCENARIOBUFFER_HXX
21 : #define OOX_XLS_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 : // ============================================================================
32 :
33 0 : struct ScenarioCellModel
34 : {
35 : ::com::sun::star::table::CellAddress maPos;
36 : ::rtl::OUString maValue;
37 : sal_Int32 mnNumFmtId;
38 : bool mbDeleted;
39 :
40 : explicit ScenarioCellModel();
41 : };
42 :
43 : // ----------------------------------------------------------------------------
44 :
45 0 : struct ScenarioModel
46 : {
47 : ::rtl::OUString maName; /// Name of the scenario.
48 : ::rtl::OUString maComment; /// Comment.
49 : ::rtl::OUString maUser; /// Name of user created the scenario.
50 : bool mbLocked; /// True = input cell values locked.
51 : bool mbHidden; /// True = scenario is hidden.
52 :
53 : explicit ScenarioModel();
54 : };
55 :
56 : // ----------------------------------------------------------------------------
57 :
58 0 : class Scenario : public WorkbookHelper
59 : {
60 : public:
61 : explicit Scenario( const WorkbookHelper& rHelper, sal_Int16 nSheet );
62 :
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 );
67 :
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 );
72 :
73 : /** Creates the scenario in the Calc document. */
74 : void finalizeImport();
75 :
76 : private:
77 : typedef ::std::vector< ScenarioCellModel > ScenarioCellVector;
78 :
79 : ScenarioCellVector maCells; /// Scenario cells.
80 : ScenarioModel maModel; /// Scenario model data.
81 : sal_Int16 mnSheet; /// Index of the sheet this scenario is based on.
82 : };
83 :
84 : // ============================================================================
85 :
86 : struct SheetScenariosModel
87 : {
88 : sal_Int32 mnCurrent; /// Selected scenario.
89 : sal_Int32 mnShown; /// Visible scenario.
90 :
91 : explicit SheetScenariosModel();
92 : };
93 :
94 : // ----------------------------------------------------------------------------
95 :
96 0 : class SheetScenarios : public WorkbookHelper
97 : {
98 : public:
99 : explicit SheetScenarios( const WorkbookHelper& rHelper, sal_Int16 nSheet );
100 :
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 );
105 :
106 : /** Creates and returns a new scenario in this collection. */
107 : Scenario& createScenario();
108 :
109 : /** Creates all scenarios in the Calc sheet. */
110 : void finalizeImport();
111 :
112 : private:
113 : typedef RefVector< Scenario > ScenarioVector;
114 : ScenarioVector maScenarios;
115 : SheetScenariosModel maModel;
116 : sal_Int16 mnSheet;
117 : };
118 :
119 : // ============================================================================
120 :
121 22 : class ScenarioBuffer : public WorkbookHelper
122 : {
123 : public:
124 : explicit ScenarioBuffer( const WorkbookHelper& rHelper );
125 :
126 : /** Creates and returns a scenario collection for the passed sheet. */
127 : SheetScenarios& createSheetScenarios( sal_Int16 nSheet );
128 :
129 : /** Creates all scenarios in the Calc document. */
130 : void finalizeImport();
131 :
132 : private:
133 : typedef RefMap< sal_Int16, SheetScenarios, ::std::greater< sal_Int16 > > SheetScenariosMap;
134 : SheetScenariosMap maSheetScenarios;
135 : };
136 :
137 : // ============================================================================
138 :
139 : } // namespace xls
140 : } // namespace oox
141 :
142 : #endif
143 :
144 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|