/src/libreoffice/sc/source/ui/view/overlayobject.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 <overlayobject.hxx> |
21 | | #include <basegfx/range/b2drange.hxx> |
22 | | #include <basegfx/polygon/b2dpolygon.hxx> |
23 | | #include <basegfx/polygon/b2dpolygontools.hxx> |
24 | | #include <svx/sdr/overlay/overlaymanager.hxx> |
25 | | #include <drawinglayer/primitive2d/PolyPolygonMarkerPrimitive2D.hxx> |
26 | | #include <officecfg/Office/Common.hxx> |
27 | | #include <vcl/settings.hxx> |
28 | | |
29 | | using sdr::overlay::OverlayObject; |
30 | | using sdr::overlay::OverlayManager; |
31 | | |
32 | 0 | #define DASH_UPDATE_INTERVAL 500 // in msec |
33 | | |
34 | | ScOverlayDashedBorder::ScOverlayDashedBorder(const ::basegfx::B2DRange& rRange, const Color& rColor) : |
35 | 0 | OverlayObject(rColor), |
36 | 0 | mbToggle(true) |
37 | 0 | { |
38 | | // tdf#115688: Let the user choose in the accessibility option page ("Tools" --> "Options" --> "Accessibility --> "Allow other animations") if the "marching ants" animation is allowed. |
39 | | // tdf#161765: Don't override LO's animation settings with OS's all-or-nothing animation setting, |
40 | | // but do respect OS's animation setting if the user has selected the option "System". |
41 | | // New options: "System"/"No"/"Yes" |
42 | 0 | mbAllowsAnimation = MiscSettings::IsAnimatedOthersAllowed(); |
43 | 0 | maRange = rRange; |
44 | 0 | } |
45 | | |
46 | | ScOverlayDashedBorder::~ScOverlayDashedBorder() |
47 | 0 | { |
48 | 0 | } |
49 | | |
50 | | void ScOverlayDashedBorder::Trigger(sal_uInt32 nTime) |
51 | 0 | { |
52 | 0 | OverlayManager* pMgr = getOverlayManager(); |
53 | 0 | if (pMgr) |
54 | 0 | { |
55 | 0 | SetTime(nTime + DASH_UPDATE_INTERVAL); |
56 | 0 | mbToggle = !mbToggle; |
57 | 0 | pMgr->InsertEvent(*this); |
58 | 0 | objectChange(); |
59 | 0 | } |
60 | 0 | } |
61 | | |
62 | | void ScOverlayDashedBorder::stripeDefinitionHasChanged() |
63 | 0 | { |
64 | 0 | objectChange(); |
65 | 0 | } |
66 | | |
67 | | drawinglayer::primitive2d::Primitive2DContainer ScOverlayDashedBorder::createOverlayObjectPrimitive2DSequence() |
68 | 0 | { |
69 | 0 | using ::basegfx::B2DPolygon; |
70 | 0 | using ::basegfx::B2DPolyPolygon; |
71 | |
|
72 | 0 | OverlayManager* pMgr = getOverlayManager(); |
73 | 0 | if (!pMgr) |
74 | 0 | return drawinglayer::primitive2d::Primitive2DContainer(); |
75 | | |
76 | 0 | basegfx::BColor aColorA = pMgr->getStripeColorA().getBColor(); |
77 | 0 | basegfx::BColor aColorB = pMgr->getStripeColorB().getBColor(); |
78 | 0 | if (!mbToggle) |
79 | 0 | ::std::swap(aColorA, aColorB); |
80 | |
|
81 | 0 | const basegfx::B2DPolygon aPoly = basegfx::utils::createPolygonFromRect(maRange); |
82 | 0 | B2DPolyPolygon aPolygon(aPoly); |
83 | 0 | const drawinglayer::primitive2d::Primitive2DReference aReference( |
84 | 0 | new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D( |
85 | 0 | std::move(aPolygon), aColorA, aColorB, pMgr->getStripeLengthPixel())); |
86 | |
|
87 | 0 | return drawinglayer::primitive2d::Primitive2DContainer { aReference }; |
88 | 0 | } |
89 | | |
90 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |