Camino only - Bug 392970: Split NSString+Utils.mm into NSString+Gecko.mm and NSString+Utils.m to allow general util use in .m files. r/sr=mento

git-svn-id: svn://10.0.0.236/trunk@233246 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
stuart.morgan%alumni.case.edu
2007-08-28 22:12:26 +00:00
parent 8fd3fb498f
commit 6e5ed5647b
30 changed files with 568 additions and 48 deletions

View File

@@ -241,6 +241,12 @@
33B778820C55C59A00A6D67F /* libnssdbm3.dylib in Copy Security Libraries */ = {isa = PBXBuildFile; fileRef = 33B778800C55C57800A6D67F /* libnssdbm3.dylib */; };
33F3B70B0C63F5F7007DFBD0 /* ScriptingSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F3B70A0C63F5F7007DFBD0 /* ScriptingSupport.mm */; };
33F3B70C0C63F5F7007DFBD0 /* ScriptingSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F3B70A0C63F5F7007DFBD0 /* ScriptingSupport.mm */; };
33FBAAF80C84D0AB00DD459E /* NSString+Gecko.h in Headers */ = {isa = PBXBuildFile; fileRef = 33FBAAF30C84D0A500DD459E /* NSString+Gecko.h */; };
33FBAAF90C84D0AC00DD459E /* NSString+Gecko.h in Headers */ = {isa = PBXBuildFile; fileRef = 33FBAAF30C84D0A500DD459E /* NSString+Gecko.h */; };
33FBAAFC0C84D0CA00DD459E /* NSString+Gecko.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33FBAAFA0C84D0CA00DD459E /* NSString+Gecko.mm */; };
33FBAAFD0C84D0CA00DD459E /* NSString+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 33FBAAFB0C84D0CA00DD459E /* NSString+Utils.m */; };
33FBAAFE0C84D0CA00DD459E /* NSString+Gecko.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33FBAAFA0C84D0CA00DD459E /* NSString+Gecko.mm */; };
33FBAAFF0C84D0CA00DD459E /* NSString+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 33FBAAFB0C84D0CA00DD459E /* NSString+Utils.m */; };
34884A36074F7C5D000EA76B /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34884A35074F7C5D000EA76B /* AddressBook.framework */; };
34884A37074F7C5D000EA76B /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34884A35074F7C5D000EA76B /* AddressBook.framework */; };
3489ADCB0753B717005ADF6C /* ABAddressBook+Utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 3489ADC90753B717005ADF6C /* ABAddressBook+Utils.h */; };
@@ -446,7 +452,6 @@
3F44ACA905BDFB9E00CB4B08 /* RemoteDataProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = F558137C030AEF9B0176F207 /* RemoteDataProvider.mm */; };
3F44ACAA05BDFB9E00CB4B08 /* SiteIconProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = F558137D030AEF9B0176F207 /* SiteIconProvider.mm */; };
3F44ACAB05BDFB9E00CB4B08 /* BrowserTabViewItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5B950BD030C83B601A96654 /* BrowserTabViewItem.mm */; };
3F44ACAC05BDFB9E00CB4B08 /* NSString+Utils.mm in Sources */ = {isa = PBXBuildFile; fileRef = F558099E02F22168015DF512 /* NSString+Utils.mm */; };
3F44ACAD05BDFB9E00CB4B08 /* CHBrowserListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = F558B1F1030F6E470166970F /* CHBrowserListener.mm */; };
3F44ACAD05BDFB9E00CB4B18 /* CmXULAppInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = F558B1F1030F6E470166972F /* CmXULAppInfo.mm */; };
3F44ACAE05BDFB9E00CB4B08 /* NSBezierPath+Utils.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5D98EB9031AC37801A96654 /* NSBezierPath+Utils.mm */; };
@@ -856,7 +861,6 @@
3F44AEDE05BDFBA000CB4B08 /* AppComponents.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5D33CBD02EF61A901A967F3 /* AppComponents.mm */; };
3F44AEDF05BDFBA000CB4B08 /* SecurityDialogs.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5D33CBE02EF61A901A967F3 /* SecurityDialogs.mm */; };
3F44AEE005BDFBA000CB4B08 /* CocoaPromptService.mm in Sources */ = {isa = PBXBuildFile; fileRef = F566BD1302EFA9AD01A967F3 /* CocoaPromptService.mm */; };
3F44AEE105BDFBA000CB4B08 /* NSString+Utils.mm in Sources */ = {isa = PBXBuildFile; fileRef = F558099E02F22168015DF512 /* NSString+Utils.mm */; };
3F44AEE205BDFBA000CB4B08 /* ToolTip.mm in Sources */ = {isa = PBXBuildFile; fileRef = F549ACDE0302DE6001026D5D /* ToolTip.mm */; };
3F44AEE305BDFBA000CB4B08 /* NSScreen+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = F549ACDF0302DE6001026D5D /* NSScreen+Utils.m */; };
3F44AEE405BDFBA000CB4B08 /* SiteIconProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = F558137D030AEF9B0176F207 /* SiteIconProvider.mm */; };
@@ -2451,6 +2455,9 @@
33B777E10C5588E500A6D67F /* libmozlcms.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmozlcms.a; path = ../dist/lib/libmozlcms.a; sourceTree = SOURCE_ROOT; };
33B778800C55C57800A6D67F /* libnssdbm3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libnssdbm3.dylib; path = ../dist/lib/libnssdbm3.dylib; sourceTree = SOURCE_ROOT; };
33F3B70A0C63F5F7007DFBD0 /* ScriptingSupport.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = ScriptingSupport.mm; path = src/appleevents/ScriptingSupport.mm; sourceTree = "<group>"; };
33FBAAF30C84D0A500DD459E /* NSString+Gecko.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = "NSString+Gecko.h"; path = "src/extensions/NSString+Gecko.h"; sourceTree = "<group>"; };
33FBAAFA0C84D0CA00DD459E /* NSString+Gecko.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = "NSString+Gecko.mm"; path = "src/extensions/NSString+Gecko.mm"; sourceTree = "<group>"; };
33FBAAFB0C84D0CA00DD459E /* NSString+Utils.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = "NSString+Utils.m"; path = "src/extensions/NSString+Utils.m"; sourceTree = "<group>"; };
34884A35074F7C5D000EA76B /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = /System/Library/Frameworks/AddressBook.framework; sourceTree = "<absolute>"; };
3489ADC90753B717005ADF6C /* ABAddressBook+Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ABAddressBook+Utils.h"; path = "src/extensions/ABAddressBook+Utils.h"; sourceTree = SOURCE_ROOT; };
3489ADCA0753B717005ADF6C /* ABAddressBook+Utils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "ABAddressBook+Utils.mm"; path = "src/extensions/ABAddressBook+Utils.mm"; sourceTree = SOURCE_ROOT; };
@@ -2472,7 +2479,7 @@
3F42EFAC05EC13F90045A30C /* throbber-11.tif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = "throbber-11.tif"; path = "resources/images/throbber/throbber-11.tif"; sourceTree = SOURCE_ROOT; };
3F42EFAD05EC13F90045A30C /* throbber-12.tif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = "throbber-12.tif"; path = "resources/images/throbber/throbber-12.tif"; sourceTree = SOURCE_ROOT; };
3F44AD8705BDFB9F00CB4B08 /* Info-Camino.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Info-Camino.plist"; sourceTree = "<group>"; };
3F44AD8805BDFB9F00CB4B08 /* Camino.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Camino.app; sourceTree = BUILT_PRODUCTS_DIR; };
3F44AD8805BDFB9F00CB4B08 /* Camino.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = Camino.app; sourceTree = BUILT_PRODUCTS_DIR; };
3F44AD9E05BDFB9F00CB4B08 /* Info-AppearancePrefPane.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Info-AppearancePrefPane.plist"; sourceTree = "<group>"; };
3F44AD9F05BDFB9F00CB4B08 /* Appearance.prefPane */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Appearance.prefPane; sourceTree = BUILT_PRODUCTS_DIR; };
3F44ADB205BDFBA000CB4B08 /* Info-NavigationPrefPane.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Info-NavigationPrefPane.plist"; sourceTree = "<group>"; };
@@ -2785,7 +2792,6 @@
F55714A1023B4898010001CA /* smallbookmark.tif */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = smallbookmark.tif; path = resources/images/chrome/smallbookmark.tif; sourceTree = SOURCE_ROOT; };
F557193A022B4102010001CA /* PreferencePanes.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PreferencePanes.framework; path = /System/Library/Frameworks/PreferencePanes.framework; sourceTree = "<absolute>"; };
F558099D02F22168015DF512 /* NSString+Utils.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = "NSString+Utils.h"; path = "src/extensions/NSString+Utils.h"; sourceTree = SOURCE_ROOT; };
F558099E02F22168015DF512 /* NSString+Utils.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = "NSString+Utils.mm"; path = "src/extensions/NSString+Utils.mm"; sourceTree = SOURCE_ROOT; };
F5581379030AEF9B0176F207 /* RemoteDataProvider.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = RemoteDataProvider.h; path = src/browser/RemoteDataProvider.h; sourceTree = SOURCE_ROOT; };
F558137A030AEF9B0176F207 /* SiteIconProvider.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SiteIconProvider.h; path = src/browser/SiteIconProvider.h; sourceTree = SOURCE_ROOT; };
F558137C030AEF9B0176F207 /* RemoteDataProvider.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = RemoteDataProvider.mm; path = src/browser/RemoteDataProvider.mm; sourceTree = SOURCE_ROOT; };
@@ -4381,6 +4387,7 @@
0F5FD71B07F48CDC00E8EDBD /* NSResponder+Utils.h */,
F549ACE40302DEBB01026D5D /* NSScreen+Utils.h */,
3F27D94A05DB2600007B543D /* NSSplitView+Utils.h */,
33FBAAF30C84D0A500DD459E /* NSString+Gecko.h */,
F558099D02F22168015DF512 /* NSString+Utils.h */,
0F84BF1608862E4B00E23BC4 /* NSThread+Utils.h */,
F527C90203BCD43601A80166 /* NSView+Utils.h */,
@@ -4419,7 +4426,8 @@
0F5FD71E07F48CE500E8EDBD /* NSResponder+Utils.m */,
F549ACDF0302DE6001026D5D /* NSScreen+Utils.m */,
3F27D94B05DB2600007B543D /* NSSplitView+Utils.mm */,
F558099E02F22168015DF512 /* NSString+Utils.mm */,
33FBAAFA0C84D0CA00DD459E /* NSString+Gecko.mm */,
33FBAAFB0C84D0CA00DD459E /* NSString+Utils.m */,
0F84BF1208862E3E00E23BC4 /* NSThread+Utils.m */,
3FE4ECE9082C2D89003BF39E /* NSURL+Utils.m */,
F527C90303BCD43601A80166 /* NSView+Utils.m */,
@@ -4689,6 +4697,7 @@
1F8407090C5705CC007B893D /* ThumbnailView.h in Headers */,
00335B8D0C655ABC00A607F2 /* WebSearchField.h in Headers */,
506770FA0C823B1B0050EF73 /* CHSelectHandler.h in Headers */,
33FBAAF80C84D0AB00DD459E /* NSString+Gecko.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -4844,6 +4853,7 @@
1F840B2D0C57D807007B893D /* ThumbnailView.h in Headers */,
00335B8F0C655ABC00A607F2 /* WebSearchField.h in Headers */,
506770FB0C823B1B0050EF73 /* CHSelectHandler.h in Headers */,
33FBAAF90C84D0AC00DD459E /* NSString+Gecko.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -5595,7 +5605,6 @@
3F44ACA905BDFB9E00CB4B08 /* RemoteDataProvider.mm in Sources */,
3F44ACAA05BDFB9E00CB4B08 /* SiteIconProvider.mm in Sources */,
3F44ACAB05BDFB9E00CB4B08 /* BrowserTabViewItem.mm in Sources */,
3F44ACAC05BDFB9E00CB4B08 /* NSString+Utils.mm in Sources */,
3F44ACAD05BDFB9E00CB4B08 /* CHBrowserListener.mm in Sources */,
3F44ACAD05BDFB9E00CB4B18 /* CmXULAppInfo.mm in Sources */,
3F44ACAE05BDFB9E00CB4B08 /* NSBezierPath+Utils.mm in Sources */,
@@ -5671,6 +5680,8 @@
33F3B70B0C63F5F7007DFBD0 /* ScriptingSupport.mm in Sources */,
00335B8E0C655ABC00A607F2 /* WebSearchField.mm in Sources */,
506770F70C823B090050EF73 /* CHSelectHandler.mm in Sources */,
33FBAAFC0C84D0CA00DD459E /* NSString+Gecko.mm in Sources */,
33FBAAFD0C84D0CA00DD459E /* NSString+Utils.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -5758,7 +5769,6 @@
3F44AEDE05BDFBA000CB4B08 /* AppComponents.mm in Sources */,
3F44AEDF05BDFBA000CB4B08 /* SecurityDialogs.mm in Sources */,
3F44AEE005BDFBA000CB4B08 /* CocoaPromptService.mm in Sources */,
3F44AEE105BDFBA000CB4B08 /* NSString+Utils.mm in Sources */,
3F44AEE205BDFBA000CB4B08 /* ToolTip.mm in Sources */,
3F44AEE305BDFBA000CB4B08 /* NSScreen+Utils.m in Sources */,
3F44AEE405BDFBA000CB4B08 /* SiteIconProvider.mm in Sources */,
@@ -5839,6 +5849,8 @@
33F3B70C0C63F5F7007DFBD0 /* ScriptingSupport.mm in Sources */,
00335B900C655ABC00A607F2 /* WebSearchField.mm in Sources */,
506770F80C823B090050EF73 /* CHSelectHandler.mm in Sources */,
33FBAAFE0C84D0CA00DD459E /* NSString+Gecko.mm in Sources */,
33FBAAFF0C84D0CA00DD459E /* NSString+Utils.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -42,7 +42,6 @@
#import <Cocoa/Cocoa.h>
#import "Downloads.h"
#import "NSString+Utils.h"
#include "nsCOMPtr.h"
#include "nsILocalFileMac.h"

View File

@@ -37,7 +37,7 @@
#import "PrivacyPane.h"
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "NSArray+Utils.h"
#import "ExtendedTableView.h"

View File

@@ -37,7 +37,7 @@
* ***** END LICENSE BLOCK ***** */
#import "JSConsole.h"
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "CHBrowserService.h"

View File

@@ -45,7 +45,6 @@
#import "BookmarkViewController.h"
#import "NSArray+Utils.h"
#import "NSString+Utils.h"
#import "NSPasteboard+Utils.h"
#import "NSSplitView+Utils.h"
#import "NSView+Utils.h"

View File

@@ -43,7 +43,7 @@
#include "nsStringStream.h"
#include "nsNetUtil.h"
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
NS_IMPL_ISUPPORTS1(nsAboutBookmarks, nsIAboutModule)

View File

@@ -37,7 +37,7 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import <AppKit/AppKit.h>
#import "AutoCompleteDataSource.h"

View File

@@ -40,6 +40,7 @@
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "AutoCompleteTextField.h"
#import "AutoCompleteDataSource.h"

View File

@@ -37,7 +37,6 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "NSPasteboard+Utils.h"
#import "PreferenceManager.h"

View File

@@ -41,6 +41,7 @@
#import "ABAddressBook+Utils.h"
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "NSSplitView+Utils.h"
#import "NSMenu+Utils.h"
#import "NSPasteboard+Utils.h"

View File

@@ -34,8 +34,7 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "NSView+Utils.h"
#import "ImageAdditions.h"

View File

@@ -36,7 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "CHBrowserView.h"
#import "CHBrowserService.h"

View File

@@ -50,7 +50,7 @@
// Common helper routines (also used by the context menu code)
#include "GeckoUtils.h"
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "ContentClickListener.h"
#import "PreferenceManager.h"

View File

@@ -35,8 +35,6 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#include "nsXPIDLString.h"
#include "nsIDOMWindow.h"

View File

@@ -36,7 +36,7 @@
* ***** END LICENSE BLOCK ***** */
#import <Foundation/Foundation.h>
#import "nscore.h"
extern NSString* const RemoteDataLoadRequestNotificationName;
extern NSString* const RemoteDataLoadRequestURIKey;

View File

@@ -36,7 +36,7 @@
* ***** END LICENSE BLOCK ***** */
#import "ChimeraUtils.h"
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "RemoteDataProvider.h"

View File

@@ -36,7 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "nsAlertController.h"
#import "CHBrowserService.h"

View File

@@ -35,7 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "SiteIconProvider.h"

View File

@@ -37,6 +37,7 @@
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "ChimeraUIConstants.h"

View File

@@ -37,7 +37,7 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#include "nsDownloadListener.h"

View File

@@ -39,7 +39,7 @@
#import <Cocoa/Cocoa.h>
#import <ApplicationServices/ApplicationServices.h>
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "mozView.h"

View File

@@ -36,7 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "CHBrowserService.h"
#import "CHBrowserView.h"

View File

@@ -36,7 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "NSString+Gecko.h"
#import "NSPasteboard+Utils.h"
#import "NSDate+Utils.h"

View File

@@ -37,6 +37,7 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Gecko.h"
#import "NSString+Utils.h"
#import "NSArray+Utils.h"
#import "CHBrowserView.h"

View File

@@ -35,8 +35,6 @@
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Utils.h"
#import "DraggableImageAndTextCell.h"
@interface DraggableImageAndTextCell(Private)

View File

@@ -41,7 +41,6 @@
#import "NSString+Utils.h"
#import "IconTabViewItem.h"
#import "NSString+Utils.h"
//
// NSParagraphStyle has a line break mode which will automatically

View File

@@ -0,0 +1,62 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Chimera code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Fraser <sfraser@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import <Foundation/Foundation.h>
#import "nscore.h"
class nsAString;
class nsACString;
// A category to add Gecko string translation to NSString
@interface NSString (ChimeraGeckoStringUtils)
+ (id)stringWithPRUnichars:(const PRUnichar*)inString;
+ (id)stringWith_nsAString:(const nsAString&)inString;
+ (id)stringWith_nsACString:(const nsACString&)inString; // assumes nsACString is UTF-8
- (void)assignTo_nsAString:(nsAString&)ioString;
- (id)initWith_nsAString:(const nsAString&)inString;
- (id)initWith_nsACString:(const nsACString&)inString; // assumes nsACString is UTF-8
- (id)initWithPRUnichars:(const PRUnichar*)inString;
- (NSString *)stringByRemovingWindowsShortcutAmpersand;
// allocate a new unicode buffer with the contents of the current string. Caller
// is responsible for freeing the buffer.
- (PRUnichar*)createNewUnicodeBuffer;
@end

View File

@@ -0,0 +1,139 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Chimera code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Fraser <sfraser@netscape.com>
* David Haas <haasd@cae.wisc.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import "NSString+Gecko.h"
#include "nsString.h"
#include "nsPromiseFlatString.h"
#include "nsCRT.h"
@implementation NSString (ChimeraGeckoStringUtils)
+ (id)stringWithPRUnichars:(const PRUnichar*)inString
{
if (inString)
return [self stringWithCharacters:inString length:nsCRT::strlen(inString)];
else
return [self string];
}
+ (id)stringWith_nsAString:(const nsAString&)inString
{
nsPromiseFlatString flatString = PromiseFlatString(inString);
return [self stringWithCharacters:flatString.get() length:flatString.Length()];
}
+ (id)stringWith_nsACString:(const nsACString&)inString
{
nsPromiseFlatCString flatString = PromiseFlatCString(inString);
return [self stringWithUTF8String:flatString.get()];
}
- (id)initWith_nsAString:(const nsAString&)inString
{
nsPromiseFlatString flatString = PromiseFlatString(inString);
return [self initWithCharacters:flatString.get() length:flatString.Length()];
}
- (id)initWith_nsACString:(const nsACString&)inString
{
nsPromiseFlatCString flatString = PromiseFlatCString(inString);
return [self initWithUTF8String:flatString.get()];
}
- (id)initWithPRUnichars:(const PRUnichar*)inString
{
return [self initWithCharacters:inString length:nsCRT::strlen(inString)];
}
#define ASSIGN_STACK_BUFFER_CHARACTERS 256
- (void)assignTo_nsAString:(nsAString&)ioString
{
PRUnichar stackBuffer[ASSIGN_STACK_BUFFER_CHARACTERS];
PRUnichar* buffer = stackBuffer;
// XXX maybe fix this to use SetLength(0), SetLength(len), and a writing iterator.
unsigned int len = [self length];
if (len + 1 > ASSIGN_STACK_BUFFER_CHARACTERS) {
buffer = (PRUnichar *)malloc(sizeof(PRUnichar) * (len + 1));
if (!buffer)
return;
}
[self getCharacters:buffer]; // does not null terminate
ioString.Assign(buffer, len);
if (buffer != stackBuffer)
free(buffer);
}
- (PRUnichar*)createNewUnicodeBuffer
{
PRUint32 length = [self length];
PRUnichar* retStr = (PRUnichar*)nsMemory::Alloc((length + 1) * sizeof(PRUnichar));
[self getCharacters:retStr];
retStr[length] = PRUnichar(0);
return retStr;
}
// Windows buttons have shortcut keys specified by ampersands in the
// title string. This function removes them from such strings.
-(NSString*)stringByRemovingWindowsShortcutAmpersand
{
NSMutableString* dirtyStringMutant = [NSMutableString stringWithString:self];
// we loop through removing all single ampersands and reducing double ampersands to singles
unsigned int searchLocation = 0;
while (searchLocation < [dirtyStringMutant length]) {
searchLocation = [dirtyStringMutant rangeOfString:@"&" options:nil
range:NSMakeRange(searchLocation, [dirtyStringMutant length] - searchLocation)].location;
if (searchLocation == NSNotFound) {
break;
}
else {
[dirtyStringMutant deleteCharactersInRange:NSMakeRange(searchLocation, 1)];
// ampersand or not, we leave the next character alone
searchLocation++;
}
}
return [NSString stringWithString:dirtyStringMutant];
}
@end

View File

@@ -36,10 +36,6 @@
* ***** END LICENSE BLOCK ***** */
#import <Foundation/Foundation.h>
#import "nscore.h"
class nsAString;
class nsACString;
typedef enum
{
@@ -56,14 +52,6 @@ typedef enum
+ (NSString*)stringWithUUID;
+ (id)escapedURLString:(NSString *)unescapedString;
+ (NSString*)unescapedURLString:(NSString*)escapedString;
+ (id)stringWithPRUnichars:(const PRUnichar*)inString;
+ (id)stringWith_nsAString:(const nsAString&)inString;
+ (id)stringWith_nsACString:(const nsACString&)inString; // assumes nsACString is UTF-8
- (void)assignTo_nsAString:(nsAString&)ioString;
- (id)initWith_nsAString:(const nsAString&)inString;
- (id)initWith_nsACString:(const nsACString&)inString; // assumes nsACString is UTF-8
- (id)initWithPRUnichars:(const PRUnichar*)inString;
- (BOOL)isEqualToStringIgnoringCase:(NSString*)inString;
- (NSString *)stringByRemovingCharactersInSet:(NSCharacterSet*)characterSet;
@@ -73,12 +61,7 @@ typedef enum
- (NSString *)stringByTrimmingWhitespace;
- (NSString *)stringByRemovingAmpEscapes;
- (NSString *)stringByAddingAmpEscapes;
- (NSString *)stringByRemovingWindowsShortcutAmpersand;
- (NSString *)stripWWW;
// allocate a new unicode buffer with the contents of the current string. Caller
// is responsible for freeing the buffer.
- (PRUnichar*)createNewUnicodeBuffer;
@end
@interface NSMutableString (ChimeraMutableStringUtils)

View File

@@ -0,0 +1,329 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Chimera code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Fraser <sfraser@netscape.com>
* David Haas <haasd@cae.wisc.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import <AppKit/AppKit.h> // for NSStringDrawing.h
#import "NSString+Utils.h"
@implementation NSString (ChimeraStringUtils)
+ (id)ellipsisString
{
static NSString* sEllipsisString = nil;
if (!sEllipsisString) {
unichar ellipsisChar = 0x2026;
sEllipsisString = [[NSString alloc] initWithCharacters:&ellipsisChar length:1];
}
return sEllipsisString;
}
+ (NSString*)stringWithUUID
{
NSString* uuidString = nil;
CFUUIDRef newUUID = CFUUIDCreate(kCFAllocatorDefault);
if (newUUID) {
uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, newUUID);
CFRelease(newUUID);
}
return [uuidString autorelease];
}
+ (id)escapedURLString:(NSString *)unescapedString
{
NSString *escapedString =
(NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)unescapedString,
NULL,
NULL,
kCFStringEncodingUTF8);
return [escapedString autorelease];
}
+ (NSString*)unescapedURLString:(NSString*)escapedString
{
NSString *unescapedString =
(NSString *)CFURLCreateStringByReplacingPercentEscapes(NULL,
(CFStringRef)escapedString,
CFSTR(""));
return [unescapedString autorelease];
}
- (BOOL)isEqualToStringIgnoringCase:(NSString*)inString
{
return ([self compare:inString options:NSCaseInsensitiveSearch] == NSOrderedSame);
}
- (NSString *)stringByRemovingCharactersInSet:(NSCharacterSet*)characterSet
{
NSScanner* cleanerScanner = [NSScanner scannerWithString:self];
NSMutableString* cleanString = [NSMutableString stringWithCapacity:[self length]];
while (![cleanerScanner isAtEnd]) {
NSString* stringFragment;
if ([cleanerScanner scanUpToCharactersFromSet:characterSet intoString:&stringFragment])
[cleanString appendString:stringFragment];
[cleanerScanner scanCharactersFromSet:characterSet intoString:nil];
}
return cleanString;
}
- (NSString *)stringByReplacingCharactersInSet:(NSCharacterSet*)characterSet
withString:(NSString*)string
{
NSScanner* cleanerScanner = [NSScanner scannerWithString:self];
NSMutableString* cleanString = [NSMutableString stringWithCapacity:[self length]];
while (![cleanerScanner isAtEnd])
{
NSString* stringFragment;
if ([cleanerScanner scanUpToCharactersFromSet:characterSet intoString:&stringFragment])
[cleanString appendString:stringFragment];
if ([cleanerScanner scanCharactersFromSet:characterSet intoString:nil])
[cleanString appendString:string];
}
return cleanString;
}
- (NSString*)stringByTruncatingTo:(unsigned int)maxCharacters at:(ETruncationType)truncationType
{
if ([self length] > maxCharacters)
{
NSMutableString *mutableCopy = [self mutableCopy];
[mutableCopy truncateTo:maxCharacters at:truncationType];
return [mutableCopy autorelease];
}
return self;
}
- (NSString *)stringByTruncatingToWidth:(float)inWidth at:(ETruncationType)truncationType
withAttributes:(NSDictionary *)attributes
{
if ([self sizeWithAttributes:attributes].width > inWidth)
{
NSMutableString *mutableCopy = [self mutableCopy];
[mutableCopy truncateToWidth:inWidth at:truncationType withAttributes:attributes];
return [mutableCopy autorelease];
}
return self;
}
- (NSString *)stringByTrimmingWhitespace
{
return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}
-(NSString *)stringByRemovingAmpEscapes
{
NSMutableString* dirtyStringMutant = [NSMutableString stringWithString:self];
[dirtyStringMutant replaceOccurrencesOfString:@"&amp;"
withString:@"&"
options:NSLiteralSearch
range:NSMakeRange(0,[dirtyStringMutant length])];
[dirtyStringMutant replaceOccurrencesOfString:@"&quot;"
withString:@"\""
options:NSLiteralSearch
range:NSMakeRange(0,[dirtyStringMutant length])];
[dirtyStringMutant replaceOccurrencesOfString:@"&lt;"
withString:@"<"
options:NSLiteralSearch
range:NSMakeRange(0,[dirtyStringMutant length])];
[dirtyStringMutant replaceOccurrencesOfString:@"&gt;"
withString:@">"
options:NSLiteralSearch
range:NSMakeRange(0,[dirtyStringMutant length])];
[dirtyStringMutant replaceOccurrencesOfString:@"&mdash;"
withString:@"-"
options:NSLiteralSearch
range:NSMakeRange(0,[dirtyStringMutant length])];
[dirtyStringMutant replaceOccurrencesOfString:@"&apos;"
withString:@"'"
options:NSLiteralSearch
range:NSMakeRange(0,[dirtyStringMutant length])];
// fix import from old Firefox versions, which exported &#39; instead of a plain apostrophe
[dirtyStringMutant replaceOccurrencesOfString:@"&#39;"
withString:@"'"
options:NSLiteralSearch
range:NSMakeRange(0,[dirtyStringMutant length])];
return [dirtyStringMutant stringByRemovingCharactersInSet:[NSCharacterSet controlCharacterSet]];
}
-(NSString *)stringByAddingAmpEscapes
{
NSMutableString* dirtyStringMutant = [NSMutableString stringWithString:self];
[dirtyStringMutant replaceOccurrencesOfString:@"&"
withString:@"&amp;"
options:NSLiteralSearch
range:NSMakeRange(0,[dirtyStringMutant length])];
[dirtyStringMutant replaceOccurrencesOfString:@"\""
withString:@"&quot;"
options:NSLiteralSearch
range:NSMakeRange(0,[dirtyStringMutant length])];
[dirtyStringMutant replaceOccurrencesOfString:@"<"
withString:@"&lt;"
options:NSLiteralSearch
range:NSMakeRange(0,[dirtyStringMutant length])];
[dirtyStringMutant replaceOccurrencesOfString:@">"
withString:@"&gt;"
options:NSLiteralSearch
range:NSMakeRange(0,[dirtyStringMutant length])];
return [NSString stringWithString:dirtyStringMutant];
}
@end
@implementation NSMutableString (ChimeraMutableStringUtils)
- (void)truncateTo:(unsigned)maxCharacters at:(ETruncationType)truncationType
{
if ([self length] <= maxCharacters)
return;
NSRange replaceRange;
replaceRange.length = [self length] - maxCharacters;
switch (truncationType) {
case kTruncateAtStart:
replaceRange.location = 0;
break;
case kTruncateAtMiddle:
replaceRange.location = maxCharacters / 2;
break;
case kTruncateAtEnd:
replaceRange.location = maxCharacters;
break;
default:
#if DEBUG
NSLog(@"Unknown truncation type in stringByTruncatingTo::");
#endif
replaceRange.location = maxCharacters;
break;
}
[self replaceCharactersInRange:replaceRange withString:[NSString ellipsisString]];
}
- (void)truncateToWidth:(float)maxWidth
at:(ETruncationType)truncationType
withAttributes:(NSDictionary *)attributes
{
// First check if we have to truncate at all.
if ([self sizeWithAttributes:attributes].width <= maxWidth)
return;
// Essentially, we perform a binary search on the string length
// which fits best into maxWidth.
float width = maxWidth;
int lo = 0;
int hi = [self length];
int mid;
// Make a backup copy of the string so that we can restore it if we fail low.
NSMutableString *backup = [self mutableCopy];
while (hi >= lo) {
mid = (hi + lo) / 2;
// Cut to mid chars and calculate the resulting width
[self truncateTo:mid at:truncationType];
width = [self sizeWithAttributes:attributes].width;
if (width > maxWidth) {
// Fail high - string is still to wide. For the next cut, we can simply
// work on the already cut string, so we don't restore using the backup.
hi = mid - 1;
}
else if (width == maxWidth) {
// Perfect match, abort the search.
break;
}
else {
// Fail low - we cut off too much. Restore the string before cutting again.
lo = mid + 1;
[self setString:backup];
}
}
// Perform the final cut (unless this was already a perfect match).
if (width != maxWidth)
[self truncateTo:hi at:truncationType];
[backup release];
}
@end
@implementation NSString (ChimeraFilePathStringUtils)
- (NSString*)volumeNamePathComponent
{
// if the file doesn't exist, then componentsToDisplayForPath will return nil,
// so back up to the nearest existing dir
NSString* curPath = self;
while (![[NSFileManager defaultManager] fileExistsAtPath:curPath])
{
NSString* parentDirPath = [curPath stringByDeletingLastPathComponent];
if ([parentDirPath isEqualToString:curPath])
break; // avoid endless loop
curPath = parentDirPath;
}
NSArray* displayComponents = [[NSFileManager defaultManager] componentsToDisplayForPath:curPath];
if ([displayComponents count] > 0)
return [displayComponents objectAtIndex:0];
return self;
}
- (NSString*)displayNameOfLastPathComponent
{
return [[NSFileManager defaultManager] displayNameAtPath:self];
}
@end