1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10f6e50924SAndrew Rist * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12f6e50924SAndrew Rist * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19f6e50924SAndrew Rist * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofgraphic.hxx> 27cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactofgraphic.hxx> 28cdf0e10cSrcweir #include <svx/svdograf.hxx> 29cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrattributecreator.hxx> 30cdf0e10cSrcweir #include <svl/itemset.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #ifndef ITEMID_GRF_CROP 33cdf0e10cSrcweir #define ITEMID_GRF_CROP 0 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <svx/sdgcpitm.hxx> 37cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx> 38cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontact.hxx> 39cdf0e10cSrcweir #include <svx/sdr/contact/objectcontact.hxx> 40cdf0e10cSrcweir #include <svx/sdr/event/eventhandler.hxx> 41cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 42cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrgrafprimitive2d.hxx> 43cdf0e10cSrcweir #include "svx/svdstr.hrc" 44cdf0e10cSrcweir #include <svx/svdglob.hxx> 45cdf0e10cSrcweir #include <vcl/svapp.hxx> 46cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 47cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> 48cdf0e10cSrcweir #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> 49cdf0e10cSrcweir #include <drawinglayer/primitive2d/textprimitive2d.hxx> 50cdf0e10cSrcweir #include <drawinglayer/primitive2d/textlayoutdevice.hxx> 51cdf0e10cSrcweir #include <drawinglayer/primitive2d/maskprimitive2d.hxx> 52cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx> 53cdf0e10cSrcweir #include <editeng/eeitem.hxx> 54cdf0e10cSrcweir #include <editeng/colritem.hxx> 55cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx> 56cdf0e10cSrcweir #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx> 57cdf0e10cSrcweir 58cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 59cdf0e10cSrcweir 60cdf0e10cSrcweir namespace sdr 61cdf0e10cSrcweir { 62cdf0e10cSrcweir namespace contact 63cdf0e10cSrcweir { 64cdf0e10cSrcweir // Create a Object-Specific ViewObjectContact, set ViewContact and 65cdf0e10cSrcweir // ObjectContact. Always needs to return something. 66cdf0e10cSrcweir ViewObjectContact& ViewContactOfGraphic::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir ViewObjectContact* pRetval = new ViewObjectContactOfGraphic(rObjectContact, *this); 69cdf0e10cSrcweir DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 70cdf0e10cSrcweir 71cdf0e10cSrcweir return *pRetval; 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir ViewContactOfGraphic::ViewContactOfGraphic(SdrGrafObj& rGrafObj) 75cdf0e10cSrcweir : ViewContactOfTextObj(rGrafObj) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir ViewContactOfGraphic::~ViewContactOfGraphic() 80cdf0e10cSrcweir { 81cdf0e10cSrcweir } 82cdf0e10cSrcweir 83cdf0e10cSrcweir void ViewContactOfGraphic::flushGraphicObjects() 84cdf0e10cSrcweir { 85cdf0e10cSrcweir // #i102380# The graphic is swapped out. To let that have an effect ist is necessary to 86cdf0e10cSrcweir // delete copies of the GraphicObject which are not swapped out and have no SwapHandler set 87cdf0e10cSrcweir // (this is what happnes when the GraphicObject gets copied to a SdrGrafPrimitive2D). This 88cdf0e10cSrcweir // is best achieved for the VC by clearing the local decomposition cache. It would be possible 89cdf0e10cSrcweir // to also do this for the VOC cache, but that VOCs exist exactly expresss that the object 90cdf0e10cSrcweir // gets visualised, so this would be wrong. 91cdf0e10cSrcweir flushViewIndependentPrimitive2DSequence(); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createVIP2DSForPresObj( 95cdf0e10cSrcweir const basegfx::B2DHomMatrix& rObjectMatrix, 96cdf0e10cSrcweir const drawinglayer::attribute::SdrLineFillShadowTextAttribute& rAttribute, 97cdf0e10cSrcweir const GraphicAttr& rLocalGrafInfo) const 98cdf0e10cSrcweir { 99cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence xRetval; 100cdf0e10cSrcweir GraphicObject aEmptyGraphicObject; 101cdf0e10cSrcweir GraphicAttr aEmptyGraphicAttr; 102cdf0e10cSrcweir 103cdf0e10cSrcweir // SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts 104cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference xReferenceA(new drawinglayer::primitive2d::SdrGrafPrimitive2D( 105cdf0e10cSrcweir rObjectMatrix, 106cdf0e10cSrcweir rAttribute, 107cdf0e10cSrcweir aEmptyGraphicObject, 108cdf0e10cSrcweir aEmptyGraphicAttr)); 109cdf0e10cSrcweir xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReferenceA, 1); 110cdf0e10cSrcweir 111cdf0e10cSrcweir // SdrGrafPrimitive2D with content (which is the preview graphic) scaled to smaller size and 112cdf0e10cSrcweir // without attributes 113cdf0e10cSrcweir basegfx::B2DHomMatrix aSmallerMatrix; 114cdf0e10cSrcweir 115cdf0e10cSrcweir // #i94431# for some reason, i forgot to take the PrefMapMode of the graphic 116cdf0e10cSrcweir // into account. Since EmptyPresObj's are only used in Draw/Impress, it is 117cdf0e10cSrcweir // safe to assume 100th mm as target. 118cdf0e10cSrcweir Size aPrefSize(GetGrafObject().GetGrafPrefSize()); 119cdf0e10cSrcweir 120cdf0e10cSrcweir if(MAP_PIXEL == GetGrafObject().GetGrafPrefMapMode().GetMapUnit()) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MAP_100TH_MM); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir else 125cdf0e10cSrcweir { 126cdf0e10cSrcweir aPrefSize = Application::GetDefaultDevice()->LogicToLogic(aPrefSize, GetGrafObject().GetGrafPrefMapMode(), MAP_100TH_MM); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir // decompose object matrix to get single values 130cdf0e10cSrcweir basegfx::B2DVector aScale, aTranslate; 131cdf0e10cSrcweir double fRotate, fShearX; 132cdf0e10cSrcweir rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX); 133cdf0e10cSrcweir 134cdf0e10cSrcweir const double fOffsetX((aScale.getX() - aPrefSize.getWidth()) / 2.0); 135cdf0e10cSrcweir const double fOffsetY((aScale.getY() - aPrefSize.getHeight()) / 2.0); 136cdf0e10cSrcweir 137cdf0e10cSrcweir if(basegfx::fTools::moreOrEqual(fOffsetX, 0.0) && basegfx::fTools::moreOrEqual(fOffsetY, 0.0)) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir // create the EmptyPresObj fallback visualisation. The fallback graphic 140cdf0e10cSrcweir // is already provided in rGraphicObject in this case, use it 141cdf0e10cSrcweir aSmallerMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aPrefSize.getWidth(), aPrefSize.getHeight(), fOffsetX, fOffsetY); 142cdf0e10cSrcweir aSmallerMatrix = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate) 143cdf0e10cSrcweir * aSmallerMatrix; 144cdf0e10cSrcweir 145cdf0e10cSrcweir const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false); 146cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference xReferenceB(new drawinglayer::primitive2d::SdrGrafPrimitive2D( 147cdf0e10cSrcweir aSmallerMatrix, 148cdf0e10cSrcweir drawinglayer::attribute::SdrLineFillShadowTextAttribute(), 149cdf0e10cSrcweir rGraphicObject, 150cdf0e10cSrcweir rLocalGrafInfo)); 151cdf0e10cSrcweir 152cdf0e10cSrcweir drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReferenceB); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir return xRetval; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createVIP2DSForDraft( 159cdf0e10cSrcweir const basegfx::B2DHomMatrix& rObjectMatrix, 160cdf0e10cSrcweir const drawinglayer::attribute::SdrLineFillShadowTextAttribute& rAttribute) const 161cdf0e10cSrcweir { 162cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence xRetval; 163cdf0e10cSrcweir GraphicObject aEmptyGraphicObject; 164cdf0e10cSrcweir GraphicAttr aEmptyGraphicAttr; 165cdf0e10cSrcweir 166cdf0e10cSrcweir // SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts 167cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference xReferenceA(new drawinglayer::primitive2d::SdrGrafPrimitive2D( 168cdf0e10cSrcweir rObjectMatrix, 169cdf0e10cSrcweir rAttribute, 170cdf0e10cSrcweir aEmptyGraphicObject, 171cdf0e10cSrcweir aEmptyGraphicAttr)); 172cdf0e10cSrcweir xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReferenceA, 1); 173cdf0e10cSrcweir 174cdf0e10cSrcweir if(rAttribute.getLine().isDefault()) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir // create a surrounding frame when no linestyle given 177cdf0e10cSrcweir const Color aColor(Application::GetSettings().GetStyleSettings().GetShadowColor()); 178cdf0e10cSrcweir const basegfx::BColor aBColor(aColor.getBColor()); 179cdf0e10cSrcweir basegfx::B2DPolygon aOutline(basegfx::tools::createUnitPolygon()); 180cdf0e10cSrcweir aOutline.transform(rObjectMatrix); 181cdf0e10cSrcweir 182cdf0e10cSrcweir drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, 183cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DReference( 184cdf0e10cSrcweir new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( 185cdf0e10cSrcweir aOutline, 186cdf0e10cSrcweir aBColor))); 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir // decompose object matrix to get single values 190cdf0e10cSrcweir basegfx::B2DVector aScale, aTranslate; 191cdf0e10cSrcweir double fRotate, fShearX; 192cdf0e10cSrcweir rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX); 193cdf0e10cSrcweir 194cdf0e10cSrcweir // define a distance value, used for distance from bitmap to borders and from bitmap 195cdf0e10cSrcweir // to text, too (2 mm) 196cdf0e10cSrcweir const double fDistance(200.0); 197cdf0e10cSrcweir 198cdf0e10cSrcweir // consume borders from values 199cdf0e10cSrcweir aScale.setX(std::max(0.0, aScale.getX() - (2.0 * fDistance))); 200cdf0e10cSrcweir aScale.setY(std::max(0.0, aScale.getY() - (2.0 * fDistance))); 201cdf0e10cSrcweir aTranslate.setX(aTranslate.getX() + fDistance); 202cdf0e10cSrcweir aTranslate.setY(aTranslate.getY() + fDistance); 203cdf0e10cSrcweir 204cdf0e10cSrcweir // draw a draft bitmap 205cdf0e10cSrcweir const Bitmap aDraftBitmap(ResId(BMAP_GrafikEi, *ImpGetResMgr())); 206cdf0e10cSrcweir 207cdf0e10cSrcweir if(!aDraftBitmap.IsEmpty()) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir Size aPrefSize(aDraftBitmap.GetPrefSize()); 210cdf0e10cSrcweir 211cdf0e10cSrcweir if(MAP_PIXEL == aDraftBitmap.GetPrefMapMode().GetMapUnit()) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aDraftBitmap.GetSizePixel(), MAP_100TH_MM); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir else 216cdf0e10cSrcweir { 217cdf0e10cSrcweir aPrefSize = Application::GetDefaultDevice()->LogicToLogic(aPrefSize, aDraftBitmap.GetPrefMapMode(), MAP_100TH_MM); 218cdf0e10cSrcweir } 219cdf0e10cSrcweir 220cdf0e10cSrcweir const double fBitmapScaling(2.0); 221cdf0e10cSrcweir const double fWidth(aPrefSize.getWidth() * fBitmapScaling); 222cdf0e10cSrcweir const double fHeight(aPrefSize.getHeight() * fBitmapScaling); 223cdf0e10cSrcweir 224cdf0e10cSrcweir if(basegfx::fTools::more(fWidth, 1.0) 225cdf0e10cSrcweir && basegfx::fTools::more(fHeight, 1.0) 226cdf0e10cSrcweir && basegfx::fTools::lessOrEqual(fWidth, aScale.getX()) 227cdf0e10cSrcweir && basegfx::fTools::lessOrEqual(fHeight, aScale.getY())) 228cdf0e10cSrcweir { 229cdf0e10cSrcweir const basegfx::B2DHomMatrix aBitmapMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( 230cdf0e10cSrcweir fWidth, fHeight, fShearX, fRotate, aTranslate.getX(), aTranslate.getY())); 231cdf0e10cSrcweir 232cdf0e10cSrcweir drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, 233cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DReference( 234cdf0e10cSrcweir new drawinglayer::primitive2d::BitmapPrimitive2D( 235cdf0e10cSrcweir BitmapEx(aDraftBitmap), 236cdf0e10cSrcweir aBitmapMatrix))); 237cdf0e10cSrcweir 238cdf0e10cSrcweir // consume bitmap size in X 239cdf0e10cSrcweir aScale.setX(std::max(0.0, aScale.getX() - (fWidth + fDistance))); 240cdf0e10cSrcweir aTranslate.setX(aTranslate.getX() + fWidth + fDistance); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir } 243cdf0e10cSrcweir 244cdf0e10cSrcweir // Build the text for the draft object 245cdf0e10cSrcweir XubString aDraftText = GetGrafObject().GetFileName(); 246cdf0e10cSrcweir 247cdf0e10cSrcweir if(!aDraftText.Len()) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir aDraftText = GetGrafObject().GetName(); 250cdf0e10cSrcweir aDraftText.AppendAscii(" ..."); 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253cdf0e10cSrcweir if(aDraftText.Len() && GetGrafObject().GetModel()) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir // #i103255# Goal is to produce TextPrimitives which hold the given text as 256cdf0e10cSrcweir // BlockText in the available space. It would be very tricky to do 257cdf0e10cSrcweir // an own word wrap/line layout here. 258cdf0e10cSrcweir // Using SdrBlockTextPrimitive2D OTOH is critical since it internally 259cdf0e10cSrcweir // uses the SdrObject it references. To solve this, create a temp 260cdf0e10cSrcweir // SdrObject with Attributes and Text, generate a SdrBlockTextPrimitive2D 261cdf0e10cSrcweir // directly and immediately decompose it. After that, it is no longer 262cdf0e10cSrcweir // needed and can be deleted. 263cdf0e10cSrcweir 264cdf0e10cSrcweir // create temp RectObj as TextObj and set needed attributes 265cdf0e10cSrcweir SdrRectObj aRectObj(OBJ_TEXT); 266cdf0e10cSrcweir aRectObj.SetModel(GetGrafObject().GetModel()); 267cdf0e10cSrcweir aRectObj.NbcSetText(aDraftText); 268cdf0e10cSrcweir aRectObj.SetMergedItem(SvxColorItem(Color(COL_LIGHTRED), EE_CHAR_COLOR)); 269cdf0e10cSrcweir 270cdf0e10cSrcweir // get SdrText and OPO 271cdf0e10cSrcweir SdrText* pSdrText = aRectObj.getText(0); 272cdf0e10cSrcweir OutlinerParaObject* pOPO = aRectObj.GetOutlinerParaObject(); 273cdf0e10cSrcweir 274cdf0e10cSrcweir if(pSdrText && pOPO) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir // directly use the remaining space as TextRangeTransform 277cdf0e10cSrcweir const basegfx::B2DHomMatrix aTextRangeTransform(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( 278cdf0e10cSrcweir aScale, fShearX, fRotate, aTranslate)); 279cdf0e10cSrcweir 280cdf0e10cSrcweir // directly create temp SdrBlockTextPrimitive2D 281cdf0e10cSrcweir drawinglayer::primitive2d::SdrBlockTextPrimitive2D aBlockTextPrimitive( 282cdf0e10cSrcweir pSdrText, 283cdf0e10cSrcweir *pOPO, 284cdf0e10cSrcweir aTextRangeTransform, 285cdf0e10cSrcweir SDRTEXTHORZADJUST_LEFT, 286cdf0e10cSrcweir SDRTEXTVERTADJUST_TOP, 287cdf0e10cSrcweir false, 288cdf0e10cSrcweir false, 289cdf0e10cSrcweir false, 290cdf0e10cSrcweir false, 291cdf0e10cSrcweir false); 292cdf0e10cSrcweir 293cdf0e10cSrcweir // decompose immediately with neutral ViewInformation. This will 294cdf0e10cSrcweir // layout the text to more simple TextPrimitives from drawinglayer 295cdf0e10cSrcweir const drawinglayer::geometry::ViewInformation2D aViewInformation2D; 296cdf0e10cSrcweir 297cdf0e10cSrcweir drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence( 298cdf0e10cSrcweir xRetval, 299cdf0e10cSrcweir aBlockTextPrimitive.get2DDecomposition(aViewInformation2D)); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir } 302cdf0e10cSrcweir 303cdf0e10cSrcweir return xRetval; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createViewIndependentPrimitive2DSequence() const 307cdf0e10cSrcweir { 308cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence xRetval; 309cdf0e10cSrcweir const SfxItemSet& rItemSet = GetGrafObject().GetMergedItemSet(); 310cdf0e10cSrcweir 311cdf0e10cSrcweir // create and fill GraphicAttr 312cdf0e10cSrcweir GraphicAttr aLocalGrafInfo; 313cdf0e10cSrcweir const sal_uInt16 nTrans(((SdrGrafTransparenceItem&)rItemSet.Get(SDRATTR_GRAFTRANSPARENCE)).GetValue()); 314cdf0e10cSrcweir const SdrGrafCropItem& rCrop((const SdrGrafCropItem&)rItemSet.Get(SDRATTR_GRAFCROP)); 315cdf0e10cSrcweir aLocalGrafInfo.SetLuminance(((SdrGrafLuminanceItem&)rItemSet.Get(SDRATTR_GRAFLUMINANCE)).GetValue()); 316cdf0e10cSrcweir aLocalGrafInfo.SetContrast(((SdrGrafContrastItem&)rItemSet.Get(SDRATTR_GRAFCONTRAST)).GetValue()); 317cdf0e10cSrcweir aLocalGrafInfo.SetChannelR(((SdrGrafRedItem&)rItemSet.Get(SDRATTR_GRAFRED)).GetValue()); 318cdf0e10cSrcweir aLocalGrafInfo.SetChannelG(((SdrGrafGreenItem&)rItemSet.Get(SDRATTR_GRAFGREEN)).GetValue()); 319cdf0e10cSrcweir aLocalGrafInfo.SetChannelB(((SdrGrafBlueItem&)rItemSet.Get(SDRATTR_GRAFBLUE)).GetValue()); 320cdf0e10cSrcweir aLocalGrafInfo.SetGamma(((SdrGrafGamma100Item&)rItemSet.Get(SDRATTR_GRAFGAMMA)).GetValue() * 0.01); 321cdf0e10cSrcweir aLocalGrafInfo.SetTransparency((sal_uInt8)::basegfx::fround(Min(nTrans, (sal_uInt16)100) * 2.55)); 322cdf0e10cSrcweir aLocalGrafInfo.SetInvert(((SdrGrafInvertItem&)rItemSet.Get(SDRATTR_GRAFINVERT)).GetValue()); 323cdf0e10cSrcweir aLocalGrafInfo.SetDrawMode(((SdrGrafModeItem&)rItemSet.Get(SDRATTR_GRAFMODE)).GetValue()); 324cdf0e10cSrcweir aLocalGrafInfo.SetCrop(rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom()); 325cdf0e10cSrcweir 326*4bf7a51aSArmin Le Grand // we have content if graphic is not completely transparent 327*4bf7a51aSArmin Le Grand const bool bHasContent(255L != aLocalGrafInfo.GetTransparency()); 328*4bf7a51aSArmin Le Grand drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute( 329*4bf7a51aSArmin Le Grand drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute( 330*4bf7a51aSArmin Le Grand rItemSet, 331*4bf7a51aSArmin Le Grand GetGrafObject().getText(0), 332*4bf7a51aSArmin Le Grand bHasContent)); 333cdf0e10cSrcweir 334cdf0e10cSrcweir // take unrotated snap rect for position and size. Directly use model data, not getBoundRect() or getSnapRect() 335cdf0e10cSrcweir // which will use the primitive data we just create in the near future 336cdf0e10cSrcweir const Rectangle& rRectangle = GetGrafObject().GetGeoRect(); 337cdf0e10cSrcweir const ::basegfx::B2DRange aObjectRange( 338cdf0e10cSrcweir rRectangle.Left(), rRectangle.Top(), 339cdf0e10cSrcweir rRectangle.Right(), rRectangle.Bottom()); 340cdf0e10cSrcweir 341cdf0e10cSrcweir // look for mirroring 342cdf0e10cSrcweir const GeoStat& rGeoStat(GetGrafObject().GetGeoStat()); 343cdf0e10cSrcweir const sal_Int32 nDrehWink(rGeoStat.nDrehWink); 344cdf0e10cSrcweir const bool bRota180(18000 == nDrehWink); 345cdf0e10cSrcweir const bool bMirrored(GetGrafObject().IsMirrored()); 346cdf0e10cSrcweir const sal_uInt16 nMirrorCase(bRota180 ? (bMirrored ? 3 : 4) : (bMirrored ? 2 : 1)); 347cdf0e10cSrcweir bool bHMirr((2 == nMirrorCase ) || (4 == nMirrorCase)); 348cdf0e10cSrcweir bool bVMirr((3 == nMirrorCase ) || (4 == nMirrorCase)); 349cdf0e10cSrcweir 350cdf0e10cSrcweir // set mirror flags at LocalGrafInfo. Take into account that the geometry in 351cdf0e10cSrcweir // aObjectRange is already changed and rotated when bRota180 is used. To rebuild 352cdf0e10cSrcweir // that old behaviour (as long as part of the model data), correct the H/V flags 353cdf0e10cSrcweir // accordingly. The created bitmapPrimitive WILL use the rotation, too. 354cdf0e10cSrcweir if(bRota180) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir // if bRota180 which is used for vertical mirroring, the graphic will already be rotated 357cdf0e10cSrcweir // by 180 degrees. To correct, switch off VMirror and invert HMirroring. 358cdf0e10cSrcweir bHMirr = !bHMirr; 359cdf0e10cSrcweir bVMirr = false; 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir if(bHMirr || bVMirr) 363cdf0e10cSrcweir { 364cdf0e10cSrcweir aLocalGrafInfo.SetMirrorFlags((bHMirr ? BMP_MIRROR_HORZ : 0)|(bVMirr ? BMP_MIRROR_VERT : 0)); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir // fill object matrix 368cdf0e10cSrcweir const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0); 369cdf0e10cSrcweir const double fRotate(nDrehWink ? (36000 - nDrehWink) * F_PI18000 : 0.0); 370cdf0e10cSrcweir const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( 371cdf0e10cSrcweir aObjectRange.getWidth(), aObjectRange.getHeight(), 372cdf0e10cSrcweir fShearX, fRotate, 373cdf0e10cSrcweir aObjectRange.getMinX(), aObjectRange.getMinY())); 374cdf0e10cSrcweir 375cdf0e10cSrcweir // get the current, unchenged graphic obect from SdrGrafObj 376cdf0e10cSrcweir const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false); 377cdf0e10cSrcweir 378cdf0e10cSrcweir if(visualisationUsesPresObj()) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir // it's an EmptyPresObj, create the SdrGrafPrimitive2D without content and another scaled one 381cdf0e10cSrcweir // with the content which is the placeholder graphic 382cdf0e10cSrcweir xRetval = createVIP2DSForPresObj(aObjectMatrix, aAttribute, aLocalGrafInfo); 383cdf0e10cSrcweir } 384cdf0e10cSrcweir else if(visualisationUsesDraft()) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir // #i102380# The graphic is swapped out. To not force a swap-in here, there is a mechanism 387cdf0e10cSrcweir // which shows a swapped-out-visualisation (which gets created here now) and an asynchronious 388cdf0e10cSrcweir // visual update mechanism for swapped-out grapgics when they were loaded (see AsynchGraphicLoadingEvent 389cdf0e10cSrcweir // and ViewObjectContactOfGraphic implementation). Not forcing the swap-in here allows faster 390cdf0e10cSrcweir // (non-blocking) processing here and thus in the effect e.g. fast scrolling through pages 391cdf0e10cSrcweir xRetval = createVIP2DSForDraft(aObjectMatrix, aAttribute); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir else 394cdf0e10cSrcweir { 395cdf0e10cSrcweir // create primitive. Info: Calling the copy-constructor of GraphicObject in this 396cdf0e10cSrcweir // SdrGrafPrimitive2D constructor will force a full swap-in of the graphic 397ddde725dSArmin Le Grand const drawinglayer::primitive2d::Primitive2DReference xReference( 398ddde725dSArmin Le Grand new drawinglayer::primitive2d::SdrGrafPrimitive2D( 399ddde725dSArmin Le Grand aObjectMatrix, 400ddde725dSArmin Le Grand aAttribute, 401ddde725dSArmin Le Grand rGraphicObject, 402ddde725dSArmin Le Grand aLocalGrafInfo)); 403cdf0e10cSrcweir 404cdf0e10cSrcweir xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir // always append an invisible outline for the cases where no visible content exists 408cdf0e10cSrcweir drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, 409cdf0e10cSrcweir drawinglayer::primitive2d::createHiddenGeometryPrimitives2D( 410cdf0e10cSrcweir false, aObjectMatrix)); 411cdf0e10cSrcweir 412cdf0e10cSrcweir return xRetval; 413cdf0e10cSrcweir } 414cdf0e10cSrcweir 415cdf0e10cSrcweir bool ViewContactOfGraphic::visualisationUsesPresObj() const 416cdf0e10cSrcweir { 417cdf0e10cSrcweir return GetGrafObject().IsEmptyPresObj(); 418cdf0e10cSrcweir } 419cdf0e10cSrcweir 420cdf0e10cSrcweir bool ViewContactOfGraphic::visualisationUsesDraft() const 421cdf0e10cSrcweir { 422cdf0e10cSrcweir // no draft when already PresObj 423cdf0e10cSrcweir if(visualisationUsesPresObj()) 424cdf0e10cSrcweir return false; 425cdf0e10cSrcweir 426cdf0e10cSrcweir // draft when swapped out 427cdf0e10cSrcweir const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false); 428cdf0e10cSrcweir static bool bAllowReplacements(true); 429cdf0e10cSrcweir 430cdf0e10cSrcweir if(rGraphicObject.IsSwappedOut() && bAllowReplacements) 431cdf0e10cSrcweir return true; 432cdf0e10cSrcweir 433cdf0e10cSrcweir // draft when no graphic 434cdf0e10cSrcweir if(GRAPHIC_NONE == rGraphicObject.GetType() || GRAPHIC_DEFAULT == rGraphicObject.GetType()) 435cdf0e10cSrcweir return true; 436cdf0e10cSrcweir 437cdf0e10cSrcweir return false; 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 440cdf0e10cSrcweir } // end of namespace contact 441cdf0e10cSrcweir } // end of namespace sdr 442cdf0e10cSrcweir 443cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 444cdf0e10cSrcweir // eof 445