Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svx/sdr/contact/viewcontactofgraphic.hxx>
30 : : #include <svx/sdr/contact/viewobjectcontactofgraphic.hxx>
31 : : #include <svx/svdograf.hxx>
32 : : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
33 : : #include <svl/itemset.hxx>
34 : :
35 : : #ifndef ITEMID_GRF_CROP
36 : : #define ITEMID_GRF_CROP 0
37 : : #endif
38 : :
39 : : #include <svx/sdgcpitm.hxx>
40 : : #include <svx/sdr/contact/displayinfo.hxx>
41 : : #include <svx/sdr/contact/viewobjectcontact.hxx>
42 : : #include <svx/sdr/contact/objectcontact.hxx>
43 : : #include <svx/sdr/event/eventhandler.hxx>
44 : : #include <basegfx/matrix/b2dhommatrix.hxx>
45 : : #include <svx/sdr/primitive2d/sdrgrafprimitive2d.hxx>
46 : : #include "svx/svdstr.hrc"
47 : : #include <svx/svdglob.hxx>
48 : : #include <vcl/svapp.hxx>
49 : : #include <basegfx/polygon/b2dpolygontools.hxx>
50 : : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
51 : : #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
52 : : #include <drawinglayer/primitive2d/textprimitive2d.hxx>
53 : : #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
54 : : #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
55 : : #include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
56 : : #include <editeng/eeitem.hxx>
57 : : #include <editeng/colritem.hxx>
58 : : #include <basegfx/matrix/b2dhommatrixtools.hxx>
59 : : #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
60 : :
61 : : //////////////////////////////////////////////////////////////////////////////
62 : :
63 : : namespace sdr
64 : : {
65 : : namespace contact
66 : : {
67 : : // Create a Object-Specific ViewObjectContact, set ViewContact and
68 : : // ObjectContact. Always needs to return something.
69 : 12 : ViewObjectContact& ViewContactOfGraphic::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
70 : : {
71 [ + - ]: 12 : ViewObjectContact* pRetval = new ViewObjectContactOfGraphic(rObjectContact, *this);
72 : : DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
73 : :
74 : 12 : return *pRetval;
75 : : }
76 : :
77 : 118 : ViewContactOfGraphic::ViewContactOfGraphic(SdrGrafObj& rGrafObj)
78 : 118 : : ViewContactOfTextObj(rGrafObj)
79 : : {
80 : 118 : }
81 : :
82 : 112 : ViewContactOfGraphic::~ViewContactOfGraphic()
83 : : {
84 [ - + ]: 224 : }
85 : :
86 : 12 : void ViewContactOfGraphic::flushGraphicObjects()
87 : : {
88 : : // #i102380# The graphic is swapped out. To let that have an effect ist is necessary to
89 : : // delete copies of the GraphicObject which are not swapped out and have no SwapHandler set
90 : : // (this is what happnes when the GraphicObject gets copied to a SdrGrafPrimitive2D). This
91 : : // is best achieved for the VC by clearing the local decomposition cache. It would be possible
92 : : // to also do this for the VOC cache, but that VOCs exist exactly expresss that the object
93 : : // gets visualised, so this would be wrong.
94 : 12 : flushViewIndependentPrimitive2DSequence();
95 : 12 : }
96 : :
97 : 0 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createVIP2DSForPresObj(
98 : : const basegfx::B2DHomMatrix& rObjectMatrix,
99 : : const drawinglayer::attribute::SdrLineFillShadowTextAttribute& rAttribute,
100 : : const GraphicAttr& rLocalGrafInfo) const
101 : : {
102 [ # # ]: 0 : drawinglayer::primitive2d::Primitive2DSequence xRetval;
103 [ # # ]: 0 : GraphicObject aEmptyGraphicObject;
104 [ # # ]: 0 : GraphicAttr aEmptyGraphicAttr;
105 : :
106 : : // SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts
107 : : const drawinglayer::primitive2d::Primitive2DReference xReferenceA(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
108 : : rObjectMatrix,
109 : : rAttribute,
110 : : aEmptyGraphicObject,
111 [ # # ][ # # ]: 0 : aEmptyGraphicAttr));
[ # # ]
112 [ # # ][ # # ]: 0 : xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReferenceA, 1);
[ # # ]
113 : :
114 : : // SdrGrafPrimitive2D with content (which is the preview graphic) scaled to smaller size and
115 : : // without attributes
116 [ # # ]: 0 : basegfx::B2DHomMatrix aSmallerMatrix;
117 : :
118 : : // #i94431# for some reason, i forgot to take the PrefMapMode of the graphic
119 : : // into account. Since EmptyPresObj's are only used in Draw/Impress, it is
120 : : // safe to assume 100th mm as target.
121 [ # # ]: 0 : Size aPrefSize(GetGrafObject().GetGrafPrefSize());
122 : :
123 [ # # ][ # # ]: 0 : if(MAP_PIXEL == GetGrafObject().GetGrafPrefMapMode().GetMapUnit())
124 : : {
125 [ # # ][ # # ]: 0 : aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MAP_100TH_MM);
[ # # ][ # # ]
126 : : }
127 : : else
128 : : {
129 [ # # ][ # # ]: 0 : aPrefSize = Application::GetDefaultDevice()->LogicToLogic(aPrefSize, GetGrafObject().GetGrafPrefMapMode(), MAP_100TH_MM);
[ # # ][ # # ]
[ # # ]
130 : : }
131 : :
132 : : // decompose object matrix to get single values
133 : 0 : basegfx::B2DVector aScale, aTranslate;
134 : : double fRotate, fShearX;
135 [ # # ]: 0 : rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
136 : :
137 : 0 : const double fOffsetX((aScale.getX() - aPrefSize.getWidth()) / 2.0);
138 : 0 : const double fOffsetY((aScale.getY() - aPrefSize.getHeight()) / 2.0);
139 : :
140 [ # # ][ # # ]: 0 : if(basegfx::fTools::moreOrEqual(fOffsetX, 0.0) && basegfx::fTools::moreOrEqual(fOffsetY, 0.0))
[ # # ][ # # ]
[ # # ]
141 : : {
142 : : // create the EmptyPresObj fallback visualisation. The fallback graphic
143 : : // is already provided in rGraphicObject in this case, use it
144 [ # # ][ # # ]: 0 : aSmallerMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aPrefSize.getWidth(), aPrefSize.getHeight(), fOffsetX, fOffsetY);
[ # # ]
145 : : aSmallerMatrix = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate)
146 [ # # ][ # # ]: 0 : * aSmallerMatrix;
[ # # ][ # # ]
[ # # ]
147 : :
148 [ # # ]: 0 : const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false);
149 : : const drawinglayer::primitive2d::Primitive2DReference xReferenceB(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
150 : : aSmallerMatrix,
151 : : drawinglayer::attribute::SdrLineFillShadowTextAttribute(),
152 : : rGraphicObject,
153 [ # # ][ # # ]: 0 : rLocalGrafInfo));
[ # # ][ # # ]
[ # # ]
154 : :
155 [ # # ]: 0 : drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReferenceB);
156 : : }
157 : :
158 [ # # ][ # # ]: 0 : return xRetval;
[ # # ]
159 : : }
160 : :
161 : 33 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createVIP2DSForDraft(
162 : : const basegfx::B2DHomMatrix& rObjectMatrix,
163 : : const drawinglayer::attribute::SdrLineFillShadowTextAttribute& rAttribute) const
164 : : {
165 [ + - ]: 33 : drawinglayer::primitive2d::Primitive2DSequence xRetval;
166 [ + - ]: 33 : GraphicObject aEmptyGraphicObject;
167 [ + - ]: 33 : GraphicAttr aEmptyGraphicAttr;
168 : :
169 : : // SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts
170 : : const drawinglayer::primitive2d::Primitive2DReference xReferenceA(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
171 : : rObjectMatrix,
172 : : rAttribute,
173 : : aEmptyGraphicObject,
174 [ + - ][ + - ]: 33 : aEmptyGraphicAttr));
[ + - ]
175 [ + - ][ + - ]: 33 : xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReferenceA, 1);
[ + - ]
176 : :
177 [ + - ][ + - ]: 33 : if(rAttribute.getLine().isDefault())
178 : : {
179 : : // create a surrounding frame when no linestyle given
180 [ + - ]: 33 : const Color aColor(Application::GetSettings().GetStyleSettings().GetShadowColor());
181 : 33 : const basegfx::BColor aBColor(aColor.getBColor());
182 [ + - ]: 33 : basegfx::B2DPolygon aOutline(basegfx::tools::createUnitPolygon());
183 [ + - ]: 33 : aOutline.transform(rObjectMatrix);
184 : :
185 : : drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
186 : : drawinglayer::primitive2d::Primitive2DReference(
187 : : new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
188 : : aOutline,
189 [ + - ][ + - ]: 33 : aBColor)));
[ + - ][ + - ]
[ + - ]
190 : : }
191 : :
192 : : // decompose object matrix to get single values
193 : 33 : basegfx::B2DVector aScale, aTranslate;
194 : : double fRotate, fShearX;
195 [ + - ]: 33 : rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
196 : :
197 : : // define a distance value, used for distance from bitmap to borders and from bitmap
198 : : // to text, too (2 mm)
199 : 33 : const double fDistance(200.0);
200 : :
201 : : // consume borders from values
202 [ + - ]: 33 : aScale.setX(std::max(0.0, aScale.getX() - (2.0 * fDistance)));
203 [ + - ]: 33 : aScale.setY(std::max(0.0, aScale.getY() - (2.0 * fDistance)));
204 : 33 : aTranslate.setX(aTranslate.getX() + fDistance);
205 : 33 : aTranslate.setY(aTranslate.getY() + fDistance);
206 : :
207 : : // draw a draft bitmap
208 [ + - ][ + - ]: 33 : const Bitmap aDraftBitmap(ResId(BMAP_GrafikEi, *ImpGetResMgr()));
209 : :
210 [ - + ]: 33 : if(!aDraftBitmap.IsEmpty())
211 : : {
212 : 0 : Size aPrefSize(aDraftBitmap.GetPrefSize());
213 : :
214 [ # # ]: 0 : if(MAP_PIXEL == aDraftBitmap.GetPrefMapMode().GetMapUnit())
215 : : {
216 [ # # ][ # # ]: 0 : aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aDraftBitmap.GetSizePixel(), MAP_100TH_MM);
[ # # ][ # # ]
[ # # ]
217 : : }
218 : : else
219 : : {
220 [ # # ][ # # ]: 0 : aPrefSize = Application::GetDefaultDevice()->LogicToLogic(aPrefSize, aDraftBitmap.GetPrefMapMode(), MAP_100TH_MM);
[ # # ][ # # ]
221 : : }
222 : :
223 : 0 : const double fBitmapScaling(2.0);
224 : 0 : const double fWidth(aPrefSize.getWidth() * fBitmapScaling);
225 : 0 : const double fHeight(aPrefSize.getHeight() * fBitmapScaling);
226 : :
227 [ # # ][ # # ]: 0 : if(basegfx::fTools::more(fWidth, 1.0)
[ # # # #
# # # # ]
228 [ # # ]: 0 : && basegfx::fTools::more(fHeight, 1.0)
229 [ # # ]: 0 : && basegfx::fTools::lessOrEqual(fWidth, aScale.getX())
230 [ # # ]: 0 : && basegfx::fTools::lessOrEqual(fHeight, aScale.getY()))
231 : : {
232 : : const basegfx::B2DHomMatrix aBitmapMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
233 [ # # ]: 0 : fWidth, fHeight, fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
234 : :
235 : : drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
236 : : drawinglayer::primitive2d::Primitive2DReference(
237 : : new drawinglayer::primitive2d::BitmapPrimitive2D(
238 : : BitmapEx(aDraftBitmap),
239 [ # # ][ # # ]: 0 : aBitmapMatrix)));
[ # # ][ # # ]
[ # # ][ # # ]
240 : :
241 : : // consume bitmap size in X
242 [ # # ]: 0 : aScale.setX(std::max(0.0, aScale.getX() - (fWidth + fDistance)));
243 [ # # ]: 0 : aTranslate.setX(aTranslate.getX() + fWidth + fDistance);
244 : : }
245 : : }
246 : :
247 : : // Build the text for the draft object
248 [ + - ][ + - ]: 33 : XubString aDraftText = GetGrafObject().GetFileName();
249 : :
250 [ + - ]: 33 : if(!aDraftText.Len())
251 : : {
252 [ + - ][ + - ]: 33 : aDraftText = GetGrafObject().GetName();
253 [ + - ]: 33 : aDraftText.AppendAscii(" ...");
254 : : }
255 : :
256 [ + - ][ + - ]: 33 : if(aDraftText.Len() && GetGrafObject().GetModel())
[ + - ][ + - ]
257 : : {
258 : : // #i103255# Goal is to produce TextPrimitives which hold the given text as
259 : : // BlockText in the available space. It would be very tricky to do
260 : : // an own word wrap/line layout here.
261 : : // Using SdrBlockTextPrimitive2D OTOH is critical since it internally
262 : : // uses the SdrObject it references. To solve this, create a temp
263 : : // SdrObject with Attributes and Text, generate a SdrBlockTextPrimitive2D
264 : : // directly and immediately decompose it. After that, it is no longer
265 : : // needed and can be deleted.
266 : :
267 : : // create temp RectObj as TextObj and set needed attributes
268 [ + - ]: 33 : SdrRectObj aRectObj(OBJ_TEXT);
269 [ + - ][ + - ]: 33 : aRectObj.SetModel(GetGrafObject().GetModel());
270 [ + - ]: 33 : aRectObj.NbcSetText(aDraftText);
271 [ + - ][ + - ]: 33 : aRectObj.SetMergedItem(SvxColorItem(Color(COL_LIGHTRED), EE_CHAR_COLOR));
[ + - ]
272 : :
273 : : // get SdrText and OPO
274 [ + - ]: 33 : SdrText* pSdrText = aRectObj.getText(0);
275 [ + - ]: 33 : OutlinerParaObject* pOPO = aRectObj.GetOutlinerParaObject();
276 : :
277 [ + - ][ + - ]: 33 : if(pSdrText && pOPO)
278 : : {
279 : : // directly use the remaining space as TextRangeTransform
280 : : const basegfx::B2DHomMatrix aTextRangeTransform(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
281 [ + - ]: 33 : aScale, fShearX, fRotate, aTranslate));
282 : :
283 : : // directly create temp SdrBlockTextPrimitive2D
284 : : drawinglayer::primitive2d::SdrBlockTextPrimitive2D aBlockTextPrimitive(
285 : : pSdrText,
286 : : *pOPO,
287 : : aTextRangeTransform,
288 : : SDRTEXTHORZADJUST_LEFT,
289 : : SDRTEXTVERTADJUST_TOP,
290 : : false,
291 : : false,
292 : : false,
293 : : false,
294 [ + - ]: 33 : false);
295 : :
296 : : // decompose immediately with neutral ViewInformation. This will
297 : : // layout the text to more simple TextPrimitives from drawinglayer
298 [ + - ]: 33 : const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
299 : :
300 : : drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
301 : : xRetval,
302 [ + - ][ + - ]: 33 : aBlockTextPrimitive.get2DDecomposition(aViewInformation2D));
[ + - ][ + - ]
[ + - ][ + - ]
303 [ + - ]: 33 : }
304 : : }
305 : :
306 [ + - ][ + - ]: 33 : return xRetval;
[ + - ][ + - ]
307 : : }
308 : :
309 : 99 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createViewIndependentPrimitive2DSequence() const
310 : : {
311 [ + - ]: 99 : drawinglayer::primitive2d::Primitive2DSequence xRetval;
312 [ + - ]: 99 : const SfxItemSet& rItemSet = GetGrafObject().GetMergedItemSet();
313 : : drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
314 : : drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
315 : : rItemSet,
316 [ + - ][ + - ]: 99 : GetGrafObject().getText(0)));
317 : :
318 : : // create and fill GraphicAttr
319 [ + - ]: 99 : GraphicAttr aLocalGrafInfo;
320 [ + - ]: 99 : const sal_uInt16 nTrans(((SdrGrafTransparenceItem&)rItemSet.Get(SDRATTR_GRAFTRANSPARENCE)).GetValue());
321 [ + - ]: 99 : const SdrGrafCropItem& rCrop((const SdrGrafCropItem&)rItemSet.Get(SDRATTR_GRAFCROP));
322 [ + - ]: 99 : aLocalGrafInfo.SetLuminance(((SdrGrafLuminanceItem&)rItemSet.Get(SDRATTR_GRAFLUMINANCE)).GetValue());
323 [ + - ]: 99 : aLocalGrafInfo.SetContrast(((SdrGrafContrastItem&)rItemSet.Get(SDRATTR_GRAFCONTRAST)).GetValue());
324 [ + - ]: 99 : aLocalGrafInfo.SetChannelR(((SdrGrafRedItem&)rItemSet.Get(SDRATTR_GRAFRED)).GetValue());
325 [ + - ]: 99 : aLocalGrafInfo.SetChannelG(((SdrGrafGreenItem&)rItemSet.Get(SDRATTR_GRAFGREEN)).GetValue());
326 [ + - ]: 99 : aLocalGrafInfo.SetChannelB(((SdrGrafBlueItem&)rItemSet.Get(SDRATTR_GRAFBLUE)).GetValue());
327 [ + - ]: 99 : aLocalGrafInfo.SetGamma(((SdrGrafGamma100Item&)rItemSet.Get(SDRATTR_GRAFGAMMA)).GetValue() * 0.01);
328 : 99 : aLocalGrafInfo.SetTransparency((sal_uInt8)::basegfx::fround(Min(nTrans, (sal_uInt16)100) * 2.55));
329 [ + - ]: 99 : aLocalGrafInfo.SetInvert(((SdrGrafInvertItem&)rItemSet.Get(SDRATTR_GRAFINVERT)).GetValue());
330 [ + - ]: 99 : aLocalGrafInfo.SetDrawMode(((SdrGrafModeItem&)rItemSet.Get(SDRATTR_GRAFMODE)).GetValue());
331 : 99 : aLocalGrafInfo.SetCrop(rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom());
332 : :
333 [ + - ][ + - ]: 99 : if(aAttribute.isDefault() && 255L != aLocalGrafInfo.GetTransparency())
[ + - ][ + - ]
334 : : {
335 : : // no fill, no line, no text (invisible), but the graphic content is visible.
336 : : // Create evtl. shadow for content which was not created by createNewSdrLineFillShadowTextAttribute yet
337 : : const drawinglayer::attribute::SdrShadowAttribute aShadow(
338 [ + - ]: 99 : drawinglayer::primitive2d::createNewSdrShadowAttribute(rItemSet));
339 : :
340 [ + - ][ - + ]: 99 : if(!aShadow.isDefault())
341 : : {
342 : : // create new attribute set if indeed shadow is used
343 : : aAttribute = drawinglayer::attribute::SdrLineFillShadowTextAttribute(
344 : 0 : aAttribute.getLine(),
345 : 0 : aAttribute.getFill(),
346 : 0 : aAttribute.getLineStartEnd(),
347 : : aShadow,
348 : 0 : aAttribute.getFillFloatTransGradient(),
349 [ # # ][ # # ]: 0 : aAttribute.getText());
[ # # ]
350 [ + - ]: 99 : }
351 : : }
352 : :
353 : : // take unrotated snap rect for position and size. Directly use model data, not getBoundRect() or getSnapRect()
354 : : // which will use the primitive data we just create in the near future
355 : 99 : const Rectangle& rRectangle = GetGrafObject().GetGeoRect();
356 : : const ::basegfx::B2DRange aObjectRange(
357 : 99 : rRectangle.Left(), rRectangle.Top(),
358 [ + - ]: 198 : rRectangle.Right(), rRectangle.Bottom());
359 : :
360 : : // look for mirroring
361 : 99 : const GeoStat& rGeoStat(GetGrafObject().GetGeoStat());
362 : 99 : const sal_Int32 nDrehWink(rGeoStat.nDrehWink);
363 : 99 : const bool bRota180(18000 == nDrehWink);
364 [ + - ]: 99 : const bool bMirrored(GetGrafObject().IsMirrored());
365 [ - + ][ # # ]: 99 : const sal_uInt16 nMirrorCase(bRota180 ? (bMirrored ? 3 : 4) : (bMirrored ? 2 : 1));
[ - + ]
366 [ + - ][ - + ]: 99 : bool bHMirr((2 == nMirrorCase ) || (4 == nMirrorCase));
367 [ + - ][ - + ]: 99 : bool bVMirr((3 == nMirrorCase ) || (4 == nMirrorCase));
368 : :
369 : : // set mirror flags at LocalGrafInfo. Take into account that the geometry in
370 : : // aObjectRange is already changed and rotated when bRota180 is used. To rebuild
371 : : // that old behaviour (as long as part of the model data), correct the H/V flags
372 : : // accordingly. The created bitmapPrimitive WILL use the rotation, too.
373 [ - + ]: 99 : if(bRota180)
374 : : {
375 : : // if bRota180 which is used for vertical mirroring, the graphic will already be rotated
376 : : // by 180 degrees. To correct, switch off VMirror and invert HMirroring.
377 : 0 : bHMirr = !bHMirr;
378 : 0 : bVMirr = false;
379 : : }
380 : :
381 [ + - ][ - + ]: 99 : if(bHMirr || bVMirr)
382 : : {
383 [ # # ][ # # ]: 0 : aLocalGrafInfo.SetMirrorFlags((bHMirr ? BMP_MIRROR_HORZ : 0)|(bVMirr ? BMP_MIRROR_VERT : 0));
384 : : }
385 : :
386 : : // fill object matrix
387 [ - + ]: 99 : const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
388 [ - + ]: 99 : const double fRotate(nDrehWink ? (36000 - nDrehWink) * F_PI18000 : 0.0);
389 : : const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
390 : : aObjectRange.getWidth(), aObjectRange.getHeight(),
391 : : fShearX, fRotate,
392 [ + - ][ + - ]: 99 : aObjectRange.getMinX(), aObjectRange.getMinY()));
[ + - ][ + - ]
[ + - ]
393 : :
394 : : // get the current, unchenged graphic obect from SdrGrafObj
395 [ + - ]: 99 : const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false);
396 : :
397 [ + - ][ - + ]: 99 : if(visualisationUsesPresObj())
398 : : {
399 : : // it's an EmptyPresObj, create the SdrGrafPrimitive2D without content and another scaled one
400 : : // with the content which is the placeholder graphic
401 [ # # ][ # # ]: 0 : xRetval = createVIP2DSForPresObj(aObjectMatrix, aAttribute, aLocalGrafInfo);
[ # # ]
402 : : }
403 [ + - ][ + + ]: 99 : else if(visualisationUsesDraft())
404 : : {
405 : : // #i102380# The graphic is swapped out. To not force a swap-in here, there is a mechanism
406 : : // which shows a swapped-out-visualisation (which gets created here now) and an asynchronious
407 : : // visual update mechanism for swapped-out grapgics when they were loaded (see AsynchGraphicLoadingEvent
408 : : // and ViewObjectContactOfGraphic implementation). Not forcing the swap-in here allows faster
409 : : // (non-blocking) processing here and thus in the effect e.g. fast scrolling through pages
410 [ + - ][ + - ]: 33 : xRetval = createVIP2DSForDraft(aObjectMatrix, aAttribute);
[ + - ]
411 : : }
412 : : else
413 : : {
414 : : // create primitive. Info: Calling the copy-constructor of GraphicObject in this
415 : : // SdrGrafPrimitive2D constructor will force a full swap-in of the graphic
416 : : const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
417 : : aObjectMatrix,
418 : : aAttribute,
419 : : rGraphicObject,
420 [ + - ][ + - ]: 66 : aLocalGrafInfo));
[ + - ]
421 : :
422 [ + - ][ + - ]: 66 : xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
[ + - ]
423 : : }
424 : :
425 : : // always append an invisible outline for the cases where no visible content exists
426 : : drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
427 : : drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
428 [ + - ][ + - ]: 99 : false, aObjectMatrix));
429 : :
430 [ + - ][ + - ]: 99 : return xRetval;
[ + - ]
431 : : }
432 : :
433 : 210 : bool ViewContactOfGraphic::visualisationUsesPresObj() const
434 : : {
435 : 210 : return GetGrafObject().IsEmptyPresObj();
436 : : }
437 : :
438 : 111 : bool ViewContactOfGraphic::visualisationUsesDraft() const
439 : : {
440 : : // no draft when already PresObj
441 [ - + ]: 111 : if(visualisationUsesPresObj())
442 : 0 : return false;
443 : :
444 : : // draft when swapped out
445 : 111 : const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false);
446 : : static bool bAllowReplacements(true);
447 : :
448 [ # # ][ - + ]: 111 : if(rGraphicObject.IsSwappedOut() && bAllowReplacements)
[ - + ]
449 : 0 : return true;
450 : :
451 : : // draft when no graphic
452 [ + + ][ - + ]: 111 : if(GRAPHIC_NONE == rGraphicObject.GetType() || GRAPHIC_DEFAULT == rGraphicObject.GetType())
[ + + ]
453 : 33 : return true;
454 : :
455 : 111 : return false;
456 : : }
457 : :
458 : : } // end of namespace contact
459 : : } // end of namespace sdr
460 : :
461 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|