bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / ui / sidebar / CellBorderUpdater.cxx
blobe3182611e7aef945df6a59b232954500b10afd14
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <CellBorderUpdater.hxx>
20 #include <vcl/bmpacc.hxx>
21 #include <vcl/svapp.hxx>
23 namespace sc { namespace sidebar {
25 CellBorderUpdater::CellBorderUpdater(
26 sal_uInt16 nTbxBtnId,
27 ToolBox& rTbx)
28 : mnBtnId(nTbxBtnId),
29 mrTbx(rTbx)
33 CellBorderUpdater::~CellBorderUpdater()
37 void CellBorderUpdater::UpdateCellBorder(bool bTop, bool bBot, bool bLeft, bool bRight, Image aImg, bool bVer, bool bHor)
39 BitmapEx aBmpEx( aImg.GetBitmapEx() );
40 Bitmap aBmp( aBmpEx.GetBitmap() );
41 BitmapWriteAccess* pBmpAcc = aBmp.AcquireWriteAccess();
42 const Size maBmpSize = aBmp.GetSizePixel();
44 if( pBmpAcc )
46 Bitmap aMsk;
47 BitmapWriteAccess* pMskAcc;
49 if( aBmpEx.IsAlpha() )
50 pMskAcc = ( aMsk = aBmpEx.GetAlpha().GetBitmap() ).AcquireWriteAccess();
51 else if( aBmpEx.IsTransparent() )
52 pMskAcc = ( aMsk = aBmpEx.GetMask() ).AcquireWriteAccess();
53 else
54 pMskAcc = NULL;
56 pBmpAcc->SetLineColor( ::Application::GetSettings().GetStyleSettings().GetFieldTextColor() ) ;
57 pBmpAcc->SetFillColor( COL_BLACK);
59 if(maBmpSize.Width() == 43 && maBmpSize.Height() == 43)
61 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);
62 if( pMskAcc )
64 pMskAcc->SetLineColor( COL_BLACK );
65 pMskAcc->SetFillColor( COL_BLACK );
67 if(bLeft)
69 pBmpAcc->DrawLine( aTL,aBL );
70 if( pMskAcc )
71 pMskAcc->DrawLine( aTL,aBL );
73 if(bRight)
75 pBmpAcc->DrawLine( aTR,aBR );
76 if( pMskAcc )
77 pMskAcc->DrawLine( aTR,aBR );
79 if(bTop)
81 pBmpAcc->DrawLine( aTL,aTR );
82 if( pMskAcc )
83 pMskAcc->DrawLine( aTL,aTR );
85 if(bBot)
87 pBmpAcc->DrawLine( aBL,aBR );
88 if( pMskAcc )
89 pMskAcc->DrawLine( aBL,aBR );
91 if(bVer)
93 pBmpAcc->DrawLine( aVT,aVB );
94 if( pMskAcc )
95 pMskAcc->DrawLine( aVT,aVB );
97 if(bHor)
99 pBmpAcc->DrawLine( aHL,aHR );
100 if( pMskAcc )
101 pMskAcc->DrawLine( aHL,aHR );
105 aBmp.ReleaseAccess( pBmpAcc );
106 if( pMskAcc )
107 aMsk.ReleaseAccess( pMskAcc );
109 if( aBmpEx.IsAlpha() )
110 aBmpEx = BitmapEx( aBmp, AlphaMask( aMsk ) );
111 else if( aBmpEx.IsTransparent() )
112 aBmpEx = BitmapEx( aBmp, aMsk );
113 else
114 aBmpEx = aBmp;
116 mrTbx.SetItemImage( mnBtnId, Image( aBmpEx ) );
120 } } // end of namespace svx::sidebar
122 // eof