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 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svx.hxx" 26 27 #include <svx/sdr/contact/viewcontactofsdrole2obj.hxx> 28 #include <svx/svdoole2.hxx> 29 #include <svx/sdr/contact/viewobjectcontactofsdrole2obj.hxx> 30 #include <basegfx/matrix/b2dhommatrix.hxx> 31 #include <svx/sdr/primitive2d/sdrole2primitive2d.hxx> 32 #include <drawinglayer/primitive2d/graphicprimitive2d.hxx> 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 42 ////////////////////////////////////////////////////////////////////////////// 43 44 namespace sdr 45 { 46 namespace contact 47 { 48 // Create a Object-Specific ViewObjectContact, set ViewContact and 49 // ObjectContact. Always needs to return something. 50 ViewObjectContact& ViewContactOfSdrOle2Obj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 51 { 52 ViewObjectContact* pRetval = new ViewObjectContactOfSdrOle2Obj(rObjectContact, *this); 53 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 54 55 return *pRetval; 56 } 57 58 ViewContactOfSdrOle2Obj::ViewContactOfSdrOle2Obj(SdrOle2Obj& rOle2Obj) 59 : ViewContactOfSdrRectObj(rOle2Obj) 60 { 61 } 62 63 ViewContactOfSdrOle2Obj::~ViewContactOfSdrOle2Obj() 64 { 65 } 66 67 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrOle2Obj::createPrimitive2DSequenceWithParameters( 68 bool bHighContrast) const 69 { 70 // 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()); 73 74 // create object matrix 75 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); 78 const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( 79 aObjectRange.getWidth(), aObjectRange.getHeight(), fShearX, fRotate, 80 aObjectRange.getMinX(), aObjectRange.getMinY())); 81 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))); 88 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( 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 102 bHighContrast)); 103 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 107 const drawinglayer::primitive2d::Primitive2DSequence xOLEContent(&xOleContent, 1); 108 const drawinglayer::primitive2d::Primitive2DReference xReference( 109 new drawinglayer::primitive2d::SdrOle2Primitive2D( 110 xOLEContent, 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 127