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