diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-08 10:47:13 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-08 10:47:13 +0000 |
commit | 87307aba9e8dbca16672e6df701d9f905b9e1786 (patch) | |
tree | c4c94029c34c3a5dc7e0ed2d6cee8cebc5d31e6b /sc/source/filter/xml/xmlcvali.cxx | |
parent | b142ca03365a5a5bfd8487fda9bfeea2e6db0d0b (diff) |
CWS-TOOLING: integrate CWS frmdlg
2008-12-18 09:13:09 +0100 oj r265667 : merge from odff05
2008-12-18 07:58:16 +0100 oj r265658 : #i94555# patch from <regina>, ODFF:
Add GAMMA, CHISQDIST, CHISQINV.
Make the 'cumulative' parameter of GAMMADIST optional.
Adapt the domain of CHIDIST to allow negative x.
Remove the constraint "degrees of freedom < 1.0E5" from CHIDIST and CHIINV.
Plus a mechanism to write the now optional parameter of GAMMADIST to PODF and
ODFF if omitted, for backwards compatibility.
2008-12-15 14:06:11 +0100 oj r265490 : CWS-TOOLING: rebase CWS frmdlg to trunk@264807 (milestone: DEV300:m37)
2008-12-15 13:55:28 +0100 oj r265488 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:55:07 +0100 oj r265487 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:48 +0100 oj r265486 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:36 +0100 oj r265485 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:24 +0100 oj r265484 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:48:11 +0100 oj r265483 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:31:12 +0100 oj r265479 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:13:58 +0100 oj r265477 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:10:09 +0100 oj r265476 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:05:11 +0100 oj r265475 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:47:17 +0100 oj r265467 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:46:19 +0100 oj r265466 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:45:47 +0100 oj r265465 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 07:35:07 +0100 oj r265458 : add dependency to formula
2008-12-15 07:34:24 +0100 oj r265457 : add dependency to formula
2008-12-12 13:22:00 +0100 msc r265413 : #i97089#
2008-12-12 13:20:25 +0100 msc r265412 : #i97089#
2008-12-12 12:35:12 +0100 msc r265406 : #i97089#
2008-12-12 12:34:16 +0100 msc r265405 : #i97089#
2008-12-12 12:33:05 +0100 msc r265404 : #i97089#
2008-12-12 12:31:11 +0100 msc r265403 : #i97089#
2008-12-08 11:59:10 +0100 oj r264981 : insert RTL_LOG
2008-12-08 11:50:17 +0100 oj r264980 : some small changes
2008-12-05 12:57:57 +0100 oj r264902 : eof changed
2008-12-05 12:56:46 +0100 oj r264901 : eof changed
2008-12-05 12:28:47 +0100 oj r264899 : wrong var used
2008-12-05 10:08:57 +0100 oj r264890 : token order reversed
2008-12-04 13:49:22 +0100 oc r264843 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:45:27 +0100 oc r264842 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:42:54 +0100 oc r264841 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:37:41 +0100 oc r264840 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:34:11 +0100 oc r264839 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 12:35:31 +0100 oj r264835 : new help ids for struct and function tabpage
2008-12-04 12:00:35 +0100 oj r264828 : set explicit help id
2008-12-03 14:53:27 +0100 oj r264786 : #i96845# change ref button
2008-12-03 14:51:49 +0100 oj r264785 : #i96845# change ref button
2008-12-03 08:51:57 +0100 oj r264746 : convert dos to unix lineends
2008-12-03 08:50:45 +0100 oj r264745 : convert dos to unix lineends
2008-12-03 08:50:05 +0100 oj r264744 : convert dos to unix lineends
2008-12-02 12:28:33 +0100 oj r264686 : clear help text when new helpid is set
2008-12-02 12:28:02 +0100 oj r264685 : set help id for listbox category
2008-12-02 07:15:56 +0100 oj r264655 : remove define to auto generate help ids
2008-12-01 14:36:43 +0100 oj r264604 : use temp var
2008-12-01 14:18:31 +0100 oj r264601 : moved ScJumpToken to formula
2008-12-01 14:18:11 +0100 oj r264600 : moved ScJumpToken to formula
2008-12-01 14:14:35 +0100 oj r264599 : moved ScJumpToken from sc
2008-12-01 10:48:51 +0100 oj r264589 : change quickhelptext from Shrink to Select
2008-12-01 10:28:41 +0100 oj r264588 : fix opcode data, has to be Any.Void
2008-11-28 11:16:48 +0100 oj r264532 : add help ids
2008-11-28 10:16:56 +0100 oj r264529 : set help id
2008-11-28 10:16:43 +0100 oj r264528 : set help id
2008-11-26 13:55:04 +0100 oj r264381 : #94535# use of optional instead of deleting a string myself and some small changes
2008-11-26 09:53:20 +0100 oj r264346 : compile error with debug/without debug
2008-11-25 07:41:28 +0100 oj r264271 : put static into the method which make use of them
2008-11-24 08:16:07 +0100 oj r264196 : removed not needed classes for op code
2008-11-24 08:13:44 +0100 oj r264195 : removed not needed classes for op code
2008-11-21 14:05:53 +0100 oj r264135 : make GetOpCode inline
2008-11-21 12:35:27 +0100 oj r264124 : hold symbols
2008-11-20 09:27:27 +0100 oj r264028 : merged code from DEV300_m35 which got lost
2008-11-19 20:42:12 +0100 oj r264022 : more changes for formula dialog remove
2008-11-19 20:37:41 +0100 oj r264021 : removed unused var
2008-11-19 20:35:35 +0100 oj r264020 : some more changes at token
2008-11-19 10:59:47 +0100 oj r263967 : deleted
2008-11-19 10:58:24 +0100 oj r263966 : add forui and for res files
2008-11-18 15:27:36 +0100 oj r263777 : unused para removed
2008-11-18 15:23:23 +0100 oj r263775 : add insert button to add field dlg
2008-11-18 13:39:53 +0100 oj r263764 : enable the formula dialog as well for conditional print as for conditional formatting
2008-11-18 12:03:25 +0100 oj r263760 : rename isRef in IsRef
2008-11-17 11:46:16 +0100 oj r263711 : patches for function handling
2008-11-17 11:36:22 +0100 oj r263710 : add new for forui and res file
2008-11-17 09:21:12 +0100 oj r263704 : patches for some resource for libformula
2008-11-15 12:45:30 +0100 oj r263701 : changes for formula editor extraction
2008-11-07 08:23:27 +0100 oj r263416 : merge from DEV300:m35
2008-11-07 08:22:35 +0100 oj r263415 : merge from DEV300:m35
2008-11-07 08:22:16 +0100 oj r263414 : merge from DEV300:m35
2008-11-07 08:21:41 +0100 oj r263413 : merge from DEV300:m35
2008-11-07 08:21:31 +0100 oj r263412 : merge from DEV300:m35
2008-11-07 08:20:38 +0100 oj r263411 : merge from DEV300:m35
2008-11-07 08:20:00 +0100 oj r263410 : merge from DEV300:m35
2008-11-07 08:18:50 +0100 oj r263409 : merge from DEV300:m35
2008-11-07 08:18:19 +0100 oj r263408 : merge from DEV300:m35
2008-11-07 08:10:27 +0100 oj r263407 : merge from DEV300:m35
2008-10-21 07:43:46 +0200 oj r262560 : some compile errors resolved
2008-10-17 16:40:01 +0200 oj r262291 : dep for 1st target
2008-10-07 10:08:39 +0200 oj r262077 : copy
2008-10-07 09:45:31 +0200 oj r262076 : #i94535#
2008-10-07 09:44:26 +0200 oj r262075 : #i94535# new base class
2008-10-07 09:43:21 +0200 oj r262074 : moved to formula
2008-10-07 09:41:51 +0200 oj r262073 : new images
2008-10-07 09:03:01 +0200 oj r262072 : new ids for formula
2008-10-02 08:46:27 +0200 oj r262024 : #i94535# move the formula compiler to formula
2008-10-02 08:08:54 +0200 oj r262023 : #i94535#
2008-10-02 08:06:28 +0200 oj r262022 : #i94535#
2008-10-02 08:05:52 +0200 oj r262021 : #i94535#
2008-10-01 17:15:29 +0200 oj r262014 : #i94535#
2008-10-01 17:12:40 +0200 oj r262013 : new module formula
2008-10-01 17:04:55 +0200 oj r262012 : #i94535#
2008-10-01 16:49:03 +0200 oj r262010 : #i94535#
2008-10-01 16:46:59 +0200 oj r262009 : #i94535#
Diffstat (limited to 'sc/source/filter/xml/xmlcvali.cxx')
-rw-r--r-- | sc/source/filter/xml/xmlcvali.cxx | 1576 |
1 files changed, 788 insertions, 788 deletions
diff --git a/sc/source/filter/xml/xmlcvali.cxx b/sc/source/filter/xml/xmlcvali.cxx index 7a6c4c41d211..0d78a79a5eea 100644 --- a/sc/source/filter/xml/xmlcvali.cxx +++ b/sc/source/filter/xml/xmlcvali.cxx @@ -1,788 +1,788 @@ -/************************************************************************* - * - * 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: xmlcvali.cxx,v $ - * $Revision: 1.27 $ - * - * 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 "xmlcvali.hxx" -#include "xmlimprt.hxx" -#include "xmlconti.hxx" -#include "document.hxx" -#include "XMLConverter.hxx" - -#include <xmloff/xmltkmap.hxx> -#include <xmloff/nmspmap.hxx> -#include <xmloff/xmltoken.hxx> -#include <xmloff/xmlnmspe.hxx> -#include <xmloff/XMLEventsImportContext.hxx> -#include <com/sun/star/sheet/TableValidationVisibility.hpp> -#include <tools/debug.hxx> - -using namespace com::sun::star; -using namespace xmloff::token; - -class ScXMLContentValidationContext : public SvXMLImportContext -{ - rtl::OUString sName; - rtl::OUString sHelpTitle; - rtl::OUString sHelpMessage; - rtl::OUString sErrorTitle; - rtl::OUString sErrorMessage; - rtl::OUString sErrorMessageType; - rtl::OUString sBaseCellAddress; - rtl::OUString sCondition; - ScGrammar::Grammar eGrammar; - sal_Int16 nShowList; - sal_Bool bAllowEmptyCell; - sal_Bool bDisplayHelp; - sal_Bool bDisplayError; - - SvXMLImportContextRef xEventContext; - - const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } - ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } - - void GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle); - void SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const; - void GetCondition(const rtl::OUString& sCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2, - com::sun::star::sheet::ValidationType& aValidationType, - com::sun::star::sheet::ConditionOperator& aOperator); - -public: - - ScXMLContentValidationContext( ScXMLImport& rImport, USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList); - - virtual ~ScXMLContentValidationContext(); - - virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); - - virtual void EndElement(); - - void SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay); - void SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const rtl::OUString& sMessageType, const sal_Bool bDisplay); - void SetErrorMacro(const sal_Bool bExecute); -}; - -class ScXMLHelpMessageContext : public SvXMLImportContext -{ - rtl::OUString sTitle; - rtl::OUStringBuffer sMessage; - sal_Int32 nParagraphCount; - sal_Bool bDisplay; - - ScXMLContentValidationContext* pValidationContext; - - const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } - ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } - -public: - - ScXMLHelpMessageContext( ScXMLImport& rImport, USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pValidationContext); - - virtual ~ScXMLHelpMessageContext(); - - virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); - - virtual void EndElement(); -}; - -class ScXMLErrorMessageContext : public SvXMLImportContext -{ - rtl::OUString sTitle; - rtl::OUStringBuffer sMessage; - rtl::OUString sMessageType; - sal_Int32 nParagraphCount; - sal_Bool bDisplay; - - ScXMLContentValidationContext* pValidationContext; - - const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } - ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } - -public: - - ScXMLErrorMessageContext( ScXMLImport& rImport, USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pValidationContext); - - virtual ~ScXMLErrorMessageContext(); - - virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); - - virtual void EndElement(); -}; - -class ScXMLErrorMacroContext : public SvXMLImportContext -{ - rtl::OUString sName; - sal_Bool bExecute; - - ScXMLContentValidationContext* pValidationContext; - - const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } - ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } - -public: - - ScXMLErrorMacroContext( ScXMLImport& rImport, USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pValidationContext); - - virtual ~ScXMLErrorMacroContext(); - - virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLocalName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); - virtual void EndElement(); -}; - -//------------------------------------------------------------------ - -ScXMLContentValidationsContext::ScXMLContentValidationsContext( 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 ) -{ - // here are no attributes -} - -ScXMLContentValidationsContext::~ScXMLContentValidationsContext() -{ -} - -SvXMLImportContext *ScXMLContentValidationsContext::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().GetContentValidationsElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLName ) ) - { - case XML_TOK_CONTENT_VALIDATION: - pContext = new ScXMLContentValidationContext( GetScImport(), nPrefix, rLName, xAttrList); - break; - } - - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLContentValidationsContext::EndElement() -{ -} - -ScXMLContentValidationContext::ScXMLContentValidationContext( 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 ), - sName(), - sHelpTitle(), - sHelpMessage(), - sErrorTitle(), - sErrorMessage(), - sErrorMessageType(), - sBaseCellAddress(), - sCondition(), - nShowList(sheet::TableValidationVisibility::UNSORTED), - bAllowEmptyCell(sal_True), - bDisplayHelp(sal_False), - bDisplayError(sal_False) -{ - const ScGrammar::Grammar eStorageGrammar = eGrammar = GetScImport().GetDocument()->GetStorageGrammar(); - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationAttrTokenMap(); - 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_CONTENT_VALIDATION_NAME: - sName = sValue; - break; - case XML_TOK_CONTENT_VALIDATION_CONDITION: - { - sal_uInt16 nCondPrefix = GetImport().GetNamespaceMap(). - _GetKeyByAttrName( sValue, &sCondition, sal_False ); - - if (!ScXMLImport::IsAcceptedFormulaNamespace( nCondPrefix, - sValue, eGrammar, eStorageGrammar)) - sCondition = sValue; - } - break; - case XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS: - sBaseCellAddress = sValue; - break; - case XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL: - if (IsXMLToken(sValue, XML_FALSE)) - bAllowEmptyCell = sal_False; - break; - case XML_TOK_CONTENT_VALIDATION_DISPLAY_LIST: - { - if (IsXMLToken(sValue, XML_NO)) - { - nShowList = sheet::TableValidationVisibility::INVISIBLE; - } - else if (IsXMLToken(sValue, XML_UNSORTED)) - { - nShowList = sheet::TableValidationVisibility::UNSORTED; - } - else if (IsXMLToken(sValue, XML_SORTED_ASCENDING)) - { - nShowList = sheet::TableValidationVisibility::SORTEDASCENDING; - } - } - break; - } - } -} - -ScXMLContentValidationContext::~ScXMLContentValidationContext() -{ -} - -SvXMLImportContext *ScXMLContentValidationContext::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().GetContentValidationElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLName ) ) - { - case XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE: - pContext = new ScXMLHelpMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this); - break; - case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE: - pContext = new ScXMLErrorMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this); - break; - case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO: - pContext = new ScXMLErrorMacroContext( GetScImport(), nPrefix, rLName, xAttrList, this); - break; - case XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS: - pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName ); - xEventContext = pContext; - break; - } - - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLContentValidationContext::GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle) -{ - if (IsXMLToken(sMessageType, XML_MACRO)) - aAlertStyle = sheet::ValidationAlertStyle_MACRO; - else if (IsXMLToken(sMessageType, XML_STOP)) - aAlertStyle = sheet::ValidationAlertStyle_STOP; - else if (IsXMLToken(sMessageType, XML_WARNING)) - aAlertStyle = sheet::ValidationAlertStyle_WARNING; - else if (IsXMLToken(sMessageType, XML_INFORMATION)) - aAlertStyle = sheet::ValidationAlertStyle_INFO; - else // don't leave uninitialized - aAlertStyle = sheet::ValidationAlertStyle_STOP; -} - -void ScXMLContentValidationContext::SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const -{ - sal_Int32 i = 0; - sal_Bool bString = sal_False; - sal_Int32 nBrakes = 0; - while ((sFormulas[i] != ',' || nBrakes > 0 || bString) && i < sFormulas.getLength()) - { - if (sFormulas[i] == '(') - ++nBrakes; - if (sFormulas[i] == ')') - --nBrakes; - if (sFormulas[i] == '"') - bString = !bString; - ++i; - } - if (sFormulas[i] == ',') - { - sFormula1 = sFormulas.copy(0, i); - sFormula2 = sFormulas.copy(i + 1); - } -} - -void ScXMLContentValidationContext::GetCondition(const rtl::OUString& sTempCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2, - com::sun::star::sheet::ValidationType& aValidationType, - com::sun::star::sheet::ConditionOperator& aOperator) -{ - aValidationType = sheet::ValidationType_ANY; // #b6343997# default if no condition is given - aOperator = sheet::ConditionOperator_NONE; - - rtl::OUString sLocalCondition(sTempCondition); - if (sLocalCondition.getLength()) - { - // ToDo: erase all blanks in the condition, but not in formulas or strings - rtl::OUString scell_content(RTL_CONSTASCII_USTRINGPARAM("cell_content")); - rtl::OUString scell_content_is_date(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date")); - rtl::OUString scell_content_is_time(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time")); - rtl::OUString scell_content_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between")); - rtl::OUString scell_content_is_in_list(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-in-list")); - rtl::OUString scell_content_text_length(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length")); - rtl::OUString scell_content_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between")); - rtl::OUString scell_content_is_whole_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number")); - rtl::OUString scell_content_is_decimal_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number")); - rtl::OUString scell_content_text_length_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between")); - rtl::OUString scell_content_text_length_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between")); - sal_Int32 i = 0; - sal_Bool bAnd(sal_True); - while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength()) - ++i; - if (sLocalCondition[i] == '(') - { - if (i != scell_content_text_length.getLength() && - i != scell_content_text_length_is_between.getLength() && - i != scell_content_text_length_is_not_between.getLength() && - i != scell_content_is_in_list.getLength()) - { - if (i == scell_content_is_time.getLength()) - { - rtl::OUString sTemp = sLocalCondition.copy(0, i); - if (sTemp == scell_content_is_time) - aValidationType = sheet::ValidationType_TIME; - else - aValidationType = sheet::ValidationType_DATE; - } - else if (i == scell_content_is_whole_number.getLength()) - aValidationType = sheet::ValidationType_WHOLE; - else if (i == scell_content_is_decimal_number.getLength()) - aValidationType = sheet::ValidationType_DECIMAL; - sLocalCondition = sLocalCondition.copy(i + 2); - rtl::OUString sTemp = sLocalCondition.copy(0, 5); - if (sTemp.compareToAscii(" and ") == 0) - sLocalCondition = sLocalCondition.copy(5); - else - bAnd = sal_False; - } - if (sLocalCondition.getLength() && bAnd) - { - i = 0; - while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength()) - ++i; - if (sLocalCondition[i] == '(') - { - rtl::OUString sTemp = sLocalCondition.copy(0, i); - sLocalCondition = sLocalCondition.copy(i + 1); - if (i == scell_content_is_between.getLength() || - i == scell_content_text_length_is_between.getLength()) - { - if (sTemp == scell_content_is_in_list) - { - aValidationType = sheet::ValidationType_LIST; - sFormula1 = sLocalCondition.copy(0, sLocalCondition.getLength() - 1); - aOperator = sheet::ConditionOperator_EQUAL; - } - else - { - if (i == scell_content_text_length_is_between.getLength()) - aValidationType = sheet::ValidationType_TEXT_LEN; - aOperator = sheet::ConditionOperator_BETWEEN; - sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1); - SetFormulas(sLocalCondition, sFormula1, sFormula2); - } - } - else if (i == scell_content_is_not_between.getLength() || - i == scell_content_text_length_is_not_between.getLength()) - { - if (i == scell_content_text_length_is_not_between.getLength()) - aValidationType = sheet::ValidationType_TEXT_LEN; - aOperator = sheet::ConditionOperator_NOT_BETWEEN; - sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1); - SetFormulas(sLocalCondition, sFormula1, sFormula2); - } - else if (i == scell_content.getLength() || - i == scell_content_text_length.getLength()) - { - if (i == scell_content_text_length.getLength()) - aValidationType = sheet::ValidationType_TEXT_LEN; - sLocalCondition = sLocalCondition.copy(1); - switch (sLocalCondition[0]) - { - case '<' : - { - if (sLocalCondition[1] == '=') - { - aOperator = sheet::ConditionOperator_LESS_EQUAL; - sLocalCondition = sLocalCondition.copy(2); - } - else - { - aOperator = sheet::ConditionOperator_LESS; - sLocalCondition = sLocalCondition.copy(1); - } - } - break; - case '>' : - { - if (sLocalCondition[1] == '=') - { - aOperator = sheet::ConditionOperator_GREATER_EQUAL; - sLocalCondition = sLocalCondition.copy(2); - } - else - { - aOperator = sheet::ConditionOperator_GREATER; - sLocalCondition = sLocalCondition.copy(1); - } - } - break; - case '=' : - { - aOperator = sheet::ConditionOperator_EQUAL; - sLocalCondition = sLocalCondition.copy(1); - } - break; - case '!' : - { - aOperator = sheet::ConditionOperator_NOT_EQUAL; - sLocalCondition = sLocalCondition.copy(1); - } - break; - } - sFormula1 = sLocalCondition; - } - } - } - } - } - - // a validation type (date, integer) without a condition isn't possible - if ( aOperator == sheet::ConditionOperator_NONE ) - aValidationType = sheet::ValidationType_ANY; -} - -void ScXMLContentValidationContext::EndElement() -{ - // #i36650# event-listeners element moved up one level - if (xEventContext.Is()) - { - rtl::OUString sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError")); - XMLEventsImportContext* pEvents = - (XMLEventsImportContext*)&xEventContext; - uno::Sequence<beans::PropertyValue> aValues; - pEvents->GetEventSequence( sOnError, aValues ); - - sal_Int32 nLength = aValues.getLength(); - for( sal_Int32 i = 0; i < nLength; i++ ) - { - // #i47525# must allow "MacroName" or "Script" - if ( aValues[i].Name.equalsAsciiL( "MacroName", sizeof("MacroName")-1 ) || - aValues[i].Name.equalsAsciiL( "Script", sizeof("Script")-1 ) ) - { - aValues[i].Value >>= sErrorTitle; - break; - } - } - } - - ScMyImportValidation aValidation; - aValidation.eGrammar = eGrammar; - aValidation.sName = sName; - aValidation.sBaseCellAddress = sBaseCellAddress; - aValidation.sImputTitle = sHelpTitle; - aValidation.sImputMessage = sHelpMessage; - aValidation.sErrorTitle = sErrorTitle; - aValidation.sErrorMessage = sErrorMessage; - GetCondition(sCondition, aValidation.sFormula1, aValidation.sFormula2, aValidation.aValidationType, aValidation.aOperator); - GetAlertStyle(sErrorMessageType, aValidation.aAlertStyle); - aValidation.bShowErrorMessage = bDisplayError; - aValidation.bShowImputMessage = bDisplayHelp; - aValidation.bIgnoreBlanks = bAllowEmptyCell; - aValidation.nShowList = nShowList; - GetScImport().AddValidation(aValidation); -} - -void ScXMLContentValidationContext::SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay) -{ - sHelpTitle = sTitle; - sHelpMessage = sMessage; - bDisplayHelp = bDisplay; -} - -void ScXMLContentValidationContext::SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, - const rtl::OUString& sMessageType, const sal_Bool bDisplay) -{ - sErrorTitle = sTitle; - sErrorMessage = sMessage; - sErrorMessageType = sMessageType; - bDisplayError = bDisplay; -} - -void ScXMLContentValidationContext::SetErrorMacro(const sal_Bool bExecute) -{ - sErrorMessageType = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("macro")); - bDisplayError = bExecute; -} - -ScXMLHelpMessageContext::ScXMLHelpMessageContext( ScXMLImport& rImport, - USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pTempValidationContext) : - SvXMLImportContext( rImport, nPrfx, rLName ), - sTitle(), - sMessage(), - nParagraphCount(0), - bDisplay(sal_False) -{ - pValidationContext = pTempValidationContext; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationHelpMessageAttrTokenMap(); - 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_HELP_MESSAGE_ATTR_TITLE: - sTitle = sValue; - break; - case XML_TOK_HELP_MESSAGE_ATTR_DISPLAY: - bDisplay = IsXMLToken(sValue, XML_TRUE); - break; - } - } -} - -ScXMLHelpMessageContext::~ScXMLHelpMessageContext() -{ -} - -SvXMLImportContext *ScXMLHelpMessageContext::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().GetContentValidationMessageElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLName ) ) - { - case XML_TOK_P: - { - if(nParagraphCount) - sMessage.append(static_cast<sal_Unicode>('\n')); - ++nParagraphCount; - pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage); - } - break; - } - - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLHelpMessageContext::EndElement() -{ - pValidationContext->SetHelpMessage(sTitle, sMessage.makeStringAndClear(), bDisplay); -} - -ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport, - USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pTempValidationContext) : - SvXMLImportContext( rImport, nPrfx, rLName ), - sTitle(), - sMessage(), - sMessageType(), - nParagraphCount(0), - bDisplay(sal_False) -{ - pValidationContext = pTempValidationContext; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMessageAttrTokenMap(); - 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_ERROR_MESSAGE_ATTR_TITLE: - sTitle = sValue; - break; - case XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE: - sMessageType = sValue; - break; - case XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY: - bDisplay = IsXMLToken(sValue, XML_TRUE); - break; - } - } -} - -ScXMLErrorMessageContext::~ScXMLErrorMessageContext() -{ -} - -SvXMLImportContext *ScXMLErrorMessageContext::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().GetContentValidationMessageElemTokenMap(); - switch( rTokenMap.Get( nPrefix, rLName ) ) - { - case XML_TOK_P: - { - if(nParagraphCount) - sMessage.append(static_cast<sal_Unicode>('\n')); - ++nParagraphCount; - pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage); - } - break; - } - - if( !pContext ) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLErrorMessageContext::EndElement() -{ - pValidationContext->SetErrorMessage(sTitle, sMessage.makeStringAndClear(), sMessageType, bDisplay); -} - -ScXMLErrorMacroContext::ScXMLErrorMacroContext( ScXMLImport& rImport, - USHORT nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& xAttrList, - ScXMLContentValidationContext* pTempValidationContext) : - SvXMLImportContext( rImport, nPrfx, rLName ), - sName(), - bExecute(sal_False) -{ - pValidationContext = pTempValidationContext; - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMacroAttrTokenMap(); - 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_ERROR_MACRO_ATTR_NAME: - sName = sValue; - break; - case XML_TOK_ERROR_MACRO_ATTR_EXECUTE: - bExecute = IsXMLToken(sValue, XML_TRUE); - break; - } - } -} - -ScXMLErrorMacroContext::~ScXMLErrorMacroContext() -{ -} - -SvXMLImportContext *ScXMLErrorMacroContext::CreateChildContext( USHORT nPrefix, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ ) -{ - SvXMLImportContext *pContext = NULL; - - if ((nPrefix == XML_NAMESPACE_SCRIPT) && IsXMLToken(rLName, XML_EVENTS)) - { - pContext = new XMLEventsImportContext(GetImport(), nPrefix, rLName); - } - if (!pContext) - pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName ); - - return pContext; -} - -void ScXMLErrorMacroContext::EndElement() -{ - pValidationContext->SetErrorMacro( bExecute ); -} +/*************************************************************************
+ *
+ * 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: xmlcvali.cxx,v $
+ * $Revision: 1.27 $
+ *
+ * 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 "xmlcvali.hxx"
+#include "xmlimprt.hxx"
+#include "xmlconti.hxx"
+#include "document.hxx"
+#include "XMLConverter.hxx"
+
+#include <xmloff/xmltkmap.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmltoken.hxx>
+#include <xmloff/xmlnmspe.hxx>
+#include <xmloff/XMLEventsImportContext.hxx>
+#include <com/sun/star/sheet/TableValidationVisibility.hpp>
+#include <tools/debug.hxx>
+
+using namespace com::sun::star;
+using namespace xmloff::token;
+
+class ScXMLContentValidationContext : public SvXMLImportContext
+{
+ rtl::OUString sName;
+ rtl::OUString sHelpTitle;
+ rtl::OUString sHelpMessage;
+ rtl::OUString sErrorTitle;
+ rtl::OUString sErrorMessage;
+ rtl::OUString sErrorMessageType;
+ rtl::OUString sBaseCellAddress;
+ rtl::OUString sCondition;
+ formula::FormulaGrammar::Grammar eGrammar;
+ sal_Int16 nShowList;
+ sal_Bool bAllowEmptyCell;
+ sal_Bool bDisplayHelp;
+ sal_Bool bDisplayError;
+
+ SvXMLImportContextRef xEventContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+ void GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle);
+ void SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const;
+ void GetCondition(const rtl::OUString& sCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2,
+ com::sun::star::sheet::ValidationType& aValidationType,
+ com::sun::star::sheet::ConditionOperator& aOperator);
+
+public:
+
+ ScXMLContentValidationContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList);
+
+ virtual ~ScXMLContentValidationContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+
+ void SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay);
+ void SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const rtl::OUString& sMessageType, const sal_Bool bDisplay);
+ void SetErrorMacro(const sal_Bool bExecute);
+};
+
+class ScXMLHelpMessageContext : public SvXMLImportContext
+{
+ rtl::OUString sTitle;
+ rtl::OUStringBuffer sMessage;
+ sal_Int32 nParagraphCount;
+ sal_Bool bDisplay;
+
+ ScXMLContentValidationContext* pValidationContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+public:
+
+ ScXMLHelpMessageContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pValidationContext);
+
+ virtual ~ScXMLHelpMessageContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+};
+
+class ScXMLErrorMessageContext : public SvXMLImportContext
+{
+ rtl::OUString sTitle;
+ rtl::OUStringBuffer sMessage;
+ rtl::OUString sMessageType;
+ sal_Int32 nParagraphCount;
+ sal_Bool bDisplay;
+
+ ScXMLContentValidationContext* pValidationContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+public:
+
+ ScXMLErrorMessageContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pValidationContext);
+
+ virtual ~ScXMLErrorMessageContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+
+ virtual void EndElement();
+};
+
+class ScXMLErrorMacroContext : public SvXMLImportContext
+{
+ rtl::OUString sName;
+ sal_Bool bExecute;
+
+ ScXMLContentValidationContext* pValidationContext;
+
+ const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
+ ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
+
+public:
+
+ ScXMLErrorMacroContext( ScXMLImport& rImport, USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pValidationContext);
+
+ virtual ~ScXMLErrorMacroContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList );
+ virtual void EndElement();
+};
+
+//------------------------------------------------------------------
+
+ScXMLContentValidationsContext::ScXMLContentValidationsContext( 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 )
+{
+ // here are no attributes
+}
+
+ScXMLContentValidationsContext::~ScXMLContentValidationsContext()
+{
+}
+
+SvXMLImportContext *ScXMLContentValidationsContext::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().GetContentValidationsElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_CONTENT_VALIDATION:
+ pContext = new ScXMLContentValidationContext( GetScImport(), nPrefix, rLName, xAttrList);
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLContentValidationsContext::EndElement()
+{
+}
+
+ScXMLContentValidationContext::ScXMLContentValidationContext( 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 ),
+ sName(),
+ sHelpTitle(),
+ sHelpMessage(),
+ sErrorTitle(),
+ sErrorMessage(),
+ sErrorMessageType(),
+ sBaseCellAddress(),
+ sCondition(),
+ nShowList(sheet::TableValidationVisibility::UNSORTED),
+ bAllowEmptyCell(sal_True),
+ bDisplayHelp(sal_False),
+ bDisplayError(sal_False)
+{
+ const formula::FormulaGrammar::Grammar eStorageGrammar = eGrammar = GetScImport().GetDocument()->GetStorageGrammar();
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationAttrTokenMap();
+ 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_CONTENT_VALIDATION_NAME:
+ sName = sValue;
+ break;
+ case XML_TOK_CONTENT_VALIDATION_CONDITION:
+ {
+ sal_uInt16 nCondPrefix = GetImport().GetNamespaceMap().
+ _GetKeyByAttrName( sValue, &sCondition, sal_False );
+
+ if (!ScXMLImport::IsAcceptedFormulaNamespace( nCondPrefix,
+ sValue, eGrammar, eStorageGrammar))
+ sCondition = sValue;
+ }
+ break;
+ case XML_TOK_CONTENT_VALIDATION_BASE_CELL_ADDRESS:
+ sBaseCellAddress = sValue;
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ALLOW_EMPTY_CELL:
+ if (IsXMLToken(sValue, XML_FALSE))
+ bAllowEmptyCell = sal_False;
+ break;
+ case XML_TOK_CONTENT_VALIDATION_DISPLAY_LIST:
+ {
+ if (IsXMLToken(sValue, XML_NO))
+ {
+ nShowList = sheet::TableValidationVisibility::INVISIBLE;
+ }
+ else if (IsXMLToken(sValue, XML_UNSORTED))
+ {
+ nShowList = sheet::TableValidationVisibility::UNSORTED;
+ }
+ else if (IsXMLToken(sValue, XML_SORTED_ASCENDING))
+ {
+ nShowList = sheet::TableValidationVisibility::SORTEDASCENDING;
+ }
+ }
+ break;
+ }
+ }
+}
+
+ScXMLContentValidationContext::~ScXMLContentValidationContext()
+{
+}
+
+SvXMLImportContext *ScXMLContentValidationContext::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().GetContentValidationElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_CONTENT_VALIDATION_ELEM_HELP_MESSAGE:
+ pContext = new ScXMLHelpMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this);
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MESSAGE:
+ pContext = new ScXMLErrorMessageContext( GetScImport(), nPrefix, rLName, xAttrList, this);
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ELEM_ERROR_MACRO:
+ pContext = new ScXMLErrorMacroContext( GetScImport(), nPrefix, rLName, xAttrList, this);
+ break;
+ case XML_TOK_CONTENT_VALIDATION_ELEM_EVENT_LISTENERS:
+ pContext = new XMLEventsImportContext( GetImport(), nPrefix, rLName );
+ xEventContext = pContext;
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLContentValidationContext::GetAlertStyle(const rtl::OUString& sMessageType, com::sun::star::sheet::ValidationAlertStyle& aAlertStyle)
+{
+ if (IsXMLToken(sMessageType, XML_MACRO))
+ aAlertStyle = sheet::ValidationAlertStyle_MACRO;
+ else if (IsXMLToken(sMessageType, XML_STOP))
+ aAlertStyle = sheet::ValidationAlertStyle_STOP;
+ else if (IsXMLToken(sMessageType, XML_WARNING))
+ aAlertStyle = sheet::ValidationAlertStyle_WARNING;
+ else if (IsXMLToken(sMessageType, XML_INFORMATION))
+ aAlertStyle = sheet::ValidationAlertStyle_INFO;
+ else // don't leave uninitialized
+ aAlertStyle = sheet::ValidationAlertStyle_STOP;
+}
+
+void ScXMLContentValidationContext::SetFormulas(const rtl::OUString& sFormulas, rtl::OUString& sFormula1, rtl::OUString& sFormula2) const
+{
+ sal_Int32 i = 0;
+ sal_Bool bString = sal_False;
+ sal_Int32 nBrakes = 0;
+ while ((sFormulas[i] != ',' || nBrakes > 0 || bString) && i < sFormulas.getLength())
+ {
+ if (sFormulas[i] == '(')
+ ++nBrakes;
+ if (sFormulas[i] == ')')
+ --nBrakes;
+ if (sFormulas[i] == '"')
+ bString = !bString;
+ ++i;
+ }
+ if (sFormulas[i] == ',')
+ {
+ sFormula1 = sFormulas.copy(0, i);
+ sFormula2 = sFormulas.copy(i + 1);
+ }
+}
+
+void ScXMLContentValidationContext::GetCondition(const rtl::OUString& sTempCondition, rtl::OUString& sFormula1, rtl::OUString& sFormula2,
+ com::sun::star::sheet::ValidationType& aValidationType,
+ com::sun::star::sheet::ConditionOperator& aOperator)
+{
+ aValidationType = sheet::ValidationType_ANY; // #b6343997# default if no condition is given
+ aOperator = sheet::ConditionOperator_NONE;
+
+ rtl::OUString sLocalCondition(sTempCondition);
+ if (sLocalCondition.getLength())
+ {
+ // ToDo: erase all blanks in the condition, but not in formulas or strings
+ rtl::OUString scell_content(RTL_CONSTASCII_USTRINGPARAM("cell_content"));
+ rtl::OUString scell_content_is_date(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-date"));
+ rtl::OUString scell_content_is_time(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-time"));
+ rtl::OUString scell_content_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-between"));
+ rtl::OUString scell_content_is_in_list(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-in-list"));
+ rtl::OUString scell_content_text_length(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length"));
+ rtl::OUString scell_content_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-not-between"));
+ rtl::OUString scell_content_is_whole_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-whole-number"));
+ rtl::OUString scell_content_is_decimal_number(RTL_CONSTASCII_USTRINGPARAM("cell-content-is-decimal-number"));
+ rtl::OUString scell_content_text_length_is_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-between"));
+ rtl::OUString scell_content_text_length_is_not_between(RTL_CONSTASCII_USTRINGPARAM("cell-content-text-length-is-not-between"));
+ sal_Int32 i = 0;
+ sal_Bool bAnd(sal_True);
+ while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength())
+ ++i;
+ if (sLocalCondition[i] == '(')
+ {
+ if (i != scell_content_text_length.getLength() &&
+ i != scell_content_text_length_is_between.getLength() &&
+ i != scell_content_text_length_is_not_between.getLength() &&
+ i != scell_content_is_in_list.getLength())
+ {
+ if (i == scell_content_is_time.getLength())
+ {
+ rtl::OUString sTemp = sLocalCondition.copy(0, i);
+ if (sTemp == scell_content_is_time)
+ aValidationType = sheet::ValidationType_TIME;
+ else
+ aValidationType = sheet::ValidationType_DATE;
+ }
+ else if (i == scell_content_is_whole_number.getLength())
+ aValidationType = sheet::ValidationType_WHOLE;
+ else if (i == scell_content_is_decimal_number.getLength())
+ aValidationType = sheet::ValidationType_DECIMAL;
+ sLocalCondition = sLocalCondition.copy(i + 2);
+ rtl::OUString sTemp = sLocalCondition.copy(0, 5);
+ if (sTemp.compareToAscii(" and ") == 0)
+ sLocalCondition = sLocalCondition.copy(5);
+ else
+ bAnd = sal_False;
+ }
+ if (sLocalCondition.getLength() && bAnd)
+ {
+ i = 0;
+ while (sLocalCondition[i] != '(' && i < sLocalCondition.getLength())
+ ++i;
+ if (sLocalCondition[i] == '(')
+ {
+ rtl::OUString sTemp = sLocalCondition.copy(0, i);
+ sLocalCondition = sLocalCondition.copy(i + 1);
+ if (i == scell_content_is_between.getLength() ||
+ i == scell_content_text_length_is_between.getLength())
+ {
+ if (sTemp == scell_content_is_in_list)
+ {
+ aValidationType = sheet::ValidationType_LIST;
+ sFormula1 = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
+ aOperator = sheet::ConditionOperator_EQUAL;
+ }
+ else
+ {
+ if (i == scell_content_text_length_is_between.getLength())
+ aValidationType = sheet::ValidationType_TEXT_LEN;
+ aOperator = sheet::ConditionOperator_BETWEEN;
+ sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
+ SetFormulas(sLocalCondition, sFormula1, sFormula2);
+ }
+ }
+ else if (i == scell_content_is_not_between.getLength() ||
+ i == scell_content_text_length_is_not_between.getLength())
+ {
+ if (i == scell_content_text_length_is_not_between.getLength())
+ aValidationType = sheet::ValidationType_TEXT_LEN;
+ aOperator = sheet::ConditionOperator_NOT_BETWEEN;
+ sLocalCondition = sLocalCondition.copy(0, sLocalCondition.getLength() - 1);
+ SetFormulas(sLocalCondition, sFormula1, sFormula2);
+ }
+ else if (i == scell_content.getLength() ||
+ i == scell_content_text_length.getLength())
+ {
+ if (i == scell_content_text_length.getLength())
+ aValidationType = sheet::ValidationType_TEXT_LEN;
+ sLocalCondition = sLocalCondition.copy(1);
+ switch (sLocalCondition[0])
+ {
+ case '<' :
+ {
+ if (sLocalCondition[1] == '=')
+ {
+ aOperator = sheet::ConditionOperator_LESS_EQUAL;
+ sLocalCondition = sLocalCondition.copy(2);
+ }
+ else
+ {
+ aOperator = sheet::ConditionOperator_LESS;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ }
+ break;
+ case '>' :
+ {
+ if (sLocalCondition[1] == '=')
+ {
+ aOperator = sheet::ConditionOperator_GREATER_EQUAL;
+ sLocalCondition = sLocalCondition.copy(2);
+ }
+ else
+ {
+ aOperator = sheet::ConditionOperator_GREATER;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ }
+ break;
+ case '=' :
+ {
+ aOperator = sheet::ConditionOperator_EQUAL;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ break;
+ case '!' :
+ {
+ aOperator = sheet::ConditionOperator_NOT_EQUAL;
+ sLocalCondition = sLocalCondition.copy(1);
+ }
+ break;
+ }
+ sFormula1 = sLocalCondition;
+ }
+ }
+ }
+ }
+ }
+
+ // a validation type (date, integer) without a condition isn't possible
+ if ( aOperator == sheet::ConditionOperator_NONE )
+ aValidationType = sheet::ValidationType_ANY;
+}
+
+void ScXMLContentValidationContext::EndElement()
+{
+ // #i36650# event-listeners element moved up one level
+ if (xEventContext.Is())
+ {
+ rtl::OUString sOnError(RTL_CONSTASCII_USTRINGPARAM("OnError"));
+ XMLEventsImportContext* pEvents =
+ (XMLEventsImportContext*)&xEventContext;
+ uno::Sequence<beans::PropertyValue> aValues;
+ pEvents->GetEventSequence( sOnError, aValues );
+
+ sal_Int32 nLength = aValues.getLength();
+ for( sal_Int32 i = 0; i < nLength; i++ )
+ {
+ // #i47525# must allow "MacroName" or "Script"
+ if ( aValues[i].Name.equalsAsciiL( "MacroName", sizeof("MacroName")-1 ) ||
+ aValues[i].Name.equalsAsciiL( "Script", sizeof("Script")-1 ) )
+ {
+ aValues[i].Value >>= sErrorTitle;
+ break;
+ }
+ }
+ }
+
+ ScMyImportValidation aValidation;
+ aValidation.eGrammar = eGrammar;
+ aValidation.sName = sName;
+ aValidation.sBaseCellAddress = sBaseCellAddress;
+ aValidation.sImputTitle = sHelpTitle;
+ aValidation.sImputMessage = sHelpMessage;
+ aValidation.sErrorTitle = sErrorTitle;
+ aValidation.sErrorMessage = sErrorMessage;
+ GetCondition(sCondition, aValidation.sFormula1, aValidation.sFormula2, aValidation.aValidationType, aValidation.aOperator);
+ GetAlertStyle(sErrorMessageType, aValidation.aAlertStyle);
+ aValidation.bShowErrorMessage = bDisplayError;
+ aValidation.bShowImputMessage = bDisplayHelp;
+ aValidation.bIgnoreBlanks = bAllowEmptyCell;
+ aValidation.nShowList = nShowList;
+ GetScImport().AddValidation(aValidation);
+}
+
+void ScXMLContentValidationContext::SetHelpMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage, const sal_Bool bDisplay)
+{
+ sHelpTitle = sTitle;
+ sHelpMessage = sMessage;
+ bDisplayHelp = bDisplay;
+}
+
+void ScXMLContentValidationContext::SetErrorMessage(const rtl::OUString& sTitle, const rtl::OUString& sMessage,
+ const rtl::OUString& sMessageType, const sal_Bool bDisplay)
+{
+ sErrorTitle = sTitle;
+ sErrorMessage = sMessage;
+ sErrorMessageType = sMessageType;
+ bDisplayError = bDisplay;
+}
+
+void ScXMLContentValidationContext::SetErrorMacro(const sal_Bool bExecute)
+{
+ sErrorMessageType = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("macro"));
+ bDisplayError = bExecute;
+}
+
+ScXMLHelpMessageContext::ScXMLHelpMessageContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pTempValidationContext) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ sTitle(),
+ sMessage(),
+ nParagraphCount(0),
+ bDisplay(sal_False)
+{
+ pValidationContext = pTempValidationContext;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationHelpMessageAttrTokenMap();
+ 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_HELP_MESSAGE_ATTR_TITLE:
+ sTitle = sValue;
+ break;
+ case XML_TOK_HELP_MESSAGE_ATTR_DISPLAY:
+ bDisplay = IsXMLToken(sValue, XML_TRUE);
+ break;
+ }
+ }
+}
+
+ScXMLHelpMessageContext::~ScXMLHelpMessageContext()
+{
+}
+
+SvXMLImportContext *ScXMLHelpMessageContext::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().GetContentValidationMessageElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_P:
+ {
+ if(nParagraphCount)
+ sMessage.append(static_cast<sal_Unicode>('\n'));
+ ++nParagraphCount;
+ pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage);
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLHelpMessageContext::EndElement()
+{
+ pValidationContext->SetHelpMessage(sTitle, sMessage.makeStringAndClear(), bDisplay);
+}
+
+ScXMLErrorMessageContext::ScXMLErrorMessageContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pTempValidationContext) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ sTitle(),
+ sMessage(),
+ sMessageType(),
+ nParagraphCount(0),
+ bDisplay(sal_False)
+{
+ pValidationContext = pTempValidationContext;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMessageAttrTokenMap();
+ 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_ERROR_MESSAGE_ATTR_TITLE:
+ sTitle = sValue;
+ break;
+ case XML_TOK_ERROR_MESSAGE_ATTR_MESSAGE_TYPE:
+ sMessageType = sValue;
+ break;
+ case XML_TOK_ERROR_MESSAGE_ATTR_DISPLAY:
+ bDisplay = IsXMLToken(sValue, XML_TRUE);
+ break;
+ }
+ }
+}
+
+ScXMLErrorMessageContext::~ScXMLErrorMessageContext()
+{
+}
+
+SvXMLImportContext *ScXMLErrorMessageContext::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().GetContentValidationMessageElemTokenMap();
+ switch( rTokenMap.Get( nPrefix, rLName ) )
+ {
+ case XML_TOK_P:
+ {
+ if(nParagraphCount)
+ sMessage.append(static_cast<sal_Unicode>('\n'));
+ ++nParagraphCount;
+ pContext = new ScXMLContentContext( GetScImport(), nPrefix, rLName, xAttrList, sMessage);
+ }
+ break;
+ }
+
+ if( !pContext )
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLErrorMessageContext::EndElement()
+{
+ pValidationContext->SetErrorMessage(sTitle, sMessage.makeStringAndClear(), sMessageType, bDisplay);
+}
+
+ScXMLErrorMacroContext::ScXMLErrorMacroContext( ScXMLImport& rImport,
+ USHORT nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+ ScXMLContentValidationContext* pTempValidationContext) :
+ SvXMLImportContext( rImport, nPrfx, rLName ),
+ sName(),
+ bExecute(sal_False)
+{
+ pValidationContext = pTempValidationContext;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetContentValidationErrorMacroAttrTokenMap();
+ 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_ERROR_MACRO_ATTR_NAME:
+ sName = sValue;
+ break;
+ case XML_TOK_ERROR_MACRO_ATTR_EXECUTE:
+ bExecute = IsXMLToken(sValue, XML_TRUE);
+ break;
+ }
+ }
+}
+
+ScXMLErrorMacroContext::~ScXMLErrorMacroContext()
+{
+}
+
+SvXMLImportContext *ScXMLErrorMacroContext::CreateChildContext( USHORT nPrefix,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
+{
+ SvXMLImportContext *pContext = NULL;
+
+ if ((nPrefix == XML_NAMESPACE_SCRIPT) && IsXMLToken(rLName, XML_EVENTS))
+ {
+ pContext = new XMLEventsImportContext(GetImport(), nPrefix, rLName);
+ }
+ if (!pContext)
+ pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
+
+ return pContext;
+}
+
+void ScXMLErrorMacroContext::EndElement()
+{
+ pValidationContext->SetErrorMacro( bExecute );
+}
|