diff options
Diffstat (limited to 'sc/source/filter/xml/xmlnexpi.cxx')
-rw-r--r-- | sc/source/filter/xml/xmlnexpi.cxx | 524 |
1 files changed, 262 insertions, 262 deletions
diff --git a/sc/source/filter/xml/xmlnexpi.cxx b/sc/source/filter/xml/xmlnexpi.cxx index 249522c1a9bc..3f822d5274c6 100644 --- a/sc/source/filter/xml/xmlnexpi.cxx +++ b/sc/source/filter/xml/xmlnexpi.cxx @@ -1,262 +1,262 @@ -/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: xmlnexpi.cxx,v $
- * $Revision: 1.18 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sc.hxx"
-
-
-
-// INCLUDE ---------------------------------------------------------------
-#include <rtl/ustrbuf.hxx>
-
-#include "xmlnexpi.hxx"
-#include "xmlimprt.hxx"
-#include "xmlcelli.hxx"
-#include "docuno.hxx"
-#include "global.hxx"
-#include "document.hxx"
-#include "XMLConverter.hxx"
-
-#include <xmloff/xmltkmap.hxx>
-#include <xmloff/nmspmap.hxx>
-
-using namespace com::sun::star;
-
-//------------------------------------------------------------------
-
-ScXMLNamedExpressionsContext::ScXMLNamedExpressionsContext( ScXMLImport& rImport,
- USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) :
- SvXMLImportContext( rImport, nPrfx, rLName )
-{
-/* sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for( sal_Int16 i=0; i < nAttrCount; ++i )
- {
- const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
- rtl::OUString aLocalName;
- USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName );
- const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
-
- const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap();
-
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
- {
- }
- }*/
- rImport.LockSolarMutex();
-}
-
-ScXMLNamedExpressionsContext::~ScXMLNamedExpressionsContext()
-{
- GetScImport().UnlockSolarMutex();
-}
-
-SvXMLImportContext *ScXMLNamedExpressionsContext::CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
-{
- SvXMLImportContext *pContext(0);
-
- const SvXMLTokenMap& rTokenMap(GetScImport().GetNamedExpressionsElemTokenMap());
- switch( rTokenMap.Get( nPrefix, rLName ) )
- {
- case XML_TOK_NAMED_EXPRESSIONS_NAMED_RANGE:
- pContext = new ScXMLNamedRangeContext( GetScImport(), nPrefix,
- rLName, xAttrList//,
- //this
- );
- break;
- case XML_TOK_NAMED_EXPRESSIONS_NAMED_EXPRESSION:
- pContext = new ScXMLNamedExpressionContext( GetScImport(), nPrefix,
- rLName, xAttrList//,
- //this
- );
- break;
- }
-
- if( !pContext )
- pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
-
- return pContext;
-}
-
-void ScXMLNamedExpressionsContext::EndElement()
-{
- // happends in ScXMLImport::EndDocument()
- // because it has to be set after the Database Ranges
-}
-
-ScXMLNamedRangeContext::ScXMLNamedRangeContext( ScXMLImport& rImport,
- USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
- SvXMLImportContext( rImport, nPrfx, rLName )
-{
- ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression);
- // A simple table:cell-range-address is not a formula expression, stored
- // without [] brackets but with dot, .A1
- pNamedExpression->eGrammar = formula::FormulaGrammar::mergeToGrammar(
- GetScImport().GetDocument()->GetStorageGrammar(),
- formula::FormulaGrammar::CONV_OOO);
- sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
- const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap();
- for( sal_Int16 i=0; i < nAttrCount; ++i )
- {
- const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
- rtl::OUString aLocalName;
- USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName ));
- const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
-
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
- {
- case XML_TOK_NAMED_RANGE_ATTR_NAME :
- {
- pNamedExpression->sName = sValue;
- }
- break;
- case XML_TOK_NAMED_RANGE_ATTR_CELL_RANGE_ADDRESS :
- {
- pNamedExpression->sContent = sValue;
- }
- break;
- case XML_TOK_NAMED_RANGE_ATTR_BASE_CELL_ADDRESS :
- {
- pNamedExpression->sBaseCellAddress = sValue;
- }
- break;
- case XML_TOK_NAMED_RANGE_ATTR_RANGE_USABLE_AS :
- {
- pNamedExpression->sRangeType = sValue;
- }
- break;
- }
- }
- pNamedExpression->bIsExpression = sal_False;
- GetScImport().AddNamedExpression(pNamedExpression);
-}
-
-ScXMLNamedRangeContext::~ScXMLNamedRangeContext()
-{
-}
-
-SvXMLImportContext *ScXMLNamedRangeContext::CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
-{
-/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap();
- switch( rTokenMap.Get( nPrefix, rLName ) )
- {
- }*/
- return new SvXMLImportContext( GetImport(), nPrefix, rLName );
-}
-
-void ScXMLNamedRangeContext::EndElement()
-{
-}
-
-ScXMLNamedExpressionContext::ScXMLNamedExpressionContext( ScXMLImport& rImport,
- USHORT nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
- SvXMLImportContext( rImport, nPrfx, rLName )
-{
- ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression);
- const formula::FormulaGrammar::Grammar eStorageGrammar = pNamedExpression->eGrammar =
- GetScImport().GetDocument()->GetStorageGrammar();
- sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
- const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetNamedExpressionAttrTokenMap());
- for( sal_Int16 i=0; i < nAttrCount; ++i )
- {
- const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
- rtl::OUString aLocalName;
- USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
- sAttrName, &aLocalName ));
- const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
-
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
- {
- case XML_TOK_NAMED_EXPRESSION_ATTR_NAME :
- {
- pNamedExpression->sName = sValue;
- }
- break;
- case XML_TOK_NAMED_EXPRESSION_ATTR_EXPRESSION :
- {
- rtl::OUString sFormula;
- sal_uInt16 nFormulaPrefix = GetImport().GetNamespaceMap().
- _GetKeyByAttrName( sValue, &sFormula, sal_False );
-
- if (ScXMLImport::IsAcceptedFormulaNamespace( nFormulaPrefix,
- sValue, pNamedExpression->eGrammar,
- eStorageGrammar))
- pNamedExpression->sContent = sFormula;
- else
- pNamedExpression->sContent = sValue;
- }
- break;
- case XML_TOK_NAMED_EXPRESSION_ATTR_BASE_CELL_ADDRESS :
- {
- pNamedExpression->sBaseCellAddress = sValue;
- }
- break;
- }
- }
- pNamedExpression->bIsExpression = sal_True;
- GetScImport().AddNamedExpression(pNamedExpression);
-}
-
-ScXMLNamedExpressionContext::~ScXMLNamedExpressionContext()
-{
-}
-
-SvXMLImportContext *ScXMLNamedExpressionContext::CreateChildContext( USHORT nPrefix,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
-{
-/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap();
- switch( rTokenMap.Get( nPrefix, rLName ) )
- {
- }*/
- return new SvXMLImportContext( GetImport(), nPrefix, rLName );;
-}
-
-void ScXMLNamedExpressionContext::EndElement()
-{
-}
-
+/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: xmlnexpi.cxx,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sc.hxx" + + + +// INCLUDE --------------------------------------------------------------- +#include <rtl/ustrbuf.hxx> + +#include "xmlnexpi.hxx" +#include "xmlimprt.hxx" +#include "xmlcelli.hxx" +#include "docuno.hxx" +#include "global.hxx" +#include "document.hxx" +#include "XMLConverter.hxx" + +#include <xmloff/xmltkmap.hxx> +#include <xmloff/nmspmap.hxx> + +using namespace com::sun::star; + +//------------------------------------------------------------------ + +ScXMLNamedExpressionsContext::ScXMLNamedExpressionsContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ +/* sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; ++i ) + { + const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i )); + rtl::OUString aLocalName; + USHORT nPrefix = GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName ); + const rtl::OUString& sValue(xAttrList->getValueByIndex( i )); + + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap(); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + } + }*/ + rImport.LockSolarMutex(); +} + +ScXMLNamedExpressionsContext::~ScXMLNamedExpressionsContext() +{ + GetScImport().UnlockSolarMutex(); +} + +SvXMLImportContext *ScXMLNamedExpressionsContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList ) +{ + SvXMLImportContext *pContext(0); + + const SvXMLTokenMap& rTokenMap(GetScImport().GetNamedExpressionsElemTokenMap()); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + case XML_TOK_NAMED_EXPRESSIONS_NAMED_RANGE: + pContext = new ScXMLNamedRangeContext( GetScImport(), nPrefix, + rLName, xAttrList//, + //this + ); + break; + case XML_TOK_NAMED_EXPRESSIONS_NAMED_EXPRESSION: + pContext = new ScXMLNamedExpressionContext( GetScImport(), nPrefix, + rLName, xAttrList//, + //this + ); + break; + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); + + return pContext; +} + +void ScXMLNamedExpressionsContext::EndElement() +{ + // happends in ScXMLImport::EndDocument() + // because it has to be set after the Database Ranges +} + +ScXMLNamedRangeContext::ScXMLNamedRangeContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression); + // A simple table:cell-range-address is not a formula expression, stored + // without [] brackets but with dot, .A1 + pNamedExpression->eGrammar = formula::FormulaGrammar::mergeToGrammar( + GetScImport().GetDocument()->GetStorageGrammar(), + formula::FormulaGrammar::CONV_OOO); + sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0); + const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetNamedRangeAttrTokenMap(); + for( sal_Int16 i=0; i < nAttrCount; ++i ) + { + const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i )); + rtl::OUString aLocalName; + USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName )); + const rtl::OUString& sValue(xAttrList->getValueByIndex( i )); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_NAMED_RANGE_ATTR_NAME : + { + pNamedExpression->sName = sValue; + } + break; + case XML_TOK_NAMED_RANGE_ATTR_CELL_RANGE_ADDRESS : + { + pNamedExpression->sContent = sValue; + } + break; + case XML_TOK_NAMED_RANGE_ATTR_BASE_CELL_ADDRESS : + { + pNamedExpression->sBaseCellAddress = sValue; + } + break; + case XML_TOK_NAMED_RANGE_ATTR_RANGE_USABLE_AS : + { + pNamedExpression->sRangeType = sValue; + } + break; + } + } + pNamedExpression->bIsExpression = sal_False; + GetScImport().AddNamedExpression(pNamedExpression); +} + +ScXMLNamedRangeContext::~ScXMLNamedRangeContext() +{ +} + +SvXMLImportContext *ScXMLNamedRangeContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) +{ +/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + }*/ + return new SvXMLImportContext( GetImport(), nPrefix, rLName ); +} + +void ScXMLNamedRangeContext::EndElement() +{ +} + +ScXMLNamedExpressionContext::ScXMLNamedExpressionContext( ScXMLImport& rImport, + USHORT nPrfx, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& xAttrList) : + SvXMLImportContext( rImport, nPrfx, rLName ) +{ + ScMyNamedExpression* pNamedExpression(new ScMyNamedExpression); + const formula::FormulaGrammar::Grammar eStorageGrammar = pNamedExpression->eGrammar = + GetScImport().GetDocument()->GetStorageGrammar(); + sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0); + const SvXMLTokenMap& rAttrTokenMap(GetScImport().GetNamedExpressionAttrTokenMap()); + for( sal_Int16 i=0; i < nAttrCount; ++i ) + { + const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i )); + rtl::OUString aLocalName; + USHORT nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName( + sAttrName, &aLocalName )); + const rtl::OUString& sValue(xAttrList->getValueByIndex( i )); + + switch( rAttrTokenMap.Get( nPrefix, aLocalName ) ) + { + case XML_TOK_NAMED_EXPRESSION_ATTR_NAME : + { + pNamedExpression->sName = sValue; + } + break; + case XML_TOK_NAMED_EXPRESSION_ATTR_EXPRESSION : + { + rtl::OUString sFormula; + sal_uInt16 nFormulaPrefix = GetImport().GetNamespaceMap(). + _GetKeyByAttrName( sValue, &sFormula, sal_False ); + + if (ScXMLImport::IsAcceptedFormulaNamespace( nFormulaPrefix, + sValue, pNamedExpression->eGrammar, + eStorageGrammar)) + pNamedExpression->sContent = sFormula; + else + pNamedExpression->sContent = sValue; + } + break; + case XML_TOK_NAMED_EXPRESSION_ATTR_BASE_CELL_ADDRESS : + { + pNamedExpression->sBaseCellAddress = sValue; + } + break; + } + } + pNamedExpression->bIsExpression = sal_True; + GetScImport().AddNamedExpression(pNamedExpression); +} + +ScXMLNamedExpressionContext::~ScXMLNamedExpressionContext() +{ +} + +SvXMLImportContext *ScXMLNamedExpressionContext::CreateChildContext( USHORT nPrefix, + const ::rtl::OUString& rLName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) +{ +/* const SvXMLTokenMap& rTokenMap = GetScImport().GetTableElemTokenMap(); + switch( rTokenMap.Get( nPrefix, rLName ) ) + { + }*/ + return new SvXMLImportContext( GetImport(), nPrefix, rLName );; +} + +void ScXMLNamedExpressionContext::EndElement() +{ +} + |