1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24#ifndef _CFSTRINGUTILITIES_HXX_
25#include "CFStringUtilities.hxx"
26#endif
27
28#include "NSString_OOoAdditions.hxx"
29
30#define CLASS_NAME "NSString"
31
32@implementation NSString (OOoAdditions)
33
34+ (id) stringWithOUString:(const rtl::OUString&)ouString
35{
36    DBG_PRINT_ENTRY(CLASS_NAME, __func__, "ouString", ouString);
37
38    NSString *string = [[NSString alloc] initWithOUString:ouString];
39
40    DBG_PRINT_EXIT(CLASS_NAME, __func__, string);
41    return [string autorelease];
42}
43
44- (id) initWithOUString:(const rtl::OUString&)ouString
45{
46    DBG_PRINT_ENTRY(CLASS_NAME, __func__, "ouString", ouString);
47    if ((self = [super init])) {
48        self = [self initWithCharacters:ouString.getStr() length:ouString.getLength()];
49
50        DBG_PRINT_EXIT(CLASS_NAME, __func__, self);
51
52        return self;
53    }
54
55    DBG_PRINT_EXIT(CLASS_NAME, __func__, self);
56    return nil;
57}
58
59- (rtl::OUString) OUString
60{
61    unsigned int nFileNameLength = [self length];
62
63    UniChar unichars[nFileNameLength+1];
64
65    //'close' the string buffer correctly
66    unichars[nFileNameLength] = '\0';
67
68    [self getCharacters:unichars];
69
70    return rtl::OUString(unichars);
71}
72
73@end
74