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 #include "precompiled_sc.hxx"
23
24 #include <CellBorderUpdater.hxx>
25 #include <vcl/bmpacc.hxx>
26 #include <vcl/svapp.hxx>
27
28 namespace sc { namespace sidebar {
29
CellBorderUpdater(sal_uInt16 nTbxBtnId,ToolBox & rTbx)30 CellBorderUpdater::CellBorderUpdater(
31 sal_uInt16 nTbxBtnId,
32 ToolBox& rTbx)
33 : mnBtnId(nTbxBtnId),
34 mrTbx(rTbx)
35 {
36 }
37
~CellBorderUpdater()38 CellBorderUpdater::~CellBorderUpdater()
39 {
40 }
41
UpdateCellBorder(bool bTop,bool bBot,bool bLeft,bool bRight,Image aImg,bool bVer,bool bHor)42 void CellBorderUpdater::UpdateCellBorder(bool bTop, bool bBot, bool bLeft, bool bRight, Image aImg, bool bVer, bool bHor)
43 {
44 BitmapEx aBmpEx( aImg.GetBitmapEx() );
45 Bitmap aBmp( aBmpEx.GetBitmap() );
46 BitmapWriteAccess* pBmpAcc = aBmp.AcquireWriteAccess();
47 const Size maBmpSize = aBmp.GetSizePixel();
48
49 if( pBmpAcc )
50 {
51 Bitmap aMsk;
52 BitmapWriteAccess* pMskAcc;
53
54 if( aBmpEx.IsAlpha() )
55 pMskAcc = ( aMsk = aBmpEx.GetAlpha().GetBitmap() ).AcquireWriteAccess();
56 else if( aBmpEx.IsTransparent() )
57 pMskAcc = ( aMsk = aBmpEx.GetMask() ).AcquireWriteAccess();
58 else
59 pMskAcc = NULL;
60
61 pBmpAcc->SetLineColor( ::Application::GetSettings().GetStyleSettings().GetFieldTextColor() ) ;
62 pBmpAcc->SetFillColor( COL_BLACK);
63
64 if(maBmpSize.Width() == 43 && maBmpSize.Height() == 43)
65 {
66 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 if( pMskAcc )
68 {
69 pMskAcc->SetLineColor( COL_BLACK );
70 pMskAcc->SetFillColor( COL_BLACK );
71 }
72 if(bLeft)
73 {
74 pBmpAcc->DrawLine( aTL,aBL );
75 if( pMskAcc )
76 pMskAcc->DrawLine( aTL,aBL );
77 }
78 if(bRight)
79 {
80 pBmpAcc->DrawLine( aTR,aBR );
81 if( pMskAcc )
82 pMskAcc->DrawLine( aTR,aBR );
83 }
84 if(bTop)
85 {
86 pBmpAcc->DrawLine( aTL,aTR );
87 if( pMskAcc )
88 pMskAcc->DrawLine( aTL,aTR );
89 }
90 if(bBot)
91 {
92 pBmpAcc->DrawLine( aBL,aBR );
93 if( pMskAcc )
94 pMskAcc->DrawLine( aBL,aBR );
95 }
96 if(bVer)
97 {
98 pBmpAcc->DrawLine( aVT,aVB );
99 if( pMskAcc )
100 pMskAcc->DrawLine( aVT,aVB );
101 }
102 if(bHor)
103 {
104 pBmpAcc->DrawLine( aHL,aHR );
105 if( pMskAcc )
106 pMskAcc->DrawLine( aHL,aHR );
107 }
108 }
109
110 aBmp.ReleaseAccess( pBmpAcc );
111 if( pMskAcc )
112 aMsk.ReleaseAccess( pMskAcc );
113
114 if( aBmpEx.IsAlpha() )
115 aBmpEx = BitmapEx( aBmp, AlphaMask( aMsk ) );
116 else if( aBmpEx.IsTransparent() )
117 aBmpEx = BitmapEx( aBmp, aMsk );
118 else
119 aBmpEx = aBmp;
120
121 mrTbx.SetItemImage( mnBtnId, Image( aBmpEx ) );
122 }
123 }
124
125 } } // end of namespace svx::sidebar
126
127 // eof
128