1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "xmllabri.hxx"
21 #include <xmloff/xmltoken.hxx>
22 #include "xmlimprt.hxx"
23 #include <xmloff/xmlnamespace.hxx>
25 using namespace ::com::sun::star
;
26 using namespace xmloff::token
;
28 ScXMLLabelRangesContext::ScXMLLabelRangesContext(
29 ScXMLImport
& rImport
):
30 ScXMLImportContext( rImport
)
32 rImport
.LockSolarMutex();
35 ScXMLLabelRangesContext::~ScXMLLabelRangesContext()
37 GetScImport().UnlockSolarMutex();
40 uno::Reference
< xml::sax::XFastContextHandler
> SAL_CALL
ScXMLLabelRangesContext::createFastChildContext(
41 sal_Int32 nElement
, const uno::Reference
< xml::sax::XFastAttributeList
>& xAttrList
)
43 SvXMLImportContext
* pContext(nullptr);
44 sax_fastparser::FastAttributeList
*pAttribList
=
45 &sax_fastparser::castToFastAttributeList( xAttrList
);
49 case XML_ELEMENT( TABLE
, XML_LABEL_RANGE
):
50 pContext
= new ScXMLLabelRangeContext( GetScImport(), pAttribList
);
57 ScXMLLabelRangeContext::ScXMLLabelRangeContext(
59 const rtl::Reference
<sax_fastparser::FastAttributeList
>& rAttrList
) :
60 ScXMLImportContext( rImport
),
61 bColumnOrientation( false )
63 if ( !rAttrList
.is() )
66 for (auto &aIter
: *rAttrList
)
68 switch (aIter
.getToken())
70 case XML_ELEMENT( TABLE
, XML_LABEL_CELL_RANGE_ADDRESS
):
71 sLabelRangeStr
= aIter
.toString();
73 case XML_ELEMENT( TABLE
, XML_DATA_CELL_RANGE_ADDRESS
):
74 sDataRangeStr
= aIter
.toString();
76 case XML_ELEMENT( TABLE
, XML_ORIENTATION
):
77 bColumnOrientation
= IsXMLToken(aIter
, XML_COLUMN
);
83 ScXMLLabelRangeContext::~ScXMLLabelRangeContext()
87 void SAL_CALL
ScXMLLabelRangeContext::endFastElement( sal_Int32
/*nElement*/ )
89 // Label ranges must be stored as strings until all sheets are loaded
90 // (like named expressions).
92 ScMyLabelRange
aLabelRange(
93 ScMyLabelRange
{sLabelRangeStr
, sDataRangeStr
, bColumnOrientation
});
95 GetScImport().AddLabelRange(std::move(aLabelRange
));
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */