Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "view/SlsFontProvider.hxx"
21 :
22 : #include "controller/SlideSorterController.hxx"
23 :
24 : #include <sfx2/app.hxx>
25 : #include <osl/getglobalmutex.hxx>
26 : #include <com/sun/star/uno/RuntimeException.hpp>
27 :
28 : using namespace ::sd::slidesorter;
29 :
30 : namespace sd { namespace slidesorter { namespace view {
31 :
32 : FontProvider* FontProvider::mpInstance = NULL;
33 :
34 0 : FontProvider& FontProvider::Instance()
35 : {
36 0 : if (mpInstance == NULL)
37 : {
38 : ::osl::GetGlobalMutex aMutexFunctor;
39 0 : ::osl::MutexGuard aGuard (aMutexFunctor());
40 0 : if (mpInstance == NULL)
41 : {
42 : // Create an instance of the class and register it at the
43 : // SdGlobalResourceContainer so that it is eventually released.
44 0 : FontProvider* pInstance = new FontProvider();
45 0 : SdGlobalResourceContainer::Instance().AddResource (
46 0 : ::std::unique_ptr<SdGlobalResource>(pInstance));
47 : OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
48 0 : mpInstance = pInstance;
49 0 : }
50 : }
51 : else
52 : {
53 : OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
54 : }
55 :
56 : // We throw an exception when for some strange reason no instance of
57 : // this class exists.
58 0 : if (mpInstance == NULL)
59 : throw ::com::sun::star::uno::RuntimeException("com.sun.star.document.IndexedPropertyValues",
60 0 : NULL);
61 :
62 0 : return *mpInstance;
63 : }
64 :
65 0 : FontProvider::FontProvider()
66 : : maFont(),
67 0 : maMapMode()
68 : {
69 0 : }
70 :
71 0 : FontProvider::~FontProvider()
72 : {
73 0 : }
74 :
75 0 : void FontProvider::Invalidate()
76 : {
77 0 : maFont.reset();
78 0 : }
79 :
80 66 : } } } // end of namespace ::sd::slidesorter::view
81 :
82 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|