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/sdprcitm.hxx>
42#include <vcl/canvastools.hxx>
43
44using namespace com::sun::star;
45
46namespace sdr::contact
47{
49 : ViewContactOfSdrRectObj(rCaptionObj)
50 {
51 }
52
54 {
55 }
56
58 {
59 const SdrCaptionObj& rCaptionObj(static_cast<const SdrCaptionObj&>(GetSdrObject()));
60 const SfxItemSet& rItemSet = rCaptionObj.GetMergedItemSet();
63 rItemSet,
64 rCaptionObj.getText(0),
65 false));
66
67 // take unrotated snap rect (direct model data) for position and size
68 const tools::Rectangle aRectangle(rCaptionObj.GetGeoRect());
69 const ::basegfx::B2DRange aObjectRange = vcl::unotools::b2DRectangleFromRectangle(aRectangle);
70 const GeoStat& rGeoStat(rCaptionObj.GetGeoStat());
71
72 // fill object matrix
74 aObjectRange.getWidth(), aObjectRange.getHeight(),
75 -rGeoStat.mfTanShearAngle,
76 rGeoStat.nRotationAngle ? toRadians(36000_deg100 - rGeoStat.nRotationAngle) : 0.0,
77 aObjectRange.getMinX(), aObjectRange.getMinY()));
78
79 // calculate corner radius
80 double fCornerRadiusX;
81 double fCornerRadiusY;
83 rCaptionObj.GetEckenradius(), aObjectRange, fCornerRadiusX, fCornerRadiusY);
84 basegfx::B2DPolygon aTail(rCaptionObj.getTailPolygon());
85
86 // create primitive. Always create one (even if invisible) to let the decomposition
87 // of SdrCaptionPrimitive2D create needed invisible elements for HitTest and BoundRect
90 aObjectMatrix,
91 aAttribute,
92 std::move(aTail),
93 fCornerRadiusX,
94 fCornerRadiusY));
95
96 if(!aAttribute.isDefault() && rCaptionObj.GetSpecialTextBoxShadow())
97 {
98 // for SC, the caption object may have a specialized shadow. The usual object shadow is off
99 // and a specialized shadow gets created here (see old paint)
100 const XColorItem& rShadColItem = rItemSet.Get(SDRATTR_SHADOWCOLOR);
101 const sal_uInt16 nShadowTransparence(rItemSet.Get(SDRATTR_SHADOWTRANSPARENCE).GetValue());
102 const Color aShadowColor(rShadColItem.GetColorValue());
103 const drawing::FillStyle eShadowStyle = rItemSet.Get(XATTR_FILLSTYLE).GetValue();
104
105 // Create own ItemSet and modify as needed
106 // Always hide lines for special calc shadow
107 SfxItemSet aSet(rItemSet);
108 aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
109
110 if(drawing::FillStyle_HATCH == eShadowStyle)
111 {
112 // #41666# Hatch color is set hard to shadow color
113 XHatch aHatch = rItemSet.Get(XATTR_FILLHATCH).GetHatchValue();
114 aHatch.SetColor(aShadowColor);
115 aSet.Put(XFillHatchItem(OUString(),aHatch));
116 }
117 else
118 {
119 if(drawing::FillStyle_SOLID != eShadowStyle)
120 {
121 // force fill to solid (for Gradient, Bitmap and *no* fill (#119750# not filled comments *have* shadow))
122 aSet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
123 }
124
125 aSet.Put(XFillColorItem(OUString(),aShadowColor));
126 aSet.Put(XFillTransparenceItem(nShadowTransparence));
127 }
128
129 // create FillAttribute from modified ItemSet
133
134 if(!aFill.isDefault() && 1.0 != aFill.getTransparence())
135 {
136 // add shadow offset to object matrix
137 const sal_uInt32 nXDist(rItemSet.Get(SDRATTR_SHADOWXDIST).GetValue());
138 const sal_uInt32 nYDist(rItemSet.Get(SDRATTR_SHADOWYDIST).GetValue());
139
140 if(nXDist || nYDist)
141 {
142 // #119750# create object and shadow outline, clip shadow outline
143 // on object outline. If there is a rest, create shadow. Do this to
144 // emulate that shadow is *not* visible behind the object for
145 // transparent object fill for comments in excel
146 basegfx::B2DPolygon aObjectOutline(
148 basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
149 fCornerRadiusX,
150 fCornerRadiusY));
151 aObjectOutline.transform(aObjectMatrix);
152
153 // create shadow outline
154 basegfx::B2DPolygon aShadowOutline(aObjectOutline);
155 aShadowOutline.transform(
157
158 // clip shadow outline against object outline
159 const basegfx::B2DPolyPolygon aClippedShadow(
161 aShadowOutline,
162 basegfx::B2DPolyPolygon(aObjectOutline),
163 false, // take the outside
164 false));
165
166 if(aClippedShadow.count())
167 {
168 // if there is shadow, create the specialized shadow primitive
170 aClippedShadow,
171 aFill,
173 }
174 }
175 }
176
177 if(xSpecialShadow.is())
178 {
179 // if we really got a special shadow, create a two-element retval with the shadow
180 // behind the standard object's geometry
181 rVisitor.visit(std::move(xSpecialShadow));
182 }
183 }
184
185 rVisitor.visit(std::move(xReference));
186 }
187
188} // end of namespace
189
190/* 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 nRotationAngle
Definition: svdtrans.hxx:203
bool GetSpecialTextBoxShadow() const
Definition: svdocapt.hxx:92
::basegfx::B2DPolygon getTailPolygon() const
Definition: svdocapt.cxx:751
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1977
const tools::Rectangle & GetGeoRect() const
Definition: svdotext.cxx:1458
tools::Long GetEckenradius() const
Definition: svdotext.cxx:1708
virtual SdrText * getText(sal_Int32 nIndex) const override
returns the nth available text.
Definition: svdotext.cxx:2088
const GeoStat & GetGeoStat() const
Definition: svdotext.hxx:390
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:300
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::SdrLineFillEffectsTextAttribute createNewSdrLineFillEffectsTextAttribute(const SfxItemSet &rSet, const SdrText *pText, bool bHasContent)
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)
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)
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)