summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-30 10:35:44 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-31 20:58:23 +0200
commitc9edb99bdc74715e7d952b2b95a4d75a73300207 (patch)
tree96fa01ae751c52d7e23896cfc6d837fd026ee676 /sw
parent59a1a711902d29a92c2babad28d8577bb03dd91b (diff)
loplugin:flatten in sw/core/ole..sw/core/table
Change-Id: If74f1cfca114d52566164656c34a0764cfbaad43 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99886 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/objectpositioning/anchoredobjectposition.cxx86
-rw-r--r--sw/source/core/ole/ndole.cxx144
-rw-r--r--sw/source/core/swg/SwXMLTextBlocks1.cxx62
-rw-r--r--sw/source/core/swg/swblocks.cxx64
-rw-r--r--sw/source/core/table/swnewtable.cxx142
-rw-r--r--sw/source/core/table/swtable.cxx100
6 files changed, 300 insertions, 298 deletions
diff --git a/sw/source/core/objectpositioning/anchoredobjectposition.cxx b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
index 09b616edb507..99bbd7f49d5d 100644
--- a/sw/source/core/objectpositioning/anchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/anchoredobjectposition.cxx
@@ -750,51 +750,51 @@ void SwAnchoredObjectPosition::ToggleHoriOrientAndAlign(
sal_Int16& _iopeRelOrient
)
{
- if( _bToggleLeftRight )
+ if( !_bToggleLeftRight )
+ return;
+
+ // toggle orientation
+ switch ( _ioeHoriOrient )
{
- // toggle orientation
- switch ( _ioeHoriOrient )
- {
- case text::HoriOrientation::RIGHT :
- {
- _ioeHoriOrient = text::HoriOrientation::LEFT;
- }
- break;
- case text::HoriOrientation::LEFT :
- {
- _ioeHoriOrient = text::HoriOrientation::RIGHT;
- }
- break;
- default:
- break;
- }
+ case text::HoriOrientation::RIGHT :
+ {
+ _ioeHoriOrient = text::HoriOrientation::LEFT;
+ }
+ break;
+ case text::HoriOrientation::LEFT :
+ {
+ _ioeHoriOrient = text::HoriOrientation::RIGHT;
+ }
+ break;
+ default:
+ break;
+ }
- // toggle relative alignment
- switch ( _iopeRelOrient )
- {
- case text::RelOrientation::PAGE_RIGHT :
- {
- _iopeRelOrient = text::RelOrientation::PAGE_LEFT;
- }
- break;
- case text::RelOrientation::PAGE_LEFT :
- {
- _iopeRelOrient = text::RelOrientation::PAGE_RIGHT;
- }
- break;
- case text::RelOrientation::FRAME_RIGHT :
- {
- _iopeRelOrient = text::RelOrientation::FRAME_LEFT;
- }
- break;
- case text::RelOrientation::FRAME_LEFT :
- {
- _iopeRelOrient = text::RelOrientation::FRAME_RIGHT;
- }
- break;
- default:
- break;
- }
+ // toggle relative alignment
+ switch ( _iopeRelOrient )
+ {
+ case text::RelOrientation::PAGE_RIGHT :
+ {
+ _iopeRelOrient = text::RelOrientation::PAGE_LEFT;
+ }
+ break;
+ case text::RelOrientation::PAGE_LEFT :
+ {
+ _iopeRelOrient = text::RelOrientation::PAGE_RIGHT;
+ }
+ break;
+ case text::RelOrientation::FRAME_RIGHT :
+ {
+ _iopeRelOrient = text::RelOrientation::FRAME_LEFT;
+ }
+ break;
+ case text::RelOrientation::FRAME_LEFT :
+ {
+ _iopeRelOrient = text::RelOrientation::FRAME_RIGHT;
+ }
+ break;
+ default:
+ break;
}
}
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx
index a480f0a9bae5..50bbe3ebf883 100644
--- a/sw/source/core/ole/ndole.cxx
+++ b/sw/source/core/ole/ndole.cxx
@@ -572,22 +572,22 @@ void SwOLENode::BreakFileLink_Impl()
{
SfxObjectShell* pPers = GetDoc()->GetPersist();
- if ( pPers )
+ if ( !pPers )
+ return;
+
+ uno::Reference< embed::XStorage > xStorage = pPers->GetStorage();
+ if ( !xStorage.is() )
+ return;
+
+ try
+ {
+ uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.GetOleRef(), uno::UNO_QUERY_THROW );
+ xLinkSupport->breakLink( xStorage, maOLEObj.GetCurrentPersistName() );
+ DisconnectFileLink_Impl();
+ maLinkURL.clear();
+ }
+ catch( uno::Exception& )
{
- uno::Reference< embed::XStorage > xStorage = pPers->GetStorage();
- if ( xStorage.is() )
- {
- try
- {
- uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.GetOleRef(), uno::UNO_QUERY_THROW );
- xLinkSupport->breakLink( xStorage, maOLEObj.GetCurrentPersistName() );
- DisconnectFileLink_Impl();
- maLinkURL.clear();
- }
- catch( uno::Exception& )
- {
- }
- }
}
}
@@ -602,27 +602,27 @@ void SwOLENode::DisconnectFileLink_Impl()
void SwOLENode::CheckFileLink_Impl()
{
- if ( maOLEObj.m_xOLERef.GetObject().is() && !mpObjectLink )
+ if ( !(maOLEObj.m_xOLERef.GetObject().is() && !mpObjectLink) )
+ return;
+
+ try
{
- try
+ uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY_THROW );
+ if ( xLinkSupport->isLink() )
{
- uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY_THROW );
- if ( xLinkSupport->isLink() )
+ const OUString aLinkURL = xLinkSupport->getLinkURL();
+ if ( !aLinkURL.isEmpty() )
{
- const OUString aLinkURL = xLinkSupport->getLinkURL();
- if ( !aLinkURL.isEmpty() )
- {
- // this is a file link so the model link manager should handle it
- mpObjectLink = new SwEmbedObjectLink( this );
- maLinkURL = aLinkURL;
- GetDoc()->getIDocumentLinksAdministration().GetLinkManager().InsertFileLink( *mpObjectLink, sfx2::SvBaseLinkObjectType::ClientOle, aLinkURL );
- mpObjectLink->Connect();
- }
+ // this is a file link so the model link manager should handle it
+ mpObjectLink = new SwEmbedObjectLink( this );
+ maLinkURL = aLinkURL;
+ GetDoc()->getIDocumentLinksAdministration().GetLinkManager().InsertFileLink( *mpObjectLink, sfx2::SvBaseLinkObjectType::ClientOle, aLinkURL );
+ mpObjectLink->Connect();
}
}
- catch( uno::Exception& )
- {
- }
+ }
+ catch( uno::Exception& )
+ {
}
}
@@ -862,39 +862,39 @@ SwOLEObj::~SwOLEObj() COVERITY_NOEXCEPT_FALSE
void SwOLEObj::SetNode( SwOLENode* pNode )
{
m_pOLENode = pNode;
- if ( m_aName.isEmpty() )
- {
- SwDoc* pDoc = pNode->GetDoc();
-
- // If there's already a SvPersist instance, we use it
- SfxObjectShell* p = pDoc->GetPersist();
- if( !p )
- {
- // TODO/LATER: Isn't an EmbeddedObjectContainer sufficient here?
- // What happens to the document?
- OSL_ENSURE( false, "Why are we creating a DocShell here??" );
- p = new SwDocShell( pDoc, SfxObjectCreateMode::INTERNAL );
- p->DoInitNew();
- }
+ if ( !m_aName.isEmpty() )
+ return;
- OUString aObjName;
- uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY );
- if ( xChild.is() && xChild->getParent() != p->GetModel() )
- // it is possible that the parent was set already
- xChild->setParent( p->GetModel() );
- if (!p->GetEmbeddedObjectContainer().InsertEmbeddedObject( m_xOLERef.GetObject(), aObjName ) )
- {
- OSL_FAIL( "InsertObject failed" );
- if ( xChild.is() )
- xChild->setParent( nullptr );
- }
- else
- m_xOLERef.AssignToContainer( &p->GetEmbeddedObjectContainer(), aObjName );
+ SwDoc* pDoc = pNode->GetDoc();
- const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required
+ // If there's already a SvPersist instance, we use it
+ SfxObjectShell* p = pDoc->GetPersist();
+ if( !p )
+ {
+ // TODO/LATER: Isn't an EmbeddedObjectContainer sufficient here?
+ // What happens to the document?
+ OSL_ENSURE( false, "Why are we creating a DocShell here??" );
+ p = new SwDocShell( pDoc, SfxObjectCreateMode::INTERNAL );
+ p->DoInitNew();
+ }
- m_aName = aObjName;
+ OUString aObjName;
+ uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY );
+ if ( xChild.is() && xChild->getParent() != p->GetModel() )
+ // it is possible that the parent was set already
+ xChild->setParent( p->GetModel() );
+ if (!p->GetEmbeddedObjectContainer().InsertEmbeddedObject( m_xOLERef.GetObject(), aObjName ) )
+ {
+ OSL_FAIL( "InsertObject failed" );
+ if ( xChild.is() )
+ xChild->setParent( nullptr );
}
+ else
+ m_xOLERef.AssignToContainer( &p->GetEmbeddedObjectContainer(), aObjName );
+
+ const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required
+
+ m_aName = aObjName;
}
OUString SwOLEObj::GetStyleString()
@@ -1219,20 +1219,20 @@ void SwOLELRUCache::InsertObj( SwOLEObj& rObj )
m_OleObjects.erase(it);
it = m_OleObjects.end();
}
- if (it == m_OleObjects.end())
+ if (it != m_OleObjects.end())
+ return;
+
+ std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this
+ // try to remove objects if necessary
+ sal_Int32 nCount = m_OleObjects.size();
+ sal_Int32 nPos = nCount-1;
+ while (nPos >= 0 && nCount >= m_nLRU_InitSize)
{
- std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this
- // try to remove objects if necessary
- sal_Int32 nCount = m_OleObjects.size();
- sal_Int32 nPos = nCount-1;
- while (nPos >= 0 && nCount >= m_nLRU_InitSize)
- {
- pObj = m_OleObjects[ nPos-- ];
- if ( pObj->UnloadObject() )
- nCount--;
- }
- m_OleObjects.push_front(&rObj);
+ pObj = m_OleObjects[ nPos-- ];
+ if ( pObj->UnloadObject() )
+ nCount--;
}
+ m_OleObjects.push_front(&rObj);
}
void SwOLELRUCache::RemoveObj( SwOLEObj& rObj )
diff --git a/sw/source/core/swg/SwXMLTextBlocks1.cxx b/sw/source/core/swg/SwXMLTextBlocks1.cxx
index 1b286f57afef..30c6a9ce1b83 100644
--- a/sw/source/core/swg/SwXMLTextBlocks1.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks1.cxx
@@ -416,46 +416,46 @@ void SwXMLTextBlocks::ReadInfo()
}
void SwXMLTextBlocks::WriteInfo()
{
- if ( xBlkRoot.is() || ERRCODE_NONE == OpenFile ( false ) )
- {
- uno::Reference< uno::XComponentContext > xContext =
- comphelper::getProcessComponentContext();
+ if ( !(xBlkRoot.is() || ERRCODE_NONE == OpenFile ( false )) )
+ return;
- uno::Reference < xml::sax::XWriter > xWriter = xml::sax::Writer::create(xContext);
+ uno::Reference< uno::XComponentContext > xContext =
+ comphelper::getProcessComponentContext();
- /*
- if ( xBlkRoot->IsContained( sDocName) )
- {
- xBlkRoot->Remove ( sDocName );
- xBlkRoot->Commit();
- }
- */
+ uno::Reference < xml::sax::XWriter > xWriter = xml::sax::Writer::create(xContext);
- try
- {
- uno::Reference < io::XStream > xDocStream = xBlkRoot->openStreamElement( XMLN_BLOCKLIST,
- embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE );
+ /*
+ if ( xBlkRoot->IsContained( sDocName) )
+ {
+ xBlkRoot->Remove ( sDocName );
+ xBlkRoot->Commit();
+ }
+ */
- uno::Reference < beans::XPropertySet > xSet( xDocStream, uno::UNO_QUERY );
- xSet->setPropertyValue("MediaType", Any(OUString( "text/xml" )) );
- uno::Reference < io::XOutputStream > xOut = xDocStream->getOutputStream();
- xWriter->setOutputStream(xOut);
+ try
+ {
+ uno::Reference < io::XStream > xDocStream = xBlkRoot->openStreamElement( XMLN_BLOCKLIST,
+ embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE );
- rtl::Reference<SwXMLBlockListExport> xExp(new SwXMLBlockListExport( xContext, *this, XMLN_BLOCKLIST, xWriter) );
+ uno::Reference < beans::XPropertySet > xSet( xDocStream, uno::UNO_QUERY );
+ xSet->setPropertyValue("MediaType", Any(OUString( "text/xml" )) );
+ uno::Reference < io::XOutputStream > xOut = xDocStream->getOutputStream();
+ xWriter->setOutputStream(xOut);
- xExp->exportDoc( XML_BLOCK_LIST );
+ rtl::Reference<SwXMLBlockListExport> xExp(new SwXMLBlockListExport( xContext, *this, XMLN_BLOCKLIST, xWriter) );
- uno::Reference < embed::XTransactedObject > xTrans( xBlkRoot, uno::UNO_QUERY );
- if ( xTrans.is() )
- xTrans->commit();
- }
- catch ( uno::Exception& )
- {
- }
+ xExp->exportDoc( XML_BLOCK_LIST );
- m_bInfoChanged = false;
- return;
+ uno::Reference < embed::XTransactedObject > xTrans( xBlkRoot, uno::UNO_QUERY );
+ if ( xTrans.is() )
+ xTrans->commit();
}
+ catch ( uno::Exception& )
+ {
+ }
+
+ m_bInfoChanged = false;
+ return;
}
ErrCode SwXMLTextBlocks::SetMacroTable(
diff --git a/sw/source/core/swg/swblocks.cxx b/sw/source/core/swg/swblocks.cxx
index 803c1bb0b48b..474e9fb4ee5d 100644
--- a/sw/source/core/swg/swblocks.cxx
+++ b/sw/source/core/swg/swblocks.cxx
@@ -231,8 +231,10 @@ SwTextBlocks::SwTextBlocks( const OUString& rFile )
case SwImpBlocks::FileType::NoFile: m_pImp.reset( new SwXMLTextBlocks( sFileName ) ); break;
default: break;
}
- if( !m_pImp )
- m_nErr = ERR_SWG_FILE_FORMAT_ERROR;
+ if( m_pImp )
+ return;
+
+ m_nErr = ERR_SWG_FILE_FORMAT_ERROR;
}
SwTextBlocks::~SwTextBlocks()
@@ -307,40 +309,40 @@ bool SwTextBlocks::Delete( sal_uInt16 n )
void SwTextBlocks::Rename( sal_uInt16 n, const OUString* s, const OUString* l )
{
- if( m_pImp && !m_pImp->m_bInPutMuchBlocks )
+ if( !(m_pImp && !m_pImp->m_bInPutMuchBlocks) )
+ return;
+
+ m_pImp->m_nCurrentIndex = USHRT_MAX;
+ OUString aNew;
+ OUString aLong;
+ if( s )
+ aNew = aLong = *s;
+ if( l )
+ aLong = *l;
+ if( aNew.isEmpty() )
{
- m_pImp->m_nCurrentIndex = USHRT_MAX;
- OUString aNew;
- OUString aLong;
- if( s )
- aNew = aLong = *s;
- if( l )
- aLong = *l;
- if( aNew.isEmpty() )
- {
- OSL_ENSURE( false, "No short name provided in the rename" );
- m_nErr = ERR_SWG_INTERNAL_ERROR;
- return;
- }
+ OSL_ENSURE( false, "No short name provided in the rename" );
+ m_nErr = ERR_SWG_INTERNAL_ERROR;
+ return;
+ }
- if( m_pImp->IsFileChanged() )
- m_nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
- else if( ERRCODE_NONE == ( m_nErr = m_pImp->OpenFile( false )))
+ if( m_pImp->IsFileChanged() )
+ m_nErr = ERR_TXTBLOCK_NEWFILE_ERROR;
+ else if( ERRCODE_NONE == ( m_nErr = m_pImp->OpenFile( false )))
+ {
+ // Set the new entry in the list before we do that!
+ aNew = GetAppCharClass().uppercase( aNew );
+ m_nErr = m_pImp->Rename( n, aNew );
+ if( !m_nErr )
{
- // Set the new entry in the list before we do that!
- aNew = GetAppCharClass().uppercase( aNew );
- m_nErr = m_pImp->Rename( n, aNew );
- if( !m_nErr )
- {
- bool bOnlyText = m_pImp->m_aNames[ n ]->bIsOnlyText;
- m_pImp->m_aNames.erase( m_pImp->m_aNames.begin() + n );
- m_pImp->AddName( aNew, aLong, bOnlyText );
- m_nErr = m_pImp->MakeBlockList();
- }
+ bool bOnlyText = m_pImp->m_aNames[ n ]->bIsOnlyText;
+ m_pImp->m_aNames.erase( m_pImp->m_aNames.begin() + n );
+ m_pImp->AddName( aNew, aLong, bOnlyText );
+ m_nErr = m_pImp->MakeBlockList();
}
- m_pImp->CloseFile();
- m_pImp->Touch();
}
+ m_pImp->CloseFile();
+ m_pImp->Touch();
}
bool SwTextBlocks::BeginGetDoc( sal_uInt16 n )
diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index d1e724936d11..73fd1d8acedc 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -1564,53 +1564,53 @@ bool SwTable::InsertRow( SwDoc* pDoc, const SwSelBoxes& rBoxes,
void SwTable::PrepareDelBoxes( const SwSelBoxes& rBoxes )
{
- if( IsNewModel() )
+ if( !IsNewModel() )
+ return;
+
+ for (size_t i = 0; i < rBoxes.size(); ++i)
{
- for (size_t i = 0; i < rBoxes.size(); ++i)
+ SwTableBox* pBox = rBoxes[i];
+ long nRowSpan = pBox->getRowSpan();
+ if( nRowSpan != 1 && pBox->GetFrameFormat()->GetFrameSize().GetWidth() )
{
- SwTableBox* pBox = rBoxes[i];
- long nRowSpan = pBox->getRowSpan();
- if( nRowSpan != 1 && pBox->GetFrameFormat()->GetFrameSize().GetWidth() )
+ long nLeft = lcl_Box2LeftBorder( *pBox );
+ SwTableLine *pLine = pBox->GetUpper();
+ sal_uInt16 nLinePos = GetTabLines().GetPos( pLine);
+ OSL_ENSURE( nLinePos < USHRT_MAX, "Box/table mismatch" );
+ if( nRowSpan > 1 )
{
- long nLeft = lcl_Box2LeftBorder( *pBox );
- SwTableLine *pLine = pBox->GetUpper();
- sal_uInt16 nLinePos = GetTabLines().GetPos( pLine);
- OSL_ENSURE( nLinePos < USHRT_MAX, "Box/table mismatch" );
- if( nRowSpan > 1 )
+ if( ++nLinePos < GetTabLines().size() )
{
- if( ++nLinePos < GetTabLines().size() )
- {
- pLine = GetTabLines()[ nLinePos ];
- pBox = lcl_LeftBorder2Box( nLeft, pLine );
- OSL_ENSURE( pBox, "RowSpan irritation I" );
- if( pBox )
- pBox->setRowSpan( --nRowSpan );
- }
+ pLine = GetTabLines()[ nLinePos ];
+ pBox = lcl_LeftBorder2Box( nLeft, pLine );
+ OSL_ENSURE( pBox, "RowSpan irritation I" );
+ if( pBox )
+ pBox->setRowSpan( --nRowSpan );
}
- else if( nLinePos > 0 )
+ }
+ else if( nLinePos > 0 )
+ {
+ do
{
- do
+ pLine = GetTabLines()[ --nLinePos ];
+ pBox = lcl_LeftBorder2Box( nLeft, pLine );
+ OSL_ENSURE( pBox, "RowSpan irritation II" );
+ if( pBox )
{
- pLine = GetTabLines()[ --nLinePos ];
- pBox = lcl_LeftBorder2Box( nLeft, pLine );
- OSL_ENSURE( pBox, "RowSpan irritation II" );
- if( pBox )
+ nRowSpan = pBox->getRowSpan();
+ if( nRowSpan > 1 )
{
- nRowSpan = pBox->getRowSpan();
- if( nRowSpan > 1 )
- {
- lcl_InvalidateCellFrame( *pBox );
- --nRowSpan;
- }
- else
- ++nRowSpan;
- pBox->setRowSpan( nRowSpan );
+ lcl_InvalidateCellFrame( *pBox );
+ --nRowSpan;
}
else
- nRowSpan = 1;
+ ++nRowSpan;
+ pBox->setRowSpan( nRowSpan );
}
- while( nRowSpan < 0 && nLinePos > 0 );
+ else
+ nRowSpan = 1;
}
+ while( nRowSpan < 0 && nLinePos > 0 );
}
}
}
@@ -2022,49 +2022,49 @@ void SwTable::RestoreRowSpan( const SwSaveRowSpan& rSave )
return;
sal_uInt16 nLineCount = GetTabLines().size();
OSL_ENSURE( rSave.mnSplitLine < nLineCount, "Restore behind last line?" );
- if( rSave.mnSplitLine < nLineCount )
+ if( rSave.mnSplitLine >= nLineCount )
+ return;
+
+ SwTableLine* pLine = GetTabLines()[rSave.mnSplitLine];
+ const size_t nColCount = pLine->GetTabBoxes().size();
+ OSL_ENSURE( nColCount, "Empty Table Line" );
+ OSL_ENSURE( nColCount == rSave.mnRowSpans.size(), "Wrong row span store" );
+ if( nColCount != rSave.mnRowSpans.size() )
+ return;
+
+ for( size_t nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
{
- SwTableLine* pLine = GetTabLines()[rSave.mnSplitLine];
- const size_t nColCount = pLine->GetTabBoxes().size();
- OSL_ENSURE( nColCount, "Empty Table Line" );
- OSL_ENSURE( nColCount == rSave.mnRowSpans.size(), "Wrong row span store" );
- if( nColCount == rSave.mnRowSpans.size() )
+ SwTableBox* pBox = pLine->GetTabBoxes()[nCurrCol];
+ OSL_ENSURE( pBox, "Missing Table Box" );
+ long nRowSp = pBox->getRowSpan();
+ if( nRowSp != rSave.mnRowSpans[ nCurrCol ] )
{
- for( size_t nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol )
+ OSL_ENSURE( -nRowSp == rSave.mnRowSpans[ nCurrCol ], "Pardon me?!" );
+ OSL_ENSURE( rSave.mnRowSpans[ nCurrCol ] < 0, "Pardon me?!" );
+ pBox->setRowSpan( -nRowSp );
+
+ sal_uInt16 nLine = rSave.mnSplitLine;
+ if( nLine )
{
- SwTableBox* pBox = pLine->GetTabBoxes()[nCurrCol];
- OSL_ENSURE( pBox, "Missing Table Box" );
- long nRowSp = pBox->getRowSpan();
- if( nRowSp != rSave.mnRowSpans[ nCurrCol ] )
+ long nLeftBorder = lcl_Box2LeftBorder( *pBox );
+ SwTableBox* pNext;
+ do
{
- OSL_ENSURE( -nRowSp == rSave.mnRowSpans[ nCurrCol ], "Pardon me?!" );
- OSL_ENSURE( rSave.mnRowSpans[ nCurrCol ] < 0, "Pardon me?!" );
- pBox->setRowSpan( -nRowSp );
-
- sal_uInt16 nLine = rSave.mnSplitLine;
- if( nLine )
+ pNext = lcl_LeftBorder2Box( nLeftBorder, GetTabLines()[--nLine] );
+ if( pNext )
{
- long nLeftBorder = lcl_Box2LeftBorder( *pBox );
- SwTableBox* pNext;
- do
+ pBox = pNext;
+ long nNewSpan = pBox->getRowSpan();
+ if( pBox->getRowSpan() < 1 )
+ nNewSpan -= nRowSp;
+ else
{
- pNext = lcl_LeftBorder2Box( nLeftBorder, GetTabLines()[--nLine] );
- if( pNext )
- {
- pBox = pNext;
- long nNewSpan = pBox->getRowSpan();
- if( pBox->getRowSpan() < 1 )
- nNewSpan -= nRowSp;
- else
- {
- nNewSpan += nRowSp;
- pNext = nullptr;
- }
- pBox->setRowSpan( nNewSpan );
- }
- } while( nLine && pNext );
+ nNewSpan += nRowSp;
+ pNext = nullptr;
+ }
+ pBox->setRowSpan( nNewSpan );
}
- }
+ } while( nLine && pNext );
}
}
}
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 69dbe1f9bfe1..b36b62a05a41 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -451,44 +451,44 @@ static void lcl_SortedTabColInsert( SwTabCols &rToFill, const SwTableBox *pBox,
else if ( bRefreshHidden )
::lcl_RefreshHidden( rToFill, nPos );
- if ( bHidden && !bRefreshHidden )
+ if ( !(bHidden && !bRefreshHidden) )
+ return;
+
+ // calculate minimum/maximum values for the existing entries:
+ nLeftMin = nPos - nLeftMin;
+ nRightMax = nPos + nRightMax;
+
+ // check if nPos is entry:
+ bool bFoundPos = false;
+ bool bFoundMax = false;
+ for ( size_t j = 0; !(bFoundPos && bFoundMax ) && j < rToFill.Count(); ++j )
{
- // calculate minimum/maximum values for the existing entries:
- nLeftMin = nPos - nLeftMin;
- nRightMax = nPos + nRightMax;
+ SwTabColsEntry& rEntry = rToFill.GetEntry( j );
+ long nCmp = rToFill[j];
- // check if nPos is entry:
- bool bFoundPos = false;
- bool bFoundMax = false;
- for ( size_t j = 0; !(bFoundPos && bFoundMax ) && j < rToFill.Count(); ++j )
+ if ( (nPos >= ((nCmp >= COLFUZZY) ? nCmp - COLFUZZY : nCmp)) &&
+ (nPos <= (nCmp + COLFUZZY)) )
{
- SwTabColsEntry& rEntry = rToFill.GetEntry( j );
- long nCmp = rToFill[j];
+ // check if nLeftMin is > old minimum for entry nPos:
+ const long nOldMin = rEntry.nMin;
+ if ( nLeftMin > nOldMin )
+ rEntry.nMin = nLeftMin;
+ // check if nRightMin is < old maximum for entry nPos:
+ const long nOldMax = rEntry.nMax;
+ if ( nRightMax < nOldMax )
+ rEntry.nMax = nRightMax;
- if ( (nPos >= ((nCmp >= COLFUZZY) ? nCmp - COLFUZZY : nCmp)) &&
- (nPos <= (nCmp + COLFUZZY)) )
- {
- // check if nLeftMin is > old minimum for entry nPos:
- const long nOldMin = rEntry.nMin;
- if ( nLeftMin > nOldMin )
- rEntry.nMin = nLeftMin;
- // check if nRightMin is < old maximum for entry nPos:
- const long nOldMax = rEntry.nMax;
- if ( nRightMax < nOldMax )
- rEntry.nMax = nRightMax;
-
- bFoundPos = true;
- }
- else if ( (nRightMax >= ((nCmp >= COLFUZZY) ? nCmp - COLFUZZY : nCmp)) &&
- (nRightMax <= (nCmp + COLFUZZY)) )
- {
- // check if nPos is > old minimum for entry nRightMax:
- const long nOldMin = rEntry.nMin;
- if ( nPos > nOldMin )
- rEntry.nMin = nPos;
+ bFoundPos = true;
+ }
+ else if ( (nRightMax >= ((nCmp >= COLFUZZY) ? nCmp - COLFUZZY : nCmp)) &&
+ (nRightMax <= (nCmp + COLFUZZY)) )
+ {
+ // check if nPos is > old minimum for entry nRightMax:
+ const long nOldMin = rEntry.nMin;
+ if ( nPos > nOldMin )
+ rEntry.nMin = nPos;
- bFoundMax = true;
- }
+ bFoundMax = true;
}
}
}
@@ -2571,25 +2571,25 @@ void SwTableBox::ActualiseValueBox()
{
const SfxPoolItem *pFormatItem, *pValItem;
SwFrameFormat* pFormat = GetFrameFormat();
- if( SfxItemState::SET == pFormat->GetItemState( RES_BOXATR_FORMAT, true, &pFormatItem )
- && SfxItemState::SET == pFormat->GetItemState( RES_BOXATR_VALUE, true, &pValItem ))
- {
- const sal_uLong nFormatId = static_cast<const SwTableBoxNumFormat*>(pFormatItem)->GetValue();
- sal_uLong nNdPos = ULONG_MAX;
- SvNumberFormatter* pNumFormatr = pFormat->GetDoc()->GetNumberFormatter();
+ if( SfxItemState::SET != pFormat->GetItemState( RES_BOXATR_FORMAT, true, &pFormatItem )
+ || SfxItemState::SET != pFormat->GetItemState( RES_BOXATR_VALUE, true, &pValItem ))
+ return;
- if( !pNumFormatr->IsTextFormat( nFormatId ) &&
- ULONG_MAX != (nNdPos = IsValidNumTextNd()) )
- {
- double fVal = static_cast<const SwTableBoxValue*>(pValItem)->GetValue();
- Color* pCol = nullptr;
- OUString sNewText;
- pNumFormatr->GetOutputString( fVal, nFormatId, sNewText, &pCol );
+ const sal_uLong nFormatId = static_cast<const SwTableBoxNumFormat*>(pFormatItem)->GetValue();
+ sal_uLong nNdPos = ULONG_MAX;
+ SvNumberFormatter* pNumFormatr = pFormat->GetDoc()->GetNumberFormatter();
- const OUString& rText = m_pStartNode->GetNodes()[ nNdPos ]->GetTextNode()->GetText();
- if( rText != sNewText )
- ChgTextToNum( *this, sNewText, pCol, false ,nNdPos);
- }
+ if( !pNumFormatr->IsTextFormat( nFormatId ) &&
+ ULONG_MAX != (nNdPos = IsValidNumTextNd()) )
+ {
+ double fVal = static_cast<const SwTableBoxValue*>(pValItem)->GetValue();
+ Color* pCol = nullptr;
+ OUString sNewText;
+ pNumFormatr->GetOutputString( fVal, nFormatId, sNewText, &pCol );
+
+ const OUString& rText = m_pStartNode->GetNodes()[ nNdPos ]->GetTextNode()->GetText();
+ if( rText != sNewText )
+ ChgTextToNum( *this, sNewText, pCol, false ,nNdPos);
}
}