blob: 5fb6e538ec067730865a6b1087fc299cec29c8c6 [file] [log] [blame]
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
//___________________________________________________________________
#include "xmllabri.hxx"
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmltoken.hxx>
#include "xmlimprt.hxx"
using namespace ::com::sun::star;
using ::rtl::OUString;
using namespace xmloff::token;
//___________________________________________________________________
ScXMLLabelRangesContext::ScXMLLabelRangesContext(
ScXMLImport& rImport,
sal_uInt16 nPrefix,
const OUString& rLName,
const uno::Reference< xml::sax::XAttributeList >& /* xAttrList */ ):
SvXMLImportContext( rImport, nPrefix, rLName )
{
rImport.LockSolarMutex();
}
ScXMLLabelRangesContext::~ScXMLLabelRangesContext()
{
GetScImport().UnlockSolarMutex();
}
SvXMLImportContext* ScXMLLabelRangesContext::CreateChildContext(
sal_uInt16 nPrefix,
const OUString& rLName,
const uno::Reference< xml::sax::XAttributeList >& xAttrList )
{
SvXMLImportContext* pContext(NULL);
const SvXMLTokenMap& rTokenMap(GetScImport().GetLabelRangesElemTokenMap());
switch( rTokenMap.Get( nPrefix, rLName ) )
{
case XML_TOK_LABEL_RANGE_ELEM:
pContext = new ScXMLLabelRangeContext( GetScImport(), nPrefix, rLName, xAttrList );
break;
}
if( !pContext )
pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
return pContext;
}
void ScXMLLabelRangesContext::EndElement()
{
}
//___________________________________________________________________
ScXMLLabelRangeContext::ScXMLLabelRangeContext(
ScXMLImport& rImport,
sal_uInt16 nPrfx,
const OUString& rLName,
const uno::Reference< xml::sax::XAttributeList >& xAttrList ) :
SvXMLImportContext( rImport, nPrfx, rLName ),
bColumnOrientation( sal_False )
{
sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetLabelRangeAttrTokenMap());
for( sal_Int16 nIndex = 0; nIndex < nAttrCount; ++nIndex )
{
const rtl::OUString& sAttrName (xAttrList->getNameByIndex( nIndex ));
const rtl::OUString& sValue (xAttrList->getValueByIndex( nIndex ));
OUString aLocalName;
sal_uInt16 nPrefix (GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ));
switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
{
case XML_TOK_LABEL_RANGE_ATTR_LABEL_RANGE:
sLabelRangeStr = sValue;
break;
case XML_TOK_LABEL_RANGE_ATTR_DATA_RANGE:
sDataRangeStr = sValue;
break;
case XML_TOK_LABEL_RANGE_ATTR_ORIENTATION:
bColumnOrientation = IsXMLToken(sValue, XML_COLUMN );
break;
}
}
}
ScXMLLabelRangeContext::~ScXMLLabelRangeContext()
{
}
SvXMLImportContext* ScXMLLabelRangeContext::CreateChildContext(
sal_uInt16 nPrefix,
const OUString& rLName,
const uno::Reference< xml::sax::XAttributeList >& /* xAttrList */ )
{
return new SvXMLImportContext( GetImport(), nPrefix, rLName );
}
void ScXMLLabelRangeContext::EndElement()
{
// #b5071088# Label ranges must be stored as strings until all sheets are loaded
// (like named expressions).
ScMyLabelRange* pLabelRange = new ScMyLabelRange;
pLabelRange->sLabelRangeStr = sLabelRangeStr;
pLabelRange->sDataRangeStr = sDataRangeStr;
pLabelRange->bColumnOrientation = bColumnOrientation;
GetScImport().AddLabelRange(pLabelRange);
}