bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svx / svdpntv.hxx
blobce62413bc7c552d84ee9ea8751fa9ed17d3e89bc
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 #ifndef INCLUDED_SVX_SVDPNTV_HXX
21 #define INCLUDED_SVX_SVDPNTV_HXX
23 #include <svl/SfxBroadcaster.hxx>
24 #include <svl/lstner.hxx>
25 #include <svl/undo.hxx>
26 #include <svx/svddrag.hxx>
27 #include <svx/svdlayer.hxx>
28 #include <vcl/window.hxx>
29 #include <svtools/colorcfg.hxx>
30 #include <com/sun/star/awt/XControlContainer.hpp>
31 #include <svl/itemset.hxx>
32 #include <vcl/timer.hxx>
33 #include <svx/svxdllapi.h>
34 #include <svtools/optionsdrawinglayer.hxx>
35 #include <unotools/options.hxx>
36 #include <vcl/idle.hxx>
37 #include <memory>
40 // Pre defines
41 class SdrPageWindow;
43 namespace com { namespace sun { namespace star { namespace awt {
44 class XControlContainer;
45 }}}}
46 namespace sdr { namespace overlay { class OverlayManager; } }
48 class SdrPage;
49 class SdrView;
50 class SfxItemSet;
51 class SfxStyleSheet;
52 class SdrOle2Obj;
53 class SdrModel;
54 class SdrObject;
55 enum class GraphicManagerDrawFlags;
57 #ifdef DBG_UTIL
58 class SdrItemBrowser;
59 #endif
61 namespace sdr { namespace contact {
62 class ViewObjectContactRedirector;
66 // Defines for AnimationMode
67 enum class SdrAnimationMode
69 Animate,
70 Disable
74 class SdrPaintView;
76 namespace sdr
78 namespace contact
80 class ViewObjectContactRedirector;
85 class SVX_DLLPUBLIC SvxViewChangedHint : public SfxHint
87 public:
88 explicit SvxViewChangedHint();
91 class SdrPaintWindow;
93 /**
94 * Helper to convert any GDIMetaFile to a good quality BitmapEx,
95 * using default parameters and graphic::XPrimitive2DRenderer
97 BitmapEx SVX_DLLPUBLIC convertMetafileToBitmapEx(
98 const GDIMetaFile& rMtf,
99 const basegfx::B2DRange& rTargetRange,
100 const sal_uInt32 nMaximumQuadraticPixels);
102 ////////////////////////////////////////////////////////////////////////////////////////////////////
104 // SdrPaintView
105 // SdrSnapView
106 // SdrMarkView
107 // SdrEditView
108 // SdrPolyEditView
109 // SdrGlueEditView
110 // SdrObjEditView
111 // SdrExchangeView
112 // SdrDragView
113 // SdrCreateView
114 // SdrView
115 // DlgEdView
116 // GraphCtrlView
117 // E3dView
118 // DrawViewWrapper
119 // FmFormView
120 // ScDrawView
121 // sd::View (may have more?)
122 // sd::DrawView
123 // SwDrawView
124 // OSectionView
126 class SVX_DLLPUBLIC SdrPaintView : public SfxListener, public SfxRepeatTarget, public SfxBroadcaster, public ::utl::ConfigurationListener
128 private:
129 friend class SdrPageView;
130 friend class SdrGrafObj;
132 // the SdrModel this view was created with, unchanged during lifetime
133 SdrModel& mrSdrModelFromSdrView;
135 std::unique_ptr<SdrPageView> mpPageView;
136 protected:
137 SdrModel* mpModel;
138 #ifdef DBG_UTIL
139 VclPtr<SdrItemBrowser> mpItemBrowser;
140 #endif
141 VclPtr<OutputDevice> mpActualOutDev; // Only for comparison
142 VclPtr<OutputDevice> mpDragWin;
143 SfxStyleSheet* mpDefaultStyleSheet;
145 OUString maActualLayer; // Current drawing layer
146 OUString maMeasureLayer; // Current layer for measurements
148 // Container aPagV; // List of SdrPageViews
150 // All windows this view is displayed on
151 std::vector< std::unique_ptr<SdrPaintWindow> > maPaintWindows;
153 Size maGridBig; // FIXME: We need to get rid of this eventually
154 Size maGridFin; // FIXME: We need to get rid of this eventually
155 SdrDragStat maDragStat;
156 tools::Rectangle maMaxWorkArea;
157 SfxItemSet maDefaultAttr;
158 Idle maComeBackIdle;
160 SdrAnimationMode meAnimationMode;
162 sal_uInt16 mnHitTolPix;
163 sal_uInt16 mnMinMovPix;
164 sal_uInt16 mnHitTolLog;
165 sal_uInt16 mnMinMovLog;
167 // Hold an incarnation of Drawinglayer configuration options
168 SvtOptionsDrawinglayer const maDrawinglayerOpt;
170 bool mbPageVisible : 1;
171 bool mbPageShadowVisible : 1;
172 bool mbPageBorderVisible : 1;
173 bool mbBordVisible : 1;
174 bool mbGridVisible : 1;
175 bool mbGridFront : 1;
176 bool mbHlplVisible : 1;
177 bool mbHlplFront : 1;
178 bool mbGlueVisible : 1; // Persistent; show glue points
179 bool mbGlueVisible2 : 1; // Also show glue points for GluePointEdit
180 bool mbGlueVisible3 : 1; // Also show glue points for EdgeTool
181 bool mbGlueVisible4 : 1; // Show glue points, if one edge is selected
182 bool mbSomeObjChgdFlag : 1;
183 bool mbSwapAsynchron : 1;
184 bool mbPrintPreview : 1;
186 // These bools manage, the status that is displayed
188 bool mbAnimationPause : 1;
190 // Flag which decides if buffered output for this view is allowed. When
191 // set, PreRendering for PageView rendering will be used. Default is sal_False
192 bool mbBufferedOutputAllowed : 1;
194 // Flag which decides if buffered overlay for this view is allowed. When
195 // set, the output will be buffered in an overlay vdev. When not, overlay is
196 // directly painted to OutDev. Default is sal_False.
197 bool mbBufferedOverlayAllowed : 1;
199 // Allow page painting at all?
200 bool mbPagePaintingAllowed : 1;
202 // Is this a preview renderer?
203 bool mbPreviewRenderer : 1;
205 // Flags for calc and sw for suppressing OLE, CHART or DRAW objects
206 bool mbHideOle : 1;
207 bool mbHideChart : 1;
208 bool mbHideDraw : 1; // hide draw objects other than form controls
209 bool mbHideFormControl : 1; // hide form controls only
211 public:
212 // Interface for PagePaintingAllowed flag
213 bool IsBufferedOutputAllowed() const;
214 void SetBufferedOutputAllowed(bool bNew);
216 // Interface for BufferedOverlayAllowed flag
217 bool IsBufferedOverlayAllowed() const;
218 void SetBufferedOverlayAllowed(bool bNew);
220 // Allow page painting at all?
221 bool IsPagePaintingAllowed() const { return mbPagePaintingAllowed;}
222 void SetPagePaintingAllowed(bool bNew);
224 virtual rtl::Reference<sdr::overlay::OverlayManager> CreateOverlayManager(OutputDevice& rDevice) const;
226 protected:
227 svtools::ColorConfig maColorConfig;
228 Color maGridColor;
230 // Interface to SdrPaintWindow
231 void DeletePaintWindow(SdrPaintWindow& rOld);
232 void ConfigurationChanged( ::utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
233 void InitOverlayManager(rtl::Reference<sdr::overlay::OverlayManager> xOverlayManager) const;
235 public:
236 sal_uInt32 PaintWindowCount() const { return maPaintWindows.size(); }
237 SdrPaintWindow* FindPaintWindow(const OutputDevice& rOut) const;
238 SdrPaintWindow* GetPaintWindow(sal_uInt32 nIndex) const;
239 // Replacement for GetWin(0), may return 0L (!)
240 OutputDevice* GetFirstOutputDevice() const;
242 private:
243 SVX_DLLPRIVATE void ImpClearVars();
244 DECL_LINK(ImpComeBackHdl, Timer*, void);
246 protected:
247 sal_uInt16 ImpGetMinMovLogic(short nMinMov, const OutputDevice* pOut) const;
248 sal_uInt16 ImpGetHitTolLogic(short nHitTol, const OutputDevice* pOut) const;
250 // If one does not want to wait for the IdleState of the system (cheated as const)
251 void FlushComeBackTimer() const;
252 void TheresNewMapMode();
253 void ImpSetGlueVisible2(bool bOn) { if (mbGlueVisible2!=bOn) { mbGlueVisible2=bOn; if (!mbGlueVisible && !mbGlueVisible3 && !mbGlueVisible4) GlueInvalidate(); } }
254 void ImpSetGlueVisible3(bool bOn) { if (mbGlueVisible3!=bOn) { mbGlueVisible3=bOn; if (!mbGlueVisible && !mbGlueVisible2 && !mbGlueVisible4) GlueInvalidate(); } }
255 void ImpSetGlueVisible4(bool bOn) { if (mbGlueVisible4!=bOn) { mbGlueVisible4=bOn; if (!mbGlueVisible && !mbGlueVisible2 && !mbGlueVisible3) GlueInvalidate(); } }
257 public:
258 bool ImpIsGlueVisible() { return mbGlueVisible || mbGlueVisible2 || mbGlueVisible3 || mbGlueVisible4; }
260 protected:
261 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
262 void GlueInvalidate() const;
264 // ModelHasChanged is called, as soon as the system is idle again after many SdrHintKind::ObjectChange.
266 // Any sub-class override this method, MUST call the base class' ModelHasChanged() method
267 virtual void ModelHasChanged();
269 // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView
270 // A SdrView always needs a SdrModel for lifetime (Pool, ...)
271 SdrPaintView(SdrModel& rSdrModel, OutputDevice* pOut);
272 virtual ~SdrPaintView() override;
274 public:
275 // SdrModel access on SdrView level
276 SdrModel& getSdrModelFromSdrView() const { return mrSdrModelFromSdrView; }
278 virtual void ClearPageView();
279 SdrModel* GetModel() const { return mpModel; }
281 virtual bool IsAction() const;
282 virtual void MovAction(const Point& rPnt);
283 virtual void EndAction();
284 virtual void BckAction();
285 virtual void BrkAction(); // Cancel all Actions (e.g. cancel dragging)
286 virtual void TakeActionRect(tools::Rectangle& rRect) const;
288 // Info about TextEdit. Default is sal_False.
289 virtual bool IsTextEdit() const;
291 // Must be called for every Window change as well as MapMode (Scaling) change:
292 // If the SdrView is shown in multiple windows at the same time (e.g.
293 // using the split pane), so that I can convert my pixel values to logical
294 // values.
295 void SetActualWin(const OutputDevice* pWin);
296 void SetMinMoveDistancePixel(sal_uInt16 nVal) { mnMinMovPix=nVal; TheresNewMapMode(); }
297 void SetHitTolerancePixel(sal_uInt16 nVal) { mnHitTolPix=nVal; TheresNewMapMode(); }
298 sal_uInt16 GetHitTolerancePixel() const { return mnHitTolPix; }
300 // Data read access on logic HitTolerance and MinMoveTolerance
301 sal_uInt16 getHitTolLog() const { return mnHitTolLog; }
303 // Using the DragState we can tell e.g. which distance was
304 // already dragged
305 const SdrDragStat& GetDragStat() const { return maDragStat; }
307 // Registering/de-registering a PageView at a View
309 // The same Page cannot be registered multiple times.
311 // Methods ending in PgNum expect being passed a Page number.
312 // Methods ending in PvNum, instead, expect the number of the
313 // PageView at the SdrView (iterating over all registered Pages).
314 virtual SdrPageView* ShowSdrPage(SdrPage* pPage);
315 virtual void HideSdrPage();
317 // Iterate over all registered PageViews
318 SdrPageView* GetSdrPageView() const { return mpPageView.get(); }
320 // A SdrView can be displayed on multiple Windows at the same time
321 virtual void AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window* pWindow);
322 virtual void DeleteWindowFromPaintView(OutputDevice* pOldWin);
324 void SetLayerVisible(const OUString& rName, bool bShow);
325 bool IsLayerVisible(const OUString& rName) const;
327 void SetLayerLocked(const OUString& rName, bool bLock=true);
328 bool IsLayerLocked(const OUString& rName) const;
330 void SetLayerPrintable(const OUString& rName, bool bPrn);
331 bool IsLayerPrintable(const OUString& rName) const;
333 // PrePaint call forwarded from app windows
334 void PrePaint();
337 // Used internally for Draw/Impress/sch/chart2
338 virtual void CompleteRedraw(OutputDevice* pOut, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector = nullptr);
340 // #i72889# used from CompleteRedraw() implementation internally, added to be able to do a complete redraw in single steps
342 // BeginCompleteRedraw returns (or even creates) a SdrPaintWindow which will then be used as the
343 // target for paints. Since paints may be buffered, use its GetTargetOutputDevice() method which will
344 // return the buffer in case it's buffered.
346 // DoCompleteRedraw then draws the DrawingLayer hierarchy
347 // EndCompleteRedraw does the necessary refreshes, paints text edit and overlay as well as destroys the
348 // SdrPaintWindow again, if needed.
349 // This means: the SdrPaintWindow is no longer safe after this closing call.
350 virtual SdrPaintWindow* BeginCompleteRedraw(OutputDevice* pOut);
351 void DoCompleteRedraw(SdrPaintWindow& rPaintWindow, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector = nullptr);
352 virtual void EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer);
355 // Used for the other applications basctl/sc/sw which call DrawLayer at PageViews
356 // #i74769# Interface change to use common BeginCompleteRedraw/EndCompleteRedraw
357 // #i76114# bDisableIntersect disables intersecting rReg with the Window's paint region
358 SdrPaintWindow* BeginDrawLayers(OutputDevice* pOut, const vcl::Region& rReg, bool bDisableIntersect = false);
360 // Used when the region passed to BeginDrawLayers needs to be changed
361 void UpdateDrawLayersRegion(OutputDevice* pOut, const vcl::Region& rReg);
362 void EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer);
364 protected:
366 // Used to paint the form layer after the PreRender device is flushed (painted) to the window.
367 void ImpFormLayerDrawing( SdrPaintWindow& rPaintWindow );
369 static vcl::Region OptimizeDrawLayersRegion(OutputDevice* pOut, const vcl::Region& rReg, bool bDisableIntersect);
371 public:
372 /// Draw Page as a white area or not
373 bool IsPageVisible() const { return mbPageVisible; }
375 /// Draw Page shadow or not
376 bool IsPageShadowVisible() const { return mbPageShadowVisible; }
378 /// Draw Page as a white area or not
379 bool IsPageBorderVisible() const { return mbPageBorderVisible; }
381 /// Draw Border line or not
382 bool IsBordVisible() const { return mbBordVisible; }
384 /// Draw Grid or not
385 bool IsGridVisible() const { return mbGridVisible; }
387 /// Draw Grid in front of objects or behind them
388 bool IsGridFront() const { return mbGridFront ; }
390 /// Draw Help line of the Page or not
391 bool IsHlplVisible() const { return mbHlplVisible; }
393 /// Draw Help line in front of the objects or behind them
394 bool IsHlplFront() const { return mbHlplFront ; }
396 const Color& GetGridColor() const { return maGridColor;}
397 void SetPageVisible(bool bOn = true) { mbPageVisible=bOn; InvalidateAllWin(); }
398 void SetPageShadowVisible(bool bOn) { mbPageShadowVisible=bOn; InvalidateAllWin(); }
399 void SetPageBorderVisible(bool bOn = true) { mbPageBorderVisible=bOn; InvalidateAllWin(); }
400 void SetBordVisible(bool bOn = true) { mbBordVisible=bOn; InvalidateAllWin(); }
401 void SetGridVisible(bool bOn) { mbGridVisible=bOn; InvalidateAllWin(); }
402 void SetGridFront(bool bOn) { mbGridFront =bOn; InvalidateAllWin(); }
403 void SetHlplVisible(bool bOn = true) { mbHlplVisible=bOn; InvalidateAllWin(); }
404 void SetHlplFront(bool bOn) { mbHlplFront =bOn; InvalidateAllWin(); }
405 void SetGlueVisible(bool bOn = true) { if (mbGlueVisible!=bOn) { mbGlueVisible=bOn; if (!mbGlueVisible2 && !mbGlueVisible3 && !mbGlueVisible4) GlueInvalidate(); } }
407 bool IsPreviewRenderer() const { return mbPreviewRenderer; }
408 void SetPreviewRenderer(bool bOn) { mbPreviewRenderer=bOn; }
410 // Access methods for calc and sw hide object modes
411 bool getHideOle() const { return mbHideOle; }
412 bool getHideChart() const { return mbHideChart; }
413 bool getHideDraw() const { return mbHideDraw; }
414 bool getHideFormControl() const { return mbHideFormControl; }
415 void setHideOle(bool bNew) { if(bNew != mbHideOle) mbHideOle = bNew; }
416 void setHideChart(bool bNew) { if(bNew != mbHideChart) mbHideChart = bNew; }
417 void setHideDraw(bool bNew) { if(bNew != mbHideDraw) mbHideDraw = bNew; }
418 void setHideFormControl(bool bNew) { if(bNew != mbHideFormControl) mbHideFormControl = bNew; }
420 void SetGridCoarse(const Size& rSiz) { maGridBig=rSiz; }
421 void SetGridFine(const Size& rSiz) {
422 maGridFin=rSiz;
423 if (maGridFin.Height()==0) maGridFin.setHeight(maGridFin.Width());
424 if (mbGridVisible) InvalidateAllWin();
426 const Size& GetGridCoarse() const { return maGridBig; }
427 const Size& GetGridFine() const { return maGridFin; }
429 void InvalidateAllWin();
430 void InvalidateAllWin(const tools::Rectangle& rRect);
432 /// If the View should not call Invalidate() on the windows, override
433 /// the following 2 methods and do something else.
434 virtual void InvalidateOneWin(OutputDevice& rWin);
435 virtual void InvalidateOneWin(OutputDevice& rWin, const tools::Rectangle& rRect);
437 void SetActiveLayer(const OUString& rName) { maActualLayer=rName; }
438 const OUString& GetActiveLayer() const { return maActualLayer; }
440 /// Leave an object group of all visible Pages (like `chdir ..` in MSDOS)
441 void LeaveOneGroup();
443 /// Leave all entered object groups of all visible Pages (like `chdir \` in MSDOS)
444 void LeaveAllGroup();
446 /// Determine, whether Leave is useful or not
447 bool IsGroupEntered() const;
449 /// Default attributes at the View
450 /// Newly created objects are assigned these attributes by default when they are created.
451 void SetDefaultAttr(const SfxItemSet& rAttr, bool bReplaceAll);
452 const SfxItemSet& GetDefaultAttr() const { return maDefaultAttr; }
453 void SetDefaultStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
455 void SetNotPersistDefaultAttr(const SfxItemSet& rAttr);
456 void MergeNotPersistDefaultAttr(SfxItemSet& rAttr) const;
458 /// Execute a swap-in of e.g. graphics asynchronously.
459 /// This does not reload all graphics like Paint does, but kicks off
460 /// the loading there. When such an object is done loading, it is displayed.
461 /// TODO: Only works at the moment, if SwapGraphics is enabled in the model.
462 /// The default = false flag is non-persistent
463 bool IsSwapAsynchron() const { return mbSwapAsynchron; }
464 void SetSwapAsynchron(bool bJa=true) { mbSwapAsynchron=bJa; }
465 virtual bool KeyInput(const KeyEvent& rKEvt, vcl::Window* pWin);
467 virtual bool MouseButtonDown(const MouseEvent& /*rMEvt*/, OutputDevice* /*pWin*/) { return false; }
468 virtual bool MouseButtonUp(const MouseEvent& /*rMEvt*/, OutputDevice* /*pWin*/) { return false; }
469 virtual bool MouseMove(const MouseEvent& /*rMEvt*/, OutputDevice* /*pWin*/) { return false; }
470 virtual bool RequestHelp(const HelpEvent& /*rHEvt*/) { return false; }
471 virtual bool Command(const CommandEvent& /*rCEvt*/, vcl::Window* /*pWin*/) { return false; }
473 void GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
475 void SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
476 SfxStyleSheet* GetStyleSheet() const; // SfxStyleSheet* GetStyleSheet(bool& rOk) const;
477 void SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr);
479 virtual void MakeVisible(const tools::Rectangle& rRect, vcl::Window& rWin);
481 /// For Plugins
482 /// Is called by the Paint of the OLE object
483 virtual void DoConnect(SdrOle2Obj* pOleObj);
485 /// Enable/disable animations for ::Paint
486 /// Is used by e.g. SdrGrafObj, if it contains an animation
487 /// Preventing automatic animation is needed for e.g. the presentation view
488 bool IsAnimationEnabled() const { return ( SdrAnimationMode::Animate == meAnimationMode ); }
489 void SetAnimationEnabled( bool bEnable=true );
491 /// Set/unset pause state for animations
492 void SetAnimationPause( bool bSet );
494 /// Mode when starting an animation in the Paint Handler:
495 /// 1. SdrAnimationMode::Animate (default): start animation normally
496 /// 2. SDR_ANIMATION_DONT_ANIMATE: only show the replacement picture
497 /// 3. SdrAnimationMode::Disable: don't start and don't show any replacement
498 void SetAnimationMode( const SdrAnimationMode eMode );
500 /// The Browser is destroyed for bShow=false
501 #ifdef DBG_UTIL
502 void ShowItemBrowser(bool bShow);
503 bool IsItemBrowserVisible() const { return mpItemBrowser!=nullptr && GetItemBrowser()->IsVisible(); }
504 vcl::Window* GetItemBrowser() const;
505 #endif
507 /// Must be called by the App when scrolling etc. in order for
508 /// an active FormControl to be moved too
509 void VisAreaChanged(const OutputDevice* pOut);
510 void VisAreaChanged();
512 bool IsPrintPreview() const { return mbPrintPreview; }
513 void SetPrintPreview(bool bOn = true) { mbPrintPreview=bOn; }
515 const svtools::ColorConfig& getColorConfig() const { return maColorConfig;}
517 void onChangeColorConfig();
519 // #103834# Set background color for svx at SdrPageViews
520 void SetApplicationBackgroundColor(Color aBackgroundColor);
522 // #103911# Set document color for svx at SdrPageViews
523 void SetApplicationDocumentColor(Color aDocumentColor);
525 // #i38135#
526 // Sets the timer for Object animations and restarts.
527 void SetAnimationTimer(sal_uInt32 nTime);
529 // Access to Drawinglayer configuration options
530 const SvtOptionsDrawinglayer& getOptionsDrawinglayer() const { return maDrawinglayerOpt; }
533 #endif // INCLUDED_SVX_SVDPNTV_HXX
535 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */