LibreOffice Module svx (master) 1
viewcontactofsdrole2obj.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#include <drawinglayer/primitive2d/Tools.hxx>
22#include <svx/svdoole2.hxx>
27#include <vcl/canvastools.hxx>
28#include <tools/debug.hxx>
32#include <svx/charthelper.hxx>
33#include <svtools/embedhlp.hxx>
34
35namespace sdr::contact {
36
37// Create an Object-Specific ViewObjectContact, set ViewContact and
38// ObjectContact. Always needs to return something.
40{
41 ViewObjectContact* pRetval = new ViewObjectContactOfSdrOle2Obj(rObjectContact, *this);
42 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
43
44 return *pRetval;
45}
46
49{
50}
51
53{
54}
55
57{
58 // take unrotated snap rect (direct model data) for position and size
59 const tools::Rectangle aRectangle(GetOle2Obj().GetGeoRect());
60 const basegfx::B2DRange aObjectRange = vcl::unotools::b2DRectangleFromRectangle(aRectangle);
61
62 // create object matrix
63 const GeoStat& rGeoStat(GetOle2Obj().GetGeoStat());
64 const double fShearX(-rGeoStat.mfTanShearAngle);
65 const double fRotate(rGeoStat.m_nRotationAngle ? toRadians(36000_deg100 - rGeoStat.m_nRotationAngle) : 0.0);
66
68 aObjectRange.getWidth(), aObjectRange.getHeight(),
69 fShearX,
70 fRotate,
71 aObjectRange.getMinX(), aObjectRange.getMinY());
72}
73
75{
76 // get object transformation
77 const basegfx::B2DHomMatrix aObjectMatrix(createObjectTransform());
78
79 // Prepare attribute settings, will be used soon anyways
80 const SfxItemSet& rItemSet = GetOle2Obj().GetMergedItemSet();
81
82 // this may be refined more granular; if no content, attributes may get simpler
85 rItemSet,
86 GetOle2Obj().getText(0),
87 true));
89
90 if(GetOle2Obj().IsChart())
91 {
92 // try to get chart primitives and chart range directly from xChartModel
93 basegfx::B2DRange aChartContentRange;
97 aChartContentRange));
98 const double fWidth(aChartContentRange.getWidth());
99 const double fHeight(aChartContentRange.getHeight());
100
101 if(!aChartSequence.empty()
102 && basegfx::fTools::more(fWidth, 0.0)
103 && basegfx::fTools::more(fHeight, 0.0))
104 {
105 // create embedding transformation
108 -aChartContentRange.getMinX(),
109 -aChartContentRange.getMinY()));
110
111 aEmbed.scale(1.0 / fWidth, 1.0 / fHeight);
112 aEmbed = aObjectMatrix * aEmbed;
114 aEmbed,
115 std::move(aChartSequence));
116 }
117 }
118
119 if(!xContent.is())
120 {
121 // #i102063# embed OLE content in an own primitive; this will be able to decompose accessing
122 // the weak SdrOle2 reference and will also implement getB2DRange() for fast BoundRect
123 // calculations without OLE Graphic access (which may trigger e.g. chart recalculation).
124 // It will also take care of HighContrast and ScaleContent
126 GetOle2Obj(),
127 aObjectMatrix,
128
129 // #i104867# add GraphicVersion number to be able to check for
130 // content change in the primitive later
131 GetOle2Obj().getEmbeddedObjectRef().getGraphicVersion() );
132 }
133
134 // create primitive. Use Ole2 primitive here. Prepare attribute settings, will
135 // be used soon anyways. Always create primitives to allow the decomposition of
136 // SdrOle2Primitive2D to create needed invisible elements for HitTest and/or BoundRect
140 aObjectMatrix,
141 aAttribute));
142
143 rVisitor.visit(xReference);
144}
145
147{
148 // this may be refined more granular; if no content, attributes may get simpler
151 GetOle2Obj().GetMergedItemSet(),
152 GetOle2Obj().getText(0),
153 true);
154
156
159 GetOle2Obj(),
160 aObjectMatrix,
161 GetOle2Obj().getEmbeddedObjectRef().getGraphicVersion());
162
166 aObjectMatrix,
167 aAttribute));
168
170}
171
173{
175}
176
177}
178
179/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static drawinglayer::primitive2d::Primitive2DContainer tryToGetChartContentAsPrimitive2DSequence(const css::uno::Reference< css::frame::XModel > &rXModel, basegfx::B2DRange &rRange)
Definition: charthelper.cxx:53
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
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1974
void scale(double fX, double fY)
TYPE getWidth() const
TYPE getMinX() const
TYPE getMinY() const
TYPE getHeight() const
virtual void visit(const Primitive2DReference &)=0
virtual void createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor &rVisitor) const override
void createPrimitive2DSequenceWithParameters(drawinglayer::primitive2d::Primitive2DDecompositionVisitor &rVisitor) const
virtual basegfx::B2DRange getRange(const drawinglayer::geometry::ViewInformation2D &rViewInfo2D) const override
basegfx::B2DHomMatrix createObjectTransform() const
helper to create transformation from SdrObject
virtual ViewObjectContact & CreateObjectSpecificViewObjectContact(ObjectContact &rObjectContact) override
#define DBG_ASSERT(sCon, aError)
double toRadians(D x)
bool more(const T &rfValA, const T &rfValB)
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
B2DHomMatrix createScaleShearXRotateTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fShearX, double fRadiant, double fTranslateX, double fTranslateY)
basegfx::B2DRange getB2DRangeFromPrimitive2DReference(const Primitive2DReference &rCandidate, const geometry::ViewInformation2D &aViewInformation)
attribute::SdrLineFillEffectsTextAttribute createNewSdrLineFillEffectsTextAttribute(const SfxItemSet &rSet, const SdrText *pText, bool bHasContent, bool bSuppressShadow)
css::uno::Reference< css::frame::XModel > getXModel(const css::uno::Reference< css::uno::XInterface > &_rxComponent)
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)