Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <CellBorderUpdater.hxx>
21 : #include <vcl/bmpacc.hxx>
22 : #include <vcl/svapp.hxx>
23 : #include <vcl/settings.hxx>
24 :
25 : namespace sc { namespace sidebar {
26 :
27 0 : CellBorderUpdater::CellBorderUpdater(
28 : sal_uInt16 nTbxBtnId,
29 : ToolBox& rTbx)
30 : : mnBtnId(nTbxBtnId),
31 0 : mrTbx(rTbx)
32 : {
33 0 : }
34 :
35 0 : CellBorderUpdater::~CellBorderUpdater()
36 : {
37 0 : }
38 :
39 0 : void CellBorderUpdater::UpdateCellBorder(bool bTop, bool bBot, bool bLeft, bool bRight, Image aImg, bool bVer, bool bHor)
40 : {
41 0 : BitmapEx aBmpEx( aImg.GetBitmapEx() );
42 0 : Bitmap aBmp( aBmpEx.GetBitmap() );
43 0 : BitmapWriteAccess* pBmpAcc = aBmp.AcquireWriteAccess();
44 0 : const Size maBmpSize = aBmp.GetSizePixel();
45 :
46 0 : if( pBmpAcc )
47 : {
48 0 : Bitmap aMsk;
49 : BitmapWriteAccess* pMskAcc;
50 :
51 0 : if( aBmpEx.IsAlpha() )
52 0 : pMskAcc = ( aMsk = aBmpEx.GetAlpha().GetBitmap() ).AcquireWriteAccess();
53 0 : else if( aBmpEx.IsTransparent() )
54 0 : pMskAcc = ( aMsk = aBmpEx.GetMask() ).AcquireWriteAccess();
55 : else
56 0 : pMskAcc = NULL;
57 :
58 0 : pBmpAcc->SetLineColor( ::Application::GetSettings().GetStyleSettings().GetFieldTextColor() ) ;
59 0 : pBmpAcc->SetFillColor( COL_BLACK);
60 :
61 0 : if(maBmpSize.Width() == 43 && maBmpSize.Height() == 43)
62 : {
63 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);
64 0 : if( pMskAcc )
65 : {
66 0 : pMskAcc->SetLineColor( COL_BLACK );
67 0 : pMskAcc->SetFillColor( COL_BLACK );
68 : }
69 0 : if(bLeft)
70 : {
71 0 : pBmpAcc->DrawLine( aTL,aBL );
72 0 : if( pMskAcc )
73 0 : pMskAcc->DrawLine( aTL,aBL );
74 : }
75 0 : if(bRight)
76 : {
77 0 : pBmpAcc->DrawLine( aTR,aBR );
78 0 : if( pMskAcc )
79 0 : pMskAcc->DrawLine( aTR,aBR );
80 : }
81 0 : if(bTop)
82 : {
83 0 : pBmpAcc->DrawLine( aTL,aTR );
84 0 : if( pMskAcc )
85 0 : pMskAcc->DrawLine( aTL,aTR );
86 : }
87 0 : if(bBot)
88 : {
89 0 : pBmpAcc->DrawLine( aBL,aBR );
90 0 : if( pMskAcc )
91 0 : pMskAcc->DrawLine( aBL,aBR );
92 : }
93 0 : if(bVer)
94 : {
95 0 : pBmpAcc->DrawLine( aVT,aVB );
96 0 : if( pMskAcc )
97 0 : pMskAcc->DrawLine( aVT,aVB );
98 : }
99 0 : if(bHor)
100 : {
101 0 : pBmpAcc->DrawLine( aHL,aHR );
102 0 : if( pMskAcc )
103 0 : pMskAcc->DrawLine( aHL,aHR );
104 : }
105 : }
106 :
107 0 : aBmp.ReleaseAccess( pBmpAcc );
108 0 : if( pMskAcc )
109 0 : aMsk.ReleaseAccess( pMskAcc );
110 :
111 0 : if( aBmpEx.IsAlpha() )
112 0 : aBmpEx = BitmapEx( aBmp, AlphaMask( aMsk ) );
113 0 : else if( aBmpEx.IsTransparent() )
114 0 : aBmpEx = BitmapEx( aBmp, aMsk );
115 : else
116 0 : aBmpEx = aBmp;
117 :
118 0 : mrTbx.SetItemImage( mnBtnId, Image( aBmpEx ) );
119 0 : }
120 0 : }
121 :
122 : } } // end of namespace svx::sidebar
123 :
124 : // eof
125 :
126 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|