diff options
Diffstat (limited to 'vcl')
64 files changed, 3948 insertions, 3954 deletions
diff --git a/vcl/backendtest/VisualBackendTest.cxx b/vcl/backendtest/VisualBackendTest.cxx index b3e1b3eb144c..858ae7b996f1 100644 --- a/vcl/backendtest/VisualBackendTest.cxx +++ b/vcl/backendtest/VisualBackendTest.cxx @@ -127,18 +127,18 @@ public: else if(nCode == KEY_SPACE) mnTest++; - if (nCode == KEY_BACKSPACE || nCode == KEY_SPACE) + if (nCode != KEY_BACKSPACE && nCode != KEY_SPACE) + return; + + if (mnTest % gnNumberOfTests == gnNumberOfTests - 1) { - if (mnTest % gnNumberOfTests == gnNumberOfTests - 1) - { - mbAnimate = true; - maUpdateTimer.Start(); - } - else - { - mbAnimate = false; - Invalidate(); - } + mbAnimate = true; + maUpdateTimer.Start(); + } + else + { + mbAnimate = false; + Invalidate(); } } diff --git a/vcl/headless/CustomWidgetDraw.cxx b/vcl/headless/CustomWidgetDraw.cxx index 600875d5c4ca..6a1346a4aaf6 100644 --- a/vcl/headless/CustomWidgetDraw.cxx +++ b/vcl/headless/CustomWidgetDraw.cxx @@ -25,30 +25,30 @@ CustomWidgetDraw::CustomWidgetDraw(SvpSalGraphics& rGraphics) { #ifndef DISABLE_DYNLOADING static bool s_bMissingLibrary = false; - if (!s_pWidgetImplementation && !s_bMissingLibrary) + if (s_pWidgetImplementation || s_bMissingLibrary) + return; + + OUString aUrl("${LO_LIB_DIR}/" SVLIBRARY("vcl_widget_theme")); + rtl::Bootstrap::expandMacros(aUrl); + osl::Module aLibrary; + aLibrary.load(aUrl, SAL_LOADMODULE_GLOBAL); + auto fCreateWidgetThemeLibraryFunction + = reinterpret_cast<vcl::WidgetThemeLibrary*(SAL_CALL*)()>( + aLibrary.getFunctionSymbol("CreateWidgetThemeLibrary")); + aLibrary.release(); + + if (fCreateWidgetThemeLibraryFunction) + s_pWidgetImplementation = (*fCreateWidgetThemeLibraryFunction)(); + + // Init + if (s_pWidgetImplementation) { - OUString aUrl("${LO_LIB_DIR}/" SVLIBRARY("vcl_widget_theme")); - rtl::Bootstrap::expandMacros(aUrl); - osl::Module aLibrary; - aLibrary.load(aUrl, SAL_LOADMODULE_GLOBAL); - auto fCreateWidgetThemeLibraryFunction - = reinterpret_cast<vcl::WidgetThemeLibrary*(SAL_CALL*)()>( - aLibrary.getFunctionSymbol("CreateWidgetThemeLibrary")); - aLibrary.release(); - - if (fCreateWidgetThemeLibraryFunction) - s_pWidgetImplementation = (*fCreateWidgetThemeLibraryFunction)(); - - // Init - if (s_pWidgetImplementation) - { - ImplSVData* pSVData = ImplGetSVData(); - pSVData->maNWFData.mbNoFocusRects = true; - pSVData->maNWFData.mbNoFocusRectsForFlatButtons = true; - } - else - s_bMissingLibrary = true; + ImplSVData* pSVData = ImplGetSVData(); + pSVData->maNWFData.mbNoFocusRects = true; + pSVData->maNWFData.mbNoFocusRectsForFlatButtons = true; } + else + s_bMissingLibrary = true; #endif } diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx index e38e14e18d7e..89af9b272185 100644 --- a/vcl/headless/svpframe.cxx +++ b/vcl/headless/svpframe.cxx @@ -310,27 +310,27 @@ void SvpSalFrame::SetWindowState( const SalFrameState *pState ) return; // Request for position or size change - if (pState->mnMask & FRAMESTATE_MASK_GEOMETRY) - { - long nX = maGeometry.nX; - long nY = maGeometry.nY; - long nWidth = maGeometry.nWidth; - long nHeight = maGeometry.nHeight; - - // change requested properties - if (pState->mnMask & WindowStateMask::X) - nX = pState->mnX; - if (pState->mnMask & WindowStateMask::Y) - nY = pState->mnY; - if (pState->mnMask & WindowStateMask::Width) - nWidth = pState->mnWidth; - if (pState->mnMask & WindowStateMask::Height) - nHeight = pState->mnHeight; - - SetPosSize( nX, nY, nWidth, nHeight, - SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y | - SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT ); - } + if (!(pState->mnMask & FRAMESTATE_MASK_GEOMETRY)) + return; + + long nX = maGeometry.nX; + long nY = maGeometry.nY; + long nWidth = maGeometry.nWidth; + long nHeight = maGeometry.nHeight; + + // change requested properties + if (pState->mnMask & WindowStateMask::X) + nX = pState->mnX; + if (pState->mnMask & WindowStateMask::Y) + nY = pState->mnY; + if (pState->mnMask & WindowStateMask::Width) + nWidth = pState->mnWidth; + if (pState->mnMask & WindowStateMask::Height) + nHeight = pState->mnHeight; + + SetPosSize( nX, nY, nWidth, nHeight, + SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y | + SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT ); } bool SvpSalFrame::GetWindowState( SalFrameState* pState ) diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 9f1a56e18e8c..f8276b57c542 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -618,19 +618,19 @@ namespace } } - if(!rSurface) - { - // create data on-demand - rSurface = std::make_shared<BitmapHelper>(rSourceBitmap); + if(rSurface) + return; - if(bBufferSource) - { - // add to buffering mechanism to potentially reuse next time - const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rSourceBitmap)); - rSrcBmp.addOrReplaceSystemDependentData<SystemDependentData_BitmapHelper>( - ImplGetSystemDependentDataManager(), - rSurface); - } + // create data on-demand + rSurface = std::make_shared<BitmapHelper>(rSourceBitmap); + + if(bBufferSource) + { + // add to buffering mechanism to potentially reuse next time + const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rSourceBitmap)); + rSrcBmp.addOrReplaceSystemDependentData<SystemDependentData_BitmapHelper>( + ImplGetSystemDependentDataManager(), + rSurface); } } @@ -655,19 +655,19 @@ namespace } } - if(!rMask) - { - // create data on-demand - rMask = std::make_shared<MaskHelper>(rMaskBitmap); + if(rMask) + return; - if(bBufferMask) - { - // add to buffering mechanism to potentially reuse next time - const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rMaskBitmap)); - rSrcBmp.addOrReplaceSystemDependentData<SystemDependentData_MaskHelper>( - ImplGetSystemDependentDataManager(), - rMask); - } + // create data on-demand + rMask = std::make_shared<MaskHelper>(rMaskBitmap); + + if(bBufferMask) + { + // add to buffering mechanism to potentially reuse next time + const SvpSalBitmap& rSrcBmp(static_cast<const SvpSalBitmap&>(rMaskBitmap)); + rSrcBmp.addOrReplaceSystemDependentData<SystemDependentData_MaskHelper>( + ImplGetSystemDependentDataManager(), + rMask); } } } diff --git a/vcl/opengl/RenderList.cxx b/vcl/opengl/RenderList.cxx index 4830f1040de9..e894bb67ce50 100644 --- a/vcl/opengl/RenderList.cxx +++ b/vcl/opengl/RenderList.cxx @@ -127,24 +127,24 @@ void appendPolyLine(vcl::LineBuilder& rBuilder, const basegfx::B2DPolygon& rPoly } } - if (!bClosed && nPoints >= 2 && (eLineCap == css::drawing::LineCap_ROUND || eLineCap == css::drawing::LineCap_SQUARE)) - { - glm::vec2 aBeginCapPoint1(rPolygon.getB2DPoint(0).getX(), rPolygon.getB2DPoint(0).getY()); - glm::vec2 aBeginCapPoint2(rPolygon.getB2DPoint(1).getX(), rPolygon.getB2DPoint(1).getY()); + if (bClosed || nPoints < 2 || (eLineCap != css::drawing::LineCap_ROUND && eLineCap != css::drawing::LineCap_SQUARE)) + return; - glm::vec2 aEndCapPoint1(rPolygon.getB2DPoint(nPoints - 1).getX(), rPolygon.getB2DPoint(nPoints - 1).getY()); - glm::vec2 aEndCapPoint2(rPolygon.getB2DPoint(nPoints - 2).getX(), rPolygon.getB2DPoint(nPoints - 2).getY()); + glm::vec2 aBeginCapPoint1(rPolygon.getB2DPoint(0).getX(), rPolygon.getB2DPoint(0).getY()); + glm::vec2 aBeginCapPoint2(rPolygon.getB2DPoint(1).getX(), rPolygon.getB2DPoint(1).getY()); - if (eLineCap == css::drawing::LineCap_ROUND) - { - rBuilder.appendRoundLineCapVertices(aBeginCapPoint1, aBeginCapPoint2); - rBuilder.appendRoundLineCapVertices(aEndCapPoint1, aEndCapPoint2); - } - else if (eLineCap == css::drawing::LineCap_SQUARE) - { - rBuilder.appendSquareLineCapVertices(aBeginCapPoint1, aBeginCapPoint2); - rBuilder.appendSquareLineCapVertices(aEndCapPoint1, aEndCapPoint2); - } + glm::vec2 aEndCapPoint1(rPolygon.getB2DPoint(nPoints - 1).getX(), rPolygon.getB2DPoint(nPoints - 1).getY()); + glm::vec2 aEndCapPoint2(rPolygon.getB2DPoint(nPoints - 2).getX(), rPolygon.getB2DPoint(nPoints - 2).getY()); + + if (eLineCap == css::drawing::LineCap_ROUND) + { + rBuilder.appendRoundLineCapVertices(aBeginCapPoint1, aBeginCapPoint2); + rBuilder.appendRoundLineCapVertices(aEndCapPoint1, aEndCapPoint2); + } + else if (eLineCap == css::drawing::LineCap_SQUARE) + { + rBuilder.appendSquareLineCapVertices(aBeginCapPoint1, aBeginCapPoint2); + rBuilder.appendSquareLineCapVertices(aEndCapPoint1, aEndCapPoint2); } } @@ -237,23 +237,23 @@ void RenderList::addDrawRectangle(long nX, long nY, long nWidth, long nHeight, d fX1 - 0.5f, fY2 - 0.5f, fX2 + 0.5f, fY2 + 0.5f, nLineColor, fTransparency); } - if (nFillColor != SALCOLOR_NONE) + if (nFillColor == SALCOLOR_NONE) + return; + + if (nLineColor == SALCOLOR_NONE) { - if (nLineColor == SALCOLOR_NONE) - { - appendRectangle(rRenderParameter.maVertices, rRenderParameter.maIndices, - fX1 - 0.5f, fY1 - 0.5f, fX1 + 0.5f, fY2 + 0.5f, nFillColor, fTransparency); - appendRectangle(rRenderParameter.maVertices, rRenderParameter.maIndices, - fX1 - 0.5f, fY1 - 0.5f, fX2 + 0.5f, fY1 + 0.5f, nFillColor, fTransparency); - appendRectangle(rRenderParameter.maVertices, rRenderParameter.maIndices, - fX2 - 0.5f, fY1 - 0.5f, fX2 + 0.5f, fY2 + 0.5f, nFillColor, fTransparency); - appendRectangle(rRenderParameter.maVertices, rRenderParameter.maIndices, - fX1 - 0.5f, fY2 - 0.5f, fX2 + 0.5f, fY2 + 0.5f, nFillColor, fTransparency); - } - // Draw rectangle fill with fill color appendRectangle(rRenderParameter.maVertices, rRenderParameter.maIndices, - fX1 + 0.5f, fY1 + 0.5f, fX2 - 0.5f, fY2 - 0.5f, nFillColor, fTransparency); + fX1 - 0.5f, fY1 - 0.5f, fX1 + 0.5f, fY2 + 0.5f, nFillColor, fTransparency); + appendRectangle(rRenderParameter.maVertices, rRenderParameter.maIndices, + fX1 - 0.5f, fY1 - 0.5f, fX2 + 0.5f, fY1 + 0.5f, nFillColor, fTransparency); + appendRectangle(rRenderParameter.maVertices, rRenderParameter.maIndices, + fX2 - 0.5f, fY1 - 0.5f, fX2 + 0.5f, fY2 + 0.5f, nFillColor, fTransparency); + appendRectangle(rRenderParameter.maVertices, rRenderParameter.maIndices, + fX1 - 0.5f, fY2 - 0.5f, fX2 + 0.5f, fY2 + 0.5f, nFillColor, fTransparency); } + // Draw rectangle fill with fill color + appendRectangle(rRenderParameter.maVertices, rRenderParameter.maIndices, + fX1 + 0.5f, fY1 + 0.5f, fX2 - 0.5f, fY2 - 0.5f, nFillColor, fTransparency); } void RenderList::addDrawLine(long nX1, long nY1, long nX2, long nY2, Color nLineColor, bool bUseAA) @@ -311,39 +311,39 @@ void RenderList::addDrawPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon, } } - if (nLineColor != SALCOLOR_NONE || bUseAA) - { - RenderParameters& rLineRenderParameter = maRenderEntries.back().maLineParameters; - Color nColor = (nLineColor == SALCOLOR_NONE) ? nFillColor : nLineColor; + if (nLineColor == SALCOLOR_NONE && !bUseAA) + return; - vcl::LineBuilder aBuilder(rLineRenderParameter.maVertices, rLineRenderParameter.maIndices, - nColor, fTransparency, 1.0f, bUseAA); + RenderParameters& rLineRenderParameter = maRenderEntries.back().maLineParameters; + Color nColor = (nLineColor == SALCOLOR_NONE) ? nFillColor : nLineColor; - for (const basegfx::B2DPolygon& rPolygon : rPolyPolygon) - { - basegfx::B2DPolygon aPolygon(rPolygon); - if (rPolygon.areControlPointsUsed()) - aPolygon = rPolygon.getDefaultAdaptiveSubdivision(); + vcl::LineBuilder aBuilder(rLineRenderParameter.maVertices, rLineRenderParameter.maIndices, + nColor, fTransparency, 1.0f, bUseAA); - sal_uInt32 nPoints = aPolygon.count(); - if (nPoints <= 1) - continue; + for (const basegfx::B2DPolygon& rPolygon : rPolyPolygon) + { + basegfx::B2DPolygon aPolygon(rPolygon); + if (rPolygon.areControlPointsUsed()) + aPolygon = rPolygon.getDefaultAdaptiveSubdivision(); - GLfloat x1, y1, x2, y2; - sal_uInt32 index1, index2; + sal_uInt32 nPoints = aPolygon.count(); + if (nPoints <= 1) + continue; - for (sal_uInt32 i = 0; i <= nPoints; ++i) - { - index1 = i % nPoints; - index2 = (i + 1) % nPoints; + GLfloat x1, y1, x2, y2; + sal_uInt32 index1, index2; - x1 = aPolygon.getB2DPoint(index1).getX(); - y1 = aPolygon.getB2DPoint(index1).getY(); - x2 = aPolygon.getB2DPoint(index2).getX(); - y2 = aPolygon.getB2DPoint(index2).getY(); + for (sal_uInt32 i = 0; i <= nPoints; ++i) + { + index1 = i % nPoints; + index2 = (i + 1) % nPoints; - aBuilder.appendLine(glm::vec2(x1, y1), glm::vec2(x2, y2)); - } + x1 = aPolygon.getB2DPoint(index1).getX(); + y1 = aPolygon.getB2DPoint(index1).getY(); + x2 = aPolygon.getB2DPoint(index2).getX(); + y2 = aPolygon.getB2DPoint(index2).getY(); + + aBuilder.appendLine(glm::vec2(x1, y1), glm::vec2(x2, y2)); } } } diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx index 6c76154ea498..3125642aa44e 100644 --- a/vcl/opengl/gdiimpl.cxx +++ b/vcl/opengl/gdiimpl.cxx @@ -731,27 +731,27 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin mpProgram->DrawArrays(GL_TRIANGLE_FAN, aVertices); CHECK_GL_ERROR(); - if( !blockAA && mrParent.getAntiAliasB2DDraw()) - { - // Make the edges antialiased by drawing the edge lines again with AA. - // TODO: If transparent drawing is set up, drawing the lines themselves twice - // may be a problem, if that is a real problem, the polygon areas itself needs to be - // masked out for this or something. + if( blockAA || !mrParent.getAntiAliasB2DDraw()) + return; + + // Make the edges antialiased by drawing the edge lines again with AA. + // TODO: If transparent drawing is set up, drawing the lines themselves twice + // may be a problem, if that is a real problem, the polygon areas itself needs to be + // masked out for this or something. #ifdef DBG_UTIL - assert( mProgramIsSolidColor ); + assert( mProgramIsSolidColor ); #endif - Color lastSolidColor = mProgramSolidColor; - double lastSolidTransparency = mProgramSolidTransparency; - if (UseLine(lastSolidColor, lastSolidTransparency, 1.0f, true)) + Color lastSolidColor = mProgramSolidColor; + double lastSolidTransparency = mProgramSolidTransparency; + if (UseLine(lastSolidColor, lastSolidTransparency, 1.0f, true)) + { + for( i = 0; i < nPoints; ++i ) { - for( i = 0; i < nPoints; ++i ) - { - const SalPoint& rPt1 = pPtAry[ i ]; - const SalPoint& rPt2 = pPtAry[ ( i + 1 ) % nPoints ]; - DrawLineSegment(rPt1.mnX, rPt1.mnY, rPt2.mnX, rPt2.mnY); - } - UseSolid( lastSolidColor, lastSolidTransparency ); + const SalPoint& rPt1 = pPtAry[ i ]; + const SalPoint& rPt2 = pPtAry[ ( i + 1 ) % nPoints ]; + DrawLineSegment(rPt1.mnX, rPt1.mnY, rPt2.mnX, rPt2.mnY); } + UseSolid( lastSolidColor, lastSolidTransparency ); } } @@ -776,27 +776,27 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const tools::Polygon& rPolygon, b mpProgram->DrawArrays(GL_TRIANGLE_FAN, aVertices); CHECK_GL_ERROR(); - if( !blockAA && mrParent.getAntiAliasB2DDraw()) - { - // Make the edges antialiased by drawing the edge lines again with AA. - // TODO: If transparent drawing is set up, drawing the lines themselves twice - // may be a problem, if that is a real problem, the polygon areas itself needs to be - // masked out for this or something. + if( blockAA || !mrParent.getAntiAliasB2DDraw()) + return; + + // Make the edges antialiased by drawing the edge lines again with AA. + // TODO: If transparent drawing is set up, drawing the lines themselves twice + // may be a problem, if that is a real problem, the polygon areas itself needs to be + // masked out for this or something. #ifdef DBG_UTIL - assert( mProgramIsSolidColor ); + assert( mProgramIsSolidColor ); #endif - Color lastSolidColor = mProgramSolidColor; - double lastSolidTransparency = mProgramSolidTransparency; - if (UseLine(lastSolidColor, lastSolidTransparency, 1.0f, true)) + Color lastSolidColor = mProgramSolidColor; + double lastSolidTransparency = mProgramSolidTransparency; + if (UseLine(lastSolidColor, lastSolidTransparency, 1.0f, true)) + { + for( i = 0; i < nPoints; ++i ) { - for( i = 0; i < nPoints; ++i ) - { - const Point& rPt1 = rPolygon.GetPoint( i ); - const Point& rPt2 = rPolygon.GetPoint(( i + 1 ) % nPoints ); - DrawLineSegment(rPt1.getX(), rPt1.getY(), rPt2.getX(), rPt2.getY()); - } - UseSolid( lastSolidColor, lastSolidTransparency ); + const Point& rPt1 = rPolygon.GetPoint( i ); + const Point& rPt2 = rPolygon.GetPoint(( i + 1 ) % nPoints ); + DrawLineSegment(rPt1.getX(), rPt1.getY(), rPt2.getX(), rPt2.getY()); } + UseSolid( lastSolidColor, lastSolidTransparency ); } } @@ -828,27 +828,27 @@ void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoi mpProgram->DrawArrays(GL_TRIANGLE_FAN, aVertices); CHECK_GL_ERROR(); - if( !blockAA && mrParent.getAntiAliasB2DDraw()) - { - // Make the edges antialiased by drawing the edge lines again with AA. - // TODO: If transparent drawing is set up, drawing the lines themselves twice - // may be a problem, if that is a real problem, the polygon areas itself needs to be - // masked out for this or something. + if( blockAA || !mrParent.getAntiAliasB2DDraw()) + return; + + // Make the edges antialiased by drawing the edge lines again with AA. + // TODO: If transparent drawing is set up, drawing the lines themselves twice + // may be a problem, if that is a real problem, the polygon areas itself needs to be + // masked out for this or something. #ifdef DBG_UTIL - assert( mProgramIsSolidColor ); + assert( mProgramIsSolidColor ); #endif - Color lastSolidColor = mProgramSolidColor; - double lastSolidTransparency = mProgramSolidTransparency; - if (UseLine(lastSolidColor, lastSolidTransparency, 1.0f, true)) + Color lastSolidColor = mProgramSolidColor; + double lastSolidTransparency = mProgramSolidTransparency; + if (UseLine(lastSolidColor, lastSolidTransparency, 1.0f, true)) + { + for( i = 0; i < nPoints; ++i ) { - for( i = 0; i < nPoints; ++i ) - { - const basegfx::B2DPoint& rPt1 = rPolygon.getB2DPoint( i ); - const basegfx::B2DPoint& rPt2 = rPolygon.getB2DPoint(( i + 1 ) % nPoints ); - DrawLineSegment(rPt1.getX(), rPt1.getY(), rPt2.getX(), rPt2.getY()); - } - UseSolid( lastSolidColor, lastSolidTransparency ); + const basegfx::B2DPoint& rPt1 = rPolygon.getB2DPoint( i ); + const basegfx::B2DPoint& rPt2 = rPolygon.getB2DPoint(( i + 1 ) % nPoints ); + DrawLineSegment(rPt1.getX(), rPt1.getY(), rPt2.getX(), rPt2.getY()); } + UseSolid( lastSolidColor, lastSolidTransparency ); } } diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx index 9f4acc0fc8eb..35e4098dafa2 100644 --- a/vcl/opengl/texture.cxx +++ b/vcl/opengl/texture.cxx @@ -169,39 +169,39 @@ GLuint ImplOpenGLTexture::AddStencil() ImplOpenGLTexture::~ImplOpenGLTexture() { VCL_GL_INFO( "~OpenGLTexture " << mnTexture ); - if( mnTexture != 0 ) + if( mnTexture == 0 ) + return; + + // During shutdown GL is already de-initialized, so we should not try to create a new context. + OpenGLZone aZone; + rtl::Reference<OpenGLContext> xContext = OpenGLContext::getVCLContext(false); + if( xContext.is() ) { - // During shutdown GL is already de-initialized, so we should not try to create a new context. - OpenGLZone aZone; - rtl::Reference<OpenGLContext> xContext = OpenGLContext::getVCLContext(false); - if( xContext.is() ) + // FIXME: this is really not optimal performance-wise. + + // Check we have been correctly un-bound from all framebuffers. + ImplSVData* pSVData = ImplGetSVData(); + rtl::Reference<OpenGLContext> pContext = pSVData->maGDIData.mpLastContext; + + if( pContext.is() ) { - // FIXME: this is really not optimal performance-wise. - - // Check we have been correctly un-bound from all framebuffers. - ImplSVData* pSVData = ImplGetSVData(); - rtl::Reference<OpenGLContext> pContext = pSVData->maGDIData.mpLastContext; - - if( pContext.is() ) - { - pContext->makeCurrent(); - pContext->UnbindTextureFromFramebuffers( mnTexture ); - } - - if( mnOptStencil != 0 ) - { - glDeleteRenderbuffers( 1, &mnOptStencil ); - mnOptStencil = 0; - } - auto& rState = pContext->state(); - rState.texture().unbindAndDelete(mnTexture); - mnTexture = 0; + pContext->makeCurrent(); + pContext->UnbindTextureFromFramebuffers( mnTexture ); } - else + + if( mnOptStencil != 0 ) { + glDeleteRenderbuffers( 1, &mnOptStencil ); mnOptStencil = 0; - mnTexture = 0; } + auto& rState = pContext->state(); + rState.texture().unbindAndDelete(mnTexture); + mnTexture = 0; + } + else + { + mnOptStencil = 0; + mnTexture = 0; } } diff --git a/vcl/opengl/x11/X11DeviceInfo.cxx b/vcl/opengl/x11/X11DeviceInfo.cxx index b75c22012380..f7c979ef77e6 100644 --- a/vcl/opengl/x11/X11DeviceInfo.cxx +++ b/vcl/opengl/x11/X11DeviceInfo.cxx @@ -252,27 +252,27 @@ void X11OpenGLDeviceInfo::GetData() } // read major.minor version numbers of the driver (not to be confused with the OpenGL version) - if (whereToReadVersionNumbers) + if (!whereToReadVersionNumbers) + return; + + // copy into writable buffer, for tokenization + strncpy(buf, whereToReadVersionNumbers, buf_size-1); + buf[buf_size-1] = 0; + bufptr = buf; + + // now try to read major.minor version numbers. In case of failure, gracefully exit: these numbers have + // been initialized as 0 anyways + char *token = strtok_wrapper(".", &bufptr); + if (token) { - // copy into writable buffer, for tokenization - strncpy(buf, whereToReadVersionNumbers, buf_size-1); - buf[buf_size-1] = 0; - bufptr = buf; - - // now try to read major.minor version numbers. In case of failure, gracefully exit: these numbers have - // been initialized as 0 anyways - char *token = strtok_wrapper(".", &bufptr); + mnMajorVersion = strtol(token, nullptr, 10); + token = strtok_wrapper(".", &bufptr); if (token) { - mnMajorVersion = strtol(token, nullptr, 10); + mnMinorVersion = strtol(token, nullptr, 10); token = strtok_wrapper(".", &bufptr); if (token) - { - mnMinorVersion = strtol(token, nullptr, 10); - token = strtok_wrapper(".", &bufptr); - if (token) - mnRevisionVersion = strtol(token, nullptr, 10); - } + mnRevisionVersion = strtol(token, nullptr, 10); } } } diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx index 0030a71a0544..81351e3beae3 100644 --- a/vcl/opengl/x11/gdiimpl.cxx +++ b/vcl/opengl/x11/gdiimpl.cxx @@ -431,21 +431,21 @@ void X11OpenGLContext::makeCurrent() void X11OpenGLContext::destroyCurrentContext() { - if(m_aGLWin.ctx) - { - std::vector<GLXContext>::iterator itr = std::remove( g_vShareList.begin(), g_vShareList.end(), m_aGLWin.ctx ); - if (itr != g_vShareList.end()) - g_vShareList.erase(itr); + if(!m_aGLWin.ctx) + return; - glXMakeCurrent(m_aGLWin.dpy, None, nullptr); - g_bAnyCurrent = false; - if( glGetError() != GL_NO_ERROR ) - { - SAL_WARN("vcl.opengl", "glError: " << glGetError()); - } - glXDestroyContext(m_aGLWin.dpy, m_aGLWin.ctx); - m_aGLWin.ctx = nullptr; + std::vector<GLXContext>::iterator itr = std::remove( g_vShareList.begin(), g_vShareList.end(), m_aGLWin.ctx ); + if (itr != g_vShareList.end()) + g_vShareList.erase(itr); + + glXMakeCurrent(m_aGLWin.dpy, None, nullptr); + g_bAnyCurrent = false; + if( glGetError() != GL_NO_ERROR ) + { + SAL_WARN("vcl.opengl", "glError: " << glGetError()); } + glXDestroyContext(m_aGLWin.dpy, m_aGLWin.ctx); + m_aGLWin.ctx = nullptr; } void X11OpenGLContext::init(Display* dpy, Window win, int screen) diff --git a/vcl/qt5/Qt5FilePicker.cxx b/vcl/qt5/Qt5FilePicker.cxx index d648a5d94b75..5e0f88412056 100644 --- a/vcl/qt5/Qt5FilePicker.cxx +++ b/vcl/qt5/Qt5FilePicker.cxx @@ -823,31 +823,31 @@ void SAL_CALL Qt5FilePicker::initialize(const uno::Sequence<uno::Any>& args) css::uno::Reference<css::awt::XWindow> xParentWindow; if (args.getLength() > 1) args[1] >>= xParentWindow; - if (xParentWindow.is()) - { - css::uno::Reference<css::awt::XSystemDependentWindowPeer> xSysWinPeer(xParentWindow, - css::uno::UNO_QUERY); - if (xSysWinPeer.is()) - { - // the sal_*Int8 handling is strange, but it's public API - no way around - css::uno::Sequence<sal_Int8> aProcessIdent(16); - rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8*>(aProcessIdent.getArray())); - uno::Any aAny = xSysWinPeer->getWindowHandle( - aProcessIdent, css::lang::SystemDependent::SYSTEM_XWINDOW); - css::awt::SystemDependentXWindow xSysWin; - aAny >>= xSysWin; - - const auto& pFrames = pSalInst->getFrames(); - const long aWindowHandle = xSysWin.WindowHandle; - const auto it = std::find_if(pFrames.begin(), pFrames.end(), - [&aWindowHandle](auto pFrame) -> bool { - const SystemEnvData* pData = pFrame->GetSystemData(); - return pData && long(pData->aWindow) == aWindowHandle; - }); - if (it != pFrames.end()) - m_pParentWidget = static_cast<Qt5Frame*>(*it)->asChild(); - } - } + if (!xParentWindow.is()) + return; + + css::uno::Reference<css::awt::XSystemDependentWindowPeer> xSysWinPeer(xParentWindow, + css::uno::UNO_QUERY); + if (!xSysWinPeer.is()) + return; + + // the sal_*Int8 handling is strange, but it's public API - no way around + css::uno::Sequence<sal_Int8> aProcessIdent(16); + rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8*>(aProcessIdent.getArray())); + uno::Any aAny + = xSysWinPeer->getWindowHandle(aProcessIdent, css::lang::SystemDependent::SYSTEM_XWINDOW); + css::awt::SystemDependentXWindow xSysWin; + aAny >>= xSysWin; + + const auto& pFrames = pSalInst->getFrames(); + const long aWindowHandle = xSysWin.WindowHandle; + const auto it + = std::find_if(pFrames.begin(), pFrames.end(), [&aWindowHandle](auto pFrame) -> bool { + const SystemEnvData* pData = pFrame->GetSystemData(); + return pData && long(pData->aWindow) == aWindowHandle; + }); + if (it != pFrames.end()) + m_pParentWidget = static_cast<Qt5Frame*>(*it)->asChild(); } void SAL_CALL Qt5FilePicker::cancel() { m_pFileDialog->reject(); } diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index ed3368ac3970..f008f4538bd7 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -547,35 +547,35 @@ void Qt5Frame::SetPosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt1 } } - if (nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y)) + if (!(nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y))) + return; + + if (m_pParent) { - if (m_pParent) - { - const SalFrameGeometry& aParentGeometry = m_pParent->maGeometry; - if (QGuiApplication::isRightToLeft()) - nX = aParentGeometry.nX + aParentGeometry.nWidth - nX - maGeometry.nWidth - 1; - else - nX += aParentGeometry.nX; - nY += aParentGeometry.nY; - - Qt5MainWindow* pTopLevel = m_pParent->GetTopLevelWindow(); - if (pTopLevel && pTopLevel->menuBar() && pTopLevel->menuBar()->isVisible()) - nY += round(pTopLevel->menuBar()->geometry().height() * devicePixelRatioF()); - } + const SalFrameGeometry& aParentGeometry = m_pParent->maGeometry; + if (QGuiApplication::isRightToLeft()) + nX = aParentGeometry.nX + aParentGeometry.nWidth - nX - maGeometry.nWidth - 1; + else + nX += aParentGeometry.nX; + nY += aParentGeometry.nY; - if (!(nFlags & SAL_FRAME_POSSIZE_X)) - nX = maGeometry.nX; - else if (!(nFlags & SAL_FRAME_POSSIZE_Y)) - nY = maGeometry.nY; + Qt5MainWindow* pTopLevel = m_pParent->GetTopLevelWindow(); + if (pTopLevel && pTopLevel->menuBar() && pTopLevel->menuBar()->isVisible()) + nY += round(pTopLevel->menuBar()->geometry().height() * devicePixelRatioF()); + } - // assume the reposition happened - // needed for calculations and will eventually be corrected by events later - maGeometry.nX = nX; - maGeometry.nY = nY; + if (!(nFlags & SAL_FRAME_POSSIZE_X)) + nX = maGeometry.nX; + else if (!(nFlags & SAL_FRAME_POSSIZE_Y)) + nY = maGeometry.nY; - m_bDefaultPos = false; - asChild()->move(round(nX / devicePixelRatioF()), round(nY / devicePixelRatioF())); - } + // assume the reposition happened + // needed for calculations and will eventually be corrected by events later + maGeometry.nX = nX; + maGeometry.nY = nY; + + m_bDefaultPos = false; + asChild()->move(round(nX / devicePixelRatioF()), round(nY / devicePixelRatioF())); } void Qt5Frame::GetClientSize(long& rWidth, long& rHeight) @@ -600,25 +600,25 @@ SalFrame* Qt5Frame::GetParent() const { return m_pParent; } void Qt5Frame::SetModal(bool bModal) { - if (isWindow()) - { - auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance)); - assert(pSalInst); - pSalInst->RunInMainThread([this, bModal]() { + if (!isWindow()) + return; - QWidget* const pChild = asChild(); - const bool bWasVisible = pChild->isVisible(); + auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance)); + assert(pSalInst); + pSalInst->RunInMainThread([this, bModal]() { - // modality change is only effective if the window is hidden - if (bWasVisible) - pChild->hide(); + QWidget* const pChild = asChild(); + const bool bWasVisible = pChild->isVisible(); - pChild->setWindowModality(bModal ? Qt::WindowModal : Qt::NonModal); + // modality change is only effective if the window is hidden + if (bWasVisible) + pChild->hide(); - if (bWasVisible) - pChild->show(); - }); - } + pChild->setWindowModality(bModal ? Qt::WindowModal : Qt::NonModal); + + if (bWasVisible) + pChild->show(); + }); } bool Qt5Frame::GetModal() const { return isWindow() && windowHandle()->isModal(); } @@ -1189,52 +1189,52 @@ void Qt5Frame::EndSetClipRegion() { m_bNullRegion = false; } void Qt5Frame::SetScreenNumber(unsigned int nScreen) { - if (isWindow()) + if (!isWindow()) + return; + + QWindow* const pWindow = windowHandle(); + if (!pWindow) + return; + + QList<QScreen*> screens = QApplication::screens(); + if (static_cast<int>(nScreen) < screens.size() || m_bFullScreenSpanAll) { - QWindow* const pWindow = windowHandle(); - if (pWindow) - { - QList<QScreen*> screens = QApplication::screens(); - if (static_cast<int>(nScreen) < screens.size() || m_bFullScreenSpanAll) - { - QRect screenGeo; - - if (!m_bFullScreenSpanAll) - { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - screenGeo = QApplication::desktop()->screenGeometry(nScreen); - SAL_WNODEPRECATED_DECLARATIONS_POP - pWindow->setScreen(QApplication::screens()[nScreen]); - } - else // special case: fullscreen over all available screens - { - assert(m_bFullScreen); - // left-most screen - SAL_WNODEPRECATED_DECLARATIONS_PUSH - int nLeftScreen = QApplication::desktop()->screenNumber(QPoint(0, 0)); - SAL_WNODEPRECATED_DECLARATIONS_POP - // entire virtual desktop - screenGeo = QApplication::screens()[nLeftScreen]->availableVirtualGeometry(); - pWindow->setScreen(QApplication::screens()[nLeftScreen]); - pWindow->setGeometry(screenGeo); - nScreen = nLeftScreen; - } - - // setScreen by itself has no effect, explicitly move the widget to - // the new screen - asChild()->move(screenGeo.topLeft()); - } - else - { - // index outta bounds, use primary screen - QScreen* primaryScreen = QApplication::primaryScreen(); - pWindow->setScreen(primaryScreen); - nScreen = static_cast<sal_uInt32>(screenNumber(primaryScreen)); - } + QRect screenGeo; - maGeometry.nDisplayScreenNumber = nScreen; + if (!m_bFullScreenSpanAll) + { + SAL_WNODEPRECATED_DECLARATIONS_PUSH + screenGeo = QApplication::desktop()->screenGeometry(nScreen); + SAL_WNODEPRECATED_DECLARATIONS_POP + pWindow->setScreen(QApplication::screens()[nScreen]); + } + else // special case: fullscreen over all available screens + { + assert(m_bFullScreen); + // left-most screen + SAL_WNODEPRECATED_DECLARATIONS_PUSH + int nLeftScreen = QApplication::desktop()->screenNumber(QPoint(0, 0)); + SAL_WNODEPRECATED_DECLARATIONS_POP + // entire virtual desktop + screenGeo = QApplication::screens()[nLeftScreen]->availableVirtualGeometry(); + pWindow->setScreen(QApplication::screens()[nLeftScreen]); + pWindow->setGeometry(screenGeo); + nScreen = nLeftScreen; } + + // setScreen by itself has no effect, explicitly move the widget to + // the new screen + asChild()->move(screenGeo.topLeft()); } + else + { + // index outta bounds, use primary screen + QScreen* primaryScreen = QApplication::primaryScreen(); + pWindow->setScreen(primaryScreen); + nScreen = static_cast<sal_uInt32>(screenNumber(primaryScreen)); + } + + maGeometry.nDisplayScreenNumber = nScreen; } void Qt5Frame::SetApplicationID(const OUString& rWMClass) diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx index 98615247035a..f7c2e480118c 100644 --- a/vcl/qt5/Qt5Menu.cxx +++ b/vcl/qt5/Qt5Menu.cxx @@ -356,21 +356,21 @@ void Qt5Menu::RemoveItem(unsigned nPos) { SolarMutexGuard aGuard; - if (nPos < maItems.size()) - { - Qt5MenuItem* pItem = maItems[nPos]; - pItem->mpAction.reset(); - pItem->mpMenu.reset(); + if (nPos >= maItems.size()) + return; - maItems.erase(maItems.begin() + nPos); + Qt5MenuItem* pItem = maItems[nPos]; + pItem->mpAction.reset(); + pItem->mpMenu.reset(); - // Recalculate action groups if necessary: - // if separator between two QActionGroups was removed, - // it may be needed to merge them - if (nPos > 0) - { - ReinitializeActionGroup(nPos - 1); - } + maItems.erase(maItems.begin() + nPos); + + // Recalculate action groups if necessary: + // if separator between two QActionGroups was removed, + // it may be needed to merge them + if (nPos > 0) + { + ReinitializeActionGroup(nPos - 1); } } @@ -421,26 +421,26 @@ void Qt5Menu::SetFrame(const SalFrame* pFrame) mpFrame->SetMenu(this); Qt5MainWindow* pMainWindow = mpFrame->GetTopLevelWindow(); - if (pMainWindow) + if (!pMainWindow) + return; + + mpQMenuBar = pMainWindow->menuBar(); + if (mpQMenuBar) { - mpQMenuBar = pMainWindow->menuBar(); - if (mpQMenuBar) + mpQMenuBar->clear(); + QPushButton* pButton + = static_cast<QPushButton*>(mpQMenuBar->cornerWidget(Qt::TopRightCorner)); + if (pButton && ((mpCloseButton != pButton) || !maCloseButtonConnection)) { - mpQMenuBar->clear(); - QPushButton* pButton - = static_cast<QPushButton*>(mpQMenuBar->cornerWidget(Qt::TopRightCorner)); - if (pButton && ((mpCloseButton != pButton) || !maCloseButtonConnection)) - { - maCloseButtonConnection - = connect(pButton, &QPushButton::clicked, this, &Qt5Menu::slotCloseDocument); - mpCloseButton = pButton; - } + maCloseButtonConnection + = connect(pButton, &QPushButton::clicked, this, &Qt5Menu::slotCloseDocument); + mpCloseButton = pButton; } + } - mpQMenu = nullptr; + mpQMenu = nullptr; - DoFullMenuUpdate(mpVCLMenu); - } + DoFullMenuUpdate(mpVCLMenu); } void Qt5Menu::DoFullMenuUpdate(Menu* pMenuBar) @@ -578,21 +578,21 @@ const Qt5Frame* Qt5Menu::GetFrame() const void Qt5Menu::slotMenuTriggered(Qt5MenuItem* pQItem) { - if (pQItem) - { - Qt5Menu* pSalMenu = pQItem->mpParentMenu; - Qt5Menu* pTopLevel = pSalMenu->GetTopLevel(); + if (!pQItem) + return; - Menu* pMenu = pSalMenu->GetMenu(); - auto mnId = pQItem->mnId; - - // HACK to allow HandleMenuCommandEvent to "not-set" the checked button - // LO expects a signal before an item state change, so reset the check item - if (pQItem->mpAction->isCheckable() - && (!pQItem->mpActionGroup || pQItem->mpActionGroup->actions().size() <= 1)) - pQItem->mpAction->setChecked(!pQItem->mpAction->isChecked()); - pTopLevel->GetMenu()->HandleMenuCommandEvent(pMenu, mnId); - } + Qt5Menu* pSalMenu = pQItem->mpParentMenu; + Qt5Menu* pTopLevel = pSalMenu->GetTopLevel(); + + Menu* pMenu = pSalMenu->GetMenu(); + auto mnId = pQItem->mnId; + + // HACK to allow HandleMenuCommandEvent to "not-set" the checked button + // LO expects a signal before an item state change, so reset the check item + if (pQItem->mpAction->isCheckable() + && (!pQItem->mpActionGroup || pQItem->mpActionGroup->actions().size() <= 1)) + pQItem->mpAction->setChecked(!pQItem->mpAction->isChecked()); + pTopLevel->GetMenu()->HandleMenuCommandEvent(pMenu, mnId); } void Qt5Menu::slotMenuAboutToShow(Qt5MenuItem* pQItem) diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx index a3df4315b668..cd8fca063a7e 100644 --- a/vcl/skia/SkiaHelper.cxx +++ b/vcl/skia/SkiaHelper.cxx @@ -145,52 +145,52 @@ static sk_app::VulkanWindowContext::SharedGrContext getTemporaryGrContext(); static void checkDeviceDenylisted(bool blockDisable = false) { static bool done = false; - if (!done) - { - SkiaZone zone; + if (done) + return; - switch (renderMethodToUse()) + SkiaZone zone; + + switch (renderMethodToUse()) + { + case RenderVulkan: { - case RenderVulkan: + // First try if a GrContext already exists. + sk_app::VulkanWindowContext::SharedGrContext grContext + = sk_app::VulkanWindowContext::getSharedGrContext(); + if (!grContext.getGrContext()) { - // First try if a GrContext already exists. - sk_app::VulkanWindowContext::SharedGrContext grContext - = sk_app::VulkanWindowContext::getSharedGrContext(); - if (!grContext.getGrContext()) - { - // This function is called from isVclSkiaEnabled(), which - // may be called when deciding which X11 visual to use, - // and that visual is normally needed when creating - // Skia's VulkanWindowContext, which is needed for the GrContext. - // Avoid the loop by creating a temporary GrContext - // that will use the default X11 visual (that shouldn't matter - // for just finding out information about Vulkan) and destroying - // the temporary context will clean up again. - grContext = getTemporaryGrContext(); - } - bool denylisted = true; // assume the worst - if (grContext.getGrContext()) // Vulkan was initialized properly - { - denylisted = isVulkanDenylisted( - sk_app::VulkanWindowContext::getPhysDeviceProperties()); - SAL_INFO("vcl.skia", "Vulkan denylisted: " << denylisted); - } - else - SAL_INFO("vcl.skia", "Vulkan could not be initialized"); - if (denylisted && !blockDisable) - { - disableRenderMethod(RenderVulkan); - writeSkiaRasterInfo(); - } - break; + // This function is called from isVclSkiaEnabled(), which + // may be called when deciding which X11 visual to use, + // and that visual is normally needed when creating + // Skia's VulkanWindowContext, which is needed for the GrContext. + // Avoid the loop by creating a temporary GrContext + // that will use the default X11 visual (that shouldn't matter + // for just finding out information about Vulkan) and destroying + // the temporary context will clean up again. + grContext = getTemporaryGrContext(); } - case RenderRaster: - SAL_INFO("vcl.skia", "Using Skia raster mode"); + bool denylisted = true; // assume the worst + if (grContext.getGrContext()) // Vulkan was initialized properly + { + denylisted + = isVulkanDenylisted(sk_app::VulkanWindowContext::getPhysDeviceProperties()); + SAL_INFO("vcl.skia", "Vulkan denylisted: " << denylisted); + } + else + SAL_INFO("vcl.skia", "Vulkan could not be initialized"); + if (denylisted && !blockDisable) + { + disableRenderMethod(RenderVulkan); writeSkiaRasterInfo(); - return; // software, never denylisted + } + break; } - done = true; + case RenderRaster: + SAL_INFO("vcl.skia", "Using Skia raster mode"); + writeSkiaRasterInfo(); + return; // software, never denylisted } + done = true; } static bool skiaSupportedByBackend = false; diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 7f8fa50aced3..0da11b1c57d8 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -120,21 +120,21 @@ void SkiaSalBitmap::CreateBitmapData() // and a VCL bitmap can change its grayscale status simply by changing the palette. // Moreover creating SkImage from SkBitmap does a data copy unless the bitmap is immutable. // So just always store pixels in our buffer and convert as necessary. - if (mScanlineSize != 0 && mPixelsSize.Height() != 0) - { - size_t allocate = mScanlineSize * mPixelsSize.Height(); + if (mScanlineSize == 0 || mPixelsSize.Height() == 0) + return; + + size_t allocate = mScanlineSize * mPixelsSize.Height(); #ifdef DBG_UTIL - allocate += sizeof(CANARY); + allocate += sizeof(CANARY); #endif - mBuffer = boost::make_shared_noinit<sal_uInt8[]>(allocate); + mBuffer = boost::make_shared_noinit<sal_uInt8[]>(allocate); #ifdef DBG_UTIL - // fill with random garbage - sal_uInt8* buffer = mBuffer.get(); - for (size_t i = 0; i < allocate; i++) - buffer[i] = (i & 0xFF); - memcpy(buffer + allocate - sizeof(CANARY), CANARY, sizeof(CANARY)); + // fill with random garbage + sal_uInt8* buffer = mBuffer.get(); + for (size_t i = 0; i < allocate; i++) + buffer[i] = (i & 0xFF); + memcpy(buffer + allocate - sizeof(CANARY), CANARY, sizeof(CANARY)); #endif - } } bool SkiaSalBitmap::Create(const SalBitmap& rSalBmp) diff --git a/vcl/skia/zone.cxx b/vcl/skia/zone.cxx index 50f5e1ea73a8..0271608f5ba4 100644 --- a/vcl/skia/zone.cxx +++ b/vcl/skia/zone.cxx @@ -26,23 +26,23 @@ void SkiaZone::hardDisable() { // protect ourselves from double calling etc. static bool bDisabled = false; - if (!bDisabled) - { - bDisabled = true; + if (bDisabled) + return; - // Instead of disabling Skia as a whole, only force the CPU-based - // raster mode, which should be safe as it does not use drivers. - std::shared_ptr<comphelper::ConfigurationChanges> xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::VCL::ForceSkiaRaster::set(true, xChanges); - xChanges->commit(); + bDisabled = true; - // Force synchronous config write - css::uno::Reference<css::util::XFlushable>( - css::configuration::theDefaultProvider::get(comphelper::getProcessComponentContext()), - css::uno::UNO_QUERY_THROW) - ->flush(); - } + // Instead of disabling Skia as a whole, only force the CPU-based + // raster mode, which should be safe as it does not use drivers. + std::shared_ptr<comphelper::ConfigurationChanges> xChanges( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::VCL::ForceSkiaRaster::set(true, xChanges); + xChanges->commit(); + + // Force synchronous config write + css::uno::Reference<css::util::XFlushable>( + css::configuration::theDefaultProvider::get(comphelper::getProcessComponentContext()), + css::uno::UNO_QUERY_THROW) + ->flush(); } void SkiaZone::checkDebug(int nUnchanged, const CrashWatchdogTimingsValues& aTimingValues) diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx index d9eaed56ce73..2b799dabf3af 100644 --- a/vcl/source/animate/Animation.cxx +++ b/vcl/source/animate/Animation.cxx @@ -239,26 +239,26 @@ void Animation::Draw(OutputDevice* pOut, const Point& rDestPt, const Size& rDest { const size_t nCount = maList.size(); - if (nCount) - { - AnimationBitmap* pObj = maList[std::min(mnPos, nCount - 1)].get(); + if (!nCount) + return; - if (pOut->GetConnectMetaFile() || (pOut->GetOutDevType() == OUTDEV_PRINTER)) - maList[0]->maBitmapEx.Draw(pOut, rDestPt, rDestSz); - else if (ANIMATION_TIMEOUT_ON_CLICK == pObj->mnWait) - pObj->maBitmapEx.Draw(pOut, rDestPt, rDestSz); - else - { - const size_t nOldPos = mnPos; - if (mbLoopTerminated) - const_cast<Animation*>(this)->mnPos = nCount - 1; + AnimationBitmap* pObj = maList[std::min(mnPos, nCount - 1)].get(); - { - ImplAnimView{ const_cast<Animation*>(this), pOut, rDestPt, rDestSz, 0 }; - } + if (pOut->GetConnectMetaFile() || (pOut->GetOutDevType() == OUTDEV_PRINTER)) + maList[0]->maBitmapEx.Draw(pOut, rDestPt, rDestSz); + else if (ANIMATION_TIMEOUT_ON_CLICK == pObj->mnWait) + pObj->maBitmapEx.Draw(pOut, rDestPt, rDestSz); + else + { + const size_t nOldPos = mnPos; + if (mbLoopTerminated) + const_cast<Animation*>(this)->mnPos = nCount - 1; - const_cast<Animation*>(this)->mnPos = nOldPos; + { + ImplAnimView{ const_cast<Animation*>(this), pOut, rDestPt, rDestSz, 0 }; } + + const_cast<Animation*>(this)->mnPos = nOldPos; } } @@ -499,33 +499,31 @@ void Animation::Mirror(BmpMirrorFlags nMirrorFlags) bool bRet; - if (!IsInAnimation() && !maList.empty()) - { - bRet = true; + if (IsInAnimation() || maList.empty()) + return; + + bRet = true; + + if (nMirrorFlags == BmpMirrorFlags::NONE) + return; - if (nMirrorFlags != BmpMirrorFlags::NONE) + for (size_t i = 0, n = maList.size(); (i < n) && bRet; ++i) + { + AnimationBitmap* pStepBmp = maList[i].get(); + bRet = pStepBmp->maBitmapEx.Mirror(nMirrorFlags); + if (bRet) { - for (size_t i = 0, n = maList.size(); (i < n) && bRet; ++i) - { - AnimationBitmap* pStepBmp = maList[i].get(); - bRet = pStepBmp->maBitmapEx.Mirror(nMirrorFlags); - if (bRet) - { - if (nMirrorFlags & BmpMirrorFlags::Horizontal) - pStepBmp->maPositionPixel.setX(maGlobalSize.Width() - - pStepBmp->maPositionPixel.X() - - pStepBmp->maSizePixel.Width()); - - if (nMirrorFlags & BmpMirrorFlags::Vertical) - pStepBmp->maPositionPixel.setY(maGlobalSize.Height() - - pStepBmp->maPositionPixel.Y() - - pStepBmp->maSizePixel.Height()); - } - } + if (nMirrorFlags & BmpMirrorFlags::Horizontal) + pStepBmp->maPositionPixel.setX(maGlobalSize.Width() - pStepBmp->maPositionPixel.X() + - pStepBmp->maSizePixel.Width()); - maBitmapEx.Mirror(nMirrorFlags); + if (nMirrorFlags & BmpMirrorFlags::Vertical) + pStepBmp->maPositionPixel.setY(maGlobalSize.Height() - pStepBmp->maPositionPixel.Y() + - pStepBmp->maSizePixel.Height()); } } + + maBitmapEx.Mirror(nMirrorFlags); } void Animation::Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent, @@ -535,20 +533,19 @@ void Animation::Adjust(short nLuminancePercent, short nContrastPercent, short nC bool bRet; - if (!IsInAnimation() && !maList.empty()) - { - bRet = true; + if (IsInAnimation() || maList.empty()) + return; - for (size_t i = 0, n = maList.size(); (i < n) && bRet; ++i) - { - bRet = maList[i]->maBitmapEx.Adjust(nLuminancePercent, nContrastPercent, - nChannelRPercent, nChannelGPercent, - nChannelBPercent, fGamma, bInvert); - } + bRet = true; - maBitmapEx.Adjust(nLuminancePercent, nContrastPercent, nChannelRPercent, nChannelGPercent, - nChannelBPercent, fGamma, bInvert); + for (size_t i = 0, n = maList.size(); (i < n) && bRet; ++i) + { + bRet = maList[i]->maBitmapEx.Adjust(nLuminancePercent, nContrastPercent, nChannelRPercent, + nChannelGPercent, nChannelBPercent, fGamma, bInvert); } + + maBitmapEx.Adjust(nLuminancePercent, nContrastPercent, nChannelRPercent, nChannelGPercent, + nChannelBPercent, fGamma, bInvert); } SvStream& WriteAnimation(SvStream& rOStm, const Animation& rAnimation) diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx index ebe7588c562f..acbab4bb6b85 100644 --- a/vcl/source/app/help.cxx +++ b/vcl/source/app/help.cxx @@ -402,19 +402,19 @@ void HelpTextWindow::Paint( vcl::RenderContext& rRenderContext, const tools::Rec } // border - if (!bNativeOK) + if (bNativeOK) + return; + + Size aSz = GetOutputSizePixel(); + rRenderContext.DrawRect(tools::Rectangle(Point(), aSz)); + if (mnHelpWinStyle == HELPWINSTYLE_BALLOON) { - Size aSz = GetOutputSizePixel(); - rRenderContext.DrawRect(tools::Rectangle(Point(), aSz)); - if (mnHelpWinStyle == HELPWINSTYLE_BALLOON) - { - aSz.AdjustWidth( -2 ); - aSz.AdjustHeight( -2 ); - Color aColor(rRenderContext.GetLineColor()); - rRenderContext.SetLineColor(COL_GRAY); - rRenderContext.DrawRect(tools::Rectangle(Point(1, 1), aSz)); - rRenderContext.SetLineColor(aColor); - } + aSz.AdjustWidth( -2 ); + aSz.AdjustHeight( -2 ); + Color aColor(rRenderContext.GetLineColor()); + rRenderContext.SetLineColor(COL_GRAY); + rRenderContext.DrawRect(tools::Rectangle(Point(1, 1), aSz)); + rRenderContext.SetLineColor(aColor); } } diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 37b6f595e178..3c95b11eeb33 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1205,28 +1205,28 @@ public: void CollectChildren(const vcl::Window& rCurrent, const basegfx::B2IPoint& rTopLeft, weld::ScreenShotCollection& rControlDataCollection) { - if (rCurrent.IsVisible()) + if (!rCurrent.IsVisible()) + return; + + const Point aCurrentPos(rCurrent.GetPosPixel()); + const Size aCurrentSize(rCurrent.GetSizePixel()); + const basegfx::B2IPoint aCurrentTopLeft(rTopLeft.getX() + aCurrentPos.X(), + rTopLeft.getY() + aCurrentPos.Y()); + const basegfx::B2IRange aCurrentRange( + aCurrentTopLeft, + aCurrentTopLeft + basegfx::B2IPoint(aCurrentSize.Width(), aCurrentSize.Height())); + + if (!aCurrentRange.isEmpty()) { - const Point aCurrentPos(rCurrent.GetPosPixel()); - const Size aCurrentSize(rCurrent.GetSizePixel()); - const basegfx::B2IPoint aCurrentTopLeft(rTopLeft.getX() + aCurrentPos.X(), - rTopLeft.getY() + aCurrentPos.Y()); - const basegfx::B2IRange aCurrentRange( - aCurrentTopLeft, - aCurrentTopLeft + basegfx::B2IPoint(aCurrentSize.Width(), aCurrentSize.Height())); + rControlDataCollection.emplace_back(rCurrent.GetHelpId(), aCurrentRange); + } - if (!aCurrentRange.isEmpty()) + for (sal_uInt16 a(0); a < rCurrent.GetChildCount(); a++) + { + vcl::Window* pChild = rCurrent.GetChild(a); + if (nullptr != pChild) { - rControlDataCollection.emplace_back(rCurrent.GetHelpId(), aCurrentRange); - } - - for (sal_uInt16 a(0); a < rCurrent.GetChildCount(); a++) - { - vcl::Window* pChild = rCurrent.GetChild(a); - if (nullptr != pChild) - { - CollectChildren(*pChild, aCurrentTopLeft, rControlDataCollection); - } + CollectChildren(*pChild, aCurrentTopLeft, rControlDataCollection); } } } @@ -4651,21 +4651,22 @@ public: assert(col >= 0 && "cannot sort on expander column"); LclHeaderTabListBox* pHeaderBox = dynamic_cast<LclHeaderTabListBox*>(m_xTreeView.get()); - if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr) + HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr; + if (!pHeaderBar) + return; + + sal_uInt16 nTextId = pHeaderBar->GetItemId(col); + HeaderBarItemBits nBits = pHeaderBar->GetItemBits(nTextId); + nBits &= ~HeaderBarItemBits::UPARROW; + nBits &= ~HeaderBarItemBits::DOWNARROW; + if (eState != TRISTATE_INDET) { - sal_uInt16 nTextId = pHeaderBar->GetItemId(col); - HeaderBarItemBits nBits = pHeaderBar->GetItemBits(nTextId); - nBits &= ~HeaderBarItemBits::UPARROW; - nBits &= ~HeaderBarItemBits::DOWNARROW; - if (eState != TRISTATE_INDET) - { - if (eState == TRISTATE_TRUE) - nBits |= HeaderBarItemBits::DOWNARROW; - else - nBits |= HeaderBarItemBits::UPARROW; - } - pHeaderBar->SetItemBits(nTextId, nBits); + if (eState == TRISTATE_TRUE) + nBits |= HeaderBarItemBits::DOWNARROW; + else + nBits |= HeaderBarItemBits::UPARROW; } + pHeaderBar->SetItemBits(nTextId, nBits); } virtual TriState get_sort_indicator(int col) const override @@ -6381,25 +6382,25 @@ IMPL_LINK(SalInstanceEntryTreeView, KeyPressListener, VclWindowEvent&, rEvent, v return; const KeyEvent& rKeyEvent = *static_cast<KeyEvent*>(rEvent.GetData()); sal_uInt16 nKeyCode = rKeyEvent.GetKeyCode().GetCode(); - if (nKeyCode == KEY_UP || nKeyCode == KEY_DOWN || nKeyCode == KEY_PAGEUP - || nKeyCode == KEY_PAGEDOWN) + if (!(nKeyCode == KEY_UP || nKeyCode == KEY_DOWN || nKeyCode == KEY_PAGEUP + || nKeyCode == KEY_PAGEDOWN)) + return; + + m_pTreeView->disable_notify_events(); + auto& rListBox = m_pTreeView->getTreeView(); + if (!rListBox.FirstSelected()) { - m_pTreeView->disable_notify_events(); - auto& rListBox = m_pTreeView->getTreeView(); - if (!rListBox.FirstSelected()) - { - if (SvTreeListEntry* pEntry = rListBox.First()) - rListBox.Select(pEntry, true); - } - else - rListBox.KeyInput(rKeyEvent); - m_xEntry->set_text(m_xTreeView->get_selected_text()); - m_xEntry->select_region(0, -1); - m_pTreeView->enable_notify_events(); - m_bTreeChange = true; - m_pEntry->fire_signal_changed(); - m_bTreeChange = false; + if (SvTreeListEntry* pEntry = rListBox.First()) + rListBox.Select(pEntry, true); } + else + rListBox.KeyInput(rKeyEvent); + m_xEntry->set_text(m_xTreeView->get_selected_text()); + m_xEntry->select_region(0, -1); + m_pTreeView->enable_notify_events(); + m_bTreeChange = true; + m_pEntry->fire_signal_changed(); + m_bTreeChange = false; } IMPL_LINK(SalInstanceEntryTreeView, AutocompleteHdl, Edit&, rEdit, void) @@ -6853,37 +6854,37 @@ void SalInstanceWindow::help() weld::Widget* pSource = xTemp ? xTemp.get() : this; bool bRunNormalHelpRequest = !m_aHelpRequestHdl.IsSet() || m_aHelpRequestHdl.Call(*pSource); Help* pHelp = bRunNormalHelpRequest ? Application::GetHelp() : nullptr; - if (pHelp) - { - // tdf#126007, there's a nice fallback route for offline help where - // the current page of a notebook will get checked when the help - // button is pressed and there was no help for the dialog found. - // - // But for online help that route doesn't get taken, so bodge this here - // by using the page help id if available and if the help button itself - // was the original id - if (m_pBuilder && sHelpId.endsWith("/help")) + if (!pHelp) + return; + + // tdf#126007, there's a nice fallback route for offline help where + // the current page of a notebook will get checked when the help + // button is pressed and there was no help for the dialog found. + // + // But for online help that route doesn't get taken, so bodge this here + // by using the page help id if available and if the help button itself + // was the original id + if (m_pBuilder && sHelpId.endsWith("/help")) + { + OString sPageId = m_pBuilder->get_current_page_help_id(); + if (!sPageId.isEmpty()) + sHelpId = sPageId; + else { - OString sPageId = m_pBuilder->get_current_page_help_id(); - if (!sPageId.isEmpty()) - sHelpId = sPageId; - else + // tdf#129068 likewise the help for the wrapping dialog is less + // helpful than the help for the content area could be + vcl::Window* pContentArea = nullptr; + if (::Dialog* pDialog = dynamic_cast<::Dialog*>(m_xWindow.get())) + pContentArea = pDialog->get_content_area(); + if (pContentArea) { - // tdf#129068 likewise the help for the wrapping dialog is less - // helpful than the help for the content area could be - vcl::Window* pContentArea = nullptr; - if (::Dialog* pDialog = dynamic_cast<::Dialog*>(m_xWindow.get())) - pContentArea = pDialog->get_content_area(); - if (pContentArea) - { - vcl::Window* pContentWidget = pContentArea->GetWindow(GetWindowType::LastChild); - if (pContentWidget) - sHelpId = pContentWidget->GetHelpId(); - } + vcl::Window* pContentWidget = pContentArea->GetWindow(GetWindowType::LastChild); + if (pContentWidget) + sHelpId = pContentWidget->GetHelpId(); } } - pHelp->Start(OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), pSource); } + pHelp->Start(OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), pSource); } //iterate upwards through the hierarchy from this widgets through its parents diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 8e18213f412a..340aebf92435 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -2864,20 +2864,20 @@ void AllSettings::SetLanguageTag(const OUString& rLanguage, bool bCanonicalize) void AllSettings::SetLanguageTag( const LanguageTag& rLanguageTag ) { - if (mxData->maLocale != rLanguageTag) - { - CopyData(); + if (mxData->maLocale == rLanguageTag) + return; - mxData->maLocale = rLanguageTag; + CopyData(); - if ( mxData->mpLocaleDataWrapper ) - { - mxData->mpLocaleDataWrapper.reset(); - } - if ( mxData->mpI18nHelper ) - { - mxData->mpI18nHelper.reset(); - } + mxData->maLocale = rLanguageTag; + + if ( mxData->mpLocaleDataWrapper ) + { + mxData->mpLocaleDataWrapper.reset(); + } + if ( mxData->mpI18nHelper ) + { + mxData->mpI18nHelper.reset(); } } diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 60bc22d12c6a..80b92f34de5d 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -1686,19 +1686,19 @@ void registerPollCallbacks( void unregisterPollCallbacks() { ImplSVData * pSVData = ImplGetSVData(); - if (pSVData) - { - // Not hyper-elegant - but in the case of Android & unipoll we need to detach - // this thread from the JVM's clutches to avoid a crash closing document - if (pSVData->mpPollClosure && pSVData->mpDefInst) - pSVData->mpDefInst->releaseMainThread(); - - // Just set mpPollClosure to null as that is what calling this means, that the callback data - // points to an object that no longer exists. In particular, don't set - // pSVData->mpPollCallback to nullptr as that is used to detect whether Unipoll is in use in - // isUnipoll(). - pSVData->mpPollClosure = nullptr; - } + if (!pSVData) + return; + + // Not hyper-elegant - but in the case of Android & unipoll we need to detach + // this thread from the JVM's clutches to avoid a crash closing document + if (pSVData->mpPollClosure && pSVData->mpDefInst) + pSVData->mpDefInst->releaseMainThread(); + + // Just set mpPollClosure to null as that is what calling this means, that the callback data + // points to an object that no longer exists. In particular, don't set + // pSVData->mpPollCallback to nullptr as that is used to detect whether Unipoll is in use in + // isUnipoll(). + pSVData->mpPollClosure = nullptr; } bool isUnipoll() diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx index 16772724c782..41f9f1bd7af4 100644 --- a/vcl/source/app/svdata.cxx +++ b/vcl/source/app/svdata.cxx @@ -388,19 +388,19 @@ void SetSVWinData(ImplSVWinData* pSVWinData) ImplSVData* pSVData = ImplGetSVData(); assert(pSVData != nullptr); - if (pSVData->mpWinData != pSVWinData) + if (pSVData->mpWinData == pSVWinData) + return; + + // If current one is the static, clean it up to avoid having lingering references. + if (pSVData->mpWinData == &private_aImplSVWinData::get()) { - // If current one is the static, clean it up to avoid having lingering references. - if (pSVData->mpWinData == &private_aImplSVWinData::get()) - { - pSVData->mpWinData->mpFocusWin.reset(); - } + pSVData->mpWinData->mpFocusWin.reset(); + } - pSVData->mpWinData = pSVWinData; - if (pSVData->mpWinData == nullptr) - { - pSVData->mpWinData = &private_aImplSVWinData::get(); // Never leave it null. - } + pSVData->mpWinData = pSVWinData; + if (pSVData->mpWinData == nullptr) + { + pSVData->mpWinData = &private_aImplSVWinData::get(); // Never leave it null. } } @@ -453,19 +453,19 @@ void SetSVHelpData(ImplSVHelpData* pSVHelpData) return; ImplSVData* pSVData = ImplGetSVData(); - if (pSVData->mpHelpData != pSVHelpData) + if (pSVData->mpHelpData == pSVHelpData) + return; + + // If current one is the static, clean it up to avoid having lingering references. + if (pSVData->mpHelpData == &private_aImplSVHelpData::get()) { - // If current one is the static, clean it up to avoid having lingering references. - if (pSVData->mpHelpData == &private_aImplSVHelpData::get()) - { - pSVData->mpHelpData->mpHelpWin.reset(); - } + pSVData->mpHelpData->mpHelpWin.reset(); + } - pSVData->mpHelpData = pSVHelpData; - if (pSVData->mpHelpData == nullptr) - { - pSVData->mpHelpData = &private_aImplSVHelpData::get(); // Never leave it null. - } + pSVData->mpHelpData = pSVHelpData; + if (pSVData->mpHelpData == nullptr) + { + pSVData->mpHelpData = &private_aImplSVHelpData::get(); // Never leave it null. } } diff --git a/vcl/source/app/unohelp.cxx b/vcl/source/app/unohelp.cxx index 6d9e6f31abe5..f08e54131259 100644 --- a/vcl/source/app/unohelp.cxx +++ b/vcl/source/app/unohelp.cxx @@ -48,20 +48,19 @@ uno::Reference < i18n::XCharacterClassification > vcl::unohelper::CreateCharacte void vcl::unohelper::NotifyAccessibleStateEventGlobally( const css::accessibility::AccessibleEventObject& rEventObject ) { css::uno::Reference< css::awt::XExtendedToolkit > xExtToolkit( Application::GetVCLToolkit(), uno::UNO_QUERY ); - if ( xExtToolkit.is() ) + if ( !xExtToolkit.is() ) + return; + + // Only for focus events + sal_Int16 nType = css::accessibility::AccessibleStateType::INVALID; + rEventObject.NewValue >>= nType; + if ( nType == css::accessibility::AccessibleStateType::FOCUSED ) + xExtToolkit->fireFocusGained( rEventObject.Source ); + else { - // Only for focus events - sal_Int16 nType = css::accessibility::AccessibleStateType::INVALID; - rEventObject.NewValue >>= nType; + rEventObject.OldValue >>= nType; if ( nType == css::accessibility::AccessibleStateType::FOCUSED ) - xExtToolkit->fireFocusGained( rEventObject.Source ); - else - { - rEventObject.OldValue >>= nType; - if ( nType == css::accessibility::AccessibleStateType::FOCUSED ) - xExtToolkit->fireFocusLost( rEventObject.Source ); - } - + xExtToolkit->fireFocusLost( rEventObject.Source ); } } diff --git a/vcl/source/bitmap/Octree.cxx b/vcl/source/bitmap/Octree.cxx index 44f911ef0c92..b39e5a1673f2 100644 --- a/vcl/source/bitmap/Octree.cxx +++ b/vcl/source/bitmap/Octree.cxx @@ -40,45 +40,45 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors) const BitmapReadAccess* pAccess = &rReadAcc; sal_uLong nMax(nColors); - if (!!*pAccess) - { - const long nWidth = pAccess->Width(); - const long nHeight = pAccess->Height(); + if (!*pAccess) + return; + + const long nWidth = pAccess->Width(); + const long nHeight = pAccess->Height(); - if (pAccess->HasPalette()) + if (pAccess->HasPalette()) + { + for (long nY = 0; nY < nHeight; nY++) { - for (long nY = 0; nY < nHeight; nY++) + Scanline pScanline = pAccess->GetScanline(nY); + for (long nX = 0; nX < nWidth; nX++) { - Scanline pScanline = pAccess->GetScanline(nY); - for (long nX = 0; nX < nWidth; nX++) - { - mpColor = &pAccess->GetPaletteColor(pAccess->GetIndexFromData(pScanline, nX)); - mnLevel = 0; - add(pTree); - - while (mnLeafCount > nMax) - reduce(); - } + mpColor = &pAccess->GetPaletteColor(pAccess->GetIndexFromData(pScanline, nX)); + mnLevel = 0; + add(pTree); + + while (mnLeafCount > nMax) + reduce(); } } - else - { - BitmapColor aColor; + } + else + { + BitmapColor aColor; - mpColor = &aColor; + mpColor = &aColor; - for (long nY = 0; nY < nHeight; nY++) + for (long nY = 0; nY < nHeight; nY++) + { + Scanline pScanline = pAccess->GetScanline(nY); + for (long nX = 0; nX < nWidth; nX++) { - Scanline pScanline = pAccess->GetScanline(nY); - for (long nX = 0; nX < nWidth; nX++) - { - aColor = pAccess->GetPixelFromData(pScanline, nX); - mnLevel = 0; - add(pTree); - - while (mnLeafCount > nMax) - reduce(); - } + aColor = pAccess->GetPixelFromData(pScanline, nX); + mnLevel = 0; + add(pTree); + + while (mnLeafCount > nMax) + reduce(); } } } diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx index 4da73a65d3cc..242f4a3a958c 100644 --- a/vcl/source/bitmap/bitmap.cxx +++ b/vcl/source/bitmap/bitmap.cxx @@ -57,63 +57,63 @@ Bitmap::Bitmap(std::shared_ptr<SalBitmap> const & pSalBitmap) Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalette* pPal ) { - if (rSizePixel.Width() && rSizePixel.Height()) - { - BitmapPalette aPal; - BitmapPalette* pRealPal = nullptr; + if (!(rSizePixel.Width() && rSizePixel.Height())) + return; + + BitmapPalette aPal; + BitmapPalette* pRealPal = nullptr; - if( nBitCount <= 8 ) + if( nBitCount <= 8 ) + { + if( !pPal ) { - if( !pPal ) + if( 1 == nBitCount ) { - if( 1 == nBitCount ) - { - aPal.SetEntryCount( 2 ); - aPal[ 0 ] = COL_BLACK; - aPal[ 1 ] = COL_WHITE; - } - else if( ( 4 == nBitCount ) || ( 8 == nBitCount ) ) + aPal.SetEntryCount( 2 ); + aPal[ 0 ] = COL_BLACK; + aPal[ 1 ] = COL_WHITE; + } + else if( ( 4 == nBitCount ) || ( 8 == nBitCount ) ) + { + aPal.SetEntryCount( 1 << nBitCount ); + aPal[ 0 ] = COL_BLACK; + aPal[ 1 ] = COL_BLUE; + aPal[ 2 ] = COL_GREEN; + aPal[ 3 ] = COL_CYAN; + aPal[ 4 ] = COL_RED; + aPal[ 5 ] = COL_MAGENTA; + aPal[ 6 ] = COL_BROWN; + aPal[ 7 ] = COL_GRAY; + aPal[ 8 ] = COL_LIGHTGRAY; + aPal[ 9 ] = COL_LIGHTBLUE; + aPal[ 10 ] = COL_LIGHTGREEN; + aPal[ 11 ] = COL_LIGHTCYAN; + aPal[ 12 ] = COL_LIGHTRED; + aPal[ 13 ] = COL_LIGHTMAGENTA; + aPal[ 14 ] = COL_YELLOW; + aPal[ 15 ] = COL_WHITE; + + // Create dither palette + if( 8 == nBitCount ) { - aPal.SetEntryCount( 1 << nBitCount ); - aPal[ 0 ] = COL_BLACK; - aPal[ 1 ] = COL_BLUE; - aPal[ 2 ] = COL_GREEN; - aPal[ 3 ] = COL_CYAN; - aPal[ 4 ] = COL_RED; - aPal[ 5 ] = COL_MAGENTA; - aPal[ 6 ] = COL_BROWN; - aPal[ 7 ] = COL_GRAY; - aPal[ 8 ] = COL_LIGHTGRAY; - aPal[ 9 ] = COL_LIGHTBLUE; - aPal[ 10 ] = COL_LIGHTGREEN; - aPal[ 11 ] = COL_LIGHTCYAN; - aPal[ 12 ] = COL_LIGHTRED; - aPal[ 13 ] = COL_LIGHTMAGENTA; - aPal[ 14 ] = COL_YELLOW; - aPal[ 15 ] = COL_WHITE; - - // Create dither palette - if( 8 == nBitCount ) - { - sal_uInt16 nActCol = 16; + sal_uInt16 nActCol = 16; - for( sal_uInt16 nB = 0; nB < 256; nB += 51 ) - for( sal_uInt16 nG = 0; nG < 256; nG += 51 ) - for( sal_uInt16 nR = 0; nR < 256; nR += 51 ) - aPal[ nActCol++ ] = BitmapColor( static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG), static_cast<sal_uInt8>(nB) ); + for( sal_uInt16 nB = 0; nB < 256; nB += 51 ) + for( sal_uInt16 nG = 0; nG < 256; nG += 51 ) + for( sal_uInt16 nR = 0; nR < 256; nR += 51 ) + aPal[ nActCol++ ] = BitmapColor( static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG), static_cast<sal_uInt8>(nB) ); - // Set standard Office colors - aPal[ nActCol++ ] = BitmapColor( 0, 184, 255 ); - } + // Set standard Office colors + aPal[ nActCol++ ] = BitmapColor( 0, 184, 255 ); } } - else - pRealPal = const_cast<BitmapPalette*>(pPal); } - - mxSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap(); - mxSalBmp->Create( rSizePixel, nBitCount, pRealPal ? *pRealPal : aPal ); + else + pRealPal = const_cast<BitmapPalette*>(pPal); } + + mxSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap(); + mxSalBmp->Create( rSizePixel, nBitCount, pRealPal ? *pRealPal : aPal ); } #ifdef DBG_UTIL diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index b58b8d9fe019..3015c65f1b0c 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -633,30 +633,30 @@ void PushButton::ImplInitSettings( bool bBackground ) { Button::ImplInitSettings(); - if ( bBackground ) + if ( !bBackground ) + return; + + SetBackground(); + // #i38498#: do not check for GetParent()->IsChildTransparentModeEnabled() + // otherwise the formcontrol button will be overdrawn due to ParentClipMode::NoClip + // for radio and checkbox this is ok as they should appear transparent in documents + if ( IsNativeControlSupported( ControlType::Pushbutton, ControlPart::Entire ) || + (GetStyle() & WB_FLATBUTTON) != 0 ) { - SetBackground(); - // #i38498#: do not check for GetParent()->IsChildTransparentModeEnabled() - // otherwise the formcontrol button will be overdrawn due to ParentClipMode::NoClip - // for radio and checkbox this is ok as they should appear transparent in documents - if ( IsNativeControlSupported( ControlType::Pushbutton, ControlPart::Entire ) || - (GetStyle() & WB_FLATBUTTON) != 0 ) - { - EnableChildTransparentMode(); - SetParentClipMode( ParentClipMode::NoClip ); - SetPaintTransparent( true ); - - if ((GetStyle() & WB_FLATBUTTON) == 0) - mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects; - else - mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRectsForFlatButtons; - } + EnableChildTransparentMode(); + SetParentClipMode( ParentClipMode::NoClip ); + SetPaintTransparent( true ); + + if ((GetStyle() & WB_FLATBUTTON) == 0) + mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects; else - { - EnableChildTransparentMode( false ); - SetParentClipMode(); - SetPaintTransparent( false ); - } + mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRectsForFlatButtons; + } + else + { + EnableChildTransparentMode( false ); + SetParentClipMode(); + SetPaintTransparent( false ); } } @@ -1032,31 +1032,31 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext) ShowFocus(ImplGetFocusRect()); } - if (!bNativeOK) + if (bNativeOK) + return; + + // draw PushButtonFrame, aInRect has content size afterwards + if (GetStyle() & WB_FLATBUTTON) { - // draw PushButtonFrame, aInRect has content size afterwards - if (GetStyle() & WB_FLATBUTTON) - { - tools::Rectangle aTempRect(aInRect); - if (bRollOver) - ImplDrawPushButtonFrame(rRenderContext, aTempRect, nButtonStyle); - aInRect.AdjustLeft(2 ); - aInRect.AdjustTop(2 ); - aInRect.AdjustRight( -2 ); - aInRect.AdjustBottom( -2 ); - } - else - { - ImplDrawPushButtonFrame(rRenderContext, aInRect, nButtonStyle); - } + tools::Rectangle aTempRect(aInRect); + if (bRollOver) + ImplDrawPushButtonFrame(rRenderContext, aTempRect, nButtonStyle); + aInRect.AdjustLeft(2 ); + aInRect.AdjustTop(2 ); + aInRect.AdjustRight( -2 ); + aInRect.AdjustBottom( -2 ); + } + else + { + ImplDrawPushButtonFrame(rRenderContext, aInRect, nButtonStyle); + } - // draw content - ImplDrawPushButtonContent(&rRenderContext, DrawFlags::NONE, aInRect, bDrawMenuSep, nButtonStyle); + // draw content + ImplDrawPushButtonContent(&rRenderContext, DrawFlags::NONE, aInRect, bDrawMenuSep, nButtonStyle); - if (HasFocus()) - { - ShowFocus(ImplGetFocusRect()); - } + if (HasFocus()) + { + ShowFocus(ImplGetFocusRect()); } } @@ -1137,22 +1137,22 @@ PushButton::PushButton( vcl::Window* pParent, WinBits nStyle ) : void PushButton::MouseButtonDown( const MouseEvent& rMEvt ) { - if ( rMEvt.IsLeft() && - ImplHitTestPushButton( this, rMEvt.GetPosPixel() ) ) - { - StartTrackingFlags nTrackFlags = StartTrackingFlags::NONE; + if ( !(rMEvt.IsLeft() && + ImplHitTestPushButton( this, rMEvt.GetPosPixel() )) ) + return; - if ( ( GetStyle() & WB_REPEAT ) && - ! ( GetStyle() & WB_TOGGLE ) ) - nTrackFlags |= StartTrackingFlags::ButtonRepeat; + StartTrackingFlags nTrackFlags = StartTrackingFlags::NONE; - GetButtonState() |= DrawButtonFlags::Pressed; - Invalidate(); - StartTracking( nTrackFlags ); + if ( ( GetStyle() & WB_REPEAT ) && + ! ( GetStyle() & WB_TOGGLE ) ) + nTrackFlags |= StartTrackingFlags::ButtonRepeat; - if ( nTrackFlags & StartTrackingFlags::ButtonRepeat ) - Click(); - } + GetButtonState() |= DrawButtonFlags::Pressed; + Invalidate(); + StartTracking( nTrackFlags ); + + if ( nTrackFlags & StartTrackingFlags::ButtonRepeat ) + Click(); } void PushButton::Tracking( const TrackingEvent& rTEvt ) @@ -1504,25 +1504,25 @@ void PushButton::SetDropDown( PushButtonDropdownStyle nStyle ) void PushButton::SetState( TriState eState ) { - if ( meState != eState ) - { - meState = eState; - if ( meState == TRISTATE_FALSE ) - GetButtonState() &= ~DrawButtonFlags(DrawButtonFlags::Checked | DrawButtonFlags::DontKnow); - else if ( meState == TRISTATE_TRUE ) - { - GetButtonState() &= ~DrawButtonFlags::DontKnow; - GetButtonState() |= DrawButtonFlags::Checked; - } - else // TRISTATE_INDET - { - GetButtonState() &= ~DrawButtonFlags::Checked; - GetButtonState() |= DrawButtonFlags::DontKnow; - } + if ( meState == eState ) + return; - CompatStateChanged( StateChangedType::State ); - Toggle(); + meState = eState; + if ( meState == TRISTATE_FALSE ) + GetButtonState() &= ~DrawButtonFlags(DrawButtonFlags::Checked | DrawButtonFlags::DontKnow); + else if ( meState == TRISTATE_TRUE ) + { + GetButtonState() &= ~DrawButtonFlags::DontKnow; + GetButtonState() |= DrawButtonFlags::Checked; + } + else // TRISTATE_INDET + { + GetButtonState() &= ~DrawButtonFlags::Checked; + GetButtonState() |= DrawButtonFlags::DontKnow; } + + CompatStateChanged( StateChangedType::State ); + Toggle(); } void PushButton::statusChanged(const css::frame::FeatureStateEvent& rEvent) @@ -1806,30 +1806,30 @@ void RadioButton::ImplInitSettings( bool bBackground ) { Button::ImplInitSettings(); - if ( bBackground ) + if ( !bBackground ) + return; + + vcl::Window* pParent = GetParent(); + if ( !IsControlBackground() && + (pParent->IsChildTransparentModeEnabled() || IsNativeControlSupported( ControlType::Radiobutton, ControlPart::Entire ) ) ) { - vcl::Window* pParent = GetParent(); - if ( !IsControlBackground() && - (pParent->IsChildTransparentModeEnabled() || IsNativeControlSupported( ControlType::Radiobutton, ControlPart::Entire ) ) ) - { - EnableChildTransparentMode(); - SetParentClipMode( ParentClipMode::NoClip ); - SetPaintTransparent( true ); - SetBackground(); - if( IsNativeControlSupported( ControlType::Radiobutton, ControlPart::Entire ) ) - mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects; - } - else - { - EnableChildTransparentMode( false ); - SetParentClipMode(); - SetPaintTransparent( false ); + EnableChildTransparentMode(); + SetParentClipMode( ParentClipMode::NoClip ); + SetPaintTransparent( true ); + SetBackground(); + if( IsNativeControlSupported( ControlType::Radiobutton, ControlPart::Entire ) ) + mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects; + } + else + { + EnableChildTransparentMode( false ); + SetParentClipMode(); + SetPaintTransparent( false ); - if ( IsControlBackground() ) - SetBackground( GetControlBackground() ); - else - SetBackground( pParent->GetBackground() ); - } + if ( IsControlBackground() ) + SetBackground( GetControlBackground() ); + else + SetBackground( pParent->GetBackground() ); } } @@ -1860,92 +1860,92 @@ void RadioButton::ImplDrawRadioButtonState(vcl::RenderContext& rRenderContext) nState, aControlValue, OUString()); } - if (!bNativeOK) + if (bNativeOK) + return; + + if (!maImage) { - if (!maImage) - { - DrawButtonFlags nStyle = GetButtonState(); - if (!IsEnabled()) - nStyle |= DrawButtonFlags::Disabled; - if (mbChecked) - nStyle |= DrawButtonFlags::Checked; - Image aImage = GetRadioImage(rRenderContext.GetSettings(), nStyle); - if (IsZoom()) - rRenderContext.DrawImage(maStateRect.TopLeft(), maStateRect.GetSize(), aImage); - else - rRenderContext.DrawImage(maStateRect.TopLeft(), aImage); - } + DrawButtonFlags nStyle = GetButtonState(); + if (!IsEnabled()) + nStyle |= DrawButtonFlags::Disabled; + if (mbChecked) + nStyle |= DrawButtonFlags::Checked; + Image aImage = GetRadioImage(rRenderContext.GetSettings(), nStyle); + if (IsZoom()) + rRenderContext.DrawImage(maStateRect.TopLeft(), maStateRect.GetSize(), aImage); else - { - HideFocus(); + rRenderContext.DrawImage(maStateRect.TopLeft(), aImage); + } + else + { + HideFocus(); - DecorationView aDecoView(&rRenderContext); - const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); - tools::Rectangle aImageRect = maStateRect; - Size aImageSize = maImage.GetSizePixel(); - bool bEnabled = IsEnabled(); + DecorationView aDecoView(&rRenderContext); + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + tools::Rectangle aImageRect = maStateRect; + Size aImageSize = maImage.GetSizePixel(); + bool bEnabled = IsEnabled(); - aImageSize.setWidth( CalcZoom(aImageSize.Width()) ); - aImageSize.setHeight( CalcZoom(aImageSize.Height()) ); + aImageSize.setWidth( CalcZoom(aImageSize.Width()) ); + aImageSize.setHeight( CalcZoom(aImageSize.Height()) ); - aImageRect.AdjustLeft( 1 ); - aImageRect.AdjustTop( 1 ); - aImageRect.AdjustRight( -1 ); - aImageRect.AdjustBottom( -1 ); + aImageRect.AdjustLeft( 1 ); + aImageRect.AdjustTop( 1 ); + aImageRect.AdjustRight( -1 ); + aImageRect.AdjustBottom( -1 ); - // display border and selection status - aImageRect = aDecoView.DrawFrame(aImageRect, DrawFrameStyle::DoubleIn); - if ((GetButtonState() & DrawButtonFlags::Pressed) || !bEnabled) - rRenderContext.SetFillColor( rStyleSettings.GetFaceColor()); - else - rRenderContext.SetFillColor(rStyleSettings.GetFieldColor()); - rRenderContext.SetLineColor(); - rRenderContext.DrawRect(aImageRect); + // display border and selection status + aImageRect = aDecoView.DrawFrame(aImageRect, DrawFrameStyle::DoubleIn); + if ((GetButtonState() & DrawButtonFlags::Pressed) || !bEnabled) + rRenderContext.SetFillColor( rStyleSettings.GetFaceColor()); + else + rRenderContext.SetFillColor(rStyleSettings.GetFieldColor()); + rRenderContext.SetLineColor(); + rRenderContext.DrawRect(aImageRect); - // display image - DrawImageFlags nImageStyle = DrawImageFlags::NONE; - if (!bEnabled) - nImageStyle |= DrawImageFlags::Disable; + // display image + DrawImageFlags nImageStyle = DrawImageFlags::NONE; + if (!bEnabled) + nImageStyle |= DrawImageFlags::Disable; - Image* pImage = &maImage; + Image* pImage = &maImage; - Point aImagePos(aImageRect.TopLeft()); - aImagePos.AdjustX((aImageRect.GetWidth() - aImageSize.Width()) / 2 ); - aImagePos.AdjustY((aImageRect.GetHeight() - aImageSize.Height()) / 2 ); - if (IsZoom()) - rRenderContext.DrawImage(aImagePos, aImageSize, *pImage, nImageStyle); - else - rRenderContext.DrawImage(aImagePos, *pImage, nImageStyle); + Point aImagePos(aImageRect.TopLeft()); + aImagePos.AdjustX((aImageRect.GetWidth() - aImageSize.Width()) / 2 ); + aImagePos.AdjustY((aImageRect.GetHeight() - aImageSize.Height()) / 2 ); + if (IsZoom()) + rRenderContext.DrawImage(aImagePos, aImageSize, *pImage, nImageStyle); + else + rRenderContext.DrawImage(aImagePos, *pImage, nImageStyle); - aImageRect.AdjustLeft( 1 ); - aImageRect.AdjustTop( 1 ); - aImageRect.AdjustRight( -1 ); - aImageRect.AdjustBottom( -1 ); + aImageRect.AdjustLeft( 1 ); + aImageRect.AdjustTop( 1 ); + aImageRect.AdjustRight( -1 ); + aImageRect.AdjustBottom( -1 ); - ImplSetFocusRect(aImageRect); + ImplSetFocusRect(aImageRect); - if (mbChecked) + if (mbChecked) + { + rRenderContext.SetLineColor(rStyleSettings.GetHighlightColor()); + rRenderContext.SetFillColor(); + if ((aImageSize.Width() >= 20) || (aImageSize.Height() >= 20)) { - rRenderContext.SetLineColor(rStyleSettings.GetHighlightColor()); - rRenderContext.SetFillColor(); - if ((aImageSize.Width() >= 20) || (aImageSize.Height() >= 20)) - { - aImageRect.AdjustLeft( 1 ); - aImageRect.AdjustTop( 1 ); - aImageRect.AdjustRight( -1 ); - aImageRect.AdjustBottom( -1 ); - } - rRenderContext.DrawRect(aImageRect); aImageRect.AdjustLeft( 1 ); aImageRect.AdjustTop( 1 ); aImageRect.AdjustRight( -1 ); aImageRect.AdjustBottom( -1 ); - rRenderContext.DrawRect(aImageRect); } - - if (HasFocus()) - ShowFocus(ImplGetFocusRect()); + rRenderContext.DrawRect(aImageRect); + aImageRect.AdjustLeft( 1 ); + aImageRect.AdjustTop( 1 ); + aImageRect.AdjustRight( -1 ); + aImageRect.AdjustBottom( -1 ); + rRenderContext.DrawRect(aImageRect); } + + if (HasFocus()) + ShowFocus(ImplGetFocusRect()); } } @@ -2605,19 +2605,19 @@ void RadioButton::Check( bool bCheck ) else mpWindowImpl->mnStyle &= ~WB_TABSTOP; - if ( mbChecked != bCheck ) - { - mbChecked = bCheck; - VclPtr<vcl::Window> xWindow = this; - CompatStateChanged( StateChangedType::State ); - if ( xWindow->IsDisposed() ) - return; - if ( bCheck && mbRadioCheck ) - ImplUncheckAllOther(); - if ( xWindow->IsDisposed() ) - return; - Toggle(); - } + if ( mbChecked == bCheck ) + return; + + mbChecked = bCheck; + VclPtr<vcl::Window> xWindow = this; + CompatStateChanged( StateChangedType::State ); + if ( xWindow->IsDisposed() ) + return; + if ( bCheck && mbRadioCheck ) + ImplUncheckAllOther(); + if ( xWindow->IsDisposed() ) + return; + Toggle(); } long RadioButton::ImplGetImageToTextDistance() const @@ -2893,30 +2893,30 @@ void CheckBox::ImplInitSettings( bool bBackground ) { Button::ImplInitSettings(); - if ( bBackground ) + if ( !bBackground ) + return; + + vcl::Window* pParent = GetParent(); + if ( !IsControlBackground() && + (pParent->IsChildTransparentModeEnabled() || IsNativeControlSupported( ControlType::Checkbox, ControlPart::Entire ) ) ) { - vcl::Window* pParent = GetParent(); - if ( !IsControlBackground() && - (pParent->IsChildTransparentModeEnabled() || IsNativeControlSupported( ControlType::Checkbox, ControlPart::Entire ) ) ) - { - EnableChildTransparentMode(); - SetParentClipMode( ParentClipMode::NoClip ); - SetPaintTransparent( true ); - SetBackground(); - if( IsNativeControlSupported( ControlType::Checkbox, ControlPart::Entire ) ) - ImplGetWindowImpl()->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects; - } - else - { - EnableChildTransparentMode( false ); - SetParentClipMode(); - SetPaintTransparent( false ); + EnableChildTransparentMode(); + SetParentClipMode( ParentClipMode::NoClip ); + SetPaintTransparent( true ); + SetBackground(); + if( IsNativeControlSupported( ControlType::Checkbox, ControlPart::Entire ) ) + ImplGetWindowImpl()->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects; + } + else + { + EnableChildTransparentMode( false ); + SetParentClipMode(); + SetPaintTransparent( false ); - if ( IsControlBackground() ) - SetBackground( GetControlBackground() ); - else - SetBackground( pParent->GetBackground() ); - } + if ( IsControlBackground() ) + SetBackground( GetControlBackground() ); + else + SetBackground( pParent->GetBackground() ); } } @@ -2950,21 +2950,21 @@ void CheckBox::ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext) nState, aControlValue, OUString()); } - if (!bNativeOK) - { - DrawButtonFlags nStyle = GetButtonState(); - if (!IsEnabled()) - nStyle |= DrawButtonFlags::Disabled; - if (meState == TRISTATE_INDET) - nStyle |= DrawButtonFlags::DontKnow; - else if (meState == TRISTATE_TRUE) - nStyle |= DrawButtonFlags::Checked; - Image aImage = GetCheckImage(GetSettings(), nStyle); - if (IsZoom()) - rRenderContext.DrawImage(maStateRect.TopLeft(), maStateRect.GetSize(), aImage); - else - rRenderContext.DrawImage(maStateRect.TopLeft(), aImage); - } + if (bNativeOK) + return; + + DrawButtonFlags nStyle = GetButtonState(); + if (!IsEnabled()) + nStyle |= DrawButtonFlags::Disabled; + if (meState == TRISTATE_INDET) + nStyle |= DrawButtonFlags::DontKnow; + else if (meState == TRISTATE_TRUE) + nStyle |= DrawButtonFlags::Checked; + Image aImage = GetCheckImage(GetSettings(), nStyle); + if (IsZoom()) + rRenderContext.DrawImage(maStateRect.TopLeft(), maStateRect.GetSize(), aImage); + else + rRenderContext.DrawImage(maStateRect.TopLeft(), aImage); } void CheckBox::ImplDraw( OutputDevice* pDev, DrawFlags nDrawFlags, diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 9942da05aaed..6e0f7c6e5a9c 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -479,23 +479,23 @@ IMPL_LINK_NOARG(ComboBox::Impl, ImplDoubleClickHdl, ImplListBoxWindow*, void) void ComboBox::ToggleDropDown() { - if( IsDropDownBox() ) + if( !IsDropDownBox() ) + return; + + if (m_pImpl->m_pFloatWin->IsInPopupMode()) + m_pImpl->m_pFloatWin->EndPopupMode(); + else { - if (m_pImpl->m_pFloatWin->IsInPopupMode()) - m_pImpl->m_pFloatWin->EndPopupMode(); + m_pImpl->m_pSubEdit->GrabFocus(); + if (!m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount()) + m_pImpl->ImplUpdateFloatSelection(); else - { - m_pImpl->m_pSubEdit->GrabFocus(); - if (!m_pImpl->m_pImplLB->GetEntryList()->GetMRUCount()) - m_pImpl->ImplUpdateFloatSelection(); - else - m_pImpl->m_pImplLB->SelectEntry( 0 , true ); - CallEventListeners( VclEventId::DropdownPreOpen ); - m_pImpl->m_pBtn->SetPressed( true ); - SetSelection( Selection( 0, SELECTION_MAX ) ); - m_pImpl->m_pFloatWin->StartFloat( true ); - CallEventListeners( VclEventId::DropdownOpen ); - } + m_pImpl->m_pImplLB->SelectEntry( 0 , true ); + CallEventListeners( VclEventId::DropdownPreOpen ); + m_pImpl->m_pBtn->SetPressed( true ); + SetSelection( Selection( 0, SELECTION_MAX ) ); + m_pImpl->m_pFloatWin->StartFloat( true ); + CallEventListeners( VclEventId::DropdownOpen ); } } @@ -693,22 +693,22 @@ void ComboBox::DataChanged( const DataChangedEvent& rDCEvt ) { Control::DataChanged( rDCEvt ); - if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) || + if ( !((rDCEvt.GetType() == DataChangedEventType::FONTS) || (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) || ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && - (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) ) - { - if (m_pImpl->m_pBtn) - { - m_pImpl->m_pBtn->SetSettings( GetSettings() ); - ImplInitDropDownButton( m_pImpl->m_pBtn ); - } - Resize(); - m_pImpl->m_pImplLB->Resize(); // not called by ComboBox::Resize() if ImplLB is unchanged + (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))) ) + return; - SetBackground(); // due to a hack in Window::UpdateSettings the background must be reset - // otherwise it will overpaint NWF drawn comboboxes + if (m_pImpl->m_pBtn) + { + m_pImpl->m_pBtn->SetSettings( GetSettings() ); + ImplInitDropDownButton( m_pImpl->m_pBtn ); } + Resize(); + m_pImpl->m_pImplLB->Resize(); // not called by ComboBox::Resize() if ImplLB is unchanged + + SetBackground(); // due to a hack in Window::UpdateSettings the background must be reset + // otherwise it will overpaint NWF drawn comboboxes } bool ComboBox::EventNotify( NotifyEvent& rNEvt ) diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index fc1a93dd030e..bd4a2aa20c38 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -888,34 +888,34 @@ void Edit::ImplInsertText( const OUString& rStr, const Selection* pNewSel, bool void Edit::ImplSetText( const OUString& rText, const Selection* pNewSelection ) { // we delete text by "selecting" the old text completely then calling InsertText; this is flicker free - if ( ( rText.getLength() <= mnMaxTextLen ) && - ( (rText != maText.getStr()) || (pNewSelection && (*pNewSelection != maSelection)) ) ) + if ( ( rText.getLength() > mnMaxTextLen ) || + ( rText == maText.getStr() && (!pNewSelection || (*pNewSelection == maSelection)) ) ) + return; + + ImplClearLayoutData(); + maSelection.Min() = 0; + maSelection.Max() = maText.getLength(); + if ( mnXOffset || HasPaintEvent() ) { - ImplClearLayoutData(); - maSelection.Min() = 0; - maSelection.Max() = maText.getLength(); - if ( mnXOffset || HasPaintEvent() ) - { - mnXOffset = 0; - maText = ImplGetValidString( rText ); + mnXOffset = 0; + maText = ImplGetValidString( rText ); - // #i54929# recalculate mnXOffset before ImplSetSelection, - // else cursor ends up in wrong position - ImplAlign(); + // #i54929# recalculate mnXOffset before ImplSetSelection, + // else cursor ends up in wrong position + ImplAlign(); - if ( pNewSelection ) - ImplSetSelection( *pNewSelection, false ); + if ( pNewSelection ) + ImplSetSelection( *pNewSelection, false ); - if ( mnXOffset && !pNewSelection ) - maSelection.Max() = 0; + if ( mnXOffset && !pNewSelection ) + maSelection.Max() = 0; - Invalidate(); - } - else - ImplInsertText( rText, pNewSelection ); - - CallEventListeners( VclEventId::EditModify ); + Invalidate(); } + else + ImplInsertText( rText, pNewSelection ); + + CallEventListeners( VclEventId::EditModify ); } ControlType Edit::ImplGetNativeControlType() const @@ -994,58 +994,58 @@ void Edit::ImplPaintBorder(vcl::RenderContext const & rRenderContext) if (SupportsDoubleBuffering()) return; - if (ImplUseNativeBorder(rRenderContext, GetStyle()) || IsPaintTransparent()) + if (!(ImplUseNativeBorder(rRenderContext, GetStyle()) || IsPaintTransparent())) + return; + + // draw the inner part by painting the whole control using its border window + vcl::Window* pBorder = GetWindow(GetWindowType::Border); + if (pBorder == this) { - // draw the inner part by painting the whole control using its border window - vcl::Window* pBorder = GetWindow(GetWindowType::Border); + // we have no border, use parent + vcl::Window* pControl = mbIsSubEdit ? GetParent() : this; + pBorder = pControl->GetWindow(GetWindowType::Border); if (pBorder == this) - { - // we have no border, use parent - vcl::Window* pControl = mbIsSubEdit ? GetParent() : this; - pBorder = pControl->GetWindow(GetWindowType::Border); - if (pBorder == this) - pBorder = GetParent(); - } + pBorder = GetParent(); + } - if (pBorder) + if (!pBorder) + return; + + // set proper clipping region to not overdraw the whole control + vcl::Region aClipRgn = GetPaintRegion(); + if (!aClipRgn.IsNull()) + { + // transform clipping region to border window's coordinate system + if (IsRTLEnabled() != pBorder->IsRTLEnabled() && AllSettings::GetLayoutRTL()) { - // set proper clipping region to not overdraw the whole control - vcl::Region aClipRgn = GetPaintRegion(); - if (!aClipRgn.IsNull()) - { - // transform clipping region to border window's coordinate system - if (IsRTLEnabled() != pBorder->IsRTLEnabled() && AllSettings::GetLayoutRTL()) - { - // need to mirror in case border is not RTL but edit is (or vice versa) + // need to mirror in case border is not RTL but edit is (or vice versa) - // mirror - tools::Rectangle aBounds(aClipRgn.GetBoundRect()); - int xNew = GetOutputSizePixel().Width() - aBounds.GetWidth() - aBounds.Left(); - aClipRgn.Move(xNew - aBounds.Left(), 0); + // mirror + tools::Rectangle aBounds(aClipRgn.GetBoundRect()); + int xNew = GetOutputSizePixel().Width() - aBounds.GetWidth() - aBounds.Left(); + aClipRgn.Move(xNew - aBounds.Left(), 0); - // move offset of border window - Point aBorderOffs = pBorder->ScreenToOutputPixel(OutputToScreenPixel(Point())); - aClipRgn.Move(aBorderOffs.X(), aBorderOffs.Y()); - } - else - { - // normal case - Point aBorderOffs = pBorder->ScreenToOutputPixel(OutputToScreenPixel(Point())); - aClipRgn.Move(aBorderOffs.X(), aBorderOffs.Y()); - } + // move offset of border window + Point aBorderOffs = pBorder->ScreenToOutputPixel(OutputToScreenPixel(Point())); + aClipRgn.Move(aBorderOffs.X(), aBorderOffs.Y()); + } + else + { + // normal case + Point aBorderOffs = pBorder->ScreenToOutputPixel(OutputToScreenPixel(Point())); + aClipRgn.Move(aBorderOffs.X(), aBorderOffs.Y()); + } - vcl::Region oldRgn(pBorder->GetClipRegion()); - pBorder->SetClipRegion(aClipRgn); + vcl::Region oldRgn(pBorder->GetClipRegion()); + pBorder->SetClipRegion(aClipRgn); - pBorder->Paint(*pBorder, tools::Rectangle()); + pBorder->Paint(*pBorder, tools::Rectangle()); - pBorder->SetClipRegion(oldRgn); - } - else - { - pBorder->Paint(*pBorder, tools::Rectangle()); - } - } + pBorder->SetClipRegion(oldRgn); + } + else + { + pBorder->Paint(*pBorder, tools::Rectangle()); } } @@ -1269,40 +1269,40 @@ void Edit::ImplCopy( uno::Reference< datatransfer::clipboard::XClipboard > const void Edit::ImplPaste( uno::Reference< datatransfer::clipboard::XClipboard > const & rxClipboard ) { - if ( rxClipboard.is() ) - { - uno::Reference< datatransfer::XTransferable > xDataObj; + if ( !rxClipboard.is() ) + return; - try - { - SolarMutexReleaser aReleaser; - xDataObj = rxClipboard->getContents(); - } - catch( const css::uno::Exception& ) - { - } + uno::Reference< datatransfer::XTransferable > xDataObj; - if ( xDataObj.is() ) + try { - datatransfer::DataFlavor aFlavor; - SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor ); - try - { - uno::Any aData = xDataObj->getTransferData( aFlavor ); - OUString aText; - aData >>= aText; + SolarMutexReleaser aReleaser; + xDataObj = rxClipboard->getContents(); + } + catch( const css::uno::Exception& ) + { + } - Selection aSelection(maSelection); - aSelection.Justify(); - if (ImplTruncateToMaxLen(aText, aSelection.Len())) - ShowTruncationWarning(GetFrameWeld()); + if ( !xDataObj.is() ) + return; - ReplaceSelected( aText ); - } - catch( const css::uno::Exception& ) - { - } - } + datatransfer::DataFlavor aFlavor; + SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor ); + try + { + uno::Any aData = xDataObj->getTransferData( aFlavor ); + OUString aText; + aData >>= aText; + + Selection aSelection(maSelection); + aSelection.Justify(); + if (ImplTruncateToMaxLen(aText, aSelection.Len())) + ShowTruncationWarning(GetFrameWeld()); + + ReplaceSelected( aText ); + } + catch( const css::uno::Exception& ) + { } } @@ -2732,36 +2732,35 @@ void Edit::dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent { SolarMutexGuard aVclGuard; - if ( !IsTracking() && maSelection.Len() && - !mbPassword && (!mpDDInfo || !mpDDInfo->bStarterOfDD) ) // no repeated D&D - { - Selection aSel( maSelection ); - aSel.Justify(); + if ( !(!IsTracking() && maSelection.Len() && + !mbPassword && (!mpDDInfo || !mpDDInfo->bStarterOfDD)) ) // no repeated D&D + return; - // only if mouse in the selection... - Point aMousePos( rDGE.DragOriginX, rDGE.DragOriginY ); - sal_Int32 nCharPos = ImplGetCharPos( aMousePos ); - if ( (nCharPos >= aSel.Min()) && (nCharPos < aSel.Max()) ) - { - if ( !mpDDInfo ) - mpDDInfo.reset(new DDInfo); + Selection aSel( maSelection ); + aSel.Justify(); - mpDDInfo->bStarterOfDD = true; - mpDDInfo->aDndStartSel = aSel; + // only if mouse in the selection... + Point aMousePos( rDGE.DragOriginX, rDGE.DragOriginY ); + sal_Int32 nCharPos = ImplGetCharPos( aMousePos ); + if ( (nCharPos < aSel.Min()) || (nCharPos >= aSel.Max()) ) + return; - if ( IsTracking() ) - EndTracking(); // before D&D disable tracking + if ( !mpDDInfo ) + mpDDInfo.reset(new DDInfo); - vcl::unohelper::TextDataObject* pDataObj = new vcl::unohelper::TextDataObject( GetSelected() ); - sal_Int8 nActions = datatransfer::dnd::DNDConstants::ACTION_COPY; - if ( !IsReadOnly() ) - nActions |= datatransfer::dnd::DNDConstants::ACTION_MOVE; - rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, pDataObj, mxDnDListener ); - if ( GetCursor() ) - GetCursor()->Hide(); + mpDDInfo->bStarterOfDD = true; + mpDDInfo->aDndStartSel = aSel; - } - } + if ( IsTracking() ) + EndTracking(); // before D&D disable tracking + + vcl::unohelper::TextDataObject* pDataObj = new vcl::unohelper::TextDataObject( GetSelected() ); + sal_Int8 nActions = datatransfer::dnd::DNDConstants::ACTION_COPY; + if ( !IsReadOnly() ) + nActions |= datatransfer::dnd::DNDConstants::ACTION_MOVE; + rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, pDataObj, mxDnDListener ); + if ( GetCursor() ) + GetCursor()->Hide(); } // css::datatransfer::dnd::XDragSourceListener diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx index 65089351795d..23bd0d14ad1e 100644 --- a/vcl/source/control/field.cxx +++ b/vcl/source/control/field.cxx @@ -405,32 +405,32 @@ void ImplUpdateSeparators( const OUString& rOldDecSep, const OUString& rNewDecSe bool bChangeDec = (rOldDecSep != rNewDecSep); bool bChangeTh = (rOldThSep != rNewThSep ); - if( bChangeDec || bChangeTh ) - { - bool bUpdateMode = pEdit->IsUpdateMode(); - pEdit->SetUpdateMode( false ); - OUString aText = pEdit->GetText(); - ImplUpdateSeparatorString( aText, rOldDecSep, rNewDecSep, rOldThSep, rNewThSep ); - pEdit->SetText( aText ); + if( !(bChangeDec || bChangeTh) ) + return; + + bool bUpdateMode = pEdit->IsUpdateMode(); + pEdit->SetUpdateMode( false ); + OUString aText = pEdit->GetText(); + ImplUpdateSeparatorString( aText, rOldDecSep, rNewDecSep, rOldThSep, rNewThSep ); + pEdit->SetText( aText ); - ComboBox* pCombo = dynamic_cast<ComboBox*>(pEdit); - if( pCombo ) + ComboBox* pCombo = dynamic_cast<ComboBox*>(pEdit); + if( pCombo ) + { + // update box entries + sal_Int32 nEntryCount = pCombo->GetEntryCount(); + for ( sal_Int32 i=0; i < nEntryCount; i++ ) { - // update box entries - sal_Int32 nEntryCount = pCombo->GetEntryCount(); - for ( sal_Int32 i=0; i < nEntryCount; i++ ) - { - aText = pCombo->GetEntry( i ); - void* pEntryData = pCombo->GetEntryData( i ); - ImplUpdateSeparatorString( aText, rOldDecSep, rNewDecSep, rOldThSep, rNewThSep ); - pCombo->RemoveEntryAt(i); - pCombo->InsertEntry( aText, i ); - pCombo->SetEntryData( i, pEntryData ); - } + aText = pCombo->GetEntry( i ); + void* pEntryData = pCombo->GetEntryData( i ); + ImplUpdateSeparatorString( aText, rOldDecSep, rNewDecSep, rOldThSep, rNewThSep ); + pCombo->RemoveEntryAt(i); + pCombo->InsertEntry( aText, i ); + pCombo->SetEntryData( i, pEntryData ); } - if( bUpdateMode ) - pEdit->SetUpdateMode( bUpdateMode ); } + if( bUpdateMode ) + pEdit->SetUpdateMode( bUpdateMode ); } } // namespace @@ -733,34 +733,34 @@ void NumericFormatter::FieldLast() void NumericFormatter::ImplNewFieldValue( sal_Int64 nNewValue ) { - if ( GetField() ) - { - // !!! We should check why we do not validate in ImplSetUserValue() if the value was - // changed. This should be done there as well since otherwise the call to Modify would not - // be allowed. Anyway, the paths from ImplNewFieldValue, ImplSetUserValue, and ImplSetText - // should be checked and clearly traced (with comment) in order to find out what happens. + if ( !GetField() ) + return; - Selection aSelection = GetField()->GetSelection(); - aSelection.Justify(); - OUString aText = GetField()->GetText(); - // leave it as is if selected until end - if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) - { - if ( !aSelection.Len() ) - aSelection.Min() = SELECTION_MAX; - aSelection.Max() = SELECTION_MAX; - } + // !!! We should check why we do not validate in ImplSetUserValue() if the value was + // changed. This should be done there as well since otherwise the call to Modify would not + // be allowed. Anyway, the paths from ImplNewFieldValue, ImplSetUserValue, and ImplSetText + // should be checked and clearly traced (with comment) in order to find out what happens. - sal_Int64 nOldLastValue = mnLastValue; - ImplSetUserValue( nNewValue, &aSelection ); - mnLastValue = nOldLastValue; + Selection aSelection = GetField()->GetSelection(); + aSelection.Justify(); + OUString aText = GetField()->GetText(); + // leave it as is if selected until end + if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) + { + if ( !aSelection.Len() ) + aSelection.Min() = SELECTION_MAX; + aSelection.Max() = SELECTION_MAX; + } - // Modify during Edit is only set during KeyInput - if ( GetField()->GetText() != aText ) - { - GetField()->SetModifyFlag(); - GetField()->Modify(); - } + sal_Int64 nOldLastValue = mnLastValue; + ImplSetUserValue( nNewValue, &aSelection ); + mnLastValue = nOldLastValue; + + // Modify during Edit is only set during KeyInput + if ( GetField()->GetText() != aText ) + { + GetField()->SetModifyFlag(); + GetField()->Modify(); } } diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index 511976249c8d..fc81066ef0f6 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -401,27 +401,27 @@ static void ImplPatternProcessStrictModify( Edit* pEdit, rLiteralMask, bSameMask); - if ( aNewText != aText ) + if ( aNewText == aText ) + return; + + // adjust selection such that it remains at the end if it was there before + Selection aSel = pEdit->GetSelection(); + sal_Int64 nMaxSel = std::max( aSel.Min(), aSel.Max() ); + if ( nMaxSel >= aText.getLength() ) { - // adjust selection such that it remains at the end if it was there before - Selection aSel = pEdit->GetSelection(); - sal_Int64 nMaxSel = std::max( aSel.Min(), aSel.Max() ); - if ( nMaxSel >= aText.getLength() ) + sal_Int32 nMaxPos = aNewText.getLength(); + ImplPatternMaxPos(aNewText, rEditMask, 0, bSameMask, nMaxSel, nMaxPos); + if ( aSel.Min() == aSel.Max() ) { - sal_Int32 nMaxPos = aNewText.getLength(); - ImplPatternMaxPos(aNewText, rEditMask, 0, bSameMask, nMaxSel, nMaxPos); - if ( aSel.Min() == aSel.Max() ) - { - aSel.Min() = nMaxPos; - aSel.Max() = aSel.Min(); - } - else if ( aSel.Min() > aSel.Max() ) - aSel.Min() = nMaxPos; - else - aSel.Max() = nMaxPos; + aSel.Min() = nMaxPos; + aSel.Max() = aSel.Min(); } - pEdit->SetText( aNewText, aSel ); + else if ( aSel.Min() > aSel.Max() ) + aSel.Min() = nMaxPos; + else + aSel.Max() = nMaxPos; } + pEdit->SetText( aNewText, aSel ); } static void ImplPatternProcessStrictModify( weld::Entry& rEntry, @@ -435,30 +435,30 @@ static void ImplPatternProcessStrictModify( weld::Entry& rEntry, rLiteralMask, bSameMask); - if (aNewText != aText) - { - // adjust selection such that it remains at the end if it was there before - int nStartPos, nEndPos; - rEntry.get_selection_bounds(nStartPos, nEndPos); + if (aNewText == aText) + return; - int nMaxSel = std::max(nStartPos, nEndPos); - if (nMaxSel >= aText.getLength()) + // adjust selection such that it remains at the end if it was there before + int nStartPos, nEndPos; + rEntry.get_selection_bounds(nStartPos, nEndPos); + + int nMaxSel = std::max(nStartPos, nEndPos); + if (nMaxSel >= aText.getLength()) + { + sal_Int32 nMaxPos = aNewText.getLength(); + ImplPatternMaxPos(aNewText, rEditMask, 0, bSameMask, nMaxSel, nMaxPos); + if (nStartPos == nEndPos) { - sal_Int32 nMaxPos = aNewText.getLength(); - ImplPatternMaxPos(aNewText, rEditMask, 0, bSameMask, nMaxSel, nMaxPos); - if (nStartPos == nEndPos) - { - nStartPos = nMaxPos; - nEndPos = nMaxPos; - } - else if (nStartPos > nMaxPos) - nStartPos = nMaxPos; - else - nEndPos = nMaxPos; + nStartPos = nMaxPos; + nEndPos = nMaxPos; } - rEntry.set_text(aNewText); - rEntry.select_region(nStartPos, nEndPos); + else if (nStartPos > nMaxPos) + nStartPos = nMaxPos; + else + nEndPos = nMaxPos; } + rEntry.set_text(aNewText); + rEntry.select_region(nStartPos, nEndPos); } static sal_Int32 ImplPatternLeftPos(const OString& rEditMask, sal_Int32 nCursorPos) @@ -1555,19 +1555,19 @@ static void ImplDateIncrementYear( Date& rDate, bool bUp ) if ( nYear > SAL_MIN_INT16 ) rDate.SetYear( rDate.GetPrevYear() ); } - if (nMonth == 2) + if (nMonth != 2) + return; + + // Handle February 29 from leap year to non-leap year. + sal_uInt16 nDay = rDate.GetDay(); + if (nDay > 28) { - // Handle February 29 from leap year to non-leap year. - sal_uInt16 nDay = rDate.GetDay(); - if (nDay > 28) - { - // The check would not be necessary if it was guaranteed that the - // date was valid before and actually was a leap year, - // de-/incrementing a leap year with 29 always results in 28. - sal_uInt16 nDaysInMonth = Date::GetDaysInMonth( nMonth, rDate.GetYear()); - if (nDay > nDaysInMonth) - rDate.SetDay( nDaysInMonth); - } + // The check would not be necessary if it was guaranteed that the + // date was valid before and actually was a leap year, + // de-/incrementing a leap year with 29 always results in 28. + sal_uInt16 nDaysInMonth = Date::GetDaysInMonth( nMonth, rDate.GetYear()); + if (nDay > nDaysInMonth) + rDate.SetDay( nDaysInMonth); } } @@ -1609,67 +1609,67 @@ int DateFormatter::GetDateArea(ExtDateFieldFormat eFormat, const OUString& rText void DateField::ImplDateSpinArea( bool bUp ) { // increment days if all is selected - if ( GetField() ) + if ( !GetField() ) + return; + + Date aDate( GetDate() ); + Selection aSelection = GetField()->GetSelection(); + aSelection.Justify(); + OUString aText( GetText() ); + if ( static_cast<sal_Int32>(aSelection.Len()) == aText.getLength() ) + ImplDateIncrementDay( aDate, bUp ); + else { - Date aDate( GetDate() ); - Selection aSelection = GetField()->GetSelection(); - aSelection.Justify(); - OUString aText( GetText() ); - if ( static_cast<sal_Int32>(aSelection.Len()) == aText.getLength() ) - ImplDateIncrementDay( aDate, bUp ); - else - { - ExtDateFieldFormat eFormat = GetExtDateFormat( true ); - sal_Int8 nDateArea = GetDateArea(eFormat, aText, aSelection.Max(), ImplGetLocaleDataWrapper()); + ExtDateFieldFormat eFormat = GetExtDateFormat( true ); + sal_Int8 nDateArea = GetDateArea(eFormat, aText, aSelection.Max(), ImplGetLocaleDataWrapper()); - switch( eFormat ) + switch( eFormat ) + { + case ExtDateFieldFormat::ShortMMDDYY: + case ExtDateFieldFormat::ShortMMDDYYYY: + switch( nDateArea ) { - case ExtDateFieldFormat::ShortMMDDYY: - case ExtDateFieldFormat::ShortMMDDYYYY: - switch( nDateArea ) - { - case 1: ImplDateIncrementMonth( aDate, bUp ); - break; - case 2: ImplDateIncrementDay( aDate, bUp ); - break; - case 3: ImplDateIncrementYear( aDate, bUp ); - break; - } - break; - case ExtDateFieldFormat::ShortDDMMYY: - case ExtDateFieldFormat::ShortDDMMYYYY: - switch( nDateArea ) - { - case 1: ImplDateIncrementDay( aDate, bUp ); - break; - case 2: ImplDateIncrementMonth( aDate, bUp ); - break; - case 3: ImplDateIncrementYear( aDate, bUp ); - break; - } - break; - case ExtDateFieldFormat::ShortYYMMDD: - case ExtDateFieldFormat::ShortYYYYMMDD: - case ExtDateFieldFormat::ShortYYMMDD_DIN5008: - case ExtDateFieldFormat::ShortYYYYMMDD_DIN5008: - switch( nDateArea ) - { - case 1: ImplDateIncrementYear( aDate, bUp ); - break; - case 2: ImplDateIncrementMonth( aDate, bUp ); - break; - case 3: ImplDateIncrementDay( aDate, bUp ); - break; - } - break; - default: - OSL_FAIL( "invalid conversion" ); - break; + case 1: ImplDateIncrementMonth( aDate, bUp ); + break; + case 2: ImplDateIncrementDay( aDate, bUp ); + break; + case 3: ImplDateIncrementYear( aDate, bUp ); + break; + } + break; + case ExtDateFieldFormat::ShortDDMMYY: + case ExtDateFieldFormat::ShortDDMMYYYY: + switch( nDateArea ) + { + case 1: ImplDateIncrementDay( aDate, bUp ); + break; + case 2: ImplDateIncrementMonth( aDate, bUp ); + break; + case 3: ImplDateIncrementYear( aDate, bUp ); + break; + } + break; + case ExtDateFieldFormat::ShortYYMMDD: + case ExtDateFieldFormat::ShortYYYYMMDD: + case ExtDateFieldFormat::ShortYYMMDD_DIN5008: + case ExtDateFieldFormat::ShortYYYYMMDD_DIN5008: + switch( nDateArea ) + { + case 1: ImplDateIncrementYear( aDate, bUp ); + break; + case 2: ImplDateIncrementMonth( aDate, bUp ); + break; + case 3: ImplDateIncrementDay( aDate, bUp ); + break; } + break; + default: + OSL_FAIL( "invalid conversion" ); + break; } - - ImplNewFieldValue( aDate ); } + + ImplNewFieldValue( aDate ); } DateFormatter::DateFormatter(Edit* pEdit) @@ -1832,30 +1832,30 @@ void DateFormatter::ImplSetUserDate( const Date& rNewDate, Selection const * pNe void DateFormatter::ImplNewFieldValue( const Date& rDate ) { - if ( GetField() ) - { - Selection aSelection = GetField()->GetSelection(); - aSelection.Justify(); - OUString aText = GetField()->GetText(); + if ( !GetField() ) + return; - // If selected until the end then keep it that way - if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) - { - if ( !aSelection.Len() ) - aSelection.Min() = SELECTION_MAX; - aSelection.Max() = SELECTION_MAX; - } + Selection aSelection = GetField()->GetSelection(); + aSelection.Justify(); + OUString aText = GetField()->GetText(); - Date aOldLastDate = maLastDate; - ImplSetUserDate( rDate, &aSelection ); - maLastDate = aOldLastDate; + // If selected until the end then keep it that way + if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) + { + if ( !aSelection.Len() ) + aSelection.Min() = SELECTION_MAX; + aSelection.Max() = SELECTION_MAX; + } - // Modify at Edit is only set at KeyInput - if ( GetField()->GetText() != aText ) - { - GetField()->SetModifyFlag(); - GetField()->Modify(); - } + Date aOldLastDate = maLastDate; + ImplSetUserDate( rDate, &aSelection ); + maLastDate = aOldLastDate; + + // Modify at Edit is only set at KeyInput + if ( GetField()->GetText() != aText ) + { + GetField()->SetModifyFlag(); + GetField()->Modify(); } } @@ -2695,30 +2695,30 @@ void TimeFormatter::SetTime( const tools::Time& rNewTime ) void TimeFormatter::ImplNewFieldValue( const tools::Time& rTime ) { - if ( GetField() ) - { - Selection aSelection = GetField()->GetSelection(); - aSelection.Justify(); - OUString aText = GetField()->GetText(); + if ( !GetField() ) + return; - // If selected until the end then keep it that way - if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) - { - if ( !aSelection.Len() ) - aSelection.Min() = SELECTION_MAX; - aSelection.Max() = SELECTION_MAX; - } + Selection aSelection = GetField()->GetSelection(); + aSelection.Justify(); + OUString aText = GetField()->GetText(); - tools::Time aOldLastTime = maLastTime; - ImplSetUserTime( rTime, &aSelection ); - maLastTime = aOldLastTime; + // If selected until the end then keep it that way + if ( static_cast<sal_Int32>(aSelection.Max()) == aText.getLength() ) + { + if ( !aSelection.Len() ) + aSelection.Min() = SELECTION_MAX; + aSelection.Max() = SELECTION_MAX; + } - // Modify at Edit is only set at KeyInput - if ( GetField()->GetText() != aText ) - { - GetField()->SetModifyFlag(); - GetField()->Modify(); - } + tools::Time aOldLastTime = maLastTime; + ImplSetUserTime( rTime, &aSelection ); + maLastTime = aOldLastTime; + + // Modify at Edit is only set at KeyInput + if ( GetField()->GetText() != aText ) + { + GetField()->SetModifyFlag(); + GetField()->Modify(); } } diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index 475124a94d27..e25a506c6a48 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -879,46 +879,46 @@ void ImplListBoxWindow::MouseButtonDown( const MouseEvent& rMEvt ) void ImplListBoxWindow::MouseMove( const MouseEvent& rMEvt ) { - if (!rMEvt.IsLeaveWindow() && !mbMulti && IsMouseMoveSelect() && mpEntryList->GetEntryCount()) - { - tools::Rectangle aRect( Point(), GetOutputSizePixel() ); - if( aRect.IsInside( rMEvt.GetPosPixel() ) ) + if (rMEvt.IsLeaveWindow() || mbMulti || !IsMouseMoveSelect() || !mpEntryList->GetEntryCount()) + return; + + tools::Rectangle aRect( Point(), GetOutputSizePixel() ); + if( !aRect.IsInside( rMEvt.GetPosPixel() ) ) + return; + + if ( IsMouseMoveSelect() ) + { + sal_Int32 nSelect = GetEntryPosForPoint( rMEvt.GetPosPixel() ); + if( nSelect == LISTBOX_ENTRY_NOTFOUND ) + nSelect = mpEntryList->GetEntryCount() - 1; + nSelect = std::min( nSelect, GetLastVisibleEntry() ); + nSelect = std::min( nSelect, static_cast<sal_Int32>( mpEntryList->GetEntryCount() - 1 ) ); + // Select only visible Entries with MouseMove, otherwise Tracking... + if ( IsVisible( nSelect ) && + mpEntryList->IsEntrySelectable( nSelect ) && + ( ( nSelect != mnCurrentPos ) || !GetEntryList()->GetSelectedEntryCount() || ( nSelect != GetEntryList()->GetSelectedEntryPos( 0 ) ) ) ) { - if ( IsMouseMoveSelect() ) + mbTrackingSelect = true; + if ( SelectEntries( nSelect, LET_TRACKING ) ) { - sal_Int32 nSelect = GetEntryPosForPoint( rMEvt.GetPosPixel() ); - if( nSelect == LISTBOX_ENTRY_NOTFOUND ) - nSelect = mpEntryList->GetEntryCount() - 1; - nSelect = std::min( nSelect, GetLastVisibleEntry() ); - nSelect = std::min( nSelect, static_cast<sal_Int32>( mpEntryList->GetEntryCount() - 1 ) ); - // Select only visible Entries with MouseMove, otherwise Tracking... - if ( IsVisible( nSelect ) && - mpEntryList->IsEntrySelectable( nSelect ) && - ( ( nSelect != mnCurrentPos ) || !GetEntryList()->GetSelectedEntryCount() || ( nSelect != GetEntryList()->GetSelectedEntryPos( 0 ) ) ) ) - { - mbTrackingSelect = true; - if ( SelectEntries( nSelect, LET_TRACKING ) ) - { - // When list box selection change by mouse move, notify - // VclEventId::ListboxSelect vcl event. - maListItemSelectHdl.Call(nullptr); - } - mbTrackingSelect = false; - } + // When list box selection change by mouse move, notify + // VclEventId::ListboxSelect vcl event. + maListItemSelectHdl.Call(nullptr); } + mbTrackingSelect = false; + } + } - // if the DD button was pressed and someone moved into the ListBox - // with the mouse button pressed... - if ( rMEvt.IsLeft() && !rMEvt.IsSynthetic() ) - { - if ( !mbMulti && GetEntryList()->GetSelectedEntryCount() ) - mnTrackingSaveSelection = GetEntryList()->GetSelectedEntryPos( 0 ); - else - mnTrackingSaveSelection = LISTBOX_ENTRY_NOTFOUND; + // if the DD button was pressed and someone moved into the ListBox + // with the mouse button pressed... + if ( rMEvt.IsLeft() && !rMEvt.IsSynthetic() ) + { + if ( !mbMulti && GetEntryList()->GetSelectedEntryCount() ) + mnTrackingSaveSelection = GetEntryList()->GetSelectedEntryPos( 0 ); + else + mnTrackingSaveSelection = LISTBOX_ENTRY_NOTFOUND; - StartTracking( StartTrackingFlags::ScrollRepeat ); - } - } + StartTracking( StartTrackingFlags::ScrollRepeat ); } } @@ -933,51 +933,51 @@ void ImplListBoxWindow::DeselectAll() void ImplListBoxWindow::SelectEntry( sal_Int32 nPos, bool bSelect ) { - if( (mpEntryList->IsEntryPosSelected( nPos ) != bSelect) && mpEntryList->IsEntrySelectable( nPos ) ) + if( (mpEntryList->IsEntryPosSelected( nPos ) == bSelect) || !mpEntryList->IsEntrySelectable( nPos ) ) + return; + + ImplHideFocusRect(); + if( bSelect ) { - ImplHideFocusRect(); - if( bSelect ) + if( !mbMulti ) { - if( !mbMulti ) + // deselect the selected entry + sal_Int32 nDeselect = GetEntryList()->GetSelectedEntryPos( 0 ); + if( nDeselect != LISTBOX_ENTRY_NOTFOUND ) { - // deselect the selected entry - sal_Int32 nDeselect = GetEntryList()->GetSelectedEntryPos( 0 ); - if( nDeselect != LISTBOX_ENTRY_NOTFOUND ) - { - //SelectEntryPos( nDeselect, false ); - GetEntryList()->SelectEntry( nDeselect, false ); - if (IsUpdateMode() && IsReallyVisible()) - Invalidate(); - } + //SelectEntryPos( nDeselect, false ); + GetEntryList()->SelectEntry( nDeselect, false ); + if (IsUpdateMode() && IsReallyVisible()) + Invalidate(); } - mpEntryList->SelectEntry( nPos, true ); - mnCurrentPos = nPos; - if ( ( nPos != LISTBOX_ENTRY_NOTFOUND ) && IsUpdateMode() ) + } + mpEntryList->SelectEntry( nPos, true ); + mnCurrentPos = nPos; + if ( ( nPos != LISTBOX_ENTRY_NOTFOUND ) && IsUpdateMode() ) + { + Invalidate(); + if ( !IsVisible( nPos ) ) { - Invalidate(); - if ( !IsVisible( nPos ) ) + ImplClearLayoutData(); + sal_Int32 nVisibleEntries = GetLastVisibleEntry()-mnTop; + if ( !nVisibleEntries || !IsReallyVisible() || ( nPos < GetTopEntry() ) ) { - ImplClearLayoutData(); - sal_Int32 nVisibleEntries = GetLastVisibleEntry()-mnTop; - if ( !nVisibleEntries || !IsReallyVisible() || ( nPos < GetTopEntry() ) ) - { - Resize(); - ShowProminentEntry( nPos ); - } - else - { - ShowProminentEntry( nPos ); - } + Resize(); + ShowProminentEntry( nPos ); + } + else + { + ShowProminentEntry( nPos ); } } } - else - { - mpEntryList->SelectEntry( nPos, false ); - Invalidate(); - } - mbSelectionChanged = true; } + else + { + mpEntryList->SelectEntry( nPos, false ); + Invalidate(); + } + mbSelectionChanged = true; } bool ImplListBoxWindow::SelectEntries( sal_Int32 nSelect, LB_EVENT_TYPE eLET, bool bShift, bool bCtrl, bool bSelectPosChange /*=FALSE*/ ) @@ -1859,19 +1859,19 @@ void ImplListBoxWindow::SetTopEntry( sal_Int32 nTop ) while( nTop > 0 && mpEntryList->GetAddedHeight( nLastEntry, nTop-1 ) + pLast->getHeightWithMargin() <= nWHeight ) nTop--; - if ( nTop != mnTop ) - { - ImplClearLayoutData(); - long nDiff = mpEntryList->GetAddedHeight( mnTop, nTop ); - PaintImmediately(); - ImplHideFocusRect(); - mnTop = nTop; - Scroll( 0, nDiff ); - PaintImmediately(); - if( HasFocus() ) - ImplShowFocusRect(); - maScrollHdl.Call( this ); - } + if ( nTop == mnTop ) + return; + + ImplClearLayoutData(); + long nDiff = mpEntryList->GetAddedHeight( mnTop, nTop ); + PaintImmediately(); + ImplHideFocusRect(); + mnTop = nTop; + Scroll( 0, nDiff ); + PaintImmediately(); + if( HasFocus() ) + ImplShowFocusRect(); + maScrollHdl.Call( this ); } void ImplListBoxWindow::ShowProminentEntry( sal_Int32 nEntryPos ) diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx index fc7806d732a7..2061b0b32f22 100644 --- a/vcl/source/control/listbox.cxx +++ b/vcl/source/control/listbox.cxx @@ -213,31 +213,31 @@ IMPL_LINK_NOARG(ListBox, ImplCancelHdl, LinkParamNone*, void) IMPL_LINK( ListBox, ImplSelectionChangedHdl, sal_Int32, nChanged, void ) { - if ( !mpImplLB->IsTrackingSelect() ) + if ( mpImplLB->IsTrackingSelect() ) + return; + + const ImplEntryList* pEntryList = mpImplLB->GetEntryList(); + if ( pEntryList->IsEntryPosSelected( nChanged ) ) { - const ImplEntryList* pEntryList = mpImplLB->GetEntryList(); - if ( pEntryList->IsEntryPosSelected( nChanged ) ) - { - // FIXME? This should've been turned into an ImplPaintEntry some time ago... - if ( nChanged < pEntryList->GetMRUCount() ) - nChanged = pEntryList->FindEntry( pEntryList->GetEntryText( nChanged ) ); - mpImplWin->SetItemPos( nChanged ); - mpImplWin->SetString( mpImplLB->GetEntryList()->GetEntryText( nChanged ) ); - if( mpImplLB->GetEntryList()->HasImages() ) - { - Image aImage = mpImplLB->GetEntryList()->GetEntryImage( nChanged ); - mpImplWin->SetImage( aImage ); - } - } - else + // FIXME? This should've been turned into an ImplPaintEntry some time ago... + if ( nChanged < pEntryList->GetMRUCount() ) + nChanged = pEntryList->FindEntry( pEntryList->GetEntryText( nChanged ) ); + mpImplWin->SetItemPos( nChanged ); + mpImplWin->SetString( mpImplLB->GetEntryList()->GetEntryText( nChanged ) ); + if( mpImplLB->GetEntryList()->HasImages() ) { - mpImplWin->SetItemPos( LISTBOX_ENTRY_NOTFOUND ); - mpImplWin->SetString( OUString() ); - Image aImage; + Image aImage = mpImplLB->GetEntryList()->GetEntryImage( nChanged ); mpImplWin->SetImage( aImage ); } - mpImplWin->Invalidate(); } + else + { + mpImplWin->SetItemPos( LISTBOX_ENTRY_NOTFOUND ); + mpImplWin->SetString( OUString() ); + Image aImage; + mpImplWin->SetImage( aImage ); + } + mpImplWin->Invalidate(); } IMPL_LINK_NOARG(ListBox, ImplDoubleClickHdl, ImplListBoxWindow*, void) @@ -247,20 +247,20 @@ IMPL_LINK_NOARG(ListBox, ImplDoubleClickHdl, ImplListBoxWindow*, void) IMPL_LINK_NOARG(ListBox, ImplClickBtnHdl, void*, void) { - if( !mpFloatWin->IsInPopupMode() ) - { - CallEventListeners( VclEventId::DropdownPreOpen ); - mpImplWin->GrabFocus(); - mpBtn->SetPressed( true ); - mpFloatWin->StartFloat( true ); - CallEventListeners( VclEventId::DropdownOpen ); + if( mpFloatWin->IsInPopupMode() ) + return; - ImplClearLayoutData(); - if( mpImplLB ) - mpImplLB->GetMainWindow()->ImplClearLayoutData(); - if( mpImplWin ) - mpImplWin->ImplClearLayoutData(); - } + CallEventListeners( VclEventId::DropdownPreOpen ); + mpImplWin->GrabFocus(); + mpBtn->SetPressed( true ); + mpFloatWin->StartFloat( true ); + CallEventListeners( VclEventId::DropdownOpen ); + + ImplClearLayoutData(); + if( mpImplLB ) + mpImplLB->GetMainWindow()->ImplClearLayoutData(); + if( mpImplWin ) + mpImplWin->ImplClearLayoutData(); } IMPL_LINK_NOARG(ListBox, ImplPopupModeEndHdl, FloatingWindow*, void) @@ -295,18 +295,18 @@ IMPL_LINK_NOARG(ListBox, ImplPopupModeEndHdl, FloatingWindow*, void) void ListBox::ToggleDropDown() { - if( IsDropDownBox() ) + if( !IsDropDownBox() ) + return; + + if( mpFloatWin->IsInPopupMode() ) + mpFloatWin->EndPopupMode(); + else { - if( mpFloatWin->IsInPopupMode() ) - mpFloatWin->EndPopupMode(); - else - { - CallEventListeners( VclEventId::DropdownPreOpen ); - mpImplWin->GrabFocus(); - mpBtn->SetPressed( true ); - mpFloatWin->StartFloat( true ); - CallEventListeners( VclEventId::DropdownOpen ); - } + CallEventListeners( VclEventId::DropdownPreOpen ); + mpImplWin->GrabFocus(); + mpBtn->SetPressed( true ); + mpFloatWin->StartFloat( true ); + CallEventListeners( VclEventId::DropdownOpen ); } } @@ -470,28 +470,28 @@ void ListBox::DataChanged( const DataChangedEvent& rDCEvt ) { Control::DataChanged( rDCEvt ); - if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) || + if ( !((rDCEvt.GetType() == DataChangedEventType::FONTS) || (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) || ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && - (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) ) - { - SetBackground(); // Due to a hack in Window::UpdateSettings the background must be reset - // otherwise it will overpaint NWF drawn listboxes - Resize(); - mpImplLB->Resize(); // Is not called by ListBox::Resize() if the ImplLB does not change + (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))) ) + return; - if ( mpImplWin ) - { - mpImplWin->SetSettings( GetSettings() ); // If not yet set... - mpImplWin->ApplySettings(*mpImplWin); + SetBackground(); // Due to a hack in Window::UpdateSettings the background must be reset + // otherwise it will overpaint NWF drawn listboxes + Resize(); + mpImplLB->Resize(); // Is not called by ListBox::Resize() if the ImplLB does not change - mpBtn->SetSettings( GetSettings() ); - ImplInitDropDownButton( mpBtn ); - } + if ( mpImplWin ) + { + mpImplWin->SetSettings( GetSettings() ); // If not yet set... + mpImplWin->ApplySettings(*mpImplWin); - if ( IsDropDownBox() ) - Invalidate(); + mpBtn->SetSettings( GetSettings() ); + ImplInitDropDownButton( mpBtn ); } + + if ( IsDropDownBox() ) + Invalidate(); } void ListBox::EnableAutoSize( bool bAuto ) diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx index 7082042df261..0f61ea90b496 100644 --- a/vcl/source/control/prgsbar.cxx +++ b/vcl/source/control/prgsbar.cxx @@ -92,25 +92,25 @@ void ProgressBar::ImplInitSettings( bool bFont, } } - if ( bForeground || bFont ) + if ( !(bForeground || bFont) ) + return; + + Color aColor = rStyleSettings.GetHighlightColor(); + if ( IsControlForeground() ) + aColor = GetControlForeground(); + if ( aColor.IsRGBEqual( GetBackground().GetColor() ) ) { - Color aColor = rStyleSettings.GetHighlightColor(); - if ( IsControlForeground() ) - aColor = GetControlForeground(); - if ( aColor.IsRGBEqual( GetBackground().GetColor() ) ) - { - if ( aColor.GetLuminance() > 100 ) - aColor.DecreaseLuminance( 64 ); - else - aColor.IncreaseLuminance( 64 ); - } - SetLineColor(); - SetFillColor( aColor ); + if ( aColor.GetLuminance() > 100 ) + aColor.DecreaseLuminance( 64 ); + else + aColor.IncreaseLuminance( 64 ); + } + SetLineColor(); + SetFillColor( aColor ); /* FIXME: !!! We do not support text output at the moment - SetTextColor( aColor ); - SetTextFillColor(); + SetTextColor( aColor ); + SetTextFillColor(); */ - } } void ProgressBar::ImplDrawProgress(vcl::RenderContext& rRenderContext, sal_uInt16 nNewPerc) diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx index 8e008465e279..01b645c1b80c 100644 --- a/vcl/source/control/scrbar.cxx +++ b/vcl/source/control/scrbar.cxx @@ -799,34 +799,34 @@ void ScrollBar::ImplDragThumb( const Point& rMousePos ) nMovePix = rMousePos.Y()-(maThumbRect.Top()+mnMouseOff); // Move thumb if necessary - if ( nMovePix ) - { - mnThumbPixPos += nMovePix; - if ( mnThumbPixPos < 0 ) - mnThumbPixPos = 0; - if ( mnThumbPixPos > (mnThumbPixRange-mnThumbPixSize) ) - mnThumbPixPos = mnThumbPixRange-mnThumbPixSize; - long nOldPos = mnThumbPos; - mnThumbPos = ImplCalcThumbPos( mnThumbPixPos ); - ImplUpdateRects(); - if ( mbFullDrag && (nOldPos != mnThumbPos) ) - { - // When dragging in windows the repaint request gets starved so dragging - // the scrollbar feels slower than it actually is. Let's force an immediate - // repaint of the scrollbar. - if (SupportsDoubleBuffering()) - { - Invalidate(); - PaintImmediately(); - } - else - ImplDraw(*this); + if ( !nMovePix ) + return; - mnDelta = mnThumbPos-nOldPos; - Scroll(); - mnDelta = 0; - } + mnThumbPixPos += nMovePix; + if ( mnThumbPixPos < 0 ) + mnThumbPixPos = 0; + if ( mnThumbPixPos > (mnThumbPixRange-mnThumbPixSize) ) + mnThumbPixPos = mnThumbPixRange-mnThumbPixSize; + long nOldPos = mnThumbPos; + mnThumbPos = ImplCalcThumbPos( mnThumbPixPos ); + ImplUpdateRects(); + if ( !(mbFullDrag && (nOldPos != mnThumbPos)) ) + return; + + // When dragging in windows the repaint request gets starved so dragging + // the scrollbar feels slower than it actually is. Let's force an immediate + // repaint of the scrollbar. + if (SupportsDoubleBuffering()) + { + Invalidate(); + PaintImmediately(); } + else + ImplDraw(*this); + + mnDelta = mnThumbPos-nOldPos; + Scroll(); + mnDelta = 0; } void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt ) @@ -951,19 +951,19 @@ void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt ) } // Should we start Tracking? - if ( meScrollType != ScrollType::DontKnow ) - { - // store original position for cancel and EndScroll delta - mnStartPos = mnThumbPos; - // #92906# Call StartTracking() before ImplDoMouseAction(), otherwise - // MouseButtonUp() / EndTracking() may be called if somebody is spending - // a lot of time in the scroll handler - StartTracking( nTrackFlags ); - ImplDoMouseAction( rMousePos ); - - if( bDragToMouse ) - ImplDragThumb( rMousePos ); - } + if ( meScrollType == ScrollType::DontKnow ) + return; + + // store original position for cancel and EndScroll delta + mnStartPos = mnThumbPos; + // #92906# Call StartTracking() before ImplDoMouseAction(), otherwise + // MouseButtonUp() / EndTracking() may be called if somebody is spending + // a lot of time in the scroll handler + StartTracking( nTrackFlags ); + ImplDoMouseAction( rMousePos ); + + if( bDragToMouse ) + ImplDragThumb( rMousePos ); } @@ -1344,20 +1344,19 @@ void ScrollBar::SetRange( const Range& rRange ) long nNewMaxRange = aRange.Max(); // If Range differs, set a new one - if ( (mnMinRange != nNewMinRange) || - (mnMaxRange != nNewMaxRange) ) - { - mnMinRange = nNewMinRange; - mnMaxRange = nNewMaxRange; + if ( (mnMinRange == nNewMinRange) && (mnMaxRange == nNewMaxRange)) + return; - // Adapt Thumb - if ( mnThumbPos > mnMaxRange-mnVisibleSize ) - mnThumbPos = mnMaxRange-mnVisibleSize; - if ( mnThumbPos < mnMinRange ) - mnThumbPos = mnMinRange; + mnMinRange = nNewMinRange; + mnMaxRange = nNewMaxRange; - CompatStateChanged( StateChangedType::Data ); - } + // Adapt Thumb + if ( mnThumbPos > mnMaxRange-mnVisibleSize ) + mnThumbPos = mnMaxRange-mnVisibleSize; + if ( mnThumbPos < mnMinRange ) + mnThumbPos = mnMinRange; + + CompatStateChanged( StateChangedType::Data ); } void ScrollBar::SetThumbPos( long nNewThumbPos ) diff --git a/vcl/source/control/slider.cxx b/vcl/source/control/slider.cxx index 61841ef4c216..24c84d0a3a3e 100644 --- a/vcl/source/control/slider.cxx +++ b/vcl/source/control/slider.cxx @@ -178,27 +178,27 @@ void Slider::ImplUpdateRects( bool bUpdate ) maThumbRect.SetEmpty(); } - if ( bUpdate ) + if ( !bUpdate ) + return; + + if ( aOldThumbRect == maThumbRect ) + return; + + if( bInvalidateAll ) + Invalidate(InvalidateFlags::NoChildren | InvalidateFlags::NoErase); + else { - if ( aOldThumbRect != maThumbRect ) - { - if( bInvalidateAll ) - Invalidate(InvalidateFlags::NoChildren | InvalidateFlags::NoErase); - else - { - vcl::Region aInvalidRegion( aOldThumbRect ); - aInvalidRegion.Union( maThumbRect ); + vcl::Region aInvalidRegion( aOldThumbRect ); + aInvalidRegion.Union( maThumbRect ); - if( !IsBackground() && GetParent() ) - { - const Point aPos( GetPosPixel() ); - aInvalidRegion.Move( aPos.X(), aPos.Y() ); - GetParent()->Invalidate( aInvalidRegion, InvalidateFlags::Transparent | InvalidateFlags::Update ); - } - else - Invalidate( aInvalidRegion ); - } + if( !IsBackground() && GetParent() ) + { + const Point aPos( GetPosPixel() ); + aInvalidRegion.Move( aPos.X(), aPos.Y() ); + GetParent()->Invalidate( aInvalidRegion, InvalidateFlags::Transparent | InvalidateFlags::Update ); } + else + Invalidate( aInvalidRegion ); } } @@ -444,21 +444,21 @@ void Slider::ImplDraw(vcl::RenderContext& rRenderContext) } } - if (!maThumbRect.IsEmpty()) + if (maThumbRect.IsEmpty()) + return; + + if (bEnabled) { - if (bEnabled) - { - nStyle = DrawButtonFlags::NONE; - if (mnStateFlags & SLIDER_STATE_THUMB_DOWN) - nStyle |= DrawButtonFlags::Pressed; - aDecoView.DrawButton(maThumbRect, nStyle); - } - else - { - rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); - rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor()); - rRenderContext.DrawRect(maThumbRect); - } + nStyle = DrawButtonFlags::NONE; + if (mnStateFlags & SLIDER_STATE_THUMB_DOWN) + nStyle |= DrawButtonFlags::Pressed; + aDecoView.DrawButton(maThumbRect, nStyle); + } + else + { + rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); + rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor()); + rRenderContext.DrawRect(maThumbRect); } } @@ -604,43 +604,43 @@ void Slider::ImplDoSlideAction( ScrollType eScrollType ) void Slider::MouseButtonDown( const MouseEvent& rMEvt ) { - if ( rMEvt.IsLeft() ) - { - const Point& rMousePos = rMEvt.GetPosPixel(); - StartTrackingFlags nTrackFlags = StartTrackingFlags::NONE; + if ( !rMEvt.IsLeft() ) + return; - if ( maThumbRect.IsInside( rMousePos ) ) - { - meScrollType = ScrollType::Drag; + const Point& rMousePos = rMEvt.GetPosPixel(); + StartTrackingFlags nTrackFlags = StartTrackingFlags::NONE; - // calculate additional values - Point aCenterPos = maThumbRect.Center(); - if ( GetStyle() & WB_HORZ ) - mnMouseOff = rMousePos.X()-aCenterPos.X(); - else - mnMouseOff = rMousePos.Y()-aCenterPos.Y(); - } - else if ( ImplIsPageUp( rMousePos ) ) - { - nTrackFlags = StartTrackingFlags::ButtonRepeat; - meScrollType = ScrollType::PageUp; - } - else if ( ImplIsPageDown( rMousePos ) ) - { - nTrackFlags = StartTrackingFlags::ButtonRepeat; - meScrollType = ScrollType::PageDown; - } + if ( maThumbRect.IsInside( rMousePos ) ) + { + meScrollType = ScrollType::Drag; - // Shall we start Tracking? - if( meScrollType != ScrollType::DontKnow ) - { - // store Start position for cancel and EndScroll delta - mnStartPos = mnThumbPos; - ImplDoMouseAction( rMousePos, /*bCallAction*/true ); - PaintImmediately(); + // calculate additional values + Point aCenterPos = maThumbRect.Center(); + if ( GetStyle() & WB_HORZ ) + mnMouseOff = rMousePos.X()-aCenterPos.X(); + else + mnMouseOff = rMousePos.Y()-aCenterPos.Y(); + } + else if ( ImplIsPageUp( rMousePos ) ) + { + nTrackFlags = StartTrackingFlags::ButtonRepeat; + meScrollType = ScrollType::PageUp; + } + else if ( ImplIsPageDown( rMousePos ) ) + { + nTrackFlags = StartTrackingFlags::ButtonRepeat; + meScrollType = ScrollType::PageDown; + } - StartTracking( nTrackFlags ); - } + // Shall we start Tracking? + if( meScrollType != ScrollType::DontKnow ) + { + // store Start position for cancel and EndScroll delta + mnStartPos = mnThumbPos; + ImplDoMouseAction( rMousePos, /*bCallAction*/true ); + PaintImmediately(); + + StartTracking( nTrackFlags ); } } diff --git a/vcl/source/control/spinbtn.cxx b/vcl/source/control/spinbtn.cxx index 35e67a1b557a..531c90222233 100644 --- a/vcl/source/control/spinbtn.cxx +++ b/vcl/source/control/spinbtn.cxx @@ -353,20 +353,19 @@ void SpinButton::SetRange( const Range& rRange ) long nNewMaxRange = aRange.Max(); // do something only if old and new range differ - if ( (mnMinRange != nNewMinRange) || - (mnMaxRange != nNewMaxRange) ) - { - mnMinRange = nNewMinRange; - mnMaxRange = nNewMaxRange; + if ( (mnMinRange == nNewMinRange) && (mnMaxRange == nNewMaxRange)) + return; - // adjust value to new range, if necessary - if ( mnValue > mnMaxRange ) - mnValue = mnMaxRange; - if ( mnValue < mnMinRange ) - mnValue = mnMinRange; + mnMinRange = nNewMinRange; + mnMaxRange = nNewMaxRange; - CompatStateChanged( StateChangedType::Data ); - } + // adjust value to new range, if necessary + if ( mnValue > mnMaxRange ) + mnValue = mnMaxRange; + if ( mnValue < mnMinRange ) + mnValue = mnMinRange; + + CompatStateChanged( StateChangedType::Data ); } void SpinButton::SetValue( long nValue ) diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx index 9f560b50be2b..d9298ae1598a 100644 --- a/vcl/source/control/spinfld.cxx +++ b/vcl/source/control/spinfld.cxx @@ -305,35 +305,35 @@ void SpinField::ImplInit(vcl::Window* pParent, WinBits nWinStyle) { Edit::ImplInit( pParent, nWinStyle ); - if (nWinStyle & (WB_SPIN | WB_DROPDOWN)) - { - mbSpin = true; + if (!(nWinStyle & (WB_SPIN | WB_DROPDOWN))) + return; - // Some themes want external spin buttons, therefore the main - // spinfield should not overdraw the border between its encapsulated - // edit field and the spin buttons - if ((nWinStyle & WB_SPIN) && ImplUseNativeBorder(*this, nWinStyle)) - { - SetBackground(); - mpEdit.set(VclPtr<Edit>::Create(this, WB_NOBORDER)); - mpEdit->SetBackground(); - } - else - mpEdit.set(VclPtr<Edit>::Create(this, WB_NOBORDER)); + mbSpin = true; - mpEdit->EnableRTL(false); - mpEdit->SetPosPixel(Point()); - mpEdit->Show(); + // Some themes want external spin buttons, therefore the main + // spinfield should not overdraw the border between its encapsulated + // edit field and the spin buttons + if ((nWinStyle & WB_SPIN) && ImplUseNativeBorder(*this, nWinStyle)) + { + SetBackground(); + mpEdit.set(VclPtr<Edit>::Create(this, WB_NOBORDER)); + mpEdit->SetBackground(); + } + else + mpEdit.set(VclPtr<Edit>::Create(this, WB_NOBORDER)); - SetSubEdit(mpEdit); + mpEdit->EnableRTL(false); + mpEdit->SetPosPixel(Point()); + mpEdit->Show(); - maRepeatTimer.SetInvokeHandler(LINK( this, SpinField, ImplTimeout)); - maRepeatTimer.SetTimeout(MouseSettings::GetButtonStartRepeat()); - if (nWinStyle & WB_REPEAT) - mbRepeat = true; + SetSubEdit(mpEdit); - SetCompoundControl(true); - } + maRepeatTimer.SetInvokeHandler(LINK( this, SpinField, ImplTimeout)); + maRepeatTimer.SetTimeout(MouseSettings::GetButtonStartRepeat()); + if (nWinStyle & WB_REPEAT) + mbRepeat = true; + + SetCompoundControl(true); } SpinField::SpinField(vcl::Window* pParent, WinBits nWinStyle, WindowType nType) : @@ -686,63 +686,63 @@ void SpinField::ImplCalcButtonAreas(OutputDevice* pDev, const Size& rOutSz, tool void SpinField::Resize() { - if (mbSpin) - { - Control::Resize(); - Size aSize = GetOutputSizePixel(); - bool bSubEditPositioned = false; + if (!mbSpin) + return; - if (GetStyle() & (WB_SPIN | WB_DROPDOWN)) - { - ImplCalcButtonAreas( this, aSize, maDropDownRect, maUpperRect, maLowerRect ); + Control::Resize(); + Size aSize = GetOutputSizePixel(); + bool bSubEditPositioned = false; - ImplControlValue aControlValue; - Point aPoint; - tools::Rectangle aContent, aBound; + if (GetStyle() & (WB_SPIN | WB_DROPDOWN)) + { + ImplCalcButtonAreas( this, aSize, maDropDownRect, maUpperRect, maLowerRect ); - // use the full extent of the control - vcl::Window *pBorder = GetWindow( GetWindowType::Border ); - tools::Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() ); + ImplControlValue aControlValue; + Point aPoint; + tools::Rectangle aContent, aBound; - // adjust position and size of the edit field - if (GetNativeControlRegion(ControlType::Spinbox, ControlPart::SubEdit, aArea, ControlState::NONE, - aControlValue, aBound, aContent) && - // there is just no useful native support for spinfields with dropdown - !(GetStyle() & WB_DROPDOWN)) - { - // convert back from border space to local coordinates - aPoint = pBorder->ScreenToOutputPixel(OutputToScreenPixel(aPoint)); - aContent.Move(-aPoint.X(), -aPoint.Y()); + // use the full extent of the control + vcl::Window *pBorder = GetWindow( GetWindowType::Border ); + tools::Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() ); - // use the themes drop down size - mpEdit->SetPosPixel( aContent.TopLeft() ); - bSubEditPositioned = true; - aSize = aContent.GetSize(); - } - else - { - if (maUpperRect.IsEmpty()) - { - SAL_WARN_IF( maDropDownRect.IsEmpty(), "vcl", "SpinField::Resize: SPIN && DROPDOWN, but all empty rects?" ); - aSize.setWidth( maDropDownRect.Left() ); - } - else - aSize.setWidth( maUpperRect.Left() ); - } + // adjust position and size of the edit field + if (GetNativeControlRegion(ControlType::Spinbox, ControlPart::SubEdit, aArea, ControlState::NONE, + aControlValue, aBound, aContent) && + // there is just no useful native support for spinfields with dropdown + !(GetStyle() & WB_DROPDOWN)) + { + // convert back from border space to local coordinates + aPoint = pBorder->ScreenToOutputPixel(OutputToScreenPixel(aPoint)); + aContent.Move(-aPoint.X(), -aPoint.Y()); + + // use the themes drop down size + mpEdit->SetPosPixel( aContent.TopLeft() ); + bSubEditPositioned = true; + aSize = aContent.GetSize(); } - - if (!bSubEditPositioned) + else { - // this moves our sub edit if RTL gets switched - mpEdit->SetPosPixel(Point()); + if (maUpperRect.IsEmpty()) + { + SAL_WARN_IF( maDropDownRect.IsEmpty(), "vcl", "SpinField::Resize: SPIN && DROPDOWN, but all empty rects?" ); + aSize.setWidth( maDropDownRect.Left() ); + } + else + aSize.setWidth( maUpperRect.Left() ); } - mpEdit->SetSizePixel(aSize); + } - if (GetStyle() & WB_SPIN) - Invalidate(tools::Rectangle(maUpperRect.TopLeft(), maLowerRect.BottomRight())); - if (GetStyle() & WB_DROPDOWN) - Invalidate(maDropDownRect); + if (!bSubEditPositioned) + { + // this moves our sub edit if RTL gets switched + mpEdit->SetPosPixel(Point()); } + mpEdit->SetSizePixel(aSize); + + if (GetStyle() & WB_SPIN) + Invalidate(tools::Rectangle(maUpperRect.TopLeft(), maLowerRect.BottomRight())); + if (GetStyle() & WB_DROPDOWN) + Invalidate(maDropDownRect); } void SpinField::StateChanged(StateChangedType nType) diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 728e4c379858..b5275f6cb539 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -143,34 +143,34 @@ void TabControl::ImplInitSettings( bool bBackground ) { Control::ImplInitSettings(); - if ( bBackground ) + if ( !bBackground ) + return; + + vcl::Window* pParent = GetParent(); + if ( !IsControlBackground() && + (pParent->IsChildTransparentModeEnabled() + || IsNativeControlSupported(ControlType::TabPane, ControlPart::Entire) + || IsNativeControlSupported(ControlType::TabItem, ControlPart::Entire) ) ) + + { + // set transparent mode for NWF tabcontrols to have + // the background always cleared properly + EnableChildTransparentMode(); + SetParentClipMode( ParentClipMode::NoClip ); + SetPaintTransparent( true ); + SetBackground(); + ImplGetWindowImpl()->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects; + } + else { - vcl::Window* pParent = GetParent(); - if ( !IsControlBackground() && - (pParent->IsChildTransparentModeEnabled() - || IsNativeControlSupported(ControlType::TabPane, ControlPart::Entire) - || IsNativeControlSupported(ControlType::TabItem, ControlPart::Entire) ) ) + EnableChildTransparentMode( false ); + SetParentClipMode(); + SetPaintTransparent( false ); - { - // set transparent mode for NWF tabcontrols to have - // the background always cleared properly - EnableChildTransparentMode(); - SetParentClipMode( ParentClipMode::NoClip ); - SetPaintTransparent( true ); - SetBackground(); - ImplGetWindowImpl()->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects; - } + if ( IsControlBackground() ) + SetBackground( GetControlBackground() ); else - { - EnableChildTransparentMode( false ); - SetParentClipMode(); - SetPaintTransparent( false ); - - if ( IsControlBackground() ) - SetBackground( GetControlBackground() ); - else - SetBackground( pParent->GetBackground() ); - } + SetBackground( pParent->GetBackground() ); } } @@ -1674,68 +1674,68 @@ void TabControl::RemovePage( sal_uInt16 nPageId ) sal_uInt16 nPos = GetPagePos( nPageId ); // does the item exist ? - if ( nPos != TAB_PAGE_NOTFOUND ) + if ( nPos == TAB_PAGE_NOTFOUND ) + return; + + //remove page item + std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin() + nPos; + bool bIsCurrentPage = (it->id() == mnCurPageId); + mpTabCtrlData->maItemList.erase( it ); + if( mpTabCtrlData->mpListBox ) { - //remove page item - std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin() + nPos; - bool bIsCurrentPage = (it->id() == mnCurPageId); - mpTabCtrlData->maItemList.erase( it ); - if( mpTabCtrlData->mpListBox ) - { - mpTabCtrlData->mpListBox->RemoveEntry( nPos ); - mpTabCtrlData->mpListBox->SetDropDownLineCount( mpTabCtrlData->mpListBox->GetEntryCount() ); - } + mpTabCtrlData->mpListBox->RemoveEntry( nPos ); + mpTabCtrlData->mpListBox->SetDropDownLineCount( mpTabCtrlData->mpListBox->GetEntryCount() ); + } - // If current page is removed, then first page gets the current page - if ( bIsCurrentPage ) - { - mnCurPageId = 0; + // If current page is removed, then first page gets the current page + if ( bIsCurrentPage ) + { + mnCurPageId = 0; - if( ! mpTabCtrlData->maItemList.empty() ) - { - // don't do this by simply setting mnCurPageId to pFirstItem->id() - // this leaves a lot of stuff (such trivia as _showing_ the new current page) undone - // instead, call SetCurPageId - // without this, the next (outside) call to SetCurPageId with the id of the first page - // will result in doing nothing (as we assume that nothing changed, then), and the page - // will never be shown. - // 86875 - 05/11/2001 - frank.schoenheit@germany.sun.com - - SetCurPageId(mpTabCtrlData->maItemList[0].id()); - } + if( ! mpTabCtrlData->maItemList.empty() ) + { + // don't do this by simply setting mnCurPageId to pFirstItem->id() + // this leaves a lot of stuff (such trivia as _showing_ the new current page) undone + // instead, call SetCurPageId + // without this, the next (outside) call to SetCurPageId with the id of the first page + // will result in doing nothing (as we assume that nothing changed, then), and the page + // will never be shown. + // 86875 - 05/11/2001 - frank.schoenheit@germany.sun.com + + SetCurPageId(mpTabCtrlData->maItemList[0].id()); } + } - mbFormat = true; - if ( IsUpdateMode() ) - Invalidate(); + mbFormat = true; + if ( IsUpdateMode() ) + Invalidate(); - ImplFreeLayoutData(); + ImplFreeLayoutData(); - CallEventListeners( VclEventId::TabpageRemoved, reinterpret_cast<void*>(nPageId) ); - } + CallEventListeners( VclEventId::TabpageRemoved, reinterpret_cast<void*>(nPageId) ); } void TabControl::SetPageEnabled( sal_uInt16 i_nPageId, bool i_bEnable ) { ImplTabItem* pItem = ImplGetItem( i_nPageId ); - if (pItem && pItem->m_bEnabled != i_bEnable) - { - pItem->m_bEnabled = i_bEnable; - if (!pItem->m_bVisible) - return; + if (!pItem || pItem->m_bEnabled == i_bEnable) + return; - mbFormat = true; - if( mpTabCtrlData->mpListBox ) - mpTabCtrlData->mpListBox->SetEntryFlags( GetPagePos( i_nPageId ), - i_bEnable ? ListBoxEntryFlags::NONE : (ListBoxEntryFlags::DisableSelection | ListBoxEntryFlags::DrawDisabled) ); + pItem->m_bEnabled = i_bEnable; + if (!pItem->m_bVisible) + return; - // SetCurPageId will change to a valid page - if (pItem->id() == mnCurPageId) - SetCurPageId( mnCurPageId ); - else if ( IsUpdateMode() ) - Invalidate(); - } + mbFormat = true; + if( mpTabCtrlData->mpListBox ) + mpTabCtrlData->mpListBox->SetEntryFlags( GetPagePos( i_nPageId ), + i_bEnable ? ListBoxEntryFlags::NONE : (ListBoxEntryFlags::DisableSelection | ListBoxEntryFlags::DrawDisabled) ); + + // SetCurPageId will change to a valid page + if (pItem->id() == mnCurPageId) + SetCurPageId( mnCurPageId ); + else if ( IsUpdateMode() ) + Invalidate(); } void TabControl::SetPageVisible( sal_uInt16 nPageId, bool bVisible ) @@ -1814,25 +1814,25 @@ void TabControl::SetCurPageId( sal_uInt16 nPageId ) break; } - if( nPos != TAB_PAGE_NOTFOUND ) - { - nPageId = mpTabCtrlData->maItemList[nPos].id(); - if ( nPageId == mnCurPageId ) - { - if ( mnActPageId ) - mnActPageId = nPageId; - return; - } + if( nPos == TAB_PAGE_NOTFOUND ) + return; + nPageId = mpTabCtrlData->maItemList[nPos].id(); + if ( nPageId == mnCurPageId ) + { if ( mnActPageId ) mnActPageId = nPageId; - else - { - mbFormat = true; - sal_uInt16 nOldId = mnCurPageId; - mnCurPageId = nPageId; - ImplChangeTabPage( nPageId, nOldId ); - } + return; + } + + if ( mnActPageId ) + mnActPageId = nPageId; + else + { + mbFormat = true; + sal_uInt16 nOldId = mnCurPageId; + mnCurPageId = nPageId; + ImplChangeTabPage( nPageId, nOldId ); } } @@ -1846,23 +1846,23 @@ sal_uInt16 TabControl::GetCurPageId() const void TabControl::SelectTabPage( sal_uInt16 nPageId ) { - if ( nPageId && (nPageId != mnCurPageId) ) - { - ImplFreeLayoutData(); + if ( !nPageId || (nPageId == mnCurPageId) ) + return; - CallEventListeners( VclEventId::TabpageDeactivate, reinterpret_cast<void*>(mnCurPageId) ); - if ( DeactivatePage() ) - { - mnActPageId = nPageId; - ActivatePage(); - // Page could have been switched by the Activate handler - nPageId = mnActPageId; - mnActPageId = 0; - SetCurPageId( nPageId ); - if( mpTabCtrlData->mpListBox ) - mpTabCtrlData->mpListBox->SelectEntryPos( GetPagePos( nPageId ) ); - CallEventListeners( VclEventId::TabpageActivate, reinterpret_cast<void*>(nPageId) ); - } + ImplFreeLayoutData(); + + CallEventListeners( VclEventId::TabpageDeactivate, reinterpret_cast<void*>(mnCurPageId) ); + if ( DeactivatePage() ) + { + mnActPageId = nPageId; + ActivatePage(); + // Page could have been switched by the Activate handler + nPageId = mnActPageId; + mnActPageId = 0; + SetCurPageId( nPageId ); + if( mpTabCtrlData->mpListBox ) + mpTabCtrlData->mpListBox->SelectEntryPos( GetPagePos( nPageId ) ); + CallEventListeners( VclEventId::TabpageActivate, reinterpret_cast<void*>(nPageId) ); } } @@ -1870,25 +1870,25 @@ void TabControl::SetTabPage( sal_uInt16 nPageId, TabPage* pTabPage ) { ImplTabItem* pItem = ImplGetItem( nPageId ); - if ( pItem && (pItem->mpTabPage.get() != pTabPage) ) + if ( !pItem || (pItem->mpTabPage.get() == pTabPage) ) + return; + + if ( pTabPage ) { - if ( pTabPage ) - { - if ( IsDefaultSize() ) - SetTabPageSizePixel( pTabPage->GetSizePixel() ); + if ( IsDefaultSize() ) + SetTabPageSizePixel( pTabPage->GetSizePixel() ); - // only set here, so that Resize does not reposition TabPage - pItem->mpTabPage = pTabPage; - queue_resize(); + // only set here, so that Resize does not reposition TabPage + pItem->mpTabPage = pTabPage; + queue_resize(); - if (pItem->id() == mnCurPageId) - ImplChangeTabPage(pItem->id(), 0); - } - else - { - pItem->mpTabPage = nullptr; - queue_resize(); - } + if (pItem->id() == mnCurPageId) + ImplChangeTabPage(pItem->id(), 0); + } + else + { + pItem->mpTabPage = nullptr; + queue_resize(); } } @@ -1906,21 +1906,21 @@ void TabControl::SetPageText( sal_uInt16 nPageId, const OUString& rText ) { ImplTabItem* pItem = ImplGetItem( nPageId ); - if ( pItem && pItem->maText != rText ) + if ( !pItem || pItem->maText == rText ) + return; + + pItem->maText = rText; + mbFormat = true; + if( mpTabCtrlData->mpListBox ) { - pItem->maText = rText; - mbFormat = true; - if( mpTabCtrlData->mpListBox ) - { - sal_uInt16 nPos = GetPagePos( nPageId ); - mpTabCtrlData->mpListBox->RemoveEntry( nPos ); - mpTabCtrlData->mpListBox->InsertEntry( rText, nPos ); - } - if ( IsUpdateMode() ) - Invalidate(); - ImplFreeLayoutData(); - CallEventListeners( VclEventId::TabpagePageTextChanged, reinterpret_cast<void*>(nPageId) ); + sal_uInt16 nPos = GetPagePos( nPageId ); + mpTabCtrlData->mpListBox->RemoveEntry( nPos ); + mpTabCtrlData->mpListBox->InsertEntry( rText, nPos ); } + if ( IsUpdateMode() ) + Invalidate(); + ImplFreeLayoutData(); + CallEventListeners( VclEventId::TabpagePageTextChanged, reinterpret_cast<void*>(nPageId) ); } OUString const & TabControl::GetPageText( sal_uInt16 nPageId ) const @@ -2203,38 +2203,38 @@ NotebookbarTabControlBase::~NotebookbarTabControlBase() void NotebookbarTabControlBase::SetContext( vcl::EnumContext::Context eContext ) { - if (eLastContext != eContext) + if (eLastContext == eContext) + return; + + bool bHandled = false; + + for (int nChild = 0; nChild < GetPageCount(); ++nChild) { - bool bHandled = false; + sal_uInt16 nPageId = TabControl::GetPageId(nChild); + TabPage* pPage = GetTabPage(nPageId); - for (int nChild = 0; nChild < GetPageCount(); ++nChild) + if (pPage) { - sal_uInt16 nPageId = TabControl::GetPageId(nChild); - TabPage* pPage = GetTabPage(nPageId); + SetPageVisible(nPageId, pPage->HasContext(eContext) || pPage->HasContext(vcl::EnumContext::Context::Any)); - if (pPage) + if (!bHandled && bLastContextWasSupported + && pPage->HasContext(vcl::EnumContext::Context::Default)) { - SetPageVisible(nPageId, pPage->HasContext(eContext) || pPage->HasContext(vcl::EnumContext::Context::Any)); - - if (!bHandled && bLastContextWasSupported - && pPage->HasContext(vcl::EnumContext::Context::Default)) - { - SetCurPageId(nPageId); - } + SetCurPageId(nPageId); + } - if (pPage->HasContext(eContext) && eContext != vcl::EnumContext::Context::Any) - { - SetCurPageId(nPageId); - bHandled = true; - bLastContextWasSupported = true; - } + if (pPage->HasContext(eContext) && eContext != vcl::EnumContext::Context::Any) + { + SetCurPageId(nPageId); + bHandled = true; + bLastContextWasSupported = true; } } - - if (!bHandled) - bLastContextWasSupported = false; - eLastContext = eContext; } + + if (!bHandled) + bLastContextWasSupported = false; + eLastContext = eContext; } void NotebookbarTabControlBase::dispose() diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx index 165dbfde9fa9..610b723d5057 100644 --- a/vcl/source/edit/textdata.cxx +++ b/vcl/source/edit/textdata.cxx @@ -232,34 +232,34 @@ void TEParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormat { sal_uInt16 nLines = maLines.size(); SAL_WARN_IF( !nLines, "vcl", "CorrectPortionNumbersFromLine: Empty portion?" ); - if ( nLastFormattedLine < ( nLines - 1 ) ) + if ( nLastFormattedLine >= ( nLines - 1 ) ) + return; + + const TextLine& rLastFormatted = maLines[ nLastFormattedLine ]; + const TextLine& rUnformatted = maLines[ nLastFormattedLine+1 ]; + std::ptrdiff_t nPortionDiff = rUnformatted.GetStartPortion() - rLastFormatted.GetEndPortion(); + sal_Int32 nTextDiff = rUnformatted.GetStart() - rLastFormatted.GetEnd(); + nTextDiff++; // LastFormatted.GetEnd() was inclusive => subtracted one too much! + + // The first unformatted one has to start exactly one portion past the last + // formatted one. + // If a portion got split in the changed row, nLastEnd could be > nNextStart! + std::ptrdiff_t nPDiff = -( nPortionDiff-1 ); + const sal_Int32 nTDiff = -( nTextDiff-1 ); + if ( !(nPDiff || nTDiff) ) + return; + + for ( sal_uInt16 nL = nLastFormattedLine+1; nL < nLines; nL++ ) { - const TextLine& rLastFormatted = maLines[ nLastFormattedLine ]; - const TextLine& rUnformatted = maLines[ nLastFormattedLine+1 ]; - std::ptrdiff_t nPortionDiff = rUnformatted.GetStartPortion() - rLastFormatted.GetEndPortion(); - sal_Int32 nTextDiff = rUnformatted.GetStart() - rLastFormatted.GetEnd(); - nTextDiff++; // LastFormatted.GetEnd() was inclusive => subtracted one too much! - - // The first unformatted one has to start exactly one portion past the last - // formatted one. - // If a portion got split in the changed row, nLastEnd could be > nNextStart! - std::ptrdiff_t nPDiff = -( nPortionDiff-1 ); - const sal_Int32 nTDiff = -( nTextDiff-1 ); - if ( nPDiff || nTDiff ) - { - for ( sal_uInt16 nL = nLastFormattedLine+1; nL < nLines; nL++ ) - { - TextLine& rLine = maLines[ nL ]; + TextLine& rLine = maLines[ nL ]; - rLine.SetStartPortion(rLine.GetStartPortion() + nPDiff); - rLine.SetEndPortion(rLine.GetEndPortion() + nPDiff); + rLine.SetStartPortion(rLine.GetStartPortion() + nPDiff); + rLine.SetEndPortion(rLine.GetEndPortion() + nPDiff); - rLine.SetStart(rLine.GetStart() + nTDiff); - rLine.SetEnd(rLine.GetEnd() + nTDiff); + rLine.SetStart(rLine.GetStart() + nTDiff); + rLine.SetEnd(rLine.GetEnd() + nTDiff); - rLine.SetValid(); - } - } + rLine.SetValid(); } } diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index e5465c52c402..e1cd87a682b6 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -1376,35 +1376,35 @@ void TextEngine::SeekCursor( sal_uInt32 nPara, sal_Int32 nPos, vcl::Font& rFont, } } - if ( mpIMEInfos && mpIMEInfos->pAttribs && ( mpIMEInfos->aPos.GetPara() == nPara ) && - ( nPos > mpIMEInfos->aPos.GetIndex() ) && ( nPos <= ( mpIMEInfos->aPos.GetIndex() + mpIMEInfos->nLen ) ) ) - { - ExtTextInputAttr nAttr = mpIMEInfos->pAttribs[ nPos - mpIMEInfos->aPos.GetIndex() - 1 ]; - if ( nAttr & ExtTextInputAttr::Underline ) - rFont.SetUnderline( LINESTYLE_SINGLE ); - else if ( nAttr & ExtTextInputAttr::BoldUnderline ) - rFont.SetUnderline( LINESTYLE_BOLD ); - else if ( nAttr & ExtTextInputAttr::DottedUnderline ) - rFont.SetUnderline( LINESTYLE_DOTTED ); - else if ( nAttr & ExtTextInputAttr::DashDotUnderline ) - rFont.SetUnderline( LINESTYLE_DOTTED ); - if ( nAttr & ExtTextInputAttr::RedText ) - rFont.SetColor( COL_RED ); - else if ( nAttr & ExtTextInputAttr::HalfToneText ) - rFont.SetColor( COL_LIGHTGRAY ); - if ( nAttr & ExtTextInputAttr::Highlight ) - { - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - rFont.SetColor( rStyleSettings.GetHighlightTextColor() ); - rFont.SetFillColor( rStyleSettings.GetHighlightColor() ); - rFont.SetTransparent( false ); - } - else if ( nAttr & ExtTextInputAttr::GrayWaveline ) - { - rFont.SetUnderline( LINESTYLE_WAVE ); + if ( !(mpIMEInfos && mpIMEInfos->pAttribs && ( mpIMEInfos->aPos.GetPara() == nPara ) && + ( nPos > mpIMEInfos->aPos.GetIndex() ) && ( nPos <= ( mpIMEInfos->aPos.GetIndex() + mpIMEInfos->nLen ) )) ) + return; + + ExtTextInputAttr nAttr = mpIMEInfos->pAttribs[ nPos - mpIMEInfos->aPos.GetIndex() - 1 ]; + if ( nAttr & ExtTextInputAttr::Underline ) + rFont.SetUnderline( LINESTYLE_SINGLE ); + else if ( nAttr & ExtTextInputAttr::BoldUnderline ) + rFont.SetUnderline( LINESTYLE_BOLD ); + else if ( nAttr & ExtTextInputAttr::DottedUnderline ) + rFont.SetUnderline( LINESTYLE_DOTTED ); + else if ( nAttr & ExtTextInputAttr::DashDotUnderline ) + rFont.SetUnderline( LINESTYLE_DOTTED ); + if ( nAttr & ExtTextInputAttr::RedText ) + rFont.SetColor( COL_RED ); + else if ( nAttr & ExtTextInputAttr::HalfToneText ) + rFont.SetColor( COL_LIGHTGRAY ); + if ( nAttr & ExtTextInputAttr::Highlight ) + { + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + rFont.SetColor( rStyleSettings.GetHighlightTextColor() ); + rFont.SetFillColor( rStyleSettings.GetHighlightColor() ); + rFont.SetTransparent( false ); + } + else if ( nAttr & ExtTextInputAttr::GrayWaveline ) + { + rFont.SetUnderline( LINESTYLE_WAVE ); // if( pOut ) // pOut->SetTextLineColor( COL_LIGHTGRAY ); - } } } @@ -2462,20 +2462,20 @@ void TextEngine::Write( SvStream& rOutput ) void TextEngine::RemoveAttribs( sal_uInt32 nPara ) { - if ( nPara < mpDoc->GetNodes().size() ) + if ( nPara >= mpDoc->GetNodes().size() ) + return; + + TextNode* pNode = mpDoc->GetNodes()[ nPara ].get(); + if ( pNode->GetCharAttribs().Count() ) { - TextNode* pNode = mpDoc->GetNodes()[ nPara ].get(); - if ( pNode->GetCharAttribs().Count() ) - { - pNode->GetCharAttribs().Clear(); + pNode->GetCharAttribs().Clear(); - TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPara ); - pTEParaPortion->MarkSelectionInvalid( 0 ); + TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPara ); + pTEParaPortion->MarkSelectionInvalid( 0 ); - mbFormatted = false; + mbFormatted = false; - IdleFormatAndUpdate( nullptr, 0xFFFF ); - } + IdleFormatAndUpdate( nullptr, 0xFFFF ); } } @@ -2487,23 +2487,23 @@ void TextEngine::SetAttrib( const TextAttrib& rAttr, sal_uInt32 nPara, sal_Int32 // As TextEngine is currently intended only for TextEditors, there is no Undo for Attributes! - if ( nPara < mpDoc->GetNodes().size() ) - { - TextNode* pNode = mpDoc->GetNodes()[ nPara ].get(); - TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPara ); + if ( nPara >= mpDoc->GetNodes().size() ) + return; + + TextNode* pNode = mpDoc->GetNodes()[ nPara ].get(); + TEParaPortion* pTEParaPortion = mpTEParaPortions->GetObject( nPara ); - const sal_Int32 nMax = pNode->GetText().getLength(); - if ( nStart > nMax ) - nStart = nMax; - if ( nEnd > nMax ) - nEnd = nMax; + const sal_Int32 nMax = pNode->GetText().getLength(); + if ( nStart > nMax ) + nStart = nMax; + if ( nEnd > nMax ) + nEnd = nMax; - pNode->GetCharAttribs().InsertAttrib( std::make_unique<TextCharAttrib>( rAttr, nStart, nEnd ) ); - pTEParaPortion->MarkSelectionInvalid( nStart ); + pNode->GetCharAttribs().InsertAttrib( std::make_unique<TextCharAttrib>( rAttr, nStart, nEnd ) ); + pTEParaPortion->MarkSelectionInvalid( nStart ); - mbFormatted = false; - IdleFormatAndUpdate( nullptr, 0xFFFF ); - } + mbFormatted = false; + IdleFormatAndUpdate( nullptr, 0xFFFF ); } void TextEngine::SetTextAlign( TxtAlign eAlign ) diff --git a/vcl/source/edit/textundo.cxx b/vcl/source/edit/textundo.cxx index b910be11257b..2e57d0be2a37 100644 --- a/vcl/source/edit/textundo.cxx +++ b/vcl/source/edit/textundo.cxx @@ -36,23 +36,23 @@ namespace void Shorten (OUString& rString) { auto const nLen = rString.getLength(); - if (nLen > 48) - { - // If possible, we don't break a word, hence first we look for a space. - // Space before the ellipsis: - auto iFirst = rString.lastIndexOf(' ', 32); - if (iFirst == -1 || iFirst < 16) - iFirst = 24; // not possible - // Space after the ellipsis: - auto iLast = rString.indexOf(' ', nLen - 16); - if (iLast == -1 || iLast > nLen - 4) - iLast = nLen - 8; // not possible - // finally: - rString = - rString.copy(0, iFirst + 1) + - "..." + - rString.copy(iLast); - } + if (nLen <= 48) + return; + + // If possible, we don't break a word, hence first we look for a space. + // Space before the ellipsis: + auto iFirst = rString.lastIndexOf(' ', 32); + if (iFirst == -1 || iFirst < 16) + iFirst = 24; // not possible + // Space after the ellipsis: + auto iLast = rString.indexOf(' ', nLen - 16); + if (iLast == -1 || iLast > nLen - 4) + iLast = nLen - 8; // not possible + // finally: + rString = + rString.copy(0, iFirst + 1) + + "..." + + rString.copy(iLast); } } // namespace diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index 3582e6742529..f468acd984d7 100644 --- a/vcl/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -304,95 +304,95 @@ void TextView::ImpHighlight( const TextSelection& rSel ) { TextSelection aSel( rSel ); aSel.Justify(); - if ( aSel.HasRange() && !mpImpl->mpTextEngine->IsInUndo() && mpImpl->mpTextEngine->GetUpdateMode() ) - { - mpImpl->mpCursor->Hide(); + if ( !(aSel.HasRange() && !mpImpl->mpTextEngine->IsInUndo() && mpImpl->mpTextEngine->GetUpdateMode()) ) + return; - SAL_WARN_IF( mpImpl->mpTextEngine->mpIdleFormatter->IsActive(), "vcl", "ImpHighlight: Not formatted!" ); + mpImpl->mpCursor->Hide(); + + SAL_WARN_IF( mpImpl->mpTextEngine->mpIdleFormatter->IsActive(), "vcl", "ImpHighlight: Not formatted!" ); - tools::Rectangle aVisArea( mpImpl->maStartDocPos, mpImpl->mpWindow->GetOutputSizePixel() ); - long nY = 0; - const sal_uInt32 nStartPara = aSel.GetStart().GetPara(); - const sal_uInt32 nEndPara = aSel.GetEnd().GetPara(); - for ( sal_uInt32 nPara = 0; nPara <= nEndPara; ++nPara ) + tools::Rectangle aVisArea( mpImpl->maStartDocPos, mpImpl->mpWindow->GetOutputSizePixel() ); + long nY = 0; + const sal_uInt32 nStartPara = aSel.GetStart().GetPara(); + const sal_uInt32 nEndPara = aSel.GetEnd().GetPara(); + for ( sal_uInt32 nPara = 0; nPara <= nEndPara; ++nPara ) + { + const long nParaHeight = mpImpl->mpTextEngine->CalcParaHeight( nPara ); + if ( ( nPara >= nStartPara ) && ( ( nY + nParaHeight ) > aVisArea.Top() ) ) { - const long nParaHeight = mpImpl->mpTextEngine->CalcParaHeight( nPara ); - if ( ( nPara >= nStartPara ) && ( ( nY + nParaHeight ) > aVisArea.Top() ) ) + TEParaPortion* pTEParaPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( nPara ); + std::vector<TextLine>::size_type nStartLine = 0; + std::vector<TextLine>::size_type nEndLine = pTEParaPortion->GetLines().size() -1; + if ( nPara == nStartPara ) + nStartLine = pTEParaPortion->GetLineNumber( aSel.GetStart().GetIndex(), false ); + if ( nPara == nEndPara ) + nEndLine = pTEParaPortion->GetLineNumber( aSel.GetEnd().GetIndex(), true ); + + // iterate over all lines + for ( std::vector<TextLine>::size_type nLine = nStartLine; nLine <= nEndLine; nLine++ ) { - TEParaPortion* pTEParaPortion = mpImpl->mpTextEngine->mpTEParaPortions->GetObject( nPara ); - std::vector<TextLine>::size_type nStartLine = 0; - std::vector<TextLine>::size_type nEndLine = pTEParaPortion->GetLines().size() -1; - if ( nPara == nStartPara ) - nStartLine = pTEParaPortion->GetLineNumber( aSel.GetStart().GetIndex(), false ); - if ( nPara == nEndPara ) - nEndLine = pTEParaPortion->GetLineNumber( aSel.GetEnd().GetIndex(), true ); - - // iterate over all lines - for ( std::vector<TextLine>::size_type nLine = nStartLine; nLine <= nEndLine; nLine++ ) + TextLine& rLine = pTEParaPortion->GetLines()[ nLine ]; + sal_Int32 nStartIndex = rLine.GetStart(); + sal_Int32 nEndIndex = rLine.GetEnd(); + if ( ( nPara == nStartPara ) && ( nLine == nStartLine ) ) + nStartIndex = aSel.GetStart().GetIndex(); + if ( ( nPara == nEndPara ) && ( nLine == nEndLine ) ) + nEndIndex = aSel.GetEnd().GetIndex(); + + // possible if at the beginning of a wrapped line + if ( nEndIndex < nStartIndex ) + nEndIndex = nStartIndex; + + tools::Rectangle aTmpRect( mpImpl->mpTextEngine->GetEditCursor( TextPaM( nPara, nStartIndex ), false ) ); + aTmpRect.AdjustTop(nY ); + aTmpRect.AdjustBottom(nY ); + Point aTopLeft( aTmpRect.TopLeft() ); + + aTmpRect = mpImpl->mpTextEngine->GetEditCursor( TextPaM( nPara, nEndIndex ), true ); + aTmpRect.AdjustTop(nY ); + aTmpRect.AdjustBottom(nY ); + Point aBottomRight( aTmpRect.BottomRight() ); + aBottomRight.AdjustX( -1 ); + + // only paint if in the visible region + if ( ( aTopLeft.X() < aBottomRight.X() ) && ( aBottomRight.Y() >= aVisArea.Top() ) ) { - TextLine& rLine = pTEParaPortion->GetLines()[ nLine ]; - sal_Int32 nStartIndex = rLine.GetStart(); - sal_Int32 nEndIndex = rLine.GetEnd(); - if ( ( nPara == nStartPara ) && ( nLine == nStartLine ) ) - nStartIndex = aSel.GetStart().GetIndex(); - if ( ( nPara == nEndPara ) && ( nLine == nEndLine ) ) - nEndIndex = aSel.GetEnd().GetIndex(); - - // possible if at the beginning of a wrapped line - if ( nEndIndex < nStartIndex ) - nEndIndex = nStartIndex; - - tools::Rectangle aTmpRect( mpImpl->mpTextEngine->GetEditCursor( TextPaM( nPara, nStartIndex ), false ) ); - aTmpRect.AdjustTop(nY ); - aTmpRect.AdjustBottom(nY ); - Point aTopLeft( aTmpRect.TopLeft() ); - - aTmpRect = mpImpl->mpTextEngine->GetEditCursor( TextPaM( nPara, nEndIndex ), true ); - aTmpRect.AdjustTop(nY ); - aTmpRect.AdjustBottom(nY ); - Point aBottomRight( aTmpRect.BottomRight() ); - aBottomRight.AdjustX( -1 ); - - // only paint if in the visible region - if ( ( aTopLeft.X() < aBottomRight.X() ) && ( aBottomRight.Y() >= aVisArea.Top() ) ) - { - Point aPnt1( GetWindowPos( aTopLeft ) ); - Point aPnt2( GetWindowPos( aBottomRight ) ); + Point aPnt1( GetWindowPos( aTopLeft ) ); + Point aPnt2( GetWindowPos( aBottomRight ) ); - tools::Rectangle aRect( aPnt1, aPnt2 ); - mpImpl->mpWindow->Invert( aRect ); - } + tools::Rectangle aRect( aPnt1, aPnt2 ); + mpImpl->mpWindow->Invert( aRect ); } } - nY += nParaHeight; - - if ( nY >= aVisArea.Bottom() ) - break; } + nY += nParaHeight; + + if ( nY >= aVisArea.Bottom() ) + break; } } void TextView::ImpSetSelection( const TextSelection& rSelection ) { - if (rSelection != mpImpl->maSelection) - { - bool bCaret = false, bSelection = false; - const TextPaM &rEnd = rSelection.GetEnd(); - const TextPaM &rOldEnd = mpImpl->maSelection.GetEnd(); - bool bGap = rSelection.HasRange(), bOldGap = mpImpl->maSelection.HasRange(); - if (rEnd != rOldEnd) - bCaret = true; - if (bGap || bOldGap) - bSelection = true; + if (rSelection == mpImpl->maSelection) + return; - mpImpl->maSelection = rSelection; + bool bCaret = false, bSelection = false; + const TextPaM &rEnd = rSelection.GetEnd(); + const TextPaM &rOldEnd = mpImpl->maSelection.GetEnd(); + bool bGap = rSelection.HasRange(), bOldGap = mpImpl->maSelection.HasRange(); + if (rEnd != rOldEnd) + bCaret = true; + if (bGap || bOldGap) + bSelection = true; - if (bSelection) - mpImpl->mpTextEngine->Broadcast(TextHint(SfxHintId::TextViewSelectionChanged)); + mpImpl->maSelection = rSelection; - if (bCaret) - mpImpl->mpTextEngine->Broadcast(TextHint(SfxHintId::TextViewCaretChanged)); - } + if (bSelection) + mpImpl->mpTextEngine->Broadcast(TextHint(SfxHintId::TextViewSelectionChanged)); + + if (bCaret) + mpImpl->mpTextEngine->Broadcast(TextHint(SfxHintId::TextViewCaretChanged)); } void TextView::ShowSelection() @@ -414,26 +414,26 @@ void TextView::ImpShowHideSelection(const TextSelection* pRange) { const TextSelection* pRangeOrSelection = pRange ? pRange : &mpImpl->maSelection; - if ( pRangeOrSelection->HasRange() ) + if ( !pRangeOrSelection->HasRange() ) + return; + + if ( mpImpl->mbHighlightSelection ) { - if ( mpImpl->mbHighlightSelection ) - { - ImpHighlight( *pRangeOrSelection ); - } + ImpHighlight( *pRangeOrSelection ); + } + else + { + if( mpImpl->mpWindow->IsPaintTransparent() ) + mpImpl->mpWindow->Invalidate(); else { - if( mpImpl->mpWindow->IsPaintTransparent() ) - mpImpl->mpWindow->Invalidate(); - else - { - TextSelection aRange( *pRangeOrSelection ); - aRange.Justify(); - bool bVisCursor = mpImpl->mpCursor->IsVisible(); - mpImpl->mpCursor->Hide(); - Invalidate(); - if (bVisCursor) - mpImpl->mpCursor->Show(); - } + TextSelection aRange( *pRangeOrSelection ); + aRange.Justify(); + bool bVisCursor = mpImpl->mpCursor->IsVisible(); + mpImpl->mpCursor->Hide(); + Invalidate(); + if (bVisCursor) + mpImpl->mpCursor->Show(); } } } @@ -715,42 +715,42 @@ void TextView::MouseButtonDown( const MouseEvent& rMouseEvent ) mpImpl->mbClickedInSelection = IsSelectionAtPoint( rMouseEvent.GetPosPixel() ); // special cases - if ( !rMouseEvent.IsShift() && ( rMouseEvent.GetClicks() >= 2 ) ) + if ( rMouseEvent.IsShift() || ( rMouseEvent.GetClicks() < 2 )) + return; + + if ( rMouseEvent.IsMod2() ) { - if ( rMouseEvent.IsMod2() ) - { - HideSelection(); - ImpSetSelection( mpImpl->maSelection.GetEnd() ); - SetCursorAtPoint( rMouseEvent.GetPosPixel() ); // not set by SelectionEngine for MOD2 - } + HideSelection(); + ImpSetSelection( mpImpl->maSelection.GetEnd() ); + SetCursorAtPoint( rMouseEvent.GetPosPixel() ); // not set by SelectionEngine for MOD2 + } - if ( rMouseEvent.GetClicks() == 2 ) + if ( rMouseEvent.GetClicks() == 2 ) + { + // select word + if ( mpImpl->maSelection.GetEnd().GetIndex() < mpImpl->mpTextEngine->GetTextLen( mpImpl->maSelection.GetEnd().GetPara() ) ) { - // select word - if ( mpImpl->maSelection.GetEnd().GetIndex() < mpImpl->mpTextEngine->GetTextLen( mpImpl->maSelection.GetEnd().GetPara() ) ) - { - HideSelection(); - // tdf#57879 - expand selection to include connector punctuations - TextSelection aNewSel; - mpImpl->mpTextEngine->GetWord( mpImpl->maSelection.GetEnd(), &aNewSel.GetStart(), &aNewSel.GetEnd() ); - ImpSetSelection( aNewSel ); - ShowSelection(); - ShowCursor(); - } + HideSelection(); + // tdf#57879 - expand selection to include connector punctuations + TextSelection aNewSel; + mpImpl->mpTextEngine->GetWord( mpImpl->maSelection.GetEnd(), &aNewSel.GetStart(), &aNewSel.GetEnd() ); + ImpSetSelection( aNewSel ); + ShowSelection(); + ShowCursor(); } - else if ( rMouseEvent.GetClicks() == 3 ) + } + else if ( rMouseEvent.GetClicks() == 3 ) + { + // select paragraph + if ( mpImpl->maSelection.GetStart().GetIndex() || ( mpImpl->maSelection.GetEnd().GetIndex() < mpImpl->mpTextEngine->GetTextLen( mpImpl->maSelection.GetEnd().GetPara() ) ) ) { - // select paragraph - if ( mpImpl->maSelection.GetStart().GetIndex() || ( mpImpl->maSelection.GetEnd().GetIndex() < mpImpl->mpTextEngine->GetTextLen( mpImpl->maSelection.GetEnd().GetPara() ) ) ) - { - HideSelection(); - TextSelection aNewSel( mpImpl->maSelection ); - aNewSel.GetStart().GetIndex() = 0; - aNewSel.GetEnd().GetIndex() = mpImpl->mpTextEngine->mpDoc->GetNodes()[ mpImpl->maSelection.GetEnd().GetPara() ]->GetText().getLength(); - ImpSetSelection( aNewSel ); - ShowSelection(); - ShowCursor(); - } + HideSelection(); + TextSelection aNewSel( mpImpl->maSelection ); + aNewSel.GetStart().GetIndex() = 0; + aNewSel.GetEnd().GetIndex() = mpImpl->mpTextEngine->mpDoc->GetNodes()[ mpImpl->maSelection.GetEnd().GetPara() ]->GetText().getLength(); + ImpSetSelection( aNewSel ); + ShowSelection(); + ShowCursor(); } } } @@ -970,23 +970,23 @@ void TextView::Cut() void TextView::Copy( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard ) { - if ( rxClipboard.is() ) - { - TETextDataObject* pDataObj = new TETextDataObject( GetSelected() ); + if ( !rxClipboard.is() ) + return; - SolarMutexReleaser aReleaser; + TETextDataObject* pDataObj = new TETextDataObject( GetSelected() ); - try - { - rxClipboard->setContents( pDataObj, nullptr ); + SolarMutexReleaser aReleaser; - css::uno::Reference< css::datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, css::uno::UNO_QUERY ); - if( xFlushableClipboard.is() ) - xFlushableClipboard->flushClipboard(); - } - catch( const css::uno::Exception& ) - { - } + try + { + rxClipboard->setContents( pDataObj, nullptr ); + + css::uno::Reference< css::datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, css::uno::UNO_QUERY ); + if( xFlushableClipboard.is() ) + xFlushableClipboard->flushClipboard(); + } + catch( const css::uno::Exception& ) + { } } @@ -998,44 +998,44 @@ void TextView::Copy() void TextView::Paste( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard ) { - if ( rxClipboard.is() ) - { - css::uno::Reference< css::datatransfer::XTransferable > xDataObj; + if ( !rxClipboard.is() ) + return; - try - { - SolarMutexReleaser aReleaser; - xDataObj = rxClipboard->getContents(); - } - catch( const css::uno::Exception& ) - { - } + css::uno::Reference< css::datatransfer::XTransferable > xDataObj; - if ( xDataObj.is() ) + try + { + SolarMutexReleaser aReleaser; + xDataObj = rxClipboard->getContents(); + } + catch( const css::uno::Exception& ) { - css::datatransfer::DataFlavor aFlavor; - SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor ); - if ( xDataObj->isDataFlavorSupported( aFlavor ) ) - { - try - { - css::uno::Any aData = xDataObj->getTransferData( aFlavor ); - OUString aText; - aData >>= aText; - bool bWasTruncated = false; - if( mpImpl->mpTextEngine->GetMaxTextLen() != 0 ) - bWasTruncated = ImplTruncateNewText( aText ); - InsertText( aText ); - mpImpl->mpTextEngine->Broadcast( TextHint( SfxHintId::TextModified ) ); - - if( bWasTruncated ) - Edit::ShowTruncationWarning(mpImpl->mpWindow->GetFrameWeld()); - } - catch( const css::datatransfer::UnsupportedFlavorException& ) - { - } - } } + + if ( !xDataObj.is() ) + return; + + css::datatransfer::DataFlavor aFlavor; + SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor ); + if ( !xDataObj->isDataFlavorSupported( aFlavor ) ) + return; + + try + { + css::uno::Any aData = xDataObj->getTransferData( aFlavor ); + OUString aText; + aData >>= aText; + bool bWasTruncated = false; + if( mpImpl->mpTextEngine->GetMaxTextLen() != 0 ) + bWasTruncated = ImplTruncateNewText( aText ); + InsertText( aText ); + mpImpl->mpTextEngine->Broadcast( TextHint( SfxHintId::TextModified ) ); + + if( bWasTruncated ) + Edit::ShowTruncationWarning(mpImpl->mpWindow->GetFrameWeld()); + } + catch( const css::datatransfer::UnsupportedFlavorException& ) + { } } @@ -1804,24 +1804,24 @@ bool TextView::ImplCheckTextLen( const OUString& rNewText ) void TextView::dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& rDGE ) { - if ( mpImpl->mbClickedInSelection ) - { - SolarMutexGuard aVclGuard; + if ( !mpImpl->mbClickedInSelection ) + return; - SAL_WARN_IF( !mpImpl->maSelection.HasRange(), "vcl", "TextView::dragGestureRecognized: mpImpl->mbClickedInSelection, but no selection?" ); + SolarMutexGuard aVclGuard; - mpImpl->mpDDInfo.reset(new TextDDInfo); - mpImpl->mpDDInfo->mbStarterOfDD = true; + SAL_WARN_IF( !mpImpl->maSelection.HasRange(), "vcl", "TextView::dragGestureRecognized: mpImpl->mbClickedInSelection, but no selection?" ); - TETextDataObject* pDataObj = new TETextDataObject( GetSelected() ); + mpImpl->mpDDInfo.reset(new TextDDInfo); + mpImpl->mpDDInfo->mbStarterOfDD = true; - mpImpl->mpCursor->Hide(); + TETextDataObject* pDataObj = new TETextDataObject( GetSelected() ); - sal_Int8 nActions = css::datatransfer::dnd::DNDConstants::ACTION_COPY; - if ( !IsReadOnly() ) - nActions |= css::datatransfer::dnd::DNDConstants::ACTION_MOVE; - rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, pDataObj, mpImpl->mxDnDListener ); - } + mpImpl->mpCursor->Hide(); + + sal_Int8 nActions = css::datatransfer::dnd::DNDConstants::ACTION_COPY; + if ( !IsReadOnly() ) + nActions |= css::datatransfer::dnd::DNDConstants::ACTION_MOVE; + rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, pDataObj, mpImpl->mxDnDListener ); } void TextView::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& ) diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx index 6ed335dae9ac..eabdfa5c6dc3 100644 --- a/vcl/source/edit/vclmedit.cxx +++ b/vcl/source/edit/vclmedit.cxx @@ -845,23 +845,23 @@ void TextWindow::Command( const CommandEvent& rCEvt ) void TextWindow::GetFocus() { Window::GetFocus(); - if ( !mbActivePopup ) + if ( mbActivePopup ) + return; + + bool bGotoCursor = !mpExtTextView->IsReadOnly(); + if ( mbFocusSelectionHide && IsReallyVisible() + && ( mbSelectOnTab && + (!mbInMBDown || ( GetSettings().GetStyleSettings().GetSelectionOptions() & SelectionOptions::Focus ) )) ) { - bool bGotoCursor = !mpExtTextView->IsReadOnly(); - if ( mbFocusSelectionHide && IsReallyVisible() - && ( mbSelectOnTab && - (!mbInMBDown || ( GetSettings().GetStyleSettings().GetSelectionOptions() & SelectionOptions::Focus ) )) ) - { - // select everything, but do not scroll - bool bAutoScroll = mpExtTextView->IsAutoScroll(); - mpExtTextView->SetAutoScroll( false ); - mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( TEXT_PARA_ALL, TEXT_INDEX_ALL ) ) ); - mpExtTextView->SetAutoScroll( bAutoScroll ); - bGotoCursor = false; - } - mpExtTextView->SetPaintSelection( true ); - mpExtTextView->ShowCursor( bGotoCursor ); + // select everything, but do not scroll + bool bAutoScroll = mpExtTextView->IsAutoScroll(); + mpExtTextView->SetAutoScroll( false ); + mpExtTextView->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( TEXT_PARA_ALL, TEXT_INDEX_ALL ) ) ); + mpExtTextView->SetAutoScroll( bAutoScroll ); + bGotoCursor = false; } + mpExtTextView->SetPaintSelection( true ); + mpExtTextView->ShowCursor( bGotoCursor ); } void TextWindow::LoseFocus() @@ -986,25 +986,25 @@ void VclMultiLineEdit::ImplInitSettings(bool bBackground) pImpVclMEdit->GetTextWindow()->GetTextEngine()->SetFont(TheFont); pImpVclMEdit->GetTextWindow()->SetTextColor(aTextColor); - if (bBackground) + if (!bBackground) + return; + + if (IsPaintTransparent()) { - if (IsPaintTransparent()) - { - pImpVclMEdit->GetTextWindow()->SetPaintTransparent(true); - pImpVclMEdit->GetTextWindow()->SetBackground(); - pImpVclMEdit->GetTextWindow()->SetControlBackground(); - SetBackground(); - SetControlBackground(); - } + pImpVclMEdit->GetTextWindow()->SetPaintTransparent(true); + pImpVclMEdit->GetTextWindow()->SetBackground(); + pImpVclMEdit->GetTextWindow()->SetControlBackground(); + SetBackground(); + SetControlBackground(); + } + else + { + if (IsControlBackground()) + pImpVclMEdit->GetTextWindow()->SetBackground(GetControlBackground()); else - { - if (IsControlBackground()) - pImpVclMEdit->GetTextWindow()->SetBackground(GetControlBackground()); - else - pImpVclMEdit->GetTextWindow()->SetBackground(rStyleSettings.GetFieldColor()); - // also adjust for VclMultiLineEdit as the TextComponent might hide Scrollbars - SetBackground(pImpVclMEdit->GetTextWindow()->GetBackground()); - } + pImpVclMEdit->GetTextWindow()->SetBackground(rStyleSettings.GetFieldColor()); + // also adjust for VclMultiLineEdit as the TextComponent might hide Scrollbars + SetBackground(pImpVclMEdit->GetTextWindow()->GetBackground()); } } diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx index 5321ea2599c5..797466366d2a 100644 --- a/vcl/source/filter/FilterConfigCache.cxx +++ b/vcl/source/filter/FilterConfigCache.cxx @@ -157,61 +157,61 @@ void FilterConfigCache::ImplInit() Reference< XNameAccess > xTypeAccess ( openConfig("types" ), UNO_QUERY ); Reference< XNameAccess > xFilterAccess( openConfig("filters"), UNO_QUERY ); - if ( xTypeAccess.is() && xFilterAccess.is() ) + if ( !(xTypeAccess.is() && xFilterAccess.is()) ) + return; + + const Sequence< OUString > lAllFilter = xFilterAccess->getElementNames(); + + for ( const OUString& sInternalFilterName : lAllFilter ) { - const Sequence< OUString > lAllFilter = xFilterAccess->getElementNames(); + Reference< XPropertySet > xFilterSet; + xFilterAccess->getByName( sInternalFilterName ) >>= xFilterSet; + if (!xFilterSet.is()) + continue; + + FilterConfigCacheEntry aEntry; + + aEntry.sInternalFilterName = sInternalFilterName; + xFilterSet->getPropertyValue(STYPE) >>= aEntry.sType; + xFilterSet->getPropertyValue(SUINAME) >>= aEntry.sUIName; + xFilterSet->getPropertyValue(SREALFILTERNAME) >>= aEntry.sFilterType; + Sequence< OUString > lFlags; + xFilterSet->getPropertyValue(SFLAGS) >>= lFlags; + if (lFlags.getLength()!=1 || lFlags[0].isEmpty()) + continue; + if (lFlags[0].equalsIgnoreAsciiCase("import")) + aEntry.nFlags = 1; + else if (lFlags[0].equalsIgnoreAsciiCase("export")) + aEntry.nFlags = 2; + + OUString sFormatName; + xFilterSet->getPropertyValue(SFORMATNAME) >>= sFormatName; + aEntry.CreateFilterName( sFormatName ); + + Reference< XPropertySet > xTypeSet; + xTypeAccess->getByName( aEntry.sType ) >>= xTypeSet; + if (!xTypeSet.is()) + continue; + + xTypeSet->getPropertyValue(SMEDIATYPE) >>= aEntry.sMediaType; + css::uno::Sequence<OUString> tmp; + if (xTypeSet->getPropertyValue(SEXTENSIONS) >>= tmp) + aEntry.lExtensionList = comphelper::sequenceToContainer<std::vector<OUString>>(tmp); + + // The first extension will be used + // to generate our internal FilterType ( BMP, WMF ... ) + OUString aExtension( aEntry.GetShortName() ); + if (aExtension.getLength() != 3) + continue; - for ( const OUString& sInternalFilterName : lAllFilter ) - { - Reference< XPropertySet > xFilterSet; - xFilterAccess->getByName( sInternalFilterName ) >>= xFilterSet; - if (!xFilterSet.is()) - continue; - - FilterConfigCacheEntry aEntry; - - aEntry.sInternalFilterName = sInternalFilterName; - xFilterSet->getPropertyValue(STYPE) >>= aEntry.sType; - xFilterSet->getPropertyValue(SUINAME) >>= aEntry.sUIName; - xFilterSet->getPropertyValue(SREALFILTERNAME) >>= aEntry.sFilterType; - Sequence< OUString > lFlags; - xFilterSet->getPropertyValue(SFLAGS) >>= lFlags; - if (lFlags.getLength()!=1 || lFlags[0].isEmpty()) - continue; - if (lFlags[0].equalsIgnoreAsciiCase("import")) - aEntry.nFlags = 1; - else if (lFlags[0].equalsIgnoreAsciiCase("export")) - aEntry.nFlags = 2; - - OUString sFormatName; - xFilterSet->getPropertyValue(SFORMATNAME) >>= sFormatName; - aEntry.CreateFilterName( sFormatName ); - - Reference< XPropertySet > xTypeSet; - xTypeAccess->getByName( aEntry.sType ) >>= xTypeSet; - if (!xTypeSet.is()) - continue; - - xTypeSet->getPropertyValue(SMEDIATYPE) >>= aEntry.sMediaType; - css::uno::Sequence<OUString> tmp; - if (xTypeSet->getPropertyValue(SEXTENSIONS) >>= tmp) - aEntry.lExtensionList = comphelper::sequenceToContainer<std::vector<OUString>>(tmp); - - // The first extension will be used - // to generate our internal FilterType ( BMP, WMF ... ) - OUString aExtension( aEntry.GetShortName() ); - if (aExtension.getLength() != 3) - continue; - - if ( aEntry.nFlags & 1 ) - aImport.push_back( aEntry ); - if ( aEntry.nFlags & 2 ) - aExport.push_back( aEntry ); - - // bFilterEntryCreated!? - if (!( aEntry.nFlags & 3 )) - continue; //? Entry was already inserted ... but following code will be suppressed?! - } + if ( aEntry.nFlags & 1 ) + aImport.push_back( aEntry ); + if ( aEntry.nFlags & 2 ) + aExport.push_back( aEntry ); + + // bFilterEntryCreated!? + if (!( aEntry.nFlags & 3 )) + continue; //? Entry was already inserted ... but following code will be suppressed?! } }; diff --git a/vcl/source/filter/FilterConfigItem.cxx b/vcl/source/filter/FilterConfigItem.cxx index 41c9ec401064..a81102321388 100644 --- a/vcl/source/filter/FilterConfigItem.cxx +++ b/vcl/source/filter/FilterConfigItem.cxx @@ -105,28 +105,28 @@ void FilterConfigItem::ImpInitTree( const OUString& rSubTree ) Reference< XMultiServiceFactory > xCfgProv = theDefaultProvider::get( xContext ); OUString sTree = "/org.openoffice." + rSubTree; - if ( ImpIsTreeAvailable(xCfgProv, sTree) ) - { - // creation arguments: nodepath - PropertyValue aPathArgument; - aPathArgument.Name = "nodepath"; - aPathArgument.Value <<= sTree; + if ( !ImpIsTreeAvailable(xCfgProv, sTree) ) + return; - Sequence< Any > aArguments( 1 ); - aArguments[ 0 ] <<= aPathArgument; + // creation arguments: nodepath + PropertyValue aPathArgument; + aPathArgument.Name = "nodepath"; + aPathArgument.Value <<= sTree; - try - { - xUpdatableView = xCfgProv->createInstanceWithArguments( - "com.sun.star.configuration.ConfigurationUpdateAccess", - aArguments ); - if ( xUpdatableView.is() ) - xPropSet.set( xUpdatableView, UNO_QUERY ); - } - catch ( css::uno::Exception& ) - { - OSL_FAIL( "FilterConfigItem::FilterConfigItem - Could not access configuration Key" ); - } + Sequence< Any > aArguments( 1 ); + aArguments[ 0 ] <<= aPathArgument; + + try + { + xUpdatableView = xCfgProv->createInstanceWithArguments( + "com.sun.star.configuration.ConfigurationUpdateAccess", + aArguments ); + if ( xUpdatableView.is() ) + xPropSet.set( xUpdatableView, UNO_QUERY ); + } + catch ( css::uno::Exception& ) + { + OSL_FAIL( "FilterConfigItem::FilterConfigItem - Could not access configuration Key" ); } } @@ -158,23 +158,23 @@ FilterConfigItem::~FilterConfigItem() void FilterConfigItem::WriteModifiedConfig() { - if ( xUpdatableView.is() ) + if ( !xUpdatableView.is() ) + return; + + if ( !(xPropSet.is() && bModified) ) + return; + + Reference< XChangesBatch > xUpdateControl( xUpdatableView, UNO_QUERY ); + if ( xUpdateControl.is() ) { - if ( xPropSet.is() && bModified ) + try { - Reference< XChangesBatch > xUpdateControl( xUpdatableView, UNO_QUERY ); - if ( xUpdateControl.is() ) - { - try - { - xUpdateControl->commitChanges(); - bModified = false; - } - catch ( css::uno::Exception& ) - { - OSL_FAIL( "FilterConfigItem::FilterConfigItem - Could not update configuration data" ); - } - } + xUpdateControl->commitChanges(); + bModified = false; + } + catch ( css::uno::Exception& ) + { + OSL_FAIL( "FilterConfigItem::FilterConfigItem - Could not update configuration data" ); } } } @@ -316,27 +316,27 @@ void FilterConfigItem::WriteBool( const OUString& rKey, bool bNewValue ) aBool.Value <<= bNewValue; WritePropertyValue( aFilterData, aBool ); - if ( xPropSet.is() ) + if ( !xPropSet.is() ) + return; + + Any aAny; + if ( !ImplGetPropertyValue( aAny, xPropSet, rKey ) ) + return; + + bool bOldValue(true); + if ( !(aAny >>= bOldValue) ) + return; + + if ( bOldValue != bNewValue ) { - Any aAny; - if ( ImplGetPropertyValue( aAny, xPropSet, rKey ) ) + try { - bool bOldValue(true); - if ( aAny >>= bOldValue ) - { - if ( bOldValue != bNewValue ) - { - try - { - xPropSet->setPropertyValue( rKey, Any(bNewValue) ); - bModified = true; - } - catch ( css::uno::Exception& ) - { - OSL_FAIL( "FilterConfigItem::WriteBool - could not set PropertyValue" ); - } - } - } + xPropSet->setPropertyValue( rKey, Any(bNewValue) ); + bModified = true; + } + catch ( css::uno::Exception& ) + { + OSL_FAIL( "FilterConfigItem::WriteBool - could not set PropertyValue" ); } } } @@ -348,28 +348,28 @@ void FilterConfigItem::WriteInt32( const OUString& rKey, sal_Int32 nNewValue ) aInt32.Value <<= nNewValue; WritePropertyValue( aFilterData, aInt32 ); - if ( xPropSet.is() ) - { - Any aAny; + if ( !xPropSet.is() ) + return; + + Any aAny; - if ( ImplGetPropertyValue( aAny, xPropSet, rKey ) ) + if ( !ImplGetPropertyValue( aAny, xPropSet, rKey ) ) + return; + + sal_Int32 nOldValue = 0; + if ( !(aAny >>= nOldValue) ) + return; + + if ( nOldValue != nNewValue ) + { + try { - sal_Int32 nOldValue = 0; - if ( aAny >>= nOldValue ) - { - if ( nOldValue != nNewValue ) - { - try - { - xPropSet->setPropertyValue( rKey, Any(nNewValue) ); - bModified = true; - } - catch ( css::uno::Exception& ) - { - OSL_FAIL( "FilterConfigItem::WriteInt32 - could not set PropertyValue" ); - } - } - } + xPropSet->setPropertyValue( rKey, Any(nNewValue) ); + bModified = true; + } + catch ( css::uno::Exception& ) + { + OSL_FAIL( "FilterConfigItem::WriteInt32 - could not set PropertyValue" ); } } } diff --git a/vcl/source/filter/igif/gifread.cxx b/vcl/source/filter/igif/gifread.cxx index 47d9acb53c2a..045a6de0571e 100644 --- a/vcl/source/filter/igif/gifread.cxx +++ b/vcl/source/filter/igif/gifread.cxx @@ -302,27 +302,27 @@ void GIFReader::ReadPaletteEntries( BitmapPalette* pPal, sal_uLong nCount ) std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[ nLen ]); std::size_t nRead = rIStm.ReadBytes(pBuf.get(), nLen); nCount = nRead/3UL; - if( NO_PENDING( rIStm ) ) - { - sal_uInt8* pTmp = pBuf.get(); + if( !(NO_PENDING( rIStm )) ) + return; - for (sal_uLong i = 0; i < nCount; ++i) - { - BitmapColor& rColor = (*pPal)[i]; + sal_uInt8* pTmp = pBuf.get(); - rColor.SetRed( *pTmp++ ); - rColor.SetGreen( *pTmp++ ); - rColor.SetBlue( *pTmp++ ); - } + for (sal_uLong i = 0; i < nCount; ++i) + { + BitmapColor& rColor = (*pPal)[i]; - // if possible accommodate some standard colours - if( nCount < 256 ) - { - (*pPal)[ 255UL ] = COL_WHITE; + rColor.SetRed( *pTmp++ ); + rColor.SetGreen( *pTmp++ ); + rColor.SetBlue( *pTmp++ ); + } - if( nCount < 255 ) - (*pPal)[ 254UL ] = COL_BLACK; - } + // if possible accommodate some standard colours + if( nCount < 256 ) + { + (*pPal)[ 255UL ] = COL_WHITE; + + if( nCount < 255 ) + (*pPal)[ 254UL ] = COL_BLACK; } } diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx index df7374770463..cd378f4a855f 100644 --- a/vcl/source/filter/jpeg/JpegReader.cxx +++ b/vcl/source/filter/jpeg/JpegReader.cxx @@ -113,20 +113,20 @@ static void skip_input_data (j_decompress_ptr cinfo, long numberOfBytes) * it doesn't work on pipes. Not clear that being smart is worth * any trouble anyway --- large skips are infrequent. */ - if (numberOfBytes > 0) + if (numberOfBytes <= 0) + return; + + while (numberOfBytes > static_cast<long>(source->pub.bytes_in_buffer)) { - while (numberOfBytes > static_cast<long>(source->pub.bytes_in_buffer)) - { - numberOfBytes -= static_cast<long>(source->pub.bytes_in_buffer); - (void) fill_input_buffer(cinfo); + numberOfBytes -= static_cast<long>(source->pub.bytes_in_buffer); + (void) fill_input_buffer(cinfo); - /* note we assume that fill_input_buffer will never return false, - * so suspension need not be handled. - */ - } - source->pub.next_input_byte += static_cast<size_t>(numberOfBytes); - source->pub.bytes_in_buffer -= static_cast<size_t>(numberOfBytes); + /* note we assume that fill_input_buffer will never return false, + * so suspension need not be handled. + */ } + source->pub.next_input_byte += static_cast<size_t>(numberOfBytes); + source->pub.bytes_in_buffer -= static_cast<size_t>(numberOfBytes); } static void term_source (j_decompress_ptr) diff --git a/vcl/source/filter/png/pngwrite.cxx b/vcl/source/filter/png/pngwrite.cxx index 8190c1efd38a..720a5d10f3cb 100644 --- a/vcl/source/filter/png/pngwrite.cxx +++ b/vcl/source/filter/png/pngwrite.cxx @@ -112,136 +112,116 @@ PNGWriterImpl::PNGWriterImpl( const BitmapEx& rBitmapEx, , mnBBP(0) , mbTrueAlpha(false) { - if (!rBitmapEx.IsEmpty()) - { - BitmapEx aBitmapEx; + if (rBitmapEx.IsEmpty()) + return; - if (rBitmapEx.GetBitmap().GetBitCount() == 32) - { - if (!vcl::bitmap::convertBitmap32To24Plus8(rBitmapEx, aBitmapEx)) - return; - } - else - { - aBitmapEx = rBitmapEx; - } + BitmapEx aBitmapEx; - Bitmap aBmp(aBitmapEx.GetBitmap()); + if (rBitmapEx.GetBitmap().GetBitCount() == 32) + { + if (!vcl::bitmap::convertBitmap32To24Plus8(rBitmapEx, aBitmapEx)) + return; + } + else + { + aBitmapEx = rBitmapEx; + } - mnMaxChunkSize = std::numeric_limits<sal_uInt32>::max(); + Bitmap aBmp(aBitmapEx.GetBitmap()); - if (pFilterData) + mnMaxChunkSize = std::numeric_limits<sal_uInt32>::max(); + + if (pFilterData) + { + for (const auto& rPropVal : *pFilterData) { - for (const auto& rPropVal : *pFilterData) + if (rPropVal.Name == "Compression") + rPropVal.Value >>= mnCompLevel; + else if (rPropVal.Name == "Interlaced") + rPropVal.Value >>= mnInterlaced; + else if (rPropVal.Name == "MaxChunkSize") { - if (rPropVal.Name == "Compression") - rPropVal.Value >>= mnCompLevel; - else if (rPropVal.Name == "Interlaced") - rPropVal.Value >>= mnInterlaced; - else if (rPropVal.Name == "MaxChunkSize") - { - sal_Int32 nVal = 0; - if (rPropVal.Value >>= nVal) - mnMaxChunkSize = static_cast<sal_uInt32>(nVal); - } + sal_Int32 nVal = 0; + if (rPropVal.Value >>= nVal) + mnMaxChunkSize = static_cast<sal_uInt32>(nVal); } } - mnBitsPerPixel = static_cast<sal_uInt8>(aBmp.GetBitCount()); + } + mnBitsPerPixel = static_cast<sal_uInt8>(aBmp.GetBitCount()); - if (aBitmapEx.IsTransparent()) + if (aBitmapEx.IsTransparent()) + { + if (mnBitsPerPixel <= 8 && aBitmapEx.IsAlpha()) { - if (mnBitsPerPixel <= 8 && aBitmapEx.IsAlpha()) - { - aBmp.Convert( BmpConversion::N24Bit ); - mnBitsPerPixel = 24; - } + aBmp.Convert( BmpConversion::N24Bit ); + mnBitsPerPixel = 24; + } - if (mnBitsPerPixel <= 8) // transparent palette + if (mnBitsPerPixel <= 8) // transparent palette + { + aBmp.Convert(BmpConversion::N8BitTrans); + aBmp.Replace(aBitmapEx.GetMask(), BMP_COL_TRANS); + mnBitsPerPixel = 8; + mpAccess = Bitmap::ScopedReadAccess(aBmp); + if (mpAccess) { - aBmp.Convert(BmpConversion::N8BitTrans); - aBmp.Replace(aBitmapEx.GetMask(), BMP_COL_TRANS); - mnBitsPerPixel = 8; - mpAccess = Bitmap::ScopedReadAccess(aBmp); - if (mpAccess) - { - if (ImplWriteHeader()) - { - ImplWritepHYs(aBitmapEx); - ImplWritePalette(); - ImplWriteTransparent(); - ImplWriteIDAT(); - } - mpAccess.reset(); - } - else + if (ImplWriteHeader()) { - mbStatus = false; + ImplWritepHYs(aBitmapEx); + ImplWritePalette(); + ImplWriteTransparent(); + ImplWriteIDAT(); } + mpAccess.reset(); } else { - mpAccess = Bitmap::ScopedReadAccess(aBmp); // true RGB with alphachannel - if (mpAccess) + mbStatus = false; + } + } + else + { + mpAccess = Bitmap::ScopedReadAccess(aBmp); // true RGB with alphachannel + if (mpAccess) + { + mbTrueAlpha = aBitmapEx.IsAlpha(); + if (mbTrueAlpha) { - mbTrueAlpha = aBitmapEx.IsAlpha(); - if (mbTrueAlpha) + AlphaMask aMask(aBitmapEx.GetAlpha()); + mpMaskAccess = aMask.AcquireReadAccess(); + if (mpMaskAccess) { - AlphaMask aMask(aBitmapEx.GetAlpha()); - mpMaskAccess = aMask.AcquireReadAccess(); - if (mpMaskAccess) - { - if (ImplWriteHeader()) - { - ImplWritepHYs(aBitmapEx); - ImplWriteIDAT(); - } - aMask.ReleaseAccess(mpMaskAccess); - mpMaskAccess = nullptr; - } - else + if (ImplWriteHeader()) { - mbStatus = false; + ImplWritepHYs(aBitmapEx); + ImplWriteIDAT(); } + aMask.ReleaseAccess(mpMaskAccess); + mpMaskAccess = nullptr; } else { - Bitmap aMask(aBitmapEx.GetMask()); - mpMaskAccess = aMask.AcquireReadAccess(); - if (mpMaskAccess) - { - if (ImplWriteHeader()) - { - ImplWritepHYs(aBitmapEx); - ImplWriteIDAT(); - } - Bitmap::ReleaseAccess(mpMaskAccess); - mpMaskAccess = nullptr; - } - else - { - mbStatus = false; - } + mbStatus = false; } - mpAccess.reset(); } else { - mbStatus = false; - } - } - } - else - { - mpAccess = Bitmap::ScopedReadAccess(aBmp); // palette + RGB without alphachannel - if (mpAccess) - { - if (ImplWriteHeader()) - { - ImplWritepHYs(aBitmapEx); - if (mpAccess->HasPalette()) - ImplWritePalette(); - - ImplWriteIDAT(); + Bitmap aMask(aBitmapEx.GetMask()); + mpMaskAccess = aMask.AcquireReadAccess(); + if (mpMaskAccess) + { + if (ImplWriteHeader()) + { + ImplWritepHYs(aBitmapEx); + ImplWriteIDAT(); + } + Bitmap::ReleaseAccess(mpMaskAccess); + mpMaskAccess = nullptr; + } + else + { + mbStatus = false; + } } mpAccess.reset(); } @@ -250,12 +230,32 @@ PNGWriterImpl::PNGWriterImpl( const BitmapEx& rBitmapEx, mbStatus = false; } } + } + else + { + mpAccess = Bitmap::ScopedReadAccess(aBmp); // palette + RGB without alphachannel + if (mpAccess) + { + if (ImplWriteHeader()) + { + ImplWritepHYs(aBitmapEx); + if (mpAccess->HasPalette()) + ImplWritePalette(); - if (mbStatus) + ImplWriteIDAT(); + } + mpAccess.reset(); + } + else { - ImplOpenChunk(PNGCHUNK_IEND); // create an IEND chunk + mbStatus = false; } } + + if (mbStatus) + { + ImplOpenChunk(PNGCHUNK_IEND); // create an IEND chunk + } } bool PNGWriterImpl::Write(SvStream& rOStm) @@ -359,19 +359,19 @@ void PNGWriterImpl::ImplWriteTransparent() void PNGWriterImpl::ImplWritepHYs(const BitmapEx& rBmpEx) { - if (rBmpEx.GetPrefMapMode().GetMapUnit() == MapUnit::Map100thMM) - { - Size aPrefSize(rBmpEx.GetPrefSize()); + if (rBmpEx.GetPrefMapMode().GetMapUnit() != MapUnit::Map100thMM) + return; - if (aPrefSize.Width() && aPrefSize.Height() && mnWidth && mnHeight) - { - ImplOpenChunk(PNGCHUNK_pHYs); - sal_uInt32 nPrefSizeX = static_cast<sal_uInt32>(100000.0 / (static_cast<double>(aPrefSize.Width()) / mnWidth) + 0.5); - sal_uInt32 nPrefSizeY = static_cast<sal_uInt32>(100000.0 / (static_cast<double>(aPrefSize.Height()) / mnHeight) + 0.5); - ImplWriteChunk(nPrefSizeX); - ImplWriteChunk(nPrefSizeY); - ImplWriteChunk(sal_uInt8(1)); // nMapUnit - } + Size aPrefSize(rBmpEx.GetPrefSize()); + + if (aPrefSize.Width() && aPrefSize.Height() && mnWidth && mnHeight) + { + ImplOpenChunk(PNGCHUNK_pHYs); + sal_uInt32 nPrefSizeX = static_cast<sal_uInt32>(100000.0 / (static_cast<double>(aPrefSize.Width()) / mnWidth) + 0.5); + sal_uInt32 nPrefSizeY = static_cast<sal_uInt32>(100000.0 / (static_cast<double>(aPrefSize.Height()) / mnHeight) + 0.5); + ImplWriteChunk(nPrefSizeX); + ImplWriteChunk(nPrefSizeY); + ImplWriteChunk(sal_uInt8(1)); // nMapUnit } } diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index 0204999672dc..e02fa107d233 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -415,37 +415,37 @@ bool EMFWriter::ImplPrepareHandleSelect( sal_uInt32& rHandle, sal_uLong nSelectT void EMFWriter::ImplCheckLineAttr() { - if( mbLineChanged && ImplPrepareHandleSelect( mnLineHandle, LINE_SELECT ) ) - { - sal_uInt32 nStyle = maVDev->IsLineColor() ? 0 : 5; + if( !(mbLineChanged && ImplPrepareHandleSelect( mnLineHandle, LINE_SELECT )) ) + return; - ImplBeginRecord( WIN_EMR_CREATEPEN ); - m_rStm.WriteUInt32( mnLineHandle ).WriteUInt32( nStyle ).WriteUInt32( 0/*nWidth*/ ).WriteUInt32( 0/*nHeight*/ ); - ImplWriteColor( maVDev->GetLineColor() ); - ImplEndRecord(); + sal_uInt32 nStyle = maVDev->IsLineColor() ? 0 : 5; - ImplBeginRecord( WIN_EMR_SELECTOBJECT ); - m_rStm.WriteUInt32( mnLineHandle ); - ImplEndRecord(); - } + ImplBeginRecord( WIN_EMR_CREATEPEN ); + m_rStm.WriteUInt32( mnLineHandle ).WriteUInt32( nStyle ).WriteUInt32( 0/*nWidth*/ ).WriteUInt32( 0/*nHeight*/ ); + ImplWriteColor( maVDev->GetLineColor() ); + ImplEndRecord(); + + ImplBeginRecord( WIN_EMR_SELECTOBJECT ); + m_rStm.WriteUInt32( mnLineHandle ); + ImplEndRecord(); } void EMFWriter::ImplCheckFillAttr() { - if( mbFillChanged && ImplPrepareHandleSelect( mnFillHandle, FILL_SELECT ) ) - { - sal_uInt32 nStyle = maVDev->IsFillColor() ? 0 : 1; + if( !(mbFillChanged && ImplPrepareHandleSelect( mnFillHandle, FILL_SELECT )) ) + return; - ImplBeginRecord( WIN_EMR_CREATEBRUSHINDIRECT ); - m_rStm.WriteUInt32( mnFillHandle ).WriteUInt32( nStyle ); - ImplWriteColor( maVDev->GetFillColor() ); - m_rStm.WriteUInt32( 0/*nPatternStyle*/ ); - ImplEndRecord(); + sal_uInt32 nStyle = maVDev->IsFillColor() ? 0 : 1; - ImplBeginRecord( WIN_EMR_SELECTOBJECT ); - m_rStm.WriteUInt32( mnFillHandle ); - ImplEndRecord(); - } + ImplBeginRecord( WIN_EMR_CREATEBRUSHINDIRECT ); + m_rStm.WriteUInt32( mnFillHandle ).WriteUInt32( nStyle ); + ImplWriteColor( maVDev->GetFillColor() ); + m_rStm.WriteUInt32( 0/*nPatternStyle*/ ); + ImplEndRecord(); + + ImplBeginRecord( WIN_EMR_SELECTOBJECT ); + m_rStm.WriteUInt32( mnFillHandle ); + ImplEndRecord(); } void EMFWriter::ImplCheckTextAttr() @@ -618,26 +618,26 @@ void EMFWriter::ImplWriteRect( const tools::Rectangle& rRect ) void EMFWriter::ImplWritePolygonRecord( const tools::Polygon& rPoly, bool bClose ) { - if( rPoly.GetSize() ) + if( !rPoly.GetSize() ) + return; + + if( rPoly.HasFlags() ) + ImplWritePath( rPoly, bClose ); + else { - if( rPoly.HasFlags() ) - ImplWritePath( rPoly, bClose ); - else - { - if( bClose ) - ImplCheckFillAttr(); + if( bClose ) + ImplCheckFillAttr(); - ImplCheckLineAttr(); + ImplCheckLineAttr(); - ImplBeginRecord( bClose ? WIN_EMR_POLYGON : WIN_EMR_POLYLINE ); - ImplWriteRect( rPoly.GetBoundRect() ); - m_rStm.WriteUInt32( rPoly.GetSize() ); + ImplBeginRecord( bClose ? WIN_EMR_POLYGON : WIN_EMR_POLYLINE ); + ImplWriteRect( rPoly.GetBoundRect() ); + m_rStm.WriteUInt32( rPoly.GetSize() ); - for( sal_uInt16 i = 0; i < rPoly.GetSize(); i++ ) - ImplWritePoint( rPoly[ i ] ); + for( sal_uInt16 i = 0; i < rPoly.GetSize(); i++ ) + ImplWritePoint( rPoly[ i ] ); - ImplEndRecord(); - } + ImplEndRecord(); } } @@ -645,46 +645,46 @@ void EMFWriter::ImplWritePolyPolygonRecord( const tools::PolyPolygon& rPolyPoly { sal_uInt16 n, i, nPolyCount = rPolyPoly.Count(); - if( nPolyCount ) + if( !nPolyCount ) + return; + + if( 1 == nPolyCount ) + ImplWritePolygonRecord( rPolyPoly[ 0 ], true ); + else { - if( 1 == nPolyCount ) - ImplWritePolygonRecord( rPolyPoly[ 0 ], true ); - else - { - bool bHasFlags = false; - sal_uInt32 nTotalPoints = 0; + bool bHasFlags = false; + sal_uInt32 nTotalPoints = 0; - for( i = 0; i < nPolyCount; i++ ) - { - nTotalPoints += rPolyPoly[ i ].GetSize(); - if ( rPolyPoly[ i ].HasFlags() ) - bHasFlags = true; - } - if( nTotalPoints ) + for( i = 0; i < nPolyCount; i++ ) + { + nTotalPoints += rPolyPoly[ i ].GetSize(); + if ( rPolyPoly[ i ].HasFlags() ) + bHasFlags = true; + } + if( nTotalPoints ) + { + if ( bHasFlags ) + ImplWritePath( rPolyPoly, true ); + else { - if ( bHasFlags ) - ImplWritePath( rPolyPoly, true ); - else - { - ImplCheckFillAttr(); - ImplCheckLineAttr(); + ImplCheckFillAttr(); + ImplCheckLineAttr(); - ImplBeginRecord( WIN_EMR_POLYPOLYGON ); - ImplWriteRect( rPolyPoly.GetBoundRect() ); - m_rStm.WriteUInt32( nPolyCount ).WriteUInt32( nTotalPoints ); + ImplBeginRecord( WIN_EMR_POLYPOLYGON ); + ImplWriteRect( rPolyPoly.GetBoundRect() ); + m_rStm.WriteUInt32( nPolyCount ).WriteUInt32( nTotalPoints ); - for( i = 0; i < nPolyCount; i++ ) - m_rStm.WriteUInt32( rPolyPoly[ i ].GetSize() ); + for( i = 0; i < nPolyCount; i++ ) + m_rStm.WriteUInt32( rPolyPoly[ i ].GetSize() ); - for( i = 0; i < nPolyCount; i++ ) - { - const tools::Polygon& rPoly = rPolyPoly[ i ]; + for( i = 0; i < nPolyCount; i++ ) + { + const tools::Polygon& rPoly = rPolyPoly[ i ]; - for( n = 0; n < rPoly.GetSize(); n++ ) - ImplWritePoint( rPoly[ n ] ); - } - ImplEndRecord(); + for( n = 0; n < rPoly.GetSize(); n++ ) + ImplWritePoint( rPoly[ n ] ); } + ImplEndRecord(); } } } @@ -911,38 +911,38 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, c void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon) { - if(rLinePolygon.count()) - { - basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); - basegfx::B2DPolyPolygon aFillPolyPolygon; + if(!rLinePolygon.count()) + return; - rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); + basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); + basegfx::B2DPolyPolygon aFillPolyPolygon; - if(aLinePolyPolygon.count()) + rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); + + if(aLinePolyPolygon.count()) + { + for(auto const& rB2DPolygon : aLinePolyPolygon) { - for(auto const& rB2DPolygon : aLinePolyPolygon) - { - ImplWritePolygonRecord( tools::Polygon(rB2DPolygon), false ); - } + ImplWritePolygonRecord( tools::Polygon(rB2DPolygon), false ); } + } - if(aFillPolyPolygon.count()) - { - const Color aOldLineColor(maVDev->GetLineColor()); - const Color aOldFillColor(maVDev->GetFillColor()); + if(!aFillPolyPolygon.count()) + return; - maVDev->SetLineColor(); - maVDev->SetFillColor(aOldLineColor); + const Color aOldLineColor(maVDev->GetLineColor()); + const Color aOldFillColor(maVDev->GetFillColor()); - for(auto const& rB2DPolygon : aFillPolyPolygon) - { - ImplWritePolyPolygonRecord(tools::PolyPolygon( tools::Polygon(rB2DPolygon) )); - } + maVDev->SetLineColor(); + maVDev->SetFillColor(aOldLineColor); - maVDev->SetLineColor(aOldLineColor); - maVDev->SetFillColor(aOldFillColor); - } + for(auto const& rB2DPolygon : aFillPolyPolygon) + { + ImplWritePolyPolygonRecord(tools::PolyPolygon( tools::Polygon(rB2DPolygon) )); } + + maVDev->SetLineColor(aOldLineColor); + maVDev->SetFillColor(aOldFillColor); } void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index d9fa0d61ffe1..3e0d048c925a 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -164,24 +164,24 @@ WMFWriter::WMFWriter() void WMFWriter::MayCallback() { - if ( xStatusIndicator.is() ) - { - sal_uLong nPercent; + if ( !xStatusIndicator.is() ) + return; - // we simply assume that 16386 actions match to a bitmap - // (normally a metafile either contains only actions or some bitmaps and - // almost no actions. In which case the ratio is less important) + sal_uLong nPercent; - nPercent=((nWrittenBitmaps<<14)+(nActBitmapPercent<<14)/100+nWrittenActions) - *100 - /((nNumberOfBitmaps<<14)+nNumberOfActions); + // we simply assume that 16386 actions match to a bitmap + // (normally a metafile either contains only actions or some bitmaps and + // almost no actions. In which case the ratio is less important) - if ( nPercent >= nLastPercent + 3 ) - { - nLastPercent = nPercent; - if( nPercent <= 100 ) - xStatusIndicator->setValue( nPercent ); - } + nPercent=((nWrittenBitmaps<<14)+(nActBitmapPercent<<14)/100+nWrittenActions) + *100 + /((nNumberOfBitmaps<<14)+nNumberOfActions); + + if ( nPercent >= nLastPercent + 3 ) + { + nLastPercent = nPercent; + if( nPercent <= 100 ) + xStatusIndicator->setValue( nPercent ); } } @@ -942,684 +942,684 @@ void WMFWriter::SetAllAttr() eDstHorTextAlign = eSrcHorTextAlign; WMFRecord_SetTextAlign( eDstTextAlign, eDstHorTextAlign ); } - if ( aDstFont != aSrcFont ) + if ( aDstFont == aSrcFont ) + return; + + pVirDev->SetFont(aSrcFont); + if ( aDstFont.GetFamilyName() != aSrcFont.GetFamilyName() ) { - pVirDev->SetFont(aSrcFont); - if ( aDstFont.GetFamilyName() != aSrcFont.GetFamilyName() ) + FontCharMapRef xFontCharMap; + if ( pVirDev->GetFontCharMap( xFontCharMap ) ) { - FontCharMapRef xFontCharMap; - if ( pVirDev->GetFontCharMap( xFontCharMap ) ) - { - if ( ( xFontCharMap->GetFirstChar() & 0xff00 ) == 0xf000 ) - aSrcFont.SetCharSet( RTL_TEXTENCODING_SYMBOL ); - else if ( aSrcFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) - aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 ); - } + if ( ( xFontCharMap->GetFirstChar() & 0xff00 ) == 0xf000 ) + aSrcFont.SetCharSet( RTL_TEXTENCODING_SYMBOL ); + else if ( aSrcFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) + aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 ); } - - aDstFont = aSrcFont; - CreateSelectDeleteFont(aDstFont); } + + aDstFont = aSrcFont; + CreateSelectDeleteFont(aDstFont); } void WMFWriter::HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon) { - if(rLinePolygon.count()) - { - basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); - basegfx::B2DPolyPolygon aFillPolyPolygon; + if(!rLinePolygon.count()) + return; - rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); + basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); + basegfx::B2DPolyPolygon aFillPolyPolygon; - if(aLinePolyPolygon.count()) - { - aSrcLineInfo = rInfo; - SetLineAndFillAttr(); + rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); - for(auto const& rB2DPolygon : aLinePolyPolygon) - { - WMFRecord_PolyLine( tools::Polygon(rB2DPolygon) ); - } - } + if(aLinePolyPolygon.count()) + { + aSrcLineInfo = rInfo; + SetLineAndFillAttr(); - if(aFillPolyPolygon.count()) + for(auto const& rB2DPolygon : aLinePolyPolygon) { - const Color aOldLineColor(aSrcLineColor); - const Color aOldFillColor(aSrcFillColor); + WMFRecord_PolyLine( tools::Polygon(rB2DPolygon) ); + } + } - aSrcLineColor = COL_TRANSPARENT; - aSrcFillColor = aOldLineColor; - SetLineAndFillAttr(); + if(!aFillPolyPolygon.count()) + return; - for(auto const& rB2DPolygon : aFillPolyPolygon) - { - WMFRecord_Polygon( tools::Polygon(rB2DPolygon) ); - } + const Color aOldLineColor(aSrcLineColor); + const Color aOldFillColor(aSrcFillColor); - aSrcLineColor = aOldLineColor; - aSrcFillColor = aOldFillColor; - SetLineAndFillAttr(); - } + aSrcLineColor = COL_TRANSPARENT; + aSrcFillColor = aOldLineColor; + SetLineAndFillAttr(); + + for(auto const& rB2DPolygon : aFillPolyPolygon) + { + WMFRecord_Polygon( tools::Polygon(rB2DPolygon) ); } + + aSrcLineColor = aOldLineColor; + aSrcFillColor = aOldFillColor; + SetLineAndFillAttr(); } void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) { - if( bStatus ) - { - size_t nACount = rMTF.GetActionSize(); + if( !bStatus ) + return; + + size_t nACount = rMTF.GetActionSize(); - WMFRecord_SetStretchBltMode(); + WMFRecord_SetStretchBltMode(); - for( size_t nA = 0; nA < nACount; nA++ ) + for( size_t nA = 0; nA < nACount; nA++ ) + { + MetaAction* pMA = rMTF.GetAction( nA ); + + switch( pMA->GetType() ) { - MetaAction* pMA = rMTF.GetAction( nA ); + case MetaActionType::PIXEL: + { + const MetaPixelAction* pA = static_cast<const MetaPixelAction *>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_SetPixel( pA->GetPoint(), pA->GetColor() ); + } + break; + + case MetaActionType::POINT: + { + const MetaPointAction* pA = static_cast<const MetaPointAction*>(pMA); + const Point& rPt = pA->GetPoint(); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_MoveTo( rPt); + WMFRecord_LineTo( rPt ); + } + break; - switch( pMA->GetType() ) + case MetaActionType::LINE: { - case MetaActionType::PIXEL: + const MetaLineAction* pA = static_cast<const MetaLineAction *>(pMA); + if(pA->GetLineInfo().IsDefault()) { - const MetaPixelAction* pA = static_cast<const MetaPixelAction *>(pMA); - aSrcLineInfo = LineInfo(); + aSrcLineInfo = pA->GetLineInfo(); SetLineAndFillAttr(); - WMFRecord_SetPixel( pA->GetPoint(), pA->GetColor() ); + WMFRecord_MoveTo( pA->GetStartPoint() ); + WMFRecord_LineTo( pA->GetEndPoint() ); } - break; - - case MetaActionType::POINT: + else { - const MetaPointAction* pA = static_cast<const MetaPointAction*>(pMA); - const Point& rPt = pA->GetPoint(); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_MoveTo( rPt); - WMFRecord_LineTo( rPt ); + // LineInfo used; handle Dash/Dot and fat lines + basegfx::B2DPolygon aPolygon; + aPolygon.append(basegfx::B2DPoint(pA->GetStartPoint().X(), pA->GetStartPoint().Y())); + aPolygon.append(basegfx::B2DPoint(pA->GetEndPoint().X(), pA->GetEndPoint().Y())); + HandleLineInfoPolyPolygons(pA->GetLineInfo(), aPolygon); } - break; + } + break; + + case MetaActionType::RECT: + { + const MetaRectAction* pA = static_cast<const MetaRectAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Rectangle( pA->GetRect() ); + } + break; + + case MetaActionType::ROUNDRECT: + { + const MetaRoundRectAction* pA = static_cast<const MetaRoundRectAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_RoundRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() ); + } + break; + + case MetaActionType::ELLIPSE: + { + const MetaEllipseAction* pA = static_cast<const MetaEllipseAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Ellipse( pA->GetRect() ); + } + break; - case MetaActionType::LINE: + case MetaActionType::ARC: + { + const MetaArcAction* pA = static_cast<const MetaArcAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Arc( pA->GetRect(),pA->GetStartPoint(),pA->GetEndPoint() ); + } + break; + + case MetaActionType::PIE: + { + const MetaPieAction* pA = static_cast<const MetaPieAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Pie( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); + } + break; + + case MetaActionType::CHORD: + { + const MetaChordAction* pA = static_cast<const MetaChordAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Chord( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); + } + break; + + case MetaActionType::POLYLINE: + { + const MetaPolyLineAction* pA = static_cast<const MetaPolyLineAction*>(pMA); + const tools::Polygon& rPoly = pA->GetPolygon(); + + if( rPoly.GetSize() ) { - const MetaLineAction* pA = static_cast<const MetaLineAction *>(pMA); if(pA->GetLineInfo().IsDefault()) { aSrcLineInfo = pA->GetLineInfo(); SetLineAndFillAttr(); - WMFRecord_MoveTo( pA->GetStartPoint() ); - WMFRecord_LineTo( pA->GetEndPoint() ); + WMFRecord_PolyLine( rPoly ); } else { // LineInfo used; handle Dash/Dot and fat lines - basegfx::B2DPolygon aPolygon; - aPolygon.append(basegfx::B2DPoint(pA->GetStartPoint().X(), pA->GetStartPoint().Y())); - aPolygon.append(basegfx::B2DPoint(pA->GetEndPoint().X(), pA->GetEndPoint().Y())); - HandleLineInfoPolyPolygons(pA->GetLineInfo(), aPolygon); + HandleLineInfoPolyPolygons(pA->GetLineInfo(), rPoly.getB2DPolygon()); } } - break; - - case MetaActionType::RECT: - { - const MetaRectAction* pA = static_cast<const MetaRectAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Rectangle( pA->GetRect() ); - } - break; - - case MetaActionType::ROUNDRECT: - { - const MetaRoundRectAction* pA = static_cast<const MetaRoundRectAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_RoundRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound() ); - } - break; + } + break; - case MetaActionType::ELLIPSE: - { - const MetaEllipseAction* pA = static_cast<const MetaEllipseAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Ellipse( pA->GetRect() ); - } - break; + case MetaActionType::POLYGON: + { + const MetaPolygonAction* pA = static_cast<const MetaPolygonAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Polygon( pA->GetPolygon() ); + } + break; - case MetaActionType::ARC: - { - const MetaArcAction* pA = static_cast<const MetaArcAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Arc( pA->GetRect(),pA->GetStartPoint(),pA->GetEndPoint() ); - } - break; + case MetaActionType::POLYPOLYGON: + { + const MetaPolyPolygonAction* pA = static_cast<const MetaPolyPolygonAction*>(pMA); + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_PolyPolygon( pA->GetPolyPolygon() ); + } + break; - case MetaActionType::PIE: - { - const MetaPieAction* pA = static_cast<const MetaPieAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Pie( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); - } - break; + case MetaActionType::TEXTRECT: + { + const MetaTextRectAction * pA = static_cast<const MetaTextRectAction*>(pMA); + OUString aTemp( pA->GetText() ); + aSrcLineInfo = LineInfo(); + SetAllAttr(); + + Point aPos( pA->GetRect().TopLeft() ); + if ( !WMFRecord_Escape_Unicode( aPos, aTemp, nullptr ) ) + WMFRecord_TextOut( aPos, aTemp ); + } + break; - case MetaActionType::CHORD: - { - const MetaChordAction* pA = static_cast<const MetaChordAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Chord( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint() ); - } - break; + case MetaActionType::TEXT: + { + const MetaTextAction * pA = static_cast<const MetaTextAction*>(pMA); + OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); + aSrcLineInfo = LineInfo(); + SetAllAttr(); + if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, nullptr ) ) + WMFRecord_TextOut( pA->GetPoint(), aTemp ); + } + break; - case MetaActionType::POLYLINE: - { - const MetaPolyLineAction* pA = static_cast<const MetaPolyLineAction*>(pMA); - const tools::Polygon& rPoly = pA->GetPolygon(); + case MetaActionType::TEXTARRAY: + { + const MetaTextArrayAction* pA = static_cast<const MetaTextArrayAction*>(pMA); - if( rPoly.GetSize() ) - { - if(pA->GetLineInfo().IsDefault()) - { - aSrcLineInfo = pA->GetLineInfo(); - SetLineAndFillAttr(); - WMFRecord_PolyLine( rPoly ); - } - else - { - // LineInfo used; handle Dash/Dot and fat lines - HandleLineInfoPolyPolygons(pA->GetLineInfo(), rPoly.getB2DPolygon()); - } - } - } - break; + OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); + aSrcLineInfo = LineInfo(); + SetAllAttr(); + if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pA->GetDXArray() ) ) + WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pA->GetDXArray() ); + } + break; - case MetaActionType::POLYGON: - { - const MetaPolygonAction* pA = static_cast<const MetaPolygonAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Polygon( pA->GetPolygon() ); - } - break; + case MetaActionType::STRETCHTEXT: + { + const MetaStretchTextAction* pA = static_cast<const MetaStretchTextAction *>(pMA); + OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); - case MetaActionType::POLYPOLYGON: + pVirDev->SetFont( aSrcFont ); + const sal_Int32 nLen = aTemp.getLength(); + std::unique_ptr<long[]> pDXAry(nLen ? new long[ nLen ] : nullptr); + const sal_Int32 nNormSize = pVirDev->GetTextArray( aTemp, pDXAry.get() ); + if (nLen && nNormSize == 0) { - const MetaPolyPolygonAction* pA = static_cast<const MetaPolyPolygonAction*>(pMA); - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_PolyPolygon( pA->GetPolyPolygon() ); + OSL_FAIL("Impossible div by 0 action: MetaStretchTextAction!"); } - break; - - case MetaActionType::TEXTRECT: + else { - const MetaTextRectAction * pA = static_cast<const MetaTextRectAction*>(pMA); - OUString aTemp( pA->GetText() ); + for ( sal_Int32 i = 0; i < ( nLen - 1 ); i++ ) + pDXAry[ i ] = pDXAry[ i ] * static_cast<sal_Int32>(pA->GetWidth()) / nNormSize; + if ( ( nLen <= 1 ) || ( static_cast<sal_Int32>(pA->GetWidth()) == nNormSize ) ) + pDXAry.reset(); aSrcLineInfo = LineInfo(); SetAllAttr(); - - Point aPos( pA->GetRect().TopLeft() ); - if ( !WMFRecord_Escape_Unicode( aPos, aTemp, nullptr ) ) - WMFRecord_TextOut( aPos, aTemp ); + if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pDXAry.get() ) ) + WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pDXAry.get() ); } - break; + } + break; - case MetaActionType::TEXT: - { - const MetaTextAction * pA = static_cast<const MetaTextAction*>(pMA); - OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); - aSrcLineInfo = LineInfo(); - SetAllAttr(); - if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, nullptr ) ) - WMFRecord_TextOut( pA->GetPoint(), aTemp ); - } - break; + case MetaActionType::BMP: + { + const MetaBmpAction* pA = static_cast<const MetaBmpAction *>(pMA); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetBitmap().GetSizePixel(), pA->GetBitmap() ); + } + break; - case MetaActionType::TEXTARRAY: - { - const MetaTextArrayAction* pA = static_cast<const MetaTextArrayAction*>(pMA); + case MetaActionType::BMPSCALE: + { + const MetaBmpScaleAction* pA = static_cast<const MetaBmpScaleAction*>(pMA); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pA->GetBitmap() ); + } + break; - OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); - aSrcLineInfo = LineInfo(); - SetAllAttr(); - if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pA->GetDXArray() ) ) - WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pA->GetDXArray() ); - } - break; + case MetaActionType::BMPSCALEPART: + { + const MetaBmpScalePartAction* pA = static_cast<const MetaBmpScalePartAction*>(pMA); + Bitmap aTmp( pA->GetBitmap() ); - case MetaActionType::STRETCHTEXT: - { - const MetaStretchTextAction* pA = static_cast<const MetaStretchTextAction *>(pMA); - OUString aTemp = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); - - pVirDev->SetFont( aSrcFont ); - const sal_Int32 nLen = aTemp.getLength(); - std::unique_ptr<long[]> pDXAry(nLen ? new long[ nLen ] : nullptr); - const sal_Int32 nNormSize = pVirDev->GetTextArray( aTemp, pDXAry.get() ); - if (nLen && nNormSize == 0) - { - OSL_FAIL("Impossible div by 0 action: MetaStretchTextAction!"); - } - else - { - for ( sal_Int32 i = 0; i < ( nLen - 1 ); i++ ) - pDXAry[ i ] = pDXAry[ i ] * static_cast<sal_Int32>(pA->GetWidth()) / nNormSize; - if ( ( nLen <= 1 ) || ( static_cast<sal_Int32>(pA->GetWidth()) == nNormSize ) ) - pDXAry.reset(); - aSrcLineInfo = LineInfo(); - SetAllAttr(); - if ( !WMFRecord_Escape_Unicode( pA->GetPoint(), aTemp, pDXAry.get() ) ) - WMFRecord_ExtTextOut( pA->GetPoint(), aTemp, pDXAry.get() ); - } - } - break; + if( aTmp.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ) ) + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aTmp ); + } + break; - case MetaActionType::BMP: - { - const MetaBmpAction* pA = static_cast<const MetaBmpAction *>(pMA); - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetBitmap().GetSizePixel(), pA->GetBitmap() ); - } - break; + case MetaActionType::BMPEX: + { + const MetaBmpExAction* pA = static_cast<const MetaBmpExAction *>(pMA); + Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); + Bitmap aMsk( pA->GetBitmapEx().GetMask() ); - case MetaActionType::BMPSCALE: + if( !!aMsk ) { - const MetaBmpScaleAction* pA = static_cast<const MetaBmpScaleAction*>(pMA); - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pA->GetBitmap() ); + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + WMFRecord_StretchDIB( pA->GetPoint(), aMsk.GetSizePixel(), aBmp, W_SRCPAINT ); + WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp, W_SRCAND ); } - break; - - case MetaActionType::BMPSCALEPART: - { - const MetaBmpScalePartAction* pA = static_cast<const MetaBmpScalePartAction*>(pMA); - Bitmap aTmp( pA->GetBitmap() ); + else + WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp ); + } + break; - if( aTmp.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ) ) - WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aTmp ); - } - break; + case MetaActionType::BMPEXSCALE: + { + const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pMA); + Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); + Bitmap aMsk( pA->GetBitmapEx().GetMask() ); - case MetaActionType::BMPEX: + if( !!aMsk ) { - const MetaBmpExAction* pA = static_cast<const MetaBmpExAction *>(pMA); - Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); - Bitmap aMsk( pA->GetBitmapEx().GetMask() ); - - if( !!aMsk ) - { - aBmp.Replace( aMsk, COL_WHITE ); - aMsk.Invert(); - WMFRecord_StretchDIB( pA->GetPoint(), aMsk.GetSizePixel(), aBmp, W_SRCPAINT ); - WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp, W_SRCAND ); - } - else - WMFRecord_StretchDIB( pA->GetPoint(), aBmp.GetSizePixel(), aBmp ); + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aMsk, W_SRCPAINT ); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp, W_SRCAND ); } - break; - - case MetaActionType::BMPEXSCALE: - { - const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pMA); - Bitmap aBmp( pA->GetBitmapEx().GetBitmap() ); - Bitmap aMsk( pA->GetBitmapEx().GetMask() ); + else + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp ); + } + break; - if( !!aMsk ) - { - aBmp.Replace( aMsk, COL_WHITE ); - aMsk.Invert(); - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aMsk, W_SRCPAINT ); - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp, W_SRCAND ); - } - else - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), aBmp ); - } - break; + case MetaActionType::BMPEXSCALEPART: + { + const MetaBmpExScalePartAction* pA = static_cast<const MetaBmpExScalePartAction*>(pMA); + BitmapEx aBmpEx( pA->GetBitmapEx() ); + aBmpEx.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); + Bitmap aBmp( aBmpEx.GetBitmap() ); + Bitmap aMsk( aBmpEx.GetMask() ); - case MetaActionType::BMPEXSCALEPART: + if( !!aMsk ) { - const MetaBmpExScalePartAction* pA = static_cast<const MetaBmpExScalePartAction*>(pMA); - BitmapEx aBmpEx( pA->GetBitmapEx() ); - aBmpEx.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); - Bitmap aBmp( aBmpEx.GetBitmap() ); - Bitmap aMsk( aBmpEx.GetMask() ); - - if( !!aMsk ) - { - aBmp.Replace( aMsk, COL_WHITE ); - aMsk.Invert(); - WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aMsk, W_SRCPAINT ); - WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp, W_SRCAND ); - } - else - WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp ); + aBmp.Replace( aMsk, COL_WHITE ); + aMsk.Invert(); + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aMsk, W_SRCPAINT ); + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp, W_SRCAND ); } - break; + else + WMFRecord_StretchDIB( pA->GetDestPoint(), pA->GetDestSize(), aBmp ); + } + break; - case MetaActionType::GRADIENT: - { - const MetaGradientAction* pA = static_cast<const MetaGradientAction*>(pMA); - GDIMetaFile aTmpMtf; + case MetaActionType::GRADIENT: + { + const MetaGradientAction* pA = static_cast<const MetaGradientAction*>(pMA); + GDIMetaFile aTmpMtf; - pVirDev->AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf ); - WriteRecords( aTmpMtf ); - } - break; + pVirDev->AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf ); + WriteRecords( aTmpMtf ); + } + break; - case MetaActionType::HATCH: - { - const MetaHatchAction* pA = static_cast<const MetaHatchAction*>(pMA); - GDIMetaFile aTmpMtf; + case MetaActionType::HATCH: + { + const MetaHatchAction* pA = static_cast<const MetaHatchAction*>(pMA); + GDIMetaFile aTmpMtf; - pVirDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf ); - WriteRecords( aTmpMtf ); - } - break; + pVirDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf ); + WriteRecords( aTmpMtf ); + } + break; - case MetaActionType::WALLPAPER: - { - const MetaWallpaperAction* pA = static_cast<const MetaWallpaperAction*>(pMA); - const Color& rColor = pA->GetWallpaper().GetColor(); - const Color aOldLineColor( aSrcLineColor ); - const Color aOldFillColor( aSrcFillColor ); + case MetaActionType::WALLPAPER: + { + const MetaWallpaperAction* pA = static_cast<const MetaWallpaperAction*>(pMA); + const Color& rColor = pA->GetWallpaper().GetColor(); + const Color aOldLineColor( aSrcLineColor ); + const Color aOldFillColor( aSrcFillColor ); + + aSrcLineColor = rColor; + aSrcFillColor = rColor; + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_Rectangle( pA->GetRect() ); + aSrcLineColor = aOldLineColor; + aSrcFillColor = aOldFillColor; + } + break; - aSrcLineColor = rColor; - aSrcFillColor = rColor; - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_Rectangle( pA->GetRect() ); - aSrcLineColor = aOldLineColor; - aSrcFillColor = aOldFillColor; - } - break; + case MetaActionType::ISECTRECTCLIPREGION: + { + const MetaISectRectClipRegionAction* pA = static_cast<const MetaISectRectClipRegionAction*>(pMA); + WMFRecord_IntersectClipRect( pA->GetRect() ); + } + break; - case MetaActionType::ISECTRECTCLIPREGION: - { - const MetaISectRectClipRegionAction* pA = static_cast<const MetaISectRectClipRegionAction*>(pMA); - WMFRecord_IntersectClipRect( pA->GetRect() ); - } - break; + case MetaActionType::LINECOLOR: + { + const MetaLineColorAction* pA = static_cast<const MetaLineColorAction*>(pMA); - case MetaActionType::LINECOLOR: - { - const MetaLineColorAction* pA = static_cast<const MetaLineColorAction*>(pMA); + if( pA->IsSetting() ) + aSrcLineColor = pA->GetColor(); + else + aSrcLineColor = COL_TRANSPARENT; + } + break; - if( pA->IsSetting() ) - aSrcLineColor = pA->GetColor(); - else - aSrcLineColor = COL_TRANSPARENT; - } - break; + case MetaActionType::FILLCOLOR: + { + const MetaFillColorAction* pA = static_cast<const MetaFillColorAction*>(pMA); - case MetaActionType::FILLCOLOR: - { - const MetaFillColorAction* pA = static_cast<const MetaFillColorAction*>(pMA); + if( pA->IsSetting() ) + aSrcFillColor = pA->GetColor(); + else + aSrcFillColor = COL_TRANSPARENT; + } + break; - if( pA->IsSetting() ) - aSrcFillColor = pA->GetColor(); - else - aSrcFillColor = COL_TRANSPARENT; - } - break; + case MetaActionType::TEXTCOLOR: + { + const MetaTextColorAction* pA = static_cast<const MetaTextColorAction*>(pMA); + aSrcTextColor = pA->GetColor(); + } + break; - case MetaActionType::TEXTCOLOR: - { - const MetaTextColorAction* pA = static_cast<const MetaTextColorAction*>(pMA); - aSrcTextColor = pA->GetColor(); - } - break; + case MetaActionType::TEXTFILLCOLOR: + { + const MetaTextFillColorAction* pA = static_cast<const MetaTextFillColorAction*>(pMA); + if( pA->IsSetting() ) + aSrcFont.SetFillColor( pA->GetColor() ); + else + aSrcFont.SetFillColor( COL_TRANSPARENT ); + } + break; - case MetaActionType::TEXTFILLCOLOR: - { - const MetaTextFillColorAction* pA = static_cast<const MetaTextFillColorAction*>(pMA); - if( pA->IsSetting() ) - aSrcFont.SetFillColor( pA->GetColor() ); - else - aSrcFont.SetFillColor( COL_TRANSPARENT ); - } - break; + case MetaActionType::TEXTALIGN: + { + const MetaTextAlignAction* pA = static_cast<const MetaTextAlignAction*>(pMA); + eSrcTextAlign = pA->GetTextAlign(); + } + break; - case MetaActionType::TEXTALIGN: - { - const MetaTextAlignAction* pA = static_cast<const MetaTextAlignAction*>(pMA); - eSrcTextAlign = pA->GetTextAlign(); - } - break; + case MetaActionType::MAPMODE: + { + const MetaMapModeAction* pA = static_cast<const MetaMapModeAction*>(pMA); - case MetaActionType::MAPMODE: + if (aSrcMapMode!=pA->GetMapMode()) { - const MetaMapModeAction* pA = static_cast<const MetaMapModeAction*>(pMA); - - if (aSrcMapMode!=pA->GetMapMode()) + if( pA->GetMapMode().GetMapUnit() == MapUnit::MapRelative ) { - if( pA->GetMapMode().GetMapUnit() == MapUnit::MapRelative ) - { - const MapMode& aMM = pA->GetMapMode(); - Fraction aScaleX = aMM.GetScaleX(); - Fraction aScaleY = aMM.GetScaleY(); - - Point aOrigin = aSrcMapMode.GetOrigin(); - BigInt aX( aOrigin.X() ); - aX *= BigInt( aScaleX.GetDenominator() ); - if( aOrigin.X() >= 0 ) - if( aScaleX.GetNumerator() >= 0 ) - aX += BigInt( aScaleX.GetNumerator()/2 ); - else - aX -= BigInt( (aScaleX.GetNumerator()+1)/2 ); + const MapMode& aMM = pA->GetMapMode(); + Fraction aScaleX = aMM.GetScaleX(); + Fraction aScaleY = aMM.GetScaleY(); + + Point aOrigin = aSrcMapMode.GetOrigin(); + BigInt aX( aOrigin.X() ); + aX *= BigInt( aScaleX.GetDenominator() ); + if( aOrigin.X() >= 0 ) + if( aScaleX.GetNumerator() >= 0 ) + aX += BigInt( aScaleX.GetNumerator()/2 ); else - if( aScaleX.GetNumerator() >= 0 ) - aX -= BigInt( (aScaleX.GetNumerator()-1)/2 ); - else - aX += BigInt( aScaleX.GetNumerator()/2 ); - aX /= BigInt( aScaleX.GetNumerator() ); - aOrigin.setX( static_cast<long>(aX) + aMM.GetOrigin().X() ); - BigInt aY( aOrigin.Y() ); - aY *= BigInt( aScaleY.GetDenominator() ); - if( aOrigin.Y() >= 0 ) - if( aScaleY.GetNumerator() >= 0 ) - aY += BigInt( aScaleY.GetNumerator()/2 ); - else - aY -= BigInt( (aScaleY.GetNumerator()+1)/2 ); + aX -= BigInt( (aScaleX.GetNumerator()+1)/2 ); + else + if( aScaleX.GetNumerator() >= 0 ) + aX -= BigInt( (aScaleX.GetNumerator()-1)/2 ); + else + aX += BigInt( aScaleX.GetNumerator()/2 ); + aX /= BigInt( aScaleX.GetNumerator() ); + aOrigin.setX( static_cast<long>(aX) + aMM.GetOrigin().X() ); + BigInt aY( aOrigin.Y() ); + aY *= BigInt( aScaleY.GetDenominator() ); + if( aOrigin.Y() >= 0 ) + if( aScaleY.GetNumerator() >= 0 ) + aY += BigInt( aScaleY.GetNumerator()/2 ); else - if( aScaleY.GetNumerator() >= 0 ) - aY -= BigInt( (aScaleY.GetNumerator()-1)/2 ); - else - aY += BigInt( aScaleY.GetNumerator()/2 ); - aY /= BigInt( aScaleY.GetNumerator() ); - aOrigin.setY( static_cast<long>(aY) + aMM.GetOrigin().Y() ); - aSrcMapMode.SetOrigin( aOrigin ); - - aScaleX *= aSrcMapMode.GetScaleX(); - aScaleY *= aSrcMapMode.GetScaleY(); - aSrcMapMode.SetScaleX( aScaleX ); - aSrcMapMode.SetScaleY( aScaleY ); - } + aY -= BigInt( (aScaleY.GetNumerator()+1)/2 ); else - aSrcMapMode=pA->GetMapMode(); + if( aScaleY.GetNumerator() >= 0 ) + aY -= BigInt( (aScaleY.GetNumerator()-1)/2 ); + else + aY += BigInt( aScaleY.GetNumerator()/2 ); + aY /= BigInt( aScaleY.GetNumerator() ); + aOrigin.setY( static_cast<long>(aY) + aMM.GetOrigin().Y() ); + aSrcMapMode.SetOrigin( aOrigin ); + + aScaleX *= aSrcMapMode.GetScaleX(); + aScaleY *= aSrcMapMode.GetScaleY(); + aSrcMapMode.SetScaleX( aScaleX ); + aSrcMapMode.SetScaleY( aScaleY ); } + else + aSrcMapMode=pA->GetMapMode(); } - break; + } + break; - case MetaActionType::FONT: - { - const MetaFontAction* pA = static_cast<const MetaFontAction*>(pMA); - aSrcFont = pA->GetFont(); + case MetaActionType::FONT: + { + const MetaFontAction* pA = static_cast<const MetaFontAction*>(pMA); + aSrcFont = pA->GetFont(); - if ( (aSrcFont.GetCharSet() == RTL_TEXTENCODING_DONTKNOW) - || (aSrcFont.GetCharSet() == RTL_TEXTENCODING_UNICODE) ) - { - aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 ); - } - eSrcTextAlign = aSrcFont.GetAlignment(); - aSrcTextColor = aSrcFont.GetColor(); - aSrcFont.SetAlignment( ALIGN_BASELINE ); - aSrcFont.SetColor( COL_WHITE ); + if ( (aSrcFont.GetCharSet() == RTL_TEXTENCODING_DONTKNOW) + || (aSrcFont.GetCharSet() == RTL_TEXTENCODING_UNICODE) ) + { + aSrcFont.SetCharSet( RTL_TEXTENCODING_MS_1252 ); } - break; + eSrcTextAlign = aSrcFont.GetAlignment(); + aSrcTextColor = aSrcFont.GetColor(); + aSrcFont.SetAlignment( ALIGN_BASELINE ); + aSrcFont.SetColor( COL_WHITE ); + } + break; - case MetaActionType::PUSH: - { - const MetaPushAction* pA = static_cast<const MetaPushAction*>(pMA); - - WMFWriterAttrStackMember* pAt = new WMFWriterAttrStackMember; - pAt->nFlags = pA->GetFlags(); - pAt->aClipRegion = aSrcClipRegion; - pAt->aLineColor=aSrcLineColor; - pAt->aFillColor=aSrcFillColor; - pAt->eRasterOp=eSrcRasterOp; - pAt->aFont=aSrcFont; - pAt->eTextAlign=eSrcTextAlign; - pAt->aTextColor=aSrcTextColor; - pAt->aMapMode=aSrcMapMode; - pAt->aLineInfo=aDstLineInfo; - pAt->pSucc=pAttrStack; - pAttrStack=pAt; - - SetAllAttr(); // update ( now all source attributes are equal to the destination attributes ) - WMFRecord_SaveDC(); + case MetaActionType::PUSH: + { + const MetaPushAction* pA = static_cast<const MetaPushAction*>(pMA); + + WMFWriterAttrStackMember* pAt = new WMFWriterAttrStackMember; + pAt->nFlags = pA->GetFlags(); + pAt->aClipRegion = aSrcClipRegion; + pAt->aLineColor=aSrcLineColor; + pAt->aFillColor=aSrcFillColor; + pAt->eRasterOp=eSrcRasterOp; + pAt->aFont=aSrcFont; + pAt->eTextAlign=eSrcTextAlign; + pAt->aTextColor=aSrcTextColor; + pAt->aMapMode=aSrcMapMode; + pAt->aLineInfo=aDstLineInfo; + pAt->pSucc=pAttrStack; + pAttrStack=pAt; + + SetAllAttr(); // update ( now all source attributes are equal to the destination attributes ) + WMFRecord_SaveDC(); - } - break; + } + break; - case MetaActionType::POP: - { - WMFWriterAttrStackMember * pAt=pAttrStack; + case MetaActionType::POP: + { + WMFWriterAttrStackMember * pAt=pAttrStack; - if( pAt ) - { - aDstLineInfo = pAt->aLineInfo; - aDstLineColor = pAt->aLineColor; - if ( pAt->nFlags & PushFlags::LINECOLOR ) - aSrcLineColor = pAt->aLineColor; - aDstFillColor = pAt->aFillColor; - if ( pAt->nFlags & PushFlags::FILLCOLOR ) - aSrcFillColor = pAt->aFillColor; - eDstROP2 = pAt->eRasterOp; - if ( pAt->nFlags & PushFlags::RASTEROP ) - eSrcRasterOp = pAt->eRasterOp; - aDstFont = pAt->aFont; - if ( pAt->nFlags & PushFlags::FONT ) - aSrcFont = pAt->aFont; - eDstTextAlign = pAt->eTextAlign; - if ( pAt->nFlags & ( PushFlags::FONT | PushFlags::TEXTALIGN ) ) - eSrcTextAlign = pAt->eTextAlign; - aDstTextColor = pAt->aTextColor; - if ( pAt->nFlags & ( PushFlags::FONT | PushFlags::TEXTCOLOR ) ) - aSrcTextColor = pAt->aTextColor; - if ( pAt->nFlags & PushFlags::MAPMODE ) - aSrcMapMode = pAt->aMapMode; - aDstClipRegion = pAt->aClipRegion; - if ( pAt->nFlags & PushFlags::CLIPREGION ) - aSrcClipRegion = pAt->aClipRegion; - - WMFRecord_RestoreDC(); - pAttrStack = pAt->pSucc; - delete pAt; - } + if( pAt ) + { + aDstLineInfo = pAt->aLineInfo; + aDstLineColor = pAt->aLineColor; + if ( pAt->nFlags & PushFlags::LINECOLOR ) + aSrcLineColor = pAt->aLineColor; + aDstFillColor = pAt->aFillColor; + if ( pAt->nFlags & PushFlags::FILLCOLOR ) + aSrcFillColor = pAt->aFillColor; + eDstROP2 = pAt->eRasterOp; + if ( pAt->nFlags & PushFlags::RASTEROP ) + eSrcRasterOp = pAt->eRasterOp; + aDstFont = pAt->aFont; + if ( pAt->nFlags & PushFlags::FONT ) + aSrcFont = pAt->aFont; + eDstTextAlign = pAt->eTextAlign; + if ( pAt->nFlags & ( PushFlags::FONT | PushFlags::TEXTALIGN ) ) + eSrcTextAlign = pAt->eTextAlign; + aDstTextColor = pAt->aTextColor; + if ( pAt->nFlags & ( PushFlags::FONT | PushFlags::TEXTCOLOR ) ) + aSrcTextColor = pAt->aTextColor; + if ( pAt->nFlags & PushFlags::MAPMODE ) + aSrcMapMode = pAt->aMapMode; + aDstClipRegion = pAt->aClipRegion; + if ( pAt->nFlags & PushFlags::CLIPREGION ) + aSrcClipRegion = pAt->aClipRegion; + + WMFRecord_RestoreDC(); + pAttrStack = pAt->pSucc; + delete pAt; } - break; + } + break; - case MetaActionType::EPS : - { - const MetaEPSAction* pA = static_cast<const MetaEPSAction*>(pMA); - const GDIMetaFile& aGDIMetaFile( pA->GetSubstitute() ); + case MetaActionType::EPS : + { + const MetaEPSAction* pA = static_cast<const MetaEPSAction*>(pMA); + const GDIMetaFile& aGDIMetaFile( pA->GetSubstitute() ); - size_t nCount = aGDIMetaFile.GetActionSize(); - for ( size_t i = 0; i < nCount; i++ ) + size_t nCount = aGDIMetaFile.GetActionSize(); + for ( size_t i = 0; i < nCount; i++ ) + { + const MetaAction* pMetaAct = aGDIMetaFile.GetAction( i ); + if ( pMetaAct->GetType() == MetaActionType::BMPSCALE ) { - const MetaAction* pMetaAct = aGDIMetaFile.GetAction( i ); - if ( pMetaAct->GetType() == MetaActionType::BMPSCALE ) - { - const MetaBmpScaleAction* pBmpScaleAction = static_cast<const MetaBmpScaleAction*>(pMetaAct); - WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap() ); - break; - } + const MetaBmpScaleAction* pBmpScaleAction = static_cast<const MetaBmpScaleAction*>(pMetaAct); + WMFRecord_StretchDIB( pA->GetPoint(), pA->GetSize(), pBmpScaleAction->GetBitmap() ); + break; } } - break; + } + break; - case MetaActionType::RASTEROP: - { - const MetaRasterOpAction* pA = static_cast<const MetaRasterOpAction*>(pMA); - eSrcRasterOp=pA->GetRasterOp(); - } - break; + case MetaActionType::RASTEROP: + { + const MetaRasterOpAction* pA = static_cast<const MetaRasterOpAction*>(pMA); + eSrcRasterOp=pA->GetRasterOp(); + } + break; - case MetaActionType::Transparent: - { - aSrcLineInfo = LineInfo(); - SetLineAndFillAttr(); - WMFRecord_PolyPolygon( static_cast<const MetaTransparentAction*>(pMA)->GetPolyPolygon() ); - } - break; + case MetaActionType::Transparent: + { + aSrcLineInfo = LineInfo(); + SetLineAndFillAttr(); + WMFRecord_PolyPolygon( static_cast<const MetaTransparentAction*>(pMA)->GetPolyPolygon() ); + } + break; - case MetaActionType::FLOATTRANSPARENT: - { - const MetaFloatTransparentAction* pA = static_cast<const MetaFloatTransparentAction*>(pMA); + case MetaActionType::FLOATTRANSPARENT: + { + const MetaFloatTransparentAction* pA = static_cast<const MetaFloatTransparentAction*>(pMA); - GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() ); - Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() ); - const Size aSrcSize( aTmpMtf.GetPrefSize() ); - const Point aDestPt( pA->GetPoint() ); - const Size aDestSize( pA->GetSize() ); - const double fScaleX = aSrcSize.Width() ? static_cast<double>(aDestSize.Width()) / aSrcSize.Width() : 1.0; - const double fScaleY = aSrcSize.Height() ? static_cast<double>(aDestSize.Height()) / aSrcSize.Height() : 1.0; - long nMoveX, nMoveY; + GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() ); + Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() ); + const Size aSrcSize( aTmpMtf.GetPrefSize() ); + const Point aDestPt( pA->GetPoint() ); + const Size aDestSize( pA->GetSize() ); + const double fScaleX = aSrcSize.Width() ? static_cast<double>(aDestSize.Width()) / aSrcSize.Width() : 1.0; + const double fScaleY = aSrcSize.Height() ? static_cast<double>(aDestSize.Height()) / aSrcSize.Height() : 1.0; + long nMoveX, nMoveY; - aSrcLineInfo = LineInfo(); - SetAllAttr(); + aSrcLineInfo = LineInfo(); + SetAllAttr(); - if( fScaleX != 1.0 || fScaleY != 1.0 ) - { - aTmpMtf.Scale( fScaleX, fScaleY ); - aSrcPt.setX( FRound( aSrcPt.X() * fScaleX ) ); - aSrcPt.setY( FRound( aSrcPt.Y() * fScaleY ) ); - } + if( fScaleX != 1.0 || fScaleY != 1.0 ) + { + aTmpMtf.Scale( fScaleX, fScaleY ); + aSrcPt.setX( FRound( aSrcPt.X() * fScaleX ) ); + aSrcPt.setY( FRound( aSrcPt.Y() * fScaleY ) ); + } - nMoveX = aDestPt.X() - aSrcPt.X(); - nMoveY = aDestPt.Y() - aSrcPt.Y(); + nMoveX = aDestPt.X() - aSrcPt.X(); + nMoveY = aDestPt.Y() - aSrcPt.Y(); - if( nMoveX || nMoveY ) - aTmpMtf.Move( nMoveX, nMoveY ); + if( nMoveX || nMoveY ) + aTmpMtf.Move( nMoveX, nMoveY ); - WriteRecords( aTmpMtf ); - } - break; + WriteRecords( aTmpMtf ); + } + break; - case MetaActionType::LAYOUTMODE: + case MetaActionType::LAYOUTMODE: + { + ComplexTextLayoutFlags nLayoutMode = static_cast<const MetaLayoutModeAction*>(pMA)->GetLayoutMode(); + eSrcHorTextAlign = 0; // TA_LEFT + if ((nLayoutMode & ComplexTextLayoutFlags::BiDiRtl) != ComplexTextLayoutFlags::Default) { - ComplexTextLayoutFlags nLayoutMode = static_cast<const MetaLayoutModeAction*>(pMA)->GetLayoutMode(); - eSrcHorTextAlign = 0; // TA_LEFT - if ((nLayoutMode & ComplexTextLayoutFlags::BiDiRtl) != ComplexTextLayoutFlags::Default) - { - eSrcHorTextAlign = W_TA_RIGHT | W_TA_RTLREADING; - } - if ((nLayoutMode & ComplexTextLayoutFlags::TextOriginRight) != ComplexTextLayoutFlags::Default) - eSrcHorTextAlign |= W_TA_RIGHT; - else if ((nLayoutMode & ComplexTextLayoutFlags::TextOriginLeft) != ComplexTextLayoutFlags::Default) - eSrcHorTextAlign &= ~W_TA_RIGHT; - break; + eSrcHorTextAlign = W_TA_RIGHT | W_TA_RTLREADING; } - - case MetaActionType::CLIPREGION: - case MetaActionType::TEXTLANGUAGE: - case MetaActionType::COMMENT: - // Explicitly ignored cases - break; - - default: - // TODO: Implement more cases as necessary. Let's not bother with a warning. + if ((nLayoutMode & ComplexTextLayoutFlags::TextOriginRight) != ComplexTextLayoutFlags::Default) + eSrcHorTextAlign |= W_TA_RIGHT; + else if ((nLayoutMode & ComplexTextLayoutFlags::TextOriginLeft) != ComplexTextLayoutFlags::Default) + eSrcHorTextAlign &= ~W_TA_RIGHT; break; } - nWrittenActions++; - MayCallback(); - - if (pWMF->GetError()) - bStatus=false; + case MetaActionType::CLIPREGION: + case MetaActionType::TEXTLANGUAGE: + case MetaActionType::COMMENT: + // Explicitly ignored cases + break; - if(!bStatus) - break; + default: + // TODO: Implement more cases as necessary. Let's not bother with a warning. + break; } + + nWrittenActions++; + MayCallback(); + + if (pWMF->GetError()) + bStatus=false; + + if(!bStatus) + break; } } diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index cad283431bc7..c5e56e8b2db4 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -1001,22 +1001,22 @@ static void GetNames(TrueTypeFont *t) for( i = 0; t->psname[i] != 0 && bPSNameOK; i++ ) if( t->psname[ i ] < 33 || (t->psname[ i ] & 0x80) ) bPSNameOK = false; - if( !bPSNameOK ) - { - /* check if family is a suitable replacement */ - if( t->ufamily && t->family ) - { - bool bReplace = true; + if( bPSNameOK ) + return; - for( i = 0; t->ufamily[ i ] != 0 && bReplace; i++ ) - if( t->ufamily[ i ] < 33 || t->ufamily[ i ] > 127 ) - bReplace = false; - if( bReplace ) - { - free( t->psname ); - t->psname = strdup( t->family ); - } - } + /* check if family is a suitable replacement */ + if( !(t->ufamily && t->family) ) + return; + + bool bReplace = true; + + for( i = 0; t->ufamily[ i ] != 0 && bReplace; i++ ) + if( t->ufamily[ i ] < 33 || t->ufamily[ i ] > 127 ) + bReplace = false; + if( bReplace ) + { + free( t->psname ); + t->psname = strdup( t->family ); } } @@ -1325,24 +1325,24 @@ static void FindCmap(TrueTypeFont *ttf) } } - if (ttf->cmapType != CMAP_NOT_USABLE) { - switch (GetUInt16(ttf->cmap, 0)) { - case 0: ttf->mapper = getGlyph0; break; - case 2: ttf->mapper = getGlyph2; break; - case 4: ttf->mapper = getGlyph4; break; - case 6: ttf->mapper = getGlyph6; break; - case 12: ttf->mapper= getGlyph12; break; - default: + if (ttf->cmapType == CMAP_NOT_USABLE) return; + + switch (GetUInt16(ttf->cmap, 0)) { + case 0: ttf->mapper = getGlyph0; break; + case 2: ttf->mapper = getGlyph2; break; + case 4: ttf->mapper = getGlyph4; break; + case 6: ttf->mapper = getGlyph6; break; + case 12: ttf->mapper= getGlyph12; break; + default: #if OSL_DEBUG_LEVEL > 1 - /*- if the cmap table is really broken */ - SAL_WARN("vcl.fonts", ttf->fname << ": " - << GetUInt16(ttf->cmap, 0) - << " is not a recognized cmap format.."); + /*- if the cmap table is really broken */ + SAL_WARN("vcl.fonts", ttf->fname << ": " + << GetUInt16(ttf->cmap, 0) + << " is not a recognized cmap format.."); #endif - ttf->cmapType = CMAP_NOT_USABLE; - ttf->cmap = nullptr; - ttf->mapper = nullptr; - } + ttf->cmapType = CMAP_NOT_USABLE; + ttf->cmap = nullptr; + ttf->mapper = nullptr; } } diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx index 3bea9bd1e535..3980e99f99de 100644 --- a/vcl/source/fontsubset/ttcr.cxx +++ b/vcl/source/fontsubset/ttcr.cxx @@ -166,24 +166,24 @@ void AddTable(TrueTypeCreator *_this, TrueTypeTable *table) void RemoveTable(TrueTypeCreator *_this, sal_uInt32 tag) { - if (listCount(_this->tables)) - { - listToFirst(_this->tables); - int done = 0; - do { - if (static_cast<TrueTypeTable *>(listCurrent(_this->tables))->tag == tag) - { - listRemove(_this->tables); - } - else + if (!listCount(_this->tables)) + return; + + listToFirst(_this->tables); + int done = 0; + do { + if (static_cast<TrueTypeTable *>(listCurrent(_this->tables))->tag == tag) + { + listRemove(_this->tables); + } + else + { + if (listNext(_this->tables)) { - if (listNext(_this->tables)) - { - done = 1; - } + done = 1; } - } while (!done); - } + } + } while (!done); } static void ProcessTables(TrueTypeCreator *); @@ -430,21 +430,21 @@ static void TrueTypeTableDispose_glyf(TrueTypeTable *_this) static void TrueTypeTableDispose_cmap(TrueTypeTable *_this) { - if (_this) { - table_cmap *t = static_cast<table_cmap *>(_this->data); - if (t) { - CmapSubTable *s = t->s; - if (s) { - for (sal_uInt32 i = 0; i < t->m; i++) { - if (s[i].xc) free(s[i].xc); - if (s[i].xg) free(s[i].xg); - } - free(s); + if (!_this) return; + + table_cmap *t = static_cast<table_cmap *>(_this->data); + if (t) { + CmapSubTable *s = t->s; + if (s) { + for (sal_uInt32 i = 0; i < t->m; i++) { + if (s[i].xc) free(s[i].xc); + if (s[i].xg) free(s[i].xg); } - free(t); + free(s); } - free(_this); + free(t); } + free(_this); } static void TrueTypeTableDispose_name(TrueTypeTable *_this) @@ -457,23 +457,23 @@ static void TrueTypeTableDispose_name(TrueTypeTable *_this) static void TrueTypeTableDispose_post(TrueTypeTable *_this) { - if (_this) { - tdata_post *p = static_cast<tdata_post *>(_this->data); - if (p) { - if (p->format == 0x00030000) { - /* do nothing */ - } else { - SAL_WARN("vcl.fonts", "Unsupported format of a 'post' table: " - << std::setfill('0') - << std::setw(8) - << std::hex - << std::uppercase - << static_cast<int>(p->format) << "."); - } - free(p); + if (!_this) return; + + tdata_post *p = static_cast<tdata_post *>(_this->data); + if (p) { + if (p->format == 0x00030000) { + /* do nothing */ + } else { + SAL_WARN("vcl.fonts", "Unsupported format of a 'post' table: " + << std::setfill('0') + << std::setw(8) + << std::hex + << std::uppercase + << static_cast<int>(p->format) << "."); } - free(_this); + free(p); } + free(_this); } /* destructor vtable */ diff --git a/vcl/source/helper/canvasbitmap.cxx b/vcl/source/helper/canvasbitmap.cxx index b720cdf3b1b7..1747c09d5cf4 100644 --- a/vcl/source/helper/canvasbitmap.cxx +++ b/vcl/source/helper/canvasbitmap.cxx @@ -128,268 +128,268 @@ VclCanvasBitmap::VclCanvasBitmap( const BitmapEx& rBitmap ) : m_aLayout.Palette.clear(); m_aLayout.IsMsbFirst = false; - if( m_pBmpAcc ) + if( !m_pBmpAcc ) + return; + + m_aLayout.ScanLines = m_pBmpAcc->Height(); + m_aLayout.ScanLineBytes = (m_pBmpAcc->GetBitCount()*m_pBmpAcc->Width() + 7) / 8; + m_aLayout.ScanLineStride = m_pBmpAcc->GetScanlineSize(); + m_aLayout.PlaneStride = 0; + + switch( m_pBmpAcc->GetScanlineFormat() ) { - m_aLayout.ScanLines = m_pBmpAcc->Height(); - m_aLayout.ScanLineBytes = (m_pBmpAcc->GetBitCount()*m_pBmpAcc->Width() + 7) / 8; - m_aLayout.ScanLineStride = m_pBmpAcc->GetScanlineSize(); - m_aLayout.PlaneStride = 0; + case ScanlineFormat::N1BitMsbPal: + m_bPalette = true; + m_nBitsPerInputPixel = 1; + m_nEndianness = util::Endianness::LITTLE; // doesn't matter + m_aLayout.IsMsbFirst = true; + break; - switch( m_pBmpAcc->GetScanlineFormat() ) - { - case ScanlineFormat::N1BitMsbPal: - m_bPalette = true; - m_nBitsPerInputPixel = 1; - m_nEndianness = util::Endianness::LITTLE; // doesn't matter - m_aLayout.IsMsbFirst = true; - break; - - case ScanlineFormat::N1BitLsbPal: - m_bPalette = true; - m_nBitsPerInputPixel = 1; - m_nEndianness = util::Endianness::LITTLE; // doesn't matter - m_aLayout.IsMsbFirst = false; - break; - - case ScanlineFormat::N4BitMsnPal: - m_bPalette = true; - m_nBitsPerInputPixel = 4; - m_nEndianness = util::Endianness::LITTLE; // doesn't matter - m_aLayout.IsMsbFirst = true; - break; - - case ScanlineFormat::N4BitLsnPal: - m_bPalette = true; - m_nBitsPerInputPixel = 4; - m_nEndianness = util::Endianness::LITTLE; // doesn't matter - m_aLayout.IsMsbFirst = false; - break; - - case ScanlineFormat::N8BitPal: - m_bPalette = true; - m_nBitsPerInputPixel = 8; - m_nEndianness = util::Endianness::LITTLE; // doesn't matter - m_aLayout.IsMsbFirst = false; // doesn't matter - break; - - case ScanlineFormat::N8BitTcMask: - m_bPalette = false; - m_nBitsPerInputPixel = 8; - m_nEndianness = util::Endianness::LITTLE; // doesn't matter - m_aLayout.IsMsbFirst = false; // doesn't matter - setComponentInfo( m_pBmpAcc->GetColorMask().GetRedMask(), - m_pBmpAcc->GetColorMask().GetGreenMask(), - m_pBmpAcc->GetColorMask().GetBlueMask() ); - break; - - case ScanlineFormat::N24BitTcBgr: - m_bPalette = false; - m_nBitsPerInputPixel = 24; - m_nEndianness = util::Endianness::LITTLE; - m_aLayout.IsMsbFirst = false; // doesn't matter - setComponentInfo( static_cast<sal_uInt32>(0xff0000UL), - static_cast<sal_uInt32>(0x00ff00UL), - static_cast<sal_uInt32>(0x0000ffUL) ); - break; - - case ScanlineFormat::N24BitTcRgb: - m_bPalette = false; - m_nBitsPerInputPixel = 24; - m_nEndianness = util::Endianness::LITTLE; - m_aLayout.IsMsbFirst = false; // doesn't matter - setComponentInfo( static_cast<sal_uInt32>(0x0000ffUL), - static_cast<sal_uInt32>(0x00ff00UL), - static_cast<sal_uInt32>(0xff0000UL) ); - break; - - case ScanlineFormat::N32BitTcAbgr: - { - m_bPalette = false; - m_nBitsPerInputPixel = 32; - m_nEndianness = util::Endianness::LITTLE; - m_aLayout.IsMsbFirst = false; // doesn't matter - - m_aComponentTags.realloc(4); - sal_Int8* pTags = m_aComponentTags.getArray(); - pTags[0] = rendering::ColorComponentTag::ALPHA; - pTags[1] = rendering::ColorComponentTag::RGB_BLUE; - pTags[2] = rendering::ColorComponentTag::RGB_GREEN; - pTags[3] = rendering::ColorComponentTag::RGB_RED; - - m_aComponentBitCounts.realloc(4); - sal_Int32* pCounts = m_aComponentBitCounts.getArray(); - pCounts[0] = 8; - pCounts[1] = 8; - pCounts[2] = 8; - pCounts[3] = 8; - - m_nRedIndex = 3; - m_nGreenIndex = 2; - m_nBlueIndex = 1; - m_nAlphaIndex = 0; - } + case ScanlineFormat::N1BitLsbPal: + m_bPalette = true; + m_nBitsPerInputPixel = 1; + m_nEndianness = util::Endianness::LITTLE; // doesn't matter + m_aLayout.IsMsbFirst = false; break; - case ScanlineFormat::N32BitTcArgb: - { - m_bPalette = false; - m_nBitsPerInputPixel = 32; - m_nEndianness = util::Endianness::LITTLE; - m_aLayout.IsMsbFirst = false; // doesn't matter - - m_aComponentTags.realloc(4); - sal_Int8* pTags = m_aComponentTags.getArray(); - pTags[0] = rendering::ColorComponentTag::ALPHA; - pTags[1] = rendering::ColorComponentTag::RGB_RED; - pTags[2] = rendering::ColorComponentTag::RGB_GREEN; - pTags[3] = rendering::ColorComponentTag::RGB_BLUE; - - m_aComponentBitCounts.realloc(4); - sal_Int32* pCounts = m_aComponentBitCounts.getArray(); - pCounts[0] = 8; - pCounts[1] = 8; - pCounts[2] = 8; - pCounts[3] = 8; - - m_nRedIndex = 1; - m_nGreenIndex = 2; - m_nBlueIndex = 3; - m_nAlphaIndex = 0; - } + case ScanlineFormat::N4BitMsnPal: + m_bPalette = true; + m_nBitsPerInputPixel = 4; + m_nEndianness = util::Endianness::LITTLE; // doesn't matter + m_aLayout.IsMsbFirst = true; break; - case ScanlineFormat::N32BitTcBgra: - { - m_bPalette = false; - m_nBitsPerInputPixel = 32; - m_nEndianness = util::Endianness::LITTLE; - m_aLayout.IsMsbFirst = false; // doesn't matter - - m_aComponentTags.realloc(4); - sal_Int8* pTags = m_aComponentTags.getArray(); - pTags[0] = rendering::ColorComponentTag::RGB_BLUE; - pTags[1] = rendering::ColorComponentTag::RGB_GREEN; - pTags[2] = rendering::ColorComponentTag::RGB_RED; - pTags[3] = rendering::ColorComponentTag::ALPHA; - - m_aComponentBitCounts.realloc(4); - sal_Int32* pCounts = m_aComponentBitCounts.getArray(); - pCounts[0] = 8; - pCounts[1] = 8; - pCounts[2] = 8; - pCounts[3] = 8; - - m_nRedIndex = 2; - m_nGreenIndex = 1; - m_nBlueIndex = 0; - m_nAlphaIndex = 3; - } + case ScanlineFormat::N4BitLsnPal: + m_bPalette = true; + m_nBitsPerInputPixel = 4; + m_nEndianness = util::Endianness::LITTLE; // doesn't matter + m_aLayout.IsMsbFirst = false; break; - case ScanlineFormat::N32BitTcRgba: - { - m_bPalette = false; - m_nBitsPerInputPixel = 32; - m_nEndianness = util::Endianness::LITTLE; - m_aLayout.IsMsbFirst = false; // doesn't matter - - m_aComponentTags.realloc(4); - sal_Int8* pTags = m_aComponentTags.getArray(); - pTags[0] = rendering::ColorComponentTag::RGB_RED; - pTags[1] = rendering::ColorComponentTag::RGB_GREEN; - pTags[2] = rendering::ColorComponentTag::RGB_BLUE; - pTags[3] = rendering::ColorComponentTag::ALPHA; - - m_aComponentBitCounts.realloc(4); - sal_Int32* pCounts = m_aComponentBitCounts.getArray(); - pCounts[0] = 8; - pCounts[1] = 8; - pCounts[2] = 8; - pCounts[3] = 8; - - m_nRedIndex = 0; - m_nGreenIndex = 1; - m_nBlueIndex = 2; - m_nAlphaIndex = 3; - } + case ScanlineFormat::N8BitPal: + m_bPalette = true; + m_nBitsPerInputPixel = 8; + m_nEndianness = util::Endianness::LITTLE; // doesn't matter + m_aLayout.IsMsbFirst = false; // doesn't matter break; - case ScanlineFormat::N32BitTcMask: - m_bPalette = false; - m_nBitsPerInputPixel = 32; - m_nEndianness = util::Endianness::LITTLE; - m_aLayout.IsMsbFirst = false; // doesn't matter - setComponentInfo( m_pBmpAcc->GetColorMask().GetRedMask(), - m_pBmpAcc->GetColorMask().GetGreenMask(), - m_pBmpAcc->GetColorMask().GetBlueMask() ); - break; - - default: - OSL_FAIL( "unsupported bitmap format" ); - break; - } + case ScanlineFormat::N8BitTcMask: + m_bPalette = false; + m_nBitsPerInputPixel = 8; + m_nEndianness = util::Endianness::LITTLE; // doesn't matter + m_aLayout.IsMsbFirst = false; // doesn't matter + setComponentInfo( m_pBmpAcc->GetColorMask().GetRedMask(), + m_pBmpAcc->GetColorMask().GetGreenMask(), + m_pBmpAcc->GetColorMask().GetBlueMask() ); + break; - if( m_bPalette ) - { - m_aComponentTags.realloc(1); - m_aComponentTags[0] = rendering::ColorComponentTag::INDEX; + case ScanlineFormat::N24BitTcBgr: + m_bPalette = false; + m_nBitsPerInputPixel = 24; + m_nEndianness = util::Endianness::LITTLE; + m_aLayout.IsMsbFirst = false; // doesn't matter + setComponentInfo( static_cast<sal_uInt32>(0xff0000UL), + static_cast<sal_uInt32>(0x00ff00UL), + static_cast<sal_uInt32>(0x0000ffUL) ); + break; - m_aComponentBitCounts.realloc(1); - m_aComponentBitCounts[0] = m_nBitsPerInputPixel; + case ScanlineFormat::N24BitTcRgb: + m_bPalette = false; + m_nBitsPerInputPixel = 24; + m_nEndianness = util::Endianness::LITTLE; + m_aLayout.IsMsbFirst = false; // doesn't matter + setComponentInfo( static_cast<sal_uInt32>(0x0000ffUL), + static_cast<sal_uInt32>(0x00ff00UL), + static_cast<sal_uInt32>(0xff0000UL) ); + break; - m_nIndexIndex = 0; + case ScanlineFormat::N32BitTcAbgr: + { + m_bPalette = false; + m_nBitsPerInputPixel = 32; + m_nEndianness = util::Endianness::LITTLE; + m_aLayout.IsMsbFirst = false; // doesn't matter + + m_aComponentTags.realloc(4); + sal_Int8* pTags = m_aComponentTags.getArray(); + pTags[0] = rendering::ColorComponentTag::ALPHA; + pTags[1] = rendering::ColorComponentTag::RGB_BLUE; + pTags[2] = rendering::ColorComponentTag::RGB_GREEN; + pTags[3] = rendering::ColorComponentTag::RGB_RED; + + m_aComponentBitCounts.realloc(4); + sal_Int32* pCounts = m_aComponentBitCounts.getArray(); + pCounts[0] = 8; + pCounts[1] = 8; + pCounts[2] = 8; + pCounts[3] = 8; + + m_nRedIndex = 3; + m_nGreenIndex = 2; + m_nBlueIndex = 1; + m_nAlphaIndex = 0; } + break; - m_nBitsPerOutputPixel = m_nBitsPerInputPixel; - if( m_aBmpEx.IsTransparent() ) + case ScanlineFormat::N32BitTcArgb: { - // TODO(P1): need to interleave alpha with bitmap data - - // won't fuss with less-than-8 bit for now - m_nBitsPerOutputPixel = std::max(sal_Int32(8),m_nBitsPerInputPixel); - - // check whether alpha goes in front or behind the - // bitcount sequence. If pixel format is little endian, - // put it behind all the other channels. If it's big - // endian, put it in front (because later, the actual data - // always gets written after the pixel data) - - // TODO(Q1): slight catch - in the case of the - // BMP_FORMAT_32BIT_XX_ARGB formats, duplicate alpha - // channels might happen! - m_aComponentTags.realloc(m_aComponentTags.getLength()+1); - m_aComponentTags[m_aComponentTags.getLength()-1] = rendering::ColorComponentTag::ALPHA; - - m_aComponentBitCounts.realloc(m_aComponentBitCounts.getLength()+1); - m_aComponentBitCounts[m_aComponentBitCounts.getLength()-1] = m_aBmpEx.IsAlpha() ? 8 : 1; - - if( m_nEndianness == util::Endianness::BIG ) - { - // put alpha in front of all the color channels - sal_Int8* pTags =m_aComponentTags.getArray(); - sal_Int32* pCounts=m_aComponentBitCounts.getArray(); - std::rotate(pTags, - pTags+m_aComponentTags.getLength()-1, - pTags+m_aComponentTags.getLength()); - std::rotate(pCounts, - pCounts+m_aComponentBitCounts.getLength()-1, - pCounts+m_aComponentBitCounts.getLength()); - ++m_nRedIndex; - ++m_nGreenIndex; - ++m_nBlueIndex; - ++m_nIndexIndex; - m_nAlphaIndex=0; - } + m_bPalette = false; + m_nBitsPerInputPixel = 32; + m_nEndianness = util::Endianness::LITTLE; + m_aLayout.IsMsbFirst = false; // doesn't matter + + m_aComponentTags.realloc(4); + sal_Int8* pTags = m_aComponentTags.getArray(); + pTags[0] = rendering::ColorComponentTag::ALPHA; + pTags[1] = rendering::ColorComponentTag::RGB_RED; + pTags[2] = rendering::ColorComponentTag::RGB_GREEN; + pTags[3] = rendering::ColorComponentTag::RGB_BLUE; + + m_aComponentBitCounts.realloc(4); + sal_Int32* pCounts = m_aComponentBitCounts.getArray(); + pCounts[0] = 8; + pCounts[1] = 8; + pCounts[2] = 8; + pCounts[3] = 8; + + m_nRedIndex = 1; + m_nGreenIndex = 2; + m_nBlueIndex = 3; + m_nAlphaIndex = 0; + } + break; - // always add a full byte to the pixel size, otherwise - // pixel packing hell breaks loose. - m_nBitsPerOutputPixel += 8; + case ScanlineFormat::N32BitTcBgra: + { + m_bPalette = false; + m_nBitsPerInputPixel = 32; + m_nEndianness = util::Endianness::LITTLE; + m_aLayout.IsMsbFirst = false; // doesn't matter + + m_aComponentTags.realloc(4); + sal_Int8* pTags = m_aComponentTags.getArray(); + pTags[0] = rendering::ColorComponentTag::RGB_BLUE; + pTags[1] = rendering::ColorComponentTag::RGB_GREEN; + pTags[2] = rendering::ColorComponentTag::RGB_RED; + pTags[3] = rendering::ColorComponentTag::ALPHA; + + m_aComponentBitCounts.realloc(4); + sal_Int32* pCounts = m_aComponentBitCounts.getArray(); + pCounts[0] = 8; + pCounts[1] = 8; + pCounts[2] = 8; + pCounts[3] = 8; + + m_nRedIndex = 2; + m_nGreenIndex = 1; + m_nBlueIndex = 0; + m_nAlphaIndex = 3; + } + break; - // adapt scanline parameters - const Size aSize = m_aBitmap.GetSizePixel(); - m_aLayout.ScanLineBytes = - m_aLayout.ScanLineStride = (aSize.Width()*m_nBitsPerOutputPixel + 7)/8; + case ScanlineFormat::N32BitTcRgba: + { + m_bPalette = false; + m_nBitsPerInputPixel = 32; + m_nEndianness = util::Endianness::LITTLE; + m_aLayout.IsMsbFirst = false; // doesn't matter + + m_aComponentTags.realloc(4); + sal_Int8* pTags = m_aComponentTags.getArray(); + pTags[0] = rendering::ColorComponentTag::RGB_RED; + pTags[1] = rendering::ColorComponentTag::RGB_GREEN; + pTags[2] = rendering::ColorComponentTag::RGB_BLUE; + pTags[3] = rendering::ColorComponentTag::ALPHA; + + m_aComponentBitCounts.realloc(4); + sal_Int32* pCounts = m_aComponentBitCounts.getArray(); + pCounts[0] = 8; + pCounts[1] = 8; + pCounts[2] = 8; + pCounts[3] = 8; + + m_nRedIndex = 0; + m_nGreenIndex = 1; + m_nBlueIndex = 2; + m_nAlphaIndex = 3; } + break; + + case ScanlineFormat::N32BitTcMask: + m_bPalette = false; + m_nBitsPerInputPixel = 32; + m_nEndianness = util::Endianness::LITTLE; + m_aLayout.IsMsbFirst = false; // doesn't matter + setComponentInfo( m_pBmpAcc->GetColorMask().GetRedMask(), + m_pBmpAcc->GetColorMask().GetGreenMask(), + m_pBmpAcc->GetColorMask().GetBlueMask() ); + break; + + default: + OSL_FAIL( "unsupported bitmap format" ); + break; + } + + if( m_bPalette ) + { + m_aComponentTags.realloc(1); + m_aComponentTags[0] = rendering::ColorComponentTag::INDEX; + + m_aComponentBitCounts.realloc(1); + m_aComponentBitCounts[0] = m_nBitsPerInputPixel; + + m_nIndexIndex = 0; } + + m_nBitsPerOutputPixel = m_nBitsPerInputPixel; + if( !m_aBmpEx.IsTransparent() ) + return; + + // TODO(P1): need to interleave alpha with bitmap data - + // won't fuss with less-than-8 bit for now + m_nBitsPerOutputPixel = std::max(sal_Int32(8),m_nBitsPerInputPixel); + + // check whether alpha goes in front or behind the + // bitcount sequence. If pixel format is little endian, + // put it behind all the other channels. If it's big + // endian, put it in front (because later, the actual data + // always gets written after the pixel data) + + // TODO(Q1): slight catch - in the case of the + // BMP_FORMAT_32BIT_XX_ARGB formats, duplicate alpha + // channels might happen! + m_aComponentTags.realloc(m_aComponentTags.getLength()+1); + m_aComponentTags[m_aComponentTags.getLength()-1] = rendering::ColorComponentTag::ALPHA; + + m_aComponentBitCounts.realloc(m_aComponentBitCounts.getLength()+1); + m_aComponentBitCounts[m_aComponentBitCounts.getLength()-1] = m_aBmpEx.IsAlpha() ? 8 : 1; + + if( m_nEndianness == util::Endianness::BIG ) + { + // put alpha in front of all the color channels + sal_Int8* pTags =m_aComponentTags.getArray(); + sal_Int32* pCounts=m_aComponentBitCounts.getArray(); + std::rotate(pTags, + pTags+m_aComponentTags.getLength()-1, + pTags+m_aComponentTags.getLength()); + std::rotate(pCounts, + pCounts+m_aComponentBitCounts.getLength()-1, + pCounts+m_aComponentBitCounts.getLength()); + ++m_nRedIndex; + ++m_nGreenIndex; + ++m_nBlueIndex; + ++m_nIndexIndex; + m_nAlphaIndex=0; + } + + // always add a full byte to the pixel size, otherwise + // pixel packing hell breaks loose. + m_nBitsPerOutputPixel += 8; + + // adapt scanline parameters + const Size aSize = m_aBitmap.GetSizePixel(); + m_aLayout.ScanLineBytes = + m_aLayout.ScanLineStride = (aSize.Width()*m_nBitsPerOutputPixel + 7)/8; } VclCanvasBitmap::~VclCanvasBitmap() diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index 6aeb53af17a4..64a470fe5f63 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -845,22 +845,22 @@ void OpenGLZone::hardDisable() { // protect ourselves from double calling etc. static bool bDisabled = false; - if (!bDisabled) - { - bDisabled = true; - - // Disable the OpenGL support - std::shared_ptr<comphelper::ConfigurationChanges> xChanges( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::VCL::UseOpenGL::set(false, xChanges); - xChanges->commit(); - - // Force synchronous config write - css::uno::Reference< css::util::XFlushable >( - css::configuration::theDefaultProvider::get( - comphelper::getProcessComponentContext()), - css::uno::UNO_QUERY_THROW)->flush(); - } + if (bDisabled) + return; + + bDisabled = true; + + // Disable the OpenGL support + std::shared_ptr<comphelper::ConfigurationChanges> xChanges( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::VCL::UseOpenGL::set(false, xChanges); + xChanges->commit(); + + // Force synchronous config write + css::uno::Reference< css::util::XFlushable >( + css::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext()), + css::uno::UNO_QUERY_THROW)->flush(); } void OpenGLZone::relaxWatchdogTimings() diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 508b7df307d3..58a096a79045 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -644,60 +644,60 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r aOutPt.AdjustY( -(aOutSz.Height() - 1) ); } - if (!aDstRect.Intersection(tools::Rectangle(aOutPt, aOutSz)).IsEmpty()) - { - static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA"); - bool bTryDirectPaint(!pDisableNative && !bHMirr && !bVMirr); + if (aDstRect.Intersection(tools::Rectangle(aOutPt, aOutSz)).IsEmpty()) + return; - if (bTryDirectPaint) - { - Point aRelPt = aOutPt + Point(mnOutOffX, mnOutOffY); - SalTwoRect aTR( - rSrcPtPixel.X(), rSrcPtPixel.Y(), - rSrcSizePixel.Width(), rSrcSizePixel.Height(), - aRelPt.X(), aRelPt.Y(), - aOutSz.Width(), aOutSz.Height()); + static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA"); + bool bTryDirectPaint(!pDisableNative && !bHMirr && !bVMirr); - SalBitmap* pSalSrcBmp = rBmp.ImplGetSalBitmap().get(); - SalBitmap* pSalAlphaBmp = rAlpha.ImplGetSalBitmap().get(); + if (bTryDirectPaint) + { + Point aRelPt = aOutPt + Point(mnOutOffX, mnOutOffY); + SalTwoRect aTR( + rSrcPtPixel.X(), rSrcPtPixel.Y(), + rSrcSizePixel.Width(), rSrcSizePixel.Height(), + aRelPt.X(), aRelPt.Y(), + aOutSz.Width(), aOutSz.Height()); - // #i83087# Naturally, system alpha blending (SalGraphics::DrawAlphaBitmap) cannot work - // with separate alpha VDev + SalBitmap* pSalSrcBmp = rBmp.ImplGetSalBitmap().get(); + SalBitmap* pSalAlphaBmp = rAlpha.ImplGetSalBitmap().get(); - // try to blend the alpha bitmap with the alpha virtual device - if (mpAlphaVDev) + // #i83087# Naturally, system alpha blending (SalGraphics::DrawAlphaBitmap) cannot work + // with separate alpha VDev + + // try to blend the alpha bitmap with the alpha virtual device + if (mpAlphaVDev) + { + Bitmap aAlphaBitmap( mpAlphaVDev->GetBitmap( aRelPt, aOutSz ) ); + if (SalBitmap* pSalAlphaBmp2 = aAlphaBitmap.ImplGetSalBitmap().get()) { - Bitmap aAlphaBitmap( mpAlphaVDev->GetBitmap( aRelPt, aOutSz ) ); - if (SalBitmap* pSalAlphaBmp2 = aAlphaBitmap.ImplGetSalBitmap().get()) + if (mpGraphics->BlendAlphaBitmap(aTR, *pSalSrcBmp, *pSalAlphaBmp, *pSalAlphaBmp2, this)) { - if (mpGraphics->BlendAlphaBitmap(aTR, *pSalSrcBmp, *pSalAlphaBmp, *pSalAlphaBmp2, this)) - { - mpAlphaVDev->BlendBitmap(aTR, rAlpha); - return; - } - } - } - else - { - if (mpGraphics->DrawAlphaBitmap(aTR, *pSalSrcBmp, *pSalAlphaBmp, this)) + mpAlphaVDev->BlendBitmap(aTR, rAlpha); return; + } } } + else + { + if (mpGraphics->DrawAlphaBitmap(aTR, *pSalSrcBmp, *pSalAlphaBmp, this)) + return; + } + } - // we need to make sure OpenGL never reaches this slow code path + // we need to make sure OpenGL never reaches this slow code path - assert(!SkiaHelper::isVCLSkiaEnabled()); + assert(!SkiaHelper::isVCLSkiaEnabled()); #if HAVE_FEATURE_OPENGL - assert(!OpenGLHelper::isVCLOpenGLEnabled()); + assert(!OpenGLHelper::isVCLOpenGLEnabled()); #endif - tools::Rectangle aBmpRect(Point(), rBmp.GetSizePixel()); - if (!aBmpRect.Intersection(tools::Rectangle(rSrcPtPixel, rSrcSizePixel)).IsEmpty()) - { - Point auxOutPt(LogicToPixel(rDestPt)); - Size auxOutSz(LogicToPixel(rDestSize)); + tools::Rectangle aBmpRect(Point(), rBmp.GetSizePixel()); + if (!aBmpRect.Intersection(tools::Rectangle(rSrcPtPixel, rSrcSizePixel)).IsEmpty()) + { + Point auxOutPt(LogicToPixel(rDestPt)); + Size auxOutSz(LogicToPixel(rDestSize)); - DrawDeviceAlphaBitmapSlowPath(rBmp, rAlpha, aDstRect, aBmpRect, auxOutSz, auxOutPt); - } + DrawDeviceAlphaBitmapSlowPath(rBmp, rAlpha, aDstRect, aBmpRect, auxOutSz, auxOutPt); } } @@ -1350,88 +1350,88 @@ void OutputDevice::DrawTransformedBitmapEx( return; } - if(!aVisibleRange.isEmpty()) - { - BitmapEx aTransformed(rBitmapEx); + if(aVisibleRange.isEmpty()) + return; - // #122923# when the result needs an alpha channel due to being rotated or sheared - // and thus uncovering areas, add these channels so that the own transformer (used - // in getTransformed) also creates a transformed alpha channel - if(!aTransformed.IsTransparent() && (bSheared || bRotated)) - { - // parts will be uncovered, extend aTransformed with a mask bitmap - const Bitmap aContent(aTransformed.GetBitmap()); + BitmapEx aTransformed(rBitmapEx); - AlphaMask aMaskBmp(aContent.GetSizePixel()); - aMaskBmp.Erase(0); + // #122923# when the result needs an alpha channel due to being rotated or sheared + // and thus uncovering areas, add these channels so that the own transformer (used + // in getTransformed) also creates a transformed alpha channel + if(!aTransformed.IsTransparent() && (bSheared || bRotated)) + { + // parts will be uncovered, extend aTransformed with a mask bitmap + const Bitmap aContent(aTransformed.GetBitmap()); - aTransformed = BitmapEx(aContent, aMaskBmp); - } + AlphaMask aMaskBmp(aContent.GetSizePixel()); + aMaskBmp.Erase(0); - // Remove scaling from aFulltransform: we transform due to shearing or rotation, scaling - // will happen according to aDestSize. - basegfx::B2DVector aFullScale, aFullTranslate; - double fFullRotate, fFullShearX; - aFullTransform.decompose(aFullScale, aFullTranslate, fFullRotate, fFullShearX); - // Require positive scaling, negative scaling would loose horizontal or vertical flip. - if (aFullScale.getX() > 0 && aFullScale.getY() > 0) - { - basegfx::B2DHomMatrix aTransform = basegfx::utils::createScaleB2DHomMatrix( - rOriginalSizePixel.getWidth() / aFullScale.getX(), - rOriginalSizePixel.getHeight() / aFullScale.getY()); - aFullTransform *= aTransform; - } + aTransformed = BitmapEx(aContent, aMaskBmp); + } - double fSourceRatio = 1.0; - if (rOriginalSizePixel.getHeight() != 0) - { - fSourceRatio = rOriginalSizePixel.getWidth() / rOriginalSizePixel.getHeight(); - } - double fTargetRatio = 1.0; - if (aFullScale.getY() != 0) - { - fTargetRatio = aFullScale.getX() / aFullScale.getY(); - } - bool bAspectRatioKept = rtl::math::approxEqual(fSourceRatio, fTargetRatio); - if (bSheared || !bAspectRatioKept) - { - // Not only rotation, or scaling does not keep aspect ratio. - aTransformed = aTransformed.getTransformed( - aFullTransform, - aVisibleRange, - fMaximumArea); - } - else + // Remove scaling from aFulltransform: we transform due to shearing or rotation, scaling + // will happen according to aDestSize. + basegfx::B2DVector aFullScale, aFullTranslate; + double fFullRotate, fFullShearX; + aFullTransform.decompose(aFullScale, aFullTranslate, fFullRotate, fFullShearX); + // Require positive scaling, negative scaling would loose horizontal or vertical flip. + if (aFullScale.getX() > 0 && aFullScale.getY() > 0) + { + basegfx::B2DHomMatrix aTransform = basegfx::utils::createScaleB2DHomMatrix( + rOriginalSizePixel.getWidth() / aFullScale.getX(), + rOriginalSizePixel.getHeight() / aFullScale.getY()); + aFullTransform *= aTransform; + } + + double fSourceRatio = 1.0; + if (rOriginalSizePixel.getHeight() != 0) + { + fSourceRatio = rOriginalSizePixel.getWidth() / rOriginalSizePixel.getHeight(); + } + double fTargetRatio = 1.0; + if (aFullScale.getY() != 0) + { + fTargetRatio = aFullScale.getX() / aFullScale.getY(); + } + bool bAspectRatioKept = rtl::math::approxEqual(fSourceRatio, fTargetRatio); + if (bSheared || !bAspectRatioKept) + { + // Not only rotation, or scaling does not keep aspect ratio. + aTransformed = aTransformed.getTransformed( + aFullTransform, + aVisibleRange, + fMaximumArea); + } + else + { + // Just rotation, can do that directly. + fFullRotate = fmod(fFullRotate * -1, F_2PI); + if (fFullRotate < 0) { - // Just rotation, can do that directly. - fFullRotate = fmod(fFullRotate * -1, F_2PI); - if (fFullRotate < 0) - { - fFullRotate += F_2PI; - } - long nAngle10 = basegfx::fround(basegfx::rad2deg(fFullRotate) * 10); - aTransformed.Rotate(nAngle10, COL_TRANSPARENT); + fFullRotate += F_2PI; } - basegfx::B2DRange aTargetRange(0.0, 0.0, 1.0, 1.0); + long nAngle10 = basegfx::fround(basegfx::rad2deg(fFullRotate) * 10); + aTransformed.Rotate(nAngle10, COL_TRANSPARENT); + } + basegfx::B2DRange aTargetRange(0.0, 0.0, 1.0, 1.0); - // get logic object target range - aTargetRange.transform(rTransformation); + // get logic object target range + aTargetRange.transform(rTransformation); - // get from unified/relative VisibleRange to logoc one - aVisibleRange.transform( - basegfx::utils::createScaleTranslateB2DHomMatrix( - aTargetRange.getRange(), - aTargetRange.getMinimum())); + // get from unified/relative VisibleRange to logoc one + aVisibleRange.transform( + basegfx::utils::createScaleTranslateB2DHomMatrix( + aTargetRange.getRange(), + aTargetRange.getMinimum())); - // extract point and size; do not remove size, the bitmap may have been prepared reduced by purpose - // #i124580# the correct DestSize needs to be calculated based on MaxXY values - const Point aDestPt(basegfx::fround(aVisibleRange.getMinX()), basegfx::fround(aVisibleRange.getMinY())); - const Size aDestSize( - basegfx::fround(aVisibleRange.getMaxX()) - aDestPt.X(), - basegfx::fround(aVisibleRange.getMaxY()) - aDestPt.Y()); + // extract point and size; do not remove size, the bitmap may have been prepared reduced by purpose + // #i124580# the correct DestSize needs to be calculated based on MaxXY values + const Point aDestPt(basegfx::fround(aVisibleRange.getMinX()), basegfx::fround(aVisibleRange.getMinY())); + const Size aDestSize( + basegfx::fround(aVisibleRange.getMaxX()) - aDestPt.X(), + basegfx::fround(aVisibleRange.getMaxY()) - aDestPt.Y()); - DrawBitmapEx(aDestPt, aDestSize, aTransformed); - } + DrawBitmapEx(aDestPt, aDestSize, aTransformed); } void OutputDevice::DrawShadowBitmapEx( diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index b7d8bfeeba7c..e5b8a9fbc1bf 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -525,18 +525,18 @@ void OutputDevice::ImplClearAllFontData(bool bNewFontLists) // clear global font lists to have them updated pSVData->maGDIData.mxScreenFontCache->Invalidate(); - if ( bNewFontLists ) + if ( !bNewFontLists ) + return; + + pSVData->maGDIData.mxScreenFontList->Clear(); + vcl::Window * pFrame = pSVData->maFrameData.mpFirstFrame; + if ( pFrame ) { - pSVData->maGDIData.mxScreenFontList->Clear(); - vcl::Window * pFrame = pSVData->maFrameData.mpFirstFrame; - if ( pFrame ) + if ( pFrame->AcquireGraphics() ) { - if ( pFrame->AcquireGraphics() ) - { - OutputDevice *pDevice = pFrame; - pDevice->mpGraphics->ClearDevFontCache(); - pDevice->mpGraphics->GetDevFontList(pFrame->mpWindowImpl->mpFrameData->mxFontCollection.get()); - } + OutputDevice *pDevice = pFrame; + pDevice->mpGraphics->ClearDevFontCache(); + pDevice->mpGraphics->GetDevFontList(pFrame->mpWindowImpl->mpFrameData->mxFontCollection.get()); } } } @@ -908,23 +908,23 @@ vcl::Font OutputDevice::GetDefaultFont( DefaultFontType nType, LanguageType eLan void OutputDevice::ImplInitFontList() const { + if( mxFontCollection->Count() ) + return; + + if( !(mpGraphics || AcquireGraphics()) ) + return; + + SAL_INFO( "vcl.gdi", "OutputDevice::ImplInitFontList()" ); + mpGraphics->GetDevFontList(mxFontCollection.get()); + + // There is absolutely no way there should be no fonts available on the device if( !mxFontCollection->Count() ) { - if( mpGraphics || AcquireGraphics() ) - { - SAL_INFO( "vcl.gdi", "OutputDevice::ImplInitFontList()" ); - mpGraphics->GetDevFontList(mxFontCollection.get()); - - // There is absolutely no way there should be no fonts available on the device - if( !mxFontCollection->Count() ) - { - OUString aError( "Application error: no fonts and no vcl resource found on your system" ); - OUString aResStr(VclResId(SV_ACCESSERROR_NO_FONTS)); - if (!aResStr.isEmpty()) - aError = aResStr; - Application::Abort(aError); - } - } + OUString aError( "Application error: no fonts and no vcl resource found on your system" ); + OUString aResStr(VclResId(SV_ACCESSERROR_NO_FONTS)); + if (!aResStr.isEmpty()) + aError = aResStr; + Application::Abort(aError); } } diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx index 2e8406714daf..8919c474ba65 100644 --- a/vcl/source/outdev/gradient.cxx +++ b/vcl/source/outdev/gradient.cxx @@ -176,70 +176,70 @@ void OutputDevice::DrawGradientToMetafile ( const tools::PolyPolygon& rPolyPoly, if ( !mpMetaFile ) return; - if ( rPolyPoly.Count() && rPolyPoly[ 0 ].GetSize() ) + if ( !(rPolyPoly.Count() && rPolyPoly[ 0 ].GetSize()) ) + return; + + Gradient aGradient( rGradient ); + + if ( mnDrawMode & DrawModeFlags::GrayGradient ) { - Gradient aGradient( rGradient ); + SetGrayscaleColors( aGradient ); + } - if ( mnDrawMode & DrawModeFlags::GrayGradient ) - { - SetGrayscaleColors( aGradient ); - } + const tools::Rectangle aBoundRect( rPolyPoly.GetBoundRect() ); - const tools::Rectangle aBoundRect( rPolyPoly.GetBoundRect() ); + if ( rPolyPoly.IsRect() ) + { + mpMetaFile->AddAction( new MetaGradientAction( aBoundRect, aGradient ) ); + } + else + { + mpMetaFile->AddAction( new MetaCommentAction( "XGRAD_SEQ_BEGIN" ) ); + mpMetaFile->AddAction( new MetaGradientExAction( rPolyPoly, rGradient ) ); - if ( rPolyPoly.IsRect() ) - { - mpMetaFile->AddAction( new MetaGradientAction( aBoundRect, aGradient ) ); - } - else - { - mpMetaFile->AddAction( new MetaCommentAction( "XGRAD_SEQ_BEGIN" ) ); - mpMetaFile->AddAction( new MetaGradientExAction( rPolyPoly, rGradient ) ); + ClipAndDrawGradientMetafile ( rGradient, rPolyPoly ); - ClipAndDrawGradientMetafile ( rGradient, rPolyPoly ); + mpMetaFile->AddAction( new MetaCommentAction( "XGRAD_SEQ_END" ) ); + } - mpMetaFile->AddAction( new MetaCommentAction( "XGRAD_SEQ_END" ) ); - } + if( !IsDeviceOutputNecessary() || ImplIsRecordLayout() ) + return; - if( !IsDeviceOutputNecessary() || ImplIsRecordLayout() ) - return; + // Clip and then draw the gradient + if( tools::Rectangle( PixelToLogic( Point() ), GetOutputSize() ).IsEmpty() ) + return; - // Clip and then draw the gradient - if( !tools::Rectangle( PixelToLogic( Point() ), GetOutputSize() ).IsEmpty() ) - { - // convert rectangle to pixels - tools::Rectangle aRect( ImplLogicToDevicePixel( aBoundRect ) ); - aRect.Justify(); + // convert rectangle to pixels + tools::Rectangle aRect( ImplLogicToDevicePixel( aBoundRect ) ); + aRect.Justify(); - // do nothing if the rectangle is empty - if ( !aRect.IsEmpty() ) - { - if( !mbOutputClipped ) - { - // calculate step count if necessary - if ( !aGradient.GetSteps() ) - aGradient.SetSteps( GRADIENT_DEFAULT_STEPCOUNT ); + // do nothing if the rectangle is empty + if ( aRect.IsEmpty() ) + return; - if ( rPolyPoly.IsRect() ) - { - // because we draw with no border line, we have to expand gradient - // rect to avoid missing lines on the right and bottom edge - aRect.AdjustLeft( -1 ); - aRect.AdjustTop( -1 ); - aRect.AdjustRight( 1 ); - aRect.AdjustBottom( 1 ); - } + if( mbOutputClipped ) + return; - // if the clipping polypolygon is a rectangle, then it's the same size as the bounding of the - // polypolygon, so pass in a NULL for the clipping parameter - if( aGradient.GetStyle() == GradientStyle::Linear || rGradient.GetStyle() == GradientStyle::Axial ) - DrawLinearGradientToMetafile( aRect, aGradient ); - else - DrawComplexGradientToMetafile( aRect, aGradient ); - } - } - } + // calculate step count if necessary + if ( !aGradient.GetSteps() ) + aGradient.SetSteps( GRADIENT_DEFAULT_STEPCOUNT ); + + if ( rPolyPoly.IsRect() ) + { + // because we draw with no border line, we have to expand gradient + // rect to avoid missing lines on the right and bottom edge + aRect.AdjustLeft( -1 ); + aRect.AdjustTop( -1 ); + aRect.AdjustRight( 1 ); + aRect.AdjustBottom( 1 ); } + + // if the clipping polypolygon is a rectangle, then it's the same size as the bounding of the + // polypolygon, so pass in a NULL for the clipping parameter + if( aGradient.GetStyle() == GradientStyle::Linear || rGradient.GetStyle() == GradientStyle::Axial ) + DrawLinearGradientToMetafile( aRect, aGradient ); + else + DrawComplexGradientToMetafile( aRect, aGradient ); } namespace @@ -592,26 +592,26 @@ void OutputDevice::DrawComplexGradient( const tools::Rectangle& rRect, } // we should draw last inner Polygon if we output PolyPolygon - if( xPolyPoly ) - { - const tools::Polygon& rPoly = xPolyPoly->GetObject( 1 ); + if( !xPolyPoly ) + return; - if( !rPoly.GetBoundRect().IsEmpty() ) - { - // #107349# Paint last polygon with end color only if loop - // has generated output. Otherwise, the current - // (i.e. start) color is taken, to generate _any_ output. - if( bPaintLastPolygon ) - { - nRed = GetGradientColorValue( nEndRed ); - nGreen = GetGradientColorValue( nEndGreen ); - nBlue = GetGradientColorValue( nEndBlue ); - } + const tools::Polygon& rPoly = xPolyPoly->GetObject( 1 ); - mpGraphics->SetFillColor( Color( nRed, nGreen, nBlue ) ); - ImplDrawPolygon( rPoly, pClixPolyPoly ); - } + if( rPoly.GetBoundRect().IsEmpty() ) + return; + + // #107349# Paint last polygon with end color only if loop + // has generated output. Otherwise, the current + // (i.e. start) color is taken, to generate _any_ output. + if( bPaintLastPolygon ) + { + nRed = GetGradientColorValue( nEndRed ); + nGreen = GetGradientColorValue( nEndGreen ); + nBlue = GetGradientColorValue( nEndBlue ); } + + mpGraphics->SetFillColor( Color( nRed, nGreen, nBlue ) ); + ImplDrawPolygon( rPoly, pClixPolyPoly ); } void OutputDevice::DrawLinearGradientToMetafile( const tools::Rectangle& rRect, @@ -916,21 +916,21 @@ void OutputDevice::DrawComplexGradientToMetafile( const tools::Rectangle& rRect, const tools::Polygon& rPoly = xPolyPoly->GetObject( 1 ); - if( !rPoly.GetBoundRect().IsEmpty() ) - { - // #107349# Paint last polygon with end color only if loop - // has generated output. Otherwise, the current - // (i.e. start) color is taken, to generate _any_ output. - if( bPaintLastPolygon ) - { - nRed = GetGradientColorValue( nEndRed ); - nGreen = GetGradientColorValue( nEndGreen ); - nBlue = GetGradientColorValue( nEndBlue ); - } + if( rPoly.GetBoundRect().IsEmpty() ) + return; - mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); - mpMetaFile->AddAction( new MetaPolygonAction( rPoly ) ); + // #107349# Paint last polygon with end color only if loop + // has generated output. Otherwise, the current + // (i.e. start) color is taken, to generate _any_ output. + if( bPaintLastPolygon ) + { + nRed = GetGradientColorValue( nEndRed ); + nGreen = GetGradientColorValue( nEndGreen ); + nBlue = GetGradientColorValue( nEndBlue ); } + + mpMetaFile->AddAction( new MetaFillColorAction( Color( nRed, nGreen, nBlue ), true ) ); + mpMetaFile->AddAction( new MetaPolygonAction( rPoly ) ); } long OutputDevice::GetGradientStepCount( long nMinRect ) diff --git a/vcl/source/outdev/hatch.cxx b/vcl/source/outdev/hatch.cxx index c5cba12778e7..5f9396394a27 100644 --- a/vcl/source/outdev/hatch.cxx +++ b/vcl/source/outdev/hatch.cxx @@ -141,39 +141,52 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& { assert(!is_double_buffered_window()); - if(rPolyPoly.Count()) - { - // #i115630# DrawHatch does not work with beziers included in the polypolygon, take care of that - bool bIsCurve(false); + if(!rPolyPoly.Count()) + return; - for(sal_uInt16 a(0); !bIsCurve && a < rPolyPoly.Count(); a++) + // #i115630# DrawHatch does not work with beziers included in the polypolygon, take care of that + bool bIsCurve(false); + + for(sal_uInt16 a(0); !bIsCurve && a < rPolyPoly.Count(); a++) + { + if(rPolyPoly[a].HasFlags()) { - if(rPolyPoly[a].HasFlags()) - { - bIsCurve = true; - } + bIsCurve = true; } + } - if(bIsCurve) - { - OSL_ENSURE(false, "DrawHatch does *not* support curves, falling back to AdaptiveSubdivide()..."); - tools::PolyPolygon aPolyPoly; + if(bIsCurve) + { + OSL_ENSURE(false, "DrawHatch does *not* support curves, falling back to AdaptiveSubdivide()..."); + tools::PolyPolygon aPolyPoly; - rPolyPoly.AdaptiveSubdivide(aPolyPoly); - DrawHatch(aPolyPoly, rHatch, bMtf); + rPolyPoly.AdaptiveSubdivide(aPolyPoly); + DrawHatch(aPolyPoly, rHatch, bMtf); + } + else + { + tools::Rectangle aRect( rPolyPoly.GetBoundRect() ); + const long nLogPixelWidth = ImplDevicePixelToLogicWidth( 1 ); + const long nWidth = ImplDevicePixelToLogicWidth( std::max( ImplLogicWidthToDevicePixel( rHatch.GetDistance() ), 3L ) ); + std::unique_ptr<Point[]> pPtBuffer(new Point[ HATCH_MAXPOINTS ]); + Point aPt1, aPt2, aEndPt1; + Size aInc; + + // Single hatch + aRect.AdjustLeft( -nLogPixelWidth ); aRect.AdjustTop( -nLogPixelWidth ); aRect.AdjustRight(nLogPixelWidth ); aRect.AdjustBottom(nLogPixelWidth ); + CalcHatchValues( aRect, nWidth, rHatch.GetAngle(), aPt1, aPt2, aInc, aEndPt1 ); + do + { + DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); + aPt1.AdjustX(aInc.Width() ); aPt1.AdjustY(aInc.Height() ); + aPt2.AdjustX(aInc.Width() ); aPt2.AdjustY(aInc.Height() ); } - else + while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); + + if( ( rHatch.GetStyle() == HatchStyle::Double ) || ( rHatch.GetStyle() == HatchStyle::Triple ) ) { - tools::Rectangle aRect( rPolyPoly.GetBoundRect() ); - const long nLogPixelWidth = ImplDevicePixelToLogicWidth( 1 ); - const long nWidth = ImplDevicePixelToLogicWidth( std::max( ImplLogicWidthToDevicePixel( rHatch.GetDistance() ), 3L ) ); - std::unique_ptr<Point[]> pPtBuffer(new Point[ HATCH_MAXPOINTS ]); - Point aPt1, aPt2, aEndPt1; - Size aInc; - - // Single hatch - aRect.AdjustLeft( -nLogPixelWidth ); aRect.AdjustTop( -nLogPixelWidth ); aRect.AdjustRight(nLogPixelWidth ); aRect.AdjustBottom(nLogPixelWidth ); - CalcHatchValues( aRect, nWidth, rHatch.GetAngle(), aPt1, aPt2, aInc, aEndPt1 ); + // Double hatch + CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 900, aPt1, aPt2, aInc, aEndPt1 ); do { DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); @@ -182,10 +195,10 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& } while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); - if( ( rHatch.GetStyle() == HatchStyle::Double ) || ( rHatch.GetStyle() == HatchStyle::Triple ) ) + if( rHatch.GetStyle() == HatchStyle::Triple ) { - // Double hatch - CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 900, aPt1, aPt2, aInc, aEndPt1 ); + // Triple hatch + CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 450, aPt1, aPt2, aInc, aEndPt1 ); do { DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); @@ -193,19 +206,6 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& aPt2.AdjustX(aInc.Width() ); aPt2.AdjustY(aInc.Height() ); } while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); - - if( rHatch.GetStyle() == HatchStyle::Triple ) - { - // Triple hatch - CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 450, aPt1, aPt2, aInc, aEndPt1 ); - do - { - DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); - aPt1.AdjustX(aInc.Width() ); aPt1.AdjustY(aInc.Height() ); - aPt2.AdjustX(aInc.Width() ); aPt2.AdjustY(aInc.Height() ); - } - while( ( aPt1.X() <= aEndPt1.X() ) && ( aPt1.Y() <= aEndPt1.Y() ) ); - } } } } @@ -380,23 +380,23 @@ void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPol } } - if( nPCounter > 1 ) - { - qsort( pPtBuffer, nPCounter, sizeof( Point ), HatchCmpFnc ); + if( nPCounter <= 1 ) + return; - if( nPCounter & 1 ) - nPCounter--; + qsort( pPtBuffer, nPCounter, sizeof( Point ), HatchCmpFnc ); - if( bMtf ) - { - for( long i = 0; i < nPCounter; i += 2 ) - mpMetaFile->AddAction( new MetaLineAction( pPtBuffer[ i ], pPtBuffer[ i + 1 ] ) ); - } - else - { - for( long i = 0; i < nPCounter; i += 2 ) - DrawHatchLine_DrawLine(pPtBuffer[i], pPtBuffer[i+1]); - } + if( nPCounter & 1 ) + nPCounter--; + + if( bMtf ) + { + for( long i = 0; i < nPCounter; i += 2 ) + mpMetaFile->AddAction( new MetaLineAction( pPtBuffer[ i ], pPtBuffer[ i + 1 ] ) ); + } + else + { + for( long i = 0; i < nPCounter; i += 2 ) + DrawHatchLine_DrawLine(pPtBuffer[i], pPtBuffer[i+1]); } } diff --git a/vcl/source/outdev/mask.cxx b/vcl/source/outdev/mask.cxx index 209389cfbb56..90b3cbc1b0e5 100644 --- a/vcl/source/outdev/mask.cxx +++ b/vcl/source/outdev/mask.cxx @@ -134,21 +134,21 @@ void OutputDevice::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor, } // TODO: Use mask here - if( mpAlphaVDev ) - { - const Bitmap& rAlphaMask( rMask.CreateMask( rMaskColor ) ); - - // #i25167# Restrict mask painting to _opaque_ areas - // of the mask, otherwise we spoil areas where no - // bitmap content was ever visible. Interestingly - // enough, this can be achieved by taking the mask as - // the transparency mask of itself - mpAlphaVDev->DrawBitmapEx( rDestPt, - rDestSize, - rSrcPtPixel, - rSrcSizePixel, - BitmapEx( rAlphaMask, rMask ) ); - } + if( !mpAlphaVDev ) + return; + + const Bitmap& rAlphaMask( rMask.CreateMask( rMaskColor ) ); + + // #i25167# Restrict mask painting to _opaque_ areas + // of the mask, otherwise we spoil areas where no + // bitmap content was ever visible. Interestingly + // enough, this can be achieved by taking the mask as + // the transparency mask of itself + mpAlphaVDev->DrawBitmapEx( rDestPt, + rDestSize, + rSrcPtPixel, + rSrcSizePixel, + BitmapEx( rAlphaMask, rMask ) ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx index a9ca52d9449b..804ba883c210 100644 --- a/vcl/source/outdev/outdevstate.cxx +++ b/vcl/source/outdev/outdevstate.cxx @@ -516,37 +516,37 @@ void OutputDevice::SetFont( const vcl::Font& rNewFont ) mpMetaFile->AddAction( new MetaTextFillColorAction( aFont.GetFillColor(), !aFont.IsTransparent() ) ); } - if ( !maFont.IsSameInstance( aFont ) ) + if ( maFont.IsSameInstance( aFont ) ) + return; + + // Optimization MT/HDU: COL_TRANSPARENT means SetFont should ignore the font color, + // because SetTextColor() is used for this. + // #i28759# maTextColor might have been changed behind our back, commit then, too. + if( aFont.GetColor() != COL_TRANSPARENT + && (aFont.GetColor() != maFont.GetColor() || aFont.GetColor() != maTextColor ) ) { - // Optimization MT/HDU: COL_TRANSPARENT means SetFont should ignore the font color, - // because SetTextColor() is used for this. - // #i28759# maTextColor might have been changed behind our back, commit then, too. - if( aFont.GetColor() != COL_TRANSPARENT - && (aFont.GetColor() != maFont.GetColor() || aFont.GetColor() != maTextColor ) ) - { - maTextColor = aFont.GetColor(); - mbInitTextColor = true; - if( mpMetaFile ) - mpMetaFile->AddAction( new MetaTextColorAction( aFont.GetColor() ) ); - } - maFont = aFont; - mbNewFont = true; + maTextColor = aFont.GetColor(); + mbInitTextColor = true; + if( mpMetaFile ) + mpMetaFile->AddAction( new MetaTextColorAction( aFont.GetColor() ) ); + } + maFont = aFont; + mbNewFont = true; - if( mpAlphaVDev ) - { - // #i30463# - // Since SetFont might change the text color, apply that only - // selectively to alpha vdev (which normally paints opaque text - // with COL_BLACK) - if( aFont.GetColor() != COL_TRANSPARENT ) - { - mpAlphaVDev->SetTextColor( COL_BLACK ); - aFont.SetColor( COL_TRANSPARENT ); - } + if( !mpAlphaVDev ) + return; - mpAlphaVDev->SetFont( aFont ); - } + // #i30463# + // Since SetFont might change the text color, apply that only + // selectively to alpha vdev (which normally paints opaque text + // with COL_BLACK) + if( aFont.GetColor() != COL_TRANSPARENT ) + { + mpAlphaVDev->SetTextColor( COL_BLACK ); + aFont.SetColor( COL_TRANSPARENT ); } + + mpAlphaVDev->SetFont( aFont ); } diff --git a/vcl/source/outdev/rect.cxx b/vcl/source/outdev/rect.cxx index 2d8fe4524155..a9bc729c002b 100644 --- a/vcl/source/outdev/rect.cxx +++ b/vcl/source/outdev/rect.cxx @@ -394,40 +394,40 @@ BmpMirrorFlags AdjustTwoRect( SalTwoRect& rTwoRect, const Size& rSizePix ) void AdjustTwoRect( SalTwoRect& rTwoRect, const tools::Rectangle& rValidSrcRect ) { - if( ( rTwoRect.mnSrcX < rValidSrcRect.Left() ) || ( rTwoRect.mnSrcX >= rValidSrcRect.Right() ) || + if( !(( rTwoRect.mnSrcX < rValidSrcRect.Left() ) || ( rTwoRect.mnSrcX >= rValidSrcRect.Right() ) || ( rTwoRect.mnSrcY < rValidSrcRect.Top() ) || ( rTwoRect.mnSrcY >= rValidSrcRect.Bottom() ) || ( ( rTwoRect.mnSrcX + rTwoRect.mnSrcWidth ) > rValidSrcRect.Right() ) || - ( ( rTwoRect.mnSrcY + rTwoRect.mnSrcHeight ) > rValidSrcRect.Bottom() ) ) - { - const tools::Rectangle aSourceRect( Point( rTwoRect.mnSrcX, rTwoRect.mnSrcY ), - Size( rTwoRect.mnSrcWidth, rTwoRect.mnSrcHeight ) ); - tools::Rectangle aCropRect( aSourceRect ); + ( ( rTwoRect.mnSrcY + rTwoRect.mnSrcHeight ) > rValidSrcRect.Bottom() )) ) + return; - aCropRect.Intersection( rValidSrcRect ); + const tools::Rectangle aSourceRect( Point( rTwoRect.mnSrcX, rTwoRect.mnSrcY ), + Size( rTwoRect.mnSrcWidth, rTwoRect.mnSrcHeight ) ); + tools::Rectangle aCropRect( aSourceRect ); - if( aCropRect.IsEmpty() ) - { - rTwoRect.mnSrcWidth = rTwoRect.mnSrcHeight = rTwoRect.mnDestWidth = rTwoRect.mnDestHeight = 0; - } - else - { - const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? static_cast<double>( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; - const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? static_cast<double>( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; + aCropRect.Intersection( rValidSrcRect ); - const long nDstX1 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Left() - rTwoRect.mnSrcX ) ); - const long nDstY1 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Top() - rTwoRect.mnSrcY ) ); - const long nDstX2 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Right() - rTwoRect.mnSrcX ) ); - const long nDstY2 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Bottom() - rTwoRect.mnSrcY ) ); - - rTwoRect.mnSrcX = aCropRect.Left(); - rTwoRect.mnSrcY = aCropRect.Top(); - rTwoRect.mnSrcWidth = aCropRect.GetWidth(); - rTwoRect.mnSrcHeight = aCropRect.GetHeight(); - rTwoRect.mnDestX = nDstX1; - rTwoRect.mnDestY = nDstY1; - rTwoRect.mnDestWidth = nDstX2 - nDstX1 + 1; - rTwoRect.mnDestHeight = nDstY2 - nDstY1 + 1; - } + if( aCropRect.IsEmpty() ) + { + rTwoRect.mnSrcWidth = rTwoRect.mnSrcHeight = rTwoRect.mnDestWidth = rTwoRect.mnDestHeight = 0; + } + else + { + const double fFactorX = ( rTwoRect.mnSrcWidth > 1 ) ? static_cast<double>( rTwoRect.mnDestWidth - 1 ) / ( rTwoRect.mnSrcWidth - 1 ) : 0.0; + const double fFactorY = ( rTwoRect.mnSrcHeight > 1 ) ? static_cast<double>( rTwoRect.mnDestHeight - 1 ) / ( rTwoRect.mnSrcHeight - 1 ) : 0.0; + + const long nDstX1 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Left() - rTwoRect.mnSrcX ) ); + const long nDstY1 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Top() - rTwoRect.mnSrcY ) ); + const long nDstX2 = rTwoRect.mnDestX + FRound( fFactorX * ( aCropRect.Right() - rTwoRect.mnSrcX ) ); + const long nDstY2 = rTwoRect.mnDestY + FRound( fFactorY * ( aCropRect.Bottom() - rTwoRect.mnSrcY ) ); + + rTwoRect.mnSrcX = aCropRect.Left(); + rTwoRect.mnSrcY = aCropRect.Top(); + rTwoRect.mnSrcWidth = aCropRect.GetWidth(); + rTwoRect.mnSrcHeight = aCropRect.GetHeight(); + rTwoRect.mnDestX = nDstX1; + rTwoRect.mnDestY = nDstY1; + rTwoRect.mnDestWidth = nDstX2 - nDstX1 + 1; + rTwoRect.mnDestHeight = nDstY2 - nDstY1 + 1; } } diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index 6ade6113fc99..26866aaaeedb 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -330,176 +330,176 @@ void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY, break; } - if ( nLineHeight ) + if ( !nLineHeight ) + return; + + if ( mbLineColor || mbInitLineColor ) { - if ( mbLineColor || mbInitLineColor ) - { - mpGraphics->SetLineColor(); - mbInitLineColor = true; - } - mpGraphics->SetFillColor( aColor ); - mbInitFillColor = true; + mpGraphics->SetLineColor(); + mbInitLineColor = true; + } + mpGraphics->SetFillColor( aColor ); + mbInitFillColor = true; - long nLeft = nDistX; + long nLeft = nDistX; - switch ( eTextLine ) + switch ( eTextLine ) + { + case LINESTYLE_SINGLE: + case LINESTYLE_BOLD: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + break; + case LINESTYLE_DOUBLE: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); + break; + case LINESTYLE_DOTTED: + case LINESTYLE_BOLDDOTTED: { - case LINESTYLE_SINGLE: - case LINESTYLE_BOLD: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - break; - case LINESTYLE_DOUBLE: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); - break; - case LINESTYLE_DOTTED: - case LINESTYLE_BOLDDOTTED: - { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; - long nTempWidth = nDotWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempWidth > nEnd ) - nTempWidth = nEnd-nLeft; + long nTempWidth = nDotWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) + { + if ( nLeft+nTempWidth > nEnd ) + nTempWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); - nLeft += nDotWidth*2; - } + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); + nLeft += nDotWidth*2; } - break; - case LINESTYLE_DASH: - case LINESTYLE_LONGDASH: - case LINESTYLE_BOLDDASH: - case LINESTYLE_BOLDLONGDASH: + } + break; + case LINESTYLE_DASH: + case LINESTYLE_LONGDASH: + case LINESTYLE_BOLDDASH: + case LINESTYLE_BOLDLONGDASH: + { + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; + + long nMinDashWidth; + long nMinSpaceWidth; + long nSpaceWidth; + long nDashWidth; + if ( (eTextLine == LINESTYLE_LONGDASH) || + (eTextLine == LINESTYLE_BOLDLONGDASH) ) { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; - - long nMinDashWidth; - long nMinSpaceWidth; - long nSpaceWidth; - long nDashWidth; - if ( (eTextLine == LINESTYLE_LONGDASH) || - (eTextLine == LINESTYLE_BOLDLONGDASH) ) - { - nMinDashWidth = nDotWidth*6; - nMinSpaceWidth = nDotWidth*2; - nDashWidth = 200; - nSpaceWidth = 100; - } - else - { - nMinDashWidth = nDotWidth*4; - nMinSpaceWidth = (nDotWidth*150)/100; - nDashWidth = 100; - nSpaceWidth = 50; - } - nDashWidth = ((nDashWidth*mnDPIX)+1270)/2540; - nSpaceWidth = ((nSpaceWidth*mnDPIX)+1270)/2540; - // DashWidth will be increased if the line is getting too thick - // in proportion to the line's length - if ( nDashWidth < nMinDashWidth ) - nDashWidth = nMinDashWidth; - if ( nSpaceWidth < nMinSpaceWidth ) - nSpaceWidth = nMinSpaceWidth; - - long nTempWidth = nDashWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempWidth > nEnd ) - nTempWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); - nLeft += nDashWidth+nSpaceWidth; - } + nMinDashWidth = nDotWidth*6; + nMinSpaceWidth = nDotWidth*2; + nDashWidth = 200; + nSpaceWidth = 100; } - break; - case LINESTYLE_DASHDOT: - case LINESTYLE_BOLDDASHDOT: + else { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; - - long nDashWidth = ((100*mnDPIX)+1270)/2540; - long nMinDashWidth = nDotWidth*4; - // DashWidth will be increased if the line is getting too thick - // in proportion to the line's length - if ( nDashWidth < nMinDashWidth ) - nDashWidth = nMinDashWidth; - - long nTempDotWidth = nDotWidth; - long nTempDashWidth = nDashWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempDotWidth > nEnd ) - nTempDotWidth = nEnd-nLeft; + nMinDashWidth = nDotWidth*4; + nMinSpaceWidth = (nDotWidth*150)/100; + nDashWidth = 100; + nSpaceWidth = 50; + } + nDashWidth = ((nDashWidth*mnDPIX)+1270)/2540; + nSpaceWidth = ((nSpaceWidth*mnDPIX)+1270)/2540; + // DashWidth will be increased if the line is getting too thick + // in proportion to the line's length + if ( nDashWidth < nMinDashWidth ) + nDashWidth = nMinDashWidth; + if ( nSpaceWidth < nMinSpaceWidth ) + nSpaceWidth = nMinSpaceWidth; + + long nTempWidth = nDashWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) + { + if ( nLeft+nTempWidth > nEnd ) + nTempWidth = nEnd-nLeft; + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempWidth, nLineHeight ); + nLeft += nDashWidth+nSpaceWidth; + } + } + break; + case LINESTYLE_DASHDOT: + case LINESTYLE_BOLDDASHDOT: + { + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; + + long nDashWidth = ((100*mnDPIX)+1270)/2540; + long nMinDashWidth = nDotWidth*4; + // DashWidth will be increased if the line is getting too thick + // in proportion to the line's length + if ( nDashWidth < nMinDashWidth ) + nDashWidth = nMinDashWidth; + + long nTempDotWidth = nDotWidth; + long nTempDashWidth = nDashWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) + { + if ( nLeft+nTempDotWidth > nEnd ) + nTempDotWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); - nLeft += nDotWidth*2; - if ( nLeft > nEnd ) - break; + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); + nLeft += nDotWidth*2; + if ( nLeft > nEnd ) + break; - if ( nLeft+nTempDashWidth > nEnd ) - nTempDashWidth = nEnd-nLeft; + if ( nLeft+nTempDashWidth > nEnd ) + nTempDashWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); - nLeft += nDashWidth+nDotWidth; - } + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); + nLeft += nDashWidth+nDotWidth; } - break; - case LINESTYLE_DASHDOTDOT: - case LINESTYLE_BOLDDASHDOTDOT: + } + break; + case LINESTYLE_DASHDOTDOT: + case LINESTYLE_BOLDDASHDOTDOT: + { + long nDotWidth = nLineHeight*mnDPIY; + nDotWidth += mnDPIY/2; + nDotWidth /= mnDPIY; + + long nDashWidth = ((100*mnDPIX)+1270)/2540; + long nMinDashWidth = nDotWidth*4; + // DashWidth will be increased if the line is getting too thick + // in proportion to the line's length + if ( nDashWidth < nMinDashWidth ) + nDashWidth = nMinDashWidth; + + long nTempDotWidth = nDotWidth; + long nTempDashWidth = nDashWidth; + long nEnd = nLeft+nWidth; + while ( nLeft < nEnd ) { - long nDotWidth = nLineHeight*mnDPIY; - nDotWidth += mnDPIY/2; - nDotWidth /= mnDPIY; - - long nDashWidth = ((100*mnDPIX)+1270)/2540; - long nMinDashWidth = nDotWidth*4; - // DashWidth will be increased if the line is getting too thick - // in proportion to the line's length - if ( nDashWidth < nMinDashWidth ) - nDashWidth = nMinDashWidth; - - long nTempDotWidth = nDotWidth; - long nTempDashWidth = nDashWidth; - long nEnd = nLeft+nWidth; - while ( nLeft < nEnd ) - { - if ( nLeft+nTempDotWidth > nEnd ) - nTempDotWidth = nEnd-nLeft; + if ( nLeft+nTempDotWidth > nEnd ) + nTempDotWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); - nLeft += nDotWidth*2; - if ( nLeft > nEnd ) - break; + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); + nLeft += nDotWidth*2; + if ( nLeft > nEnd ) + break; - if ( nLeft+nTempDotWidth > nEnd ) - nTempDotWidth = nEnd-nLeft; + if ( nLeft+nTempDotWidth > nEnd ) + nTempDotWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); - nLeft += nDotWidth*2; - if ( nLeft > nEnd ) - break; + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDotWidth, nLineHeight ); + nLeft += nDotWidth*2; + if ( nLeft > nEnd ) + break; - if ( nLeft+nTempDashWidth > nEnd ) - nTempDashWidth = nEnd-nLeft; + if ( nLeft+nTempDashWidth > nEnd ) + nTempDashWidth = nEnd-nLeft; - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); - nLeft += nDashWidth+nDotWidth; - } + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nTempDashWidth, nLineHeight ); + nLeft += nDashWidth+nDotWidth; } - break; - default: - break; } + break; + default: + break; } } @@ -537,31 +537,31 @@ void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, break; } - if ( nLineHeight ) + if ( !nLineHeight ) + return; + + if ( mbLineColor || mbInitLineColor ) { - if ( mbLineColor || mbInitLineColor ) - { - mpGraphics->SetLineColor(); - mbInitLineColor = true; - } - mpGraphics->SetFillColor( aColor ); - mbInitFillColor = true; + mpGraphics->SetLineColor(); + mbInitLineColor = true; + } + mpGraphics->SetFillColor( aColor ); + mbInitFillColor = true; - const long& nLeft = nDistX; + const long& nLeft = nDistX; - switch ( eStrikeout ) - { - case STRIKEOUT_SINGLE: - case STRIKEOUT_BOLD: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - break; - case STRIKEOUT_DOUBLE: - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); - ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); - break; - default: - break; - } + switch ( eStrikeout ) + { + case STRIKEOUT_SINGLE: + case STRIKEOUT_BOLD: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + break; + case STRIKEOUT_DOUBLE: + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos, nWidth, nLineHeight ); + ImplDrawTextRect( nBaseX, nBaseY, nLeft, nLinePos2, nWidth, nLineHeight ); + break; + default: + break; } } diff --git a/vcl/source/toolkit/group.cxx b/vcl/source/toolkit/group.cxx index ef7b28794e48..a1178eca2b32 100644 --- a/vcl/source/toolkit/group.cxx +++ b/vcl/source/toolkit/group.cxx @@ -57,29 +57,29 @@ void GroupBox::ImplInitSettings( bool bBackground ) { Control::ImplInitSettings(); - if ( bBackground ) + if ( !bBackground ) + return; + + vcl::Window* pParent = GetParent(); + if ( (pParent->IsChildTransparentModeEnabled() || + !(pParent->GetStyle() & WB_CLIPCHILDREN) ) && + !IsControlBackground() ) { - vcl::Window* pParent = GetParent(); - if ( (pParent->IsChildTransparentModeEnabled() || - !(pParent->GetStyle() & WB_CLIPCHILDREN) ) && - !IsControlBackground() ) - { - EnableChildTransparentMode(); - SetParentClipMode( ParentClipMode::NoClip ); - SetPaintTransparent( true ); - SetBackground(); - } - else - { - EnableChildTransparentMode( false ); - SetParentClipMode(); - SetPaintTransparent( false ); + EnableChildTransparentMode(); + SetParentClipMode( ParentClipMode::NoClip ); + SetPaintTransparent( true ); + SetBackground(); + } + else + { + EnableChildTransparentMode( false ); + SetParentClipMode(); + SetPaintTransparent( false ); - if ( IsControlBackground() ) - SetBackground( GetControlBackground() ); - else - SetBackground( pParent->GetBackground() ); - } + if ( IsControlBackground() ) + SetBackground( GetControlBackground() ); + else + SetBackground( pParent->GetBackground() ); } } diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx index ce9cfeff5679..068a2d46250a 100644 --- a/vcl/source/treelist/svimpbox.cxx +++ b/vcl/source/treelist/svimpbox.cxx @@ -514,22 +514,22 @@ void SvImpLBox::InvalidateEntriesFrom( long nY ) const void SvImpLBox::InvalidateEntry( long nY ) const { - if( !(m_nFlags & LBoxFlags::InPaint )) - { - tools::Rectangle aRect( GetVisibleArea() ); - long nMaxBottom = aRect.Bottom(); - aRect.SetTop( nY ); - aRect.SetBottom( nY ); aRect.AdjustBottom(m_pView->GetEntryHeight() ); - if( aRect.Top() > nMaxBottom ) - return; - if( aRect.Bottom() > nMaxBottom ) - aRect.SetBottom( nMaxBottom ); - if (m_pView->SupportsDoubleBuffering()) - // Perform full paint when flicker is to be avoided explicitly. - m_pView->Invalidate(); - else - m_pView->Invalidate(aRect); - } + if( m_nFlags & LBoxFlags::InPaint ) + return; + + tools::Rectangle aRect( GetVisibleArea() ); + long nMaxBottom = aRect.Bottom(); + aRect.SetTop( nY ); + aRect.SetBottom( nY ); aRect.AdjustBottom(m_pView->GetEntryHeight() ); + if( aRect.Top() > nMaxBottom ) + return; + if( aRect.Bottom() > nMaxBottom ) + aRect.SetBottom( nMaxBottom ); + if (m_pView->SupportsDoubleBuffering()) + // Perform full paint when flicker is to be avoided explicitly. + m_pView->Invalidate(); + else + m_pView->Invalidate(aRect); } void SvImpLBox::InvalidateEntry( SvTreeListEntry* pEntry ) @@ -2089,33 +2089,33 @@ void SvImpLBox::ExpandAll() void SvImpLBox::CollapseTo(SvTreeListEntry* pParentToCollapse) { // collapse all parents until we get to the given parent to collapse - if (pParentToCollapse) + if (!pParentToCollapse) + return; + + sal_uInt16 nRefDepth; + // special case explorer: if the root only has a single + // entry, don't collapse the root entry + if (m_pTree->GetChildList(nullptr).size() < 2) { - sal_uInt16 nRefDepth; - // special case explorer: if the root only has a single - // entry, don't collapse the root entry - if (m_pTree->GetChildList(nullptr).size() < 2) + nRefDepth = 1; + pParentToCollapse = m_pCursor; + while (m_pTree->GetParent(pParentToCollapse) + && m_pTree->GetDepth(m_pTree->GetParent(pParentToCollapse)) > 0) { - nRefDepth = 1; - pParentToCollapse = m_pCursor; - while (m_pTree->GetParent(pParentToCollapse) - && m_pTree->GetDepth(m_pTree->GetParent(pParentToCollapse)) > 0) - { - pParentToCollapse = m_pTree->GetParent(pParentToCollapse); - } + pParentToCollapse = m_pTree->GetParent(pParentToCollapse); } - else - nRefDepth = m_pTree->GetDepth(pParentToCollapse); + } + else + nRefDepth = m_pTree->GetDepth(pParentToCollapse); - if (m_pView->IsExpanded(pParentToCollapse)) - m_pView->Collapse(pParentToCollapse); - SvTreeListEntry* pCur = m_pTree->Next(pParentToCollapse); - while (pCur && m_pTree->GetDepth(pCur) > nRefDepth) - { - if (pCur->HasChildren() && m_pView->IsExpanded(pCur)) - m_pView->Collapse(pCur); - pCur = m_pTree->Next(pCur); - } + if (m_pView->IsExpanded(pParentToCollapse)) + m_pView->Collapse(pParentToCollapse); + SvTreeListEntry* pCur = m_pTree->Next(pParentToCollapse); + while (pCur && m_pTree->GetDepth(pCur) > nRefDepth) + { + if (pCur->HasChildren() && m_pView->IsExpanded(pCur)) + m_pView->Collapse(pCur); + pCur = m_pTree->Next(pCur); } } diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index f86f23ccfcc0..97f8e698ba0c 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -1769,21 +1769,21 @@ public: virtual void MouseButtonDown(const MouseEvent& rMEvt) override { mrRenderer.SetSizePixel(GetSizePixel()); - if (!mrRenderer.MouseButtonDown(rMEvt)) - { - if (testThreads) - { // render this window asynchronously in a new thread - sal_uInt32 nDelaySecs = 0; - if (rMEvt.GetButtons() & MOUSE_RIGHT) - nDelaySecs = 5; - mxThread = new RenderThread(*this, nDelaySecs); - } - else - { // spawn another window - VclPtrInstance<DemoWin> pNewWin(mrRenderer, testThreads); - pNewWin->SetText("Another interactive VCL demo window"); - pNewWin->Show(); - } + if (mrRenderer.MouseButtonDown(rMEvt)) + return; + + if (testThreads) + { // render this window asynchronously in a new thread + sal_uInt32 nDelaySecs = 0; + if (rMEvt.GetButtons() & MOUSE_RIGHT) + nDelaySecs = 5; + mxThread = new RenderThread(*this, nDelaySecs); + } + else + { // spawn another window + VclPtrInstance<DemoWin> pNewWin(mrRenderer, testThreads); + pNewWin->SetText("Another interactive VCL demo window"); + pNewWin->Show(); } } virtual void KeyInput(const KeyEvent& rKEvt) override |