Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / vcl / inc / unx / geninst.h
blobe79fd1fd56d4f9acf998804897354800350e82e3
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 #ifndef INCLUDED_VCL_INC_GENERIC_GENINST_H
21 #define INCLUDED_VCL_INC_GENERIC_GENINST_H
23 #include <comphelper/solarmutex.hxx>
24 #include <tools/solar.h>
25 #include <osl/thread.hxx>
26 #include <vclpluginapi.h>
27 #include <salinst.hxx>
28 #include <saldatabasic.hxx>
29 #include "unx/genprn.h"
31 class VCL_DLLPUBLIC SalYieldMutexReleaser
33 sal_uLong m_nYieldCount;
34 public:
35 inline SalYieldMutexReleaser();
36 inline ~SalYieldMutexReleaser();
39 inline SalYieldMutexReleaser::SalYieldMutexReleaser()
41 m_nYieldCount = GetSalData()->m_pInstance->ReleaseYieldMutex();
44 inline SalYieldMutexReleaser::~SalYieldMutexReleaser()
46 GetSalData()->m_pInstance->AcquireYieldMutex( m_nYieldCount );
49 class VCL_DLLPUBLIC SalYieldMutex : public comphelper::SolarMutex
51 osl::Mutex m_mutex;
53 protected:
54 sal_uIntPtr mnCount;
55 oslThreadIdentifier mnThreadId;
57 public:
58 SalYieldMutex();
59 virtual ~SalYieldMutex() override;
61 virtual void acquire() override;
62 virtual void release() override;
63 virtual bool tryToAcquire() override;
65 sal_uIntPtr GetAcquireCount() const { return mnCount; }
66 oslThreadIdentifier GetThreadId() const { return mnThreadId; }
70 * Abstract generic class to build vclplugin's instance classes from
72 class GenPspGraphics;
73 class PhysicalFontCollection;
74 class VCL_DLLPUBLIC SalGenericInstance : public SalInstance
76 protected:
77 bool mbPrinterInit;
78 std::unique_ptr<SalYieldMutex> mpSalYieldMutex;
80 public:
81 SalGenericInstance( SalYieldMutex* pMutex )
82 : mbPrinterInit( false ), mpSalYieldMutex( pMutex ) {}
83 virtual ~SalGenericInstance() override;
85 // Yield mutex
86 virtual comphelper::SolarMutex* GetYieldMutex() override;
87 virtual sal_uIntPtr ReleaseYieldMutex() override;
88 virtual void AcquireYieldMutex( sal_uIntPtr nCount ) override;
89 virtual bool CheckYieldMutex() override;
91 // Printing
92 virtual SalInfoPrinter* CreateInfoPrinter ( SalPrinterQueueInfo* pQueueInfo,
93 ImplJobSetup* pSetupData ) override;
94 virtual void DestroyInfoPrinter ( SalInfoPrinter* pPrinter ) override;
95 virtual SalPrinter* CreatePrinter ( SalInfoPrinter* pInfoPrinter ) override;
96 virtual void DestroyPrinter ( SalPrinter* pPrinter ) override;
97 virtual void GetPrinterQueueInfo ( ImplPrnQueueList* pList ) override;
98 virtual void GetPrinterQueueState ( SalPrinterQueueInfo* pInfo ) override;
99 virtual void DeletePrinterQueueInfo ( SalPrinterQueueInfo* pInfo ) override;
100 virtual OUString GetDefaultPrinter() override;
101 virtual void PostPrintersChanged() = 0;
102 virtual void updatePrinterUpdate() override;
103 virtual void jobStartedPrinterUpdate() override;
104 virtual void jobEndedPrinterUpdate() override;
105 bool isPrinterInit() const { return mbPrinterInit; }
106 virtual GenPspGraphics *CreatePrintGraphics() = 0;
108 virtual OUString getOSVersion() override;
110 // prolly belongs somewhere else ... just a font help
111 static void RegisterFontSubstitutors( PhysicalFontCollection* pFontCollection );
113 protected:
114 static void configurePspInfoPrinter( PspSalInfoPrinter* pInfoPrinter,
115 SalPrinterQueueInfo* pQueueInfo,
116 ImplJobSetup* pSetupData );
119 inline SalGenericInstance *GetGenericInstance()
121 return static_cast<SalGenericInstance *>(GetSalData()->m_pInstance);
124 #endif // INCLUDED_VCL_INC_GENERIC_GENINST_H
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */