Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / xml / xmlsceni.cxx
blob37df2e26db526c62051cd505bcbbde7f39d65bbf
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 #include <document.hxx>
21 #include "xmlimprt.hxx"
22 #include "xmlsceni.hxx"
23 #include <attrib.hxx>
24 #include <rangeutl.hxx>
26 #include <xmloff/xmltoken.hxx>
27 #include <xmloff/xmlnmspe.hxx>
29 #include <sax/tools/converter.hxx>
31 using namespace com::sun::star;
32 using namespace xmloff::token;
34 ScXMLTableScenarioContext::ScXMLTableScenarioContext(
35 ScXMLImport& rImport,
36 const rtl::Reference<sax_fastparser::FastAttributeList>& rAttrList ):
37 ScXMLImportContext( rImport ),
38 aBorderColor( COL_BLACK ),
39 bDisplayBorder( true ),
40 bCopyBack( true ),
41 bCopyStyles( true ),
42 bCopyFormulas( true ),
43 bIsActive( false ),
44 bProtected( false )
46 rImport.LockSolarMutex();
48 if ( rAttrList.is() )
50 for (auto &aIter : *rAttrList)
52 switch (aIter.getToken())
54 case XML_ELEMENT( TABLE, XML_DISPLAY_BORDER ):
55 bDisplayBorder = IsXMLToken(aIter, XML_TRUE);
56 break;
57 case XML_ELEMENT( TABLE, XML_BORDER_COLOR ):
58 ::sax::Converter::convertColor(aBorderColor, aIter.toString());
59 break;
60 case XML_ELEMENT( TABLE, XML_COPY_BACK ):
61 bCopyBack = IsXMLToken(aIter, XML_TRUE);
62 break;
63 case XML_ELEMENT( TABLE, XML_COPY_STYLES ):
64 bCopyStyles = IsXMLToken(aIter, XML_TRUE);
65 break;
66 case XML_ELEMENT( TABLE, XML_COPY_FORMULAS ):
67 bCopyFormulas = IsXMLToken(aIter, XML_TRUE);
68 break;
69 case XML_ELEMENT( TABLE, XML_IS_ACTIVE ):
70 bIsActive = IsXMLToken(aIter, XML_TRUE);
71 break;
72 case XML_ELEMENT( TABLE, XML_SCENARIO_RANGES ):
73 ScRangeStringConverter::GetRangeListFromString(
74 aScenarioRanges, aIter.toString(), GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO );
75 break;
76 case XML_ELEMENT( TABLE, XML_COMMENT ):
77 sComment = aIter.toString();
78 break;
79 case XML_ELEMENT( TABLE, XML_PROTECTED ):
80 bProtected = IsXMLToken(aIter, XML_TRUE);
81 break;
87 ScXMLTableScenarioContext::~ScXMLTableScenarioContext()
89 GetScImport().UnlockSolarMutex();
92 void SAL_CALL ScXMLTableScenarioContext::endFastElement( sal_Int32 /*nElement*/ )
94 SCTAB nCurrTable( GetScImport().GetTables().GetCurrentSheet() );
95 ScDocument* pDoc(GetScImport().GetDocument());
96 if (pDoc)
98 pDoc->SetScenario( nCurrTable, true );
99 ScScenarioFlags nFlags( ScScenarioFlags::NONE );
100 if( bDisplayBorder )
101 nFlags |= ScScenarioFlags::ShowFrame;
102 if( bCopyBack )
103 nFlags |= ScScenarioFlags::TwoWay;
104 if( bCopyStyles )
105 nFlags |= ScScenarioFlags::Attrib;
106 if( !bCopyFormulas )
107 nFlags |= ScScenarioFlags::Value;
108 if( bProtected )
109 nFlags |= ScScenarioFlags::Protected;
110 pDoc->SetScenarioData( nCurrTable, sComment, aBorderColor, nFlags );
111 for( size_t i = 0; i < aScenarioRanges.size(); ++i )
113 ScRange const & rRange = aScenarioRanges[ i ];
114 pDoc->ApplyFlagsTab( rRange.aStart.Col(), rRange.aStart.Row(),
115 rRange.aEnd.Col(), rRange.aEnd.Row(), nCurrTable, ScMF::Scenario );
117 pDoc->SetActiveScenario( nCurrTable, bIsActive );
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */