1/*************************************************************************
2 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 *
7 * OpenOffice.org - a multi-platform office productivity suite
8 *
9 * This file is part of OpenOffice.org.
10 *
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org.  If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
25 *
26 ************************************************************************/
27
28#ifndef _CFSTRINGUTILITIES_HXX_
29#include "CFStringUtilities.hxx"
30#endif
31
32#include "NSString_OOoAdditions.hxx"
33
34#define CLASS_NAME "NSString"
35
36@implementation NSString (OOoAdditions)
37
38+ (id) stringWithOUString:(const rtl::OUString&)ouString
39{
40    DBG_PRINT_ENTRY(CLASS_NAME, __func__, "ouString", ouString);
41
42    NSString *string = [[NSString alloc] initWithOUString:ouString];
43
44    DBG_PRINT_EXIT(CLASS_NAME, __func__, string);
45    return [string autorelease];
46}
47
48- (id) initWithOUString:(const rtl::OUString&)ouString
49{
50    DBG_PRINT_ENTRY(CLASS_NAME, __func__, "ouString", ouString);
51    if ((self = [super init])) {
52        self = [self initWithCharacters:ouString.getStr() length:ouString.getLength()];
53
54        DBG_PRINT_EXIT(CLASS_NAME, __func__, self);
55
56        return self;
57    }
58
59    DBG_PRINT_EXIT(CLASS_NAME, __func__, self);
60    return nil;
61}
62
63- (rtl::OUString) OUString
64{
65    unsigned int nFileNameLength = [self length];
66
67    UniChar unichars[nFileNameLength+1];
68
69    //'close' the string buffer correctly
70    unichars[nFileNameLength] = '\0';
71
72    [self getCharacters:unichars];
73
74    return rtl::OUString(unichars);
75}
76
77@end
78