1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include "precompiled_svx.hxx" 29*cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrprimitivetools.hxx> 30*cdf0e10cSrcweir #include <vcl/bmpacc.hxx> 31*cdf0e10cSrcweir #include <osl/mutex.hxx> 32*cdf0e10cSrcweir #include <vcl/lazydelete.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 35*cdf0e10cSrcweir // helper methods 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir namespace drawinglayer 38*cdf0e10cSrcweir { 39*cdf0e10cSrcweir namespace primitive2d 40*cdf0e10cSrcweir { 41*cdf0e10cSrcweir BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor) 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir static vcl::DeleteOnDeinit< BitmapEx > aRetVal(0); 44*cdf0e10cSrcweir static basegfx::BColor aColor; 45*cdf0e10cSrcweir ::osl::Mutex m_mutex; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir if(!aRetVal.get() || rBColor != aColor) 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir // copy values 50*cdf0e10cSrcweir aColor = rBColor; 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir // create bitmap 53*cdf0e10cSrcweir Bitmap aContent(Size(3, 3), 24); 54*cdf0e10cSrcweir Bitmap aMask(Size(3, 3), 1); 55*cdf0e10cSrcweir BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess(); 56*cdf0e10cSrcweir BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess(); 57*cdf0e10cSrcweir OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)"); 58*cdf0e10cSrcweir const Color aVCLColor(aColor); 59*cdf0e10cSrcweir const BitmapColor aPixColor(aVCLColor); 60*cdf0e10cSrcweir const BitmapColor aMaskColor(0x01); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir // Y,X unusual order (!) 63*cdf0e10cSrcweir pWContent->SetPixel(0, 1, aPixColor); 64*cdf0e10cSrcweir pWContent->SetPixel(1, 0, aPixColor); 65*cdf0e10cSrcweir pWContent->SetPixel(1, 1, aPixColor); 66*cdf0e10cSrcweir pWContent->SetPixel(1, 2, aPixColor); 67*cdf0e10cSrcweir pWContent->SetPixel(2, 1, aPixColor); 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir pWMask->SetPixel(0, 0, aMaskColor); 70*cdf0e10cSrcweir pWMask->SetPixel(0, 2, aMaskColor); 71*cdf0e10cSrcweir pWMask->SetPixel(2, 0, aMaskColor); 72*cdf0e10cSrcweir pWMask->SetPixel(2, 2, aMaskColor); 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir aContent.ReleaseAccess(pWContent); 75*cdf0e10cSrcweir aMask.ReleaseAccess(pWMask); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir // create and exchange at aRetVal 78*cdf0e10cSrcweir delete aRetVal.set(new BitmapEx(aContent, aMask)); 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir return aRetVal.get() ? *aRetVal.get() : BitmapEx(); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir BitmapEx createDefaultGluepoint_7x7(const basegfx::BColor& rBColorA, const basegfx::BColor& rBColorB) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir static vcl::DeleteOnDeinit< BitmapEx > aRetVal(0); 87*cdf0e10cSrcweir static basegfx::BColor aColorA; 88*cdf0e10cSrcweir static basegfx::BColor aColorB; 89*cdf0e10cSrcweir ::osl::Mutex m_mutex; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir if(!aRetVal.get() || rBColorA != aColorA || rBColorB != aColorB) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir // copy values 94*cdf0e10cSrcweir aColorA = rBColorA; 95*cdf0e10cSrcweir aColorB = rBColorB; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir // create bitmap 98*cdf0e10cSrcweir Bitmap aContent(Size(7, 7), 24); 99*cdf0e10cSrcweir Bitmap aMask(Size(7, 7), 1); 100*cdf0e10cSrcweir BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess(); 101*cdf0e10cSrcweir BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess(); 102*cdf0e10cSrcweir OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)"); 103*cdf0e10cSrcweir const Color aColA(aColorA); 104*cdf0e10cSrcweir const Color aColB(aColorB); 105*cdf0e10cSrcweir const BitmapColor aPixColorA(aColA); 106*cdf0e10cSrcweir const BitmapColor aPixColorB(aColB); 107*cdf0e10cSrcweir const BitmapColor aMaskColor(0x01); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir // Y,X unusual order (!) 110*cdf0e10cSrcweir pWContent->SetPixel(0, 1, aPixColorA); 111*cdf0e10cSrcweir pWContent->SetPixel(0, 5, aPixColorA); 112*cdf0e10cSrcweir pWContent->SetPixel(1, 0, aPixColorA); 113*cdf0e10cSrcweir pWContent->SetPixel(1, 2, aPixColorA); 114*cdf0e10cSrcweir pWContent->SetPixel(1, 4, aPixColorA); 115*cdf0e10cSrcweir pWContent->SetPixel(1, 6, aPixColorA); 116*cdf0e10cSrcweir pWContent->SetPixel(2, 1, aPixColorA); 117*cdf0e10cSrcweir pWContent->SetPixel(2, 3, aPixColorA); 118*cdf0e10cSrcweir pWContent->SetPixel(2, 5, aPixColorA); 119*cdf0e10cSrcweir pWContent->SetPixel(3, 2, aPixColorA); 120*cdf0e10cSrcweir pWContent->SetPixel(3, 4, aPixColorA); 121*cdf0e10cSrcweir pWContent->SetPixel(4, 1, aPixColorA); 122*cdf0e10cSrcweir pWContent->SetPixel(4, 3, aPixColorA); 123*cdf0e10cSrcweir pWContent->SetPixel(4, 5, aPixColorA); 124*cdf0e10cSrcweir pWContent->SetPixel(5, 0, aPixColorA); 125*cdf0e10cSrcweir pWContent->SetPixel(5, 2, aPixColorA); 126*cdf0e10cSrcweir pWContent->SetPixel(5, 4, aPixColorA); 127*cdf0e10cSrcweir pWContent->SetPixel(5, 6, aPixColorA); 128*cdf0e10cSrcweir pWContent->SetPixel(6, 1, aPixColorA); 129*cdf0e10cSrcweir pWContent->SetPixel(6, 5, aPixColorA); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir pWContent->SetPixel(1, 1, aPixColorB); 132*cdf0e10cSrcweir pWContent->SetPixel(1, 5, aPixColorB); 133*cdf0e10cSrcweir pWContent->SetPixel(2, 2, aPixColorB); 134*cdf0e10cSrcweir pWContent->SetPixel(2, 4, aPixColorB); 135*cdf0e10cSrcweir pWContent->SetPixel(3, 3, aPixColorB); 136*cdf0e10cSrcweir pWContent->SetPixel(4, 2, aPixColorB); 137*cdf0e10cSrcweir pWContent->SetPixel(4, 4, aPixColorB); 138*cdf0e10cSrcweir pWContent->SetPixel(5, 1, aPixColorB); 139*cdf0e10cSrcweir pWContent->SetPixel(5, 5, aPixColorB); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir pWMask->SetPixel(0, 0, aMaskColor); 142*cdf0e10cSrcweir pWMask->SetPixel(0, 2, aMaskColor); 143*cdf0e10cSrcweir pWMask->SetPixel(0, 3, aMaskColor); 144*cdf0e10cSrcweir pWMask->SetPixel(0, 4, aMaskColor); 145*cdf0e10cSrcweir pWMask->SetPixel(0, 6, aMaskColor); 146*cdf0e10cSrcweir pWMask->SetPixel(1, 3, aMaskColor); 147*cdf0e10cSrcweir pWMask->SetPixel(2, 0, aMaskColor); 148*cdf0e10cSrcweir pWMask->SetPixel(2, 6, aMaskColor); 149*cdf0e10cSrcweir pWMask->SetPixel(3, 0, aMaskColor); 150*cdf0e10cSrcweir pWMask->SetPixel(3, 1, aMaskColor); 151*cdf0e10cSrcweir pWMask->SetPixel(3, 5, aMaskColor); 152*cdf0e10cSrcweir pWMask->SetPixel(3, 6, aMaskColor); 153*cdf0e10cSrcweir pWMask->SetPixel(4, 0, aMaskColor); 154*cdf0e10cSrcweir pWMask->SetPixel(4, 6, aMaskColor); 155*cdf0e10cSrcweir pWMask->SetPixel(5, 3, aMaskColor); 156*cdf0e10cSrcweir pWMask->SetPixel(6, 0, aMaskColor); 157*cdf0e10cSrcweir pWMask->SetPixel(6, 2, aMaskColor); 158*cdf0e10cSrcweir pWMask->SetPixel(6, 3, aMaskColor); 159*cdf0e10cSrcweir pWMask->SetPixel(6, 4, aMaskColor); 160*cdf0e10cSrcweir pWMask->SetPixel(6, 6, aMaskColor); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir aContent.ReleaseAccess(pWContent); 163*cdf0e10cSrcweir aMask.ReleaseAccess(pWMask); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir // create and exchange at aRetVal 166*cdf0e10cSrcweir delete aRetVal.set(new BitmapEx(aContent, aMask)); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir return aRetVal.get() ? *aRetVal.get() : BitmapEx(); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir } // end of namespace primitive2d 173*cdf0e10cSrcweir } // end of namespace drawinglayer 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 176*cdf0e10cSrcweir // eof 177