summaryrefslogtreecommitdiff
path: root/include/sal
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2013-04-19 18:54:16 +0200
committerDavid Tardon <dtardon@redhat.com>2013-04-24 05:17:10 +0000
commit6c7659b584ea7ed3652ca4eb9a2297f36310c365 (patch)
treeadf631e2d3db309b0696babd9d026bce0996c215 /include/sal
parent24500d6798007d84521eb24a81c121ebe69d3bfd (diff)
move URE headers to include/
Change-Id: Ib48a12e902f2311c295b2007f08f44dee28f431d Reviewed-on: https://gerrit.libreoffice.org/3499 Reviewed-by: David Tardon <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'include/sal')
-rw-r--r--include/sal/ByteBufferWrapper.hxx40
-rw-r--r--include/sal/alloca.h66
-rw-r--r--include/sal/config.h100
-rw-r--r--include/sal/detail/log.h106
-rw-r--r--include/sal/log-areas.dox355
-rw-r--r--include/sal/log.hxx317
-rw-r--r--include/sal/macros.h66
-rw-r--r--include/sal/main.h149
-rw-r--r--include/sal/mathconf.h156
-rw-r--r--include/sal/saldllapi.h35
-rw-r--r--include/sal/types.h566
-rw-r--r--include/sal/typesizes.h20
12 files changed, 1976 insertions, 0 deletions
diff --git a/include/sal/ByteBufferWrapper.hxx b/include/sal/ByteBufferWrapper.hxx
new file mode 100644
index 000000000000..63bb618278d6
--- /dev/null
+++ b/include/sal/ByteBufferWrapper.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef _SAL_BYTEBUFFERWRAPPER_HXX
+#define _SAL_BYTEBUFFERWRAPPER_HXX
+
+#ifdef ANDROID
+
+#include <jni.h>
+
+#include <sal/types.h>
+
+namespace org { namespace libreoffice { namespace touch {
+
+class ByteBufferWrapper
+{
+private:
+ jobject object;
+
+public:
+ ByteBufferWrapper(JNIEnv *env, jobject o);
+
+ sal_uInt8* pointer();
+
+ void operator()(sal_uInt8 *p);
+};
+
+}; }; };
+
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/alloca.h b/include/sal/alloca.h
new file mode 100644
index 000000000000..c42f723f4af3
--- /dev/null
+++ b/include/sal/alloca.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SAL_ALLOCA_H
+#define INCLUDED_SAL_ALLOCA_H
+
+#if defined (SOLARIS) || defined (LINUX) || defined(__EMX__) || defined(AIX) || defined(ANDROID)
+
+#ifndef INCLUDED_ALLOCA_H
+#include <alloca.h>
+#define INCLUDED_ALLOCA_H
+#endif
+
+#elif defined (FREEBSD) || defined(NETBSD) || defined(OPENBSD) || defined(DRAGONFLY)
+
+#ifndef INCLUDED_STDLIB_H
+#include <stdlib.h>
+#define INCLUDED_STDLIB_H
+#endif
+
+#elif defined (MACOSX)
+
+#ifndef INCLUDED_SYS_TYPES_H
+#include <sys/types.h>
+#define INCLUDED_SYS_TYPES_H
+#endif
+
+#elif defined (IOS)
+
+#ifndef INCLUDED_SYS_TYPES_H
+#include <sys/types.h>
+#define INCLUDED_SYS_TYPES_H
+#endif
+
+#elif defined (WNT)
+
+#ifndef INCLUDED_MALLOC_H
+#include <malloc.h>
+#define INCLUDED_MALLOC_H
+#endif
+
+#else
+
+#error "unknown platform: please check for alloca"
+
+#endif
+
+#endif /* INCLUDED_SAL_ALLOCA_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/config.h b/include/sal/config.h
new file mode 100644
index 000000000000..ee230fe49d69
--- /dev/null
+++ b/include/sal/config.h
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _SAL_CONFIG_H_
+#define _SAL_CONFIG_H_
+
+#if defined LIBO_INTERNAL_ONLY
+#include "config_global.h"
+#endif
+
+#include <stdlib.h>
+
+#ifdef WIN32
+#define SAL_W32
+#define SAL_DLLEXTENSION ".dll"
+#define SAL_PRGEXTENSION ".exe"
+#define SAL_PATHSEPARATOR ';'
+#define SAL_PATHDELIMITER '\\'
+#define SAL_CONFIGFILE( name ) name ".ini"
+
+#ifdef _MSC_VER
+
+#ifndef _USE_MATH_DEFINES
+#define _USE_MATH_DEFINES // needed by Visual C++ for math constants
+#endif
+
+#endif /* defined _MSC_VER */
+
+/* Provide ISO C99 compatible versions of snprint and vsnprintf */
+#ifdef __MINGW32__
+#define _SNPRINTF_DLLIMPORT
+#endif
+#ifndef _SNPRINTF_H
+#include <systools/win32/snprintf.h>
+#endif
+
+#endif /* defined WIN32 */
+
+#if defined(SOLARIS) || defined(LINUX) || defined(NETBSD) || defined(FREEBSD) || \
+ defined(AIX) || defined(OPENBSD) || defined(DRAGONFLY) || defined(ANDROID)
+#define SAL_UNX
+#define SAL_DLLEXTENSION ".so"
+#define SAL_DLLPREFIX "lib"
+#define SAL_PRGEXTENSION ".bin"
+#define SAL_PATHSEPARATOR ':'
+#define SAL_PATHDELIMITER '/'
+#define SAL_CONFIGFILE( name ) name "rc"
+#endif
+
+#ifdef MACOSX
+#define SAL_UNX
+#define SAL_DLLEXTENSION ".dylib"
+#define SAL_DLLPREFIX "lib"
+#define SAL_PRGEXTENSION ".bin"
+#define SAL_PATHSEPARATOR ':'
+#define SAL_PATHDELIMITER '/'
+#define SAL_CONFIGFILE( name ) name "rc"
+#endif
+
+#ifdef IOS
+#define SAL_UNX
+/* SAL_DLLEXTENSION should not really be used on iOS, as iOS apps are
+ * not allowed to load own dynamic libraries.
+ */
+#define SAL_DLLEXTENSION ".dylib"
+#define SAL_DLLPREFIX "lib"
+/* This is fairly pointless too, an iOS app consists of a single
+ * executable (plus data files).
+ */
+#define SAL_PRGEXTENSION ".bin"
+#define SAL_PATHSEPARATOR ':'
+#define SAL_PATHDELIMITER '/'
+#define SAL_CONFIGFILE( name ) name "rc"
+#endif
+
+#ifdef sun
+#undef sun
+#define sun sun
+#endif
+
+#endif /*_SAL_CONFIG_H_ */
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/detail/log.h b/include/sal/detail/log.h
new file mode 100644
index 000000000000..5cfc5e5fc0cc
--- /dev/null
+++ b/include/sal/detail/log.h
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SAL_DETAIL_LOG_H
+#define INCLUDED_SAL_DETAIL_LOG_H
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+/** @cond INTERNAL */
+
+/* This header makes available replacements working in both C and C++ for the
+ obsolete osl/diagnose.h functionality that in turn is used from both C and
+ C++ code and the obsolete tools/debug.hxx and
+ canvas/inc/canvas/verbosetrace.hxx functionality that uses printf-style
+ formatting. Once that obsolete functionality is removed, this header can be
+ removed, too.
+
+ This header uses variadic macros in both C (where they are officially only
+ supported since C99) and C++ (where they are officially only supported since
+ C++11). It appears that all relevant compilers (esp. GCC 4.0 and MS VS 2008
+ Express) already support them in their C and C++ dialects. See also
+ <http://wiki.apache.org/stdcxx/C++0xCompilerSupport>.
+
+ Avoid the use of other sal code in this header as much as possible, so that
+ this code can be called from other sal code without causing endless
+ recursion.
+*/
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+/*
+ Clang warns about 'sal_True && sal_True' (those being integers and not booleans)
+ when it sees preprocessed source (-save-temps or using icecream)
+*/
+#if defined __cplusplus
+#define SAL_LOG_TRUE true
+#define SAL_LOG_FALSE false
+#else
+#define SAL_LOG_TRUE sal_True
+#define SAL_LOG_FALSE sal_False
+#endif
+
+enum sal_detail_LogLevel {
+ SAL_DETAIL_LOG_LEVEL_INFO, SAL_DETAIL_LOG_LEVEL_WARN,
+ SAL_DETAIL_LOG_LEVEL_DEBUG = SAL_MAX_ENUM
+};
+
+SAL_DLLPUBLIC void SAL_CALL sal_detail_logFormat(
+ enum sal_detail_LogLevel level, char const * area, char const * where,
+ char const * format, ...)
+/* TODO: enabling this will produce a huge amount of -Werror=format errors: */
+#if defined __GNUC__ && 0
+ __attribute__((format(printf, 4, 5)))
+#endif
+ ;
+
+#if defined __cplusplus
+}
+#endif
+
+#define SAL_DETAIL_LOG_FORMAT(condition, level, area, where, ...) \
+ do { \
+ if (condition) { \
+ sal_detail_logFormat((level), (area), (where), __VA_ARGS__); \
+ } \
+ } while (SAL_LOG_FALSE)
+
+#if defined SAL_LOG_INFO
+#define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_TRUE
+#else
+#define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_FALSE
+#endif
+#if defined SAL_LOG_WARN
+#define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_TRUE
+#else
+#define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_FALSE
+#endif
+
+#define SAL_DETAIL_WHERE __FILE__ ":" SAL_STRINGIFY(__LINE__) ": "
+
+#define SAL_DETAIL_INFO_IF_FORMAT(condition, area, ...) \
+ SAL_DETAIL_LOG_FORMAT( \
+ SAL_DETAIL_ENABLE_LOG_INFO && (condition), SAL_DETAIL_LOG_LEVEL_INFO, \
+ area, SAL_DETAIL_WHERE, __VA_ARGS__)
+
+#define SAL_DETAIL_WARN_IF_FORMAT(condition, area, ...) \
+ SAL_DETAIL_LOG_FORMAT( \
+ SAL_DETAIL_ENABLE_LOG_WARN && (condition), SAL_DETAIL_LOG_LEVEL_WARN, \
+ area, SAL_DETAIL_WHERE, __VA_ARGS__)
+
+/** @endcond */
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
new file mode 100644
index 000000000000..d21f14388d96
--- /dev/null
+++ b/include/sal/log-areas.dox
@@ -0,0 +1,355 @@
+// NOTE: This file is also parsed by a compiler plugin. Make sure all
+// areas are marked with '@li @c'.
+
+/**
+@page sal_log_areas SAL debug areas
+
+@short List and description of areas for the SAL debug macros
+
+This is a list of areas that are used by the SAL_INFO family of macros. See
+@ref sal_log "basic log functionality" for details about this functionality.
+
+If you need a debug area in some code, first check this list and use the
+appropriate area if it exists. This list is not definite, if you need a new
+area, use it and add it to an appropriate section with an explanation.
+Generally, use the name of the relevant code module as the first area segment.
+Please keep all entries sorted.
+
+This list should give you an overview of which areas to enable when debugging
+certain functionality.
+
+@section SAL
+
+@li @c sal.debug - SAL debugging functionality
+@li @c sal.osl - SAL OSL library
+@li @c sal.rtl - SAL RTL library
+@li @c sal.textenc - the textencoding SAL library
+
+@section basctl
+
+@li @c basctl.basicide
+
+@section basebmp
+
+@li @c basebmp.bitmapdevice
+
+@section basic
+
+@li @c basic
+@li @c basic.sbx
+
+@section canvas
+
+@li @c canvas
+@li @c canvas.cairo
+@li @c canvas.null
+
+@section chart2
+
+@li @c chart2
+@li @c chart2.areachart
+
+@section connectivity
+
+@li @c connectivity.cpool
+@li @c connectivity.commontools
+@li @c connectivity.mork
+@li @c connectivity.parse
+@li @c connectivity.postgresql
+
+@section cui
+
+@li @c cui.customize
+@li @c cui.dialogs
+@li @c cui.factory
+@li @c cui.options
+@li @c cui.tabpages
+
+@section Calc
+
+@li @c sc
+@li @c sc.core
+@li @c sc.ui - Calc UI
+
+@section desktop
+
+@li @c desktop
+@li @c desktop.deployment
+@li @c desktop.migration
+
+@section Draw
+
+@li @c sd
+@li @c sd.fwk
+@li @c sd.sls - slidesorter
+@li @c sd.tools
+@li @c sd.ui
+@li @c sd.view
+@li @c sd.slideshow
+@li @c sdremote
+@li @c sdremote.bluetooth
+
+@section editeng
+
+@li @c editeng
+@li @c editeng.items
+
+@section embeddedobj
+
+@li @c embeddedobj - embedded objects
+@li @c embeddedobj.ole - OLE embedded objects
+
+@section extensions
+
+@li @c extensions.dbpilots
+@li @c extensions.plugin
+@li @c extensions.scanner
+@li @c extensions.update
+
+@section Filter
+
+@li @c filter.ms - escher import/export
+@li @c filter.xslt - xslt import/export
+@li @c oox.xmlstream - XmlStream class
+@li @c oox.storage - ZipStorage class
+@li @c oox.ppt - pptx filter
+
+@section formula
+
+@li @c formula.core
+
+@section fpicker
+
+@li @c fpicker.aqua
+@li @c fpicker.office
+
+@section framework
+
+@li @c fwk - framework
+@li @c fwk.desktop
+@li @c fwk.session
+
+@section i18nlangtag
+
+@li @c i18nlangtag - language tags
+
+@section i18npool
+
+@li @c i18npool - general i18npool
+
+@section i18n
+
+@li @c i18n - module independent i18n related, e.g. language tag usage
+
+@section io
+
+@li @c io.streams
+
+@section jvmfwk
+
+@li @c jfw
+@li @c jfw.level1
+@li @c jfw.level2
+
+@section Math
+
+@li @c starmath.rtf
+@li @c starmath.ooxml - OOXML import/export
+@li @c starmath.wordbase
+
+@section sdext
+
+@li @c sdext.minimizer
+@li @c sdext.pdfimport
+@li @c sdext.pdfimport.pdfparse
+@li @c sdext.presenter
+
+@section sfx2
+
+@li @c sfx2
+@li @c sfx2.appl
+@li @c sfx2.bastyp
+@li @c sfx2.config
+@li @c sfx2.control
+@li @c sfx2.dialog
+@li @c sfx2.doc
+@li @c sfx2.notify
+@li @c sfx2.view
+
+@section slideshow
+
+@li @c slideshow.opengl
+@li @c slideshow.eventqueue
+
+@section svl
+
+@li @c svl
+@li @c svl.numbers
+
+@section svtools
+
+@li @c svtools.config
+@li @c svtools.contnr
+@li @c svtools.control
+@li @c svtools.dialogs
+@li @c svtools.filter
+@li @c svtools.misc
+@li @c svtools.table
+@li @c svtools.uno
+
+@section svx
+
+@li @c svx.dialog
+@li @c svx.fmcomp
+@li @c svx.form
+@li @c svx.stbcrtls - StatusBarControl
+@li @c svx.table
+@li @c svx.tbxcrtls - ToolboxControl
+@li @c svx.sdr
+@li @c svx.uno
+
+@section toolkit
+
+@li @c toolkit.controls
+
+@section tools
+
+@li @c tools.debug
+@li @c tools.datetime
+@li @c tools.generic
+@li @c tools.memtools
+@li @c tools.rc - resource manager
+@li @c tools.stream - SvStream class
+
+@section ucb
+
+@li @c cmisucp
+@li @c ucb.ucp
+@li @c ucb.ucp.gio
+@li @c ucb.ucp.webdav
+
+@section unotools
+
+@li @c unotools.config
+@li @c unotools.i18n
+@li @c unotools.misc
+@li @c unotools.ucbhelper
+
+@section URE
+
+@li @c rtl.string - ::rtl::OString, ::rtl::OUString, and related functionality
+@li @c salhelper.thread - ::salhelper::Thread class
+
+@section sax
+
+@li @c sax.cppunit
+
+@section stoc
+
+@li @c stoc.corerefl - CoreReflection
+@li @c stoc.tdmanager - TypeDescriptionManager
+
+@section svl
+
+@li @c svl.items
+
+@section VCL
+
+@li @c vcl
+@li @c vcl.a11y
+@li @c vcl.atsui - ATSUI (obsolete) -using code for Mac OS X
+@li @c vcl.control
+@li @c vcl.coretext - CoreText-using code for Mac OS X and iOS
+@li @c vcl.fonts - font-specific code
+@li @c vcl.gdi - the GDI part of VCL, devices, bitmaps, etc.
+@li @c vcl.gtk - Gtk+ 2/3 plugin
+@li @c vcl.headless - bitmap-based backend
+@li @c vcl.kde - KDE
+@li @c vcl.kde4 - KDE4
+@li @c vcl.layout - Widget layout
+@li @c vcl.scrollbar - Scroll Bars
+@li @c vcl.sm - Session Manager
+@li @c vcl.window
+@li @c vcl.unity
+@li @c vcl.virdev
+
+@section Writer
+
+@li @c sw
+@li @c sw.core - Writer core
+@li @c sw.docx
+@li @c sw.envelp
+@li @c sw.level2
+@li @c sw.rtf - .rtf export filter
+@li @c sw.uno - Writer UNO interfaces
+@li @c sw.ww8 - .doc/.docx export filter, .doc import filter (not writerfilter)
+@li @c sw.ww8.level2 - further info for sw.ww8
+
+@section writerfilter
+
+@li @c writerfilter
+@li @c writerfilter.profile - load times of filters
+
+@section xmloff
+
+@li @c xmloff.core
+@li @c xmloff.forms
+@li @c xmloff.chart
+@li @c xmloff.style
+
+@section xmlsecurity
+
+@li @c xmlsecurity.dialogs - xml security dialogs
+@li @c xmlsecurity.helper
+@li @c xmlsecurity.xmlsec - xmlsec wrapper
+
+@section xmlscript
+
+@li @c xmlscript.xmlhelper
+@li @c xmlscript.xmldlg
+@li @c xmlscript.xmlflat
+@li @c xmlscript.xmllib
+@li @c xmlscript.xmlmod
+
+@section dbaccess
+
+@li @c dbaccess
+@li @c dbaccess.ui
+
+@section svx
+
+@li @c svx
+@li @c svx.fmcmop
+
+@section other
+
+@li @c accessibility
+@li @c avmedia
+@li @c basebmp
+@li @c binaryurp
+@li @c bridges
+@li @c comphelper
+@li @c configmgr
+@li @c cppcanvas
+@li @c cppuhelper
+@li @c cppu
+@li @c forms
+@li @c helpcompiler
+@li @c linguistic
+@li @c oox
+@li @c package
+@li @c rsc
+@li @c sax
+@li @c shell
+@li @c stoc
+@li @c svg
+@li @c ucbhelper
+@li @c unoidl
+@li @c uui
+@li @c vbahelper
+@li @c xmlhelp
+@li @c xmloff
+@li @c xmlreader
+
+*/
+/* vim:set ft=cpp shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/log.hxx b/include/sal/log.hxx
new file mode 100644
index 000000000000..6eae1b59d43c
--- /dev/null
+++ b/include/sal/log.hxx
@@ -0,0 +1,317 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SAL_LOG_HXX
+#define INCLUDED_SAL_LOG_HXX
+
+#include "sal/config.h"
+
+#include <cstdlib>
+#include <sstream>
+#include <string>
+
+#include "sal/detail/log.h"
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+// Avoid the use of other sal code in this header as much as possible, so that
+// this code can be called from other sal code without causing endless
+// recursion.
+
+/// @cond INTERNAL
+
+extern "C" SAL_DLLPUBLIC void SAL_CALL sal_detail_log(
+ enum sal_detail_LogLevel level, char const * area, char const * where,
+ char const * message);
+
+namespace sal { namespace detail {
+
+inline void SAL_CALL log(
+ sal_detail_LogLevel level, char const * area, char const * where,
+ std::ostringstream const & stream)
+{
+ // An alternative would be to have sal_detail_log take a std::ostringstream
+ // pointer (via a C void pointer); the advantage would be smaller client
+ // code (the ".str().c_str()" part would move into the implementation of
+ // sal_detail_log) and potential for proper support of embedded null
+ // characters within the message, but the disadvantage would be dependence
+ // on the C++ ABI; as a compromise, the ".str().c_str()" part has been moved
+ // to this inline function so that it is potentially only emitted once per
+ // dynamic library:
+ sal_detail_log(level, area, where, stream.str().c_str());
+}
+
+// Special handling of the common case where the message consists of just a
+// string literal, to produce smaller call-site code:
+
+struct StreamStart {};
+
+struct StreamString {
+ StreamString(char const * s): string(s) {}
+
+ char const * string;
+
+ typedef char Result;
+};
+
+struct StreamIgnore {
+ typedef struct { char a[2]; } Result;
+};
+
+inline StreamString operator <<(
+ SAL_UNUSED_PARAMETER StreamStart const &, char const * s)
+{
+ return StreamString(s);
+}
+
+template< typename T > inline StreamIgnore operator <<(
+ SAL_UNUSED_PARAMETER StreamStart const &, SAL_UNUSED_PARAMETER T const &)
+{
+ std::abort();
+#if defined _MSC_VER && _MSC_VER < 1700
+ return StreamIgnore();
+#endif
+}
+
+template< typename T > inline StreamIgnore operator <<(
+ SAL_UNUSED_PARAMETER StreamString const &, SAL_UNUSED_PARAMETER T const &)
+{
+ std::abort();
+#if defined _MSC_VER && _MSC_VER < 1700
+ return StreamIgnore();
+#endif
+}
+
+template< typename T > inline StreamIgnore operator <<(
+ SAL_UNUSED_PARAMETER StreamIgnore const &, SAL_UNUSED_PARAMETER T const &)
+{
+ std::abort();
+#if defined _MSC_VER && _MSC_VER < 1700
+ return StreamIgnore();
+#endif
+}
+
+template< typename T > typename T::Result getResult(T const &);
+
+inline char const * unwrapStream(StreamString const & s) { return s.string; }
+
+inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) {
+ std::abort();
+#if defined _MSC_VER && _MSC_VER < 1700
+ return 0;
+#endif
+}
+
+} }
+
+#define SAL_DETAIL_LOG_STREAM(condition, level, area, where, stream) \
+ do { \
+ if (condition) { \
+ if (sizeof ::sal::detail::getResult( \
+ ::sal::detail::StreamStart() << stream) == 1) \
+ { \
+ ::sal_detail_log( \
+ (level), (area), (where), \
+ ::sal::detail::unwrapStream( \
+ ::sal::detail::StreamStart() << stream)); \
+ } else { \
+ ::std::ostringstream sal_detail_stream; \
+ sal_detail_stream << stream; \
+ ::sal::detail::log( \
+ (level), (area), (where), sal_detail_stream); \
+ } \
+ } \
+ } while (false)
+
+/// @endcond
+
+/** A simple macro to create a "file and line number" string.
+
+ Potentially not only useful within the log framework (where it is used
+ automatically), but also when creating exception messages.
+
+ @attention For now, this functionality should only be used internally within
+ LibreOffice. It may change again in a future version.
+
+ @since LibreOffice 3.5
+*/
+#define SAL_WHERE SAL_DETAIL_WHERE
+
+/** A facility for generating temporary string messages by piping items into a
+ C++ std::ostringstream.
+
+ This can be useful for example in a call to SAL_INFO when depending on some
+ boolean condition data of incompatible types shall be streamed into the
+ message, as in:
+
+ SAL_INFO("foo", "object: " << (hasName ? obj->name : SAL_STREAM(obj)));
+
+ @attention For now, this functionality should only be used internally within
+ LibreOffice. It may change again in a future version.
+
+ @since LibreOffice 3.5
+*/
+#define SAL_STREAM(stream) \
+ (dynamic_cast< ::std::ostringstream & >(::std::ostringstream() << stream). \
+ str())
+
+/**
+ @page sal_log Basic logging functionality.
+
+ @short Macros for logging.
+
+ SAL_INFO(char const * area, expr),
+ SAL_INFO_IF(bool condition, char const * area, expr),
+ SAL_WARN(char const * area, expr),
+ SAL_WARN_IF(bool condition, char const * area, expr), and SAL_DEBUG(expr)
+ produce an info, warning, or debug log entry with a message produced by
+ piping items into a C++ std::ostringstream. The given expr must be so that
+ the full expression "stream << expr" is valid, where stream is a variable of
+ type std::ostringstream.
+
+ SAL_INFO("foo", "string " << s << " of length " << n)
+
+ would be an example of such a call.
+
+ The composed message should be in UTF-8 and it should contain no vertical
+ formatting characters and no null characters
+
+ For the _IF variants, log output is only generated if the given condition is
+ true (in addition to the other conditions that have to be met).
+
+ The SAL_DEBUG macro is for temporary debug statements that are used while
+ working on code. It is never meant to remain in the code. It will always
+ simply output the given expression in debug builds.
+
+ For all the other macros, the given area argument must be non-null and must
+ match the regular expression
+
+ @verbatim
+ <area> ::= <segment>("."<segment>)*
+ @endverbatim
+
+ with
+
+ @verbatim
+ <segment> ::= [0-9a-z]+
+ @endverbatim
+
+ For a list of areas used see @ref sal_log_areas "SAL debug areas". Whenever
+ you use a new log area, add it to the file sal/inc/sal/log-areas.dox .
+
+ Whether these macros generate any log output is controlled in a two-stage
+ process.
+
+ First, at compile time the macros SAL_LOG_INFO and SAL_LOG_WARN,
+ respectively, control whether the INFO and WARN macros, respectively,
+ expand to actual code (in case the macro is defined, to any value) or to
+ no-ops (in case the macro is not defined).
+
+ Second, at runtime the environment variable SAL_LOG further limits which
+ macro calls actually generate log output. The environment variable SAL_LOG
+ must either be unset or must match the regular expression
+
+ @verbatim
+ <env> ::= <switch>*
+ @endverbatim
+
+ with
+
+ @verbatim
+ <switch> ::= <sense><level>("."<area>)?
+ <sense> ::= "+"|"-"
+ <level> ::= "INFO"|"WARN"
+ @endverbatim
+
+ If the environment variable is unset, "+WARN" is used instead (which results
+ in all warnings being output but no infos). If the given value does not
+ match the regular expression, "+INFO+WARN" is used instead (which in turn
+ results in everything being output).
+
+ A given macro call's level (INFO or WARN) and area is matched against the
+ given switches as follows: Only those switches for which the level matches
+ the given level and for which the area is a prefix (including both empty and
+ full prefixes) of the given area are considered. Log output is generated if
+ and only if among the longest such switches (if any), there is at least one
+ that has a sense of "+". (That is, if both +INFO.foo and -INFO.foo are
+ present, +INFO.foo wins.)
+
+ For example, if SAL_LOG is "+INFO-INFO.foo+INFO.foo.bar", then calls like
+ SAL_INFO("foo.bar", ...), SAL_INFO("foo.bar.baz", ...), or
+ SAL_INFO("other", ...) generate output, while calls like
+ SAL_INFO("foo", ...) or SAL_INFO("foo.barzzz", ...) do not.
+
+ The generated log output consists of the given level ("info" or "warn"), the
+ given area, the process ID, the thread ID, the source file, and the source
+ line number, each followed by a colon, followed by a space, the given
+ message, and a newline. The precise format of the log output is subject to
+ change. The log output is printed to stderr without further text encoding
+ conversion.
+
+ @see @ref sal_log_areas
+
+ @attention For now, this functionality should only be used internally within
+ LibreOffice. It may change again in a future version.
+
+ @since LibreOffice 3.5
+*/
+
+/**
+ Produce log entry from stream in the given log area.
+
+ See @ref sal_log "basic logging functionality" for details.
+*/
+#define SAL_INFO(area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ SAL_DETAIL_ENABLE_LOG_INFO, ::SAL_DETAIL_LOG_LEVEL_INFO, area, \
+ SAL_WHERE, stream)
+
+/**
+ Produce log entry from stream in the given log area if condition is true.
+
+ See @ref sal_log "basic logging functionality" for details.
+*/
+#define SAL_INFO_IF(condition, area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ SAL_DETAIL_ENABLE_LOG_INFO && (condition), \
+ ::SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, stream)
+
+/**
+ Produce warning entry from stream in the given log area.
+
+ See @ref sal_log "basic logging functionality" for details.
+*/
+#define SAL_WARN(area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ SAL_DETAIL_ENABLE_LOG_WARN, ::SAL_DETAIL_LOG_LEVEL_WARN, area, \
+ SAL_WHERE, stream)
+
+/**
+ Produce warning entry from stream in the given log area if condition is true.
+
+ See @ref sal_log "basic logging functionality" for details.
+*/
+#define SAL_WARN_IF(condition, area, stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ SAL_DETAIL_ENABLE_LOG_WARN && (condition), \
+ ::SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, stream)
+
+/**
+ Produce temporary debugging output from stream. This macro is meant to be
+ used only while working on code and should never exist in production code.
+
+ See @ref sal_log "basic logging functionality" for details.
+*/
+#define SAL_DEBUG(stream) \
+ SAL_DETAIL_LOG_STREAM( \
+ SAL_LOG_TRUE, ::SAL_DETAIL_LOG_LEVEL_DEBUG, 0, 0, stream)
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/macros.h b/include/sal/macros.h
new file mode 100644
index 000000000000..262f81996657
--- /dev/null
+++ b/include/sal/macros.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _SAL_MACROS_H_
+#define _SAL_MACROS_H_
+
+#include <stddef.h>
+
+#ifndef SAL_N_ELEMENTS
+# if defined(__cplusplus) && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L )
+ /*
+ * Magic template to calculate at compile time the number of elements
+ * in an array. Enforcing that the argument must be a array and not
+ * a pointer, e.g.
+ * char *pFoo="foo";
+ * SAL_N_ELEMENTS(pFoo);
+ * fails while
+ * SAL_N_ELEMENTS("foo");
+ * or
+ * char aFoo[]="foo";
+ * SAL_N_ELEMENTS(aFoo);
+ * pass
+ *
+ * Unfortunately if arr is an array of an anonymous class then we need
+ * C++0x, i.e. see
+ * http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#757
+ */
+ template <typename T, size_t S> char (&sal_n_array_size( T(&)[S] ))[S];
+# define SAL_N_ELEMENTS(arr) (sizeof(sal_n_array_size(arr)))
+# else
+# define SAL_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
+# endif
+#endif
+
+#ifndef SAL_BOUND
+# define SAL_BOUND(x,l,h) ((x) <= (l) ? (l) : ((x) >= (h) ? (h) : (x)))
+#endif
+
+#ifndef SAL_ABS
+# define SAL_ABS(a) (((a) < 0) ? (-(a)) : (a))
+#endif
+
+#ifndef SAL_STRINGIFY
+# define SAL_STRINGIFY_ARG(x) #x
+# define SAL_STRINGIFY(x) SAL_STRINGIFY_ARG(x)
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/main.h b/include/sal/main.h
new file mode 100644
index 000000000000..634b57cac534
--- /dev/null
+++ b/include/sal/main.h
@@ -0,0 +1,149 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _SAL_MAIN_H_
+#define _SAL_MAIN_H_
+
+#include "sal/config.h"
+
+#include "sal/saldllapi.h"
+#include "sal/types.h"
+
+#if defined AIX
+#include <unistd.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SAL_DLLPUBLIC void SAL_CALL sal_detail_initialize(int argc, char ** argv);
+SAL_DLLPUBLIC void SAL_CALL sal_detail_deinitialize();
+
+#if defined IOS || defined ANDROID
+
+#error No code that includes this should be built for iOS or Android
+
+#else
+
+#define SAL_MAIN_WITH_ARGS_IMPL \
+int SAL_CALL main(int argc, char ** argv) \
+{ \
+ int ret; \
+ sal_detail_initialize(argc, argv); \
+ ret = sal_main_with_args(argc, argv); \
+ sal_detail_deinitialize(); \
+ return ret; \
+}
+
+#define SAL_MAIN_IMPL \
+int SAL_CALL main(int argc, char ** argv) \
+{ \
+ int ret; \
+ sal_detail_initialize(argc, argv); \
+ ret = sal_main(); \
+ sal_detail_deinitialize(); \
+ return ret; \
+}
+
+#endif
+
+
+/* Definition macros for CRT entries */
+
+#ifdef SAL_W32
+
+#include <stdlib.h>
+
+/* Sorry but this is neccessary cause HINSTANCE is a typedef that differs (C++ causes an error) */
+
+#ifndef WINAPI
+# define WINAPI __stdcall
+#endif
+
+#if !defined(DECLARE_HANDLE)
+# ifdef STRICT
+ typedef void *HANDLE;
+# define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
+# else
+ typedef void *PVOID;
+ typedef PVOID HANDLE;
+# define DECLARE_HANDLE(name) typedef HANDLE name
+# endif
+DECLARE_HANDLE(HINSTANCE);
+#endif
+
+
+
+#define SAL_WIN_WinMain \
+int WINAPI WinMain( HINSTANCE _hinst, HINSTANCE _dummy, char* _cmdline, int _nshow ) \
+{ \
+ int argc = __argc; char ** argv = __argv; \
+ (void) _hinst; (void) _dummy; (void) _cmdline; (void) _nshow; /* unused */ \
+ return main(argc, argv); \
+}
+
+#else /* ! SAL_W32 */
+
+# define SAL_WIN_WinMain
+
+#endif /* ! SAL_W32 */
+
+/* Implementation macro */
+
+#define SAL_IMPLEMENT_MAIN_WITH_ARGS(_argc_, _argv_) \
+ static int SAL_CALL sal_main_with_args (int _argc_, char ** _argv_); \
+ SAL_MAIN_WITH_ARGS_IMPL \
+ SAL_WIN_WinMain \
+ static int SAL_CALL sal_main_with_args(int _argc_, char ** _argv_)
+
+#define SAL_IMPLEMENT_MAIN() \
+ static int SAL_CALL sal_main(void); \
+ SAL_MAIN_IMPL \
+ SAL_WIN_WinMain \
+ static int SAL_CALL sal_main(void)
+
+/*
+ "How to use" Examples:
+
+ #include <sal/main.h>
+
+ SAL_IMPLEMENT_MAIN()
+ {
+ DoSomething();
+
+ return 0;
+ }
+
+ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
+ {
+ DoSomethingWithArgs(argc, argv);
+
+ return 0;
+ }
+
+*/
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* _SAL_MAIN_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/mathconf.h b/include/sal/mathconf.h
new file mode 100644
index 000000000000..fefd213e3684
--- /dev/null
+++ b/include/sal/mathconf.h
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SAL_MATHCONF_H
+#define INCLUDED_SAL_MATHCONF_H
+
+#include "osl/endian.h"
+
+#include <float.h>
+
+#if defined SOLARIS
+#include <ieeefp.h>
+#endif /* SOLARIS */
+
+#if defined(__cplusplus) && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L )
+#include <cmath>
+#endif
+
+#if defined(IOS)
+#if defined(__cplusplus)
+#include <cmath>
+#else
+#include <math.h>
+#endif
+#endif
+
+#if defined __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Generally, the C standard guarantees that at program startup, "trapping or
+ stopping (if supported) is disabled on all [floating-point] exceptions"
+ (F.7.3/1 of the August 3, 1998 draft of C99), and that during program
+ execution, "a programmer can safely assume default modes (or be unaware of
+ them)" (7.6/2, footnote 161 of the August 3, 1998 draft of C99). Reportedly,
+ on Windows there are printer drivers that switch on exceptions. To avoid
+ problems, the SAL_MATH_FPEXCEPTIONS_OFF macro can be used to explicitly
+ switch off exceptions (on Windows).
+ */
+#if defined WNT
+#define SAL_MATH_FPEXCEPTIONS_OFF() _control87( _MCW_EM, _MCW_EM )
+#else /* WNT */
+#define SAL_MATH_FPEXCEPTIONS_OFF()
+#endif /* WNT */
+
+
+/* SAL_MATH_FINITE(d): test double d on INFINITY, NaN et al. */
+#if !defined SOLARIS && !defined ANDROID \
+ && defined(__cplusplus) \
+ && ( defined(__GXX_EXPERIMENTAL_CXX0X__) \
+ || __cplusplus >= 201103L \
+ || defined(IOS) )
+#define SAL_MATH_FINITE(d) std::isfinite(d)
+#elif defined( IOS )
+#define SAL_MATH_FINITE(d) isfinite(d)
+#elif defined( WNT)
+#define SAL_MATH_FINITE(d) _finite(d)
+#elif defined LINUX || defined UNX
+#define SAL_MATH_FINITE(d) finite(d)
+#else /* WNT, LINUX, UNX */
+#error "SAL_MATH_FINITE not defined"
+#endif /* WNT, LINUX, UNX */
+
+
+/* This needs to be fixed for non--IEEE-754 platforms: */
+#if 1 /* IEEE 754 supported */
+#if defined OSL_BIGENDIAN
+
+/* IEEE 754 double structures for BigEndian */
+union sal_math_Double
+{
+ struct
+ {
+ unsigned sign : 1;
+ unsigned exponent :11;
+ unsigned fraction_hi :20;
+ unsigned fraction_lo :32;
+ } inf_parts;
+ struct
+ {
+ unsigned sign : 1;
+ unsigned exponent :11;
+ unsigned qnan_bit : 1;
+ unsigned bits :19;
+ unsigned fraction_lo :32;
+ } nan_parts;
+ struct
+ {
+ unsigned msw :32;
+ unsigned lsw :32;
+ } w32_parts;
+ double value;
+};
+
+#elif defined OSL_LITENDIAN
+
+/* IEEE 754 double structures for LittleEndian */
+union sal_math_Double
+{
+ struct {
+ unsigned fraction_lo :32;
+ unsigned fraction_hi :20;
+ unsigned exponent :11;
+ unsigned sign : 1;
+ } inf_parts;
+ struct {
+ unsigned fraction_lo :32;
+ unsigned bits :19;
+ unsigned qnan_bit : 1;
+ unsigned exponent :11;
+ unsigned sign : 1;
+ } nan_parts;
+ struct
+ {
+ unsigned lsw :32;
+ unsigned msw :32;
+ } w32_parts;
+ double value;
+};
+
+#else /* OSL_BIGENDIAN, OSL_LITENDIAN */
+
+#error "neither OSL_BIGENDIAN nor OSL_LITENDIAN"
+
+#endif /* OSL_BIGENDIAN, OSL_LITENDIAN */
+#else /* IEEE 754 supported */
+
+#error "don't know how to handle IEEE 754"
+
+#endif /* IEEE 754 supported */
+
+
+#if defined __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* INCLUDED_SAL_MATHCONF_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/saldllapi.h b/include/sal/saldllapi.h
new file mode 100644
index 000000000000..f45e50e1cc5b
--- /dev/null
+++ b/include/sal/saldllapi.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SALDLLAPI_H
+#define INCLUDED_SALDLLAPI_H
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+#if defined(SAL_DLLIMPLEMENTATION)
+#define SAL_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define SAL_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif /* INCLUDED_SALDLLAPI_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/types.h b/include/sal/types.h
new file mode 100644
index 000000000000..55f2e729ac8b
--- /dev/null
+++ b/include/sal/types.h
@@ -0,0 +1,566 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _SAL_TYPES_H_
+#define _SAL_TYPES_H_
+
+#include <sal/config.h>
+#include <sal/macros.h>
+
+#include <sal/typesizes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/********************************************************************************/
+/* Data types
+*/
+
+/* Boolean */
+typedef unsigned char sal_Bool;
+# define sal_False ((sal_Bool)0)
+# define sal_True ((sal_Bool)1)
+
+/* char is assumed to always be 1 byte long */
+typedef signed char sal_Int8;
+typedef unsigned char sal_uInt8;
+
+#if SAL_TYPES_SIZEOFSHORT == 2
+ typedef signed short sal_Int16;
+ typedef unsigned short sal_uInt16;
+#else
+ #error "Could not find 16-bit type, add support for your architecture"
+#endif
+
+#if SAL_TYPES_SIZEOFLONG == 4
+ typedef signed long sal_Int32;
+ typedef unsigned long sal_uInt32;
+ #define SAL_PRIdINT32 "ld"
+ #define SAL_PRIuUINT32 "lu"
+ #define SAL_PRIxUINT32 "lx"
+ #define SAL_PRIXUINT32 "lX"
+#elif SAL_TYPES_SIZEOFINT == 4
+ typedef signed int sal_Int32;
+ typedef unsigned int sal_uInt32;
+ #define SAL_PRIdINT32 "d"
+ #define SAL_PRIuUINT32 "u"
+ #define SAL_PRIxUINT32 "x"
+ #define SAL_PRIXUINT32 "X"
+#else
+ #error "Could not find 32-bit type, add support for your architecture"
+#endif
+
+#ifdef _MSC_VER
+ typedef __int64 sal_Int64;
+ typedef unsigned __int64 sal_uInt64;
+
+ /* The following are macros that will add the 64 bit constant suffix. */
+ #define SAL_CONST_INT64(x) x##i64
+ #define SAL_CONST_UINT64(x) x##ui64
+
+ #define SAL_PRIdINT64 "I64d"
+ #define SAL_PRIuUINT64 "I64u"
+ #define SAL_PRIxUINT64 "I64x"
+ #define SAL_PRIXUINT64 "I64X"
+#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C) || defined (__GNUC__) || defined (sgi)
+ #if SAL_TYPES_SIZEOFLONG == 8
+ typedef signed long int sal_Int64;
+ typedef unsigned long int sal_uInt64;
+
+
+ /* The following are macros that will add the 64 bit constant suffix. */
+ #define SAL_CONST_INT64(x) x##l
+ #define SAL_CONST_UINT64(x) x##ul
+
+ #define SAL_PRIdINT64 "ld"
+ #define SAL_PRIuUINT64 "lu"
+ #define SAL_PRIxUINT64 "lx"
+ #define SAL_PRIXUINT64 "lX"
+ #elif SAL_TYPES_SIZEOFLONGLONG == 8
+ typedef signed long long sal_Int64;
+ typedef unsigned long long sal_uInt64;
+
+ /* The following are macros that will add the 64 bit constant suffix. */
+ #define SAL_CONST_INT64(x) x##ll
+ #define SAL_CONST_UINT64(x) x##ull
+
+ #ifdef __MINGW32__
+ #define SAL_PRIdINT64 "I64d"
+ #define SAL_PRIuUINT64 "I64u"
+ #define SAL_PRIxUINT64 "I64x"
+ #define SAL_PRIXUINT64 "I64X"
+ #else
+ #define SAL_PRIdINT64 "lld"
+ #define SAL_PRIuUINT64 "llu"
+ #define SAL_PRIxUINT64 "llx"
+ #define SAL_PRIXUINT64 "llX"
+ #endif
+ #else
+ #error "Could not find 64-bit type, add support for your architecture"
+ #endif
+#else
+ #error "Please define the 64-bit types for your architecture/compiler in sal/inc/sal/types.h"
+#endif
+
+typedef char sal_Char;
+typedef signed char sal_sChar;
+typedef unsigned char sal_uChar;
+
+#if ( defined(SAL_W32) && !defined(__MINGW32__) )
+ // http://msdn.microsoft.com/en-us/library/s3f49ktz%28v=vs.80%29.aspx
+ // "By default wchar_t is a typedef for unsigned short."
+ // But MinGW has a native wchar_t, and on many places, we cannot deal with
+ // that, so sal_Unicode has to be explicitly typedef'd as sal_uInt16 there.
+ typedef wchar_t sal_Unicode;
+#else
+ #define SAL_UNICODE_NOTEQUAL_WCHAR_T
+ typedef sal_uInt16 sal_Unicode;
+#endif
+
+typedef void * sal_Handle;
+
+/* sal_Size should currently be the native width of the platform */
+#if SAL_TYPES_SIZEOFPOINTER == 4
+ typedef sal_uInt32 sal_Size;
+ typedef sal_Int32 sal_sSize;
+#elif SAL_TYPES_SIZEOFPOINTER == 8
+ typedef sal_uInt64 sal_Size;
+ typedef sal_Int64 sal_sSize;
+#else
+ #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
+#endif
+
+/* sal_PtrDiff holds the result of a pointer subtraction */
+#if SAL_TYPES_SIZEOFPOINTER == 4
+ typedef sal_Int32 sal_PtrDiff;
+#elif SAL_TYPES_SIZEOFPOINTER == 8
+ typedef sal_Int64 sal_PtrDiff;
+#else
+ #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
+#endif
+
+/* printf-style conversion specification length modifiers for size_t and
+ ptrdiff_t (most platforms support C99, MSC has its own extension) */
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ #define SAL_PRI_SIZET "I"
+ #define SAL_PRI_PTRDIFFT "I"
+#else
+ #define SAL_PRI_SIZET "z"
+ #define SAL_PRI_PTRDIFFT "t"
+#endif
+
+/* sal_IntPtr, sal_uIntPtr are integer types designed to hold pointers so that any valid
+ * pointer to void can be converted to this type and back to a pointer to void and the
+ * result will compare to the original pointer */
+#if SAL_TYPES_SIZEOFPOINTER == 4
+ typedef sal_Int32 sal_IntPtr;
+ typedef sal_uInt32 sal_uIntPtr;
+ #define SAL_PRIdINTPTR SAL_PRIdINT32
+ #define SAL_PRIuUINTPTR SAL_PRIuUINT32
+ #define SAL_PRIxUINTPTR SAL_PRIxUINT32
+ #define SAL_PRIXUINTPTR SAL_PRIXUINT32
+#elif SAL_TYPES_SIZEOFPOINTER == 8
+ typedef sal_Int64 sal_IntPtr;
+ typedef sal_uInt64 sal_uIntPtr;
+ #define SAL_PRIdINTPTR SAL_PRIdINT64
+ #define SAL_PRIuUINTPTR SAL_PRIuUINT64
+ #define SAL_PRIxUINTPTR SAL_PRIxUINT64
+ #define SAL_PRIXUINTPTR SAL_PRIXUINT64
+#else
+ #error "Please make sure SAL_TYPES_SIZEOFPOINTER is defined for your architecture/compiler"
+#endif
+
+/********************************************************************************/
+/* Useful defines
+ */
+
+/* The following SAL_MIN_INTn defines codify the assumption that the signed
+ * sal_Int types use two's complement representation. Defining them as
+ * "-0x7F... - 1" instead of as "-0x80..." prevents warnings about applying the
+ * unary minus operator to unsigned quantities.
+ */
+#define SAL_MIN_INT8 ((sal_Int8) (-0x7F - 1))
+#define SAL_MAX_INT8 ((sal_Int8) 0x7F)
+#define SAL_MAX_UINT8 ((sal_uInt8) 0xFF)
+#define SAL_MIN_INT16 ((sal_Int16) (-0x7FFF - 1))
+#define SAL_MAX_INT16 ((sal_Int16) 0x7FFF)
+#define SAL_MAX_UINT16 ((sal_uInt16) 0xFFFF)
+#define SAL_MIN_INT32 ((sal_Int32) (-0x7FFFFFFF - 1))
+#define SAL_MAX_INT32 ((sal_Int32) 0x7FFFFFFF)
+#define SAL_MAX_UINT32 ((sal_uInt32) 0xFFFFFFFF)
+#define SAL_MIN_INT64 ((sal_Int64) (SAL_CONST_INT64(-0x7FFFFFFFFFFFFFFF) - 1))
+#define SAL_MAX_INT64 ((sal_Int64) SAL_CONST_INT64(0x7FFFFFFFFFFFFFFF))
+#define SAL_MAX_UINT64 ((sal_uInt64) SAL_CONST_UINT64(0xFFFFFFFFFFFFFFFF))
+
+#if SAL_TYPES_SIZEOFLONG == 4
+#define SAL_MAX_SSIZE SAL_MAX_INT32
+#define SAL_MAX_SIZE SAL_MAX_UINT32
+#elif SAL_TYPES_SIZEOFLONG == 8
+#define SAL_MAX_SSIZE SAL_MAX_INT64
+#define SAL_MAX_SIZE SAL_MAX_UINT64
+#endif
+
+#if defined(SAL_W32) || defined(SAL_UNX)
+# define SAL_MAX_ENUM 0x7fffffff
+#endif
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
+# define SAL_DLLPUBLIC_EXPORT __declspec(dllexport)
+# define SAL_JNI_EXPORT __declspec(dllexport)
+#if defined(_MSC_VER)
+# define SAL_DLLPUBLIC_IMPORT __declspec(dllimport)
+#else
+# define SAL_DLLPUBLIC_IMPORT
+#endif // defined(_MSC_VER)
+# define SAL_DLLPRIVATE
+# define SAL_DLLPUBLIC_TEMPLATE
+# define SAL_CALL __cdecl
+# define SAL_CALL_ELLIPSE __cdecl
+#elif defined SAL_UNX
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x550)
+# define SAL_DLLPUBLIC_EXPORT __global
+# define SAL_JNI_EXPORT __global
+# define SAL_DLLPUBLIC_IMPORT
+# define SAL_DLLPRIVATE __hidden
+# define SAL_DLLPUBLIC_TEMPLATE
+# elif defined(__SUNPRO_C ) && (__SUNPRO_C >= 0x550)
+# define SAL_DLLPUBLIC_EXPORT __global
+# define SAL_JNI_EXPORT __global
+# define SAL_DLLPUBLIC_IMPORT
+# define SAL_DLLPRIVATE __hidden
+# define SAL_DLLPUBLIC_TEMPLATE
+# elif defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE)
+# if defined(DISABLE_DYNLOADING)
+# define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("hidden")))
+# define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
+# define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("hidden")))
+# define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
+# define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("hidden")))
+# else
+# define SAL_DLLPUBLIC_EXPORT __attribute__ ((visibility("default")))
+# define SAL_JNI_EXPORT __attribute__ ((visibility("default")))
+# define SAL_DLLPUBLIC_IMPORT __attribute__ ((visibility("default")))
+# define SAL_DLLPRIVATE __attribute__ ((visibility("hidden")))
+# define SAL_DLLPUBLIC_TEMPLATE __attribute__ ((visibility("default")))
+# endif
+# else
+# define SAL_DLLPUBLIC_EXPORT
+# define SAL_JNI_EXPORT
+# define SAL_DLLPUBLIC_IMPORT
+# define SAL_DLLPRIVATE
+# define SAL_DLLPUBLIC_TEMPLATE
+# endif
+# define SAL_CALL
+# define SAL_CALL_ELLIPSE
+#else
+# error("unknown platform")
+#endif
+
+/**
+ Exporting the symbols necessary for exception handling on GCC.
+
+ These macros are used for inline declarations of exception classes, as in
+ rtl/malformeduriexception.hxx.
+*/
+#if defined(__GNUC__) && ! defined(__MINGW32__)
+# if defined(DISABLE_DYNLOADING)
+# define SAL_EXCEPTION_DLLPUBLIC_EXPORT __attribute__((visibility("default")))
+# else
+# define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT
+# endif
+# define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE
+#else
+# define SAL_EXCEPTION_DLLPUBLIC_EXPORT
+# define SAL_EXCEPTION_DLLPRIVATE
+#endif
+
+/** Use this as markup for functions and methods whose return value must be
+ checked.
+
+ Compilers that support a construct of this nature will emit a compile
+ time warning on unchecked return value.
+*/
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
+# define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#else
+# define SAL_WARN_UNUSED_RESULT
+#endif
+
+/** Use this for pure virtual classes, e.g. class SAL_NO_VTABLE Foo { ...
+ This hinders the compiler from setting a generic vtable stating that
+ a pure virtual function was called and thus slightly reduces code size.
+*/
+#ifdef _MSC_VER
+# define SAL_NO_VTABLE __declspec(novtable)
+#else
+# define SAL_NO_VTABLE
+#endif
+
+#ifdef SAL_W32
+# pragma pack(push, 8)
+#endif
+
+/** This is the binary specification of a SAL sequence.
+ <br>
+*/
+typedef struct _sal_Sequence
+{
+ /** reference count of sequence<br>
+ */
+ sal_Int32 nRefCount;
+ /** element count<br>
+ */
+ sal_Int32 nElements;
+ /** elements array<br>
+ */
+ char elements[1];
+} sal_Sequence;
+
+#define SAL_SEQUENCE_HEADER_SIZE ((sal_Size)&((sal_Sequence *)0)->elements)
+
+#if defined( SAL_W32)
+#pragma pack(pop)
+#endif
+
+/** Definition of function throw clause macros. These have been introduced
+ to reduce code size by balancing out compiler bugs.
+
+ These macros are ONLY for function declarations,
+ use common C++ throw statement for throwing exceptions, e.g.
+ throw RuntimeException();
+
+ SAL_THROW() should be used for all C++ functions, e.g. SAL_THROW(())
+ SAL_THROW_EXTERN_C() should be used for all C functions
+*/
+#ifdef __cplusplus
+#if defined(__GNUC__) || defined(__SUNPRO_CC) || defined(__sgi)
+#define SAL_THROW( exc )
+#else /* MSVC, all other */
+#define SAL_THROW( exc ) throw exc
+#endif /* __GNUC__, __SUNPRO_CC */
+#define SAL_THROW_EXTERN_C() throw ()
+#else /* ! __cplusplus */
+/* SAL_THROW() must not be used in C headers, only SAL_THROW_EXTERN_C() is defined */
+#define SAL_THROW_EXTERN_C()
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#ifdef __cplusplus
+
+enum __sal_NoAcquire
+{
+ /** definition of a no acquire enum for ctors
+ */
+ SAL_NO_ACQUIRE
+};
+
+namespace com { namespace sun { namespace star { } } }
+
+/** short-circuit extra-verbose API namespaces
+
+ @since LibreOffice 4.0
+*/
+namespace css = ::com::sun::star;
+
+/** C++11 "= delete" feature.
+
+ With HAVE_CXX11_DELETE, calling a deleted function will cause a compile-time
+ error, while otherwise it will only cause a link-time error as the declared
+ function is not defined.
+
+ @since LibreOffice 4.1
+*/
+#if HAVE_CXX11_DELETE
+#define SAL_DELETED_FUNCTION = delete
+#else
+#define SAL_DELETED_FUNCTION
+#endif
+
+/** C++11 "override" feature.
+
+ With HAVE_CXX11_OVERRIDE, force the method to override a existing method in
+ parent, error out if the method with the correct signature does not exist.
+
+ @since LibreOffice 4.1
+*/
+#if HAVE_CXX11_OVERRIDE
+#define SAL_OVERRIDE override
+#else
+#define SAL_OVERRIDE
+#endif
+
+/** C++11 "final" feature.
+
+ With HAVE_CXX11_FINAL, mark a class as non-derivable or a method as non-overridable.
+
+ @since LibreOffice 4.1
+*/
+#if HAVE_CXX11_FINAL
+#define SAL_FINAL final
+#else
+#define SAL_FINAL
+#endif
+
+#endif /* __cplusplus */
+
+#ifdef __cplusplus
+
+namespace sal {
+
+/**
+ A static_cast between integral types, to avoid C++ compiler warnings.
+
+ In C++ source code, use sal::static_int_cast<T>(n) instead of
+ static_cast<T>(n) whenever a compiler warning about integral type problems
+ shall be silenced. That way, source code that needs to be modified when the
+ type of any of the expressions involved in the compiler warning is changed
+ can be found more easily.
+
+ Both template arguments T1 and T2 must be integral types.
+*/
+template< typename T1, typename T2 > inline T1 static_int_cast(T2 n) {
+ return static_cast< T1 >(n);
+}
+
+}
+
+#else /* __cplusplus */
+
+/**
+ A cast between integer types, to avoid C compiler warnings.
+
+ In C source code, use SAL_INT_CAST(type, expr) instead of ((type) (expr))
+ whenever a compiler warning about integer type problems shall be silenced.
+ That way, source code that needs to be modified when the type of any of the
+ expressions involved in the compiler warning is changed can be found more
+ easily.
+
+ The argument 'type' must be an integer type and the argument 'expr' must be
+ an integer expression. Both arguments are evaluated exactly once.
+*/
+#define SAL_INT_CAST(type, expr) ((type) (expr))
+
+#endif /* __cplusplus */
+
+/**
+ Use as follows:
+ SAL_DEPRECATED("Dont use, its evil.") void doit(int nPara);
+*/
+
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
+# define SAL_DEPRECATED(message) __attribute__((deprecated(message)))
+#elif (__GNUC__)
+# define SAL_DEPRECATED(message) __attribute__((deprecated))
+#elif defined(_MSC_VER)
+# define SAL_DEPRECATED(message) __declspec(deprecated(message))
+#else
+# define SAL_DEPRECATED(message)
+#endif
+
+/**
+ This macro is used to tag interfaces that are deprecated for both
+ internal and external API users, but where we are still writing
+ out the internal usage. Ultimately these should be replaced by
+ SAL_DEPRECATED, and then removed.
+
+ Use as follows:
+ SAL_DEPRECATED_INTERNAL("Dont use, its evil.") void doit(int nPara);
+ */
+#ifdef LIBO_INTERNAL_ONLY
+# define SAL_DEPRECATED_INTERNAL(message)
+#else
+# define SAL_DEPRECATED_INTERNAL(message) SAL_DEPRECATED(message)
+#endif
+
+/**
+ Use as follows:
+ SAL_WNODEPRECATED_DECLARATIONS_PUSH
+ \::std::auto_ptr<X> ...
+ SAL_WNODEPRECATED_DECLARATIONS_POP
+*/
+
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
+#define SAL_WNODEPRECATED_DECLARATIONS_PUSH \
+ _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic push)) \
+ _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic ignored "-Wdeprecated-declarations"))
+#define SAL_WNODEPRECATED_DECLARATIONS_POP \
+ _Pragma(SAL_STRINGIFY_ARG(GCC diagnostic pop))
+#else
+# define SAL_WNODEPRECATED_DECLARATIONS_PUSH
+# define SAL_WNODEPRECATED_DECLARATIONS_POP
+#endif
+
+/** Annotate unused but required C++ function parameters.
+
+ An unused parameter is required if the function needs to adhere to a given
+ type (e.g., if its address is assigned to a function pointer of a specific
+ type, or if it is called from template code). This annotation helps static
+ analysis tools suppress false warnings. In the case of virtual functions
+ (where unused required parameters are common, too), the annotation is not
+ required (as static analysis tools can themselves derive the information
+ whether a function is virtual).
+
+ Use the annotation in function definitions like
+
+ void f(SAL_UNUSED_PARAMETER int) {}
+
+ C does not allow unnamed parameters, anyway, so a function definition like
+ the above needs to be written there as
+
+ void f(int dummy) { (void) dummy; / * avoid warnings * / }
+
+ without a SAL_UNUSED_PARAMETER annotation.
+
+ @since LibreOffice 3.6
+ */
+#if defined __cplusplus
+#if defined __GNUC__
+#define SAL_UNUSED_PARAMETER __attribute__ ((unused))
+#else
+#define SAL_UNUSED_PARAMETER
+#endif
+#endif
+
+/**
+
+ Annotate classes where a compiler should warn if an instance is unused.
+
+ The compiler cannot warn about unused instances if they have non-trivial
+ or external constructors or destructors. Classes marked with SAL_WARN_UNUSED
+ will be warned about.
+
+ Currently implemented by a Clang compiler plugin.
+
+ @since LibreOffice 4.0
+
+*/
+
+#if defined __clang__
+#define SAL_WARN_UNUSED __attribute__((annotate("lo_warn_unused")))
+#else
+#define SAL_WARN_UNUSED
+#endif
+
+#endif /*_SAL_TYPES_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sal/typesizes.h b/include/sal/typesizes.h
new file mode 100644
index 000000000000..e981818b9ced
--- /dev/null
+++ b/include/sal/typesizes.h
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+/* DO NOT INCLUDE THIS HEADER DIRECTLY!
+ *
+ * It is only needed to make the build work. config_typesizes.h is
+ * copied to SDK as sal/typesizes.h and this is how sal/types.h includes
+ * it. This means we need to have sal/typesizes.h available for build
+ * too.
+ */
+
+#include "config_typesizes.h"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */