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 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"
31 // ============================================================================
33 struct ScenarioCellModel
35 ::com::sun::star::table::CellAddress maPos
;
40 explicit ScenarioCellModel();
43 // ----------------------------------------------------------------------------
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
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();
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
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();
113 typedef RefVector
< Scenario
> ScenarioVector
;
114 ScenarioVector maScenarios
;
115 SheetScenariosModel maModel
;
119 // ============================================================================
121 class ScenarioBuffer
: public WorkbookHelper
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();
133 typedef RefMap
< sal_Int16
, SheetScenarios
, ::std::greater
< sal_Int16
> > SheetScenariosMap
;
134 SheetScenariosMap maSheetScenarios
;
137 // ============================================================================
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */