Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/inc/sdmod.hxx
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
#pragma once
21
22
#include "glob.hxx"
23
#include "pres.hxx"
24
25
#include <sot/storage.hxx>
26
#include "sddllapi.h"
27
#include <svl/itemprop.hxx>
28
#include <svl/lstner.hxx>
29
#include <com/sun/star/beans/XPropertySetInfo.hpp>
30
#include <sfx2/app.hxx>
31
#include <sfx2/module.hxx>
32
#include <sal/types.h>
33
#include <vcl/virdev.hxx>
34
#include <map>
35
#include <memory>
36
#include <span>
37
#include <string_view>
38
39
class SdOptions;
40
class SvxSearchItem;
41
class EditFieldInfo;
42
class SdTransferable;
43
class SvNumberFormatter;
44
class SfxErrorHandler;
45
class SfxFrame;
46
class VclSimpleEvent;
47
namespace svtools { class ColorConfig; }
48
enum class SdrObjKind : sal_uInt16;
49
50
namespace com::sun::star::frame {
51
    class XFrame;
52
}
53
54
struct SdExtPropertySetInfoCacheCompare
55
{
56
    bool operator()(const std::span<SfxItemPropertyMapEntry const>& lhs, const std::span<SfxItemPropertyMapEntry const>& rhs) const
57
1.16M
    {
58
1.16M
        return lhs.data() < rhs.data();
59
1.16M
    }
60
};
61
typedef std::map<
62
            std::span<SfxItemPropertyMapEntry const>,
63
            css::uno::Reference<css::beans::XPropertySetInfo>,
64
            SdExtPropertySetInfoCacheCompare > SdExtPropertySetInfoCache;
65
typedef std::map< SdrObjKind, css::uno::Sequence< css::uno::Type> > SdTypesCache;
66
67
/*
68
69
  This subclass of <SfxModule> (which is a subclass of <SfxShell>) is
70
  linked to the DLL. One instance of this class exists while the DLL is
71
  loaded.
72
73
  SdModule is like to be compared with the <SfxApplication>-subclass.
74
75
  Remember: Don`t export this class! It uses DLL-internal symbols.
76
77
*/
78
79
class SAL_DLLPUBLIC_RTTI SdModule final : public SfxModule, public SfxListener
80
{
81
public:
82
                            SFX_DECL_INTERFACE(SD_IF_SDAPP)
83
                            DECL_DLLPRIVATE_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
84
85
private:
86
    /// SfxInterface initializer.
87
    static void InitInterface_Impl();
88
89
public:
90
                            SdModule(SfxObjectFactory* pDrawObjFact, SfxObjectFactory* pGraphicObjFact);
91
    virtual                 ~SdModule() override;
92
93
    SdTransferable*         pTransferClip;
94
    SdTransferable*         pTransferDrag;
95
    SdTransferable*         pTransferSelection;
96
97
    void                    Execute(SfxRequest& rReq);
98
    void                    GetState(SfxItemSet&);
99
100
    SdOptions*              GetSdOptions(DocumentType eDocType);
101
102
0
    bool                    GetWaterCan() const { return bWaterCan; }
103
0
    void                    SetWaterCan( bool bWC ) { bWaterCan = bWC; }
104
105
0
    SvxSearchItem*          GetSearchItem() { return pSearchItem.get(); }
106
    void                    SetSearchItem(std::unique_ptr<SvxSearchItem> pItem);
107
108
    /** Return the virtual device that can be used for printer independent
109
        layout.
110
        @return
111
            The returned pointer is NULL when the device could not be
112
            created when this modules was instantiated.
113
    */
114
42.5k
    OutputDevice* GetVirtualRefDevice() { return mpVirtualRefDevice;}
115
116
    SD_DLLPUBLIC SvNumberFormatter*     GetNumberFormatter();
117
118
    // virtual methods for the option dialog
119
    virtual std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
120
    virtual void         ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
121
    virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
122
    virtual SfxStyleFamilies CreateStyleFamilies() override;
123
124
    SdExtPropertySetInfoCache gImplImpressPropertySetInfoCache;
125
    SdExtPropertySetInfoCache gImplDrawPropertySetInfoCache;
126
    SdTypesCache gImplTypesCache;
127
128
    svtools::ColorConfig& GetColorConfig();
129
130
5.93M
    static auto get() { return static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule::Draw)); }
131
132
private:
133
134
    SdOptions*              pImpressOptions;
135
    SdOptions*              pDrawOptions;
136
    std::unique_ptr<SvxSearchItem>      pSearchItem;
137
    std::unique_ptr<SvNumberFormatter>  pNumberFormatter;
138
    bool                    bWaterCan;
139
    std::unique_ptr<SfxErrorHandler> mpErrorHdl;
140
    /** This device is used for printer independent layout.  It is virtual
141
        in the sense that it does not represent a printer.  The pointer may
142
        be NULL when the virtual device could not be created.
143
    */
144
    VclPtr< VirtualDevice >  mpVirtualRefDevice;
145
146
    virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
147
148
    SfxFrame* ExecuteNewDocument( SfxRequest const & rReq );
149
150
    static SfxFrame* CreateEmptyDocument( const css::uno::Reference< css::frame::XFrame >& i_rFrame );
151
    static SfxFrame* CreateFromTemplate(const OUString& rTemplatePath,
152
                                        const css::uno::Reference<css::frame::XFrame>& i_rFrame,
153
                                        const bool bReplaceable);
154
155
    bool mbEventListenerAdded;
156
157
    /** Take an outline from a text document and create a new impress
158
        document according to the structure of the outline.
159
        @param rRequest
160
            This typically is the unmodified request from an execute()
161
            function from where this function is called.
162
    */
163
    static bool OutlineToImpress(SfxRequest const & rRequest);
164
165
    /** Add an eventlistener as soon as possible in sd, allows to use
166
        remote devices to start the slideshow elegantly, and respecting
167
        portability
168
        @EventListenerHdl
169
            The event listener handler
170
        @VclSimpleEvent *
171
            a pointer to a VCLSimpleEvent (see vcl/vclevent.hxx )
172
    */
173
    DECL_DLLPRIVATE_STATIC_LINK( SdModule, EventListenerHdl, VclSimpleEvent&, void );
174
175
    std::unique_ptr<svtools::ColorConfig> mpColorConfig;
176
};
177
178
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */