LibreOffice Module sc (master)  1
xmlsceni.cxx
Go to the documentation of this file.
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 #include <document.hxx>
21 #include "xmlimprt.hxx"
22 #include "xmlsceni.hxx"
23 #include <attrib.hxx>
24 #include <rangeutl.hxx>
25 
26 #include <xmloff/xmltoken.hxx>
27 #include <xmloff/xmlnamespace.hxx>
28 
29 #include <sax/tools/converter.hxx>
30 
31 using namespace com::sun::star;
32 using namespace xmloff::token;
33 
35  ScXMLImport& rImport,
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 )
45 {
46  rImport.LockSolarMutex();
47 
48  if ( !rAttrList.is() )
49  return;
50 
51  for (auto &aIter : *rAttrList)
52  {
53  switch (aIter.getToken())
54  {
57  break;
60  break;
62  bCopyBack = IsXMLToken(aIter, XML_TRUE);
63  break;
66  break;
69  break;
71  bIsActive = IsXMLToken(aIter, XML_TRUE);
72  break;
76  break;
77  case XML_ELEMENT( TABLE, XML_COMMENT ):
78  sComment = aIter.toString();
79  break;
81  bProtected = IsXMLToken(aIter, XML_TRUE);
82  break;
83  }
84  }
85 }
86 
88 {
90 }
91 
92 void SAL_CALL ScXMLTableScenarioContext::endFastElement( sal_Int32 /*nElement*/ )
93 {
94  SCTAB nCurrTable( GetScImport().GetTables().GetCurrentSheet() );
95  ScDocument* pDoc(GetScImport().GetDocument());
96  if (!pDoc)
97  return;
98 
99  pDoc->SetScenario( nCurrTable, true );
101  if( bDisplayBorder )
102  nFlags |= ScScenarioFlags::ShowFrame;
103  if( bCopyBack )
104  nFlags |= ScScenarioFlags::TwoWay;
105  if( bCopyStyles )
106  nFlags |= ScScenarioFlags::Attrib;
107  if( !bCopyFormulas )
108  nFlags |= ScScenarioFlags::Value;
109  if( bProtected )
110  nFlags |= ScScenarioFlags::Protected;
111  pDoc->SetScenarioData( nCurrTable, sComment, aBorderColor, nFlags );
112  for( size_t i = 0; i < aScenarioRanges.size(); ++i )
113  {
114  ScRange const & rRange = aScenarioRanges[ i ];
115  pDoc->ApplyFlagsTab( rRange.aStart.Col(), rRange.aStart.Row(),
116  rRange.aEnd.Col(), rRange.aEnd.Row(), nCurrTable, ScMF::Scenario );
117  }
118  pDoc->SetActiveScenario( nCurrTable, bIsActive );
119 }
120 
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XML_COPY_BACK
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
ScAddress aStart
Definition: address.hxx:500
SC_DLLPUBLIC void SetScenario(SCTAB nTab, bool bFlag)
Definition: documen3.cxx:407
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
SCROW Row() const
Definition: address.hxx:262
ScRangeList aScenarioRanges
Definition: xmlsceni.hxx:35
ScDocument * GetDocument()
Definition: xmlimprt.hxx:296
ScScenarioFlags
Definition: global.hxx:236
SC_DLLPUBLIC bool ApplyFlagsTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, ScMF nFlags)
Definition: document.cxx:5015
ScAddress aEnd
Definition: address.hxx:501
XML_IS_ACTIVE
void LockSolarMutex()
Definition: xmlimprt.cxx:1699
XML_PROTECTED
XML_DISPLAY_BORDER
This class exists only to provide GetScImport() to its derived classes.
SC_DLLPUBLIC void SetScenarioData(SCTAB nTab, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
Definition: documen3.cxx:418
int i
SC_DLLPUBLIC void SetActiveScenario(SCTAB nTab, bool bActive)
Definition: documen3.cxx:863
XML_COPY_STYLES
size_t size() const
Definition: rangelst.hxx:90
virtual ~ScXMLTableScenarioContext() override
Definition: xmlsceni.cxx:87
static bool GetRangeListFromString(ScRangeList &rRangeList, const OUString &rRangeListStr, const ScDocument *pDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Unicode cSeparator= ' ', sal_Unicode cQuote= '\'')
Definition: rangeutl.cxx:528
ScXMLImport & GetScImport()
XML_COPY_FORMULAS
XML_BORDER_COLOR
SCCOL Col() const
Definition: address.hxx:267
TABLE
ScXMLTableScenarioContext(ScXMLImport &rImport, const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList)
Definition: xmlsceni.cxx:34
static bool convertColor(sal_Int32 &rColor, const OUString &rValue)
field button for datapilot
void UnlockSolarMutex()
Definition: xmlimprt.cxx:1717
#define XML_ELEMENT(prefix, name)
XML_TRUE
XML_SCENARIO_RANGES
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
Definition: xmlsceni.cxx:92
sal_Int16 SCTAB
Definition: types.hxx:23
XML_COMMENT