LCOV - code coverage report
Current view: top level - parser/htmlparser - nsParserMsgUtils.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 29 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include "nsIServiceManager.h"
       7             : #include "nsIStringBundle.h"
       8             : #include "nsXPIDLString.h"
       9             : #include "nsParserMsgUtils.h"
      10             : #include "nsNetCID.h"
      11             : #include "mozilla/Services.h"
      12             : 
      13           0 : static nsresult GetBundle(const char * aPropFileName, nsIStringBundle **aBundle)
      14             : {
      15           0 :   NS_ENSURE_ARG_POINTER(aPropFileName);
      16           0 :   NS_ENSURE_ARG_POINTER(aBundle);
      17             : 
      18             :   // Create a bundle for the localization
      19             : 
      20             :   nsCOMPtr<nsIStringBundleService> stringService =
      21           0 :     mozilla::services::GetStringBundleService();
      22           0 :   if (!stringService)
      23           0 :     return NS_ERROR_FAILURE;
      24             : 
      25           0 :   return stringService->CreateBundle(aPropFileName, aBundle);
      26             : }
      27             : 
      28             : nsresult
      29           0 : nsParserMsgUtils::GetLocalizedStringByName(const char * aPropFileName, const char* aKey, nsString& oVal)
      30             : {
      31           0 :   oVal.Truncate();
      32             : 
      33           0 :   NS_ENSURE_ARG_POINTER(aKey);
      34             : 
      35           0 :   nsCOMPtr<nsIStringBundle> bundle;
      36           0 :   nsresult rv = GetBundle(aPropFileName,getter_AddRefs(bundle));
      37           0 :   if (NS_SUCCEEDED(rv) && bundle) {
      38           0 :     nsXPIDLString valUni;
      39           0 :     nsAutoString key; key.AssignWithConversion(aKey);
      40           0 :     rv = bundle->GetStringFromName(key.get(), getter_Copies(valUni));
      41           0 :     if (NS_SUCCEEDED(rv) && valUni) {
      42           0 :       oVal.Assign(valUni);
      43             :     }  
      44             :   }
      45             : 
      46           0 :   return rv;
      47             : }
      48             : 
      49             : nsresult
      50           0 : nsParserMsgUtils::GetLocalizedStringByID(const char * aPropFileName, uint32_t aID, nsString& oVal)
      51             : {
      52           0 :   oVal.Truncate();
      53             : 
      54           0 :   nsCOMPtr<nsIStringBundle> bundle;
      55           0 :   nsresult rv = GetBundle(aPropFileName,getter_AddRefs(bundle));
      56           0 :   if (NS_SUCCEEDED(rv) && bundle) {
      57           0 :     nsXPIDLString valUni;
      58           0 :     rv = bundle->GetStringFromID(aID, getter_Copies(valUni));
      59           0 :     if (NS_SUCCEEDED(rv) && valUni) {
      60           0 :       oVal.Assign(valUni);
      61             :     }  
      62             :   }
      63             : 
      64           0 :   return rv;
      65             : }

Generated by: LCOV version 1.13