update dev300-m58
[ooovba.git] / sc / source / filter / xml / xmllabri.cxx
blobe4798fa6ad86a36736cc1755c96976e3c1253b28
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmllabri.cxx,v $
10 * $Revision: 1.14 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
35 //___________________________________________________________________
36 #include "xmllabri.hxx"
37 #include <xmloff/nmspmap.hxx>
38 #include <xmloff/xmltoken.hxx>
39 #include "xmlimprt.hxx"
41 using namespace ::com::sun::star;
42 using ::rtl::OUString;
43 using namespace xmloff::token;
46 //___________________________________________________________________
48 ScXMLLabelRangesContext::ScXMLLabelRangesContext(
49 ScXMLImport& rImport,
50 USHORT nPrefix,
51 const OUString& rLName,
52 const uno::Reference< xml::sax::XAttributeList >& /* xAttrList */ ):
53 SvXMLImportContext( rImport, nPrefix, rLName )
55 rImport.LockSolarMutex();
58 ScXMLLabelRangesContext::~ScXMLLabelRangesContext()
60 GetScImport().UnlockSolarMutex();
63 SvXMLImportContext* ScXMLLabelRangesContext::CreateChildContext(
64 USHORT nPrefix,
65 const OUString& rLName,
66 const uno::Reference< xml::sax::XAttributeList >& xAttrList )
68 SvXMLImportContext* pContext(NULL);
69 const SvXMLTokenMap& rTokenMap(GetScImport().GetLabelRangesElemTokenMap());
71 switch( rTokenMap.Get( nPrefix, rLName ) )
73 case XML_TOK_LABEL_RANGE_ELEM:
74 pContext = new ScXMLLabelRangeContext( GetScImport(), nPrefix, rLName, xAttrList );
75 break;
77 if( !pContext )
78 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
80 return pContext;
83 void ScXMLLabelRangesContext::EndElement()
88 //___________________________________________________________________
90 ScXMLLabelRangeContext::ScXMLLabelRangeContext(
91 ScXMLImport& rImport,
92 USHORT nPrfx,
93 const OUString& rLName,
94 const uno::Reference< xml::sax::XAttributeList >& xAttrList ) :
95 SvXMLImportContext( rImport, nPrfx, rLName ),
96 bColumnOrientation( sal_False )
98 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
99 const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetLabelRangeAttrTokenMap());
101 for( sal_Int16 nIndex = 0; nIndex < nAttrCount; ++nIndex )
103 const rtl::OUString& sAttrName (xAttrList->getNameByIndex( nIndex ));
104 const rtl::OUString& sValue (xAttrList->getValueByIndex( nIndex ));
105 OUString aLocalName;
106 USHORT nPrefix (GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ));
108 switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
110 case XML_TOK_LABEL_RANGE_ATTR_LABEL_RANGE:
111 sLabelRangeStr = sValue;
112 break;
113 case XML_TOK_LABEL_RANGE_ATTR_DATA_RANGE:
114 sDataRangeStr = sValue;
115 break;
116 case XML_TOK_LABEL_RANGE_ATTR_ORIENTATION:
117 bColumnOrientation = IsXMLToken(sValue, XML_COLUMN );
118 break;
123 ScXMLLabelRangeContext::~ScXMLLabelRangeContext()
127 SvXMLImportContext* ScXMLLabelRangeContext::CreateChildContext(
128 USHORT nPrefix,
129 const OUString& rLName,
130 const uno::Reference< xml::sax::XAttributeList >& /* xAttrList */ )
132 return new SvXMLImportContext( GetImport(), nPrefix, rLName );
135 void ScXMLLabelRangeContext::EndElement()
137 // #b5071088# Label ranges must be stored as strings until all sheets are loaded
138 // (like named expressions).
140 ScMyLabelRange* pLabelRange = new ScMyLabelRange;
142 pLabelRange->sLabelRangeStr = sLabelRangeStr;
143 pLabelRange->sDataRangeStr = sDataRangeStr;
144 pLabelRange->bColumnOrientation = bColumnOrientation;
146 GetScImport().AddLabelRange(pLabelRange);