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