viewobjectcontactofsdrole2obj.cxx (f6e50924) viewobjectcontactofsdrole2obj.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

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

25#include "precompiled_svx.hxx"
26
27#include <svx/sdr/contact/viewobjectcontactofsdrole2obj.hxx>
28#include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
29#include <svx/sdr/contact/viewcontactofsdrole2obj.hxx>
30#include <svx/svdoole2.hxx>
31#include <svx/sdr/contact/objectcontact.hxx>
32#include <svx/svdview.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

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

25#include "precompiled_svx.hxx"
26
27#include <svx/sdr/contact/viewobjectcontactofsdrole2obj.hxx>
28#include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
29#include <svx/sdr/contact/viewcontactofsdrole2obj.hxx>
30#include <svx/svdoole2.hxx>
31#include <svx/sdr/contact/objectcontact.hxx>
32#include <svx/svdview.hxx>
33#include <drawinglayer/primitive2d/chartprimitive2d.hxx>
34#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
35#include <basegfx/polygon/b2dpolygontools.hxx>
36#include <com/sun/star/embed/EmbedMisc.hpp>
37#include <com/sun/star/embed/EmbedStates.hpp>
38#include <basegfx/polygon/b2dpolygon.hxx>
33#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
34#include <basegfx/polygon/b2dpolygontools.hxx>
35#include <com/sun/star/embed/EmbedMisc.hpp>
36#include <com/sun/star/embed/EmbedStates.hpp>
37#include <basegfx/polygon/b2dpolygon.hxx>
38#include <basegfx/matrix/b2dhommatrix.hxx>
39
40//////////////////////////////////////////////////////////////////////////////
41
42using namespace com::sun::star;
43
44//////////////////////////////////////////////////////////////////////////////
45
46namespace sdr

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

65 {
66 const svt::EmbeddedObjectRef& xObjRef = rSdrOle2.getEmbeddedObjectRef();
67 if ( xObjRef.is() )
68 nState = xObjRef->getCurrentState();
69 }
70
71 const bool bIsOutplaceActive(nState == embed::EmbedStates::ACTIVE);
72 const bool bIsInplaceActive((nState == embed::EmbedStates::INPLACE_ACTIVE) || (nState == embed::EmbedStates::UI_ACTIVE));
39
40//////////////////////////////////////////////////////////////////////////////
41
42using namespace com::sun::star;
43
44//////////////////////////////////////////////////////////////////////////////
45
46namespace sdr

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

65 {
66 const svt::EmbeddedObjectRef& xObjRef = rSdrOle2.getEmbeddedObjectRef();
67 if ( xObjRef.is() )
68 nState = xObjRef->getCurrentState();
69 }
70
71 const bool bIsOutplaceActive(nState == embed::EmbedStates::ACTIVE);
72 const bool bIsInplaceActive((nState == embed::EmbedStates::INPLACE_ACTIVE) || (nState == embed::EmbedStates::UI_ACTIVE));
73 const bool bIsChart(rSdrOle2.IsChart());
74 bool bDone(false);
75
76 if(!bDone && bIsInplaceActive)
77 {
78 if( !GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile() )
79 {
80 //no need to create a primitive sequence here as the OLE object does render itself
81 //in case of charts the superfluous creation of a metafile is strongly performance relevant!
82 bDone = true;
83 }
84 }
85
86 if( !bDone )
87 {
73 bool bDone(false);
74
75 if(!bDone && bIsInplaceActive)
76 {
77 if( !GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile() )
78 {
79 //no need to create a primitive sequence here as the OLE object does render itself
80 //in case of charts the superfluous creation of a metafile is strongly performance relevant!
81 bDone = true;
82 }
83 }
84
85 if( !bDone )
86 {
88 const Rectangle& rObjectRectangle(rSdrOle2.GetGeoRect());
89 const basegfx::B2DRange aObjectRange(rObjectRectangle.Left(), rObjectRectangle.Top(), rObjectRectangle.Right(), rObjectRectangle.Bottom());
90
91 // create object transform
92 basegfx::B2DHomMatrix aObjectTransform;
93 aObjectTransform.set(0, 0, aObjectRange.getWidth());
94 aObjectTransform.set(1, 1, aObjectRange.getHeight());
95 aObjectTransform.set(0, 2, aObjectRange.getMinX());
96 aObjectTransform.set(1, 2, aObjectRange.getMinY());
97
98 if(bIsChart)
99 {
100 //charts must be painted resolution dependent!! #i82893#, #i75867#
101
102 // for chart, to not lose the current better quality visualisation which
103 // uses a direct paint, use a primtive wrapper for that exceptional case. The renderers
104 // will then ATM paint it to an OutputDevice directly.
105 // In later versions this should be replaced by getting the Primitive2DSequnce from
106 // the chart and using it.
107 // to be able to render something in non-VCL using renderers, the wrapper is a
108 // GroupPrimitive2D which automatically decomposes to the already created Metafile
109 // content.
110 // For being completely compatible, ATM Window and VDEV PrettyPrinting is suppressed.
111 // It works in the VCL renderers, though. So for activating again with VCL primitive
112 // renderers, change conditions here.
113
114 // determine if embedding and PrettyPrinting shall be done at all
115 uno::Reference< frame::XModel > xChartModel;
116 bool bDoChartPrettyPrinting(true);
117
118 // the original ChartPrettyPainter does not do it for Window
119 if(bDoChartPrettyPrinting && GetObjectContact().isOutputToWindow())
120 {
121 bDoChartPrettyPrinting = false;
122 }
123
124 // the original ChartPrettyPainter does not do it for VDEV
125 if(bDoChartPrettyPrinting && GetObjectContact().isOutputToVirtualDevice())
126 {
127 if(GetObjectContact().isOutputToPDFFile())
128 {
129 // #i97982#
130 // For PDF files, allow PrettyPrinting
131 }
132 else
133 {
134 bDoChartPrettyPrinting = false;
135 }
136 }
137
138 // the chart model is needed. Check if it's available
139 if(bDoChartPrettyPrinting)
140 {
141 // get chart model
142 xChartModel = rSdrOle2.getXModel();
143
144 if(!xChartModel.is())
145 {
146 bDoChartPrettyPrinting = false;
147 }
148 }
149
150 if(bDoChartPrettyPrinting)
151 {
152 // embed MetaFile data in a specialized Wrapper Primitive which holds also the ChartModel needed
153 // for PrettyPrinting
154 const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::ChartPrimitive2D(
155 xChartModel, aObjectTransform, xRetval));
156 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
157 bDone = true;
158 }
159 }
160
161 if( !bDone )
87 //old stuff that should be reworked
162 {
88 {
163 //old stuff that should be reworked
89 //if no replacement image is available load the OLE object
90// if(!rSdrOle2.GetGraphic()) //try to fetch the metafile - this can lead to the actual creation of the metafile what can be extremely expensive (e.g. for big charts)!!! #i101925#
91// {
92// // try to create embedded object
93// rSdrOle2.GetObjRef(); //this loads the OLE object if it is not loaded already
94// }
95 const svt::EmbeddedObjectRef& xObjRef = rSdrOle2.getEmbeddedObjectRef();
96 if(xObjRef.is())
164 {
97 {
165 //if no replacement image is available load the OLE object
166 if(!rSdrOle2.GetGraphic()) //try to fetch the metafile - this can lead to the actual creation of the metafile what can be extremely expensive (e.g. for big charts)!!! #i101925#
98 const sal_Int64 nMiscStatus(xObjRef->getStatus(rSdrOle2.GetAspect()));
99
100 // this hack (to change model data during PAINT argh(!)) should be reworked
101 if(!rSdrOle2.IsResizeProtect() && (nMiscStatus & embed::EmbedMisc::EMBED_NEVERRESIZE))
167 {
102 {
168 // try to create embedded object
169 rSdrOle2.GetObjRef(); //this loads the OLE object if it is not loaded already
103 const_cast< SdrOle2Obj* >(&rSdrOle2)->SetResizeProtect(true);
170 }
104 }
171 const svt::EmbeddedObjectRef& xObjRef = rSdrOle2.getEmbeddedObjectRef();
172 if(xObjRef.is())
173 {
174 const sal_Int64 nMiscStatus(xObjRef->getStatus(rSdrOle2.GetAspect()));
175
105
176 // this hack (to change model data during PAINT argh(!)) should be reworked
177 if(!rSdrOle2.IsResizeProtect() && (nMiscStatus & embed::EmbedMisc::EMBED_NEVERRESIZE))
178 {
179 const_cast< SdrOle2Obj* >(&rSdrOle2)->SetResizeProtect(true);
180 }
106 SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
107 if(pPageView && (nMiscStatus & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE))
108 {
109 // connect plugin object
110 pPageView->GetView().DoConnect(const_cast< SdrOle2Obj* >(&rSdrOle2));
111 }
112 }
113 }//end old stuff to rework
181
114
182 SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
183 if(pPageView && (nMiscStatus & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE))
184 {
185 // connect plugin object
186 pPageView->GetView().DoConnect(const_cast< SdrOle2Obj* >(&rSdrOle2));
187 }
188 }
189 }//end old stuff to rework
115 // create OLE primitive stuff directly at VC with HC as parameter
116 const ViewContactOfSdrOle2Obj& rVC = static_cast< const ViewContactOfSdrOle2Obj& >(GetViewContact());
117 xRetval = rVC.createPrimitive2DSequenceWithParameters(GetObjectContact().isDrawModeHighContrast());
190
118
191 // create OLE primitive stuff directly at VC with HC as parameter
192 const ViewContactOfSdrOle2Obj& rVC = static_cast< const ViewContactOfSdrOle2Obj& >(GetViewContact());
193 xRetval = rVC.createPrimitive2DSequenceWithParameters(GetObjectContact().isDrawModeHighContrast());
194 }
195
196 if(bIsOutplaceActive)
197 {
198 // do not shade when printing or PDF exporting
199 if(!GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile())
200 {
119 if(bIsOutplaceActive)
120 {
121 // do not shade when printing or PDF exporting
122 if(!GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile())
123 {
201 // shade the representation if the object is activated outplace
124 // get object transformation
125 const basegfx::B2DHomMatrix aObjectMatrix(static_cast< ViewContactOfSdrOle2Obj& >(GetViewContact()).createObjectTransform());
126
127 // shade the representation if the object is activated outplace
202 basegfx::B2DPolygon aObjectOutline(basegfx::tools::createUnitPolygon());
128 basegfx::B2DPolygon aObjectOutline(basegfx::tools::createUnitPolygon());
203 aObjectOutline.transform(aObjectTransform);
129 aObjectOutline.transform(aObjectMatrix);
204
205 // Use a FillHatchPrimitive2D with necessary attributes
206 const drawinglayer::attribute::FillHatchAttribute aFillHatch(
207 drawinglayer::attribute::HATCHSTYLE_SINGLE, // single hatch
208 125.0, // 1.25 mm
209 45.0 * F_PI180, // 45 degree diagonal
210 Color(COL_BLACK).getBColor(), // black color
211 false); // no filling

--- 28 unchanged lines hidden ---
130
131 // Use a FillHatchPrimitive2D with necessary attributes
132 const drawinglayer::attribute::FillHatchAttribute aFillHatch(
133 drawinglayer::attribute::HATCHSTYLE_SINGLE, // single hatch
134 125.0, // 1.25 mm
135 45.0 * F_PI180, // 45 degree diagonal
136 Color(COL_BLACK).getBColor(), // black color
137 false); // no filling

--- 28 unchanged lines hidden ---