fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / xml / xmlsceni.cxx
blob9e44757cee16352424e9468f131e5afcef9d5fe5
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 "docuno.hxx"
24 #include "attrib.hxx"
25 #include "XMLConverter.hxx"
26 #include "rangeutl.hxx"
28 #include <xmloff/xmltkmap.hxx>
29 #include <xmloff/nmspmap.hxx>
30 #include <xmloff/xmltoken.hxx>
32 #include <sax/tools/converter.hxx>
34 using namespace com::sun::star;
35 using namespace xmloff::token;
37 ScXMLTableScenarioContext::ScXMLTableScenarioContext(
38 ScXMLImport& rImport,
39 sal_uInt16 nPrfx,
40 const OUString& rLName,
41 const uno::Reference< xml::sax::XAttributeList >& xAttrList ):
42 SvXMLImportContext( rImport, nPrfx, rLName ),
43 aBorderColor( COL_BLACK ),
44 bDisplayBorder( true ),
45 bCopyBack( true ),
46 bCopyStyles( true ),
47 bCopyFormulas( true ),
48 bIsActive( false ),
49 bProtected( false )
51 rImport.LockSolarMutex();
52 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
53 const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetTableScenarioAttrTokenMap());
54 for( sal_Int16 i = 0; i < nAttrCount; ++i )
56 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
57 OUString aLocalName;
58 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
59 sAttrName, &aLocalName ));
60 const OUString& sValue(xAttrList->getValueByIndex( i ));
62 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
64 case XML_TOK_TABLE_SCENARIO_ATTR_DISPLAY_BORDER:
66 bDisplayBorder = IsXMLToken(sValue, XML_TRUE);
68 break;
69 case XML_TOK_TABLE_SCENARIO_ATTR_BORDER_COLOR:
71 sal_Int32 nColor(0);
72 ::sax::Converter::convertColor(nColor, sValue);
73 aBorderColor.SetColor(nColor);
75 break;
76 case XML_TOK_TABLE_SCENARIO_ATTR_COPY_BACK:
78 bCopyBack = IsXMLToken(sValue, XML_TRUE);
80 break;
81 case XML_TOK_TABLE_SCENARIO_ATTR_COPY_STYLES:
83 bCopyStyles = IsXMLToken(sValue, XML_TRUE);
85 break;
86 case XML_TOK_TABLE_SCENARIO_ATTR_COPY_FORMULAS:
88 bCopyFormulas = IsXMLToken(sValue, XML_TRUE);
90 break;
91 case XML_TOK_TABLE_SCENARIO_ATTR_IS_ACTIVE:
93 bIsActive = IsXMLToken(sValue, XML_TRUE);
95 break;
96 case XML_TOK_TABLE_SCENARIO_ATTR_SCENARIO_RANGES:
98 ScRangeStringConverter::GetRangeListFromString(
99 aScenarioRanges, sValue, GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO );
101 break;
102 case XML_TOK_TABLE_SCENARIO_ATTR_COMMENT:
104 sComment = sValue;
106 break;
107 case XML_TOK_TABLE_SCENARIO_ATTR_PROTECTED:
109 bProtected = IsXMLToken(sValue, XML_TRUE);
111 break;
116 ScXMLTableScenarioContext::~ScXMLTableScenarioContext()
118 GetScImport().UnlockSolarMutex();
121 SvXMLImportContext *ScXMLTableScenarioContext::CreateChildContext(
122 sal_uInt16 nPrefix,
123 const OUString& rLName,
124 const uno::Reference< xml::sax::XAttributeList >& /* xAttrList */ )
126 return new SvXMLImportContext( GetImport(), nPrefix, rLName );
129 void ScXMLTableScenarioContext::EndElement()
131 SCTAB nCurrTable( GetScImport().GetTables().GetCurrentSheet() );
132 ScDocument* pDoc(GetScImport().GetDocument());
133 if (pDoc)
135 pDoc->SetScenario( nCurrTable, true );
136 sal_uInt16 nFlags( 0 );
137 if( bDisplayBorder )
138 nFlags |= SC_SCENARIO_SHOWFRAME;
139 if( bCopyBack )
140 nFlags |= SC_SCENARIO_TWOWAY;
141 if( bCopyStyles )
142 nFlags |= SC_SCENARIO_ATTRIB;
143 if( !bCopyFormulas )
144 nFlags |= SC_SCENARIO_VALUE;
145 if( bProtected )
146 nFlags |= SC_SCENARIO_PROTECT;
147 pDoc->SetScenarioData( nCurrTable, OUString( sComment ), aBorderColor, nFlags );
148 for( size_t i = 0; i < aScenarioRanges.size(); ++i )
150 ScRange* pRange(aScenarioRanges[ i ]);
151 if( pRange )
152 pDoc->ApplyFlagsTab( pRange->aStart.Col(), pRange->aStart.Row(),
153 pRange->aEnd.Col(), pRange->aEnd.Row(), nCurrTable, SC_MF_SCENARIO );
155 pDoc->SetActiveScenario( nCurrTable, bIsActive );
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */