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