calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / unx / generic / app / geninst.cxx
blob191d87ca76b70f8944198a54608c80bd16f4f471
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
22 #if defined(LINUX)
23 # include <stdio.h>
24 #endif
25 #if defined(__FreeBSD__)
26 # include <sys/utsname.h>
27 #endif
29 #include <config_features.h>
30 #if HAVE_FEATURE_OPENGL
31 #include <vcl/opengl/OpenGLContext.hxx>
32 #endif
33 #include <unx/geninst.h>
34 #include <o3tl/string_view.hxx>
36 // SalYieldMutex
38 SalYieldMutex::SalYieldMutex()
40 #if HAVE_FEATURE_OPENGL
41 SetBeforeReleaseHandler( &OpenGLContext::prepareForYield );
42 #endif
45 SalYieldMutex::~SalYieldMutex()
49 SalGenericInstance::~SalGenericInstance()
53 OUString SalGenericInstance::getOSVersion()
55 OUString aKernelVer = "unknown";
56 #if defined(LINUX)
57 FILE* pVersion = fopen( "/proc/version", "r" );
58 if ( pVersion )
60 char aVerBuffer[512];
61 if ( fgets ( aVerBuffer, 511, pVersion ) )
63 aKernelVer = OUString::createFromAscii( aVerBuffer );
64 // "Linux version 3.16.7-29-desktop ..."
65 std::u16string_view aVers = o3tl::getToken(aKernelVer, 2, ' ' );
66 // "3.16.7-29-desktop ..."
67 size_t nTooDetailed = aVers.find( '.', 2);
68 if (nTooDetailed < 1 || nTooDetailed > 8)
69 aKernelVer = "Linux (misparsed version)";
70 else // "3.16.7-29-desktop ..."
71 aKernelVer = OUString::Concat("Linux ") + aVers.substr(0, nTooDetailed);
73 fclose( pVersion );
75 #elif defined(__FreeBSD__)
76 struct utsname stName;
77 if ( uname( &stName ) != 0 )
78 return aKernelVer;
80 sal_Int32 nDots = 0;
81 sal_Int32 nIndex = 0;
82 aKernelVer = OUString::createFromAscii( stName.release );
83 while ( nIndex++ < aKernelVer.getLength() )
85 const char c = stName.release[ nIndex ];
86 if ( c == ' ' || c == '-' || ( c == '.' && nDots++ > 0 ) )
87 break;
89 aKernelVer = OUString::createFromAscii(stName.sysname) + " " + aKernelVer.copy(0, nIndex);
90 #elif defined(EMSCRIPTEN)
91 #define str(s) #s
92 #define xstr(s) str(s)
93 aKernelVer = "Emscripten " xstr(__EMSCRIPTEN_major__)
94 "." xstr(__EMSCRIPTEN_minor__) "." xstr(__EMSCRIPTEN_tiny__);
95 #endif
96 return aKernelVer;
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */