Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
2c40b082
Kaydet (Commit)
2c40b082
authored
Mar 02, 2015
tarafından
Tomaž Vajngerl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
code cleanup in tbxcolorupdate.cxx
Change-Id: I671e59bab5bc649cc12026647531f8612eec394b
üst
0451615f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
76 deletions
+73
-76
tbxcolorupdate.cxx
svx/source/tbxctrls/tbxcolorupdate.cxx
+73
-76
No files found.
svx/source/tbxctrls/tbxcolorupdate.cxx
Dosyayı görüntüle @
2c40b082
...
@@ -27,12 +27,8 @@
...
@@ -27,12 +27,8 @@
#include <vcl/settings.hxx>
#include <vcl/settings.hxx>
#include <tools/debug.hxx>
#include <tools/debug.hxx>
namespace
svx
namespace
svx
{
{
//= ToolboxButtonColorUpdater
//= ToolboxButtonColorUpdater
/* Note:
/* Note:
...
@@ -45,74 +41,70 @@ namespace svx
...
@@ -45,74 +41,70 @@ namespace svx
*/
*/
ToolboxButtonColorUpdater
::
ToolboxButtonColorUpdater
(
ToolboxButtonColorUpdater
::
ToolboxButtonColorUpdater
(
sal_uInt16
nId
,
sal_uInt16
nId
,
sal_uInt16
nTbxBtnId
,
ToolBox
*
pToolBox
)
sal_uInt16
nTbxBtnId
,
:
mnBtnId
(
nTbxBtnId
)
ToolBox
*
ptrTbx
)
:
,
mnSlotId
(
nId
)
mnBtnId
(
nTbxBtnId
),
,
mpTbx
(
pToolBox
)
mnSlotId
(
nId
),
,
maCurColor
(
COL_TRANSPARENT
)
mpTbx
(
ptrTbx
),
maCurColor
(
COL_TRANSPARENT
)
{
{
DBG_ASSERT
(
ptrTbx
,
"ToolBox not found :-("
);
DBG_ASSERT
(
pToolBox
,
"ToolBox not found :-("
);
mbWasHiContrastMode
=
p
trTbx
?
(
ptrTbx
->
GetSettings
().
GetStyleSettings
().
GetHighContrastMode
()
)
:
sal_F
alse
;
mbWasHiContrastMode
=
p
ToolBox
?
pToolBox
->
GetSettings
().
GetStyleSettings
().
GetHighContrastMode
()
:
f
alse
;
switch
(
mnSlotId
)
switch
(
mnSlotId
)
{
{
case
SID_ATTR_CHAR_COLOR
:
case
SID_ATTR_CHAR_COLOR
:
case
SID_ATTR_CHAR_COLOR2
:
case
SID_ATTR_CHAR_COLOR2
:
Update
(
COL_RED
);
Update
(
COL_RED
);
break
;
break
;
case
SID_FRAME_LINECOLOR
:
case
SID_FRAME_LINECOLOR
:
Update
(
COL_BLUE
);
Update
(
COL_BLUE
);
break
;
break
;
case
SID_ATTR_CHAR_COLOR_BACKGROUND
:
case
SID_ATTR_CHAR_COLOR_BACKGROUND
:
case
SID_BACKGROUND_COLOR
:
case
SID_BACKGROUND_COLOR
:
Update
(
COL_YELLOW
);
Update
(
COL_YELLOW
);
break
;
break
;
case
SID_ATTR_LINE_COLOR
:
case
SID_ATTR_LINE_COLOR
:
Update
(
COL_BLACK
);
Update
(
COL_BLACK
);
break
;
break
;
case
SID_ATTR_FILL_COLOR
:
case
SID_ATTR_FILL_COLOR
:
Update
(
COL_DEFAULT_SHAPE_FILLING
);
Update
(
COL_DEFAULT_SHAPE_FILLING
);
break
;
break
;
default
:
default
:
Update
(
COL_TRANSPARENT
);
Update
(
COL_TRANSPARENT
);
}
}
}
}
ToolboxButtonColorUpdater
::~
ToolboxButtonColorUpdater
()
ToolboxButtonColorUpdater
::~
ToolboxButtonColorUpdater
()
{
{}
}
void
ToolboxButtonColorUpdater
::
Update
(
const
Color
&
rColor
)
void
ToolboxButtonColorUpdater
::
Update
(
const
Color
&
rColor
)
{
{
Image
aImage
(
mpTbx
->
GetItemImage
(
mnBtnId
)
);
Image
aImage
(
mpTbx
->
GetItemImage
(
mnBtnId
)
);
Size
aItemSize
(
mpTbx
->
GetItemContentSize
(
mnBtnId
)
);
Size
aItemSize
(
mpTbx
->
GetItemContentSize
(
mnBtnId
)
);
const
bool
bSizeChanged
=
(
maBmpSize
!=
aItemSize
);
const
bool
bSizeChanged
=
(
maBmpSize
!=
aItemSize
);
const
bool
bDisplayModeChanged
=
(
mbWasHiContrastMode
!=
mpTbx
->
GetSettings
().
GetStyleSettings
().
GetHighContrastMode
()
);
const
bool
bDisplayModeChanged
=
(
mbWasHiContrastMode
!=
mpTbx
->
GetSettings
().
GetStyleSettings
().
GetHighContrastMode
()
);
Color
aColor
(
rColor
);
Color
aColor
(
rColor
);
// !!! #109290# Workaround for SetFillColor with COL_AUTO
// !!! #109290# Workaround for SetFillColor with COL_AUTO
if
(
aColor
.
GetColor
()
==
COL_AUTO
)
if
(
aColor
.
GetColor
()
==
COL_AUTO
)
aColor
=
Color
(
COL_TRANSPARENT
);
aColor
=
Color
(
COL_TRANSPARENT
);
// For a shape selected in 'Draw', when color selected in Sidebar > Line > Color
// For a shape selected in 'Draw', when color selected in Sidebar > Line > Color
// is COL_BLACK, then (maCurColor != aColor) becomes 'false', therefore we take
// is COL_BLACK, then (maCurColor != aColor) becomes 'false', therefore we take
// explicit care of COL_BLACK from the last argument in the condition so that the
// explicit care of COL_BLACK from the last argument in the condition so that the
// Update() does its routine job appropriately !
// Update() does its routine job appropriately !
if
(
(
maCurColor
!=
aColor
)
||
bSizeChanged
||
bDisplayModeChanged
||
(
aColor
==
COL_BLACK
)
)
if
((
maCurColor
!=
aColor
)
||
bSizeChanged
||
bDisplayModeChanged
||
(
aColor
==
COL_BLACK
)
)
{
{
// create an empty bitmap, and copy the original bitmap inside
// create an empty bitmap, and copy the original bitmap inside
// (so that it grows in case the original bitmap was smaller)
// (so that it grows in case the original bitmap was smaller)
sal_uInt8
nAlpha
=
255
;
sal_uInt8
nAlpha
=
255
;
BitmapEx
aBmpEx
(
Bitmap
(
aItemSize
,
24
),
AlphaMask
(
aItemSize
,
&
nAlpha
)
);
BitmapEx
aBmpEx
(
Bitmap
(
aItemSize
,
24
),
AlphaMask
(
aItemSize
,
&
nAlpha
));
BitmapEx
aSource
(
aImage
.
GetBitmapEx
()
);
BitmapEx
aSource
(
aImage
.
GetBitmapEx
());
Rectangle
aRect
(
Point
(
0
,
0
),
long
nWidth
=
std
::
min
(
aItemSize
.
Width
(),
aSource
.
GetSizePixel
().
Width
());
Size
(
std
::
min
(
aItemSize
.
Width
(),
aSource
.
GetSizePixel
().
Width
()
),
std
::
min
(
aItemSize
.
Height
(),
aSource
.
GetSizePixel
().
Height
()
)
)
);
long
nHeight
=
std
::
min
(
aItemSize
.
Height
(),
aSource
.
GetSizePixel
().
Height
());
Rectangle
aRect
(
Point
(
0
,
0
),
Size
(
nWidth
,
nHeight
));
aBmpEx
.
CopyPixel
(
aRect
,
aRect
,
&
aSource
);
aBmpEx
.
CopyPixel
(
aRect
,
aRect
,
&
aSource
);
Bitmap
aBmp
(
aBmpEx
.
GetBitmap
()
);
Bitmap
aBmp
(
aBmpEx
.
GetBitmap
()
);
...
@@ -120,33 +112,41 @@ namespace svx
...
@@ -120,33 +112,41 @@ namespace svx
maBmpSize
=
aBmp
.
GetSizePixel
();
maBmpSize
=
aBmp
.
GetSizePixel
();
if
(
pBmpAcc
)
if
(
pBmpAcc
)
{
{
Bitmap
aMsk
;
Bitmap
aMsk
;
BitmapWriteAccess
*
pMskAcc
;
BitmapWriteAccess
*
pMskAcc
;
if
(
aBmpEx
.
IsAlpha
()
)
if
(
aBmpEx
.
IsAlpha
())
pMskAcc
=
(
aMsk
=
aBmpEx
.
GetAlpha
().
GetBitmap
()
).
AcquireWriteAccess
();
{
else
if
(
aBmpEx
.
IsTransparent
()
)
aMsk
=
aBmpEx
.
GetAlpha
().
GetBitmap
();
pMskAcc
=
(
aMsk
=
aBmpEx
.
GetMask
()
).
AcquireWriteAccess
();
pMskAcc
=
aMsk
.
AcquireWriteAccess
();
}
else
if
(
aBmpEx
.
IsTransparent
())
{
aMsk
=
aBmpEx
.
GetMask
();
pMskAcc
=
aMsk
.
AcquireWriteAccess
();
}
else
else
{
pMskAcc
=
NULL
;
pMskAcc
=
NULL
;
}
mbWasHiContrastMode
=
mpTbx
->
GetSettings
().
GetStyleSettings
().
GetHighContrastMode
();
mbWasHiContrastMode
=
mpTbx
->
GetSettings
().
GetStyleSettings
().
GetHighContrastMode
();
if
(
(
COL_TRANSPARENT
!=
aColor
.
GetColor
()
)
&&
(
maBmpSize
.
Width
()
==
maBmpSize
.
Height
()
)
)
if
((
COL_TRANSPARENT
!=
aColor
.
GetColor
())
&&
(
maBmpSize
.
Width
()
==
maBmpSize
.
Height
())
)
pBmpAcc
->
SetLineColor
(
aColor
);
pBmpAcc
->
SetLineColor
(
aColor
);
else
if
(
mpTbx
->
GetBackground
().
GetColor
().
IsDark
()
)
else
if
(
mpTbx
->
GetBackground
().
GetColor
().
IsDark
()
)
pBmpAcc
->
SetLineColor
(
Color
(
COL_WHITE
)
);
pBmpAcc
->
SetLineColor
(
Color
(
COL_WHITE
)
);
else
else
pBmpAcc
->
SetLineColor
(
Color
(
COL_BLACK
)
);
pBmpAcc
->
SetLineColor
(
Color
(
COL_BLACK
)
);
// use not only COL_TRANSPARENT for detection of transparence,
// use not only COL_TRANSPARENT for detection of transparence,
// but the method/way which is designed to do that
// but the method/way which is designed to do that
const
bool
bIsTransparent
(
0xff
==
aColor
.
GetTransparency
());
const
bool
bIsTransparent
(
0xff
==
aColor
.
GetTransparency
());
maCurColor
=
aColor
;
maCurColor
=
aColor
;
if
(
bIsTransparent
)
if
(
bIsTransparent
)
{
{
pBmpAcc
->
SetFillColor
();
pBmpAcc
->
SetFillColor
();
}
}
...
@@ -155,45 +155,42 @@ namespace svx
...
@@ -155,45 +155,42 @@ namespace svx
pBmpAcc
->
SetFillColor
(
maCurColor
);
pBmpAcc
->
SetFillColor
(
maCurColor
);
}
}
if
(
maBmpSize
.
Width
()
==
maBmpSize
.
Height
()
)
if
(
maBmpSize
.
Width
()
==
maBmpSize
.
Height
()
)
maUpdRect
=
Rectangle
(
Point
(
0
,
maBmpSize
.
Height
()
*
3
/
4
),
Size
(
maBmpSize
.
Width
(),
maBmpSize
.
Height
()
/
4
)
);
maUpdRect
=
Rectangle
(
Point
(
0
,
maBmpSize
.
Height
()
*
3
/
4
),
Size
(
maBmpSize
.
Width
(),
maBmpSize
.
Height
()
/
4
)
);
else
else
maUpdRect
=
Rectangle
(
Point
(
maBmpSize
.
Height
()
+
2
,
2
),
Point
(
maBmpSize
.
Width
()
-
3
,
maBmpSize
.
Height
()
-
3
)
);
maUpdRect
=
Rectangle
(
Point
(
maBmpSize
.
Height
()
+
2
,
2
),
Point
(
maBmpSize
.
Width
()
-
3
,
maBmpSize
.
Height
()
-
3
)
);
pBmpAcc
->
DrawRect
(
maUpdRect
);
pBmpAcc
->
DrawRect
(
maUpdRect
);
if
(
pMskAcc
)
if
(
pMskAcc
)
{
{
if
(
bIsTransparent
)
if
(
bIsTransparent
)
{
{
pMskAcc
->
SetLineColor
(
COL_BLACK
);
pMskAcc
->
SetLineColor
(
COL_BLACK
);
pMskAcc
->
SetFillColor
(
COL_WHITE
);
pMskAcc
->
SetFillColor
(
COL_WHITE
);
}
}
else
else
pMskAcc
->
SetFillColor
(
COL_BLACK
);
pMskAcc
->
SetFillColor
(
COL_BLACK
);
pMskAcc
->
DrawRect
(
maUpdRect
);
pMskAcc
->
DrawRect
(
maUpdRect
);
}
}
aBmp
.
ReleaseAccess
(
pBmpAcc
);
aBmp
.
ReleaseAccess
(
pBmpAcc
);
if
(
pMskAcc
)
if
(
pMskAcc
)
aMsk
.
ReleaseAccess
(
pMskAcc
);
aMsk
.
ReleaseAccess
(
pMskAcc
);
if
(
aBmpEx
.
IsAlpha
()
)
if
(
aBmpEx
.
IsAlpha
()
)
aBmpEx
=
BitmapEx
(
aBmp
,
AlphaMask
(
aMsk
)
);
aBmpEx
=
BitmapEx
(
aBmp
,
AlphaMask
(
aMsk
)
);
else
if
(
aBmpEx
.
IsTransparent
()
)
else
if
(
aBmpEx
.
IsTransparent
()
)
aBmpEx
=
BitmapEx
(
aBmp
,
aMsk
);
aBmpEx
=
BitmapEx
(
aBmp
,
aMsk
);
else
else
aBmpEx
=
aBmp
;
aBmpEx
=
aBmp
;
mpTbx
->
SetItemImage
(
mnBtnId
,
Image
(
aBmpEx
)
);
mpTbx
->
SetItemImage
(
mnBtnId
,
Image
(
aBmpEx
)
);
}
}
}
}
}
}
}
// namespace svx
}
// namespace svx
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment