diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-06 12:58:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-06 14:20:20 +0200 |
commit | 8f719de217b1079bd985b3bc63bbfa97069483bc (patch) | |
tree | cb15a422b7df468d913cb0815d628f7c0bc4fd9b /svx/source | |
parent | bfc298d02ca6275588d5897d97ced9498a3e91aa (diff) |
loplugin:flatten in svx
Change-Id: I31f33a5f693d5fdb8282181c5bd7f31971efe784
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100236
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source')
64 files changed, 4534 insertions, 4511 deletions
diff --git a/svx/source/core/extedit.cxx b/svx/source/core/extedit.cxx index b6e1387aba50..3225e47f02bb 100644 --- a/svx/source/core/extedit.cxx +++ b/svx/source/core/extedit.cxx @@ -184,21 +184,21 @@ void SdrExternalToolEdit::Update(Graphic & rGraphic) { assert(m_pObj && m_pView); // timer should be deleted by Notify() too SdrPageView *const pPageView = m_pView->GetSdrPageView(); - if (pPageView) - { - SdrGrafObj *const pNewObj(static_cast<SdrGrafObj*>(m_pObj->CloneSdrObject(m_pObj->getSdrModelFromSdrObject()))); - assert(pNewObj); - OUString const description = - m_pView->GetDescriptionOfMarkedObjects() + " External Edit"; - m_pView->BegUndo(description); - pNewObj->SetGraphicObject(rGraphic); - // set to new object before ReplaceObjectAtView() so that Notify() will - // not delete the running timer and crash - SdrObject *const pOldObj = m_pObj; - m_pObj = pNewObj; - m_pView->ReplaceObjectAtView(pOldObj, *pPageView, pNewObj); - m_pView->EndUndo(); - } + if (!pPageView) + return; + + SdrGrafObj *const pNewObj(static_cast<SdrGrafObj*>(m_pObj->CloneSdrObject(m_pObj->getSdrModelFromSdrObject()))); + assert(pNewObj); + OUString const description = + m_pView->GetDescriptionOfMarkedObjects() + " External Edit"; + m_pView->BegUndo(description); + pNewObj->SetGraphicObject(rGraphic); + // set to new object before ReplaceObjectAtView() so that Notify() will + // not delete the running timer and crash + SdrObject *const pOldObj = m_pObj; + m_pObj = pNewObj; + m_pView->ReplaceObjectAtView(pOldObj, *pPageView, pNewObj); + m_pView->EndUndo(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index 123179c1100a..1e42bc0b720b 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -801,24 +801,24 @@ EnhancedCustomShape2d::EnhancedCustomShape2d(SdrObjCustomShape& rSdrObjCustomSha sal_Int32 nLength = seqEquations.getLength(); - if ( nLength ) + if ( !nLength ) + return; + + vNodesSharedPtr.resize( nLength ); + vEquationResults.resize( nLength ); + for ( sal_Int32 i = 0; i < nLength; i++ ) { - vNodesSharedPtr.resize( nLength ); - vEquationResults.resize( nLength ); - for ( sal_Int32 i = 0; i < nLength; i++ ) + vEquationResults[ i ].bReady = false; + try { - vEquationResults[ i ].bReady = false; - try - { - vNodesSharedPtr[ i ] = EnhancedCustomShape::FunctionParser::parseFunction( seqEquations[ i ], *this ); - } - catch ( EnhancedCustomShape::ParseError& ) - { - SAL_INFO( - "svx", - "error: equation number: " << i << ", parser failed (" - << seqEquations[i] << ")"); - } + vNodesSharedPtr[ i ] = EnhancedCustomShape::FunctionParser::parseFunction( seqEquations[ i ], *this ); + } + catch ( EnhancedCustomShape::ParseError& ) + { + SAL_INFO( + "svx", + "error: equation number: " << i << ", parser failed (" + << seqEquations[i] << ")"); } } } @@ -2556,89 +2556,89 @@ void EnhancedCustomShape2d::CreateSubPath( aNewB2DPolyPolygon.append(aNewB2DPolygon); } - if(aNewB2DPolyPolygon.count()) + if(!aNewB2DPolyPolygon.count()) + return; + + // #i37011# + bool bForceCreateTwoObjects(false); + + if(!bSortFilledObjectsToBack && !aNewB2DPolyPolygon.isClosed() && !bNoStroke) + { + bForceCreateTwoObjects = true; + } + + if(bLineGeometryNeededOnly) { - // #i37011# - bool bForceCreateTwoObjects(false); + bForceCreateTwoObjects = true; + bNoFill = true; + bNoStroke = false; + } - if(!bSortFilledObjectsToBack && !aNewB2DPolyPolygon.isClosed() && !bNoStroke) - { - bForceCreateTwoObjects = true; + if(bForceCreateTwoObjects || bSortFilledObjectsToBack) + { + if(bFilled && !bNoFill) + { + basegfx::B2DPolyPolygon aClosedPolyPolygon(aNewB2DPolyPolygon); + aClosedPolyPolygon.setClosed(true); + SdrPathObj* pFill = new SdrPathObj( + mrSdrObjCustomShape.getSdrModelFromSdrObject(), + OBJ_POLY, + aClosedPolyPolygon); + SfxItemSet aTempSet(*this); + aTempSet.Put(makeSdrShadowItem(false)); + aTempSet.Put(XLineStyleItem(drawing::LineStyle_NONE)); + pFill->SetMergedItemSet(aTempSet); + rObjectList.push_back(std::pair< SdrPathObj*, double >(pFill, dBrightness)); } - if(bLineGeometryNeededOnly) + if(!bNoStroke) { - bForceCreateTwoObjects = true; - bNoFill = true; - bNoStroke = false; + // there is no reason to use OBJ_PLIN here when the polygon is actually closed, + // the non-fill is defined by XFILL_NONE. Since SdrPathObj::ImpForceKind() needs + // to correct the polygon (here: open it) using the type, the last edge may get lost. + // Thus, use a type that fits the polygon + SdrPathObj* pStroke = new SdrPathObj( + mrSdrObjCustomShape.getSdrModelFromSdrObject(), + aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN, + aNewB2DPolyPolygon); + SfxItemSet aTempSet(*this); + aTempSet.Put(makeSdrShadowItem(false)); + aTempSet.Put(XFillStyleItem(drawing::FillStyle_NONE)); + pStroke->SetMergedItemSet(aTempSet); + rObjectList.push_back(std::pair< SdrPathObj*, double >(pStroke, dBrightness)); } + } + else + { + SdrPathObj* pObj = nullptr; + SfxItemSet aTempSet(*this); + aTempSet.Put(makeSdrShadowItem(false)); - if(bForceCreateTwoObjects || bSortFilledObjectsToBack) + if(bNoFill) { - if(bFilled && !bNoFill) - { - basegfx::B2DPolyPolygon aClosedPolyPolygon(aNewB2DPolyPolygon); - aClosedPolyPolygon.setClosed(true); - SdrPathObj* pFill = new SdrPathObj( - mrSdrObjCustomShape.getSdrModelFromSdrObject(), - OBJ_POLY, - aClosedPolyPolygon); - SfxItemSet aTempSet(*this); - aTempSet.Put(makeSdrShadowItem(false)); - aTempSet.Put(XLineStyleItem(drawing::LineStyle_NONE)); - pFill->SetMergedItemSet(aTempSet); - rObjectList.push_back(std::pair< SdrPathObj*, double >(pFill, dBrightness)); - } - - if(!bNoStroke) - { - // there is no reason to use OBJ_PLIN here when the polygon is actually closed, - // the non-fill is defined by XFILL_NONE. Since SdrPathObj::ImpForceKind() needs - // to correct the polygon (here: open it) using the type, the last edge may get lost. - // Thus, use a type that fits the polygon - SdrPathObj* pStroke = new SdrPathObj( - mrSdrObjCustomShape.getSdrModelFromSdrObject(), - aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN, - aNewB2DPolyPolygon); - SfxItemSet aTempSet(*this); - aTempSet.Put(makeSdrShadowItem(false)); - aTempSet.Put(XFillStyleItem(drawing::FillStyle_NONE)); - pStroke->SetMergedItemSet(aTempSet); - rObjectList.push_back(std::pair< SdrPathObj*, double >(pStroke, dBrightness)); - } + // see comment above about OBJ_PLIN + pObj = new SdrPathObj( + mrSdrObjCustomShape.getSdrModelFromSdrObject(), + aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN, + aNewB2DPolyPolygon); + aTempSet.Put(XFillStyleItem(drawing::FillStyle_NONE)); } else { - SdrPathObj* pObj = nullptr; - SfxItemSet aTempSet(*this); - aTempSet.Put(makeSdrShadowItem(false)); - - if(bNoFill) - { - // see comment above about OBJ_PLIN - pObj = new SdrPathObj( - mrSdrObjCustomShape.getSdrModelFromSdrObject(), - aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN, - aNewB2DPolyPolygon); - aTempSet.Put(XFillStyleItem(drawing::FillStyle_NONE)); - } - else - { - aNewB2DPolyPolygon.setClosed(true); - pObj = new SdrPathObj( - mrSdrObjCustomShape.getSdrModelFromSdrObject(), - OBJ_POLY, - aNewB2DPolyPolygon); - } - - if(bNoStroke) - { - aTempSet.Put(XLineStyleItem(drawing::LineStyle_NONE)); - } + aNewB2DPolyPolygon.setClosed(true); + pObj = new SdrPathObj( + mrSdrObjCustomShape.getSdrModelFromSdrObject(), + OBJ_POLY, + aNewB2DPolyPolygon); + } - pObj->SetMergedItemSet(aTempSet); - rObjectList.push_back(std::pair< SdrPathObj*, double >(pObj, dBrightness)); + if(bNoStroke) + { + aTempSet.Put(XLineStyleItem(drawing::LineStyle_NONE)); } + + pObj->SetMergedItemSet(aTempSet); + rObjectList.push_back(std::pair< SdrPathObj*, double >(pObj, dBrightness)); } } @@ -2748,83 +2748,83 @@ void EnhancedCustomShape2d::AdaptObjColor( sal_uInt32& nColorIndex, sal_uInt32 nColorCount) { - if ( !rObj.IsLine() ) + if ( rObj.IsLine() ) + return; + + const drawing::FillStyle eFillStyle = rObj.GetMergedItem(XATTR_FILLSTYLE).GetValue(); + switch( eFillStyle ) { - const drawing::FillStyle eFillStyle = rObj.GetMergedItem(XATTR_FILLSTYLE).GetValue(); - switch( eFillStyle ) + default: + case drawing::FillStyle_SOLID: { - default: - case drawing::FillStyle_SOLID: + Color aFillColor; + + if ( nColorCount || 0.0 != dBrightness ) { - Color aFillColor; + aFillColor = GetColorData( + rCustomShapeSet.Get( XATTR_FILLCOLOR ).GetColorValue(), + std::min(nColorIndex, nColorCount-1), + dBrightness ); + rObj.SetMergedItem( XFillColorItem( "", aFillColor ) ); + } + break; + } + case drawing::FillStyle_GRADIENT: + { + XGradient aXGradient(rObj.GetMergedItem(XATTR_FILLGRADIENT).GetGradientValue()); - if ( nColorCount || 0.0 != dBrightness ) - { - aFillColor = GetColorData( - rCustomShapeSet.Get( XATTR_FILLCOLOR ).GetColorValue(), + if ( nColorCount || 0.0 != dBrightness ) + { + aXGradient.SetStartColor( + GetColorData( + aXGradient.GetStartColor(), std::min(nColorIndex, nColorCount-1), - dBrightness ); - rObj.SetMergedItem( XFillColorItem( "", aFillColor ) ); - } - break; + dBrightness )); + aXGradient.SetEndColor( + GetColorData( + aXGradient.GetEndColor(), + std::min(nColorIndex, nColorCount-1), + dBrightness )); } - case drawing::FillStyle_GRADIENT: - { - XGradient aXGradient(rObj.GetMergedItem(XATTR_FILLGRADIENT).GetGradientValue()); - if ( nColorCount || 0.0 != dBrightness ) - { - aXGradient.SetStartColor( - GetColorData( - aXGradient.GetStartColor(), - std::min(nColorIndex, nColorCount-1), - dBrightness )); - aXGradient.SetEndColor( - GetColorData( - aXGradient.GetEndColor(), - std::min(nColorIndex, nColorCount-1), - dBrightness )); - } + rObj.SetMergedItem( XFillGradientItem( "", aXGradient ) ); + break; + } + case drawing::FillStyle_HATCH: + { + XHatch aXHatch(rObj.GetMergedItem(XATTR_FILLHATCH).GetHatchValue()); - rObj.SetMergedItem( XFillGradientItem( "", aXGradient ) ); - break; - } - case drawing::FillStyle_HATCH: + if ( nColorCount || 0.0 != dBrightness ) { - XHatch aXHatch(rObj.GetMergedItem(XATTR_FILLHATCH).GetHatchValue()); - - if ( nColorCount || 0.0 != dBrightness ) - { - aXHatch.SetColor( - GetColorData( - aXHatch.GetColor(), - std::min(nColorIndex, nColorCount-1), - dBrightness )); - } - - rObj.SetMergedItem( XFillHatchItem( "", aXHatch ) ); - break; + aXHatch.SetColor( + GetColorData( + aXHatch.GetColor(), + std::min(nColorIndex, nColorCount-1), + dBrightness )); } - case drawing::FillStyle_BITMAP: + + rObj.SetMergedItem( XFillHatchItem( "", aXHatch ) ); + break; + } + case drawing::FillStyle_BITMAP: + { + if ( nColorCount || 0.0 != dBrightness ) { - if ( nColorCount || 0.0 != dBrightness ) - { - BitmapEx aBitmap(rObj.GetMergedItem(XATTR_FILLBITMAP).GetGraphicObject().GetGraphic().GetBitmapEx()); + BitmapEx aBitmap(rObj.GetMergedItem(XATTR_FILLBITMAP).GetGraphicObject().GetGraphic().GetBitmapEx()); - short nLuminancePercent = static_cast< short > ( GetLuminanceChange( - std::min(nColorIndex, nColorCount-1))); - aBitmap.Adjust( nLuminancePercent, 0, 0, 0, 0 ); + short nLuminancePercent = static_cast< short > ( GetLuminanceChange( + std::min(nColorIndex, nColorCount-1))); + aBitmap.Adjust( nLuminancePercent, 0, 0, 0, 0 ); - rObj.SetMergedItem(XFillBitmapItem(OUString(), Graphic(aBitmap))); - } - - break; + rObj.SetMergedItem(XFillBitmapItem(OUString(), Graphic(aBitmap))); } - } - if ( nColorIndex < nColorCount ) - nColorIndex++; + break; + } } + + if ( nColorIndex < nColorCount ) + nColorIndex++; } SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly ) @@ -3014,20 +3014,20 @@ SdrObject* EnhancedCustomShape2d::CreateObject( bool bLineGeometryNeededOnly ) void EnhancedCustomShape2d::ApplyGluePoints( SdrObject* pObj ) { - if ( pObj ) - { - for ( const auto& rGluePoint : std::as_const(seqGluePoints) ) - { - SdrGluePoint aGluePoint; + if ( !pObj ) + return; - aGluePoint.SetPos( GetPoint( rGluePoint, true, true ) ); - aGluePoint.SetPercent( false ); - aGluePoint.SetAlign( SdrAlign::VERT_TOP | SdrAlign::HORZ_LEFT ); - aGluePoint.SetEscDir( SdrEscapeDirection::SMART ); - SdrGluePointList* pList = pObj->ForceGluePointList(); - if( pList ) - /* sal_uInt16 nId = */ pList->Insert( aGluePoint ); - } + for ( const auto& rGluePoint : std::as_const(seqGluePoints) ) + { + SdrGluePoint aGluePoint; + + aGluePoint.SetPos( GetPoint( rGluePoint, true, true ) ); + aGluePoint.SetPercent( false ); + aGluePoint.SetAlign( SdrAlign::VERT_TOP | SdrAlign::HORZ_LEFT ); + aGluePoint.SetEscDir( SdrEscapeDirection::SMART ); + SdrGluePointList* pList = pObj->ForceGluePointList(); + if( pList ) + /* sal_uInt16 nId = */ pList->Insert( aGluePoint ); } } diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx index cddb4571e93a..adf9bd12e396 100644 --- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx @@ -571,20 +571,20 @@ static basegfx::B2DPolyPolygon GetOutlinesFromShape2d( const SdrObject* pShape2d static void CalcDistances( const tools::Polygon& rPoly, std::vector< double >& rDistances ) { sal_uInt16 i, nCount = rPoly.GetSize(); - if ( nCount > 1 ) + if ( nCount <= 1 ) + return; + + for ( i = 0; i < nCount; i++ ) { - for ( i = 0; i < nCount; i++ ) - { - double fDistance = i ? rPoly.CalcDistance( i, i - 1 ) : 0.0; - rDistances.push_back( fDistance ); - } - std::partial_sum( rDistances.begin(), rDistances.end(), rDistances.begin() ); - double fLength = rDistances[ rDistances.size() - 1 ]; - if ( fLength > 0.0 ) - { - for ( auto& rDistance : rDistances ) - rDistance /= fLength; - } + double fDistance = i ? rPoly.CalcDistance( i, i - 1 ) : 0.0; + rDistances.push_back( fDistance ); + } + std::partial_sum( rDistances.begin(), rDistances.end(), rDistances.begin() ); + double fLength = rDistances[ rDistances.size() - 1 ]; + if ( fLength > 0.0 ) + { + for ( auto& rDistance : rDistances ) + rDistance /= fLength; } } @@ -645,29 +645,29 @@ static void InsertMissingOutlinePoints( const std::vector< double >& rDistances, static void GetPoint( const tools::Polygon& rPoly, const std::vector< double >& rDistances, const double& fX, double& fx1, double& fy1 ) { fy1 = fx1 = 0.0; - if ( rPoly.GetSize() > 1 ) - { - std::vector< double >::const_iterator aIter = std::lower_bound( rDistances.begin(), rDistances.end(), fX ); - sal_uInt16 nIdx = sal::static_int_cast<sal_uInt16>( std::distance( rDistances.begin(), aIter ) ); - if ( aIter == rDistances.end() ) - nIdx--; - const Point& rPt = rPoly[ nIdx ]; - fx1 = rPt.X(); - fy1 = rPt.Y(); - if ( nIdx && ( aIter != rDistances.end() ) && !rtl::math::approxEqual( *aIter, fX ) ) - { - nIdx = sal::static_int_cast<sal_uInt16>( std::distance( rDistances.begin(), aIter ) ); - double fDist0 = *( aIter - 1 ); - double fd = ( 1.0 / ( *aIter - fDist0 ) ) * ( fX - fDist0 ); - const Point& rPt2 = rPoly[ nIdx - 1 ]; - double fWidth = rPt.X() - rPt2.X(); - double fHeight= rPt.Y() - rPt2.Y(); - fWidth *= fd; - fHeight*= fd; - fx1 = rPt2.X() + fWidth; - fy1 = rPt2.Y() + fHeight; - } - } + if ( rPoly.GetSize() <= 1 ) + return; + + std::vector< double >::const_iterator aIter = std::lower_bound( rDistances.begin(), rDistances.end(), fX ); + sal_uInt16 nIdx = sal::static_int_cast<sal_uInt16>( std::distance( rDistances.begin(), aIter ) ); + if ( aIter == rDistances.end() ) + nIdx--; + const Point& rPt = rPoly[ nIdx ]; + fx1 = rPt.X(); + fy1 = rPt.Y(); + if ( !(nIdx && ( aIter != rDistances.end() ) && !rtl::math::approxEqual( *aIter, fX )) ) + return; + + nIdx = sal::static_int_cast<sal_uInt16>( std::distance( rDistances.begin(), aIter ) ); + double fDist0 = *( aIter - 1 ); + double fd = ( 1.0 / ( *aIter - fDist0 ) ) * ( fX - fDist0 ); + const Point& rPt2 = rPoly[ nIdx - 1 ]; + double fWidth = rPt.X() - rPt2.X(); + double fHeight= rPt.Y() - rPt2.Y(); + fWidth *= fd; + fHeight*= fd; + fx1 = rPt2.X() + fWidth; + fy1 = rPt2.Y() + fHeight; } static void FitTextOutlinesToShapeOutlines( const tools::PolyPolygon& aOutlines2d, FWData& rFWData ) diff --git a/svx/source/engine3d/dragmt3d.cxx b/svx/source/engine3d/dragmt3d.cxx index 231305eeae37..9e7425a02ed0 100644 --- a/svx/source/engine3d/dragmt3d.cxx +++ b/svx/source/engine3d/dragmt3d.cxx @@ -278,51 +278,51 @@ E3dDragRotate::E3dDragRotate(SdrDragView &_rView, // Get center of all selected objects in eye coordinates const sal_uInt32 nCnt(maGrp.size()); - if(nCnt) - { - const E3dScene* pScene(maGrp[0].mr3DObj.getRootE3dSceneFromE3dObject()); + if(!nCnt) + return; - if(nullptr != pScene) - { - const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact()); - const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D()); + const E3dScene* pScene(maGrp[0].mr3DObj.getRootE3dSceneFromE3dObject()); - for(sal_uInt32 nOb(0); nOb < nCnt; nOb++) - { - E3dDragMethodUnit& rCandidate = maGrp[nOb]; - basegfx::B3DPoint aObjCenter = rCandidate.mr3DObj.GetBoundVolume().getCenter(); - const basegfx::B3DHomMatrix aTransform(aViewInfo3D.getOrientation() * rCandidate.maDisplayTransform * rCandidate.maInitTransform); + if(nullptr == pScene) + return; - aObjCenter = aTransform * aObjCenter; - maGlobalCenter += aObjCenter; - } + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact()); + const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D()); - // Divide by the number - if(nCnt > 1) - { - maGlobalCenter /= static_cast<double>(nCnt); - } + for(sal_uInt32 nOb(0); nOb < nCnt; nOb++) + { + E3dDragMethodUnit& rCandidate = maGrp[nOb]; + basegfx::B3DPoint aObjCenter = rCandidate.mr3DObj.GetBoundVolume().getCenter(); + const basegfx::B3DHomMatrix aTransform(aViewInfo3D.getOrientation() * rCandidate.maDisplayTransform * rCandidate.maInitTransform); - // get rotate center and transform to 3D eye coordinates - basegfx::B2DPoint aRotCenter2D(Ref1().X(), Ref1().Y()); + aObjCenter = aTransform * aObjCenter; + maGlobalCenter += aObjCenter; + } - // from world to relative scene using inverse getObjectTransformation() - basegfx::B2DHomMatrix aInverseObjectTransform(rVCScene.getObjectTransformation()); - aInverseObjectTransform.invert(); - aRotCenter2D = aInverseObjectTransform * aRotCenter2D; + // Divide by the number + if(nCnt > 1) + { + maGlobalCenter /= static_cast<double>(nCnt); + } - // from 3D view to 3D eye - basegfx::B3DPoint aRotCenter3D(aRotCenter2D.getX(), aRotCenter2D.getY(), 0.0); - basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection()); - aInverseViewToEye.invert(); - aRotCenter3D = aInverseViewToEye * aRotCenter3D; + // get rotate center and transform to 3D eye coordinates + basegfx::B2DPoint aRotCenter2D(Ref1().X(), Ref1().Y()); - // Use X,Y of the RotCenter and depth of the common object centre - // as rotation point in the space - maGlobalCenter.setX(aRotCenter3D.getX()); - maGlobalCenter.setY(aRotCenter3D.getY()); - } - } + // from world to relative scene using inverse getObjectTransformation() + basegfx::B2DHomMatrix aInverseObjectTransform(rVCScene.getObjectTransformation()); + aInverseObjectTransform.invert(); + aRotCenter2D = aInverseObjectTransform * aRotCenter2D; + + // from 3D view to 3D eye + basegfx::B3DPoint aRotCenter3D(aRotCenter2D.getX(), aRotCenter2D.getY(), 0.0); + basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection()); + aInverseViewToEye.invert(); + aRotCenter3D = aInverseViewToEye * aRotCenter3D; + +// Use X,Y of the RotCenter and depth of the common object centre +// as rotation point in the space + maGlobalCenter.setX(aRotCenter3D.getX()); + maGlobalCenter.setY(aRotCenter3D.getY()); } @@ -333,115 +333,115 @@ void E3dDragRotate::MoveSdrDrag(const Point& rPnt) // call parent E3dDragMethod::MoveSdrDrag(rPnt); - if(DragStat().CheckMinMoved(rPnt)) + if(!DragStat().CheckMinMoved(rPnt)) + return; + + // Get modifier + sal_uInt16 nModifier = 0; + if(dynamic_cast<const E3dView*>(&getSdrDragView())) { - // Get modifier - sal_uInt16 nModifier = 0; - if(dynamic_cast<const E3dView*>(&getSdrDragView())) + const MouseEvent& rLastMouse = static_cast<E3dView&>(getSdrDragView()).GetMouseEvent(); + nModifier = rLastMouse.GetModifier(); + } + + // Rotate all objects + const sal_uInt32 nCnt(maGrp.size()); + + for(sal_uInt32 nOb(0); nOb < nCnt; nOb++) + { + // Determine rotation angle + double fWAngle, fHAngle; + E3dDragMethodUnit& rCandidate = maGrp[nOb]; + + if(E3dDragConstraint::Z == meConstraint) { - const MouseEvent& rLastMouse = static_cast<E3dView&>(getSdrDragView()).GetMouseEvent(); - nModifier = rLastMouse.GetModifier(); + fWAngle = NormAngle36000(GetAngle(rPnt - DragStat().GetRef1()) - + rCandidate.mnStartAngle) - rCandidate.mnLastAngle; + rCandidate.mnLastAngle = static_cast<long>(fWAngle) + rCandidate.mnLastAngle; + fWAngle /= 100.0; + fHAngle = 0.0; + } + else + { + if ((maFullBound.GetWidth() == 0) || (maFullBound.GetHeight() == 0)) + throw o3tl::divide_by_zero(); + fWAngle = 90.0 * static_cast<double>(rPnt.X() - maLastPos.X()) + / static_cast<double>(maFullBound.GetWidth()); + fHAngle = 90.0 * static_cast<double>(rPnt.Y() - maLastPos.Y()) + / static_cast<double>(maFullBound.GetHeight()); } + long nSnap = 0; - // Rotate all objects - const sal_uInt32 nCnt(maGrp.size()); + if(!getSdrDragView().IsRotateAllowed()) + nSnap = 90; - for(sal_uInt32 nOb(0); nOb < nCnt; nOb++) + if(nSnap != 0) { - // Determine rotation angle - double fWAngle, fHAngle; - E3dDragMethodUnit& rCandidate = maGrp[nOb]; + fWAngle = static_cast<double>((static_cast<long>(fWAngle) + nSnap/2) / nSnap * nSnap); + fHAngle = static_cast<double>((static_cast<long>(fHAngle) + nSnap/2) / nSnap * nSnap); + } - if(E3dDragConstraint::Z == meConstraint) - { - fWAngle = NormAngle36000(GetAngle(rPnt - DragStat().GetRef1()) - - rCandidate.mnStartAngle) - rCandidate.mnLastAngle; - rCandidate.mnLastAngle = static_cast<long>(fWAngle) + rCandidate.mnLastAngle; - fWAngle /= 100.0; - fHAngle = 0.0; - } + // to radians + fWAngle = basegfx::deg2rad(fWAngle); + fHAngle = basegfx::deg2rad(fHAngle); + + // Determine transformation + basegfx::B3DHomMatrix aRotMat; + if(E3dDragConstraint::Y & meConstraint) + { + if(nModifier & KEY_MOD2) + aRotMat.rotate(0.0, 0.0, fWAngle); else - { - if ((maFullBound.GetWidth() == 0) || (maFullBound.GetHeight() == 0)) - throw o3tl::divide_by_zero(); - fWAngle = 90.0 * static_cast<double>(rPnt.X() - maLastPos.X()) - / static_cast<double>(maFullBound.GetWidth()); - fHAngle = 90.0 * static_cast<double>(rPnt.Y() - maLastPos.Y()) - / static_cast<double>(maFullBound.GetHeight()); - } - long nSnap = 0; + aRotMat.rotate(0.0, fWAngle, 0.0); + } + else if(E3dDragConstraint::Z & meConstraint) + { + if(nModifier & KEY_MOD2) + aRotMat.rotate(0.0, fWAngle, 0.0); + else + aRotMat.rotate(0.0, 0.0, fWAngle); + } + if(E3dDragConstraint::X & meConstraint) + { + aRotMat.rotate(fHAngle, 0.0, 0.0); + } - if(!getSdrDragView().IsRotateAllowed()) - nSnap = 90; + const E3dScene* pScene(rCandidate.mr3DObj.getRootE3dSceneFromE3dObject()); - if(nSnap != 0) - { - fWAngle = static_cast<double>((static_cast<long>(fWAngle) + nSnap/2) / nSnap * nSnap); - fHAngle = static_cast<double>((static_cast<long>(fHAngle) + nSnap/2) / nSnap * nSnap); - } + if(nullptr != pScene) + { + // Transformation in eye coordinates, there rotate then and back + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact()); + const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D()); + basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation()); + aInverseOrientation.invert(); - // to radians - fWAngle = basegfx::deg2rad(fWAngle); - fHAngle = basegfx::deg2rad(fHAngle); + basegfx::B3DHomMatrix aTransMat(rCandidate.maDisplayTransform); + aTransMat *= aViewInfo3D.getOrientation(); + aTransMat.translate(-maGlobalCenter.getX(), -maGlobalCenter.getY(), -maGlobalCenter.getZ()); + aTransMat *= aRotMat; + aTransMat.translate(maGlobalCenter.getX(), maGlobalCenter.getY(), maGlobalCenter.getZ()); + aTransMat *= aInverseOrientation; + aTransMat *= rCandidate.maInvDisplayTransform; - // Determine transformation - basegfx::B3DHomMatrix aRotMat; - if(E3dDragConstraint::Y & meConstraint) - { - if(nModifier & KEY_MOD2) - aRotMat.rotate(0.0, 0.0, fWAngle); - else - aRotMat.rotate(0.0, fWAngle, 0.0); - } - else if(E3dDragConstraint::Z & meConstraint) + // ...and apply + rCandidate.maTransform *= aTransMat; + + if(mbMoveFull) { - if(nModifier & KEY_MOD2) - aRotMat.rotate(0.0, fWAngle, 0.0); - else - aRotMat.rotate(0.0, 0.0, fWAngle); + E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj); + rCandidate.mr3DObj.SetTransform(rCandidate.maTransform); } - if(E3dDragConstraint::X & meConstraint) + else { - aRotMat.rotate(fHAngle, 0.0, 0.0); - } - - const E3dScene* pScene(rCandidate.mr3DObj.getRootE3dSceneFromE3dObject()); - - if(nullptr != pScene) - { - // Transformation in eye coordinates, there rotate then and back - const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact()); - const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D()); - basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation()); - aInverseOrientation.invert(); - - basegfx::B3DHomMatrix aTransMat(rCandidate.maDisplayTransform); - aTransMat *= aViewInfo3D.getOrientation(); - aTransMat.translate(-maGlobalCenter.getX(), -maGlobalCenter.getY(), -maGlobalCenter.getZ()); - aTransMat *= aRotMat; - aTransMat.translate(maGlobalCenter.getX(), maGlobalCenter.getY(), maGlobalCenter.getZ()); - aTransMat *= aInverseOrientation; - aTransMat *= rCandidate.maInvDisplayTransform; - - // ...and apply - rCandidate.maTransform *= aTransMat; - - if(mbMoveFull) - { - E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj); - rCandidate.mr3DObj.SetTransform(rCandidate.maTransform); - } - else - { - Hide(); - rCandidate.maWireframePoly.transform(aTransMat); - Show(); - } + Hide(); + rCandidate.maWireframePoly.transform(aTransMat); + Show(); } } - maLastPos = rPnt; - DragStat().NextMove(rPnt); } + maLastPos = rPnt; + DragStat().NextMove(rPnt); } PointerStyle E3dDragRotate::GetSdrDragPointer() const @@ -508,220 +508,220 @@ void E3dDragMove::MoveSdrDrag(const Point& rPnt) // call parent E3dDragMethod::MoveSdrDrag(rPnt); - if(DragStat().CheckMinMoved(rPnt)) + if(!DragStat().CheckMinMoved(rPnt)) + return; + + if(SdrHdlKind::Move == meWhatDragHdl) { - if(SdrHdlKind::Move == meWhatDragHdl) - { - // Translation - // Determine the motion vector - const sal_uInt32 nCnt(maGrp.size()); + // Translation + // Determine the motion vector + const sal_uInt32 nCnt(maGrp.size()); - // Get modifier - sal_uInt16 nModifier(0); + // Get modifier + sal_uInt16 nModifier(0); - if(dynamic_cast<const E3dView*>(&getSdrDragView())) - { - const MouseEvent& rLastMouse = static_cast<E3dView&>(getSdrDragView()).GetMouseEvent(); - nModifier = rLastMouse.GetModifier(); - } + if(dynamic_cast<const E3dView*>(&getSdrDragView())) + { + const MouseEvent& rLastMouse = static_cast<E3dView&>(getSdrDragView()).GetMouseEvent(); + nModifier = rLastMouse.GetModifier(); + } - for(sal_uInt32 nOb(0); nOb < nCnt; nOb++) - { - E3dDragMethodUnit& rCandidate = maGrp[nOb]; - const E3dScene* pScene(rCandidate.mr3DObj.getRootE3dSceneFromE3dObject()); + for(sal_uInt32 nOb(0); nOb < nCnt; nOb++) + { + E3dDragMethodUnit& rCandidate = maGrp[nOb]; + const E3dScene* pScene(rCandidate.mr3DObj.getRootE3dSceneFromE3dObject()); - if(nullptr != pScene) - { - const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact()); - const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D()); + if(nullptr != pScene) + { + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact()); + const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D()); - // move coor from 2d world to 3d Eye - basegfx::B2DPoint aGlobalMoveHead2D(static_cast<double>(rPnt.X() - maLastPos.X()), static_cast<double>(rPnt.Y() - maLastPos.Y())); - basegfx::B2DPoint aGlobalMoveTail2D(0.0, 0.0); - basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation()); + // move coor from 2d world to 3d Eye + basegfx::B2DPoint aGlobalMoveHead2D(static_cast<double>(rPnt.X() - maLastPos.X()), static_cast<double>(rPnt.Y() - maLastPos.Y())); + basegfx::B2DPoint aGlobalMoveTail2D(0.0, 0.0); + basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation()); - aInverseSceneTransform.invert(); - aGlobalMoveHead2D = aInverseSceneTransform * aGlobalMoveHead2D; - aGlobalMoveTail2D = aInverseSceneTransform * aGlobalMoveTail2D; + aInverseSceneTransform.invert(); + aGlobalMoveHead2D = aInverseSceneTransform * aGlobalMoveHead2D; + aGlobalMoveTail2D = aInverseSceneTransform * aGlobalMoveTail2D; - basegfx::B3DPoint aMoveHead3D(aGlobalMoveHead2D.getX(), aGlobalMoveHead2D.getY(), 0.5); - basegfx::B3DPoint aMoveTail3D(aGlobalMoveTail2D.getX(), aGlobalMoveTail2D.getY(), 0.5); - basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection()); - aInverseViewToEye.invert(); + basegfx::B3DPoint aMoveHead3D(aGlobalMoveHead2D.getX(), aGlobalMoveHead2D.getY(), 0.5); + basegfx::B3DPoint aMoveTail3D(aGlobalMoveTail2D.getX(), aGlobalMoveTail2D.getY(), 0.5); + basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection()); + aInverseViewToEye.invert(); - aMoveHead3D = aInverseViewToEye * aMoveHead3D; - aMoveTail3D = aInverseViewToEye * aMoveTail3D; + aMoveHead3D = aInverseViewToEye * aMoveHead3D; + aMoveTail3D = aInverseViewToEye * aMoveTail3D; - // eventually switch movement from XY to XZ plane - if(nModifier & KEY_MOD2) - { - double fZwi = aMoveHead3D.getY(); - aMoveHead3D.setY(aMoveHead3D.getZ()); - aMoveHead3D.setZ(fZwi); + // eventually switch movement from XY to XZ plane + if(nModifier & KEY_MOD2) + { + double fZwi = aMoveHead3D.getY(); + aMoveHead3D.setY(aMoveHead3D.getZ()); + aMoveHead3D.setZ(fZwi); - fZwi = aMoveTail3D.getY(); - aMoveTail3D.setY(aMoveTail3D.getZ()); - aMoveTail3D.setZ(fZwi); - } + fZwi = aMoveTail3D.getY(); + aMoveTail3D.setY(aMoveTail3D.getZ()); + aMoveTail3D.setZ(fZwi); + } - // Motion vector from eye coordinates to parent coordinates - basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation()); - aInverseOrientation.invert(); - basegfx::B3DHomMatrix aCompleteTrans(rCandidate.maInvDisplayTransform * aInverseOrientation); + // Motion vector from eye coordinates to parent coordinates + basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation()); + aInverseOrientation.invert(); + basegfx::B3DHomMatrix aCompleteTrans(rCandidate.maInvDisplayTransform * aInverseOrientation); - aMoveHead3D = aCompleteTrans * aMoveHead3D; - aMoveTail3D = aCompleteTrans* aMoveTail3D; + aMoveHead3D = aCompleteTrans * aMoveHead3D; + aMoveTail3D = aCompleteTrans* aMoveTail3D; - // build transformation - basegfx::B3DHomMatrix aTransMat; - basegfx::B3DPoint aTranslate(aMoveHead3D - aMoveTail3D); - aTransMat.translate(aTranslate.getX(), aTranslate.getY(), aTranslate.getZ()); + // build transformation + basegfx::B3DHomMatrix aTransMat; + basegfx::B3DPoint aTranslate(aMoveHead3D - aMoveTail3D); + aTransMat.translate(aTranslate.getX(), aTranslate.getY(), aTranslate.getZ()); - // ...and apply - rCandidate.maTransform *= aTransMat; + // ...and apply + rCandidate.maTransform *= aTransMat; - if(mbMoveFull) - { - E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj); - rCandidate.mr3DObj.SetTransform(rCandidate.maTransform); - } - else - { - Hide(); - rCandidate.maWireframePoly.transform(aTransMat); - Show(); - } + if(mbMoveFull) + { + E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj); + rCandidate.mr3DObj.SetTransform(rCandidate.maTransform); + } + else + { + Hide(); + rCandidate.maWireframePoly.transform(aTransMat); + Show(); } } } - else + } + else + { + // Scaling + // Determine scaling vector + Point aStartPos = DragStat().GetStart(); + const sal_uInt32 nCnt(maGrp.size()); + + for(sal_uInt32 nOb(0); nOb < nCnt; nOb++) { - // Scaling - // Determine scaling vector - Point aStartPos = DragStat().GetStart(); - const sal_uInt32 nCnt(maGrp.size()); + E3dDragMethodUnit& rCandidate = maGrp[nOb]; + const basegfx::B3DPoint aObjectCenter(rCandidate.mr3DObj.GetBoundVolume().getCenter()); + const E3dScene* pScene(rCandidate.mr3DObj.getRootE3dSceneFromE3dObject()); - for(sal_uInt32 nOb(0); nOb < nCnt; nOb++) + if(nullptr != pScene) { - E3dDragMethodUnit& rCandidate = maGrp[nOb]; - const basegfx::B3DPoint aObjectCenter(rCandidate.mr3DObj.GetBoundVolume().getCenter()); - const E3dScene* pScene(rCandidate.mr3DObj.getRootE3dSceneFromE3dObject()); + // transform from 2D world view to 3D eye + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact()); + const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D()); - if(nullptr != pScene) - { - // transform from 2D world view to 3D eye - const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact()); - const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D()); + basegfx::B2DPoint aGlobalScaleStart2D(static_cast<double>(aStartPos.X()), static_cast<double>(aStartPos.Y())); + basegfx::B2DPoint aGlobalScaleNext2D(static_cast<double>(rPnt.X()), static_cast<double>(rPnt.Y())); + basegfx::B2DPoint aGlobalScaleFixPos2D(static_cast<double>(maScaleFixPos.X()), static_cast<double>(maScaleFixPos.Y())); + basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation()); - basegfx::B2DPoint aGlobalScaleStart2D(static_cast<double>(aStartPos.X()), static_cast<double>(aStartPos.Y())); - basegfx::B2DPoint aGlobalScaleNext2D(static_cast<double>(rPnt.X()), static_cast<double>(rPnt.Y())); - basegfx::B2DPoint aGlobalScaleFixPos2D(static_cast<double>(maScaleFixPos.X()), static_cast<double>(maScaleFixPos.Y())); - basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation()); + aInverseSceneTransform.invert(); + aGlobalScaleStart2D = aInverseSceneTransform * aGlobalScaleStart2D; + aGlobalScaleNext2D = aInverseSceneTransform * aGlobalScaleNext2D; + aGlobalScaleFixPos2D = aInverseSceneTransform * aGlobalScaleFixPos2D; - aInverseSceneTransform.invert(); - aGlobalScaleStart2D = aInverseSceneTransform * aGlobalScaleStart2D; - aGlobalScaleNext2D = aInverseSceneTransform * aGlobalScaleNext2D; - aGlobalScaleFixPos2D = aInverseSceneTransform * aGlobalScaleFixPos2D; + basegfx::B3DPoint aGlobalScaleStart3D(aGlobalScaleStart2D.getX(), aGlobalScaleStart2D.getY(), aObjectCenter.getZ()); + basegfx::B3DPoint aGlobalScaleNext3D(aGlobalScaleNext2D.getX(), aGlobalScaleNext2D.getY(), aObjectCenter.getZ()); + basegfx::B3DPoint aGlobalScaleFixPos3D(aGlobalScaleFixPos2D.getX(), aGlobalScaleFixPos2D.getY(), aObjectCenter.getZ()); + basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection()); - basegfx::B3DPoint aGlobalScaleStart3D(aGlobalScaleStart2D.getX(), aGlobalScaleStart2D.getY(), aObjectCenter.getZ()); - basegfx::B3DPoint aGlobalScaleNext3D(aGlobalScaleNext2D.getX(), aGlobalScaleNext2D.getY(), aObjectCenter.getZ()); - basegfx::B3DPoint aGlobalScaleFixPos3D(aGlobalScaleFixPos2D.getX(), aGlobalScaleFixPos2D.getY(), aObjectCenter.getZ()); - basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection()); + aInverseViewToEye.invert(); + basegfx::B3DPoint aScStart(aInverseViewToEye * aGlobalScaleStart3D); + basegfx::B3DPoint aScNext(aInverseViewToEye * aGlobalScaleNext3D); + basegfx::B3DPoint aScFixPos(aInverseViewToEye * aGlobalScaleFixPos3D); - aInverseViewToEye.invert(); - basegfx::B3DPoint aScStart(aInverseViewToEye * aGlobalScaleStart3D); - basegfx::B3DPoint aScNext(aInverseViewToEye * aGlobalScaleNext3D); - basegfx::B3DPoint aScFixPos(aInverseViewToEye * aGlobalScaleFixPos3D); + // constraints? + switch(meWhatDragHdl) + { + case SdrHdlKind::Left: + case SdrHdlKind::Right: + // to constrain on X -> Y equal + aScNext.setY(aScFixPos.getY()); + break; + case SdrHdlKind::Upper: + case SdrHdlKind::Lower: + // constrain to Y -> X equal + aScNext.setX(aScFixPos.getX()); + break; + default: + break; + } - // constraints? - switch(meWhatDragHdl) - { - case SdrHdlKind::Left: - case SdrHdlKind::Right: - // to constrain on X -> Y equal - aScNext.setY(aScFixPos.getY()); - break; - case SdrHdlKind::Upper: - case SdrHdlKind::Lower: - // constrain to Y -> X equal - aScNext.setX(aScFixPos.getX()); - break; - default: - break; - } + // get scale vector in eye coordinates + basegfx::B3DPoint aScaleVec(aScStart - aScFixPos); + aScaleVec.setZ(1.0); - // get scale vector in eye coordinates - basegfx::B3DPoint aScaleVec(aScStart - aScFixPos); - aScaleVec.setZ(1.0); + if(aScaleVec.getX() != 0.0) + { + aScaleVec.setX((aScNext.getX() - aScFixPos.getX()) / aScaleVec.getX()); + } + else + { + aScaleVec.setX(1.0); + } - if(aScaleVec.getX() != 0.0) - { - aScaleVec.setX((aScNext.getX() - aScFixPos.getX()) / aScaleVec.getX()); - } - else - { - aScaleVec.setX(1.0); - } + if(aScaleVec.getY() != 0.0) + { + aScaleVec.setY((aScNext.getY() - aScFixPos.getY()) / aScaleVec.getY()); + } + else + { + aScaleVec.setY(1.0); + } - if(aScaleVec.getY() != 0.0) + // SHIFT-key used? + if(getSdrDragView().IsOrtho()) + { + if(fabs(aScaleVec.getX()) > fabs(aScaleVec.getY())) { - aScaleVec.setY((aScNext.getY() - aScFixPos.getY()) / aScaleVec.getY()); + // X is biggest + aScaleVec.setY(aScaleVec.getX()); } else { - aScaleVec.setY(1.0); - } - - // SHIFT-key used? - if(getSdrDragView().IsOrtho()) - { - if(fabs(aScaleVec.getX()) > fabs(aScaleVec.getY())) - { - // X is biggest - aScaleVec.setY(aScaleVec.getX()); - } - else - { - // Y is biggest - aScaleVec.setX(aScaleVec.getY()); - } + // Y is biggest + aScaleVec.setX(aScaleVec.getY()); } + } - // build transformation - basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation()); - aInverseOrientation.invert(); + // build transformation + basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation()); + aInverseOrientation.invert(); - basegfx::B3DHomMatrix aNewTrans = rCandidate.maInitTransform; - aNewTrans *= rCandidate.maDisplayTransform; - aNewTrans *= aViewInfo3D.getOrientation(); - aNewTrans.translate(-aScFixPos.getX(), -aScFixPos.getY(), -aScFixPos.getZ()); - aNewTrans.scale(aScaleVec.getX(), aScaleVec.getY(), aScaleVec.getZ()); - aNewTrans.translate(aScFixPos.getX(), aScFixPos.getY(), aScFixPos.getZ()); - aNewTrans *= aInverseOrientation; - aNewTrans *= rCandidate.maInvDisplayTransform; + basegfx::B3DHomMatrix aNewTrans = rCandidate.maInitTransform; + aNewTrans *= rCandidate.maDisplayTransform; + aNewTrans *= aViewInfo3D.getOrientation(); + aNewTrans.translate(-aScFixPos.getX(), -aScFixPos.getY(), -aScFixPos.getZ()); + aNewTrans.scale(aScaleVec.getX(), aScaleVec.getY(), aScaleVec.getZ()); + aNewTrans.translate(aScFixPos.getX(), aScFixPos.getY(), aScFixPos.getZ()); + aNewTrans *= aInverseOrientation; + aNewTrans *= rCandidate.maInvDisplayTransform; - // ...and apply - rCandidate.maTransform = aNewTrans; + // ...and apply + rCandidate.maTransform = aNewTrans; - if(mbMoveFull) - { - E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj); - rCandidate.mr3DObj.SetTransform(rCandidate.maTransform); - } - else - { - Hide(); - rCandidate.maWireframePoly.clear(); - rCandidate.maWireframePoly = rCandidate.mr3DObj.CreateWireframe(); - rCandidate.maWireframePoly.transform(rCandidate.maTransform); - Show(); - } + if(mbMoveFull) + { + E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj); + rCandidate.mr3DObj.SetTransform(rCandidate.maTransform); + } + else + { + Hide(); + rCandidate.maWireframePoly.clear(); + rCandidate.maWireframePoly = rCandidate.mr3DObj.CreateWireframe(); + rCandidate.maWireframePoly.transform(rCandidate.maTransform); + Show(); } } } - maLastPos = rPnt; - DragStat().NextMove(rPnt); } + maLastPos = rPnt; + DragStat().NextMove(rPnt); } PointerStyle E3dDragMove::GetSdrDragPointer() const diff --git a/svx/source/engine3d/e3dsceneupdater.cxx b/svx/source/engine3d/e3dsceneupdater.cxx index 07df1af059b9..f2569e325b4e 100644 --- a/svx/source/engine3d/e3dsceneupdater.cxx +++ b/svx/source/engine3d/e3dsceneupdater.cxx @@ -28,83 +28,84 @@ E3DModifySceneSnapRectUpdater::E3DModifySceneSnapRectUpdater(const SdrObject* pO : mpScene(nullptr) { // Secure old 3D transformation stack before modification - if(const E3dObject* pE3dObject = dynamic_cast< const E3dObject* >(pObject)) + const E3dObject* pE3dObject = dynamic_cast< const E3dObject* >(pObject); + if(!pE3dObject) + return; + + mpScene = pE3dObject->getRootE3dSceneFromE3dObject(); + + if(nullptr == mpScene || mpScene->getRootE3dSceneFromE3dObject() != mpScene) + return; + + // if there is a scene and it's the outmost scene, get current 3D range + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(mpScene->GetViewContact()); + const basegfx::B3DRange aAllContentRange(rVCScene.getAllContentRange3D()); + + if(aAllContentRange.isEmpty()) { - mpScene = pE3dObject->getRootE3dSceneFromE3dObject(); - - if(nullptr != mpScene && mpScene->getRootE3dSceneFromE3dObject() == mpScene) - { - // if there is a scene and it's the outmost scene, get current 3D range - const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(mpScene->GetViewContact()); - const basegfx::B3DRange aAllContentRange(rVCScene.getAllContentRange3D()); - - if(aAllContentRange.isEmpty()) - { - // no content, nothing to do - mpScene = nullptr; - } - else - { - // secure current 3D transformation stack - mpViewInformation3D.reset( - new drawinglayer::geometry::ViewInformation3D( - rVCScene.getViewInformation3D(aAllContentRange))); - } - } + // no content, nothing to do + mpScene = nullptr; + } + else + { + // secure current 3D transformation stack + mpViewInformation3D.reset( + new drawinglayer::geometry::ViewInformation3D( + rVCScene.getViewInformation3D(aAllContentRange))); } } E3DModifySceneSnapRectUpdater::~E3DModifySceneSnapRectUpdater() { - if(mpScene && mpViewInformation3D) + if(!(mpScene && mpViewInformation3D)) + return; + + // after changing parts of the scene, use the secured last 3d transformation stack and the new content + // range to calculate a new, eventually expanded or shrunk, 2D geometry for the scene and apply it. + // Get new content range + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(mpScene->GetViewContact()); + basegfx::B3DRange aAllContentRange(rVCScene.getAllContentRange3D()); + + // only change when there is still content; else let scene stay at old SnapRect + if(aAllContentRange.isEmpty()) + return; + + // check if object transform of scene has changed + if(mpViewInformation3D->getObjectTransformation() != mpScene->GetTransform()) + { + // If Yes, it needs to be updated since it's - for historical reasons - + // part of the basic 3d transformation stack of the scene + drawinglayer::geometry::ViewInformation3D* pNew = new drawinglayer::geometry::ViewInformation3D( + mpScene->GetTransform(), // replace object transformation with new local transform + mpViewInformation3D->getOrientation(), + mpViewInformation3D->getProjection(), + mpViewInformation3D->getDeviceToView(), + mpViewInformation3D->getViewTime(), + mpViewInformation3D->getExtendedInformationSequence()); + mpViewInformation3D.reset(pNew); + } + + // transform content range to scene-relative coordinates using old 3d transformation stack + aAllContentRange.transform(mpViewInformation3D->getObjectToView()); + + // build 2d relative content range + basegfx::B2DRange aSnapRange( + aAllContentRange.getMinX(), aAllContentRange.getMinY(), + aAllContentRange.getMaxX(), aAllContentRange.getMaxY()); + + // transform to 2D world coordinates using scene's 2D transformation + aSnapRange.transform(rVCScene.getObjectTransformation()); + + // snap to (old) integer + const tools::Rectangle aNewSnapRect( + sal_Int32(floor(aSnapRange.getMinX())), sal_Int32(floor(aSnapRange.getMinY())), + sal_Int32(ceil(aSnapRange.getMaxX())), sal_Int32(ceil(aSnapRange.getMaxY()))); + + // set as new SnapRect and invalidate bound volume + if(mpScene->GetSnapRect() != aNewSnapRect) { - // after changing parts of the scene, use the secured last 3d transformation stack and the new content - // range to calculate a new, eventually expanded or shrunk, 2D geometry for the scene and apply it. - // Get new content range - const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(mpScene->GetViewContact()); - basegfx::B3DRange aAllContentRange(rVCScene.getAllContentRange3D()); - - // only change when there is still content; else let scene stay at old SnapRect - if(!aAllContentRange.isEmpty()) - { - // check if object transform of scene has changed - if(mpViewInformation3D->getObjectTransformation() != mpScene->GetTransform()) - { - // If Yes, it needs to be updated since it's - for historical reasons - - // part of the basic 3d transformation stack of the scene - drawinglayer::geometry::ViewInformation3D* pNew = new drawinglayer::geometry::ViewInformation3D( - mpScene->GetTransform(), // replace object transformation with new local transform - mpViewInformation3D->getOrientation(), - mpViewInformation3D->getProjection(), - mpViewInformation3D->getDeviceToView(), - mpViewInformation3D->getViewTime(), - mpViewInformation3D->getExtendedInformationSequence()); - mpViewInformation3D.reset(pNew); - } - - // transform content range to scene-relative coordinates using old 3d transformation stack - aAllContentRange.transform(mpViewInformation3D->getObjectToView()); - - // build 2d relative content range - basegfx::B2DRange aSnapRange( - aAllContentRange.getMinX(), aAllContentRange.getMinY(), - aAllContentRange.getMaxX(), aAllContentRange.getMaxY()); - - // transform to 2D world coordinates using scene's 2D transformation - aSnapRange.transform(rVCScene.getObjectTransformation()); - - // snap to (old) integer - const tools::Rectangle aNewSnapRect( - sal_Int32(floor(aSnapRange.getMinX())), sal_Int32(floor(aSnapRange.getMinY())), - sal_Int32(ceil(aSnapRange.getMaxX())), sal_Int32(ceil(aSnapRange.getMaxY()))); - - // set as new SnapRect and invalidate bound volume - if(mpScene->GetSnapRect() != aNewSnapRect) - { - mpScene->SetSnapRect(aNewSnapRect); - mpScene->InvalidateBoundVolume(); - } - } + mpScene->SetSnapRect(aNewSnapRect); + mpScene->InvalidateBoundVolume(); } } diff --git a/svx/source/engine3d/helperhittest3d.cxx b/svx/source/engine3d/helperhittest3d.cxx index f553b4d0e744..65ed16af7154 100644 --- a/svx/source/engine3d/helperhittest3d.cxx +++ b/svx/source/engine3d/helperhittest3d.cxx @@ -67,29 +67,29 @@ static void getAllHit3DObjectWithRelativePoint( { o_rResult.clear(); - if(!rFront.equal(rBack)) - { - // rObject is an E3dCompoundObject, so it cannot be a scene (which is an E3dObject) - const sdr::contact::ViewContactOfE3d& rVCObject = static_cast< sdr::contact::ViewContactOfE3d& >(rObject.GetViewContact()); - const drawinglayer::primitive3d::Primitive3DContainer aPrimitives(rVCObject.getViewIndependentPrimitive3DContainer()); + if(rFront.equal(rBack)) + return; - if(!aPrimitives.empty()) - { - // make BoundVolume empty and overlapping test for speedup - const basegfx::B3DRange aObjectRange(aPrimitives.getB3DRange(rObjectViewInformation3D)); + // rObject is an E3dCompoundObject, so it cannot be a scene (which is an E3dObject) + const sdr::contact::ViewContactOfE3d& rVCObject = static_cast< sdr::contact::ViewContactOfE3d& >(rObject.GetViewContact()); + const drawinglayer::primitive3d::Primitive3DContainer aPrimitives(rVCObject.getViewIndependentPrimitive3DContainer()); - if(!aObjectRange.isEmpty()) - { - const basegfx::B3DRange aFrontBackRange(rFront, rBack); + if(aPrimitives.empty()) + return; - if(aObjectRange.overlaps(aFrontBackRange)) - { - // bound volumes hit, geometric cut tests needed - drawinglayer::processor3d::CutFindProcessor aCutFindProcessor(rObjectViewInformation3D, rFront, rBack, bAnyHit); - aCutFindProcessor.process(aPrimitives); - o_rResult = aCutFindProcessor.getCutPoints(); - } - } + // make BoundVolume empty and overlapping test for speedup + const basegfx::B3DRange aObjectRange(aPrimitives.getB3DRange(rObjectViewInformation3D)); + + if(!aObjectRange.isEmpty()) + { + const basegfx::B3DRange aFrontBackRange(rFront, rBack); + + if(aObjectRange.overlaps(aFrontBackRange)) + { + // bound volumes hit, geometric cut tests needed + drawinglayer::processor3d::CutFindProcessor aCutFindProcessor(rObjectViewInformation3D, rFront, rBack, bAnyHit); + aCutFindProcessor.process(aPrimitives); + o_rResult = aCutFindProcessor.getCutPoints(); } } } @@ -164,67 +164,67 @@ void getAllHit3DObjectsSortedFrontToBack( o_rResult.clear(); SdrObjList* pList = rScene.GetSubList(); - if(nullptr != pList && 0 != pList->GetObjCount()) + if(nullptr == pList || 0 == pList->GetObjCount()) + return; + + // prepare relative HitPoint. To do so, get the VC of the 3DScene and from there + // the Scene's 2D transformation. Multiplying with the inverse transformation + // will create a point relative to the 3D scene as unit-2d-object + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rScene.GetViewContact()); + basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation()); + aInverseSceneTransform.invert(); + const basegfx::B2DPoint aRelativePoint(aInverseSceneTransform * rPoint); + + // check if test point is inside scene's area at all + if(!(aRelativePoint.getX() >= 0.0 && aRelativePoint.getX() <= 1.0 && aRelativePoint.getY() >= 0.0 && aRelativePoint.getY() <= 1.0)) + return; + + SdrObjListIter aIterator(pList, SdrIterMode::DeepNoGroups); + ::std::vector< ImplPairDephAndObject > aDepthAndObjectResults; + const uno::Sequence< beans::PropertyValue > aEmptyParameters; + drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters); + + while(aIterator.IsMore()) { - // prepare relative HitPoint. To do so, get the VC of the 3DScene and from there - // the Scene's 2D transformation. Multiplying with the inverse transformation - // will create a point relative to the 3D scene as unit-2d-object - const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rScene.GetViewContact()); - basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation()); - aInverseSceneTransform.invert(); - const basegfx::B2DPoint aRelativePoint(aInverseSceneTransform * rPoint); + const E3dCompoundObject* pCandidate = dynamic_cast< const E3dCompoundObject* >(aIterator.Next()); - // check if test point is inside scene's area at all - if(aRelativePoint.getX() >= 0.0 && aRelativePoint.getX() <= 1.0 && aRelativePoint.getY() >= 0.0 && aRelativePoint.getY() <= 1.0) + if(pCandidate) { - SdrObjListIter aIterator(pList, SdrIterMode::DeepNoGroups); - ::std::vector< ImplPairDephAndObject > aDepthAndObjectResults; - const uno::Sequence< beans::PropertyValue > aEmptyParameters; - drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters); + fillViewInformation3DForCompoundObject(aViewInfo3D, *pCandidate); + + // create HitPoint Front and Back, transform to object coordinates + basegfx::B3DHomMatrix aViewToObject(aViewInfo3D.getObjectToView()); + aViewToObject.invert(); + const basegfx::B3DPoint aFront(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 0.0)); + const basegfx::B3DPoint aBack(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 1.0)); - while(aIterator.IsMore()) + if(!aFront.equal(aBack)) { - const E3dCompoundObject* pCandidate = dynamic_cast< const E3dCompoundObject* >(aIterator.Next()); + // get all hit points with object + ::std::vector< basegfx::B3DPoint > aHitsWithObject; + getAllHit3DObjectWithRelativePoint(aFront, aBack, *pCandidate, aViewInfo3D, aHitsWithObject, false); - if(pCandidate) + for(const basegfx::B3DPoint & a : aHitsWithObject) { - fillViewInformation3DForCompoundObject(aViewInfo3D, *pCandidate); - - // create HitPoint Front and Back, transform to object coordinates - basegfx::B3DHomMatrix aViewToObject(aViewInfo3D.getObjectToView()); - aViewToObject.invert(); - const basegfx::B3DPoint aFront(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 0.0)); - const basegfx::B3DPoint aBack(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 1.0)); - - if(!aFront.equal(aBack)) - { - // get all hit points with object - ::std::vector< basegfx::B3DPoint > aHitsWithObject; - getAllHit3DObjectWithRelativePoint(aFront, aBack, *pCandidate, aViewInfo3D, aHitsWithObject, false); - - for(const basegfx::B3DPoint & a : aHitsWithObject) - { - const basegfx::B3DPoint aPointInViewCoordinates(aViewInfo3D.getObjectToView() * a); - aDepthAndObjectResults.emplace_back(pCandidate, aPointInViewCoordinates.getZ()); - } - } + const basegfx::B3DPoint aPointInViewCoordinates(aViewInfo3D.getObjectToView() * a); + aDepthAndObjectResults.emplace_back(pCandidate, aPointInViewCoordinates.getZ()); } } + } + } - // fill nRetval - const sal_uInt32 nCount(aDepthAndObjectResults.size()); + // fill nRetval + const sal_uInt32 nCount(aDepthAndObjectResults.size()); - if(nCount) - { - // sort aDepthAndObjectResults by depth - ::std::sort(aDepthAndObjectResults.begin(), aDepthAndObjectResults.end()); + if(nCount) + { + // sort aDepthAndObjectResults by depth + ::std::sort(aDepthAndObjectResults.begin(), aDepthAndObjectResults.end()); - // copy SdrObject pointers to return result set - for(const auto& rResult : aDepthAndObjectResults) - { - o_rResult.push_back(rResult.getObject()); - } - } + // copy SdrObject pointers to return result set + for(const auto& rResult : aDepthAndObjectResults) + { + o_rResult.push_back(rResult.getObject()); } } } diff --git a/svx/source/engine3d/lathe3d.cxx b/svx/source/engine3d/lathe3d.cxx index 37060f96e73a..fbcfe3e44029 100644 --- a/svx/source/engine3d/lathe3d.cxx +++ b/svx/source/engine3d/lathe3d.cxx @@ -133,26 +133,26 @@ SdrObjectUniquePtr E3dLatheObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAdd void E3dLatheObj::SetPolyPoly2D(const basegfx::B2DPolyPolygon& rNew) { - if(maPolyPoly2D != rNew) - { - maPolyPoly2D = rNew; - maPolyPoly2D.removeDoublePoints(); + if(maPolyPoly2D == rNew) + return; - if(maPolyPoly2D.count()) - { - const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0)); - sal_uInt32 nSegCnt(rPoly.count()); + maPolyPoly2D = rNew; + maPolyPoly2D.removeDoublePoints(); - if(nSegCnt && !rPoly.isClosed()) - { - nSegCnt -= 1; - } + if(maPolyPoly2D.count()) + { + const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0)); + sal_uInt32 nSegCnt(rPoly.count()); - GetProperties().SetObjectItemDirect(makeSvx3DVerticalSegmentsItem(nSegCnt)); + if(nSegCnt && !rPoly.isClosed()) + { + nSegCnt -= 1; } - ActionChanged(); + GetProperties().SetObjectItemDirect(makeSvx3DVerticalSegmentsItem(nSegCnt)); } + + ActionChanged(); } // Get the name of the object (singular) diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx index eca597bb4eeb..36b45053f720 100644 --- a/svx/source/engine3d/obj3d.cxx +++ b/svx/source/engine3d/obj3d.cxx @@ -554,40 +554,40 @@ void E3dCompoundObject::RecalcSnapRect() E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this); maSnapRect = tools::Rectangle(); - if(pRootScene) - { - // get VC of 3D candidate - const sdr::contact::ViewContactOfE3d* pVCOfE3D = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&GetViewContact()); + if(!pRootScene) + return; - if(pVCOfE3D) - { - // get 3D primitive sequence - const drawinglayer::primitive3d::Primitive3DContainer xLocalSequence(pVCOfE3D->getViewIndependentPrimitive3DContainer()); + // get VC of 3D candidate + const sdr::contact::ViewContactOfE3d* pVCOfE3D = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&GetViewContact()); - if(!xLocalSequence.empty()) - { - // get BoundVolume - basegfx::B3DRange aBoundVolume(xLocalSequence.getB3DRange(aViewInfo3D)); + if(!pVCOfE3D) + return; - // transform bound volume to relative scene coordinates - aBoundVolume.transform(aViewInfo3D.getObjectToView()); + // get 3D primitive sequence + const drawinglayer::primitive3d::Primitive3DContainer xLocalSequence(pVCOfE3D->getViewIndependentPrimitive3DContainer()); - // build 2d relative scene range - basegfx::B2DRange aSnapRange( - aBoundVolume.getMinX(), aBoundVolume.getMinY(), - aBoundVolume.getMaxX(), aBoundVolume.getMaxY()); + if(xLocalSequence.empty()) + return; - // transform to 2D world coordinates - const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact()); - aSnapRange.transform(rVCScene.getObjectTransformation()); + // get BoundVolume + basegfx::B3DRange aBoundVolume(xLocalSequence.getB3DRange(aViewInfo3D)); - // snap to integer - maSnapRect = tools::Rectangle( - sal_Int32(floor(aSnapRange.getMinX())), sal_Int32(floor(aSnapRange.getMinY())), - sal_Int32(ceil(aSnapRange.getMaxX())), sal_Int32(ceil(aSnapRange.getMaxY()))); - } - } - } + // transform bound volume to relative scene coordinates + aBoundVolume.transform(aViewInfo3D.getObjectToView()); + + // build 2d relative scene range + basegfx::B2DRange aSnapRange( + aBoundVolume.getMinX(), aBoundVolume.getMinY(), + aBoundVolume.getMaxX(), aBoundVolume.getMaxY()); + + // transform to 2D world coordinates + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact()); + aSnapRange.transform(rVCScene.getObjectTransformation()); + + // snap to integer + maSnapRect = tools::Rectangle( + sal_Int32(floor(aSnapRange.getMinX())), sal_Int32(floor(aSnapRange.getMinY())), + sal_Int32(ceil(aSnapRange.getMaxX())), sal_Int32(ceil(aSnapRange.getMaxY()))); } E3dCompoundObject* E3dCompoundObject::CloneSdrObject(SdrModel& rTargetModel) const diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx index 66b13477067e..09a7bbdfa973 100644 --- a/svx/source/engine3d/scene3d.cxx +++ b/svx/source/engine3d/scene3d.cxx @@ -844,23 +844,23 @@ void E3dScene::NbcSetLayer(SdrLayerID nLayer) void E3dScene::handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) { - if(pOldPage != pNewPage) + if(pOldPage == pNewPage) + return; + + // call parent + E3dObject::handlePageChange(pOldPage, pNewPage); + + for(size_t a(0); a < GetObjCount(); a++) { - // call parent - E3dObject::handlePageChange(pOldPage, pNewPage); + E3dObject* pCandidate = dynamic_cast< E3dObject* >(GetObj(a)); - for(size_t a(0); a < GetObjCount(); a++) + if(pCandidate) { - E3dObject* pCandidate = dynamic_cast< E3dObject* >(GetObj(a)); - - if(pCandidate) - { - pCandidate->handlePageChange(pOldPage, pNewPage); - } - else - { - OSL_ENSURE(false, "E3dScene::handlePageChange invalid object list (!)"); - } + pCandidate->handlePageChange(pOldPage, pNewPage); + } + else + { + OSL_ENSURE(false, "E3dScene::handlePageChange invalid object list (!)"); } } } diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx index 77d94ab1c581..78bc1dd15521 100644 --- a/svx/source/engine3d/view3d.cxx +++ b/svx/source/engine3d/view3d.cxx @@ -92,38 +92,38 @@ Impl3DMirrorConstructOverlay::Impl3DMirrorConstructOverlay(const E3dView& rView) mpPolygons(nullptr), maFullOverlay() { - if(mnCount) + if(!mnCount) + return; + + if(mrView.IsSolidDragging()) { - if(mrView.IsSolidDragging()) - { - SdrPageView* pPV = rView.GetSdrPageView(); + SdrPageView* pPV = rView.GetSdrPageView(); - if(pPV && pPV->PageWindowCount()) + if(pPV && pPV->PageWindowCount()) + { + for(size_t a = 0; a < mnCount; ++a) { - for(size_t a = 0; a < mnCount; ++a) - { - SdrObject* pObject = mrView.GetMarkedObjectByIndex(a); + SdrObject* pObject = mrView.GetMarkedObjectByIndex(a); - if(pObject) - { - // use the view-independent primitive representation (without - // evtl. GridOffset, that may be applied to the DragEntry individually) - const drawinglayer::primitive2d::Primitive2DContainer& aNewSequence( - pObject->GetViewContact().getViewIndependentPrimitive2DContainer()); - maFullOverlay.append(aNewSequence); - } + if(pObject) + { + // use the view-independent primitive representation (without + // evtl. GridOffset, that may be applied to the DragEntry individually) + const drawinglayer::primitive2d::Primitive2DContainer& aNewSequence( + pObject->GetViewContact().getViewIndependentPrimitive2DContainer()); + maFullOverlay.append(aNewSequence); } } } - else - { - mpPolygons = new basegfx::B2DPolyPolygon[mnCount]; + } + else + { + mpPolygons = new basegfx::B2DPolyPolygon[mnCount]; - for(size_t a = 0; a < mnCount; ++a) - { - SdrObject* pObject = mrView.GetMarkedObjectByIndex(a); - mpPolygons[mnCount - (a + 1)] = pObject->TakeXorPoly(); - } + for(size_t a = 0; a < mnCount; ++a) + { + SdrObject* pObject = mrView.GetMarkedObjectByIndex(a); + mpPolygons[mnCount - (a + 1)] = pObject->TakeXorPoly(); } } } @@ -613,75 +613,75 @@ bool E3dView::IsConvertTo3DObjPossible() const void E3dView::ImpIsConvertTo3DPossible(SdrObject const * pObj, bool& rAny3D, bool& rGroupSelected) const { - if(pObj) + if(!pObj) + return; + + if(dynamic_cast< const E3dObject* >(pObj) != nullptr) { - if(dynamic_cast< const E3dObject* >(pObj) != nullptr) - { - rAny3D = true; - } - else + rAny3D = true; + } + else + { + if(pObj->IsGroupObject()) { - if(pObj->IsGroupObject()) + SdrObjListIter aIter(*pObj, SdrIterMode::DeepNoGroups); + while(aIter.IsMore()) { - SdrObjListIter aIter(*pObj, SdrIterMode::DeepNoGroups); - while(aIter.IsMore()) - { - SdrObject* pNewObj = aIter.Next(); - ImpIsConvertTo3DPossible(pNewObj, rAny3D, rGroupSelected); - } - rGroupSelected = true; + SdrObject* pNewObj = aIter.Next(); + ImpIsConvertTo3DPossible(pNewObj, rAny3D, rGroupSelected); } + rGroupSelected = true; } } } void E3dView::ImpChangeSomeAttributesFor3DConversion(SdrObject* pObj) { - if(dynamic_cast<const SdrTextObj*>( pObj) != nullptr) - { - const SfxItemSet& rSet = pObj->GetMergedItemSet(); - const SvxColorItem& rTextColorItem = rSet.Get(EE_CHAR_COLOR); - if(rTextColorItem.GetValue() == COL_BLACK) - { - //For black text objects, the color set to gray - if(pObj->getSdrPageFromSdrObject()) - { - // if black is only default attribute from - // pattern set it hard so that it is used in undo. - pObj->SetMergedItem(SvxColorItem(COL_BLACK, EE_CHAR_COLOR)); + if(dynamic_cast<const SdrTextObj*>( pObj) == nullptr) + return; - // add undo now - if( GetModel()->IsUndoEnabled() ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); - } + const SfxItemSet& rSet = pObj->GetMergedItemSet(); + const SvxColorItem& rTextColorItem = rSet.Get(EE_CHAR_COLOR); + if(rTextColorItem.GetValue() != COL_BLACK) + return; - pObj->SetMergedItem(SvxColorItem(COL_GRAY, EE_CHAR_COLOR)); - } + //For black text objects, the color set to gray + if(pObj->getSdrPageFromSdrObject()) + { + // if black is only default attribute from + // pattern set it hard so that it is used in undo. + pObj->SetMergedItem(SvxColorItem(COL_BLACK, EE_CHAR_COLOR)); + + // add undo now + if( GetModel()->IsUndoEnabled() ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); } + + pObj->SetMergedItem(SvxColorItem(COL_GRAY, EE_CHAR_COLOR)); } void E3dView::ImpChangeSomeAttributesFor3DConversion2(SdrObject* pObj) { - if(dynamic_cast<const SdrPathObj*>( pObj) != nullptr) + if(dynamic_cast<const SdrPathObj*>( pObj) == nullptr) + return; + + const SfxItemSet& rSet = pObj->GetMergedItemSet(); + sal_Int32 nLineWidth = rSet.Get(XATTR_LINEWIDTH).GetValue(); + drawing::LineStyle eLineStyle = rSet.Get(XATTR_LINESTYLE).GetValue(); + drawing::FillStyle eFillStyle = rSet.Get(XATTR_FILLSTYLE).GetValue(); + + if(static_cast<SdrPathObj*>(pObj)->IsClosed() + && eLineStyle == drawing::LineStyle_SOLID + && !nLineWidth + && eFillStyle != drawing::FillStyle_NONE) { - const SfxItemSet& rSet = pObj->GetMergedItemSet(); - sal_Int32 nLineWidth = rSet.Get(XATTR_LINEWIDTH).GetValue(); - drawing::LineStyle eLineStyle = rSet.Get(XATTR_LINESTYLE).GetValue(); - drawing::FillStyle eFillStyle = rSet.Get(XATTR_FILLSTYLE).GetValue(); - - if(static_cast<SdrPathObj*>(pObj)->IsClosed() - && eLineStyle == drawing::LineStyle_SOLID - && !nLineWidth - && eFillStyle != drawing::FillStyle_NONE) + if(pObj->getSdrPageFromSdrObject() && GetModel()->IsUndoEnabled() ) { - if(pObj->getSdrPageFromSdrObject() && GetModel()->IsUndoEnabled() ) - { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); - } - - pObj->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE)); - pObj->SetMergedItem(XLineWidthItem(0)); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); } + + pObj->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE)); + pObj->SetMergedItem(XLineWidthItem(0)); } } @@ -690,139 +690,139 @@ void E3dView::ImpCreateSingle3DObjectFlat(E3dScene* pScene, SdrObject* pObj, boo // Single PathObject, transform this SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pObj ); - if(pPath) - { - E3dDefaultAttributes aDefault = Get3DDefaultAttributes(); + if(!pPath) + return; - if(bExtrude) - { - aDefault.SetDefaultExtrudeCharacterMode(true); - } - else - { - aDefault.SetDefaultLatheCharacterMode(true); - } + E3dDefaultAttributes aDefault = Get3DDefaultAttributes(); - // Get Itemset of the original object - SfxItemSet aSet(pObj->GetMergedItemSet()); + if(bExtrude) + { + aDefault.SetDefaultExtrudeCharacterMode(true); + } + else + { + aDefault.SetDefaultLatheCharacterMode(true); + } - drawing::FillStyle eFillStyle = aSet.Get(XATTR_FILLSTYLE).GetValue(); + // Get Itemset of the original object + SfxItemSet aSet(pObj->GetMergedItemSet()); - // line style turned off - aSet.Put(XLineStyleItem(drawing::LineStyle_NONE)); + drawing::FillStyle eFillStyle = aSet.Get(XATTR_FILLSTYLE).GetValue(); - //Determining if FILL_Attribut is set. - if(!pPath->IsClosed() || eFillStyle == drawing::FillStyle_NONE) - { - // This SdrPathObj is not filled, leave the front and rear face out. - // Moreover, a two-sided representation necessary. - aDefault.SetDefaultExtrudeCloseFront(false); - aDefault.SetDefaultExtrudeCloseBack(false); + // line style turned off + aSet.Put(XLineStyleItem(drawing::LineStyle_NONE)); - aSet.Put(makeSvx3DDoubleSidedItem(true)); + //Determining if FILL_Attribut is set. + if(!pPath->IsClosed() || eFillStyle == drawing::FillStyle_NONE) + { + // This SdrPathObj is not filled, leave the front and rear face out. + // Moreover, a two-sided representation necessary. + aDefault.SetDefaultExtrudeCloseFront(false); + aDefault.SetDefaultExtrudeCloseBack(false); - // Set fill attribute - aSet.Put(XFillStyleItem(drawing::FillStyle_SOLID)); + aSet.Put(makeSvx3DDoubleSidedItem(true)); - // Fill color must be the color line, because the object was - // previously just a line - Color aColorLine = aSet.Get(XATTR_LINECOLOR).GetColorValue(); - aSet.Put(XFillColorItem(OUString(), aColorLine)); - } + // Set fill attribute + aSet.Put(XFillStyleItem(drawing::FillStyle_SOLID)); - // Create a new extrude object - E3dObject* p3DObj = nullptr; - if(bExtrude) - { - p3DObj = new E3dExtrudeObj(pObj->getSdrModelFromSdrObject(), aDefault, pPath->GetPathPoly(), fDepth); - } - else - { - // rLatheMat expects coordinates with y-axis up, pPath uses y-axis down - basegfx::B2DHomMatrix aFlipVerticalMat(1.0, 0.0, 0.0, 0.0, -1.0, 0.0); - basegfx::B2DPolyPolygon aPolyPoly2D(pPath->GetPathPoly()); - aPolyPoly2D.transform(aFlipVerticalMat); - aPolyPoly2D.transform(rLatheMat); - // ctor E3dLatheObj expects coordinates with y-axis down - aPolyPoly2D.transform(aFlipVerticalMat); - p3DObj = new E3dLatheObj(pObj->getSdrModelFromSdrObject(), aDefault, aPolyPoly2D); - } + // Fill color must be the color line, because the object was + // previously just a line + Color aColorLine = aSet.Get(XATTR_LINECOLOR).GetColorValue(); + aSet.Put(XFillColorItem(OUString(), aColorLine)); + } + + // Create a new extrude object + E3dObject* p3DObj = nullptr; + if(bExtrude) + { + p3DObj = new E3dExtrudeObj(pObj->getSdrModelFromSdrObject(), aDefault, pPath->GetPathPoly(), fDepth); + } + else + { + // rLatheMat expects coordinates with y-axis up, pPath uses y-axis down + basegfx::B2DHomMatrix aFlipVerticalMat(1.0, 0.0, 0.0, 0.0, -1.0, 0.0); + basegfx::B2DPolyPolygon aPolyPoly2D(pPath->GetPathPoly()); + aPolyPoly2D.transform(aFlipVerticalMat); + aPolyPoly2D.transform(rLatheMat); + // ctor E3dLatheObj expects coordinates with y-axis down + aPolyPoly2D.transform(aFlipVerticalMat); + p3DObj = new E3dLatheObj(pObj->getSdrModelFromSdrObject(), aDefault, aPolyPoly2D); + } - // Set attribute - p3DObj->NbcSetLayer(pObj->GetLayer()); + // Set attribute + p3DObj->NbcSetLayer(pObj->GetLayer()); - p3DObj->SetMergedItemSet(aSet); + p3DObj->SetMergedItemSet(aSet); - p3DObj->NbcSetStyleSheet(pObj->GetStyleSheet(), true); + p3DObj->NbcSetStyleSheet(pObj->GetStyleSheet(), true); - // Insert a new extrude object - pScene->InsertObject(p3DObj); - } + // Insert a new extrude object + pScene->InsertObject(p3DObj); } void E3dView::ImpCreate3DObject(E3dScene* pScene, SdrObject* pObj, bool bExtrude, double fDepth, basegfx::B2DHomMatrix const & rLatheMat) { - if(pObj) + if(!pObj) + return; + + // change text color attribute for not so dark colors + if(pObj->IsGroupObject()) { - // change text color attribute for not so dark colors - if(pObj->IsGroupObject()) + SdrObjListIter aIter(*pObj, SdrIterMode::DeepWithGroups); + while(aIter.IsMore()) { - SdrObjListIter aIter(*pObj, SdrIterMode::DeepWithGroups); - while(aIter.IsMore()) - { - SdrObject* pGroupMember = aIter.Next(); - ImpChangeSomeAttributesFor3DConversion(pGroupMember); - } + SdrObject* pGroupMember = aIter.Next(); + ImpChangeSomeAttributesFor3DConversion(pGroupMember); } - else - ImpChangeSomeAttributesFor3DConversion(pObj); + } + else + ImpChangeSomeAttributesFor3DConversion(pObj); + + // convert completely to path objects + SdrObject* pNewObj1 = pObj->ConvertToPolyObj(false, false).release(); - // convert completely to path objects - SdrObject* pNewObj1 = pObj->ConvertToPolyObj(false, false).release(); + if(!pNewObj1) + return; - if(pNewObj1) + // change text color attribute for not so dark colors + if(pNewObj1->IsGroupObject()) + { + SdrObjListIter aIter(*pNewObj1, SdrIterMode::DeepWithGroups); + while(aIter.IsMore()) { - // change text color attribute for not so dark colors - if(pNewObj1->IsGroupObject()) - { - SdrObjListIter aIter(*pNewObj1, SdrIterMode::DeepWithGroups); - while(aIter.IsMore()) - { - SdrObject* pGroupMember = aIter.Next(); - ImpChangeSomeAttributesFor3DConversion2(pGroupMember); - } - } - else - ImpChangeSomeAttributesFor3DConversion2(pNewObj1); + SdrObject* pGroupMember = aIter.Next(); + ImpChangeSomeAttributesFor3DConversion2(pGroupMember); + } + } + else + ImpChangeSomeAttributesFor3DConversion2(pNewObj1); - // convert completely to path objects - SdrObject* pNewObj2 = pObj->ConvertToContourObj(pNewObj1, true); + // convert completely to path objects + SdrObject* pNewObj2 = pObj->ConvertToContourObj(pNewObj1, true); - if(pNewObj2) + if(pNewObj2) + { + // add all to flat scene + if(pNewObj2->IsGroupObject()) + { + SdrObjListIter aIter(*pNewObj2, SdrIterMode::DeepWithGroups); + while(aIter.IsMore()) { - // add all to flat scene - if(pNewObj2->IsGroupObject()) - { - SdrObjListIter aIter(*pNewObj2, SdrIterMode::DeepWithGroups); - while(aIter.IsMore()) - { - SdrObject* pGroupMember = aIter.Next(); - ImpCreateSingle3DObjectFlat(pScene, pGroupMember, bExtrude, fDepth, rLatheMat); - } - } - else - ImpCreateSingle3DObjectFlat(pScene, pNewObj2, bExtrude, fDepth, rLatheMat); - - // delete object in between - if (pNewObj2 != pObj && pNewObj2 != pNewObj1) - SdrObject::Free( pNewObj2 ); + SdrObject* pGroupMember = aIter.Next(); + ImpCreateSingle3DObjectFlat(pScene, pGroupMember, bExtrude, fDepth, rLatheMat); } - - // delete object in between - if (pNewObj1 != pObj) - SdrObject::Free( pNewObj1 ); } + else + ImpCreateSingle3DObjectFlat(pScene, pNewObj2, bExtrude, fDepth, rLatheMat); + + // delete object in between + if (pNewObj2 != pObj && pNewObj2 != pNewObj1) + SdrObject::Free( pNewObj2 ); } + + // delete object in between + if (pNewObj1 != pObj) + SdrObject::Free( pNewObj1 ); } void E3dView::ConvertMarkedObjTo3D(bool bExtrude, const basegfx::B2DPoint& rPnt1, const basegfx::B2DPoint& rPnt2) @@ -1029,126 +1029,126 @@ struct E3dDepthLayer void E3dView::DoDepthArrange(E3dScene const * pScene, double fDepth) { - if(pScene && pScene->GetSubList() && pScene->GetSubList()->GetObjCount() > 1) + if(!(pScene && pScene->GetSubList() && pScene->GetSubList()->GetObjCount() > 1)) + return; + + SdrObjList* pSubList = pScene->GetSubList(); + SdrObjListIter aIter(pSubList, SdrIterMode::Flat); + E3dDepthLayer* pBaseLayer = nullptr; + E3dDepthLayer* pLayer = nullptr; + sal_Int32 nNumLayers = 0; + + while(aIter.IsMore()) { - SdrObjList* pSubList = pScene->GetSubList(); - SdrObjListIter aIter(pSubList, SdrIterMode::Flat); - E3dDepthLayer* pBaseLayer = nullptr; - E3dDepthLayer* pLayer = nullptr; - sal_Int32 nNumLayers = 0; + E3dExtrudeObj* pExtrudeObj = dynamic_cast< E3dExtrudeObj* >(aIter.Next()); - while(aIter.IsMore()) + if(pExtrudeObj) { - E3dExtrudeObj* pExtrudeObj = dynamic_cast< E3dExtrudeObj* >(aIter.Next()); - - if(pExtrudeObj) + const basegfx::B2DPolyPolygon aExtrudePoly( + basegfx::utils::prepareForPolygonOperation(pExtrudeObj->GetExtrudePolygon())); + const SfxItemSet& rLocalSet = pExtrudeObj->GetMergedItemSet(); + const drawing::FillStyle eLocalFillStyle = rLocalSet.Get(XATTR_FILLSTYLE).GetValue(); + const Color aLocalColor = rLocalSet.Get(XATTR_FILLCOLOR).GetColorValue(); + + // sort in ExtrudeObj + if(pLayer) { - const basegfx::B2DPolyPolygon aExtrudePoly( - basegfx::utils::prepareForPolygonOperation(pExtrudeObj->GetExtrudePolygon())); - const SfxItemSet& rLocalSet = pExtrudeObj->GetMergedItemSet(); - const drawing::FillStyle eLocalFillStyle = rLocalSet.Get(XATTR_FILLSTYLE).GetValue(); - const Color aLocalColor = rLocalSet.Get(XATTR_FILLCOLOR).GetColorValue(); - - // sort in ExtrudeObj - if(pLayer) - { - // do we have overlap with an object of this layer? - bool bOverlap(false); + // do we have overlap with an object of this layer? + bool bOverlap(false); - for(const auto& rAct : pLayer->mvNeighbours) + for(const auto& rAct : pLayer->mvNeighbours) + { + // do rAct.mpObj and pExtrudeObj overlap? Check by + // using logical AND clipping + const basegfx::B2DPolyPolygon aAndPolyPolygon( + basegfx::utils::solvePolygonOperationAnd( + aExtrudePoly, + rAct.maPreparedPolyPolygon)); + + if(aAndPolyPolygon.count() != 0) { - // do rAct.mpObj and pExtrudeObj overlap? Check by - // using logical AND clipping - const basegfx::B2DPolyPolygon aAndPolyPolygon( - basegfx::utils::solvePolygonOperationAnd( - aExtrudePoly, - rAct.maPreparedPolyPolygon)); - - if(aAndPolyPolygon.count() != 0) - { - // second criteria: is another fillstyle or color used? - const SfxItemSet& rCompareSet = rAct.mpObj->GetMergedItemSet(); + // second criteria: is another fillstyle or color used? + const SfxItemSet& rCompareSet = rAct.mpObj->GetMergedItemSet(); - drawing::FillStyle eCompareFillStyle = rCompareSet.Get(XATTR_FILLSTYLE).GetValue(); + drawing::FillStyle eCompareFillStyle = rCompareSet.Get(XATTR_FILLSTYLE).GetValue(); - if(eLocalFillStyle == eCompareFillStyle) + if(eLocalFillStyle == eCompareFillStyle) + { + if(eLocalFillStyle == drawing::FillStyle_SOLID) { - if(eLocalFillStyle == drawing::FillStyle_SOLID) - { - Color aCompareColor = rCompareSet.Get(XATTR_FILLCOLOR).GetColorValue(); + Color aCompareColor = rCompareSet.Get(XATTR_FILLCOLOR).GetColorValue(); - if(aCompareColor == aLocalColor) - { - continue; - } - } - else if(eLocalFillStyle == drawing::FillStyle_NONE) + if(aCompareColor == aLocalColor) { continue; } } - - bOverlap = true; - break; + else if(eLocalFillStyle == drawing::FillStyle_NONE) + { + continue; + } } - } - if(bOverlap) - { - // yes, start a new layer - pLayer->mpDown = new E3dDepthLayer; - pLayer = pLayer->mpDown; - nNumLayers++; - pLayer->mvNeighbours.emplace_back(pExtrudeObj, aExtrudePoly); - } - else - { - // no, add to current layer - pLayer->mvNeighbours.emplace(pLayer->mvNeighbours.begin(), pExtrudeObj, aExtrudePoly); + bOverlap = true; + break; } } - else + + if(bOverlap) { - // first layer ever - pBaseLayer = new E3dDepthLayer; - pLayer = pBaseLayer; + // yes, start a new layer + pLayer->mpDown = new E3dDepthLayer; + pLayer = pLayer->mpDown; nNumLayers++; pLayer->mvNeighbours.emplace_back(pExtrudeObj, aExtrudePoly); } + else + { + // no, add to current layer + pLayer->mvNeighbours.emplace(pLayer->mvNeighbours.begin(), pExtrudeObj, aExtrudePoly); + } + } + else + { + // first layer ever + pBaseLayer = new E3dDepthLayer; + pLayer = pBaseLayer; + nNumLayers++; + pLayer->mvNeighbours.emplace_back(pExtrudeObj, aExtrudePoly); } } + } - // number of layers is done - if(nNumLayers > 1) - { - // need to be arranged - double fMinDepth = fDepth * 0.8; - double fStep = (fDepth - fMinDepth) / static_cast<double>(nNumLayers); - pLayer = pBaseLayer; + // number of layers is done + if(nNumLayers > 1) + { + // need to be arranged + double fMinDepth = fDepth * 0.8; + double fStep = (fDepth - fMinDepth) / static_cast<double>(nNumLayers); + pLayer = pBaseLayer; - while(pLayer) + while(pLayer) + { + // move along layer + for(auto& rAct : pLayer->mvNeighbours) { - // move along layer - for(auto& rAct : pLayer->mvNeighbours) - { - // adapt extrude value - rAct.mpObj->SetMergedItem(SfxUInt32Item(SDRATTR_3DOBJ_DEPTH, sal_uInt32(fMinDepth + 0.5))); - } - - // next layer - pLayer = pLayer->mpDown; - fMinDepth += fStep; + // adapt extrude value + rAct.mpObj->SetMergedItem(SfxUInt32Item(SDRATTR_3DOBJ_DEPTH, sal_uInt32(fMinDepth + 0.5))); } - } - // cleanup - while(pBaseLayer) - { - pLayer = pBaseLayer->mpDown; - delete pBaseLayer; - pBaseLayer = pLayer; + // next layer + pLayer = pLayer->mpDown; + fMinDepth += fStep; } } + + // cleanup + while(pBaseLayer) + { + pLayer = pBaseLayer->mpDown; + delete pBaseLayer; + pBaseLayer = pLayer; + } } // Start drag, create for 3D objects before possibly drag method @@ -1443,35 +1443,35 @@ void E3dView::End3DCreation(bool bUseDefaultValuesForMirrorAxes) { ResetCreationActive(); - if(AreObjectsMarked()) + if(!AreObjectsMarked()) + return; + + if(bUseDefaultValuesForMirrorAxes) { - if(bUseDefaultValuesForMirrorAxes) - { - tools::Rectangle aRect = GetAllMarkedRect(); - if(aRect.GetWidth() <= 1) - aRect.SetSize(Size(500, aRect.GetHeight())); - if(aRect.GetHeight() <= 1) - aRect.SetSize(Size(aRect.GetWidth(), 500)); + tools::Rectangle aRect = GetAllMarkedRect(); + if(aRect.GetWidth() <= 1) + aRect.SetSize(Size(500, aRect.GetHeight())); + if(aRect.GetHeight() <= 1) + aRect.SetSize(Size(aRect.GetWidth(), 500)); - basegfx::B2DPoint aPnt1(aRect.Left(), -aRect.Top()); - basegfx::B2DPoint aPnt2(aRect.Left(), -aRect.Bottom()); + basegfx::B2DPoint aPnt1(aRect.Left(), -aRect.Top()); + basegfx::B2DPoint aPnt2(aRect.Left(), -aRect.Bottom()); - ConvertMarkedObjTo3D(false, aPnt1, aPnt2); - } - else - { - // Turn off helper overlay - // Determine from the handle positions and the displacement of - // the points - const SdrHdlList &aHdlList = GetHdlList(); - Point aMirrorRef1 = aHdlList.GetHdl(SdrHdlKind::Ref1)->GetPos(); - Point aMirrorRef2 = aHdlList.GetHdl(SdrHdlKind::Ref2)->GetPos(); + ConvertMarkedObjTo3D(false, aPnt1, aPnt2); + } + else + { + // Turn off helper overlay + // Determine from the handle positions and the displacement of + // the points + const SdrHdlList &aHdlList = GetHdlList(); + Point aMirrorRef1 = aHdlList.GetHdl(SdrHdlKind::Ref1)->GetPos(); + Point aMirrorRef2 = aHdlList.GetHdl(SdrHdlKind::Ref2)->GetPos(); - basegfx::B2DPoint aPnt1(aMirrorRef1.X(), -aMirrorRef1.Y()); - basegfx::B2DPoint aPnt2(aMirrorRef2.X(), -aMirrorRef2.Y()); + basegfx::B2DPoint aPnt1(aMirrorRef1.X(), -aMirrorRef1.Y()); + basegfx::B2DPoint aPnt2(aMirrorRef2.X(), -aMirrorRef2.Y()); - ConvertMarkedObjTo3D(false, aPnt1, aPnt2); - } + ConvertMarkedObjTo3D(false, aPnt1, aPnt2); } } @@ -1520,20 +1520,20 @@ bool E3dView::IsBreak3DObjPossible() const void E3dView::Break3DObj() { - if(IsBreak3DObjPossible()) - { - // ALL selected objects are changed - const size_t nCount = GetMarkedObjectCount(); + if(!IsBreak3DObjPossible()) + return; - BegUndo(SvxResId(RID_SVX_3D_UNDO_BREAK_LATHE)); - for(size_t a=0; a<nCount; ++a) - { - E3dObject* pObj = static_cast<E3dObject*>(GetMarkedObjectByIndex(a)); - BreakSingle3DObj(pObj); - } - DeleteMarked(); - EndUndo(); + // ALL selected objects are changed + const size_t nCount = GetMarkedObjectCount(); + + BegUndo(SvxResId(RID_SVX_3D_UNDO_BREAK_LATHE)); + for(size_t a=0; a<nCount; ++a) + { + E3dObject* pObj = static_cast<E3dObject*>(GetMarkedObjectByIndex(a)); + BreakSingle3DObj(pObj); } + DeleteMarked(); + EndUndo(); } void E3dView::BreakSingle3DObj(E3dObject* pObj) @@ -1569,31 +1569,31 @@ void E3dView::CheckPossibilities() SdrView::CheckPossibilities(); // Set other flags - if(m_bGroupPossible || m_bUnGroupPossible || m_bGrpEnterPossible) + if(!(m_bGroupPossible || m_bUnGroupPossible || m_bGrpEnterPossible)) + return; + + const size_t nMarkCnt = GetMarkedObjectCount(); + bool bCoumpound = false; + bool b3DObject = false; + for(size_t nObjs = 0; (nObjs < nMarkCnt) && !bCoumpound; ++nObjs) { - const size_t nMarkCnt = GetMarkedObjectCount(); - bool bCoumpound = false; - bool b3DObject = false; - for(size_t nObjs = 0; (nObjs < nMarkCnt) && !bCoumpound; ++nObjs) - { - SdrObject *pObj = GetMarkedObjectByIndex(nObjs); - if(dynamic_cast< const E3dCompoundObject* >(pObj)) - bCoumpound = true; - if(dynamic_cast< const E3dObject* >(pObj)) - b3DObject = true; - } + SdrObject *pObj = GetMarkedObjectByIndex(nObjs); + if(dynamic_cast< const E3dCompoundObject* >(pObj)) + bCoumpound = true; + if(dynamic_cast< const E3dObject* >(pObj)) + b3DObject = true; + } - // So far: there are two or more of any objects selected. See if - // compound objects are involved. If yes, ban grouping. - if(m_bGroupPossible && bCoumpound) - m_bGroupPossible = false; + // So far: there are two or more of any objects selected. See if + // compound objects are involved. If yes, ban grouping. + if(m_bGroupPossible && bCoumpound) + m_bGroupPossible = false; - if(m_bUnGroupPossible && b3DObject) - m_bUnGroupPossible = false; + if(m_bUnGroupPossible && b3DObject) + m_bUnGroupPossible = false; - if(m_bGrpEnterPossible && bCoumpound) - m_bGrpEnterPossible = false; - } + if(m_bGrpEnterPossible && bCoumpound) + m_bGrpEnterPossible = false; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index 340e3b11e36c..767d944a9abe 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -753,22 +753,21 @@ void FmGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMe bAllowHide = bAllowHide && (xCols->getCount()-nHiddenCols > 1); // AND there are at least two visible columns rMenu.EnableItem(rMenu.GetItemId("hide"), bAllowHide); - if (bMarked) + if (!bMarked) + return; + + SfxViewFrame* pCurrentFrame = SfxViewFrame::Current(); + SfxItemState eState = SfxItemState::UNKNOWN; + // ask the bindings of the current view frame (which should be the one we're residing in) for the state + if (pCurrentFrame) { + std::unique_ptr<SfxPoolItem> pItem; + eState = pCurrentFrame->GetBindings().QueryState(SID_FM_CTL_PROPERTIES, pItem); - SfxViewFrame* pCurrentFrame = SfxViewFrame::Current(); - SfxItemState eState = SfxItemState::UNKNOWN; - // ask the bindings of the current view frame (which should be the one we're residing in) for the state - if (pCurrentFrame) + if (eState >= SfxItemState::DEFAULT && pItem != nullptr) { - std::unique_ptr<SfxPoolItem> pItem; - eState = pCurrentFrame->GetBindings().QueryState(SID_FM_CTL_PROPERTIES, pItem); - - if (eState >= SfxItemState::DEFAULT && pItem != nullptr) - { - bool bChecked = dynamic_cast<const SfxBoolItem*>( pItem.get()) != nullptr && static_cast<SfxBoolItem*>(pItem.get())->GetValue(); - rMenu.CheckItem("column", bChecked); - } + bool bChecked = dynamic_cast<const SfxBoolItem*>( pItem.get()) != nullptr && static_cast<SfxBoolItem*>(pItem.get())->GetValue(); + rMenu.CheckItem("column", bChecked); } } } @@ -962,22 +961,22 @@ void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMe SfxViewFrame* pCurrentFrame = SfxViewFrame::Current(); OSL_ENSURE( pCurrentFrame, "FmGridHeader::PostExecuteColumnContextMenu: no view frame -> no bindings -> no property browser!" ); - if ( pCurrentFrame ) + if ( !pCurrentFrame ) + return; + + if ( eInspectorAction == eUpdateInspector ) { - if ( eInspectorAction == eUpdateInspector ) - { - if ( !pCurrentFrame->HasChildWindow( SID_FM_SHOW_PROPERTIES ) ) - eInspectorAction = eNone; - } + if ( !pCurrentFrame->HasChildWindow( SID_FM_SHOW_PROPERTIES ) ) + eInspectorAction = eNone; + } - if ( eInspectorAction != eNone ) - { - SfxBoolItem aShowItem( SID_FM_SHOW_PROPERTIES, eInspectorAction != eCloseInspector ); + if ( eInspectorAction != eNone ) + { + SfxBoolItem aShowItem( SID_FM_SHOW_PROPERTIES, eInspectorAction != eCloseInspector ); - pCurrentFrame->GetBindings().GetDispatcher()->ExecuteList( - SID_FM_SHOW_PROPERTY_BROWSER, SfxCallMode::ASYNCHRON, - { &aShowItem }); - } + pCurrentFrame->GetBindings().GetDispatcher()->ExecuteList( + SID_FM_SHOW_PROPERTY_BROWSER, SfxCallMode::ASYNCHRON, + { &aShowItem }); } } @@ -1071,18 +1070,18 @@ void FmGridControl::propertyChange(const css::beans::PropertyChangeEvent& evt) const DbGridRowRef& xRow = GetCurrentRow(); // no adjustment of the properties is carried out during positioning Reference<XPropertySet> xSet(evt.Source,UNO_QUERY); - if (xRow.is() && (::cppu::any2bool(xSet->getPropertyValue(FM_PROP_ISNEW))|| CompareBookmark(getDataSource()->getBookmark(), xRow->GetBookmark()))) + if (!(xRow.is() && (::cppu::any2bool(xSet->getPropertyValue(FM_PROP_ISNEW))|| CompareBookmark(getDataSource()->getBookmark(), xRow->GetBookmark())))) + return; + + if (evt.PropertyName == FM_PROP_ISMODIFIED) { - if (evt.PropertyName == FM_PROP_ISMODIFIED) + // modified or clean ? + GridRowStatus eStatus = ::comphelper::getBOOL(evt.NewValue) ? GridRowStatus::Modified : GridRowStatus::Clean; + if (eStatus != xRow->GetStatus()) { - // modified or clean ? - GridRowStatus eStatus = ::comphelper::getBOOL(evt.NewValue) ? GridRowStatus::Modified : GridRowStatus::Clean; - if (eStatus != xRow->GetStatus()) - { - xRow->SetStatus(eStatus); - SolarMutexGuard aGuard; - RowModified(GetCurrentPos()); - } + xRow->SetStatus(eStatus); + SolarMutexGuard aGuard; + RowModified(GetCurrentPos()); } } } @@ -1091,32 +1090,32 @@ void FmGridControl::SetDesignMode(bool bMode) { bool bOldMode = IsDesignMode(); DbGridControl::SetDesignMode(bMode); - if (bOldMode != bMode) + if (bOldMode == bMode) + return; + + if (!bMode) { - if (!bMode) - { - // cancel selection - markColumn(USHRT_MAX); - } - else + // cancel selection + markColumn(USHRT_MAX); + } + else + { + Reference< css::container::XIndexContainer > xColumns(GetPeer()->getColumns()); + Reference< css::view::XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY); + if (xSelSupplier.is()) { - Reference< css::container::XIndexContainer > xColumns(GetPeer()->getColumns()); - Reference< css::view::XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY); - if (xSelSupplier.is()) + Any aSelection = xSelSupplier->getSelection(); + Reference< css::beans::XPropertySet > xColumn; + if (aSelection.getValueType().getTypeClass() == TypeClass_INTERFACE) + xColumn.set(aSelection, css::uno::UNO_QUERY); + Reference< XInterface > xCurrent; + for (sal_Int32 i=0; i<xColumns->getCount(); ++i) { - Any aSelection = xSelSupplier->getSelection(); - Reference< css::beans::XPropertySet > xColumn; - if (aSelection.getValueType().getTypeClass() == TypeClass_INTERFACE) - xColumn.set(aSelection, css::uno::UNO_QUERY); - Reference< XInterface > xCurrent; - for (sal_Int32 i=0; i<xColumns->getCount(); ++i) + xCurrent.set(xColumns->getByIndex(i), css::uno::UNO_QUERY); + if (xCurrent == xColumn) { - xCurrent.set(xColumns->getByIndex(i), css::uno::UNO_QUERY); - if (xCurrent == xColumn) - { - markColumn(GetColumnIdFromModelPos(i)); - break; - } + markColumn(GetColumnIdFromModelPos(i)); + break; } } } @@ -1431,23 +1430,23 @@ VclPtr<BrowserHeader> FmGridControl::imp_CreateHeaderBar(BrowseBox* pParent) void FmGridControl::markColumn(sal_uInt16 nId) { - if (GetHeaderBar() && m_nMarkedColumnId != nId) + if (!(GetHeaderBar() && m_nMarkedColumnId != nId)) + return; + + // deselect + if (m_nMarkedColumnId != BROWSER_INVALIDID) { - // deselect - if (m_nMarkedColumnId != BROWSER_INVALIDID) - { - HeaderBarItemBits aBits = GetHeaderBar()->GetItemBits(m_nMarkedColumnId) & ~HeaderBarItemBits::FLAT; - GetHeaderBar()->SetItemBits(m_nMarkedColumnId, aBits); - } + HeaderBarItemBits aBits = GetHeaderBar()->GetItemBits(m_nMarkedColumnId) & ~HeaderBarItemBits::FLAT; + GetHeaderBar()->SetItemBits(m_nMarkedColumnId, aBits); + } - if (nId != BROWSER_INVALIDID) - { - HeaderBarItemBits aBits = GetHeaderBar()->GetItemBits(nId) | HeaderBarItemBits::FLAT; - GetHeaderBar()->SetItemBits(nId, aBits); - } - m_nMarkedColumnId = nId; + if (nId != BROWSER_INVALIDID) + { + HeaderBarItemBits aBits = GetHeaderBar()->GetItemBits(nId) | HeaderBarItemBits::FLAT; + GetHeaderBar()->SetItemBits(nId, aBits); } + m_nMarkedColumnId = nId; } bool FmGridControl::isColumnMarked(sal_uInt16 nId) const @@ -1468,18 +1467,18 @@ void FmGridControl::RowHeightChanged() Reference< XPropertySet > xModel( GetPeer()->getColumns(), UNO_QUERY ); DBG_ASSERT( xModel.is(), "FmGridControl::RowHeightChanged: no model!" ); - if ( xModel.is() ) + if ( !xModel.is() ) + return; + + try { - try - { - sal_Int32 nUnzoomedPixelHeight = CalcReverseZoom( GetDataRowHeight() ); - Any aProperty = makeAny( static_cast<sal_Int32>(PixelToLogic( Point(0, nUnzoomedPixelHeight), MapMode(MapUnit::Map10thMM)).Y()) ); - xModel->setPropertyValue( FM_PROP_ROWHEIGHT, aProperty ); - } - catch( const Exception& ) - { - TOOLS_WARN_EXCEPTION( "svx", "FmGridControl::RowHeightChanged" ); - } + sal_Int32 nUnzoomedPixelHeight = CalcReverseZoom( GetDataRowHeight() ); + Any aProperty = makeAny( static_cast<sal_Int32>(PixelToLogic( Point(0, nUnzoomedPixelHeight), MapMode(MapUnit::Map10thMM)).Y()) ); + xModel->setPropertyValue( FM_PROP_ROWHEIGHT, aProperty ); + } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "svx", "FmGridControl::RowHeightChanged" ); } } @@ -1973,42 +1972,42 @@ void FmGridControl::Select() break; } - if (nSelectedColumn != m_nCurrentSelectedColumn) - { - // BEFORE calling the select at the SelectionSupplier! - m_nCurrentSelectedColumn = nSelectedColumn; + if (nSelectedColumn == m_nCurrentSelectedColumn) + return; - if (!m_bSelecting) - { - m_bSelecting = true; + // BEFORE calling the select at the SelectionSupplier! + m_nCurrentSelectedColumn = nSelectedColumn; - try + if (m_bSelecting) + return; + + m_bSelecting = true; + + try + { + Reference< XIndexAccess > xColumns = GetPeer()->getColumns(); + Reference< XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY); + if (xSelSupplier.is()) + { + if (nSelectedColumn != SAL_MAX_UINT16) { - Reference< XIndexAccess > xColumns = GetPeer()->getColumns(); - Reference< XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY); - if (xSelSupplier.is()) - { - if (nSelectedColumn != SAL_MAX_UINT16) - { - Reference< XPropertySet > xColumn( - xColumns->getByIndex(nSelectedColumn), - css::uno::UNO_QUERY); - xSelSupplier->select(makeAny(xColumn)); - } - else - { - xSelSupplier->select(Any()); - } - } + Reference< XPropertySet > xColumn( + xColumns->getByIndex(nSelectedColumn), + css::uno::UNO_QUERY); + xSelSupplier->select(makeAny(xColumn)); } - catch(Exception&) + else { + xSelSupplier->select(Any()); } - - - m_bSelecting = false; } } + catch(Exception&) + { + } + + + m_bSelecting = false; } diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index ea9a96ea0b27..7fad867309d7 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -459,143 +459,143 @@ void SAL_CALL FmXGridControl::createPeer(const Reference< css::awt::XToolkit >& // TODO: why the hell this whole class does not use any mutex? - if (!getPeer().is()) - { - mbCreatingPeer = true; - // mbCreatingPeer is virtually the same as m_nPeerCreationLevel, but it's the base class' method - // to prevent recursion. + if (getPeer().is()) + return; - vcl::Window* pParentWin = nullptr; - if (rParentPeer.is()) - { - VCLXWindow* pParent = comphelper::getUnoTunnelImplementation<VCLXWindow>(rParentPeer); - if (pParent) - pParentWin = pParent->GetWindow().get(); - } + mbCreatingPeer = true; + // mbCreatingPeer is virtually the same as m_nPeerCreationLevel, but it's the base class' method + // to prevent recursion. + + vcl::Window* pParentWin = nullptr; + if (rParentPeer.is()) + { + VCLXWindow* pParent = comphelper::getUnoTunnelImplementation<VCLXWindow>(rParentPeer); + if (pParent) + pParentWin = pParent->GetWindow().get(); + } - FmXGridPeer* pPeer = imp_CreatePeer(pParentWin); - DBG_ASSERT(pPeer != nullptr, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !"); - setPeer( pPeer ); + FmXGridPeer* pPeer = imp_CreatePeer(pParentWin); + DBG_ASSERT(pPeer != nullptr, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !"); + setPeer( pPeer ); - // reading the properties from the model + // reading the properties from the model // ++m_nPeerCreationLevel; - updateFromModel(); - - // consider the following ugly scenario: updateFromModel leads to a propertiesChanges on the Control, - // which determines, dat a "critical" property has changed (e.g. "Border") and therefore starts a new - // Peer, which lands again here in createPeer we also start a second FmXGridPeer and initialise it. - // Then we exit from the first incarnation's updateFromModel and continue working with the pPeer, - // that is in fact now already obsolete (as another peer is being started in the second incarnation). - // Therefore the effort with the PeerCreationLevel, which ensures that we really use the Peer - // created at the deepest level, but first initialise it in the top-level. + updateFromModel(); + + // consider the following ugly scenario: updateFromModel leads to a propertiesChanges on the Control, + // which determines, dat a "critical" property has changed (e.g. "Border") and therefore starts a new + // Peer, which lands again here in createPeer we also start a second FmXGridPeer and initialise it. + // Then we exit from the first incarnation's updateFromModel and continue working with the pPeer, + // that is in fact now already obsolete (as another peer is being started in the second incarnation). + // Therefore the effort with the PeerCreationLevel, which ensures that we really use the Peer + // created at the deepest level, but first initialise it in the top-level. // if (--m_nPeerCreationLevel == 0) - { - DBG_ASSERT(getPeer().is(), "FmXGridControl::createPeer : something went wrong ... no top level peer !"); - pPeer = comphelper::getUnoTunnelImplementation<FmXGridPeer>(getPeer()); + { + DBG_ASSERT(getPeer().is(), "FmXGridControl::createPeer : something went wrong ... no top level peer !"); + pPeer = comphelper::getUnoTunnelImplementation<FmXGridPeer>(getPeer()); - setPosSize( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight, css::awt::PosSize::POSSIZE ); + setPosSize( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight, css::awt::PosSize::POSSIZE ); - Reference< XIndexContainer > xColumns(getModel(), UNO_QUERY); - if (xColumns.is()) - pPeer->setColumns(xColumns); + Reference< XIndexContainer > xColumns(getModel(), UNO_QUERY); + if (xColumns.is()) + pPeer->setColumns(xColumns); - if (maComponentInfos.bVisible) - pPeer->setVisible(true); + if (maComponentInfos.bVisible) + pPeer->setVisible(true); - if (!maComponentInfos.bEnable) - pPeer->setEnable(false); + if (!maComponentInfos.bEnable) + pPeer->setEnable(false); - if (maWindowListeners.getLength()) - pPeer->addWindowListener( &maWindowListeners ); + if (maWindowListeners.getLength()) + pPeer->addWindowListener( &maWindowListeners ); - if (maFocusListeners.getLength()) - pPeer->addFocusListener( &maFocusListeners ); + if (maFocusListeners.getLength()) + pPeer->addFocusListener( &maFocusListeners ); - if (maKeyListeners.getLength()) - pPeer->addKeyListener( &maKeyListeners ); + if (maKeyListeners.getLength()) + pPeer->addKeyListener( &maKeyListeners ); - if (maMouseListeners.getLength()) - pPeer->addMouseListener( &maMouseListeners ); + if (maMouseListeners.getLength()) + pPeer->addMouseListener( &maMouseListeners ); - if (maMouseMotionListeners.getLength()) - pPeer->addMouseMotionListener( &maMouseMotionListeners ); + if (maMouseMotionListeners.getLength()) + pPeer->addMouseMotionListener( &maMouseMotionListeners ); - if (maPaintListeners.getLength()) - pPeer->addPaintListener( &maPaintListeners ); + if (maPaintListeners.getLength()) + pPeer->addPaintListener( &maPaintListeners ); - if (m_aModifyListeners.getLength()) - pPeer->addModifyListener( &m_aModifyListeners ); + if (m_aModifyListeners.getLength()) + pPeer->addModifyListener( &m_aModifyListeners ); - if (m_aUpdateListeners.getLength()) - pPeer->addUpdateListener( &m_aUpdateListeners ); + if (m_aUpdateListeners.getLength()) + pPeer->addUpdateListener( &m_aUpdateListeners ); - if (m_aContainerListeners.getLength()) - pPeer->addContainerListener( &m_aContainerListeners ); + if (m_aContainerListeners.getLength()) + pPeer->addContainerListener( &m_aContainerListeners ); - // forward the design mode - bool bForceAlivePeer = m_bInDraw && !maComponentInfos.bVisible; - // (we force an alive-mode peer if we're in "draw", cause in this case the peer will be used for drawing in - // foreign devices. We ensure this with the visibility check as a living peer is assumed to be noncritical - // only if invisible) - Any aOldCursorBookmark; - if (!mbDesignMode || bForceAlivePeer) + // forward the design mode + bool bForceAlivePeer = m_bInDraw && !maComponentInfos.bVisible; + // (we force an alive-mode peer if we're in "draw", cause in this case the peer will be used for drawing in + // foreign devices. We ensure this with the visibility check as a living peer is assumed to be noncritical + // only if invisible) + Any aOldCursorBookmark; + if (!mbDesignMode || bForceAlivePeer) + { + Reference< XFormComponent > xComp(getModel(), UNO_QUERY); + if (xComp.is()) { - Reference< XFormComponent > xComp(getModel(), UNO_QUERY); - if (xComp.is()) + Reference< XRowSet > xForm(xComp->getParent(), UNO_QUERY); + // is the form alive? + // we can see that if the form contains columns + Reference< css::sdbcx::XColumnsSupplier > xColumnsSupplier(xForm, UNO_QUERY); + if (xColumnsSupplier.is()) { - Reference< XRowSet > xForm(xComp->getParent(), UNO_QUERY); - // is the form alive? - // we can see that if the form contains columns - Reference< css::sdbcx::XColumnsSupplier > xColumnsSupplier(xForm, UNO_QUERY); - if (xColumnsSupplier.is()) + if (Reference< XIndexAccess > (xColumnsSupplier->getColumns(),UNO_QUERY_THROW)->getCount()) { - if (Reference< XIndexAccess > (xColumnsSupplier->getColumns(),UNO_QUERY_THROW)->getCount()) + // we get only a new bookmark if the resultset is not forwardonly + if (::comphelper::getINT32(Reference< XPropertySet > (xForm, UNO_QUERY_THROW)->getPropertyValue(FM_PROP_RESULTSET_TYPE)) != ResultSetType::FORWARD_ONLY) { - // we get only a new bookmark if the resultset is not forwardonly - if (::comphelper::getINT32(Reference< XPropertySet > (xForm, UNO_QUERY_THROW)->getPropertyValue(FM_PROP_RESULTSET_TYPE)) != ResultSetType::FORWARD_ONLY) + // as the FmGridControl touches the data source it is connected to we have to remember the current + // cursor position (and restore afterwards) + // OJ: but only when we stand on a valid row + if ( !xForm->isBeforeFirst() && !xForm->isAfterLast() ) { - // as the FmGridControl touches the data source it is connected to we have to remember the current - // cursor position (and restore afterwards) - // OJ: but only when we stand on a valid row - if ( !xForm->isBeforeFirst() && !xForm->isAfterLast() ) + try + { + aOldCursorBookmark = Reference< css::sdbcx::XRowLocate > (xForm, UNO_QUERY_THROW)->getBookmark(); + } + catch( const Exception& ) { - try - { - aOldCursorBookmark = Reference< css::sdbcx::XRowLocate > (xForm, UNO_QUERY_THROW)->getBookmark(); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("svx"); - } + DBG_UNHANDLED_EXCEPTION("svx"); } } } } - pPeer->setRowSet(xForm); } + pPeer->setRowSet(xForm); } - pPeer->setDesignMode(mbDesignMode && !bForceAlivePeer); + } + pPeer->setDesignMode(mbDesignMode && !bForceAlivePeer); - try - { - if (aOldCursorBookmark.hasValue()) - { // we have a valid bookmark, so we have to restore the cursor's position - Reference< XFormComponent > xComp(getModel(), UNO_QUERY); - Reference< css::sdbcx::XRowLocate > xLocate(xComp->getParent(), UNO_QUERY); - xLocate->moveToBookmark(aOldCursorBookmark); - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("svx"); + try + { + if (aOldCursorBookmark.hasValue()) + { // we have a valid bookmark, so we have to restore the cursor's position + Reference< XFormComponent > xComp(getModel(), UNO_QUERY); + Reference< css::sdbcx::XRowLocate > xLocate(xComp->getParent(), UNO_QUERY); + xLocate->moveToBookmark(aOldCursorBookmark); } - - Reference< css::awt::XView > xPeerView(getPeer(), UNO_QUERY); - xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY ); - xPeerView->setGraphics( mxGraphics ); } - mbCreatingPeer = false; + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("svx"); + } + + Reference< css::awt::XView > xPeerView(getPeer(), UNO_QUERY); + xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY ); + xPeerView->setGraphics( mxGraphics ); } + mbCreatingPeer = false; } @@ -2102,21 +2102,21 @@ void FmXGridPeer::startCursorListening() void FmXGridPeer::stopCursorListening() { - if (!--m_nCursorListening) - { - if (m_xCursor.is()) - m_xCursor->removeRowSetListener(this); + if (--m_nCursorListening) + return; - Reference< XReset > xReset(m_xCursor, UNO_QUERY); - if (xReset.is()) - xReset->removeResetListener(this); + if (m_xCursor.is()) + m_xCursor->removeRowSetListener(this); - Reference< XPropertySet > xSet(m_xCursor, UNO_QUERY); - if (xSet.is()) - { - xSet->removePropertyChangeListener(FM_PROP_ISMODIFIED, this); - xSet->removePropertyChangeListener(FM_PROP_ROWCOUNT, this); - } + Reference< XReset > xReset(m_xCursor, UNO_QUERY); + if (xReset.is()) + xReset->removeResetListener(this); + + Reference< XPropertySet > xSet(m_xCursor, UNO_QUERY); + if (xSet.is()) + { + xSet->removePropertyChangeListener(FM_PROP_ISMODIFIED, this); + xSet->removePropertyChangeListener(FM_PROP_ROWCOUNT, this); } } @@ -2154,20 +2154,20 @@ void FmXGridPeer::setRowSet(const Reference< XRowSet >& _rDatabaseCursor) m_xCursor = _rDatabaseCursor; - if (pGrid) - { - Reference< XLoadable > xLoadable(m_xCursor, UNO_QUERY); - // only if the form is loaded we set the rowset - if (xLoadable.is() && xLoadable->isLoaded()) - pGrid->setDataSource(m_xCursor); - else - pGrid->setDataSource(Reference< XRowSet > ()); + if (!pGrid) + return; - if (xLoadable.is()) - { - startCursorListening(); - xLoadable->addLoadListener(this); - } + Reference< XLoadable > xLoadable(m_xCursor, UNO_QUERY); + // only if the form is loaded we set the rowset + if (xLoadable.is() && xLoadable->isLoaded()) + pGrid->setDataSource(m_xCursor); + else + pGrid->setDataSource(Reference< XRowSet > ()); + + if (xLoadable.is()) + { + startCursorListening(); + xLoadable->addLoadListener(this); } } @@ -2204,46 +2204,46 @@ void FmXGridPeer::selectionChanged(const EventObject& evt) SolarMutexGuard aGuard; VclPtr< FmGridControl > pGrid = GetAs< FmGridControl >(); - if (pGrid) + if (!pGrid) + return; + + Reference< css::view::XSelectionSupplier > xSelSupplier(evt.Source, UNO_QUERY); + Any aSelection = xSelSupplier->getSelection(); + DBG_ASSERT(aSelection.getValueType().getTypeClass() == TypeClass_INTERFACE, "FmXGridPeer::selectionChanged : invalid selection !"); + Reference< XPropertySet > xSelection; + aSelection >>= xSelection; + if (xSelection.is()) { - Reference< css::view::XSelectionSupplier > xSelSupplier(evt.Source, UNO_QUERY); - Any aSelection = xSelSupplier->getSelection(); - DBG_ASSERT(aSelection.getValueType().getTypeClass() == TypeClass_INTERFACE, "FmXGridPeer::selectionChanged : invalid selection !"); - Reference< XPropertySet > xSelection; - aSelection >>= xSelection; - if (xSelection.is()) - { - Reference< XPropertySet > xCol; - sal_Int32 i = 0; - sal_Int32 nColCount = m_xColumns->getCount(); + Reference< XPropertySet > xCol; + sal_Int32 i = 0; + sal_Int32 nColCount = m_xColumns->getCount(); - for (; i < nColCount; ++i) + for (; i < nColCount; ++i) + { + m_xColumns->getByIndex(i) >>= xCol; + if ( xCol == xSelection ) { - m_xColumns->getByIndex(i) >>= xCol; - if ( xCol == xSelection ) - { - pGrid->markColumn(pGrid->GetColumnIdFromModelPos(static_cast<sal_uInt16>(i))); - break; - } + pGrid->markColumn(pGrid->GetColumnIdFromModelPos(static_cast<sal_uInt16>(i))); + break; } - // The columns have to be 1-based for the VCL control. - // If necessary, pass on the selection to the VCL control - if ( i != pGrid->GetSelectedColumn() ) - { // (if this does not take effect, the selectionChanged was implicitly triggered by the control itself) - if ( i < nColCount ) - { - pGrid->SelectColumnPos(pGrid->GetViewColumnPos(pGrid->GetColumnIdFromModelPos( static_cast<sal_uInt16>(i) )) + 1); - // SelectColumnPos has led to an implicit ActivateCell again - if (pGrid->IsEditing()) - pGrid->DeactivateCell(); - } - else - pGrid->SetNoSelection(); + } + // The columns have to be 1-based for the VCL control. + // If necessary, pass on the selection to the VCL control + if ( i != pGrid->GetSelectedColumn() ) + { // (if this does not take effect, the selectionChanged was implicitly triggered by the control itself) + if ( i < nColCount ) + { + pGrid->SelectColumnPos(pGrid->GetViewColumnPos(pGrid->GetColumnIdFromModelPos( static_cast<sal_uInt16>(i) )) + 1); + // SelectColumnPos has led to an implicit ActivateCell again + if (pGrid->IsEditing()) + pGrid->DeactivateCell(); } + else + pGrid->SetNoSelection(); } - else - pGrid->markColumn(USHRT_MAX); } + else + pGrid->markColumn(USHRT_MAX); } // XElementAccess @@ -2421,29 +2421,29 @@ Sequence< Reference< css::frame::XDispatch > > FmXGridPeer::queryDispatches(cons void FmXGridPeer::registerDispatchProviderInterceptor(const Reference< css::frame::XDispatchProviderInterceptor >& _xInterceptor) { - if (_xInterceptor.is()) + if (!_xInterceptor.is()) + return; + + if (m_xFirstDispatchInterceptor.is()) { - if (m_xFirstDispatchInterceptor.is()) - { - // there is already an interceptor; the new one will become its master - _xInterceptor->setSlaveDispatchProvider(m_xFirstDispatchInterceptor); - m_xFirstDispatchInterceptor->setMasterDispatchProvider(m_xFirstDispatchInterceptor); - } - else - { - // it is the first interceptor; set ourself as slave - _xInterceptor->setSlaveDispatchProvider(static_cast<css::frame::XDispatchProvider*>(this)); - } + // there is already an interceptor; the new one will become its master + _xInterceptor->setSlaveDispatchProvider(m_xFirstDispatchInterceptor); + m_xFirstDispatchInterceptor->setMasterDispatchProvider(m_xFirstDispatchInterceptor); + } + else + { + // it is the first interceptor; set ourself as slave + _xInterceptor->setSlaveDispatchProvider(static_cast<css::frame::XDispatchProvider*>(this)); + } - // we are the master of the chain's first interceptor - m_xFirstDispatchInterceptor = _xInterceptor; - m_xFirstDispatchInterceptor->setMasterDispatchProvider(static_cast<css::frame::XDispatchProvider*>(this)); + // we are the master of the chain's first interceptor + m_xFirstDispatchInterceptor = _xInterceptor; + m_xFirstDispatchInterceptor->setMasterDispatchProvider(static_cast<css::frame::XDispatchProvider*>(this)); - // we have a new interceptor and we're alive ? - if (!isDesignMode()) - // -> check for new dispatchers - UpdateDispatches(); - } + // we have a new interceptor and we're alive ? + if (!isDesignMode()) + // -> check for new dispatchers + UpdateDispatches(); } diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index c325b519ed4f..ee688865530a 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -753,44 +753,44 @@ void DbCellControl::ImplInitWindow( vcl::Window const & rParent, const InitWindo } } - if (_eInitWhat & InitWindowFacet::Background) + if (!(_eInitWhat & InitWindowFacet::Background)) + return; + + if (rParent.IsControlBackground()) { - if (rParent.IsControlBackground()) + Color aColor(rParent.GetControlBackground()); + for (vcl::Window* pWindow : pWindows) { - Color aColor(rParent.GetControlBackground()); - for (vcl::Window* pWindow : pWindows) + if (pWindow) { - if (pWindow) + if (isTransparent()) + pWindow->SetBackground(); + else { - if (isTransparent()) - pWindow->SetBackground(); - else - { - pWindow->SetBackground(aColor); - pWindow->SetControlBackground(aColor); - } - pWindow->SetFillColor(aColor); + pWindow->SetBackground(aColor); + pWindow->SetControlBackground(aColor); } + pWindow->SetFillColor(aColor); } } - else + } + else + { + if (m_pPainter) { - if (m_pPainter) - { - if (isTransparent()) - m_pPainter->SetBackground(); - else - m_pPainter->SetBackground(rParent.GetBackground()); - m_pPainter->SetFillColor(rParent.GetFillColor()); - } + if (isTransparent()) + m_pPainter->SetBackground(); + else + m_pPainter->SetBackground(rParent.GetBackground()); + m_pPainter->SetFillColor(rParent.GetFillColor()); + } - if (m_pWindow) - { - if (isTransparent()) - m_pWindow->SetBackground(rParent.GetBackground()); - else - m_pWindow->SetFillColor(rParent.GetFillColor()); - } + if (m_pWindow) + { + if (isTransparent()) + m_pWindow->SetBackground(rParent.GetBackground()); + else + m_pWindow->SetFillColor(rParent.GetFillColor()); } } } @@ -799,18 +799,18 @@ void DbCellControl::implAdjustReadOnly( const Reference< XPropertySet >& _rxMode { DBG_ASSERT( m_pWindow, "DbCellControl::implAdjustReadOnly: not to be called without window!" ); DBG_ASSERT( _rxModel.is(), "DbCellControl::implAdjustReadOnly: invalid model!" ); - if ( m_pWindow && _rxModel.is() ) + if ( !(m_pWindow && _rxModel.is()) ) + return; + + ControlBase* pEditWindow = dynamic_cast<ControlBase*>(m_pWindow.get()); + if ( pEditWindow ) { - ControlBase* pEditWindow = dynamic_cast<ControlBase*>(m_pWindow.get()); - if ( pEditWindow ) + bool bReadOnly = m_rColumn.IsReadOnly(); + if ( !bReadOnly ) { - bool bReadOnly = m_rColumn.IsReadOnly(); - if ( !bReadOnly ) - { - _rxModel->getPropertyValue( i_bReadOnly ? OUString(FM_PROP_READONLY) : OUString(FM_PROP_ISREADONLY)) >>= bReadOnly; - } - pEditWindow->SetEditableReadOnly(bReadOnly); + _rxModel->getPropertyValue( i_bReadOnly ? OUString(FM_PROP_READONLY) : OUString(FM_PROP_ISREADONLY)) >>= bReadOnly; } + pEditWindow->SetEditableReadOnly(bReadOnly); } } @@ -2492,19 +2492,19 @@ void DbListBox::SetList(const Any& rItems) m_bBound = false; css::uno::Sequence<OUString> aTest; - if (rItems >>= aTest) + if (!(rItems >>= aTest)) + return; + + if (aTest.hasElements()) { - if (aTest.hasElements()) - { - for (const OUString& rString : std::as_const(aTest)) - rFieldList.append_text(rString); + for (const OUString& rString : std::as_const(aTest)) + rFieldList.append_text(rString); - m_rColumn.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ) >>= m_aValueList; - m_bBound = m_aValueList.hasElements(); + m_rColumn.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ) >>= m_aValueList; + m_bBound = m_aValueList.hasElements(); - // tell the grid control that this controller is invalid and has to be re-initialized - invalidatedController(); - } + // tell the grid control that this controller is invalid and has to be re-initialized + invalidatedController(); } } @@ -2649,24 +2649,24 @@ void DbFilterField::SetList(const Any& rItems, bool bComboBox) { css::uno::Sequence<OUString> aTest; rItems >>= aTest; - if (aTest.hasElements()) + if (!aTest.hasElements()) + return; + + if (bComboBox) { - if (bComboBox) - { - ComboBoxControl* pField = static_cast<ComboBoxControl*>(m_pWindow.get()); - weld::ComboBox& rComboBox = pField->get_widget(); - for (const OUString& rString : std::as_const(aTest)) - rComboBox.append_text(rString); - } - else - { - ListBoxControl* pField = static_cast<ListBoxControl*>(m_pWindow.get()); - weld::ComboBox& rFieldBox = pField->get_widget(); - for (const OUString& rString : std::as_const(aTest)) - rFieldBox.append_text(rString); + ComboBoxControl* pField = static_cast<ComboBoxControl*>(m_pWindow.get()); + weld::ComboBox& rComboBox = pField->get_widget(); + for (const OUString& rString : std::as_const(aTest)) + rComboBox.append_text(rString); + } + else + { + ListBoxControl* pField = static_cast<ListBoxControl*>(m_pWindow.get()); + weld::ComboBox& rFieldBox = pField->get_widget(); + for (const OUString& rString : std::as_const(aTest)) + rFieldBox.append_text(rString); - m_rColumn.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ) >>= m_aValueList; - } + m_rColumn.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ) >>= m_aValueList; } } diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index 7ad0d355419e..fe556acde87c 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -104,20 +104,20 @@ private: } virtual void SAL_CALL rowsChanged(const css::sdb::RowsChangeEvent& i_aEvt) override { - if ( i_aEvt.Action == RowChangeAction::UPDATE ) + if ( i_aEvt.Action != RowChangeAction::UPDATE ) + return; + + ::DbGridControl::GrantControlAccess aAccess; + CursorWrapper* pSeek = m_pControl->GetSeekCursor(aAccess); + const DbGridRowRef& rSeekRow = m_pControl->GetSeekRow(aAccess); + for(const Any& rBookmark : i_aEvt.Bookmarks) { - ::DbGridControl::GrantControlAccess aAccess; - CursorWrapper* pSeek = m_pControl->GetSeekCursor(aAccess); - const DbGridRowRef& rSeekRow = m_pControl->GetSeekRow(aAccess); - for(const Any& rBookmark : i_aEvt.Bookmarks) - { - pSeek->moveToBookmark(rBookmark); - // get the data - rSeekRow->SetState(pSeek, true); - sal_Int32 nSeekPos = pSeek->getRow() - 1; - m_pControl->SetSeekPos(nSeekPos,aAccess); - m_pControl->RowModified(nSeekPos); - } + pSeek->moveToBookmark(rBookmark); + // get the data + rSeekRow->SetState(pSeek, true); + sal_Int32 nSeekPos = pSeek->getRow() - 1; + m_pControl->SetSeekPos(nSeekPos,aAccess); + m_pControl->RowModified(nSeekPos); } } }; @@ -467,31 +467,31 @@ IMPL_LINK(NavigationBar, OnClick, weld::Button&, rButton, void) void NavigationBar::InvalidateAll(sal_Int32 nCurrentPos, bool bAll) { - if (m_nCurrentPos != nCurrentPos || nCurrentPos < 0 || bAll) - { - DbGridControl* pParent = static_cast<DbGridControl*>(GetParent()); + if (!(m_nCurrentPos != nCurrentPos || nCurrentPos < 0 || bAll)) + return; - sal_Int32 nAdjustedRowCount = pParent->GetRowCount() - ((pParent->GetOptions() & DbGridControlOptions::Insert) ? 2 : 1); + DbGridControl* pParent = static_cast<DbGridControl*>(GetParent()); - // check if everything needs to be invalidated - bAll = bAll || m_nCurrentPos <= 0; - bAll = bAll || nCurrentPos <= 0; - bAll = bAll || m_nCurrentPos >= nAdjustedRowCount; - bAll = bAll || nCurrentPos >= nAdjustedRowCount; + sal_Int32 nAdjustedRowCount = pParent->GetRowCount() - ((pParent->GetOptions() & DbGridControlOptions::Insert) ? 2 : 1); - if ( bAll ) - { - m_nCurrentPos = nCurrentPos; - int i = 0; - while (ControlMap[i] != DbGridControlNavigationBarState::NONE) - SetState(ControlMap[i++]); - } - else // is in the center - { - m_nCurrentPos = nCurrentPos; - SetState(DbGridControlNavigationBarState::Count); - SetState(DbGridControlNavigationBarState::Absolute); - } + // check if everything needs to be invalidated + bAll = bAll || m_nCurrentPos <= 0; + bAll = bAll || nCurrentPos <= 0; + bAll = bAll || m_nCurrentPos >= nAdjustedRowCount; + bAll = bAll || nCurrentPos >= nAdjustedRowCount; + + if ( bAll ) + { + m_nCurrentPos = nCurrentPos; + int i = 0; + while (ControlMap[i] != DbGridControlNavigationBarState::NONE) + SetState(ControlMap[i++]); + } + else // is in the center + { + m_nCurrentPos = nCurrentPos; + SetState(DbGridControlNavigationBarState::Count); + SetState(DbGridControlNavigationBarState::Absolute); } } @@ -621,20 +621,20 @@ void NavigationBar::SetState(DbGridControlNavigationBarState nWhich) default: break; } DBG_ASSERT(pWnd, "no window"); - if (pWnd && (pWnd->get_sensitive() != bAvailable)) + if (!(pWnd && (pWnd->get_sensitive() != bAvailable))) + return; + + // this "pWnd->IsEnabled() != bAvailable" is a little hack : Window::Enable always generates a user + // event (ImplGenerateMouseMove) even if nothing happened. This may lead to some unwanted effects, so we + // do this check. + // For further explanation see Bug 69900. + pWnd->set_sensitive(bAvailable); + if (!bAvailable) { - // this "pWnd->IsEnabled() != bAvailable" is a little hack : Window::Enable always generates a user - // event (ImplGenerateMouseMove) even if nothing happened. This may lead to some unwanted effects, so we - // do this check. - // For further explanation see Bug 69900. - pWnd->set_sensitive(bAvailable); - if (!bAvailable) - { - if (pWnd == m_xNextBtn.get()) - m_aNextRepeat.Stop(); - else if (pWnd == m_xPrevBtn.get()) - m_aPrevRepeat.Stop(); - } + if (pWnd == m_xNextBtn.get()) + m_aNextRepeat.Stop(); + else if (pWnd == m_xPrevBtn.get()) + m_aPrevRepeat.Stop(); } } @@ -925,19 +925,19 @@ void DbGridControl::ImplInitWindow( const InitWindowFacet _eInitWhat ) } } - if ( _eInitWhat & InitWindowFacet::Background ) + if ( !(_eInitWhat & InitWindowFacet::Background) ) + return; + + if (IsControlBackground()) { - if (IsControlBackground()) - { - GetDataWindow().SetBackground(GetControlBackground()); - GetDataWindow().SetControlBackground(GetControlBackground()); - GetDataWindow().SetFillColor(GetControlBackground()); - } - else - { - GetDataWindow().SetControlBackground(); - GetDataWindow().SetFillColor(GetFillColor()); - } + GetDataWindow().SetBackground(GetControlBackground()); + GetDataWindow().SetControlBackground(GetControlBackground()); + GetDataWindow().SetFillColor(GetControlBackground()); + } + else + { + GetDataWindow().SetControlBackground(); + GetDataWindow().SetFillColor(GetFillColor()); } } @@ -1686,41 +1686,41 @@ void DbGridControl::RecalcRows(long nNewTopRow, sal_uInt16 nLinesOnScreen, bool void DbGridControl::RowInserted(long nRow, long nNumRows, bool bDoPaint) { - if (nNumRows) - { - if (m_bRecordCountFinal && m_nTotalCount < 0) - { - // if we have an insert row we have to reduce to count by 1 - // as the total count reflects only the existing rows in database - m_nTotalCount = GetRowCount() + nNumRows; - if (m_xEmptyRow.is()) - --m_nTotalCount; - } - else if (m_nTotalCount >= 0) - m_nTotalCount += nNumRows; + if (!nNumRows) + return; - EditBrowseBox::RowInserted(nRow, nNumRows, bDoPaint); - m_aBar->InvalidateState(DbGridControlNavigationBarState::Count); + if (m_bRecordCountFinal && m_nTotalCount < 0) + { + // if we have an insert row we have to reduce to count by 1 + // as the total count reflects only the existing rows in database + m_nTotalCount = GetRowCount() + nNumRows; + if (m_xEmptyRow.is()) + --m_nTotalCount; } + else if (m_nTotalCount >= 0) + m_nTotalCount += nNumRows; + + EditBrowseBox::RowInserted(nRow, nNumRows, bDoPaint); + m_aBar->InvalidateState(DbGridControlNavigationBarState::Count); } void DbGridControl::RowRemoved(long nRow, long nNumRows, bool bDoPaint) { - if (nNumRows) - { - if (m_bRecordCountFinal && m_nTotalCount < 0) - { - m_nTotalCount = GetRowCount() - nNumRows; - // if we have an insert row reduce by 1 - if (m_xEmptyRow.is()) - --m_nTotalCount; - } - else if (m_nTotalCount >= 0) - m_nTotalCount -= nNumRows; + if (!nNumRows) + return; - EditBrowseBox::RowRemoved(nRow, nNumRows, bDoPaint); - m_aBar->InvalidateState(DbGridControlNavigationBarState::Count); + if (m_bRecordCountFinal && m_nTotalCount < 0) + { + m_nTotalCount = GetRowCount() - nNumRows; + // if we have an insert row reduce by 1 + if (m_xEmptyRow.is()) + --m_nTotalCount; } + else if (m_nTotalCount >= 0) + m_nTotalCount -= nNumRows; + + EditBrowseBox::RowRemoved(nRow, nNumRows, bDoPaint); + m_aBar->InvalidateState(DbGridControlNavigationBarState::Count); } void DbGridControl::AdjustRows() @@ -2373,63 +2373,63 @@ void DbGridControl::AppendNew() void DbGridControl::SetDesignMode(bool bMode) { - if (IsDesignMode() != bMode) + if (IsDesignMode() == bMode) + return; + + // adjust Enable/Disable for design mode so that the headerbar remains configurable + if (bMode) { - // adjust Enable/Disable for design mode so that the headerbar remains configurable - if (bMode) - { - if (!IsEnabled()) - { - Enable(); - GetDataWindow().Disable(); - } - } - else + if (!IsEnabled()) { - // disable completely - if (!GetDataWindow().IsEnabled()) - Disable(); + Enable(); + GetDataWindow().Disable(); } + } + else + { + // disable completely + if (!GetDataWindow().IsEnabled()) + Disable(); + } - m_bDesignMode = bMode; - GetDataWindow().SetMouseTransparent(bMode); - SetMouseTransparent(bMode); + m_bDesignMode = bMode; + GetDataWindow().SetMouseTransparent(bMode); + SetMouseTransparent(bMode); - m_aBar->InvalidateAll(m_nCurrentPos, true); - } + m_aBar->InvalidateAll(m_nCurrentPos, true); } void DbGridControl::SetFilterMode(bool bMode) { - if (IsFilterMode() != bMode) - { - m_bFilterMode = bMode; + if (IsFilterMode() == bMode) + return; - if (bMode) - { - SetUpdateMode(false); + m_bFilterMode = bMode; - // there is no cursor anymore - if (IsEditing()) - DeactivateCell(); - RemoveRows(false); + if (bMode) + { + SetUpdateMode(false); - m_xEmptyRow = new DbGridRow(); + // there is no cursor anymore + if (IsEditing()) + DeactivateCell(); + RemoveRows(false); - // setting the new filter controls - for (auto const & pCurCol : m_aColumns) - { - if (!pCurCol->IsHidden()) - pCurCol->UpdateControl(); - } + m_xEmptyRow = new DbGridRow(); - // one row for filtering - RowInserted(0); - SetUpdateMode(true); + // setting the new filter controls + for (auto const & pCurCol : m_aColumns) + { + if (!pCurCol->IsHidden()) + pCurCol->UpdateControl(); } - else - setDataSource(Reference< XRowSet > ()); + + // one row for filtering + RowInserted(0); + SetUpdateMode(true); } + else + setDataSource(Reference< XRowSet > ()); } OUString DbGridControl::GetCellText(long _nRow, sal_uInt16 _nColId) const @@ -2503,50 +2503,50 @@ void DbGridControl::DataSourcePropertyChanged(const PropertyChangeEvent& evt) SolarMutexGuard aGuard; // prop "IsModified" changed ? // during update don't care about the modified state - if (!IsUpdating() && evt.PropertyName == FM_PROP_ISMODIFIED ) - { - Reference< XPropertySet > xSource(evt.Source, UNO_QUERY); - DBG_ASSERT( xSource.is(), "DbGridControl::DataSourcePropertyChanged: invalid event source!" ); - bool bIsNew = false; - if (xSource.is()) - bIsNew = ::comphelper::getBOOL(xSource->getPropertyValue(FM_PROP_ISNEW)); - - if (bIsNew && m_xCurrentRow.is()) - { - DBG_ASSERT(::comphelper::getBOOL(xSource->getPropertyValue(FM_PROP_ROWCOUNTFINAL)), "DbGridControl::DataSourcePropertyChanged : somebody moved the form to a new record before the row count was final !"); - sal_Int32 nRecordCount = 0; - xSource->getPropertyValue(FM_PROP_ROWCOUNT) >>= nRecordCount; - if (::comphelper::getBOOL(evt.NewValue)) - { // modified state changed from sal_False to sal_True and we're on an insert row - // -> we've to add a new grid row - if ((nRecordCount == GetRowCount() - 1) && m_xCurrentRow->IsNew()) - { - RowInserted(GetRowCount()); - InvalidateStatusCell(m_nCurrentPos); - m_aBar->InvalidateAll(m_nCurrentPos); - } - } - else - { // modified state changed from sal_True to sal_False and we're on an insert row - // we have two "new row"s at the moment : the one we're editing currently (where the current - // column is the only dirty element) and a "new new" row which is completely clean. As the first - // one is about to be cleaned, too, the second one is obsolete now. - if (m_xCurrentRow->IsNew() && nRecordCount == (GetRowCount() - 2)) - { - RowRemoved(GetRowCount() - 1); - InvalidateStatusCell(m_nCurrentPos); - m_aBar->InvalidateAll(m_nCurrentPos); - } + if (IsUpdating() || evt.PropertyName != FM_PROP_ISMODIFIED) + return; + + Reference< XPropertySet > xSource(evt.Source, UNO_QUERY); + DBG_ASSERT( xSource.is(), "DbGridControl::DataSourcePropertyChanged: invalid event source!" ); + bool bIsNew = false; + if (xSource.is()) + bIsNew = ::comphelper::getBOOL(xSource->getPropertyValue(FM_PROP_ISNEW)); + + if (bIsNew && m_xCurrentRow.is()) + { + DBG_ASSERT(::comphelper::getBOOL(xSource->getPropertyValue(FM_PROP_ROWCOUNTFINAL)), "DbGridControl::DataSourcePropertyChanged : somebody moved the form to a new record before the row count was final !"); + sal_Int32 nRecordCount = 0; + xSource->getPropertyValue(FM_PROP_ROWCOUNT) >>= nRecordCount; + if (::comphelper::getBOOL(evt.NewValue)) + { // modified state changed from sal_False to sal_True and we're on an insert row + // -> we've to add a new grid row + if ((nRecordCount == GetRowCount() - 1) && m_xCurrentRow->IsNew()) + { + RowInserted(GetRowCount()); + InvalidateStatusCell(m_nCurrentPos); + m_aBar->InvalidateAll(m_nCurrentPos); } } - if (m_xCurrentRow.is()) - { - m_xCurrentRow->SetStatus(::comphelper::getBOOL(evt.NewValue) ? GridRowStatus::Modified : GridRowStatus::Clean); - m_xCurrentRow->SetNew( bIsNew ); - InvalidateStatusCell(m_nCurrentPos); - SAL_INFO("svx.fmcomp", "modified flag changed, new state: " << ROWSTATUS(m_xCurrentRow)); + else + { // modified state changed from sal_True to sal_False and we're on an insert row + // we have two "new row"s at the moment : the one we're editing currently (where the current + // column is the only dirty element) and a "new new" row which is completely clean. As the first + // one is about to be cleaned, too, the second one is obsolete now. + if (m_xCurrentRow->IsNew() && nRecordCount == (GetRowCount() - 2)) + { + RowRemoved(GetRowCount() - 1); + InvalidateStatusCell(m_nCurrentPos); + m_aBar->InvalidateAll(m_nCurrentPos); + } } } + if (m_xCurrentRow.is()) + { + m_xCurrentRow->SetStatus(::comphelper::getBOOL(evt.NewValue) ? GridRowStatus::Modified : GridRowStatus::Clean); + m_xCurrentRow->SetNew( bIsNew ); + InvalidateStatusCell(m_nCurrentPos); + SAL_INFO("svx.fmcomp", "modified flag changed, new state: " << ROWSTATUS(m_xCurrentRow)); + } } void DbGridControl::StartDrag( sal_Int8 /*nAction*/, const Point& rPosPixel ) @@ -2714,32 +2714,32 @@ void DbGridControl::CellModified() } } - if (!IsFilterMode() && IsValid(m_xCurrentRow) && !m_xCurrentRow->IsModified()) + if (!(!IsFilterMode() && IsValid(m_xCurrentRow) && !m_xCurrentRow->IsModified())) + return; + + // enable edit mode + // a data set should be inserted + if (m_xCurrentRow->IsNew()) { - // enable edit mode - // a data set should be inserted - if (m_xCurrentRow->IsNew()) + m_xCurrentRow->SetStatus(GridRowStatus::Modified); + SAL_INFO("svx.fmcomp", "current row is new, new state: MODIFIED"); + // if no row was added yet, do it now + if (m_nCurrentPos == GetRowCount() - 1) { - m_xCurrentRow->SetStatus(GridRowStatus::Modified); - SAL_INFO("svx.fmcomp", "current row is new, new state: MODIFIED"); - // if no row was added yet, do it now - if (m_nCurrentPos == GetRowCount() - 1) - { - // increment RowCount - RowInserted(GetRowCount()); - InvalidateStatusCell(m_nCurrentPos); - m_aBar->InvalidateAll(m_nCurrentPos); - } - } - else if (m_xCurrentRow->GetStatus() != GridRowStatus::Modified) - { - m_xCurrentRow->SetState(m_pDataCursor.get(), false); - SAL_INFO("svx.fmcomp", "current row is not new, after SetState, new state: " << ROWSTATUS(m_xCurrentRow)); - m_xCurrentRow->SetStatus(GridRowStatus::Modified); - SAL_INFO("svx.fmcomp", "current row is not new, new state: MODIFIED"); + // increment RowCount + RowInserted(GetRowCount()); InvalidateStatusCell(m_nCurrentPos); + m_aBar->InvalidateAll(m_nCurrentPos); } } + else if (m_xCurrentRow->GetStatus() != GridRowStatus::Modified) + { + m_xCurrentRow->SetState(m_pDataCursor.get(), false); + SAL_INFO("svx.fmcomp", "current row is not new, after SetState, new state: " << ROWSTATUS(m_xCurrentRow)); + m_xCurrentRow->SetStatus(GridRowStatus::Modified); + SAL_INFO("svx.fmcomp", "current row is not new, new state: MODIFIED"); + InvalidateStatusCell(m_nCurrentPos); + } } void DbGridControl::Dispatch(sal_uInt16 nId) @@ -3346,23 +3346,23 @@ void DbGridControl::FieldValueChanged(sal_uInt16 _nId) size_t Location = GetModelColumnPos( _nId ); DbGridColumn* pColumn = ( Location < m_aColumns.size() ) ? m_aColumns[ Location ].get() : nullptr; - if (pColumn) - { - std::unique_ptr<vcl::SolarMutexTryAndBuyGuard> pGuard; - while (!m_bWantDestruction && (!pGuard || !pGuard->isAcquired())) - pGuard.reset(new vcl::SolarMutexTryAndBuyGuard); + if (!pColumn) + return; - if (m_bWantDestruction) - { // at this moment, within another thread, our destructor tries to destroy the listener which called this method - // => don't do anything - // 73365 - 23.02.00 - FS - return; - } + std::unique_ptr<vcl::SolarMutexTryAndBuyGuard> pGuard; + while (!m_bWantDestruction && (!pGuard || !pGuard->isAcquired())) + pGuard.reset(new vcl::SolarMutexTryAndBuyGuard); - // and finally do the update ... - pColumn->UpdateFromField(m_xCurrentRow.get(), m_xFormatter); - RowModified(GetCurRow()); + if (m_bWantDestruction) + { // at this moment, within another thread, our destructor tries to destroy the listener which called this method + // => don't do anything + // 73365 - 23.02.00 - FS + return; } + + // and finally do the update ... + pColumn->UpdateFromField(m_xCurrentRow.get(), m_xFormatter); + RowModified(GetCurRow()); } void DbGridControl::FieldListenerDisposing(sal_uInt16 _nId) diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx index ba59128312fb..ca0c86e34a22 100644 --- a/svx/source/form/datanavi.cxx +++ b/svx/source/form/datanavi.cxx @@ -783,72 +783,72 @@ namespace svxform { OUString sTemp; - if ( DGTSubmission == m_eGroup ) + if ( DGTSubmission != m_eGroup ) + return; + + try { - try + std::unique_ptr<weld::TreeIter> xEntry(m_xItemList->make_iterator()); + if (!m_xItemList->get_selected(xEntry.get())) { - std::unique_ptr<weld::TreeIter> xEntry(m_xItemList->make_iterator()); - if (!m_xItemList->get_selected(xEntry.get())) - { - SAL_WARN( "svx.form", "corrupt tree" ); - return; - } + SAL_WARN( "svx.form", "corrupt tree" ); + return; + } - // #i36262# may be called for submission entry *or* for - // submission children. If we don't have any children, we - // assume the latter case and use the parent - if (!m_xItemList->iter_has_child(*xEntry)) - m_xItemList->iter_parent(*xEntry); + // #i36262# may be called for submission entry *or* for + // submission children. If we don't have any children, we + // assume the latter case and use the parent + if (!m_xItemList->iter_has_child(*xEntry)) + m_xItemList->iter_parent(*xEntry); - _rEntry->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp; - m_xItemList->set_text(*xEntry, sTemp); + _rEntry->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp; + m_xItemList->set_text(*xEntry, sTemp); - _rEntry->getPropertyValue( PN_SUBMISSION_BIND ) >>= sTemp; - OUString sEntry = SvxResId( RID_STR_DATANAV_SUBM_BIND ) + sTemp; - if (!m_xItemList->iter_children(*xEntry)) - { - SAL_WARN( "svx.form", "corrupt tree" ); - return; - } - m_xItemList->set_text(*xEntry, sEntry); - _rEntry->getPropertyValue( PN_SUBMISSION_REF ) >>= sTemp; - sEntry = SvxResId( RID_STR_DATANAV_SUBM_REF ) + sTemp; - if (!m_xItemList->iter_next_sibling(*xEntry)) - { - SAL_WARN( "svx.form", "corrupt tree" ); - return; - } - m_xItemList->set_text(*xEntry, sEntry); - _rEntry->getPropertyValue( PN_SUBMISSION_ACTION ) >>= sTemp; - sEntry = SvxResId( RID_STR_DATANAV_SUBM_ACTION ) + sTemp; - if (!m_xItemList->iter_next_sibling(*xEntry)) - { - SAL_WARN( "svx.form", "corrupt tree" ); - return; - } - _rEntry->getPropertyValue( PN_SUBMISSION_METHOD ) >>= sTemp; - sEntry = SvxResId( RID_STR_DATANAV_SUBM_METHOD ) + - m_aMethodString.toUI( sTemp ); - if (!m_xItemList->iter_next_sibling(*xEntry)) - { - SAL_WARN( "svx.form", "corrupt tree" ); - return; - } - m_xItemList->set_text(*xEntry, sEntry); - _rEntry->getPropertyValue( PN_SUBMISSION_REPLACE ) >>= sTemp; - sEntry = SvxResId( RID_STR_DATANAV_SUBM_REPLACE ) + - m_aReplaceString.toUI( sTemp ); - if (!m_xItemList->iter_next_sibling(*xEntry)) - { - SAL_WARN( "svx.form", "corrupt tree" ); - return; - } - m_xItemList->set_text(*xEntry, sEntry); + _rEntry->getPropertyValue( PN_SUBMISSION_BIND ) >>= sTemp; + OUString sEntry = SvxResId( RID_STR_DATANAV_SUBM_BIND ) + sTemp; + if (!m_xItemList->iter_children(*xEntry)) + { + SAL_WARN( "svx.form", "corrupt tree" ); + return; } - catch ( Exception const & ) + m_xItemList->set_text(*xEntry, sEntry); + _rEntry->getPropertyValue( PN_SUBMISSION_REF ) >>= sTemp; + sEntry = SvxResId( RID_STR_DATANAV_SUBM_REF ) + sTemp; + if (!m_xItemList->iter_next_sibling(*xEntry)) + { + SAL_WARN( "svx.form", "corrupt tree" ); + return; + } + m_xItemList->set_text(*xEntry, sEntry); + _rEntry->getPropertyValue( PN_SUBMISSION_ACTION ) >>= sTemp; + sEntry = SvxResId( RID_STR_DATANAV_SUBM_ACTION ) + sTemp; + if (!m_xItemList->iter_next_sibling(*xEntry)) + { + SAL_WARN( "svx.form", "corrupt tree" ); + return; + } + _rEntry->getPropertyValue( PN_SUBMISSION_METHOD ) >>= sTemp; + sEntry = SvxResId( RID_STR_DATANAV_SUBM_METHOD ) + + m_aMethodString.toUI( sTemp ); + if (!m_xItemList->iter_next_sibling(*xEntry)) + { + SAL_WARN( "svx.form", "corrupt tree" ); + return; + } + m_xItemList->set_text(*xEntry, sEntry); + _rEntry->getPropertyValue( PN_SUBMISSION_REPLACE ) >>= sTemp; + sEntry = SvxResId( RID_STR_DATANAV_SUBM_REPLACE ) + + m_aReplaceString.toUI( sTemp ); + if (!m_xItemList->iter_next_sibling(*xEntry)) { - TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EditEntry()" ); + SAL_WARN( "svx.form", "corrupt tree" ); + return; } + m_xItemList->set_text(*xEntry, sEntry); + } + catch ( Exception const & ) + { + TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EditEntry()" ); } } @@ -1220,38 +1220,38 @@ namespace svxform pMenu->set_sensitive("edit", bEnableEdit); pMenu->set_sensitive("delete", bEnableRemove); } - if ( DGTInstance == m_eGroup ) + if ( DGTInstance != m_eGroup ) + return; + + const char* pResId1 = RID_STR_DATANAV_EDIT_ELEMENT; + const char* pResId2 = RID_STR_DATANAV_REMOVE_ELEMENT; + if (bEntry) { - const char* pResId1 = RID_STR_DATANAV_EDIT_ELEMENT; - const char* pResId2 = RID_STR_DATANAV_REMOVE_ELEMENT; - if (bEntry) + ItemNode* pNode = reinterpret_cast<ItemNode*>(m_xItemList->get_id(*xEntry).toInt64()); + if ( pNode && pNode->m_xNode.is() ) { - ItemNode* pNode = reinterpret_cast<ItemNode*>(m_xItemList->get_id(*xEntry).toInt64()); - if ( pNode && pNode->m_xNode.is() ) + try { - try - { - css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType(); - if ( eChildType == css::xml::dom::NodeType_ATTRIBUTE_NODE ) - { - pResId1 = RID_STR_DATANAV_EDIT_ATTRIBUTE; - pResId2 = RID_STR_DATANAV_REMOVE_ATTRIBUTE; - } - } - catch ( Exception const & ) + css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType(); + if ( eChildType == css::xml::dom::NodeType_ATTRIBUTE_NODE ) { - TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EnableMenuItems()" ); + pResId1 = RID_STR_DATANAV_EDIT_ATTRIBUTE; + pResId2 = RID_STR_DATANAV_REMOVE_ATTRIBUTE; } } - } - m_xToolBox->set_item_label("edit", SvxResId(pResId1)); - m_xToolBox->set_item_label("delete", SvxResId(pResId2)); - if (pMenu) - { - pMenu->set_label("edit", SvxResId( pResId1 ) ); - pMenu->set_label("delete", SvxResId( pResId2 ) ); + catch ( Exception const & ) + { + TOOLS_WARN_EXCEPTION( "svx.form", "XFormsPage::EnableMenuItems()" ); + } } } + m_xToolBox->set_item_label("edit", SvxResId(pResId1)); + m_xToolBox->set_item_label("delete", SvxResId(pResId2)); + if (pMenu) + { + pMenu->set_label("edit", SvxResId( pResId1 ) ); + pMenu->set_label("delete", SvxResId( pResId2 ) ); + } } DataNavigatorWindow::DataNavigatorWindow(vcl::Window* pParent, weld::Builder& rBuilder, SfxBindings const * pBindings) @@ -1932,22 +1932,22 @@ namespace svxform void DataNavigatorWindow::NotifyChanges( bool _bLoadAll ) { - if ( !m_bIsNotifyDisabled ) + if ( m_bIsNotifyDisabled ) + return; + + if ( _bLoadAll ) { - if ( _bLoadAll ) - { - // reset all members - RemoveBroadcaster(); - m_xDataContainer.clear(); - m_xFrameModel.clear(); - m_xModelsBox->clear(); - m_nLastSelectedPos = -1; - // for a reload - LoadModels(); - } - else - m_aUpdateTimer.Start(); + // reset all members + RemoveBroadcaster(); + m_xDataContainer.clear(); + m_xFrameModel.clear(); + m_xModelsBox->clear(); + m_nLastSelectedPos = -1; + // for a reload + LoadModels(); } + else + m_aUpdateTimer.Start(); } void DataNavigatorWindow::AddContainerBroadcaster( const css::uno::Reference< css::container::XContainer >& xContainer ) @@ -2130,27 +2130,27 @@ namespace svxform m_xConstraintBtn->set_sensitive( m_xConstraintCB->get_active() ); m_xCalculateBtn->set_sensitive( m_xCalculateCB->get_active() ); - if ( pBox && m_xTempBinding.is() ) - { - OUString sTemp, sPropName; - if ( m_xRequiredCB.get() == pBox ) - sPropName = PN_REQUIRED_EXPR; - else if ( m_xRelevantCB.get() == pBox ) - sPropName = PN_RELEVANT_EXPR; - else if ( m_xConstraintCB.get() == pBox ) - sPropName = PN_CONSTRAINT_EXPR; - else if ( m_xReadonlyCB.get() == pBox ) - sPropName = PN_READONLY_EXPR; - else if ( m_xCalculateCB.get() == pBox ) - sPropName = PN_CALCULATE_EXPR; - bool bIsChecked = pBox->get_active(); - m_xTempBinding->getPropertyValue( sPropName ) >>= sTemp; - if ( bIsChecked && sTemp.isEmpty() ) - sTemp = TRUE_VALUE; - else if ( !bIsChecked && !sTemp.isEmpty() ) - sTemp.clear(); - m_xTempBinding->setPropertyValue( sPropName, makeAny( sTemp ) ); - } + if ( !(pBox && m_xTempBinding.is()) ) + return; + + OUString sTemp, sPropName; + if ( m_xRequiredCB.get() == pBox ) + sPropName = PN_REQUIRED_EXPR; + else if ( m_xRelevantCB.get() == pBox ) + sPropName = PN_RELEVANT_EXPR; + else if ( m_xConstraintCB.get() == pBox ) + sPropName = PN_CONSTRAINT_EXPR; + else if ( m_xReadonlyCB.get() == pBox ) + sPropName = PN_READONLY_EXPR; + else if ( m_xCalculateCB.get() == pBox ) + sPropName = PN_CALCULATE_EXPR; + bool bIsChecked = pBox->get_active(); + m_xTempBinding->getPropertyValue( sPropName ) >>= sTemp; + if ( bIsChecked && sTemp.isEmpty() ) + sTemp = TRUE_VALUE; + else if ( !bIsChecked && !sTemp.isEmpty() ) + sTemp.clear(); + m_xTempBinding->setPropertyValue( sPropName, makeAny( sTemp ) ); } IMPL_LINK(AddDataItemDialog, ConditionHdl, weld::Button&, rBtn, void) @@ -2450,43 +2450,43 @@ namespace svxform void AddDataItemDialog::InitDataTypeBox() { - if ( m_eItemType != DITText ) + if ( m_eItemType == DITText ) + return; + + Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY ); + if ( !xModel.is() ) + return; + + try { - Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY ); - if ( xModel.is() ) + Reference< css::xforms::XDataTypeRepository > xDataTypes = + xModel->getDataTypeRepository(); + if ( xDataTypes.is() ) { - try - { - Reference< css::xforms::XDataTypeRepository > xDataTypes = - xModel->getDataTypeRepository(); - if ( xDataTypes.is() ) - { - const Sequence< OUString > aNameList = xDataTypes->getElementNames(); - for ( const OUString& rName : aNameList ) - m_xDataTypeLB->append_text(rName); - } + const Sequence< OUString > aNameList = xDataTypes->getElementNames(); + for ( const OUString& rName : aNameList ) + m_xDataTypeLB->append_text(rName); + } - if ( m_xTempBinding.is() ) + if ( m_xTempBinding.is() ) + { + OUString sTemp; + if ( m_xTempBinding->getPropertyValue( PN_BINDING_TYPE ) >>= sTemp ) + { + int nPos = m_xDataTypeLB->find_text(sTemp); + if (nPos == -1) { - OUString sTemp; - if ( m_xTempBinding->getPropertyValue( PN_BINDING_TYPE ) >>= sTemp ) - { - int nPos = m_xDataTypeLB->find_text(sTemp); - if (nPos == -1) - { - m_xDataTypeLB->append_text(sTemp); - nPos = m_xDataTypeLB->get_count() - 1; - } - m_xDataTypeLB->set_active(nPos); - } + m_xDataTypeLB->append_text(sTemp); + nPos = m_xDataTypeLB->get_count() - 1; } - } - catch ( Exception const & ) - { - TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitDataTypeBox()" ); + m_xDataTypeLB->set_active(nPos); } } } + catch ( Exception const & ) + { + TOOLS_WARN_EXCEPTION( "svx.form", "AddDataItemDialog::InitDataTypeBox()" ); + } } void AddDataItemDialog::InitText( DataItemType _eType ) diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index ac588c2b76f3..9cb6051ee7a0 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -1088,20 +1088,20 @@ void FmFilterNavigator::UpdateContent(const Reference< XIndexAccess > & xControl // expand the filters for the current controller std::unique_ptr<weld::TreeIter> xEntry = FindEntry(m_pModel->GetCurrentForm()); - if (xEntry && !m_xTreeView->get_row_expanded(*xEntry)) - { - m_xTreeView->unselect_all(); + if (!xEntry || m_xTreeView->get_row_expanded(*xEntry)) + return; - m_xTreeView->expand_row(*xEntry); + m_xTreeView->unselect_all(); - xEntry = FindEntry(m_pModel->GetCurrentItems()); - if (xEntry) - { - if (!m_xTreeView->get_row_expanded(*xEntry)) - m_xTreeView->expand_row(*xEntry); - m_xTreeView->select(*xEntry); - SelectHdl(*m_xTreeView); - } + m_xTreeView->expand_row(*xEntry); + + xEntry = FindEntry(m_pModel->GetCurrentItems()); + if (xEntry) + { + if (!m_xTreeView->get_row_expanded(*xEntry)) + m_xTreeView->expand_row(*xEntry); + m_xTreeView->select(*xEntry); + SelectHdl(*m_xTreeView); } } diff --git a/svx/source/form/fmPropBrw.cxx b/svx/source/form/fmPropBrw.cxx index f77b79f400f6..15ea18d96ad5 100644 --- a/svx/source/form/fmPropBrw.cxx +++ b/svx/source/form/fmPropBrw.cxx @@ -331,58 +331,58 @@ bool FmPropBrw::implIsReadOnlyModel() const void FmPropBrw::implSetNewSelection( const InterfaceBag& _rSelection ) { - if ( m_xBrowserController.is() ) + if ( !m_xBrowserController.is() ) + return; + + try { - try - { - Reference< XObjectInspector > xInspector( m_xBrowserController, UNO_QUERY_THROW ); + Reference< XObjectInspector > xInspector( m_xBrowserController, UNO_QUERY_THROW ); - // tell it the objects to inspect - xInspector->inspect( comphelper::containerToSequence(_rSelection) ); - } - catch( const VetoException& ) - { - return; - } - catch( const Exception& ) - { - OSL_FAIL( "FmPropBrw::implSetNewSelection: caught an unexpected exception!" ); - return; - } + // tell it the objects to inspect + xInspector->inspect( comphelper::containerToSequence(_rSelection) ); + } + catch( const VetoException& ) + { + return; + } + catch( const Exception& ) + { + OSL_FAIL( "FmPropBrw::implSetNewSelection: caught an unexpected exception!" ); + return; + } - // set the new title according to the selected object - OUString sTitle; + // set the new title according to the selected object + OUString sTitle; - if ( _rSelection.empty() ) - { - sTitle = SvxResId(RID_STR_NO_PROPERTIES); - } - else if ( _rSelection.size() > 1 ) - { - // no form component and (no form or no name) -> Multiselection - sTitle = SvxResId(RID_STR_PROPERTIES_CONTROL) + - SvxResId(RID_STR_PROPTITLE_MULTISELECT); - } - else + if ( _rSelection.empty() ) + { + sTitle = SvxResId(RID_STR_NO_PROPERTIES); + } + else if ( _rSelection.size() > 1 ) + { + // no form component and (no form or no name) -> Multiselection + sTitle = SvxResId(RID_STR_PROPERTIES_CONTROL) + + SvxResId(RID_STR_PROPTITLE_MULTISELECT); + } + else + { + Reference< XPropertySet > xSingleSelection( *_rSelection.begin(), UNO_QUERY); + if ( ::comphelper::hasProperty( FM_PROP_CLASSID, xSingleSelection ) ) { - Reference< XPropertySet > xSingleSelection( *_rSelection.begin(), UNO_QUERY); - if ( ::comphelper::hasProperty( FM_PROP_CLASSID, xSingleSelection ) ) - { - sal_Int16 nClassID = FormComponentType::CONTROL; - xSingleSelection->getPropertyValue( FM_PROP_CLASSID ) >>= nClassID; + sal_Int16 nClassID = FormComponentType::CONTROL; + xSingleSelection->getPropertyValue( FM_PROP_CLASSID ) >>= nClassID; - sTitle = SvxResId(RID_STR_PROPERTIES_CONTROL) + - GetUIHeadlineName(nClassID, makeAny(xSingleSelection)); - } - else if ( Reference< XForm >( xSingleSelection, UNO_QUERY ).is() ) - sTitle = SvxResId(RID_STR_PROPERTIES_FORM); + sTitle = SvxResId(RID_STR_PROPERTIES_CONTROL) + + GetUIHeadlineName(nClassID, makeAny(xSingleSelection)); } + else if ( Reference< XForm >( xSingleSelection, UNO_QUERY ).is() ) + sTitle = SvxResId(RID_STR_PROPERTIES_FORM); + } - if ( implIsReadOnlyModel() ) - sTitle += SvxResId(RID_STR_READONLY_VIEW); + if ( implIsReadOnlyModel() ) + sTitle += SvxResId(RID_STR_READONLY_VIEW); - m_xDialog->set_title(sTitle); - } + m_xDialog->set_title(sTitle); } void FmPropBrw::FillInfo( SfxChildWinInfo& rInfo ) const diff --git a/svx/source/form/fmexch.cxx b/svx/source/form/fmexch.cxx index 39ef077b1ec1..34187a6ea2e5 100644 --- a/svx/source/form/fmexch.cxx +++ b/svx/source/form/fmexch.cxx @@ -47,20 +47,20 @@ namespace svxform void OLocalExchange::clear() { - if ( isClipboardOwner() ) + if ( !isClipboardOwner() ) + return; + + try { - try - { - Reference< clipboard::XClipboard > xClipBoard( getOwnClipboard() ); - if ( xClipBoard.is() ) - xClipBoard->setContents( nullptr, nullptr ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("svx"); - } - m_bClipboardOwner = false; + Reference< clipboard::XClipboard > xClipBoard( getOwnClipboard() ); + if ( xClipBoard.is() ) + xClipBoard->setContents( nullptr, nullptr ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("svx"); } + m_bClipboardOwner = false; } void SAL_CALL OLocalExchange::lostOwnership( const Reference< clipboard::XClipboard >& _rxClipboard, const Reference< XTransferable >& _rxTrans ) diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index dc6924662262..d3db9a653f1d 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -738,22 +738,22 @@ void SAL_CALL FmXFormShell::disposing(const lang::EventObject& e) m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell); } - if (e.Source == m_xExternalViewController) - { - Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY ); - OSL_ENSURE( xFormController.is(), "FmXFormShell::disposing: invalid external view controller!" ); - if (xFormController.is()) - xFormController->removeActivateListener(static_cast<XFormControllerListener*>(this)); + if (e.Source != m_xExternalViewController) + return; - if (m_xExternalViewController.is()) - m_xExternalViewController->removeEventListener(static_cast<XEventListener*>(static_cast<XPropertyChangeListener*>(this))); + Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY ); + OSL_ENSURE( xFormController.is(), "FmXFormShell::disposing: invalid external view controller!" ); + if (xFormController.is()) + xFormController->removeActivateListener(static_cast<XFormControllerListener*>(this)); - m_xExternalViewController = nullptr; - m_xExternalDisplayedForm = nullptr; - m_xExtViewTriggerController = nullptr; + if (m_xExternalViewController.is()) + m_xExternalViewController->removeEventListener(static_cast<XEventListener*>(static_cast<XPropertyChangeListener*>(this))); - InvalidateSlot_Lock( SID_FM_VIEW_AS_GRID, false ); - } + m_xExternalViewController = nullptr; + m_xExternalDisplayedForm = nullptr; + m_xExtViewTriggerController = nullptr; + + InvalidateSlot_Lock( SID_FM_VIEW_AS_GRID, false ); } @@ -806,20 +806,20 @@ void FmXFormShell::invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatu OSL_ENSURE( !_rFeatures.empty(), "FmXFormShell::invalidateFeatures: invalid arguments!" ); - if ( m_pShell->GetViewShell() && m_pShell->GetViewShell()->GetViewFrame() ) - { - // unfortunately, SFX requires sal_uInt16 - ::std::vector< sal_uInt16 > aSlotIds( _rFeatures.begin(), _rFeatures.end() ); + if ( !(m_pShell->GetViewShell() && m_pShell->GetViewShell()->GetViewFrame()) ) + return; - // furthermore, SFX wants a terminating 0 - aSlotIds.push_back( 0 ); + // unfortunately, SFX requires sal_uInt16 + ::std::vector< sal_uInt16 > aSlotIds( _rFeatures.begin(), _rFeatures.end() ); - // and, last but not least, SFX wants the ids to be sorted - ::std::sort( aSlotIds.begin(), aSlotIds.end() - 1 ); + // furthermore, SFX wants a terminating 0 + aSlotIds.push_back( 0 ); - sal_uInt16 *pSlotIds = aSlotIds.data(); - m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( pSlotIds ); - } + // and, last but not least, SFX wants the ids to be sorted + ::std::sort( aSlotIds.begin(), aSlotIds.end() - 1 ); + + sal_uInt16 *pSlotIds = aSlotIds.data(); + m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( pSlotIds ); } @@ -1302,54 +1302,54 @@ void FmXFormShell::LoopGrids_Lock(LoopGridsSync nSync, LoopGridsFlags nFlags) return; Reference< XIndexContainer> xControlModels(m_xActiveForm, UNO_QUERY); - if (xControlModels.is()) + if (!xControlModels.is()) + return; + + for (sal_Int32 i=0; i<xControlModels->getCount(); ++i) { - for (sal_Int32 i=0; i<xControlModels->getCount(); ++i) - { - Reference< XPropertySet> xModelSet; - xControlModels->getByIndex(i) >>= xModelSet; - if (!xModelSet.is()) - continue; + Reference< XPropertySet> xModelSet; + xControlModels->getByIndex(i) >>= xModelSet; + if (!xModelSet.is()) + continue; - if (!::comphelper::hasProperty(FM_PROP_CLASSID, xModelSet)) - continue; - sal_Int16 nClassId = ::comphelper::getINT16(xModelSet->getPropertyValue(FM_PROP_CLASSID)); - if (FormComponentType::GRIDCONTROL != nClassId) - continue; + if (!::comphelper::hasProperty(FM_PROP_CLASSID, xModelSet)) + continue; + sal_Int16 nClassId = ::comphelper::getINT16(xModelSet->getPropertyValue(FM_PROP_CLASSID)); + if (FormComponentType::GRIDCONTROL != nClassId) + continue; - if (!::comphelper::hasProperty(FM_PROP_CURSORCOLOR, xModelSet) || !::comphelper::hasProperty(FM_PROP_ALWAYSSHOWCURSOR, xModelSet) || !::comphelper::hasProperty(FM_PROP_DISPLAYSYNCHRON, xModelSet)) - continue; + if (!::comphelper::hasProperty(FM_PROP_CURSORCOLOR, xModelSet) || !::comphelper::hasProperty(FM_PROP_ALWAYSSHOWCURSOR, xModelSet) || !::comphelper::hasProperty(FM_PROP_DISPLAYSYNCHRON, xModelSet)) + continue; - switch (nSync) + switch (nSync) + { + case LoopGridsSync::DISABLE_SYNC: { - case LoopGridsSync::DISABLE_SYNC: - { - xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(false)); - } - break; - case LoopGridsSync::FORCE_SYNC: - { - Any aOldVal( xModelSet->getPropertyValue(FM_PROP_DISPLAYSYNCHRON) ); - xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(true)); - xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, aOldVal); - } - break; - case LoopGridsSync::ENABLE_SYNC: - { - xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(true)); - } - break; + xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(false)); } - - if (nFlags & LoopGridsFlags::DISABLE_ROCTRLR) + break; + case LoopGridsSync::FORCE_SYNC: { - xModelSet->setPropertyValue(FM_PROP_ALWAYSSHOWCURSOR, Any(false)); - Reference< XPropertyState> xModelPropState(xModelSet, UNO_QUERY); - if (xModelPropState.is()) - xModelPropState->setPropertyToDefault(FM_PROP_CURSORCOLOR); - else - xModelSet->setPropertyValue(FM_PROP_CURSORCOLOR, Any()); // this should be the default + Any aOldVal( xModelSet->getPropertyValue(FM_PROP_DISPLAYSYNCHRON) ); + xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(true)); + xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, aOldVal); } + break; + case LoopGridsSync::ENABLE_SYNC: + { + xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(true)); + } + break; + } + + if (nFlags & LoopGridsFlags::DISABLE_ROCTRLR) + { + xModelSet->setPropertyValue(FM_PROP_ALWAYSSHOWCURSOR, Any(false)); + Reference< XPropertyState> xModelPropState(xModelSet, UNO_QUERY); + if (xModelPropState.is()) + xModelPropState->setPropertyToDefault(FM_PROP_CURSORCOLOR); + else + xModelSet->setPropertyValue(FM_PROP_CURSORCOLOR, Any()); // this should be the default } } } @@ -1753,27 +1753,27 @@ void FmXFormShell::ExecuteFormSlot_Lock( sal_Int32 _nSlot ) rController->execute( _nSlot ); - if ( _nSlot == SID_FM_RECORD_UNDO ) + if ( _nSlot != SID_FM_RECORD_UNDO ) + return; + + // if we're doing an UNDO, *and* if the affected form is the form which we also display + // as external view, then we need to reset the controls of the external form, too + if (getInternalForm_Lock(getActiveForm_Lock()) != m_xExternalDisplayedForm) + return; + + Reference< XIndexAccess > xContainer( m_xExternalDisplayedForm, UNO_QUERY ); + if ( !xContainer.is() ) + return; + + Reference< XReset > xReset; + for ( sal_Int32 i = 0; i < xContainer->getCount(); ++i ) { - // if we're doing an UNDO, *and* if the affected form is the form which we also display - // as external view, then we need to reset the controls of the external form, too - if (getInternalForm_Lock(getActiveForm_Lock()) == m_xExternalDisplayedForm) + if ( ( xContainer->getByIndex( i ) >>= xReset ) && xReset.is() ) { - Reference< XIndexAccess > xContainer( m_xExternalDisplayedForm, UNO_QUERY ); - if ( xContainer.is() ) - { - Reference< XReset > xReset; - for ( sal_Int32 i = 0; i < xContainer->getCount(); ++i ) - { - if ( ( xContainer->getByIndex( i ) >>= xReset ) && xReset.is() ) - { - // no resets on sub forms - Reference< XForm > xAsForm( xReset, UNO_QUERY ); - if ( !xAsForm.is() ) - xReset->reset(); - } - } - } + // no resets on sub forms + Reference< XForm > xAsForm( xReset, UNO_QUERY ); + if ( !xAsForm.is() ) + xReset->reset(); } } } @@ -3782,59 +3782,59 @@ void FmXFormShell::loadForms_Lock(FmFormPage* _pPage, const LoadFormsFlags _nBeh } DBG_ASSERT( _pPage, "FmXFormShell::loadForms: invalid page!" ); - if ( _pPage ) - { - // lock the undo env so the forms can change non-transient properties while loading - // (without this my doc's modified flag would be set) - FmFormModel& rFmFormModel(dynamic_cast< FmFormModel& >(_pPage->getSdrModelFromSdrPage())); - rFmFormModel.GetUndoEnv().Lock(); + if ( !_pPage ) + return; - // load all forms - Reference< XIndexAccess > xForms = _pPage->GetForms( false ); + // lock the undo env so the forms can change non-transient properties while loading + // (without this my doc's modified flag would be set) + FmFormModel& rFmFormModel(dynamic_cast< FmFormModel& >(_pPage->getSdrModelFromSdrPage())); + rFmFormModel.GetUndoEnv().Lock(); - if ( xForms.is() ) + // load all forms + Reference< XIndexAccess > xForms = _pPage->GetForms( false ); + + if ( xForms.is() ) + { + Reference< XLoadable > xForm; + for ( sal_Int32 j = 0, nCount = xForms->getCount(); j < nCount; ++j ) { - Reference< XLoadable > xForm; - for ( sal_Int32 j = 0, nCount = xForms->getCount(); j < nCount; ++j ) + xForms->getByIndex( j ) >>= xForm; + bool bFormWasLoaded = false; + // a database form must be loaded for + try { - xForms->getByIndex( j ) >>= xForm; - bool bFormWasLoaded = false; - // a database form must be loaded for - try + if ( !( _nBehaviour & LoadFormsFlags::Unload ) ) { - if ( !( _nBehaviour & LoadFormsFlags::Unload ) ) - { - if ( lcl_isLoadable( xForm ) && !xForm->isLoaded() ) - xForm->load(); - } - else - { - if ( xForm->isLoaded() ) - { - bFormWasLoaded = true; - xForm->unload(); - } - } + if ( lcl_isLoadable( xForm ) && !xForm->isLoaded() ) + xForm->load(); } - catch( const Exception& ) + else { - DBG_UNHANDLED_EXCEPTION("svx"); + if ( xForm->isLoaded() ) + { + bFormWasLoaded = true; + xForm->unload(); + } } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("svx"); + } - // reset the form if it was loaded - if ( bFormWasLoaded ) - { - Reference< XIndexAccess > xContainer( xForm, UNO_QUERY ); - DBG_ASSERT( xContainer.is(), "FmXFormShell::loadForms: the form is no container!" ); - if ( xContainer.is() ) - smartControlReset( xContainer ); - } + // reset the form if it was loaded + if ( bFormWasLoaded ) + { + Reference< XIndexAccess > xContainer( xForm, UNO_QUERY ); + DBG_ASSERT( xContainer.is(), "FmXFormShell::loadForms: the form is no container!" ); + if ( xContainer.is() ) + smartControlReset( xContainer ); } } - - // unlock the environment - rFmFormModel.GetUndoEnv().UnLock(); } + + // unlock the environment + rFmFormModel.GetUndoEnv().UnLock(); } diff --git a/svx/source/form/fmsrcimp.cxx b/svx/source/form/fmsrcimp.cxx index 8510a1f2692b..f9976d3cac66 100644 --- a/svx/source/form/fmsrcimp.cxx +++ b/svx/source/form/fmsrcimp.cxx @@ -738,25 +738,25 @@ void FmSearchEngine::SetFormatterUsing(bool bSet) void FmSearchEngine::PropagateProgress(bool _bDontPropagateOverflow) { - if (m_aProgressHandler.IsSet()) - { - FmSearchProgress aProgress; - try - { - aProgress.aSearchState = FmSearchProgress::State::Progress; - aProgress.nCurrentRecord = m_xSearchCursor.getRow() - 1; - if (m_bForward) - aProgress.bOverflow = !_bDontPropagateOverflow && m_xSearchCursor.isFirst(); - else - aProgress.bOverflow = !_bDontPropagateOverflow && m_xSearchCursor.isLast(); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("svx"); - } + if (!m_aProgressHandler.IsSet()) + return; - m_aProgressHandler.Call(&aProgress); + FmSearchProgress aProgress; + try + { + aProgress.aSearchState = FmSearchProgress::State::Progress; + aProgress.nCurrentRecord = m_xSearchCursor.getRow() - 1; + if (m_bForward) + aProgress.bOverflow = !_bDontPropagateOverflow && m_xSearchCursor.isFirst(); + else + aProgress.bOverflow = !_bDontPropagateOverflow && m_xSearchCursor.isLast(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("svx"); } + + m_aProgressHandler.Call(&aProgress); } diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index 7b8fa027941f..9cb5f876e286 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -248,40 +248,40 @@ void FmXUndoEnvironment::ModeChanged() if ( !rModel.GetObjectShell() ) return; - if (bReadOnly != (rModel.GetObjectShell()->IsReadOnly() || rModel.GetObjectShell()->IsReadOnlyUI())) - { - bReadOnly = !bReadOnly; + if (bReadOnly == (rModel.GetObjectShell()->IsReadOnly() || rModel.GetObjectShell()->IsReadOnlyUI())) + return; + + bReadOnly = !bReadOnly; - sal_uInt16 nCount = rModel.GetPageCount(); - sal_uInt16 i; - for (i = 0; i < nCount; i++) + sal_uInt16 nCount = rModel.GetPageCount(); + sal_uInt16 i; + for (i = 0; i < nCount; i++) + { + FmFormPage* pPage = dynamic_cast<FmFormPage*>( rModel.GetPage(i) ); + if ( pPage ) { - FmFormPage* pPage = dynamic_cast<FmFormPage*>( rModel.GetPage(i) ); - if ( pPage ) - { - Reference< css::form::XForms > xForms = pPage->GetForms( false ).get(); - if ( xForms.is() ) - TogglePropertyListening( xForms ); - } + Reference< css::form::XForms > xForms = pPage->GetForms( false ).get(); + if ( xForms.is() ) + TogglePropertyListening( xForms ); } + } - nCount = rModel.GetMasterPageCount(); - for (i = 0; i < nCount; i++) + nCount = rModel.GetMasterPageCount(); + for (i = 0; i < nCount; i++) + { + FmFormPage* pPage = dynamic_cast<FmFormPage*>( rModel.GetMasterPage(i) ); + if ( pPage ) { - FmFormPage* pPage = dynamic_cast<FmFormPage*>( rModel.GetMasterPage(i) ); - if ( pPage ) - { - Reference< css::form::XForms > xForms = pPage->GetForms( false ).get(); - if ( xForms.is() ) - TogglePropertyListening( xForms ); - } + Reference< css::form::XForms > xForms = pPage->GetForms( false ).get(); + if ( xForms.is() ) + TogglePropertyListening( xForms ); } - - if (!bReadOnly) - StartListening(rModel); - else - EndListening(rModel); } + + if (!bReadOnly) + StartListening(rModel); + else + EndListening(rModel); } @@ -395,51 +395,51 @@ void FmXUndoEnvironment::Inserted(FmFormObj* pObj) // is the control still assigned to a form Reference< XInterface > xModel(pObj->GetUnoControlModel(), UNO_QUERY); Reference< XFormComponent > xContent(xModel, UNO_QUERY); - if (xContent.is() && pObj->getSdrPageFromSdrObject()) + if (!(xContent.is() && pObj->getSdrPageFromSdrObject())) + return; + + // if the component doesn't belong to a form, yet, find one to insert into + if (!xContent->getParent().is()) { - // if the component doesn't belong to a form, yet, find one to insert into - if (!xContent->getParent().is()) + try { - try - { - const Reference< XIndexContainer >& xObjectParent = pObj->GetOriginalParent(); - - FmFormPage& rPage(dynamic_cast< FmFormPage& >( *pObj->getSdrPageFromSdrObject())); - Reference< XIndexAccess > xForms( rPage.GetForms(), UNO_QUERY_THROW ); - - Reference< XIndexContainer > xNewParent; - Reference< XForm > xForm; - sal_Int32 nPos = -1; - if ( lcl_searchElement( xForms, xObjectParent ) ) - { - // the form which was the parent of the object when it was removed is still - // part of the form component hierarchy of the current page - xNewParent = xObjectParent; - xForm.set( xNewParent, UNO_QUERY_THROW ); - nPos = ::std::min( pObj->GetOriginalIndex(), xNewParent->getCount() ); - } - else - { - xForm.set( rPage.GetImpl().findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW ); - xNewParent.set( xForm, UNO_QUERY_THROW ); - nPos = xNewParent->getCount(); - } + const Reference< XIndexContainer >& xObjectParent = pObj->GetOriginalParent(); - FmFormPageImpl::setUniqueName( xContent, xForm ); - xNewParent->insertByIndex( nPos, makeAny( xContent ) ); + FmFormPage& rPage(dynamic_cast< FmFormPage& >( *pObj->getSdrPageFromSdrObject())); + Reference< XIndexAccess > xForms( rPage.GetForms(), UNO_QUERY_THROW ); - Reference< XEventAttacherManager > xManager( xNewParent, UNO_QUERY_THROW ); - xManager->registerScriptEvents( nPos, pObj->GetOriginalEvents() ); + Reference< XIndexContainer > xNewParent; + Reference< XForm > xForm; + sal_Int32 nPos = -1; + if ( lcl_searchElement( xForms, xObjectParent ) ) + { + // the form which was the parent of the object when it was removed is still + // part of the form component hierarchy of the current page + xNewParent = xObjectParent; + xForm.set( xNewParent, UNO_QUERY_THROW ); + nPos = ::std::min( pObj->GetOriginalIndex(), xNewParent->getCount() ); } - catch( const Exception& ) + else { - DBG_UNHANDLED_EXCEPTION("svx"); + xForm.set( rPage.GetImpl().findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW ); + xNewParent.set( xForm, UNO_QUERY_THROW ); + nPos = xNewParent->getCount(); } - } - // reset FormObject - pObj->ClearObjEnv(); + FmFormPageImpl::setUniqueName( xContent, xForm ); + xNewParent->insertByIndex( nPos, makeAny( xContent ) ); + + Reference< XEventAttacherManager > xManager( xNewParent, UNO_QUERY_THROW ); + xManager->registerScriptEvents( nPos, pObj->GetOriginalEvents() ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("svx"); + } } + + // reset FormObject + pObj->ClearObjEnv(); } @@ -472,38 +472,37 @@ void FmXUndoEnvironment::Removed(FmFormObj* pObj) // is the control still assigned to a form Reference< XFormComponent > xContent(pObj->GetUnoControlModel(), UNO_QUERY); - if (xContent.is()) - { - // The object is taken out of a list. - // If a father exists, the object is removed at the father and - // noted at the FormObject! + if (!xContent.is()) + return; - // If the object is reinserted and a parent exists, this parent is set though. - Reference< XIndexContainer > xForm(xContent->getParent(), UNO_QUERY); - if (xForm.is()) - { - Reference< XIndexAccess > xIndexAccess(xForm.get()); - // determine which position the child was at - const sal_Int32 nPos = getElementPos(xIndexAccess, xContent); - if (nPos >= 0) - { - Sequence< ScriptEventDescriptor > aEvts; - Reference< XEventAttacherManager > xManager(xForm, UNO_QUERY); - if (xManager.is()) - aEvts = xManager->getScriptEvents(nPos); + // The object is taken out of a list. + // If a father exists, the object is removed at the father and + // noted at the FormObject! - try - { - pObj->SetObjEnv(xForm, nPos, aEvts); - xForm->removeByIndex(nPos); - } - catch(Exception&) - { - DBG_UNHANDLED_EXCEPTION("svx"); - } + // If the object is reinserted and a parent exists, this parent is set though. + Reference< XIndexContainer > xForm(xContent->getParent(), UNO_QUERY); + if (!xForm.is()) + return; - } - } + Reference< XIndexAccess > xIndexAccess(xForm.get()); + // determine which position the child was at + const sal_Int32 nPos = getElementPos(xIndexAccess, xContent); + if (nPos < 0) + return; + + Sequence< ScriptEventDescriptor > aEvts; + Reference< XEventAttacherManager > xManager(xForm, UNO_QUERY); + if (xManager.is()) + aEvts = xManager->getScriptEvents(nPos); + + try + { + pObj->SetObjEnv(xForm, nPos, aEvts); + xForm->removeByIndex(nPos); + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION("svx"); } } @@ -977,19 +976,19 @@ void FmUndoPropertyAction::Undo() { FmXUndoEnvironment& rEnv = static_cast<FmFormModel&>(rMod).GetUndoEnv(); - if (xObj.is() && !rEnv.IsLocked()) + if (!(xObj.is() && !rEnv.IsLocked())) + return; + + rEnv.Lock(); + try { - rEnv.Lock(); - try - { - xObj->setPropertyValue( aPropertyName, aOldValue ); - } - catch( const Exception& ) - { - TOOLS_WARN_EXCEPTION( "svx", "FmUndoPropertyAction::Undo" ); - } - rEnv.UnLock(); + xObj->setPropertyValue( aPropertyName, aOldValue ); + } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "svx", "FmUndoPropertyAction::Undo" ); } + rEnv.UnLock(); } @@ -997,19 +996,19 @@ void FmUndoPropertyAction::Redo() { FmXUndoEnvironment& rEnv = static_cast<FmFormModel&>(rMod).GetUndoEnv(); - if (xObj.is() && !rEnv.IsLocked()) + if (!(xObj.is() && !rEnv.IsLocked())) + return; + + rEnv.Lock(); + try { - rEnv.Lock(); - try - { - xObj->setPropertyValue( aPropertyName, aNewValue ); - } - catch( const Exception& ) - { - TOOLS_WARN_EXCEPTION( "svx", "FmUndoPropertyAction::Redo" ); - } - rEnv.UnLock(); + xObj->setPropertyValue( aPropertyName, aNewValue ); } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "svx", "FmUndoPropertyAction::Redo" ); + } + rEnv.UnLock(); } @@ -1034,25 +1033,25 @@ FmUndoContainerAction::FmUndoContainerAction(FmFormModel& _rMod, // some old code suggested this could be a valid argument. However, this code was // buggy, and it *seemed* that nobody used it - so it was removed. - if ( xCont.is() && xElem.is() ) - { - // normalize - m_xElement = xElem; - if ( m_eAction == Removed ) - { - if (m_nIndex >= 0) - { - Reference< XEventAttacherManager > xManager( xCont, UNO_QUERY ); - if ( xManager.is() ) - m_aEvents = xManager->getScriptEvents(m_nIndex); - } - else - m_xElement = nullptr; + if ( !(xCont.is() && xElem.is()) ) + return; - // we now own the element - m_xOwnElement = m_xElement; - } + // normalize + m_xElement = xElem; + if ( m_eAction != Removed ) + return; + + if (m_nIndex >= 0) + { + Reference< XEventAttacherManager > xManager( xCont, UNO_QUERY ); + if ( xManager.is() ) + m_aEvents = xManager->getScriptEvents(m_nIndex); } + else + m_xElement = nullptr; + + // we now own the element + m_xOwnElement = m_xElement; } @@ -1079,30 +1078,30 @@ void FmUndoContainerAction::DisposeElement( const Reference< XInterface > & xEle void FmUndoContainerAction::implReInsert( ) { - if ( m_xContainer->getCount() >= m_nIndex ) + if ( m_xContainer->getCount() < m_nIndex ) + return; + + // insert the element + Any aVal; + if ( m_xContainer->getElementType() == cppu::UnoType<XFormComponent>::get() ) { - // insert the element - Any aVal; - if ( m_xContainer->getElementType() == cppu::UnoType<XFormComponent>::get() ) - { - aVal <<= Reference< XFormComponent >( m_xElement, UNO_QUERY ); - } - else - { - aVal <<= Reference< XForm >( m_xElement, UNO_QUERY ); - } - m_xContainer->insertByIndex( m_nIndex, aVal ); + aVal <<= Reference< XFormComponent >( m_xElement, UNO_QUERY ); + } + else + { + aVal <<= Reference< XForm >( m_xElement, UNO_QUERY ); + } + m_xContainer->insertByIndex( m_nIndex, aVal ); - OSL_ENSURE( getElementPos( m_xContainer.get(), m_xElement ) == m_nIndex, "FmUndoContainerAction::implReInsert: insertion did not work!" ); + OSL_ENSURE( getElementPos( m_xContainer.get(), m_xElement ) == m_nIndex, "FmUndoContainerAction::implReInsert: insertion did not work!" ); - // register the events - Reference< XEventAttacherManager > xManager( m_xContainer, UNO_QUERY ); - if ( xManager.is() ) - xManager->registerScriptEvents( m_nIndex, m_aEvents ); + // register the events + Reference< XEventAttacherManager > xManager( m_xContainer, UNO_QUERY ); + if ( xManager.is() ) + xManager->registerScriptEvents( m_nIndex, m_aEvents ); - // we don't own the object anymore - m_xOwnElement = nullptr; - } + // we don't own the object anymore + m_xOwnElement = nullptr; } @@ -1138,56 +1137,56 @@ void FmUndoContainerAction::Undo() { FmXUndoEnvironment& rEnv = static_cast< FmFormModel& >( rMod ).GetUndoEnv(); - if ( m_xContainer.is() && !rEnv.IsLocked() && m_xElement.is() ) + if ( !(m_xContainer.is() && !rEnv.IsLocked() && m_xElement.is()) ) + return; + + rEnv.Lock(); + try { - rEnv.Lock(); - try + switch ( m_eAction ) { - switch ( m_eAction ) - { - case Inserted: - implReRemove(); - break; + case Inserted: + implReRemove(); + break; - case Removed: - implReInsert(); - break; - } - } - catch( const Exception& ) - { - TOOLS_WARN_EXCEPTION( "svx", "FmUndoContainerAction::Undo" ); + case Removed: + implReInsert(); + break; } - rEnv.UnLock(); } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "svx", "FmUndoContainerAction::Undo" ); + } + rEnv.UnLock(); } void FmUndoContainerAction::Redo() { FmXUndoEnvironment& rEnv = static_cast< FmFormModel& >( rMod ).GetUndoEnv(); - if ( m_xContainer.is() && !rEnv.IsLocked() && m_xElement.is() ) + if ( !(m_xContainer.is() && !rEnv.IsLocked() && m_xElement.is()) ) + return; + + rEnv.Lock(); + try { - rEnv.Lock(); - try + switch ( m_eAction ) { - switch ( m_eAction ) - { - case Inserted: - implReInsert(); - break; + case Inserted: + implReInsert(); + break; - case Removed: - implReRemove(); - break; - } - } - catch( const Exception& ) - { - TOOLS_WARN_EXCEPTION( "svx", "FmUndoContainerAction::Redo" ); + case Removed: + implReRemove(); + break; } - rEnv.UnLock(); } + catch( const Exception& ) + { + TOOLS_WARN_EXCEPTION( "svx", "FmUndoContainerAction::Redo" ); + } + rEnv.UnLock(); } diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx index 1ed008e59633..dec92f21f711 100644 --- a/svx/source/form/fmview.cxx +++ b/svx/source/form/fmview.cxx @@ -132,23 +132,23 @@ void FmFormView::MarkListHasChanged() { E3dView::MarkListHasChanged(); - if ( pFormShell && IsDesignMode() ) + if ( !(pFormShell && IsDesignMode()) ) + return; + + FmFormObj* pObj = getMarkedGrid(); + if ( pImpl->m_pMarkedGrid && pImpl->m_pMarkedGrid != pObj ) { - FmFormObj* pObj = getMarkedGrid(); - if ( pImpl->m_pMarkedGrid && pImpl->m_pMarkedGrid != pObj ) + pImpl->m_pMarkedGrid = nullptr; + if ( pImpl->m_xWindow.is() ) { - pImpl->m_pMarkedGrid = nullptr; - if ( pImpl->m_xWindow.is() ) - { - pImpl->m_xWindow->removeFocusListener(pImpl.get()); - pImpl->m_xWindow = nullptr; - } - SetMoveOutside(false); - //OLMRefreshAllIAOManagers(); + pImpl->m_xWindow->removeFocusListener(pImpl.get()); + pImpl->m_xWindow = nullptr; } - - pFormShell->GetImpl()->SetSelectionDelayed_Lock(); + SetMoveOutside(false); + //OLMRefreshAllIAOManagers(); } + + pFormShell->GetImpl()->SetSelectionDelayed_Lock(); } namespace @@ -404,21 +404,21 @@ SdrObjectUniquePtr FmFormView::CreateFieldControl(const OUString& rFieldDesc) co void FmFormView::InsertControlContainer(const Reference< css::awt::XControlContainer > & xCC) { - if( !IsDesignMode() ) + if( IsDesignMode() ) + return; + + SdrPageView* pPageView = GetSdrPageView(); + if( !pPageView ) + return; + + for( sal_uInt32 i = 0; i < pPageView->PageWindowCount(); i++ ) { - SdrPageView* pPageView = GetSdrPageView(); - if( pPageView ) - { - for( sal_uInt32 i = 0; i < pPageView->PageWindowCount(); i++ ) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i); + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i); - if( rPageWindow.GetControlContainer( false ) == xCC ) - { - pImpl->addWindow(rPageWindow); - break; - } - } + if( rPageWindow.GetControlContainer( false ) == xCC ) + { + pImpl->addWindow(rPageWindow); + break; } } } diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index 1ede28ae3409..e5e844776272 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -157,24 +157,24 @@ FormViewPageWindowAdapter::FormViewPageWindowAdapter( const css::uno::Reference< // create an XFormController for every form FmFormPage* pFormPage = dynamic_cast< FmFormPage* >( _rWindow.GetPageView().GetPage() ); DBG_ASSERT( pFormPage, "FormViewPageWindowAdapter::FormViewPageWindowAdapter: no FmFormPage found!" ); - if ( pFormPage ) + if ( !pFormPage ) + return; + + try { - try - { - Reference< XIndexAccess > xForms( pFormPage->GetForms(), UNO_QUERY_THROW ); - sal_uInt32 nLength = xForms->getCount(); - for (sal_uInt32 i = 0; i < nLength; i++) - { - Reference< XForm > xForm( xForms->getByIndex(i), UNO_QUERY ); - if ( xForm.is() ) - setController( xForm, nullptr ); - } - } - catch (const Exception&) + Reference< XIndexAccess > xForms( pFormPage->GetForms(), UNO_QUERY_THROW ); + sal_uInt32 nLength = xForms->getCount(); + for (sal_uInt32 i = 0; i < nLength; i++) { - DBG_UNHANDLED_EXCEPTION("svx"); + Reference< XForm > xForm( xForms->getByIndex(i), UNO_QUERY ); + if ( xForm.is() ) + setController( xForm, nullptr ); } } + catch (const Exception&) + { + DBG_UNHANDLED_EXCEPTION("svx"); + } } FormViewPageWindowAdapter::~FormViewPageWindowAdapter() @@ -688,48 +688,48 @@ IMPL_LINK_NOARG(FmXFormView, OnActivate, void*, void) } // setting the controller to activate - if (m_pView->GetFormShell() && m_pView->GetActualOutDev() && m_pView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW) - { - FmXFormShell* const pShImpl = m_pView->GetFormShell()->GetImpl(); + if (!(m_pView->GetFormShell() && m_pView->GetActualOutDev() && m_pView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW)) + return; - if(!pShImpl) - return; + FmXFormShell* const pShImpl = m_pView->GetFormShell()->GetImpl(); - find_active_databaseform fad(pShImpl->getActiveController_Lock()); + if(!pShImpl) + return; - vcl::Window* pWindow = const_cast<vcl::Window*>(static_cast<const vcl::Window*>(m_pView->GetActualOutDev())); - PFormViewPageWindowAdapter pAdapter = m_aPageWindowAdapters.empty() ? nullptr : m_aPageWindowAdapters[0]; - for (const auto& rpPageWindowAdapter : m_aPageWindowAdapters) - { - if ( pWindow == rpPageWindowAdapter->getWindow() ) - pAdapter = rpPageWindowAdapter; - } + find_active_databaseform fad(pShImpl->getActiveController_Lock()); - if ( pAdapter.is() ) - { - Reference< XFormController > xControllerToActivate; - for (const Reference< XFormController > & xController : pAdapter->GetList()) - { - if ( !xController.is() ) - continue; + vcl::Window* pWindow = const_cast<vcl::Window*>(static_cast<const vcl::Window*>(m_pView->GetActualOutDev())); + PFormViewPageWindowAdapter pAdapter = m_aPageWindowAdapters.empty() ? nullptr : m_aPageWindowAdapters[0]; + for (const auto& rpPageWindowAdapter : m_aPageWindowAdapters) + { + if ( pWindow == rpPageWindowAdapter->getWindow() ) + pAdapter = rpPageWindowAdapter; + } - { - Reference< XFormController > xActiveController(fad(xController)); - if (xActiveController.is()) - { - xControllerToActivate = xActiveController; - break; - } - } + if ( !pAdapter.is() ) + return; - if(xControllerToActivate.is() || !isActivableDatabaseForm(xController)) - continue; + Reference< XFormController > xControllerToActivate; + for (const Reference< XFormController > & xController : pAdapter->GetList()) + { + if ( !xController.is() ) + continue; - xControllerToActivate = xController; + { + Reference< XFormController > xActiveController(fad(xController)); + if (xActiveController.is()) + { + xControllerToActivate = xActiveController; + break; } - pShImpl->setActiveController_Lock(xControllerToActivate); } + + if(xControllerToActivate.is() || !isActivableDatabaseForm(xController)) + continue; + + xControllerToActivate = xController; } + pShImpl->setActiveController_Lock(xControllerToActivate); } @@ -1811,82 +1811,82 @@ void FmXFormView::restoreMarkList( SdrMarkList& _rRestoredMarkList ) const SdrMarkList& rCurrentList = m_pView->GetMarkedObjectList(); FmFormPage* pPage = GetFormShell() ? GetFormShell()->GetCurPage() : nullptr; - if (pPage) - { - if (rCurrentList.GetMarkCount()) - { // there is a current mark ... hmm. Is it a subset of the mark we remembered in saveMarkList? - bool bMisMatch = false; - - // loop through all current marks - const size_t nCurrentCount = rCurrentList.GetMarkCount(); - for ( size_t i=0; i<nCurrentCount && !bMisMatch; ++i ) - { - const SdrObject* pCurrentMarked = rCurrentList.GetMark( i )->GetMarkedSdrObj(); + if (!pPage) + return; - // loop through all saved marks, check for equality - bool bFound = false; - const size_t nSavedCount = m_aMark.GetMarkCount(); - for ( size_t j=0; j<nSavedCount && !bFound; ++j ) - { - if ( m_aMark.GetMark( j )->GetMarkedSdrObj() == pCurrentMarked ) - bFound = true; - } + if (rCurrentList.GetMarkCount()) + { // there is a current mark ... hmm. Is it a subset of the mark we remembered in saveMarkList? + bool bMisMatch = false; - // did not find a current mark in the saved marks - if ( !bFound ) - bMisMatch = true; - } + // loop through all current marks + const size_t nCurrentCount = rCurrentList.GetMarkCount(); + for ( size_t i=0; i<nCurrentCount && !bMisMatch; ++i ) + { + const SdrObject* pCurrentMarked = rCurrentList.GetMark( i )->GetMarkedSdrObj(); - if ( bMisMatch ) + // loop through all saved marks, check for equality + bool bFound = false; + const size_t nSavedCount = m_aMark.GetMarkCount(); + for ( size_t j=0; j<nSavedCount && !bFound; ++j ) { - m_aMark.Clear(); - _rRestoredMarkList = rCurrentList; - return; + if ( m_aMark.GetMark( j )->GetMarkedSdrObj() == pCurrentMarked ) + bFound = true; } + + // did not find a current mark in the saved marks + if ( !bFound ) + bMisMatch = true; } - // it is important that the objects of the mark list are not accessed, - // because they can be already destroyed - SdrPageView* pCurPageView = m_pView->GetSdrPageView(); - SdrObjListIter aPageIter( pPage ); - bool bFound = true; - - // do all objects still exist - const size_t nCount = m_aMark.GetMarkCount(); - for (size_t i = 0; i < nCount && bFound; ++i) + + if ( bMisMatch ) { - SdrMark* pMark = m_aMark.GetMark(i); - SdrObject* pObj = pMark->GetMarkedSdrObj(); - if (pObj->IsGroupObject()) - { - SdrObjListIter aIter(pObj->GetSubList()); - while (aIter.IsMore() && bFound) - bFound = lcl_hasObject(aPageIter, aIter.Next()); - } - else - bFound = lcl_hasObject(aPageIter, pObj); + m_aMark.Clear(); + _rRestoredMarkList = rCurrentList; + return; + } + } + // it is important that the objects of the mark list are not accessed, + // because they can be already destroyed + SdrPageView* pCurPageView = m_pView->GetSdrPageView(); + SdrObjListIter aPageIter( pPage ); + bool bFound = true; - bFound = bFound && pCurPageView == pMark->GetPageView(); + // do all objects still exist + const size_t nCount = m_aMark.GetMarkCount(); + for (size_t i = 0; i < nCount && bFound; ++i) + { + SdrMark* pMark = m_aMark.GetMark(i); + SdrObject* pObj = pMark->GetMarkedSdrObj(); + if (pObj->IsGroupObject()) + { + SdrObjListIter aIter(pObj->GetSubList()); + while (aIter.IsMore() && bFound) + bFound = lcl_hasObject(aPageIter, aIter.Next()); } + else + bFound = lcl_hasObject(aPageIter, pObj); - if (bFound) + bFound = bFound && pCurPageView == pMark->GetPageView(); + } + + if (bFound) + { + // evaluate the LastObject + if (nCount) // now mark the objects { - // evaluate the LastObject - if (nCount) // now mark the objects + for (size_t i = 0; i < nCount; ++i) { - for (size_t i = 0; i < nCount; ++i) - { - SdrMark* pMark = m_aMark.GetMark(i); - SdrObject* pObj = pMark->GetMarkedSdrObj(); - if ( pObj->GetObjInventor() == SdrInventor::FmForm ) - if ( !m_pView->IsObjMarked( pObj ) ) - m_pView->MarkObj( pObj, pMark->GetPageView() ); - } - - _rRestoredMarkList = m_aMark; + SdrMark* pMark = m_aMark.GetMark(i); + SdrObject* pObj = pMark->GetMarkedSdrObj(); + if ( pObj->GetObjInventor() == SdrInventor::FmForm ) + if ( !m_pView->IsObjMarked( pObj ) ) + m_pView->MarkObj( pObj, pMark->GetPageView() ); } + + _rRestoredMarkList = m_aMark; } - m_aMark.Clear(); } + m_aMark.Clear(); } void SAL_CALL FmXFormView::focusGained( const FocusEvent& /*e*/ ) diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index b3d493a3d7c3..23475041866c 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -1906,19 +1906,19 @@ void FormController::addToEventAttacher(const Reference< XControl > & xControl) // register at the event attacher Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY); - if (xComp.is() && m_xModelAsIndex.is()) + if (!(xComp.is() && m_xModelAsIndex.is())) + return; + + // and look for the position of the ControlModel in it + sal_uInt32 nPos = m_xModelAsIndex->getCount(); + Reference< XFormComponent > xTemp; + for( ; nPos; ) { - // and look for the position of the ControlModel in it - sal_uInt32 nPos = m_xModelAsIndex->getCount(); - Reference< XFormComponent > xTemp; - for( ; nPos; ) + m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; + if (xComp.get() == xTemp.get()) { - m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; - if (xComp.get() == xTemp.get()) - { - m_xModelAsManager->attach( nPos, Reference<XInterface>( xControl, UNO_QUERY ), makeAny(xControl) ); - break; - } + m_xModelAsManager->attach( nPos, Reference<XInterface>( xControl, UNO_QUERY ), makeAny(xControl) ); + break; } } } @@ -1933,19 +1933,19 @@ void FormController::removeFromEventAttacher(const Reference< XControl > & xCont // register at the event attacher Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY); - if ( xComp.is() && m_xModelAsIndex.is() ) + if ( !(xComp.is() && m_xModelAsIndex.is()) ) + return; + + // and look for the position of the ControlModel in it + sal_uInt32 nPos = m_xModelAsIndex->getCount(); + Reference< XFormComponent > xTemp; + for( ; nPos; ) { - // and look for the position of the ControlModel in it - sal_uInt32 nPos = m_xModelAsIndex->getCount(); - Reference< XFormComponent > xTemp; - for( ; nPos; ) + m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; + if (xComp.get() == xTemp.get()) { - m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; - if (xComp.get() == xTemp.get()) - { - m_xModelAsManager->detach( nPos, Reference<XInterface>( xControl, UNO_QUERY ) ); - break; - } + m_xModelAsManager->detach( nPos, Reference<XInterface>( xControl, UNO_QUERY ) ); + break; } } } @@ -2115,48 +2115,48 @@ void FormController::setControlLock(const Reference< XControl > & xControl) // a. if the entire record is locked // b. if the associated field is locked Reference< XBoundControl > xBound(xControl, UNO_QUERY); - if (xBound.is() && + if (!(xBound.is() && ( (bLocked && bLocked != bool(xBound->getLock())) || - !bLocked)) // always uncheck individual fields when unlocking + !bLocked))) // always uncheck individual fields when unlocking + return; + + // there is a data source + Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); + if (!(xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))) + return; + + // what about the ReadOnly and Enable properties + bool bTouch = true; + if (::comphelper::hasProperty(FM_PROP_ENABLED, xSet)) + bTouch = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ENABLED)); + if (::comphelper::hasProperty(FM_PROP_READONLY, xSet)) + bTouch = !::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_READONLY)); + + if (!bTouch) + return; + + Reference< XPropertySet > xField; + xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; + if (!xField.is()) + return; + + if (bLocked) + xBound->setLock(bLocked); + else { - // there is a data source - Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY); - if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet)) + try { - // what about the ReadOnly and Enable properties - bool bTouch = true; - if (::comphelper::hasProperty(FM_PROP_ENABLED, xSet)) - bTouch = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ENABLED)); - if (::comphelper::hasProperty(FM_PROP_READONLY, xSet)) - bTouch = !::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_READONLY)); - - if (bTouch) - { - Reference< XPropertySet > xField; - xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField; - if (xField.is()) - { - if (bLocked) - xBound->setLock(bLocked); - else - { - try - { - Any aVal = xField->getPropertyValue(FM_PROP_ISREADONLY); - if (aVal.hasValue() && ::comphelper::getBOOL(aVal)) - xBound->setLock(true); - else - xBound->setLock(bLocked); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("svx"); - } - - } - } - } + Any aVal = xField->getPropertyValue(FM_PROP_ISREADONLY); + if (aVal.hasValue() && ::comphelper::getBOOL(aVal)) + xBound->setLock(true); + else + xBound->setLock(bLocked); } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("svx"); + } + } } @@ -2360,23 +2360,23 @@ void FormController::implControlInserted( const Reference< XControl>& _rxControl if ( xInterception.is() ) createInterceptor( xInterception ); - if ( _rxControl.is() ) - { - Reference< XControlModel > xModel( _rxControl->getModel() ); + if ( !_rxControl.is() ) + return; - // we want to know about the reset of the model of our controls - // (for correctly resetting m_bModified) - Reference< XReset > xReset( xModel, UNO_QUERY ); - if ( xReset.is() ) - xReset->addResetListener( this ); + Reference< XControlModel > xModel( _rxControl->getModel() ); - // and we want to know about the validity, to visually indicate it - Reference< XValidatableFormComponent > xValidatable( xModel, UNO_QUERY ); - if ( xValidatable.is() ) - { - xValidatable->addFormComponentValidityListener( this ); - m_aControlBorderManager.validityChanged( _rxControl, xValidatable ); - } + // we want to know about the reset of the model of our controls + // (for correctly resetting m_bModified) + Reference< XReset > xReset( xModel, UNO_QUERY ); + if ( xReset.is() ) + xReset->addResetListener( this ); + + // and we want to know about the validity, to visually indicate it + Reference< XValidatableFormComponent > xValidatable( xModel, UNO_QUERY ); + if ( xValidatable.is() ) + { + xValidatable->addFormComponentValidityListener( this ); + m_aControlBorderManager.validityChanged( _rxControl, xValidatable ); } } diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx index 8bc70bdb9510..c84ec322bc80 100644 --- a/svx/source/form/navigatortree.cxx +++ b/svx/source/form/navigatortree.cxx @@ -1213,20 +1213,20 @@ namespace svxform void NavigatorTree::doCut() { - if ( implPrepareExchange( DND_ACTION_MOVE ) ) - { - m_aControlExchange.setClipboardListener( LINK( this, NavigatorTree, OnClipboardAction ) ); - m_aControlExchange.copyToClipboard( ); - m_bKeyboardCut = true; + if ( !implPrepareExchange( DND_ACTION_MOVE ) ) + return; - // mark all the entries we just "cut" into the clipboard as "nearly moved" - for (const auto& rEntry : m_arrCurrentSelection ) - { - if (!rEntry) - continue; - m_aCutEntries.emplace(m_xTreeView->make_iterator(rEntry.get())); - m_xTreeView->set_sensitive(*rEntry, false); - } + m_aControlExchange.setClipboardListener( LINK( this, NavigatorTree, OnClipboardAction ) ); + m_aControlExchange.copyToClipboard( ); + m_bKeyboardCut = true; + + // mark all the entries we just "cut" into the clipboard as "nearly moved" + for (const auto& rEntry : m_arrCurrentSelection ) + { + if (!rEntry) + continue; + m_aCutEntries.emplace(m_xTreeView->make_iterator(rEntry.get())); + m_xTreeView->set_sensitive(*rEntry, false); } } @@ -1449,22 +1449,22 @@ namespace svxform IMPL_LINK_NOARG(NavigatorTree, OnClipboardAction, OLocalExchange&, void) { - if ( !m_aControlExchange.isClipboardOwner() ) - { - if ( doingKeyboardCut() ) - { - for (const auto& rEntry : m_aCutEntries) - { - if (!rEntry) - continue; - m_xTreeView->set_sensitive(*rEntry, true); - } - ListBoxEntrySet aEmpty; - m_aCutEntries.swap( aEmpty ); + if ( m_aControlExchange.isClipboardOwner() ) + return; - m_bKeyboardCut = false; - } + if ( !doingKeyboardCut() ) + return; + + for (const auto& rEntry : m_aCutEntries) + { + if (!rEntry) + continue; + m_xTreeView->set_sensitive(*rEntry, true); } + ListBoxEntrySet aEmpty; + m_aCutEntries.swap( aEmpty ); + + m_bKeyboardCut = false; } void NavigatorTree::ShowSelectionProperties(bool bForce) @@ -1893,20 +1893,20 @@ namespace svxform // if exactly one form is selected now, shell should notice it as CurrentForm // (if selection handling isn't locked, view cares about it in MarkListHasChanged // but mechanism doesn't work, if form is empty for example - if ((m_arrCurrentSelection.size() == 1) && (m_nFormsSelected == 1)) + if ((m_arrCurrentSelection.size() != 1) || (m_nFormsSelected != 1)) + return; + + std::unique_ptr<weld::TreeIter> xSelected(m_xTreeView->make_iterator()); + if (!m_xTreeView->get_selected(xSelected.get())) + xSelected.reset(); + FmFormData* pSingleSelectionData = xSelected ? dynamic_cast<FmFormData*>(reinterpret_cast<FmEntryData*>(m_xTreeView->get_id(*xSelected).toInt64())) + : nullptr; + DBG_ASSERT( pSingleSelectionData, "NavigatorTree::SynchronizeMarkList: invalid selected form!" ); + if ( pSingleSelectionData ) { - std::unique_ptr<weld::TreeIter> xSelected(m_xTreeView->make_iterator()); - if (!m_xTreeView->get_selected(xSelected.get())) - xSelected.reset(); - FmFormData* pSingleSelectionData = xSelected ? dynamic_cast<FmFormData*>(reinterpret_cast<FmEntryData*>(m_xTreeView->get_id(*xSelected).toInt64())) - : nullptr; - DBG_ASSERT( pSingleSelectionData, "NavigatorTree::SynchronizeMarkList: invalid selected form!" ); - if ( pSingleSelectionData ) - { - InterfaceBag aSelection; - aSelection.insert( Reference< XInterface >( pSingleSelectionData->GetFormIface(), UNO_QUERY ) ); - pFormShell->GetImpl()->setCurrentSelection_Lock(aSelection); - } + InterfaceBag aSelection; + aSelection.insert( Reference< XInterface >( pSingleSelectionData->GetFormIface(), UNO_QUERY ) ); + pFormShell->GetImpl()->setCurrentSelection_Lock(aSelection); } } @@ -2030,20 +2030,20 @@ namespace svxform bPaint = true; } // while ( aIter.IsMore() ) - if ( bPaint ) + if ( !bPaint ) + return; + + // make the mark visible + ::tools::Rectangle aMarkRect( pFormView->GetAllMarkedRect()); + for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i ) { - // make the mark visible - ::tools::Rectangle aMarkRect( pFormView->GetAllMarkedRect()); - for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i ) + SdrPaintWindow* pPaintWindow = pFormView->GetPaintWindow( i ); + OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); + if ( OUTDEV_WINDOW == rOutDev.GetOutDevType() ) { - SdrPaintWindow* pPaintWindow = pFormView->GetPaintWindow( i ); - OutputDevice& rOutDev = pPaintWindow->GetOutputDevice(); - if ( OUTDEV_WINDOW == rOutDev.GetOutDevType() ) - { - pFormView->MakeVisible( aMarkRect, static_cast<vcl::Window&>(rOutDev) ); - } - } // for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i ) - } + pFormView->MakeVisible( aMarkRect, static_cast<vcl::Window&>(rOutDev) ); + } + } // for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i ) } diff --git a/svx/source/form/navigatortreemodel.cxx b/svx/source/form/navigatortreemodel.cxx index a0f6baa661a8..945592a0b730 100644 --- a/svx/source/form/navigatortreemodel.cxx +++ b/svx/source/form/navigatortreemodel.cxx @@ -800,20 +800,20 @@ namespace svxform // refill model form root upward Clear(); - if (xForms.is()) - { - xForms->addContainerListener(m_pPropChangeList.get()); + if (!xForms.is()) + return; - FillBranch(nullptr); + xForms->addContainerListener(m_pPropChangeList.get()); - // select same control in tree as in view - // (or all of them), if there is one ... - if(!m_pFormShell) return; // no shell + FillBranch(nullptr); - FmFormView* pFormView = m_pFormShell->GetFormView(); - DBG_ASSERT(pFormView != nullptr, "NavigatorTreeModel::UpdateContent : no FormView"); - BroadcastMarkedObjects(pFormView->GetMarkedObjectList()); - } + // select same control in tree as in view + // (or all of them), if there is one ... + if(!m_pFormShell) return; // no shell + + FmFormView* pFormView = m_pFormShell->GetFormView(); + DBG_ASSERT(pFormView != nullptr, "NavigatorTreeModel::UpdateContent : no FormView"); + BroadcastMarkedObjects(pFormView->GetMarkedObjectList()); } diff --git a/svx/source/gallery2/codec.cxx b/svx/source/gallery2/codec.cxx index 5063632d1d93..5adef9b37841 100644 --- a/svx/source/gallery2/codec.cxx +++ b/svx/source/gallery2/codec.cxx @@ -85,67 +85,67 @@ void GalleryCodec::Read( SvStream& rStmToRead ) { sal_uInt32 nVersion = 0; - if( IsCoded( rStm, nVersion ) ) - { - sal_uInt32 nCompressedSize, nUnCompressedSize; + if( !IsCoded( rStm, nVersion ) ) + return; + + sal_uInt32 nCompressedSize, nUnCompressedSize; - rStm.SeekRel( 6 ); - rStm.ReadUInt32( nUnCompressedSize ).ReadUInt32( nCompressedSize ); + rStm.SeekRel( 6 ); + rStm.ReadUInt32( nUnCompressedSize ).ReadUInt32( nCompressedSize ); - // decompress - if( 1 == nVersion ) + // decompress + if( 1 == nVersion ) + { + std::unique_ptr<sal_uInt8[]> pCompressedBuffer(new sal_uInt8[ nCompressedSize ]); + rStm.ReadBytes(pCompressedBuffer.get(), nCompressedSize); + sal_uInt8* pInBuf = pCompressedBuffer.get(); + std::unique_ptr<sal_uInt8[]> pOutBuf(new sal_uInt8[ nUnCompressedSize ]); + sal_uInt8* pTmpBuf = pOutBuf.get(); + sal_uInt8* pLast = pOutBuf.get() + nUnCompressedSize - 1; + sal_uIntPtr nIndex = 0, nCountByte, nRunByte; + bool bEndDecoding = false; + + do { - std::unique_ptr<sal_uInt8[]> pCompressedBuffer(new sal_uInt8[ nCompressedSize ]); - rStm.ReadBytes(pCompressedBuffer.get(), nCompressedSize); - sal_uInt8* pInBuf = pCompressedBuffer.get(); - std::unique_ptr<sal_uInt8[]> pOutBuf(new sal_uInt8[ nUnCompressedSize ]); - sal_uInt8* pTmpBuf = pOutBuf.get(); - sal_uInt8* pLast = pOutBuf.get() + nUnCompressedSize - 1; - sal_uIntPtr nIndex = 0, nCountByte, nRunByte; - bool bEndDecoding = false; - - do + nCountByte = *pInBuf++; + + if ( !nCountByte ) { - nCountByte = *pInBuf++; + nRunByte = *pInBuf++; - if ( !nCountByte ) + if ( nRunByte > 2 ) { - nRunByte = *pInBuf++; - - if ( nRunByte > 2 ) - { - // filling absolutely - memcpy( &pTmpBuf[ nIndex ], pInBuf, nRunByte ); - pInBuf += nRunByte; - nIndex += nRunByte; - - // note WORD alignment - if ( nRunByte & 1 ) - pInBuf++; - } - else if ( nRunByte == 1 ) // End of the image - bEndDecoding = true; - } - else - { - const sal_uInt8 cVal = *pInBuf++; - - memset( &pTmpBuf[ nIndex ], cVal, nCountByte ); - nIndex += nCountByte; + // filling absolutely + memcpy( &pTmpBuf[ nIndex ], pInBuf, nRunByte ); + pInBuf += nRunByte; + nIndex += nRunByte; + + // note WORD alignment + if ( nRunByte & 1 ) + pInBuf++; } + else if ( nRunByte == 1 ) // End of the image + bEndDecoding = true; } - while ( !bEndDecoding && ( pTmpBuf <= pLast ) ); + else + { + const sal_uInt8 cVal = *pInBuf++; - rStmToRead.WriteBytes(pOutBuf.get(), nUnCompressedSize); + memset( &pTmpBuf[ nIndex ], cVal, nCountByte ); + nIndex += nCountByte; + } } - else if( 2 == nVersion ) - { - ZCodec aCodec; + while ( !bEndDecoding && ( pTmpBuf <= pLast ) ); - aCodec.BeginCompression(); - aCodec.Decompress( rStm, rStmToRead ); - aCodec.EndCompression(); - } + rStmToRead.WriteBytes(pOutBuf.get(), nUnCompressedSize); + } + else if( 2 == nVersion ) + { + ZCodec aCodec; + + aCodec.BeginCompression(); + aCodec.Decompress( rStm, rStmToRead ); + aCodec.EndCompression(); } } diff --git a/svx/source/gallery2/galbrws1.cxx b/svx/source/gallery2/galbrws1.cxx index f4c3da3b41a8..cb0b291b106d 100644 --- a/svx/source/gallery2/galbrws1.cxx +++ b/svx/source/gallery2/galbrws1.cxx @@ -89,19 +89,19 @@ void GalleryBrowser1::ImplInsertThemeEntry( const GalleryThemeEntry* pEntry ) { static const bool bShowHiddenThemes = ( getenv( "GALLERY_SHOW_HIDDEN_THEMES" ) != nullptr ); - if( pEntry && ( !pEntry->IsHidden() || bShowHiddenThemes ) ) - { - const OUString* pImage; + if( !(pEntry && ( !pEntry->IsHidden() || bShowHiddenThemes )) ) + return; - if( pEntry->IsReadOnly() ) - pImage = &aImgReadOnly; - else if( pEntry->IsDefault() ) - pImage = &aImgDefault; - else - pImage = &aImgNormal; + const OUString* pImage; - mxThemes->append("", pEntry->GetThemeName(), *pImage); - } + if( pEntry->IsReadOnly() ) + pImage = &aImgReadOnly; + else if( pEntry->IsDefault() ) + pImage = &aImgDefault; + else + pImage = &aImgNormal; + + mxThemes->append("", pEntry->GetThemeName(), *pImage); } void GalleryBrowser1::ImplFillExchangeData( const GalleryTheme* pThm, ExchangeData& rData ) @@ -135,37 +135,37 @@ void GalleryBrowser1::ImplGetExecuteVector(std::vector<OString>& o_aExec) { GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this ); - if( pTheme ) - { - bool bUpdateAllowed, bRenameAllowed, bRemoveAllowed; - static const bool bIdDialog = ( getenv( "GALLERY_ENABLE_ID_DIALOG" ) != nullptr ); + if( !pTheme ) + return; - if( pTheme->IsReadOnly() ) - bUpdateAllowed = bRenameAllowed = bRemoveAllowed = false; - else if( pTheme->IsDefault() ) - { - bUpdateAllowed = bRenameAllowed = true; - bRemoveAllowed = false; - } - else - bUpdateAllowed = bRenameAllowed = bRemoveAllowed = true; + bool bUpdateAllowed, bRenameAllowed, bRemoveAllowed; + static const bool bIdDialog = ( getenv( "GALLERY_ENABLE_ID_DIALOG" ) != nullptr ); - if( bUpdateAllowed && pTheme->GetObjectCount() ) - o_aExec.emplace_back("update"); + if( pTheme->IsReadOnly() ) + bUpdateAllowed = bRenameAllowed = bRemoveAllowed = false; + else if( pTheme->IsDefault() ) + { + bUpdateAllowed = bRenameAllowed = true; + bRemoveAllowed = false; + } + else + bUpdateAllowed = bRenameAllowed = bRemoveAllowed = true; - if( bRenameAllowed ) - o_aExec.emplace_back("rename"); + if( bUpdateAllowed && pTheme->GetObjectCount() ) + o_aExec.emplace_back("update"); - if( bRemoveAllowed ) - o_aExec.emplace_back("delete"); + if( bRenameAllowed ) + o_aExec.emplace_back("rename"); - if( bIdDialog && !pTheme->IsReadOnly() ) - o_aExec.emplace_back("assign"); + if( bRemoveAllowed ) + o_aExec.emplace_back("delete"); - o_aExec.emplace_back("properties"); + if( bIdDialog && !pTheme->IsReadOnly() ) + o_aExec.emplace_back("assign"); - mpGallery->ReleaseTheme( pTheme, *this ); - } + o_aExec.emplace_back("properties"); + + mpGallery->ReleaseTheme( pTheme, *this ); } void GalleryBrowser1::ImplGalleryThemeProperties( const OUString & rThemeName, bool bCreateNew ) diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx index b1449a811d93..352faf0b1caa 100644 --- a/svx/source/gallery2/galbrws2.cxx +++ b/svx/source/gallery2/galbrws2.cxx @@ -495,25 +495,25 @@ void GalleryBrowser2::ShowContextMenu(const CommandEvent& rCEvt) Point aSelPos; const sal_uInt32 nItemId = ImplGetSelectedItemId( rCEvt.IsMouseEvent() ? &aMousePos : nullptr, aSelPos ); - if( mpCurTheme && nItemId && ( nItemId <= mpCurTheme->GetObjectCount() ) ) - { - ImplSelectItemId( nItemId ); + if( !(mpCurTheme && nItemId && ( nItemId <= mpCurTheme->GetObjectCount() )) ) + return; - css::uno::Reference< css::frame::XFrame > xFrame( GetFrame() ); - if ( xFrame.is() ) - { - weld::Widget* pParent = GetViewWindow(); - mnCurActionPos = nItemId - 1; - rtl::Reference< GalleryThemePopup > xPopup( - new GalleryThemePopup( - pParent, - mpCurTheme, - mnCurActionPos, - GALLERYBROWSERMODE_PREVIEW == GetMode(), - this ) ); - xPopup->ExecutePopup(pParent, aSelPos); - } - } + ImplSelectItemId( nItemId ); + + css::uno::Reference< css::frame::XFrame > xFrame( GetFrame() ); + if ( !xFrame.is() ) + return; + + weld::Widget* pParent = GetViewWindow(); + mnCurActionPos = nItemId - 1; + rtl::Reference< GalleryThemePopup > xPopup( + new GalleryThemePopup( + pParent, + mpCurTheme, + mnCurActionPos, + GALLERYBROWSERMODE_PREVIEW == GetMode(), + this ) ); + xPopup->ExecutePopup(pParent, aSelPos); } bool GalleryBrowser2::ViewBoxHasFocus() const @@ -630,83 +630,83 @@ void GalleryBrowser2::SelectTheme( const OUString& rThemeName ) void GalleryBrowser2::SetMode( GalleryBrowserMode eMode ) { - if( GetMode() != eMode ) - { - meLastMode = GetMode(); + if( GetMode() == eMode ) + return; - switch( eMode ) + meLastMode = GetMode(); + + switch( eMode ) + { + case GALLERYBROWSERMODE_ICON: { - case GALLERYBROWSERMODE_ICON: - { - mxListView->hide(); + mxListView->hide(); - mxPreview->Hide(); - mxPreview->SetGraphic( Graphic() ); - GalleryPreview::PreviewMedia( INetURLObject() ); + mxPreview->Hide(); + mxPreview->SetGraphic( Graphic() ); + GalleryPreview::PreviewMedia( INetURLObject() ); - mxIconView->Show(); + mxIconView->Show(); - mxIconButton->set_sensitive(true); - mxListButton->set_sensitive(true); + mxIconButton->set_sensitive(true); + mxListButton->set_sensitive(true); - mxIconButton->set_active(true); - mxListButton->set_active(false); - } - break; + mxIconButton->set_active(true); + mxListButton->set_active(false); + } + break; - case GALLERYBROWSERMODE_LIST: - { - mxIconView->Hide(); + case GALLERYBROWSERMODE_LIST: + { + mxIconView->Hide(); - mxPreview->Hide(); - mxPreview->SetGraphic( Graphic() ); - GalleryPreview::PreviewMedia( INetURLObject() ); + mxPreview->Hide(); + mxPreview->SetGraphic( Graphic() ); + GalleryPreview::PreviewMedia( INetURLObject() ); - mxListView->show(); - UpdateRows(true); + mxListView->show(); + UpdateRows(true); - mxIconButton->set_sensitive(true); - mxListButton->set_sensitive(true); + mxIconButton->set_sensitive(true); + mxListButton->set_sensitive(true); - mxIconButton->set_active(false); - mxListButton->set_active(true); - } - break; + mxIconButton->set_active(false); + mxListButton->set_active(true); + } + break; - case GALLERYBROWSERMODE_PREVIEW: - { - Graphic aGraphic; - Point aSelPos; - const sal_uInt32 nItemId = ImplGetSelectedItemId( nullptr, aSelPos ); + case GALLERYBROWSERMODE_PREVIEW: + { + Graphic aGraphic; + Point aSelPos; + const sal_uInt32 nItemId = ImplGetSelectedItemId( nullptr, aSelPos ); - if( nItemId ) - { - const sal_uInt32 nPos = nItemId - 1; + if( nItemId ) + { + const sal_uInt32 nPos = nItemId - 1; - mxIconView->Hide(); - mxListView->hide(); + mxIconView->Hide(); + mxListView->hide(); - if( mpCurTheme ) - mpCurTheme->GetGraphic( nPos, aGraphic ); + if( mpCurTheme ) + mpCurTheme->GetGraphic( nPos, aGraphic ); - mxPreview->SetGraphic( aGraphic ); - mxPreview->Show(); + mxPreview->SetGraphic( aGraphic ); + mxPreview->Show(); - if( mpCurTheme && mpCurTheme->GetObjectKind( nPos ) == SgaObjKind::Sound ) - GalleryPreview::PreviewMedia( mpCurTheme->GetObjectURL( nPos ) ); + if( mpCurTheme && mpCurTheme->GetObjectKind( nPos ) == SgaObjKind::Sound ) + GalleryPreview::PreviewMedia( mpCurTheme->GetObjectURL( nPos ) ); - mxIconButton->set_sensitive(false); - mxListButton->set_sensitive(false); - } + mxIconButton->set_sensitive(false); + mxListButton->set_sensitive(false); } - break; - - default: - break; } + break; - GalleryBrowser2::meInitMode = meMode = eMode; + default: + break; } + + GalleryBrowser2::meInitMode = meMode = eMode; } weld::Widget* GalleryBrowser2::GetViewWindow() const @@ -728,51 +728,51 @@ weld::Widget* GalleryBrowser2::GetViewWindow() const void GalleryBrowser2::Travel( GalleryBrowserTravel eTravel ) { - if( mpCurTheme ) + if( !mpCurTheme ) + return; + + Point aSelPos; + const sal_uInt32 nItemId = ImplGetSelectedItemId( nullptr, aSelPos ); + + if( !nItemId ) + return; + + sal_uInt32 nNewItemId = nItemId; + + switch( eTravel ) { - Point aSelPos; - const sal_uInt32 nItemId = ImplGetSelectedItemId( nullptr, aSelPos ); + case GalleryBrowserTravel::First: nNewItemId = 1; break; + case GalleryBrowserTravel::Last: nNewItemId = mpCurTheme->GetObjectCount(); break; + case GalleryBrowserTravel::Previous: nNewItemId--; break; + case GalleryBrowserTravel::Next: nNewItemId++; break; + default: + break; + } - if( nItemId ) - { - sal_uInt32 nNewItemId = nItemId; + if( nNewItemId < 1 ) + nNewItemId = 1; + else if( nNewItemId > mpCurTheme->GetObjectCount() ) + nNewItemId = mpCurTheme->GetObjectCount(); - switch( eTravel ) - { - case GalleryBrowserTravel::First: nNewItemId = 1; break; - case GalleryBrowserTravel::Last: nNewItemId = mpCurTheme->GetObjectCount(); break; - case GalleryBrowserTravel::Previous: nNewItemId--; break; - case GalleryBrowserTravel::Next: nNewItemId++; break; - default: - break; - } + if( nNewItemId == nItemId ) + return; - if( nNewItemId < 1 ) - nNewItemId = 1; - else if( nNewItemId > mpCurTheme->GetObjectCount() ) - nNewItemId = mpCurTheme->GetObjectCount(); + ImplSelectItemId( nNewItemId ); + ImplUpdateInfoBar(); - if( nNewItemId != nItemId ) - { - ImplSelectItemId( nNewItemId ); - ImplUpdateInfoBar(); + if( GALLERYBROWSERMODE_PREVIEW != GetMode() ) + return; - if( GALLERYBROWSERMODE_PREVIEW == GetMode() ) - { - Graphic aGraphic; - const sal_uInt32 nPos = nNewItemId - 1; + Graphic aGraphic; + const sal_uInt32 nPos = nNewItemId - 1; - mpCurTheme->GetGraphic( nPos, aGraphic ); - mxPreview->SetGraphic( aGraphic ); + mpCurTheme->GetGraphic( nPos, aGraphic ); + mxPreview->SetGraphic( aGraphic ); - if( SgaObjKind::Sound == mpCurTheme->GetObjectKind( nPos ) ) - GalleryPreview::PreviewMedia( mpCurTheme->GetObjectURL( nPos ) ); + if( SgaObjKind::Sound == mpCurTheme->GetObjectKind( nPos ) ) + GalleryPreview::PreviewMedia( mpCurTheme->GetObjectURL( nPos ) ); - mxPreview->Invalidate(); - } - } - } - } + mxPreview->Invalidate(); } void GalleryBrowser2::ImplUpdateViews( sal_uInt16 nSelectionId ) @@ -1099,61 +1099,61 @@ void GalleryBrowser2::Execute(const OString &rIdent) Point aSelPos; const sal_uInt32 nItemId = ImplGetSelectedItemId( nullptr, aSelPos ); - if( mpCurTheme && nItemId ) - { - mnCurActionPos = nItemId - 1; + if( !(mpCurTheme && nItemId) ) + return; - if (rIdent == "preview") - SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode ); - else if (rIdent == "delete") + mnCurActionPos = nItemId - 1; + + if (rIdent == "preview") + SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode ); + else if (rIdent == "delete") + { + if (!mpCurTheme->IsReadOnly()) { - if (!mpCurTheme->IsReadOnly()) + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetViewWindow(), "svx/ui/querydeleteobjectdialog.ui")); + std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("QueryDeleteObjectDialog")); + if (xQuery->run() == RET_YES) { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetViewWindow(), "svx/ui/querydeleteobjectdialog.ui")); - std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("QueryDeleteObjectDialog")); - if (xQuery->run() == RET_YES) - { - mpCurTheme->RemoveObject( mnCurActionPos ); - } + mpCurTheme->RemoveObject( mnCurActionPos ); } } - else if (rIdent == "title") + } + else if (rIdent == "title") + { + std::unique_ptr<SgaObject> pObj = mpCurTheme->AcquireObject( mnCurActionPos ); + + if( pObj ) { - std::unique_ptr<SgaObject> pObj = mpCurTheme->AcquireObject( mnCurActionPos ); + const OUString aOldTitle( GetItemText( *pObj, GalleryItemFlags::Title ) ); - if( pObj ) + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractTitleDialog> aDlg(pFact->CreateTitleDialog(GetViewWindow(), aOldTitle)); + if( aDlg->Execute() == RET_OK ) { - const OUString aOldTitle( GetItemText( *pObj, GalleryItemFlags::Title ) ); + OUString aNewTitle( aDlg->GetTitle() ); - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractTitleDialog> aDlg(pFact->CreateTitleDialog(GetViewWindow(), aOldTitle)); - if( aDlg->Execute() == RET_OK ) + if( ( aNewTitle.isEmpty() && !pObj->GetTitle().isEmpty() ) || ( aNewTitle != aOldTitle ) ) { - OUString aNewTitle( aDlg->GetTitle() ); - - if( ( aNewTitle.isEmpty() && !pObj->GetTitle().isEmpty() ) || ( aNewTitle != aOldTitle ) ) - { - if( aNewTitle.isEmpty() ) - aNewTitle = "__<empty>__"; + if( aNewTitle.isEmpty() ) + aNewTitle = "__<empty>__"; - pObj->SetTitle( aNewTitle ); - mpCurTheme->InsertObject( *pObj ); - } + pObj->SetTitle( aNewTitle ); + mpCurTheme->InsertObject( *pObj ); } } } - else if (rIdent == "copy") - { - mpCurTheme->CopyToClipboard(mnCurActionPos); - } - else if (rIdent == "paste") + } + else if (rIdent == "copy") + { + mpCurTheme->CopyToClipboard(mnCurActionPos); + } + else if (rIdent == "paste") + { + if( !mpCurTheme->IsReadOnly() ) { - if( !mpCurTheme->IsReadOnly() ) - { - TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromClipboard(GetSystemClipboard())); - mpCurTheme->InsertTransferable( aDataHelper.GetTransferable(), mnCurActionPos ); - } - } + TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromClipboard(GetSystemClipboard())); + mpCurTheme->InsertTransferable( aDataHelper.GetTransferable(), mnCurActionPos ); + } } } diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx index 47ef1757755d..1cb99eb5ae37 100644 --- a/svx/source/gallery2/galctrl.cxx +++ b/svx/source/gallery2/galctrl.cxx @@ -198,19 +198,19 @@ bool GalleryPreview::StartDrag() void GalleryPreview::PreviewMedia( const INetURLObject& rURL ) { #if HAVE_FEATURE_AVMEDIA - if (rURL.GetProtocol() != INetProtocol::NotValid) - { - ::avmedia::MediaFloater* pFloater = avmedia::getMediaFloater(); + if (rURL.GetProtocol() == INetProtocol::NotValid) + return; - if (!pFloater) - { - SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( SID_AVMEDIA_PLAYER, SfxCallMode::SYNCHRON ); - pFloater = avmedia::getMediaFloater(); - } + ::avmedia::MediaFloater* pFloater = avmedia::getMediaFloater(); - if (pFloater) - pFloater->setURL( rURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ), "", true ); + if (!pFloater) + { + SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( SID_AVMEDIA_PLAYER, SfxCallMode::SYNCHRON ); + pFloater = avmedia::getMediaFloater(); } + + if (pFloater) + pFloater->setURL( rURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ), "", true ); #else (void) rURL; #endif diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index 79533c4f0891..a7dc2bd4823f 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -583,21 +583,21 @@ void Gallery::RenameTheme( const OUString& rOldName, const OUString& rNewName ) GalleryThemeEntry* pThemeEntry = ImplGetThemeEntry( rOldName ); // check if the new theme name is already present - if( pThemeEntry && !HasTheme( rNewName ) && !pThemeEntry->IsReadOnly() ) - { - SfxListener aListener; - GalleryTheme* pThm = AcquireTheme( rOldName, aListener ); + if( !pThemeEntry || HasTheme( rNewName ) || pThemeEntry->IsReadOnly() ) + return; - if( pThm ) - { - pThemeEntry->SetName( rNewName ); - if (pThm->pThm->IsModified()) - if (!pThm->mpGalleryBinaryEngine->implWrite(*pThm)) - pThm->ImplSetModified(false); + SfxListener aListener; + GalleryTheme* pThm = AcquireTheme( rOldName, aListener ); - Broadcast( GalleryHint( GalleryHintType::THEME_RENAMED, rOldName, pThm->GetName() ) ); - ReleaseTheme( pThm, aListener ); - } + if( pThm ) + { + pThemeEntry->SetName( rNewName ); + if (pThm->pThm->IsModified()) + if (!pThm->mpGalleryBinaryEngine->implWrite(*pThm)) + pThm->ImplSetModified(false); + + Broadcast( GalleryHint( GalleryHintType::THEME_RENAMED, rOldName, pThm->GetName() ) ); + ReleaseTheme( pThm, aListener ); } } diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx index ca425f661d17..8a5c7ac50ebf 100644 --- a/svx/source/gallery2/galmisc.cxx +++ b/svx/source/gallery2/galmisc.cxx @@ -322,25 +322,25 @@ GalleryProgress::GalleryProgress( const GraphicFilter* pFilter ) uno::Reference< awt::XProgressMonitor > xMonitor( xMgr->createInstance( "com.sun.star.awt.XProgressMonitor" ), uno::UNO_QUERY ); - if ( xMonitor.is() ) - { - mxProgressBar = xMonitor; + if ( !xMonitor.is() ) + return; - OUString aProgressText; + mxProgressBar = xMonitor; - if( pFilter ) - { - aProgressText = SvxResId(RID_SVXSTR_GALLERY_FILTER); + OUString aProgressText; + + if( pFilter ) + { + aProgressText = SvxResId(RID_SVXSTR_GALLERY_FILTER); // pFilter->SetUpdatePercentHdl( LINK( this, GalleryProgress, Update ) ); // sj: progress wasn't working up from SO7 at all // // so I am removing this. The gallery progress should // // be changed to use the XStatusIndicator instead of XProgressMonitor - } - else - aProgressText = "Gallery"; - - xMonitor->addText( "Gallery", aProgressText, false ) ; - mxProgressBar->setRange( 0, GALLERY_PROGRESS_RANGE ); } + else + aProgressText = "Gallery"; + + xMonitor->addText( "Gallery", aProgressText, false ) ; + mxProgressBar->setRange( 0, GALLERY_PROGRESS_RANGE ); } GalleryProgress::~GalleryProgress() diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx index e2922419f1e4..fea1384300e0 100644 --- a/svx/source/gallery2/galobj.cxx +++ b/svx/source/gallery2/galobj.cxx @@ -398,19 +398,19 @@ SvxGalleryDrawModel::SvxGalleryDrawModel() { mxDoc = SfxObjectShell::CreateObjectByFactoryName( "sdraw" ); - if( mxDoc.Is() ) - { - mxDoc->DoInitNew(); + if( !mxDoc.Is() ) + return; + + mxDoc->DoInitNew(); - uno::Reference< lang::XUnoTunnel > xTunnel( mxDoc->GetModel(), uno::UNO_QUERY ); - if( xTunnel.is() ) + uno::Reference< lang::XUnoTunnel > xTunnel( mxDoc->GetModel(), uno::UNO_QUERY ); + if( xTunnel.is() ) + { + mpFormModel = dynamic_cast< FmFormModel* >( + reinterpret_cast<SdrModel*>(xTunnel->getSomething(SdrModel::getUnoTunnelId()))); + if( mpFormModel ) { - mpFormModel = dynamic_cast< FmFormModel* >( - reinterpret_cast<SdrModel*>(xTunnel->getSomething(SdrModel::getUnoTunnelId()))); - if( mpFormModel ) - { - mpFormModel->InsertPage( mpFormModel->AllocPage( false ) ); - } + mpFormModel->InsertPage( mpFormModel->AllocPage( false ) ); } } } diff --git a/svx/source/items/customshapeitem.cxx b/svx/source/items/customshapeitem.cxx index 57ec15e6b5e3..9a86a3bdb4aa 100644 --- a/svx/source/items/customshapeitem.cxx +++ b/svx/source/items/customshapeitem.cxx @@ -201,37 +201,37 @@ void SdrCustomShapeGeometryItem::SetPropertyValue( const OUString& rSequenceName void SdrCustomShapeGeometryItem::ClearPropertyValue( const OUString& rPropName ) { - if ( aPropSeq.hasElements() ) + if ( !aPropSeq.hasElements() ) + return; + + PropertyHashMap::iterator aHashIter( aPropHashMap.find( rPropName ) ); + if ( aHashIter == aPropHashMap.end() ) + return; + + css::uno::Any& rSeqAny = aPropSeq[(*aHashIter).second].Value; + if (auto pSecSequence + = o3tl::tryAccess<css::uno::Sequence<beans::PropertyValue>>(rSeqAny)) { - PropertyHashMap::iterator aHashIter( aPropHashMap.find( rPropName ) ); - if ( aHashIter != aPropHashMap.end() ) + for (const auto& rPropVal : *pSecSequence) { - css::uno::Any& rSeqAny = aPropSeq[(*aHashIter).second].Value; - if (auto pSecSequence - = o3tl::tryAccess<css::uno::Sequence<beans::PropertyValue>>(rSeqAny)) - { - for (const auto& rPropVal : *pSecSequence) - { - auto _aHashIter(aPropPairHashMap.find(PropertyPair(rPropName, rPropVal.Name))); - if (_aHashIter != aPropPairHashMap.end()) - aPropPairHashMap.erase(_aHashIter); // removing property from pair hashmap - } - } - sal_Int32 nLength = aPropSeq.getLength(); - if ( nLength ) - { - sal_Int32 nIndex = (*aHashIter).second; - if ( nIndex != ( nLength - 1 ) ) // resizing sequence - { - PropertyHashMap::iterator aHashIter2( aPropHashMap.find( aPropSeq[ nLength - 1 ].Name ) ); - (*aHashIter2).second = nIndex; - aPropSeq[ nIndex ] = aPropSeq[ nLength - 1 ]; - } - aPropSeq.realloc( nLength - 1 ); - } - aPropHashMap.erase( aHashIter ); // removing property from hashmap + auto _aHashIter(aPropPairHashMap.find(PropertyPair(rPropName, rPropVal.Name))); + if (_aHashIter != aPropPairHashMap.end()) + aPropPairHashMap.erase(_aHashIter); // removing property from pair hashmap + } + } + sal_Int32 nLength = aPropSeq.getLength(); + if ( nLength ) + { + sal_Int32 nIndex = (*aHashIter).second; + if ( nIndex != ( nLength - 1 ) ) // resizing sequence + { + PropertyHashMap::iterator aHashIter2( aPropHashMap.find( aPropSeq[ nLength - 1 ].Name ) ); + (*aHashIter2).second = nIndex; + aPropSeq[ nIndex ] = aPropSeq[ nLength - 1 ]; } + aPropSeq.realloc( nLength - 1 ); } + aPropHashMap.erase( aHashIter ); // removing property from hashmap } SdrCustomShapeGeometryItem::~SdrCustomShapeGeometryItem() diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index ade17b02af62..718728907e94 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -284,24 +284,24 @@ void SvxNumberFormatShell::RemoveFormat(const OUString& rFormat, sal_uInt16& rCa DBG_ASSERT(nDelKey != NUMBERFORMAT_ENTRY_NOT_FOUND, "entry not found!"); DBG_ASSERT(!IsRemoved_Impl(nDelKey), "entry already removed!"); - if ((nDelKey != NUMBERFORMAT_ENTRY_NOT_FOUND) && !IsRemoved_Impl(nDelKey)) - { - aDelList.push_back(nDelKey); + if ((nDelKey == NUMBERFORMAT_ENTRY_NOT_FOUND) || IsRemoved_Impl(nDelKey)) + return; - ::std::vector<sal_uInt32>::iterator nAt = GetAdded_Impl(nDelKey); - if (nAt != aAddList.end()) - { - aAddList.erase(nAt); - } + aDelList.push_back(nDelKey); - nCurCategory = pFormatter->GetType(nDelKey); - pCurFmtTable = &(pFormatter->GetEntryTable(nCurCategory, nCurFormatKey, eCurLanguage)); + ::std::vector<sal_uInt32>::iterator nAt = GetAdded_Impl(nDelKey); + if (nAt != aAddList.end()) + { + aAddList.erase(nAt); + } - nCurFormatKey = pFormatter->GetStandardFormat(nCurCategory, eCurLanguage); + nCurCategory = pFormatter->GetType(nDelKey); + pCurFmtTable = &(pFormatter->GetEntryTable(nCurCategory, nCurFormatKey, eCurLanguage)); - CategoryToPos_Impl(nCurCategory, rCatLbSelPos); - rFmtSelPos = FillEntryList_Impl(rFmtEntries); - } + nCurFormatKey = pFormatter->GetStandardFormat(nCurCategory, eCurLanguage); + + CategoryToPos_Impl(nCurCategory, rCatLbSelPos); + rFmtSelPos = FillEntryList_Impl(rFmtEntries); } void SvxNumberFormatShell::MakeFormat(OUString& rFormat, bool bThousand, bool bNegRed, @@ -1361,30 +1361,30 @@ void SvxNumberFormatShell::GetCurrencySymbols(std::vector<OUString>& rList, sal_ SvxCurrencyToolBoxControl::GetCurrencySymbols(rList, bFlag, aCurCurrencyList); - if (pPos != nullptr) - { - const NfCurrencyTable& rCurrencyTable = SvNumberFormatter::GetTheCurrencyTable(); - sal_uInt16 nTableCount = rCurrencyTable.size(); + if (pPos == nullptr) + return; - *pPos = 0; - size_t nCount = aCurCurrencyList.size(); + const NfCurrencyTable& rCurrencyTable = SvNumberFormatter::GetTheCurrencyTable(); + sal_uInt16 nTableCount = rCurrencyTable.size(); - if (bFlag) - { - *pPos = 1; - nCurCurrencyEntryPos = 1; - } - else + *pPos = 0; + size_t nCount = aCurCurrencyList.size(); + + if (bFlag) + { + *pPos = 1; + nCurCurrencyEntryPos = 1; + } + else + { + for (size_t i = 1; i < nCount; i++) { - for (size_t i = 1; i < nCount; i++) + const sal_uInt16 j = aCurCurrencyList[i]; + if (j != sal_uInt16(-1) && j < nTableCount && pTmpCurrencyEntry == &rCurrencyTable[j]) { - const sal_uInt16 j = aCurCurrencyList[i]; - if (j != sal_uInt16(-1) && j < nTableCount && pTmpCurrencyEntry == &rCurrencyTable[j]) - { - *pPos = static_cast<sal_uInt16>(i); - nCurCurrencyEntryPos = static_cast<sal_uInt16>(i); - break; - } + *pPos = static_cast<sal_uInt16>(i); + nCurCurrencyEntryPos = static_cast<sal_uInt16>(i); + break; } } } @@ -1397,20 +1397,20 @@ void SvxNumberFormatShell::SetCurrencySymbol(sal_uInt32 nPos) bBankingSymbol = (nPos >= nCount); - if (nPos < aCurCurrencyList.size()) + if (nPos >= aCurCurrencyList.size()) + return; + + sal_uInt16 nCurrencyPos = aCurCurrencyList[nPos]; + if (nCurrencyPos != sal_uInt16(-1)) { - sal_uInt16 nCurrencyPos = aCurCurrencyList[nPos]; - if (nCurrencyPos != sal_uInt16(-1)) - { - pCurCurrencyEntry = const_cast<NfCurrencyEntry*>(&rCurrencyTable[nCurrencyPos]); - nCurCurrencyEntryPos = nPos; - } - else - { - pCurCurrencyEntry = nullptr; - nCurCurrencyEntryPos = 0; - nCurFormatKey = pFormatter->GetFormatIndex(NF_CURRENCY_1000DEC2_RED, eCurLanguage); - } + pCurCurrencyEntry = const_cast<NfCurrencyEntry*>(&rCurrencyTable[nCurrencyPos]); + nCurCurrencyEntryPos = nPos; + } + else + { + pCurCurrencyEntry = nullptr; + nCurCurrencyEntryPos = 0; + nCurFormatKey = pFormatter->GetFormatIndex(NF_CURRENCY_1000DEC2_RED, eCurLanguage); } } diff --git a/svx/source/sidebar/ContextChangeEventMultiplexer.cxx b/svx/source/sidebar/ContextChangeEventMultiplexer.cxx index ce1d5785f4dc..ce552b0ac837 100644 --- a/svx/source/sidebar/ContextChangeEventMultiplexer.cxx +++ b/svx/source/sidebar/ContextChangeEventMultiplexer.cxx @@ -36,25 +36,25 @@ void ContextChangeEventMultiplexer::NotifyContextChange ( const css::uno::Reference<css::frame::XController>& rxController, const vcl::EnumContext::Context eContext) { - if (rxController.is() && rxController->getFrame().is()) - { - const css::ui::ContextChangeEventObject aEvent( - rxController, - GetModuleName(rxController->getFrame()), - vcl::EnumContext::GetContextName(eContext)); + if (!(rxController.is() && rxController->getFrame().is())) + return; + + const css::ui::ContextChangeEventObject aEvent( + rxController, + GetModuleName(rxController->getFrame()), + vcl::EnumContext::GetContextName(eContext)); - css::uno::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( - css::ui::ContextChangeEventMultiplexer::get( - ::comphelper::getProcessComponentContext())); - if (xMultiplexer.is()) - xMultiplexer->broadcastContextChangeEvent(aEvent, rxController); + css::uno::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer ( + css::ui::ContextChangeEventMultiplexer::get( + ::comphelper::getProcessComponentContext())); + if (xMultiplexer.is()) + xMultiplexer->broadcastContextChangeEvent(aEvent, rxController); - // notify the LOK too after all the change have taken effect. - if (comphelper::LibreOfficeKit::isActive()) - { - if (SfxViewShell* pViewShell = SfxViewShell::Get(rxController)) - SfxLokHelper::notifyContextChange(pViewShell, GetModuleName(rxController->getFrame()), vcl::EnumContext::GetContextName(eContext)); - } + // notify the LOK too after all the change have taken effect. + if (comphelper::LibreOfficeKit::isActive()) + { + if (SfxViewShell* pViewShell = SfxViewShell::Get(rxController)) + SfxLokHelper::notifyContextChange(pViewShell, GetModuleName(rxController->getFrame()), vcl::EnumContext::GetContextName(eContext)); } } diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx index 357f7ba6ab63..5768e54002a0 100644 --- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx +++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx @@ -212,41 +212,41 @@ IMPL_LINK_NOARG(AreaPropertyPanelBase, ClickImportBitmapHdl, weld::Button&, void { SvxOpenGraphicDialog aDlg("Import", GetFrameWeld()); aDlg.EnableLink(false); - if( aDlg.Execute() == ERRCODE_NONE ) + if( aDlg.Execute() != ERRCODE_NONE ) + return; + + Graphic aGraphic; + EnterWait(); + ErrCode nError = aDlg.GetGraphic( aGraphic ); + LeaveWait(); + if( nError != ERRCODE_NONE ) + return; + + XBitmapListRef pList = SfxObjectShell::Current()->GetItem(SID_BITMAP_LIST)->GetBitmapList(); + INetURLObject aURL( aDlg.GetPath() ); + OUString aFileName = aURL.GetLastName().getToken(0, '.'); + OUString aName = aFileName; + long j = 1; + bool bValidBitmapName = false; + while( !bValidBitmapName ) { - Graphic aGraphic; - EnterWait(); - ErrCode nError = aDlg.GetGraphic( aGraphic ); - LeaveWait(); - if( nError == ERRCODE_NONE ) + bValidBitmapName = true; + for( long i = 0; i < pList->Count() && bValidBitmapName; i++ ) { - XBitmapListRef pList = SfxObjectShell::Current()->GetItem(SID_BITMAP_LIST)->GetBitmapList(); - INetURLObject aURL( aDlg.GetPath() ); - OUString aFileName = aURL.GetLastName().getToken(0, '.'); - OUString aName = aFileName; - long j = 1; - bool bValidBitmapName = false; - while( !bValidBitmapName ) + if( aName == pList->GetBitmap(i)->GetName() ) { - bValidBitmapName = true; - for( long i = 0; i < pList->Count() && bValidBitmapName; i++ ) - { - if( aName == pList->GetBitmap(i)->GetName() ) - { - bValidBitmapName = false; - aName = aFileName + OUString::number(j++); - } - } + bValidBitmapName = false; + aName = aFileName + OUString::number(j++); } - - pList->Insert(std::make_unique<XBitmapEntry>(aGraphic, aName)); - pList->Save(); - mxLbFillAttr->clear(); - SvxFillAttrBox::Fill(*mxLbFillAttr, pList); - mxLbFillAttr->set_active_text(aName); - SelectFillAttrHdl(*mxLbFillAttr); } } + + pList->Insert(std::make_unique<XBitmapEntry>(aGraphic, aName)); + pList->Save(); + mxLbFillAttr->clear(); + SvxFillAttrBox::Fill(*mxLbFillAttr, pList); + mxLbFillAttr->set_active_text(aName); + SelectFillAttrHdl(*mxLbFillAttr); } IMPL_LINK_NOARG(AreaPropertyPanelBase, SelectFillTypeHdl, weld::ComboBox&, void) diff --git a/svx/source/sidebar/inspector/InspectorTextPanel.cxx b/svx/source/sidebar/inspector/InspectorTextPanel.cxx index 2a212f33fe22..356dfd8cb975 100644 --- a/svx/source/sidebar/inspector/InspectorTextPanel.cxx +++ b/svx/source/sidebar/inspector/InspectorTextPanel.cxx @@ -107,23 +107,23 @@ static void FillBox_Impl(weld::TreeView& rListBoxStyles, const TreeNode& rCurren const OUString& rName = rCurrent.sNodeName; OUString sPairValue; - if (rCurrent.NodeType != TreeNode::SimpleProperty - || GetPropertyValues(rName, rCurrent.aValue, sPairValue)) + if (!(rCurrent.NodeType != TreeNode::SimpleProperty + || GetPropertyValues(rName, rCurrent.aValue, sPairValue))) + return; + + rListBoxStyles.insert(pParent, -1, &rName, nullptr, nullptr, nullptr, false, pResult.get()); + rListBoxStyles.set_sensitive(*pResult, !rCurrent.isGrey, 0); + rListBoxStyles.set_text_emphasis(*pResult, rCurrent.NodeType == TreeNode::Category, 0); + + if (rCurrent.NodeType == TreeNode::SimpleProperty) { - rListBoxStyles.insert(pParent, -1, &rName, nullptr, nullptr, nullptr, false, pResult.get()); - rListBoxStyles.set_sensitive(*pResult, !rCurrent.isGrey, 0); - rListBoxStyles.set_text_emphasis(*pResult, rCurrent.NodeType == TreeNode::Category, 0); - - if (rCurrent.NodeType == TreeNode::SimpleProperty) - { - rListBoxStyles.set_text(*pResult, sPairValue, 1); - rListBoxStyles.set_sensitive(*pResult, !rCurrent.isGrey, 1); - rListBoxStyles.set_text_emphasis(*pResult, false, 1); - } - - for (const TreeNode& rChildNode : rCurrent.children) - FillBox_Impl(rListBoxStyles, rChildNode, pResult.get()); + rListBoxStyles.set_text(*pResult, sPairValue, 1); + rListBoxStyles.set_sensitive(*pResult, !rCurrent.isGrey, 1); + rListBoxStyles.set_text_emphasis(*pResult, false, 1); } + + for (const TreeNode& rChildNode : rCurrent.children) + FillBox_Impl(rListBoxStyles, rChildNode, pResult.get()); } void InspectorTextPanel::updateEntries(const std::vector<TreeNode>& rStore) diff --git a/svx/source/sidebar/line/LinePropertyPanelBase.cxx b/svx/source/sidebar/line/LinePropertyPanelBase.cxx index d78e2358436a..1038be5c5351 100644 --- a/svx/source/sidebar/line/LinePropertyPanelBase.cxx +++ b/svx/source/sidebar/line/LinePropertyPanelBase.cxx @@ -326,67 +326,67 @@ IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeEdgeStyleHdl, weld::ComboBox&, void { const sal_Int32 nPos(mxLBEdgeStyle->get_active()); - if (nPos != -1 && mxLBEdgeStyle->get_value_changed_from_saved()) - { - std::unique_ptr<XLineJointItem> pItem; + if (nPos == -1 || !mxLBEdgeStyle->get_value_changed_from_saved()) + return; + + std::unique_ptr<XLineJointItem> pItem; - switch(nPos) + switch(nPos) + { + case 0: // rounded { - case 0: // rounded - { - pItem.reset(new XLineJointItem(drawing::LineJoint_ROUND)); - break; - } - case 1: // none - { - pItem.reset(new XLineJointItem(drawing::LineJoint_NONE)); - break; - } - case 2: // mitered - { - pItem.reset(new XLineJointItem(drawing::LineJoint_MITER)); - break; - } - case 3: // beveled - { - pItem.reset(new XLineJointItem(drawing::LineJoint_BEVEL)); - break; - } + pItem.reset(new XLineJointItem(drawing::LineJoint_ROUND)); + break; + } + case 1: // none + { + pItem.reset(new XLineJointItem(drawing::LineJoint_NONE)); + break; + } + case 2: // mitered + { + pItem.reset(new XLineJointItem(drawing::LineJoint_MITER)); + break; + } + case 3: // beveled + { + pItem.reset(new XLineJointItem(drawing::LineJoint_BEVEL)); + break; } - - setLineJoint(pItem.get()); } + + setLineJoint(pItem.get()); } IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeCapStyleHdl, weld::ComboBox&, void) { const sal_Int32 nPos(mxLBCapStyle->get_active()); - if (nPos != -1 && mxLBCapStyle->get_value_changed_from_saved()) - { - std::unique_ptr<XLineCapItem> pItem; + if (!(nPos != -1 && mxLBCapStyle->get_value_changed_from_saved())) + return; + + std::unique_ptr<XLineCapItem> pItem; - switch(nPos) + switch(nPos) + { + case 0: // flat { - case 0: // flat - { - pItem.reset(new XLineCapItem(drawing::LineCap_BUTT)); - break; - } - case 1: // round - { - pItem.reset(new XLineCapItem(drawing::LineCap_ROUND)); - break; - } - case 2: // square - { - pItem.reset(new XLineCapItem(drawing::LineCap_SQUARE)); - break; - } + pItem.reset(new XLineCapItem(drawing::LineCap_BUTT)); + break; + } + case 1: // round + { + pItem.reset(new XLineCapItem(drawing::LineCap_ROUND)); + break; + } + case 2: // square + { + pItem.reset(new XLineCapItem(drawing::LineCap_SQUARE)); + break; } - - setLineCap(pItem.get()); } + + setLineCap(pItem.get()); } IMPL_LINK_NOARG(LinePropertyPanelBase, ToolboxWidthSelectHdl, const OString&, void) diff --git a/svx/source/sidebar/nbdtmg.cxx b/svx/source/sidebar/nbdtmg.cxx index 627da9eaee8e..3d995028bb99 100644 --- a/svx/source/sidebar/nbdtmg.cxx +++ b/svx/source/sidebar/nbdtmg.cxx @@ -141,30 +141,30 @@ sal_uInt16 NBOTypeMgrBase:: IsSingleLevel(sal_uInt16 nCurLevel) void NBOTypeMgrBase::SetItems(const SfxItemSet* pArg) { pSet = pArg; - if ( pSet ) - { - SfxAllItemSet aSet(*pSet); + if ( !pSet ) + return; + + SfxAllItemSet aSet(*pSet); - const SfxStringItem* pBulletCharFmt = aSet.GetItem<SfxStringItem>(SID_BULLET_CHAR_FMT, false); - if (pBulletCharFmt) - aBulletCharFmtName = pBulletCharFmt->GetValue(); + const SfxStringItem* pBulletCharFmt = aSet.GetItem<SfxStringItem>(SID_BULLET_CHAR_FMT, false); + if (pBulletCharFmt) + aBulletCharFmtName = pBulletCharFmt->GetValue(); - const SfxStringItem* pNumCharFmt = aSet.GetItem<SfxStringItem>(SID_NUM_CHAR_FMT, false); - if (pNumCharFmt) - aNumCharFmtName = pNumCharFmt->GetValue(); + const SfxStringItem* pNumCharFmt = aSet.GetItem<SfxStringItem>(SID_NUM_CHAR_FMT, false); + if (pNumCharFmt) + aNumCharFmtName = pNumCharFmt->GetValue(); - const SfxPoolItem* pItem; - SfxItemState eState = pSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); + const SfxPoolItem* pItem; + SfxItemState eState = pSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); + if(eState == SfxItemState::SET) + { + eCoreUnit = pSet->GetPool()->GetMetric(pSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE)); + } else { + //sd use different sid for numbering rule + eState = pSet->GetItemState(EE_PARA_NUMBULLET, false, &pItem); if(eState == SfxItemState::SET) { - eCoreUnit = pSet->GetPool()->GetMetric(pSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE)); - } else { - //sd use different sid for numbering rule - eState = pSet->GetItemState(EE_PARA_NUMBULLET, false, &pItem); - if(eState == SfxItemState::SET) - { - eCoreUnit = pSet->GetPool()->GetMetric(pSet->GetPool()->GetWhich(EE_PARA_NUMBULLET)); - } + eCoreUnit = pSet->GetPool()->GetMetric(pSet->GetPool()->GetWhich(EE_PARA_NUMBULLET)); } } } diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx index 322e6700ad80..eb5913f5efb0 100644 --- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx +++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx @@ -1066,20 +1066,20 @@ void PosSizePropertyPanel::SetPosSizeMinMax() void PosSizePropertyPanel::UpdateUIScale() { const Fraction aUIScale (mpView->GetModel()->GetUIScale()); - if (maUIScale != aUIScale) - { - // UI scale has changed. + if (maUIScale == aUIScale) + return; - // Remember the new UI scale. - maUIScale = aUIScale; + // UI scale has changed. - // The content of the position and size boxes is only updated when item changes are notified. - // Request such notifications without changing the actual item values. - GetBindings()->Invalidate(SID_ATTR_TRANSFORM_POS_X, true); - GetBindings()->Invalidate(SID_ATTR_TRANSFORM_POS_Y, true); - GetBindings()->Invalidate(SID_ATTR_TRANSFORM_WIDTH, true); - GetBindings()->Invalidate(SID_ATTR_TRANSFORM_HEIGHT, true); - } + // Remember the new UI scale. + maUIScale = aUIScale; + + // The content of the position and size boxes is only updated when item changes are notified. + // Request such notifications without changing the actual item values. + GetBindings()->Invalidate(SID_ATTR_TRANSFORM_POS_X, true); + GetBindings()->Invalidate(SID_ATTR_TRANSFORM_POS_Y, true); + GetBindings()->Invalidate(SID_ATTR_TRANSFORM_WIDTH, true); + GetBindings()->Invalidate(SID_ATTR_TRANSFORM_HEIGHT, true); } diff --git a/svx/source/smarttags/SmartTagMgr.cxx b/svx/source/smarttags/SmartTagMgr.cxx index a81bce9609c3..8d82643c82aa 100644 --- a/svx/source/smarttags/SmartTagMgr.cxx +++ b/svx/source/smarttags/SmartTagMgr.cxx @@ -202,49 +202,49 @@ bool SmartTagMgr::IsSmartTagTypeEnabled( const OUString& rSmartTagType ) const void SmartTagMgr::WriteConfiguration( const bool* pIsLabelTextWithSmartTags, const std::vector< OUString >* pDisabledTypes ) const { - if ( mxConfigurationSettings.is() ) + if ( !mxConfigurationSettings.is() ) + return; + + bool bCommit = false; + + if ( pIsLabelTextWithSmartTags ) { - bool bCommit = false; + const Any aEnabled = makeAny( *pIsLabelTextWithSmartTags ); - if ( pIsLabelTextWithSmartTags ) + try { - const Any aEnabled = makeAny( *pIsLabelTextWithSmartTags ); - - try - { - mxConfigurationSettings->setPropertyValue( "RecognizeSmartTags", aEnabled ); - bCommit = true; - } - catch ( css::uno::Exception& ) - { - } + mxConfigurationSettings->setPropertyValue( "RecognizeSmartTags", aEnabled ); + bCommit = true; } - - if ( pDisabledTypes ) + catch ( css::uno::Exception& ) { - Sequence< OUString > aTypes = comphelper::containerToSequence(*pDisabledTypes); + } + } - const Any aNewTypes = makeAny( aTypes ); + if ( pDisabledTypes ) + { + Sequence< OUString > aTypes = comphelper::containerToSequence(*pDisabledTypes); - try - { - mxConfigurationSettings->setPropertyValue( "ExcludedSmartTagTypes", aNewTypes ); - bCommit = true; - } - catch ( css::uno::Exception& ) - { - } + const Any aNewTypes = makeAny( aTypes ); + + try + { + mxConfigurationSettings->setPropertyValue( "ExcludedSmartTagTypes", aNewTypes ); + bCommit = true; } + catch ( css::uno::Exception& ) + { + } + } - if ( bCommit ) + if ( bCommit ) + { + try + { + Reference< util::XChangesBatch >( mxConfigurationSettings, UNO_QUERY_THROW )->commitChanges(); + } + catch ( css::uno::Exception& ) { - try - { - Reference< util::XChangesBatch >( mxConfigurationSettings, UNO_QUERY_THROW )->commitChanges(); - } - catch ( css::uno::Exception& ) - { - } } } } @@ -415,28 +415,28 @@ void SmartTagMgr::PrepareConfiguration( const OUString& rConfigurationGroupName void SmartTagMgr::ReadConfiguration( bool bExcludedTypes, bool bRecognize ) { - if ( mxConfigurationSettings.is() ) + if ( !mxConfigurationSettings.is() ) + return; + + if ( bExcludedTypes ) { - if ( bExcludedTypes ) - { - maDisabledSmartTagTypes.clear(); + maDisabledSmartTagTypes.clear(); - Any aAny = mxConfigurationSettings->getPropertyValue( "ExcludedSmartTagTypes" ); - Sequence< OUString > aValues; - aAny >>= aValues; + Any aAny = mxConfigurationSettings->getPropertyValue( "ExcludedSmartTagTypes" ); + Sequence< OUString > aValues; + aAny >>= aValues; - for ( const auto& rValue : std::as_const(aValues) ) - maDisabledSmartTagTypes.insert( rValue ); - } + for ( const auto& rValue : std::as_const(aValues) ) + maDisabledSmartTagTypes.insert( rValue ); + } - if ( bRecognize ) - { - Any aAny = mxConfigurationSettings->getPropertyValue( "RecognizeSmartTags" ); - bool bValue = true; - aAny >>= bValue; + if ( bRecognize ) + { + Any aAny = mxConfigurationSettings->getPropertyValue( "RecognizeSmartTags" ); + bool bValue = true; + aAny >>= bValue; - mbLabelTextWithSmartTags = bValue; - } + mbLabelTextWithSmartTags = bValue; } } diff --git a/svx/source/table/accessiblecell.cxx b/svx/source/table/accessiblecell.cxx index 2a584ff58dd8..39f520fed028 100644 --- a/svx/source/table/accessiblecell.cxx +++ b/svx/source/table/accessiblecell.cxx @@ -70,18 +70,18 @@ void AccessibleCell::Init() { SdrView* pView = maShapeTreeInfo.GetSdrView(); const vcl::Window* pWindow = maShapeTreeInfo.GetWindow (); - if( (pView != nullptr) && (pWindow != nullptr) && mxCell.is()) + if( !((pView != nullptr) && (pWindow != nullptr) && mxCell.is())) + return; + + // create AccessibleTextHelper to handle this shape's text + if( mxCell->CanCreateEditOutlinerParaObject() || mxCell->GetOutlinerParaObject() != nullptr ) { - // create AccessibleTextHelper to handle this shape's text - if( mxCell->CanCreateEditOutlinerParaObject() || mxCell->GetOutlinerParaObject() != nullptr ) - { - // non-empty text -> use full-fledged edit source right away + // non-empty text -> use full-fledged edit source right away - mpText.reset( new AccessibleTextHelper( std::make_unique<SvxTextEditSource>(mxCell->GetObject(), mxCell.get(), *pView, *pWindow) ) ); - if( mxCell.is() && mxCell->IsActiveCell() ) - mpText->SetFocus(); - mpText->SetEventSource(this); - } + mpText.reset( new AccessibleTextHelper( std::make_unique<SvxTextEditSource>(mxCell->GetObject(), mxCell.get(), *pView, *pWindow) ) ); + if( mxCell.is() && mxCell->IsActiveCell() ) + mpText->SetFocus(); + mpText->SetEventSource(this); } } diff --git a/svx/source/table/accessibletableshape.cxx b/svx/source/table/accessibletableshape.cxx index 2b55d0e8c365..691dffc76982 100644 --- a/svx/source/table/accessibletableshape.cxx +++ b/svx/source/table/accessibletableshape.cxx @@ -221,7 +221,10 @@ void AccessibleTableShapeImpl::getColumnAndRow( sal_Int32 nChildIndex, sal_Int32 // XModifyListener void SAL_CALL AccessibleTableShapeImpl::modified( const EventObject& /*aEvent*/ ) { - if( mxTable.is() ) try + if( !mxTable.is() ) + return; + + try { // structural changes may have happened to the table, validate all accessible cell instances AccessibleCellMap aTempChildMap; @@ -706,20 +709,20 @@ void SAL_CALL AccessibleTableShape::selectAccessibleChild( sal_Int32 nChildIndex // todo, select table shape?!? SvxTableController* pController = getTableController(); - if( pController ) + if( !pController ) + return; + + CellPos aFirstPos( aPos ), aLastPos( aPos ); + if( pController->hasSelectedCells() ) { - CellPos aFirstPos( aPos ), aLastPos( aPos ); - if( pController->hasSelectedCells() ) - { - pController->getSelectedCells( aFirstPos, aLastPos ); + pController->getSelectedCells( aFirstPos, aLastPos ); - aFirstPos.mnRow = std::min( aFirstPos.mnRow, aPos.mnRow ); - aFirstPos.mnCol = std::min( aFirstPos.mnCol, aPos.mnCol ); - aLastPos.mnRow = std::max( aLastPos.mnRow, aPos.mnRow ); - aLastPos.mnCol = std::max( aLastPos.mnCol, aPos.mnCol ); - } - pController->setSelectedCells( aFirstPos, aLastPos ); + aFirstPos.mnRow = std::min( aFirstPos.mnRow, aPos.mnRow ); + aFirstPos.mnCol = std::min( aFirstPos.mnCol, aPos.mnCol ); + aLastPos.mnRow = std::max( aLastPos.mnRow, aPos.mnRow ); + aLastPos.mnCol = std::max( aLastPos.mnCol, aPos.mnCol ); } + pController->setSelectedCells( aFirstPos, aLastPos ); } @@ -802,23 +805,23 @@ void SAL_CALL AccessibleTableShape::deselectAccessibleChild( sal_Int32 nChildInd // todo, select table shape?!? SvxTableController* pController = getTableController(); - if( pController && pController->hasSelectedCells() ) - { - CellPos aFirstPos, aLastPos; - pController->getSelectedCells( aFirstPos, aLastPos ); + if( !(pController && pController->hasSelectedCells()) ) + return; - // create a selection where aPos is not part of anymore - aFirstPos.mnRow = std::min( aFirstPos.mnRow, aPos.mnRow+1 ); - aFirstPos.mnCol = std::min( aFirstPos.mnCol, aPos.mnCol+1 ); - aLastPos.mnRow = std::max( aLastPos.mnRow, aPos.mnRow-1 ); - aLastPos.mnCol = std::max( aLastPos.mnCol, aPos.mnCol-1 ); - - // new selection may be invalid (child to deselect is not at a border of the selection but in between) - if( (aFirstPos.mnRow > aLastPos.mnRow) || (aFirstPos.mnCol > aLastPos.mnCol) ) - pController->clearSelection(); // if selection is invalid, clear all - else - pController->setSelectedCells( aFirstPos, aLastPos ); - } + CellPos aFirstPos, aLastPos; + pController->getSelectedCells( aFirstPos, aLastPos ); + + // create a selection where aPos is not part of anymore + aFirstPos.mnRow = std::min( aFirstPos.mnRow, aPos.mnRow+1 ); + aFirstPos.mnCol = std::min( aFirstPos.mnCol, aPos.mnCol+1 ); + aLastPos.mnRow = std::max( aLastPos.mnRow, aPos.mnRow-1 ); + aLastPos.mnCol = std::max( aLastPos.mnCol, aPos.mnCol-1 ); + + // new selection may be invalid (child to deselect is not at a border of the selection but in between) + if( (aFirstPos.mnRow > aLastPos.mnRow) || (aFirstPos.mnCol > aLastPos.mnCol) ) + pController->clearSelection(); // if selection is invalid, clear all + else + pController->setSelectedCells( aFirstPos, aLastPos ); } // XAccessibleTableSelection @@ -896,32 +899,32 @@ void SAL_CALL AccessibleTableShape::selectionChanged (const EventObject& rEvent { //sdr::table::CellRef xCellRef = static_cast< sdr::table::CellRef > (rEvent.Source); Reference< XCell > xCell(rEvent.Source, UNO_QUERY); - if (xCell.is()) + if (!xCell.is()) + return; + + rtl::Reference< AccessibleCell > xAccCell = mxImpl->getAccessibleCell( xCell ); + if (!xAccCell.is()) + return; + + sal_Int32 nIndex = xAccCell->getAccessibleIndexInParent(), + nCount = getSelectedAccessibleChildCount(); + bool bSelected = isAccessibleChildSelected(nIndex); + if (mnPreviousSelectionCount == 0 && nCount > 0 && bSelected) { - rtl::Reference< AccessibleCell > xAccCell = mxImpl->getAccessibleCell( xCell ); - if (xAccCell.is()) - { - sal_Int32 nIndex = xAccCell->getAccessibleIndexInParent(), - nCount = getSelectedAccessibleChildCount(); - bool bSelected = isAccessibleChildSelected(nIndex); - if (mnPreviousSelectionCount == 0 && nCount > 0 && bSelected) - { - xAccCell->SetState(AccessibleStateType::SELECTED); - xAccCell->CommitChange(AccessibleEventId::SELECTION_CHANGED, Any(), Any()); - } - else if (bSelected) - { - xAccCell->SetState(AccessibleStateType::SELECTED); - xAccCell->CommitChange(AccessibleEventId::SELECTION_CHANGED_ADD, Any(), Any()); - } - else - { - xAccCell->ResetState(AccessibleStateType::SELECTED); - xAccCell->CommitChange(AccessibleEventId::SELECTION_CHANGED_REMOVE, Any(), Any()); - } - mnPreviousSelectionCount = nCount; - } + xAccCell->SetState(AccessibleStateType::SELECTED); + xAccCell->CommitChange(AccessibleEventId::SELECTION_CHANGED, Any(), Any()); + } + else if (bSelected) + { + xAccCell->SetState(AccessibleStateType::SELECTED); + xAccCell->CommitChange(AccessibleEventId::SELECTION_CHANGED_ADD, Any(), Any()); + } + else + { + xAccCell->ResetState(AccessibleStateType::SELECTED); + xAccCell->CommitChange(AccessibleEventId::SELECTION_CHANGED_REMOVE, Any(), Any()); } + mnPreviousSelectionCount = nCount; } // Get the currently active cell which is text editing AccessibleCell* AccessibleTableShape::GetActiveAccessibleCell() diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index 070e47952776..d587b2324245 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -470,27 +470,27 @@ void Cell::mergeContent( const CellRef& xSourceCell ) { SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); - if( xSourceCell->hasText() ) - { - SdrOutliner& rOutliner=rTableObj.ImpGetDrawOutliner(); - rOutliner.SetUpdateMode(true); + if( !xSourceCell->hasText() ) + return; - if( hasText() ) - { - rOutliner.SetText(*GetOutlinerParaObject()); - rOutliner.AddText(*xSourceCell->GetOutlinerParaObject()); - } - else - { - rOutliner.SetText(*xSourceCell->GetOutlinerParaObject()); - } + SdrOutliner& rOutliner=rTableObj.ImpGetDrawOutliner(); + rOutliner.SetUpdateMode(true); - SetOutlinerParaObject( rOutliner.CreateParaObject() ); - rOutliner.Clear(); - xSourceCell->SetOutlinerParaObject(rOutliner.CreateParaObject()); - rOutliner.Clear(); - SetStyleSheet( GetStyleSheet(), true ); + if( hasText() ) + { + rOutliner.SetText(*GetOutlinerParaObject()); + rOutliner.AddText(*xSourceCell->GetOutlinerParaObject()); + } + else + { + rOutliner.SetText(*xSourceCell->GetOutlinerParaObject()); } + + SetOutlinerParaObject( rOutliner.CreateParaObject() ); + rOutliner.Clear(); + xSourceCell->SetOutlinerParaObject(rOutliner.CreateParaObject()); + rOutliner.Clear(); + SetStyleSheet( GetStyleSheet(), true ); } @@ -516,26 +516,26 @@ void Cell::cloneFrom( const CellRef& xCell ) void Cell::replaceContentAndFormating( const CellRef& xSourceCell ) { - if( xSourceCell.is() && mpProperties ) - { - mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() ); + if( !(xSourceCell.is() && mpProperties) ) + return; - // tdf#118354 OutlinerParaObject may be nullptr, do not dereference when - // not set (!) - if(nullptr != xSourceCell->GetOutlinerParaObject()) - { - SetOutlinerParaObject( std::make_unique<OutlinerParaObject>(*xSourceCell->GetOutlinerParaObject()) ); - } + mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() ); - SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); - SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() ); + // tdf#118354 OutlinerParaObject may be nullptr, do not dereference when + // not set (!) + if(nullptr != xSourceCell->GetOutlinerParaObject()) + { + SetOutlinerParaObject( std::make_unique<OutlinerParaObject>(*xSourceCell->GetOutlinerParaObject()) ); + } - if(&rSourceTableObj.getSdrModelFromSdrObject() != &rTableObj.getSdrModelFromSdrObject()) - { - // TTTT should not happen - if, then a clone may be needed - // Maybe add an assertion here later - SetStyleSheet( nullptr, true ); - } + SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); + SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() ); + + if(&rSourceTableObj.getSdrModelFromSdrObject() != &rTableObj.getSdrModelFromSdrObject()) + { + // TTTT should not happen - if, then a clone may be needed + // Maybe add an assertion here later + SetStyleSheet( nullptr, true ); } } @@ -552,21 +552,21 @@ void Cell::setMerged() void Cell::copyFormatFrom( const CellRef& xSourceCell ) { - if( xSourceCell.is() && mpProperties ) - { - mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() ); - SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); - SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() ); + if( !(xSourceCell.is() && mpProperties) ) + return; - if(&rSourceTableObj.getSdrModelFromSdrObject() != &rTableObj.getSdrModelFromSdrObject()) - { - // TTTT should not happen - if, then a clone may be needed - // Maybe add an assertion here later - SetStyleSheet( nullptr, true ); - } + mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() ); + SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); + SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() ); - notifyModified(); + if(&rSourceTableObj.getSdrModelFromSdrObject() != &rTableObj.getSdrModelFromSdrObject()) + { + // TTTT should not happen - if, then a clone may be needed + // Maybe add an assertion here later + SetStyleSheet( nullptr, true ); } + + notifyModified(); } @@ -1589,21 +1589,21 @@ void SAL_CALL Cell::setAllPropertiesToDefault() SdrOutliner& rOutliner = GetObject().ImpGetDrawOutliner(); OutlinerParaObject* pParaObj = GetOutlinerParaObject(); - if( pParaObj ) - { - rOutliner.SetText(*pParaObj); - sal_Int32 nParaCount(rOutliner.GetParagraphCount()); + if( !pParaObj ) + return; - if(nParaCount) - { - ESelection aSelection( 0, 0, EE_PARA_ALL, EE_TEXTPOS_ALL); - rOutliner.RemoveAttribs(aSelection, true, 0); + rOutliner.SetText(*pParaObj); + sal_Int32 nParaCount(rOutliner.GetParagraphCount()); + + if(nParaCount) + { + ESelection aSelection( 0, 0, EE_PARA_ALL, EE_TEXTPOS_ALL); + rOutliner.RemoveAttribs(aSelection, true, 0); - std::unique_ptr<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount); - rOutliner.Clear(); + std::unique_ptr<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount); + rOutliner.Clear(); - SetOutlinerParaObject(std::move(pTemp)); - } + SetOutlinerParaObject(std::move(pTemp)); } } diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 79ba8a93e2d8..202006d828a8 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -585,7 +585,10 @@ void SdrTableObjImpl::dispose() void SdrTableObjImpl::DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset ) { - if( (nEdge >= 0) && mxTable.is()) try + if( !((nEdge >= 0) && mxTable.is())) + return; + + try { const OUString sSize( "Size" ); if( mbHorizontal ) @@ -670,28 +673,28 @@ void SdrTableObjImpl::update() { // source can be the table model itself or the assigned table template TableModelNotifyGuard aGuard( mxTable.get() ); - if( mpTableObj ) + if( !mpTableObj ) + return; + + if( (maEditPos.mnRow >= getRowCount()) || (maEditPos.mnCol >= getColumnCount()) || (getCell( maEditPos ) != mxActiveCell) ) { - if( (maEditPos.mnRow >= getRowCount()) || (maEditPos.mnCol >= getColumnCount()) || (getCell( maEditPos ) != mxActiveCell) ) - { - if(maEditPos.mnRow >= getRowCount()) - maEditPos.mnRow = getRowCount()-1; + if(maEditPos.mnRow >= getRowCount()) + maEditPos.mnRow = getRowCount()-1; - if(maEditPos.mnCol >= getColumnCount()) - maEditPos.mnCol = getColumnCount()-1; + if(maEditPos.mnCol >= getColumnCount()) + maEditPos.mnCol = getColumnCount()-1; - mpTableObj->setActiveCell( maEditPos ); - } + mpTableObj->setActiveCell( maEditPos ); + } - ApplyCellStyles(); + ApplyCellStyles(); - mpTableObj->maRect = mpTableObj->maLogicRect; - LayoutTable( mpTableObj->maRect, false, false ); + mpTableObj->maRect = mpTableObj->maLogicRect; + LayoutTable( mpTableObj->maRect, false, false ); - mpTableObj->SetRectsDirty(); - mpTableObj->ActionChanged(); - mpTableObj->BroadcastObjectChange(); - } + mpTableObj->SetRectsDirty(); + mpTableObj->ActionChanged(); + mpTableObj->BroadcastObjectChange(); } @@ -789,40 +792,40 @@ void SdrTableObjImpl::LayoutTable( tools::Rectangle& rArea, bool bFitWidth, bool { if (utl::ConfigManager::IsFuzzing()) return; - if(mpLayouter) - { - // Optimization: SdrTableObj::SetChanged() can call this very often, repeatedly - // with the same settings, noticeably increasing load time. Skip if already done. - bool bInteractiveMightGrowBecauseTextChanged = - mpTableObj->IsReallyEdited() && (mpTableObj->IsAutoGrowHeight() || mpTableObj->IsAutoGrowWidth()); - WritingMode writingMode = mpTableObj->GetWritingMode(); - if( bInteractiveMightGrowBecauseTextChanged - || lastLayoutTable != this || lastLayoutInputRectangle != rArea - || lastLayoutFitWidth != bFitWidth || lastLayoutFitHeight != bFitHeight - || lastLayoutMode != writingMode - || lastRowCount != getRowCount() - || lastColCount != getColumnCount() - || lastColWidths != getColumnWidths() ) - { - lastLayoutTable = this; - lastLayoutInputRectangle = rArea; - lastLayoutFitWidth = bFitWidth; - lastLayoutFitHeight = bFitHeight; - lastLayoutMode = writingMode; - lastRowCount = getRowCount(); - lastColCount = getColumnCount(); - // Column resize, when the total width and column count of the - // table is unchanged, but re-layout is still needed. - lastColWidths = getColumnWidths(); - TableModelNotifyGuard aGuard( mxTable.get() ); - mpLayouter->LayoutTable( rArea, bFitWidth, bFitHeight ); - lastLayoutResultRectangle = rArea; - } - else - { - rArea = lastLayoutResultRectangle; - mpLayouter->UpdateBorderLayout(); - } + if(!mpLayouter) + return; + + // Optimization: SdrTableObj::SetChanged() can call this very often, repeatedly + // with the same settings, noticeably increasing load time. Skip if already done. + bool bInteractiveMightGrowBecauseTextChanged = + mpTableObj->IsReallyEdited() && (mpTableObj->IsAutoGrowHeight() || mpTableObj->IsAutoGrowWidth()); + WritingMode writingMode = mpTableObj->GetWritingMode(); + if( bInteractiveMightGrowBecauseTextChanged + || lastLayoutTable != this || lastLayoutInputRectangle != rArea + || lastLayoutFitWidth != bFitWidth || lastLayoutFitHeight != bFitHeight + || lastLayoutMode != writingMode + || lastRowCount != getRowCount() + || lastColCount != getColumnCount() + || lastColWidths != getColumnWidths() ) + { + lastLayoutTable = this; + lastLayoutInputRectangle = rArea; + lastLayoutFitWidth = bFitWidth; + lastLayoutFitHeight = bFitHeight; + lastLayoutMode = writingMode; + lastRowCount = getRowCount(); + lastColCount = getColumnCount(); + // Column resize, when the total width and column count of the + // table is unchanged, but re-layout is still needed. + lastColWidths = getColumnWidths(); + TableModelNotifyGuard aGuard( mxTable.get() ); + mpLayouter->LayoutTable( rArea, bFitWidth, bFitHeight ); + lastLayoutResultRectangle = rArea; + } + else + { + rArea = lastLayoutResultRectangle; + mpLayouter->UpdateBorderLayout(); } } @@ -1577,7 +1580,10 @@ void SdrTableObj::changeEdge(bool bHorizontal, int nEdge, sal_Int32 nOffset) void SdrTableObj::setActiveCell( const CellPos& rPos ) { - if( mpImpl.is() && mpImpl->mxTable.is() ) try + if( !(mpImpl.is() && mpImpl->mxTable.is()) ) + return; + + try { mpImpl->mxActiveCell.set( dynamic_cast< Cell* >( mpImpl->mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ).get() ) ); if( mpImpl->mxActiveCell.is() && mpImpl->mxActiveCell->isMerged() ) @@ -1905,20 +1911,20 @@ OutlinerParaObject* SdrTableObj::GetOutlinerParaObject() const void SdrTableObj::NbcSetOutlinerParaObject( std::unique_ptr<OutlinerParaObject> pTextObject) { CellRef xCell( getActiveCell() ); - if( xCell.is() ) - { - // Update HitTestOutliner - const SdrTextObj* pTestObj(getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj()); + if( !xCell.is() ) + return; - if(pTestObj && pTestObj->GetOutlinerParaObject() == xCell->GetOutlinerParaObject()) - { - getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr); - } + // Update HitTestOutliner + const SdrTextObj* pTestObj(getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj()); - xCell->SetOutlinerParaObject( std::move(pTextObject) ); - SetTextSizeDirty(); - NbcAdjustTextFrameWidthAndHeight(); + if(pTestObj && pTestObj->GetOutlinerParaObject() == xCell->GetOutlinerParaObject()) + { + getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr); } + + xCell->SetOutlinerParaObject( std::move(pTextObject) ); + SetTextSizeDirty(); + NbcAdjustTextFrameWidthAndHeight(); } diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx index c9c3e7177737..2169f04599dc 100644 --- a/svx/source/table/tablecontroller.cxx +++ b/svx/source/table/tablecontroller.cxx @@ -855,35 +855,35 @@ void SvxTableController::onDelete( sal_uInt16 nSId ) void SvxTableController::onSelect( sal_uInt16 nSId ) { - if( mxTable.is() ) - { - const sal_Int32 nRowCount = mxTable->getRowCount(); - const sal_Int32 nColCount = mxTable->getColumnCount(); - if( nRowCount && nColCount ) - { - CellPos aStart, aEnd; - getSelectedCells( aStart, aEnd ); + if( !mxTable.is() ) + return; - switch( nSId ) - { - case SID_TABLE_SELECT_ALL: - aEnd.mnCol = 0; aEnd.mnRow = 0; - aStart.mnCol = nColCount - 1; aStart.mnRow = nRowCount - 1; - break; - case SID_TABLE_SELECT_COL: - aEnd.mnRow = nRowCount - 1; - aStart.mnRow = 0; - break; - case SID_TABLE_SELECT_ROW: - aEnd.mnCol = nColCount - 1; - aStart.mnCol = 0; - break; - } + const sal_Int32 nRowCount = mxTable->getRowCount(); + const sal_Int32 nColCount = mxTable->getColumnCount(); + if( !(nRowCount && nColCount) ) + return; - StartSelection( aEnd ); - gotoCell( aStart, true, nullptr ); - } + CellPos aStart, aEnd; + getSelectedCells( aStart, aEnd ); + + switch( nSId ) + { + case SID_TABLE_SELECT_ALL: + aEnd.mnCol = 0; aEnd.mnRow = 0; + aStart.mnCol = nColCount - 1; aStart.mnRow = nRowCount - 1; + break; + case SID_TABLE_SELECT_COL: + aEnd.mnRow = nRowCount - 1; + aStart.mnRow = 0; + break; + case SID_TABLE_SELECT_ROW: + aEnd.mnCol = nColCount - 1; + aStart.mnCol = 0; + break; } + + StartSelection( aEnd ); + gotoCell( aStart, true, nullptr ); } namespace @@ -909,62 +909,62 @@ void SvxTableController::onFormatTable(const SfxRequest& rReq) SdrModel& rModel(rTableObj.getSdrModelFromSdrObject()); const SfxItemSet* pArgs = rReq.GetArgs(); - if(!pArgs) - { - SfxItemSet aNewAttr(rModel.GetItemPool()); + if(pArgs) + return; - // merge drawing layer text distance items into SvxBoxItem used by the dialog - SvxBoxItem aBoxItem(mergeDrawinglayerTextDistancesAndSvxBoxItem(aNewAttr)); + SfxItemSet aNewAttr(rModel.GetItemPool()); - SvxBoxInfoItem aBoxInfoItem( aNewAttr.Get( SDRATTR_TABLE_BORDER_INNER ) ); + // merge drawing layer text distance items into SvxBoxItem used by the dialog + SvxBoxItem aBoxItem(mergeDrawinglayerTextDistancesAndSvxBoxItem(aNewAttr)); - MergeAttrFromSelectedCells(aNewAttr, false); - FillCommonBorderAttrFromSelectedCells( aBoxItem, aBoxInfoItem ); - aNewAttr.Put( aBoxItem ); - aNewAttr.Put( aBoxInfoItem ); + SvxBoxInfoItem aBoxInfoItem( aNewAttr.Get( SDRATTR_TABLE_BORDER_INNER ) ); - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<SfxAbstractTabDialog> xDlg( pFact->CreateSvxFormatCellsDialog( - rReq.GetFrameWeld(), - &aNewAttr, - rModel) ); + MergeAttrFromSelectedCells(aNewAttr, false); + FillCommonBorderAttrFromSelectedCells( aBoxItem, aBoxInfoItem ); + aNewAttr.Put( aBoxItem ); + aNewAttr.Put( aBoxInfoItem ); - // Even Cancel Button is returning positive(101) value, - if (xDlg->Execute() == RET_OK) - { - SfxItemSet aNewSet(*(xDlg->GetOutputItemSet())); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr<SfxAbstractTabDialog> xDlg( pFact->CreateSvxFormatCellsDialog( + rReq.GetFrameWeld(), + &aNewAttr, + rModel) ); - //Only properties that were unchanged by the dialog appear in this - //itemset. We had constructed these two properties from other - //ones, so if they were not changed, then forcible set them back to - //their originals in the new result set so we can decompose that - //unchanged state back to their input properties - if (aNewSet.GetItemState(SDRATTR_TABLE_BORDER, false) != SfxItemState::SET) - { - aNewSet.Put(aBoxItem); - } - if (aNewSet.GetItemState(SDRATTR_TABLE_BORDER_INNER, false) != SfxItemState::SET) - { - aNewSet.Put(aBoxInfoItem); - } + // Even Cancel Button is returning positive(101) value, + if (xDlg->Execute() != RET_OK) + return; - SvxBoxItem aNewBoxItem( aNewSet.Get( SDRATTR_TABLE_BORDER ) ); + SfxItemSet aNewSet(*(xDlg->GetOutputItemSet())); - if( aNewBoxItem.GetDistance( SvxBoxItemLine::LEFT ) != aBoxItem.GetDistance( SvxBoxItemLine::LEFT ) ) - aNewSet.Put(makeSdrTextLeftDistItem( aNewBoxItem.GetDistance( SvxBoxItemLine::LEFT ) ) ); + //Only properties that were unchanged by the dialog appear in this + //itemset. We had constructed these two properties from other + //ones, so if they were not changed, then forcible set them back to + //their originals in the new result set so we can decompose that + //unchanged state back to their input properties + if (aNewSet.GetItemState(SDRATTR_TABLE_BORDER, false) != SfxItemState::SET) + { + aNewSet.Put(aBoxItem); + } + if (aNewSet.GetItemState(SDRATTR_TABLE_BORDER_INNER, false) != SfxItemState::SET) + { + aNewSet.Put(aBoxInfoItem); + } - if( aNewBoxItem.GetDistance( SvxBoxItemLine::RIGHT ) != aBoxItem.GetDistance( SvxBoxItemLine::RIGHT ) ) - aNewSet.Put(makeSdrTextRightDistItem( aNewBoxItem.GetDistance( SvxBoxItemLine::RIGHT ) ) ); + SvxBoxItem aNewBoxItem( aNewSet.Get( SDRATTR_TABLE_BORDER ) ); - if( aNewBoxItem.GetDistance( SvxBoxItemLine::TOP ) != aBoxItem.GetDistance( SvxBoxItemLine::TOP ) ) - aNewSet.Put(makeSdrTextUpperDistItem( aNewBoxItem.GetDistance( SvxBoxItemLine::TOP ) ) ); + if( aNewBoxItem.GetDistance( SvxBoxItemLine::LEFT ) != aBoxItem.GetDistance( SvxBoxItemLine::LEFT ) ) + aNewSet.Put(makeSdrTextLeftDistItem( aNewBoxItem.GetDistance( SvxBoxItemLine::LEFT ) ) ); - if( aNewBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) != aBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) ) - aNewSet.Put(makeSdrTextLowerDistItem( aNewBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) ) ); + if( aNewBoxItem.GetDistance( SvxBoxItemLine::RIGHT ) != aBoxItem.GetDistance( SvxBoxItemLine::RIGHT ) ) + aNewSet.Put(makeSdrTextRightDistItem( aNewBoxItem.GetDistance( SvxBoxItemLine::RIGHT ) ) ); - SetAttrToSelectedCells(aNewSet, false); - } - } + if( aNewBoxItem.GetDistance( SvxBoxItemLine::TOP ) != aBoxItem.GetDistance( SvxBoxItemLine::TOP ) ) + aNewSet.Put(makeSdrTextUpperDistItem( aNewBoxItem.GetDistance( SvxBoxItemLine::TOP ) ) ); + + if( aNewBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) != aBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) ) + aNewSet.Put(makeSdrTextLowerDistItem( aNewBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) ) ); + + SetAttrToSelectedCells(aNewSet, false); } void SvxTableController::Execute( SfxRequest& rReq ) @@ -1077,7 +1077,10 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs ) return; const SfxStringItem* pArg = dynamic_cast< const SfxStringItem* >( &pArgs->Get( SID_TABLE_STYLE ) ); - if( pArg && mxTable.is() ) try + if( !(pArg && mxTable.is()) ) + return; + + try { Reference< XStyleFamiliesSupplier > xSFS( rModel.getUnoModel(), UNO_QUERY_THROW ); Reference< XNameAccess > xFamilyNameAccess( xSFS->getStyleFamilies(), UNO_SET_THROW ); @@ -1278,50 +1281,50 @@ void SvxTableController::SplitMarkedCells(const SfxRequest& rReq) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); ScopedVclPtr<SvxAbstractSplitTableDialog> xDlg(pFact->CreateSvxSplitTableDialog(rReq.GetFrameWeld(), false, 99)); - if( xDlg->Execute() ) - { - const sal_Int32 nCount = xDlg->GetCount() - 1; + if( !xDlg->Execute() ) + return; - if( nCount < 1 ) - return; + const sal_Int32 nCount = xDlg->GetCount() - 1; - CellPos aStart, aEnd; - getSelectedCells( aStart, aEnd ); - Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow ) ), UNO_QUERY_THROW ); - const sal_Int32 nRowCount = mxTable->getRowCount(); - const sal_Int32 nColCount = mxTable->getColumnCount(); - SdrTableObj& rTableObj(*mxTableObj); + if( nCount < 1 ) + return; - if( rTableObj.IsTextEditActive() ) - mrView.SdrEndTextEdit(true); + CellPos aStart, aEnd; + getSelectedCells( aStart, aEnd ); + Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow ) ), UNO_QUERY_THROW ); + const sal_Int32 nRowCount = mxTable->getRowCount(); + const sal_Int32 nColCount = mxTable->getColumnCount(); + SdrTableObj& rTableObj(*mxTableObj); - TableModelNotifyGuard aGuard( mxTable.get() ); - SdrModel& rModel(rTableObj.getSdrModelFromSdrObject()); - const bool bUndo(rModel.IsUndoEnabled()); + if( rTableObj.IsTextEditActive() ) + mrView.SdrEndTextEdit(true); - if( bUndo ) - { - rModel.BegUndo( SvxResId(STR_TABLE_SPLIT) ); - rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj)); - } + TableModelNotifyGuard aGuard( mxTable.get() ); + SdrModel& rModel(rTableObj.getSdrModelFromSdrObject()); + const bool bUndo(rModel.IsUndoEnabled()); - if( xDlg->IsHorizontal() ) - { - xRange->split( 0, nCount ); - } - else - { - xRange->split( nCount, 0 ); - } + if( bUndo ) + { + rModel.BegUndo( SvxResId(STR_TABLE_SPLIT) ); + rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj)); + } - if( bUndo ) - rModel.EndUndo(); + if( xDlg->IsHorizontal() ) + { + xRange->split( 0, nCount ); + } + else + { + xRange->split( nCount, 0 ); + } + + if( bUndo ) + rModel.EndUndo(); - aEnd.mnRow += mxTable->getRowCount() - nRowCount; - aEnd.mnCol += mxTable->getColumnCount() - nColCount; + aEnd.mnRow += mxTable->getRowCount() - nRowCount; + aEnd.mnCol += mxTable->getColumnCount() - nColCount; - setSelectedCells( aStart, aEnd ); - } + setSelectedCells( aStart, aEnd ); } void SvxTableController::DistributeColumns(const bool bOptimize, const bool bMinimize) @@ -1486,61 +1489,61 @@ void SvxTableController::changeTableEdge(const SfxRequest& rReq) const auto* pIndex = rReq.GetArg<SfxUInt16Item>(SID_TABLE_BORDER_INDEX); const auto* pOffset = rReq.GetArg<SfxInt32Item>(SID_TABLE_BORDER_OFFSET); - if (pType && pIndex && pOffset) - { - const OUString sType = pType->GetValue(); - const sal_uInt16 nIndex = pIndex->GetValue(); - const sal_Int32 nOffset = convertTwipToMm100(pOffset->GetValue()); + if (!(pType && pIndex && pOffset)) + return; - SdrTableObj& rTableObj(*mxTableObj); + const OUString sType = pType->GetValue(); + const sal_uInt16 nIndex = pIndex->GetValue(); + const sal_Int32 nOffset = convertTwipToMm100(pOffset->GetValue()); - sal_Int32 nEdgeIndex = -1; - bool bHorizontal = sType.startsWith("row"); + SdrTableObj& rTableObj(*mxTableObj); - if (sType == "column-left" || sType == "row-left") - { - nEdgeIndex = 0; - } - else if (sType == "column-right") - { - // Number of edges = number of columns + 1 - nEdgeIndex = rTableObj.getColumnCount(); - } - else if (sType == "row-right") - { - // Number of edges = number of rows + 1 - nEdgeIndex = rTableObj.getRowCount(); - } - else if (sType == "column-middle" || sType == "row-middle") - { - nEdgeIndex = nIndex + 1; - } + sal_Int32 nEdgeIndex = -1; + bool bHorizontal = sType.startsWith("row"); - if (nEdgeIndex >= 0) - { - TableModelNotifyGuard aGuard(mxTable.get()); - SdrModel& rModel(rTableObj.getSdrModelFromSdrObject()); - const bool bUndo(rModel.IsUndoEnabled()); - if (bUndo) - { - auto pUndoObject = rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj); - rModel.BegUndo(pUndoObject->GetComment()); - rModel.AddUndo(std::move(pUndoObject)); + if (sType == "column-left" || sType == "row-left") + { + nEdgeIndex = 0; + } + else if (sType == "column-right") + { + // Number of edges = number of columns + 1 + nEdgeIndex = rTableObj.getColumnCount(); + } + else if (sType == "row-right") + { + // Number of edges = number of rows + 1 + nEdgeIndex = rTableObj.getRowCount(); + } + else if (sType == "column-middle" || sType == "row-middle") + { + nEdgeIndex = nIndex + 1; + } - auto* pGeoUndo = static_cast<SdrUndoGeoObj*>(pUndoObject.get()); - if (pGeoUndo) - pGeoUndo->SetSkipChangeLayout(true); - } - tools::Rectangle aBoundRect; - if (rTableObj.GetUserCall()) - aBoundRect = rTableObj.GetLastBoundRect(); - rTableObj.changeEdge(bHorizontal, nEdgeIndex, nOffset); - rTableObj.SetChanged(); - rTableObj.SendUserCall(SdrUserCallType::Resize, aBoundRect); - if (bUndo) - rModel.EndUndo(); - } + if (nEdgeIndex < 0) + return; + + TableModelNotifyGuard aGuard(mxTable.get()); + SdrModel& rModel(rTableObj.getSdrModelFromSdrObject()); + const bool bUndo(rModel.IsUndoEnabled()); + if (bUndo) + { + auto pUndoObject = rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj); + rModel.BegUndo(pUndoObject->GetComment()); + rModel.AddUndo(std::move(pUndoObject)); + + auto* pGeoUndo = static_cast<SdrUndoGeoObj*>(pUndoObject.get()); + if (pGeoUndo) + pGeoUndo->SetSkipChangeLayout(true); } + tools::Rectangle aBoundRect; + if (rTableObj.GetUserCall()) + aBoundRect = rTableObj.GetLastBoundRect(); + rTableObj.changeEdge(bHorizontal, nEdgeIndex, nOffset); + rTableObj.SetChanged(); + rTableObj.SendUserCall(SdrUserCallType::Resize, aBoundRect); + if (bUndo) + rModel.EndUndo(); } // internals @@ -1934,7 +1937,10 @@ void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, s void SvxTableController::checkCell( CellPos& rPos ) { - if( mxTable.is() ) try + if( !mxTable.is() ) + return; + + try { if( rPos.mnCol >= mxTable->getColumnCount() ) rPos.mnCol = mxTable->getColumnCount()-1; @@ -1951,7 +1957,10 @@ void SvxTableController::checkCell( CellPos& rPos ) void SvxTableController::findMergeOrigin( CellPos& rPos ) { - if( mxTable.is() ) try + if( !mxTable.is() ) + return; + + try { Reference< XMergeableCell > xCell( mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ), UNO_QUERY_THROW ); if( xCell->isMerged() ) @@ -1975,65 +1984,65 @@ void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, Tbl SdrTableObj& rTableObj(*mxTableObj); - if(rTableObj.getSdrPageFromSdrObject() == pPV->GetPage()) + if(rTableObj.getSdrPageFromSdrObject() != pPV->GetPage()) + return; + + bool bEmptyOutliner = false; + + if(!rTableObj.GetOutlinerParaObject() && mrView.GetTextEditOutliner()) { - bool bEmptyOutliner = false; + ::Outliner* pOutl = mrView.GetTextEditOutliner(); + sal_Int32 nParaCnt = pOutl->GetParagraphCount(); + Paragraph* p1stPara = pOutl->GetParagraph( 0 ); - if(!rTableObj.GetOutlinerParaObject() && mrView.GetTextEditOutliner()) + if(nParaCnt==1 && p1stPara) { - ::Outliner* pOutl = mrView.GetTextEditOutliner(); - sal_Int32 nParaCnt = pOutl->GetParagraphCount(); - Paragraph* p1stPara = pOutl->GetParagraph( 0 ); - - if(nParaCnt==1 && p1stPara) + // with only one paragraph + if (pOutl->GetText(p1stPara).isEmpty()) { - // with only one paragraph - if (pOutl->GetText(p1stPara).isEmpty()) - { - bEmptyOutliner = true; - } + bEmptyOutliner = true; } } + } - CellPos aPos( rPos ); - findMergeOrigin( aPos ); + CellPos aPos( rPos ); + findMergeOrigin( aPos ); - if( &rTableObj != mrView.GetTextEditObject() || bEmptyOutliner || !rTableObj.IsTextEditActive( aPos ) ) - { - if( rTableObj.IsTextEditActive() ) - mrView.SdrEndTextEdit(true); + if( !(&rTableObj != mrView.GetTextEditObject() || bEmptyOutliner || !rTableObj.IsTextEditActive( aPos )) ) + return; + + if( rTableObj.IsTextEditActive() ) + mrView.SdrEndTextEdit(true); - rTableObj.setActiveCell( aPos ); + rTableObj.setActiveCell( aPos ); - // create new outliner, owner will be the SdrObjEditView - SdrModel& rModel(rTableObj.getSdrModelFromSdrObject()); - std::unique_ptr<SdrOutliner> pOutl(SdrMakeOutliner(OutlinerMode::OutlineObject, rModel)); + // create new outliner, owner will be the SdrObjEditView + SdrModel& rModel(rTableObj.getSdrModelFromSdrObject()); + std::unique_ptr<SdrOutliner> pOutl(SdrMakeOutliner(OutlinerMode::OutlineObject, rModel)); - if (pOutl && rTableObj.IsVerticalWriting()) - pOutl->SetVertical( true ); + if (pOutl && rTableObj.IsVerticalWriting()) + pOutl->SetVertical( true ); - if (mrView.SdrBeginTextEdit(&rTableObj, pPV, pWindow, true, pOutl.release())) - { - maCursorLastPos = maCursorFirstPos = rPos; + if (!mrView.SdrBeginTextEdit(&rTableObj, pPV, pWindow, true, pOutl.release())) + return; - OutlinerView* pOLV = mrView.GetTextEditOutlinerView(); + maCursorLastPos = maCursorFirstPos = rPos; - // Move cursor to end of text - ESelection aNewSelection; + OutlinerView* pOLV = mrView.GetTextEditOutlinerView(); - const WritingMode eMode = rTableObj.GetWritingMode(); - if (((nAction == TblAction::GotoLeftCell) || (nAction == TblAction::GotoRightCell)) && (eMode != WritingMode_TB_RL)) - { - const bool bLast = ((nAction == TblAction::GotoLeftCell) && (eMode == WritingMode_LR_TB)) || - ((nAction == TblAction::GotoRightCell) && (eMode == WritingMode_RL_TB)); + // Move cursor to end of text + ESelection aNewSelection; - if( bLast ) - aNewSelection = ESelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND); - } - pOLV->SetSelection(aNewSelection); - } - } + const WritingMode eMode = rTableObj.GetWritingMode(); + if (((nAction == TblAction::GotoLeftCell) || (nAction == TblAction::GotoRightCell)) && (eMode != WritingMode_TB_RL)) + { + const bool bLast = ((nAction == TblAction::GotoLeftCell) && (eMode == WritingMode_LR_TB)) || + ((nAction == TblAction::GotoRightCell) && (eMode == WritingMode_RL_TB)); + + if( bLast ) + aNewSelection = ESelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND); } + pOLV->SetSelection(aNewSelection); } @@ -2250,85 +2259,85 @@ void SvxTableController::updateSelectionOverlay() return; destroySelectionOverlay(); - if( mbCellSelectionMode ) - { - sdr::table::SdrTableObj* pTableObj = mxTableObj.get(); - if( pTableObj ) - { - sdr::overlay::OverlayObjectCell::RangeVector aRanges; + if( !mbCellSelectionMode ) + return; - tools::Rectangle aStartRect, aEndRect; - CellPos aStart,aEnd; - getSelectedCells( aStart, aEnd ); - pTableObj->getCellBounds( aStart, aStartRect ); + sdr::table::SdrTableObj* pTableObj = mxTableObj.get(); + if( !pTableObj ) + return; - basegfx::B2DRange a2DRange( basegfx::B2DPoint(aStartRect.Left(), aStartRect.Top()) ); - a2DRange.expand( basegfx::B2DPoint(aStartRect.Right(), aStartRect.Bottom()) ); + sdr::overlay::OverlayObjectCell::RangeVector aRanges; - findMergeOrigin( aEnd ); - pTableObj->getCellBounds( aEnd, aEndRect ); - a2DRange.expand( basegfx::B2DPoint(aEndRect.Left(), aEndRect.Top()) ); - a2DRange.expand( basegfx::B2DPoint(aEndRect.Right(), aEndRect.Bottom()) ); - aRanges.push_back( a2DRange ); + tools::Rectangle aStartRect, aEndRect; + CellPos aStart,aEnd; + getSelectedCells( aStart, aEnd ); + pTableObj->getCellBounds( aStart, aStartRect ); - ::Color aHighlight( COL_BLUE ); - OutputDevice* pOutDev = mrView.GetFirstOutputDevice(); - if( pOutDev ) - aHighlight = pOutDev->GetSettings().GetStyleSettings().GetHighlightColor(); + basegfx::B2DRange a2DRange( basegfx::B2DPoint(aStartRect.Left(), aStartRect.Top()) ); + a2DRange.expand( basegfx::B2DPoint(aStartRect.Right(), aStartRect.Bottom()) ); - const sal_uInt32 nCount = mrView.PaintWindowCount(); - for( sal_uInt32 nIndex = 0; nIndex < nCount; nIndex++ ) - { - SdrPaintWindow* pPaintWindow = mrView.GetPaintWindow(nIndex); - if( pPaintWindow ) - { - const rtl::Reference < sdr::overlay::OverlayManager >& xOverlayManager = pPaintWindow->GetOverlayManager(); - if( xOverlayManager.is() ) - { - std::unique_ptr<sdr::overlay::OverlayObjectCell> pOverlay(new sdr::overlay::OverlayObjectCell( aHighlight, aRanges )); + findMergeOrigin( aEnd ); + pTableObj->getCellBounds( aEnd, aEndRect ); + a2DRange.expand( basegfx::B2DPoint(aEndRect.Left(), aEndRect.Top()) ); + a2DRange.expand( basegfx::B2DPoint(aEndRect.Right(), aEndRect.Bottom()) ); + aRanges.push_back( a2DRange ); - xOverlayManager->add(*pOverlay); - mpSelectionOverlay.reset(new sdr::overlay::OverlayObjectList); - mpSelectionOverlay->append(std::move(pOverlay)); - } - } - } + ::Color aHighlight( COL_BLUE ); + OutputDevice* pOutDev = mrView.GetFirstOutputDevice(); + if( pOutDev ) + aHighlight = pOutDev->GetSettings().GetStyleSettings().GetHighlightColor(); - // If tiled rendering, emit callbacks for sdr table selection. - if (pOutDev && comphelper::LibreOfficeKit::isActive()) + const sal_uInt32 nCount = mrView.PaintWindowCount(); + for( sal_uInt32 nIndex = 0; nIndex < nCount; nIndex++ ) + { + SdrPaintWindow* pPaintWindow = mrView.GetPaintWindow(nIndex); + if( pPaintWindow ) + { + const rtl::Reference < sdr::overlay::OverlayManager >& xOverlayManager = pPaintWindow->GetOverlayManager(); + if( xOverlayManager.is() ) { - tools::Rectangle aSelection(a2DRange.getMinX(), a2DRange.getMinY(), a2DRange.getMaxX(), a2DRange.getMaxY()); - - if (pOutDev->GetMapMode().GetMapUnit() == MapUnit::Map100thMM) - aSelection = OutputDevice::LogicToLogic(aSelection, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + std::unique_ptr<sdr::overlay::OverlayObjectCell> pOverlay(new sdr::overlay::OverlayObjectCell( aHighlight, aRanges )); - if(SfxViewShell* pViewShell = SfxViewShell::Current()) - { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, aSelection.toString().getStr()); - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, aSelection.toString().getStr()); - } + xOverlayManager->add(*pOverlay); + mpSelectionOverlay.reset(new sdr::overlay::OverlayObjectList); + mpSelectionOverlay->append(std::move(pOverlay)); } } } + + // If tiled rendering, emit callbacks for sdr table selection. + if (!(pOutDev && comphelper::LibreOfficeKit::isActive())) + return; + + tools::Rectangle aSelection(a2DRange.getMinX(), a2DRange.getMinY(), a2DRange.getMaxX(), a2DRange.getMaxY()); + + if (pOutDev->GetMapMode().GetMapUnit() == MapUnit::Map100thMM) + aSelection = OutputDevice::LogicToLogic(aSelection, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + + if(SfxViewShell* pViewShell = SfxViewShell::Current()) + { + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, aSelection.toString().getStr()); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, aSelection.toString().getStr()); + } } void SvxTableController::destroySelectionOverlay() { - if( mpSelectionOverlay ) - { - mpSelectionOverlay.reset(); + if( !mpSelectionOverlay ) + return; + + mpSelectionOverlay.reset(); - if (comphelper::LibreOfficeKit::isActive()) + if (comphelper::LibreOfficeKit::isActive()) + { + // Clear the LOK text selection so far provided by this table. + if(SfxViewShell* pViewShell = SfxViewShell::Current()) { - // Clear the LOK text selection so far provided by this table. - if(SfxViewShell* pViewShell = SfxViewShell::Current()) - { - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, "EMPTY"); - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, "EMPTY"); - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, "EMPTY"); - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, "EMPTY"); - } + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, "EMPTY"); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, "EMPTY"); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, "EMPTY"); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, "EMPTY"); } } } @@ -2336,38 +2345,38 @@ void SvxTableController::destroySelectionOverlay() void SvxTableController::MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const { - if( mxTable.is() ) - { - CellPos aStart, aEnd; - const_cast<SvxTableController&>(*this).getSelectedCells( aStart, aEnd ); + if( !mxTable.is() ) + return; - for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ ) + CellPos aStart, aEnd; + const_cast<SvxTableController&>(*this).getSelectedCells( aStart, aEnd ); + + for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ ) + { + for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ ) { - for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ ) + CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) ); + if( xCell.is() && !xCell->isMerged() ) { - CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) ); - if( xCell.is() && !xCell->isMerged() ) + const SfxItemSet& rSet = xCell->GetItemSet(); + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich(aIter.FirstWhich()); + while(nWhich) { - const SfxItemSet& rSet = xCell->GetItemSet(); - SfxWhichIter aIter(rSet); - sal_uInt16 nWhich(aIter.FirstWhich()); - while(nWhich) + if(!bOnlyHardAttr) { - if(!bOnlyHardAttr) - { - if(SfxItemState::DONTCARE == rSet.GetItemState(nWhich, false)) - rAttr.InvalidateItem(nWhich); - else - rAttr.MergeValue(rSet.Get(nWhich), true); - } - else if(SfxItemState::SET == rSet.GetItemState(nWhich, false)) - { - const SfxPoolItem& rItem = rSet.Get(nWhich); - rAttr.MergeValue(rItem, true); - } - - nWhich = aIter.NextWhich(); + if(SfxItemState::DONTCARE == rSet.GetItemState(nWhich, false)) + rAttr.InvalidateItem(nWhich); + else + rAttr.MergeValue(rSet.Get(nWhich), true); } + else if(SfxItemState::SET == rSet.GetItemState(nWhich, false)) + { + const SfxPoolItem& rItem = rSet.Get(nWhich); + rAttr.MergeValue(rItem, true); + } + + nWhich = aIter.NextWhich(); } } } @@ -2527,86 +2536,86 @@ static void ImplApplyBorderLineItem( CellPosFlag nCellPosFlags, const SvxBorderL void SvxTableController::ApplyBorderAttr( const SfxItemSet& rAttr ) { - if( mxTable.is() ) - { - const sal_Int32 nRowCount = mxTable->getRowCount(); - const sal_Int32 nColCount = mxTable->getColumnCount(); - if( nRowCount && nColCount ) - { - const SvxBoxItem* pBoxItem = nullptr; - if(SfxItemState::SET == rAttr.GetItemState(SDRATTR_TABLE_BORDER, false) ) - pBoxItem = &rAttr.Get( SDRATTR_TABLE_BORDER ); + if( !mxTable.is() ) + return; - const SvxBoxInfoItem* pBoxInfoItem = nullptr; - if(SfxItemState::SET == rAttr.GetItemState(SDRATTR_TABLE_BORDER_INNER, false) ) - pBoxInfoItem = &rAttr.Get( SDRATTR_TABLE_BORDER_INNER ); + const sal_Int32 nRowCount = mxTable->getRowCount(); + const sal_Int32 nColCount = mxTable->getColumnCount(); + if( !(nRowCount && nColCount) ) + return; - const SvxColorItem* pLineColorItem = nullptr; - if(SfxItemState::SET == rAttr.GetItemState(SID_FRAME_LINECOLOR, false) ) - pLineColorItem = &rAttr.Get( SID_FRAME_LINECOLOR ); + const SvxBoxItem* pBoxItem = nullptr; + if(SfxItemState::SET == rAttr.GetItemState(SDRATTR_TABLE_BORDER, false) ) + pBoxItem = &rAttr.Get( SDRATTR_TABLE_BORDER ); - const SvxBorderLine* pBorderLineItem = nullptr; - if(SfxItemState::SET == rAttr.GetItemState(SID_FRAME_LINESTYLE, false) ) - pBorderLineItem = rAttr.Get( SID_FRAME_LINESTYLE ).GetLine(); + const SvxBoxInfoItem* pBoxInfoItem = nullptr; + if(SfxItemState::SET == rAttr.GetItemState(SDRATTR_TABLE_BORDER_INNER, false) ) + pBoxInfoItem = &rAttr.Get( SDRATTR_TABLE_BORDER_INNER ); - if( pBoxInfoItem && !pBoxItem ) - { - const static SvxBoxItem gaEmptyBoxItem( SDRATTR_TABLE_BORDER ); - pBoxItem = &gaEmptyBoxItem; - } - else if( pBoxItem && !pBoxInfoItem ) - { - const static SvxBoxInfoItem gaEmptyBoxInfoItem( SDRATTR_TABLE_BORDER_INNER ); - pBoxInfoItem = &gaEmptyBoxInfoItem; - } + const SvxColorItem* pLineColorItem = nullptr; + if(SfxItemState::SET == rAttr.GetItemState(SID_FRAME_LINECOLOR, false) ) + pLineColorItem = &rAttr.Get( SID_FRAME_LINECOLOR ); - CellPos aStart, aEnd; - getSelectedCells( aStart, aEnd ); + const SvxBorderLine* pBorderLineItem = nullptr; + if(SfxItemState::SET == rAttr.GetItemState(SID_FRAME_LINESTYLE, false) ) + pBorderLineItem = rAttr.Get( SID_FRAME_LINESTYLE ).GetLine(); - const sal_Int32 nLastRow = std::min( aEnd.mnRow + 2, nRowCount ); - const sal_Int32 nLastCol = std::min( aEnd.mnCol + 2, nColCount ); + if( pBoxInfoItem && !pBoxItem ) + { + const static SvxBoxItem gaEmptyBoxItem( SDRATTR_TABLE_BORDER ); + pBoxItem = &gaEmptyBoxItem; + } + else if( pBoxItem && !pBoxInfoItem ) + { + const static SvxBoxInfoItem gaEmptyBoxInfoItem( SDRATTR_TABLE_BORDER_INNER ); + pBoxInfoItem = &gaEmptyBoxInfoItem; + } - for( sal_Int32 nRow = std::max( aStart.mnRow - 1, sal_Int32(0) ); nRow < nLastRow; nRow++ ) - { - CellPosFlag nRowFlags = CellPosFlag::NONE; - nRowFlags |= (nRow == aStart.mnRow) ? CellPosFlag::Top : CellPosFlag::NONE; - nRowFlags |= (nRow == aEnd.mnRow) ? CellPosFlag::Bottom : CellPosFlag::NONE; - nRowFlags |= (nRow < aStart.mnRow) ? CellPosFlag::Upper : CellPosFlag::NONE; - nRowFlags |= (nRow > aEnd.mnRow) ? CellPosFlag::Lower : CellPosFlag::NONE; + CellPos aStart, aEnd; + getSelectedCells( aStart, aEnd ); - for( sal_Int32 nCol = std::max( aStart.mnCol - 1, sal_Int32(0) ); nCol < nLastCol; nCol++ ) - { - CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) ); - if( !xCell.is() ) - continue; + const sal_Int32 nLastRow = std::min( aEnd.mnRow + 2, nRowCount ); + const sal_Int32 nLastCol = std::min( aEnd.mnCol + 2, nColCount ); - const SfxItemSet& rSet = xCell->GetItemSet(); - const SvxBoxItem* pOldOuter = &rSet.Get( SDRATTR_TABLE_BORDER ); + for( sal_Int32 nRow = std::max( aStart.mnRow - 1, sal_Int32(0) ); nRow < nLastRow; nRow++ ) + { + CellPosFlag nRowFlags = CellPosFlag::NONE; + nRowFlags |= (nRow == aStart.mnRow) ? CellPosFlag::Top : CellPosFlag::NONE; + nRowFlags |= (nRow == aEnd.mnRow) ? CellPosFlag::Bottom : CellPosFlag::NONE; + nRowFlags |= (nRow < aStart.mnRow) ? CellPosFlag::Upper : CellPosFlag::NONE; + nRowFlags |= (nRow > aEnd.mnRow) ? CellPosFlag::Lower : CellPosFlag::NONE; - SvxBoxItem aNewFrame( *pOldOuter ); + for( sal_Int32 nCol = std::max( aStart.mnCol - 1, sal_Int32(0) ); nCol < nLastCol; nCol++ ) + { + CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) ); + if( !xCell.is() ) + continue; - CellPosFlag nCellPosFlags = nRowFlags; - nCellPosFlags |= (nCol == aStart.mnCol) ? CellPosFlag::Left : CellPosFlag::NONE; - nCellPosFlags |= (nCol == aEnd.mnCol) ? CellPosFlag::Right : CellPosFlag::NONE; - nCellPosFlags |= (nCol < aStart.mnCol) ? CellPosFlag::Before : CellPosFlag::NONE; - nCellPosFlags |= (nCol > aEnd.mnCol) ? CellPosFlag::After : CellPosFlag::NONE; + const SfxItemSet& rSet = xCell->GetItemSet(); + const SvxBoxItem* pOldOuter = &rSet.Get( SDRATTR_TABLE_BORDER ); - if( pBoxItem && pBoxInfoItem ) - ImplApplyBoxItem( nCellPosFlags, pBoxItem, pBoxInfoItem, aNewFrame ); + SvxBoxItem aNewFrame( *pOldOuter ); - if( pLineColorItem ) - ImplApplyLineColorItem( nCellPosFlags, pLineColorItem, aNewFrame ); + CellPosFlag nCellPosFlags = nRowFlags; + nCellPosFlags |= (nCol == aStart.mnCol) ? CellPosFlag::Left : CellPosFlag::NONE; + nCellPosFlags |= (nCol == aEnd.mnCol) ? CellPosFlag::Right : CellPosFlag::NONE; + nCellPosFlags |= (nCol < aStart.mnCol) ? CellPosFlag::Before : CellPosFlag::NONE; + nCellPosFlags |= (nCol > aEnd.mnCol) ? CellPosFlag::After : CellPosFlag::NONE; - if( pBorderLineItem ) - ImplApplyBorderLineItem( nCellPosFlags, pBorderLineItem, aNewFrame ); + if( pBoxItem && pBoxInfoItem ) + ImplApplyBoxItem( nCellPosFlags, pBoxItem, pBoxInfoItem, aNewFrame ); - if (aNewFrame != *pOldOuter) - { - SfxItemSet aAttr(*rSet.GetPool(), rSet.GetRanges()); - aAttr.Put(aNewFrame); - xCell->SetMergedItemSetAndBroadcast( aAttr, false ); - } - } + if( pLineColorItem ) + ImplApplyLineColorItem( nCellPosFlags, pLineColorItem, aNewFrame ); + + if( pBorderLineItem ) + ImplApplyBorderLineItem( nCellPosFlags, pBorderLineItem, aNewFrame ); + + if (aNewFrame != *pOldOuter) + { + SfxItemSet aAttr(*rSet.GetPool(), rSet.GetRanges()); + aAttr.Put(aNewFrame); + xCell->SetMergedItemSetAndBroadcast( aAttr, false ); } } } @@ -3072,84 +3081,84 @@ void lcl_MergeCommonBorderAttr(LinesState& rLinesState, const SvxBoxItem& rCellB void SvxTableController::FillCommonBorderAttrFromSelectedCells( SvxBoxItem& rBoxItem, SvxBoxInfoItem& rBoxInfoItem ) const { - if( mxTable.is() ) - { - const sal_Int32 nRowCount = mxTable->getRowCount(); - const sal_Int32 nColCount = mxTable->getColumnCount(); - if( nRowCount && nColCount ) - { - CellPos aStart, aEnd; - const_cast< SvxTableController* >( this )->getSelectedCells( aStart, aEnd ); - - // We are adding one more row/column around the block of selected cells. - // We will be checking the adjoining border of these too. - const sal_Int32 nLastRow = std::min( aEnd.mnRow + 2, nRowCount ); - const sal_Int32 nLastCol = std::min( aEnd.mnCol + 2, nColCount ); - - rBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::ALL, false ); - LinesState aLinesState( rBoxItem, rBoxInfoItem ); - - /* Here we go through all the selected cells (enhanced by - * the adjoining row/column on each side) and determine the - * lines for presentation. The algorithm is simple: - * 1. if a border or inner line is set (or unset) in all - * cells to the same value, it will be used. - * 2. if a border or inner line is set only in some cells, - * it will be set to indeterminate state (SetValid() on - * rBoxInfoItem). - */ - for( sal_Int32 nRow = std::max( aStart.mnRow - 1, sal_Int32(0) ); nRow < nLastRow; nRow++ ) - { - CellPosFlag nRowFlags = CellPosFlag::NONE; - nRowFlags |= (nRow == aStart.mnRow) ? CellPosFlag::Top : CellPosFlag::NONE; - nRowFlags |= (nRow == aEnd.mnRow) ? CellPosFlag::Bottom : CellPosFlag::NONE; - nRowFlags |= (nRow < aStart.mnRow) ? CellPosFlag::Upper : CellPosFlag::NONE; - nRowFlags |= (nRow > aEnd.mnRow) ? CellPosFlag::Lower : CellPosFlag::NONE; - - for( sal_Int32 nCol = std::max( aStart.mnCol - 1, sal_Int32(0) ); nCol < nLastCol; nCol++ ) - { - CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) ); - if( !xCell.is() ) - continue; + if( !mxTable.is() ) + return; - CellPosFlag nCellPosFlags = nRowFlags; - nCellPosFlags |= (nCol == aStart.mnCol) ? CellPosFlag::Left : CellPosFlag::NONE; - nCellPosFlags |= (nCol == aEnd.mnCol) ? CellPosFlag::Right : CellPosFlag::NONE; - nCellPosFlags |= (nCol < aStart.mnCol) ? CellPosFlag::Before : CellPosFlag::NONE; - nCellPosFlags |= (nCol > aEnd.mnCol) ? CellPosFlag::After : CellPosFlag::NONE; + const sal_Int32 nRowCount = mxTable->getRowCount(); + const sal_Int32 nColCount = mxTable->getColumnCount(); + if( !(nRowCount && nColCount) ) + return; - const SfxItemSet& rSet = xCell->GetItemSet(); - SvxBoxItem aCellBoxItem(mergeDrawinglayerTextDistancesAndSvxBoxItem(rSet)); - lcl_MergeCommonBorderAttr( aLinesState, aCellBoxItem, nCellPosFlags ); - } - } + CellPos aStart, aEnd; + const_cast< SvxTableController* >( this )->getSelectedCells( aStart, aEnd ); + + // We are adding one more row/column around the block of selected cells. + // We will be checking the adjoining border of these too. + const sal_Int32 nLastRow = std::min( aEnd.mnRow + 2, nRowCount ); + const sal_Int32 nLastCol = std::min( aEnd.mnCol + 2, nColCount ); + + rBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::ALL, false ); + LinesState aLinesState( rBoxItem, rBoxInfoItem ); + + /* Here we go through all the selected cells (enhanced by + * the adjoining row/column on each side) and determine the + * lines for presentation. The algorithm is simple: + * 1. if a border or inner line is set (or unset) in all + * cells to the same value, it will be used. + * 2. if a border or inner line is set only in some cells, + * it will be set to indeterminate state (SetValid() on + * rBoxInfoItem). + */ + for( sal_Int32 nRow = std::max( aStart.mnRow - 1, sal_Int32(0) ); nRow < nLastRow; nRow++ ) + { + CellPosFlag nRowFlags = CellPosFlag::NONE; + nRowFlags |= (nRow == aStart.mnRow) ? CellPosFlag::Top : CellPosFlag::NONE; + nRowFlags |= (nRow == aEnd.mnRow) ? CellPosFlag::Bottom : CellPosFlag::NONE; + nRowFlags |= (nRow < aStart.mnRow) ? CellPosFlag::Upper : CellPosFlag::NONE; + nRowFlags |= (nRow > aEnd.mnRow) ? CellPosFlag::Lower : CellPosFlag::NONE; + + for( sal_Int32 nCol = std::max( aStart.mnCol - 1, sal_Int32(0) ); nCol < nLastCol; nCol++ ) + { + CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) ); + if( !xCell.is() ) + continue; - if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::TOP]) - aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::TOP); - if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::BOTTOM]) - aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::BOTTOM); - if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::LEFT]) - aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::LEFT); - if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::RIGHT]) - aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::RIGHT); - if (!aLinesState.aInnerLineIndeterminate[SvxBoxInfoItemLine::HORI]) - aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::HORI); - if (!aLinesState.aInnerLineIndeterminate[SvxBoxInfoItemLine::VERT]) - aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::VERT); - - if (!aLinesState.bDistanceIndeterminate) - { - if (aLinesState.aDistanceSet[SvxBoxItemLine::TOP]) - aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::TOP], SvxBoxItemLine::TOP); - if (aLinesState.aDistanceSet[SvxBoxItemLine::BOTTOM]) - aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::BOTTOM], SvxBoxItemLine::BOTTOM); - if (aLinesState.aDistanceSet[SvxBoxItemLine::LEFT]) - aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::LEFT], SvxBoxItemLine::LEFT); - if (aLinesState.aDistanceSet[SvxBoxItemLine::RIGHT]) - aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::RIGHT], SvxBoxItemLine::RIGHT); - aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::DISTANCE); - } - } + CellPosFlag nCellPosFlags = nRowFlags; + nCellPosFlags |= (nCol == aStart.mnCol) ? CellPosFlag::Left : CellPosFlag::NONE; + nCellPosFlags |= (nCol == aEnd.mnCol) ? CellPosFlag::Right : CellPosFlag::NONE; + nCellPosFlags |= (nCol < aStart.mnCol) ? CellPosFlag::Before : CellPosFlag::NONE; + nCellPosFlags |= (nCol > aEnd.mnCol) ? CellPosFlag::After : CellPosFlag::NONE; + + const SfxItemSet& rSet = xCell->GetItemSet(); + SvxBoxItem aCellBoxItem(mergeDrawinglayerTextDistancesAndSvxBoxItem(rSet)); + lcl_MergeCommonBorderAttr( aLinesState, aCellBoxItem, nCellPosFlags ); + } + } + + if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::TOP]) + aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::TOP); + if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::BOTTOM]) + aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::BOTTOM); + if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::LEFT]) + aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::LEFT); + if (!aLinesState.aBorderIndeterminate[SvxBoxItemLine::RIGHT]) + aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::RIGHT); + if (!aLinesState.aInnerLineIndeterminate[SvxBoxInfoItemLine::HORI]) + aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::HORI); + if (!aLinesState.aInnerLineIndeterminate[SvxBoxInfoItemLine::VERT]) + aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::VERT); + + if (!aLinesState.bDistanceIndeterminate) + { + if (aLinesState.aDistanceSet[SvxBoxItemLine::TOP]) + aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::TOP], SvxBoxItemLine::TOP); + if (aLinesState.aDistanceSet[SvxBoxItemLine::BOTTOM]) + aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::BOTTOM], SvxBoxItemLine::BOTTOM); + if (aLinesState.aDistanceSet[SvxBoxItemLine::LEFT]) + aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::LEFT], SvxBoxItemLine::LEFT); + if (aLinesState.aDistanceSet[SvxBoxItemLine::RIGHT]) + aLinesState.rBoxItem.SetDistance(aLinesState.aDistance[SvxBoxItemLine::RIGHT], SvxBoxItemLine::RIGHT); + aLinesState.rBoxInfoItem.SetValid(SvxBoxInfoItemValidFlags::DISTANCE); } } diff --git a/svx/source/table/tabledesign.cxx b/svx/source/table/tabledesign.cxx index b5c697eb6235..b8888c14ca71 100644 --- a/svx/source/table/tabledesign.cxx +++ b/svx/source/table/tabledesign.cxx @@ -369,22 +369,22 @@ void SAL_CALL TableDesignStyle::replaceByName( const OUString& rName, const Any& Reference< XStyle > xOldStyle( maCellStyles[nIndex] ); - if( xNewStyle != xOldStyle ) - { - Reference< XModifyListener > xListener( this ); + if( xNewStyle == xOldStyle ) + return; - // end listening to old style, if possible - Reference< XModifyBroadcaster > xOldBroadcaster( xOldStyle, UNO_QUERY ); - if( xOldBroadcaster.is() ) - xOldBroadcaster->removeModifyListener( xListener ); + Reference< XModifyListener > xListener( this ); - // start listening to new style, if possible - Reference< XModifyBroadcaster > xNewBroadcaster( xNewStyle, UNO_QUERY ); - if( xNewBroadcaster.is() ) - xNewBroadcaster->addModifyListener( xListener ); + // end listening to old style, if possible + Reference< XModifyBroadcaster > xOldBroadcaster( xOldStyle, UNO_QUERY ); + if( xOldBroadcaster.is() ) + xOldBroadcaster->removeModifyListener( xListener ); - maCellStyles[nIndex] = xNewStyle; - } + // start listening to new style, if possible + Reference< XModifyBroadcaster > xNewBroadcaster( xNewStyle, UNO_QUERY ); + if( xNewBroadcaster.is() ) + xNewBroadcaster->addModifyListener( xListener ); + + maCellStyles[nIndex] = xNewStyle; } diff --git a/svx/source/table/tablehandles.cxx b/svx/source/table/tablehandles.cxx index 110102788fb7..52cef1299295 100644 --- a/svx/source/table/tablehandles.cxx +++ b/svx/source/table/tablehandles.cxx @@ -142,57 +142,57 @@ void TableEdgeHdl::CreateB2dIAObject() { GetRidOfIAObject(); - if(pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden()) + if(!(pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden())) + return; + + SdrMarkView* pView = pHdlList->GetView(); + SdrPageView* pPageView = pView->GetSdrPageView(); + + if(!pPageView) + return; + + basegfx::B2DPolyPolygon aVisible; + basegfx::B2DPolyPolygon aInvisible; + + // get visible and invisible parts + getPolyPolygon(aVisible, aInvisible, nullptr); + + if(!(aVisible.count() || aInvisible.count())) + return; + + for(sal_uInt32 nWindow = 0; nWindow < pPageView->PageWindowCount(); nWindow++) { - SdrMarkView* pView = pHdlList->GetView(); - SdrPageView* pPageView = pView->GetSdrPageView(); + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(nWindow); - if(pPageView) + if(rPageWindow.GetPaintWindow().OutputToWindow()) { - basegfx::B2DPolyPolygon aVisible; - basegfx::B2DPolyPolygon aInvisible; + const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); + if (xManager.is()) + { + if(aVisible.count()) + { + // create overlay object for visible parts + std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject(new OverlayTableEdge(aVisible, true)); - // get visible and invisible parts - getPolyPolygon(aVisible, aInvisible, nullptr); + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); + } - if(aVisible.count() || aInvisible.count()) - { - for(sal_uInt32 nWindow = 0; nWindow < pPageView->PageWindowCount(); nWindow++) + if(aInvisible.count()) { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(nWindow); - - if(rPageWindow.GetPaintWindow().OutputToWindow()) - { - const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); - if (xManager.is()) - { - if(aVisible.count()) - { - // create overlay object for visible parts - std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject(new OverlayTableEdge(aVisible, true)); - - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); - } - - if(aInvisible.count()) - { - // also create overlay object for invisible parts to allow - // a standard HitTest using the primitives from that overlay object - // (see OverlayTableEdge implementation) - std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject(new OverlayTableEdge(aInvisible, false)); - - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); - } - } - } + // also create overlay object for invisible parts to allow + // a standard HitTest using the primitives from that overlay object + // (see OverlayTableEdge implementation) + std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject(new OverlayTableEdge(aInvisible, false)); + + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); } } } @@ -259,48 +259,48 @@ void TableBorderHdl::CreateB2dIAObject() { GetRidOfIAObject(); - if (pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden()) - { - SdrMarkView* pView = pHdlList->GetView(); - SdrPageView* pPageView = pView->GetSdrPageView(); + if (!(pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden())) + return; - if (!pPageView) - return; + SdrMarkView* pView = pHdlList->GetView(); + SdrPageView* pPageView = pView->GetSdrPageView(); - for(sal_uInt32 nWindow = 0; nWindow < pPageView->PageWindowCount(); nWindow++) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(nWindow); + if (!pPageView) + return; - if (rPageWindow.GetPaintWindow().OutputToWindow()) - { - const rtl::Reference<sdr::overlay::OverlayManager>& xManager = rPageWindow.GetOverlayManager(); + for(sal_uInt32 nWindow = 0; nWindow < pPageView->PageWindowCount(); nWindow++) + { + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(nWindow); - if (xManager.is()) - { - const basegfx::B2DRange aRange = vcl::unotools::b2DRectangleFromRectangle(maRectangle); - const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; - const Color aHilightColor(aSvtOptionsDrawinglayer.getHilightColor()); - const double fTransparence(aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() * 0.01); - // make animation dependent from text edit active, because for tables - // this handle is also used when text edit *is* active for it. This - // interferes too much concerning repaint stuff (at least as long as - // text edit is not yet on the overlay) - - OutputDevice& rOutDev = rPageWindow.GetPaintWindow().GetOutputDevice(); - float fScaleFactor = rOutDev.GetDPIScaleFactor(); - double fWidth = fScaleFactor * 6.0; - - std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject( - new sdr::overlay::OverlayRectangle(aRange.getMinimum(), aRange.getMaximum(), - aHilightColor, fTransparence, - fWidth, 0.0, 0.0, mbAnimate)); + if (rPageWindow.GetPaintWindow().OutputToWindow()) + { + const rtl::Reference<sdr::overlay::OverlayManager>& xManager = rPageWindow.GetOverlayManager(); - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); - } + if (xManager.is()) + { + const basegfx::B2DRange aRange = vcl::unotools::b2DRectangleFromRectangle(maRectangle); + const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; + const Color aHilightColor(aSvtOptionsDrawinglayer.getHilightColor()); + const double fTransparence(aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() * 0.01); + // make animation dependent from text edit active, because for tables + // this handle is also used when text edit *is* active for it. This + // interferes too much concerning repaint stuff (at least as long as + // text edit is not yet on the overlay) + + OutputDevice& rOutDev = rPageWindow.GetPaintWindow().GetOutputDevice(); + float fScaleFactor = rOutDev.GetDPIScaleFactor(); + double fWidth = fScaleFactor * 6.0; + + std::unique_ptr<sdr::overlay::OverlayObject> pOverlayObject( + new sdr::overlay::OverlayRectangle(aRange.getMinimum(), aRange.getMaximum(), + aHilightColor, fTransparence, + fWidth, 0.0, 0.0, mbAnimate)); + + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); } } } diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx index cca3557b870e..f9160a077f3f 100644 --- a/svx/source/table/tablelayouter.cxx +++ b/svx/source/table/tablelayouter.cxx @@ -1112,7 +1112,10 @@ void TableLayouter::DistributeColumns( ::tools::Rectangle& rArea, const bool bOptimize, const bool bMinimize ) { - if( mxTable.is() ) try + if( !mxTable.is() ) + return; + + try { const sal_Int32 nColCount = getColumnCount(); Reference< XTableColumns > xCols( mxTable->getColumns(), UNO_SET_THROW ); @@ -1206,7 +1209,10 @@ void TableLayouter::DistributeRows( ::tools::Rectangle& rArea, const bool bOptimize, const bool bMinimize ) { - if( mxTable.is() ) try + if( !mxTable.is() ) + return; + + try { const sal_Int32 nRowCount = mxTable->getRowCount(); Reference< XTableRows > xRows( mxTable->getRows(), UNO_SET_THROW ); diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx index 464f862c0947..f121f1ee9ee2 100644 --- a/svx/source/table/tablemodel.cxx +++ b/svx/source/table/tablemodel.cxx @@ -115,30 +115,30 @@ TableModel::TableModel( SdrTableObj* pTableObj, const TableModelRef& xSourceTabl , mbNotifyPending( false ) , mnNotifyLock( 0 ) { - if( xSourceTable.is() ) - { - const sal_Int32 nColCount = xSourceTable->getColumnCountImpl(); - const sal_Int32 nRowCount = xSourceTable->getRowCountImpl(); + if( !xSourceTable.is() ) + return; - init( nColCount, nRowCount ); + const sal_Int32 nColCount = xSourceTable->getColumnCountImpl(); + const sal_Int32 nRowCount = xSourceTable->getRowCountImpl(); - sal_Int32 nRows = nRowCount; - while( nRows-- ) - (*maRows[nRows]) = *xSourceTable->maRows[nRows]; + init( nColCount, nRowCount ); - sal_Int32 nColumns = nColCount; - while( nColumns-- ) - (*maColumns[nColumns]) = *xSourceTable->maColumns[nColumns]; + sal_Int32 nRows = nRowCount; + while( nRows-- ) + (*maRows[nRows]) = *xSourceTable->maRows[nRows]; - // copy cells - for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) + sal_Int32 nColumns = nColCount; + while( nColumns-- ) + (*maColumns[nColumns]) = *xSourceTable->maColumns[nColumns]; + + // copy cells + for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) + { + for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) { - for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) - { - CellRef xTargetCell( getCell( nCol, nRow ) ); - if( xTargetCell.is() ) - xTargetCell->cloneFrom( xSourceTable->getCell( nCol, nRow ) ); - } + CellRef xTargetCell( getCell( nCol, nRow ) ); + if( xTargetCell.is() ) + xTargetCell->cloneFrom( xSourceTable->getCell( nCol, nRow ) ); } } } @@ -594,79 +594,79 @@ CellRef TableModel::createCell() void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount ) { - if( nCount && mpTableObj ) - { - try - { - SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); - TableModelNotifyGuard aGuard( this ); - nIndex = insert_range<ColumnVector,ColumnVector::iterator,TableColumnRef>( maColumns, nIndex, nCount ); + if( !(nCount && mpTableObj) ) + return; - sal_Int32 nRows = getRowCountImpl(); - while( nRows-- ) - maRows[nRows]->insertColumns( nIndex, nCount, nullptr ); + try + { + SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); + TableModelNotifyGuard aGuard( this ); + nIndex = insert_range<ColumnVector,ColumnVector::iterator,TableColumnRef>( maColumns, nIndex, nCount ); - ColumnVector aNewColumns(nCount); - for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) - { - TableColumnRef xNewCol( new TableColumn( this, nIndex+nOffset ) ); - maColumns[nIndex+nOffset] = xNewCol; - aNewColumns[nOffset] = xNewCol; - } + sal_Int32 nRows = getRowCountImpl(); + while( nRows-- ) + maRows[nRows]->insertColumns( nIndex, nCount, nullptr ); - const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); + ColumnVector aNewColumns(nCount); + for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) + { + TableColumnRef xNewCol( new TableColumn( this, nIndex+nOffset ) ); + maColumns[nIndex+nOffset] = xNewCol; + aNewColumns[nOffset] = xNewCol; + } - if( bUndo ) - { - rModel.BegUndo( SvxResId(STR_TABLE_INSCOL) ); - rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); + const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); - TableModelRef xThis( this ); + if( bUndo ) + { + rModel.BegUndo( SvxResId(STR_TABLE_INSCOL) ); + rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); - nRows = getRowCountImpl(); - CellVector aNewCells( nCount * nRows ); - CellVector::iterator aCellIter( aNewCells.begin() ); + TableModelRef xThis( this ); - nRows = getRowCountImpl(); - for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) - { - for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) - (*aCellIter++) = getCell( nIndex + nOffset, nRow ); - } + nRows = getRowCountImpl(); + CellVector aNewCells( nCount * nRows ); + CellVector::iterator aCellIter( aNewCells.begin() ); - rModel.AddUndo( std::make_unique<InsertColUndo>( xThis, nIndex, aNewColumns, aNewCells ) ); + nRows = getRowCountImpl(); + for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) + { + for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) + (*aCellIter++) = getCell( nIndex + nOffset, nRow ); } - const sal_Int32 nRowCount = getRowCountImpl(); - // check if cells merge over new columns - for( sal_Int32 nCol = 0; nCol < nIndex; ++nCol ) + rModel.AddUndo( std::make_unique<InsertColUndo>( xThis, nIndex, aNewColumns, aNewCells ) ); + } + + const sal_Int32 nRowCount = getRowCountImpl(); + // check if cells merge over new columns + for( sal_Int32 nCol = 0; nCol < nIndex; ++nCol ) + { + for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) { - for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) + CellRef xCell( getCell( nCol, nRow ) ); + sal_Int32 nColSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getColumnSpan() : 1; + if( (nColSpan != 1) && ((nColSpan + nCol ) > nIndex) ) { - CellRef xCell( getCell( nCol, nRow ) ); - sal_Int32 nColSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getColumnSpan() : 1; - if( (nColSpan != 1) && ((nColSpan + nCol ) > nIndex) ) - { - // cell merges over newly created columns, so add the new columns to the merged cell - const sal_Int32 nRowSpan = xCell->getRowSpan(); - nColSpan += nCount; - merge( nCol, nRow, nColSpan, nRowSpan ); - } + // cell merges over newly created columns, so add the new columns to the merged cell + const sal_Int32 nRowSpan = xCell->getRowSpan(); + nColSpan += nCount; + merge( nCol, nRow, nColSpan, nRowSpan ); } } + } - if( bUndo ) - rModel.EndUndo(); + if( bUndo ) + rModel.EndUndo(); - rModel.SetChanged(); - } - catch( Exception& ) - { - OSL_FAIL("sdr::table::TableModel::insertColumns(), exception caught!"); - } - updateColumns(); - setModified(true); + rModel.SetChanged(); + } + catch( Exception& ) + { + OSL_FAIL("sdr::table::TableModel::insertColumns(), exception caught!"); } + updateColumns(); + setModified(true); } @@ -674,168 +674,168 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount ) { sal_Int32 nColCount = getColumnCountImpl(); - if( mpTableObj && nCount && (nIndex >= 0) && (nIndex < nColCount) ) + if( !(mpTableObj && nCount && (nIndex >= 0) && (nIndex < nColCount)) ) + return; + + try { - try - { - TableModelNotifyGuard aGuard( this ); + TableModelNotifyGuard aGuard( this ); - // clip removed columns to columns actually available - if( (nIndex + nCount) > nColCount ) - nCount = nColCount - nIndex; + // clip removed columns to columns actually available + if( (nIndex + nCount) > nColCount ) + nCount = nColCount - nIndex; - sal_Int32 nRows = getRowCountImpl(); - SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); - const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); + sal_Int32 nRows = getRowCountImpl(); + SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); + const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); + + if( bUndo ) + { + rModel.BegUndo( SvxResId(STR_UNDO_COL_DELETE) ); + rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); - if( bUndo ) + TableModelRef xThis( this ); + ColumnVector aRemovedCols( nCount ); + sal_Int32 nOffset; + for( nOffset = 0; nOffset < nCount; ++nOffset ) { - rModel.BegUndo( SvxResId(STR_UNDO_COL_DELETE) ); - rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); + aRemovedCols[nOffset] = maColumns[nIndex+nOffset]; + } - TableModelRef xThis( this ); - ColumnVector aRemovedCols( nCount ); - sal_Int32 nOffset; + CellVector aRemovedCells( nCount * nRows ); + CellVector::iterator aCellIter( aRemovedCells.begin() ); + for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) + { for( nOffset = 0; nOffset < nCount; ++nOffset ) - { - aRemovedCols[nOffset] = maColumns[nIndex+nOffset]; - } - - CellVector aRemovedCells( nCount * nRows ); - CellVector::iterator aCellIter( aRemovedCells.begin() ); - for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) - { - for( nOffset = 0; nOffset < nCount; ++nOffset ) - (*aCellIter++) = getCell( nIndex + nOffset, nRow ); - } - - rModel.AddUndo( std::make_unique<RemoveColUndo>( xThis, nIndex, aRemovedCols, aRemovedCells ) ); + (*aCellIter++) = getCell( nIndex + nOffset, nRow ); } - // only rows before and inside the removed rows are considered - nColCount = nIndex + nCount + 1; + rModel.AddUndo( std::make_unique<RemoveColUndo>( xThis, nIndex, aRemovedCols, aRemovedCells ) ); + } - const sal_Int32 nRowCount = getRowCountImpl(); + // only rows before and inside the removed rows are considered + nColCount = nIndex + nCount + 1; - // first check merged cells before and inside the removed rows - for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) + const sal_Int32 nRowCount = getRowCountImpl(); + + // first check merged cells before and inside the removed rows + for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) + { + for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) { - for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) - { - CellRef xCell( getCell( nCol, nRow ) ); - sal_Int32 nColSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getColumnSpan() : 1; - if( nColSpan <= 1 ) - continue; + CellRef xCell( getCell( nCol, nRow ) ); + sal_Int32 nColSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getColumnSpan() : 1; + if( nColSpan <= 1 ) + continue; - if( nCol >= nIndex ) + if( nCol >= nIndex ) + { + // current cell is inside the removed columns + if( (nCol + nColSpan) > ( nIndex + nCount ) ) { - // current cell is inside the removed columns - if( (nCol + nColSpan) > ( nIndex + nCount ) ) + // current cells merges with columns after the removed columns + const sal_Int32 nRemove = nCount - nCol + nIndex; + + CellRef xTargetCell( getCell( nIndex + nCount, nRow ) ); + if( xTargetCell.is() ) { - // current cells merges with columns after the removed columns - const sal_Int32 nRemove = nCount - nCol + nIndex; - - CellRef xTargetCell( getCell( nIndex + nCount, nRow ) ); - if( xTargetCell.is() ) - { - if( bUndo ) - xTargetCell->AddUndo(); - xTargetCell->merge( nColSpan - nRemove, xCell->getRowSpan() ); - xTargetCell->replaceContentAndFormating( xCell ); - } + if( bUndo ) + xTargetCell->AddUndo(); + xTargetCell->merge( nColSpan - nRemove, xCell->getRowSpan() ); + xTargetCell->replaceContentAndFormating( xCell ); } } - else if( nColSpan > (nIndex - nCol) ) - { - // current cells spans inside the removed columns, so adjust - const sal_Int32 nRemove = ::std::min( nCount, nCol + nColSpan - nIndex ); - if( bUndo ) - xCell->AddUndo(); - xCell->merge( nColSpan - nRemove, xCell->getRowSpan() ); - } + } + else if( nColSpan > (nIndex - nCol) ) + { + // current cells spans inside the removed columns, so adjust + const sal_Int32 nRemove = ::std::min( nCount, nCol + nColSpan - nIndex ); + if( bUndo ) + xCell->AddUndo(); + xCell->merge( nColSpan - nRemove, xCell->getRowSpan() ); } } + } - // now remove the columns - remove_range<ColumnVector,ColumnVector::iterator>( maColumns, nIndex, nCount ); - while( nRows-- ) - maRows[nRows]->removeColumns( nIndex, nCount ); - - if( bUndo ) - rModel.EndUndo(); + // now remove the columns + remove_range<ColumnVector,ColumnVector::iterator>( maColumns, nIndex, nCount ); + while( nRows-- ) + maRows[nRows]->removeColumns( nIndex, nCount ); - rModel.SetChanged(); - } - catch( Exception& ) - { - OSL_FAIL("sdr::table::TableModel::removeColumns(), exception caught!"); - } + if( bUndo ) + rModel.EndUndo(); - updateColumns(); - setModified(true); + rModel.SetChanged(); } + catch( Exception& ) + { + OSL_FAIL("sdr::table::TableModel::removeColumns(), exception caught!"); + } + + updateColumns(); + setModified(true); } void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount ) { - if( nCount && mpTableObj ) - { - SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); - const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); + if( !(nCount && mpTableObj) ) + return; - try - { - TableModelNotifyGuard aGuard( this ); + SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); + const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); - nIndex = insert_range<RowVector,RowVector::iterator,TableRowRef>( maRows, nIndex, nCount ); + try + { + TableModelNotifyGuard aGuard( this ); - RowVector aNewRows(nCount); - const sal_Int32 nColCount = getColumnCountImpl(); - for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) - { - TableRowRef xNewRow( new TableRow( this, nIndex+nOffset, nColCount ) ); - maRows[nIndex+nOffset] = xNewRow; - aNewRows[nOffset] = xNewRow; - } + nIndex = insert_range<RowVector,RowVector::iterator,TableRowRef>( maRows, nIndex, nCount ); - if( bUndo ) - { - rModel.BegUndo( SvxResId(STR_TABLE_INSROW) ); - rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); - TableModelRef xThis( this ); - rModel.AddUndo( std::make_unique<InsertRowUndo>( xThis, nIndex, aNewRows ) ); - } + RowVector aNewRows(nCount); + const sal_Int32 nColCount = getColumnCountImpl(); + for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) + { + TableRowRef xNewRow( new TableRow( this, nIndex+nOffset, nColCount ) ); + maRows[nIndex+nOffset] = xNewRow; + aNewRows[nOffset] = xNewRow; + } + + if( bUndo ) + { + rModel.BegUndo( SvxResId(STR_TABLE_INSROW) ); + rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); + TableModelRef xThis( this ); + rModel.AddUndo( std::make_unique<InsertRowUndo>( xThis, nIndex, aNewRows ) ); + } - // check if cells merge over new columns - for( sal_Int32 nRow = 0; nRow < nIndex; ++nRow ) + // check if cells merge over new columns + for( sal_Int32 nRow = 0; nRow < nIndex; ++nRow ) + { + for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) { - for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) + CellRef xCell( getCell( nCol, nRow ) ); + sal_Int32 nRowSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getRowSpan() : 1; + if( (nRowSpan > 1) && ((nRowSpan + nRow) > nIndex) ) { - CellRef xCell( getCell( nCol, nRow ) ); - sal_Int32 nRowSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getRowSpan() : 1; - if( (nRowSpan > 1) && ((nRowSpan + nRow) > nIndex) ) - { - // cell merges over newly created columns, so add the new columns to the merged cell - const sal_Int32 nColSpan = xCell->getColumnSpan(); - nRowSpan += nCount; - merge( nCol, nRow, nColSpan, nRowSpan ); - } + // cell merges over newly created columns, so add the new columns to the merged cell + const sal_Int32 nColSpan = xCell->getColumnSpan(); + nRowSpan += nCount; + merge( nCol, nRow, nColSpan, nRowSpan ); } } } - catch( Exception& ) - { - OSL_FAIL("sdr::table::TableModel::insertRows(), exception caught!"); - } - if( bUndo ) - rModel.EndUndo(); + } + catch( Exception& ) + { + OSL_FAIL("sdr::table::TableModel::insertRows(), exception caught!"); + } + if( bUndo ) + rModel.EndUndo(); - rModel.SetChanged(); + rModel.SetChanged(); - updateRows(); - setModified(true); - } + updateRows(); + setModified(true); } @@ -843,93 +843,93 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount ) { sal_Int32 nRowCount = getRowCountImpl(); - if( mpTableObj && nCount && (nIndex >= 0) && (nIndex < nRowCount) ) - { - SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); - const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); + if( !(mpTableObj && nCount && (nIndex >= 0) && (nIndex < nRowCount)) ) + return; - try - { - TableModelNotifyGuard aGuard( this ); + SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject()); + const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled()); - // clip removed rows to rows actually available - if( (nIndex + nCount) > nRowCount ) - nCount = nRowCount - nIndex; + try + { + TableModelNotifyGuard aGuard( this ); - if( bUndo ) - { - rModel.BegUndo( SvxResId(STR_UNDO_ROW_DELETE) ); - rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); + // clip removed rows to rows actually available + if( (nIndex + nCount) > nRowCount ) + nCount = nRowCount - nIndex; - TableModelRef xThis( this ); + if( bUndo ) + { + rModel.BegUndo( SvxResId(STR_UNDO_ROW_DELETE) ); + rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); - RowVector aRemovedRows( nCount ); - for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) - aRemovedRows[nOffset] = maRows[nIndex+nOffset]; + TableModelRef xThis( this ); - rModel.AddUndo( std::make_unique<RemoveRowUndo>( xThis, nIndex, aRemovedRows ) ); - } + RowVector aRemovedRows( nCount ); + for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset ) + aRemovedRows[nOffset] = maRows[nIndex+nOffset]; - // only rows before and inside the removed rows are considered - nRowCount = nIndex + nCount + 1; + rModel.AddUndo( std::make_unique<RemoveRowUndo>( xThis, nIndex, aRemovedRows ) ); + } - const sal_Int32 nColCount = getColumnCountImpl(); + // only rows before and inside the removed rows are considered + nRowCount = nIndex + nCount + 1; - // first check merged cells before and inside the removed rows - for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) + const sal_Int32 nColCount = getColumnCountImpl(); + + // first check merged cells before and inside the removed rows + for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) + { + for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) { - for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol ) - { - CellRef xCell( getCell( nCol, nRow ) ); - sal_Int32 nRowSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getRowSpan() : 1; - if( nRowSpan <= 1 ) - continue; + CellRef xCell( getCell( nCol, nRow ) ); + sal_Int32 nRowSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getRowSpan() : 1; + if( nRowSpan <= 1 ) + continue; - if( nRow >= nIndex ) + if( nRow >= nIndex ) + { + // current cell is inside the removed rows + if( (nRow + nRowSpan) > (nIndex + nCount) ) { - // current cell is inside the removed rows - if( (nRow + nRowSpan) > (nIndex + nCount) ) + // current cells merges with rows after the removed rows + const sal_Int32 nRemove = nCount - nRow + nIndex; + + CellRef xTargetCell( getCell( nCol, nIndex + nCount ) ); + if( xTargetCell.is() ) { - // current cells merges with rows after the removed rows - const sal_Int32 nRemove = nCount - nRow + nIndex; - - CellRef xTargetCell( getCell( nCol, nIndex + nCount ) ); - if( xTargetCell.is() ) - { - if( bUndo ) - xTargetCell->AddUndo(); - xTargetCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove ); - xTargetCell->replaceContentAndFormating( xCell ); - } + if( bUndo ) + xTargetCell->AddUndo(); + xTargetCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove ); + xTargetCell->replaceContentAndFormating( xCell ); } } - else if( nRowSpan > (nIndex - nRow) ) - { - // current cells spans inside the removed rows, so adjust - const sal_Int32 nRemove = ::std::min( nCount, nRow + nRowSpan - nIndex ); - if( bUndo ) - xCell->AddUndo(); - xCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove ); - } + } + else if( nRowSpan > (nIndex - nRow) ) + { + // current cells spans inside the removed rows, so adjust + const sal_Int32 nRemove = ::std::min( nCount, nRow + nRowSpan - nIndex ); + if( bUndo ) + xCell->AddUndo(); + xCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove ); } } + } - // now remove the rows - remove_range<RowVector,RowVector::iterator>( maRows, nIndex, nCount ); - - if( bUndo ) - rModel.EndUndo(); + // now remove the rows + remove_range<RowVector,RowVector::iterator>( maRows, nIndex, nCount ); - rModel.SetChanged(); - } - catch( Exception& ) - { - OSL_FAIL("sdr::table::TableModel::removeRows(), exception caught!"); - } + if( bUndo ) + rModel.EndUndo(); - updateRows(); - setModified(true); + rModel.SetChanged(); } + catch( Exception& ) + { + OSL_FAIL("sdr::table::TableModel::removeRows(), exception caught!"); + } + + updateRows(); + setModified(true); } diff --git a/svx/source/table/tablerow.cxx b/svx/source/table/tablerow.cxx index 2bb1f15d5c6f..71b51a653a6f 100644 --- a/svx/source/table/tablerow.cxx +++ b/svx/source/table/tablerow.cxx @@ -103,18 +103,18 @@ TableRow& TableRow::operator=( const TableRow& r ) void TableRow::insertColumns( sal_Int32 nIndex, sal_Int32 nCount, CellVector::iterator const * pIter /* = 0 */ ) { throwIfDisposed(); - if( nCount ) + if( !nCount ) + return; + + if( nIndex >= static_cast< sal_Int32 >( maCells.size() ) ) + nIndex = static_cast< sal_Int32 >( maCells.size() ); + if ( pIter ) + maCells.insert( maCells.begin() + nIndex, *pIter, (*pIter) + nCount ); + else { - if( nIndex >= static_cast< sal_Int32 >( maCells.size() ) ) - nIndex = static_cast< sal_Int32 >( maCells.size() ); - if ( pIter ) - maCells.insert( maCells.begin() + nIndex, *pIter, (*pIter) + nCount ); - else - { - maCells.reserve( maCells.size() + nCount ); - for ( sal_Int32 i = 0; i < nCount; i++ ) - maCells.insert( maCells.begin() + nIndex + i, mxTableModel->createCell() ); - } + maCells.reserve( maCells.size() + nCount ); + for ( sal_Int32 i = 0; i < nCount; i++ ) + maCells.insert( maCells.begin() + nIndex + i, mxTableModel->createCell() ); } } @@ -122,30 +122,30 @@ void TableRow::insertColumns( sal_Int32 nIndex, sal_Int32 nCount, CellVector::it void TableRow::removeColumns( sal_Int32 nIndex, sal_Int32 nCount ) { throwIfDisposed(); - if( (nCount >= 0) && ( nIndex >= 0) ) + if( (nCount < 0) || ( nIndex < 0)) + return; + + if( (nIndex + nCount) < static_cast< sal_Int32 >( maCells.size() ) ) { - if( (nIndex + nCount) < static_cast< sal_Int32 >( maCells.size() ) ) - { - CellVector::iterator aBegin( maCells.begin() ); - std::advance(aBegin, nIndex); + CellVector::iterator aBegin( maCells.begin() ); + std::advance(aBegin, nIndex); - if( nCount > 1 ) - { - CellVector::iterator aEnd( aBegin ); - while( nCount-- && (aEnd != maCells.end()) ) - ++aEnd; - maCells.erase( aBegin, aEnd ); - } - else - { - maCells.erase( aBegin ); - } + if( nCount > 1 ) + { + CellVector::iterator aEnd( aBegin ); + while( nCount-- && (aEnd != maCells.end()) ) + ++aEnd; + maCells.erase( aBegin, aEnd ); } else { - maCells.resize( nIndex ); + maCells.erase( aBegin ); } } + else + { + maCells.resize( nIndex ); + } } const TableModelRef& TableRow::getModel() const diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx index 31ac85755e40..63aa489c8bf7 100644 --- a/svx/source/table/tableundo.cxx +++ b/svx/source/table/tableundo.cxx @@ -129,23 +129,23 @@ void CellUndo::setDataToCell( const Data& rData ) void CellUndo::getDataFromCell( Data& rData ) { - if( mxObjRef.is() && mxCell.is() ) - { - if( mxCell->mpProperties ) - rData.mpProperties = mxCell->CloneProperties( *mxObjRef, *mxCell); - - if( mxCell->GetOutlinerParaObject() ) - rData.mpOutlinerParaObject = new OutlinerParaObject(*mxCell->GetOutlinerParaObject()); - else - rData.mpOutlinerParaObject = nullptr; - - rData.msFormula = mxCell->msFormula; - rData.mfValue = mxCell->mfValue; - rData.mnError = mxCell->mnError; - rData.mbMerged = mxCell->mbMerged; - rData.mnRowSpan = mxCell->mnRowSpan; - rData.mnColSpan = mxCell->mnColSpan; - } + if( !(mxObjRef.is() && mxCell.is()) ) + return; + + if( mxCell->mpProperties ) + rData.mpProperties = mxCell->CloneProperties( *mxObjRef, *mxCell); + + if( mxCell->GetOutlinerParaObject() ) + rData.mpOutlinerParaObject = new OutlinerParaObject(*mxCell->GetOutlinerParaObject()); + else + rData.mpOutlinerParaObject = nullptr; + + rData.msFormula = mxCell->msFormula; + rData.mfValue = mxCell->mfValue; + rData.mnError = mxCell->mnError; + rData.mbMerged = mxCell->mbMerged; + rData.mnRowSpan = mxCell->mnRowSpan; + rData.mnColSpan = mxCell->mnColSpan; } diff --git a/svx/source/toolbars/extrusionbar.cxx b/svx/source/toolbars/extrusionbar.cxx index 5ca8a22d1b2b..5297f304b7bf 100644 --- a/svx/source/toolbars/extrusionbar.cxx +++ b/svx/source/toolbars/extrusionbar.cxx @@ -586,28 +586,28 @@ void ExtrusionBar::execute( SdrView* pSdrView, SfxRequest const & rReq, SfxBindi break; } - if( nSID == SID_EXTRUSION_TOGGLE ) - { - static const sal_uInt16 SidArray[] = { - SID_EXTRUSION_TILT_DOWN, - SID_EXTRUSION_TILT_UP, - SID_EXTRUSION_TILT_LEFT, - SID_EXTRUSION_TILT_RIGHT, - SID_EXTRUSION_DEPTH_FLOATER, - SID_EXTRUSION_DIRECTION_FLOATER, - SID_EXTRUSION_LIGHTING_FLOATER, - SID_EXTRUSION_SURFACE_FLOATER, - SID_EXTRUSION_3D_COLOR, - SID_EXTRUSION_DEPTH, - SID_EXTRUSION_DIRECTION, - SID_EXTRUSION_PROJECTION, - SID_EXTRUSION_LIGHTING_DIRECTION, - SID_EXTRUSION_LIGHTING_INTENSITY, - SID_EXTRUSION_SURFACE, - 0 }; - - rBindings.Invalidate( SidArray ); - } + if( nSID != SID_EXTRUSION_TOGGLE ) + return; + + static const sal_uInt16 SidArray[] = { + SID_EXTRUSION_TILT_DOWN, + SID_EXTRUSION_TILT_UP, + SID_EXTRUSION_TILT_LEFT, + SID_EXTRUSION_TILT_RIGHT, + SID_EXTRUSION_DEPTH_FLOATER, + SID_EXTRUSION_DIRECTION_FLOATER, + SID_EXTRUSION_LIGHTING_FLOATER, + SID_EXTRUSION_SURFACE_FLOATER, + SID_EXTRUSION_3D_COLOR, + SID_EXTRUSION_DEPTH, + SID_EXTRUSION_DIRECTION, + SID_EXTRUSION_PROJECTION, + SID_EXTRUSION_LIGHTING_DIRECTION, + SID_EXTRUSION_LIGHTING_INTENSITY, + SID_EXTRUSION_SURFACE, + 0 }; + + rBindings.Invalidate( SidArray ); } static void getExtrusionDirectionState( SdrView const * pSdrView, SfxItemSet& rSet ) diff --git a/svx/source/toolbars/fontworkbar.cxx b/svx/source/toolbars/fontworkbar.cxx index ae46b755b76e..308f4d2f6b60 100644 --- a/svx/source/toolbars/fontworkbar.cxx +++ b/svx/source/toolbars/fontworkbar.cxx @@ -325,79 +325,79 @@ static void GetGeometryForCustomShape( SdrCustomShapeGeometryItem& rGeometryItem /* SJ: CustomShapes that are available in the gallery are having the highest priority, so we will take a look there before taking the internal default */ - if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) ) + if ( !GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) ) + return; + + std::vector< OUString > aObjList; + if ( !GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) ) + return; + + for ( std::vector<OUString>::size_type i = 0; i < aObjList.size(); i++ ) { - std::vector< OUString > aObjList; - if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) ) + if ( aObjList[ i ].equalsIgnoreAsciiCase( rCustomShape ) ) { - for ( std::vector<OUString>::size_type i = 0; i < aObjList.size(); i++ ) + FmFormModel aFormModel; + SfxItemPool& rPool(aFormModel.GetItemPool()); + rPool.FreezeIdRanges(); + + if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) ) { - if ( aObjList[ i ].equalsIgnoreAsciiCase( rCustomShape ) ) + const SdrObject* pSourceObj = nullptr; + if (aFormModel.GetPageCount() > 0) + pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 ); + SAL_WARN_IF(!pSourceObj, "svx.form", "No content in gallery custom shape '" << rCustomShape << "'" ); + if( pSourceObj ) { - FmFormModel aFormModel; - SfxItemPool& rPool(aFormModel.GetItemPool()); - rPool.FreezeIdRanges(); - - if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) ) + PropertyValue aPropVal_; + const SdrCustomShapeGeometryItem& rSourceGeometry = pSourceObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); + const css::uno::Any* pAny = rSourceGeometry.GetPropertyValueByName( sType ); + if ( pAny ) { - const SdrObject* pSourceObj = nullptr; - if (aFormModel.GetPageCount() > 0) - pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 ); - SAL_WARN_IF(!pSourceObj, "svx.form", "No content in gallery custom shape '" << rCustomShape << "'" ); - if( pSourceObj ) - { - PropertyValue aPropVal_; - const SdrCustomShapeGeometryItem& rSourceGeometry = pSourceObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); - const css::uno::Any* pAny = rSourceGeometry.GetPropertyValueByName( sType ); - if ( pAny ) - { - aPropVal_.Name = sType; - aPropVal_.Value = *pAny; - rGeometryItem.SetPropertyValue( aPropVal_ ); - } - pAny = rSourceGeometry.GetPropertyValueByName( sAdjustmentValues ); - if ( pAny ) - { - aPropVal_.Name = sAdjustmentValues; - aPropVal_.Value = *pAny; - rGeometryItem.SetPropertyValue( aPropVal_ ); - } - pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateOrigin ); - if ( pAny ) - { - aPropVal_.Name = sCoordinateOrigin; - aPropVal_.Value = *pAny; - rGeometryItem.SetPropertyValue( aPropVal_ ); - } - pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateSize ); - if ( pAny ) - { - aPropVal_.Name = sCoordinateSize; - aPropVal_.Value = *pAny; - rGeometryItem.SetPropertyValue( aPropVal_ ); - } - pAny = rSourceGeometry.GetPropertyValueByName( sEquations ); - if ( pAny ) - { - aPropVal_.Name = sEquations; - aPropVal_.Value = *pAny; - rGeometryItem.SetPropertyValue( aPropVal_ ); - } - pAny = rSourceGeometry.GetPropertyValueByName( sHandles ); - if ( pAny ) - { - aPropVal_.Name = sHandles; - aPropVal_.Value = *pAny; - rGeometryItem.SetPropertyValue( aPropVal_ ); - } - pAny = rSourceGeometry.GetPropertyValueByName( sPath ); - if ( pAny ) - { - aPropVal_.Name = sPath; - aPropVal_.Value = *pAny; - rGeometryItem.SetPropertyValue( aPropVal_ ); - } - } + aPropVal_.Name = sType; + aPropVal_.Value = *pAny; + rGeometryItem.SetPropertyValue( aPropVal_ ); + } + pAny = rSourceGeometry.GetPropertyValueByName( sAdjustmentValues ); + if ( pAny ) + { + aPropVal_.Name = sAdjustmentValues; + aPropVal_.Value = *pAny; + rGeometryItem.SetPropertyValue( aPropVal_ ); + } + pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateOrigin ); + if ( pAny ) + { + aPropVal_.Name = sCoordinateOrigin; + aPropVal_.Value = *pAny; + rGeometryItem.SetPropertyValue( aPropVal_ ); + } + pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateSize ); + if ( pAny ) + { + aPropVal_.Name = sCoordinateSize; + aPropVal_.Value = *pAny; + rGeometryItem.SetPropertyValue( aPropVal_ ); + } + pAny = rSourceGeometry.GetPropertyValueByName( sEquations ); + if ( pAny ) + { + aPropVal_.Name = sEquations; + aPropVal_.Value = *pAny; + rGeometryItem.SetPropertyValue( aPropVal_ ); + } + pAny = rSourceGeometry.GetPropertyValueByName( sHandles ); + if ( pAny ) + { + aPropVal_.Name = sHandles; + aPropVal_.Value = *pAny; + rGeometryItem.SetPropertyValue( aPropVal_ ); + } + pAny = rSourceGeometry.GetPropertyValueByName( sPath ); + if ( pAny ) + { + aPropVal_.Name = sPath; + aPropVal_.Value = *pAny; + rGeometryItem.SetPropertyValue( aPropVal_ ); } } } diff --git a/svx/source/unodraw/gluepts.cxx b/svx/source/unodraw/gluepts.cxx index 37b661ac60c5..d1eaa2fbc847 100644 --- a/svx/source/unodraw/gluepts.cxx +++ b/svx/source/unodraw/gluepts.cxx @@ -263,35 +263,35 @@ void SAL_CALL SvxUnoGluePointAccess::removeByIdentifier( sal_Int32 Identifier ) // XIdentifierReplace void SAL_CALL SvxUnoGluePointAccess::replaceByIdentifer( sal_Int32 Identifier, const uno::Any& aElement ) { - if( mpObject.is() ) - { - struct drawing::GluePoint2 aGluePoint; - if( (Identifier < NON_USER_DEFINED_GLUE_POINTS) || !(aElement >>= aGluePoint)) - throw lang::IllegalArgumentException(); + if( !mpObject.is() ) + return; - const sal_uInt16 nId = static_cast<sal_uInt16>( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1; + struct drawing::GluePoint2 aGluePoint; + if( (Identifier < NON_USER_DEFINED_GLUE_POINTS) || !(aElement >>= aGluePoint)) + throw lang::IllegalArgumentException(); - SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() ); - const sal_uInt16 nCount = pList ? pList->GetCount() : 0; - sal_uInt16 i; - for( i = 0; i < nCount; i++ ) + const sal_uInt16 nId = static_cast<sal_uInt16>( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1; + + SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() ); + const sal_uInt16 nCount = pList ? pList->GetCount() : 0; + sal_uInt16 i; + for( i = 0; i < nCount; i++ ) + { + if( (*pList)[i].GetId() == nId ) { - if( (*pList)[i].GetId() == nId ) - { - // change the glue point - SdrGluePoint& rTempPoint = (*pList)[i]; - convert( aGluePoint, rTempPoint ); + // change the glue point + SdrGluePoint& rTempPoint = (*pList)[i]; + convert( aGluePoint, rTempPoint ); - // only repaint, no objectchange - mpObject->ActionChanged(); - // mpObject->BroadcastObjectChange(); + // only repaint, no objectchange + mpObject->ActionChanged(); + // mpObject->BroadcastObjectChange(); - return; - } + return; } - - throw container::NoSuchElementException(); } + + throw container::NoSuchElementException(); } // XIdentifierAccess diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx index 6cc9a35f90dc..5fdc880c7cad 100644 --- a/svx/source/unodraw/unomod.cxx +++ b/svx/source/unodraw/unomod.cxx @@ -621,18 +621,18 @@ void SAL_CALL SvxUnoDrawPagesAccess::remove( const uno::Reference< drawing::XDra ::SolarMutexGuard aGuard; sal_uInt16 nPageCount = mrModel.mpDoc->GetPageCount(); - if( nPageCount > 1 ) + if( nPageCount <= 1 ) + return; + + // get pPage from xPage and get Id (nPos) + SvxDrawPage* pSvxPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>( xPage ); + if( pSvxPage ) { - // get pPage from xPage and get Id (nPos) - SvxDrawPage* pSvxPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>( xPage ); - if( pSvxPage ) + SdrPage* pPage = pSvxPage->GetSdrPage(); + if(pPage) { - SdrPage* pPage = pSvxPage->GetSdrPage(); - if(pPage) - { - sal_uInt16 nPage = pPage->GetPageNum(); - mrModel.mpDoc->DeletePage( nPage ); - } + sal_uInt16 nPage = pPage->GetPageNum(); + mrModel.mpDoc->DeletePage( nPage ); } } } diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx index bba5929f5b2f..d58980400961 100644 --- a/svx/source/unodraw/unopage.cxx +++ b/svx/source/unodraw/unopage.cxx @@ -124,36 +124,36 @@ void SvxDrawPage::dispose() } // Do not hold the mutex because we are broadcasting - if( bDoDispose ) - { - // Create an event with this as sender - try - { - uno::Reference< uno::XInterface > xSource( uno::Reference< uno::XInterface >::query( static_cast<lang::XComponent *>(this) ) ); - css::document::EventObject aEvt; - aEvt.Source = xSource; - // inform all listeners to release this object - // The listener container are automatically cleared - mrBHelper.aLC.disposeAndClear( aEvt ); - // notify subclasses to do their dispose - disposing(); - } - catch(const css::uno::Exception&) - { - // catch exception and throw again but signal that - // the object was disposed. Dispose should be called - // only once. - osl::MutexGuard aGuard( mrBHelper.rMutex ); - mrBHelper.bDisposed = true; - mrBHelper.bInDispose = false; - throw; - } + if( !bDoDispose ) + return; + // Create an event with this as sender + try + { + uno::Reference< uno::XInterface > xSource( uno::Reference< uno::XInterface >::query( static_cast<lang::XComponent *>(this) ) ); + css::document::EventObject aEvt; + aEvt.Source = xSource; + // inform all listeners to release this object + // The listener container are automatically cleared + mrBHelper.aLC.disposeAndClear( aEvt ); + // notify subclasses to do their dispose + disposing(); + } + catch(const css::uno::Exception&) + { + // catch exception and throw again but signal that + // the object was disposed. Dispose should be called + // only once. osl::MutexGuard aGuard( mrBHelper.rMutex ); mrBHelper.bDisposed = true; mrBHelper.bInDispose = false; + throw; } + osl::MutexGuard aGuard( mrBHelper.rMutex ); + mrBHelper.bDisposed = true; + mrBHelper.bInDispose = false; + } void SAL_CALL SvxDrawPage::addEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) @@ -406,18 +406,18 @@ void SvxDrawPage::SelectObjectsInView( const Reference< drawing::XShapes > & aSh SAL_WARN_IF(!pPageView, "svx", "SdrPageView is NULL!"); SAL_WARN_IF(!mpView, "svx", "SdrView is NULL!"); - if(pPageView!=nullptr && mpView!=nullptr) - { - mpView->UnmarkAllObj( pPageView ); + if(pPageView==nullptr || mpView==nullptr) + return; - long nCount = aShapes->getCount(); - for( long i = 0; i < nCount; i++ ) - { - uno::Any aAny( aShapes->getByIndex(i) ); - Reference< drawing::XShape > xShape; - if( aAny >>= xShape ) - lcl_markSdrObjectOfShape( xShape, *mpView, *pPageView ); - } + mpView->UnmarkAllObj( pPageView ); + + long nCount = aShapes->getCount(); + for( long i = 0; i < nCount; i++ ) + { + uno::Any aAny( aShapes->getByIndex(i) ); + Reference< drawing::XShape > xShape; + if( aAny >>= xShape ) + lcl_markSdrObjectOfShape( xShape, *mpView, *pPageView ); } } diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index e68eadc9f54b..c7b0b6de609b 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -1718,48 +1718,48 @@ void SAL_CALL SvxCustomShape::setPropertyValue( const OUString& aPropertyName, c SvxShape::setPropertyValue( aPropertyName, aValue ); - if ( bCustomShapeGeometry ) - { - static_cast<SdrObjCustomShape*>(pObject)->MergeDefaultAttributes(); - tools::Rectangle aRect( pObject->GetSnapRect() ); + if ( !bCustomShapeGeometry ) + return; - // #i38892# - bool bNeedsMirrorX = static_cast<SdrObjCustomShape*>(pObject)->IsMirroredX() != bMirroredX; - bool bNeedsMirrorY = static_cast<SdrObjCustomShape*>(pObject)->IsMirroredY() != bMirroredY; + static_cast<SdrObjCustomShape*>(pObject)->MergeDefaultAttributes(); + tools::Rectangle aRect( pObject->GetSnapRect() ); - std::unique_ptr< SdrGluePointList > pListCopy; - if( bNeedsMirrorX || bNeedsMirrorY ) - { - const SdrGluePointList* pList = pObject->GetGluePointList(); - if( pList ) - pListCopy.reset( new SdrGluePointList(*pList) ); - } + // #i38892# + bool bNeedsMirrorX = static_cast<SdrObjCustomShape*>(pObject)->IsMirroredX() != bMirroredX; + bool bNeedsMirrorY = static_cast<SdrObjCustomShape*>(pObject)->IsMirroredY() != bMirroredY; - if ( bNeedsMirrorX ) - { - Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() ); - Point aBottom( aTop.X(), aTop.Y() + 1000 ); - pObject->NbcMirror( aTop, aBottom ); - // NbcMirroring is flipping the current mirror state, - // so we have to set the correct state again - static_cast<SdrObjCustomShape*>(pObject)->SetMirroredX( !bMirroredX ); - } - if ( bNeedsMirrorY ) - { - Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 ); - Point aRight( aLeft.X() + 1000, aLeft.Y() ); - pObject->NbcMirror( aLeft, aRight ); - // NbcMirroring is flipping the current mirror state, - // so we have to set the correct state again - static_cast<SdrObjCustomShape*>(pObject)->SetMirroredY( !bMirroredY ); - } + std::unique_ptr< SdrGluePointList > pListCopy; + if( bNeedsMirrorX || bNeedsMirrorY ) + { + const SdrGluePointList* pList = pObject->GetGluePointList(); + if( pList ) + pListCopy.reset( new SdrGluePointList(*pList) ); + } - if( pListCopy ) - { - SdrGluePointList* pNewList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() ); - if(pNewList) - *pNewList = *pListCopy; - } + if ( bNeedsMirrorX ) + { + Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() ); + Point aBottom( aTop.X(), aTop.Y() + 1000 ); + pObject->NbcMirror( aTop, aBottom ); + // NbcMirroring is flipping the current mirror state, + // so we have to set the correct state again + static_cast<SdrObjCustomShape*>(pObject)->SetMirroredX( !bMirroredX ); + } + if ( bNeedsMirrorY ) + { + Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 ); + Point aRight( aLeft.X() + 1000, aLeft.Y() ); + pObject->NbcMirror( aLeft, aRight ); + // NbcMirroring is flipping the current mirror state, + // so we have to set the correct state again + static_cast<SdrObjCustomShape*>(pObject)->SetMirroredY( !bMirroredY ); + } + + if( pListCopy ) + { + SdrGluePointList* pNewList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() ); + if(pNewList) + *pNewList = *pListCopy; } } diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx index eab0cd5bb111..658cb2c8fd6c 100644 --- a/svx/source/unodraw/unoshap4.cxx +++ b/svx/source/unodraw/unoshap4.cxx @@ -460,37 +460,37 @@ void SvxOle2Shape::createLink( const OUString& aLinkURL ) uno::Reference< embed::XEmbeddedObject > xObj = pPersist->getEmbeddedObjectContainer().InsertEmbeddedLink( aMediaDescr , aPersistName ); - if( xObj.is() ) + if( !xObj.is() ) + return; + + tools::Rectangle aRect = pOle2Obj->GetLogicRect(); + if ( aRect.GetWidth() == 101 && aRect.GetHeight() == 101 ) { - tools::Rectangle aRect = pOle2Obj->GetLogicRect(); - if ( aRect.GetWidth() == 101 && aRect.GetHeight() == 101 ) - { - // default size - try - { - awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() ); - aRect.SetSize( Size( aSz.Width, aSz.Height ) ); - } - catch( embed::NoVisualAreaSizeException& ) - {} - pOle2Obj->SetLogicRect( aRect ); - } - else + // default size + try { - awt::Size aSz; - Size aSize = pOle2Obj->GetLogicRect().GetSize(); - aSz.Width = aSize.Width(); - aSz.Height = aSize.Height(); - xObj->setVisualAreaSize( pOle2Obj->GetAspect(), aSz ); + awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() ); + aRect.SetSize( Size( aSz.Width, aSz.Height ) ); } + catch( embed::NoVisualAreaSizeException& ) + {} + pOle2Obj->SetLogicRect( aRect ); + } + else + { + awt::Size aSz; + Size aSize = pOle2Obj->GetLogicRect().GetSize(); + aSz.Width = aSize.Width(); + aSz.Height = aSize.Height(); + xObj->setVisualAreaSize( pOle2Obj->GetAspect(), aSz ); + } - // connect the object after the visual area is set - SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME, uno::makeAny( aPersistName ) ); + // connect the object after the visual area is set + SvxShape::setPropertyValue( UNO_NAME_OLE2_PERSISTNAME, uno::makeAny( aPersistName ) ); - // the object is inserted during setting of PersistName property usually - if ( pOle2Obj->IsEmpty() ) - pOle2Obj->SetObjRef( xObj ); - } + // the object is inserted during setting of PersistName property usually + if ( pOle2Obj->IsEmpty() ) + pOle2Obj->SetObjRef( xObj ); } void SvxOle2Shape::resetModifiedState() diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 080f455c4005..d1e76804133e 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -341,27 +341,27 @@ void SvxShape::impl_initFromSdrObject() const SdrInventor nInventor = GetSdrObject()->GetObjInventor(); // is it one of ours (svx) ? - if( nInventor == SdrInventor::Default || nInventor == SdrInventor::E3d || nInventor == SdrInventor::FmForm ) + if( !(nInventor == SdrInventor::Default || nInventor == SdrInventor::E3d || nInventor == SdrInventor::FmForm) ) + return; + + if(nInventor == SdrInventor::FmForm) { - if(nInventor == SdrInventor::FmForm) - { - mpImpl->mnObjId = OBJ_UNO; - } - else - { - mpImpl->mnObjId = GetSdrObject()->GetObjIdentifier(); - if( nInventor == SdrInventor::E3d ) - mpImpl->mnObjId |= E3D_INVENTOR_FLAG; - } + mpImpl->mnObjId = OBJ_UNO; + } + else + { + mpImpl->mnObjId = GetSdrObject()->GetObjIdentifier(); + if( nInventor == SdrInventor::E3d ) + mpImpl->mnObjId |= E3D_INVENTOR_FLAG; + } - switch(mpImpl->mnObjId) - { - case OBJ_CCUT: // segment of circle - case OBJ_CARC: // arc of circle - case OBJ_SECT: // sector - mpImpl->mnObjId = OBJ_CIRC; - break; - } + switch(mpImpl->mnObjId) + { + case OBJ_CCUT: // segment of circle + case OBJ_CARC: // arc of circle + case OBJ_SECT: // sector + mpImpl->mnObjId = OBJ_CIRC; + break; } } @@ -426,24 +426,24 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw() { DBG_TESTSOLARMUTEX(); - if(HasSdrObject()) + if(!HasSdrObject()) + return; + + MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0)); + if(eMapUnit == MapUnit::Map100thMM) + return; + + switch(eMapUnit) { - MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0)); - if(eMapUnit != MapUnit::Map100thMM) + case MapUnit::MapTwip : { - switch(eMapUnit) - { - case MapUnit::MapTwip : - { - rPoint.A() = MM_TO_TWIPS(rPoint.A()); - rPoint.B() = MM_TO_TWIPS(rPoint.B()); - break; - } - default: - { - OSL_FAIL("AW: Missing unit translation to PoolMetric!"); - } - } + rPoint.A() = MM_TO_TWIPS(rPoint.A()); + rPoint.B() = MM_TO_TWIPS(rPoint.B()); + break; + } + default: + { + OSL_FAIL("AW: Missing unit translation to PoolMetric!"); } } } @@ -451,27 +451,27 @@ void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw() void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const throw() { DBG_TESTSOLARMUTEX(); - if(HasSdrObject()) + if(!HasSdrObject()) + return; + + MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0)); + if(eMapUnit == MapUnit::Map100thMM) + return; + + switch(eMapUnit) { - MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0)); - if(eMapUnit != MapUnit::Map100thMM) + case MapUnit::MapTwip : { - switch(eMapUnit) - { - case MapUnit::MapTwip : - { - basegfx::B2DHomMatrix aTransform; - const double fMMToTWIPS(72.0 / 127.0); + basegfx::B2DHomMatrix aTransform; + const double fMMToTWIPS(72.0 / 127.0); - aTransform.scale(fMMToTWIPS, fMMToTWIPS); - rPolyPolygon.transform(aTransform); - break; - } - default: - { - OSL_FAIL("Missing unit translation to PoolMetric!"); - } - } + aTransform.scale(fMMToTWIPS, fMMToTWIPS); + rPolyPolygon.transform(aTransform); + break; + } + default: + { + OSL_FAIL("Missing unit translation to PoolMetric!"); } } } @@ -479,29 +479,29 @@ void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DHomMatrix& rB2DHomMatrix) const throw() { DBG_TESTSOLARMUTEX(); - if(HasSdrObject()) + if(!HasSdrObject()) + return; + + MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0)); + if(eMapUnit == MapUnit::Map100thMM) + return; + + switch(eMapUnit) { - MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0)); - if(eMapUnit != MapUnit::Map100thMM) + case MapUnit::MapTwip : { - switch(eMapUnit) - { - case MapUnit::MapTwip : - { - const double fMMToTWIPS(72.0 / 127.0); - const basegfx::utils::B2DHomMatrixBufferedDecompose aDecomposedTransform(rB2DHomMatrix); - rB2DHomMatrix = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix( - aDecomposedTransform.getScale() * fMMToTWIPS, - aDecomposedTransform.getShearX(), - aDecomposedTransform.getRotate(), - aDecomposedTransform.getTranslate() * fMMToTWIPS); - break; - } - default: - { - OSL_FAIL("Missing unit translation to PoolMetric!"); - } - } + const double fMMToTWIPS(72.0 / 127.0); + const basegfx::utils::B2DHomMatrixBufferedDecompose aDecomposedTransform(rB2DHomMatrix); + rB2DHomMatrix = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix( + aDecomposedTransform.getScale() * fMMToTWIPS, + aDecomposedTransform.getShearX(), + aDecomposedTransform.getRotate(), + aDecomposedTransform.getTranslate() * fMMToTWIPS); + break; + } + default: + { + OSL_FAIL("Missing unit translation to PoolMetric!"); } } } @@ -510,24 +510,24 @@ void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw() { DBG_TESTSOLARMUTEX(); MapUnit eMapUnit = MapUnit::Map100thMM; - if(HasSdrObject()) + if(!HasSdrObject()) + return; + + eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0); + if(eMapUnit == MapUnit::Map100thMM) + return; + + switch(eMapUnit) { - eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0); - if(eMapUnit != MapUnit::Map100thMM) + case MapUnit::MapTwip : { - switch(eMapUnit) - { - case MapUnit::MapTwip : - { - rPoint.A() = TWIPS_TO_MM(rPoint.A()); - rPoint.B() = TWIPS_TO_MM(rPoint.B()); - break; - } - default: - { - OSL_FAIL("AW: Missing unit translation to 100th mm!"); - } - } + rPoint.A() = TWIPS_TO_MM(rPoint.A()); + rPoint.B() = TWIPS_TO_MM(rPoint.B()); + break; + } + default: + { + OSL_FAIL("AW: Missing unit translation to 100th mm!"); } } } @@ -536,26 +536,26 @@ void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) cons { DBG_TESTSOLARMUTEX(); MapUnit eMapUnit = MapUnit::Map100thMM; - if(HasSdrObject()) + if(!HasSdrObject()) + return; + + eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0); + if(eMapUnit == MapUnit::Map100thMM) + return; + + switch(eMapUnit) { - eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0); - if(eMapUnit != MapUnit::Map100thMM) + case MapUnit::MapTwip : { - switch(eMapUnit) - { - case MapUnit::MapTwip : - { - basegfx::B2DHomMatrix aTransform; - const double fTWIPSToMM(127.0 / 72.0); - aTransform.scale(fTWIPSToMM, fTWIPSToMM); - rPolyPolygon.transform(aTransform); - break; - } - default: - { - OSL_FAIL("Missing unit translation to 100th mm!"); - } - } + basegfx::B2DHomMatrix aTransform; + const double fTWIPSToMM(127.0 / 72.0); + aTransform.scale(fTWIPSToMM, fTWIPSToMM); + rPolyPolygon.transform(aTransform); + break; + } + default: + { + OSL_FAIL("Missing unit translation to 100th mm!"); } } } @@ -564,29 +564,29 @@ void SvxShape::ForceMetricTo100th_mm(basegfx::B2DHomMatrix& rB2DHomMatrix) const { DBG_TESTSOLARMUTEX(); MapUnit eMapUnit = MapUnit::Map100thMM; - if(HasSdrObject()) + if(!HasSdrObject()) + return; + + eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0); + if(eMapUnit == MapUnit::Map100thMM) + return; + + switch(eMapUnit) { - eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0); - if(eMapUnit != MapUnit::Map100thMM) + case MapUnit::MapTwip : { - switch(eMapUnit) - { - case MapUnit::MapTwip : - { - const double fTWIPSToMM(127.0 / 72.0); - const basegfx::utils::B2DHomMatrixBufferedDecompose aDecomposedTransform(rB2DHomMatrix); - rB2DHomMatrix = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix( - aDecomposedTransform.getScale() * fTWIPSToMM, - aDecomposedTransform.getShearX(), - aDecomposedTransform.getRotate(), - aDecomposedTransform.getTranslate() * fTWIPSToMM); - break; - } - default: - { - OSL_FAIL("Missing unit translation to 100th mm!"); - } - } + const double fTWIPSToMM(127.0 / 72.0); + const basegfx::utils::B2DHomMatrixBufferedDecompose aDecomposedTransform(rB2DHomMatrix); + rB2DHomMatrix = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix( + aDecomposedTransform.getScale() * fTWIPSToMM, + aDecomposedTransform.getShearX(), + aDecomposedTransform.getRotate(), + aDecomposedTransform.getTranslate() * fTWIPSToMM); + break; + } + default: + { + OSL_FAIL("Missing unit translation to 100th mm!"); } } } @@ -594,48 +594,48 @@ void SvxShape::ForceMetricTo100th_mm(basegfx::B2DHomMatrix& rB2DHomMatrix) const static void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet, SfxItemSet& rSet, const uno::Reference< beans::XPropertySet >& xSet, const SfxItemPropertyMap* pMap ) { - if(rPropSet.AreThereOwnUsrAnys()) - { - const SfxItemPropertyMap& rSrc = rPropSet.getPropertyMap(); - PropertyEntryVector_t aSrcPropVector = rSrc.getPropertyEntries(); + if(!rPropSet.AreThereOwnUsrAnys()) + return; - for(const auto& rSrcProp : aSrcPropVector) - { - const sal_uInt16 nWID = rSrcProp.nWID; - if(SfxItemPool::IsWhich(nWID) - && (nWID < OWN_ATTR_VALUE_START || nWID > OWN_ATTR_VALUE_END) - && rPropSet.GetUsrAnyForID(rSrcProp)) - rSet.Put(rSet.GetPool()->GetDefaultItem(nWID)); - } + const SfxItemPropertyMap& rSrc = rPropSet.getPropertyMap(); + PropertyEntryVector_t aSrcPropVector = rSrc.getPropertyEntries(); + + for(const auto& rSrcProp : aSrcPropVector) + { + const sal_uInt16 nWID = rSrcProp.nWID; + if(SfxItemPool::IsWhich(nWID) + && (nWID < OWN_ATTR_VALUE_START || nWID > OWN_ATTR_VALUE_END) + && rPropSet.GetUsrAnyForID(rSrcProp)) + rSet.Put(rSet.GetPool()->GetDefaultItem(nWID)); + } - for(const auto& rSrcProp : aSrcPropVector) + for(const auto& rSrcProp : aSrcPropVector) + { + if(rSrcProp.nWID) { - if(rSrcProp.nWID) + uno::Any* pUsrAny = rPropSet.GetUsrAnyForID(rSrcProp); + if(pUsrAny) { - uno::Any* pUsrAny = rPropSet.GetUsrAnyForID(rSrcProp); - if(pUsrAny) + // search for equivalent entry in pDst + const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rSrcProp.sName ); + if(pEntry) { - // search for equivalent entry in pDst - const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rSrcProp.sName ); - if(pEntry) + // entry found + if(pEntry->nWID >= OWN_ATTR_VALUE_START && pEntry->nWID <= OWN_ATTR_VALUE_END) { - // entry found - if(pEntry->nWID >= OWN_ATTR_VALUE_START && pEntry->nWID <= OWN_ATTR_VALUE_END) - { - // special ID in PropertySet, can only be set - // directly at the object - xSet->setPropertyValue( rSrcProp.sName, *pUsrAny); - } - else - { - SvxItemPropertySet_setPropertyValue(pEntry, *pUsrAny, rSet); - } + // special ID in PropertySet, can only be set + // directly at the object + xSet->setPropertyValue( rSrcProp.sName, *pUsrAny); + } + else + { + SvxItemPropertySet_setPropertyValue(pEntry, *pUsrAny, rSet); } } } } - const_cast< SvxItemPropertySet& >(rPropSet).ClearAllUsrAny(); } + const_cast< SvxItemPropertySet& >(rPropSet).ClearAllUsrAny(); } @@ -1037,31 +1037,31 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw() break; }; - if( bClearMe ) + if( !bClearMe ) + return; + + if(!HasSdrObjectOwnership()) { - if(!HasSdrObjectOwnership()) + if(nullptr != pSdrObject) { - if(nullptr != pSdrObject) - { - EndListening(pSdrObject->getSdrModelFromSdrObject()); - pSdrObject->setUnoShape(nullptr); - } - - mpSdrObjectWeakReference.reset(nullptr); - - // SdrModel *is* going down, try to Free SdrObject even - // when !HasSdrObjectOwnership - if(nullptr != pSdrObject && !pSdrObject->IsInserted()) - { - SdrObject::Free(pSdrObject); - } + EndListening(pSdrObject->getSdrModelFromSdrObject()); + pSdrObject->setUnoShape(nullptr); } - if(!mpImpl->mbDisposing) + mpSdrObjectWeakReference.reset(nullptr); + + // SdrModel *is* going down, try to Free SdrObject even + // when !HasSdrObjectOwnership + if(nullptr != pSdrObject && !pSdrObject->IsInserted()) { - dispose(); + SdrObject::Free(pSdrObject); } } + + if(!mpImpl->mbDisposing) + { + dispose(); + } } // XShape @@ -1300,42 +1300,42 @@ void SAL_CALL SvxShape::dispose() mpImpl->maDisposeListeners.disposeAndClear(aEvt); mpImpl->maPropertyNotifier.disposing(); - if ( HasSdrObject() ) - { - SdrObject* pObject = GetSdrObject(); + if ( !HasSdrObject() ) + return; - EndListening( pObject->getSdrModelFromSdrObject() ); - bool bFreeSdrObject = false; + SdrObject* pObject = GetSdrObject(); - if ( pObject->IsInserted() && pObject->getSdrPageFromSdrObject() ) - { - OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" ); - // normally, we are allowed to free the SdrObject only if we have its ownership. - // Why isn't this checked here? + EndListening( pObject->getSdrModelFromSdrObject() ); + bool bFreeSdrObject = false; + + if ( pObject->IsInserted() && pObject->getSdrPageFromSdrObject() ) + { + OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" ); + // normally, we are allowed to free the SdrObject only if we have its ownership. + // Why isn't this checked here? - SdrPage* pPage = pObject->getSdrPageFromSdrObject(); - // delete the SdrObject from the page - const size_t nCount = pPage->GetObjCount(); - for ( size_t nNum = 0; nNum < nCount; ++nNum ) + SdrPage* pPage = pObject->getSdrPageFromSdrObject(); + // delete the SdrObject from the page + const size_t nCount = pPage->GetObjCount(); + for ( size_t nNum = 0; nNum < nCount; ++nNum ) + { + if ( pPage->GetObj( nNum ) == pObject ) { - if ( pPage->GetObj( nNum ) == pObject ) - { - OSL_VERIFY( pPage->RemoveObject( nNum ) == pObject ); - bFreeSdrObject = true; - break; - } + OSL_VERIFY( pPage->RemoveObject( nNum ) == pObject ); + bFreeSdrObject = true; + break; } } + } - pObject->setUnoShape(nullptr); + pObject->setUnoShape(nullptr); - if ( bFreeSdrObject ) - { - // in case we have the ownership of the SdrObject, a Free - // would do nothing. So ensure the ownership is reset. - mpImpl->mbHasSdrObjectOwnership = false; - SdrObject::Free( pObject ); - } + if ( bFreeSdrObject ) + { + // in case we have the ownership of the SdrObject, a Free + // would do nothing. So ensure the ownership is reset. + mpImpl->mbHasSdrObjectOwnership = false; + SdrObject::Free( pObject ); } } diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx index 61fdc3636b74..6a5bd4febfe8 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -435,18 +435,18 @@ void SvxTextEditSourceImpl::SetupOutliner() // only for UAA edit source: setup outliner equivalently as in // SdrTextObj::Paint(), such that formatting equals screen // layout - if( mpObject && mpOutliner ) + if( !(mpObject && mpOutliner) ) + return; + + SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject ); + tools::Rectangle aPaintRect; + if( pTextObj ) { - SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject ); - tools::Rectangle aPaintRect; - if( pTextObj ) - { - tools::Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() ); - pTextObj->SetupOutlinerFormatting( *mpOutliner, aPaintRect ); + tools::Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() ); + pTextObj->SetupOutlinerFormatting( *mpOutliner, aPaintRect ); - // calc text offset from shape anchor - maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft(); - } + // calc text offset from shape anchor + maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft(); } } @@ -456,18 +456,18 @@ void SvxTextEditSourceImpl::UpdateOutliner() // only for UAA edit source: update outliner equivalently as in // SdrTextObj::Paint(), such that formatting equals screen // layout - if( mpObject && mpOutliner ) + if( !(mpObject && mpOutliner) ) + return; + + SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject ); + tools::Rectangle aPaintRect; + if( pTextObj ) { - SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( mpObject ); - tools::Rectangle aPaintRect; - if( pTextObj ) - { - tools::Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() ); - pTextObj->UpdateOutlinerFormatting( *mpOutliner, aPaintRect ); + tools::Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() ); + pTextObj->UpdateOutlinerFormatting( *mpOutliner, aPaintRect ); - // calc text offset from shape anchor - maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft(); - } + // calc text offset from shape anchor + maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft(); } } @@ -761,44 +761,44 @@ void SvxTextEditSourceImpl::UpdateData() // DrawOutliner. Thus, all changes made on the text forwarder are // reflected on the view and committed to the model on // SdrEndTextEdit(). Thus, no need for explicit updates here. - if( !HasView() || !IsEditMode() ) + if( HasView() && IsEditMode() ) + return; + + if( mbIsLocked ) { - if( mbIsLocked ) - { - mbNeedsUpdate = true; - } - else + mbNeedsUpdate = true; + } + else + { + if( mpOutliner && mpObject && mpText ) { - if( mpOutliner && mpObject && mpText ) + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject ); + if( pTextObj ) { - SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject ); - if( pTextObj ) + if( mpOutliner->GetParagraphCount() != 1 || mpOutliner->GetEditEngine().GetTextLen( 0 ) ) { - if( mpOutliner->GetParagraphCount() != 1 || mpOutliner->GetEditEngine().GetTextLen( 0 ) ) + if( mpOutliner->GetParagraphCount() > 1 ) { - if( mpOutliner->GetParagraphCount() > 1 ) + if (pTextObj->IsTextFrame() && pTextObj->GetTextKind() == OBJ_TITLETEXT) { - if (pTextObj->IsTextFrame() && pTextObj->GetTextKind() == OBJ_TITLETEXT) + while( mpOutliner->GetParagraphCount() > 1 ) { - while( mpOutliner->GetParagraphCount() > 1 ) - { - ESelection aSel( 0,mpOutliner->GetEditEngine().GetTextLen( 0 ), 1,0 ); - mpOutliner->QuickInsertLineBreak( aSel ); - } + ESelection aSel( 0,mpOutliner->GetEditEngine().GetTextLen( 0 ), 1,0 ); + mpOutliner->QuickInsertLineBreak( aSel ); } } - - pTextObj->NbcSetOutlinerParaObjectForText( mpOutliner->CreateParaObject(), mpText ); - } - else - { - pTextObj->NbcSetOutlinerParaObjectForText( nullptr,mpText ); } - } - if( mpObject->IsEmptyPresObj() ) - mpObject->SetEmptyPresObj(false); + pTextObj->NbcSetOutlinerParaObjectForText( mpOutliner->CreateParaObject(), mpText ); + } + else + { + pTextObj->NbcSetOutlinerParaObjectForText( nullptr,mpText ); + } } + + if( mpObject->IsEmptyPresObj() ) + mpObject->SetEmptyPresObj(false); } } } diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx index f9839c38b8ed..b9082b6325c2 100644 --- a/svx/source/xml/xmlgrhlp.cxx +++ b/svx/source/xml/xmlgrhlp.cxx @@ -105,63 +105,63 @@ GraphicInputStream::GraphicInputStream(GraphicObject const & aGraphicObject, con { maTempFile.EnableKillingFile(); - if (aGraphicObject.GetType() != GraphicType::NONE) - { - std::unique_ptr<SvStream> pStream = ::utl::UcbStreamHelper::CreateStream(maTempFile.GetURL(), StreamMode::WRITE | StreamMode::TRUNC); + if (aGraphicObject.GetType() == GraphicType::NONE) + return; - if (pStream) - { - const Graphic& aGraphic(aGraphicObject.GetGraphic()); - const GfxLink aGfxLink(aGraphic.GetGfxLink()); - bool bRet = false; + std::unique_ptr<SvStream> pStream = ::utl::UcbStreamHelper::CreateStream(maTempFile.GetURL(), StreamMode::WRITE | StreamMode::TRUNC); - if (aGfxLink.GetDataSize() && aGfxLink.GetData()) - { - if (rMimeType.isEmpty()) - { - pStream->WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize()); - bRet = (pStream->GetError() == ERRCODE_NONE); - } - else - { - GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter(); - bRet = (rFilter.ExportGraphic(aGraphic, "", *pStream, rFilter.GetExportFormatNumberForMediaType(rMimeType)) == ERRCODE_NONE); - } - } - else - { - if (aGraphic.GetType() == GraphicType::Bitmap) - { - GraphicFilter & rFilter = GraphicFilter::GetGraphicFilter(); - OUString aFormat = rMimeType; + if (!pStream) + return; - if (aGraphic.IsAnimated()) - aFormat = "image/gif"; - else if (aFormat.isEmpty()) - aFormat = "image/png"; + const Graphic& aGraphic(aGraphicObject.GetGraphic()); + const GfxLink aGfxLink(aGraphic.GetGfxLink()); + bool bRet = false; - bRet = (rFilter.ExportGraphic(aGraphic, "", *pStream, rFilter.GetExportFormatNumberForMediaType(aFormat)) == ERRCODE_NONE); - } - else if (rMimeType.isEmpty() && aGraphic.GetType() == GraphicType::GdiMetafile) - { - pStream->SetVersion(SOFFICE_FILEFORMAT_8); - pStream->SetCompressMode(SvStreamCompressFlags::ZBITMAP); - const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()).Write(*pStream); - bRet = (pStream->GetError() == ERRCODE_NONE); - } - else if (!rMimeType.isEmpty()) - { - GraphicFilter & rFilter = GraphicFilter::GetGraphicFilter(); - bRet = ( rFilter.ExportGraphic( aGraphic, "", *pStream, rFilter.GetExportFormatNumberForMediaType( rMimeType ) ) == ERRCODE_NONE ); - } - } + if (aGfxLink.GetDataSize() && aGfxLink.GetData()) + { + if (rMimeType.isEmpty()) + { + pStream->WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize()); + bRet = (pStream->GetError() == ERRCODE_NONE); + } + else + { + GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter(); + bRet = (rFilter.ExportGraphic(aGraphic, "", *pStream, rFilter.GetExportFormatNumberForMediaType(rMimeType)) == ERRCODE_NONE); + } + } + else + { + if (aGraphic.GetType() == GraphicType::Bitmap) + { + GraphicFilter & rFilter = GraphicFilter::GetGraphicFilter(); + OUString aFormat = rMimeType; - if (bRet) - { - pStream->Seek( 0 ); - mxStreamWrapper = new ::utl::OInputStreamWrapper(std::move(pStream)); - } + if (aGraphic.IsAnimated()) + aFormat = "image/gif"; + else if (aFormat.isEmpty()) + aFormat = "image/png"; + + bRet = (rFilter.ExportGraphic(aGraphic, "", *pStream, rFilter.GetExportFormatNumberForMediaType(aFormat)) == ERRCODE_NONE); + } + else if (rMimeType.isEmpty() && aGraphic.GetType() == GraphicType::GdiMetafile) + { + pStream->SetVersion(SOFFICE_FILEFORMAT_8); + pStream->SetCompressMode(SvStreamCompressFlags::ZBITMAP); + const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()).Write(*pStream); + bRet = (pStream->GetError() == ERRCODE_NONE); } + else if (!rMimeType.isEmpty()) + { + GraphicFilter & rFilter = GraphicFilter::GetGraphicFilter(); + bRet = ( rFilter.ExportGraphic( aGraphic, "", *pStream, rFilter.GetExportFormatNumberForMediaType( rMimeType ) ) == ERRCODE_NONE ); + } + } + + if (bRet) + { + pStream->Seek( 0 ); + mxStreamWrapper = new ::utl::OInputStreamWrapper(std::move(pStream)); } } diff --git a/svx/source/xoutdev/_xpoly.cxx b/svx/source/xoutdev/_xpoly.cxx index abb536aedc82..f56c1b411248 100644 --- a/svx/source/xoutdev/_xpoly.cxx +++ b/svx/source/xoutdev/_xpoly.cxx @@ -113,31 +113,31 @@ void ImpXPolygon::Resize( sal_uInt16 nNewSize, bool bDeletePoints ) memset( pFlagAry.get(), 0, nSize ); // copy if needed - if( nOldSize ) + if( !nOldSize ) + return; + + if( nOldSize < nSize ) { - if( nOldSize < nSize ) - { - memcpy( pPointAry.get(), pOldPointAry, nOldSize*sizeof( Point ) ); - memcpy( pFlagAry.get(), pOldFlagAry, nOldSize ); - } - else - { - memcpy( pPointAry.get(), pOldPointAry, nSize*sizeof( Point ) ); - memcpy( pFlagAry.get(), pOldFlagAry, nSize ); + memcpy( pPointAry.get(), pOldPointAry, nOldSize*sizeof( Point ) ); + memcpy( pFlagAry.get(), pOldFlagAry, nOldSize ); + } + else + { + memcpy( pPointAry.get(), pOldPointAry, nSize*sizeof( Point ) ); + memcpy( pFlagAry.get(), pOldFlagAry, nSize ); - // adjust number of valid points - if( nPoints > nSize ) - nPoints = nSize; - } - if ( bDeletePoints ) - { - delete[] pOldPointAry; - pOldPointAry = nullptr; - } - else - bDeleteOldPoints = true; - delete[] pOldFlagAry; + // adjust number of valid points + if( nPoints > nSize ) + nPoints = nSize; } + if ( bDeletePoints ) + { + delete[] pOldPointAry; + pOldPointAry = nullptr; + } + else + bDeleteOldPoints = true; + delete[] pOldFlagAry; } void ImpXPolygon::InsertSpace( sal_uInt16 nPos, sal_uInt16 nCount ) @@ -169,20 +169,20 @@ void ImpXPolygon::Remove( sal_uInt16 nPos, sal_uInt16 nCount ) { CheckPointDelete(); - if( (nPos + nCount) <= nPoints ) - { - sal_uInt16 nMove = nPoints - nPos - nCount; + if( (nPos + nCount) > nPoints ) + return; - if( nMove ) - { - memmove( &pPointAry[nPos], &pPointAry[nPos+nCount], - nMove * sizeof(Point) ); - memmove( &pFlagAry[nPos], &pFlagAry[nPos+nCount], nMove ); - } - std::fill(pPointAry.get() + (nPoints - nCount), pPointAry.get() + nPoints, Point()); - memset( &pFlagAry [nPoints - nCount], 0, nCount ); - nPoints = nPoints - nCount; + sal_uInt16 nMove = nPoints - nPos - nCount; + + if( nMove ) + { + memmove( &pPointAry[nPos], &pPointAry[nPos+nCount], + nMove * sizeof(Point) ); + memmove( &pFlagAry[nPos], &pFlagAry[nPos+nCount], nMove ); } + std::fill(pPointAry.get() + (nPoints - nCount), pPointAry.get() + nPoints, Point()); + memset( &pFlagAry [nPoints - nCount], 0, nCount ); + nPoints = nPoints - nCount; } void ImpXPolygon::CheckPointDelete() const |