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