summaryrefslogtreecommitdiff
path: root/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx')
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx240
1 files changed, 140 insertions, 100 deletions
diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx
index d5681c60463e..635ae9c7fcc8 100644
--- a/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx
@@ -37,10 +37,13 @@
#include <svx/sdr/contact/viewcontactofsdrole2obj.hxx>
#include <svx/svdoole2.hxx>
#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/svdview.hxx>
#include <drawinglayer/primitive2d/chartprimitive2d.hxx>
#include <drawinglayer/attribute/fillattribute.hxx>
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <com/sun/star/embed/EmbedMisc.hpp>
+#include <com/sun/star/embed/EmbedStates.hpp>
//////////////////////////////////////////////////////////////////////////////
@@ -57,136 +60,173 @@ namespace sdr
return static_cast< ViewContactOfSdrOle2Obj& >(GetViewContact()).GetOle2Obj();
}
- drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfSdrOle2Obj::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfSdrOle2Obj::createPrimitive2DSequence(
+ const DisplayInfo& /*rDisplayInfo*/) const
{
// this method is overloaded to do some things the old SdrOle2Obj::DoPaintObject did.
// In the future, some of these may be solved different, but ATM try to stay compatible
// with the old behaviour
drawinglayer::primitive2d::Primitive2DSequence xRetval;
const SdrOle2Obj& rSdrOle2 = getSdrOle2Object();
- const bool bIsActive(rSdrOle2.executeOldDoPaintPreparations(GetObjectContact().TryToGetSdrPageView()));
- const Rectangle& rObjectRectangle(rSdrOle2.GetGeoRect());
- const basegfx::B2DRange aObjectRange(rObjectRectangle.Left(), rObjectRectangle.Top(), rObjectRectangle.Right(), rObjectRectangle.Bottom());
-
- // create object transform
- basegfx::B2DHomMatrix aObjectTransform;
- aObjectTransform.set(0, 0, aObjectRange.getWidth());
- aObjectTransform.set(1, 1, aObjectRange.getHeight());
- aObjectTransform.set(0, 2, aObjectRange.getMinX());
- aObjectTransform.set(1, 2, aObjectRange.getMinY());
-
- if(GetObjectContact().isDrawModeHighContrast())
- {
- // directly call at the corresponding VC and force OLE Graphic to HighContrast
- const ViewContactOfSdrOle2Obj& rVC = static_cast< const ViewContactOfSdrOle2Obj& >(GetViewContact());
- Graphic* pOLEHighContrastGraphic = rSdrOle2.getEmbeddedObjectRef().GetHCGraphic();
+ sal_Int32 nState(-1);
- if(pOLEHighContrastGraphic)
- {
- // there is a graphic set, use it
- xRetval = rVC.createPrimitive2DSequenceWithGivenGraphic(*pOLEHighContrastGraphic, rSdrOle2.IsEmptyPresObj());
- }
- else
- {
- // no HighContrast graphic, use default empty OLE bitmap
- const Bitmap aEmptyOLEBitmap(rSdrOle2.GetEmtyOLEReplacementBitmap());
- const Graphic aEmtyOLEGraphic(aEmptyOLEBitmap);
-
- xRetval = rVC.createPrimitive2DSequenceWithGivenGraphic(aEmtyOLEGraphic, true);
- }
- }
- else
{
- // call parent which will use the regular createViewIndependentPrimitive2DSequence
- // at the corresponding VC
- xRetval = ViewObjectContactOfSdrObj::createPrimitive2DSequence(rDisplayInfo);
+ const svt::EmbeddedObjectRef& xObjRef = rSdrOle2.getEmbeddedObjectRef();
+ if ( xObjRef.is() )
+ nState = xObjRef->getCurrentState();
}
- if(rSdrOle2.getEmbeddedObjectRef().IsChart())
+ const bool bIsOutplaceActive(nState == embed::EmbedStates::ACTIVE);
+ const bool bIsInplaceActive((nState == embed::EmbedStates::INPLACE_ACTIVE) || (nState == embed::EmbedStates::UI_ACTIVE));
+ const bool bIsChart(rSdrOle2.IsChart());
+ bool bDone(false);
+
+ if(!bDone && bIsInplaceActive)
{
- // for chart, to not lose the current better quality visualisation which
- // uses a direct paint, use a primtive wrapper for that exceptional case. The renderers
- // will then ATM paint it to an OutputDevice directly.
- // In later versions this should be replaced by getting the Primitive2DSequnce from
- // the chart and using it.
- // to be able to render something in non-VCL using renderers, the wrapper is a
- // GroupPrimitive2D which automatically decomposes to the already created Metafile
- // content.
- // For being completely compatible, ATM Window and VDEV PrettyPrinting is suppressed.
- // It works in the VCL renderers, though. So for activating again with VCL primitive
- // renderers, change conditions here.
-
- // determine if embedding and PrettyPrinting shall be done at all
- uno::Reference< frame::XModel > xChartModel;
- bool bDoChartPrettyPrinting(true);
- static bool bPrettyPrintingForBitmaps(false);
-
- // the original ChartPrettyPainter does not do it for Window
- if(!bPrettyPrintingForBitmaps && bDoChartPrettyPrinting && GetObjectContact().isOutputToWindow())
+ if( !GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile() )
{
- bDoChartPrettyPrinting = false;
+ //no need to create a primitive sequence here as the OLE object does render itself
+ //in case of charts the superfluous creation of a metafile is strongly performance relevant!
+ bDone = true;
}
+ }
+
+ if( !bDone )
+ {
+ const Rectangle& rObjectRectangle(rSdrOle2.GetGeoRect());
+ const basegfx::B2DRange aObjectRange(rObjectRectangle.Left(), rObjectRectangle.Top(), rObjectRectangle.Right(), rObjectRectangle.Bottom());
- // the original ChartPrettyPainter does not do it for VDEV
- if(!bPrettyPrintingForBitmaps && bDoChartPrettyPrinting && GetObjectContact().isOutputToVirtualDevice())
+ // create object transform
+ basegfx::B2DHomMatrix aObjectTransform;
+ aObjectTransform.set(0, 0, aObjectRange.getWidth());
+ aObjectTransform.set(1, 1, aObjectRange.getHeight());
+ aObjectTransform.set(0, 2, aObjectRange.getMinX());
+ aObjectTransform.set(1, 2, aObjectRange.getMinY());
+
+ if(bIsChart)
{
- if(GetObjectContact().isOutputToPDFFile())
+ //charts must be painted resolution dependent!! #i82893#, #i75867#
+
+ // for chart, to not lose the current better quality visualisation which
+ // uses a direct paint, use a primtive wrapper for that exceptional case. The renderers
+ // will then ATM paint it to an OutputDevice directly.
+ // In later versions this should be replaced by getting the Primitive2DSequnce from
+ // the chart and using it.
+ // to be able to render something in non-VCL using renderers, the wrapper is a
+ // GroupPrimitive2D which automatically decomposes to the already created Metafile
+ // content.
+ // For being completely compatible, ATM Window and VDEV PrettyPrinting is suppressed.
+ // It works in the VCL renderers, though. So for activating again with VCL primitive
+ // renderers, change conditions here.
+
+ // determine if embedding and PrettyPrinting shall be done at all
+ uno::Reference< frame::XModel > xChartModel;
+ bool bDoChartPrettyPrinting(true);
+
+ // the original ChartPrettyPainter does not do it for Window
+ if(bDoChartPrettyPrinting && GetObjectContact().isOutputToWindow())
{
- // #i97982#
- // For PDF files, allow PrettyPrinting
+ bDoChartPrettyPrinting = false;
}
- else
+
+ // the original ChartPrettyPainter does not do it for VDEV
+ if(bDoChartPrettyPrinting && GetObjectContact().isOutputToVirtualDevice())
{
- bDoChartPrettyPrinting = false;
+ if(GetObjectContact().isOutputToPDFFile())
+ {
+ // #i97982#
+ // For PDF files, allow PrettyPrinting
+ }
+ else
+ {
+ bDoChartPrettyPrinting = false;
+ }
}
- }
- // the chart model is needed. Check if it's available
- if(bDoChartPrettyPrinting)
- {
- // get chart model
- xChartModel = rSdrOle2.getXModel();
+ // the chart model is needed. Check if it's available
+ if(bDoChartPrettyPrinting)
+ {
+ // get chart model
+ xChartModel = rSdrOle2.getXModel();
- if(!xChartModel.is())
+ if(!xChartModel.is())
+ {
+ bDoChartPrettyPrinting = false;
+ }
+ }
+
+ if(bDoChartPrettyPrinting)
{
- bDoChartPrettyPrinting = false;
+ // embed MetaFile data in a specialized Wrapper Primitive which holds also the ChartModel needed
+ // for PrettyPrinting
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::ChartPrimitive2D(
+ xChartModel, aObjectTransform, xRetval));
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ bDone = true;
}
}
- if(bDoChartPrettyPrinting)
+ if( !bDone )
{
- // embed MetaFile data in a specialized Wrapper Primitive which holds also the ChartModel needed
- // for PrettyPrinting
- const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::ChartPrimitive2D(
- xChartModel, aObjectTransform, xRetval));
- xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ //old stuff that should be reworked
+ {
+ //if no replacement image is available load the OLE object
+ 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#
+ {
+ // try to create embedded object
+ rSdrOle2.GetObjRef(); //this loads the OLE object if it is not loaded already
+ }
+ const svt::EmbeddedObjectRef& xObjRef = rSdrOle2.getEmbeddedObjectRef();
+ if(xObjRef.is())
+ {
+ const sal_Int64 nMiscStatus(xObjRef->getStatus(rSdrOle2.GetAspect()));
+
+ // this hack (to change model data during PAINT argh(!)) should be reworked
+ if(!rSdrOle2.IsResizeProtect() && (nMiscStatus & embed::EmbedMisc::EMBED_NEVERRESIZE))
+ {
+ const_cast< SdrOle2Obj* >(&rSdrOle2)->SetResizeProtect(true);
+ }
+
+ SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
+ if(pPageView && (nMiscStatus & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE))
+ {
+ // connect plugin object
+ pPageView->GetView().DoConnect(const_cast< SdrOle2Obj* >(&rSdrOle2));
+ }
+ }
+ }//end old stuff to rework
+
+ // create OLE primitive stuff directly at VC with HC as parameter
+ const ViewContactOfSdrOle2Obj& rVC = static_cast< const ViewContactOfSdrOle2Obj& >(GetViewContact());
+ xRetval = rVC.createPrimitive2DSequenceWithParameters(GetObjectContact().isDrawModeHighContrast());
}
- }
- if(bIsActive)
- {
- // do not shade when printing or PDF exporting
- if(!GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile())
+ if(bIsOutplaceActive)
{
- // shade the representation if the object is activated outplace
- basegfx::B2DPolygon aObjectOutline(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0)));
- aObjectOutline.transform(aObjectTransform);
-
- // Use a FillHatchPrimitive2D with necessary attributes
- const drawinglayer::attribute::FillHatchAttribute aFillHatch(
- drawinglayer::attribute::HATCHSTYLE_SINGLE, // single hatch
- 125.0, // 1.25 mm
- 45.0 * F_PI180, // 45 degree diagonal
- Color(COL_BLACK).getBColor(), // black color
- false); // no filling
-
- const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolyPolygonHatchPrimitive2D(
- basegfx::B2DPolyPolygon(aObjectOutline),
- Color(COL_BLACK).getBColor(),
- aFillHatch));
-
- drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReference);
+ // do not shade when printing or PDF exporting
+ if(!GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile())
+ {
+ // shade the representation if the object is activated outplace
+ basegfx::B2DPolygon aObjectOutline(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0)));
+ aObjectOutline.transform(aObjectTransform);
+
+ // Use a FillHatchPrimitive2D with necessary attributes
+ const drawinglayer::attribute::FillHatchAttribute aFillHatch(
+ drawinglayer::attribute::HATCHSTYLE_SINGLE, // single hatch
+ 125.0, // 1.25 mm
+ 45.0 * F_PI180, // 45 degree diagonal
+ Color(COL_BLACK).getBColor(), // black color
+ false); // no filling
+
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolyPolygonHatchPrimitive2D(
+ basegfx::B2DPolyPolygon(aObjectOutline),
+ Color(COL_BLACK).getBColor(),
+ aFillHatch));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReference);
+ }
}
+
}
return xRetval;