cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / View.hxx
blob49375687199843111393404b534a80105e36510b
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 <memory>
23 #include <pres.hxx>
24 #include <tools/gen.hxx>
25 #include <vcl/transfer.hxx>
26 #include <svx/fmview.hxx>
27 #include <svx/svdpage.hxx>
28 #include <vcl/idle.hxx>
30 #include "smarttag.hxx"
31 #include "fusearch.hxx"
33 class SdDrawDocument;
34 class SdPage;
35 class SdrOle2Obj;
36 class SdrGrafObj;
37 class SdrMediaObj;
38 class OutputDevice;
39 class ImageMap;
40 class Graphic;
41 class SdrOutliner;
43 namespace avmedia { class PlayerListener; }
45 namespace sd {
47 class DrawDocShell;
48 class ViewShell;
49 class Window;
50 class ViewClipboard;
52 //For master view we want to force that master
53 //textboxes have readonly text, because the
54 //text is the auto-generated click-here-to-edit
55 //and it doesn't help to change it
56 class OutlinerMasterViewFilter
58 private:
59 SdrOutliner *m_pOutl;
60 bool m_bReadOnly;
61 public:
62 OutlinerMasterViewFilter()
63 : m_pOutl(nullptr)
64 , m_bReadOnly(false)
67 void Start(SdrOutliner *pOutl);
68 void End();
71 class SearchContext
73 private:
74 rtl::Reference<FuSearch> maFunctionSearch;
76 public:
77 rtl::Reference<FuSearch>& getFunctionSearch()
79 return maFunctionSearch;
82 void setSearchFunction(rtl::Reference<FuSearch> const & xFunction)
84 resetSearchFunction();
85 maFunctionSearch = xFunction;
88 void resetSearchFunction()
90 if (maFunctionSearch.is())
91 maFunctionSearch->Dispose();
95 class SAL_DLLPUBLIC_RTTI View : public FmFormView
97 public:
99 View (
100 SdDrawDocument& rDrawDoc,
101 OutputDevice* pOutDev,
102 ViewShell* pViewSh=nullptr);
103 virtual ~View() override;
105 void CompleteRedraw( OutputDevice* pOutDev, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector = nullptr) override;
107 virtual void GetAttributes( SfxItemSet& rTargetSet, bool bOnlyHardAttr = false ) const;
108 virtual bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll = false, bool bSlide = false, bool bMaster = false);
109 virtual void MarkListHasChanged() override;
110 void SelectAll();
111 void DoCut();
112 void DoCopy();
113 void DoPaste(::sd::Window* pWindow=nullptr);
114 virtual void DoConnect(SdrOle2Obj* pOleObj) override;
115 virtual bool SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr = false);
116 void StartDrag( const Point& rStartPos, vcl::Window* pWindow );
117 virtual void DragFinished( sal_Int8 nDropAction );
118 virtual sal_Int8 AcceptDrop (
119 const AcceptDropEvent& rEvt,
120 DropTargetHelper& rTargetHelper,
121 SdrLayerID nLayer);
122 virtual sal_Int8 ExecuteDrop (
123 const ExecuteDropEvent& rEvt,
124 ::sd::Window* pTargetWindow,
125 sal_uInt16 nPage,
126 SdrLayerID nLayer);
128 css::uno::Reference<css::datatransfer::XTransferable>
129 CreateClipboardDataObject ();
130 css::uno::Reference<css::datatransfer::XTransferable>
131 CreateDragDataObject (::sd::View*, vcl::Window& rWindow,
132 const Point& rDragPos);
133 css::uno::Reference<css::datatransfer::XTransferable>
134 CreateSelectionDataObject (::sd::View*);
136 // update clipboard to what is selected
137 void UpdateSelectionClipboard();
139 // release content of clipboard, if we own the content
140 void ClearSelectionClipboard();
142 DrawDocShell* GetDocSh() const { return mpDocSh; }
143 inline SdDrawDocument& GetDoc() const;
144 ViewShell* GetViewShell() const { return mpViewSh; }
145 SfxViewShell* GetSfxViewShell() const override;
147 // Create a local UndoManager
148 std::unique_ptr<SdrUndoManager> createLocalTextUndoManager() override;
150 virtual bool SdrBeginTextEdit(SdrObject* pObj, SdrPageView* pPV = nullptr, vcl::Window* pWin = nullptr, bool bIsNewObj = false,
151 SdrOutliner* pGivenOutliner = nullptr, OutlinerView* pGivenOutlinerView = nullptr,
152 bool bDontDeleteOutliner = false, bool bOnlyOneView = false, bool bGrabFocus = true) override;
154 virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally = false) override;
156 bool RestoreDefaultText( SdrTextObj* pTextObj );
158 bool InsertData( const TransferableDataHelper& rDataHelper,
159 const Point& rPos, sal_Int8& rDnDAction, bool bDrag,
160 SotClipboardFormatId nFormat = SotClipboardFormatId::NONE,
161 sal_uInt16 nPage = SDRPAGE_NOTFOUND, SdrLayerID nLayer = SDRLAYER_NOTFOUND );
162 /** gets the metafile from the given transferable helper and insert it as a graphic shape.
163 @param bOptimize if set to true, the metafile is analyzed and if only one bitmap action is
164 present, then is inserted as a single graphic.
166 bool InsertMetaFile( const TransferableDataHelper& rDataHelper,
167 const Point& rInsertPos,
168 ImageMap const * pImageMap, bool bOptimize );
169 SdrGrafObj* InsertGraphic( const Graphic& rGraphic,
170 sal_Int8& rAction, const Point& rPos,
171 SdrObject* pSelectedObj, ImageMap const * pImageMap );
172 void InsertMediaURL( const OUString& rMediaURL, sal_Int8& rAction,
173 const Point& rPos, const Size& rSize,
174 bool const bLink );
175 SdrMediaObj* InsertMediaObj(const OUString& rURL, sal_Int8& rAction,
176 const Point& rPos, const Size& rSize );
178 bool PasteRTFTable( SvStream& rOStm, SdrPage* pPage, SdrInsertFlags nPasteOptions );
179 bool PasteHTMLTable( SvStream& rOStm, SdrPage* pPage, SdrInsertFlags nPasteOptions );
181 bool IsPresObjSelected(bool bOnPage = true, bool bOnMasterPage = true, bool bCheckPresObjListOnly = false, bool bCheckLayoutOnly = false) const;
183 void SetMarkedOriginalSize();
185 bool IsMorphingAllowed() const;
186 bool IsVectorizeAllowed() const;
188 virtual SfxStyleSheet* GetStyleSheet() const;
190 /** return parameter:
191 pExchangeList == NULL -> all names are unique
192 bNameOK == false -> cancel by user
193 nType == 0 -> pages
194 nType == 1 -> objects
195 nType == 2 -> pages and objects */
197 bool GetExchangeList( std::vector<OUString> &rExchangeList,
198 std::vector<OUString> &rBookmarkList,
199 const sal_uInt16 nType );
201 /** returns true if we have an undo manager and there is an open list undo action */
202 bool isRecordingUndo() const;
204 virtual void AddCustomHdl() override;
206 SmartTagSet& getSmartTags() { return maSmartTags; }
207 void updateHandles();
209 virtual SdrViewContext GetContext() const override;
210 virtual bool HasMarkablePoints() const override;
211 virtual sal_Int32 GetMarkablePointCount() const override;
212 virtual bool HasMarkedPoints() const override;
213 virtual bool MarkPoint(SdrHdl& rHdl, bool bUnmark=false) override;
214 virtual void CheckPossibilities() override;
215 virtual bool MarkPoints(const ::tools::Rectangle* pRect, bool bUnmark) override;
216 using SdrMarkView::MarkPoints;
218 bool ShouldToggleOn(
219 const bool bBulletOnOffMode,
220 const bool bNormalBullet);
222 /** change the bullets/numbering of the marked objects
224 @param bToggle
225 true: just toggle the current bullets/numbering on --> off resp. off --> on
227 @param bHandleBullets
228 true: handle bullets
229 false: handle numbering
231 @param pNumRule
232 numbering rule which needs to be applied. can be 0.
234 void ChangeMarkedObjectsBulletsNumbering(
235 const bool bToggle,
236 const bool bHandleBullets,
237 const SvxNumRule* pNumRule);
239 void SetPossibilitiesDirty() { m_bPossibilitiesDirty = true; }
240 void SetMoveAllowed( bool bSet ) { m_bMoveAllowed = bSet; }
241 void SetMoveProtected( bool bSet ) { m_bMoveProtect = bSet; }
242 void SetResizeFreeAllowed( bool bSet ) { m_bResizeFreeAllowed = bSet; }
243 void SetResizePropAllowed( bool bSet ) { m_bResizePropAllowed = bSet; }
244 void SetResizeProtected( bool bSet ) { m_bResizeProtect = bSet; }
246 SdrObject* GetEmptyPresentationObject( PresObjKind eKind );
247 SdPage* GetPage();
248 SdrObject* GetSelectedSingleObject(SdPage const * pPage);
249 void SetAuthor(const OUString& rAuthor) { m_sAuthor = rAuthor; }
250 const OUString& GetAuthor() const { return m_sAuthor; }
252 SearchContext& getSearchContext() { return maSearchContext; }
253 protected:
254 DECL_DLLPRIVATE_LINK( OnParagraphInsertedHdl, ::Outliner::ParagraphHdlParam, void );
255 DECL_DLLPRIVATE_LINK( OnParagraphRemovingHdl, ::Outliner::ParagraphHdlParam, void );
257 virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfo ) override;
258 virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfo ) override;
260 SdDrawDocument& mrDoc;
261 DrawDocShell* mpDocSh;
262 ViewShell* mpViewSh;
263 std::unique_ptr<SdrMarkList> mpDragSrcMarkList;
264 SdrObject* mpDropMarkerObj;
265 std::unique_ptr<SdrDropMarkerOverlay> mpDropMarker;
266 sal_uInt16 mnDragSrcPgNum;
267 Point maDropPos;
268 ::std::vector<OUString> maDropFileVector;
269 sal_Int8 mnAction;
270 Idle maDropErrorIdle;
271 Idle maDropInsertFileIdle;
272 rtl::Reference<avmedia::PlayerListener> mxDropMediaSizeListener;
273 sal_uInt16 mnLockRedrawSmph;
274 bool mbIsDropAllowed;
276 DECL_DLLPRIVATE_LINK( DropErrorHdl, Timer*, void );
277 DECL_DLLPRIVATE_LINK( DropInsertFileHdl, Timer*, void );
278 DECL_DLLPRIVATE_LINK( ExecuteNavigatorDrop, void*, void );
280 void ImplClearDrawDropMarker();
282 SmartTagSet maSmartTags;
284 private:
285 ::std::unique_ptr<ViewClipboard> mpClipboard;
286 OutlinerMasterViewFilter maMasterViewFilter;
287 SearchContext maSearchContext;
289 OUString m_sAuthor;
292 SdDrawDocument& View::GetDoc() const
294 return mrDoc;
297 } // end of namespace sd
299 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */