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 .
22 #include <QtCore/QString>
23 #include <QtCore/QRect>
24 #include <QtCore/QSize>
25 #include <QtGui/QImage>
27 #include <rtl/string.hxx>
28 #include <rtl/ustring.hxx>
29 #include <tools/gen.hxx>
33 inline OUString
toOUString(const QString
& s
)
35 // QString stores UTF16, just like OUString
36 return OUString(reinterpret_cast<const sal_Unicode
*>(s
.data()), s
.length());
39 inline QString
toQString(const OUString
& s
)
41 return QString::fromUtf16(reinterpret_cast<ushort
const*>(s
.getStr()), s
.getLength());
44 inline QRect
toQRect(const tools::Rectangle
& rRect
)
46 return QRect(rRect
.Left(), rRect
.Top(), rRect
.GetWidth(), rRect
.GetHeight());
49 inline QSize
toQSize(const Size
& rSize
) { return QSize(rSize
.Width(), rSize
.Height()); }
51 inline Size
toSize(const QSize
& rSize
) { return Size(rSize
.width(), rSize
.height()); }
53 static constexpr QImage::Format Qt5_DefaultFormat32
= QImage::Format_ARGB32
;
55 inline QImage::Format
getBitFormat(sal_uInt16 nBitCount
)
60 return QImage::Format_Mono
;
62 return QImage::Format_Indexed8
;
64 return QImage::Format_RGB16
;
66 return QImage::Format_RGB888
;
68 return Qt5_DefaultFormat32
;
73 return QImage::Format_Invalid
;
76 inline sal_uInt16
getFormatBits(QImage::Format eFormat
)
80 case QImage::Format_Mono
:
82 case QImage::Format_Indexed8
:
84 case QImage::Format_RGB16
:
86 case QImage::Format_RGB888
:
88 case Qt5_DefaultFormat32
:
96 typedef struct _cairo_surface cairo_surface_t
;
99 void operator()(cairo_surface_t
* pSurface
) const;
102 typedef std::unique_ptr
<cairo_surface_t
, CairoDeleter
> UniqueCairoSurface
;
104 sal_uInt16
GetKeyModCode(Qt::KeyboardModifiers eKeyModifiers
);
105 sal_uInt16
GetMouseModCode(Qt::MouseButtons eButtons
);
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */