Version 7.6.7.2, tag libreoffice-7.6.7.2
[LibreOffice.git] / sd / inc / sdmod.hxx
blob4fca79b04b13e57f0f9c9c77bf613d0be7343066
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include "glob.hxx"
23 #include "pres.hxx"
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 <o3tl/span.hxx>
35 #include <map>
36 #include <memory>
37 #include <string_view>
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;
50 namespace com::sun::star::frame {
51 class XFrame;
54 enum class SdOptionStreamMode
56 Load = 0,
57 Store = 1
60 struct SdExtPropertySetInfoCacheCompare
62 bool operator()(const o3tl::span<SfxItemPropertyMapEntry const>& lhs, const o3tl::span<SfxItemPropertyMapEntry const>& rhs) const
64 return lhs.data() < rhs.data();
67 typedef std::map<
68 o3tl::span<SfxItemPropertyMapEntry const>,
69 css::uno::Reference<css::beans::XPropertySetInfo>,
70 SdExtPropertySetInfoCacheCompare > SdExtPropertySetInfoCache;
71 typedef std::map< SdrObjKind, css::uno::Sequence< css::uno::Type> > SdTypesCache;
75 This subclass of <SfxModule> (which is a subclass of <SfxShell>) is
76 linked to the DLL. One instance of this class exists while the DLL is
77 loaded.
79 SdModule is like to be compared with the <SfxApplication>-subclass.
81 Remember: Don`t export this class! It uses DLL-internal symbols.
85 class SAL_DLLPUBLIC_RTTI SdModule final : public SfxModule, public SfxListener
87 public:
88 SFX_DECL_INTERFACE(SD_IF_SDAPP)
89 DECL_DLLPRIVATE_LINK( CalcFieldValueHdl, EditFieldInfo*, void );
91 private:
92 /// SfxInterface initializer.
93 static void InitInterface_Impl();
95 public:
96 SdModule(SfxObjectFactory* pDrawObjFact, SfxObjectFactory* pGraphicObjFact);
97 virtual ~SdModule() override;
99 SdTransferable* pTransferClip;
100 SdTransferable* pTransferDrag;
101 SdTransferable* pTransferSelection;
103 void Execute(SfxRequest& rReq);
104 void GetState(SfxItemSet&);
106 SdOptions* GetSdOptions(DocumentType eDocType);
107 SD_DLLPUBLIC tools::SvRef<SotStorageStream> GetOptionStream( std::u16string_view rOptionName, SdOptionStreamMode eMode );
109 bool GetWaterCan() const { return bWaterCan; }
110 void SetWaterCan( bool bWC ) { bWaterCan = bWC; }
112 SvxSearchItem* GetSearchItem() { return pSearchItem.get(); }
113 void SetSearchItem(std::unique_ptr<SvxSearchItem> pItem);
115 /** Return the virtual device that can be used for printer independent
116 layout.
117 @return
118 The returned pointer is NULL when the device could not be
119 created when this modules was instantiated.
121 OutputDevice* GetVirtualRefDevice() { return mpVirtualRefDevice;}
123 SD_DLLPUBLIC SvNumberFormatter* GetNumberFormatter();
125 // virtual methods for the option dialog
126 virtual std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
127 virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
128 virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
129 virtual std::optional<SfxStyleFamilies> CreateStyleFamilies() override;
131 SdExtPropertySetInfoCache gImplImpressPropertySetInfoCache;
132 SdExtPropertySetInfoCache gImplDrawPropertySetInfoCache;
133 SdTypesCache gImplTypesCache;
135 svtools::ColorConfig& GetColorConfig();
137 private:
139 SdOptions* pImpressOptions;
140 SdOptions* pDrawOptions;
141 std::unique_ptr<SvxSearchItem> pSearchItem;
142 std::unique_ptr<SvNumberFormatter> pNumberFormatter;
143 tools::SvRef<SotStorage> xOptionStorage;
144 bool bWaterCan;
145 std::unique_ptr<SfxErrorHandler> mpErrorHdl;
146 /** This device is used for printer independent layout. It is virtual
147 in the sense that it does not represent a printer. The pointer may
148 be NULL when the virtual device could not be created.
150 VclPtr< VirtualDevice > mpVirtualRefDevice;
152 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
154 SfxFrame* ExecuteNewDocument( SfxRequest const & rReq );
156 static SfxFrame* CreateEmptyDocument( const css::uno::Reference< css::frame::XFrame >& i_rFrame );
157 static SfxFrame* CreateFromTemplate(const OUString& rTemplatePath,
158 const css::uno::Reference<css::frame::XFrame>& i_rFrame,
159 const bool bReplaceable);
161 bool mbEventListenerAdded;
163 /** Take an outline from a text document and create a new impress
164 document according to the structure of the outline.
165 @param rRequest
166 This typically is the unmodified request from an execute()
167 function from where this function is called.
169 static bool OutlineToImpress(SfxRequest const & rRequest);
171 /** Add an eventlistener as soon as possible in sd, allows to use
172 remote devices to start the slideshow elegantly, and respecting
173 portability
174 @EventListenerHdl
175 The event listener handler
176 @VclSimpleEvent *
177 a pointer to a VCLSimpleEvent (see vcl/vclevent.hxx )
179 DECL_DLLPRIVATE_STATIC_LINK( SdModule, EventListenerHdl, VclSimpleEvent&, void );
181 std::unique_ptr<svtools::ColorConfig> mpColorConfig;
184 #define SD_MOD() ( static_cast<SdModule*>(SfxApplication::GetModule(SfxToolsModule::Draw)) )
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */