1*facb16e7SArmin Le Grand /************************************************************** 2*facb16e7SArmin Le Grand * 3*facb16e7SArmin Le Grand * Licensed to the Apache Software Foundation (ASF) under one 4*facb16e7SArmin Le Grand * or more contributor license agreements. See the NOTICE file 5*facb16e7SArmin Le Grand * distributed with this work for additional information 6*facb16e7SArmin Le Grand * regarding copyright ownership. The ASF licenses this file 7*facb16e7SArmin Le Grand * to you under the Apache License, Version 2.0 (the 8*facb16e7SArmin Le Grand * "License"); you may not use this file except in compliance 9*facb16e7SArmin Le Grand * with the License. You may obtain a copy of the License at 10*facb16e7SArmin Le Grand * 11*facb16e7SArmin Le Grand * http://www.apache.org/licenses/LICENSE-2.0 12*facb16e7SArmin Le Grand * 13*facb16e7SArmin Le Grand * Unless required by applicable law or agreed to in writing, 14*facb16e7SArmin Le Grand * software distributed under the License is distributed on an 15*facb16e7SArmin Le Grand * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*facb16e7SArmin Le Grand * KIND, either express or implied. See the License for the 17*facb16e7SArmin Le Grand * specific language governing permissions and limitations 18*facb16e7SArmin Le Grand * under the License. 19*facb16e7SArmin Le Grand * 20*facb16e7SArmin Le Grand *************************************************************/ 21*facb16e7SArmin Le Grand 22*facb16e7SArmin Le Grand #include "precompiled_sc.hxx" 23*facb16e7SArmin Le Grand 24*facb16e7SArmin Le Grand #include <CellBorderUpdater.hxx> 25*facb16e7SArmin Le Grand #include <vcl/bmpacc.hxx> 26*facb16e7SArmin Le Grand #include <vcl/svapp.hxx> 27*facb16e7SArmin Le Grand 28*facb16e7SArmin Le Grand namespace sc { namespace sidebar { 29*facb16e7SArmin Le Grand 30*facb16e7SArmin Le Grand CellBorderUpdater::CellBorderUpdater( 31*facb16e7SArmin Le Grand sal_uInt16 nTbxBtnId, 32*facb16e7SArmin Le Grand ToolBox& rTbx) 33*facb16e7SArmin Le Grand : mnBtnId(nTbxBtnId), 34*facb16e7SArmin Le Grand mrTbx(rTbx) 35*facb16e7SArmin Le Grand { 36*facb16e7SArmin Le Grand } 37*facb16e7SArmin Le Grand 38*facb16e7SArmin Le Grand CellBorderUpdater::~CellBorderUpdater() 39*facb16e7SArmin Le Grand { 40*facb16e7SArmin Le Grand } 41*facb16e7SArmin Le Grand 42*facb16e7SArmin Le Grand void CellBorderUpdater::UpdateCellBorder(bool bTop, bool bBot, bool bLeft, bool bRight, Image aImg, bool bVer, bool bHor) 43*facb16e7SArmin Le Grand { 44*facb16e7SArmin Le Grand BitmapEx aBmpEx( aImg.GetBitmapEx() ); 45*facb16e7SArmin Le Grand Bitmap aBmp( aBmpEx.GetBitmap() ); 46*facb16e7SArmin Le Grand BitmapWriteAccess* pBmpAcc = aBmp.AcquireWriteAccess(); 47*facb16e7SArmin Le Grand const Size maBmpSize = aBmp.GetSizePixel(); 48*facb16e7SArmin Le Grand 49*facb16e7SArmin Le Grand if( pBmpAcc ) 50*facb16e7SArmin Le Grand { 51*facb16e7SArmin Le Grand Bitmap aMsk; 52*facb16e7SArmin Le Grand BitmapWriteAccess* pMskAcc; 53*facb16e7SArmin Le Grand 54*facb16e7SArmin Le Grand if( aBmpEx.IsAlpha() ) 55*facb16e7SArmin Le Grand pMskAcc = ( aMsk = aBmpEx.GetAlpha().GetBitmap() ).AcquireWriteAccess(); 56*facb16e7SArmin Le Grand else if( aBmpEx.IsTransparent() ) 57*facb16e7SArmin Le Grand pMskAcc = ( aMsk = aBmpEx.GetMask() ).AcquireWriteAccess(); 58*facb16e7SArmin Le Grand else 59*facb16e7SArmin Le Grand pMskAcc = NULL; 60*facb16e7SArmin Le Grand 61*facb16e7SArmin Le Grand pBmpAcc->SetLineColor( ::Application::GetSettings().GetStyleSettings().GetFieldTextColor() ) ; 62*facb16e7SArmin Le Grand pBmpAcc->SetFillColor( COL_BLACK); 63*facb16e7SArmin Le Grand 64*facb16e7SArmin Le Grand if(maBmpSize.Width() == 43 && maBmpSize.Height() == 43) 65*facb16e7SArmin Le Grand { 66*facb16e7SArmin Le Grand Point aTL(2, 1), aTR(42,1), aBL(2, 41), aBR(42, 41), aHL(2,21), aHR(42, 21), aVT(22,1), aVB(22, 41); 67*facb16e7SArmin Le Grand if( pMskAcc ) 68*facb16e7SArmin Le Grand { 69*facb16e7SArmin Le Grand pMskAcc->SetLineColor( COL_BLACK ); 70*facb16e7SArmin Le Grand pMskAcc->SetFillColor( COL_BLACK ); 71*facb16e7SArmin Le Grand } 72*facb16e7SArmin Le Grand if(bLeft) 73*facb16e7SArmin Le Grand { 74*facb16e7SArmin Le Grand pBmpAcc->DrawLine( aTL,aBL ); 75*facb16e7SArmin Le Grand if( pMskAcc ) 76*facb16e7SArmin Le Grand pMskAcc->DrawLine( aTL,aBL ); 77*facb16e7SArmin Le Grand } 78*facb16e7SArmin Le Grand if(bRight) 79*facb16e7SArmin Le Grand { 80*facb16e7SArmin Le Grand pBmpAcc->DrawLine( aTR,aBR ); 81*facb16e7SArmin Le Grand if( pMskAcc ) 82*facb16e7SArmin Le Grand pMskAcc->DrawLine( aTR,aBR ); 83*facb16e7SArmin Le Grand } 84*facb16e7SArmin Le Grand if(bTop) 85*facb16e7SArmin Le Grand { 86*facb16e7SArmin Le Grand pBmpAcc->DrawLine( aTL,aTR ); 87*facb16e7SArmin Le Grand if( pMskAcc ) 88*facb16e7SArmin Le Grand pMskAcc->DrawLine( aTL,aTR ); 89*facb16e7SArmin Le Grand } 90*facb16e7SArmin Le Grand if(bBot) 91*facb16e7SArmin Le Grand { 92*facb16e7SArmin Le Grand pBmpAcc->DrawLine( aBL,aBR ); 93*facb16e7SArmin Le Grand if( pMskAcc ) 94*facb16e7SArmin Le Grand pMskAcc->DrawLine( aBL,aBR ); 95*facb16e7SArmin Le Grand } 96*facb16e7SArmin Le Grand if(bVer) 97*facb16e7SArmin Le Grand { 98*facb16e7SArmin Le Grand pBmpAcc->DrawLine( aVT,aVB ); 99*facb16e7SArmin Le Grand if( pMskAcc ) 100*facb16e7SArmin Le Grand pMskAcc->DrawLine( aVT,aVB ); 101*facb16e7SArmin Le Grand } 102*facb16e7SArmin Le Grand if(bHor) 103*facb16e7SArmin Le Grand { 104*facb16e7SArmin Le Grand pBmpAcc->DrawLine( aHL,aHR ); 105*facb16e7SArmin Le Grand if( pMskAcc ) 106*facb16e7SArmin Le Grand pMskAcc->DrawLine( aHL,aHR ); 107*facb16e7SArmin Le Grand } 108*facb16e7SArmin Le Grand } 109*facb16e7SArmin Le Grand 110*facb16e7SArmin Le Grand aBmp.ReleaseAccess( pBmpAcc ); 111*facb16e7SArmin Le Grand if( pMskAcc ) 112*facb16e7SArmin Le Grand aMsk.ReleaseAccess( pMskAcc ); 113*facb16e7SArmin Le Grand 114*facb16e7SArmin Le Grand if( aBmpEx.IsAlpha() ) 115*facb16e7SArmin Le Grand aBmpEx = BitmapEx( aBmp, AlphaMask( aMsk ) ); 116*facb16e7SArmin Le Grand else if( aBmpEx.IsTransparent() ) 117*facb16e7SArmin Le Grand aBmpEx = BitmapEx( aBmp, aMsk ); 118*facb16e7SArmin Le Grand else 119*facb16e7SArmin Le Grand aBmpEx = aBmp; 120*facb16e7SArmin Le Grand 121*facb16e7SArmin Le Grand mrTbx.SetItemImage( mnBtnId, Image( aBmpEx ) ); 122*facb16e7SArmin Le Grand } 123*facb16e7SArmin Le Grand } 124*facb16e7SArmin Le Grand 125*facb16e7SArmin Le Grand } } // end of namespace svx::sidebar 126*facb16e7SArmin Le Grand 127*facb16e7SArmin Le Grand // eof 128