2007-11-13 02:42:03 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-11-13 02:42:03 -08:00
|
|
|
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsRDFCID.h"
|
|
|
|
#include "nsIRDFService.h"
|
2011-10-28 00:35:45 -07:00
|
|
|
#include "nsString.h"
|
2007-11-13 02:42:03 -08:00
|
|
|
#include "nsXULTemplateResultStorage.h"
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(nsXULTemplateResultStorage, nsIXULTemplateResult)
|
2007-11-13 02:42:03 -08:00
|
|
|
|
|
|
|
nsXULTemplateResultStorage::nsXULTemplateResultStorage(nsXULTemplateResultSetStorage* aResultSet)
|
|
|
|
{
|
2013-12-03 20:57:17 -08:00
|
|
|
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
2013-12-03 13:10:30 -08:00
|
|
|
nsCOMPtr<nsIRDFService> rdfService = do_GetService(kRDFServiceCID);
|
2007-11-13 02:42:03 -08:00
|
|
|
rdfService->GetAnonymousResource(getter_AddRefs(mNode));
|
|
|
|
mResultSet = aResultSet;
|
|
|
|
if (aResultSet) {
|
|
|
|
mResultSet->FillColumnValues(mValues);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 19:09:15 -07:00
|
|
|
nsXULTemplateResultStorage::~nsXULTemplateResultStorage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-11-13 02:42:03 -08:00
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsXULTemplateResultStorage::GetIsContainer(bool* aIsContainer)
|
2007-11-13 02:42:03 -08:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
*aIsContainer = false;
|
2007-11-13 02:42:03 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsXULTemplateResultStorage::GetIsEmpty(bool* aIsEmpty)
|
2007-11-13 02:42:03 -08:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
*aIsEmpty = true;
|
2007-11-13 02:42:03 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsXULTemplateResultStorage::GetMayProcessChildren(bool* aMayProcessChildren)
|
2007-11-13 02:42:03 -08:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
*aMayProcessChildren = false;
|
2007-11-13 02:42:03 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTemplateResultStorage::GetId(nsAString& aId)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
const char* uri = nullptr;
|
2007-11-13 02:42:03 -08:00
|
|
|
mNode->GetValueConst(&uri);
|
|
|
|
|
|
|
|
aId.Assign(NS_ConvertUTF8toUTF16(uri));
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTemplateResultStorage::GetResource(nsIRDFResource** aResource)
|
|
|
|
{
|
|
|
|
*aResource = mNode;
|
|
|
|
NS_IF_ADDREF(*aResource);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTemplateResultStorage::GetType(nsAString& aType)
|
|
|
|
{
|
|
|
|
aType.Truncate();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTemplateResultStorage::GetBindingFor(nsIAtom* aVar, nsAString& aValue)
|
|
|
|
{
|
2008-04-17 09:19:30 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aVar);
|
|
|
|
|
2007-11-13 02:42:03 -08:00
|
|
|
aValue.Truncate();
|
|
|
|
if (!mResultSet) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t idx = mResultSet->GetColumnIndex(aVar);
|
2007-11-13 02:42:03 -08:00
|
|
|
if (idx < 0) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIVariant * value = mValues[idx];
|
|
|
|
if (value) {
|
|
|
|
value->GetAsAString(aValue);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTemplateResultStorage::GetBindingObjectFor(nsIAtom* aVar, nsISupports** aValue)
|
|
|
|
{
|
2008-04-17 09:19:30 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aVar);
|
|
|
|
|
2007-11-13 02:42:03 -08:00
|
|
|
if (mResultSet) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t idx = mResultSet->GetColumnIndex(aVar);
|
2007-11-13 02:42:03 -08:00
|
|
|
if (idx >= 0) {
|
|
|
|
*aValue = mValues[idx];
|
|
|
|
NS_IF_ADDREF(*aValue);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
*aValue = nullptr;
|
2007-11-13 02:42:03 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTemplateResultStorage::RuleMatched(nsISupports* aQuery, nsIDOMNode* aRuleNode)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTemplateResultStorage::HasBeenRemoved()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|