/src/libreoffice/sc/source/ui/unoobj/drdefuno.cxx
Line | Count | Source |
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 <drdefuno.hxx> |
21 | | #include <docsh.hxx> |
22 | | #include <drwlayer.hxx> |
23 | | |
24 | | #include <svx/unoprov.hxx> |
25 | | #include <vcl/svapp.hxx> |
26 | | |
27 | | ScDrawDefaultsObj::ScDrawDefaultsObj(ScDocShell* pDocSh) : |
28 | 555 | SvxUnoDrawPool( nullptr, SvxPropertySetInfoPool::getDrawingDefaults() ), |
29 | 555 | pDocShell( pDocSh ) |
30 | 555 | { |
31 | | // SvxUnoDrawPool is initialized without model, |
32 | | // draw layer is created on demand in getModelPool |
33 | | |
34 | 555 | pDocShell->GetDocument().AddUnoObject(*this); |
35 | 555 | } Unexecuted instantiation: ScDrawDefaultsObj::ScDrawDefaultsObj(ScDocShell*) ScDrawDefaultsObj::ScDrawDefaultsObj(ScDocShell*) Line | Count | Source | 28 | 555 | SvxUnoDrawPool( nullptr, SvxPropertySetInfoPool::getDrawingDefaults() ), | 29 | 555 | pDocShell( pDocSh ) | 30 | 555 | { | 31 | | // SvxUnoDrawPool is initialized without model, | 32 | | // draw layer is created on demand in getModelPool | 33 | | | 34 | 555 | pDocShell->GetDocument().AddUnoObject(*this); | 35 | 555 | } |
|
36 | | |
37 | | ScDrawDefaultsObj::~ScDrawDefaultsObj() noexcept |
38 | 555 | { |
39 | 555 | SolarMutexGuard g; |
40 | | |
41 | 555 | if (pDocShell) |
42 | 555 | pDocShell->GetDocument().RemoveUnoObject(*this); |
43 | 555 | } |
44 | | |
45 | | void ScDrawDefaultsObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) |
46 | 0 | { |
47 | 0 | if ( rHint.GetId() == SfxHintId::Dying ) |
48 | 0 | { |
49 | 0 | pDocShell = nullptr; // document gone |
50 | 0 | } |
51 | 0 | } |
52 | | |
53 | | SfxItemPool* ScDrawDefaultsObj::getModelPool( bool bReadOnly ) noexcept |
54 | 2.72k | { |
55 | 2.72k | SfxItemPool* pRet = nullptr; |
56 | | |
57 | 2.72k | try |
58 | 2.72k | { |
59 | 2.72k | if ( pDocShell ) |
60 | 2.72k | { |
61 | 2.72k | ScDrawLayer* pModel = bReadOnly ? |
62 | 0 | pDocShell->GetDocument().GetDrawLayer() : |
63 | 2.72k | pDocShell->MakeDrawLayer(); |
64 | 2.72k | if ( pModel ) |
65 | 2.72k | pRet = &pModel->GetItemPool(); |
66 | 2.72k | } |
67 | 2.72k | } |
68 | 2.72k | catch (...) |
69 | 2.72k | { |
70 | 0 | } |
71 | | |
72 | 2.72k | if ( !pRet ) |
73 | 0 | pRet = SvxUnoDrawPool::getModelPool( bReadOnly ); // uses default pool |
74 | | |
75 | 2.72k | return pRet; |
76 | 2.72k | } |
77 | | |
78 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |