/src/libreoffice/svx/source/svdraw/svdpntv.cxx
Line | Count | Source |
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 | | #include <memory> |
21 | | #include <svx/svdpntv.hxx> |
22 | | #include <vcl/weld/MessageDialog.hxx> |
23 | | #include <vcl/window.hxx> |
24 | | #include <svx/sdrpaintwindow.hxx> |
25 | | #include <svx/svdmodel.hxx> |
26 | | |
27 | | #include <svx/svdpage.hxx> |
28 | | #include <svx/svdpagv.hxx> |
29 | | #include <svl/hint.hxx> |
30 | | |
31 | | #include <svx/svdview.hxx> |
32 | | #include <svx/svdglue.hxx> |
33 | | #include <svx/svdobj.hxx> |
34 | | #include <sxlayitm.hxx> |
35 | | #include <svl/itemiter.hxx> |
36 | | #include <editeng/eeitem.hxx> |
37 | | #include <svl/whiter.hxx> |
38 | | #include <svl/style.hxx> |
39 | | #include <svx/sdrpagewindow.hxx> |
40 | | #include <vcl/svapp.hxx> |
41 | | #include <svx/sdr/contact/objectcontact.hxx> |
42 | | #include <svx/sdr/animation/objectanimator.hxx> |
43 | | #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> |
44 | | #include <drawinglayer/converters.hxx> |
45 | | #include <basegfx/matrix/b2dhommatrixtools.hxx> |
46 | | #include <comphelper/lok.hxx> |
47 | | #include <svx/svdviter.hxx> |
48 | | #include <osl/diagnose.h> |
49 | | #include <officecfg/Office/Common.hxx> |
50 | | |
51 | | using namespace ::com::sun::star; |
52 | | |
53 | | // interface to SdrPaintWindow |
54 | | |
55 | | SdrPaintWindow* SdrPaintView::FindPaintWindow(const OutputDevice& rOut) const |
56 | 62.5k | { |
57 | | // back to loop - there is more to test than a std::find_if and a lambda can do |
58 | 62.5k | for(auto& candidate : maPaintWindows) |
59 | 62.5k | { |
60 | 62.5k | if(&(candidate->GetOutputDevice()) == &rOut) |
61 | 62.5k | { |
62 | 62.5k | return candidate.get(); |
63 | 62.5k | } |
64 | | |
65 | | // check for patched to allow finding in that state, too |
66 | 0 | if(nullptr != candidate->getPatched() && &(candidate->getPatched()->GetOutputDevice()) == &rOut) |
67 | 0 | { |
68 | 0 | return candidate->getPatched(); |
69 | 0 | } |
70 | 0 | } |
71 | | |
72 | 0 | return nullptr; |
73 | 62.5k | } |
74 | | |
75 | | SdrPaintWindow* SdrPaintView::GetPaintWindow(sal_uInt32 nIndex) const |
76 | 733k | { |
77 | 733k | return maPaintWindows[nIndex].get(); |
78 | 733k | } |
79 | | |
80 | | void SdrPaintView::DeletePaintWindow(const SdrPaintWindow& rOld) |
81 | 0 | { |
82 | 0 | auto aFindResult = ::std::find_if(maPaintWindows.begin(), maPaintWindows.end(), |
83 | 0 | [&](const std::unique_ptr<SdrPaintWindow>& p) { return p.get() == &rOld; }); |
84 | |
|
85 | 0 | if(aFindResult != maPaintWindows.end()) |
86 | 0 | { |
87 | 0 | maPaintWindows.erase(aFindResult); |
88 | 0 | } |
89 | 0 | } |
90 | | |
91 | | OutputDevice* SdrPaintView::GetFirstOutputDevice() const |
92 | 66.6k | { |
93 | 66.6k | if(PaintWindowCount()) |
94 | 66.6k | { |
95 | 66.6k | return &(GetPaintWindow(0)->GetOutputDevice()); |
96 | 66.6k | } |
97 | | |
98 | 0 | return nullptr; |
99 | 66.6k | } |
100 | | |
101 | | |
102 | 160 | SvxViewChangedHint::SvxViewChangedHint() : SfxHint(SfxHintId::SvxViewChanged) |
103 | 160 | { |
104 | 160 | } |
105 | | |
106 | | |
107 | | Bitmap convertMetafileToBitmap( |
108 | | const GDIMetaFile& rMtf, |
109 | | const basegfx::B2DRange& rTargetRange, |
110 | | const sal_uInt32 nMaximumQuadraticPixels) |
111 | 0 | { |
112 | 0 | Bitmap aBitmap; |
113 | |
|
114 | 0 | if(rMtf.GetActionSize()) |
115 | 0 | { |
116 | 0 | const drawinglayer::primitive2d::Primitive2DReference aMtf( |
117 | 0 | new drawinglayer::primitive2d::MetafilePrimitive2D( |
118 | 0 | basegfx::utils::createScaleTranslateB2DHomMatrix( |
119 | 0 | rTargetRange.getRange(), |
120 | 0 | rTargetRange.getMinimum()), |
121 | 0 | rMtf)); |
122 | 0 | aBitmap = drawinglayer::convertPrimitive2DContainerToBitmap( |
123 | 0 | drawinglayer::primitive2d::Primitive2DContainer { aMtf }, |
124 | 0 | rTargetRange, |
125 | 0 | nMaximumQuadraticPixels); |
126 | 0 | } |
127 | |
|
128 | 0 | return aBitmap; |
129 | 0 | } |
130 | | |
131 | | SdrPaintView::SdrPaintView(SdrModel& rSdrModel, OutputDevice* pOut) |
132 | 138k | : mrModel(rSdrModel) |
133 | 138k | , mpActualOutDev(nullptr) |
134 | 138k | , mpDragWin(nullptr) |
135 | 138k | , mpDefaultStyleSheet(nullptr) |
136 | 138k | , maDefaultAttr(rSdrModel.GetItemPool()) |
137 | 138k | , maComeBackIdle( "svx::SdrPaintView aComeBackIdle" ) |
138 | 138k | , meAnimationMode(SdrAnimationMode::Animate) |
139 | 138k | , mnHitTolPix(2) |
140 | 138k | , mnMinMovPix(3) |
141 | 138k | , mnHitTolLog(0) |
142 | 138k | , mnMinMovLog(0) |
143 | 138k | , mbPageVisible(true) |
144 | 138k | , mbPageShadowVisible(true) |
145 | 138k | , mbPageBorderVisible(true) |
146 | 138k | , mbBordVisible(true) |
147 | 138k | , mbGridVisible(true) |
148 | 138k | , mbGridFront(false) |
149 | 138k | , mbHlplVisible(true) |
150 | 138k | , mbHlplFront(true) |
151 | 138k | , mbGlueVisible(false) |
152 | 138k | , mbGlueVisible2(false) |
153 | 138k | , mbGlueVisible3(false) |
154 | 138k | , mbGlueVisible4(false) |
155 | 138k | , mbSomeObjChgdFlag(false) |
156 | 138k | , mbSwapAsynchron(false) |
157 | 138k | , mbPrintPreview(false) |
158 | 138k | , mbAnimationPause(false) |
159 | 138k | , mbBufferedOutputAllowed(false) |
160 | 138k | , mbBufferedOverlayAllowed(false) |
161 | 138k | , mbPageDecorationAllowed(true) |
162 | 138k | , mbMasterPageVisualizationAllowed(true) |
163 | 138k | , mbPreviewRenderer(false) |
164 | 138k | , mbHideOle(false) |
165 | 138k | , mbHideChart(false) |
166 | 138k | , mbHideDraw(false) |
167 | 138k | , mbHideFormControl(false) |
168 | 138k | , mbHideBackground(false) |
169 | 138k | , mbPaintTextEdit(true) |
170 | 138k | , maGridColor(COL_BLACK) |
171 | 138k | { |
172 | 138k | maComeBackIdle.SetPriority(TaskPriority::REPAINT); |
173 | 138k | maComeBackIdle.SetInvokeHandler(LINK(this,SdrPaintView,ImpComeBackHdl)); |
174 | | |
175 | 138k | SetDefaultStyleSheet(GetModel().GetDefaultStyleSheet(), true); |
176 | | |
177 | 138k | if (pOut) |
178 | 66.6k | AddDeviceToPaintView(*pOut); |
179 | | |
180 | 138k | maColorConfig.AddListener(this); |
181 | 138k | onChangeColorConfig(); |
182 | 138k | } |
183 | | |
184 | | SdrPaintView::~SdrPaintView() |
185 | 138k | { |
186 | 138k | if (mpDefaultStyleSheet) |
187 | 30.9k | EndListening(*mpDefaultStyleSheet); |
188 | | |
189 | 138k | maColorConfig.RemoveListener(this); |
190 | 138k | ClearPageView(); |
191 | | |
192 | | // delete existing SdrPaintWindows |
193 | 138k | maPaintWindows.clear(); |
194 | 138k | } |
195 | | |
196 | | |
197 | | void SdrPaintView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) |
198 | 1.56M | { |
199 | | //If the stylesheet has been destroyed |
200 | 1.56M | if (&rBC == mpDefaultStyleSheet) |
201 | 4.35k | { |
202 | 4.35k | if (rHint.GetId() == SfxHintId::Dying) |
203 | 0 | mpDefaultStyleSheet = nullptr; |
204 | 4.35k | return; |
205 | 4.35k | } |
206 | | |
207 | 1.55M | if (rHint.GetId() != SfxHintId::ThisIsAnSdrHint) |
208 | 9.55k | return; |
209 | 1.54M | const SdrHint* pSdrHint = static_cast<const SdrHint*>(&rHint); |
210 | 1.54M | SdrHintKind eKind = pSdrHint->GetKind(); |
211 | 1.54M | if (eKind==SdrHintKind::ObjectChange || eKind==SdrHintKind::ObjectInserted || eKind==SdrHintKind::ObjectRemoved) |
212 | 258k | { |
213 | 258k | bool bObjChg = !mbSomeObjChgdFlag; // if true, evaluate for ComeBack timer |
214 | 258k | if (bObjChg) |
215 | 25.9k | { |
216 | 25.9k | mbSomeObjChgdFlag=true; |
217 | 25.9k | const SdrModel& rModel = GetModel(); |
218 | 25.9k | if (rModel.IsWriterIdle()) |
219 | 0 | { |
220 | | // We're inside Writer idle layout: don't pick a high priority. |
221 | 0 | maComeBackIdle.SetPriority(TaskPriority::DEFAULT_IDLE); |
222 | 0 | } |
223 | 25.9k | else |
224 | 25.9k | { |
225 | 25.9k | maComeBackIdle.SetPriority(TaskPriority::REPAINT); |
226 | 25.9k | } |
227 | 25.9k | maComeBackIdle.Start(); |
228 | 25.9k | } |
229 | 258k | } |
230 | | |
231 | 1.54M | if (eKind==SdrHintKind::PageOrderChange) |
232 | 1.25M | { |
233 | 1.25M | const SdrPage* pPg=pSdrHint->GetPage(); |
234 | 1.25M | if (pPg && !pPg->IsInserted()) |
235 | 424k | { |
236 | 424k | if(mpPageView && mpPageView->GetPage() == pPg) |
237 | 0 | { |
238 | 0 | HideSdrPage(); |
239 | 0 | } |
240 | 424k | } |
241 | 1.25M | } |
242 | 1.54M | } |
243 | | |
244 | | void SdrPaintView::ConfigurationChanged( ::utl::ConfigurationBroadcaster* , ConfigurationHints eHint) |
245 | 0 | { |
246 | 0 | if (eHint == ConfigurationHints::OnlyCurrentDocumentColorScheme) |
247 | 0 | return; |
248 | 0 | onChangeColorConfig(); |
249 | 0 | InvalidateAllWin(); |
250 | 0 | } |
251 | | |
252 | | IMPL_LINK_NOARG(SdrPaintView, ImpComeBackHdl, Timer *, void) |
253 | 0 | { |
254 | 0 | if (mbSomeObjChgdFlag) { |
255 | 0 | mbSomeObjChgdFlag=false; |
256 | 0 | ModelHasChanged(); |
257 | 0 | } |
258 | 0 | } |
259 | | |
260 | | void SdrPaintView::FlushComeBackTimer() const |
261 | 0 | { |
262 | 0 | if (mbSomeObjChgdFlag) { |
263 | | // casting to nonconst |
264 | 0 | const_cast<SdrPaintView*>(this)->ImpComeBackHdl(&const_cast<SdrPaintView*>(this)->maComeBackIdle); |
265 | 0 | const_cast<SdrPaintView*>(this)->maComeBackIdle.Stop(); |
266 | 0 | } |
267 | 0 | } |
268 | | |
269 | | void SdrPaintView::ModelHasChanged() |
270 | 0 | { |
271 | | // broadcast to all PageViews |
272 | 0 | if(mpPageView && !mpPageView->GetPage()->IsInserted()) |
273 | 0 | { |
274 | 0 | HideSdrPage(); |
275 | 0 | } |
276 | | |
277 | | // test mpPageView here again, HideSdrPage() may have invalidated it. |
278 | 0 | if(mpPageView) |
279 | 0 | { |
280 | 0 | mpPageView->ModelHasChanged(); |
281 | 0 | } |
282 | 0 | } |
283 | | |
284 | | |
285 | | bool SdrPaintView::IsAction() const |
286 | 0 | { |
287 | 0 | return false; |
288 | 0 | } |
289 | | |
290 | | void SdrPaintView::MovAction(const Point&) |
291 | 0 | { |
292 | 0 | } |
293 | | |
294 | | void SdrPaintView::EndAction() |
295 | 0 | { |
296 | 0 | } |
297 | | |
298 | | void SdrPaintView::BckAction() |
299 | 0 | { |
300 | 0 | } |
301 | | |
302 | | void SdrPaintView::BrkAction() |
303 | 205k | { |
304 | 205k | } |
305 | | |
306 | | void SdrPaintView::TakeActionRect(tools::Rectangle&) const |
307 | 0 | { |
308 | 0 | } |
309 | | |
310 | | |
311 | | // info about TextEdit. Default is false. |
312 | | bool SdrPaintView::IsTextEdit() const |
313 | 0 | { |
314 | 0 | return false; |
315 | 0 | } |
316 | | |
317 | | sal_uInt16 SdrPaintView::ImpGetMinMovLogic(short nMinMov, const OutputDevice* pOut) const |
318 | 0 | { |
319 | 0 | if (nMinMov>=0) return sal_uInt16(nMinMov); |
320 | 0 | if (pOut==nullptr) |
321 | 0 | { |
322 | 0 | pOut = GetFirstOutputDevice(); |
323 | 0 | } |
324 | 0 | if (pOut!=nullptr) { |
325 | 0 | return short(-pOut->PixelToLogic(Size(nMinMov,0)).Width()); |
326 | 0 | } else { |
327 | 0 | return 0; |
328 | 0 | } |
329 | 0 | } |
330 | | |
331 | | sal_uInt16 SdrPaintView::ImpGetHitTolLogic(short nHitTol, const OutputDevice* pOut) const |
332 | 0 | { |
333 | 0 | if (nHitTol>=0) return sal_uInt16(nHitTol); |
334 | 0 | if (pOut==nullptr) |
335 | 0 | { |
336 | 0 | pOut = GetFirstOutputDevice(); |
337 | 0 | } |
338 | 0 | if (pOut!=nullptr) { |
339 | 0 | return short(-pOut->PixelToLogic(Size(nHitTol,0)).Width()); |
340 | 0 | } else { |
341 | 0 | return 0; |
342 | 0 | } |
343 | 0 | } |
344 | | |
345 | | void SdrPaintView::TheresNewMapMode() |
346 | 66.8k | { |
347 | 66.8k | if (mpActualOutDev) { |
348 | 160 | if (comphelper::LibreOfficeKit::isActive()) |
349 | 0 | { |
350 | 0 | mnHitTolLog=static_cast<sal_uInt16>(OutputDevice::LogicToLogic(Size(mnHitTolPix,0), MapMode(MapUnit::MapPixel), mpActualOutDev->GetMapMode()).Width()); |
351 | 0 | mnMinMovLog=static_cast<sal_uInt16>(OutputDevice::LogicToLogic(Size(mnMinMovPix,0), MapMode(MapUnit::MapPixel), mpActualOutDev->GetMapMode()).Width()); |
352 | 0 | } |
353 | 160 | else |
354 | 160 | { |
355 | 160 | mnHitTolLog=static_cast<sal_uInt16>(mpActualOutDev->PixelToLogic(Size(mnHitTolPix,0)).Width()); |
356 | 160 | mnMinMovLog=static_cast<sal_uInt16>(mpActualOutDev->PixelToLogic(Size(mnMinMovPix,0)).Width()); |
357 | 160 | } |
358 | 160 | } |
359 | 66.8k | } |
360 | | |
361 | | void SdrPaintView::SetActualWin(const OutputDevice* pWin) |
362 | 160 | { |
363 | 160 | mpActualOutDev = const_cast<OutputDevice *>(pWin); |
364 | 160 | TheresNewMapMode(); |
365 | 160 | } |
366 | | |
367 | | |
368 | | void SdrPaintView::ClearPageView() |
369 | 138k | { |
370 | 138k | BrkAction(); |
371 | | |
372 | 138k | if(mpPageView) |
373 | 0 | { |
374 | 0 | InvalidateAllWin(); |
375 | 0 | mpPageView.reset(); |
376 | 0 | } |
377 | 138k | } |
378 | | |
379 | | SdrPageView* SdrPaintView::ShowSdrPage(SdrPage* pPage) |
380 | 66.6k | { |
381 | 66.6k | if(pPage && (!mpPageView || mpPageView->GetPage() != pPage)) |
382 | 66.6k | { |
383 | 66.6k | if(mpPageView) |
384 | 0 | { |
385 | 0 | InvalidateAllWin(); |
386 | 0 | mpPageView.reset(); |
387 | 0 | } |
388 | | |
389 | 66.6k | if (SdrView *pView = dynamic_cast<SdrView*>(this)) |
390 | 66.6k | { |
391 | 66.6k | mpPageView.reset(new SdrPageView(pPage, *pView)); |
392 | 66.6k | mpPageView->Show(); |
393 | 66.6k | } |
394 | 66.6k | } |
395 | | |
396 | 66.6k | return mpPageView.get(); |
397 | 66.6k | } |
398 | | |
399 | | void SdrPaintView::HideSdrPage() |
400 | 66.6k | { |
401 | 66.6k | if(mpPageView) |
402 | 66.6k | { |
403 | 66.6k | mpPageView->Hide(); |
404 | 66.6k | mpPageView.reset(); |
405 | 66.6k | } |
406 | 66.6k | } |
407 | | |
408 | | void SdrPaintView::AddDeviceToPaintView(OutputDevice& rNewDev) |
409 | 66.6k | { |
410 | 66.6k | SdrPaintWindow* pNewPaintWindow = new SdrPaintWindow(*this, rNewDev); |
411 | 66.6k | maPaintWindows.emplace_back(pNewPaintWindow); |
412 | | |
413 | 66.6k | if(mpPageView) |
414 | 0 | { |
415 | 0 | mpPageView->AddPaintWindowToPageView(*pNewPaintWindow); |
416 | 0 | } |
417 | 66.6k | } |
418 | | |
419 | | void SdrPaintView::DeleteDeviceFromPaintView(OutputDevice& rOldDev) |
420 | 0 | { |
421 | 0 | SdrPaintWindow* pCandidate = FindPaintWindow(rOldDev); |
422 | |
|
423 | 0 | if(pCandidate) |
424 | 0 | { |
425 | 0 | if(mpPageView) |
426 | 0 | { |
427 | 0 | mpPageView->RemovePaintWindowFromPageView(*pCandidate); |
428 | 0 | } |
429 | |
|
430 | 0 | DeletePaintWindow(*pCandidate); |
431 | 0 | } |
432 | 0 | } |
433 | | |
434 | | void SdrPaintView::SetLayerVisible(const OUString& rName, bool bShow) |
435 | 0 | { |
436 | 0 | const bool bChanged = mpPageView && mpPageView->SetLayerVisible(rName, bShow); |
437 | 0 | if (!bChanged) |
438 | 0 | return; |
439 | 0 | InvalidateAllWin(); |
440 | 0 | } |
441 | | |
442 | | bool SdrPaintView::IsLayerVisible(const OUString& rName) const |
443 | 0 | { |
444 | 0 | return mpPageView && mpPageView->IsLayerVisible(rName); |
445 | 0 | } |
446 | | |
447 | | void SdrPaintView::SetLayerLocked(const OUString& rName, bool bLock) |
448 | 0 | { |
449 | 0 | if(mpPageView) |
450 | 0 | { |
451 | 0 | mpPageView->SetLayerLocked(rName,bLock); |
452 | 0 | } |
453 | 0 | } |
454 | | |
455 | | bool SdrPaintView::IsLayerLocked(const OUString& rName) const |
456 | 0 | { |
457 | 0 | if(mpPageView) |
458 | 0 | { |
459 | 0 | return mpPageView->IsLayerLocked(rName); |
460 | 0 | } |
461 | | |
462 | 0 | return false; |
463 | 0 | } |
464 | | |
465 | | void SdrPaintView::SetLayerPrintable(const OUString& rName, bool bPrn) |
466 | 125k | { |
467 | 125k | if(mpPageView) |
468 | 125k | { |
469 | 125k | mpPageView->SetLayerPrintable(rName,bPrn); |
470 | 125k | } |
471 | 125k | } |
472 | | |
473 | | bool SdrPaintView::IsLayerPrintable(const OUString& rName) const |
474 | 62.5k | { |
475 | 62.5k | if(mpPageView) |
476 | 62.5k | { |
477 | 62.5k | return mpPageView->IsLayerPrintable(rName); |
478 | 62.5k | } |
479 | | |
480 | 0 | return false; |
481 | 62.5k | } |
482 | | |
483 | | void SdrPaintView::PrePaint() |
484 | 0 | { |
485 | 0 | if(mpPageView) |
486 | 0 | { |
487 | 0 | mpPageView->PrePaint(); |
488 | 0 | } |
489 | 0 | } |
490 | | |
491 | | |
492 | | // #define SVX_REPAINT_TIMER_TEST |
493 | | |
494 | | void SdrPaintView::CompleteRedraw(OutputDevice* pOut, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector) |
495 | 0 | { |
496 | | #ifdef SVX_REPAINT_TIMER_TEST |
497 | | #define REMEMBERED_TIMES_COUNT (10) |
498 | | static bool bDoTimerTest(false); |
499 | | static bool bTimesInited(false); |
500 | | static sal_uInt32 nRepeatCount(10); |
501 | | static double fLastTimes[REMEMBERED_TIMES_COUNT]; |
502 | | const sal_uInt64 nStartTime(tools::Time::GetSystemTicks()); |
503 | | sal_uInt32 count(1); |
504 | | sal_uInt32 a; |
505 | | |
506 | | if(bDoTimerTest) |
507 | | { |
508 | | count = nRepeatCount; |
509 | | } |
510 | | |
511 | | for(a = 0; a < count; a++) |
512 | | { |
513 | | #endif // SVX_REPAINT_TIMER_TEST |
514 | | |
515 | | // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region |
516 | | // rReg may be made more granular (fine) with using it. Normally, rReg |
517 | | // does come from Window::Paint() anyways and thus is based on a single |
518 | | // rectangle which was derived from exactly that repaint region |
519 | 0 | vcl::Region aOptimizedRepaintRegion(rReg); |
520 | |
|
521 | 0 | if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType()) |
522 | 0 | { |
523 | 0 | vcl::Window* pWindow = pOut->GetOwnerWindow(); |
524 | |
|
525 | 0 | if(pWindow->IsInPaint()) |
526 | 0 | { |
527 | 0 | if(!pWindow->GetPaintRegion().IsEmpty()) |
528 | 0 | { |
529 | 0 | aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion()); |
530 | 0 | } |
531 | 0 | } |
532 | 0 | } |
533 | |
|
534 | 0 | SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut); |
535 | 0 | assert(pPaintWindow && "SdrPaintView::CompleteRedraw: No OutDev (!)"); |
536 | |
|
537 | 0 | DoCompleteRedraw(*pPaintWindow, aOptimizedRepaintRegion, pRedirector); |
538 | 0 | EndCompleteRedraw(*pPaintWindow, true); |
539 | |
|
540 | | #ifdef SVX_REPAINT_TIMER_TEST |
541 | | } |
542 | | |
543 | | if(bDoTimerTest) |
544 | | { |
545 | | const sal_uInt64 nStopTime(tools::Time::GetSystemTicks()); |
546 | | const sal_uInt64 nNeededTime(nStopTime - nStartTime); |
547 | | const double fTimePerPaint((double)nNeededTime / (double)nRepeatCount); |
548 | | |
549 | | if(!bTimesInited) |
550 | | { |
551 | | for(a = 0; a < REMEMBERED_TIMES_COUNT; a++) |
552 | | { |
553 | | fLastTimes[a] = fTimePerPaint; |
554 | | } |
555 | | |
556 | | bTimesInited = true; |
557 | | } |
558 | | else |
559 | | { |
560 | | for(a = 1; a < REMEMBERED_TIMES_COUNT; a++) |
561 | | { |
562 | | fLastTimes[a - 1] = fLastTimes[a]; |
563 | | } |
564 | | |
565 | | fLastTimes[REMEMBERED_TIMES_COUNT - 1] = fTimePerPaint; |
566 | | } |
567 | | |
568 | | double fAddedTimes(0.0); |
569 | | |
570 | | for(a = 0; a < REMEMBERED_TIMES_COUNT; a++) |
571 | | { |
572 | | fAddedTimes += fLastTimes[a]; |
573 | | } |
574 | | |
575 | | const double fAverageTimePerPaint(fAddedTimes / (double)REMEMBERED_TIMES_COUNT); |
576 | | |
577 | | fprintf(stderr, "-----------(start result)----------\n"); |
578 | | fprintf(stderr, "StartTime : %" SAL_PRIuUINT64 ", StopTime: %" SAL_PRIuUINT64 ", NeededTime: %" SAL_PRIuUINT64 ", TimePerPaint: %f\n", nStartTime, nStopTime, nNeededTime, fTimePerPaint); |
579 | | fprintf(stderr, "Remembered times: "); |
580 | | |
581 | | for(a = 0; a < REMEMBERED_TIMES_COUNT; a++) |
582 | | { |
583 | | fprintf(stderr, "%d: %f ", a, fLastTimes[a]); |
584 | | } |
585 | | |
586 | | fprintf(stderr, "\n"); |
587 | | fprintf(stderr, "AverageTimePerPaint: %f\n", fAverageTimePerPaint); |
588 | | fprintf(stderr, "-----------(stop result)----------\n"); |
589 | | } |
590 | | #endif // SVX_REPAINT_TIMER_TEST |
591 | 0 | } |
592 | | |
593 | | |
594 | | // #i72889# |
595 | | |
596 | | SdrPaintWindow* SdrPaintView::BeginCompleteRedraw(OutputDevice* pOut) |
597 | 62.5k | { |
598 | 62.5k | assert(pOut && "SdrPaintView::BeginCompleteRedraw: No OutDev (!)"); |
599 | 62.5k | SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut); |
600 | | |
601 | 62.5k | if(pPaintWindow) |
602 | 62.5k | { |
603 | | // draw preprocessing, only for known devices |
604 | | // prepare PreRendering |
605 | 62.5k | pPaintWindow->PreparePreRenderDevice(); |
606 | 62.5k | } |
607 | 0 | else |
608 | 0 | { |
609 | | // None of the known OutputDevices is the target of this paint, use |
610 | | // a temporary SdrPaintWindow for this Redraw. |
611 | 0 | pPaintWindow = new SdrPaintWindow(*this, *pOut); |
612 | 0 | pPaintWindow->setTemporaryTarget(true); |
613 | 0 | } |
614 | | |
615 | 62.5k | return pPaintWindow; |
616 | 62.5k | } |
617 | | |
618 | | void SdrPaintView::DoCompleteRedraw(SdrPaintWindow& rPaintWindow, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector) |
619 | 0 | { |
620 | | // redraw all PageViews with the target. This may expand the RedrawRegion |
621 | | // at the PaintWindow, plus taking care of FormLayer expansion |
622 | 0 | if(mpPageView) |
623 | 0 | { |
624 | 0 | mpPageView->CompleteRedraw(rPaintWindow, rReg, pRedirector); |
625 | 0 | } |
626 | 0 | } |
627 | | |
628 | | void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer, |
629 | | sdr::contact::ViewObjectContactRedirector* pRedirector) |
630 | 62.5k | { |
631 | 62.5k | std::unique_ptr<SdrPaintWindow> pPaintWindow; |
632 | 62.5k | if (comphelper::LibreOfficeKit::isActive() && rPaintWindow.getTemporaryTarget()) |
633 | 0 | { |
634 | | // Tiled rendering, we must paint the TextEdit to the output device. |
635 | 0 | pPaintWindow.reset(&rPaintWindow); |
636 | 0 | pPaintWindow->setTemporaryTarget(false); |
637 | 0 | } |
638 | | |
639 | 62.5k | if(rPaintWindow.getTemporaryTarget()) |
640 | 0 | { |
641 | | // get rid of temp target again |
642 | 0 | delete &rPaintWindow; |
643 | 0 | } |
644 | 62.5k | else |
645 | 62.5k | { |
646 | | // draw postprocessing, only for known devices |
647 | | // it is necessary to always paint FormLayer |
648 | | // In the LOK case control rendering is performed through LokControlHandler |
649 | | // except when the document is exported to PDF or printed, |
650 | | // so we use isTiledPainting() in place of the more generic isActive() |
651 | 62.5k | if(!comphelper::LibreOfficeKit::isTiledPainting() && bPaintFormLayer) |
652 | 62.5k | { |
653 | 62.5k | ImpFormLayerDrawing(rPaintWindow, pRedirector); |
654 | 62.5k | } |
655 | | |
656 | | // look for active TextEdit. As long as this cannot be painted to a VDev, |
657 | | // it cannot get part of buffering. In that case, output evtl. prerender |
658 | | // early and paint text edit to window. |
659 | 62.5k | SdrPageView* pPageView = GetSdrPageView(); |
660 | 62.5k | if(IsTextEdit() && pPageView) |
661 | 0 | { |
662 | 0 | if (!comphelper::LibreOfficeKit::isActive() || mbPaintTextEdit) |
663 | 0 | static_cast< SdrView* >(this)->TextEditDrawing(rPaintWindow); |
664 | 0 | } |
665 | | |
666 | 62.5k | if (comphelper::LibreOfficeKit::isActive() && pPageView) |
667 | 0 | { |
668 | | // Look for active text edits in other views showing the same page, |
669 | | // and show them as well. Show only if Page/MasterPage mode is matching. |
670 | 0 | bool bRequireMasterPage = pPageView->GetPage() ? pPageView->GetPage()->IsMasterPage() : false; |
671 | 0 | SdrViewIter::ForAllViews(pPageView->GetPage(), |
672 | 0 | [this, &bRequireMasterPage, &rPaintWindow] (SdrView* pView) |
673 | 0 | { |
674 | 0 | SdrPageView* pCurrentPageView = pView->GetSdrPageView(); |
675 | 0 | bool bIsCurrentMasterPage = (pCurrentPageView && pCurrentPageView->GetPage()) ? |
676 | 0 | pCurrentPageView->GetPage()->IsMasterPage() : false; |
677 | |
|
678 | 0 | if (pView == this || bRequireMasterPage != bIsCurrentMasterPage) |
679 | 0 | return false; |
680 | | |
681 | 0 | if (pView->IsTextEdit() && pView->GetSdrPageView()) |
682 | 0 | { |
683 | 0 | pView->TextEditDrawing(rPaintWindow); |
684 | 0 | } |
685 | 0 | return false; |
686 | 0 | }); |
687 | 0 | } |
688 | | |
689 | | // draw Overlay, also to PreRender device if exists |
690 | 62.5k | rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion()); |
691 | | |
692 | | // output PreRendering |
693 | 62.5k | rPaintWindow.OutputPreRenderDevice(rPaintWindow.GetRedrawRegion()); |
694 | 62.5k | } |
695 | 62.5k | } |
696 | | |
697 | | SdrPaintWindow* SdrPaintView::BeginDrawLayers(OutputDevice* pOut, const vcl::Region& rReg, bool bDisableIntersect) |
698 | 62.5k | { |
699 | | // #i74769# use BeginCompleteRedraw() as common base |
700 | 62.5k | SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut); |
701 | 62.5k | assert(pPaintWindow && "SdrPaintView::BeginDrawLayers: No SdrPaintWindow (!)"); |
702 | | |
703 | 62.5k | if(mpPageView) |
704 | 62.5k | { |
705 | 62.5k | SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(*pPaintWindow); |
706 | | |
707 | 62.5k | if(pKnownTarget) |
708 | 62.5k | { |
709 | 62.5k | vcl::Region aOptimizedRepaintRegion = OptimizeDrawLayersRegion( pOut, rReg, bDisableIntersect ); |
710 | | |
711 | | // prepare redraw |
712 | 62.5k | pKnownTarget->PrepareRedraw(aOptimizedRepaintRegion); |
713 | | |
714 | | // remember prepared SdrPageWindow |
715 | 62.5k | mpPageView->setPreparedPageWindow(pKnownTarget); |
716 | 62.5k | } |
717 | 62.5k | } |
718 | | |
719 | 62.5k | return pPaintWindow; |
720 | 62.5k | } |
721 | | |
722 | | void SdrPaintView::EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer, |
723 | | sdr::contact::ViewObjectContactRedirector* pRedirector) |
724 | 62.5k | { |
725 | | // #i74769# use EndCompleteRedraw() as common base |
726 | 62.5k | EndCompleteRedraw(rPaintWindow, bPaintFormLayer, pRedirector); |
727 | | |
728 | 62.5k | if(mpPageView) |
729 | 62.5k | { |
730 | | // forget prepared SdrPageWindow |
731 | 62.5k | mpPageView->setPreparedPageWindow(nullptr); |
732 | 62.5k | } |
733 | 62.5k | } |
734 | | |
735 | | void SdrPaintView::UpdateDrawLayersRegion(const OutputDevice* pOut, const vcl::Region& rReg) |
736 | 6 | { |
737 | 6 | SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut); |
738 | 6 | assert(pPaintWindow && "SdrPaintView::UpdateDrawLayersRegion: No SdrPaintWindow (!)"); |
739 | | |
740 | 6 | if(mpPageView) |
741 | 6 | { |
742 | 6 | SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(*pPaintWindow); |
743 | | |
744 | 6 | if(pKnownTarget) |
745 | 6 | { |
746 | 6 | vcl::Region aOptimizedRepaintRegion = OptimizeDrawLayersRegion( pOut, rReg, false/*bDisableIntersect*/ ); |
747 | 6 | pKnownTarget->GetPaintWindow().SetRedrawRegion(aOptimizedRepaintRegion); |
748 | 6 | mpPageView->setPreparedPageWindow(pKnownTarget); // already set actually |
749 | 6 | } |
750 | 6 | } |
751 | 6 | } |
752 | | |
753 | | vcl::Region SdrPaintView::OptimizeDrawLayersRegion(const OutputDevice* pOut, const vcl::Region& rReg, bool bDisableIntersect) |
754 | 62.5k | { |
755 | | // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region |
756 | | // rReg may be made more granular (fine) with using it. Normally, rReg |
757 | | // does come from Window::Paint() anyways and thus is based on a single |
758 | | // rectangle which was derived from exactly that repaint region |
759 | 62.5k | vcl::Region aOptimizedRepaintRegion(rReg); |
760 | | |
761 | | // #i76114# Intersecting the region with the Window's paint region is disabled |
762 | | // for print preview in Calc, because the intersection can be empty (if the paint |
763 | | // region is outside of the table area of the page), and then no clip region |
764 | | // would be set. |
765 | 62.5k | if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType() && !bDisableIntersect) |
766 | 9 | { |
767 | 9 | vcl::Window* pWindow = pOut->GetOwnerWindow(); |
768 | | |
769 | 9 | if(pWindow->IsInPaint()) |
770 | 0 | { |
771 | 0 | if(!pWindow->GetPaintRegion().IsEmpty()) |
772 | 0 | { |
773 | 0 | aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion()); |
774 | 0 | } |
775 | 0 | } |
776 | 9 | } |
777 | 62.5k | return aOptimizedRepaintRegion; |
778 | 62.5k | } |
779 | | |
780 | | |
781 | | void SdrPaintView::ImpFormLayerDrawing( SdrPaintWindow& rPaintWindow, |
782 | | sdr::contact::ViewObjectContactRedirector* pRedirector ) |
783 | 62.5k | { |
784 | 62.5k | if(!mpPageView) |
785 | 0 | return; |
786 | | |
787 | 62.5k | SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(rPaintWindow); |
788 | | |
789 | 62.5k | if(pKnownTarget) |
790 | 62.5k | { |
791 | 62.5k | const SdrModel& rModel = GetModel(); |
792 | 62.5k | const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin(); |
793 | 62.5k | const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName()); |
794 | | |
795 | | // BUFFERED use GetTargetOutputDevice() now, it may be targeted to VDevs, too |
796 | | // need to set PreparedPageWindow to make DrawLayer use the correct ObjectContact |
797 | 62.5k | mpPageView->setPreparedPageWindow(pKnownTarget); |
798 | 62.5k | mpPageView->DrawLayer(nControlLayerId, &rPaintWindow.GetTargetOutputDevice(), |
799 | 62.5k | pRedirector); |
800 | 62.5k | mpPageView->setPreparedPageWindow(nullptr); |
801 | 62.5k | } |
802 | 62.5k | } |
803 | | |
804 | | |
805 | | bool SdrPaintView::KeyInput(const KeyEvent& /*rKEvt*/, vcl::Window* /*pWin*/) |
806 | 0 | { |
807 | 0 | return false; |
808 | 0 | } |
809 | | |
810 | | void SdrPaintView::GlueInvalidate() const |
811 | 0 | { |
812 | | // Do not invalidate GluePoints in Online |
813 | | // They are handled on front-end |
814 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
815 | 0 | return; |
816 | | |
817 | 0 | const sal_uInt32 nWindowCount(PaintWindowCount()); |
818 | |
|
819 | 0 | for(sal_uInt32 nWinNum(0); nWinNum < nWindowCount; nWinNum++) |
820 | 0 | { |
821 | 0 | SdrPaintWindow* pPaintWindow = GetPaintWindow(nWinNum); |
822 | |
|
823 | 0 | if(pPaintWindow->OutputToWindow()) |
824 | 0 | { |
825 | 0 | OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); |
826 | |
|
827 | 0 | if(mpPageView) |
828 | 0 | { |
829 | 0 | const SdrObjList* pOL=mpPageView->GetObjList(); |
830 | 0 | for (const rtl::Reference<SdrObject>& pObj : *pOL) { |
831 | 0 | const SdrGluePointList* pGPL=pObj->GetGluePointList(); |
832 | 0 | if (pGPL!=nullptr && pGPL->GetCount()!=0) { |
833 | 0 | pGPL->Invalidate(*rOutDev.GetOwnerWindow(), pObj.get()); |
834 | 0 | } |
835 | 0 | } |
836 | 0 | } |
837 | 0 | } |
838 | 0 | } |
839 | 0 | } |
840 | | |
841 | | void SdrPaintView::InvalidateAllWin() |
842 | 295k | { |
843 | 295k | const sal_uInt32 nWindowCount(PaintWindowCount()); |
844 | | |
845 | 561k | for(sal_uInt32 a(0); a < nWindowCount; a++) |
846 | 266k | { |
847 | 266k | SdrPaintWindow* pPaintWindow = GetPaintWindow(a); |
848 | | |
849 | 266k | if(pPaintWindow->OutputToWindow()) |
850 | 16.5k | { |
851 | 16.5k | InvalidateOneWin(pPaintWindow->GetOutputDevice()); |
852 | 16.5k | } |
853 | 266k | } |
854 | 295k | } |
855 | | |
856 | | void SdrPaintView::InvalidateAllWin(const tools::Rectangle& rRect) |
857 | 266k | { |
858 | 266k | const sal_uInt32 nWindowCount(PaintWindowCount()); |
859 | | |
860 | 533k | for(sal_uInt32 a(0); a < nWindowCount; a++) |
861 | 266k | { |
862 | 266k | SdrPaintWindow* pPaintWindow = GetPaintWindow(a); |
863 | | |
864 | 266k | if(pPaintWindow->OutputToWindow()) |
865 | 16.5k | { |
866 | 16.5k | OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); |
867 | 16.5k | tools::Rectangle aRect(rRect); |
868 | | |
869 | 16.5k | Point aOrg(rOutDev.GetMapMode().GetOrigin()); |
870 | 16.5k | aOrg.setX(-aOrg.X() ); aOrg.setY(-aOrg.Y() ); |
871 | 16.5k | tools::Rectangle aOutRect(aOrg, rOutDev.GetOutputSize()); |
872 | | |
873 | | // In case of tiled rendering we want to get all invalidations, so visual area is not interesting. |
874 | 16.5k | if (aRect.Overlaps(aOutRect) || comphelper::LibreOfficeKit::isActive()) |
875 | 0 | { |
876 | 0 | InvalidateOneWin(rOutDev, aRect); |
877 | 0 | } |
878 | 16.5k | } |
879 | 266k | } |
880 | 266k | } |
881 | | |
882 | | void SdrPaintView::InvalidateOneWin(OutputDevice& rDevice) |
883 | 16.5k | { |
884 | | // do not erase background, that causes flicker (!) |
885 | | // tdf#160444 check device's owner window is a nullptr |
886 | | // Since commit 563f7077f1dbce31ff95ee8d2e8d17b629693db1, the |
887 | | // device's owner window gets deleted before this object is |
888 | | // deleted. |
889 | 16.5k | if (rDevice.GetOwnerWindow()) |
890 | 16.5k | rDevice.GetOwnerWindow()->Invalidate(InvalidateFlags::NoErase); |
891 | 16.5k | } |
892 | | |
893 | | void SdrPaintView::InvalidateOneWin(OutputDevice& rDevice, const tools::Rectangle& rRect) |
894 | 0 | { |
895 | | // do not erase background, that causes flicker (!) |
896 | 0 | rDevice.GetOwnerWindow()->Invalidate(rRect, InvalidateFlags::NoErase); |
897 | 0 | } |
898 | | |
899 | | void SdrPaintView::LeaveOneGroup() |
900 | 0 | { |
901 | 0 | if(mpPageView) |
902 | 0 | { |
903 | 0 | mpPageView->LeaveOneGroup(); |
904 | 0 | } |
905 | 0 | } |
906 | | |
907 | | void SdrPaintView::LeaveAllGroup() |
908 | 0 | { |
909 | 0 | if(mpPageView) |
910 | 0 | { |
911 | 0 | mpPageView->LeaveAllGroup(); |
912 | 0 | } |
913 | 0 | } |
914 | | |
915 | | bool SdrPaintView::IsGroupEntered() const |
916 | 0 | { |
917 | 0 | if(mpPageView) |
918 | 0 | { |
919 | 0 | return (mpPageView->GetEnteredLevel() != 0); |
920 | 0 | } |
921 | | |
922 | 0 | return false; |
923 | 0 | } |
924 | | |
925 | | void SdrPaintView::SetNotPersistDefaultAttr(const SfxItemSet& rAttr) |
926 | 0 | { |
927 | | // bReplaceAll has no effect here at all. |
928 | 0 | bool bMeasure= dynamic_cast<const SdrView*>(this) != nullptr && static_cast<SdrView*>(this)->IsMeasureTool(); |
929 | |
|
930 | 0 | if (const SdrLayerIdItem *pPoolItem = rAttr.GetItemIfSet(SDRATTR_LAYERID)) |
931 | 0 | { |
932 | 0 | SdrLayerID nLayerId = pPoolItem->GetValue(); |
933 | 0 | const SdrLayer* pLayer = GetModel().GetLayerAdmin().GetLayerPerID(nLayerId); |
934 | 0 | if (pLayer!=nullptr) { |
935 | 0 | if (bMeasure) maMeasureLayer=pLayer->GetName(); |
936 | 0 | else maActualLayer=pLayer->GetName(); |
937 | 0 | } |
938 | 0 | } |
939 | 0 | if (const SdrLayerNameItem *pPoolItem = rAttr.GetItemIfSet(SDRATTR_LAYERNAME)) |
940 | 0 | { |
941 | 0 | if (bMeasure) maMeasureLayer = pPoolItem->GetValue(); |
942 | 0 | else maActualLayer = pPoolItem->GetValue(); |
943 | 0 | } |
944 | 0 | } |
945 | | |
946 | | void SdrPaintView::MergeNotPersistDefaultAttr(SfxItemSet& rAttr) const |
947 | 0 | { |
948 | | // bOnlyHardAttr has no effect here at all. |
949 | 0 | bool bMeasure= dynamic_cast<const SdrView*>(this) != nullptr && static_cast<const SdrView*>(this)->IsMeasureTool(); |
950 | 0 | const OUString& aNam = bMeasure ? maMeasureLayer : maActualLayer; |
951 | 0 | rAttr.Put(SdrLayerNameItem(aNam)); |
952 | 0 | SdrLayerID nLayer = GetModel().GetLayerAdmin().GetLayerID(aNam); |
953 | 0 | if (nLayer!=SDRLAYER_NOTFOUND) { |
954 | 0 | rAttr.Put(SdrLayerIdItem(nLayer)); |
955 | 0 | } |
956 | 0 | } |
957 | | |
958 | | void SdrPaintView::SetDefaultAttr(const SfxItemSet& rAttr, bool bReplaceAll) |
959 | 0 | { |
960 | | #ifdef DBG_UTIL |
961 | | { |
962 | | bool bHasEEFeatureItems=false; |
963 | | for (SfxItemIter aIter( rAttr ); !bHasEEFeatureItems && !aIter.IsAtEnd(); aIter.Next()) |
964 | | { |
965 | | const SfxPoolItem* pItem = aIter.GetCurItem(); |
966 | | if (!IsInvalidItem(pItem)) { |
967 | | sal_uInt16 nW=pItem->Which(); |
968 | | if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) bHasEEFeatureItems=true; |
969 | | } |
970 | | } |
971 | | |
972 | | if(bHasEEFeatureItems) |
973 | | { |
974 | | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, |
975 | | VclMessageType::Info, VclButtonsType::Ok, |
976 | | u"SdrPaintView::SetDefaultAttr(): Setting EE_FEATURE items at the SdrView does not make sense! It only leads to overhead and unreadable documents."_ustr)); |
977 | | xInfoBox->run(); |
978 | | } |
979 | | } |
980 | | #endif |
981 | 0 | if (bReplaceAll) maDefaultAttr.Set(rAttr); |
982 | 0 | else maDefaultAttr.Put(rAttr,false); // if FALSE, regard InvalidItems as "holes," not as Default |
983 | 0 | SetNotPersistDefaultAttr(rAttr); |
984 | 0 | } |
985 | | |
986 | | void SdrPaintView::SetDefaultStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr) |
987 | 138k | { |
988 | 138k | if (mpDefaultStyleSheet) |
989 | 0 | EndListening(*mpDefaultStyleSheet); |
990 | 138k | mpDefaultStyleSheet=pStyleSheet; |
991 | 138k | if (mpDefaultStyleSheet) |
992 | 31.0k | StartListening(*mpDefaultStyleSheet); |
993 | | |
994 | 138k | if (pStyleSheet!=nullptr && !bDontRemoveHardAttr) { |
995 | 0 | SfxWhichIter aIter(pStyleSheet->GetItemSet()); |
996 | 0 | sal_uInt16 nWhich=aIter.FirstWhich(); |
997 | 0 | while (nWhich!=0) { |
998 | 0 | if (aIter.GetItemState()==SfxItemState::SET) { |
999 | 0 | maDefaultAttr.ClearItem(nWhich); |
1000 | 0 | } |
1001 | 0 | nWhich=aIter.NextWhich(); |
1002 | 0 | } |
1003 | 0 | } |
1004 | 138k | } |
1005 | | |
1006 | | void SdrPaintView::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const |
1007 | 0 | { |
1008 | 0 | if(bOnlyHardAttr || !mpDefaultStyleSheet) |
1009 | 0 | { |
1010 | 0 | rTargetSet.Put(maDefaultAttr, false); |
1011 | 0 | } |
1012 | 0 | else |
1013 | 0 | { |
1014 | | // else merge with DefStyleSheet |
1015 | 0 | rTargetSet.Put(mpDefaultStyleSheet->GetItemSet(), false); |
1016 | 0 | rTargetSet.Put(maDefaultAttr, false); |
1017 | 0 | } |
1018 | 0 | MergeNotPersistDefaultAttr(rTargetSet); |
1019 | 0 | } |
1020 | | |
1021 | | void SdrPaintView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll) |
1022 | 0 | { |
1023 | 0 | SetDefaultAttr(rSet,bReplaceAll); |
1024 | 0 | } |
1025 | | |
1026 | | SfxStyleSheet* SdrPaintView::GetStyleSheet() const |
1027 | 0 | { |
1028 | 0 | return mpDefaultStyleSheet; |
1029 | 0 | } |
1030 | | |
1031 | | void SdrPaintView::SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr) |
1032 | 0 | { |
1033 | 0 | SetDefaultStyleSheet(pStyleSheet,bDontRemoveHardAttr); |
1034 | 0 | } |
1035 | | |
1036 | | void SdrPaintView::MakeVisible(const tools::Rectangle& rRect, vcl::Window& rWin) |
1037 | 0 | { |
1038 | | // TODO: handle when the text cursor goes out of the chart area |
1039 | | // However this hack avoids that the cursor gets misplaced wrt the text. |
1040 | 0 | if (comphelper::LibreOfficeKit::isActive() && rWin.IsChart()) |
1041 | 0 | { |
1042 | 0 | return; |
1043 | 0 | } |
1044 | | |
1045 | 0 | MapMode aMap(rWin.GetMapMode()); |
1046 | 0 | Size aActualSize(rWin.GetOutDev()->GetOutputSize()); |
1047 | |
|
1048 | 0 | if( aActualSize.IsEmpty() ) |
1049 | 0 | return; |
1050 | | |
1051 | 0 | Size aNewSize(rRect.GetSize()); |
1052 | 0 | bool bNewScale=false; |
1053 | 0 | bool bNeedMoreX=aNewSize.Width()>aActualSize.Width(); |
1054 | 0 | bool bNeedMoreY=aNewSize.Height()>aActualSize.Height(); |
1055 | 0 | if (bNeedMoreX || bNeedMoreY) |
1056 | 0 | { |
1057 | 0 | bNewScale=true; |
1058 | | // set new MapMode (Size+Org) and invalidate everything |
1059 | 0 | double fXFact = double(aNewSize.Width()) / aActualSize.Width(); |
1060 | 0 | double fYFact = double(aNewSize.Height()) / aActualSize.Height(); |
1061 | 0 | if (fYFact>fXFact) fXFact=fYFact; |
1062 | 0 | fXFact*=aMap.GetScaleX(); |
1063 | 0 | aMap.SetScaleX(fXFact); |
1064 | 0 | aMap.SetScaleY(fYFact); |
1065 | 0 | rWin.SetMapMode(aMap); |
1066 | 0 | aActualSize=rWin.GetOutDev()->GetOutputSize(); |
1067 | 0 | } |
1068 | 0 | Point aOrg(aMap.GetOrigin()); |
1069 | 0 | tools::Long dx=0,dy=0; |
1070 | 0 | tools::Long l=-aOrg.X(); |
1071 | 0 | tools::Long r=-aOrg.X()+aActualSize.Width()-1; |
1072 | 0 | tools::Long o=-aOrg.Y(); |
1073 | 0 | tools::Long u=-aOrg.Y()+aActualSize.Height()-1; |
1074 | 0 | if (l>rRect.Left()) dx=rRect.Left()-l; |
1075 | 0 | else if (r<rRect.Right()) dx=rRect.Right()-r; |
1076 | 0 | if (o>rRect.Top()) dy=rRect.Top()-o; |
1077 | 0 | else if (u<rRect.Bottom()) dy=rRect.Bottom()-u; |
1078 | 0 | aMap.SetOrigin(Point(aOrg.X()-dx,aOrg.Y()-dy)); |
1079 | 0 | if (!bNewScale) { |
1080 | 0 | if (dx!=0 || dy!=0) { |
1081 | 0 | rWin.Scroll(-dx,-dy); |
1082 | 0 | rWin.SetMapMode(aMap); |
1083 | 0 | rWin.PaintImmediately(); |
1084 | 0 | } |
1085 | 0 | } else { |
1086 | 0 | rWin.SetMapMode(aMap); |
1087 | 0 | InvalidateOneWin(*rWin.GetOutDev()); |
1088 | 0 | } |
1089 | 0 | } |
1090 | | |
1091 | | void SdrPaintView::DoConnect(SdrOle2Obj* /*pOleObj*/) |
1092 | 0 | { |
1093 | 0 | } |
1094 | | |
1095 | | void SdrPaintView::SetAnimationEnabled( bool bEnable ) |
1096 | 0 | { |
1097 | 0 | SetAnimationMode( bEnable ? SdrAnimationMode::Animate : SdrAnimationMode::Disable ); |
1098 | 0 | } |
1099 | | |
1100 | | void SdrPaintView::SetAnimationPause( bool bSet ) |
1101 | 0 | { |
1102 | 0 | if(mbAnimationPause == bSet) |
1103 | 0 | return; |
1104 | | |
1105 | 0 | mbAnimationPause = bSet; |
1106 | |
|
1107 | 0 | if(!mpPageView) |
1108 | 0 | return; |
1109 | | |
1110 | 0 | for(sal_uInt32 b(0); b < mpPageView->PageWindowCount(); b++) |
1111 | 0 | { |
1112 | 0 | SdrPageWindow& rPageWindow = *(mpPageView->GetPageWindow(b)); |
1113 | 0 | sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact(); |
1114 | 0 | sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator(); |
1115 | |
|
1116 | 0 | if(rAnimator.IsPaused() != bSet) |
1117 | 0 | { |
1118 | 0 | rAnimator.SetPaused(bSet); |
1119 | 0 | } |
1120 | 0 | } |
1121 | 0 | } |
1122 | | |
1123 | | void SdrPaintView::SetAnimationMode( const SdrAnimationMode eMode ) |
1124 | 0 | { |
1125 | 0 | meAnimationMode = eMode; |
1126 | 0 | } |
1127 | | |
1128 | | void SdrPaintView::VisAreaChanged(const OutputDevice* pOut) |
1129 | 160 | { |
1130 | 160 | if(!mpPageView) |
1131 | 0 | return; |
1132 | | |
1133 | 160 | if (pOut) |
1134 | 160 | { |
1135 | 160 | SdrPageWindow* pWindow = mpPageView->FindPageWindow(*const_cast<OutputDevice*>(pOut)); |
1136 | | |
1137 | 160 | if(pWindow) |
1138 | 160 | { |
1139 | 160 | VisAreaChanged(); |
1140 | 160 | } |
1141 | 160 | } |
1142 | 0 | else |
1143 | 0 | { |
1144 | 0 | VisAreaChanged(); |
1145 | 0 | } |
1146 | 160 | } |
1147 | | |
1148 | | void SdrPaintView::VisAreaChanged() |
1149 | 160 | { |
1150 | | // notify SfxListener |
1151 | 160 | Broadcast(SvxViewChangedHint()); |
1152 | 160 | } |
1153 | | |
1154 | | |
1155 | | void SdrPaintView::onChangeColorConfig() |
1156 | 138k | { |
1157 | 138k | maGridColor = maColorConfig.GetColorValue( svtools::DRAWGRID ).nColor; |
1158 | 138k | } |
1159 | | |
1160 | | |
1161 | | // Set background color for svx at SdrPageViews |
1162 | | void SdrPaintView::SetApplicationBackgroundColor(Color aBackgroundColor) |
1163 | 0 | { |
1164 | 0 | if(mpPageView) |
1165 | 0 | { |
1166 | 0 | mpPageView->SetApplicationBackgroundColor(aBackgroundColor); |
1167 | 0 | } |
1168 | 0 | } |
1169 | | |
1170 | | // Set document color for svx at SdrPageViews |
1171 | | void SdrPaintView::SetApplicationDocumentColor(Color aDocumentColor) |
1172 | 0 | { |
1173 | 0 | if(mpPageView) |
1174 | 0 | { |
1175 | 0 | mpPageView->SetApplicationDocumentColor(aDocumentColor); |
1176 | 0 | } |
1177 | 0 | } |
1178 | | |
1179 | | bool SdrPaintView::IsBufferedOutputAllowed() const |
1180 | 62.5k | { |
1181 | 62.5k | return (mbBufferedOutputAllowed && officecfg::Office::Common::Drawinglayer::PaintBuffer::get()); |
1182 | 62.5k | } |
1183 | | |
1184 | | void SdrPaintView::SetBufferedOutputAllowed(bool bNew) |
1185 | 129k | { |
1186 | 129k | if(bNew != mbBufferedOutputAllowed) |
1187 | 0 | { |
1188 | 0 | mbBufferedOutputAllowed = bNew; |
1189 | 0 | } |
1190 | 129k | } |
1191 | | |
1192 | | bool SdrPaintView::IsBufferedOverlayAllowed() const |
1193 | 66.6k | { |
1194 | 66.6k | return (mbBufferedOverlayAllowed && officecfg::Office::Common::Drawinglayer::OverlayBuffer::get()); |
1195 | 66.6k | } |
1196 | | |
1197 | | void SdrPaintView::SetBufferedOverlayAllowed(bool bNew) |
1198 | 129k | { |
1199 | 129k | if(bNew != mbBufferedOverlayAllowed) |
1200 | 0 | { |
1201 | 0 | mbBufferedOverlayAllowed = bNew; |
1202 | 0 | } |
1203 | 129k | } |
1204 | | |
1205 | | |
1206 | | void SdrPaintView::SetPageDecorationAllowed(bool bNew) |
1207 | 377k | { |
1208 | 377k | if(bNew != mbPageDecorationAllowed) |
1209 | 377k | { |
1210 | 377k | mbPageDecorationAllowed = bNew; |
1211 | 377k | } |
1212 | 377k | } |
1213 | | |
1214 | | void SdrPaintView::SetMasterPageVisualizationAllowed(bool bNew) |
1215 | 377k | { |
1216 | 377k | if(bNew != mbMasterPageVisualizationAllowed) |
1217 | 377k | { |
1218 | 377k | mbMasterPageVisualizationAllowed = bNew; |
1219 | 377k | } |
1220 | 377k | } |
1221 | | |
1222 | | // #i38135# Sets the timer for Object animations and restarts. |
1223 | | void SdrPaintView::SetAnimationTimer(sal_uInt32 nTime) |
1224 | 0 | { |
1225 | 0 | if(mpPageView) |
1226 | 0 | { |
1227 | | // first, reset all timers at all windows to 0L |
1228 | 0 | for(sal_uInt32 a(0); a < mpPageView->PageWindowCount(); a++) |
1229 | 0 | { |
1230 | 0 | SdrPageWindow& rPageWindow = *mpPageView->GetPageWindow(a); |
1231 | 0 | sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact(); |
1232 | 0 | sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator(); |
1233 | 0 | rAnimator.SetTime(nTime); |
1234 | 0 | } |
1235 | 0 | } |
1236 | 0 | } |
1237 | | |
1238 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |