1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofsdrobj.hxx> 27cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx> 28cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontact.hxx> 29cdf0e10cSrcweir #include <svx/svdobj.hxx> 30cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx> 31cdf0e10cSrcweir #include <vcl/outdev.hxx> 32cdf0e10cSrcweir #include <svx/svdoole2.hxx> 33cdf0e10cSrcweir #include <svx/svdpage.hxx> 34cdf0e10cSrcweir #include <svx/sdr/contact/objectcontact.hxx> 35cdf0e10cSrcweir #include <basegfx/color/bcolor.hxx> 36cdf0e10cSrcweir #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx> 37cdf0e10cSrcweir #include <svx/sdr/contact/objectcontactofpageview.hxx> 38cdf0e10cSrcweir #include <svx/sdrpagewindow.hxx> 39cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx> 40cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrprimitivetools.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 43cdf0e10cSrcweir 44cdf0e10cSrcweir namespace sdr 45cdf0e10cSrcweir { 46cdf0e10cSrcweir namespace contact 47cdf0e10cSrcweir { 48cdf0e10cSrcweir // Create a Object-Specific ViewObjectContact, set ViewContact and 49cdf0e10cSrcweir // ObjectContact. Always needs to return something. 50cdf0e10cSrcweir ViewObjectContact& ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir ViewObjectContact* pRetval = new ViewObjectContactOfSdrObj(rObjectContact, *this); 53cdf0e10cSrcweir DBG_ASSERT(pRetval, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)"); 54cdf0e10cSrcweir 55cdf0e10cSrcweir return *pRetval; 56cdf0e10cSrcweir } 57cdf0e10cSrcweir 58cdf0e10cSrcweir ViewContactOfSdrObj::ViewContactOfSdrObj(SdrObject& rObj) 59cdf0e10cSrcweir : ViewContact(), 60cdf0e10cSrcweir mrObject(rObj), 61cdf0e10cSrcweir meRememberedAnimationKind(SDRTEXTANI_NONE) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir // init AnimationKind 64cdf0e10cSrcweir if(GetSdrObject().ISA(SdrTextObj)) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject(); 67cdf0e10cSrcweir meRememberedAnimationKind = rTextObj.GetTextAniKind(); 68cdf0e10cSrcweir } 69cdf0e10cSrcweir } 70cdf0e10cSrcweir 71cdf0e10cSrcweir ViewContactOfSdrObj::~ViewContactOfSdrObj() 72cdf0e10cSrcweir { 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir // Access to possible sub-hierarchy 76cdf0e10cSrcweir sal_uInt32 ViewContactOfSdrObj::GetObjectCount() const 77cdf0e10cSrcweir { 78cdf0e10cSrcweir if(GetSdrObject().GetSubList()) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir return GetSdrObject().GetSubList()->GetObjCount(); 81cdf0e10cSrcweir } 82cdf0e10cSrcweir 83cdf0e10cSrcweir return 0L; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir ViewContact& ViewContactOfSdrObj::GetViewContact(sal_uInt32 nIndex) const 87cdf0e10cSrcweir { 88cdf0e10cSrcweir DBG_ASSERT(GetSdrObject().GetSubList(), 89cdf0e10cSrcweir "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)"); 90cdf0e10cSrcweir SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex); 91cdf0e10cSrcweir DBG_ASSERT(pObj, "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)"); 92cdf0e10cSrcweir return pObj->GetViewContact(); 93cdf0e10cSrcweir } 94cdf0e10cSrcweir 95cdf0e10cSrcweir ViewContact* ViewContactOfSdrObj::GetParentContact() const 96cdf0e10cSrcweir { 97cdf0e10cSrcweir ViewContact* pRetval = 0L; 98cdf0e10cSrcweir SdrObjList* pObjList = GetSdrObject().GetObjList(); 99cdf0e10cSrcweir 100cdf0e10cSrcweir if(pObjList) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir if(pObjList->ISA(SdrPage)) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir // Is a page 105cdf0e10cSrcweir pRetval = &(((SdrPage*)pObjList)->GetViewContact()); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir else 108cdf0e10cSrcweir { 109cdf0e10cSrcweir // Is a group? 110cdf0e10cSrcweir if(pObjList->GetOwnerObj()) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir pRetval = &(pObjList->GetOwnerObj()->GetViewContact()); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir } 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir return pRetval; 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir // React on changes of the object of this ViewContact 121cdf0e10cSrcweir void ViewContactOfSdrObj::ActionChanged() 122cdf0e10cSrcweir { 123cdf0e10cSrcweir // look for own changes 124cdf0e10cSrcweir if(GetSdrObject().ISA(SdrTextObj)) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject(); 127cdf0e10cSrcweir 128cdf0e10cSrcweir if(rTextObj.GetTextAniKind() != meRememberedAnimationKind) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir // #i38135# now remember new type 131cdf0e10cSrcweir meRememberedAnimationKind = rTextObj.GetTextAniKind(); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir // call parent 136cdf0e10cSrcweir ViewContact::ActionChanged(); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir // overload for acessing the SdrObject 140cdf0e10cSrcweir SdrObject* ViewContactOfSdrObj::TryToGetSdrObject() const 141cdf0e10cSrcweir { 142cdf0e10cSrcweir return &GetSdrObject(); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 146cdf0e10cSrcweir // primitive stuff 147cdf0e10cSrcweir 148cdf0e10cSrcweir // add Gluepoints (if available) 149cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::createGluePointPrimitive2DSequence() const 150cdf0e10cSrcweir { 151cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence xRetval; 152cdf0e10cSrcweir const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList(); 153cdf0e10cSrcweir 154cdf0e10cSrcweir if(pGluePointList) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir const sal_uInt32 nCount(pGluePointList->GetCount()); 157cdf0e10cSrcweir 158cdf0e10cSrcweir if(nCount) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir // prepare point vector 161cdf0e10cSrcweir std::vector< basegfx::B2DPoint > aGluepointVector; 162cdf0e10cSrcweir 163cdf0e10cSrcweir // create GluePoint primitives. ATM these are relative to the SnapRect 164cdf0e10cSrcweir for(sal_uInt32 a(0L); a < nCount; a++) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir const SdrGluePoint& rCandidate = (*pGluePointList)[(sal_uInt16)a]; 167cdf0e10cSrcweir const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject())); 168cdf0e10cSrcweir 169cdf0e10cSrcweir aGluepointVector.push_back(basegfx::B2DPoint(aPosition.X(), aPosition.Y())); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir if(!aGluepointVector.empty()) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir const basegfx::BColor aBackPen(1.0, 1.0, 1.0); 175cdf0e10cSrcweir const basegfx::BColor aRGBFrontColor(0.0, 0.0, 1.0); // COL_LIGHTBLUE 176cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::MarkerArrayPrimitive2D( 177cdf0e10cSrcweir aGluepointVector, 178cdf0e10cSrcweir drawinglayer::primitive2d::createDefaultGluepoint_7x7(aBackPen, aRGBFrontColor))); 179cdf0e10cSrcweir xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 180cdf0e10cSrcweir } 181cdf0e10cSrcweir } 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir return xRetval; 185cdf0e10cSrcweir } 186cdf0e10cSrcweir } // end of namespace contact 187cdf0e10cSrcweir } // end of namespace sdr 188cdf0e10cSrcweir 189cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 190cdf0e10cSrcweir // eof 191