LibreOffice Module sc (master) 1
XMLConsolidationContext.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#include <document.hxx>
22#include <rangeutl.hxx>
23#include "xmlimprt.hxx"
24#include "XMLConverter.hxx"
25#include <xmloff/xmltoken.hxx>
27
28using namespace ::com::sun::star;
29using namespace xmloff::token;
30
32 ScXMLImport& rImport,
34 ScXMLImportContext( rImport ),
35 eFunction( SUBTOTAL_FUNC_NONE ),
36 bLinkToSource( false ),
37 bTargetAddr(false)
38{
39 rImport.LockSolarMutex();
40 if ( !rAttrList.is() )
41 return;
42
43 for (auto &aIter : *rAttrList)
44 {
45 switch (aIter.getToken())
46 {
49 break;
51 sSourceList = aIter.toString();
52 break;
54 {
55 sal_Int32 nOffset(0);
57 assert(pDoc);
59 aTargetAddr, aIter.toString(), *pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset );
60 }
61 break;
63 sUseLabel = aIter.toString();
64 break;
67 break;
68 }
69 }
70}
71
73{
75}
76
77void SAL_CALL ScXMLConsolidationContext::endFastElement( sal_Int32 /*nElement*/ )
78{
79 if (!bTargetAddr)
80 return;
81
82 std::unique_ptr<ScConsolidateParam> pConsParam(new ScConsolidateParam);
83 pConsParam->nCol = aTargetAddr.Col();
84 pConsParam->nRow = aTargetAddr.Row();
85 pConsParam->nTab = aTargetAddr.Tab();
86 pConsParam->eFunction = eFunction;
87
88 sal_uInt16 nCount = static_cast<sal_uInt16>(std::min( ScRangeStringConverter::GetTokenCount( sSourceList ), sal_Int32(0xFFFF) ));
89 if( nCount )
90 {
91 std::unique_ptr<ScArea[]> ppAreas(new ScArea[ nCount ]);
92 sal_Int32 nOffset = 0;
93 sal_uInt16 nIndex;
95 assert(pDoc);
96 for( nIndex = 0; nIndex < nCount; ++nIndex )
97 {
99 ppAreas[ nIndex ], sSourceList, *pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset ) )
100 {
102 }
103 }
104
105 pConsParam->SetAreas( std::move(ppAreas), nCount );
106 }
107
108 pConsParam->bByCol = pConsParam->bByRow = false;
110 pConsParam->bByCol = true;
111 else if( IsXMLToken( sUseLabel, XML_ROW ) )
112 pConsParam->bByRow = true;
113 else if( IsXMLToken( sUseLabel, XML_BOTH ) )
114 pConsParam->bByCol = pConsParam->bByRow = true;
115
116 pConsParam->bReferenceData = bLinkToSource;
117
119 if( pDoc )
120 pDoc->SetConsolidateDlgData( std::move(pConsParam) );
121}
122
123/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SCTAB Tab() const
Definition: address.hxx:283
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
void SetConsolidateDlgData(std::unique_ptr< ScConsolidateParam > pData)
Definition: documen2.cxx:1168
static bool GetAddressFromString(ScAddress &rAddress, std::u16string_view rAddressStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Int32 &nOffset, sal_Unicode cSeparator=' ', sal_Unicode cQuote='\'')
String to Range core.
Definition: rangeutl.cxx:461
static sal_Int32 GetTokenCount(std::u16string_view rString, sal_Unicode cSeparator=' ')
Definition: rangeutl.cxx:447
static bool GetAreaFromString(ScArea &rArea, std::u16string_view rRangeStr, const ScDocument &rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Int32 &nOffset, sal_Unicode cSeparator=' ')
Definition: rangeutl.cxx:579
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
virtual ~ScXMLConsolidationContext() override
ScXMLConsolidationContext(ScXMLImport &rImport, const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList)
static ScSubTotalFunc GetSubTotalFuncFromString(std::u16string_view rString)
This class exists only to provide GetScImport() to its derived classes.
ScXMLImport & GetScImport()
void LockSolarMutex()
Definition: xmlimprt.cxx:1519
ScDocument * GetDocument()
Definition: xmlimprt.hxx:205
void UnlockSolarMutex()
Definition: xmlimprt.cxx:1537
int nCount
@ SUBTOTAL_FUNC_NONE
Definition: global.hxx:861
sal_Int32 nIndex
TABLE
XML_TARGET_CELL_ADDRESS
XML_SOURCE_CELL_RANGE_ADDRESSES
XML_COLUMN
XML_ROW
XML_TRUE
XML_FUNCTION
XML_USE_LABEL
XML_LINK_TO_SOURCE_DATA
XML_BOTH
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
#define XML_ELEMENT(prefix, name)