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/nmspmap.hxx>
22 #include <xmloff/xmltoken.hxx>
23 #include "xmlimprt.hxx"
25 using namespace ::com::sun::star
;
26 using namespace xmloff::token
;
28 ScXMLLabelRangesContext::ScXMLLabelRangesContext(
31 const OUString
& rLName
,
32 const uno::Reference
< xml::sax::XAttributeList
>& /* xAttrList */ ):
33 SvXMLImportContext( rImport
, nPrefix
, rLName
)
35 rImport
.LockSolarMutex();
38 ScXMLLabelRangesContext::~ScXMLLabelRangesContext()
40 GetScImport().UnlockSolarMutex();
43 SvXMLImportContext
* ScXMLLabelRangesContext::CreateChildContext(
45 const OUString
& rLName
,
46 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
48 SvXMLImportContext
* pContext(NULL
);
49 const SvXMLTokenMap
& rTokenMap(GetScImport().GetLabelRangesElemTokenMap());
51 switch( rTokenMap
.Get( nPrefix
, rLName
) )
53 case XML_TOK_LABEL_RANGE_ELEM
:
54 pContext
= new ScXMLLabelRangeContext( GetScImport(), nPrefix
, rLName
, xAttrList
);
58 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
63 void ScXMLLabelRangesContext::EndElement()
67 ScXMLLabelRangeContext::ScXMLLabelRangeContext(
70 const OUString
& rLName
,
71 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
) :
72 SvXMLImportContext( rImport
, nPrfx
, rLName
),
73 bColumnOrientation( false )
75 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
76 const SvXMLTokenMap
& rAttrTokenMap(GetScImport().GetLabelRangeAttrTokenMap());
78 for( sal_Int16 nIndex
= 0; nIndex
< nAttrCount
; ++nIndex
)
80 const OUString
& sAttrName (xAttrList
->getNameByIndex( nIndex
));
81 const OUString
& sValue (xAttrList
->getValueByIndex( nIndex
));
83 sal_uInt16
nPrefix (GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName
, &aLocalName
));
85 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
87 case XML_TOK_LABEL_RANGE_ATTR_LABEL_RANGE
:
88 sLabelRangeStr
= sValue
;
90 case XML_TOK_LABEL_RANGE_ATTR_DATA_RANGE
:
91 sDataRangeStr
= sValue
;
93 case XML_TOK_LABEL_RANGE_ATTR_ORIENTATION
:
94 bColumnOrientation
= IsXMLToken(sValue
, XML_COLUMN
);
100 ScXMLLabelRangeContext::~ScXMLLabelRangeContext()
104 SvXMLImportContext
* ScXMLLabelRangeContext::CreateChildContext(
106 const OUString
& rLName
,
107 const uno::Reference
< xml::sax::XAttributeList
>& /* xAttrList */ )
109 return new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
112 void ScXMLLabelRangeContext::EndElement()
114 // Label ranges must be stored as strings until all sheets are loaded
115 // (like named expressions).
117 ScMyLabelRange
* pLabelRange
= new ScMyLabelRange
;
119 pLabelRange
->sLabelRangeStr
= sLabelRangeStr
;
120 pLabelRange
->sDataRangeStr
= sDataRangeStr
;
121 pLabelRange
->bColumnOrientation
= bColumnOrientation
;
123 GetScImport().AddLabelRange(pLabelRange
);
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */