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