summaryrefslogtreecommitdiff
path: root/cui/source/dialogs/screenshotannotationdlg.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-17 14:48:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-17 15:50:58 +0200
commit3e57aad962c9d24c535daff893db203314709cfc (patch)
tree5744fcaae69751cdd4174f5da6024ba656e77ccc /cui/source/dialogs/screenshotannotationdlg.cxx
parentbb3ea0ae51bb943f7bb3dca80eee153f9c55c03e (diff)
loplugin:flatten in cui
Change-Id: I0ea0784ab8c4542747da1e15fa7c60c60bccb602 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92423 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cui/source/dialogs/screenshotannotationdlg.cxx')
-rw-r--r--cui/source/dialogs/screenshotannotationdlg.cxx214
1 files changed, 107 insertions, 107 deletions
diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx b/cui/source/dialogs/screenshotannotationdlg.cxx
index c9a93d21d9c5..3731163a1f19 100644
--- a/cui/source/dialogs/screenshotannotationdlg.cxx
+++ b/cui/source/dialogs/screenshotannotationdlg.cxx
@@ -297,53 +297,53 @@ IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, saveButtonHandler, weld::Button&,
xFilePicker->setDefaultName(OStringToOUString(aDerivedFileName, RTL_TEXTENCODING_UTF8));
xFilePicker->setMultiSelectionMode(false);
- if (xFilePicker->execute() == ui::dialogs::ExecutableDialogResults::OK)
- {
- maLastFolderURL = xFilePicker->getDisplayDirectory();
- const uno::Sequence< OUString > files(xFilePicker->getSelectedFiles());
+ if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
+ return;
- if (files.hasElements())
- {
- OUString aConfirmedName = files[0];
+ maLastFolderURL = xFilePicker->getDisplayDirectory();
+ const uno::Sequence< OUString > files(xFilePicker->getSelectedFiles());
- if (!aConfirmedName.isEmpty())
- {
- INetURLObject aConfirmedURL(aConfirmedName);
- OUString aCurrentExtension(aConfirmedURL.getExtension());
+ if (!files.hasElements())
+ return;
- if (!aCurrentExtension.isEmpty() && aCurrentExtension != "png")
- {
- aConfirmedURL.removeExtension();
- aCurrentExtension.clear();
- }
+ OUString aConfirmedName = files[0];
- if (aCurrentExtension.isEmpty())
- {
- aConfirmedURL.setExtension("png");
- }
+ if (aConfirmedName.isEmpty())
+ return;
- // open stream
- SvFileStream aNew(aConfirmedURL.PathToFileName(), StreamMode::WRITE | StreamMode::TRUNC);
+ INetURLObject aConfirmedURL(aConfirmedName);
+ OUString aCurrentExtension(aConfirmedURL.getExtension());
- if (aNew.IsOpen())
- {
- // prepare bitmap to save - do use the original screenshot here,
- // not the dimmed one
- RepaintToBuffer();
-
- // extract Bitmap
- const BitmapEx aTargetBitmap(
- mxVirtualBufferDevice->GetBitmapEx(
- Point(0, 0),
- mxVirtualBufferDevice->GetOutputSizePixel()));
-
- // write as PNG
- vcl::PNGWriter aPNGWriter(aTargetBitmap);
- aPNGWriter.Write(aNew);
- }
- }
- }
+ if (!aCurrentExtension.isEmpty() && aCurrentExtension != "png")
+ {
+ aConfirmedURL.removeExtension();
+ aCurrentExtension.clear();
+ }
+
+ if (aCurrentExtension.isEmpty())
+ {
+ aConfirmedURL.setExtension("png");
}
+
+ // open stream
+ SvFileStream aNew(aConfirmedURL.PathToFileName(), StreamMode::WRITE | StreamMode::TRUNC);
+
+ if (!aNew.IsOpen())
+ return;
+
+ // prepare bitmap to save - do use the original screenshot here,
+ // not the dimmed one
+ RepaintToBuffer();
+
+ // extract Bitmap
+ const BitmapEx aTargetBitmap(
+ mxVirtualBufferDevice->GetBitmapEx(
+ Point(0, 0),
+ mxVirtualBufferDevice->GetOutputSizePixel()));
+
+ // write as PNG
+ vcl::PNGWriter aPNGWriter(aTargetBitmap);
+ aPNGWriter.Write(aNew);
}
weld::ScreenShotEntry* ScreenshotAnnotationDlg_Impl::CheckHit(const basegfx::B2IPoint& rPosition)
@@ -378,42 +378,42 @@ void ScreenshotAnnotationDlg_Impl::PaintScreenShotEntry(
double fLineWidth,
double fTransparency)
{
- if (mxPicture && mxVirtualBufferDevice)
+ if (!(mxPicture && mxVirtualBufferDevice))
+ return;
+
+ basegfx::B2DRange aB2DRange(rEntry.getB2IRange());
+
+ // grow in pixels to be a little bit 'outside'. This also
+ // ensures that getWidth()/getHeight() ain't 0.0 (see division below)
+ static const double fGrowTopLeft(1.5);
+ static const double fGrowBottomRight(0.5);
+ aB2DRange.expand(aB2DRange.getMinimum() - basegfx::B2DPoint(fGrowTopLeft, fGrowTopLeft));
+ aB2DRange.expand(aB2DRange.getMaximum() + basegfx::B2DPoint(fGrowBottomRight, fGrowBottomRight));
+
+ // edge rounding in pixel. Need to convert, value for
+ // createPolygonFromRect is relative [0.0 .. 1.0]
+ static const double fEdgeRoundPixel(8.0);
+ const basegfx::B2DPolygon aPolygon(
+ basegfx::utils::createPolygonFromRect(
+ aB2DRange,
+ fEdgeRoundPixel / aB2DRange.getWidth(),
+ fEdgeRoundPixel / aB2DRange.getHeight()));
+
+ mxVirtualBufferDevice->SetLineColor(rColor);
+
+ // try to use transparency
+ if (!mxVirtualBufferDevice->DrawPolyLineDirect(
+ basegfx::B2DHomMatrix(),
+ aPolygon,
+ fLineWidth,
+ fTransparency,
+ nullptr, // MM01
+ basegfx::B2DLineJoin::Round))
{
- basegfx::B2DRange aB2DRange(rEntry.getB2IRange());
-
- // grow in pixels to be a little bit 'outside'. This also
- // ensures that getWidth()/getHeight() ain't 0.0 (see division below)
- static const double fGrowTopLeft(1.5);
- static const double fGrowBottomRight(0.5);
- aB2DRange.expand(aB2DRange.getMinimum() - basegfx::B2DPoint(fGrowTopLeft, fGrowTopLeft));
- aB2DRange.expand(aB2DRange.getMaximum() + basegfx::B2DPoint(fGrowBottomRight, fGrowBottomRight));
-
- // edge rounding in pixel. Need to convert, value for
- // createPolygonFromRect is relative [0.0 .. 1.0]
- static const double fEdgeRoundPixel(8.0);
- const basegfx::B2DPolygon aPolygon(
- basegfx::utils::createPolygonFromRect(
- aB2DRange,
- fEdgeRoundPixel / aB2DRange.getWidth(),
- fEdgeRoundPixel / aB2DRange.getHeight()));
-
- mxVirtualBufferDevice->SetLineColor(rColor);
-
- // try to use transparency
- if (!mxVirtualBufferDevice->DrawPolyLineDirect(
- basegfx::B2DHomMatrix(),
+ // no transparency, draw without
+ mxVirtualBufferDevice->DrawPolyLine(
aPolygon,
- fLineWidth,
- fTransparency,
- nullptr, // MM01
- basegfx::B2DLineJoin::Round))
- {
- // no transparency, draw without
- mxVirtualBufferDevice->DrawPolyLine(
- aPolygon,
- fLineWidth);
- }
+ fLineWidth);
}
}
@@ -430,43 +430,43 @@ void ScreenshotAnnotationDlg_Impl::RepaintToBuffer(
bool bUseDimmed,
bool bPaintHilight)
{
- if (mxVirtualBufferDevice)
+ if (!mxVirtualBufferDevice)
+ return;
+
+ // reset with original screenshot bitmap
+ mxVirtualBufferDevice->DrawBitmapEx(
+ Point(0, 0),
+ bUseDimmed ? maDimmedDialogBitmap : maParentDialogBitmap);
+
+ // get various options
+ const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
+ const Color aHilightColor(aSvtOptionsDrawinglayer.getHilightColor());
+ const double fTransparence(aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() * 0.01);
+ const bool bIsAntiAliasing(aSvtOptionsDrawinglayer.IsAntiAliasing());
+ const AntialiasingFlags nOldAA(mxVirtualBufferDevice->GetAntialiasing());
+
+ if (bIsAntiAliasing)
{
- // reset with original screenshot bitmap
- mxVirtualBufferDevice->DrawBitmapEx(
- Point(0, 0),
- bUseDimmed ? maDimmedDialogBitmap : maParentDialogBitmap);
-
- // get various options
- const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
- const Color aHilightColor(aSvtOptionsDrawinglayer.getHilightColor());
- const double fTransparence(aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() * 0.01);
- const bool bIsAntiAliasing(aSvtOptionsDrawinglayer.IsAntiAliasing());
- const AntialiasingFlags nOldAA(mxVirtualBufferDevice->GetAntialiasing());
-
- if (bIsAntiAliasing)
- {
- mxVirtualBufferDevice->SetAntialiasing(AntialiasingFlags::EnableB2dDraw);
- }
+ mxVirtualBufferDevice->SetAntialiasing(AntialiasingFlags::EnableB2dDraw);
+ }
- // paint selected entries
- for (auto&& rCandidate : maSelected)
- {
- static const double fLineWidthEntries(5.0);
- PaintScreenShotEntry(*rCandidate, COL_LIGHTRED, fLineWidthEntries, fTransparence * 0.2);
- }
+ // paint selected entries
+ for (auto&& rCandidate : maSelected)
+ {
+ static const double fLineWidthEntries(5.0);
+ PaintScreenShotEntry(*rCandidate, COL_LIGHTRED, fLineWidthEntries, fTransparence * 0.2);
+ }
- // paint highlighted entry
- if (mpHilighted && bPaintHilight)
- {
- static const double fLineWidthHilight(7.0);
- PaintScreenShotEntry(*mpHilighted, aHilightColor, fLineWidthHilight, fTransparence);
- }
+ // paint highlighted entry
+ if (mpHilighted && bPaintHilight)
+ {
+ static const double fLineWidthHilight(7.0);
+ PaintScreenShotEntry(*mpHilighted, aHilightColor, fLineWidthHilight, fTransparence);
+ }
- if (bIsAntiAliasing)
- {
- mxVirtualBufferDevice->SetAntialiasing(nOldAA);
- }
+ if (bIsAntiAliasing)
+ {
+ mxVirtualBufferDevice->SetAntialiasing(nOldAA);
}
}