nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarComponentCanvas(aOuter); canvas->QueryInterface(kISupportsIID,(void **)&inst);
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalTimebarComponentCanvas(aOuter);
nsresult nsCalFactory::CreateInstance(nsISupports *aOuter,                                        const nsIID &aIID,                                        void **aResult)  {    if (aResult == NULL) {      return NS_ERROR_NULL_POINTER;    }    *aResult = NULL;      nsISupports *inst = nsnull;  if (mClassID.Equals(kCCalTimeContext)) {    nsICalTimeContext * cc = (nsICalTimeContext *)new nsCalTimeContext();    cc->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalComponent)) {    inst = (nsISupports *)new nsCalComponent();  }  else if (mClassID.Equals(kCCalDurationCommand)) {    inst = (nsISupports *)new nsCalDurationCommand();  }  else if (mClassID.Equals(kCCalDayListCommand)) {    inst = (nsISupports *)new nsCalDayListCommand();  }  else if (mClassID.Equals(kCCalFetchEventsCommand)) {    inst = (nsISupports *)new nsCalFetchEventsCommand();  }  else if (mClassID.Equals(kCCalNewModelCommand)) {    inst = (nsISupports *)new nsCalNewModelCommand();  }  else if (mClassID.Equals(kCCalContextController)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalContextController(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalTimebarContextController)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarContextController(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalMonthContextController)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalMonthContextController(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalTimebarCanvas)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarCanvas(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalCanvas)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalCanvas(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalStatusCanvas)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalStatusCanvas(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalCommandCanvas)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalCommandCanvas(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalTimebarComponentCanvas)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarComponentCanvas(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalTodoComponentCanvas)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTodoComponentCanvas(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalTimebarHeading)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarHeading(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalTimebarUserHeading)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarUserHeading(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalTimebarTimeHeading)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarTimeHeading(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalTimebarScale)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarScale(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalMultiDayViewCanvas)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalMultiDayViewCanvas(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalMultiUserViewCanvas)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalMultiUserViewCanvas(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalDayViewCanvas)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalDayViewCanvas(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalMonthViewCanvas)) {    nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalMonthViewCanvas(aOuter);    canvas->QueryInterface(kISupportsIID,(void **)&inst);  }  else if (mClassID.Equals(kCCalToolkit)) {    inst = (nsISupports *)(nsICalToolkit *)new nsCalToolkit();  }  if (inst == NULL) {      return NS_ERROR_OUT_OF_MEMORY;    }  /* For Agg in Canvas?        if (nsnull != aOuter) {            result = &it->fAggregated;        } else {            result = (nsIProtocolConnection *)it;        }*/  nsresult res = inst->QueryInterface(aIID, aResult);  if (res != NS_OK) {      // We didn't get the right interface, so clean up      delete inst;    }    return res;  }  