Back to index

lightning-sunbird  0.9+nobinonly
nsGfxFactoryPh.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Christopher Blizzard.
00019  * Portions created by the Initial Developer are Copyright (C) 2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Christopher Blizzzard <blizzard@mozilla.org>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #include "nsIGenericFactory.h"
00040 #include "nsIModule.h"
00041 #include "nsCOMPtr.h"
00042 #include "nsGfxCIID.h"
00043 
00044 #include "nsBlender.h"
00045 #include "nsFontMetricsPh.h"
00046 #include "nsRenderingContextPh.h"
00047 #include "nsDeviceContextSpecPh.h"
00048 #include "nsDeviceContextSpecFactoryP.h"
00049 #include "nsScreenManagerPh.h"
00050 #include "nsScriptableRegion.h"
00051 #include "nsDeviceContextPh.h"
00052 #include "nsPrintOptionsPh.h"
00053 #include "nsPrintSession.h"
00054 #include "nsFontList.h"
00055 #include "gfxImageFrame.h"
00056 
00057 // objects that just require generic constructors
00058 
00059 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsPh)
00060 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextPh)
00061 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextPh)
00062 NS_GENERIC_FACTORY_CONSTRUCTOR(nsImagePh)
00063 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
00064 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionPh)
00065 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecPh)
00066 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryPh)
00067 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorPh)
00068 NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
00069 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerPh)
00070 NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorPh)
00071 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsPh, Init)
00072 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
00073 NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
00074 
00075 // our custom constructors
00076 
00077 static nsresult nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
00078 {
00079   nsresult rv;
00080 
00081   nsIScriptableRegion *inst;
00082 
00083   if ( NULL == aResult )
00084   {
00085     rv = NS_ERROR_NULL_POINTER;
00086     return rv;
00087   }
00088   *aResult = NULL;
00089   if (NULL != aOuter)
00090   {
00091     rv = NS_ERROR_NO_AGGREGATION;
00092     return rv;
00093   }
00094   // create an nsRegionPh and get the scriptable region from it
00095   nsCOMPtr <nsIRegion> rgn;
00096   NS_NEWXPCOM(rgn, nsRegionPh);
00097   nsCOMPtr<nsIScriptableRegion> scriptableRgn;
00098   if (rgn != nsnull)
00099   {
00100     scriptableRgn = new nsScriptableRegion(rgn);
00101     inst = scriptableRgn;
00102   }
00103   if (NULL == inst)
00104   {
00105     rv = NS_ERROR_OUT_OF_MEMORY;
00106     return rv;
00107   }
00108   NS_ADDREF(inst);
00109   // release our variable above now that we have created our owning
00110   // reference - we don't want this to go out of scope early!
00111   scriptableRgn = nsnull;
00112   rv = inst->QueryInterface(aIID, aResult);
00113   NS_RELEASE(inst);
00114 
00115   return rv;
00116 }
00117 
00118 static const nsModuleComponentInfo components[] =
00119 {
00120   { "Ph Font Metrics",
00121     NS_FONT_METRICS_CID,
00122     "@mozilla.org/gfx/fontmetrics;1",
00123     nsFontMetricsPhConstructor },
00124 
00125   { "Ph Device Context",
00126     NS_DEVICE_CONTEXT_CID,
00127     "@mozilla.org/gfx/devicecontext;1",
00128     nsDeviceContextPhConstructor },
00129 
00130   { "Ph Rendering Context",
00131     NS_RENDERING_CONTEXT_CID,
00132     "@mozilla.org/gfx/renderingcontext;1",
00133     nsRenderingContextPhConstructor },
00134 
00135   { "Ph Image",
00136     NS_IMAGE_CID,
00137     "@mozilla.org/gfx/image;1",
00138     nsImagePhConstructor },
00139 
00140   { "Ph Region",
00141     NS_REGION_CID,
00142     "@mozilla.org/gfx/region/Ph;1",
00143     nsRegionPhConstructor },
00144 
00145   { "Scriptable Region",
00146     NS_SCRIPTABLE_REGION_CID,
00147     "@mozilla.org/gfx/region;1",
00148     nsScriptableRegionConstructor },
00149 
00150   { "Blender",
00151     NS_BLENDER_CID,
00152     "@mozilla.org/gfx/blender;1",
00153     nsBlenderConstructor },
00154 
00155   { "Ph Device Context Spec",
00156     NS_DEVICE_CONTEXT_SPEC_CID,
00157     "@mozilla.org/gfx/devicecontextspec;1",
00158     nsDeviceContextSpecPhConstructor },
00159 
00160   { "Ph Device Context Spec Factory",
00161     NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
00162     "@mozilla.org/gfx/devicecontextspecfactory;1",
00163     nsDeviceContextSpecFactoryPhConstructor },
00164 
00165   { "PrintSettings Service",
00166               NS_PRINTSETTINGSSERVICE_CID,
00167               "@mozilla.org/gfx/printsettings-service;1",
00168     nsPrintOptionsPhConstructor },
00169 
00170    { "Ph Font Enumerator",
00171     NS_FONT_ENUMERATOR_CID,
00172     "@mozilla.org/gfx/fontenumerator;1",
00173     nsFontEnumeratorPhConstructor },
00174 
00175        { "Font List",
00176               NS_FONTLIST_CID,
00177               NS_FONTLIST_CONTRACTID,
00178               nsFontListConstructor },
00179 
00180   { "Ph Screen Manager",
00181     NS_SCREENMANAGER_CID,
00182     "@mozilla.org/gfx/screenmanager;1",
00183     nsScreenManagerPhConstructor },
00184 
00185        { "Ph Printer Enumerator",
00186          NS_PRINTER_ENUMERATOR_CID,
00187        "@mozilla.org/gfx/printerenumerator;1",
00188        nsPrinterEnumeratorPhConstructor },
00189 
00190   { "Print Session",
00191     NS_PRINTSESSION_CID,
00192     "@mozilla.org/gfx/printsession;1",
00193     nsPrintSessionConstructor },
00194 
00195   { "windows image frame",
00196     GFX_IMAGEFRAME_CID,
00197     "@mozilla.org/gfx/image/frame;2",
00198     gfxImageFrameConstructor, },
00199 };
00200 
00201 NS_IMPL_NSGETMODULE(nsGfxPhModule, components)
00202