LCOV - code coverage report
Current view: directory - content/xslt/src/xslt - txXSLTEnvironmentFunctionCall.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 72 0 0.0 %
Date: 2012-06-02 Functions: 4 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is TransforMiiX XSLT processor code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Axel Hecht.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2001
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Axel Hecht <axel@pike.org>
      24                 :  *
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #include "txIXPathContext.h"
      41                 : #include "nsGkAtoms.h"
      42                 : #include "txError.h"
      43                 : #include "txXMLUtils.h"
      44                 : #include "txXSLTFunctions.h"
      45                 : #include "txNamespaceMap.h"
      46                 : 
      47                 : nsresult
      48               0 : txXSLTEnvironmentFunctionCall::evaluate(txIEvalContext* aContext,
      49                 :                                         txAExprResult** aResult)
      50                 : {
      51               0 :     *aResult = nsnull;
      52                 : 
      53               0 :     if (!requireParams(1, 1, aContext)) {
      54               0 :         return NS_ERROR_XPATH_BAD_ARGUMENT_COUNT;
      55                 :     }
      56                 : 
      57               0 :     nsAutoString property;
      58               0 :     nsresult rv = mParams[0]->evaluateToString(aContext, property);
      59               0 :     NS_ENSURE_SUCCESS(rv, rv);
      60                 : 
      61               0 :     txExpandedName qname;
      62               0 :     rv = qname.init(property, mMappings, mType != FUNCTION_AVAILABLE);
      63               0 :     NS_ENSURE_SUCCESS(rv, rv);
      64                 : 
      65               0 :     switch (mType) {
      66                 :         case SYSTEM_PROPERTY:
      67                 :         {
      68               0 :             if (qname.mNamespaceID == kNameSpaceID_XSLT) {
      69               0 :                 if (qname.mLocalName == nsGkAtoms::version) {
      70               0 :                     return aContext->recycler()->getNumberResult(1.0, aResult);
      71                 :                 }
      72               0 :                 if (qname.mLocalName == nsGkAtoms::vendor) {
      73               0 :                     return aContext->recycler()->getStringResult(
      74               0 :                           NS_LITERAL_STRING("Transformiix"), aResult);
      75                 :                 }
      76               0 :                 if (qname.mLocalName == nsGkAtoms::vendorUrl) {
      77               0 :                     return aContext->recycler()->getStringResult(
      78               0 :                           NS_LITERAL_STRING("http://www.mozilla.org/projects/xslt/"),
      79               0 :                           aResult);
      80                 :                 }
      81                 :             }
      82               0 :             aContext->recycler()->getEmptyStringResult(aResult);
      83               0 :             break;
      84                 :         }
      85                 :         case ELEMENT_AVAILABLE:
      86                 :         {
      87                 :             bool val = qname.mNamespaceID == kNameSpaceID_XSLT &&
      88               0 :                          (qname.mLocalName == nsGkAtoms::applyImports ||
      89               0 :                           qname.mLocalName == nsGkAtoms::applyTemplates ||
      90               0 :                           qname.mLocalName == nsGkAtoms::attribute ||
      91               0 :                           qname.mLocalName == nsGkAtoms::attributeSet ||
      92               0 :                           qname.mLocalName == nsGkAtoms::callTemplate ||
      93               0 :                           qname.mLocalName == nsGkAtoms::choose ||
      94               0 :                           qname.mLocalName == nsGkAtoms::comment ||
      95               0 :                           qname.mLocalName == nsGkAtoms::copy ||
      96               0 :                           qname.mLocalName == nsGkAtoms::copyOf ||
      97               0 :                           qname.mLocalName == nsGkAtoms::decimalFormat ||
      98               0 :                           qname.mLocalName == nsGkAtoms::element ||
      99               0 :                           qname.mLocalName == nsGkAtoms::fallback ||
     100               0 :                           qname.mLocalName == nsGkAtoms::forEach ||
     101               0 :                           qname.mLocalName == nsGkAtoms::_if ||
     102               0 :                           qname.mLocalName == nsGkAtoms::import ||
     103               0 :                           qname.mLocalName == nsGkAtoms::include ||
     104               0 :                           qname.mLocalName == nsGkAtoms::key ||
     105               0 :                           qname.mLocalName == nsGkAtoms::message ||
     106                 :                           //qname.mLocalName == nsGkAtoms::namespaceAlias ||
     107               0 :                           qname.mLocalName == nsGkAtoms::number ||
     108               0 :                           qname.mLocalName == nsGkAtoms::otherwise ||
     109               0 :                           qname.mLocalName == nsGkAtoms::output ||
     110               0 :                           qname.mLocalName == nsGkAtoms::param ||
     111               0 :                           qname.mLocalName == nsGkAtoms::preserveSpace ||
     112               0 :                           qname.mLocalName == nsGkAtoms::processingInstruction ||
     113               0 :                           qname.mLocalName == nsGkAtoms::sort ||
     114               0 :                           qname.mLocalName == nsGkAtoms::stripSpace ||
     115               0 :                           qname.mLocalName == nsGkAtoms::stylesheet ||
     116               0 :                           qname.mLocalName == nsGkAtoms::_template ||
     117               0 :                           qname.mLocalName == nsGkAtoms::text ||
     118               0 :                           qname.mLocalName == nsGkAtoms::transform ||
     119               0 :                           qname.mLocalName == nsGkAtoms::valueOf ||
     120               0 :                           qname.mLocalName == nsGkAtoms::variable ||
     121               0 :                           qname.mLocalName == nsGkAtoms::when ||
     122               0 :                           qname.mLocalName == nsGkAtoms::withParam);
     123                 : 
     124               0 :             aContext->recycler()->getBoolResult(val, aResult);
     125               0 :             break;
     126                 :         }
     127                 :         case FUNCTION_AVAILABLE:
     128                 :         {
     129                 :             extern bool TX_XSLTFunctionAvailable(nsIAtom* aName,
     130                 :                                                    PRInt32 aNameSpaceID);
     131                 : 
     132                 :             txCoreFunctionCall::eType type;
     133                 :             bool val = (qname.mNamespaceID == kNameSpaceID_None &&
     134                 :                           txCoreFunctionCall::getTypeFromAtom(qname.mLocalName,
     135               0 :                                                               type)) ||
     136                 :                          TX_XSLTFunctionAvailable(qname.mLocalName,
     137               0 :                                                   qname.mNamespaceID);
     138                 : 
     139               0 :             aContext->recycler()->getBoolResult(val, aResult);
     140               0 :             break;
     141                 :         }
     142                 :     }
     143                 : 
     144               0 :     return NS_OK;
     145                 : }
     146                 : 
     147                 : Expr::ResultType
     148               0 : txXSLTEnvironmentFunctionCall::getReturnType()
     149                 : {
     150                 :     return mType == SYSTEM_PROPERTY ? (STRING_RESULT | NUMBER_RESULT) :
     151               0 :                                       BOOLEAN_RESULT;
     152                 : }
     153                 : 
     154                 : bool
     155               0 : txXSLTEnvironmentFunctionCall::isSensitiveTo(ContextSensitivity aContext)
     156                 : {
     157               0 :     return argsSensitiveTo(aContext);
     158                 : }
     159                 : 
     160                 : #ifdef TX_TO_STRING
     161                 : nsresult
     162               0 : txXSLTEnvironmentFunctionCall::getNameAtom(nsIAtom** aAtom)
     163                 : {
     164                 :     *aAtom = mType == SYSTEM_PROPERTY ? nsGkAtoms::systemProperty :
     165                 :              mType == ELEMENT_AVAILABLE ? nsGkAtoms::elementAvailable :
     166               0 :              nsGkAtoms::functionAvailable;
     167               0 :     NS_ADDREF(*aAtom);
     168                 : 
     169               0 :     return NS_OK;
     170                 : }
     171                 : #endif

Generated by: LCOV version 1.7