viewcontactofsdrole2obj.cxx (f6e50924) viewcontactofsdrole2obj.cxx (78d93489)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 24 unchanged lines hidden (view full) ---

33#include <basegfx/polygon/b2dpolygontools.hxx>
34#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
35#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
36#include <svtools/colorcfg.hxx>
37#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
38#include <vcl/svapp.hxx>
39#include <svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx>
40#include <basegfx/matrix/b2dhommatrixtools.hxx>
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 24 unchanged lines hidden (view full) ---

33#include <basegfx/polygon/b2dpolygontools.hxx>
34#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
35#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
36#include <svtools/colorcfg.hxx>
37#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
38#include <vcl/svapp.hxx>
39#include <svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx>
40#include <basegfx/matrix/b2dhommatrixtools.hxx>
41#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
42#include <svx/charthelper.hxx>
41
42//////////////////////////////////////////////////////////////////////////////
43
44namespace sdr
45{
46 namespace contact
47 {
48 // Create a Object-Specific ViewObjectContact, set ViewContact and

--- 10 unchanged lines hidden (view full) ---

59 : ViewContactOfSdrRectObj(rOle2Obj)
60 {
61 }
62
63 ViewContactOfSdrOle2Obj::~ViewContactOfSdrOle2Obj()
64 {
65 }
66
43
44//////////////////////////////////////////////////////////////////////////////
45
46namespace sdr
47{
48 namespace contact
49 {
50 // Create a Object-Specific ViewObjectContact, set ViewContact and

--- 10 unchanged lines hidden (view full) ---

61 : ViewContactOfSdrRectObj(rOle2Obj)
62 {
63 }
64
65 ViewContactOfSdrOle2Obj::~ViewContactOfSdrOle2Obj()
66 {
67 }
68
67 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrOle2Obj::createPrimitive2DSequenceWithParameters(
68 bool bHighContrast) const
69 basegfx::B2DHomMatrix ViewContactOfSdrOle2Obj::createObjectTransform() const
69 {
70 // take unrotated snap rect (direct model data) for position and size
70 {
71 // take unrotated snap rect (direct model data) for position and size
71 const Rectangle& rRectangle = GetOle2Obj().GetGeoRect();
72 const basegfx::B2DRange aObjectRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom());
72 const Rectangle& rRectangle = GetOle2Obj().GetGeoRect();
73 const basegfx::B2DRange aObjectRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom());
73
74
74 // create object matrix
75 const GeoStat& rGeoStat(GetOle2Obj().GetGeoStat());
75 // create object matrix
76 const GeoStat& rGeoStat(GetOle2Obj().GetGeoStat());
76 const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
77 const double fRotate(rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0);
77 const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
78 const double fRotate(rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0);
78 const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
79 aObjectRange.getWidth(), aObjectRange.getHeight(), fShearX, fRotate,
80 aObjectRange.getMinX(), aObjectRange.getMinY()));
79
80 return basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
81 aObjectRange.getWidth(), aObjectRange.getHeight(),
82 fShearX,
83 fRotate,
84 aObjectRange.getMinX(), aObjectRange.getMinY());
85 }
81
86
87 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrOle2Obj::createPrimitive2DSequenceWithParameters(
88 bool bHighContrast) const
89 {
90 // get object transformation
91 const basegfx::B2DHomMatrix aObjectMatrix(createObjectTransform());
92
82 // Prepare attribute settings, will be used soon anyways
83 const SfxItemSet& rItemSet = GetOle2Obj().GetMergedItemSet();
84 const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
85 drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
86 rItemSet,
87 GetOle2Obj().getText(0)));
93 // Prepare attribute settings, will be used soon anyways
94 const SfxItemSet& rItemSet = GetOle2Obj().GetMergedItemSet();
95 const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
96 drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
97 rItemSet,
98 GetOle2Obj().getText(0)));
99 drawinglayer::primitive2d::Primitive2DReference xContent;
88
100
89 // #i102063# embed OLE content in an own primitive; this will be able to decompose accessing
90 // the weak SdrOle2 reference and will also implement getB2DRange() for fast BoundRect
91 // calculations without OLE Graphic access (which may trigger e.g. chart recalculation).
92 // It will also take care of HighContrast and ScaleContent
93 const drawinglayer::primitive2d::Primitive2DReference xOleContent(
94 new drawinglayer::primitive2d::SdrOleContentPrimitive2D(
101 if(GetOle2Obj().IsChart())
102 {
103 // try to get chart primitives and chart range directly from xChartModel
104 basegfx::B2DRange aChartContentRange;
105 const drawinglayer::primitive2d::Primitive2DSequence aChartSequence(
106 ChartHelper::tryToGetChartContentAsPrimitive2DSequence(
107 GetOle2Obj().getXModel(),
108 aChartContentRange));
109 const double fWidth(aChartContentRange.getWidth());
110 const double fHeight(aChartContentRange.getHeight());
111
112 if(aChartSequence.hasElements()
113 && basegfx::fTools::more(fWidth, 0.0)
114 && basegfx::fTools::more(fHeight, 0.0))
115 {
116 // create embedding transformation
117 basegfx::B2DHomMatrix aEmbed(
118 basegfx::tools::createTranslateB2DHomMatrix(
119 -aChartContentRange.getMinX(),
120 -aChartContentRange.getMinY()));
121
122 aEmbed.scale(1.0 / fWidth, 1.0 / fHeight);
123 aEmbed = aObjectMatrix * aEmbed;
124 xContent = new drawinglayer::primitive2d::TransformPrimitive2D(
125 aEmbed,
126 aChartSequence);
127 }
128 }
129
130 if(!xContent.is())
131 {
132 // #i102063# embed OLE content in an own primitive; this will be able to decompose accessing
133 // the weak SdrOle2 reference and will also implement getB2DRange() for fast BoundRect
134 // calculations without OLE Graphic access (which may trigger e.g. chart recalculation).
135 // It will also take care of HighContrast and ScaleContent
136 xContent = new drawinglayer::primitive2d::SdrOleContentPrimitive2D(
95 GetOle2Obj(),
96 aObjectMatrix,
97
98 // #i104867# add GraphicVersion number to be able to check for
99 // content change in the primitive later
100 GetOle2Obj().getEmbeddedObjectRef().getGraphicVersion(),
101
137 GetOle2Obj(),
138 aObjectMatrix,
139
140 // #i104867# add GraphicVersion number to be able to check for
141 // content change in the primitive later
142 GetOle2Obj().getEmbeddedObjectRef().getGraphicVersion(),
143
102 bHighContrast));
103
144 bHighContrast);
145 }
146
104 // create primitive. Use Ole2 primitive here. Prepare attribute settings, will
105 // be used soon anyways. Always create primitives to allow the decomposition of
106 // SdrOle2Primitive2D to create needed invisible elements for HitTest and/or BoundRect
147 // create primitive. Use Ole2 primitive here. Prepare attribute settings, will
148 // be used soon anyways. Always create primitives to allow the decomposition of
149 // SdrOle2Primitive2D to create needed invisible elements for HitTest and/or BoundRect
107 const drawinglayer::primitive2d::Primitive2DSequence xOLEContent(&xOleContent, 1);
108 const drawinglayer::primitive2d::Primitive2DReference xReference(
109 new drawinglayer::primitive2d::SdrOle2Primitive2D(
150 const drawinglayer::primitive2d::Primitive2DReference xReference(
151 new drawinglayer::primitive2d::SdrOle2Primitive2D(
110 xOLEContent,
152 drawinglayer::primitive2d::Primitive2DSequence(&xContent, 1),
111 aObjectMatrix,
112 aAttribute));
113
114 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
115 }
116
117 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrOle2Obj::createViewIndependentPrimitive2DSequence() const
118 {
119 // do as if no HC and call standard creator
120 return createPrimitive2DSequenceWithParameters(false);
121 }
122 } // end of namespace contact
123} // end of namespace sdr
124
125//////////////////////////////////////////////////////////////////////////////
126// eof
153 aObjectMatrix,
154 aAttribute));
155
156 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
157 }
158
159 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrOle2Obj::createViewIndependentPrimitive2DSequence() const
160 {
161 // do as if no HC and call standard creator
162 return createPrimitive2DSequenceWithParameters(false);
163 }
164 } // end of namespace contact
165} // end of namespace sdr
166
167//////////////////////////////////////////////////////////////////////////////
168// eof