LibreOffice Module sc (master) 1
XMLDetectiveContext.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
21
23#include <xmloff/xmltoken.hxx>
25#include "xmlimprt.hxx"
26#include "XMLConverter.hxx"
27#include <rangeutl.hxx>
28
29using namespace ::com::sun::star;
30using namespace xmloff::token;
31
33 eObjType( SC_DETOBJ_NONE ),
34 bHasError( false )
35{
36}
37
39{
40 return (nIndex < rDetOp.nIndex);
41}
42
44{
45 aDetectiveOpList.sort();
46}
47
49{
50 if( aDetectiveOpList.empty() )
51 return false;
52 ScMyImpDetectiveOpList::iterator aItr = aDetectiveOpList.begin();
53 rDetOp = *aItr;
54 aDetectiveOpList.erase( aItr );
55 return true;
56}
57
59 ScXMLImport& rImport,
60 ScMyImpDetectiveObjVec* pNewDetectiveObjVec ) :
61 ScXMLImportContext( rImport ),
62 pDetectiveObjVec( pNewDetectiveObjVec )
63{
64}
65
67{
68}
69
70uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLDetectiveContext::createFastChildContext(
71 sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
72{
73 SvXMLImportContext* pContext = nullptr;
76
77 switch (nElement)
78 {
80 pContext = new ScXMLDetectiveHighlightedContext( GetScImport(), pAttribList, pDetectiveObjVec );
81 break;
83 pContext = new ScXMLDetectiveOperationContext( GetScImport(), pAttribList );
84 break;
85 }
86
87 return pContext;
88}
89
91 ScXMLImport& rImport,
93 ScMyImpDetectiveObjVec* pNewDetectiveObjVec ):
94 ScXMLImportContext( rImport ),
95 pDetectiveObjVec( pNewDetectiveObjVec ),
96 bValid( false )
97{
98 if ( !rAttrList.is() )
99 return;
100
101 for (auto &aIter : *rAttrList)
102 {
103 switch (aIter.getToken())
104 {
106 {
107 sal_Int32 nOffset(0);
110 assert(pDoc);
112 }
113 break;
116 break;
119 break;
121 {
122 if (IsXMLToken(aIter, XML_TRUE))
124 }
125 break;
126 }
127 }
128}
129
131{
132}
133
134void SAL_CALL ScXMLDetectiveHighlightedContext::endFastElement( sal_Int32 /*nElement*/ )
135{
136 switch( aDetectiveObj.eObjType )
137 {
138 case SC_DETOBJ_ARROW:
140 break;
142 case SC_DETOBJ_CIRCLE:
143 bValid = true;
144 break;
145 default:
146 bValid = false;
147 }
148 if( bValid )
149 pDetectiveObjVec->push_back( aDetectiveObj );
150}
151
153 ScXMLImport& rImport,
155 ScXMLImportContext( rImport ),
156 bHasType( false )
157{
158 if ( rAttrList.is() )
159 {
160 for (auto &aIter : *rAttrList)
161 {
162 switch (aIter.getToken())
163 {
164 case XML_ELEMENT( TABLE, XML_NAME ):
166 break;
167 case XML_ELEMENT( TABLE, XML_INDEX ):
168 {
169 sal_Int32 nValue;
170 if (::sax::Converter::convertNumber( nValue, aIter.toView(), 0 ))
172 }
173 break;
174 }
175 }
176 }
178}
179
181{
182}
183
184void SAL_CALL ScXMLDetectiveOperationContext::endFastElement( sal_Int32 /*nElement*/ )
185{
186 if( bHasType && (aDetectiveOp.nIndex >= 0) )
188}
189
190/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::std::vector< ScMyImpDetectiveObj > ScMyImpDetectiveObjVec
ScMyImpDetectiveOpList aDetectiveOpList
bool GetFirstOp(ScMyImpDetectiveOp &rDetOp)
void AddDetectiveOp(const ScMyImpDetectiveOp &rDetOp)
const ScAddress & GetCurrentCellPos() const
Definition: xmlsubti.hxx:80
static bool GetRangeFromString(ScRange &rRange, std::u16string_view rRangeStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Int32 &nOffset, sal_Unicode cSeparator=' ', sal_Unicode cQuote='\'')
static bool GetDetOpTypeFromString(ScDetOpType &rDetOpType, std::u16string_view rString)
static ScDetectiveObjType GetDetObjTypeFromString(std::u16string_view rString)
virtual ~ScXMLDetectiveContext() override
ScMyImpDetectiveObjVec * pDetectiveObjVec
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
ScXMLDetectiveContext(ScXMLImport &rImport, ScMyImpDetectiveObjVec *pNewDetectiveObjVec)
ScMyImpDetectiveObjVec * pDetectiveObjVec
ScXMLDetectiveHighlightedContext(ScXMLImport &rImport, const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList, ScMyImpDetectiveObjVec *pNewDetectiveObjVec)
virtual ~ScXMLDetectiveHighlightedContext() override
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
virtual ~ScXMLDetectiveOperationContext() override
ScXMLDetectiveOperationContext(ScXMLImport &rImport, const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList)
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
This class exists only to provide GetScImport() to its derived classes.
ScXMLImport & GetScImport()
Use this class to manage solar mutex locking instead of calling LockSolarMutex() and UnlockSolarMutex...
Definition: xmlimprt.hxx:289
ScMyImpDetectiveOpArray * GetDetectiveOpArray()
Definition: xmlimprt.cxx:1674
ScDocument * GetDocument()
Definition: xmlimprt.hxx:205
ScMyTables & GetTables()
Definition: xmlimprt.hxx:208
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
@ SC_DETOBJ_NONE
Definition: detfunc.hxx:40
@ SC_DETOBJ_TOOTHERTAB
Definition: detfunc.hxx:43
@ SC_DETOBJ_CIRCLE
Definition: detfunc.hxx:44
@ SC_DETOBJ_ARROW
Definition: detfunc.hxx:41
@ SC_DETOBJ_FROMOTHERTAB
Definition: detfunc.hxx:42
sal_Int16 nValue
TABLE
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XML_CELL_RANGE_ADDRESS
XML_MARKED_INVALID
XML_TRUE
XML_HIGHLIGHTED_RANGE
XML_CONTAINS_ERROR
XML_INDEX
XML_NAME
XML_OPERATION
XML_DIRECTION
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
ScDetectiveObjType eObjType
bool operator<(const ScMyImpDetectiveOp &rDetOp) const
#define XML_ELEMENT(prefix, name)