Line data Source code
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 :
21 :
22 : //___________________________________________________________________
23 : #include "xmllabri.hxx"
24 : #include <xmloff/nmspmap.hxx>
25 : #include <xmloff/xmltoken.hxx>
26 : #include "xmlimprt.hxx"
27 :
28 : using namespace ::com::sun::star;
29 : using namespace xmloff::token;
30 :
31 :
32 : //___________________________________________________________________
33 :
34 0 : ScXMLLabelRangesContext::ScXMLLabelRangesContext(
35 : ScXMLImport& rImport,
36 : sal_uInt16 nPrefix,
37 : const OUString& rLName,
38 : const uno::Reference< xml::sax::XAttributeList >& /* xAttrList */ ):
39 0 : SvXMLImportContext( rImport, nPrefix, rLName )
40 : {
41 0 : rImport.LockSolarMutex();
42 0 : }
43 :
44 0 : ScXMLLabelRangesContext::~ScXMLLabelRangesContext()
45 : {
46 0 : GetScImport().UnlockSolarMutex();
47 0 : }
48 :
49 0 : SvXMLImportContext* ScXMLLabelRangesContext::CreateChildContext(
50 : sal_uInt16 nPrefix,
51 : const OUString& rLName,
52 : const uno::Reference< xml::sax::XAttributeList >& xAttrList )
53 : {
54 0 : SvXMLImportContext* pContext(NULL);
55 0 : const SvXMLTokenMap& rTokenMap(GetScImport().GetLabelRangesElemTokenMap());
56 :
57 0 : switch( rTokenMap.Get( nPrefix, rLName ) )
58 : {
59 : case XML_TOK_LABEL_RANGE_ELEM:
60 0 : pContext = new ScXMLLabelRangeContext( GetScImport(), nPrefix, rLName, xAttrList );
61 0 : break;
62 : }
63 0 : if( !pContext )
64 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
65 :
66 0 : return pContext;
67 : }
68 :
69 0 : void ScXMLLabelRangesContext::EndElement()
70 : {
71 0 : }
72 :
73 :
74 : //___________________________________________________________________
75 :
76 0 : ScXMLLabelRangeContext::ScXMLLabelRangeContext(
77 : ScXMLImport& rImport,
78 : sal_uInt16 nPrfx,
79 : const OUString& rLName,
80 : const uno::Reference< xml::sax::XAttributeList >& xAttrList ) :
81 : SvXMLImportContext( rImport, nPrfx, rLName ),
82 0 : bColumnOrientation( false )
83 : {
84 0 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
85 0 : const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetLabelRangeAttrTokenMap());
86 :
87 0 : for( sal_Int16 nIndex = 0; nIndex < nAttrCount; ++nIndex )
88 : {
89 0 : const OUString& sAttrName (xAttrList->getNameByIndex( nIndex ));
90 0 : const OUString& sValue (xAttrList->getValueByIndex( nIndex ));
91 0 : OUString aLocalName;
92 0 : sal_uInt16 nPrefix (GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ));
93 :
94 0 : switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
95 : {
96 : case XML_TOK_LABEL_RANGE_ATTR_LABEL_RANGE:
97 0 : sLabelRangeStr = sValue;
98 0 : break;
99 : case XML_TOK_LABEL_RANGE_ATTR_DATA_RANGE:
100 0 : sDataRangeStr = sValue;
101 0 : break;
102 : case XML_TOK_LABEL_RANGE_ATTR_ORIENTATION:
103 0 : bColumnOrientation = IsXMLToken(sValue, XML_COLUMN );
104 0 : break;
105 : }
106 0 : }
107 0 : }
108 :
109 0 : ScXMLLabelRangeContext::~ScXMLLabelRangeContext()
110 : {
111 0 : }
112 :
113 0 : SvXMLImportContext* ScXMLLabelRangeContext::CreateChildContext(
114 : sal_uInt16 nPrefix,
115 : const OUString& rLName,
116 : const uno::Reference< xml::sax::XAttributeList >& /* xAttrList */ )
117 : {
118 0 : return new SvXMLImportContext( GetImport(), nPrefix, rLName );
119 : }
120 :
121 0 : void ScXMLLabelRangeContext::EndElement()
122 : {
123 : // Label ranges must be stored as strings until all sheets are loaded
124 : // (like named expressions).
125 :
126 0 : ScMyLabelRange* pLabelRange = new ScMyLabelRange;
127 :
128 0 : pLabelRange->sLabelRangeStr = sLabelRangeStr;
129 0 : pLabelRange->sDataRangeStr = sDataRangeStr;
130 0 : pLabelRange->bColumnOrientation = bColumnOrientation;
131 :
132 0 : GetScImport().AddLabelRange(pLabelRange);
133 0 : }
134 :
135 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|