summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 13:42:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-21 15:55:46 +0100
commit25298930bc86d1a449a7e5b139d65e49f695f8c1 (patch)
treeb3f28ef6b18b12347694a637b6785ecb5eedc1fe
parenttdf#146244 sw: fix Undo of accepting table row insertion (diff)
downloadcore-25298930bc86d1a449a7e5b139d65e49f695f8c1.tar.gz
core-25298930bc86d1a449a7e5b139d65e49f695f8c1.zip
loplugin:flatten in canvas..cui
Change-Id: I208767eaa60d913fe2882403f1f9351eb08256f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127224 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--canvas/inc/spriteredrawmanager.hxx96
-rw-r--r--canvas/source/cairo/cairo_canvashelper.cxx28
-rw-r--r--canvas/source/tools/canvastools.cxx30
-rw-r--r--chart2/source/controller/main/ChartController_TextEdit.cxx40
-rw-r--r--chart2/source/controller/main/ChartFrameloader.cxx72
-rw-r--r--chart2/source/tools/AxisHelper.cxx62
-rw-r--r--chart2/source/view/charttypes/PieChart.cxx83
-rw-r--r--chart2/source/view/main/ChartView.cxx57
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx121
-rw-r--r--comphelper/source/container/embeddedobjectcontainer.cxx74
-rw-r--r--comphelper/source/misc/backupfilehelper.cxx488
-rw-r--r--comphelper/source/misc/namedvaluecollection.cxx40
-rw-r--r--comphelper/source/officeinstdir/officeinstallationdirectories.cxx40
-rw-r--r--configmgr/source/valueparser.cxx29
-rw-r--r--connectivity/source/drivers/calc/CDatabaseMetaData.cxx52
-rw-r--r--connectivity/source/drivers/calc/CTable.cxx35
-rw-r--r--connectivity/source/drivers/firebird/ResultSetMetaData.cxx102
-rw-r--r--connectivity/source/drivers/firebird/StatementCommonBase.cxx28
-rw-r--r--connectivity/source/drivers/hsqldb/HStorageAccess.cxx40
-rw-r--r--connectivity/source/drivers/hsqldb/StorageFileAccess.cxx46
-rw-r--r--connectivity/source/manager/mdrivermanager.cxx30
-rw-r--r--connectivity/source/parse/sqlnode.cxx155
-rw-r--r--cppu/source/threadpool/current.cxx34
-rw-r--r--cppu/source/typelib/typelib.cxx398
-rw-r--r--cppuhelper/source/servicemanager.cxx63
-rw-r--r--cui/source/customize/acccfg.cxx29
-rw-r--r--cui/source/customize/cfg.cxx28
-rw-r--r--cui/source/options/cfgchart.cxx59
-rw-r--r--cui/source/options/treeopt.cxx36
-rw-r--r--cui/source/tabpages/backgrnd.cxx52
-rw-r--r--cui/source/tabpages/swpossizetabpage.cxx97
-rw-r--r--cui/source/tabpages/textattr.cxx44
-rw-r--r--cui/source/tabpages/themepage.cxx64
33 files changed, 1319 insertions, 1333 deletions
diff --git a/canvas/inc/spriteredrawmanager.hxx b/canvas/inc/spriteredrawmanager.hxx
index 87c692f6d7dc..cf2b86e0a8cc 100644
--- a/canvas/inc/spriteredrawmanager.hxx
+++ b/canvas/inc/spriteredrawmanager.hxx
@@ -286,64 +286,64 @@ namespace canvas
{
// check whether this area contains changed sprites at all
// (if not, just ignore it)
- if( areSpritesChanged( rUpdateArea ) )
+ if( !areSpritesChanged( rUpdateArea ) )
+ return;
+
+ // at least one of the sprites actually needs an
+ // update - process whole area.
+
+ // check whether this area could be handled special
+ // (background paint, direct update, scroll, etc.)
+ ::basegfx::B2DRange aMoveStart;
+ ::basegfx::B2DRange aMoveEnd;
+ if( rUpdateArea.maComponentList.empty() )
+ {
+ rFunc.backgroundPaint( rUpdateArea.maTotalBounds );
+ }
+ else
{
- // at least one of the sprites actually needs an
- // update - process whole area.
-
- // check whether this area could be handled special
- // (background paint, direct update, scroll, etc.)
- ::basegfx::B2DRange aMoveStart;
- ::basegfx::B2DRange aMoveEnd;
- if( rUpdateArea.maComponentList.empty() )
+ // cache number of sprites in this area (it's a
+ // list, and both isAreaUpdateScroll() and
+ // isAreaUpdateOpaque() need it).
+ const ::std::size_t nNumSprites(
+ rUpdateArea.maComponentList.size() );
+
+ if( isAreaUpdateScroll( aMoveStart,
+ aMoveEnd,
+ rUpdateArea,
+ nNumSprites ) )
{
- rFunc.backgroundPaint( rUpdateArea.maTotalBounds );
+ rFunc.scrollUpdate( aMoveStart,
+ aMoveEnd,
+ rUpdateArea );
}
else
{
- // cache number of sprites in this area (it's a
- // list, and both isAreaUpdateScroll() and
- // isAreaUpdateOpaque() need it).
- const ::std::size_t nNumSprites(
- rUpdateArea.maComponentList.size() );
-
- if( isAreaUpdateScroll( aMoveStart,
- aMoveEnd,
- rUpdateArea,
+ // potentially, more than a single sprite
+ // involved. Have to sort component lists for
+ // sprite prio.
+ VectorOfSprites aSortedUpdateSprites;
+ for (auto const& elem : rUpdateArea.maComponentList)
+ {
+ const Sprite::Reference& rSprite( elem.second.getSprite() );
+ if( rSprite.is() )
+ aSortedUpdateSprites.push_back( rSprite );
+ }
+
+ ::std::sort( aSortedUpdateSprites.begin(),
+ aSortedUpdateSprites.end(),
+ SpriteWeakOrder() );
+
+ if( isAreaUpdateOpaque( rUpdateArea,
nNumSprites ) )
{
- rFunc.scrollUpdate( aMoveStart,
- aMoveEnd,
- rUpdateArea );
+ rFunc.opaqueUpdate( rUpdateArea.maTotalBounds,
+ aSortedUpdateSprites );
}
else
{
- // potentially, more than a single sprite
- // involved. Have to sort component lists for
- // sprite prio.
- VectorOfSprites aSortedUpdateSprites;
- for (auto const& elem : rUpdateArea.maComponentList)
- {
- const Sprite::Reference& rSprite( elem.second.getSprite() );
- if( rSprite.is() )
- aSortedUpdateSprites.push_back( rSprite );
- }
-
- ::std::sort( aSortedUpdateSprites.begin(),
- aSortedUpdateSprites.end(),
- SpriteWeakOrder() );
-
- if( isAreaUpdateOpaque( rUpdateArea,
- nNumSprites ) )
- {
- rFunc.opaqueUpdate( rUpdateArea.maTotalBounds,
- aSortedUpdateSprites );
- }
- else
- {
- rFunc.genericUpdate( rUpdateArea.maTotalBounds,
- aSortedUpdateSprites );
- }
+ rFunc.genericUpdate( rUpdateArea.maTotalBounds,
+ aSortedUpdateSprites );
}
}
}
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx
index 2ee30cfc3740..e9aafabe7e63 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -2015,25 +2015,25 @@ constexpr OUStringLiteral PARAMETRICPOLYPOLYGON_IMPLEMENTATION_NAME = u"Canvas::
{
SAL_INFO( "canvas.cairo", "CanvasHelper::repaint");
- if( mpCairo )
- {
- cairo_save( mpCairo.get() );
+ if( !mpCairo )
+ return true;
- cairo_rectangle( mpCairo.get(), 0, 0, maSize.getX(), maSize.getY() );
- cairo_clip( mpCairo.get() );
+ cairo_save( mpCairo.get() );
- useStates( viewState, renderState, true );
+ cairo_rectangle( mpCairo.get(), 0, 0, maSize.getX(), maSize.getY() );
+ cairo_clip( mpCairo.get() );
- cairo_matrix_t aMatrix;
+ useStates( viewState, renderState, true );
- cairo_get_matrix( mpCairo.get(), &aMatrix );
- aMatrix.xx = aMatrix.yy = 1;
- cairo_set_matrix( mpCairo.get(), &aMatrix );
+ cairo_matrix_t aMatrix;
- cairo_set_source_surface( mpCairo.get(), pSurface->getCairoSurface().get(), 0, 0 );
- cairo_paint( mpCairo.get() );
- cairo_restore( mpCairo.get() );
- }
+ cairo_get_matrix( mpCairo.get(), &aMatrix );
+ aMatrix.xx = aMatrix.yy = 1;
+ cairo_set_matrix( mpCairo.get(), &aMatrix );
+
+ cairo_set_source_surface( mpCairo.get(), pSurface->getCairoSurface().get(), 0, 0 );
+ cairo_paint( mpCairo.get() );
+ cairo_restore( mpCairo.get() );
return true;
}
diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx
index f6182ae9b7b3..048a99407c68 100644
--- a/canvas/source/tools/canvastools.cxx
+++ b/canvas/source/tools/canvastools.cxx
@@ -1080,25 +1080,25 @@ namespace canvas::tools
{
o_rxParams.realloc( 0 );
- if( i_rxCanvas.is() )
+ if( !i_rxCanvas.is() )
+ return o_rxParams;
+
+ try
{
- try
- {
- uno::Reference< rendering::XGraphicDevice > xDevice( i_rxCanvas->getDevice(),
- uno::UNO_SET_THROW );
+ uno::Reference< rendering::XGraphicDevice > xDevice( i_rxCanvas->getDevice(),
+ uno::UNO_SET_THROW );
- uno::Reference< lang::XServiceInfo > xServiceInfo( xDevice,
- uno::UNO_QUERY_THROW );
- uno::Reference< beans::XPropertySet > xPropSet( xDevice,
+ uno::Reference< lang::XServiceInfo > xServiceInfo( xDevice,
uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xPropSet( xDevice,
+ uno::UNO_QUERY_THROW );
- o_rxParams = { uno::Any(xServiceInfo->getImplementationName()),
- xPropSet->getPropertyValue( "DeviceHandle" ) };
- }
- catch( const uno::Exception& )
- {
- // ignore, but return empty sequence
- }
+ o_rxParams = { uno::Any(xServiceInfo->getImplementationName()),
+ xPropSet->getPropertyValue( "DeviceHandle" ) };
+ }
+ catch( const uno::Exception& )
+ {
+ // ignore, but return empty sequence
}
return o_rxParams;
diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx
index 23b590907f67..524d57762292 100644
--- a/chart2/source/controller/main/ChartController_TextEdit.cxx
+++ b/chart2/source/controller/main/ChartController_TextEdit.cxx
@@ -121,32 +121,32 @@ bool ChartController::EndTextEdit()
SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner();
OutlinerParaObject* pParaObj = pTextObject->GetOutlinerParaObject();
- if( pParaObj && pOutliner )
- {
- pOutliner->SetText( *pParaObj );
+ if( !pParaObj || !pOutliner )
+ return true;
- OUString aString = pOutliner->GetText(
- pOutliner->GetParagraph( 0 ),
- pOutliner->GetParagraphCount() );
+ pOutliner->SetText( *pParaObj );
- OUString aObjectCID = m_aSelection.getSelectedCID();
- if ( !aObjectCID.isEmpty() )
- {
- uno::Reference< beans::XPropertySet > xPropSet =
- ObjectIdentifier::getObjectPropertySet( aObjectCID, getModel() );
+ OUString aString = pOutliner->GetText(
+ pOutliner->GetParagraph( 0 ),
+ pOutliner->GetParagraphCount() );
- // lock controllers till end of block
- ControllerLockGuardUNO aCLGuard( getModel() );
+ OUString aObjectCID = m_aSelection.getSelectedCID();
+ if ( !aObjectCID.isEmpty() )
+ {
+ uno::Reference< beans::XPropertySet > xPropSet =
+ ObjectIdentifier::getObjectPropertySet( aObjectCID, getModel() );
- TitleHelper::setCompleteString( aString, uno::Reference<
- css::chart2::XTitle >::query( xPropSet ), m_xCC );
+ // lock controllers till end of block
+ ControllerLockGuardUNO aCLGuard( getModel() );
- OSL_ENSURE(m_pTextActionUndoGuard, "ChartController::EndTextEdit: no TextUndoGuard!");
- if (m_pTextActionUndoGuard)
- m_pTextActionUndoGuard->commit();
- }
- m_pTextActionUndoGuard.reset();
+ TitleHelper::setCompleteString( aString, uno::Reference<
+ css::chart2::XTitle >::query( xPropSet ), m_xCC );
+
+ OSL_ENSURE(m_pTextActionUndoGuard, "ChartController::EndTextEdit: no TextUndoGuard!");
+ if (m_pTextActionUndoGuard)
+ m_pTextActionUndoGuard->commit();
}
+ m_pTextActionUndoGuard.reset();
return true;
}
diff --git a/chart2/source/controller/main/ChartFrameloader.cxx b/chart2/source/controller/main/ChartFrameloader.cxx
index f598a7fff4a7..991c6a87e00f 100644
--- a/chart2/source/controller/main/ChartFrameloader.cxx
+++ b/chart2/source/controller/main/ChartFrameloader.cxx
@@ -134,49 +134,51 @@ sal_Bool SAL_CALL ChartFrameLoader::load( const uno::Sequence< beans::PropertyVa
}
// call initNew() or load() at XLoadable
- if(!bHaveLoadedModel)
- try
+ if(bHaveLoadedModel)
+ return true;
+
+ try
+ {
+ utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_URL));
+ if( aIt != aMediaDescriptor.end())
{
- utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_URL));
- if( aIt != aMediaDescriptor.end())
+ OUString aURL( (*aIt).second.get< OUString >());
+ if( aURL.startsWith( "private:factory/schart" ) )
+ {
+ // create new file
+ uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW );
+ xLoadable->initNew();
+ }
+ else
{
- OUString aURL( (*aIt).second.get< OUString >());
- if( aURL.startsWith( "private:factory/schart" ) )
+ // use the URL as BaseURL, similar to what SfxBaseModel effectively does
+ if (!aURL.isEmpty())
{
- // create new file
- uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW );
- xLoadable->initNew();
+ aMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTBASEURL] <<= aURL;
}
- else
+ aMediaDescriptor.addInputStream();
+ uno::Sequence< beans::PropertyValue > aCompleteMediaDescriptor;
+ aMediaDescriptor >> aCompleteMediaDescriptor;
+ apphelper::MediaDescriptorHelper aMDHelper( aCompleteMediaDescriptor );
+
+ // load file
+ // @todo: replace: aMediaDescriptorHelper.getReducedForModel()
+ uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW );
+ xLoadable->load( aCompleteMediaDescriptor );
+
+ //resize standalone files to get correct size:
+ if( xComponentWindow.is() && aMDHelper.ISSET_FilterName && aMDHelper.FilterName == "StarChart 5.0" )
{
- // use the URL as BaseURL, similar to what SfxBaseModel effectively does
- if (!aURL.isEmpty())
- {
- aMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTBASEURL] <<= aURL;
- }
- aMediaDescriptor.addInputStream();
- uno::Sequence< beans::PropertyValue > aCompleteMediaDescriptor;
- aMediaDescriptor >> aCompleteMediaDescriptor;
- apphelper::MediaDescriptorHelper aMDHelper( aCompleteMediaDescriptor );
-
- // load file
- // @todo: replace: aMediaDescriptorHelper.getReducedForModel()
- uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW );
- xLoadable->load( aCompleteMediaDescriptor );
-
- //resize standalone files to get correct size:
- if( xComponentWindow.is() && aMDHelper.ISSET_FilterName && aMDHelper.FilterName == "StarChart 5.0" )
- {
- awt::Rectangle aRect( xComponentWindow->getPosSize() );
- xComponentWindow->setPosSize( aRect.X, aRect.Y, aRect.Width, aRect.Height, 0 );
- }
+ awt::Rectangle aRect( xComponentWindow->getPosSize() );
+ xComponentWindow->setPosSize( aRect.X, aRect.Y, aRect.Width, aRect.Height, 0 );
}
}
}
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
return true;
}
diff --git a/chart2/source/tools/AxisHelper.cxx b/chart2/source/tools/AxisHelper.cxx
index 4c6c5dd0e8cd..276abb5dbc47 100644
--- a/chart2/source/tools/AxisHelper.cxx
+++ b/chart2/source/tools/AxisHelper.cxx
@@ -743,23 +743,23 @@ bool AxisHelper::getIndicesForAxis(
rOutDimensionIndex = -1;
rOutAxisIndex = -1;
- if( xCooSys.is() && xAxis.is() )
+ if( !xCooSys || !xAxis )
+ return false;
+
+ Reference< XAxis > xCurrentAxis;
+ sal_Int32 nDimensionCount( xCooSys->getDimension() );
+ for( sal_Int32 nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ )
{
- Reference< XAxis > xCurrentAxis;
- sal_Int32 nDimensionCount( xCooSys->getDimension() );
- for( sal_Int32 nDimensionIndex = 0; nDimensionIndex < nDimensionCount; nDimensionIndex++ )
+ sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
+ for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ )
{
- sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
- for( sal_Int32 nAxisIndex = 0; nAxisIndex <= nMaxAxisIndex; nAxisIndex++ )
- {
- xCurrentAxis = xCooSys->getAxisByDimension(nDimensionIndex,nAxisIndex);
- if( xCurrentAxis == xAxis )
- {
- rOutDimensionIndex = nDimensionIndex;
- rOutAxisIndex = nAxisIndex;
- return true;
- }
- }
+ xCurrentAxis = xCooSys->getAxisByDimension(nDimensionIndex,nAxisIndex);
+ if( xCurrentAxis == xAxis )
+ {
+ rOutDimensionIndex = nDimensionIndex;
+ rOutAxisIndex = nAxisIndex;
+ return true;
+ }
}
}
return false;
@@ -904,25 +904,25 @@ void AxisHelper::getAxisOrGridPossibilities( Sequence< sal_Bool >& rPossibilityL
bool AxisHelper::isSecondaryYAxisNeeded( const Reference< XCoordinateSystem >& xCooSys )
{
Reference< chart2::XChartTypeContainer > xCTCnt( xCooSys, uno::UNO_QUERY );
- if( xCTCnt.is() )
+ if( !xCTCnt.is() )
+ return false;
+
+ const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes() );
+ for( Reference< chart2::XChartType > const & chartType : aChartTypes )
{
- const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes() );
- for( Reference< chart2::XChartType > const & chartType : aChartTypes )
- {
- Reference< XDataSeriesContainer > xSeriesContainer( chartType, uno::UNO_QUERY );
- if( !xSeriesContainer.is() )
- continue;
+ Reference< XDataSeriesContainer > xSeriesContainer( chartType, uno::UNO_QUERY );
+ if( !xSeriesContainer.is() )
+ continue;
- Sequence< Reference< XDataSeries > > aSeriesList( xSeriesContainer->getDataSeries() );
- for( sal_Int32 nS = aSeriesList.getLength(); nS-- ; )
+ Sequence< Reference< XDataSeries > > aSeriesList( xSeriesContainer->getDataSeries() );
+ for( sal_Int32 nS = aSeriesList.getLength(); nS-- ; )
+ {
+ Reference< beans::XPropertySet > xProp( aSeriesList[nS], uno::UNO_QUERY );
+ if(xProp.is())
{
- Reference< beans::XPropertySet > xProp( aSeriesList[nS], uno::UNO_QUERY );
- if(xProp.is())
- {
- sal_Int32 nAttachedAxisIndex = 0;
- if( ( xProp->getPropertyValue( "AttachedAxisIndex" ) >>= nAttachedAxisIndex ) && nAttachedAxisIndex>0 )
- return true;
- }
+ sal_Int32 nAttachedAxisIndex = 0;
+ if( ( xProp->getPropertyValue( "AttachedAxisIndex" ) >>= nAttachedAxisIndex ) && nAttachedAxisIndex>0 )
+ return true;
}
}
}
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index 57dbab089e00..331b5e4da107 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -914,48 +914,49 @@ bool PieChart::PieLabelInfo::moveAwayFrom( const PieChart::PieLabelInfo* pFix, c
///boxes (`aOverlap`).
::basegfx::B2IRectangle aOverlap( lcl_getRect( xLabelGroupShape ) );
aOverlap.intersect( lcl_getRect( pFix->xLabelGroupShape ) );
- if( !aOverlap.isEmpty() )
- {
- //TODO: alternative move direction
-
- ///the label is shifted along the direction orthogonal to the vector
- ///starting at the pie/donut center and ending at this label anchor
- ///point;
-
- ///named `aTangentialDirection` the unit vector related to such a
- ///direction, the magnitude of the shift along such a direction is
- ///calculated in this way: if the horizontal component of
- ///`aTangentialDirection` is greater than the vertical component,
- ///the magnitude of the shift is equal to `aOverlap.Width` else to
- ///`aOverlap.Height`;
- basegfx::B2IVector aRadiusDirection = aFirstPosition - aOrigin;
- aRadiusDirection.setLength(1.0);
- basegfx::B2IVector aTangentialDirection( -aRadiusDirection.getY(), aRadiusDirection.getX() );
- bool bShiftHorizontal = abs(aTangentialDirection.getX()) > abs(aTangentialDirection.getY());
- sal_Int32 nShift = bShiftHorizontal ? static_cast<sal_Int32>(aOverlap.getWidth()) : static_cast<sal_Int32>(aOverlap.getHeight());
- ///the magnitude of the shift is also increased by 1/50-th of the width
- ///or the height of the document page;
- nShift += (bShiftHorizontal ? nLabelDistanceX : nLabelDistanceY);
- ///in case the `bMoveHalfWay` parameter is true the magnitude of
- ///the shift is halved.
- if( bMoveHalfWay )
- nShift/=2;
- ///in case the `bMoveClockwise` parameter is false the direction of
- ///`aTangentialDirection` is reversed;
- if(!bMoveClockwise)
- nShift*=-1;
- awt::Point aOldPos( xLabelGroupShape->getPosition() );
- basegfx::B2IVector aNewPos = basegfx::B2IVector( aOldPos.X, aOldPos.Y ) + nShift*aTangentialDirection;
-
- ///a final check is performed in order to be sure that the moved label
- ///is still inside the page document;
- awt::Point aNewAWTPos( aNewPos.getX(), aNewPos.getY() );
- if( !lcl_isInsidePage( aNewAWTPos, xLabelGroupShape->getSize(), rPageSize ) )
- return false;
+ if( aOverlap.isEmpty() )
+ return true;
+
+ //TODO: alternative move direction
+
+ ///the label is shifted along the direction orthogonal to the vector
+ ///starting at the pie/donut center and ending at this label anchor
+ ///point;
+
+ ///named `aTangentialDirection` the unit vector related to such a
+ ///direction, the magnitude of the shift along such a direction is
+ ///calculated in this way: if the horizontal component of
+ ///`aTangentialDirection` is greater than the vertical component,
+ ///the magnitude of the shift is equal to `aOverlap.Width` else to
+ ///`aOverlap.Height`;
+ basegfx::B2IVector aRadiusDirection = aFirstPosition - aOrigin;
+ aRadiusDirection.setLength(1.0);
+ basegfx::B2IVector aTangentialDirection( -aRadiusDirection.getY(), aRadiusDirection.getX() );
+ bool bShiftHorizontal = abs(aTangentialDirection.getX()) > abs(aTangentialDirection.getY());
+ sal_Int32 nShift = bShiftHorizontal ? static_cast<sal_Int32>(aOverlap.getWidth()) : static_cast<sal_Int32>(aOverlap.getHeight());
+ ///the magnitude of the shift is also increased by 1/50-th of the width
+ ///or the height of the document page;
+ nShift += (bShiftHorizontal ? nLabelDistanceX : nLabelDistanceY);
+ ///in case the `bMoveHalfWay` parameter is true the magnitude of
+ ///the shift is halved.
+ if( bMoveHalfWay )
+ nShift/=2;
+ ///in case the `bMoveClockwise` parameter is false the direction of
+ ///`aTangentialDirection` is reversed;
+ if(!bMoveClockwise)
+ nShift*=-1;
+ awt::Point aOldPos( xLabelGroupShape->getPosition() );
+ basegfx::B2IVector aNewPos = basegfx::B2IVector( aOldPos.X, aOldPos.Y ) + nShift*aTangentialDirection;
+
+ ///a final check is performed in order to be sure that the moved label
+ ///is still inside the page document;
+ awt::Point aNewAWTPos( aNewPos.getX(), aNewPos.getY() );
+ if( !lcl_isInsidePage( aNewAWTPos, xLabelGroupShape->getSize(), rPageSize ) )
+ return false;
+
+ xLabelGroupShape->setPosition( aNewAWTPos );
+ bMoved = true;
- xLabelGroupShape->setPosition( aNewAWTPos );
- bMoved = true;
- }
return true;
///note that no further test is performed in order to check that the
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 2387e297b54e..bc76dcf585ca 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1684,39 +1684,38 @@ bool ChartView::getExplicitValuesForAxis(
sal_Int32 nDimensionIndex=-1;
sal_Int32 nAxisIndex=-1;
- if( AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex ) )
+ if( !AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex ) )
+ return false;
+
+ rExplicitScale = pVCooSys->getExplicitScale(nDimensionIndex,nAxisIndex);
+ rExplicitIncrement = pVCooSys->getExplicitIncrement(nDimensionIndex,nAxisIndex);
+ if( !rExplicitScale.m_bShiftedCategoryPosition )
+ return true;
+
+ //remove 'one' from max
+ if( rExplicitScale.AxisType == css::chart2::AxisType::DATE )
{
- rExplicitScale = pVCooSys->getExplicitScale(nDimensionIndex,nAxisIndex);
- rExplicitIncrement = pVCooSys->getExplicitIncrement(nDimensionIndex,nAxisIndex);
- if( rExplicitScale.m_bShiftedCategoryPosition )
+ Date aMaxDate(rExplicitScale.NullDate); aMaxDate.AddDays(::rtl::math::approxFloor(rExplicitScale.Maximum));
+ //for explicit scales with shifted categories we need one interval more
+ switch( rExplicitScale.TimeResolution )
{
- //remove 'one' from max
- if( rExplicitScale.AxisType == css::chart2::AxisType::DATE )
- {
- Date aMaxDate(rExplicitScale.NullDate); aMaxDate.AddDays(::rtl::math::approxFloor(rExplicitScale.Maximum));
- //for explicit scales with shifted categories we need one interval more
- switch( rExplicitScale.TimeResolution )
- {
- case css::chart::TimeUnit::DAY:
- --aMaxDate;
- break;
- case css::chart::TimeUnit::MONTH:
- aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1);
- break;
- case css::chart::TimeUnit::YEAR:
- aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1);
- break;
- }
- rExplicitScale.Maximum = aMaxDate - rExplicitScale.NullDate;
- }
- else if( rExplicitScale.AxisType == css::chart2::AxisType::CATEGORY )
- rExplicitScale.Maximum -= 1.0;
- else if( rExplicitScale.AxisType == css::chart2::AxisType::SERIES )
- rExplicitScale.Maximum -= 1.0;
+ case css::chart::TimeUnit::DAY:
+ --aMaxDate;
+ break;
+ case css::chart::TimeUnit::MONTH:
+ aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1);
+ break;
+ case css::chart::TimeUnit::YEAR:
+ aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1);
+ break;
}
- return true;
+ rExplicitScale.Maximum = aMaxDate - rExplicitScale.NullDate;
}
- return false;
+ else if( rExplicitScale.AxisType == css::chart2::AxisType::CATEGORY )
+ rExplicitScale.Maximum -= 1.0;
+ else if( rExplicitScale.AxisType == css::chart2::AxisType::SERIES )
+ rExplicitScale.Maximum -= 1.0;
+ return true;
}
SdrPage* ChartView::getSdrPage()
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 221fee39acfc..dab77fa42292 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -2088,33 +2088,33 @@ void PlainStructType::dumpComprehensiveGetCppuType(FileStream & out)
bool PlainStructType::dumpBaseMembers(
FileStream & out, OUString const & base, bool withType)
{
- bool hasMember = false;
- if (!base.isEmpty()) {
- rtl::Reference< unoidl::Entity > ent;
- codemaker::UnoType::Sort sort = m_typeMgr->getSort(base, &ent);
- if (sort != codemaker::UnoType::Sort::PlainStruct) {
- throw CannotDumpException(
- "plain struct type base " + base
- + " is not a plain struct type");
- }
- rtl::Reference< unoidl::PlainStructTypeEntity > ent2(
- dynamic_cast< unoidl::PlainStructTypeEntity * >(ent.get()));
- assert(ent2.is());
- if (!ent2.is()) {
- return false;
+ if (base.isEmpty())
+ return false;
+
+ rtl::Reference< unoidl::Entity > ent;
+ codemaker::UnoType::Sort sort = m_typeMgr->getSort(base, &ent);
+ if (sort != codemaker::UnoType::Sort::PlainStruct) {
+ throw CannotDumpException(
+ "plain struct type base " + base
+ + " is not a plain struct type");
+ }
+ rtl::Reference< unoidl::PlainStructTypeEntity > ent2(
+ dynamic_cast< unoidl::PlainStructTypeEntity * >(ent.get()));
+ assert(ent2.is());
+ if (!ent2.is()) {
+ return false;
+ }
+ bool hasMember = dumpBaseMembers(out, ent2->getDirectBase(), withType);
+ for (const unoidl::PlainStructTypeEntity::Member& member : ent2->getDirectMembers()) {
+ if (hasMember) {
+ out << ", ";
}
- hasMember = dumpBaseMembers(out, ent2->getDirectBase(), withType);
- for (const unoidl::PlainStructTypeEntity::Member& member : ent2->getDirectMembers()) {
- if (hasMember) {
- out << ", ";
- }
- if (withType) {
- dumpType(out, member.type, true, true);
- out << " ";
- }
- out << member.name << "_";
- hasMember = true;
+ if (withType) {
+ dumpType(out, member.type, true, true);
+ out << " ";
}
+ out << member.name << "_";
+ hasMember = true;
}
return hasMember;
}
@@ -3198,45 +3198,46 @@ void ExceptionType::dumpDeclaration(FileStream & out)
bool ExceptionType::dumpBaseMembers(
FileStream & out, OUString const & base, bool withType, bool eligibleForDefaults)
{
+ if (base.isEmpty())
+ return false;
+
bool hasMember = false;
- if (!base.isEmpty()) {
- rtl::Reference< unoidl::Entity > ent;
- codemaker::UnoType::Sort sort = m_typeMgr->getSort(base, &ent);
- if (sort != codemaker::UnoType::Sort::Exception) {
- throw CannotDumpException(
- "exception type base " + base + " is not an exception type");
+ rtl::Reference< unoidl::Entity > ent;
+ codemaker::UnoType::Sort sort = m_typeMgr->getSort(base, &ent);
+ if (sort != codemaker::UnoType::Sort::Exception) {
+ throw CannotDumpException(
+ "exception type base " + base + " is not an exception type");
+ }
+ rtl::Reference< unoidl::ExceptionTypeEntity > ent2(
+ dynamic_cast< unoidl::ExceptionTypeEntity * >(ent.get()));
+ assert(ent2.is());
+ if (!ent2.is()) {
+ return false;
+ }
+ hasMember = dumpBaseMembers( out, ent2->getDirectBase(), withType,
+ eligibleForDefaults && ent2->getDirectMembers().empty() );
+ int memberCount = 0;
+ for (const unoidl::ExceptionTypeEntity::Member& member : ent2->getDirectMembers()) {
+ if (hasMember) {
+ out << ", ";
}
- rtl::Reference< unoidl::ExceptionTypeEntity > ent2(
- dynamic_cast< unoidl::ExceptionTypeEntity * >(ent.get()));
- assert(ent2.is());
- if (!ent2.is()) {
- return false;
+ if (withType) {
+ dumpType(out, member.type, true, true);
+ out << " ";
}
- hasMember = dumpBaseMembers( out, ent2->getDirectBase(), withType,
- eligibleForDefaults && ent2->getDirectMembers().empty() );
- int memberCount = 0;
- for (const unoidl::ExceptionTypeEntity::Member& member : ent2->getDirectMembers()) {
- if (hasMember) {
- out << ", ";
- }
- if (withType) {
- dumpType(out, member.type, true, true);
- out << " ";
- }
- out << member.name << "_";
- // We want to provide a default parameter value for uno::Exception subtype
- // constructors, since most of the time we don't pass a Context object in to the exception
- // throw sites.
- if (eligibleForDefaults
- && base == "com.sun.star.uno.Exception"
- && memberCount == 1
- && member.name == "Context"
- && member.type == "com.sun.star.uno.XInterface") {
- out << " = ::css::uno::Reference< ::css::uno::XInterface >()";
- }
- hasMember = true;
- ++memberCount;
+ out << member.name << "_";
+ // We want to provide a default parameter value for uno::Exception subtype
+ // constructors, since most of the time we don't pass a Context object in to the exception
+ // throw sites.
+ if (eligibleForDefaults
+ && base == "com.sun.star.uno.Exception"
+ && memberCount == 1
+ && member.name == "Context"
+ && member.type == "com.sun.star.uno.XInterface") {
+ out << " = ::css::uno::Reference< ::css::uno::XInterface >()";
}
+ hasMember = true;
+ ++memberCount;
}
return hasMember;
}
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx
index ac85e9cfdc70..2d85b73f44ba 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -135,31 +135,31 @@ void EmbeddedObjectContainer::SwitchPersistence( const uno::Reference < embed::X
bool EmbeddedObjectContainer::CommitImageSubStorage()
{
- if ( pImpl->mxImageStorage.is() )
+ if ( !pImpl->mxImageStorage )
+ return true;
+
+ try
{
- try
+ bool bReadOnlyMode = true;
+ uno::Reference < beans::XPropertySet > xSet(pImpl->mxImageStorage,uno::UNO_QUERY);
+ if ( xSet.is() )
{
- bool bReadOnlyMode = true;
- uno::Reference < beans::XPropertySet > xSet(pImpl->mxImageStorage,uno::UNO_QUERY);
- if ( xSet.is() )
- {
- // get the open mode from the parent storage
- sal_Int32 nMode = 0;
- uno::Any aAny = xSet->getPropertyValue("OpenMode");
- if ( aAny >>= nMode )
- bReadOnlyMode = !(nMode & embed::ElementModes::WRITE );
- } // if ( xSet.is() )
- if ( !bReadOnlyMode )
- {
- uno::Reference< embed::XTransactedObject > xTransact( pImpl->mxImageStorage, uno::UNO_QUERY_THROW );
- xTransact->commit();
- }
- }
- catch (const uno::Exception&)
+ // get the open mode from the parent storage
+ sal_Int32 nMode = 0;
+ uno::Any aAny = xSet->getPropertyValue("OpenMode");
+ if ( aAny >>= nMode )
+ bReadOnlyMode = !(nMode & embed::ElementModes::WRITE );
+ } // if ( xSet.is() )
+ if ( !bReadOnlyMode )
{
- return false;
+ uno::Reference< embed::XTransactedObject > xTransact( pImpl->mxImageStorage, uno::UNO_QUERY_THROW );
+ xTransact->commit();
}
}
+ catch (const uno::Exception&)
+ {
+ return false;
+ }
return true;
}
@@ -969,26 +969,26 @@ bool EmbeddedObjectContainer::RemoveEmbeddedObject( const uno::Reference < embed
else
SAL_WARN( "comphelper.container", "Object not found for removal!" );
- if ( xPersist.is() && bKeepToTempStorage ) // #i119941#
- {
- // remove replacement image (if there is one)
- RemoveGraphicStream( aName );
+ if ( !xPersist || !bKeepToTempStorage ) // #i119941#
+ return true;
- // now it's time to remove the storage from the container storage
- try
- {
+ // remove replacement image (if there is one)
+ RemoveGraphicStream( aName );
+
+ // now it's time to remove the storage from the container storage
+ try
+ {
#if OSL_DEBUG_LEVEL > 1
- // if the object has a persistence and the object is not a link than it must have persistence entry in storage
- OSL_ENSURE( bIsNotEmbedded || pImpl->mxStorage->hasByName( aName ), "The object has no persistence entry in the storage!" );
+ // if the object has a persistence and the object is not a link than it must have persistence entry in storage
+ OSL_ENSURE( bIsNotEmbedded || pImpl->mxStorage->hasByName( aName ), "The object has no persistence entry in the storage!" );
#endif
- if ( xPersist.is() && pImpl->mxStorage->hasByName( aName ) )
- pImpl->mxStorage->removeElement( aName );
- }
- catch (const uno::Exception&)
- {
- SAL_WARN( "comphelper.container", "Failed to remove object from storage!" );
- return false;
- }
+ if ( xPersist.is() && pImpl->mxStorage->hasByName( aName ) )
+ pImpl->mxStorage->removeElement( aName );
+ }
+ catch (const uno::Exception&)
+ {
+ SAL_WARN( "comphelper.container", "Failed to remove object from storage!" );
+ return false;
}
return true;
diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index d03662381939..c091ee7ab06b 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -806,197 +806,191 @@ namespace
bool copy_content_straight(oslFileHandle& rTargetHandle)
{
- if (maFile && osl::File::E_None == maFile->open(osl_File_OpenFlag_Read))
- {
- sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
- sal_uInt64 nBytesTransfer(0);
- sal_uInt64 nSize(getPackFileSize());
+ if (!maFile || osl::File::E_None != maFile->open(osl_File_OpenFlag_Read))
+ return false;
- // set offset in source file - when this is zero, a new file is to be added
- if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
- {
- while (nSize != 0)
- {
- const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
+ sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
+ sal_uInt64 nBytesTransfer(0);
+ sal_uInt64 nSize(getPackFileSize());
- if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
- {
- break;
- }
+ // set offset in source file - when this is zero, a new file is to be added
+ if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
+ {
+ while (nSize != 0)
+ {
+ const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
- if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aArray), nToTransfer, &nBytesTransfer) || nBytesTransfer != nToTransfer)
- {
- break;
- }
+ if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
+ {
+ break;
+ }
- nSize -= nToTransfer;
+ if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aArray), nToTransfer, &nBytesTransfer) || nBytesTransfer != nToTransfer)
+ {
+ break;
}
- }
- maFile->close();
- return (0 == nSize);
+ nSize -= nToTransfer;
+ }
}
- return false;
+ maFile->close();
+ return (0 == nSize);
}
bool copy_content_compress(oslFileHandle& rTargetHandle)
{
- if (maFile && osl::File::E_None == maFile->open(osl_File_OpenFlag_Read))
- {
- sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
- sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
- sal_uInt64 nBytesTransfer(0);
- sal_uInt64 nSize(getPackFileSize());
- z_stream zstream;
- memset(&zstream, 0, sizeof(zstream));
+ if (!maFile || osl::File::E_None != maFile->open(osl_File_OpenFlag_Read))
+ return false;
- if (Z_OK == deflateInit(&zstream, Z_BEST_COMPRESSION))
+ sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
+ sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
+ sal_uInt64 nBytesTransfer(0);
+ sal_uInt64 nSize(getPackFileSize());
+ z_stream zstream;
+ memset(&zstream, 0, sizeof(zstream));
+
+ if (Z_OK == deflateInit(&zstream, Z_BEST_COMPRESSION))
+ {
+ // set offset in source file - when this is zero, a new file is to be added
+ if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
{
- // set offset in source file - when this is zero, a new file is to be added
- if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
+ bool bOkay(true);
+
+ while (bOkay && nSize != 0)
{
- bool bOkay(true);
+ const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
- while (bOkay && nSize != 0)
+ if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
{
- const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
-
- if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
- {
- break;
- }
+ break;
+ }
- zstream.avail_in = nToTransfer;
- zstream.next_in = reinterpret_cast<unsigned char*>(aArray);
+ zstream.avail_in = nToTransfer;
+ zstream.next_in = reinterpret_cast<unsigned char*>(aArray);
- do {
- zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
- zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer);
+ do {
+ zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
+ zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer);
#if !defined Z_PREFIX
- const sal_Int64 nRetval(deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
+ const sal_Int64 nRetval(deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
#else
- const sal_Int64 nRetval(z_deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
+ const sal_Int64 nRetval(z_deflate(&zstream, nSize == nToTransfer ? Z_FINISH : Z_NO_FLUSH));
#endif
- if (Z_STREAM_ERROR == nRetval)
+ if (Z_STREAM_ERROR == nRetval)
+ {
+ bOkay = false;
+ }
+ else
+ {
+ const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out);
+
+ if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable)
{
bOkay = false;
}
- else
- {
- const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out);
-
- if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable)
- {
- bOkay = false;
- }
- }
- } while (bOkay && 0 == zstream.avail_out);
-
- if (!bOkay)
- {
- break;
}
+ } while (bOkay && 0 == zstream.avail_out);
- nSize -= nToTransfer;
+ if (!bOkay)
+ {
+ break;
}
+ nSize -= nToTransfer;
+ }
+
#if !defined Z_PREFIX
- deflateEnd(&zstream);
+ deflateEnd(&zstream);
#else
- z_deflateEnd(&zstream);
+ z_deflateEnd(&zstream);
#endif
- }
}
+ }
- maFile->close();
+ maFile->close();
- // get compressed size and add to entry
- if (mnFullFileSize == mnPackFileSize && mnFullFileSize == zstream.total_in)
- {
- mnPackFileSize = zstream.total_out;
- }
-
- return (0 == nSize);
+ // get compressed size and add to entry
+ if (mnFullFileSize == mnPackFileSize && mnFullFileSize == zstream.total_in)
+ {
+ mnPackFileSize = zstream.total_out;
}
- return false;
+ return (0 == nSize);
}
bool copy_content_uncompress(oslFileHandle& rTargetHandle)
{
- if (maFile && osl::File::E_None == maFile->open(osl_File_OpenFlag_Read))
- {
- sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
- sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
- sal_uInt64 nBytesTransfer(0);
- sal_uInt64 nSize(getPackFileSize());
- z_stream zstream;
- memset(&zstream, 0, sizeof(zstream));
+ if (!maFile || osl::File::E_None != maFile->open(osl_File_OpenFlag_Read))
+ return false;
- if (Z_OK == inflateInit(&zstream))
+ sal_uInt8 aArray[BACKUP_FILE_HELPER_BLOCK_SIZE];
+ sal_uInt8 aBuffer[BACKUP_FILE_HELPER_BLOCK_SIZE];
+ sal_uInt64 nBytesTransfer(0);
+ sal_uInt64 nSize(getPackFileSize());
+ z_stream zstream;
+ memset(&zstream, 0, sizeof(zstream));
+
+ if (Z_OK == inflateInit(&zstream))
+ {
+ // set offset in source file - when this is zero, a new file is to be added
+ if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
{
- // set offset in source file - when this is zero, a new file is to be added
- if (osl::File::E_None == maFile->setPos(osl_Pos_Absolut, sal_Int64(getOffset())))
+ bool bOkay(true);
+
+ while (bOkay && nSize != 0)
{
- bool bOkay(true);
+ const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
- while (bOkay && nSize != 0)
+ if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
{
- const sal_uInt64 nToTransfer(std::min(nSize, sal_uInt64(BACKUP_FILE_HELPER_BLOCK_SIZE)));
-
- if (osl::File::E_None != maFile->read(static_cast<void*>(aArray), nToTransfer, nBytesTransfer) || nBytesTransfer != nToTransfer)
- {
- break;
- }
+ break;
+ }
- zstream.avail_in = nToTransfer;
- zstream.next_in = reinterpret_cast<unsigned char*>(aArray);
+ zstream.avail_in = nToTransfer;
+ zstream.next_in = reinterpret_cast<unsigned char*>(aArray);
- do {
- zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
- zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer);
+ do {
+ zstream.avail_out = BACKUP_FILE_HELPER_BLOCK_SIZE;
+ zstream.next_out = reinterpret_cast<unsigned char*>(aBuffer);
#if !defined Z_PREFIX
- const sal_Int64 nRetval(inflate(&zstream, Z_NO_FLUSH));
+ const sal_Int64 nRetval(inflate(&zstream, Z_NO_FLUSH));
#else
- const sal_Int64 nRetval(z_inflate(&zstream, Z_NO_FLUSH));
+ const sal_Int64 nRetval(z_inflate(&zstream, Z_NO_FLUSH));
#endif
- if (Z_STREAM_ERROR == nRetval)
+ if (Z_STREAM_ERROR == nRetval)
+ {
+ bOkay = false;
+ }
+ else
+ {
+ const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out);
+
+ if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable)
{
bOkay = false;
}
- else
- {
- const sal_uInt64 nAvailable(BACKUP_FILE_HELPER_BLOCK_SIZE - zstream.avail_out);
-
- if (osl_File_E_None != osl_writeFile(rTargetHandle, static_cast<const void*>(aBuffer), nAvailable, &nBytesTransfer) || nBytesTransfer != nAvailable)
- {
- bOkay = false;
- }
- }
- } while (bOkay && 0 == zstream.avail_out);
-
- if (!bOkay)
- {
- break;
}
+ } while (bOkay && 0 == zstream.avail_out);
- nSize -= nToTransfer;
+ if (!bOkay)
+ {
+ break;
}
+ nSize -= nToTransfer;
+ }
+
#if !defined Z_PREFIX
- deflateEnd(&zstream);
+ deflateEnd(&zstream);
#else
- z_deflateEnd(&zstream);
+ z_deflateEnd(&zstream);
#endif
- }
}
-
- maFile->close();
- return (0 == nSize);
}
- return false;
+ maFile->close();
+ return (0 == nSize);
}
@@ -1421,26 +1415,24 @@ namespace
bool tryPop(oslFileHandle& rHandle)
{
- if (!maPackedFileEntryVector.empty())
- {
- // already backups there, check if different from last entry
- PackedFileEntry& aLastEntry = maPackedFileEntryVector.back();
+ if (maPackedFileEntryVector.empty())
+ return false;
- // here the uncompress flag has to be determined, true
- // means to add the file compressed, false means to add it
- // uncompressed
- bool bRetval = aLastEntry.copy_content(rHandle, true);
+ // already backups there, check if different from last entry
+ PackedFileEntry& aLastEntry = maPackedFileEntryVector.back();
- if (bRetval)
- {
- maPackedFileEntryVector.pop_back();
- mbChanged = true;
- }
+ // here the uncompress flag has to be determined, true
+ // means to add the file compressed, false means to add it
+ // uncompressed
+ bool bRetval = aLastEntry.copy_content(rHandle, true);
- return bRetval;
+ if (bRetval)
+ {
+ maPackedFileEntryVector.pop_back();
+ mbChanged = true;
}
- return false;
+ return bRetval;
}
void tryReduceToNumBackups(sal_uInt16 nNumBackups)
@@ -2227,46 +2219,44 @@ namespace comphelper
{
const OUString aFileURL(createFileURL(rSourceURL, rName, rExt));
- if (DirectoryHelper::fileExists(aFileURL))
- {
- // try Pop for base file
- const OUString aPackURL(createPackURL(rTargetURL, rName));
- PackedFile aPackedFile(aPackURL);
+ if (!DirectoryHelper::fileExists(aFileURL))
+ return false;
- if (!aPackedFile.empty())
- {
- oslFileHandle aHandle;
- OUString aTempURL;
+ // try Pop for base file
+ const OUString aPackURL(createPackURL(rTargetURL, rName));
+ PackedFile aPackedFile(aPackURL);
- // open target temp file - it exists until deleted
- if (osl::File::E_None == osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL))
- {
- bool bRetval(aPackedFile.tryPop(aHandle));
+ if (aPackedFile.empty())
+ return false;
- // close temp file (in all cases) - it exists until deleted
- osl_closeFile(aHandle);
+ oslFileHandle aHandle;
+ OUString aTempURL;
- if (bRetval)
- {
- // copy over existing file by first deleting original
- // and moving the temp file to old original
- osl::File::remove(aFileURL);
- osl::File::move(aTempURL, aFileURL);
-
- // reduce to allowed number and flush
- aPackedFile.tryReduceToNumBackups(mnNumBackups);
- aPackedFile.flush();
- }
+ // open target temp file - it exists until deleted
+ if (osl::File::E_None != osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL))
+ return false;
- // delete temp file (in all cases - it may be moved already)
- osl::File::remove(aTempURL);
+ bool bRetval(aPackedFile.tryPop(aHandle));
- return bRetval;
- }
- }
+ // close temp file (in all cases) - it exists until deleted
+ osl_closeFile(aHandle);
+
+ if (bRetval)
+ {
+ // copy over existing file by first deleting original
+ // and moving the temp file to old original
+ osl::File::remove(aFileURL);
+ osl::File::move(aTempURL, aFileURL);
+
+ // reduce to allowed number and flush
+ aPackedFile.tryReduceToNumBackups(mnNumBackups);
+ aPackedFile.flush();
}
- return false;
+ // delete temp file (in all cases - it may be moved already)
+ osl::File::remove(aTempURL);
+
+ return bRetval;
}
/////////////////// ExtensionInfo helpers ///////////////////////
@@ -2319,103 +2309,101 @@ namespace comphelper
const OUString aPackURL(createPackURL(rTargetURL, u"ExtensionInfo"));
PackedFile aPackedFile(aPackURL);
- if (!aPackedFile.empty())
- {
- oslFileHandle aHandle;
- OUString aTempURL;
+ if (aPackedFile.empty())
+ return false;
- // open target temp file - it exists until deleted
- if (osl::File::E_None == osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL))
- {
- bool bRetval(aPackedFile.tryPop(aHandle));
+ oslFileHandle aHandle;
+ OUString aTempURL;
- // close temp file (in all cases) - it exists until deleted
- osl_closeFile(aHandle);
+ // open target temp file - it exists until deleted
+ if (osl::File::E_None != osl::FileBase::createTempFile(nullptr, &aHandle, &aTempURL))
+ return false;
- if (bRetval)
- {
- // last config is in temp file, load it to ExtensionInfo
- ExtensionInfo aLoadedExtensionInfo;
- FileSharedPtr aBaseFile = std::make_shared<osl::File>(aTempURL);
+ bool bRetval(aPackedFile.tryPop(aHandle));
- if (osl::File::E_None == aBaseFile->open(osl_File_OpenFlag_Read))
- {
- if (aLoadedExtensionInfo.read_entries(aBaseFile))
- {
- // get current extension info, but from XML config files
- ExtensionInfo aCurrentExtensionInfo;
+ // close temp file (in all cases) - it exists until deleted
+ osl_closeFile(aHandle);
- aCurrentExtensionInfo.createUserExtensionRegistryEntriesFromXML(maUserConfigWorkURL);
+ if (bRetval)
+ {
+ // last config is in temp file, load it to ExtensionInfo
+ ExtensionInfo aLoadedExtensionInfo;
+ FileSharedPtr aBaseFile = std::make_shared<osl::File>(aTempURL);
- // now we have loaded last_working (aLoadedExtensionInfo) and
- // current (aCurrentExtensionInfo) ExtensionInfo and may react on
- // differences by de/activating these as needed
- const ExtensionInfoEntryVector& aUserEntries = aCurrentExtensionInfo.getExtensionInfoEntryVector();
- const ExtensionInfoEntryVector& rLoadedVector = aLoadedExtensionInfo.getExtensionInfoEntryVector();
- ExtensionInfoEntryVector aToBeDisabled;
- ExtensionInfoEntryVector aToBeEnabled;
+ if (osl::File::E_None == aBaseFile->open(osl_File_OpenFlag_Read))
+ {
+ if (aLoadedExtensionInfo.read_entries(aBaseFile))
+ {
+ // get current extension info, but from XML config files
+ ExtensionInfo aCurrentExtensionInfo;
- for (const auto& rCurrentInfo : aUserEntries)
- {
- const ExtensionInfoEntry* pLoadedInfo = nullptr;
+ aCurrentExtensionInfo.createUserExtensionRegistryEntriesFromXML(maUserConfigWorkURL);
- for (const auto& rLoadedInfo : rLoadedVector)
- {
- if (rCurrentInfo.isSameExtension(rLoadedInfo))
- {
- pLoadedInfo = &rLoadedInfo;
- break;
- }
- }
+ // now we have loaded last_working (aLoadedExtensionInfo) and
+ // current (aCurrentExtensionInfo) ExtensionInfo and may react on
+ // differences by de/activating these as needed
+ const ExtensionInfoEntryVector& aUserEntries = aCurrentExtensionInfo.getExtensionInfoEntryVector();
+ const ExtensionInfoEntryVector& rLoadedVector = aLoadedExtensionInfo.getExtensionInfoEntryVector();
+ ExtensionInfoEntryVector aToBeDisabled;
+ ExtensionInfoEntryVector aToBeEnabled;
- if (nullptr != pLoadedInfo)
- {
- // loaded info contains information about the Extension rCurrentInfo
- const bool bCurrentEnabled(rCurrentInfo.isEnabled());
- const bool bLoadedEnabled(pLoadedInfo->isEnabled());
+ for (const auto& rCurrentInfo : aUserEntries)
+ {
+ const ExtensionInfoEntry* pLoadedInfo = nullptr;
- if (bCurrentEnabled && !bLoadedEnabled)
- {
- aToBeDisabled.push_back(rCurrentInfo);
- }
- else if (!bCurrentEnabled && bLoadedEnabled)
- {
- aToBeEnabled.push_back(rCurrentInfo);
- }
- }
- else
- {
- // There is no loaded info about the Extension rCurrentInfo.
- // It needs to be disabled
- if (rCurrentInfo.isEnabled())
- {
- aToBeDisabled.push_back(rCurrentInfo);
- }
- }
+ for (const auto& rLoadedInfo : rLoadedVector)
+ {
+ if (rCurrentInfo.isSameExtension(rLoadedInfo))
+ {
+ pLoadedInfo = &rLoadedInfo;
+ break;
}
+ }
- if (!aToBeDisabled.empty() || !aToBeEnabled.empty())
+ if (nullptr != pLoadedInfo)
+ {
+ // loaded info contains information about the Extension rCurrentInfo
+ const bool bCurrentEnabled(rCurrentInfo.isEnabled());
+ const bool bLoadedEnabled(pLoadedInfo->isEnabled());
+
+ if (bCurrentEnabled && !bLoadedEnabled)
{
- ExtensionInfo::changeEnableDisableStateInXML(maUserConfigWorkURL, aToBeEnabled, aToBeDisabled);
+ aToBeDisabled.push_back(rCurrentInfo);
+ }
+ else if (!bCurrentEnabled && bLoadedEnabled)
+ {
+ aToBeEnabled.push_back(rCurrentInfo);
+ }
+ }
+ else
+ {
+ // There is no loaded info about the Extension rCurrentInfo.
+ // It needs to be disabled
+ if (rCurrentInfo.isEnabled())
+ {
+ aToBeDisabled.push_back(rCurrentInfo);
}
-
- bRetval = true;
}
}
- // reduce to allowed number and flush
- aPackedFile.tryReduceToNumBackups(mnNumBackups);
- aPackedFile.flush();
- }
-
- // delete temp file (in all cases - it may be moved already)
- osl::File::remove(aTempURL);
+ if (!aToBeDisabled.empty() || !aToBeEnabled.empty())
+ {
+ ExtensionInfo::changeEnableDisableStateInXML(maUserConfigWorkURL, aToBeEnabled, aToBeDisabled);
+ }
- return bRetval;
+ bRetval = true;
+ }
}
+
+ // reduce to allowed number and flush
+ aPackedFile.tryReduceToNumBackups(mnNumBackups);
+ aPackedFile.flush();
}
- return false;
+ // delete temp file (in all cases - it may be moved already)
+ osl::File::remove(aTempURL);
+
+ return bRetval;
}
/////////////////// FileDirInfo helpers ///////////////////////
diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx
index c56e6979a3a0..574f8e0a1898 100644
--- a/comphelper/source/misc/namedvaluecollection.cxx
+++ b/comphelper/source/misc/namedvaluecollection.cxx
@@ -179,28 +179,26 @@ namespace comphelper
bool NamedValueCollection::get_ensureType( const OUString& _rValueName, void* _pValueLocation, const Type& _rExpectedValueType ) const
{
auto pos = maValues.find( _rValueName );
- if ( pos != maValues.end() )
- {
- if ( uno_type_assignData(
- _pValueLocation, _rExpectedValueType.getTypeLibType(),
- const_cast< void* >( pos->second.getValue() ), pos->second.getValueType().getTypeLibType(),
- reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
- reinterpret_cast< uno_AcquireFunc >( cpp_acquire ),
- reinterpret_cast< uno_ReleaseFunc >( cpp_release )
- ) )
- // argument exists, and could be extracted
- return true;
-
- // argument exists, but is of wrong type
- throw IllegalArgumentException(
- "Invalid value type for '" + _rValueName
- + "'.\nExpected: " + _rExpectedValueType.getTypeName()
- + "\nFound: " + pos->second.getValueType().getTypeName(),
- nullptr, 0 );
- }
+ if ( pos == maValues.end() )
+ // argument does not exist
+ return false;
- // argument does not exist
- return false;
+ if ( uno_type_assignData(
+ _pValueLocation, _rExpectedValueType.getTypeLibType(),
+ const_cast< void* >( pos->second.getValue() ), pos->second.getValueType().getTypeLibType(),
+ reinterpret_cast< uno_QueryInterfaceFunc >( cpp_queryInterface ),
+ reinterpret_cast< uno_AcquireFunc >( cpp_acquire ),
+ reinterpret_cast< uno_ReleaseFunc >( cpp_release )
+ ) )
+ // argument exists, and could be extracted
+ return true;
+
+ // argument exists, but is of wrong type
+ throw IllegalArgumentException(
+ "Invalid value type for '" + _rValueName
+ + "'.\nExpected: " + _rExpectedValueType.getTypeName()
+ + "\nFound: " + pos->second.getValueType().getTypeName(),
+ nullptr, 0 );
}
const Any& NamedValueCollection::impl_get( const OUString& _rValueName ) const
diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
index 385f61680e1c..de6b284c5f68 100644
--- a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
+++ b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
@@ -44,30 +44,30 @@ static bool makeCanonicalFileURL( OUString & rURL )
if ( osl::FileBase::getAbsoluteFileURL( OUString(),
rURL,
aNormalizedURL )
+ != osl::DirectoryItem::E_None )
+ return false;
+
+ osl::DirectoryItem aDirItem;
+ if ( osl::DirectoryItem::get( aNormalizedURL, aDirItem )
+ != osl::DirectoryItem::E_None )
+ return false;
+
+ osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL );
+
+ if ( aDirItem.getFileStatus( aFileStatus )
== osl::DirectoryItem::E_None )
{
- osl::DirectoryItem aDirItem;
- if ( osl::DirectoryItem::get( aNormalizedURL, aDirItem )
- == osl::DirectoryItem::E_None )
+ aNormalizedURL = aFileStatus.getFileURL();
+
+ if ( !aNormalizedURL.isEmpty() )
{
- osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileURL );
+ if ( !aNormalizedURL.endsWith("/") )
+ rURL = aNormalizedURL;
+ else
+ rURL = aNormalizedURL
+ .copy( 0, aNormalizedURL.getLength() - 1 );
- if ( aDirItem.getFileStatus( aFileStatus )
- == osl::DirectoryItem::E_None )
- {
- aNormalizedURL = aFileStatus.getFileURL();
-
- if ( !aNormalizedURL.isEmpty() )
- {
- if ( !aNormalizedURL.endsWith("/") )
- rURL = aNormalizedURL;
- else
- rURL = aNormalizedURL
- .copy( 0, aNormalizedURL.getLength() - 1 );
-
- return true;
- }
- }
+ return true;
}
}
return false;
diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx
index a70c3231b702..82778e6c823b 100644
--- a/configmgr/source/valueparser.cxx
+++ b/configmgr/source/valueparser.cxx
@@ -252,22 +252,23 @@ ValueParser::ValueParser(int layer): type_(TYPE_ERROR), layer_(layer), state_()
ValueParser::~ValueParser() {}
xmlreader::XmlReader::Text ValueParser::getTextMode() const {
- if (node_.is()) {
- switch (state_) {
- case State::Text:
- if (!items_.empty()) {
- break;
- }
- [[fallthrough]];
- case State::IT:
- return
- (type_ == TYPE_STRING || type_ == TYPE_STRING_LIST ||
- !separator_.isEmpty())
- ? xmlreader::XmlReader::Text::Raw
- : xmlreader::XmlReader::Text::Normalized;
- default:
+ if (!node_)
+ return xmlreader::XmlReader::Text::NONE;
+
+ switch (state_) {
+ case State::Text:
+ if (!items_.empty()) {
break;
}
+ [[fallthrough]];
+ case State::IT:
+ return
+ (type_ == TYPE_STRING || type_ == TYPE_STRING_LIST ||
+ !separator_.isEmpty())
+ ? xmlreader::XmlReader::Text::Raw
+ : xmlreader::XmlReader::Text::Normalized;
+ default:
+ break;
}
return xmlreader::XmlReader::Text::NONE;
}
diff --git a/connectivity/source/drivers/calc/CDatabaseMetaData.cxx b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx
index 31798f5bafd0..159349cacd6f 100644
--- a/connectivity/source/drivers/calc/CDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx
@@ -59,37 +59,37 @@ static bool lcl_IsEmptyOrHidden( const Reference<XSpreadsheets>& xSheets, const
{
Any aAny = xSheets->getByName( rName );
Reference<XSpreadsheet> xSheet;
- if ( aAny >>= xSheet )
+ if ( !(aAny >>= xSheet) )
+ return false;
+
+ // test if sheet is hidden
+
+ Reference<XPropertySet> xProp( xSheet, UNO_QUERY );
+ if (xProp.is())
{
- // test if sheet is hidden
+ bool bVisible;
+ Any aVisAny = xProp->getPropertyValue("IsVisible");
+ if ( (aVisAny >>= bVisible) && !bVisible)
+ return true; // hidden
+ }
- Reference<XPropertySet> xProp( xSheet, UNO_QUERY );
- if (xProp.is())
- {
- bool bVisible;
- Any aVisAny = xProp->getPropertyValue("IsVisible");
- if ( (aVisAny >>= bVisible) && !bVisible)
- return true; // hidden
- }
+ // use the same data area as in OCalcTable to test for empty table
- // use the same data area as in OCalcTable to test for empty table
+ Reference<XSheetCellCursor> xCursor = xSheet->createCursor();
+ Reference<XCellRangeAddressable> xRange( xCursor, UNO_QUERY );
+ if ( xRange.is() )
+ {
+ xCursor->collapseToSize( 1, 1 ); // single (first) cell
+ xCursor->collapseToCurrentRegion(); // contiguous data area
- Reference<XSheetCellCursor> xCursor = xSheet->createCursor();
- Reference<XCellRangeAddressable> xRange( xCursor, UNO_QUERY );
- if ( xRange.is() )
+ CellRangeAddress aRangeAddr = xRange->getRangeAddress();
+ if ( aRangeAddr.StartColumn == aRangeAddr.EndColumn &&
+ aRangeAddr.StartRow == aRangeAddr.EndRow )
{
- xCursor->collapseToSize( 1, 1 ); // single (first) cell
- xCursor->collapseToCurrentRegion(); // contiguous data area
-
- CellRangeAddress aRangeAddr = xRange->getRangeAddress();
- if ( aRangeAddr.StartColumn == aRangeAddr.EndColumn &&
- aRangeAddr.StartRow == aRangeAddr.EndRow )
- {
- // single cell -> check content
- Reference<XCell> xCell = xCursor->getCellByPosition( 0, 0 );
- if ( xCell.is() && xCell->getType() == CellContentType_EMPTY )
- return true;
- }
+ // single cell -> check content
+ Reference<XCell> xCell = xCursor->getCellByPosition( 0, 0 );
+ if ( xCell.is() && xCell->getType() == CellContentType_EMPTY )
+ return true;
}
}
diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx
index 8e37cdd99071..90e7c4e08bed 100644
--- a/connectivity/source/drivers/calc/CTable.cxx
+++ b/connectivity/source/drivers/calc/CTable.cxx
@@ -191,24 +191,23 @@ static bool lcl_HasTextInColumn( const Reference<XSpreadsheet>& xSheet, sal_Int3
// look for any text cell or text result in the column
Reference<XCellRangeAddressable> xAddr( xSheet, UNO_QUERY );
- if (xAddr.is())
- {
- CellRangeAddress aTotalRange = xAddr->getRangeAddress();
- sal_Int32 nLastRow = aTotalRange.EndRow;
- Reference<XCellRangesQuery> xQuery( xSheet->getCellRangeByPosition( nDocColumn, nDocRow, nDocColumn, nLastRow ), UNO_QUERY );
- if (xQuery.is())
- {
- // are there text cells in the column?
- Reference<XSheetCellRanges> xTextContent = xQuery->queryContentCells( CellFlags::STRING );
- if ( xTextContent.is() && xTextContent->hasElements() )
- return true;
-
- // are there formulas with text results in the column?
- Reference<XSheetCellRanges> xTextFormula = xQuery->queryFormulaCells( FormulaResult::STRING );
- if ( xTextFormula.is() && xTextFormula->hasElements() )
- return true;
- }
- }
+ if (!xAddr)
+ return false;
+ CellRangeAddress aTotalRange = xAddr->getRangeAddress();
+ sal_Int32 nLastRow = aTotalRange.EndRow;
+ Reference<XCellRangesQuery> xQuery( xSheet->getCellRangeByPosition( nDocColumn, nDocRow, nDocColumn, nLastRow ), UNO_QUERY );
+ if (!xQuery)
+ return false;
+
+ // are there text cells in the column?
+ Reference<XSheetCellRanges> xTextContent = xQuery->queryContentCells( CellFlags::STRING );
+ if ( xTextContent.is() && xTextContent->hasElements() )
+ return true;
+
+ // are there formulas with text results in the column?
+ Reference<XSheetCellRanges> xTextFormula = xQuery->queryFormulaCells( FormulaResult::STRING );
+ if ( xTextFormula.is() && xTextFormula->hasElements() )
+ return true;
return false;
}
diff --git a/connectivity/source/drivers/firebird/ResultSetMetaData.cxx b/connectivity/source/drivers/firebird/ResultSetMetaData.cxx
index 2ed46bae9b34..78d684a725a2 100644
--- a/connectivity/source/drivers/firebird/ResultSetMetaData.cxx
+++ b/connectivity/source/drivers/firebird/ResultSetMetaData.cxx
@@ -184,34 +184,34 @@ sal_Bool SAL_CALL OResultSetMetaData::isCurrency(sal_Int32)
sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement(sal_Int32 column)
{
OUString sTable = getTableName(column);
- if( !sTable.isEmpty() )
- {
- OUString sColumnName = getColumnName( column );
+ if( sTable.isEmpty() )
+ return false;
- OUString sSql = "SELECT RDB$IDENTITY_TYPE FROM RDB$RELATION_FIELDS "
- "WHERE RDB$RELATION_NAME = '"
- + escapeWith(sTable, '\'', '\'') + "' AND "
- "RDB$FIELD_NAME = '"+ escapeWith(sColumnName, '\'', '\'') +"'";
+ OUString sColumnName = getColumnName( column );
- Reference<XStatement> xStmt =m_pConnection ->createStatement();
+ OUString sSql = "SELECT RDB$IDENTITY_TYPE FROM RDB$RELATION_FIELDS "
+ "WHERE RDB$RELATION_NAME = '"
+ + escapeWith(sTable, '\'', '\'') + "' AND "
+ "RDB$FIELD_NAME = '"+ escapeWith(sColumnName, '\'', '\'') +"'";
- Reference<XResultSet> xRes =
- xStmt->executeQuery(sSql);
- Reference<XRow> xRow ( xRes, UNO_QUERY);
- if(xRes->next())
- {
- int iType = xRow->getShort(1);
- if(iType == 1) // IDENTITY
- return true;
- }
- else
- {
- SAL_WARN("connectivity.firebird","Column '"
- << sColumnName
- << "' not found in database");
+ Reference<XStatement> xStmt =m_pConnection ->createStatement();
- return false;
- }
+ Reference<XResultSet> xRes =
+ xStmt->executeQuery(sSql);
+ Reference<XRow> xRow ( xRes, UNO_QUERY);
+ if(xRes->next())
+ {
+ int iType = xRow->getShort(1);
+ if(iType == 1) // IDENTITY
+ return true;
+ }
+ else
+ {
+ SAL_WARN("connectivity.firebird","Column '"
+ << sColumnName
+ << "' not found in database");
+
+ return false;
}
return false;
}
@@ -226,34 +226,34 @@ sal_Bool SAL_CALL OResultSetMetaData::isSigned(sal_Int32)
sal_Int32 SAL_CALL OResultSetMetaData::getPrecision(sal_Int32 column)
{
sal_Int32 nType = getColumnType(column);
- if( nType == DataType::NUMERIC || nType == DataType::DECIMAL )
+ if( nType != DataType::NUMERIC && nType != DataType::DECIMAL )
+ return 0;
+
+ OUString sColumnName = getColumnName( column );
+
+ // RDB$FIELD_SOURCE is a unique name of column per database
+ OUString sSql = "SELECT RDB$FIELD_PRECISION FROM RDB$FIELDS "
+ " INNER JOIN RDB$RELATION_FIELDS "
+ " ON RDB$RELATION_FIELDS.RDB$FIELD_SOURCE = RDB$FIELDS.RDB$FIELD_NAME "
+ "WHERE RDB$RELATION_FIELDS.RDB$RELATION_NAME = '"
+ + escapeWith(getTableName(column), '\'', '\'') + "' AND "
+ "RDB$RELATION_FIELDS.RDB$FIELD_NAME = '"
+ + escapeWith(sColumnName, '\'', '\'') +"'";
+ Reference<XStatement> xStmt= m_pConnection->createStatement();
+
+ Reference<XResultSet> xRes =
+ xStmt->executeQuery(sSql);
+ Reference<XRow> xRow ( xRes, UNO_QUERY);
+ if(xRes->next())
{
- OUString sColumnName = getColumnName( column );
-
- // RDB$FIELD_SOURCE is a unique name of column per database
- OUString sSql = "SELECT RDB$FIELD_PRECISION FROM RDB$FIELDS "
- " INNER JOIN RDB$RELATION_FIELDS "
- " ON RDB$RELATION_FIELDS.RDB$FIELD_SOURCE = RDB$FIELDS.RDB$FIELD_NAME "
- "WHERE RDB$RELATION_FIELDS.RDB$RELATION_NAME = '"
- + escapeWith(getTableName(column), '\'', '\'') + "' AND "
- "RDB$RELATION_FIELDS.RDB$FIELD_NAME = '"
- + escapeWith(sColumnName, '\'', '\'') +"'";
- Reference<XStatement> xStmt= m_pConnection->createStatement();
-
- Reference<XResultSet> xRes =
- xStmt->executeQuery(sSql);
- Reference<XRow> xRow ( xRes, UNO_QUERY);
- if(xRes->next())
- {
- return static_cast<sal_Int32>(xRow->getShort(1));
- }
- else
- {
- SAL_WARN("connectivity.firebird","Column '"
- << sColumnName
- << "' not found in database");
- return 0;
- }
+ return static_cast<sal_Int32>(xRow->getShort(1));
+ }
+ else
+ {
+ SAL_WARN("connectivity.firebird","Column '"
+ << sColumnName
+ << "' not found in database");
+ return 0;
}
return 0;
}
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.cxx b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
index 61f57f330516..01ed3f8fc854 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.cxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
@@ -421,24 +421,24 @@ sal_Int32 OStatementCommonBase::getStatementChangeCount()
}
char* pResults = aResultsBuffer;
- if (static_cast<short>(*pResults++) == isc_info_sql_records)
- {
-// const short aTotalLength = (short) isc_vax_integer(pResults, 2);
- pResults += 2;
+ if (static_cast<short>(*pResults++) != isc_info_sql_records)
+ return 0;
- // Seems to be of form TOKEN (1 byte), LENGTH (2 bytes), DATA (LENGTH bytes)
- while (*pResults != isc_info_rsb_end)
- {
- const char aToken = *pResults;
- const short aLength = static_cast<short>(isc_vax_integer(pResults+1, 2));
+// const short aTotalLength = (short) isc_vax_integer(pResults, 2);
+ pResults += 2;
- if (aToken == aDesiredInfoType)
- {
- return isc_vax_integer(pResults + 3, aLength);
- }
+ // Seems to be of form TOKEN (1 byte), LENGTH (2 bytes), DATA (LENGTH bytes)
+ while (*pResults != isc_info_rsb_end)
+ {
+ const char aToken = *pResults;
+ const short aLength = static_cast<short>(isc_vax_integer(pResults+1, 2));
- pResults += (3 + aLength);
+ if (aToken == aDesiredInfoType)
+ {
+ return isc_vax_integer(pResults + 3, aLength);
}
+
+ pResults += (3 + aLength);
}
return 0;
diff --git a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx
index 09ab485d9fd7..f4f67a8e394a 100644
--- a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx
+++ b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx
@@ -148,28 +148,28 @@ jint read_from_storage_stream( JNIEnv * env, jstring name, jstring key )
std::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
Reference< XInputStream> xIn = pHelper ? pHelper->getInputStream() : Reference< XInputStream>();
OSL_ENSURE(xIn.is(),"Input stream is NULL!");
- if ( xIn.is() )
+ if ( !xIn.is() )
+ return -1;
+
+ Sequence< ::sal_Int8 > aData(1);
+ sal_Int32 nBytesRead = -1;
+ try
{
- Sequence< ::sal_Int8 > aData(1);
- sal_Int32 nBytesRead = -1;
- try
- {
- nBytesRead = xIn->readBytes(aData,1);
- }
- catch(const Exception& e)
- {
- StorageContainer::throwJavaException(e,env);
- return -1;
+ nBytesRead = xIn->readBytes(aData,1);
+ }
+ catch(const Exception& e)
+ {
+ StorageContainer::throwJavaException(e,env);
+ return -1;
- }
- if (nBytesRead <= 0)
- {
- return -1;
- }
- else
- {
- return static_cast<unsigned char>(aData[0]);
- }
+ }
+ if (nBytesRead <= 0)
+ {
+ return -1;
+ }
+ else
+ {
+ return static_cast<unsigned char>(aData[0]);
}
return -1;
}
diff --git a/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx
index 65457ab1d129..46866df04b33 100644
--- a/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx
+++ b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx
@@ -44,42 +44,42 @@ extern "C" SAL_JNI_EXPORT jboolean JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_S
{
TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
auto storage = aStoragePair.mapStorage();
- if ( storage.is() )
+ if ( !storage )
+ return JNI_FALSE;
+
+ try
{
+ OUString sName = StorageContainer::jstring2ustring(env,name);
try
{
- OUString sName = StorageContainer::jstring2ustring(env,name);
- try
+ OUString sOldName = StorageContainer::removeOldURLPrefix(sName);
+ if ( storage->isStreamElement(sOldName) )
{
- OUString sOldName = StorageContainer::removeOldURLPrefix(sName);
- if ( storage->isStreamElement(sOldName) )
+ try
+ {
+ storage->renameElement(sOldName,StorageContainer::removeURLPrefix(sName,aStoragePair.url));
+ }
+ catch(const Exception&)
{
- try
- {
- storage->renameElement(sOldName,StorageContainer::removeURLPrefix(sName,aStoragePair.url));
- }
- catch(const Exception&)
- {
- }
}
}
- catch(const NoSuchElementException&)
- {
- }
- catch(const IllegalArgumentException&)
- {
- }
- return storage->isStreamElement(StorageContainer::removeURLPrefix(sName,aStoragePair.url));
}
catch(const NoSuchElementException&)
{
}
- catch(const Exception&)
+ catch(const IllegalArgumentException&)
{
- TOOLS_WARN_EXCEPTION("connectivity.hsqldb", "forwarding");
- if (env->ExceptionCheck())
- env->ExceptionClear();
}
+ return storage->isStreamElement(StorageContainer::removeURLPrefix(sName,aStoragePair.url));
+ }
+ catch(const NoSuchElementException&)
+ {
+ }
+ catch(const Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("connectivity.hsqldb", "forwarding");
+ if (env->ExceptionCheck())
+ env->ExceptionClear();
}
return JNI_FALSE;
}
diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx
index bef3c8d74eaa..b30007667ec3 100644
--- a/connectivity/source/manager/mdrivermanager.cxx
+++ b/connectivity/source/manager/mdrivermanager.cxx
@@ -113,23 +113,23 @@ Any SAL_CALL ODriverEnumeration::nextElement( )
const DriverAccess& operator()( const DriverAccess& _rDescriptor ) const
{
// we did not load this driver, yet
- if (!_rDescriptor.xDriver.is())
+ if (_rDescriptor.xDriver.is())
+ return _rDescriptor;
+
+ // we have a factory for it
+ if (_rDescriptor.xComponentFactory.is())
{
- // we have a factory for it
- if (_rDescriptor.xComponentFactory.is())
+ DriverAccess& rDesc = const_cast<DriverAccess&>(_rDescriptor);
+ try
{
- DriverAccess& rDesc = const_cast<DriverAccess&>(_rDescriptor);
- try
- {
- //load driver
- rDesc.xDriver.set(
- rDesc.xComponentFactory->createInstanceWithContext(mxContext), css::uno::UNO_QUERY);
- }
- catch (const Exception&)
- {
- //failure, abandon driver
- rDesc.xComponentFactory.clear();
- }
+ //load driver
+ rDesc.xDriver.set(
+ rDesc.xComponentFactory->createInstanceWithContext(mxContext), css::uno::UNO_QUERY);
+ }
+ catch (const Exception&)
+ {
+ //failure, abandon driver
+ rDesc.xComponentFactory.clear();
}
}
return _rDescriptor;
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index 02056253c300..424f016db9ca 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -147,41 +147,41 @@ namespace
{
}
- if(pSubTree->count())
+ if(!pSubTree->count())
+ return false;
+
+ const OSQLParseNode* pCol = pSubTree->getChild(pSubTree->count()-1);
+ if (SQL_ISRULE(pCol,column_val))
{
- const OSQLParseNode* pCol = pSubTree->getChild(pSubTree->count()-1);
- if (SQL_ISRULE(pCol,column_val))
- {
- assert(pCol->count() == 1);
- pCol = pCol->getChild(0);
- }
- const OSQLParseNode* pTable(nullptr);
- switch (pSubTree->count())
- {
- case 1:
- break;
- case 3:
- pTable = pSubTree->getChild(0);
- break;
- case 5:
- case 7:
- SAL_WARN("connectivity.parse", "SQL: catalog and/or schema in column_ref in predicate");
- break;
- default:
- SAL_WARN("connectivity.parse", "columnMatchP: SQL grammar changed; column_ref has " << pSubTree->count() << " children");
- assert(false);
- break;
- }
- // TODO: not all DBMS match column names case-insensitively...
- // see XDatabaseMetaData::supportsMixedCaseIdentifiers()
- // and XDatabaseMetaData::supportsMixedCaseQuotedIdentifiers()
- if ( // table name matches (or no table name)?
- ( !pTable || pTable->getTokenValue().equalsIgnoreAsciiCase(rParam.sPredicateTableAlias) )
- && // column name matches?
- pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName)
- )
- return true;
+ assert(pCol->count() == 1);
+ pCol = pCol->getChild(0);
+ }
+ const OSQLParseNode* pTable(nullptr);
+ switch (pSubTree->count())
+ {
+ case 1:
+ break;
+ case 3:
+ pTable = pSubTree->getChild(0);
+ break;
+ case 5:
+ case 7:
+ SAL_WARN("connectivity.parse", "SQL: catalog and/or schema in column_ref in predicate");
+ break;
+ default:
+ SAL_WARN("connectivity.parse", "columnMatchP: SQL grammar changed; column_ref has " << pSubTree->count() << " children");
+ assert(false);
+ break;
}
+ // TODO: not all DBMS match column names case-insensitively...
+ // see XDatabaseMetaData::supportsMixedCaseIdentifiers()
+ // and XDatabaseMetaData::supportsMixedCaseQuotedIdentifiers()
+ if ( // table name matches (or no table name)?
+ ( !pTable || pTable->getTokenValue().equalsIgnoreAsciiCase(rParam.sPredicateTableAlias) )
+ && // column name matches?
+ pCol->getTokenValue().equalsIgnoreAsciiCase(aFieldName)
+ )
+ return true;
return false;
}
}
@@ -1703,54 +1703,53 @@ void OSQLParseNode::append(OSQLParseNode* pNewNode)
bool OSQLParseNode::addDateValue(OUStringBuffer& rString, const SQLParseNodeParameter& rParam) const
{
// special display for date/time values
- if (SQL_ISRULE(this,set_fct_spec) && SQL_ISPUNCTUATION(m_aChildren[0],"{"))
- {
- const OSQLParseNode* pODBCNode = m_aChildren[1].get();
- const OSQLParseNode* pODBCNodeChild = pODBCNode->m_aChildren[0].get();
+ if (!SQL_ISRULE(this,set_fct_spec) || !SQL_ISPUNCTUATION(m_aChildren[0],"{"))
+ return false;
- if (pODBCNodeChild->getNodeType() == SQLNodeType::Keyword && (
- SQL_ISTOKEN(pODBCNodeChild, D) ||
- SQL_ISTOKEN(pODBCNodeChild, T) ||
- SQL_ISTOKEN(pODBCNodeChild, TS) ))
- {
- OUString suQuote("'");
- if (rParam.bPredicate)
- {
- if (rParam.aMetaData.shouldEscapeDateTime())
- {
- suQuote = "#";
- }
- }
- else
- {
- if (rParam.aMetaData.shouldEscapeDateTime())
- {
- // suQuote = "'";
- return false;
- }
- }
+ const OSQLParseNode* pODBCNode = m_aChildren[1].get();
+ const OSQLParseNode* pODBCNodeChild = pODBCNode->m_aChildren[0].get();
- if (!rString.isEmpty())
- rString.append(" ");
- rString.append(suQuote);
- const OUString sTokenValue = pODBCNode->m_aChildren[1]->getTokenValue();
- if (SQL_ISTOKEN(pODBCNodeChild, D))
- {
- rString.append(rParam.bPredicate ? convertDateString(rParam, sTokenValue) : sTokenValue);
- }
- else if (SQL_ISTOKEN(pODBCNodeChild, T))
- {
- rString.append(rParam.bPredicate ? convertTimeString(rParam, sTokenValue) : sTokenValue);
- }
- else
- {
- rString.append(rParam.bPredicate ? convertDateTimeString(rParam, sTokenValue) : sTokenValue);
- }
- rString.append(suQuote);
- return true;
- }
+ if (pODBCNodeChild->getNodeType() != SQLNodeType::Keyword || !(
+ SQL_ISTOKEN(pODBCNodeChild, D) ||
+ SQL_ISTOKEN(pODBCNodeChild, T) ||
+ SQL_ISTOKEN(pODBCNodeChild, TS) ))
+ return false;
+
+ OUString suQuote("'");
+ if (rParam.bPredicate)
+ {
+ if (rParam.aMetaData.shouldEscapeDateTime())
+ {
+ suQuote = "#";
+ }
}
- return false;
+ else
+ {
+ if (rParam.aMetaData.shouldEscapeDateTime())
+ {
+ // suQuote = "'";
+ return false;
+ }
+ }
+
+ if (!rString.isEmpty())
+ rString.append(" ");
+ rString.append(suQuote);
+ const OUString sTokenValue = pODBCNode->m_aChildren[1]->getTokenValue();
+ if (SQL_ISTOKEN(pODBCNodeChild, D))
+ {
+ rString.append(rParam.bPredicate ? convertDateString(rParam, sTokenValue) : sTokenValue);
+ }
+ else if (SQL_ISTOKEN(pODBCNodeChild, T))
+ {
+ rString.append(rParam.bPredicate ? convertTimeString(rParam, sTokenValue) : sTokenValue);
+ }
+ else
+ {
+ rString.append(rParam.bPredicate ? convertDateTimeString(rParam, sTokenValue) : sTokenValue);
+ }
+ rString.append(suQuote);
+ return true;
}
void OSQLParseNode::replaceNodeValue(const OUString& rTableAlias, const OUString& rColumnName)
diff --git a/cppu/source/threadpool/current.cxx b/cppu/source/threadpool/current.cxx
index d085cb4a5092..64e6bfb8f64c 100644
--- a/cppu/source/threadpool/current.cxx
+++ b/cppu/source/threadpool/current.cxx
@@ -133,31 +133,31 @@ extern "C" sal_Bool SAL_CALL uno_setCurrentContext(
id.pCurrentContext = nullptr;
}
- if (pCurrentContext)
+ if (!pCurrentContext)
+ return true;
+
+ uno_Environment * pEnv = nullptr;
+ ::uno_getEnvironment( &pEnv, pEnvTypeName, pEnvContext );
+ OSL_ASSERT( pEnv && pEnv->pExtEnv );
+ if (pEnv)
{
- uno_Environment * pEnv = nullptr;
- ::uno_getEnvironment( &pEnv, pEnvTypeName, pEnvContext );
- OSL_ASSERT( pEnv && pEnv->pExtEnv );
- if (pEnv)
+ if (pEnv->pExtEnv)
{
- if (pEnv->pExtEnv)
- {
- id.pCurrentContextEnv = pEnv->pExtEnv;
- (*id.pCurrentContextEnv->acquireInterface)(
- id.pCurrentContextEnv, pCurrentContext );
- id.pCurrentContext = pCurrentContext;
- }
- else
- {
- (*pEnv->release)( pEnv );
- return false;
- }
+ id.pCurrentContextEnv = pEnv->pExtEnv;
+ (*id.pCurrentContextEnv->acquireInterface)(
+ id.pCurrentContextEnv, pCurrentContext );
+ id.pCurrentContext = pCurrentContext;
}
else
{
+ (*pEnv->release)( pEnv );
return false;
}
}
+ else
+ {
+ return false;
+ }
return true;
}
diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
index 8ae7ca64865e..36b815492e3b 100644
--- a/cppu/source/typelib/typelib.cxx
+++ b/cppu/source/typelib/typelib.cxx
@@ -392,84 +392,84 @@ void freeTypeDescription(typelib_TypeDescription const * desc) {
// description. The parameter initTables controls whether or not to call
// typelib_typedescription_initTables in those situations.
bool complete(typelib_TypeDescription ** ppTypeDescr, bool initTables) {
- if (! (*ppTypeDescr)->bComplete)
+ if ((*ppTypeDescr)->bComplete)
+ return true;
+
+ OSL_ASSERT( (typelib_TypeClass_STRUCT == (*ppTypeDescr)->eTypeClass ||
+ typelib_TypeClass_EXCEPTION == (*ppTypeDescr)->eTypeClass ||
+ typelib_TypeClass_ENUM == (*ppTypeDescr)->eTypeClass ||
+ typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass) &&
+ !TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( (*ppTypeDescr)->eTypeClass ) );
+
+ if (typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass &&
+ reinterpret_cast<typelib_InterfaceTypeDescription *>(*ppTypeDescr)->ppAllMembers)
{
- OSL_ASSERT( (typelib_TypeClass_STRUCT == (*ppTypeDescr)->eTypeClass ||
- typelib_TypeClass_EXCEPTION == (*ppTypeDescr)->eTypeClass ||
- typelib_TypeClass_ENUM == (*ppTypeDescr)->eTypeClass ||
- typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass) &&
- !TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( (*ppTypeDescr)->eTypeClass ) );
-
- if (typelib_TypeClass_INTERFACE == (*ppTypeDescr)->eTypeClass &&
- reinterpret_cast<typelib_InterfaceTypeDescription *>(*ppTypeDescr)->ppAllMembers)
- {
- if (initTables) {
- typelib_typedescription_initTables( *ppTypeDescr );
- }
- return true;
+ if (initTables) {
+ typelib_typedescription_initTables( *ppTypeDescr );
}
+ return true;
+ }
- typelib_TypeDescription * pTD = nullptr;
- // on demand access of complete td
- TypeDescriptor_Init_Impl &rInit = Init();
- rInit.callChain( &pTD, (*ppTypeDescr)->pTypeName );
- if (pTD)
+ typelib_TypeDescription * pTD = nullptr;
+ // on demand access of complete td
+ TypeDescriptor_Init_Impl &rInit = Init();
+ rInit.callChain( &pTD, (*ppTypeDescr)->pTypeName );
+ if (pTD)
+ {
+ if (typelib_TypeClass_TYPEDEF == pTD->eTypeClass)
{
- if (typelib_TypeClass_TYPEDEF == pTD->eTypeClass)
- {
- typelib_typedescriptionreference_getDescription(
- &pTD, reinterpret_cast<typelib_IndirectTypeDescription *>(pTD)->pType );
- OSL_ASSERT( pTD );
- if (! pTD)
- return false;
- }
-
- OSL_ASSERT( typelib_TypeClass_TYPEDEF != pTD->eTypeClass );
- // typedescription found
- // set to on demand
- pTD->bOnDemand = true;
-
- if (pTD->eTypeClass == typelib_TypeClass_INTERFACE
- && !pTD->bComplete && initTables)
- {
- // mandatory info from callback chain
- OSL_ASSERT( reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD)->ppAllMembers );
- // complete except of tables init
- typelib_typedescription_initTables( pTD );
- pTD->bComplete = true;
- }
+ typelib_typedescriptionreference_getDescription(
+ &pTD, reinterpret_cast<typelib_IndirectTypeDescription *>(pTD)->pType );
+ OSL_ASSERT( pTD );
+ if (! pTD)
+ return false;
+ }
- // The type description is hold by the reference until
- // on demand is activated.
- ::typelib_typedescription_register( &pTD ); // replaces incomplete one
- OSL_ASSERT( pTD == *ppTypeDescr ); // has to merge into existing one
+ OSL_ASSERT( typelib_TypeClass_TYPEDEF != pTD->eTypeClass );
+ // typedescription found
+ // set to on demand
+ pTD->bOnDemand = true;
- // insert into the cache
- MutexGuard aGuard( rInit.maMutex );
- if( static_cast<sal_Int32>(rInit.maCache.size()) >= nCacheSize )
- {
- typelib_typedescription_release( rInit.maCache.front() );
- rInit.maCache.pop_front();
- }
- // descriptions in the cache must be acquired!
- typelib_typedescription_acquire( pTD );
- rInit.maCache.push_back( pTD );
+ if (pTD->eTypeClass == typelib_TypeClass_INTERFACE
+ && !pTD->bComplete && initTables)
+ {
+ // mandatory info from callback chain
+ OSL_ASSERT( reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD)->ppAllMembers );
+ // complete except of tables init
+ typelib_typedescription_initTables( pTD );
+ pTD->bComplete = true;
+ }
- OSL_ASSERT(
- pTD->bComplete
- || (pTD->eTypeClass == typelib_TypeClass_INTERFACE
- && !initTables));
+ // The type description is hold by the reference until
+ // on demand is activated.
+ ::typelib_typedescription_register( &pTD ); // replaces incomplete one
+ OSL_ASSERT( pTD == *ppTypeDescr ); // has to merge into existing one
- ::typelib_typedescription_release( *ppTypeDescr );
- *ppTypeDescr = pTD;
- }
- else
+ // insert into the cache
+ MutexGuard aGuard( rInit.maMutex );
+ if( static_cast<sal_Int32>(rInit.maCache.size()) >= nCacheSize )
{
- SAL_INFO(
- "cppu.typelib",
- "type cannot be completed: " << OUString::unacquired(&(*ppTypeDescr)->pTypeName));
- return false;
+ typelib_typedescription_release( rInit.maCache.front() );
+ rInit.maCache.pop_front();
}
+ // descriptions in the cache must be acquired!
+ typelib_typedescription_acquire( pTD );
+ rInit.maCache.push_back( pTD );
+
+ OSL_ASSERT(
+ pTD->bComplete
+ || (pTD->eTypeClass == typelib_TypeClass_INTERFACE
+ && !initTables));
+
+ ::typelib_typedescription_release( *ppTypeDescr );
+ *ppTypeDescr = pTD;
+ }
+ else
+ {
+ SAL_INFO(
+ "cppu.typelib",
+ "type cannot be completed: " << OUString::unacquired(&(*ppTypeDescr)->pTypeName));
+ return false;
}
return true;
}
@@ -1779,90 +1779,91 @@ bool createDerivedInterfaceMemberDescription(
typelib_TypeDescription const * base, typelib_TypeDescription * interface,
sal_Int32 index, sal_Int32 position)
{
- if (baseRef != nullptr && base != nullptr && interface != nullptr) {
- switch (base->eTypeClass) {
- case typelib_TypeClass_INTERFACE_METHOD:
- {
- typelib_typedescription_newEmpty(
- result, typelib_TypeClass_INTERFACE_METHOD, name.pData);
- typelib_InterfaceMethodTypeDescription const * baseMethod
- = reinterpret_cast<
- typelib_InterfaceMethodTypeDescription const * >(base);
- typelib_InterfaceMethodTypeDescription * newMethod
- = reinterpret_cast<
- typelib_InterfaceMethodTypeDescription * >(*result);
- newMethod->aBase.nPosition = position;
- newMethod->aBase.pMemberName
- = baseMethod->aBase.pMemberName;
+ if (!baseRef || !base || !interface)
+ return false;
+
+ switch (base->eTypeClass) {
+ case typelib_TypeClass_INTERFACE_METHOD:
+ {
+ typelib_typedescription_newEmpty(
+ result, typelib_TypeClass_INTERFACE_METHOD, name.pData);
+ typelib_InterfaceMethodTypeDescription const * baseMethod
+ = reinterpret_cast<
+ typelib_InterfaceMethodTypeDescription const * >(base);
+ typelib_InterfaceMethodTypeDescription * newMethod
+ = reinterpret_cast<
+ typelib_InterfaceMethodTypeDescription * >(*result);
+ newMethod->aBase.nPosition = position;
+ newMethod->aBase.pMemberName
+ = baseMethod->aBase.pMemberName;
+ rtl_uString_acquire(
+ newMethod->aBase.pMemberName);
+ newMethod->pReturnTypeRef = baseMethod->pReturnTypeRef;
+ typelib_typedescriptionreference_acquire(
+ newMethod->pReturnTypeRef);
+ newMethod->nParams = baseMethod->nParams;
+ newMethod->pParams = new typelib_MethodParameter[
+ newMethod->nParams];
+ for (sal_Int32 i = 0; i < newMethod->nParams; ++i) {
+ newMethod->pParams[i].pName
+ = baseMethod->pParams[i].pName;
rtl_uString_acquire(
- newMethod->aBase.pMemberName);
- newMethod->pReturnTypeRef = baseMethod->pReturnTypeRef;
+ newMethod->pParams[i].pName);
+ newMethod->pParams[i].pTypeRef
+ = baseMethod->pParams[i].pTypeRef;
typelib_typedescriptionreference_acquire(
- newMethod->pReturnTypeRef);
- newMethod->nParams = baseMethod->nParams;
- newMethod->pParams = new typelib_MethodParameter[
- newMethod->nParams];
- for (sal_Int32 i = 0; i < newMethod->nParams; ++i) {
- newMethod->pParams[i].pName
- = baseMethod->pParams[i].pName;
- rtl_uString_acquire(
- newMethod->pParams[i].pName);
- newMethod->pParams[i].pTypeRef
- = baseMethod->pParams[i].pTypeRef;
- typelib_typedescriptionreference_acquire(
- newMethod->pParams[i].pTypeRef);
- newMethod->pParams[i].bIn = baseMethod->pParams[i].bIn;
- newMethod->pParams[i].bOut = baseMethod->pParams[i].bOut;
- }
- newMethod->nExceptions = baseMethod->nExceptions;
- newMethod->ppExceptions = copyExceptions(
- baseMethod->nExceptions, baseMethod->ppExceptions);
- newMethod->bOneWay = baseMethod->bOneWay;
- newMethod->pInterface
- = reinterpret_cast< typelib_InterfaceTypeDescription * >(
- interface);
- newMethod->pBaseRef = baseRef;
- newMethod->nIndex = index;
- return true;
- }
-
- case typelib_TypeClass_INTERFACE_ATTRIBUTE:
- {
- typelib_typedescription_newEmpty(
- result, typelib_TypeClass_INTERFACE_ATTRIBUTE, name.pData);
- typelib_InterfaceAttributeTypeDescription const * baseAttribute
- = reinterpret_cast<
- typelib_InterfaceAttributeTypeDescription const * >(base);
- typelib_InterfaceAttributeTypeDescription * newAttribute
- = reinterpret_cast<
- typelib_InterfaceAttributeTypeDescription * >(*result);
- newAttribute->aBase.nPosition = position;
- newAttribute->aBase.pMemberName
- = baseAttribute->aBase.pMemberName;
- rtl_uString_acquire(newAttribute->aBase.pMemberName);
- newAttribute->bReadOnly = baseAttribute->bReadOnly;
- newAttribute->pAttributeTypeRef
- = baseAttribute->pAttributeTypeRef;
- typelib_typedescriptionreference_acquire(newAttribute->pAttributeTypeRef);
- newAttribute->pInterface
- = reinterpret_cast< typelib_InterfaceTypeDescription * >(
- interface);
- newAttribute->pBaseRef = baseRef;
- newAttribute->nIndex = index;
- newAttribute->nGetExceptions = baseAttribute->nGetExceptions;
- newAttribute->ppGetExceptions = copyExceptions(
- baseAttribute->nGetExceptions,
- baseAttribute->ppGetExceptions);
- newAttribute->nSetExceptions = baseAttribute->nSetExceptions;
- newAttribute->ppSetExceptions = copyExceptions(
- baseAttribute->nSetExceptions,
- baseAttribute->ppSetExceptions);
- return true;
+ newMethod->pParams[i].pTypeRef);
+ newMethod->pParams[i].bIn = baseMethod->pParams[i].bIn;
+ newMethod->pParams[i].bOut = baseMethod->pParams[i].bOut;
}
+ newMethod->nExceptions = baseMethod->nExceptions;
+ newMethod->ppExceptions = copyExceptions(
+ baseMethod->nExceptions, baseMethod->ppExceptions);
+ newMethod->bOneWay = baseMethod->bOneWay;
+ newMethod->pInterface
+ = reinterpret_cast< typelib_InterfaceTypeDescription * >(
+ interface);
+ newMethod->pBaseRef = baseRef;
+ newMethod->nIndex = index;
+ return true;
+ }
- default:
- break;
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE:
+ {
+ typelib_typedescription_newEmpty(
+ result, typelib_TypeClass_INTERFACE_ATTRIBUTE, name.pData);
+ typelib_InterfaceAttributeTypeDescription const * baseAttribute
+ = reinterpret_cast<
+ typelib_InterfaceAttributeTypeDescription const * >(base);
+ typelib_InterfaceAttributeTypeDescription * newAttribute
+ = reinterpret_cast<
+ typelib_InterfaceAttributeTypeDescription * >(*result);
+ newAttribute->aBase.nPosition = position;
+ newAttribute->aBase.pMemberName
+ = baseAttribute->aBase.pMemberName;
+ rtl_uString_acquire(newAttribute->aBase.pMemberName);
+ newAttribute->bReadOnly = baseAttribute->bReadOnly;
+ newAttribute->pAttributeTypeRef
+ = baseAttribute->pAttributeTypeRef;
+ typelib_typedescriptionreference_acquire(newAttribute->pAttributeTypeRef);
+ newAttribute->pInterface
+ = reinterpret_cast< typelib_InterfaceTypeDescription * >(
+ interface);
+ newAttribute->pBaseRef = baseRef;
+ newAttribute->nIndex = index;
+ newAttribute->nGetExceptions = baseAttribute->nGetExceptions;
+ newAttribute->ppGetExceptions = copyExceptions(
+ baseAttribute->nGetExceptions,
+ baseAttribute->ppGetExceptions);
+ newAttribute->nSetExceptions = baseAttribute->nSetExceptions;
+ newAttribute->ppSetExceptions = copyExceptions(
+ baseAttribute->nSetExceptions,
+ baseAttribute->ppSetExceptions);
+ return true;
}
+
+ default:
+ break;
}
return false;
}
@@ -2330,68 +2331,67 @@ extern "C" sal_Bool SAL_CALL typelib_typedescriptionreference_isAssignableFrom(
typelib_TypeDescriptionReference * pFrom )
SAL_THROW_EXTERN_C()
{
- if (pAssignable && pFrom)
- {
- typelib_TypeClass eAssignable = pAssignable->eTypeClass;
- typelib_TypeClass eFrom = pFrom->eTypeClass;
+ if (!pAssignable || !pFrom)
+ return false;
- if (eAssignable == typelib_TypeClass_ANY) // anything can be assigned to an any .)
+ typelib_TypeClass eAssignable = pAssignable->eTypeClass;
+ typelib_TypeClass eFrom = pFrom->eTypeClass;
+
+ if (eAssignable == typelib_TypeClass_ANY) // anything can be assigned to an any .)
+ return true;
+ if (eAssignable == eFrom)
+ {
+ if (type_equals( pAssignable, pFrom )) // first shot
+ {
return true;
- if (eAssignable == eFrom)
+ }
+ switch (eAssignable)
{
- if (type_equals( pAssignable, pFrom )) // first shot
- {
- return true;
- }
- switch (eAssignable)
- {
- case typelib_TypeClass_STRUCT:
- case typelib_TypeClass_EXCEPTION:
- {
- typelib_TypeDescription * pFromDescr = nullptr;
- TYPELIB_DANGER_GET( &pFromDescr, pFrom );
- if (!reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription)
- {
- TYPELIB_DANGER_RELEASE( pFromDescr );
- return false;
- }
- bool bRet = typelib_typedescriptionreference_isAssignableFrom(
- pAssignable,
- reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription->aBase.pWeakRef );
- TYPELIB_DANGER_RELEASE( pFromDescr );
- return bRet;
- }
- case typelib_TypeClass_INTERFACE:
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ {
+ typelib_TypeDescription * pFromDescr = nullptr;
+ TYPELIB_DANGER_GET( &pFromDescr, pFrom );
+ if (!reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription)
{
- typelib_TypeDescription * pFromDescr = nullptr;
- TYPELIB_DANGER_GET( &pFromDescr, pFrom );
- typelib_InterfaceTypeDescription * pFromIfc
- = reinterpret_cast<
- typelib_InterfaceTypeDescription * >(pFromDescr);
- bool bRet = false;
- for (sal_Int32 i = 0; i < pFromIfc->nBaseTypes; ++i) {
- if (typelib_typedescriptionreference_isAssignableFrom(
- pAssignable,
- pFromIfc->ppBaseTypes[i]->aBase.pWeakRef))
- {
- bRet = true;
- break;
- }
- }
TYPELIB_DANGER_RELEASE( pFromDescr );
- return bRet;
- }
- default:
- {
return false;
}
+ bool bRet = typelib_typedescriptionreference_isAssignableFrom(
+ pAssignable,
+ reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription->aBase.pWeakRef );
+ TYPELIB_DANGER_RELEASE( pFromDescr );
+ return bRet;
+ }
+ case typelib_TypeClass_INTERFACE:
+ {
+ typelib_TypeDescription * pFromDescr = nullptr;
+ TYPELIB_DANGER_GET( &pFromDescr, pFrom );
+ typelib_InterfaceTypeDescription * pFromIfc
+ = reinterpret_cast<
+ typelib_InterfaceTypeDescription * >(pFromDescr);
+ bool bRet = false;
+ for (sal_Int32 i = 0; i < pFromIfc->nBaseTypes; ++i) {
+ if (typelib_typedescriptionreference_isAssignableFrom(
+ pAssignable,
+ pFromIfc->ppBaseTypes[i]->aBase.pWeakRef))
+ {
+ bRet = true;
+ break;
+ }
}
+ TYPELIB_DANGER_RELEASE( pFromDescr );
+ return bRet;
+ }
+ default:
+ {
+ return false;
+ }
}
- return (eAssignable >= typelib_TypeClass_CHAR && eAssignable <= typelib_TypeClass_DOUBLE &&
- eFrom >= typelib_TypeClass_CHAR && eFrom <= typelib_TypeClass_DOUBLE &&
- s_aAssignableFromTab[eAssignable-1][eFrom-1]);
}
- return false;
+ return (eAssignable >= typelib_TypeClass_CHAR && eAssignable <= typelib_TypeClass_DOUBLE &&
+ eFrom >= typelib_TypeClass_CHAR && eFrom <= typelib_TypeClass_DOUBLE &&
+ s_aAssignableFromTab[eAssignable-1][eFrom-1]);
}
extern "C" sal_Bool SAL_CALL typelib_typedescription_isAssignableFrom(
diff --git a/cppuhelper/source/servicemanager.cxx b/cppuhelper/source/servicemanager.cxx
index 57a3b646858e..6e2f12813445 100644
--- a/cppuhelper/source/servicemanager.cxx
+++ b/cppuhelper/source/servicemanager.cxx
@@ -1622,37 +1622,38 @@ bool cppuhelper::ServiceManager::insertExtraData(Data const & extra) {
}
//TODO: Updating the component context singleton data should be part of the
// atomic service manager update:
- if (!extra.singletons.empty()) {
- assert(context_.is());
- css::uno::Reference< css::container::XNameContainer > cont(
- context_, css::uno::UNO_QUERY_THROW);
- for (const auto& [rName, rImpls] : extra.singletons)
- {
- OUString name("/singletons/" + rName);
- //TODO: Update should be atomic:
- try {
- cont->removeByName(name + "/arguments");
- } catch (const css::container::NoSuchElementException &) {}
- assert(!rImpls.empty());
- assert(rImpls[0]);
- SAL_INFO_IF(
- rImpls.size() > 1, "cppuhelper",
- "Arbitrarily choosing " << rImpls[0]->name
- << " among multiple implementations for singleton "
- << rName);
- try {
- cont->insertByName(
- name + "/service", css::uno::Any(rImpls[0]->name));
- } catch (css::container::ElementExistException &) {
- cont->replaceByName(
- name + "/service", css::uno::Any(rImpls[0]->name));
- }
- try {
- cont->insertByName(name, css::uno::Any());
- } catch (css::container::ElementExistException &) {
- SAL_INFO("cppuhelper", "Overwriting singleton " << rName);
- cont->replaceByName(name, css::uno::Any());
- }
+ if (extra.singletons.empty())
+ return true;
+
+ assert(context_.is());
+ css::uno::Reference< css::container::XNameContainer > cont(
+ context_, css::uno::UNO_QUERY_THROW);
+ for (const auto& [rName, rImpls] : extra.singletons)
+ {
+ OUString name("/singletons/" + rName);
+ //TODO: Update should be atomic:
+ try {
+ cont->removeByName(name + "/arguments");
+ } catch (const css::container::NoSuchElementException &) {}
+ assert(!rImpls.empty());
+ assert(rImpls[0]);
+ SAL_INFO_IF(
+ rImpls.size() > 1, "cppuhelper",
+ "Arbitrarily choosing " << rImpls[0]->name
+ << " among multiple implementations for singleton "
+ << rName);
+ try {
+ cont->insertByName(
+ name + "/service", css::uno::Any(rImpls[0]->name));
+ } catch (css::container::ElementExistException &) {
+ cont->replaceByName(
+ name + "/service", css::uno::Any(rImpls[0]->name));
+ }
+ try {
+ cont->insertByName(name, css::uno::Any());
+ } catch (css::container::ElementExistException &) {
+ SAL_INFO("cppuhelper", "Overwriting singleton " << rName);
+ cont->replaceByName(name, css::uno::Any());
}
}
return true;
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
index b6ff3af0475c..398ca509dbd7 100644
--- a/cui/source/customize/acccfg.cxx
+++ b/cui/source/customize/acccfg.cxx
@@ -797,23 +797,24 @@ IMPL_LINK(SfxAcceleratorConfigPage, KeyInputHdl, const KeyEvent&, rKey, bool)
sal_uInt16 nMod1 = aCode1.GetModifier();
// is it related to our list box ?
- if ((nCode1 != KEY_DOWN) && (nCode1 != KEY_UP) && (nCode1 != KEY_LEFT) && (nCode1 != KEY_RIGHT)
- && (nCode1 != KEY_PAGEUP) && (nCode1 != KEY_PAGEDOWN))
+ if ((nCode1 == KEY_DOWN) || (nCode1 == KEY_UP) || (nCode1 == KEY_LEFT) || (nCode1 == KEY_RIGHT)
+ || (nCode1 == KEY_PAGEUP) || (nCode1 == KEY_PAGEDOWN))
+ // no - handle it as normal dialog input
+ return false;
+
+ for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i)
{
- for (int i = 0, nCount = m_xEntriesBox->n_children(); i < nCount; ++i)
+ TAccInfo* pUserData = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64());
+ if (pUserData)
{
- TAccInfo* pUserData = reinterpret_cast<TAccInfo*>(m_xEntriesBox->get_id(i).toInt64());
- if (pUserData)
- {
- sal_uInt16 nCode2 = pUserData->m_aKey.GetCode();
- sal_uInt16 nMod2 = pUserData->m_aKey.GetModifier();
+ sal_uInt16 nCode2 = pUserData->m_aKey.GetCode();
+ sal_uInt16 nMod2 = pUserData->m_aKey.GetModifier();
- if (nCode1 == nCode2 && nMod1 == nMod2)
- {
- m_xEntriesBox->select(i);
- m_xEntriesBox->scroll_to_row(i);
- return true;
- }
+ if (nCode1 == nCode2 && nMod1 == nMod2)
+ {
+ m_xEntriesBox->select(i);
+ m_xEntriesBox->scroll_to_row(i);
+ return true;
}
}
}
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 6b975317bc4f..e083d4bd438e 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1722,27 +1722,25 @@ bool SvxConfigPage::MoveEntryData(int nSourceEntry, int nTargetEntry)
SvxConfigEntry* pTargetData =
reinterpret_cast<SvxConfigEntry*>(m_xContentsListBox->get_id(nTargetEntry).toInt64());
- if ( pSourceData != nullptr && pTargetData != nullptr )
- {
- // remove the source entry from our list
- SvxConfigPageHelper::RemoveEntry( pEntries, pSourceData );
+ if ( pSourceData == nullptr || pTargetData == nullptr )
+ return false;
- SvxEntries::iterator iter = pEntries->begin();
- SvxEntries::const_iterator end = pEntries->end();
+ // remove the source entry from our list
+ SvxConfigPageHelper::RemoveEntry( pEntries, pSourceData );
- // advance the iterator to the position of the target entry
- while (*iter != pTargetData && ++iter != end) ;
+ SvxEntries::iterator iter = pEntries->begin();
+ SvxEntries::const_iterator end = pEntries->end();
- // insert the source entry at the position after the target
- pEntries->insert( ++iter, pSourceData );
+ // advance the iterator to the position of the target entry
+ while (*iter != pTargetData && ++iter != end) ;
- GetSaveInData()->SetModified();
- GetTopLevelSelection()->SetModified();
+ // insert the source entry at the position after the target
+ pEntries->insert( ++iter, pSourceData );
- return true;
- }
+ GetSaveInData()->SetModified();
+ GetTopLevelSelection()->SetModified();
- return false;
+ return true;
}
SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
diff --git a/cui/source/options/cfgchart.cxx b/cui/source/options/cfgchart.cxx
index 2303823a0e9e..063ecc0fb184 100644
--- a/cui/source/options/cfgchart.cxx
+++ b/cui/source/options/cfgchart.cxx
@@ -190,41 +190,40 @@ bool SvxChartOptions::RetrieveOptions()
uno::Sequence< uno::Any > aProperties( aNames.getLength());
aProperties = GetProperties( aNames );
- if( aProperties.getLength() == aNames.getLength())
+ if( aProperties.getLength() != aNames.getLength())
+ return false;
+
+ // 1. default colors for series
+ maDefColors.clear();
+ uno::Sequence< sal_Int64 > aColorSeq;
+ aProperties[ 0 ] >>= aColorSeq;
+
+ sal_Int32 nCount = aColorSeq.getLength();
+ Color aCol;
+
+ // create strings for entry names
+ OUString aResName( CuiResId( RID_CUISTR_DIAGRAM_ROW ) );
+ OUString aPrefix, aPostfix, aName;
+ sal_Int32 nPos = aResName.indexOf( "$(ROW)" );
+ if( nPos != -1 )
{
- // 1. default colors for series
- maDefColors.clear();
- uno::Sequence< sal_Int64 > aColorSeq;
- aProperties[ 0 ] >>= aColorSeq;
-
- sal_Int32 nCount = aColorSeq.getLength();
- Color aCol;
-
- // create strings for entry names
- OUString aResName( CuiResId( RID_CUISTR_DIAGRAM_ROW ) );
- OUString aPrefix, aPostfix, aName;
- sal_Int32 nPos = aResName.indexOf( "$(ROW)" );
- if( nPos != -1 )
- {
- aPrefix = aResName.copy( 0, nPos );
- sal_Int32 idx = nPos + sizeof( "$(ROW)" ) - 1;
- aPostfix = aResName.copy( idx );
- }
- else
- aPrefix = aResName;
+ aPrefix = aResName.copy( 0, nPos );
+ sal_Int32 idx = nPos + sizeof( "$(ROW)" ) - 1;
+ aPostfix = aResName.copy( idx );
+ }
+ else
+ aPrefix = aResName;
- // set color values
- for( sal_Int32 i=0; i < nCount; i++ )
- {
- aCol = Color(ColorTransparency, aColorSeq[ i ]);
+ // set color values
+ for( sal_Int32 i=0; i < nCount; i++ )
+ {
+ aCol = Color(ColorTransparency, aColorSeq[ i ]);
- aName = aPrefix + OUString::number(i + 1) + aPostfix;
+ aName = aPrefix + OUString::number(i + 1) + aPostfix;
- maDefColors.append( XColorEntry( aCol, aName ));
- }
- return true;
+ maDefColors.append( XColorEntry( aCol, aName ));
}
- return false;
+ return true;
}
void SvxChartOptions::ImplCommit()
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index a3d2fc54819d..c96b80b47dd9 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -1629,27 +1629,27 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame )
static bool isNodeActive( OptionsNode const * pNode, Module* pModule )
{
- if ( pNode )
- {
- // Node for all modules active?
- if ( pNode->m_bAllModules )
- return true;
+ if ( !pNode )
+ return false;
- // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted
- if ( !getGroupName( pNode->m_sId, false ).isEmpty() )
- return true;
+ // Node for all modules active?
+ if ( pNode->m_bAllModules )
+ return true;
- // no module -> not active
- if ( !pModule )
- return false;
+ // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted
+ if ( !getGroupName( pNode->m_sId, false ).isEmpty() )
+ return true;
- // search node in active module
- if ( pModule->m_bActive )
- {
- for (auto const& j : pModule->m_aNodeList)
- if ( j->m_sId == pNode->m_sId )
- return true;
- }
+ // no module -> not active
+ if ( !pModule )
+ return false;
+
+ // search node in active module
+ if ( pModule->m_bActive )
+ {
+ for (auto const& j : pModule->m_aNodeList)
+ if ( j->m_sId == pNode->m_sId )
+ return true;
}
return false;
}
diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index 7b06e9a86092..c40fe32e9623 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -188,40 +188,40 @@ bool SvxBkgTabPage::FillItemSet( SfxItemSet* rCoreSet )
break;
}
- if (m_xTblLBox && m_xTblLBox->get_visible())
+ if (!m_xTblLBox || !m_xTblLBox->get_visible())
+ return true;
+
+ if (nSlot != SID_ATTR_BRUSH)
{
- if (nSlot != SID_ATTR_BRUSH)
+ nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH);
+ if (SfxItemState::SET == maSet.GetItemState(nWhich))
{
- nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH);
- if (SfxItemState::SET == maSet.GetItemState(nWhich))
- {
- SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich)));
- rCoreSet->Put(aBrushItem);
- }
+ SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich)));
+ rCoreSet->Put(aBrushItem);
}
- if (nSlot != SID_ATTR_BRUSH_ROW)
+ }
+ if (nSlot != SID_ATTR_BRUSH_ROW)
+ {
+ nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH_ROW);
+ if (SfxItemState::SET == maSet.GetItemState(nWhich))
{
- nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH_ROW);
- if (SfxItemState::SET == maSet.GetItemState(nWhich))
- {
- SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich)));
- rCoreSet->Put(aBrushItem);
- }
+ SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich)));
+ rCoreSet->Put(aBrushItem);
}
- if (nSlot != SID_ATTR_BRUSH_TABLE)
+ }
+ if (nSlot != SID_ATTR_BRUSH_TABLE)
+ {
+ nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH_TABLE);
+ if (SfxItemState::SET == maSet.GetItemState(nWhich))
{
- nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH_TABLE);
- if (SfxItemState::SET == maSet.GetItemState(nWhich))
- {
- SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich)));
- rCoreSet->Put(aBrushItem);
- }
+ SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich)));
+ rCoreSet->Put(aBrushItem);
}
+ }
- if (m_xTblLBox->get_value_changed_from_saved())
- {
- rCoreSet->Put(SfxUInt16Item(SID_BACKGRND_DESTINATION, m_xTblLBox->get_active()));
- }
+ if (m_xTblLBox->get_value_changed_from_saved())
+ {
+ rCoreSet->Put(SfxUInt16Item(SID_BACKGRND_DESTINATION, m_xTblLBox->get_active()));
}
return true;
diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx
index 5e5352aff400..105cf43f7ca2 100644
--- a/cui/source/tabpages/swpossizetabpage.cxx
+++ b/cui/source/tabpages/swpossizetabpage.cxx
@@ -379,55 +379,54 @@ FrmMap const aVAsCharHtmlMap[] =
static std::size_t lcl_GetFrmMapCount(const FrmMap* pMap)
{
- if( pMap )
- {
- if( pMap == aVParaHtmlMap )
- return SAL_N_ELEMENTS(aVParaHtmlMap);
- if( pMap == aVAsCharHtmlMap )
- return SAL_N_ELEMENTS( aVAsCharHtmlMap );
- if( pMap == aHParaHtmlMap )
- return SAL_N_ELEMENTS( aHParaHtmlMap );
- if( pMap == aHParaHtmlAbsMap )
- return SAL_N_ELEMENTS( aHParaHtmlAbsMap );
- if( pMap == aVPageMap )
- return SAL_N_ELEMENTS( aVPageMap );
- if( pMap == aVPageHtmlMap )
- return SAL_N_ELEMENTS( aVPageHtmlMap );
- if( pMap == aVAsCharMap )
- return SAL_N_ELEMENTS( aVAsCharMap );
- if( pMap == aVParaMap )
- return SAL_N_ELEMENTS( aVParaMap );
- if( pMap == aHParaMap )
- return SAL_N_ELEMENTS( aHParaMap );
- if( pMap == aHFrameMap )
- return SAL_N_ELEMENTS( aHFrameMap );
- if( pMap == aVFrameMap )
- return SAL_N_ELEMENTS( aVFrameMap );
- if( pMap == aHCharMap )
- return SAL_N_ELEMENTS( aHCharMap );
- if( pMap == aHCharHtmlMap )
- return SAL_N_ELEMENTS( aHCharHtmlMap );
- if( pMap == aHCharHtmlAbsMap )
- return SAL_N_ELEMENTS( aHCharHtmlAbsMap );
- if( pMap == aVCharMap )
- return SAL_N_ELEMENTS( aVCharMap );
- if( pMap == aVCharHtmlMap )
- return SAL_N_ELEMENTS( aVCharHtmlMap );
- if( pMap == aVCharHtmlAbsMap )
- return SAL_N_ELEMENTS( aVCharHtmlAbsMap );
- if( pMap == aHPageHtmlMap )
- return SAL_N_ELEMENTS( aHPageHtmlMap );
- if( pMap == aHFlyHtmlMap )
- return SAL_N_ELEMENTS( aHFlyHtmlMap );
- if( pMap == aVFlyHtmlMap )
- return SAL_N_ELEMENTS( aVFlyHtmlMap );
- if( pMap == aVMultiSelectionMap )
- return SAL_N_ELEMENTS( aVMultiSelectionMap );
- if( pMap == aHMultiSelectionMap )
- return SAL_N_ELEMENTS( aHMultiSelectionMap );
- return SAL_N_ELEMENTS(aHPageMap);
- }
- return 0;
+ if( !pMap )
+ return 0;
+
+ if( pMap == aVParaHtmlMap )
+ return SAL_N_ELEMENTS(aVParaHtmlMap);
+ if( pMap == aVAsCharHtmlMap )
+ return SAL_N_ELEMENTS( aVAsCharHtmlMap );
+ if( pMap == aHParaHtmlMap )
+ return SAL_N_ELEMENTS( aHParaHtmlMap );
+ if( pMap == aHParaHtmlAbsMap )
+ return SAL_N_ELEMENTS( aHParaHtmlAbsMap );
+ if( pMap == aVPageMap )
+ return SAL_N_ELEMENTS( aVPageMap );
+ if( pMap == aVPageHtmlMap )
+ return SAL_N_ELEMENTS( aVPageHtmlMap );
+ if( pMap == aVAsCharMap )
+ return SAL_N_ELEMENTS( aVAsCharMap );
+ if( pMap == aVParaMap )
+ return SAL_N_ELEMENTS( aVParaMap );
+ if( pMap == aHParaMap )
+ return SAL_N_ELEMENTS( aHParaMap );
+ if( pMap == aHFrameMap )
+ return SAL_N_ELEMENTS( aHFrameMap );
+ if( pMap == aVFrameMap )
+ return SAL_N_ELEMENTS( aVFrameMap );
+ if( pMap == aHCharMap )
+ return SAL_N_ELEMENTS( aHCharMap );
+ if( pMap == aHCharHtmlMap )
+ return SAL_N_ELEMENTS( aHCharHtmlMap );
+ if( pMap == aHCharHtmlAbsMap )
+ return SAL_N_ELEMENTS( aHCharHtmlAbsMap );
+ if( pMap == aVCharMap )
+ return SAL_N_ELEMENTS( aVCharMap );
+ if( pMap == aVCharHtmlMap )
+ return SAL_N_ELEMENTS( aVCharHtmlMap );
+ if( pMap == aVCharHtmlAbsMap )
+ return SAL_N_ELEMENTS( aVCharHtmlAbsMap );
+ if( pMap == aHPageHtmlMap )
+ return SAL_N_ELEMENTS( aHPageHtmlMap );
+ if( pMap == aHFlyHtmlMap )
+ return SAL_N_ELEMENTS( aHFlyHtmlMap );
+ if( pMap == aVFlyHtmlMap )
+ return SAL_N_ELEMENTS( aVFlyHtmlMap );
+ if( pMap == aVMultiSelectionMap )
+ return SAL_N_ELEMENTS( aVMultiSelectionMap );
+ if( pMap == aHMultiSelectionMap )
+ return SAL_N_ELEMENTS( aHMultiSelectionMap );
+ return SAL_N_ELEMENTS(aHPageMap);
}
static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL(
diff --git a/cui/source/tabpages/textattr.cxx b/cui/source/tabpages/textattr.cxx
index d542f9b0810e..a936e227622a 100644
--- a/cui/source/tabpages/textattr.cxx
+++ b/cui/source/tabpages/textattr.cxx
@@ -395,34 +395,34 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs)
// #103516# Do not change values if adjust controls were disabled.
bool bIsDisabled(m_aCtlPosition.IsCompletelyDisabled());
- if(!bIsDisabled)
- {
- if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE )
- {
- if (IsTextDirectionLeftToRight())
- eTHA = SDRTEXTHORZADJUST_BLOCK;
- else
- eTVA = SDRTEXTVERTADJUST_BLOCK;
- }
+ if(bIsDisabled)
+ return true;
- if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::DONTCARE )
- {
- SdrTextVertAdjust eOldTVA = rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ).GetValue();
- if( eOldTVA != eTVA )
- rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
- }
+ if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE )
+ {
+ if (IsTextDirectionLeftToRight())
+ eTHA = SDRTEXTHORZADJUST_BLOCK;
else
+ eTVA = SDRTEXTVERTADJUST_BLOCK;
+ }
+
+ if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::DONTCARE )
+ {
+ SdrTextVertAdjust eOldTVA = rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ).GetValue();
+ if( eOldTVA != eTVA )
rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
+ }
+ else
+ rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
- if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::DONTCARE )
- {
- SdrTextHorzAdjust eOldTHA = rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ).GetValue();
- if( eOldTHA != eTHA )
- rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
- }
- else
+ if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::DONTCARE )
+ {
+ SdrTextHorzAdjust eOldTHA = rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ).GetValue();
+ if( eOldTHA != eTHA )
rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
}
+ else
+ rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
return true;
}
diff --git a/cui/source/tabpages/themepage.cxx b/cui/source/tabpages/themepage.cxx
index 07d24649fb5d..35eb9156398a 100644
--- a/cui/source/tabpages/themepage.cxx
+++ b/cui/source/tabpages/themepage.cxx
@@ -130,41 +130,41 @@ bool SvxThemePage::FillItemSet(SfxItemSet* pAttrs)
{
const SfxItemSet& rOldSet = GetItemSet();
- if (rOldSet.HasItem(SID_ATTR_CHAR_GRABBAG))
+ if (!rOldSet.HasItem(SID_ATTR_CHAR_GRABBAG))
+ return true;
+
+ SfxGrabBagItem aGrabBagItem(
+ static_cast<const SfxGrabBagItem&>(rOldSet.Get(SID_ATTR_CHAR_GRABBAG)));
+
+ comphelper::SequenceAsHashMap aMap;
+ auto it = aGrabBagItem.GetGrabBag().find("Theme");
+ if (it != aGrabBagItem.GetGrabBag().end())
{
- SfxGrabBagItem aGrabBagItem(
- static_cast<const SfxGrabBagItem&>(rOldSet.Get(SID_ATTR_CHAR_GRABBAG)));
-
- comphelper::SequenceAsHashMap aMap;
- auto it = aGrabBagItem.GetGrabBag().find("Theme");
- if (it != aGrabBagItem.GetGrabBag().end())
- {
- aMap << it->second;
- }
-
- aMap["Name"] <<= m_xThemeName->get_text();
- aMap["ColorSchemeName"] <<= m_xColorSetName->get_text();
- std::vector<util::Color> aColorScheme = {
- static_cast<sal_Int32>(m_xDk1->GetSelectEntryColor()),
- static_cast<sal_Int32>(m_xLt1->GetSelectEntryColor()),
- static_cast<sal_Int32>(m_xDk2->GetSelectEntryColor()),
- static_cast<sal_Int32>(m_xLt2->GetSelectEntryColor()),
- static_cast<sal_Int32>(m_xAccent1->GetSelectEntryColor()),
- static_cast<sal_Int32>(m_xAccent2->GetSelectEntryColor()),
- static_cast<sal_Int32>(m_xAccent3->GetSelectEntryColor()),
- static_cast<sal_Int32>(m_xAccent4->GetSelectEntryColor()),
- static_cast<sal_Int32>(m_xAccent5->GetSelectEntryColor()),
- static_cast<sal_Int32>(m_xAccent6->GetSelectEntryColor()),
- static_cast<sal_Int32>(m_xHlink->GetSelectEntryColor()),
- static_cast<sal_Int32>(m_xFolHlink->GetSelectEntryColor()),
- };
- aMap["ColorScheme"] <<= comphelper::containerToSequence(aColorScheme);
-
- beans::PropertyValues aTheme = aMap.getAsConstPropertyValueList();
- aGrabBagItem.GetGrabBag()["Theme"] <<= aTheme;
- pAttrs->Put(aGrabBagItem);
+ aMap << it->second;
}
+ aMap["Name"] <<= m_xThemeName->get_text();
+ aMap["ColorSchemeName"] <<= m_xColorSetName->get_text();
+ std::vector<util::Color> aColorScheme = {
+ static_cast<sal_Int32>(m_xDk1->GetSelectEntryColor()),
+ static_cast<sal_Int32>(m_xLt1->GetSelectEntryColor()),
+ static_cast<sal_Int32>(m_xDk2->GetSelectEntryColor()),
+ static_cast<sal_Int32>(m_xLt2->GetSelectEntryColor()),
+ static_cast<sal_Int32>(m_xAccent1->GetSelectEntryColor()),
+ static_cast<sal_Int32>(m_xAccent2->GetSelectEntryColor()),
+ static_cast<sal_Int32>(m_xAccent3->GetSelectEntryColor()),
+ static_cast<sal_Int32>(m_xAccent4->GetSelectEntryColor()),
+ static_cast<sal_Int32>(m_xAccent5->GetSelectEntryColor()),
+ static_cast<sal_Int32>(m_xAccent6->GetSelectEntryColor()),
+ static_cast<sal_Int32>(m_xHlink->GetSelectEntryColor()),
+ static_cast<sal_Int32>(m_xFolHlink->GetSelectEntryColor()),
+ };
+ aMap["ColorScheme"] <<= comphelper::containerToSequence(aColorScheme);
+
+ beans::PropertyValues aTheme = aMap.getAsConstPropertyValueList();
+ aGrabBagItem.GetGrabBag()["Theme"] <<= aTheme;
+ pAttrs->Put(aGrabBagItem);
+
return true;
}