fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / view / overlayobject.cxx
bloba0cb86f0ac26bcb3a4442b490048512627b023e3
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 #include "overlayobject.hxx"
21 #include <vcl/outdev.hxx>
22 #include <vcl/lineinfo.hxx>
23 #include <tools/fract.hxx>
24 #include <basegfx/range/b2drange.hxx>
25 #include <basegfx/polygon/b2dpolygon.hxx>
26 #include <basegfx/polygon/b2dpolygontools.hxx>
27 #include <svx/sdr/overlay/overlaymanager.hxx>
28 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
29 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
30 #include <officecfg/Office/Common.hxx>
32 using sdr::overlay::OverlayObject;
33 using sdr::overlay::OverlayManager;
34 using ::drawinglayer::primitive2d::Primitive2DSequence;
36 #define DASH_UPDATE_INTERVAL 180 // in msec
38 ScOverlayDashedBorder::ScOverlayDashedBorder(const ::basegfx::B2DRange& rRange, const Color& rColor) :
39 OverlayObject(rColor),
40 mbToggle(true)
42 mbAllowsAnimation = officecfg::Office::Common::VCL::AnimationsEnabled::get();
43 maRange = rRange;
46 ScOverlayDashedBorder::~ScOverlayDashedBorder()
50 void ScOverlayDashedBorder::Trigger(sal_uInt32 nTime)
52 OverlayManager* pMgr = getOverlayManager();
53 if (pMgr)
55 SetTime(nTime + DASH_UPDATE_INTERVAL);
56 mbToggle = !mbToggle;
57 pMgr->InsertEvent(this);
58 objectChange();
62 void ScOverlayDashedBorder::stripeDefinitionHasChanged()
64 objectChange();
67 Primitive2DSequence ScOverlayDashedBorder::createOverlayObjectPrimitive2DSequence()
69 using ::basegfx::B2DPolygon;
70 using ::basegfx::B2DPolyPolygon;
72 OverlayManager* pMgr = getOverlayManager();
73 if (!pMgr)
74 return Primitive2DSequence();
76 basegfx::BColor aColorA = pMgr->getStripeColorA().getBColor();
77 basegfx::BColor aColorB = pMgr->getStripeColorB().getBColor();
78 if (!mbToggle)
79 ::std::swap(aColorA, aColorB);
81 const basegfx::B2DPolygon aPoly = basegfx::tools::createPolygonFromRect(maRange);
82 B2DPolyPolygon aPolygon(aPoly);
83 const drawinglayer::primitive2d::Primitive2DReference aReference(
84 new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D(
85 aPolygon, aColorA, aColorB, pMgr->getStripeLengthPixel()));
87 return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */