Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/inc/DrawDocShell.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 <sal/config.h>
23
24
#include <span>
25
26
#include <rtl/ref.hxx>
27
#include <sfx2/docfac.hxx>
28
#include <sfx2/objsh.hxx>
29
#include <svl/style.hxx>
30
31
#include <glob.hxx>
32
#include <pres.hxx>
33
#include <sddllapi.h>
34
#include "fupoor.hxx"
35
36
class FontList;
37
class SdDrawDocument;
38
class SdPage;
39
class SfxPrinter;
40
struct SpellCallbackInfo;
41
class SfxUndoManager;
42
class SvxNameDialog;
43
44
namespace sd {
45
46
class FrameView;
47
class ViewShell;
48
class DrawViewShell;
49
50
// DrawDocShell
51
class SAL_DLLPUBLIC_RTTI DrawDocShell : public SfxObjectShell
52
{
53
public:
54
    SFX_DECL_INTERFACE(SD_IF_SDDRAWDOCSHELL)
55
    SFX_DECL_OBJECTFACTORY();
56
57
private:
58
    /// SfxInterface initializer.
59
    static void InitInterface_Impl();
60
61
public:
62
    SD_DLLPUBLIC DrawDocShell (
63
        SfxObjectCreateMode eMode,
64
        bool bSdDataObj,
65
        DocumentType);
66
67
    DrawDocShell (
68
        SfxModelFlags nModelCreationFlags,
69
        bool bSdDataObj,
70
        DocumentType);
71
72
    DrawDocShell (
73
        SdDrawDocument* pDoc,
74
        SfxObjectCreateMode eMode,
75
        bool bSdDataObj,
76
        DocumentType);
77
    virtual ~DrawDocShell() override;
78
79
    void                    UpdateRefDevice();
80
    virtual void            Activate( bool bMDI ) override;
81
    virtual void            Deactivate( bool bMDI ) override;
82
    virtual bool            InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
83
    virtual bool            ImportFrom(SfxMedium &rMedium,
84
            css::uno::Reference<css::text::XTextRange> const& xInsertPosition)
85
        override;
86
    virtual bool            ConvertFrom( SfxMedium &rMedium ) override;
87
    virtual bool            Save() override;
88
    virtual bool            SaveAsOwnFormat( SfxMedium& rMedium ) override;
89
    virtual bool            ConvertTo( SfxMedium &rMedium ) override;
90
    virtual bool            SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
91
92
    virtual bool            Load( SfxMedium &rMedium  ) override;
93
    virtual bool            LoadFrom( SfxMedium& rMedium ) override;
94
    virtual void            UpdateLinks() override;
95
    virtual void            PerformLinkUpdate() override;
96
    virtual bool            SaveAs( SfxMedium &rMedium  ) override;
97
98
    virtual ::tools::Rectangle       GetVisArea(sal_uInt16 nAspect) const override;
99
    virtual void            Draw(OutputDevice*, const JobSetup& rSetup, sal_uInt16 nAspect, bool bOutputForScreen) override;
100
    virtual SfxUndoManager* GetUndoManager() override;
101
    virtual Printer*        GetDocumentPrinter() override;
102
    virtual void            OnDocumentPrinterChanged(Printer* pNewPrinter) override;
103
    virtual SfxStyleSheetBasePool* GetStyleSheetPool() override;
104
    virtual void            FillClass(SvGlobalName* pClassName, SotClipboardFormatId* pFormat, OUString* pFullTypeName, sal_Int32 nFileFormat, bool bTemplate = false ) const override;
105
    virtual void            SetModified( bool = true ) override;
106
    virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent,
107
                                                                            const SfxItemSet &rSet) override;
108
109
    using SfxObjectShell::GetVisArea;
110
    using SfxShell::GetViewShell;
111
112
445k
    SAL_RET_MAYBENULL sd::ViewShell* GetViewShell() { return mpViewShell; }
113
    ::sd::FrameView* GetFrameView();
114
115
67.1k
    SdDrawDocument*         GetDoc() { return mpDoc;}
116
0
    DocumentType            GetDocumentType() const { return meDocType; }
117
118
    SfxPrinter*             GetPrinter(bool bCreate);
119
    void                    SetPrinter(SfxPrinter *pNewPrinter);
120
    void                    UpdateFontList();
121
122
0
    bool                    IsInDestruction() const { return mbInDestruction; }
123
124
    void                    CancelSearching();
125
126
    void                    Execute( SfxRequest& rReq );
127
    void                    GetState(SfxItemSet&);
128
129
    void                    Connect(sd::ViewShell* pViewSh);
130
    void                    Disconnect(sd::ViewShell const * pViewSh);
131
    void                    UpdateTablePointers();
132
133
    void                    GotoBookmark(std::u16string_view rBookmark);
134
135
    SD_DLLPUBLIC Bitmap GetPagePreviewBitmap(SdPage* pPage);
136
137
    /** checks, if the given name is a valid new name for a slide
138
139
        <p>If the name is invalid, an <type>SvxNameDialog</type> pops up that
140
        queries again for a new name until it is ok or the user chose
141
        Cancel.</p>
142
143
        @param pWin is necessary to pass to the <type>SvxNameDialog</type> in
144
                    case an invalid name was entered.
145
        @param rName the new name that is to be set for a slide.  This string
146
                     may be set to an empty string (see below).
147
148
        @return sal_True, if the new name is unique.  Note that if the user entered
149
                a default name of a not-yet-existing slide (e.g. 'Slide 17'),
150
                sal_True is returned, but rName is set to an empty string.
151
     */
152
    bool                    CheckPageName(weld::Window* pWin, OUString& rName );
153
154
15.8k
    void                    SetSlotFilter(bool bEnable = false, std::span<sal_uInt16 const> pSIDs = std::span<sal_uInt16 const>()) { mbFilterEnable = bEnable; mpFilterSIDs = pSIDs; }
155
    void                    ApplySlotFilter() const;
156
157
0
    SfxStyleFamily          GetStyleFamily() const { return mnStyleFamily; }
158
15.9k
    void                    SetStyleFamily( SfxStyleFamily nSF ) { mnStyleFamily = nSF; }
159
160
    /** executes the SID_OPENDOC slot to let the framework open a document
161
        with the given URL and this document as a referer */
162
    void                    OpenBookmark( const OUString& rBookmarkURL );
163
164
    /** checks, if the given name is a valid new name for a slide
165
166
        <p>This method does not pop up any dialog (like CheckPageName).</p>
167
168
        @param rInOutPageName the new name for a slide that is to be renamed.
169
                    This string will be set to an empty string if
170
                    bResetStringIfStandardName is true and the name is of the
171
                    form of any, possibly not-yet existing, standard slide
172
                    (e.g. 'Slide 17')
173
174
        @param bResetStringIfStandardName if true allows setting rInOutPageName
175
                    to an empty string, which returns true and implies that the
176
                    slide will later on get a new standard name (with a free
177
                    slide number).
178
179
        @return true, if the new name is unique.  If bResetStringIfStandardName
180
                    is true, the return value is also true, if the slide name is
181
                    a standard name (see above)
182
     */
183
    bool                    IsNewPageNameValid( OUString & rInOutPageName, bool bResetStringIfStandardName = false );
184
185
    /** checks, if the given name is a *unique* name for an *existing* slide
186
187
        @param rPageName the name of an existing slide
188
189
        @return true, if the name is unique and the slide exists
190
    */
191
    bool                    IsPageNameUnique(std::u16string_view rPagName) const;
192
193
    /** Return the reference device for the current document.  When the
194
        inherited implementation returns a device then this is passed to the
195
        caller.  Otherwise the returned value depends on the printer
196
        independent layout mode and will usually be either a printer or a
197
        virtual device used for screen rendering.
198
        @return
199
            Returns NULL when the current document has no reference device.
200
    */
201
    virtual OutputDevice* GetDocumentRefDev() override;
202
203
    DECL_DLLPRIVATE_LINK(RenameSlideHdl, SvxNameDialog&, bool);
204
205
    // ExecuteSpellPopup now handled by DrawDocShell
206
    DECL_DLLPRIVATE_LINK( OnlineSpellCallback, SpellCallbackInfo&, void );
207
208
    void                    ClearUndoBuffer();
209
210
    std::shared_ptr<model::ColorSet> GetThemeColors() override;
211
212
private:
213
    static void setEditMode(DrawViewShell* pDrawViewShell, bool isMasterPage);
214
    void                    Construct(bool bClipboard);
215
216
    SdDrawDocument*         mpDoc;
217
    std::unique_ptr<SfxUndoManager> mpUndoManager;
218
    VclPtr<SfxPrinter>      mpPrinter;
219
    ::sd::ViewShell*        mpViewShell;
220
    std::unique_ptr<FontList> mpFontList;
221
    DocumentType            meDocType;
222
    SfxStyleFamily          mnStyleFamily;
223
    std::span<sal_uInt16 const>
224
                            mpFilterSIDs;
225
    bool                    mbFilterEnable;
226
    bool                    mbSdDataObj;
227
    bool                    mbInDestruction;
228
    bool                    mbOwnPrinter;
229
    bool                    mbOwnDocument;          // if true, we own mpDoc and will delete it in our d'tor
230
};
231
232
#ifndef SV_DECL_DRAW_DOC_SHELL_DEFINED
233
#define SV_DECL_DRAW_DOC_SHELL_DEFINED
234
typedef rtl::Reference<DrawDocShell> DrawDocShellRef;
235
#endif
236
237
} // end of namespace sd
238
239
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */