diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-16 16:13:38 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-19 10:13:00 +0100 |
commit | 6fbb6d80fe6203ff6f84ee85ca625b6e60bf5bae (patch) | |
tree | 1482de217efaafface8b1fa82ecd2320b82a1a68 /svx | |
parent | 2ab300bfa18cdcc91a9311c4c9710254b0ad7753 (diff) |
use std::array in createHistorical8x8FromArray
to make the assumption about the size of the array obvious in the code.
Change-Id: I7ebe0b037e3be38f7e33c0160742f829288bb474
Reviewed-on: https://gerrit.libreoffice.org/49938
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/accessibility/svxpixelctlaccessiblecontext.cxx | 8 | ||||
-rw-r--r-- | svx/source/dialog/dlgctrl.cxx | 39 | ||||
-rw-r--r-- | svx/source/xoutdev/xattrbmp.cxx | 2 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabptrn.cxx | 4 |
4 files changed, 21 insertions, 32 deletions
diff --git a/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx b/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx index 37c0aabd7b47..7e8aee7af76e 100644 --- a/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx +++ b/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx @@ -74,7 +74,7 @@ uno::Reference< XAccessibleContext > SvxPixelCtlAccessible::getAccessibleContext sal_Int32 SvxPixelCtlAccessible::getAccessibleChildCount( ) { ::osl::MutexGuard aGuard( m_aMutex ); - return mrPixelCtl.GetSquares(); + return SvxPixelCtl::GetSquares(); } uno::Reference< XAccessible > SvxPixelCtlAccessible::getAccessibleChild( sal_Int32 i ) { @@ -450,7 +450,7 @@ void SvxPixelCtlAccessible::NotifyChild(long nIndex,bool bSelect ,bool bCheck) uno::Reference<XAccessible> SvxPixelCtlAccessible::CreateChild (long nIndex,Point mPoint) { bool bPixelColorOrBG = mrPixelCtl.GetBitmapPixel(sal_uInt16(nIndex)) != 0; - Size size(mrPixelCtl.GetWidth() / mrPixelCtl.GetLineCount(),mrPixelCtl.GetHeight() / mrPixelCtl.GetLineCount()); + Size size(mrPixelCtl.GetWidth() / SvxPixelCtl::GetLineCount(), mrPixelCtl.GetHeight() / SvxPixelCtl::GetLineCount()); uno::Reference<XAccessible> xChild; xChild = new SvxPixelCtlAccessibleChild(mrPixelCtl, bPixelColorOrBG, @@ -794,8 +794,8 @@ tools::Rectangle const & SvxPixelCtlAccessibleChild::GetBoundingBox() OUString SvxPixelCtlAccessibleChild::GetName() { - sal_Int32 nXIndex = mnIndexInParent % mrParentWindow.GetLineCount(); - sal_Int32 nYIndex = mnIndexInParent / mrParentWindow.GetLineCount(); + sal_Int32 nXIndex = mnIndexInParent % SvxPixelCtl::GetLineCount(); + sal_Int32 nYIndex = mnIndexInParent / SvxPixelCtl::GetLineCount(); OUString str = "(" + OUString::number(nXIndex) diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index d7f47cc015bc..b6eeafb7ed0f 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -722,20 +722,15 @@ long SvxPixelCtl::ShowPosition( const Point &pt) } -SvxPixelCtl::SvxPixelCtl(vcl::Window* pParent, sal_uInt16 nNumber) +SvxPixelCtl::SvxPixelCtl(vcl::Window* pParent) : Control(pParent, WB_BORDER) - , nLines(nNumber) , bPaintable(true) , aFocusPosition(0,0) { - assert(nLines); // can't have no lines SetPixelColor( Color( COL_BLACK ) ); SetBackgroundColor( Color( COL_WHITE ) ); SetLineColor( Color( COL_LIGHTGRAY ) ); - - nSquares = nLines * nLines; - pPixel = new sal_uInt16[ nSquares ]; - memset(pPixel, 0, nSquares * sizeof(sal_uInt16)); + maPixelData.fill(0); } void SvxPixelCtl::Resize() @@ -749,27 +744,21 @@ Size SvxPixelCtl::GetOptimalSize() const return LogicToPixel(Size(72, 72), MapMode(MapUnit::MapAppFont)); } -VCL_BUILDER_FACTORY_ARGS(SvxPixelCtl, 8) +VCL_BUILDER_FACTORY(SvxPixelCtl) SvxPixelCtl::~SvxPixelCtl( ) { disposeOnce(); } -void SvxPixelCtl::dispose() -{ - delete []pPixel; - Control::dispose(); -} - // Changes the foreground or Background color void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel ) { - if( *( pPixel + nPixel) == 0 ) - *( pPixel + nPixel) = 1; // could be extended to more colors + if( maPixelData[nPixel] == 0 ) + maPixelData[nPixel] = 1; // could be extended to more colors else - *( pPixel + nPixel) = 0; + maPixelData[nPixel] = 0; } // The clicked rectangle is identified, to change its color @@ -819,7 +808,7 @@ void SvxPixelCtl::Paint( vcl::RenderContext& rRenderContext, const tools::Rectan //Draw Rectangles (squares) rRenderContext.SetLineColor(); - sal_uInt16 nLastPixel = *pPixel ? 0 : 1; + sal_uInt16 nLastPixel = maPixelData[0]; for (i = 0; i < nLines; i++) { @@ -831,9 +820,9 @@ void SvxPixelCtl::Paint( vcl::RenderContext& rRenderContext, const tools::Rectan aPtTl.X() = aRectSize.Width() * j / nLines + 1; aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1; - if (*(pPixel + i * nLines + j) != nLastPixel) + if (maPixelData[i * nLines + j] != nLastPixel) { - nLastPixel = *(pPixel + i * nLines + j); + nLastPixel = maPixelData[i * nLines + j]; // Change color: 0 -> Background color rRenderContext.SetFillColor(nLastPixel ? aPixelColor : aBackgroundColor); } @@ -996,18 +985,18 @@ void SvxPixelCtl::SetXBitmap(const BitmapEx& rBitmapEx) const BitmapColor aColor(pRead->GetColor(i/8, i%8)); if (aColor == aBack) - *(pPixel + i) = 0; + maPixelData[i] = 0; else - *(pPixel + i) = 1; + maPixelData[i] = 1; } } } // Returns a specific pixel -sal_uInt16 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel ) +sal_uInt8 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel ) const { - return *( pPixel + nPixel ); + return maPixelData[nPixel]; } // Resets to the original state of the control @@ -1015,7 +1004,7 @@ sal_uInt16 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel ) void SvxPixelCtl::Reset() { // clear pixel area - memset(pPixel, 0, nSquares * sizeof(sal_uInt16)); + maPixelData.fill(0); Invalidate(); } diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx index 336f84d9c2a8..8e28d1ab2646 100644 --- a/svx/source/xoutdev/xattrbmp.cxx +++ b/svx/source/xoutdev/xattrbmp.cxx @@ -144,7 +144,7 @@ XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem) { } -BitmapEx createHistorical8x8FromArray(sal_uInt16 const *pArray, Color aColorPix, Color aColorBack) +BitmapEx createHistorical8x8FromArray(std::array<sal_uInt8,64> const & pArray, Color aColorPix, Color aColorBack) { vcl::bitmap::RawBitmap aBitmap(Size(8, 8)); diff --git a/svx/source/xoutdev/xtabptrn.cxx b/svx/source/xoutdev/xtabptrn.cxx index 40e38cb3e331..a42be9e1e6b5 100644 --- a/svx/source/xoutdev/xtabptrn.cxx +++ b/svx/source/xoutdev/xtabptrn.cxx @@ -48,11 +48,11 @@ uno::Reference< container::XNameContainer > XPatternList::createInstance() bool XPatternList::Create() { OUStringBuffer aStr(SvxResId(RID_SVXSTR_PATTERN)); - sal_uInt16 aArray[64]; + std::array<sal_uInt8,64> aArray; BitmapEx aBitmap; const sal_Int32 nLen(aStr.getLength() - 1); - memset(aArray, 0, sizeof(aArray)); + aArray.fill(0); // white/white bitmap aStr.append(" 1"); |