diff --git a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp index a45cd0e76cf..1009225a261 100644 --- a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp +++ b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp @@ -75,7 +75,6 @@ static NS_DEFINE_CID(kCTransferableCID, NS_TRANSFERABLE_CID); static NS_DEFINE_IID(kDataFlavorCID, NS_DATAFLAVOR_CID); static NS_DEFINE_IID(kCHTMLFormatConverterCID, NS_HTMLFORMATCONVERTER_CID); static NS_DEFINE_IID(kCDragServiceCID, NS_DRAGSERVICE_CID); -static NS_DEFINE_IID(kCFontRetrieverServiceCID, NS_FONTRETRIEVERSERVICE_CID); static NS_DEFINE_IID(kCTimerCID, NS_TIMER_CID); static NS_DEFINE_IID(kCTimerManagerCID, NS_TIMERMANAGER_CID); static NS_DEFINE_IID(kSoundCID, NS_SOUND_CID); @@ -137,7 +136,6 @@ NS_SetupRegistry() nsComponentManager::RegisterComponentLib(kDataFlavorCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCHTMLFormatConverterCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCDragServiceCID, "Drag Service", "@mozilla.org/widget/dragservice;1", WIDGET_DLL, PR_FALSE, PR_FALSE); - nsComponentManager::RegisterComponentLib(kCFontRetrieverServiceCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kSoundCID, "Sound Services", "@mozilla.org/sound;1", WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCFilePickerCID, "FilePicker", "@mozilla.org/filepicker;1", WIDGET_DLL, PR_FALSE, PR_FALSE); #ifdef XP_PC diff --git a/mozilla/widget/public/Makefile.in b/mozilla/widget/public/Makefile.in index bf42bbeb130..f90aa41d40e 100644 --- a/mozilla/widget/public/Makefile.in +++ b/mozilla/widget/public/Makefile.in @@ -30,9 +30,6 @@ MODULE = widget XPIDL_MODULE = widget EXPORTS = \ - nsIFontSizeIterator.h \ - nsIFontNameIterator.h \ - nsIFontRetrieverService.h \ nsIMenuBar.h \ nsIMenu.h \ nsIMenuItem.h \ @@ -52,13 +49,6 @@ EXPORTS = \ nsWidgetsCID.h \ nsILookAndFeel.h \ nsILabel.h \ - nsIMenuBar.h \ - nsIMenu.h \ - nsIMenuItem.h \ - nsIPopUpMenu.h \ - nsIFontNameIterator.h \ - nsIFontSizeIterator.h \ - nsIFontRetrieverService.h \ nsIDragSessionGTK.h \ nsIDragSessionXlib.h \ nsIDragSessionMac.h \ diff --git a/mozilla/widget/public/makefile.win b/mozilla/widget/public/makefile.win index 69204659dfb..e1eee999b0a 100644 --- a/mozilla/widget/public/makefile.win +++ b/mozilla/widget/public/makefile.win @@ -47,9 +47,6 @@ XPIDLSRCS = \ $(NULL) EXPORTS=\ - nsIFontSizeIterator.h \ - nsIFontNameIterator.h \ - nsIFontRetrieverService.h \ nsIWidget.h \ nsIKBStateControl.h \ nsIButton.h \ diff --git a/mozilla/widget/public/nsIFontNameIterator.h b/mozilla/widget/public/nsIFontNameIterator.h deleted file mode 100644 index 8dc093381ce..00000000000 --- a/mozilla/widget/public/nsIFontNameIterator.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsIFontNameIterator_h__ -#define nsIFontNameIterator_h__ - -#include "nsISupports.h" -class nsString; - -// {CEEB39D1-0949-11d3-9A87-0050046CDA96} -#define NS_IFONTNAMEITERATOR_IID \ -{ 0xceeb39d1, 0x949, 0x11d3, { 0x9a, 0x87, 0x0, 0x50, 0x4, 0x6c, 0xda, 0x96 } }; - -class nsIFontNameIterator : public nsISupports - // Fonts are identified by strings, |Get| and |Advance| are distinct to facility wrapping - // with C++ objects as standard iterators. - { - public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONTNAMEITERATOR_IID) - - NS_IMETHOD Reset() = 0; - // does not need to be called initially, returns iterator to initial state - - NS_IMETHOD Get( nsString* aFontName ) = 0; - // returns an error when no more names are available - - NS_IMETHOD Advance() = 0; - // returns an error when no more names are available - }; - - -#endif diff --git a/mozilla/widget/public/nsIFontRetrieverService.h b/mozilla/widget/public/nsIFontRetrieverService.h deleted file mode 100644 index 30c4cd6e45c..00000000000 --- a/mozilla/widget/public/nsIFontRetrieverService.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsIFontRetrieverService_h__ -#define nsIFontRetrieverService_h__ - -#include "nsISupports.h" - -class nsIFontNameIterator; -class nsIFontSizeIterator; -class nsString; - -// {285EF9B2-094A-11d3-9A87-0050046CDA96} -#define NS_IFONTRETRIEVERSERVICE_IID \ -{ 0x285ef9b2, 0x94a, 0x11d3, { 0x9a, 0x87, 0x0, 0x50, 0x4, 0x6c, 0xda, 0x96 } }; - -class nsIFontRetrieverService : public nsISupports - // This (singleton) service exists soley as a factory to manufacture iterators -{ - public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONTRETRIEVERSERVICE_IID) - - NS_IMETHOD CreateFontNameIterator( nsIFontNameIterator** aIterator ) = 0; - - NS_IMETHOD CreateFontSizeIterator( const nsString &aFontName, nsIFontSizeIterator** aIterator ) = 0; - - NS_IMETHOD IsFontScalable( const nsString &aFontName, PRBool* aResult ) = 0; -}; - - -#endif diff --git a/mozilla/widget/public/nsIFontSizeIterator.h b/mozilla/widget/public/nsIFontSizeIterator.h deleted file mode 100644 index dbf5a513c32..00000000000 --- a/mozilla/widget/public/nsIFontSizeIterator.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef nsIFontSizeIterator_h__ -#define nsIFontSizeIterator_h__ - -#include "nsISupports.h" -class nsString; - -// {285EF9B1-094A-11d3-9A87-0050046CDA96} -#define NS_IFONTSIZEITERATOR_IID \ -{ 0x285ef9b1, 0x94a, 0x11d3, { 0x9a, 0x87, 0x0, 0x50, 0x4, 0x6c, 0xda, 0x96 } }; - -class nsIFontSizeIterator : public nsISupports - // Font sizes are identified with doubles (e.g., for the possibility of fractional sizes from MM, etc.). - // |Get| and |Advance| are distinct to facility wrapping with C++ objects as standard iterators. - { - public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONTSIZEITERATOR_IID) - - NS_IMETHOD Reset() = 0; - // does not need to be called initially, returns iterator to initial state - - NS_IMETHOD Get( double* aFontSize ) = 0; - // returns an error when no more sizes are available - - NS_IMETHOD Advance() = 0; - // returns an error when no more sizes are available - }; - - -#endif diff --git a/mozilla/widget/public/nsWidgetsCID.h b/mozilla/widget/public/nsWidgetsCID.h index 78419fab5a7..5c365202e1d 100644 --- a/mozilla/widget/public/nsWidgetsCID.h +++ b/mozilla/widget/public/nsWidgetsCID.h @@ -115,29 +115,11 @@ { 0x7f045771, 0x4beb, 0x11d2, \ { 0x8d, 0xbb, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } -//f58c2550-4a7c-11d2-bee2-00805f8a8dbd -#define NS_IMAGEBUTTON_CID \ - { 0xf58c2550, 0x4a7c, 0x11d2, \ - {0xbe, 0xe2, 0x00, 0x80, 0x5f, 0x8a, 0x8d, 0xbd} } - // {F6CD4F21-53AF-11d2-8DC4-00609703C14E} #define NS_POPUPMENU_CID \ { 0xf6cd4f21, 0x53af, 0x11d2, \ { 0x8d, 0xc4, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } -#define NS_MENUBUTTON_CID \ -{ 0x67b8e261, 0x53c3, 0x11d2, \ - { 0x8d, 0xc4, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } - -// {D3C3B8B2-55B5-11d2-9A2A-000000000000} -#define NS_IMAGEBUTTONLISTENER_CID \ -{ 0xd3c3b8b2, 0x55b5, 0x11d2, \ - { 0x9a, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } } - -// {285EF9B2-094A-11d3-9A87-0050046CDA96} -#define NS_FONTRETRIEVERSERVICE_CID \ -{ 0x285ef9b2, 0x94a, 0x11d3, { 0x9a, 0x87, 0x0, 0x50, 0x4, 0x6c, 0xda, 0x96 } } - // {6B6C423A-1DD2-11B2-8888-E540BB169DDD} #define NS_TIMER_CID \ { 0x6b6c423a, 0x1dd2, 0x11b2, \ @@ -175,13 +157,6 @@ #define NS_HTMLFORMATCONVERTER_CID \ { 0x948a0023, 0xe3a7, 0x11d2, { 0x96, 0xcf, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } } -#define NS_DATAOBJ_CID \ -{ 0x1bba7640, 0xdf52, 0x11cf, { 0x82, 0x7b, 0, 0xa0, 0x24, 0x3a, 0xe5, 0x05 } } - -// {E93E73B1-0197-11d3-96D4-0060B0FB9956} -#define NS_FILELISTTRANSFERABLE_CID \ -{ 0xe93e73b1, 0x197, 0x11d3, { 0x96, 0xd4, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } } - //----------------------------------------------------------- //Other //----------------------------------------------------------- diff --git a/mozilla/widget/src/beos/Makefile.in b/mozilla/widget/src/beos/Makefile.in index 0e7d90c946b..e714066d663 100644 --- a/mozilla/widget/src/beos/Makefile.in +++ b/mozilla/widget/src/beos/Makefile.in @@ -40,8 +40,6 @@ CPPSRCS = \ nsClipboard.cpp \ nsDragService.cpp \ nsFilePicker.cpp \ - nsFontRetrieverService.cpp \ - nsFontSizeIterator.cpp \ nsLabel.cpp \ nsLookAndFeel.cpp \ nsObject.cpp \ diff --git a/mozilla/widget/src/beos/nsFontRetrieverService.cpp b/mozilla/widget/src/beos/nsFontRetrieverService.cpp deleted file mode 100644 index 79738dd2fc8..00000000000 --- a/mozilla/widget/src/beos/nsFontRetrieverService.cpp +++ /dev/null @@ -1,454 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -#include "nsFontRetrieverService.h" -#include "nsIWidget.h" -#include - -#include "nsFont.h" -#include "nsVoidArray.h" -#include "nsFontSizeIterator.h" - -NS_IMPL_ADDREF(nsFontRetrieverService) -NS_IMPL_RELEASE(nsFontRetrieverService) - - -//---------------------------------------------------------- -nsFontRetrieverService::nsFontRetrieverService() -{ - NS_INIT_REFCNT(); - - mFontList = nsnull; - mSizeIter = nsnull; - mNameIterInx = 0; - -} - -//---------------------------------------------------------- -nsFontRetrieverService::~nsFontRetrieverService() -{ - if (nsnull != mFontList) - { - for (PRInt32 i=0;iCount();i++) - { - FontInfo * font = (FontInfo *)mFontList->ElementAt(i); - if (font->mSizes) - { - delete font->mSizes; - } - delete font; - } - delete mFontList; - } - NS_IF_RELEASE(mSizeIter); -} - -/** - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsFontRetrieverService::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - - if (NULL == aInstancePtr) - { - return NS_ERROR_NULL_POINTER; - } - - nsresult rv = NS_NOINTERFACE; - - if (aIID.Equals(NS_GET_IID(nsIFontRetrieverService))) - { - *aInstancePtr = (void*) ((nsIFontRetrieverService*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - if (aIID.Equals(NS_GET_IID(nsIFontNameIterator))) - { - *aInstancePtr = (void*) ((nsIFontNameIterator*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return rv; -} - - -//---------------------------------------------------------- -//-- nsIFontRetrieverService -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontNameIterator( nsIFontNameIterator** aIterator ) -{ - if (nsnull == aIterator) - { - return NS_ERROR_FAILURE; - } - - if (nsnull == mFontList) - { - LoadFontList(); - } - *aIterator = this; - NS_ADDREF_THIS(); - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontSizeIterator( const nsString & aFontName, - nsIFontSizeIterator** aIterator ) -{ - // save value in case someone externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do - { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) - { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) - { - if (nsnull == mSizeIter) - { - mSizeIter = new nsFontSizeIterator(); - } - NS_ASSERTION( nsnull != mSizeIter, "nsFontSizeIterator instance pointer is null"); - - *aIterator = (nsIFontSizeIterator *)mSizeIter; - NS_ADDREF(mSizeIter); - - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - mSizeIter->SetFontInfo(fontInfo); - mNameIterInx = saveIterInx; - return NS_OK; - } - mNameIterInx = saveIterInx; - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Reset() -{ - mNameIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Get( nsString* aFontName ) -{ - if (mNameIterInx < mFontList->Count()) - { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aFontName = fontInfo->mName; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Advance() -{ - if (mNameIterInx < mFontList->Count()-1) - { - mNameIterInx++; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//------------------------------ -static FontInfo * GetFontInfo(nsVoidArray * aFontList, char * aName) -{ - nsAutoString name; name.AssignWithConversion(aName); - PRInt32 i; - PRInt32 cnt = aFontList->Count(); - for (i=0;iElementAt(i); - if (fontInfo) // I don't think ElementAt can return null pointer... See Bug 8827 - { - if (fontInfo->mName.Equals(name)) - { - return fontInfo; - } - } - } - - FontInfo * fontInfo = new FontInfo(); - if (fontInfo) - { - fontInfo->mName.AssignWithConversion(aName); - //printf("Adding [%s]\n", aName);fflush(stdout); - fontInfo->mIsScalable = PR_FALSE; // X fonts aren't scalable right?? - fontInfo->mSizes = nsnull; - aFontList->AppendElement(fontInfo); - return fontInfo; - } - return nsnull; -} - -//------------------------------ -static void AddSizeToFontInfo(FontInfo * aFontInfo, PRInt32 aSize) -{ - nsVoidArray * sizes; - if (nsnull == aFontInfo->mSizes) - { - sizes = new nsVoidArray(); - aFontInfo->mSizes = sizes; - } - else - { - sizes = aFontInfo->mSizes; - } - PRInt32 i; - PRInt32 cnt = sizes->Count(); - for (i=0;iElementAt(i); - if (size == aSize) - { - return; - } - } - sizes->AppendElement((void *)aSize); -} - -//--------------------------------------------------- -// XXX - Hack - Parts of this will need to be reworked -// -// This method does brute force parcing for 4 different formats: -// -// 1) The format -*-*-*-*-*-* etc. -// -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-8 -// -// 2) Name-size format -// lucidasans-10 -// -// 3) Name-style-size -// lucidasans-bold-10 -// -// 4) Name only (implicit size) -// 6x13 -// -//-------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::LoadFontList() -{ -// char * pattern = "*"; -// int nnames = 1024; -// -// int available = nnames+1; -// int i; -// char **fonts; -// XFontStruct *info; -// -// if (nsnull == mFontList) { -// mFontList = new nsVoidArray(); -// if (nsnull == mFontList) { -// return NS_ERROR_FAILURE; -// } -// } -// -// /* Get list of fonts matching pattern */ -// for (;;) { -// // the following line is VERY slow to return -// fonts = XListFontsWithInfo(GDK_DISPLAY(), pattern, nnames, -// &available, &info); -// if (fonts == NULL || available < nnames) -// break; -// -// XFreeFontInfo(fonts, info, available); -// nnames = available * 2; -// } -// -// if (fonts == NULL) { -// fprintf(stderr, "pattern \"%s\" unmatched\n", pattern); -// return NS_ERROR_FAILURE; -// } -// -//#if 0 // debug -// // print out all the retrieved fonts -// printf("-----------------------------\n"); -// for (i=0; imSizes) { -// font->mSizes = new nsVoidArray(); -// } -// ptr = end+1; // skip past the dash that was set to zero -// -// cnt = 0; -// // now skip ahead 4 dashes -// do { -// if (*ptr == '-') cnt++; -// ptr++; -// } while (cnt < 4); -// -// // find the dash after the size -// end = strchr(ptr, '-'); -// -// if (end) { -// *end = 0; -// PRInt32 size; -// sscanf(ptr, "%d", &size); -// AddSizeToFontInfo(font, size); -// } -// } -// } else { // formats 2,3,4 -// -// // no leading dash means the start of the -// // buffer is the start of the name -// // this checks for a dash at the end of the font name -// // which means there is a size at the end -// char * end = strchr(buffer, '-'); -// if (end) { // Format 2,3 -// *end = 0; -// // Check to see if we need to create a new FontInfo obj -// // and set the currentName var to this guys font name -// if (strcmp(currentName, buffer) || NULL == font) { -// font = GetFontInfo(mFontList, buffer); -// strcpy(currentName, buffer); -// } -// end++; // advance past the dash -// // check to see if we have a number -// ptr = end; -// if (isalpha(*ptr)) { // Format 3 -// // skip until next dash -// end = strchr(ptr, '-'); -// if (end) { -// *end = 0; -// ptr = end+1; -// } -// } -// PRInt32 size; -// // yes, it has a dash at the end so it must have the size -// // check to see if the size is terminated by a dash -// // it shouldn't be -// char * end2 = strchr(ptr, '-'); -// if (end2) *end2 = 0; // put terminator at the dash -// sscanf(end, "%d", &size); -// AddSizeToFontInfo(font, size); -// -// } else { // Format #4 -// // The font has an implicit size, -// // so there is nothing to parse for size -// // so we can't really do much here -// // Check to see if we need to create a new FontInfo obj -// // and set the currentName var to this guys font name -// if (strcmp(currentName, buffer) || NULL == font) { -// font = GetFontInfo(mFontList, buffer); -// strcpy(currentName, buffer); -// } -// } -// } -// -// } -// -// XFreeFontInfo(fonts, info, available); - - return NS_OK; -} - - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::IsFontScalable(const nsString & aFontName, - PRBool* aResult ) -{ - // save value in case someone externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do - { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) - { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) - { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aResult = fontInfo->mIsScalable; - mNameIterInx = saveIterInx; - return NS_OK; - } - - mNameIterInx = saveIterInx; - return NS_ERROR_FAILURE; -} diff --git a/mozilla/widget/src/beos/nsFontRetrieverService.h b/mozilla/widget/src/beos/nsFontRetrieverService.h deleted file mode 100644 index ae3db647a98..00000000000 --- a/mozilla/widget/src/beos/nsFontRetrieverService.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontRetrieverService -#define __nsFontRetrieverService - -#include "nsIFontRetrieverService.h" -#include "nsIFontNameIterator.h" - -class nsVoidArray; -class nsFontSizeIterator; - -class nsFontRetrieverService: public nsIFontRetrieverService, - public nsIFontNameIterator { -public: - nsFontRetrieverService(); - virtual ~nsFontRetrieverService(); - - NS_DECL_ISUPPORTS - - // nsIFontRetrieverService - NS_IMETHOD CreateFontNameIterator( nsIFontNameIterator** aIterator ); - - NS_IMETHOD CreateFontSizeIterator( const nsString & aFontName, nsIFontSizeIterator** aIterator ); - NS_IMETHOD IsFontScalable( const nsString & aFontName, PRBool* aResult ); - - // nsIFontNameIterator - - NS_IMETHOD Reset(); - NS_IMETHOD Get( nsString* aFontName ); - NS_IMETHOD Advance(); - - - -protected: - NS_IMETHOD LoadFontList(); - - nsVoidArray * mFontList; - - PRInt32 mNameIterInx; - - nsFontSizeIterator * mSizeIter; -}; - -#endif diff --git a/mozilla/widget/src/beos/nsFontSizeIterator.cpp b/mozilla/widget/src/beos/nsFontSizeIterator.cpp deleted file mode 100644 index f984918c60f..00000000000 --- a/mozilla/widget/src/beos/nsFontSizeIterator.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -#include "nsFontSizeIterator.h" - -#include "nsFont.h" -#include "nsVoidArray.h" - - -NS_IMPL_ISUPPORTS1(nsFontSizeIterator, nsIFontSizeIterator) - -//---------------------------------------------------------- -nsFontSizeIterator::nsFontSizeIterator() -{ - NS_INIT_REFCNT(); - mFontInfo = nsnull; - mSizeIterInx = 0; - -} - -//---------------------------------------------------------- -nsFontSizeIterator::~nsFontSizeIterator() -{ -} - -///---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Reset() -{ - mSizeIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Get( double* aFontSize ) -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()) { - PRUint32 size = (PRUint32)mFontInfo->mSizes->ElementAt(mSizeIterInx); - *aFontSize = (double)size; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Advance() -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()-2) { - mSizeIterInx++; - return NS_OK; - } - - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::SetFontInfo( FontInfo * aFontInfo ) -{ - mFontInfo = aFontInfo; - return NS_OK; -} diff --git a/mozilla/widget/src/beos/nsFontSizeIterator.h b/mozilla/widget/src/beos/nsFontSizeIterator.h deleted file mode 100644 index a32db1af469..00000000000 --- a/mozilla/widget/src/beos/nsFontSizeIterator.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontSizeIterator -#define __nsFontSizeIterator - -#include "nsIFontSizeIterator.h" -#include "nsString.h" - -class nsVoidArray; - -typedef struct { - nsString mName; - PRBool mIsScalable; - nsVoidArray * mSizes; -} FontInfo; - - -class nsFontSizeIterator: public nsIFontSizeIterator { -public: - nsFontSizeIterator(); - virtual ~nsFontSizeIterator(); - - NS_DECL_ISUPPORTS - - // nsIFontSizeIterator - NS_IMETHOD Reset(); - NS_IMETHOD Get( double* aFontSize ); - NS_IMETHOD Advance(); - - // Native impl - NS_IMETHOD SetFontInfo( FontInfo * aFontInfo ); - -protected: - - FontInfo * mFontInfo; - PRInt32 mSizeIterInx; // current index of iter -}; - -#endif diff --git a/mozilla/widget/src/beos/nsWidgetFactory.cpp b/mozilla/widget/src/beos/nsWidgetFactory.cpp index 4bf910ef206..743aca3a331 100644 --- a/mozilla/widget/src/beos/nsWidgetFactory.cpp +++ b/mozilla/widget/src/beos/nsWidgetFactory.cpp @@ -37,7 +37,6 @@ #include "nsFilePicker.h" #include "nsLookAndFeel.h" #include "nsLabel.h" -#include "nsFontRetrieverService.h" #ifdef IBMBIDI #include "nsBidiKeyboard.h" #endif @@ -63,10 +62,8 @@ static NS_DEFINE_IID(kCAppShell, NS_APPSHELL_CID); static NS_DEFINE_IID(kCToolkit, NS_TOOLKIT_CID); static NS_DEFINE_IID(kCLookAndFeel, NS_LOOKANDFEEL_CID); static NS_DEFINE_IID(kCLabel, NS_LABEL_CID); -static NS_DEFINE_IID(kCFontRetrieverService, NS_FONTRETRIEVERSERVICE_CID); // Drag & Drop, Clipboard -static NS_DEFINE_IID(kCDataObj, NS_DATAOBJ_CID); static NS_DEFINE_IID(kCClipboard, NS_CLIPBOARD_CID); static NS_DEFINE_IID(kCClipboardHelper, NS_CLIPBOARDHELPER_CID); static NS_DEFINE_IID(kCTransferable, NS_TRANSFERABLE_CID); @@ -207,9 +204,6 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, else if (mClassID.Equals(kCHTMLFormatConverter)) { inst = (nsISupports*)new nsHTMLFormatConverter(); } - else if (mClassID.Equals(kCFontRetrieverService)) { - inst = (nsISupports*)(nsIFontRetrieverService *) new nsFontRetrieverService(); - } else if (mClassID.Equals(kCDragService)) { inst = (nsISupports*) (nsIDragService *) new nsDragService(); } diff --git a/mozilla/widget/src/build/nsWinWidgetFactory.cpp b/mozilla/widget/src/build/nsWinWidgetFactory.cpp index 6743a6a1f44..23dc7e4127f 100644 --- a/mozilla/widget/src/build/nsWinWidgetFactory.cpp +++ b/mozilla/widget/src/build/nsWinWidgetFactory.cpp @@ -34,7 +34,6 @@ #include "nsWindow.h" #include "nsAppShell.h" #include "nsIServiceManager.h" -#include "nsFontRetrieverService.h" #include "nsSound.h" #include "nsITimer.h" @@ -66,7 +65,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimer) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerManager) #ifdef IBMBIDI @@ -195,10 +193,6 @@ static nsModuleComponentInfo components[] = // "@mozilla.org/widget/dragservice/win;1", "@mozilla.org/widget/dragservice;1", nsDragServiceConstructor }, - { "Font Retriever Service", - NS_FONTRETRIEVERSERVICE_CID, - "@mozilla.org/widget/fontretrieverservice/win;1", - nsFontRetrieverServiceConstructor }, { "Timer", NS_TIMER_CID, "@mozilla.org/timer;1", diff --git a/mozilla/widget/src/gtk/Makefile.in b/mozilla/widget/src/gtk/Makefile.in index dfe2ecc0743..54bd7d15f69 100644 --- a/mozilla/widget/src/gtk/Makefile.in +++ b/mozilla/widget/src/gtk/Makefile.in @@ -39,8 +39,6 @@ CPPSRCS = \ nsCheckButton.cpp \ nsClipboard.cpp \ nsDragService.cpp \ - nsFontRetrieverService.cpp \ - nsFontSizeIterator.cpp \ nsGtkEventHandler.cpp \ nsGtkUtils.cpp \ nsKeyboardUtils.cpp \ diff --git a/mozilla/widget/src/gtk/nsFontRetrieverService.cpp b/mozilla/widget/src/gtk/nsFontRetrieverService.cpp deleted file mode 100644 index 65ddae1a6eb..00000000000 --- a/mozilla/widget/src/gtk/nsFontRetrieverService.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nscore.h" -#include "nsFontRetrieverService.h" -#include "nsIWidget.h" -#include -#include -#include -#include "X11/Xlib.h" -#include "X11/Xutil.h" - -#include "nsFont.h" -#include "nsVoidArray.h" -#include "nsFontSizeIterator.h" - -NS_IMPL_ISUPPORTS2(nsFontRetrieverService, nsIFontRetrieverService, nsIFontNameIterator) - -//---------------------------------------------------------- -nsFontRetrieverService::nsFontRetrieverService() -{ - NS_INIT_REFCNT(); - - mFontList = nsnull; - mSizeIter = nsnull; - mNameIterInx = 0; - -} - -//---------------------------------------------------------- -nsFontRetrieverService::~nsFontRetrieverService() -{ - if (nsnull != mFontList) { - for (PRInt32 i=0;iCount();i++) { - FontInfo * font = (FontInfo *)mFontList->ElementAt(i); - if (font->mSizes) { - delete font->mSizes; - } - delete font; - } - delete mFontList; - } - NS_IF_RELEASE(mSizeIter); -} - - - -//---------------------------------------------------------- -//-- nsIFontRetrieverService -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontNameIterator( nsIFontNameIterator** aIterator ) -{ - if (nsnull == aIterator) { - return NS_ERROR_FAILURE; - } - - if (nsnull == mFontList) { - LoadFontList(); - } - *aIterator = this; - NS_ADDREF_THIS(); - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontSizeIterator( const nsString & aFontName, - nsIFontSizeIterator** aIterator ) -{ - // save value in case someone externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) { - if (nsnull == mSizeIter) { - mSizeIter = new nsFontSizeIterator(); - } - NS_ASSERTION( nsnull != mSizeIter, "nsFontSizeIterator instance pointer is null"); - - *aIterator = (nsIFontSizeIterator *)mSizeIter; - NS_ADDREF(mSizeIter); - - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - mSizeIter->SetFontInfo(fontInfo); - mNameIterInx = saveIterInx; - return NS_OK; - } - mNameIterInx = saveIterInx; - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Reset() -{ - mNameIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Get( nsString* aFontName ) -{ - if (mNameIterInx < mFontList->Count()) { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aFontName = fontInfo->mName; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Advance() -{ - if (mNameIterInx < mFontList->Count()-1) { - mNameIterInx++; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//------------------------------ -static FontInfo * GetFontInfo(nsVoidArray * aFontList, char * aName) -{ - nsAutoString name; - name.AssignWithConversion(aName); - PRInt32 i; - PRInt32 cnt = aFontList->Count(); - for (i=0;iElementAt(i); - if (fontInfo->mName.Equals(name)) { - return fontInfo; - } - } - - FontInfo * fontInfo = new FontInfo(); - fontInfo->mName.AssignWithConversion(aName); - //printf("Adding [%s]\n", aName);fflush(stdout); - fontInfo->mIsScalable = PR_FALSE; // X fonts aren't scalable right?? - fontInfo->mSizes = nsnull; - aFontList->AppendElement(fontInfo); - return fontInfo; -} - -//------------------------------ -static void AddSizeToFontInfo(FontInfo * aFontInfo, PRInt32 aSize) -{ - nsVoidArray * sizes; - if (nsnull == aFontInfo->mSizes) { - sizes = new nsVoidArray(); - aFontInfo->mSizes = sizes; - } else { - sizes = aFontInfo->mSizes; - } - PRInt32 i; - PRInt32 cnt = sizes->Count(); - for (i=0;iElementAt(i)); - if (size == aSize) { - return; - } - } - sizes->AppendElement((void *)aSize); -} - -//--------------------------------------------------- -// XXX - Hack - Parts of this will need to be reworked -// -// This method does brute force parcing for 4 different formats: -// -// 1) The format -*-*-*-*-*-* etc. -// -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-8 -// -// 2) Name-size format -// lucidasans-10 -// -// 3) Name-style-size -// lucidasans-bold-10 -// -// 4) Name only (implicit size) -// 6x13 -// -//-------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::LoadFontList() -{ - char * pattern = "*"; - int nnames = 1024; - - int available = nnames+1; - int i; - char **fonts; - XFontStruct *info; - - if (nsnull == mFontList) { - mFontList = new nsVoidArray(); - if (nsnull == mFontList) { - return NS_ERROR_FAILURE; - } - } - - /* Get list of fonts matching pattern */ - for (;;) { - // the following line is VERY slow to return - fonts = XListFontsWithInfo(GDK_DISPLAY(), pattern, nnames, - &available, &info); - if (fonts == NULL || available < nnames) - break; - - XFreeFontInfo(fonts, info, available); - nnames = available * 2; - } - - if (fonts == NULL) { -#ifdef DEBUG - fprintf(stderr, "pattern \"%s\" unmatched\n", pattern); -#endif - return NS_ERROR_FAILURE; - } - -#if 0 // debug - // print out all the retrieved fonts - printf("-----------------------------\n"); - for (i=0; imSizes) { - font->mSizes = new nsVoidArray(); - } - ptr = end+1; // skip past the dash that was set to zero - - cnt = 0; - // now skip ahead 4 dashes - do { - if (*ptr == '-') cnt++; - ptr++; - } while (cnt < 4); - - // find the dash after the size - end = strchr(ptr, '-'); - - if (end) { - *end = 0; - PRInt32 size; - sscanf(ptr, "%d", &size); - AddSizeToFontInfo(font, size); - } - } - } else { // formats 2,3,4 - - // no leading dash means the start of the - // buffer is the start of the name - // this checks for a dash at the end of the font name - // which means there is a size at the end - char * end = strchr(buffer, '-'); - if (end) { // Format 2,3 - *end = 0; - // Check to see if we need to create a new FontInfo obj - // and set the currentName var to this guys font name - if (strcmp(currentName, buffer) || NULL == font) { - font = GetFontInfo(mFontList, buffer); - strcpy(currentName, buffer); - } - end++; // advance past the dash - // check to see if we have a number - ptr = end; - if (isalpha(*ptr)) { // Format 3 - // skip until next dash - end = strchr(ptr, '-'); - if (end) { - *end = 0; - ptr = end+1; - } - } - PRInt32 size; - // yes, it has a dash at the end so it must have the size - // check to see if the size is terminated by a dash - // it shouldn't be - char * end2 = strchr(ptr, '-'); - if (end2) *end2 = 0; // put terminator at the dash - sscanf(end, "%d", &size); - AddSizeToFontInfo(font, size); - - } else { // Format #4 - // The font has an implicit size, - // so there is nothing to parse for size - // so we can't really do much here - // Check to see if we need to create a new FontInfo obj - // and set the currentName var to this guys font name - if (strcmp(currentName, buffer) || NULL == font) { - font = GetFontInfo(mFontList, buffer); - strcpy(currentName, buffer); - } - } - } - - } - - XFreeFontInfo(fonts, info, available); - - return NS_OK; -} - - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::IsFontScalable(const nsString & aFontName, - PRBool* aResult ) -{ - // save value in case someone externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aResult = fontInfo->mIsScalable; - mNameIterInx = saveIterInx; - return NS_OK; - } - - mNameIterInx = saveIterInx; - return NS_ERROR_FAILURE; -} diff --git a/mozilla/widget/src/gtk/nsFontRetrieverService.h b/mozilla/widget/src/gtk/nsFontRetrieverService.h deleted file mode 100644 index 4c0e4a85cc9..00000000000 --- a/mozilla/widget/src/gtk/nsFontRetrieverService.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontRetrieverService -#define __nsFontRetrieverService - -#include "nsIFontRetrieverService.h" -#include "nsIFontNameIterator.h" - -class nsVoidArray; -class nsFontSizeIterator; - -class nsFontRetrieverService: public nsIFontRetrieverService, - public nsIFontNameIterator -{ -public: - nsFontRetrieverService(); - virtual ~nsFontRetrieverService(); - - NS_DECL_ISUPPORTS - - // nsIFontRetrieverService - NS_IMETHOD CreateFontNameIterator( nsIFontNameIterator** aIterator ); - - NS_IMETHOD CreateFontSizeIterator( const nsString & aFontName, nsIFontSizeIterator** aIterator ); - NS_IMETHOD IsFontScalable( const nsString & aFontName, PRBool* aResult ); - - // nsIFontNameIterator - - NS_IMETHOD Reset(); - NS_IMETHOD Get( nsString* aFontName ); - NS_IMETHOD Advance(); - - - -protected: - NS_IMETHOD LoadFontList(); - - nsVoidArray * mFontList; - - PRInt32 mNameIterInx; - - nsFontSizeIterator * mSizeIter; -}; - -#endif diff --git a/mozilla/widget/src/gtk/nsFontSizeIterator.cpp b/mozilla/widget/src/gtk/nsFontSizeIterator.cpp deleted file mode 100644 index e55c5dafade..00000000000 --- a/mozilla/widget/src/gtk/nsFontSizeIterator.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nscore.h" -#include "nsFontSizeIterator.h" - -#include "nsFont.h" -#include "nsVoidArray.h" - - -NS_IMPL_ISUPPORTS1(nsFontSizeIterator, nsIFontSizeIterator) - -//---------------------------------------------------------- -nsFontSizeIterator::nsFontSizeIterator() -{ - NS_INIT_REFCNT(); - mFontInfo = nsnull; - mSizeIterInx = 0; - -} - -//---------------------------------------------------------- -nsFontSizeIterator::~nsFontSizeIterator() -{ -} - -///---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Reset() -{ - mSizeIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Get( double* aFontSize ) -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()) { - PRUint32 size = NS_PTR_TO_INT32(mFontInfo->mSizes->ElementAt(mSizeIterInx)); - *aFontSize = (double)size; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Advance() -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()-2) { - mSizeIterInx++; - return NS_OK; - } - - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::SetFontInfo( FontInfo * aFontInfo ) -{ - mFontInfo = aFontInfo; - return NS_OK; -} diff --git a/mozilla/widget/src/gtk/nsFontSizeIterator.h b/mozilla/widget/src/gtk/nsFontSizeIterator.h deleted file mode 100644 index a32db1af469..00000000000 --- a/mozilla/widget/src/gtk/nsFontSizeIterator.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontSizeIterator -#define __nsFontSizeIterator - -#include "nsIFontSizeIterator.h" -#include "nsString.h" - -class nsVoidArray; - -typedef struct { - nsString mName; - PRBool mIsScalable; - nsVoidArray * mSizes; -} FontInfo; - - -class nsFontSizeIterator: public nsIFontSizeIterator { -public: - nsFontSizeIterator(); - virtual ~nsFontSizeIterator(); - - NS_DECL_ISUPPORTS - - // nsIFontSizeIterator - NS_IMETHOD Reset(); - NS_IMETHOD Get( double* aFontSize ); - NS_IMETHOD Advance(); - - // Native impl - NS_IMETHOD SetFontInfo( FontInfo * aFontInfo ); - -protected: - - FontInfo * mFontInfo; - PRInt32 mSizeIterInx; // current index of iter -}; - -#endif diff --git a/mozilla/widget/src/gtk/nsWidgetFactory.cpp b/mozilla/widget/src/gtk/nsWidgetFactory.cpp index 66d36a02b94..c279fa582cd 100644 --- a/mozilla/widget/src/gtk/nsWidgetFactory.cpp +++ b/mozilla/widget/src/gtk/nsWidgetFactory.cpp @@ -39,7 +39,6 @@ #include "nsClipboard.h" #include "nsClipboardHelper.h" #include "nsHTMLFormatConverter.h" -#include "nsFontRetrieverService.h" #include "nsDragService.h" #include "nsScrollbar.h" #include "nsSound.h" @@ -62,7 +61,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) #ifdef IBMBIDI @@ -196,10 +194,6 @@ static nsModuleComponentInfo components[] = NS_HTMLFORMATCONVERTER_CID, "@mozilla.org/widget/htmlformatconverter/gtk;1", nsHTMLFormatConverterConstructor }, - { "Gtk Font Retriever Service", - NS_FONTRETRIEVERSERVICE_CID, - "@mozilla.org/widget/fontretrieverservice/gtk;1", - nsFontRetrieverServiceConstructor }, { "Gtk Drag Service", NS_DRAGSERVICE_CID, // "@mozilla.org/widget/dragservice/gtk;1", diff --git a/mozilla/widget/src/motif/nsWidgetFactory.cpp b/mozilla/widget/src/motif/nsWidgetFactory.cpp index 1652fab9219..6d5558881c7 100644 --- a/mozilla/widget/src/motif/nsWidgetFactory.cpp +++ b/mozilla/widget/src/motif/nsWidgetFactory.cpp @@ -36,7 +36,6 @@ #include "nsTextWidget.h" #include "nsLookAndFeel.h" #include "nsLabel.h" -// #include "nsFontRetrieverService.h" // Drag & Drop, Clipboard // #include "nsClipboard.h" @@ -64,10 +63,8 @@ static NS_DEFINE_IID(kCAppShell, NS_APPSHELL_CID); static NS_DEFINE_IID(kCToolkit, NS_TOOLKIT_CID); static NS_DEFINE_IID(kCLookAndFeel, NS_LOOKANDFEEL_CID); static NS_DEFINE_IID(kCLabel, NS_LABEL_CID); -static NS_DEFINE_IID(kCFontRetrieverService, NS_FONTRETRIEVERSERVICE_CID); // Drag & Drop, Clipboard -static NS_DEFINE_IID(kCDataObj, NS_DATAOBJ_CID); static NS_DEFINE_IID(kCClipboard, NS_CLIPBOARD_CID); static NS_DEFINE_IID(kCClipboardHelper, NS_CLIPBOARDHELPER_CID); static NS_DEFINE_IID(kCTransferable, NS_TRANSFERABLE_CID); @@ -208,9 +205,6 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, inst = (nsISupports*)(nsIBidiKeyboard*) new nsBidiKeyboard(); } #endif // IBMBIDI -// else if (mClassID.Equals(kCFontRetrieverService)) { -// inst = (nsISupports*)(nsIFontRetrieverService *) new nsFontRetrieverService(); -// } #if 0 else if (mClassID.Equals(kCDragService)) { inst = (nsISupports*)new nsDragService(); diff --git a/mozilla/widget/src/os2/Makefile.in b/mozilla/widget/src/os2/Makefile.in index 0aa20008e72..a0031fbd78f 100644 --- a/mozilla/widget/src/os2/Makefile.in +++ b/mozilla/widget/src/os2/Makefile.in @@ -46,8 +46,6 @@ CPPSRCS = \ nsDirPicker.cpp \ nsFSTree.cpp \ nsFilePicker.cpp \ - nsFontRetrieverService.cpp \ - nsFontSizeIterator.cpp \ nsFrameWindow.cpp \ nsLookAndFeel.cpp \ nsModule.cpp \ diff --git a/mozilla/widget/src/os2/nsFontRetrieverService.cpp b/mozilla/widget/src/os2/nsFontRetrieverService.cpp deleted file mode 100644 index 6a50edc5066..00000000000 --- a/mozilla/widget/src/os2/nsFontRetrieverService.cpp +++ /dev/null @@ -1,244 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - * Henry Sobotka : OS/2 adaptation - */ - -#include "nsFontRetrieverService.h" - -#include "nsFont.h" -#include "nsVoidArray.h" -#include "nsFontSizeIterator.h" - -NS_IMPL_ADDREF(nsFontRetrieverService) -NS_IMPL_RELEASE(nsFontRetrieverService) - - -//---------------------------------------------------------- -nsFontRetrieverService::nsFontRetrieverService() -{ - NS_INIT_REFCNT(); - - mFontList = nsnull; - mSizeIter = nsnull; - mNameIterInx = 0; - -} - -//---------------------------------------------------------- -nsFontRetrieverService::~nsFontRetrieverService() -{ - if (nsnull != mFontList) { - for (PRInt32 i=0;iCount();i++) { - FontInfo * font = (FontInfo *)mFontList->ElementAt(i); - if (font->mSizes) { - delete font->mSizes; - } - delete font; - } - delete mFontList; - } - NS_IF_RELEASE(mSizeIter); -} - -/** - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsFontRetrieverService::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - nsresult rv = NS_NOINTERFACE; - - if (aIID.Equals(NS_GET_IID(nsIFontRetrieverService))) { - *aInstancePtr = (void*) ((nsIFontRetrieverService*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - if (aIID.Equals(NS_GET_IID(nsIFontNameIterator))) { - *aInstancePtr = (void*) ((nsIFontNameIterator*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return rv; -} - - -//---------------------------------------------------------- -//-- nsIFontRetrieverService -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontNameIterator( nsIFontNameIterator** aIterator ) -{ - if (nsnull == aIterator) { - return NS_ERROR_FAILURE; - } - - if (nsnull == mFontList) { - LoadFontList(); - } - *aIterator = this; - NS_ADDREF_THIS(); - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontSizeIterator( const nsString &aFontName, - nsIFontSizeIterator** aIterator ) -{ - // cache current value in case someone else externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) { - if (nsnull == mSizeIter) { - mSizeIter = new nsFontSizeIterator(); - } - NS_ASSERTION( nsnull != mSizeIter, "nsFontSizeIterator instance pointer is null"); - - *aIterator = (nsIFontSizeIterator *)mSizeIter; - NS_ADDREF(mSizeIter); - - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - mSizeIter->SetFontInfo(fontInfo); - mNameIterInx = saveIterInx; - return NS_OK; - } - mNameIterInx = saveIterInx; - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Reset() -{ - mNameIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Get( nsString* aFontName ) -{ - if (mNameIterInx < mFontList->Count()) { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aFontName = fontInfo->mName; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Advance() -{ - if (mNameIterInx < mFontList->Count()-1) { - mNameIterInx++; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::LoadFontList() -{ - if (nsnull == mFontList) { - mFontList = new nsVoidArray(); - if (nsnull == mFontList) { - return NS_ERROR_FAILURE; - } - } - - HPS hps = WinGetScreenPS(HWND_DESKTOP); - LONG lWant = 0, lFonts; - - // Get number of fonts - lFonts = GpiQueryFonts(hps, QF_PUBLIC | QF_PRIVATE, - 0, &lWant, 0, 0); - PFONTMETRICS fMetrics = new FONTMETRICS[lFonts]; - - // Get fontmetrics - GpiQueryFonts(hps, QF_PUBLIC | QF_PRIVATE, 0, &lFonts, - sizeof(FONTMETRICS), fMetrics); - - // Load fonts - for (LONG i = 0; i < lFonts; i++) { - FontInfo * font = new FontInfo(); - font->mName.AssignWithConversion(fMetrics[i].szFamilyname); - font->mIsScalable = PR_FALSE; - font->mSizes = nsnull; -#ifdef DEBUG_sobotka - printf("Added FONT %s\n", font->mName.ToNewCString()); -#endif - - mFontList->AppendElement(font); - } - - // Clean up - delete[] fMetrics; - WinReleasePS(hps); - - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::IsFontScalable( const nsString &aFontName, PRBool* aResult ) -{ - // cache current value in case someone else externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aResult = fontInfo->mIsScalable; - mNameIterInx = saveIterInx; - return NS_OK; - } - mNameIterInx = saveIterInx; - - return NS_ERROR_FAILURE; -} diff --git a/mozilla/widget/src/os2/nsFontRetrieverService.h b/mozilla/widget/src/os2/nsFontRetrieverService.h deleted file mode 100644 index 6bf2075d652..00000000000 --- a/mozilla/widget/src/os2/nsFontRetrieverService.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontRetrieverService -#define __nsFontRetrieverService - -#include "nsIFontRetrieverService.h" -#include "nsIFontNameIterator.h" -#define INCL_PM -#include - -class nsVoidArray; -class nsFontSizeIterator; - -class nsFontRetrieverService: public nsIFontRetrieverService, - public nsIFontNameIterator -{ -public: - nsFontRetrieverService(); - virtual ~nsFontRetrieverService(); - - NS_DECL_ISUPPORTS - - // nsIFontRetrieverService - NS_IMETHOD CreateFontNameIterator( nsIFontNameIterator** aIterator ); - NS_IMETHOD CreateFontSizeIterator( const nsString &aFontName, nsIFontSizeIterator** aIterator ); - NS_IMETHOD IsFontScalable( const nsString &aFontName, PRBool* aResult ); - - // nsIFontNameIterator - - NS_IMETHOD Reset(); - NS_IMETHOD Get( nsString* aFontName ); - NS_IMETHOD Advance(); - -protected: - NS_IMETHOD LoadFontList(); - - nsVoidArray * mFontList; - PRInt32 mNameIterInx; - nsFontSizeIterator * mSizeIter; -}; - -#endif diff --git a/mozilla/widget/src/os2/nsFontSizeIterator.cpp b/mozilla/widget/src/os2/nsFontSizeIterator.cpp deleted file mode 100644 index f984918c60f..00000000000 --- a/mozilla/widget/src/os2/nsFontSizeIterator.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -#include "nsFontSizeIterator.h" - -#include "nsFont.h" -#include "nsVoidArray.h" - - -NS_IMPL_ISUPPORTS1(nsFontSizeIterator, nsIFontSizeIterator) - -//---------------------------------------------------------- -nsFontSizeIterator::nsFontSizeIterator() -{ - NS_INIT_REFCNT(); - mFontInfo = nsnull; - mSizeIterInx = 0; - -} - -//---------------------------------------------------------- -nsFontSizeIterator::~nsFontSizeIterator() -{ -} - -///---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Reset() -{ - mSizeIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Get( double* aFontSize ) -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()) { - PRUint32 size = (PRUint32)mFontInfo->mSizes->ElementAt(mSizeIterInx); - *aFontSize = (double)size; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Advance() -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()-2) { - mSizeIterInx++; - return NS_OK; - } - - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::SetFontInfo( FontInfo * aFontInfo ) -{ - mFontInfo = aFontInfo; - return NS_OK; -} diff --git a/mozilla/widget/src/os2/nsFontSizeIterator.h b/mozilla/widget/src/os2/nsFontSizeIterator.h deleted file mode 100644 index c532ecbee2b..00000000000 --- a/mozilla/widget/src/os2/nsFontSizeIterator.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontSizeIterator -#define __nsFontSizeIterator - -#include "nsIFontSizeIterator.h" -#include "nsString.h" - -class nsVoidArray; - -typedef struct { - nsString mName; - PRBool mIsScalable; - nsVoidArray * mSizes; -} FontInfo; - - -class nsFontSizeIterator: public nsIFontSizeIterator { -public: - nsFontSizeIterator(); - virtual ~nsFontSizeIterator(); - - NS_DECL_ISUPPORTS - - // nsIFontSizeIterator - NS_IMETHOD Reset(); - NS_IMETHOD Get( double* aFontSize ); - NS_IMETHOD Advance(); - - // Native impl - NS_IMETHOD SetFontInfo( FontInfo * aFontInfo ); - -protected: - FontInfo * mFontInfo; - PRInt32 mSizeIterInx; // current index of iter -}; - -#endif diff --git a/mozilla/widget/src/os2/nsModule.cpp b/mozilla/widget/src/os2/nsModule.cpp index 3b4b7737043..4a8f6916b7c 100644 --- a/mozilla/widget/src/os2/nsModule.cpp +++ b/mozilla/widget/src/os2/nsModule.cpp @@ -44,7 +44,6 @@ // * atom management // * printing bits & pieces (though not really any more) -#include "nsIFontRetrieverService.h" #include "nsDragService.h" #include "nsAppShell.h" @@ -97,8 +96,6 @@ void nsWidgetModuleData::Init( nsIAppShell *aPrimaevalAppShell) DosQueryDBCSEnv( CCHMAXPATH, &cc, buffer); bIsDBCS = buffer[0] || buffer[1]; - fontService = nsnull; - // XXXX KNOCKED OUT UNTIL nsDragService.cpp builds again // dragService = new nsDragService; // NS_ADDREF(dragService); @@ -124,8 +121,6 @@ nsWidgetModuleData::~nsWidgetModuleData() NS_IF_RELEASE(dragService); - NS_IF_RELEASE(fontService); - PRInt32 cAtoms = atoms.Count(); HATOMTBL systbl = WinQuerySystemAtomTable(); for( PRInt32 i = 0; i < cAtoms; i++) diff --git a/mozilla/widget/src/os2/nsModule.h b/mozilla/widget/src/os2/nsModule.h index 67a1beeff75..2c6bc5bed71 100644 --- a/mozilla/widget/src/os2/nsModule.h +++ b/mozilla/widget/src/os2/nsModule.h @@ -34,7 +34,6 @@ #define _H_NSMODULE #include "nsISupports.h" -#include "nsIFontRetrieverService.h" #include "nsDragService.h" #include "nsWidgetDefs.h" @@ -58,7 +57,6 @@ class nsWidgetModuleData : public nsISupports BOOL bIsDBCS; // true if system is dbcs // xptoolkit services we look after, & the primaeval appshell too. - nsIFontRetrieverService *fontService; nsDragService *dragService; nsIAppShell *appshell; @@ -111,4 +109,4 @@ class nsWidgetModuleData : public nsISupports nsVoidArray atoms; }; -#endif \ No newline at end of file +#endif diff --git a/mozilla/widget/src/os2/nsWidgetDefs.h b/mozilla/widget/src/os2/nsWidgetDefs.h index cbc778e725e..88f2c4efc71 100644 --- a/mozilla/widget/src/os2/nsWidgetDefs.h +++ b/mozilla/widget/src/os2/nsWidgetDefs.h @@ -120,7 +120,6 @@ static nsUconvInfo gUconvInfo[15 /* eCharSet_COUNT from nsFontMetricsOS2.cpp */ { "JOHAB", 1361, NULL } }; -class nsIFontRetrieverService; class nsDragService; class nsIAppShell; diff --git a/mozilla/widget/src/os2/nsWidgetFactory.cpp b/mozilla/widget/src/os2/nsWidgetFactory.cpp index bf9f908ff8b..3209b6401bb 100644 --- a/mozilla/widget/src/os2/nsWidgetFactory.cpp +++ b/mozilla/widget/src/os2/nsWidgetFactory.cpp @@ -51,8 +51,6 @@ #include "nsDragService.h" #include "nsILocalFile.h" #include "nsFilePicker.h" -#include "nsFontRetrieverService.h" -#include "nsFontSizeIterator.h" #include "nsLookAndFeel.h" #include "nsScrollbar.h" #include "nsSound.h" @@ -77,7 +75,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsCanvas) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFrameWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) @@ -260,10 +257,6 @@ static nsModuleComponentInfo components[] = NS_FILEPICKER_CID, "@mozilla.org/filepicker;1", nsFilePickerConstructor }, - { "OS/2 Font Retriever Service", - NS_FONTRETRIEVERSERVICE_CID, - "@mozilla.org/widget/fontretrieverservice/os2;1", - nsFontRetrieverServiceConstructor }, { "OS/2 Look And Feel", NS_LOOKANDFEEL_CID, "@mozilla.org/widget/lookandfeel/os2;1", diff --git a/mozilla/widget/src/photon/nsFontRetrieverService.cpp b/mozilla/widget/src/photon/nsFontRetrieverService.cpp deleted file mode 100644 index 131da31eb75..00000000000 --- a/mozilla/widget/src/photon/nsFontRetrieverService.cpp +++ /dev/null @@ -1,398 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsFontRetrieverService.h" -#include "nsIWidget.h" -#include -#include -#include "nsPhWidgetLog.h" - -//#include -//#include "X11/Xlib.h" -//#include "X11/Xutil.h" - -#include "nsFont.h" -#include "nsVoidArray.h" -#include "nsFontSizeIterator.h" - -NS_IMPL_ISUPPORTS2(nsFontRetrieverService, nsIFontRetrieverService, nsIFontNameIterator) - -//---------------------------------------------------------- -nsFontRetrieverService::nsFontRetrieverService() -{ - NS_INIT_REFCNT(); - mFontList = nsnull; - mSizeIter = nsnull; - mNameIterInx = 0; - -} - -//---------------------------------------------------------- -nsFontRetrieverService::~nsFontRetrieverService() -{ - if (nsnull != mFontList) { - for (PRInt32 i=0;iCount();i++) { - FontInfo * font = (FontInfo *)mFontList->ElementAt(i); - if (font->mSizes) { - delete font->mSizes; - } - delete font; - } - delete mFontList; - } - NS_IF_RELEASE(mSizeIter); -} - - - -//---------------------------------------------------------- -//-- nsIFontRetrieverService -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontNameIterator( nsIFontNameIterator** aIterator ) -{ - if (nsnull == aIterator) { - return NS_ERROR_FAILURE; - } - - if (nsnull == mFontList) { - LoadFontList(); - } - *aIterator = this; - NS_ADDREF_THIS(); - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontSizeIterator( const nsString & aFontName, - nsIFontSizeIterator** aIterator ) -{ - // save value in case someone externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) { - if (nsnull == mSizeIter) { - mSizeIter = new nsFontSizeIterator(); - } - NS_ASSERTION( nsnull != mSizeIter, "nsFontSizeIterator instance pointer is null"); - - *aIterator = (nsIFontSizeIterator *)mSizeIter; - NS_ADDREF(mSizeIter); - - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - mSizeIter->SetFontInfo(fontInfo); - mNameIterInx = saveIterInx; - return NS_OK; - } - mNameIterInx = saveIterInx; - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Reset() -{ - mNameIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Get( nsString* aFontName ) -{ - if (mNameIterInx < mFontList->Count()) { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aFontName = fontInfo->mName; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Advance() -{ - if (mNameIterInx < mFontList->Count()-1) { - mNameIterInx++; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//------------------------------ -static FontInfo * GetFontInfo(nsVoidArray * aFontList, char * aName) -{ - nsAutoString name((const PRUnichar *) aName, strlen(aName) ); - PRInt32 i; - PRInt32 cnt = aFontList->Count(); - for (i=0;iElementAt(i); - if (fontInfo->mName.Equals(name)) { - return fontInfo; - } - } - - FontInfo * fontInfo = new FontInfo(); - fontInfo->mName = nsString( (const PRUnichar *) aName, strlen(aName)); - //printf("nsFontRetrieverService::GetFontInfo Adding [%s]\n", aName);fflush(stdout); - fontInfo->mIsScalable = PR_FALSE; // X fonts aren't scalable right?? - fontInfo->mSizes = nsnull; - aFontList->AppendElement(fontInfo); - return fontInfo; -} - -//------------------------------ -static void AddSizeToFontInfo(FontInfo * aFontInfo, PRInt32 aSize) -{ - nsVoidArray * sizes; - if (nsnull == aFontInfo->mSizes) { - sizes = new nsVoidArray(); - aFontInfo->mSizes = sizes; - } else { - sizes = aFontInfo->mSizes; - } - PRInt32 i; - PRInt32 cnt = sizes->Count(); - for (i=0;iElementAt(i); - if (size == aSize) { - return; - } - } - sizes->AppendElement((void *)aSize); -} - -//--------------------------------------------------- -// XXX - Hack - Parts of this will need to be reworked -// -// This method does brute force parcing for 4 different formats: -// -// 1) The format -*-*-*-*-*-* etc. -// -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-8 -// -// 2) Name-size format -// lucidasans-10 -// -// 3) Name-style-size -// lucidasans-bold-10 -// -// 4) Name only (implicit size) -// 6x13 -// -//-------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::LoadFontList() -{ -#if 0 - char * pattern = "*"; - int nnames = 1024; - - int available = nnames+1; - int i; - char **fonts; - XFontStruct *info; - - if (nsnull == mFontList) { - mFontList = new nsVoidArray(); - if (nsnull == mFontList) { - return NS_ERROR_FAILURE; - } - } - - /* Get list of fonts matching pattern */ - for (;;) { - // the following line is VERY slow to return - fonts = XListFontsWithInfo(GDK_DISPLAY(), pattern, nnames, - &available, &info); - if (fonts == NULL || available < nnames) - break; - - XFreeFontInfo(fonts, info, available); - nnames = available * 2; - } - - if (fonts == NULL) { - fprintf(stderr, "pattern \"%s\" unmatched\n", pattern); - return NS_ERROR_FAILURE; - } - -#if 0 // debug - // print out all the retrieved fonts - printf("-----------------------------\n"); - for (i=0; imSizes) { - font->mSizes = new nsVoidArray(); - } - ptr = end+1; // skip past the dash that was set to zero - - cnt = 0; - // now skip ahead 4 dashes - do { - if (*ptr == '-') cnt++; - ptr++; - } while (cnt < 4); - - // find the dash after the size - end = strchr(ptr, '-'); - - if (end) { - *end = 0; - PRInt32 size; - sscanf(ptr, "%d", &size); - AddSizeToFontInfo(font, size); - } - } - } else { // formats 2,3,4 - - // no leading dash means the start of the - // buffer is the start of the name - // this checks for a dash at the end of the font name - // which means there is a size at the end - char * end = strchr(buffer, '-'); - if (end) { // Format 2,3 - *end = 0; - // Check to see if we need to create a new FontInfo obj - // and set the currentName var to this guys font name - if (strcmp(currentName, buffer) || NULL == font) { - font = GetFontInfo(mFontList, buffer); - strcpy(currentName, buffer); - } - end++; // advance past the dash - // check to see if we have a number - ptr = end; - if (isalpha(*ptr)) { // Format 3 - // skip until next dash - end = strchr(ptr, '-'); - if (end) { - *end = 0; - ptr = end+1; - } - } - PRInt32 size; - // yes, it has a dash at the end so it must have the size - // check to see if the size is terminated by a dash - // it shouldn't be - char * end2 = strchr(ptr, '-'); - if (end2) *end2 = 0; // put terminator at the dash - sscanf(end, "%d", &size); - AddSizeToFontInfo(font, size); - - } else { // Format #4 - // The font has an implicit size, - // so there is nothing to parse for size - // so we can't really do much here - // Check to see if we need to create a new FontInfo obj - // and set the currentName var to this guys font name - if (strcmp(currentName, buffer) || NULL == font) { - font = GetFontInfo(mFontList, buffer); - strcpy(currentName, buffer); - } - } - } - - } - - XFreeFontInfo(fonts, info, available); -#endif - - return NS_OK; -} - - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::IsFontScalable(const nsString & aFontName, - PRBool* aResult ) -{ - // save value in case someone externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aResult = fontInfo->mIsScalable; - mNameIterInx = saveIterInx; - return NS_OK; - } - - mNameIterInx = saveIterInx; - return NS_ERROR_FAILURE; -} diff --git a/mozilla/widget/src/photon/nsFontRetrieverService.h b/mozilla/widget/src/photon/nsFontRetrieverService.h deleted file mode 100644 index 4c0e4a85cc9..00000000000 --- a/mozilla/widget/src/photon/nsFontRetrieverService.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontRetrieverService -#define __nsFontRetrieverService - -#include "nsIFontRetrieverService.h" -#include "nsIFontNameIterator.h" - -class nsVoidArray; -class nsFontSizeIterator; - -class nsFontRetrieverService: public nsIFontRetrieverService, - public nsIFontNameIterator -{ -public: - nsFontRetrieverService(); - virtual ~nsFontRetrieverService(); - - NS_DECL_ISUPPORTS - - // nsIFontRetrieverService - NS_IMETHOD CreateFontNameIterator( nsIFontNameIterator** aIterator ); - - NS_IMETHOD CreateFontSizeIterator( const nsString & aFontName, nsIFontSizeIterator** aIterator ); - NS_IMETHOD IsFontScalable( const nsString & aFontName, PRBool* aResult ); - - // nsIFontNameIterator - - NS_IMETHOD Reset(); - NS_IMETHOD Get( nsString* aFontName ); - NS_IMETHOD Advance(); - - - -protected: - NS_IMETHOD LoadFontList(); - - nsVoidArray * mFontList; - - PRInt32 mNameIterInx; - - nsFontSizeIterator * mSizeIter; -}; - -#endif diff --git a/mozilla/widget/src/photon/nsFontSizeIterator.cpp b/mozilla/widget/src/photon/nsFontSizeIterator.cpp deleted file mode 100644 index f984918c60f..00000000000 --- a/mozilla/widget/src/photon/nsFontSizeIterator.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -#include "nsFontSizeIterator.h" - -#include "nsFont.h" -#include "nsVoidArray.h" - - -NS_IMPL_ISUPPORTS1(nsFontSizeIterator, nsIFontSizeIterator) - -//---------------------------------------------------------- -nsFontSizeIterator::nsFontSizeIterator() -{ - NS_INIT_REFCNT(); - mFontInfo = nsnull; - mSizeIterInx = 0; - -} - -//---------------------------------------------------------- -nsFontSizeIterator::~nsFontSizeIterator() -{ -} - -///---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Reset() -{ - mSizeIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Get( double* aFontSize ) -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()) { - PRUint32 size = (PRUint32)mFontInfo->mSizes->ElementAt(mSizeIterInx); - *aFontSize = (double)size; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Advance() -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()-2) { - mSizeIterInx++; - return NS_OK; - } - - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::SetFontInfo( FontInfo * aFontInfo ) -{ - mFontInfo = aFontInfo; - return NS_OK; -} diff --git a/mozilla/widget/src/photon/nsFontSizeIterator.h b/mozilla/widget/src/photon/nsFontSizeIterator.h deleted file mode 100644 index a32db1af469..00000000000 --- a/mozilla/widget/src/photon/nsFontSizeIterator.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontSizeIterator -#define __nsFontSizeIterator - -#include "nsIFontSizeIterator.h" -#include "nsString.h" - -class nsVoidArray; - -typedef struct { - nsString mName; - PRBool mIsScalable; - nsVoidArray * mSizes; -} FontInfo; - - -class nsFontSizeIterator: public nsIFontSizeIterator { -public: - nsFontSizeIterator(); - virtual ~nsFontSizeIterator(); - - NS_DECL_ISUPPORTS - - // nsIFontSizeIterator - NS_IMETHOD Reset(); - NS_IMETHOD Get( double* aFontSize ); - NS_IMETHOD Advance(); - - // Native impl - NS_IMETHOD SetFontInfo( FontInfo * aFontInfo ); - -protected: - - FontInfo * mFontInfo; - PRInt32 mSizeIterInx; // current index of iter -}; - -#endif diff --git a/mozilla/widget/src/qt/nsFontRetrieverService.cpp b/mozilla/widget/src/qt/nsFontRetrieverService.cpp deleted file mode 100644 index dc305cb1f8b..00000000000 --- a/mozilla/widget/src/qt/nsFontRetrieverService.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsFontRetrieverService.h" -#include "nsIWidget.h" -#include - -#define FAKE_QSTRINGLIST_H /* Avoid pulling in Corel's qstringlist.h */ -#include "qfontdatabase.h" -#include "qstring.h" -#include "qstringlist.h" -#include "qvaluelist.h" - -#include "nsFont.h" -#include "nsVoidArray.h" -#include "nsFontSizeIterator.h" - -NS_IMPL_ISUPPORTS2(nsFontRetrieverService, nsIFontRetrieverService, nsIFontNameIterator) - -//---------------------------------------------------------- -nsFontRetrieverService::nsFontRetrieverService() -{ - NS_INIT_REFCNT(); - - mFontList = nsnull; - mSizeIter = nsnull; - mNameIterInx = 0; -} - -//---------------------------------------------------------- -nsFontRetrieverService::~nsFontRetrieverService() -{ - if (nsnull != mFontList) { - for (PRInt32 i=0;iCount();i++) { - FontInfo * font = (FontInfo *)mFontList->ElementAt(i); - if (font->mSizes) { - delete font->mSizes; - } - delete font; - } - delete mFontList; - } - NS_IF_RELEASE(mSizeIter); -} - - - -//---------------------------------------------------------- -//-- nsIFontRetrieverService -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontNameIterator( nsIFontNameIterator** aIterator ) -{ - if (nsnull == aIterator) { - return NS_ERROR_FAILURE; - } - - if (nsnull == mFontList) { - LoadFontList(); - } - *aIterator = this; - NS_ADDREF_THIS(); - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontSizeIterator( const nsString & aFontName, - nsIFontSizeIterator** aIterator ) -{ - // save value in case someone externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) { - if (nsnull == mSizeIter) { - mSizeIter = new nsFontSizeIterator(); - } - NS_ASSERTION( nsnull != mSizeIter, "nsFontSizeIterator instance pointer is null"); - - *aIterator = (nsIFontSizeIterator *)mSizeIter; - NS_ADDREF(mSizeIter); - - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - mSizeIter->SetFontInfo(fontInfo); - mNameIterInx = saveIterInx; - return NS_OK; - } - mNameIterInx = saveIterInx; - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Reset() -{ - mNameIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Get( nsString* aFontName ) -{ - if (mNameIterInx < mFontList->Count()) { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aFontName = fontInfo->mName; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Advance() -{ - if (mNameIterInx < mFontList->Count()-1) { - mNameIterInx++; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//------------------------------ -static FontInfo * GetFontInfo(nsVoidArray * aFontList, char * aName) -{ - nsAutoString name; - name.AssignWithConversion(aName); - PRInt32 i; - PRInt32 cnt = aFontList->Count(); - for (i=0;iElementAt(i); - if (fontInfo->mName.Equals(name)) { - return fontInfo; - } - } - - FontInfo * fontInfo = new FontInfo(); - fontInfo->mName.AssignWithConversion(aName); - //printf("Adding [%s]\n", aName);fflush(stdout); - fontInfo->mIsScalable = PR_FALSE; // X fonts aren't scalable right?? - fontInfo->mSizes = nsnull; - aFontList->AppendElement(fontInfo); - return fontInfo; -} - -//------------------------------ -static void AddSizeToFontInfo(FontInfo * aFontInfo, PRInt32 aSize) -{ - nsVoidArray * sizes; - if (nsnull == aFontInfo->mSizes) { - sizes = new nsVoidArray(); - aFontInfo->mSizes = sizes; - } else { - sizes = aFontInfo->mSizes; - } - PRInt32 i; - PRInt32 cnt = sizes->Count(); - for (i=0;iElementAt(i); - if (size == aSize) { - return; - } - } - sizes->AppendElement((void *)aSize); -} - -//--------------------------------------------------- -// XXX - Hack - Parts of this will need to be reworked -// -// This method does brute force parcing for 4 different formats: -// -// 1) The format -*-*-*-*-*-* etc. -// -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-8 -// -// 2) Name-size format -// lucidasans-10 -// -// 3) Name-style-size -// lucidasans-bold-10 -// -// 4) Name only (implicit size) -// 6x13 -// -//-------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::LoadFontList() -{ - QStringList qFamilies,qStyles,qCharsets; - typedef QValueList QFSList; - QFSList qSizes; - QString qCurFam; - QFontDatabase qFontDB; - - if (nsnull == mFontList) { - mFontList = new nsVoidArray(); - if (nsnull == mFontList) { - return NS_ERROR_FAILURE; - } - } - - /* Get list of all fonts */ - qFamilies = qFontDB.families(FALSE); - qFamilies.sort(); - for (QStringList::Iterator famIt = qFamilies.begin(); famIt != qFamilies.end(); ++famIt) { - qCharsets = qFontDB.charSets(*famIt,FALSE); - qCharsets.sort(); - for (QStringList::Iterator csIt = qCharsets.begin(); csIt != qCharsets.end(); ++csIt) { - qStyles = qFontDB.styles(*famIt,*csIt); - qStyles.sort(); - for (QStringList::Iterator stIt = qStyles.begin(); stIt != qStyles.end(); ++stIt) { - qSizes = qFontDB.pointSizes(*famIt,*stIt,*csIt); - for (QFSList::Iterator szIt = qSizes.begin(); szIt != qSizes.end(); ++szIt) { - FontInfo * font = nsnull; - - if (qCurFam.compare(*famIt) || nsnull == font) { - font = GetFontInfo(mFontList, (char*)(*famIt).latin1()); - qCurFam = *famIt; - } - if (nsnull == font->mSizes) - font->mSizes = new nsVoidArray(); - AddSizeToFontInfo(font, *szIt); - font->mIsScalable = qFontDB.isScalable(*famIt,*stIt,*csIt); - } - } - } - } - return NS_OK; -} - - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::IsFontScalable(const nsString & aFontName, - PRBool* aResult ) -{ - // save value in case someone externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aResult = fontInfo->mIsScalable; - mNameIterInx = saveIterInx; - return NS_OK; - } - - mNameIterInx = saveIterInx; - return NS_ERROR_FAILURE; -} diff --git a/mozilla/widget/src/qt/nsFontRetrieverService.h b/mozilla/widget/src/qt/nsFontRetrieverService.h deleted file mode 100644 index 4c0e4a85cc9..00000000000 --- a/mozilla/widget/src/qt/nsFontRetrieverService.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontRetrieverService -#define __nsFontRetrieverService - -#include "nsIFontRetrieverService.h" -#include "nsIFontNameIterator.h" - -class nsVoidArray; -class nsFontSizeIterator; - -class nsFontRetrieverService: public nsIFontRetrieverService, - public nsIFontNameIterator -{ -public: - nsFontRetrieverService(); - virtual ~nsFontRetrieverService(); - - NS_DECL_ISUPPORTS - - // nsIFontRetrieverService - NS_IMETHOD CreateFontNameIterator( nsIFontNameIterator** aIterator ); - - NS_IMETHOD CreateFontSizeIterator( const nsString & aFontName, nsIFontSizeIterator** aIterator ); - NS_IMETHOD IsFontScalable( const nsString & aFontName, PRBool* aResult ); - - // nsIFontNameIterator - - NS_IMETHOD Reset(); - NS_IMETHOD Get( nsString* aFontName ); - NS_IMETHOD Advance(); - - - -protected: - NS_IMETHOD LoadFontList(); - - nsVoidArray * mFontList; - - PRInt32 mNameIterInx; - - nsFontSizeIterator * mSizeIter; -}; - -#endif diff --git a/mozilla/widget/src/qt/nsFontSizeIterator.cpp b/mozilla/widget/src/qt/nsFontSizeIterator.cpp deleted file mode 100644 index 84fbb69f52b..00000000000 --- a/mozilla/widget/src/qt/nsFontSizeIterator.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#include "nsFontSizeIterator.h" - -#include "nsFont.h" -#include "nsVoidArray.h" - - -NS_IMPL_ISUPPORTS1(nsFontSizeIterator, nsIFontSizeIterator) - -//---------------------------------------------------------- -nsFontSizeIterator::nsFontSizeIterator() -{ -#ifdef DEBUG -printf("JCG nsFontSizeIterator CTOR\n"); -#endif - NS_INIT_REFCNT(); - mFontInfo = nsnull; - mSizeIterInx = 0; -} - -//---------------------------------------------------------- -nsFontSizeIterator::~nsFontSizeIterator() -{ -#ifdef DEBUG -printf("JCG nsFontSizeIterator DTOR\n"); -#endif -} - -///---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Reset() -{ - mSizeIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Get( double* aFontSize ) -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()) { - PRUint32 size = (PRUint32)mFontInfo->mSizes->ElementAt(mSizeIterInx); - *aFontSize = (double)size; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Advance() -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()-2) { - mSizeIterInx++; - return NS_OK; - } - - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::SetFontInfo( FontInfo * aFontInfo ) -{ - mFontInfo = aFontInfo; - return NS_OK; -} diff --git a/mozilla/widget/src/qt/nsFontSizeIterator.h b/mozilla/widget/src/qt/nsFontSizeIterator.h deleted file mode 100644 index a32db1af469..00000000000 --- a/mozilla/widget/src/qt/nsFontSizeIterator.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontSizeIterator -#define __nsFontSizeIterator - -#include "nsIFontSizeIterator.h" -#include "nsString.h" - -class nsVoidArray; - -typedef struct { - nsString mName; - PRBool mIsScalable; - nsVoidArray * mSizes; -} FontInfo; - - -class nsFontSizeIterator: public nsIFontSizeIterator { -public: - nsFontSizeIterator(); - virtual ~nsFontSizeIterator(); - - NS_DECL_ISUPPORTS - - // nsIFontSizeIterator - NS_IMETHOD Reset(); - NS_IMETHOD Get( double* aFontSize ); - NS_IMETHOD Advance(); - - // Native impl - NS_IMETHOD SetFontInfo( FontInfo * aFontInfo ); - -protected: - - FontInfo * mFontInfo; - PRInt32 mSizeIterInx; // current index of iter -}; - -#endif diff --git a/mozilla/widget/src/windows/makefile.win b/mozilla/widget/src/windows/makefile.win index c240bd5146e..66706651aa9 100644 --- a/mozilla/widget/src/windows/makefile.win +++ b/mozilla/widget/src/windows/makefile.win @@ -31,8 +31,6 @@ CPPSRCS = \ Accessible.cpp \ SimpleDOMNode.cpp \ !endif - nsFontRetrieverService.cpp \ - nsFontSizeIterator.cpp \ nsNativeDragTarget.cpp \ nsNativeDragSource.cpp \ nsDragService.cpp \ @@ -58,8 +56,6 @@ OBJS = \ .\$(OBJDIR)\Accessible.obj \ .\$(OBJDIR)\SimpleDOMNode.obj \ !endif - .\$(OBJDIR)\nsFontRetrieverService.obj \ - .\$(OBJDIR)\nsFontSizeIterator.obj \ .\$(OBJDIR)\nsNativeDragTarget.obj \ .\$(OBJDIR)\nsNativeDragSource.obj \ .\$(OBJDIR)\nsDragService.obj \ diff --git a/mozilla/widget/src/windows/nsFontRetrieverService.cpp b/mozilla/widget/src/windows/nsFontRetrieverService.cpp deleted file mode 100644 index ed30c247c97..00000000000 --- a/mozilla/widget/src/windows/nsFontRetrieverService.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -#include "nsFontRetrieverService.h" -#include - -#include "nsFont.h" -#include "nsVoidArray.h" -#include "nsFontSizeIterator.h" - -NS_IMPL_ADDREF(nsFontRetrieverService) -NS_IMPL_RELEASE(nsFontRetrieverService) - - -//---------------------------------------------------------- -nsFontRetrieverService::nsFontRetrieverService() -{ - NS_INIT_REFCNT(); - - mFontList = nsnull; - mSizeIter = nsnull; - mNameIterInx = 0; - -} - -//---------------------------------------------------------- -nsFontRetrieverService::~nsFontRetrieverService() -{ - if (nsnull != mFontList) { - for (PRInt32 i=0;iCount();i++) { - FontInfo * font = (FontInfo *)mFontList->ElementAt(i); - if (font->mSizes) { - delete font->mSizes; - } - delete font; - } - delete mFontList; - } - NS_IF_RELEASE(mSizeIter); -} - -/** - * @param aIID The name of the class implementing the method - * @param _classiiddef The name of the #define symbol that defines the IID - * for the class (e.g. NS_ISUPPORTS_IID) - * -*/ -nsresult nsFontRetrieverService::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - nsresult rv = NS_NOINTERFACE; - - if (aIID.Equals(NS_GET_IID(nsIFontRetrieverService))) { - *aInstancePtr = (void*) ((nsIFontRetrieverService*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - if (aIID.Equals(NS_GET_IID(nsIFontNameIterator))) { - *aInstancePtr = (void*) ((nsIFontNameIterator*)this); - NS_ADDREF_THIS(); - return NS_OK; - } - - return rv; -} - - -//---------------------------------------------------------- -//-- nsIFontRetrieverService -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontNameIterator( nsIFontNameIterator** aIterator ) -{ - if (nsnull == aIterator) { - return NS_ERROR_FAILURE; - } - - if (nsnull == mFontList) { - LoadFontList(); - } - *aIterator = this; - NS_ADDREF_THIS(); - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::CreateFontSizeIterator( const nsString &aFontName, - nsIFontSizeIterator** aIterator ) -{ - // cache current value in case someone else externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) { - if (nsnull == mSizeIter) { - mSizeIter = new nsFontSizeIterator(); - } - NS_ASSERTION( nsnull != mSizeIter, "nsFontSizeIterator instance pointer is null"); - - *aIterator = (nsIFontSizeIterator *)mSizeIter; - NS_ADDREF(mSizeIter); - - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - mSizeIter->SetFontInfo(fontInfo); - mNameIterInx = saveIterInx; - return NS_OK; - } - mNameIterInx = saveIterInx; - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Reset() -{ - mNameIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Get( nsString* aFontName ) -{ - if (mNameIterInx < mFontList->Count()) { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aFontName = fontInfo->mName; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::Advance() -{ - if (mNameIterInx < mFontList->Count()-1) { - mNameIterInx++; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -static int CALLBACK MyEnumFontFamProc(ENUMLOGFONT FAR *lpelf, - NEWTEXTMETRIC FAR *lpntm, - unsigned long fontType, - LPARAM lParam) -{ - FontInfo * font = (FontInfo *)lParam; - - //printf(" sizes-> %d\n", lpelf->elfLogFont.lfHeight); - LOGFONT ourLogFont; // Local copy of the LOGFONT structure. - memcpy(&ourLogFont, (const void *)&lpelf->elfLogFont, sizeof LOGFONT); // Make the copy - //printf("Size: %d", ourLogFont.lfHeight); - - if (fontType & TRUETYPE_FONTTYPE) { - //printf("TRUETYPE_FONTTYPE;"); - font->mIsScalable = PR_TRUE; - return 1; - } else if (fontType & RASTER_FONTTYPE) { - //printf("RASTER_FONTTYPE;"); - if (nsnull == font->mSizes ) { - font->mSizes = new nsVoidArray(); - } - } else if (fontType & DEVICE_FONTTYPE) { - //printf("DEVICE_FONTTYPE;"); - //if (nsnull == font->mSizes ) { - // font->mSizes = new nsVoidArray(); - //} - } else { - //printf("VECTOR_FONTTYPE;"); - font->mIsScalable = PR_TRUE; - } - - if (nsnull != font->mSizes) { - font->mSizes->AppendElement((void *)ourLogFont.lfHeight); - } - -#if 0 - if (ourLogFont.lfCharSet != ANSI_CHARSET) - //printf("FNT_NONANSI;"); - else - //printf("FNT_ANSI;"); - - // - // We also need to set the family type (we use it for filtering) - // - switch (ourLogFont.lfPitchAndFamily & 0xF0) - { - case FF_SWISS: - //printf("FNT_SANSSERIF;"); - break; - - case FF_ROMAN: - //printf("FNT_SERIF;"); - break; - - case FF_MODERN: - //printf("FNT_MODERN;"); - break; - - case FF_SCRIPT: - //printf("FNT_SCRIPT;"); - break; - - default: - //printf("FNT_OTHER;"); - break; - } -#endif - //printf("\n"); - - return 1; -} - -//--------------------------------------------------------------------- -// -// int CALLBACK EnumerateMyFonts -// -// This function is called as a result of the call to EnumFontFamiliesEx -// in CFViewerView::OnInitialUpdate(), once for every type face in the -// system. -// -//--------------------------------------------------------------------- -static int CALLBACK EnumerateMyFonts(ENUMLOGFONTEX *lpLogFontEx, - NEWTEXTMETRICEX *lpMetricsEx, - int fontType, - LPARAM lParam) -{ - nsVoidArray * fontList = (nsVoidArray *)lParam; - - /*printf("%s [%s][%s][%s]", lpLogFontEx->elfLogFont.lfFaceName, - lpLogFontEx->elfFullName, - lpLogFontEx->elfStyle, - lpLogFontEx->elfScript - ); */ - LOGFONT ourLogFont; // Local copy of the LOGFONT structure. - memcpy(&ourLogFont, (const void *)&lpLogFontEx->elfLogFont, sizeof LOGFONT); // Make the copy - //printf("Size: %d\n", ourLogFont.lfHeight); - - FontInfo * font = new FontInfo(); - font->mName.AssignWithConversion((char *)lpLogFontEx->elfLogFont.lfFaceName); // XXX I18N ? - font->mIsScalable = PR_FALSE; - font->mSizes = nsnull; - - - fontList->AppendElement(font); - - HDC myDC = ::GetDC(NULL); // Get the old style DC handle - ::EnumFontFamilies(myDC, lpLogFontEx->elfLogFont.lfFaceName, (FONTENUMPROC)&MyEnumFontFamProc, (LPARAM)font); - ::ReleaseDC(NULL, myDC); - - - return (1); -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::LoadFontList() -{ - if (nsnull == mFontList) { - mFontList = new nsVoidArray(); - if (nsnull == mFontList) { - return NS_ERROR_FAILURE; - } - } - - LOGFONT myLogFont; // Our font structure - HDC myDC; // Our device context - - - // Here is a partial list CHAR_SETS - /* - ANSI_CHARSET - DEFAULT_CHARSET - SYMBOL_CHARSET - SHIFTJIS_CHARSET - GB2312_CHARSET - HANGEUL_CHARSET - CHINESEBIG5_CHARSET - OEM_CHARSET - */ - - myDC = ::GetDC(NULL); // Get the old style DC handle - - // Font search parms (find all) - myLogFont.lfCharSet = ANSI_CHARSET; - myLogFont.lfFaceName[0] = 0; - myLogFont.lfPitchAndFamily = 0; - - // Force the calls to EnumerateMyFonts - ::EnumFontFamiliesEx(myDC, &myLogFont, (FONTENUMPROC)&EnumerateMyFonts, (LPARAM)mFontList, (DWORD)0); - - myLogFont.lfCharSet = SYMBOL_CHARSET; - ::EnumFontFamiliesEx(myDC, &myLogFont, (FONTENUMPROC)&EnumerateMyFonts, (LPARAM)mFontList, (DWORD)0); - - ::ReleaseDC(NULL, myDC); - - return NS_OK; - -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontRetrieverService::IsFontScalable( const nsString &aFontName, PRBool* aResult ) -{ - // cache current value in case someone else externally is using it - PRInt32 saveIterInx = mNameIterInx; - - PRBool found = PR_FALSE; - Reset(); - do { - nsAutoString name; - Get(&name); - if (name.Equals(aFontName)) { - found = PR_TRUE; - break; - } - } while (Advance() == NS_OK); - - if (found) { - FontInfo * fontInfo = (FontInfo *)mFontList->ElementAt(mNameIterInx); - *aResult = fontInfo->mIsScalable; - mNameIterInx = saveIterInx; - return NS_OK; - } - mNameIterInx = saveIterInx; - - return NS_ERROR_FAILURE; -} diff --git a/mozilla/widget/src/windows/nsFontRetrieverService.h b/mozilla/widget/src/windows/nsFontRetrieverService.h deleted file mode 100644 index 4db83d6bb76..00000000000 --- a/mozilla/widget/src/windows/nsFontRetrieverService.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontRetrieverService -#define __nsFontRetrieverService - -#include "nsIFontRetrieverService.h" -#include "nsIFontNameIterator.h" - -class nsVoidArray; -class nsFontSizeIterator; - -class nsFontRetrieverService: public nsIFontRetrieverService, - public nsIFontNameIterator { -public: - nsFontRetrieverService(); - virtual ~nsFontRetrieverService(); - - NS_DECL_ISUPPORTS - - // nsIFontRetrieverService - NS_IMETHOD CreateFontNameIterator( nsIFontNameIterator** aIterator ); - - NS_IMETHOD CreateFontSizeIterator( const nsString &aFontName, nsIFontSizeIterator** aIterator ); - - NS_IMETHOD IsFontScalable( const nsString &aFontName, PRBool* aResult ); - - // nsIFontNameIterator - - NS_IMETHOD Reset(); - NS_IMETHOD Get( nsString* aFontName ); - NS_IMETHOD Advance(); - - - -protected: - NS_IMETHOD LoadFontList(); - - nsVoidArray * mFontList; - - PRInt32 mNameIterInx; - - nsFontSizeIterator * mSizeIter; -}; - -#endif diff --git a/mozilla/widget/src/windows/nsFontSizeIterator.cpp b/mozilla/widget/src/windows/nsFontSizeIterator.cpp deleted file mode 100644 index 9d19d8e48ff..00000000000 --- a/mozilla/widget/src/windows/nsFontSizeIterator.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * Pierre Phaneuf - */ - -#include "nsFontSizeIterator.h" -#include - -#include "nsFont.h" -#include "nsVoidArray.h" - -NS_IMPL_ISUPPORTS1(nsFontSizeIterator, nsIFontSizeIterator) - -//---------------------------------------------------------- -nsFontSizeIterator::nsFontSizeIterator() -{ - NS_INIT_REFCNT(); - mFontInfo = nsnull; - mSizeIterInx = 0; - -} - -//---------------------------------------------------------- -nsFontSizeIterator::~nsFontSizeIterator() -{ -} - -///---------------------------------------------------------- -//-- nsIFontNameIterator -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Reset() -{ - mSizeIterInx = 0; - return NS_OK; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Get( double* aFontSize ) -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()) { - PRUint32 size = (PRUint32)mFontInfo->mSizes->ElementAt(mSizeIterInx); - *aFontSize = (double)size; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::Advance() -{ - if (nsnull != mFontInfo->mSizes && - mFontInfo->mSizes->Count() > 0 && - mSizeIterInx < mFontInfo->mSizes->Count()-2) { - mSizeIterInx++; - return NS_OK; - } - - return NS_ERROR_FAILURE; -} - -//---------------------------------------------------------- -NS_IMETHODIMP nsFontSizeIterator::SetFontInfo( FontInfo * aFontInfo ) -{ - mFontInfo = aFontInfo; - return NS_OK; -} diff --git a/mozilla/widget/src/windows/nsFontSizeIterator.h b/mozilla/widget/src/windows/nsFontSizeIterator.h deleted file mode 100644 index a32db1af469..00000000000 --- a/mozilla/widget/src/windows/nsFontSizeIterator.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#ifndef __nsFontSizeIterator -#define __nsFontSizeIterator - -#include "nsIFontSizeIterator.h" -#include "nsString.h" - -class nsVoidArray; - -typedef struct { - nsString mName; - PRBool mIsScalable; - nsVoidArray * mSizes; -} FontInfo; - - -class nsFontSizeIterator: public nsIFontSizeIterator { -public: - nsFontSizeIterator(); - virtual ~nsFontSizeIterator(); - - NS_DECL_ISUPPORTS - - // nsIFontSizeIterator - NS_IMETHOD Reset(); - NS_IMETHOD Get( double* aFontSize ); - NS_IMETHOD Advance(); - - // Native impl - NS_IMETHOD SetFontInfo( FontInfo * aFontInfo ); - -protected: - - FontInfo * mFontInfo; - PRInt32 mSizeIterInx; // current index of iter -}; - -#endif diff --git a/mozilla/widget/src/xlib/nsWidgetFactory.cpp b/mozilla/widget/src/xlib/nsWidgetFactory.cpp index 03d4957ebe6..d758ee7b319 100644 --- a/mozilla/widget/src/xlib/nsWidgetFactory.cpp +++ b/mozilla/widget/src/xlib/nsWidgetFactory.cpp @@ -40,7 +40,6 @@ #include "nsClipboard.h" #include "nsClipboardHelper.h" #include "nsHTMLFormatConverter.h" -//#include "nsFontRetrieverService.h" #include "nsDragService.h" #include "nsScrollBar.h" #include "nsSound.h" @@ -62,7 +61,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) -//NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontRetrieverService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) #ifdef IBMBIDI @@ -195,10 +193,6 @@ static nsModuleComponentInfo components[] = NS_HTMLFORMATCONVERTER_CID, "@mozilla.org/widget/htmlformatconverter/xlib;1", nsHTMLFormatConverterConstructor }, - //{ "Xlib Font Retriever Service", - //NS_FONTRETRIEVERSERVICE_CID, - //"@mozilla.org/widget/fontretrieverservice/xlib;1", - //nsFontRetrieverServiceConstructor }, { "Xlib Drag Service", NS_DRAGSERVICE_CID, // "@mozilla.org/widget/dragservice/xlib;1",