michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsIServiceManager.h" michael@0: #include "nsRDFCID.h" michael@0: #include "nsIRDFService.h" michael@0: #include "nsString.h" michael@0: #include "nsXULTemplateResultStorage.h" michael@0: michael@0: NS_IMPL_ISUPPORTS(nsXULTemplateResultStorage, nsIXULTemplateResult) michael@0: michael@0: nsXULTemplateResultStorage::nsXULTemplateResultStorage(nsXULTemplateResultSetStorage* aResultSet) michael@0: { michael@0: static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); michael@0: nsCOMPtr rdfService = do_GetService(kRDFServiceCID); michael@0: rdfService->GetAnonymousResource(getter_AddRefs(mNode)); michael@0: mResultSet = aResultSet; michael@0: if (aResultSet) { michael@0: mResultSet->FillColumnValues(mValues); michael@0: } michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsXULTemplateResultStorage::GetIsContainer(bool* aIsContainer) michael@0: { michael@0: *aIsContainer = false; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsXULTemplateResultStorage::GetIsEmpty(bool* aIsEmpty) michael@0: { michael@0: *aIsEmpty = true; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsXULTemplateResultStorage::GetMayProcessChildren(bool* aMayProcessChildren) michael@0: { michael@0: *aMayProcessChildren = false; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsXULTemplateResultStorage::GetId(nsAString& aId) michael@0: { michael@0: const char* uri = nullptr; michael@0: mNode->GetValueConst(&uri); michael@0: michael@0: aId.Assign(NS_ConvertUTF8toUTF16(uri)); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsXULTemplateResultStorage::GetResource(nsIRDFResource** aResource) michael@0: { michael@0: *aResource = mNode; michael@0: NS_IF_ADDREF(*aResource); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsXULTemplateResultStorage::GetType(nsAString& aType) michael@0: { michael@0: aType.Truncate(); michael@0: return NS_OK; michael@0: } michael@0: michael@0: michael@0: NS_IMETHODIMP michael@0: nsXULTemplateResultStorage::GetBindingFor(nsIAtom* aVar, nsAString& aValue) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aVar); michael@0: michael@0: aValue.Truncate(); michael@0: if (!mResultSet) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: int32_t idx = mResultSet->GetColumnIndex(aVar); michael@0: if (idx < 0) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsIVariant * value = mValues[idx]; michael@0: if (value) { michael@0: value->GetAsAString(aValue); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsXULTemplateResultStorage::GetBindingObjectFor(nsIAtom* aVar, nsISupports** aValue) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aVar); michael@0: michael@0: if (mResultSet) { michael@0: int32_t idx = mResultSet->GetColumnIndex(aVar); michael@0: if (idx >= 0) { michael@0: *aValue = mValues[idx]; michael@0: NS_IF_ADDREF(*aValue); michael@0: return NS_OK; michael@0: } michael@0: } michael@0: *aValue = nullptr; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsXULTemplateResultStorage::RuleMatched(nsISupports* aQuery, nsIDOMNode* aRuleNode) michael@0: { michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsXULTemplateResultStorage::HasBeenRemoved() michael@0: { michael@0: return NS_OK; michael@0: }