Kaydet (Commit) 7ecd3372 authored tarafından Tamás Zolnai's avatar Tamás Zolnai

Improve warnings in pivot table code

Change-Id: I5230bcb4abbc720cc2177e26f8fa5b8969039624
üst 0b5c4d38
...@@ -1155,7 +1155,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie ...@@ -1155,7 +1155,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
// source options must be first! // source options must be first!
uno::Reference<beans::XPropertySet> xSourceProp( xSource, uno::UNO_QUERY ); uno::Reference<beans::XPropertySet> xSourceProp( xSource, uno::UNO_QUERY );
OSL_ENSURE( xSourceProp.is(), "no properties at source" ); SAL_WARN_IF( !xSourceProp.is(), "sc.core", "no properties at source" );
if ( xSourceProp.is() ) if ( xSourceProp.is() )
{ {
// source options are not available for external sources // source options are not available for external sources
...@@ -1186,7 +1186,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie ...@@ -1186,7 +1186,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
// reset all orientations // reset all orientations
//TODO: "forgetSettings" or similar at source ????? //TODO: "forgetSettings" or similar at source ?????
//TODO: reset all duplicated dimensions, or reuse them below !!! //TODO: reset all duplicated dimensions, or reuse them below !!!
OSL_FAIL( "ScDPSaveData::WriteToSource" ); SAL_INFO("sc.core", "ScDPSaveData::WriteToSource");
lcl_ResetOrient( xSource ); lcl_ResetOrient( xSource );
...@@ -1232,7 +1232,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie ...@@ -1232,7 +1232,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
if ((*iter)->GetDupFlag()) if ((*iter)->GetDupFlag())
{ {
uno::Reference<util::XCloneable> xCloneable(xIntDim, uno::UNO_QUERY); uno::Reference<util::XCloneable> xCloneable(xIntDim, uno::UNO_QUERY);
OSL_ENSURE(xCloneable.is(), "cannot clone dimension"); SAL_WARN_IF(!xCloneable.is(), "sc", "cannot clone dimension");
if (xCloneable.is()) if (xCloneable.is())
{ {
uno::Reference<util::XCloneable> xNew = xCloneable->createClone(); uno::Reference<util::XCloneable> xNew = xCloneable->createClone();
...@@ -1248,7 +1248,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie ...@@ -1248,7 +1248,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
(*iter)->WriteToSource( xIntDim ); (*iter)->WriteToSource( xIntDim );
} }
} }
OSL_ENSURE(bFound, "WriteToSource: Dimension not found"); SAL_WARN_IF(!bFound, "sc.core", "WriteToSource: Dimension not found: " + aName + ".");
} }
if ( xSourceProp.is() ) if ( xSourceProp.is() )
...@@ -1263,7 +1263,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie ...@@ -1263,7 +1263,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
} }
catch(uno::Exception&) catch(uno::Exception&)
{ {
OSL_FAIL("exception in WriteToSource"); SAL_WARN("sc.core", "exception in WriteToSource");
} }
} }
...@@ -1280,7 +1280,7 @@ bool ScDPSaveData::IsEmpty() const ...@@ -1280,7 +1280,7 @@ bool ScDPSaveData::IsEmpty() const
void ScDPSaveData::RemoveAllGroupDimensions( const OUString& rSrcDimName, std::vector<OUString>* pDeletedNames ) void ScDPSaveData::RemoveAllGroupDimensions( const OUString& rSrcDimName, std::vector<OUString>* pDeletedNames )
{ {
if (!pDimensionData) if (!pDimensionData)
// No group dimensions exist. Nothing to do. // No group dimensions exist. Nothing to do.
return; return;
// Remove numeric group dimension (exists once at most). No need to delete // Remove numeric group dimension (exists once at most). No need to delete
......
...@@ -833,8 +833,8 @@ OUString PivotCacheField::createDateGroupField( const Reference< XDataPilotField ...@@ -833,8 +833,8 @@ OUString PivotCacheField::createDateGroupField( const Reference< XDataPilotField
OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotField >& rxBaseDPField, const PivotCacheField& rBaseCacheField, PivotCacheGroupItemVector& orItemNames ) const OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotField >& rxBaseDPField, const PivotCacheField& rBaseCacheField, PivotCacheGroupItemVector& orItemNames ) const
{ {
OSL_ENSURE( hasGroupItems() && !maDiscreteItems.empty(), "PivotCacheField::createParentGroupField - not a group field" ); SAL_WARN_IF( !hasGroupItems() || maDiscreteItems.empty(), "sc", "PivotCacheField::createParentGroupField - not a group field" );
OSL_ENSURE( maDiscreteItems.size() == orItemNames.size(), "PivotCacheField::createParentGroupField - number of item names does not match grouping info" ); SAL_WARN_IF( maDiscreteItems.size() != orItemNames.size(), "sc", "PivotCacheField::createParentGroupField - number of item names does not match grouping info" );
Reference< XDataPilotFieldGrouping > xDPGrouping( rxBaseDPField, UNO_QUERY ); Reference< XDataPilotFieldGrouping > xDPGrouping( rxBaseDPField, UNO_QUERY );
if( !xDPGrouping.is() ) return OUString(); if( !xDPGrouping.is() ) return OUString();
...@@ -860,7 +860,7 @@ OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotFie ...@@ -860,7 +860,7 @@ OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotFie
Reference< XDataPilotField > xDPGroupField; Reference< XDataPilotField > xDPGroupField;
for( GroupItemMap::iterator aBeg = aItemMap.begin(), aIt = aBeg, aEnd = aItemMap.end(); aIt != aEnd; ++aIt ) for( GroupItemMap::iterator aBeg = aItemMap.begin(), aIt = aBeg, aEnd = aItemMap.end(); aIt != aEnd; ++aIt )
{ {
OSL_ENSURE( !aIt->empty(), "PivotCacheField::createParentGroupField - item/group should not be empty" ); SAL_WARN_IF( aIt->empty(), "sc", "PivotCacheField::createParentGroupField - item/group should not be empty" );
if( !aIt->empty() ) if( !aIt->empty() )
{ {
/* Insert the names of the items that are part of this group. Calc /* Insert the names of the items that are part of this group. Calc
...@@ -882,7 +882,7 @@ OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotFie ...@@ -882,7 +882,7 @@ OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotFie
{ {
// only the first call of createNameGroup() returns the new field // only the first call of createNameGroup() returns the new field
Reference< XDataPilotField > xDPNewField = xDPGrouping->createNameGroup( ContainerHelper::vectorToSequence( aMembers ) ); Reference< XDataPilotField > xDPNewField = xDPGrouping->createNameGroup( ContainerHelper::vectorToSequence( aMembers ) );
OSL_ENSURE( xDPGroupField.is() != xDPNewField.is(), "PivotCacheField::createParentGroupField - missing group field" ); SAL_WARN_IF( xDPGroupField.is() == xDPNewField.is(), "sc", "PivotCacheField::createParentGroupField - missing group field" );
if( !xDPGroupField.is() ) if( !xDPGroupField.is() )
xDPGroupField = xDPNewField; xDPGroupField = xDPNewField;
...@@ -918,14 +918,15 @@ OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotFie ...@@ -918,14 +918,15 @@ OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotFie
} }
catch( Exception& ) catch( Exception& )
{ {
SAL_WARN("sc", "PivotCacheField::createParentGroupField - exception was thrown" );
} }
OSL_ENSURE( !aAutoName.isEmpty(), "PivotCacheField::createParentGroupField - cannot find auto-generated group name" ); SAL_WARN_IF( aAutoName.isEmpty(), "sc", "PivotCacheField::createParentGroupField - cannot find auto-generated group name" );
// get the real group name from the list of group items // get the real group name from the list of group items
OUString aGroupName; OUString aGroupName;
if( const PivotCacheItem* pGroupItem = maGroupItems.getCacheItem( static_cast< sal_Int32 >( aIt - aBeg ) ) ) if( const PivotCacheItem* pGroupItem = maGroupItems.getCacheItem( static_cast< sal_Int32 >( aIt - aBeg ) ) )
aGroupName = pGroupItem->getName(); aGroupName = pGroupItem->getName();
OSL_ENSURE( !aGroupName.isEmpty(), "PivotCacheField::createParentGroupField - cannot find group name" ); SAL_WARN_IF( aGroupName.isEmpty(), "sc", "PivotCacheField::createParentGroupField - cannot find group name" );
if( aGroupName.isEmpty() ) if( aGroupName.isEmpty() )
aGroupName = aAutoName; aGroupName = aAutoName;
...@@ -945,6 +946,7 @@ OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotFie ...@@ -945,6 +946,7 @@ OUString PivotCacheField::createParentGroupField( const Reference< XDataPilotFie
} }
catch( Exception& ) catch( Exception& )
{ {
SAL_WARN("sc", "PivotCacheField::createParentGroupField - exception was thrown" );
} }
} }
} }
......
...@@ -2618,6 +2618,7 @@ Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( cons ...@@ -2618,6 +2618,7 @@ Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( cons
Reference< XMembersAccess > xMembers = GetMembers(); Reference< XMembersAccess > xMembers = GetMembers();
if (!xMembers.is()) if (!xMembers.is())
{ {
SAL_WARN("sc.ui", "Cannot access members of the field object.");
delete pNewGroupDim; delete pNewGroupDim;
throw RuntimeException(); throw RuntimeException();
} }
...@@ -2628,6 +2629,7 @@ Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( cons ...@@ -2628,6 +2629,7 @@ Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( cons
if (!xMembers->hasByName(aEntryName)) if (!xMembers->hasByName(aEntryName))
{ {
SAL_WARN("sc.ui", "There is no member with that name: " + aEntryName + ".");
delete pNewGroupDim; delete pNewGroupDim;
throw IllegalArgumentException(); throw IllegalArgumentException();
} }
...@@ -2679,10 +2681,11 @@ Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( cons ...@@ -2679,10 +2681,11 @@ Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( cons
try try
{ {
xRet.set(xFields->getByName(sNewDim), UNO_QUERY); xRet.set(xFields->getByName(sNewDim), UNO_QUERY);
OSL_ENSURE(xRet.is(), "there is a name, so there should be also a field"); SAL_WARN_IF(!xRet.is(), "sc.ui", "there is a name, so there should be also a field");
} }
catch (const container::NoSuchElementException&) catch (const container::NoSuchElementException&)
{ {
SAL_WARN("sc.ui", "Cannot find field with that name: " + sNewDim + ".");
// Avoid throwing exception that's not specified in the method signature. // Avoid throwing exception that's not specified in the method signature.
throw RuntimeException(); throw RuntimeException();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment