1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
25 #include <rtl/alloc.h>
26 #include <rtl/ustrbuf.hxx>
28 #include <quartz/utils.h>
30 OUString
GetOUString( CFStringRef rStr
)
37 CFIndex nLength
= CFStringGetLength( rStr
);
43 const UniChar
* pConstStr
= CFStringGetCharactersPtr( rStr
);
46 return OUString( reinterpret_cast<sal_Unicode
const *>(pConstStr
), nLength
);
49 std::unique_ptr
<UniChar
[]> pStr(new UniChar
[nLength
]);
50 CFRange aRange
= { 0, nLength
};
51 CFStringGetCharacters( rStr
, aRange
, pStr
.get() );
53 OUString
aRet( reinterpret_cast<sal_Unicode
*>(pStr
.get()), nLength
);
57 OUString
GetOUString( const NSString
* pStr
)
64 int nLen
= [pStr length
];
70 OUStringBuffer
aBuf( nLen
+1 );
71 aBuf
.setLength( nLen
);
73 reinterpret_cast<unichar
*>(const_cast<sal_Unicode
*>(aBuf
.getStr()))];
75 return aBuf
.makeStringAndClear();
78 CFStringRef
CreateCFString( const OUString
& rStr
)
80 return CFStringCreateWithCharacters(kCFAllocatorDefault
, reinterpret_cast<UniChar
const *>(rStr
.getStr()), rStr
.getLength() );
83 NSString
* CreateNSString( const OUString
& rStr
)
85 return [[NSString alloc
] initWithCharacters
: reinterpret_cast<unichar
const *>(rStr
.getStr()) length
: rStr
.getLength()];
88 std::ostream
&operator <<(std::ostream
& s
, const CGRect
&rRect
)
93 if (CGRectIsNull(rRect
))
99 s
<< rRect
.size
<< "@" << rRect
.origin
;
105 std::ostream
&operator <<(std::ostream
& s
, const CGPoint
&rPoint
)
110 s
<< "(" << rPoint
.x
<< "," << rPoint
.y
<< ")";
115 std::ostream
&operator <<(std::ostream
& s
, const CGSize
&rSize
)
120 s
<< rSize
.width
<< "x" << rSize
.height
;
125 std::ostream
&operator <<(std::ostream
& s
, CGColorRef pColor
)
130 CFStringRef colorString
= CFCopyDescription(pColor
);
133 s
<< GetOUString(colorString
);
134 CFRelease(colorString
);
144 std::ostream
&operator <<(std::ostream
& s
, const CGAffineTransform
&aXform
)
149 if (CGAffineTransformIsIdentity(aXform
))
155 s
<< "[" << aXform
.a
<< "," << aXform
.b
<< "," << aXform
.c
<< "," << aXform
.d
<< "," << aXform
.tx
<< "," << aXform
.ty
<< "]";
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */