summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-01-15 14:49:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-01-16 10:07:07 +0100
commit63a68064bb33f180b8a231f7524d99405d910226 (patch)
tree7ecf05b057c5ca4d80a48af045998a4b34484561 /sd
parentd534a4c7b45ff254b339e806c6a11f13d9ff0043 (diff)
make the Color constructors explicitly specify transparency
to reduce the churn, we leave the existing constructor in place, and add a clang plugin to detect when the value passed to the existing constructor may contain transparency/alpha data. i.e. we leave expressions like Color(0xffffff) alone, but warn about any non-constant expression, and any expression like Color(0xff000000) Change-Id: Id2ce58e08882d9b7bd0b9f88eca97359dcdbcc8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109362 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/filter/eppt/pptx-stylesheet.cxx6
-rw-r--r--sd/source/filter/html/htmlex.cxx20
-rw-r--r--sd/source/filter/ppt/ppt97animations.cxx2
-rw-r--r--sd/source/ui/animations/CustomAnimationDialog.cxx13
-rw-r--r--sd/source/ui/dlg/copydlg.cxx4
-rw-r--r--sd/source/ui/presenter/PresenterTextView.cxx8
-rw-r--r--sd/source/ui/slideshow/slideshowimpl.cxx4
-rw-r--r--sd/source/ui/slidesorter/shell/SlideSorterService.cxx8
-rw-r--r--sd/source/ui/view/drtxtob1.cxx2
-rw-r--r--sd/source/ui/view/drviews2.cxx2
-rw-r--r--sd/source/ui/view/drviews7.cxx2
11 files changed, 35 insertions, 36 deletions
diff --git a/sd/source/filter/eppt/pptx-stylesheet.cxx b/sd/source/filter/eppt/pptx-stylesheet.cxx
index 27fc7f3ac598..459020278fc9 100644
--- a/sd/source/filter/eppt/pptx-stylesheet.cxx
+++ b/sd/source/filter/eppt/pptx-stylesheet.cxx
@@ -79,7 +79,7 @@ void PPTExCharSheet::SetStyleSheet( const css::uno::Reference< css::beans::XProp
PPTExCharLevel& rLev = maCharLevel[ nLevel ];
if ( aPortionObj.meCharColor == css::beans::PropertyState_DIRECT_VALUE )
- rLev.mnFontColor = aPortionObj.mnCharColor;
+ rLev.mnFontColor = Color(ColorTransparency, aPortionObj.mnCharColor);
if ( aPortionObj.meCharEscapement == css::beans::PropertyState_DIRECT_VALUE )
rLev.mnEscapement = aPortionObj.mnCharEscapement;
if ( aPortionObj.meCharHeight == css::beans::PropertyState_DIRECT_VALUE )
@@ -111,7 +111,7 @@ void PPTExCharSheet::Write( SvStream& rSt, sal_uInt16 nLev, bool bSimpleText,
css::uno::Any aAny;
if ( PropValue::GetPropertyValue( aAny, rPagePropSet, "IsBackgroundDark", true ) )
aAny >>= bIsDark;
- nFontColor = bIsDark ? 0xffffff : 0x000000;
+ nFontColor = Color(ColorTransparency, bIsDark ? 0xffffff : 0x000000);
}
nFontColor.SetAlpha(1);
if ( bSimpleText )
@@ -447,7 +447,7 @@ bool PPTExStyleSheet::IsHardAttribute( sal_uInt32 nInstance, sal_uInt32 nLevel,
case CharAttr_AsianOrComplexFont : return ( rChar.mnAsianOrComplexFont != nValue );
case CharAttr_Symbol : return true;
case CharAttr_FontHeight : return ( rChar.mnFontHeight != nValue );
- case CharAttr_FontColor : return ( rChar.mnFontColor != nValue );
+ case CharAttr_FontColor : return ( rChar.mnFontColor != Color(ColorTransparency, nValue) );
case CharAttr_Escapement : return ( rChar.mnEscapement != nValue );
default:
break;
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index c7819eafa3a9..87d90336e554 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -499,37 +499,37 @@ void HtmlExport::InitExportParameters( const Sequence< PropertyValue >& rParams
}
else if ( rParam.Name == "BackColor" )
{
- sal_Int32 temp = 0;
+ Color temp;
rParam.Value >>= temp;
- maBackColor = Color(temp);
+ maBackColor = temp;
mbUserAttr = true;
}
else if ( rParam.Name == "TextColor" )
{
- sal_Int32 temp = 0;
+ Color temp;
rParam.Value >>= temp;
- maTextColor = Color(temp);
+ maTextColor = temp;
mbUserAttr = true;
}
else if ( rParam.Name == "LinkColor" )
{
- sal_Int32 temp = 0;
+ Color temp ;
rParam.Value >>= temp;
- maLinkColor = Color(temp);
+ maLinkColor = temp;
mbUserAttr = true;
}
else if ( rParam.Name == "VLinkColor" )
{
- sal_Int32 temp = 0;
+ Color temp;
rParam.Value >>= temp;
- maVLinkColor = Color(temp);
+ maVLinkColor = temp;
mbUserAttr = true;
}
else if ( rParam.Name == "ALinkColor" )
{
- sal_Int32 temp = 0;
+ Color temp;
rParam.Value >>= temp;
- maALinkColor = Color(temp);
+ maALinkColor = temp;
mbUserAttr = true;
}
else if ( rParam.Name == "IsUseDocumentColors" )
diff --git a/sd/source/filter/ppt/ppt97animations.cxx b/sd/source/filter/ppt/ppt97animations.cxx
index 96d578019753..cc0b37afd913 100644
--- a/sd/source/filter/ppt/ppt97animations.cxx
+++ b/sd/source/filter/ppt/ppt97animations.cxx
@@ -35,7 +35,7 @@ void Ppt97AnimationInfoAtom::ReadStream( SvStream& rIn )
{
sal_uInt32 nTmp;
rIn.ReadUInt32( nTmp );
- nDimColor = Color(nTmp);
+ nDimColor = Color(ColorTransparency, nTmp);
rIn.ReadUInt32( nFlags );
rIn.ReadUInt32( nSoundRef );
rIn.ReadInt32( nDelayTime );
diff --git a/sd/source/ui/animations/CustomAnimationDialog.cxx b/sd/source/ui/animations/CustomAnimationDialog.cxx
index a4b247662855..fb8a5bc68efd 100644
--- a/sd/source/ui/animations/CustomAnimationDialog.cxx
+++ b/sd/source/ui/animations/CustomAnimationDialog.cxx
@@ -208,9 +208,9 @@ SdColorPropertyBox::SdColorPropertyBox(weld::Label* pLabel, weld::Container* pPa
pLabel->set_mnemonic_widget(&mxControl->get_widget());
mxControl->show();
- sal_Int32 nColor = 0;
+ Color nColor;
rValue >>= nColor;
- mxControl->SelectEntry(Color(nColor));
+ mxControl->SelectEntry(nColor);
}
IMPL_LINK_NOARG(SdColorPropertyBox, OnSelect, ColorListBox&, void)
@@ -222,11 +222,11 @@ void SdColorPropertyBox::setValue( const Any& rValue, const OUString& )
{
if (mxControl)
{
- sal_Int32 nColor = 0;
+ Color nColor;
rValue >>= nColor;
mxControl->SetNoSelection();
- mxControl->SelectEntry(Color(nColor));
+ mxControl->SelectEntry(nColor);
}
}
@@ -1000,9 +1000,8 @@ CustomAnimationEffectTabPage::CustomAnimationEffectTabPage(weld::Container* pPar
if( aDimColor.hasValue() )
{
- sal_Int32 nColor = 0;
- aDimColor >>= nColor;
- Color aColor(nColor);
+ Color aColor;
+ aDimColor >>= aColor;
mxCLBDimColor->SelectEntry(aColor);
}
else
diff --git a/sd/source/ui/dlg/copydlg.cxx b/sd/source/ui/dlg/copydlg.cxx
index 5de5d71bcd8d..89eb7992ea73 100644
--- a/sd/source/ui/dlg/copydlg.cxx
+++ b/sd/source/ui/dlg/copydlg.cxx
@@ -169,8 +169,8 @@ void CopyDlg::Reset()
m_xMtrFldAngle->set_value(aStr.getToken(0, TOKEN, nIdx).toInt64(), FieldUnit::NONE);
m_xMtrFldWidth->set_value(aStr.getToken(0, TOKEN, nIdx).toInt64(), FieldUnit::NONE);
m_xMtrFldHeight->set_value(aStr.getToken(0, TOKEN, nIdx).toInt64(), FieldUnit::NONE);
- m_xLbStartColor->SelectEntry( Color( aStr.getToken(0, TOKEN, nIdx).toUInt32() ) );
- m_xLbEndColor->SelectEntry( Color( aStr.getToken(0, TOKEN, nIdx).toUInt32() ) );
+ m_xLbStartColor->SelectEntry( Color( ColorTransparency, aStr.getToken(0, TOKEN, nIdx).toUInt32() ) );
+ m_xLbEndColor->SelectEntry( Color( ColorTransparency, aStr.getToken(0, TOKEN, nIdx).toUInt32() ) );
}
}
diff --git a/sd/source/ui/presenter/PresenterTextView.cxx b/sd/source/ui/presenter/PresenterTextView.cxx
index 46daeb6f061d..4a3301bbefc4 100644
--- a/sd/source/ui/presenter/PresenterTextView.cxx
+++ b/sd/source/ui/presenter/PresenterTextView.cxx
@@ -161,15 +161,15 @@ Any PresenterTextView::SetPropertyValue (
}
else if (rsPropertyName == gsBackgroundColorPropertyName)
{
- util::Color aColor = util::Color();
+ ::Color aColor;
if (rValue >>= aColor)
- mpImplementation->SetBackgroundColor(Color(aColor));
+ mpImplementation->SetBackgroundColor(aColor);
}
else if (rsPropertyName == gsTextColorPropertyName)
{
- util::Color aColor = util::Color();
+ ::Color aColor;
if (rValue >>= aColor)
- mpImplementation->SetTextColor(Color(aColor));
+ mpImplementation->SetTextColor(aColor);
}
else if (rsPropertyName == gsFontDescriptorPropertyName)
{
diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx
index 5b4574261934..77bab18a6c70 100644
--- a/sd/source/ui/slideshow/slideshowimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowimpl.cxx
@@ -1417,7 +1417,7 @@ void SAL_CALL SlideshowImpl::blankScreen( sal_Int32 nColor )
if( mpShowWindow && mpSlideController )
{
- if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), Color(nColor) ) )
+ if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), Color(ColorTransparency, nColor) ) )
{
pause();
}
@@ -2107,7 +2107,7 @@ IMPL_LINK( SlideshowImpl, ContextMenuSelectHdl, Menu *, pMenu, bool )
else if (sMenuId == "color")
{
//Open a color picker based on SvColorDialog
- ::Color aColor( mnUserPaintColor );
+ ::Color aColor( ColorTransparency, mnUserPaintColor );
SvColorDialog aColorDlg;
aColorDlg.SetColor( aColor );
diff --git a/sd/source/ui/slidesorter/shell/SlideSorterService.cxx b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
index cd9b167d6eff..41d05c37f0b3 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
@@ -310,7 +310,7 @@ void SAL_CALL SlideSorterService::setBackgroundColor (sal_Int32 aBackgroundColor
{
ThrowIfDisposed();
if (mpSlideSorter != nullptr && mpSlideSorter->IsValid())
- mpSlideSorter->GetProperties()->SetBackgroundColor(Color(aBackgroundColor));
+ mpSlideSorter->GetProperties()->SetBackgroundColor(Color(ColorTransparency, aBackgroundColor));
}
sal_Int32 SAL_CALL SlideSorterService::getTextColor()
@@ -327,7 +327,7 @@ void SAL_CALL SlideSorterService::setTextColor (sal_Int32 aTextColor)
{
ThrowIfDisposed();
if (mpSlideSorter != nullptr && mpSlideSorter->IsValid())
- mpSlideSorter->GetProperties()->SetTextColor(Color(aTextColor));
+ mpSlideSorter->GetProperties()->SetTextColor(Color(ColorTransparency, aTextColor));
}
sal_Int32 SAL_CALL SlideSorterService::getSelectionColor()
@@ -344,7 +344,7 @@ void SAL_CALL SlideSorterService::setSelectionColor (sal_Int32 aSelectionColor)
{
ThrowIfDisposed();
if (mpSlideSorter != nullptr && mpSlideSorter->IsValid())
- mpSlideSorter->GetProperties()->SetSelectionColor(Color(aSelectionColor));
+ mpSlideSorter->GetProperties()->SetSelectionColor(Color(ColorTransparency, aSelectionColor));
}
sal_Int32 SAL_CALL SlideSorterService::getHighlightColor()
@@ -361,7 +361,7 @@ void SAL_CALL SlideSorterService::setHighlightColor (sal_Int32 aHighlightColor)
{
ThrowIfDisposed();
if (mpSlideSorter != nullptr && mpSlideSorter->IsValid())
- mpSlideSorter->GetProperties()->SetHighlightColor(Color(aHighlightColor));
+ mpSlideSorter->GetProperties()->SetHighlightColor(Color(ColorTransparency, aHighlightColor));
}
sal_Bool SAL_CALL SlideSorterService::getIsUIReadOnly()
diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx
index 582223ed0fa3..2c92f0b66d06 100644
--- a/sd/source/ui/view/drtxtob1.cxx
+++ b/sd/source/ui/view/drtxtob1.cxx
@@ -82,7 +82,7 @@ namespace
if (sColor == "transparent")
aColor = COL_TRANSPARENT;
else
- aColor = Color(sColor.toInt32(16));
+ aColor = Color(ColorTransparency, sColor.toInt32(16));
switch (nSlot)
{
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index b11da7048b01..d60ebb701298 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -562,7 +562,7 @@ public:
if (sColor == "transparent")
aColor = COL_TRANSPARENT;
else
- aColor = Color(sColor.toInt32(16));
+ aColor = Color(ColorTransparency, sColor.toInt32(16));
switch (nSlot)
{
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index 9ce0bab63e4d..6e695b1d4f06 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1813,7 +1813,7 @@ void DrawViewShell::SetPageProperties (SfxRequest& rReq)
if (sColor == "transparent")
aColor = COL_TRANSPARENT;
else
- aColor = Color(sColor.toInt32(16));
+ aColor = Color(ColorTransparency, sColor.toInt32(16));
XFillColorItem aColorItem(OUString(), aColor);
rPageProperties.PutItem( XFillStyleItem( drawing::FillStyle_SOLID ) );