LibreOffice Module svx (master) 1
viewcontactofsdrcaptionobj.cxx
Go to the documentation of this file.
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
22#include <svx/svdocapt.hxx>
26
27
28// includes for special text box shadow (SC)
29
30#include <svl/itemset.hxx>
31#include <svx/xhatch.hxx>
32#include <svx/xfillit0.hxx>
33#include <svx/xflhtit.hxx>
34#include <svx/xflclit.hxx>
35#include <svx/xfltrit.hxx>
36#include <svx/xlineit0.hxx>
37#include <svx/sdmetitm.hxx>
38#include <svx/sdooitm.hxx>
39#include <svx/sdprcitm.hxx>
43#include <vcl/canvastools.hxx>
44
45using namespace com::sun::star;
46
47namespace sdr::contact
48{
50 : ViewContactOfSdrRectObj(rCaptionObj)
51 {
52 }
53
55 {
56 }
57
59 {
60 const SdrCaptionObj& rCaptionObj(static_cast<const SdrCaptionObj&>(GetSdrObject()));
61 const SfxItemSet& rItemSet = rCaptionObj.GetMergedItemSet();
64 rItemSet,
65 rCaptionObj.getText(0),
66 false, rCaptionObj.GetSpecialTextBoxShadow()));
67
68 // take unrotated snap rect (direct model data) for position and size
69 const tools::Rectangle aRectangle(rCaptionObj.GetGeoRect());
70 const ::basegfx::B2DRange aObjectRange = vcl::unotools::b2DRectangleFromRectangle(aRectangle);
71 const GeoStat& rGeoStat(rCaptionObj.GetGeoStat());
72
73 // fill object matrix
75 aObjectRange.getWidth(), aObjectRange.getHeight(),
76 -rGeoStat.mfTanShearAngle,
77 rGeoStat.m_nRotationAngle ? toRadians(36000_deg100 - rGeoStat.m_nRotationAngle) : 0.0,
78 aObjectRange.getMinX(), aObjectRange.getMinY()));
79
80 // calculate corner radius
81 double fCornerRadiusX;
82 double fCornerRadiusY;
84 rCaptionObj.GetEckenradius(), aObjectRange, fCornerRadiusX, fCornerRadiusY);
85 basegfx::B2DPolygon aTail(rCaptionObj.getTailPolygon());
86
87 // create primitive. Always create one (even if invisible) to let the decomposition
88 // of SdrCaptionPrimitive2D create needed invisible elements for HitTest and BoundRect
91 aObjectMatrix,
92 aAttribute,
93 std::move(aTail),
94 fCornerRadiusX,
95 fCornerRadiusY));
96
97 if(!aAttribute.isDefault() && rCaptionObj.GetSpecialTextBoxShadow())
98 {
99 // for SC, the caption object may have a specialized shadow. The usual object shadow is off
100 // and a specialized shadow gets created here (see old paint)
101 const XColorItem& rShadColItem = rItemSet.Get(SDRATTR_SHADOWCOLOR);
102 const sal_uInt16 nShadowTransparence(rItemSet.Get(SDRATTR_SHADOWTRANSPARENCE).GetValue());
103 const Color aShadowColor(rShadColItem.GetColorValue());
104 const drawing::FillStyle eShadowStyle = rItemSet.Get(XATTR_FILLSTYLE).GetValue();
105
106 // Create own ItemSet and modify as needed
107 // Always hide lines for special calc shadow
108 SfxItemSet aSet(rItemSet);
109 aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
110
111 if(drawing::FillStyle_HATCH == eShadowStyle)
112 {
113 // #41666# Hatch color is set hard to shadow color
114 XHatch aHatch = rItemSet.Get(XATTR_FILLHATCH).GetHatchValue();
115 aHatch.SetColor(aShadowColor);
116 aSet.Put(XFillHatchItem(OUString(),aHatch));
117 }
118 else
119 {
120 if(drawing::FillStyle_SOLID != eShadowStyle)
121 {
122 // force fill to solid (for Gradient, Bitmap and *no* fill (#119750# not filled comments *have* shadow))
123 aSet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
124 }
125
126 aSet.Put(XFillColorItem(OUString(),aShadowColor));
127 aSet.Put(XFillTransparenceItem(nShadowTransparence));
128 }
129
130 // create FillAttribute from modified ItemSet
134
135 if(!aFill.isDefault() && 1.0 != aFill.getTransparence())
136 {
137 // add shadow offset to object matrix
138 const bool bShadow(rItemSet.Get(SDRATTR_SHADOW).GetValue());
139 const sal_uInt32 nXDist(rItemSet.Get(SDRATTR_SHADOWXDIST).GetValue());
140 const sal_uInt32 nYDist(rItemSet.Get(SDRATTR_SHADOWYDIST).GetValue());
141
142 if (bShadow && (nXDist || nYDist))
143 {
144 // #119750# create object and shadow outline, clip shadow outline
145 // on object outline. If there is a rest, create shadow. Do this to
146 // emulate that shadow is *not* visible behind the object for
147 // transparent object fill for comments in excel
148 basegfx::B2DPolygon aObjectOutline(
150 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
151 fCornerRadiusX,
152 fCornerRadiusY));
153 aObjectOutline.transform(aObjectMatrix);
154
155 // create shadow outline
156 basegfx::B2DPolygon aShadowOutline(aObjectOutline);
157 aShadowOutline.transform(
159
160 // clip shadow outline against object outline
161 const basegfx::B2DPolyPolygon aClippedShadow(
163 aShadowOutline,
164 basegfx::B2DPolyPolygon(aObjectOutline),
165 false, // take the outside
166 false));
167
168 if(aClippedShadow.count())
169 {
170 // if there is shadow, create the specialized shadow primitive
172 aClippedShadow,
173 aFill,
175 }
176 }
177 }
178
179 if(xSpecialShadow.is())
180 {
181 // if we really got a special shadow, create a two-element retval with the shadow
182 // behind the standard object's geometry
183 rVisitor.visit(std::move(xSpecialShadow));
184 }
185 }
186
187 rVisitor.visit(std::move(xReference));
188 }
189
190} // end of namespace
191
192/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The transformation of a rectangle into a polygon, by using angle parameters from GeoStat.
Definition: svdtrans.hxx:201
double mfTanShearAngle
Definition: svdtrans.hxx:205
Degree100 m_nRotationAngle
Definition: svdtrans.hxx:203
bool GetSpecialTextBoxShadow() const
Definition: svdocapt.hxx:92
::basegfx::B2DPolygon getTailPolygon() const
Definition: svdocapt.cxx:752
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1974
const tools::Rectangle & GetGeoRect() const
Definition: svdotext.cxx:1526
tools::Long GetEckenradius() const
Definition: svdotext.cxx:1776
virtual SdrText * getText(sal_Int32 nIndex) const override
returns the nth available text.
Definition: svdotext.cxx:2156
const GeoStat & GetGeoStat() const
Definition: svdotext.hxx:419
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
const Color & GetColorValue() const
Definition: xattr.cxx:302
void SetColor(const Color &rColor)
Definition: xhatch.hxx:47
sal_uInt32 count() const
void transform(const basegfx::B2DHomMatrix &rMatrix)
virtual void visit(const Primitive2DReference &)=0
virtual void createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor &rVisitor) const override
double toRadians(D x)
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
B2DPolyPolygon clipPolygonOnPolyPolygon(const B2DPolygon &rCandidate, const B2DPolyPolygon &rClip, bool bInside, bool bStroke)
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
B2DHomMatrix createScaleShearXRotateTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fShearX, double fRadiant, double fTranslateX, double fTranslateY)
attribute::SdrFillAttribute createNewSdrFillAttribute(const SfxItemSet &rSet)
void calculateRelativeCornerRadius(sal_Int32 nRadius, const basegfx::B2DRange &rObjectRange, double &rfCornerRadiusX, double &rfCornerRadiusY)
Primitive2DReference createPolyPolygonFillPrimitive(const basegfx::B2DPolyPolygon &rPolyPolygon, const attribute::SdrFillAttribute &rFill, const attribute::FillGradientAttribute &rFillGradient)
attribute::SdrLineFillEffectsTextAttribute createNewSdrLineFillEffectsTextAttribute(const SfxItemSet &rSet, const SdrText *pText, bool bHasContent, bool bSuppressShadow)
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)
constexpr TypedWhichId< SdrOnOffItem > SDRATTR_SHADOW(SDRATTR_SHADOW_FIRST+0)
constexpr TypedWhichId< SdrPercentItem > SDRATTR_SHADOWTRANSPARENCE(SDRATTR_SHADOW_FIRST+4)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_SHADOWYDIST(SDRATTR_SHADOW_FIRST+3)
constexpr TypedWhichId< XColorItem > SDRATTR_SHADOWCOLOR(SDRATTR_SHADOW_FIRST+1)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_SHADOWXDIST(SDRATTR_SHADOW_FIRST+2)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)