27 #include <nsAutoPtr.h>
28 #include <nsComponentManagerUtils.h>
29 #include <nsUnicharUtils.h>
32 #include <sbIStringTransform.h>
45 NS_INTERFACE_TABLE_BEGIN
48 NS_INTERFACE_TABLE_END
51 sbTextPropertyInfo::sbTextPropertyInfo()
55 , mEnforceLowercaseLock(nsnull)
56 , mEnforceLowercase(PR_FALSE)
57 , mNoCompressWhitespaceLock(nsnull)
58 , mNoCompressWhitespace(PR_FALSE)
60 mType = NS_LITERAL_STRING(
"text");
62 mMinMaxLock = PR_NewLock();
63 NS_ASSERTION(mMinMaxLock,
64 "sbTextPropertyInfo::mMinMaxLock failed to create lock!");
66 mEnforceLowercaseLock = PR_NewLock();
67 NS_ASSERTION(mEnforceLowercaseLock,
68 "sbTextPropertyInfo::mEnforceLowercaseLock failed to create lock!");
70 mNoCompressWhitespaceLock = PR_NewLock();
71 NS_ASSERTION(mNoCompressWhitespaceLock,
72 "sbTextPropertyInfo::mNoCompressWhitespaceLock failed to create lock!");
96 NS_ENSURE_SUCCESS(rv, rv);
99 NS_ENSURE_SUCCESS(rv, rv);
109 nsRefPtr<sbPropertyOperator> propOp;
111 rv = sbPropertyInfo::GetOPERATOR_CONTAINS(op);
112 NS_ENSURE_SUCCESS(rv, rv);
114 NS_ENSURE_TRUE(propOp, NS_ERROR_OUT_OF_MEMORY);
116 NS_ENSURE_SUCCESS(rv, rv);
118 rv = sbPropertyInfo::GetOPERATOR_NOTCONTAINS(op);
119 NS_ENSURE_SUCCESS(rv, rv);
121 NS_ENSURE_TRUE(propOp, NS_ERROR_OUT_OF_MEMORY);
123 NS_ENSURE_SUCCESS(rv, rv);
125 rv = sbPropertyInfo::GetOPERATOR_EQUALS(op);
126 NS_ENSURE_SUCCESS(rv, rv);
128 NS_ENSURE_TRUE(propOp, NS_ERROR_OUT_OF_MEMORY);
130 NS_ENSURE_SUCCESS(rv, rv);
132 rv = sbPropertyInfo::GetOPERATOR_NOTEQUALS(op);
133 NS_ENSURE_SUCCESS(rv, rv);
135 NS_ENSURE_TRUE(propOp, NS_ERROR_OUT_OF_MEMORY);
137 NS_ENSURE_SUCCESS(rv, rv);
139 rv = sbPropertyInfo::GetOPERATOR_BEGINSWITH(op);
140 NS_ENSURE_SUCCESS(rv, rv);
142 NS_ENSURE_TRUE(propOp, NS_ERROR_OUT_OF_MEMORY);
144 NS_ENSURE_SUCCESS(rv, rv);
146 rv = sbPropertyInfo::GetOPERATOR_NOTBEGINSWITH(op);
147 NS_ENSURE_SUCCESS(rv, rv);
149 NS_ENSURE_TRUE(propOp, NS_ERROR_OUT_OF_MEMORY);
151 NS_ENSURE_SUCCESS(rv, rv);
153 rv = sbPropertyInfo::GetOPERATOR_ENDSWITH(op);
154 NS_ENSURE_SUCCESS(rv, rv);
156 NS_ENSURE_TRUE(propOp, NS_ERROR_OUT_OF_MEMORY);
158 NS_ENSURE_SUCCESS(rv, rv);
160 rv = sbPropertyInfo::GetOPERATOR_NOTENDSWITH(op);
161 NS_ENSURE_SUCCESS(rv, rv);
163 NS_ENSURE_TRUE(propOp, NS_ERROR_OUT_OF_MEMORY);
165 NS_ENSURE_SUCCESS(rv, rv);
172 NS_ENSURE_ARG_POINTER(_retval);
174 PRUint32 len = aValue.Length();
192 return NS_ERROR_NOT_IMPLEMENTED;
198 PRBool valid = PR_FALSE;
199 PRBool isTrim = PR_FALSE;
212 PRUint32 len = aValue.Length();
220 _retval = EmptyString();
221 return NS_ERROR_INVALID_ARG;
235 ToLowerCase(_retval);
240 NS_ENSURE_SUCCESS(rv, rv);
243 rv = NS_ERROR_FAILURE;
244 _retval = EmptyString();
258 CompressWhitespace(val);
263 nsCOMPtr<sbIStringTransform> stringTransform =
265 NS_ENSURE_SUCCESS(rv, rv);
275 rv = stringTransform->
276 NormalizeString(EmptyString(),
282 NS_ENSURE_SUCCESS(rv, rv);
285 if (!outVal.IsEmpty()) {
289 rv = stringTransform->RemoveArticles(val, EmptyString(), outVal);
290 NS_ENSURE_SUCCESS(rv, rv);
301 PRBool valid = PR_FALSE;
304 CompressWhitespace(_retval);
305 ToLowerCase(_retval);
307 nsCOMPtr<sbIStringTransform> stringTransform =
309 NS_ENSURE_SUCCESS(rv, rv);
312 rv = stringTransform->NormalizeString(EmptyString(),
315 NS_ENSURE_SUCCESS(rv, rv);
319 PRUint32 len = aValue.Length();
327 _retval = EmptyString();
328 return NS_ERROR_INVALID_ARG;
341 rv = NS_ERROR_FAILURE;
342 _retval = EmptyString();
348 NS_IMETHODIMP sbTextPropertyInfo::GetMinLength(PRUint32 *aMinLength)
350 NS_ENSURE_ARG_POINTER(aMinLength);
355 NS_IMETHODIMP sbTextPropertyInfo::SetMinLength(PRUint32 aMinLength)
362 NS_IMETHODIMP sbTextPropertyInfo::GetMaxLength(PRUint32 *aMaxLength)
364 NS_ENSURE_ARG_POINTER(aMaxLength);
369 NS_IMETHODIMP sbTextPropertyInfo::SetMaxLength(PRUint32 aMaxLength)
376 NS_IMETHODIMP sbTextPropertyInfo::GetEnforceLowercase(PRBool *aEnforceLowercase)
378 NS_ENSURE_ARG_POINTER(aEnforceLowercase);
383 NS_IMETHODIMP sbTextPropertyInfo::SetEnforceLowercase(PRBool aEnforceLowercase)
390 NS_IMETHODIMP sbTextPropertyInfo::GetNoCompressWhitespace(PRBool *aNoCompressWhitespace)
392 NS_ENSURE_ARG_POINTER(aNoCompressWhitespace);
397 NS_IMETHODIMP sbTextPropertyInfo::SetNoCompressWhitespace(PRBool aNoCompressWhitespace)
virtual ~sbTextPropertyInfo()
NS_IMETHOD Sanitize(const nsAString &aValue, nsAString &_retval)
void SB_CompressWhitespace(nsAString &aString, PRBool aLeading, PRBool aTrailing)
NS_IMPL_ADDREF_INHERITED(sbTextPropertyInfo, sbPropertyInfo)
NS_IMETHOD MakeSortable(const nsAString &aValue, nsAString &_retval)
nsresult InitializeOperators()
NS_IMETHOD Validate(const nsAString &aValue, PRBool *_retval)
this _dialogInput val(dateText)
PRLock * mNoCompressWhitespaceLock
The property information specific to text fields.
An interface used to describe a metadata property for use by the UI and other sbILibrary interfaces (...
PRBool mNoCompressWhitespace
nsCOMArray< sbIPropertyOperator > mOperators
NS_IMETHOD MakeSearchable(const nsAString &aValue, nsAString &_retval)
NS_IMPL_RELEASE_INHERITED(sbTextPropertyInfo, sbPropertyInfo)
NS_IMETHOD Format(const nsAString &aValue, nsAString &_retval)
PRLock * mEnforceLowercaseLock