Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / sidebar / CellBorderUpdater.cxx
blobd281cdc95f52f1f160561c3ae41f063dd8c9f3d3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <CellBorderUpdater.hxx>
21 #include <vcl/bmpacc.hxx>
22 #include <vcl/svapp.hxx>
24 namespace sc { namespace sidebar {
26 CellBorderUpdater::CellBorderUpdater(
27 sal_uInt16 nTbxBtnId,
28 ToolBox& rTbx)
29 : mnBtnId(nTbxBtnId),
30 mrTbx(rTbx)
34 CellBorderUpdater::~CellBorderUpdater()
38 void CellBorderUpdater::UpdateCellBorder(bool bTop, bool bBot, bool bLeft, bool bRight, Image aImg, bool bVer, bool bHor)
40 BitmapEx aBmpEx( aImg.GetBitmapEx() );
41 Bitmap aBmp( aBmpEx.GetBitmap() );
42 BitmapWriteAccess* pBmpAcc = aBmp.AcquireWriteAccess();
43 const Size maBmpSize = aBmp.GetSizePixel();
45 if( pBmpAcc )
47 Bitmap aMsk;
48 BitmapWriteAccess* pMskAcc;
50 if( aBmpEx.IsAlpha() )
51 pMskAcc = ( aMsk = aBmpEx.GetAlpha().GetBitmap() ).AcquireWriteAccess();
52 else if( aBmpEx.IsTransparent() )
53 pMskAcc = ( aMsk = aBmpEx.GetMask() ).AcquireWriteAccess();
54 else
55 pMskAcc = NULL;
57 pBmpAcc->SetLineColor( ::Application::GetSettings().GetStyleSettings().GetFieldTextColor() ) ;
58 pBmpAcc->SetFillColor( COL_BLACK);
60 if(maBmpSize.Width() == 43 && maBmpSize.Height() == 43)
62 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);
63 if( pMskAcc )
65 pMskAcc->SetLineColor( COL_BLACK );
66 pMskAcc->SetFillColor( COL_BLACK );
68 if(bLeft)
70 pBmpAcc->DrawLine( aTL,aBL );
71 if( pMskAcc )
72 pMskAcc->DrawLine( aTL,aBL );
74 if(bRight)
76 pBmpAcc->DrawLine( aTR,aBR );
77 if( pMskAcc )
78 pMskAcc->DrawLine( aTR,aBR );
80 if(bTop)
82 pBmpAcc->DrawLine( aTL,aTR );
83 if( pMskAcc )
84 pMskAcc->DrawLine( aTL,aTR );
86 if(bBot)
88 pBmpAcc->DrawLine( aBL,aBR );
89 if( pMskAcc )
90 pMskAcc->DrawLine( aBL,aBR );
92 if(bVer)
94 pBmpAcc->DrawLine( aVT,aVB );
95 if( pMskAcc )
96 pMskAcc->DrawLine( aVT,aVB );
98 if(bHor)
100 pBmpAcc->DrawLine( aHL,aHR );
101 if( pMskAcc )
102 pMskAcc->DrawLine( aHL,aHR );
106 aBmp.ReleaseAccess( pBmpAcc );
107 if( pMskAcc )
108 aMsk.ReleaseAccess( pMskAcc );
110 if( aBmpEx.IsAlpha() )
111 aBmpEx = BitmapEx( aBmp, AlphaMask( aMsk ) );
112 else if( aBmpEx.IsTransparent() )
113 aBmpEx = BitmapEx( aBmp, aMsk );
114 else
115 aBmpEx = aBmp;
117 mrTbx.SetItemImage( mnBtnId, Image( aBmpEx ) );
121 } } // end of namespace svx::sidebar
123 // eof
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */