Back to index

lightning-sunbird  0.9+nobinonly
nsSVGLibartGlyphMetricsDefault.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 the Mozilla SVG project.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Crocodile Clips Ltd..
00019  * Portions created by the Initial Developer are Copyright (C) 2002
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Alex Fritze <alex.fritze@crocodile-clips.com> (original author)
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 "nsCOMPtr.h"
00040 #include "nsISVGGlyphMetricsSource.h"
00041 #include "nsISVGRendererGlyphMetrics.h"
00042 #include "nsPromiseFlatString.h"
00043 #include "nsFont.h"
00044 #include "nsIFontMetrics.h"
00045 #include "nsPresContext.h"
00046 #include "float.h"
00047 #include "nsIDOMSVGMatrix.h"
00048 #include "nsIDOMSVGRect.h"
00049 #include "nsSVGTypeCIDs.h"
00050 #include "nsIComponentManager.h"
00051 
00056 
00057 
00060 class nsSVGLibartGlyphMetrics : public nsISVGRendererGlyphMetrics
00061 {
00062 protected:
00063   friend nsresult NS_NewSVGLibartGlyphMetricsDefault(nsISVGRendererGlyphMetrics **result,
00064                                                      nsISVGGlyphMetricsSource *src);
00065   
00066   nsSVGLibartGlyphMetrics(nsISVGGlyphMetricsSource *src);
00067   ~nsSVGLibartGlyphMetrics();
00068 public:
00069   // nsISupports interface:
00070   NS_DECL_ISUPPORTS
00071 
00072   // nsISVGRendererGlyphMetrics interface:
00073   NS_DECL_NSISVGRENDERERGLYPHMETRICS
00074 
00075 private:
00076 
00077 };
00078 
00081 //----------------------------------------------------------------------
00082 // implementation:
00083 
00084 nsSVGLibartGlyphMetrics::nsSVGLibartGlyphMetrics(nsISVGGlyphMetricsSource *src)
00085 {
00086 }
00087 
00088 nsSVGLibartGlyphMetrics::~nsSVGLibartGlyphMetrics()
00089 {
00090 }
00091 
00092 nsresult
00093 NS_NewSVGLibartGlyphMetricsDefault(nsISVGRendererGlyphMetrics **result,
00094                                    nsISVGGlyphMetricsSource *src)
00095 {
00096   *result = new nsSVGLibartGlyphMetrics(src);
00097   if (!*result) return NS_ERROR_OUT_OF_MEMORY;
00098   
00099   NS_ADDREF(*result);
00100   return NS_OK;
00101 }
00102 
00103 //----------------------------------------------------------------------
00104 // nsISupports methods:
00105 
00106 NS_IMPL_ADDREF(nsSVGLibartGlyphMetrics)
00107 NS_IMPL_RELEASE(nsSVGLibartGlyphMetrics)
00108 
00109 NS_INTERFACE_MAP_BEGIN(nsSVGLibartGlyphMetrics)
00110   NS_INTERFACE_MAP_ENTRY(nsISVGRendererGlyphMetrics)
00111   NS_INTERFACE_MAP_ENTRY(nsISupports)
00112 NS_INTERFACE_MAP_END
00113 
00114 //----------------------------------------------------------------------
00115 // nsISVGRendererGlyphMetrics methods:
00116 
00118 NS_IMETHODIMP
00119 nsSVGLibartGlyphMetrics::GetBaselineOffset(PRUint16 baselineIdentifier, float *_retval)
00120 {
00121   *_retval = 0.0f;
00122   
00123   switch (baselineIdentifier) {
00124     case BASELINE_TEXT_BEFORE_EDGE:
00125       break;
00126     case BASELINE_TEXT_AFTER_EDGE:
00127       break;
00128     case BASELINE_CENTRAL:
00129     case BASELINE_MIDDLE:
00130       break;
00131     case BASELINE_ALPHABETIC:
00132     default:
00133     break;
00134   }
00135   
00136   return NS_OK;
00137 }
00138 
00139 
00141 NS_IMETHODIMP
00142 nsSVGLibartGlyphMetrics::GetAdvance(float *aAdvance)
00143 {
00144   *aAdvance = 0.0f;
00145   return NS_OK;
00146 }
00147 
00148 NS_IMETHODIMP
00149 nsSVGLibartGlyphMetrics::GetAdvanceOfChar(PRUint32 charnum, float *advance)
00150 {
00151   *advance = 0.0f;
00152   return NS_OK;
00153 }
00154 
00156 NS_IMETHODIMP
00157 nsSVGLibartGlyphMetrics::GetExtentOfChar(PRUint32 charnum, nsIDOMSVGRect **_retval)
00158 {
00159   *_retval = nsnull;
00160 
00161   nsCOMPtr<nsIDOMSVGRect> rect = do_CreateInstance(NS_SVGRECT_CONTRACTID);
00162 
00163   NS_ASSERTION(rect, "could not create rect");
00164   if (!rect) return NS_ERROR_FAILURE;
00165   
00166   rect->SetX(0);
00167   rect->SetY(0);
00168   rect->SetWidth(0);
00169   rect->SetHeight(0);
00170 
00171   *_retval = rect;
00172   NS_ADDREF(*_retval);
00173   
00174   return NS_OK;
00175 }
00176 
00178 NS_IMETHODIMP
00179 nsSVGLibartGlyphMetrics::Update(PRUint32 updatemask, PRBool *_retval)
00180 {
00181   *_retval = PR_FALSE;
00182   return NS_OK;
00183 }
00184