summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-30 10:34:02 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-01 09:20:08 +0200
commitda64ad86e9f2dd66fbcecb46dcc22626e9f5a6a6 (patch)
tree6d566510d16fbf0d9525bde5ac435cf23c39fe48 /sw
parent5dccc6130242a67b6c471245d289cd4a0419602a (diff)
loplugin:flatten in sw/core/doc
Change-Id: If7738d47ec0273f24eee99b7336380cfa78c1243 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99896 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/DocumentChartDataProviderManager.cxx40
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx308
-rw-r--r--sw/source/core/doc/DocumentDeviceManager.cxx56
-rw-r--r--sw/source/core/doc/DocumentDrawModelManager.cxx26
-rw-r--r--sw/source/core/doc/DocumentFieldsManager.cxx62
-rw-r--r--sw/source/core/doc/DocumentRedlineManager.cxx120
-rw-r--r--sw/source/core/doc/DocumentSettingManager.cxx40
-rw-r--r--sw/source/core/doc/DocumentStatisticsManager.cxx22
-rw-r--r--sw/source/core/doc/acmplwrd.cxx28
-rw-r--r--sw/source/core/doc/doc.cxx140
-rw-r--r--sw/source/core/doc/docbm.cxx42
-rw-r--r--sw/source/core/doc/docchart.cxx24
-rw-r--r--sw/source/core/doc/doccomp.cxx204
-rw-r--r--sw/source/core/doc/docdesc.cxx48
-rw-r--r--sw/source/core/doc/docedt.cxx78
-rw-r--r--sw/source/core/doc/docfld.cxx70
-rw-r--r--sw/source/core/doc/docfmt.cxx68
-rw-r--r--sw/source/core/doc/doclay.cxx50
-rw-r--r--sw/source/core/doc/docnew.cxx34
-rw-r--r--sw/source/core/doc/docnum.cxx101
-rw-r--r--sw/source/core/doc/docredln.cxx184
-rw-r--r--sw/source/core/doc/docsort.cxx22
-rw-r--r--sw/source/core/doc/doctxm.cxx51
-rw-r--r--sw/source/core/doc/docxforms.cxx56
-rw-r--r--sw/source/core/doc/extinput.cxx287
-rw-r--r--sw/source/core/doc/fmtcol.cxx28
-rw-r--r--sw/source/core/doc/htmltbl.cxx491
-rw-r--r--sw/source/core/doc/notxtfrm.cxx72
-rw-r--r--sw/source/core/doc/number.cxx126
-rw-r--r--sw/source/core/doc/swserv.cxx152
-rw-r--r--sw/source/core/doc/tblafmt.cxx134
-rw-r--r--sw/source/core/doc/tblcpy.cxx236
-rw-r--r--sw/source/core/doc/tblrwcl.cxx96
-rw-r--r--sw/source/core/doc/textboxhelper.cxx578
-rw-r--r--sw/source/core/doc/visiturl.cxx78
35 files changed, 2076 insertions, 2076 deletions
diff --git a/sw/source/core/doc/DocumentChartDataProviderManager.cxx b/sw/source/core/doc/DocumentChartDataProviderManager.cxx
index 90785725e2dd..72640b4629d4 100644
--- a/sw/source/core/doc/DocumentChartDataProviderManager.cxx
+++ b/sw/source/core/doc/DocumentChartDataProviderManager.cxx
@@ -55,32 +55,32 @@ SwChartDataProvider * DocumentChartDataProviderManager::GetChartDataProvider( bo
void DocumentChartDataProviderManager::CreateChartInternalDataProviders( const SwTable *pTable )
{
- if (pTable)
+ if (!pTable)
+ return;
+
+ OUString aName( pTable->GetFrameFormat()->GetName() );
+ SwOLENode *pONd;
+ SwStartNode *pStNd;
+ SwNodeIndex aIdx( *m_rDoc.GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
+ while (nullptr != (pStNd = aIdx.GetNode().GetStartNode()))
{
- OUString aName( pTable->GetFrameFormat()->GetName() );
- SwOLENode *pONd;
- SwStartNode *pStNd;
- SwNodeIndex aIdx( *m_rDoc.GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
- while (nullptr != (pStNd = aIdx.GetNode().GetStartNode()))
+ ++aIdx;
+ pONd = aIdx.GetNode().GetOLENode();
+ if( pONd &&
+ aName == pONd->GetChartTableName() /* OLE node is chart? */ &&
+ nullptr != (pONd->getLayoutFrame( m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout() )) /* chart frame is not hidden */ )
{
- ++aIdx;
- pONd = aIdx.GetNode().GetOLENode();
- if( pONd &&
- aName == pONd->GetChartTableName() /* OLE node is chart? */ &&
- nullptr != (pONd->getLayoutFrame( m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout() )) /* chart frame is not hidden */ )
+ uno::Reference < embed::XEmbeddedObject > xIP = pONd->GetOLEObj().GetOleRef();
+ if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
{
- uno::Reference < embed::XEmbeddedObject > xIP = pONd->GetOLEObj().GetOleRef();
- if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) )
- {
- uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
- if (xChart.is())
- xChart->createInternalDataProvider( true );
+ uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
+ if (xChart.is())
+ xChart->createInternalDataProvider( true );
- // there may be more than one chart for each table thus we need to continue the loop...
- }
+ // there may be more than one chart for each table thus we need to continue the loop...
}
- aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
}
+ aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
}
}
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 434be7f7de7b..695057d342c2 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -335,86 +335,86 @@ namespace
{
const SwDoc* pSrcDoc = rPam.GetDoc();
const SwRedlineTable& rTable = pSrcDoc->getIDocumentRedlineAccess().GetRedlineTable();
- if( !rTable.empty() )
- {
- SwDoc* pDestDoc = rCpyPam.GetDoc();
- SwPosition* pCpyStt = rCpyPam.Start(), *pCpyEnd = rCpyPam.End();
- std::unique_ptr<SwPaM> pDelPam;
- const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
- // We have to count the "non-copied" nodes
- sal_uLong nDelCount;
- SwNodeIndex aCorrIdx(InitDelCount(rPam, nDelCount));
-
- SwRedlineTable::size_type n = 0;
- pSrcDoc->getIDocumentRedlineAccess().GetRedline( *pStt, &n );
- for( ; n < rTable.size(); ++n )
+ if( rTable.empty() )
+ return;
+
+ SwDoc* pDestDoc = rCpyPam.GetDoc();
+ SwPosition* pCpyStt = rCpyPam.Start(), *pCpyEnd = rCpyPam.End();
+ std::unique_ptr<SwPaM> pDelPam;
+ const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
+ // We have to count the "non-copied" nodes
+ sal_uLong nDelCount;
+ SwNodeIndex aCorrIdx(InitDelCount(rPam, nDelCount));
+
+ SwRedlineTable::size_type n = 0;
+ pSrcDoc->getIDocumentRedlineAccess().GetRedline( *pStt, &n );
+ for( ; n < rTable.size(); ++n )
+ {
+ const SwRangeRedline* pRedl = rTable[ n ];
+ if( RedlineType::Delete == pRedl->GetType() && pRedl->IsVisible() )
{
- const SwRangeRedline* pRedl = rTable[ n ];
- if( RedlineType::Delete == pRedl->GetType() && pRedl->IsVisible() )
- {
- const SwPosition *pRStt = pRedl->Start(), *pREnd = pRedl->End();
+ const SwPosition *pRStt = pRedl->Start(), *pREnd = pRedl->End();
- SwComparePosition eCmpPos = ComparePosition( *pStt, *pEnd, *pRStt, *pREnd );
- switch( eCmpPos )
- {
- case SwComparePosition::CollideEnd:
- case SwComparePosition::Before:
- // Pos1 is before Pos2
- break;
+ SwComparePosition eCmpPos = ComparePosition( *pStt, *pEnd, *pRStt, *pREnd );
+ switch( eCmpPos )
+ {
+ case SwComparePosition::CollideEnd:
+ case SwComparePosition::Before:
+ // Pos1 is before Pos2
+ break;
- case SwComparePosition::CollideStart:
- case SwComparePosition::Behind:
- // Pos1 is after Pos2
- n = rTable.size();
- break;
+ case SwComparePosition::CollideStart:
+ case SwComparePosition::Behind:
+ // Pos1 is after Pos2
+ n = rTable.size();
+ break;
- default:
+ default:
+ {
+ pDelPam.reset(new SwPaM( *pCpyStt, pDelPam.release() ));
+ if( *pStt < *pRStt )
{
- pDelPam.reset(new SwPaM( *pCpyStt, pDelPam.release() ));
- if( *pStt < *pRStt )
- {
- lcl_NonCopyCount( rPam, aCorrIdx, pRStt->nNode.GetIndex(), nDelCount );
- lcl_SetCpyPos( *pRStt, *pStt, *pCpyStt,
- *pDelPam->GetPoint(), nDelCount );
- }
- pDelPam->SetMark();
+ lcl_NonCopyCount( rPam, aCorrIdx, pRStt->nNode.GetIndex(), nDelCount );
+ lcl_SetCpyPos( *pRStt, *pStt, *pCpyStt,
+ *pDelPam->GetPoint(), nDelCount );
+ }
+ pDelPam->SetMark();
- if( *pEnd < *pREnd )
- *pDelPam->GetPoint() = *pCpyEnd;
- else
- {
- lcl_NonCopyCount( rPam, aCorrIdx, pREnd->nNode.GetIndex(), nDelCount );
- lcl_SetCpyPos( *pREnd, *pStt, *pCpyStt,
- *pDelPam->GetPoint(), nDelCount );
- }
+ if( *pEnd < *pREnd )
+ *pDelPam->GetPoint() = *pCpyEnd;
+ else
+ {
+ lcl_NonCopyCount( rPam, aCorrIdx, pREnd->nNode.GetIndex(), nDelCount );
+ lcl_SetCpyPos( *pREnd, *pStt, *pCpyStt,
+ *pDelPam->GetPoint(), nDelCount );
+ }
- if (pDelPam->GetNext() && *pDelPam->GetNext()->End() == *pDelPam->Start())
- {
- *pDelPam->GetNext()->End() = *pDelPam->End();
- pDelPam.reset(pDelPam->GetNext());
- }
+ if (pDelPam->GetNext() && *pDelPam->GetNext()->End() == *pDelPam->Start())
+ {
+ *pDelPam->GetNext()->End() = *pDelPam->End();
+ pDelPam.reset(pDelPam->GetNext());
}
}
}
}
+ }
- if( pDelPam )
- {
- RedlineFlags eOld = pDestDoc->getIDocumentRedlineAccess().GetRedlineFlags();
- pDestDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld | RedlineFlags::Ignore );
+ if( !pDelPam )
+ return;
- ::sw::UndoGuard const undoGuard(pDestDoc->GetIDocumentUndoRedo());
+ RedlineFlags eOld = pDestDoc->getIDocumentRedlineAccess().GetRedlineFlags();
+ pDestDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld | RedlineFlags::Ignore );
- do {
- pDestDoc->getIDocumentContentOperations().DeleteAndJoin( *pDelPam->GetNext() );
- if( !pDelPam->IsMultiSelection() )
- break;
- delete pDelPam->GetNext();
- } while( true );
+ ::sw::UndoGuard const undoGuard(pDestDoc->GetIDocumentUndoRedo());
- pDestDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
- }
- }
+ do {
+ pDestDoc->getIDocumentContentOperations().DeleteAndJoin( *pDelPam->GetNext() );
+ if( !pDelPam->IsMultiSelection() )
+ break;
+ delete pDelPam->GetNext();
+ } while( true );
+
+ pDestDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
}
void lcl_DeleteRedlines( const SwNodeRange& rRg, SwNodeRange const & rCpyRg )
@@ -2948,23 +2948,23 @@ void DocumentContentOperationsManager::ReRead( SwPaM& rPam, const OUString& rGrf
const OUString& rFltName, const Graphic* pGraphic )
{
SwGrfNode *pGrfNd;
- if( ( !rPam.HasMark()
+ if( !(( !rPam.HasMark()
|| rPam.GetPoint()->nNode.GetIndex() == rPam.GetMark()->nNode.GetIndex() )
- && nullptr != ( pGrfNd = rPam.GetPoint()->nNode.GetNode().GetGrfNode() ) )
+ && nullptr != ( pGrfNd = rPam.GetPoint()->nNode.GetNode().GetGrfNode() )) )
+ return;
+
+ if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
{
- if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
- {
- m_rDoc.GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoReRead>(rPam, *pGrfNd));
- }
+ m_rDoc.GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoReRead>(rPam, *pGrfNd));
+ }
- // Because we don't know if we can mirror the graphic, the mirror attribute is always reset
- if( MirrorGraph::Dont != pGrfNd->GetSwAttrSet().
- GetMirrorGrf().GetValue() )
- pGrfNd->SetAttr( SwMirrorGrf() );
+ // Because we don't know if we can mirror the graphic, the mirror attribute is always reset
+ if( MirrorGraph::Dont != pGrfNd->GetSwAttrSet().
+ GetMirrorGrf().GetValue() )
+ pGrfNd->SetAttr( SwMirrorGrf() );
- pGrfNd->ReRead( rGrfName, rFltName, pGraphic );
- m_rDoc.getIDocumentState().SetModified();
- }
+ pGrfNd->ReRead( rGrfName, rFltName, pGraphic );
+ m_rDoc.getIDocumentState().SetModified();
}
// Insert drawing object, which has to be already inserted in the DrawModel
@@ -3399,28 +3399,28 @@ void DocumentContentOperationsManager::InsertItemSet ( const SwPaM &rRg, const S
void DocumentContentOperationsManager::RemoveLeadingWhiteSpace(const SwPosition & rPos )
{
const SwTextNode* pTNd = rPos.nNode.GetNode().GetTextNode();
- if ( pTNd )
+ if ( !pTNd )
+ return;
+
+ const OUString& rText = pTNd->GetText();
+ sal_Int32 nIdx = 0;
+ while (nIdx < rText.getLength())
{
- const OUString& rText = pTNd->GetText();
- sal_Int32 nIdx = 0;
- while (nIdx < rText.getLength())
+ sal_Unicode const cCh = rText[nIdx];
+ if (('\t' != cCh) && (' ' != cCh))
{
- sal_Unicode const cCh = rText[nIdx];
- if (('\t' != cCh) && (' ' != cCh))
- {
- break;
- }
- ++nIdx;
+ break;
}
+ ++nIdx;
+ }
- if ( nIdx > 0 )
- {
- SwPaM aPam(rPos);
- aPam.GetPoint()->nContent = 0;
- aPam.SetMark();
- aPam.GetMark()->nContent = nIdx;
- DeleteRange( aPam );
- }
+ if ( nIdx > 0 )
+ {
+ SwPaM aPam(rPos);
+ aPam.GetPoint()->nContent = 0;
+ aPam.SetMark();
+ aPam.GetMark()->nContent = nIdx;
+ DeleteRange( aPam );
}
}
@@ -3798,41 +3798,41 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
// Rebuild as much as possible of all chains that are available in the original,
OSL_ENSURE( aSet.size() == aVecSwFrameFormat.size(), "Missing new Flys" );
- if ( aSet.size() == aVecSwFrameFormat.size() )
+ if ( aSet.size() != aVecSwFrameFormat.size() )
+ return;
+
+ size_t n = 0;
+ for (const auto& rFlyN : aSet)
{
- size_t n = 0;
- for (const auto& rFlyN : aSet)
+ const SwFrameFormat *pFormatN = rFlyN.GetFormat();
+ const SwFormatChain &rChain = pFormatN->GetChain();
+ int nCnt = int(nullptr != rChain.GetPrev());
+ nCnt += rChain.GetNext() ? 1: 0;
+ size_t k = 0;
+ for (const auto& rFlyK : aSet)
{
- const SwFrameFormat *pFormatN = rFlyN.GetFormat();
- const SwFormatChain &rChain = pFormatN->GetChain();
- int nCnt = int(nullptr != rChain.GetPrev());
- nCnt += rChain.GetNext() ? 1: 0;
- size_t k = 0;
- for (const auto& rFlyK : aSet)
+ const SwFrameFormat *pFormatK = rFlyK.GetFormat();
+ if ( rChain.GetPrev() == pFormatK )
{
- const SwFrameFormat *pFormatK = rFlyK.GetFormat();
- if ( rChain.GetPrev() == pFormatK )
- {
- ::lcl_ChainFormats( static_cast< SwFlyFrameFormat* >(aVecSwFrameFormat[k]),
- static_cast< SwFlyFrameFormat* >(aVecSwFrameFormat[n]) );
- --nCnt;
- }
- else if ( rChain.GetNext() == pFormatK )
- {
- ::lcl_ChainFormats( static_cast< SwFlyFrameFormat* >(aVecSwFrameFormat[n]),
- static_cast< SwFlyFrameFormat* >(aVecSwFrameFormat[k]) );
- --nCnt;
- }
- ++k;
+ ::lcl_ChainFormats( static_cast< SwFlyFrameFormat* >(aVecSwFrameFormat[k]),
+ static_cast< SwFlyFrameFormat* >(aVecSwFrameFormat[n]) );
+ --nCnt;
+ }
+ else if ( rChain.GetNext() == pFormatK )
+ {
+ ::lcl_ChainFormats( static_cast< SwFlyFrameFormat* >(aVecSwFrameFormat[n]),
+ static_cast< SwFlyFrameFormat* >(aVecSwFrameFormat[k]) );
+ --nCnt;
}
- ++n;
+ ++k;
}
-
- // Re-create content property of draw formats, knowing how old shapes
- // were paired with old fly formats (aOldTextBoxes) and that aSet is
- // parallel with aVecSwFrameFormat.
- SwTextBoxHelper::restoreLinks(aSet, aVecSwFrameFormat, aOldTextBoxes, aOldContent);
+ ++n;
}
+
+ // Re-create content property of draw formats, knowing how old shapes
+ // were paired with old fly formats (aOldTextBoxes) and that aSet is
+ // parallel with aVecSwFrameFormat.
+ SwTextBoxHelper::restoreLinks(aSet, aVecSwFrameFormat, aOldTextBoxes, aOldContent);
}
/*
@@ -4550,20 +4550,20 @@ static void lcl_PushNumruleState(
// Safe numrule item at destination.
// #i86492# - Safe also <ListId> item of destination.
const SfxItemSet * pAttrSet = pDestTextNd->GetpSwAttrSet();
- if (pAttrSet != nullptr)
+ if (pAttrSet == nullptr)
+ return;
+
+ const SfxPoolItem * pItem = nullptr;
+ aNumRuleState = pAttrSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem);
+ if (SfxItemState::SET == aNumRuleState)
{
- const SfxPoolItem * pItem = nullptr;
- aNumRuleState = pAttrSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem);
- if (SfxItemState::SET == aNumRuleState)
- {
- aNumRuleItem.reset(static_cast<SwNumRuleItem*>(pItem->Clone()));
- }
+ aNumRuleItem.reset(static_cast<SwNumRuleItem*>(pItem->Clone()));
+ }
- aListIdState = pAttrSet->GetItemState(RES_PARATR_LIST_ID, false, &pItem);
- if (SfxItemState::SET == aListIdState)
- {
- aListIdItem.reset(static_cast<SfxStringItem*>(pItem->Clone()));
- }
+ aListIdState = pAttrSet->GetItemState(RES_PARATR_LIST_ID, false, &pItem);
+ if (SfxItemState::SET == aListIdState)
+ {
+ aListIdItem.reset(static_cast<SfxStringItem*>(pItem->Clone()));
}
}
@@ -4575,24 +4575,24 @@ static void lcl_PopNumruleState(
/* If only a part of one paragraph is copied
restore the numrule at the destination. */
// #i86492# - restore also <ListId> item
- if ( !lcl_MarksWholeNode(rPam) )
+ if ( lcl_MarksWholeNode(rPam) )
+ return;
+
+ if (SfxItemState::SET == aNumRuleState)
{
- if (SfxItemState::SET == aNumRuleState)
- {
- pDestTextNd->SetAttr(*aNumRuleItem);
- }
- else
- {
- pDestTextNd->ResetAttr(RES_PARATR_NUMRULE);
- }
- if (SfxItemState::SET == aListIdState)
- {
- pDestTextNd->SetAttr(*aListIdItem);
- }
- else
- {
- pDestTextNd->ResetAttr(RES_PARATR_LIST_ID);
- }
+ pDestTextNd->SetAttr(*aNumRuleItem);
+ }
+ else
+ {
+ pDestTextNd->ResetAttr(RES_PARATR_NUMRULE);
+ }
+ if (SfxItemState::SET == aListIdState)
+ {
+ pDestTextNd->SetAttr(*aListIdItem);
+ }
+ else
+ {
+ pDestTextNd->ResetAttr(RES_PARATR_LIST_ID);
}
}
diff --git a/sw/source/core/doc/DocumentDeviceManager.cxx b/sw/source/core/doc/DocumentDeviceManager.cxx
index 18da1249341c..5dadd15d2130 100644
--- a/sw/source/core/doc/DocumentDeviceManager.cxx
+++ b/sw/source/core/doc/DocumentDeviceManager.cxx
@@ -143,38 +143,38 @@ OutputDevice* DocumentDeviceManager::getReferenceDevice(/*[in]*/ bool bCreate )
void DocumentDeviceManager::setReferenceDeviceType(/*[in]*/ bool bNewVirtual, /*[in]*/ bool bNewHiRes )
{
- if ( m_rDoc.GetDocumentSettingManager().get(DocumentSettingId::USE_VIRTUAL_DEVICE) != bNewVirtual ||
- m_rDoc.GetDocumentSettingManager().get(DocumentSettingId::USE_HIRES_VIRTUAL_DEVICE) != bNewHiRes )
- {
- if ( bNewVirtual )
- {
- VirtualDevice* pMyVirDev = getVirtualDevice( true );
- if ( !bNewHiRes )
- pMyVirDev->SetReferenceDevice( VirtualDevice::RefDevMode::Dpi600 );
- else
- pMyVirDev->SetReferenceDevice( VirtualDevice::RefDevMode::MSO1 );
+ if ( m_rDoc.GetDocumentSettingManager().get(DocumentSettingId::USE_VIRTUAL_DEVICE) == bNewVirtual &&
+ m_rDoc.GetDocumentSettingManager().get(DocumentSettingId::USE_HIRES_VIRTUAL_DEVICE) == bNewHiRes )
+ return;
- if( m_rDoc.getIDocumentDrawModelAccess().GetDrawModel() )
- m_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->SetRefDevice( pMyVirDev );
- }
+ if ( bNewVirtual )
+ {
+ VirtualDevice* pMyVirDev = getVirtualDevice( true );
+ if ( !bNewHiRes )
+ pMyVirDev->SetReferenceDevice( VirtualDevice::RefDevMode::Dpi600 );
else
- {
- // #i41075#
- // We have to take care that a printer exists before calling
- // PrtDataChanged() in order to prevent that PrtDataChanged()
- // triggers this funny situation:
- // getReferenceDevice()->getPrinter()->CreatePrinter_()
- // ->setPrinter()-> PrtDataChanged()
- SfxPrinter* pPrinter = getPrinter( true );
- if( m_rDoc.getIDocumentDrawModelAccess().GetDrawModel() )
- m_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->SetRefDevice( pPrinter );
- }
+ pMyVirDev->SetReferenceDevice( VirtualDevice::RefDevMode::MSO1 );
- m_rDoc.GetDocumentSettingManager().set(DocumentSettingId::USE_VIRTUAL_DEVICE, bNewVirtual );
- m_rDoc.GetDocumentSettingManager().set(DocumentSettingId::USE_HIRES_VIRTUAL_DEVICE, bNewHiRes );
- PrtDataChanged();
- m_rDoc.getIDocumentState().SetModified();
+ if( m_rDoc.getIDocumentDrawModelAccess().GetDrawModel() )
+ m_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->SetRefDevice( pMyVirDev );
+ }
+ else
+ {
+ // #i41075#
+ // We have to take care that a printer exists before calling
+ // PrtDataChanged() in order to prevent that PrtDataChanged()
+ // triggers this funny situation:
+ // getReferenceDevice()->getPrinter()->CreatePrinter_()
+ // ->setPrinter()-> PrtDataChanged()
+ SfxPrinter* pPrinter = getPrinter( true );
+ if( m_rDoc.getIDocumentDrawModelAccess().GetDrawModel() )
+ m_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->SetRefDevice( pPrinter );
}
+
+ m_rDoc.GetDocumentSettingManager().set(DocumentSettingId::USE_VIRTUAL_DEVICE, bNewVirtual );
+ m_rDoc.GetDocumentSettingManager().set(DocumentSettingId::USE_HIRES_VIRTUAL_DEVICE, bNewHiRes );
+ PrtDataChanged();
+ m_rDoc.getIDocumentState().SetModified();
}
const JobSetup* DocumentDeviceManager::getJobsetup() const
diff --git a/sw/source/core/doc/DocumentDrawModelManager.cxx b/sw/source/core/doc/DocumentDrawModelManager.cxx
index ef1aa1a29d65..57ecf006d278 100644
--- a/sw/source/core/doc/DocumentDrawModelManager.cxx
+++ b/sw/source/core/doc/DocumentDrawModelManager.cxx
@@ -131,21 +131,21 @@ void DocumentDrawModelManager::InitDrawModel()
mpDrawModel->SetNotifyUndoActionHdl( std::bind( &SwDoc::AddDrawUndo, &m_rDoc, std::placeholders::_1 ));
SwViewShell* const pSh = m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell();
- if ( pSh )
+ if ( !pSh )
+ return;
+
+ for(const SwViewShell& rViewSh : pSh->GetRingContainer())
{
- for(const SwViewShell& rViewSh : pSh->GetRingContainer())
+ SwRootFrame* pRoot = rViewSh.GetLayout();
+ if( pRoot && !pRoot->GetDrawPage() )
{
- SwRootFrame* pRoot = rViewSh.GetLayout();
- if( pRoot && !pRoot->GetDrawPage() )
- {
- // Disable "multiple layout" for the moment:
- // use pMasterPage instead of a new created SdrPage
- // mpDrawModel->AllocPage( FALSE );
- // mpDrawModel->InsertPage( pDrawPage );
- SdrPage* pDrawPage = pMasterPage;
- pRoot->SetDrawPage( pDrawPage );
- pDrawPage->SetSize( pRoot->getFrameArea().SSize() );
- }
+ // Disable "multiple layout" for the moment:
+ // use pMasterPage instead of a new created SdrPage
+ // mpDrawModel->AllocPage( FALSE );
+ // mpDrawModel->InsertPage( pDrawPage );
+ SdrPage* pDrawPage = pMasterPage;
+ pRoot->SetDrawPage( pDrawPage );
+ pDrawPage->SetSize( pRoot->getFrameArea().SSize() );
}
}
}
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index af90f08f8270..c77e93aa00c9 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -343,43 +343,43 @@ void DocumentFieldsManager::RemoveFieldType(size_t nField)
/*
* Dependent fields present -> ErrRaise
*/
- if(nField < mpFieldTypes->size())
- {
- SwFieldType* pTmp = (*mpFieldTypes)[nField].get();
+ if(nField >= mpFieldTypes->size())
+ return;
- // JP 29.07.96: Optionally prepare FieldList for Calculator
- SwFieldIds nWhich = pTmp->Which();
- switch( nWhich )
- {
- case SwFieldIds::SetExp:
- case SwFieldIds::User:
- mpUpdateFields->RemoveFieldType( *pTmp );
- [[fallthrough]];
- case SwFieldIds::Dde:
- if( pTmp->HasWriterListeners() && !m_rDoc.IsUsed( *pTmp ) )
- {
- if( SwFieldIds::SetExp == nWhich )
- static_cast<SwSetExpFieldType*>(pTmp)->SetDeleted( true );
- else if( SwFieldIds::User == nWhich )
- static_cast<SwUserFieldType*>(pTmp)->SetDeleted( true );
- else
- static_cast<SwDDEFieldType*>(pTmp)->SetDeleted( true );
- nWhich = SwFieldIds::Database;
- }
- break;
- default: break;
- }
+ SwFieldType* pTmp = (*mpFieldTypes)[nField].get();
- if( nWhich != SwFieldIds::Database )
+ // JP 29.07.96: Optionally prepare FieldList for Calculator
+ SwFieldIds nWhich = pTmp->Which();
+ switch( nWhich )
+ {
+ case SwFieldIds::SetExp:
+ case SwFieldIds::User:
+ mpUpdateFields->RemoveFieldType( *pTmp );
+ [[fallthrough]];
+ case SwFieldIds::Dde:
+ if( pTmp->HasWriterListeners() && !m_rDoc.IsUsed( *pTmp ) )
{
- OSL_ENSURE( !pTmp->HasWriterListeners(), "Dependent fields present!" );
+ if( SwFieldIds::SetExp == nWhich )
+ static_cast<SwSetExpFieldType*>(pTmp)->SetDeleted( true );
+ else if( SwFieldIds::User == nWhich )
+ static_cast<SwUserFieldType*>(pTmp)->SetDeleted( true );
+ else
+ static_cast<SwDDEFieldType*>(pTmp)->SetDeleted( true );
+ nWhich = SwFieldIds::Database;
}
- else
- (*mpFieldTypes)[nField].release(); // DB fields are ref-counted and delete themselves
+ break;
+ default: break;
+ }
- mpFieldTypes->erase( mpFieldTypes->begin() + nField );
- m_rDoc.getIDocumentState().SetModified();
+ if( nWhich != SwFieldIds::Database )
+ {
+ OSL_ENSURE( !pTmp->HasWriterListeners(), "Dependent fields present!" );
}
+ else
+ (*mpFieldTypes)[nField].release(); // DB fields are ref-counted and delete themselves
+
+ mpFieldTypes->erase( mpFieldTypes->begin() + nField );
+ m_rDoc.getIDocumentState().SetModified();
}
// All have to be re-evaluated.
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 143e20e21005..52bd17fd5230 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -957,81 +957,81 @@ RedlineFlags DocumentRedlineManager::GetRedlineFlags() const
void DocumentRedlineManager::SetRedlineFlags( RedlineFlags eMode )
{
- if( meRedlineFlags != eMode )
+ if( meRedlineFlags == eMode )
+ return;
+
+ if( (RedlineFlags::ShowMask & meRedlineFlags) != (RedlineFlags::ShowMask & eMode)
+ || !(RedlineFlags::ShowMask & eMode) )
{
- if( (RedlineFlags::ShowMask & meRedlineFlags) != (RedlineFlags::ShowMask & eMode)
- || !(RedlineFlags::ShowMask & eMode) )
+ bool bSaveInXMLImportFlag = m_rDoc.IsInXMLImport();
+ m_rDoc.SetInXMLImport( false );
+ // and then hide/display everything
+ void (SwRangeRedline::*pFnc)(sal_uInt16, size_t); // Allow compiler warn if use of
+ // uninitialized ptr is possible
+
+ RedlineFlags eShowMode = RedlineFlags::ShowMask & eMode;
+ if (eShowMode == (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete))
+ pFnc = &SwRangeRedline::Show;
+ else if (eShowMode == RedlineFlags::ShowInsert)
+ pFnc = &SwRangeRedline::Hide;
+ else if (eShowMode == RedlineFlags::ShowDelete)
+ pFnc = &SwRangeRedline::ShowOriginal;
+ else
{
- bool bSaveInXMLImportFlag = m_rDoc.IsInXMLImport();
- m_rDoc.SetInXMLImport( false );
- // and then hide/display everything
- void (SwRangeRedline::*pFnc)(sal_uInt16, size_t); // Allow compiler warn if use of
- // uninitialized ptr is possible
-
- RedlineFlags eShowMode = RedlineFlags::ShowMask & eMode;
- if (eShowMode == (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete))
- pFnc = &SwRangeRedline::Show;
- else if (eShowMode == RedlineFlags::ShowInsert)
- pFnc = &SwRangeRedline::Hide;
- else if (eShowMode == RedlineFlags::ShowDelete)
- pFnc = &SwRangeRedline::ShowOriginal;
- else
- {
- pFnc = &SwRangeRedline::Hide;
- eMode |= RedlineFlags::ShowInsert;
- }
+ pFnc = &SwRangeRedline::Hide;
+ eMode |= RedlineFlags::ShowInsert;
+ }
- CheckAnchoredFlyConsistency(m_rDoc);
- CHECK_REDLINE( *this )
+ CheckAnchoredFlyConsistency(m_rDoc);
+ CHECK_REDLINE( *this )
- o3tl::sorted_vector<SwRootFrame *> hiddenLayouts;
- if (eShowMode == (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete))
+ o3tl::sorted_vector<SwRootFrame *> hiddenLayouts;
+ if (eShowMode == (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete))
+ {
+ // sw_redlinehide: the problem here is that MoveFromSection
+ // creates the frames wrongly (non-merged), because its own
+ // SwRangeRedline has wrong positions until after the nodes
+ // are all moved, so fix things up by force by re-creating
+ // all merged frames from scratch.
+ o3tl::sorted_vector<SwRootFrame *> const layouts(m_rDoc.GetAllLayouts());
+ for (SwRootFrame *const pLayout : layouts)
{
- // sw_redlinehide: the problem here is that MoveFromSection
- // creates the frames wrongly (non-merged), because its own
- // SwRangeRedline has wrong positions until after the nodes
- // are all moved, so fix things up by force by re-creating
- // all merged frames from scratch.
- o3tl::sorted_vector<SwRootFrame *> const layouts(m_rDoc.GetAllLayouts());
- for (SwRootFrame *const pLayout : layouts)
+ if (pLayout->IsHideRedlines())
{
- if (pLayout->IsHideRedlines())
- {
- pLayout->SetHideRedlines(false);
- hiddenLayouts.insert(pLayout);
- }
+ pLayout->SetHideRedlines(false);
+ hiddenLayouts.insert(pLayout);
}
}
+ }
- for (sal_uInt16 nLoop = 1; nLoop <= 2; ++nLoop)
- for (size_t i = 0; i < mpRedlineTable->size(); ++i)
- {
- SwRangeRedline *const pRedline((*mpRedlineTable)[i]);
- (pRedline->*pFnc)(nLoop, i);
- while (mpRedlineTable->size() <= i
- || (*mpRedlineTable)[i] != pRedline)
- { // ensure current position
- --i; // a previous redline may have been deleted
- }
+ for (sal_uInt16 nLoop = 1; nLoop <= 2; ++nLoop)
+ for (size_t i = 0; i < mpRedlineTable->size(); ++i)
+ {
+ SwRangeRedline *const pRedline((*mpRedlineTable)[i]);
+ (pRedline->*pFnc)(nLoop, i);
+ while (mpRedlineTable->size() <= i
+ || (*mpRedlineTable)[i] != pRedline)
+ { // ensure current position
+ --i; // a previous redline may have been deleted
}
+ }
- //SwRangeRedline::MoveFromSection routinely changes
- //the keys that mpRedlineTable is sorted by
- mpRedlineTable->Resort();
-
- CheckAnchoredFlyConsistency(m_rDoc);
- CHECK_REDLINE( *this )
+ //SwRangeRedline::MoveFromSection routinely changes
+ //the keys that mpRedlineTable is sorted by
+ mpRedlineTable->Resort();
- for (SwRootFrame *const pLayout : hiddenLayouts)
- {
- pLayout->SetHideRedlines(true);
- }
+ CheckAnchoredFlyConsistency(m_rDoc);
+ CHECK_REDLINE( *this )
- m_rDoc.SetInXMLImport( bSaveInXMLImportFlag );
+ for (SwRootFrame *const pLayout : hiddenLayouts)
+ {
+ pLayout->SetHideRedlines(true);
}
- meRedlineFlags = eMode;
- m_rDoc.getIDocumentState().SetModified();
+
+ m_rDoc.SetInXMLImport( bSaveInXMLImportFlag );
}
+ meRedlineFlags = eMode;
+ m_rDoc.getIDocumentState().SetModified();
// #TODO - add 'SwExtraRedlineTable' also ?
}
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index 09f0d5efb2cc..843b6067f3c6 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -571,28 +571,28 @@ CharCompressType sw::DocumentSettingManager::getCharacterCompressionType() const
void sw::DocumentSettingManager::setCharacterCompressionType( /*[in]*/CharCompressType n )
{
- if( meChrCmprType != n )
+ if( meChrCmprType == n )
+ return;
+
+ meChrCmprType = n;
+
+ SdrModel *pDrawModel = m_rDoc.getIDocumentDrawModelAccess().GetDrawModel();
+ if( pDrawModel )
{
- meChrCmprType = n;
-
- SdrModel *pDrawModel = m_rDoc.getIDocumentDrawModelAccess().GetDrawModel();
- if( pDrawModel )
- {
- pDrawModel->SetCharCompressType( n );
- if( !m_rDoc.IsInReading() )
- pDrawModel->ReformatAllTextObjects();
- }
-
- SwRootFrame* pTmpRoot = m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout();
- if( pTmpRoot && !m_rDoc.IsInReading() )
- {
- pTmpRoot->StartAllAction();
- for( auto aLayout : m_rDoc.GetAllLayouts() )
- aLayout->InvalidateAllContent(SwInvalidateFlags::Size);
- pTmpRoot->EndAllAction();
- }
- m_rDoc.getIDocumentState().SetModified();
+ pDrawModel->SetCharCompressType( n );
+ if( !m_rDoc.IsInReading() )
+ pDrawModel->ReformatAllTextObjects();
}
+
+ SwRootFrame* pTmpRoot = m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout();
+ if( pTmpRoot && !m_rDoc.IsInReading() )
+ {
+ pTmpRoot->StartAllAction();
+ for( auto aLayout : m_rDoc.GetAllLayouts() )
+ aLayout->InvalidateAllContent(SwInvalidateFlags::Size);
+ pTmpRoot->EndAllAction();
+ }
+ m_rDoc.getIDocumentState().SetModified();
}
diff --git a/sw/source/core/doc/DocumentStatisticsManager.cxx b/sw/source/core/doc/DocumentStatisticsManager.cxx
index 9508e6d7216c..03e00df6ceee 100644
--- a/sw/source/core/doc/DocumentStatisticsManager.cxx
+++ b/sw/source/core/doc/DocumentStatisticsManager.cxx
@@ -86,19 +86,19 @@ void DocumentStatisticsManager::SetDocStat( const SwDocStat& rStat )
void DocumentStatisticsManager::UpdateDocStat( bool bCompleteAsync, bool bFields )
{
- if( mpDocStat->bModified || !mbInitialized)
+ if( !(mpDocStat->bModified || !mbInitialized))
+ return;
+
+ if (!bCompleteAsync)
{
- if (!bCompleteAsync)
- {
- maStatsUpdateIdle.Stop();
- while (IncrementalDocStatCalculate(
- std::numeric_limits<long>::max(), bFields)) {}
- }
- else if (IncrementalDocStatCalculate(5000, bFields))
- maStatsUpdateIdle.Start();
- else
- maStatsUpdateIdle.Stop();
+ maStatsUpdateIdle.Stop();
+ while (IncrementalDocStatCalculate(
+ std::numeric_limits<long>::max(), bFields)) {}
}
+ else if (IncrementalDocStatCalculate(5000, bFields))
+ maStatsUpdateIdle.Start();
+ else
+ maStatsUpdateIdle.Stop();
}
// returns true while there is more to do
diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx
index b256c50658a1..720dfd6c9120 100644
--- a/sw/source/core/doc/acmplwrd.cxx
+++ b/sw/source/core/doc/acmplwrd.cxx
@@ -361,22 +361,22 @@ void SwAutoCompleteWord::CheckChangedList(
}
}
// remove the elements at the end of the array
- if( nMyPos < nMyLen )
+ if( nMyPos >= nMyLen )
+ return;
+
+ // clear LRU array first then delete the string object
+ for( ; nNewPos < nMyLen; ++nNewPos )
{
- // clear LRU array first then delete the string object
- for( ; nNewPos < nMyLen; ++nNewPos )
- {
- SwAutoCompleteString *const pDel =
- dynamic_cast<SwAutoCompleteString*>(m_WordList[nNewPos]);
- SwAutoCompleteStringPtrDeque::iterator it = std::find( m_aLRUList.begin(), m_aLRUList.end(), pDel );
- OSL_ENSURE( m_aLRUList.end() != it, "String not found" );
- m_aLRUList.erase( it );
- delete pDel;
- }
- // remove from array
- m_WordList.erase(m_WordList.begin() + nMyPos,
- m_WordList.begin() + nMyLen);
+ SwAutoCompleteString *const pDel =
+ dynamic_cast<SwAutoCompleteString*>(m_WordList[nNewPos]);
+ SwAutoCompleteStringPtrDeque::iterator it = std::find( m_aLRUList.begin(), m_aLRUList.end(), pDel );
+ OSL_ENSURE( m_aLRUList.end() != it, "String not found" );
+ m_aLRUList.erase( it );
+ delete pDel;
}
+ // remove from array
+ m_WordList.erase(m_WordList.begin() + nMyPos,
+ m_WordList.begin() + nMyLen);
}
void SwAutoCompleteWord::DocumentDying(const SwDoc& rDoc)
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index b51e957810b3..f560de2e7238 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1185,20 +1185,20 @@ void SwDoc::SpellItAgainSam( bool bInvalid, bool bOnlyWrong, bool bSmartTags )
void SwDoc::InvalidateAutoCompleteFlag()
{
SwRootFrame* pTmpRoot = getIDocumentLayoutAccess().GetCurrentLayout();
- if( pTmpRoot )
- {
- o3tl::sorted_vector<SwRootFrame*> aAllLayouts = GetAllLayouts();
- for( auto aLayout : aAllLayouts )
- aLayout->AllInvalidateAutoCompleteWords();
- for( sal_uLong nNd = 1, nCnt = GetNodes().Count(); nNd < nCnt; ++nNd )
- {
- SwTextNode* pTextNode = GetNodes()[ nNd ]->GetTextNode();
- if ( pTextNode ) pTextNode->SetAutoCompleteWordDirty( true );
- }
+ if( !pTmpRoot )
+ return;
- for( auto aLayout : aAllLayouts )
- aLayout->SetIdleFlags();
+ o3tl::sorted_vector<SwRootFrame*> aAllLayouts = GetAllLayouts();
+ for( auto aLayout : aAllLayouts )
+ aLayout->AllInvalidateAutoCompleteWords();
+ for( sal_uLong nNd = 1, nCnt = GetNodes().Count(); nNd < nCnt; ++nNd )
+ {
+ SwTextNode* pTextNode = GetNodes()[ nNd ]->GetTextNode();
+ if ( pTextNode ) pTextNode->SetAutoCompleteWordDirty( true );
}
+
+ for( auto aLayout : aAllLayouts )
+ aLayout->SetIdleFlags();
}
const SwFormatINetFormat* SwDoc::FindINetAttr( const OUString& rName ) const
@@ -1223,73 +1223,73 @@ const SwFormatINetFormat* SwDoc::FindINetAttr( const OUString& rName ) const
void SwDoc::Summary( SwDoc* pExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress )
{
const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds();
- if( pExtDoc && !rOutNds.empty() )
+ if( !(pExtDoc && !rOutNds.empty()) )
+ return;
+
+ ::StartProgress( STR_STATSTR_SUMMARY, 0, rOutNds.size(), GetDocShell() );
+ SwNodeIndex aEndOfDoc( pExtDoc->GetNodes().GetEndOfContent(), -1 );
+ for( SwOutlineNodes::size_type i = 0; i < rOutNds.size(); ++i )
{
- ::StartProgress( STR_STATSTR_SUMMARY, 0, rOutNds.size(), GetDocShell() );
- SwNodeIndex aEndOfDoc( pExtDoc->GetNodes().GetEndOfContent(), -1 );
- for( SwOutlineNodes::size_type i = 0; i < rOutNds.size(); ++i )
+ ::SetProgressState( static_cast<long>(i), GetDocShell() );
+ const sal_uLong nIndex = rOutNds[ i ]->GetIndex();
+
+ const int nLvl = GetNodes()[ nIndex ]->GetTextNode()->GetAttrOutlineLevel()-1;
+ if( nLvl > nLevel )
+ continue;
+ long nEndOfs = 1;
+ sal_uInt8 nWish = nPara;
+ sal_uLong nNextOutNd = i + 1 < rOutNds.size() ?
+ rOutNds[ i + 1 ]->GetIndex() : GetNodes().Count();
+ bool bKeep = false;
+ while( ( nWish || bKeep ) && nIndex + nEndOfs < nNextOutNd &&
+ GetNodes()[ nIndex + nEndOfs ]->IsTextNode() )
{
- ::SetProgressState( static_cast<long>(i), GetDocShell() );
- const sal_uLong nIndex = rOutNds[ i ]->GetIndex();
+ SwTextNode* pTextNode = GetNodes()[ nIndex+nEndOfs ]->GetTextNode();
+ if (pTextNode->GetText().getLength() && nWish)
+ --nWish;
+ bKeep = pTextNode->GetSwAttrSet().GetKeep().GetValue();
+ ++nEndOfs;
+ }
- const int nLvl = GetNodes()[ nIndex ]->GetTextNode()->GetAttrOutlineLevel()-1;
- if( nLvl > nLevel )
- continue;
- long nEndOfs = 1;
- sal_uInt8 nWish = nPara;
- sal_uLong nNextOutNd = i + 1 < rOutNds.size() ?
- rOutNds[ i + 1 ]->GetIndex() : GetNodes().Count();
- bool bKeep = false;
- while( ( nWish || bKeep ) && nIndex + nEndOfs < nNextOutNd &&
- GetNodes()[ nIndex + nEndOfs ]->IsTextNode() )
+ SwNodeRange aRange( *rOutNds[ i ], 0, *rOutNds[ i ], nEndOfs );
+ GetNodes().Copy_( aRange, aEndOfDoc );
+ }
+ const SwTextFormatColls *pColl = pExtDoc->GetTextFormatColls();
+ for( SwTextFormatColls::size_type i = 0; i < pColl->size(); ++i )
+ (*pColl)[ i ]->ResetFormatAttr( RES_PAGEDESC, RES_BREAK );
+ SwNodeIndex aIndx( pExtDoc->GetNodes().GetEndOfExtras() );
+ ++aEndOfDoc;
+ while( aIndx < aEndOfDoc )
+ {
+ bool bDelete = false;
+ SwNode *pNode = &aIndx.GetNode();
+ if( pNode->IsTextNode() )
+ {
+ SwTextNode *pNd = pNode->GetTextNode();
+ if( pNd->HasSwAttrSet() )
+ pNd->ResetAttr( RES_PAGEDESC, RES_BREAK );
+ if( bImpress )
{
- SwTextNode* pTextNode = GetNodes()[ nIndex+nEndOfs ]->GetTextNode();
- if (pTextNode->GetText().getLength() && nWish)
- --nWish;
- bKeep = pTextNode->GetSwAttrSet().GetKeep().GetValue();
- ++nEndOfs;
+ SwTextFormatColl* pMyColl = pNd->GetTextColl();
+
+ const sal_uInt16 nHeadLine = static_cast<sal_uInt16>(
+ !pMyColl->IsAssignedToListLevelOfOutlineStyle()
+ ? RES_POOLCOLL_HEADLINE2
+ : RES_POOLCOLL_HEADLINE1 );
+ pMyColl = pExtDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( nHeadLine );
+ pNd->ChgFormatColl( pMyColl );
}
-
- SwNodeRange aRange( *rOutNds[ i ], 0, *rOutNds[ i ], nEndOfs );
- GetNodes().Copy_( aRange, aEndOfDoc );
- }
- const SwTextFormatColls *pColl = pExtDoc->GetTextFormatColls();
- for( SwTextFormatColls::size_type i = 0; i < pColl->size(); ++i )
- (*pColl)[ i ]->ResetFormatAttr( RES_PAGEDESC, RES_BREAK );
- SwNodeIndex aIndx( pExtDoc->GetNodes().GetEndOfExtras() );
- ++aEndOfDoc;
- while( aIndx < aEndOfDoc )
- {
- bool bDelete = false;
- SwNode *pNode = &aIndx.GetNode();
- if( pNode->IsTextNode() )
+ if( !pNd->Len() &&
+ pNd->StartOfSectionIndex()+2 < pNd->EndOfSectionIndex() )
{
- SwTextNode *pNd = pNode->GetTextNode();
- if( pNd->HasSwAttrSet() )
- pNd->ResetAttr( RES_PAGEDESC, RES_BREAK );
- if( bImpress )
- {
- SwTextFormatColl* pMyColl = pNd->GetTextColl();
-
- const sal_uInt16 nHeadLine = static_cast<sal_uInt16>(
- !pMyColl->IsAssignedToListLevelOfOutlineStyle()
- ? RES_POOLCOLL_HEADLINE2
- : RES_POOLCOLL_HEADLINE1 );
- pMyColl = pExtDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( nHeadLine );
- pNd->ChgFormatColl( pMyColl );
- }
- if( !pNd->Len() &&
- pNd->StartOfSectionIndex()+2 < pNd->EndOfSectionIndex() )
- {
- bDelete = true;
- pExtDoc->GetNodes().Delete( aIndx );
- }
+ bDelete = true;
+ pExtDoc->GetNodes().Delete( aIndx );
}
- if( !bDelete )
- ++aIndx;
}
- ::EndProgress( GetDocShell() );
+ if( !bDelete )
+ ++aIndx;
}
+ ::EndProgress( GetDocShell() );
}
namespace
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 429c2e1129f6..002582c6cb4a 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1759,29 +1759,29 @@ void SaveBookmark::SetInDoc(
else
aPam.GetPoint()->nContent.Assign(aPam.GetContentNode(), m_nContent1);
- if(!aPam.HasMark()
- || CheckNodesRange(aPam.GetPoint()->nNode, aPam.GetMark()->nNode, true))
+ if(!(!aPam.HasMark()
+ || CheckNodesRange(aPam.GetPoint()->nNode, aPam.GetMark()->nNode, true)))
+ return;
+
+ ::sw::mark::IBookmark* const pBookmark = dynamic_cast<::sw::mark::IBookmark*>(
+ pDoc->getIDocumentMarkAccess()->makeMark(aPam, m_aName,
+ m_eOrigBkmType, sw::mark::InsertMode::New));
+ if(!pBookmark)
+ return;
+
+ pBookmark->SetKeyCode(m_aCode);
+ pBookmark->SetShortName(m_aShortName);
+ pBookmark->Hide(m_bHidden);
+ pBookmark->SetHideCondition(m_aHideCondition);
+
+ if (m_pMetadataUndo)
{
- ::sw::mark::IBookmark* const pBookmark = dynamic_cast<::sw::mark::IBookmark*>(
- pDoc->getIDocumentMarkAccess()->makeMark(aPam, m_aName,
- m_eOrigBkmType, sw::mark::InsertMode::New));
- if(pBookmark)
+ ::sfx2::Metadatable * const pMeta(
+ dynamic_cast< ::sfx2::Metadatable* >(pBookmark));
+ assert(pMeta && "metadata undo, but not metadatable?");
+ if (pMeta)
{
- pBookmark->SetKeyCode(m_aCode);
- pBookmark->SetShortName(m_aShortName);
- pBookmark->Hide(m_bHidden);
- pBookmark->SetHideCondition(m_aHideCondition);
-
- if (m_pMetadataUndo)
- {
- ::sfx2::Metadatable * const pMeta(
- dynamic_cast< ::sfx2::Metadatable* >(pBookmark));
- assert(pMeta && "metadata undo, but not metadatable?");
- if (pMeta)
- {
- pMeta->RestoreMetadata(m_pMetadataUndo);
- }
- }
+ pMeta->RestoreMetadata(m_pMetadataUndo);
}
}
}
diff --git a/sw/source/core/doc/docchart.cxx b/sw/source/core/doc/docchart.cxx
index 4acfb511949a..0e2cef59555b 100644
--- a/sw/source/core/doc/docchart.cxx
+++ b/sw/source/core/doc/docchart.cxx
@@ -78,19 +78,19 @@ bool SwTable::IsTableComplexForChart( const OUString& rSelection ) const
void SwDoc::DoUpdateAllCharts()
{
SwViewShell* pVSh = getIDocumentLayoutAccess().GetCurrentViewShell();
- if( pVSh )
+ if( !pVSh )
+ return;
+
+ const SwFrameFormats& rTableFormats = *GetTableFrameFormats();
+ for( size_t n = 0; n < rTableFormats.size(); ++n )
{
- const SwFrameFormats& rTableFormats = *GetTableFrameFormats();
- for( size_t n = 0; n < rTableFormats.size(); ++n )
- {
- const SwFrameFormat* pFormat = rTableFormats[ n ];
- if( SwTable* pTmpTable = SwTable::FindTable( pFormat ) )
- if( const SwTableNode* pTableNd = pTmpTable->GetTableNode() )
- if( pTableNd->GetNodes().IsDocNodes() )
- {
- UpdateCharts_( *pTmpTable, *pVSh );
- }
- }
+ const SwFrameFormat* pFormat = rTableFormats[ n ];
+ if( SwTable* pTmpTable = SwTable::FindTable( pFormat ) )
+ if( const SwTableNode* pTableNd = pTmpTable->GetTableNode() )
+ if( pTableNd->GetNodes().IsDocNodes() )
+ {
+ UpdateCharts_( *pTmpTable, *pVSh );
+ }
}
}
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 279fbdeb4c54..149f2e1eb518 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -543,32 +543,32 @@ Hash::Hash( sal_uLong nSize )
void Hash::CalcHashValue( CompareData& rData )
{
- if( m_pHashArr )
+ if( !m_pHashArr )
+ return;
+
+ for( size_t n = 0; n < rData.GetLineCount(); ++n )
{
- for( size_t n = 0; n < rData.GetLineCount(); ++n )
- {
- const SwCompareLine* pLine = rData.GetLine( n );
- OSL_ENSURE( pLine, "where is the line?" );
- sal_uLong nH = pLine->GetHashValue();
-
- sal_uLong* pFound = &m_pHashArr[ nH % m_nPrime ];
- size_t i;
- for( i = *pFound; ; i = m_pDataArr[i].nNext )
- if( !i )
- {
- i = m_nCount++;
- m_pDataArr[i].nNext = *pFound;
- m_pDataArr[i].nHash = nH;
- m_pDataArr[i].pLine = pLine;
- *pFound = i;
- break;
- }
- else if( m_pDataArr[i].nHash == nH &&
- m_pDataArr[i].pLine->Compare( *pLine ))
- break;
+ const SwCompareLine* pLine = rData.GetLine( n );
+ OSL_ENSURE( pLine, "where is the line?" );
+ sal_uLong nH = pLine->GetHashValue();
- rData.SetIndex( n, i );
- }
+ sal_uLong* pFound = &m_pHashArr[ nH % m_nPrime ];
+ size_t i;
+ for( i = *pFound; ; i = m_pDataArr[i].nNext )
+ if( !i )
+ {
+ i = m_nCount++;
+ m_pDataArr[i].nNext = *pFound;
+ m_pDataArr[i].nHash = nH;
+ m_pDataArr[i].pLine = pLine;
+ *pFound = i;
+ break;
+ }
+ else if( m_pDataArr[i].nHash == nH &&
+ m_pDataArr[i].pLine->Compare( *pLine ))
+ break;
+
+ rData.SetIndex( n, i );
}
}
@@ -1703,82 +1703,82 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo )
}
pTmp = m_pInsertRing.get();
- if( pTmp )
- {
- do {
- if( pTmp->GetPoint()->nContent == 0 )
- {
- ++pTmp->GetPoint()->nNode;
- pTmp->GetPoint()->nContent.Assign( pTmp->GetContentNode(), 0 );
- }
- // #i101009#
- // prevent redlines that end on structural end node
- if (& GetEndOfContent() ==
- & pTmp->GetPoint()->nNode.GetNode())
- {
- --pTmp->GetPoint()->nNode;
- SwContentNode *const pContentNode( pTmp->GetContentNode() );
- pTmp->GetPoint()->nContent.Assign( pContentNode,
- pContentNode ? pContentNode->Len() : 0 );
- // tdf#106218 try to avoid losing a paragraph break here:
- if (pTmp->GetMark()->nContent == 0)
- {
- SwNodeIndex const prev(pTmp->GetMark()->nNode, -1);
- if (prev.GetNode().IsTextNode())
- {
- *pTmp->GetMark() = SwPosition(
- *prev.GetNode().GetTextNode(),
- prev.GetNode().GetTextNode()->Len());
- }
- }
- }
- } while( m_pInsertRing.get() != ( pTmp = pTmp->GetNext()) );
- SwRedlineData aRedlnData( RedlineType::Insert, nAuthor, aTimeStamp,
- OUString(), nullptr );
+ if( !pTmp )
+ return;
- // combine consecutive
- if( pTmp->GetNext() != m_pInsertRing.get() )
+ do {
+ if( pTmp->GetPoint()->nContent == 0 )
{
- do {
- SwPosition& rSttEnd = *pTmp->End(),
- & rEndStt = *pTmp->GetNext()->Start();
- const SwContentNode* pCNd;
- if( rSttEnd == rEndStt ||
- (!rEndStt.nContent.GetIndex() &&
- rEndStt.nNode.GetIndex() - 1 == rSttEnd.nNode.GetIndex() &&
- nullptr != ( pCNd = rSttEnd.nNode.GetNode().GetContentNode() ) &&
- rSttEnd.nContent.GetIndex() == pCNd->Len()))
+ ++pTmp->GetPoint()->nNode;
+ pTmp->GetPoint()->nContent.Assign( pTmp->GetContentNode(), 0 );
+ }
+ // #i101009#
+ // prevent redlines that end on structural end node
+ if (& GetEndOfContent() ==
+ & pTmp->GetPoint()->nNode.GetNode())
+ {
+ --pTmp->GetPoint()->nNode;
+ SwContentNode *const pContentNode( pTmp->GetContentNode() );
+ pTmp->GetPoint()->nContent.Assign( pContentNode,
+ pContentNode ? pContentNode->Len() : 0 );
+ // tdf#106218 try to avoid losing a paragraph break here:
+ if (pTmp->GetMark()->nContent == 0)
+ {
+ SwNodeIndex const prev(pTmp->GetMark()->nNode, -1);
+ if (prev.GetNode().IsTextNode())
{
- if( pTmp->GetNext() == m_pInsertRing.get() )
- {
- // are consecutive, so combine
- rEndStt = *pTmp->Start();
- delete pTmp;
- pTmp = m_pInsertRing.get();
- }
- else
- {
- // are consecutive, so combine
- rSttEnd = *pTmp->GetNext()->End();
- delete pTmp->GetNext();
- }
+ *pTmp->GetMark() = SwPosition(
+ *prev.GetNode().GetTextNode(),
+ prev.GetNode().GetTextNode()->Len());
}
- else
- pTmp = pTmp->GetNext();
- } while( m_pInsertRing.get() != pTmp );
+ }
}
+ } while( m_pInsertRing.get() != ( pTmp = pTmp->GetNext()) );
+ SwRedlineData aRedlnData( RedlineType::Insert, nAuthor, aTimeStamp,
+ OUString(), nullptr );
+ // combine consecutive
+ if( pTmp->GetNext() != m_pInsertRing.get() )
+ {
do {
- if (IDocumentRedlineAccess::AppendResult::APPENDED ==
- m_rDoc.getIDocumentRedlineAccess().AppendRedline(
- new SwRangeRedline(aRedlnData, *pTmp), true) &&
- m_rDoc.GetIDocumentUndoRedo().DoesUndo())
+ SwPosition& rSttEnd = *pTmp->End(),
+ & rEndStt = *pTmp->GetNext()->Start();
+ const SwContentNode* pCNd;
+ if( rSttEnd == rEndStt ||
+ (!rEndStt.nContent.GetIndex() &&
+ rEndStt.nNode.GetIndex() - 1 == rSttEnd.nNode.GetIndex() &&
+ nullptr != ( pCNd = rSttEnd.nNode.GetNode().GetContentNode() ) &&
+ rSttEnd.nContent.GetIndex() == pCNd->Len()))
{
- m_rDoc.GetIDocumentUndoRedo().AppendUndo(
- std::make_unique<SwUndoCompDoc>( *pTmp, true ));
+ if( pTmp->GetNext() == m_pInsertRing.get() )
+ {
+ // are consecutive, so combine
+ rEndStt = *pTmp->Start();
+ delete pTmp;
+ pTmp = m_pInsertRing.get();
+ }
+ else
+ {
+ // are consecutive, so combine
+ rSttEnd = *pTmp->GetNext()->End();
+ delete pTmp->GetNext();
+ }
}
- } while( m_pInsertRing.get() != ( pTmp = pTmp->GetNext()) );
+ else
+ pTmp = pTmp->GetNext();
+ } while( m_pInsertRing.get() != pTmp );
}
+
+ do {
+ if (IDocumentRedlineAccess::AppendResult::APPENDED ==
+ m_rDoc.getIDocumentRedlineAccess().AppendRedline(
+ new SwRangeRedline(aRedlnData, *pTmp), true) &&
+ m_rDoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rDoc.GetIDocumentUndoRedo().AppendUndo(
+ std::make_unique<SwUndoCompDoc>( *pTmp, true ));
+ }
+ } while( m_pInsertRing.get() != ( pTmp = pTmp->GetNext()) );
}
typedef std::shared_ptr<CompareData> CompareDataPtr;
@@ -1924,19 +1924,19 @@ SaveMergeRedline::SaveMergeRedline( const SwNode& rDstNd,
aPos.nContent.Assign( const_cast<SwContentNode*>(static_cast<const SwContentNode*>(&rDstNd)), pStt->nContent.GetIndex() );
pDestRedl = new SwRangeRedline( rSrcRedl.GetRedlineData(), aPos );
- if( RedlineType::Delete == pDestRedl->GetType() )
- {
- // mark the area as deleted
- const SwPosition* pEnd = pStt == rSrcRedl.GetPoint()
- ? rSrcRedl.GetMark()
- : rSrcRedl.GetPoint();
+ if( RedlineType::Delete != pDestRedl->GetType() )
+ return;
- pDestRedl->SetMark();
- pDestRedl->GetPoint()->nNode += pEnd->nNode.GetIndex() -
- pStt->nNode.GetIndex();
- pDestRedl->GetPoint()->nContent.Assign( pDestRedl->GetContentNode(),
- pEnd->nContent.GetIndex() );
- }
+ // mark the area as deleted
+ const SwPosition* pEnd = pStt == rSrcRedl.GetPoint()
+ ? rSrcRedl.GetMark()
+ : rSrcRedl.GetPoint();
+
+ pDestRedl->SetMark();
+ pDestRedl->GetPoint()->nNode += pEnd->nNode.GetIndex() -
+ pStt->nNode.GetIndex();
+ pDestRedl->GetPoint()->nContent.Assign( pDestRedl->GetContentNode(),
+ pEnd->nContent.GetIndex() );
}
sal_uInt16 SaveMergeRedline::InsertRedline(SwPaM* pLastDestRedline)
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 036185e88d7d..e63097b29279 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -770,36 +770,36 @@ void SwDoc::PrtOLENotify( bool bAll )
IMPL_LINK_NOARG( SwDoc, DoUpdateModifiedOLE, Timer *, void )
{
SwFEShell* pSh = static_cast<SwFEShell*>(GetEditShell());
- if( pSh )
- {
- mbOLEPrtNotifyPending = mbAllOLENotify = false;
+ if( !pSh )
+ return;
- std::unique_ptr<SwOLENodes> pNodes = SwContentNode::CreateOLENodesArray( *GetDfltGrfFormatColl(), true );
- if( pNodes )
- {
- ::StartProgress( STR_STATSTR_SWGPRTOLENOTIFY,
- 0, pNodes->size(), GetDocShell());
- getIDocumentLayoutAccess().GetCurrentLayout()->StartAllAction();
- SwMsgPoolItem aMsgHint( RES_UPDATE_ATTR );
+ mbOLEPrtNotifyPending = mbAllOLENotify = false;
- for( SwOLENodes::size_type i = 0; i < pNodes->size(); ++i )
- {
- ::SetProgressState( i, GetDocShell() );
+ std::unique_ptr<SwOLENodes> pNodes = SwContentNode::CreateOLENodesArray( *GetDfltGrfFormatColl(), true );
+ if( !pNodes )
+ return;
- SwOLENode* pOLENd = (*pNodes)[i];
- pOLENd->SetOLESizeInvalid( false );
+ ::StartProgress( STR_STATSTR_SWGPRTOLENOTIFY,
+ 0, pNodes->size(), GetDocShell());
+ getIDocumentLayoutAccess().GetCurrentLayout()->StartAllAction();
+ SwMsgPoolItem aMsgHint( RES_UPDATE_ATTR );
- // We don't know it, so the object has to be loaded.
- // If it doesn't want to be informed
- if( pOLENd->GetOLEObj().GetOleRef().is() ) // Broken?
- {
- pOLENd->ModifyNotification( &aMsgHint, &aMsgHint );
- }
- }
- getIDocumentLayoutAccess().GetCurrentLayout()->EndAllAction();
- ::EndProgress( GetDocShell() );
+ for( SwOLENodes::size_type i = 0; i < pNodes->size(); ++i )
+ {
+ ::SetProgressState( i, GetDocShell() );
+
+ SwOLENode* pOLENd = (*pNodes)[i];
+ pOLENd->SetOLESizeInvalid( false );
+
+ // We don't know it, so the object has to be loaded.
+ // If it doesn't want to be informed
+ if( pOLENd->GetOLEObj().GetOleRef().is() ) // Broken?
+ {
+ pOLENd->ModifyNotification( &aMsgHint, &aMsgHint );
}
}
+ getIDocumentLayoutAccess().GetCurrentLayout()->EndAllAction();
+ ::EndProgress( GetDocShell() );
}
static SwPageDesc* lcl_FindPageDesc( const SwPageDescs *pPageDescs,
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 07902efe3fd4..ceb7ada2f865 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -264,23 +264,23 @@ SaveRedlEndPosForRestore::SaveRedlEndPosForRestore( const SwNodeIndex& rInsIdx,
{
SwNode& rNd = rInsIdx.GetNode();
SwDoc* pDest = rNd.GetDoc();
- if( !pDest->getIDocumentRedlineAccess().GetRedlineTable().empty() )
+ if( pDest->getIDocumentRedlineAccess().GetRedlineTable().empty() )
+ return;
+
+ SwRedlineTable::size_type nFndPos;
+ const SwPosition* pEnd;
+ SwPosition aSrcPos( rInsIdx, SwIndex( rNd.GetContentNode(), nCnt ));
+ pDest->getIDocumentRedlineAccess().GetRedline( aSrcPos, &nFndPos );
+ const SwRangeRedline* pRedl;
+ while( nFndPos--
+ && *( pEnd = ( pRedl = pDest->getIDocumentRedlineAccess().GetRedlineTable()[ nFndPos ] )->End() ) == aSrcPos
+ && *pRedl->Start() < aSrcPos )
{
- SwRedlineTable::size_type nFndPos;
- const SwPosition* pEnd;
- SwPosition aSrcPos( rInsIdx, SwIndex( rNd.GetContentNode(), nCnt ));
- pDest->getIDocumentRedlineAccess().GetRedline( aSrcPos, &nFndPos );
- const SwRangeRedline* pRedl;
- while( nFndPos--
- && *( pEnd = ( pRedl = pDest->getIDocumentRedlineAccess().GetRedlineTable()[ nFndPos ] )->End() ) == aSrcPos
- && *pRedl->Start() < aSrcPos )
+ if( !mpSaveIndex )
{
- if( !mpSaveIndex )
- {
- mpSaveIndex.reset(new SwNodeIndex( rInsIdx, -1 ));
- }
- mvSavArr.push_back( const_cast<SwPosition*>(pEnd) );
+ mpSaveIndex.reset(new SwNodeIndex( rInsIdx, -1 ));
}
+ mvSavArr.push_back( const_cast<SwPosition*>(pEnd) );
}
}
@@ -328,31 +328,31 @@ void sw_GetJoinFlags( SwPaM& rPam, bool& rJoinText, bool& rJoinPrev )
{
rJoinText = false;
rJoinPrev = false;
- if( rPam.GetPoint()->nNode != rPam.GetMark()->nNode )
- {
- const SwPosition* pStt = rPam.Start(), *pEnd = rPam.End();
- SwTextNode *pSttNd = pStt->nNode.GetNode().GetTextNode();
- if( pSttNd )
- {
- SwTextNode *pEndNd = pEnd->nNode.GetNode().GetTextNode();
- rJoinText = nullptr != pEndNd;
- if( rJoinText )
- {
- bool bExchange = pStt == rPam.GetPoint();
- if( !pStt->nContent.GetIndex() &&
- pEndNd->GetText().getLength() != pEnd->nContent.GetIndex())
- bExchange = !bExchange;
- if( bExchange )
- rPam.Exchange();
- rJoinPrev = rPam.GetPoint() == pStt;
- OSL_ENSURE( !pStt->nContent.GetIndex() &&
- pEndNd->GetText().getLength() != pEnd->nContent.GetIndex()
- ? (rPam.GetPoint()->nNode < rPam.GetMark()->nNode)
- : (rPam.GetPoint()->nNode > rPam.GetMark()->nNode),
- "sw_GetJoinFlags");
- }
- }
- }
+ if( rPam.GetPoint()->nNode == rPam.GetMark()->nNode )
+ return;
+
+ const SwPosition* pStt = rPam.Start(), *pEnd = rPam.End();
+ SwTextNode *pSttNd = pStt->nNode.GetNode().GetTextNode();
+ if( !pSttNd )
+ return;
+
+ SwTextNode *pEndNd = pEnd->nNode.GetNode().GetTextNode();
+ rJoinText = nullptr != pEndNd;
+ if( !rJoinText )
+ return;
+
+ bool bExchange = pStt == rPam.GetPoint();
+ if( !pStt->nContent.GetIndex() &&
+ pEndNd->GetText().getLength() != pEnd->nContent.GetIndex())
+ bExchange = !bExchange;
+ if( bExchange )
+ rPam.Exchange();
+ rJoinPrev = rPam.GetPoint() == pStt;
+ OSL_ENSURE( !pStt->nContent.GetIndex() &&
+ pEndNd->GetText().getLength() != pEnd->nContent.GetIndex()
+ ? (rPam.GetPoint()->nNode < rPam.GetMark()->nNode)
+ : (rPam.GetPoint()->nNode > rPam.GetMark()->nNode),
+ "sw_GetJoinFlags");
}
bool sw_JoinText( SwPaM& rPam, bool bJoinPrev )
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 7d4691a3422c..57f976d27e5b 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -1094,21 +1094,21 @@ void SwDocUpdateField::InsertFieldType( const SwFieldType& rType )
OSL_ENSURE( false, "No valid field type" );
}
- if( !sFieldName.isEmpty() )
- {
- SetFieldsDirty( true );
- // look up and remove from the hash table
- sFieldName = GetAppCharClass().lowercase( sFieldName );
- sal_uInt16 n;
+ if( sFieldName.isEmpty() )
+ return;
+
+ SetFieldsDirty( true );
+ // look up and remove from the hash table
+ sFieldName = GetAppCharClass().lowercase( sFieldName );
+ sal_uInt16 n;
- SwCalcFieldType* pFnd = GetFieldTypeTable().Find( sFieldName, &n );
+ SwCalcFieldType* pFnd = GetFieldTypeTable().Find( sFieldName, &n );
- if( !pFnd )
- {
- SwCalcFieldType* pNew = new SwCalcFieldType( sFieldName, &rType );
- pNew->pNext.reset( m_FieldTypeTable[n].release() );
- m_FieldTypeTable[n].reset(pNew);
- }
+ if( !pFnd )
+ {
+ SwCalcFieldType* pNew = new SwCalcFieldType( sFieldName, &rType );
+ pNew->pNext.reset( m_FieldTypeTable[n].release() );
+ m_FieldTypeTable[n].reset(pNew);
}
}
@@ -1126,29 +1126,29 @@ void SwDocUpdateField::RemoveFieldType( const SwFieldType& rType )
default: break;
}
- if( !sFieldName.isEmpty() )
- {
- SetFieldsDirty( true );
- // look up and remove from the hash table
- sFieldName = GetAppCharClass().lowercase( sFieldName );
- sal_uInt16 n;
+ if( sFieldName.isEmpty() )
+ return;
- SwCalcFieldType* pFnd = GetFieldTypeTable().Find( sFieldName, &n );
- if( pFnd )
- {
- if (m_FieldTypeTable[n].get() == pFnd)
- {
- m_FieldTypeTable[n].reset(static_cast<SwCalcFieldType*>(pFnd->pNext.release()));
- }
- else
- {
- SwHash* pPrev = m_FieldTypeTable[n].get();
- while( pPrev->pNext.get() != pFnd )
- pPrev = pPrev->pNext.get();
- pPrev->pNext = std::move(pFnd->pNext);
- // no need to explicitly delete here, the embedded linked list uses unique_ptr
- }
- }
+ SetFieldsDirty( true );
+ // look up and remove from the hash table
+ sFieldName = GetAppCharClass().lowercase( sFieldName );
+ sal_uInt16 n;
+
+ SwCalcFieldType* pFnd = GetFieldTypeTable().Find( sFieldName, &n );
+ if( !pFnd )
+ return;
+
+ if (m_FieldTypeTable[n].get() == pFnd)
+ {
+ m_FieldTypeTable[n].reset(static_cast<SwCalcFieldType*>(pFnd->pNext.release()));
+ }
+ else
+ {
+ SwHash* pPrev = m_FieldTypeTable[n].get();
+ while( pPrev->pNext.get() != pFnd )
+ pPrev = pPrev->pNext.get();
+ pPrev->pNext = std::move(pFnd->pNext);
+ // no need to explicitly delete here, the embedded linked list uses unique_ptr
}
}
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index dfab43445940..b0d5f00dfd40 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1364,45 +1364,45 @@ void SwDoc::CopyPageDescHeaderFooterImpl( bool bCpyHeader,
else
pOldFormat = static_cast<SwFormatFooter*>(pNewItem.get())->GetFooterFormat();
- if( pOldFormat )
- {
- SwFrameFormat* pNewFormat = new SwFrameFormat( GetAttrPool(), "CpyDesc",
- GetDfltFrameFormat() );
- pNewFormat->CopyAttrs( *pOldFormat );
+ if( !pOldFormat )
+ return;
+
+ SwFrameFormat* pNewFormat = new SwFrameFormat( GetAttrPool(), "CpyDesc",
+ GetDfltFrameFormat() );
+ pNewFormat->CopyAttrs( *pOldFormat );
- if( SfxItemState::SET == pNewFormat->GetAttrSet().GetItemState(
- RES_CNTNT, false, &pItem ))
+ if( SfxItemState::SET == pNewFormat->GetAttrSet().GetItemState(
+ RES_CNTNT, false, &pItem ))
+ {
+ const SwFormatContent* pContent = static_cast<const SwFormatContent*>(pItem);
+ if( pContent->GetContentIdx() )
{
- const SwFormatContent* pContent = static_cast<const SwFormatContent*>(pItem);
- if( pContent->GetContentIdx() )
- {
- SwNodeIndex aTmpIdx( GetNodes().GetEndOfAutotext() );
- const SwNodes& rSrcNds = rSrcFormat.GetDoc()->GetNodes();
- SwStartNode* pSttNd = SwNodes::MakeEmptySection( aTmpIdx,
- bCpyHeader
- ? SwHeaderStartNode
- : SwFooterStartNode );
- const SwNode& rCSttNd = pContent->GetContentIdx()->GetNode();
- SwNodeRange aRg( rCSttNd, 0, *rCSttNd.EndOfSectionNode() );
- aTmpIdx = *pSttNd->EndOfSectionNode();
- rSrcNds.Copy_( aRg, aTmpIdx );
- aTmpIdx = *pSttNd;
- rSrcFormat.GetDoc()->GetDocumentContentOperationsManager().CopyFlyInFlyImpl(aRg, nullptr, aTmpIdx);
- // TODO: investigate calling CopyWithFlyInFly?
- SwPaM const source(aRg.aStart, aRg.aEnd);
- SwPosition dest(aTmpIdx);
- sw::CopyBookmarks(source, dest);
- pNewFormat->SetFormatAttr( SwFormatContent( pSttNd ));
- }
- else
- pNewFormat->ResetFormatAttr( RES_CNTNT );
+ SwNodeIndex aTmpIdx( GetNodes().GetEndOfAutotext() );
+ const SwNodes& rSrcNds = rSrcFormat.GetDoc()->GetNodes();
+ SwStartNode* pSttNd = SwNodes::MakeEmptySection( aTmpIdx,
+ bCpyHeader
+ ? SwHeaderStartNode
+ : SwFooterStartNode );
+ const SwNode& rCSttNd = pContent->GetContentIdx()->GetNode();
+ SwNodeRange aRg( rCSttNd, 0, *rCSttNd.EndOfSectionNode() );
+ aTmpIdx = *pSttNd->EndOfSectionNode();
+ rSrcNds.Copy_( aRg, aTmpIdx );
+ aTmpIdx = *pSttNd;
+ rSrcFormat.GetDoc()->GetDocumentContentOperationsManager().CopyFlyInFlyImpl(aRg, nullptr, aTmpIdx);
+ // TODO: investigate calling CopyWithFlyInFly?
+ SwPaM const source(aRg.aStart, aRg.aEnd);
+ SwPosition dest(aTmpIdx);
+ sw::CopyBookmarks(source, dest);
+ pNewFormat->SetFormatAttr( SwFormatContent( pSttNd ));
}
- if( bCpyHeader )
- static_cast<SwFormatHeader*>(pNewItem.get())->RegisterToFormat(*pNewFormat);
else
- static_cast<SwFormatFooter*>(pNewItem.get())->RegisterToFormat(*pNewFormat);
- rDestFormat.SetFormatAttr( *pNewItem );
+ pNewFormat->ResetFormatAttr( RES_CNTNT );
}
+ if( bCpyHeader )
+ static_cast<SwFormatHeader*>(pNewItem.get())->RegisterToFormat(*pNewFormat);
+ else
+ static_cast<SwFormatFooter*>(pNewItem.get())->RegisterToFormat(*pNewFormat);
+ rDestFormat.SetFormatAttr( *pNewItem );
}
void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc,
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index af02d317d284..61108557a752 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -1290,18 +1290,18 @@ static void lcl_collectUsedNums(std::vector<unsigned int>& rSetFlags, sal_Int32
lcl_collectUsedNums(rSetFlags, nNmLen, sName, rCmpName);
// tdf#122487 take groups into account, iterate and recurse through their
// contents for name collision check
- if (rObj.IsGroupObject())
+ if (!rObj.IsGroupObject())
+ return;
+
+ const SdrObjList* pSub(rObj.GetSubList());
+ assert(pSub && "IsGroupObject is implemented as GetSubList != nullptr");
+ const size_t nCount = pSub->GetObjCount();
+ for (size_t i = 0; i < nCount; ++i)
{
- const SdrObjList* pSub(rObj.GetSubList());
- assert(pSub && "IsGroupObject is implemented as GetSubList != nullptr");
- const size_t nCount = pSub->GetObjCount();
- for (size_t i = 0; i < nCount; ++i)
- {
- SdrObject* pObj = pSub->GetObj(i);
- if (!pObj)
- continue;
- lcl_collectUsedNums(rSetFlags, nNmLen, *pObj, rCmpName);
- }
+ SdrObject* pObj = pSub->GetObj(i);
+ if (!pObj)
+ continue;
+ lcl_collectUsedNums(rSetFlags, nNmLen, *pObj, rCmpName);
}
}
@@ -1531,21 +1531,21 @@ void SwDoc::SetAllUniqueFlyNames()
}
aArr.clear();
- if( !GetFootnoteIdxs().empty() )
+ if( GetFootnoteIdxs().empty() )
+ return;
+
+ SwTextFootnote::SetUniqueSeqRefNo( *this );
+ // #i52775# Chapter footnotes did not get updated correctly.
+ // Calling UpdateAllFootnote() instead of UpdateFootnote() solves this problem,
+ // but I do not dare to call UpdateAllFootnote() in all cases: Safety first.
+ if ( FTNNUM_CHAPTER == GetFootnoteInfo().m_eNum )
{
- SwTextFootnote::SetUniqueSeqRefNo( *this );
- // #i52775# Chapter footnotes did not get updated correctly.
- // Calling UpdateAllFootnote() instead of UpdateFootnote() solves this problem,
- // but I do not dare to call UpdateAllFootnote() in all cases: Safety first.
- if ( FTNNUM_CHAPTER == GetFootnoteInfo().m_eNum )
- {
- GetFootnoteIdxs().UpdateAllFootnote();
- }
- else
- {
- SwNodeIndex aTmp( GetNodes() );
- GetFootnoteIdxs().UpdateFootnote( aTmp );
- }
+ GetFootnoteIdxs().UpdateAllFootnote();
+ }
+ else
+ {
+ SwNodeIndex aTmp( GetNodes() );
+ GetFootnoteIdxs().UpdateFootnote( aTmp );
}
}
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index e4f38b44bbb0..24f5a218048e 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -580,26 +580,26 @@ SwDoc::~SwDoc()
void SwDoc::SetDocShell( SwDocShell* pDSh )
{
- if( mpDocShell != pDSh )
+ if( mpDocShell == pDSh )
+ return;
+
+ if (mpDocShell)
{
- if (mpDocShell)
- {
- mpDocShell->SetUndoManager(nullptr);
- }
- mpDocShell = pDSh;
- if (mpDocShell)
- {
- mpDocShell->SetUndoManager(& GetUndoManager());
- GetUndoManager().SetDocShell(mpDocShell);
- }
+ mpDocShell->SetUndoManager(nullptr);
+ }
+ mpDocShell = pDSh;
+ if (mpDocShell)
+ {
+ mpDocShell->SetUndoManager(& GetUndoManager());
+ GetUndoManager().SetDocShell(mpDocShell);
+ }
- getIDocumentLinksAdministration().GetLinkManager().SetPersist( mpDocShell );
+ getIDocumentLinksAdministration().GetLinkManager().SetPersist( mpDocShell );
- // set DocShell pointer also on DrawModel
- InitDrawModelAndDocShell(mpDocShell, GetDocumentDrawModelManager().GetDrawModel());
- assert(!GetDocumentDrawModelManager().GetDrawModel() ||
- GetDocumentDrawModelManager().GetDrawModel()->GetPersist() == GetPersist());
- }
+ // set DocShell pointer also on DrawModel
+ InitDrawModelAndDocShell(mpDocShell, GetDocumentDrawModelManager().GetDrawModel());
+ assert(!GetDocumentDrawModelManager().GetDrawModel() ||
+ GetDocumentDrawModelManager().GetDrawModel()->GetPersist() == GetPersist());
}
// Convenience method; to avoid excessive includes from docsh.hxx
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 13b6136ef89a..477f83220f32 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -81,19 +81,20 @@ namespace {
void ExpandPamForParaPropsNodes(SwPaM& rPam, SwRootFrame const*const pLayout)
{
- if (pLayout)
- { // ensure that selection from the Shell includes the para-props node
- // to which the attributes should be applied
- if (rPam.GetPoint()->nNode.GetNode().IsTextNode())
- {
- rPam.GetPoint()->nNode = *sw::GetParaPropsNode(*pLayout, rPam.GetPoint()->nNode);
- rPam.GetPoint()->nContent.Assign(rPam.GetPoint()->nNode.GetNode().GetContentNode(), 0);
- }
- if (rPam.GetMark()->nNode.GetNode().IsTextNode())
- {
- rPam.GetMark()->nNode = *sw::GetParaPropsNode(*pLayout, rPam.GetMark()->nNode);
- rPam.GetMark()->nContent.Assign(rPam.GetMark()->nNode.GetNode().GetContentNode(), 0);
- }
+ if (!pLayout)
+ return;
+
+ // ensure that selection from the Shell includes the para-props node
+ // to which the attributes should be applied
+ if (rPam.GetPoint()->nNode.GetNode().IsTextNode())
+ {
+ rPam.GetPoint()->nNode = *sw::GetParaPropsNode(*pLayout, rPam.GetPoint()->nNode);
+ rPam.GetPoint()->nContent.Assign(rPam.GetPoint()->nNode.GetNode().GetContentNode(), 0);
+ }
+ if (rPam.GetMark()->nNode.GetNode().IsTextNode())
+ {
+ rPam.GetMark()->nNode = *sw::GetParaPropsNode(*pLayout, rPam.GetMark()->nNode);
+ rPam.GetMark()->nContent.Assign(rPam.GetMark()->nNode.GetNode().GetContentNode(), 0);
}
}
}
@@ -1002,21 +1003,21 @@ void SwDoc::SetNumRuleStart( const SwPosition& rPos, bool bFlag )
{
SwTextNode* pTextNd = rPos.nNode.GetNode().GetTextNode();
- if (pTextNd)
+ if (!pTextNd)
+ return;
+
+ const SwNumRule* pRule = pTextNd->GetNumRule();
+ if( pRule && !bFlag != !pTextNd->IsListRestart())
{
- const SwNumRule* pRule = pTextNd->GetNumRule();
- if( pRule && !bFlag != !pTextNd->IsListRestart())
+ if (GetIDocumentUndoRedo().DoesUndo())
{
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo(
- std::make_unique<SwUndoNumRuleStart>(rPos, bFlag) );
- }
+ GetIDocumentUndoRedo().AppendUndo(
+ std::make_unique<SwUndoNumRuleStart>(rPos, bFlag) );
+ }
- pTextNd->SetListRestart(bFlag);
+ pTextNd->SetListRestart(bFlag);
- getIDocumentState().SetModified();
- }
+ getIDocumentState().SetModified();
}
}
@@ -1024,20 +1025,20 @@ void SwDoc::SetNodeNumStart( const SwPosition& rPos, sal_uInt16 nStt )
{
SwTextNode* pTextNd = rPos.nNode.GetNode().GetTextNode();
- if (pTextNd)
+ if (!pTextNd)
+ return;
+
+ if ( !pTextNd->HasAttrListRestartValue() ||
+ pTextNd->GetAttrListRestartValue() != nStt )
{
- if ( !pTextNd->HasAttrListRestartValue() ||
- pTextNd->GetAttrListRestartValue() != nStt )
+ if (GetIDocumentUndoRedo().DoesUndo())
{
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo(
- std::make_unique<SwUndoNumRuleStart>(rPos, nStt) );
- }
- pTextNd->SetAttrListRestartValue( nStt );
-
- getIDocumentState().SetModified();
+ GetIDocumentUndoRedo().AppendUndo(
+ std::make_unique<SwUndoNumRuleStart>(rPos, nStt) );
}
+ pTextNd->SetAttrListRestartValue( nStt );
+
+ getIDocumentState().SetModified();
}
}
@@ -1085,23 +1086,23 @@ bool SwDoc::DelNumRule( const OUString& rName, bool bBroadcast )
void SwDoc::ChgNumRuleFormats( const SwNumRule& rRule )
{
SwNumRule* pRule = FindNumRulePtr( rRule.GetName() );
- if( pRule )
- {
- SwUndoInsNum* pUndo = nullptr;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- pUndo = new SwUndoInsNum( *pRule, rRule, this );
- pUndo->GetHistory();
- GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) );
- }
- ::lcl_ChgNumRule( *this, rRule );
- if (pUndo)
- {
- pUndo->SetLRSpaceEndPos();
- }
+ if( !pRule )
+ return;
- getIDocumentState().SetModified();
+ SwUndoInsNum* pUndo = nullptr;
+ if (GetIDocumentUndoRedo().DoesUndo())
+ {
+ pUndo = new SwUndoInsNum( *pRule, rRule, this );
+ pUndo->GetHistory();
+ GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) );
+ }
+ ::lcl_ChgNumRule( *this, rRule );
+ if (pUndo)
+ {
+ pUndo->SetLRSpaceEndPos();
}
+
+ getIDocumentState().SetModified();
}
bool SwDoc::RenameNumRule(const OUString & rOldName, const OUString & rNewName,
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 585a6600acc0..6cbffb7b56d5 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1107,34 +1107,34 @@ void SwRangeRedline::CallDisplayFunc(size_t nMyPos)
void SwRangeRedline::Show(sal_uInt16 nLoop, size_t nMyPos)
{
- if( 1 <= nLoop )
- {
- SwDoc* pDoc = GetDoc();
- RedlineFlags eOld = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
- pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern(eOld | RedlineFlags::Ignore);
- ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
+ if( 1 > nLoop )
+ return;
- switch( GetType() )
- {
- case RedlineType::Insert: // Content has been inserted
- m_bIsVisible = true;
- MoveFromSection(nMyPos);
- break;
+ SwDoc* pDoc = GetDoc();
+ RedlineFlags eOld = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern(eOld | RedlineFlags::Ignore);
+ ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
- case RedlineType::Delete: // Content has been deleted
- m_bIsVisible = true;
- MoveFromSection(nMyPos);
- break;
+ switch( GetType() )
+ {
+ case RedlineType::Insert: // Content has been inserted
+ m_bIsVisible = true;
+ MoveFromSection(nMyPos);
+ break;
- case RedlineType::Format: // Attributes have been applied
- case RedlineType::Table: // Table structure has been modified
- InvalidateRange(Invalidation::Add);
- break;
- default:
- break;
- }
- pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
+ case RedlineType::Delete: // Content has been deleted
+ m_bIsVisible = true;
+ MoveFromSection(nMyPos);
+ break;
+
+ case RedlineType::Format: // Attributes have been applied
+ case RedlineType::Table: // Table structure has been modified
+ InvalidateRange(Invalidation::Add);
+ break;
+ default:
+ break;
}
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld );
}
void SwRangeRedline::Hide(sal_uInt16 nLoop, size_t nMyPos)
@@ -1451,88 +1451,88 @@ void SwRangeRedline::CopyToSection()
void SwRangeRedline::DelCopyOfSection(size_t nMyPos)
{
- if( m_pContentSect )
- {
- const SwPosition* pStt = Start(),
- * pEnd = pStt == GetPoint() ? GetMark() : GetPoint();
+ if( !m_pContentSect )
+ return;
- SwDoc* pDoc = GetDoc();
- SwPaM aPam( *pStt, *pEnd );
- SwContentNode* pCSttNd = pStt->nNode.GetNode().GetContentNode();
- SwContentNode* pCEndNd = pEnd->nNode.GetNode().GetContentNode();
+ const SwPosition* pStt = Start(),
+ * pEnd = pStt == GetPoint() ? GetMark() : GetPoint();
- if( !pCSttNd )
- {
- // In order to not move other Redlines' indices, we set them
- // to the end (is exclusive)
- const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
- for(SwRangeRedline* pRedl : rTable)
- {
- if( pRedl->GetBound() == *pStt )
- pRedl->GetBound() = *pEnd;
- if( pRedl->GetBound(false) == *pStt )
- pRedl->GetBound(false) = *pEnd;
- }
- }
+ SwDoc* pDoc = GetDoc();
+ SwPaM aPam( *pStt, *pEnd );
+ SwContentNode* pCSttNd = pStt->nNode.GetNode().GetContentNode();
+ SwContentNode* pCEndNd = pEnd->nNode.GetNode().GetContentNode();
- if( pCSttNd && pCEndNd )
+ if( !pCSttNd )
+ {
+ // In order to not move other Redlines' indices, we set them
+ // to the end (is exclusive)
+ const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
+ for(SwRangeRedline* pRedl : rTable)
{
- // #i100466# - force a <join next> on <delete and join> operation
- // tdf#125319 - rather not?
- pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam/*, true*/);
+ if( pRedl->GetBound() == *pStt )
+ pRedl->GetBound() = *pEnd;
+ if( pRedl->GetBound(false) == *pStt )
+ pRedl->GetBound(false) = *pEnd;
}
- else if( pCSttNd || pCEndNd )
- {
- if( pCSttNd && !pCEndNd )
- m_bDelLastPara = true;
- pDoc->getIDocumentContentOperations().DeleteRange( aPam );
+ }
- if( m_bDelLastPara )
+ if( pCSttNd && pCEndNd )
+ {
+ // #i100466# - force a <join next> on <delete and join> operation
+ // tdf#125319 - rather not?
+ pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam/*, true*/);
+ }
+ else if( pCSttNd || pCEndNd )
+ {
+ if( pCSttNd && !pCEndNd )
+ m_bDelLastPara = true;
+ pDoc->getIDocumentContentOperations().DeleteRange( aPam );
+
+ if( m_bDelLastPara )
+ {
+ // To prevent dangling references to the paragraph to
+ // be deleted, redline that point into this paragraph should be
+ // moved to the new end position. Since redlines in the redline
+ // table are sorted and the pEnd position is an endnode (see
+ // bDelLastPara condition above), only redlines before the
+ // current ones can be affected.
+ const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
+ size_t n = nMyPos;
+ for( bool bBreak = false; !bBreak && n > 0; )
{
- // To prevent dangling references to the paragraph to
- // be deleted, redline that point into this paragraph should be
- // moved to the new end position. Since redlines in the redline
- // table are sorted and the pEnd position is an endnode (see
- // bDelLastPara condition above), only redlines before the
- // current ones can be affected.
- const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
- size_t n = nMyPos;
- for( bool bBreak = false; !bBreak && n > 0; )
+ --n;
+ bBreak = true;
+ if( rTable[ n ]->GetBound() == *aPam.GetPoint() )
{
- --n;
- bBreak = true;
- if( rTable[ n ]->GetBound() == *aPam.GetPoint() )
- {
- rTable[ n ]->GetBound() = *pEnd;
- bBreak = false;
- }
- if( rTable[ n ]->GetBound(false) == *aPam.GetPoint() )
- {
- rTable[ n ]->GetBound(false) = *pEnd;
- bBreak = false;
- }
+ rTable[ n ]->GetBound() = *pEnd;
+ bBreak = false;
+ }
+ if( rTable[ n ]->GetBound(false) == *aPam.GetPoint() )
+ {
+ rTable[ n ]->GetBound(false) = *pEnd;
+ bBreak = false;
}
+ }
- *GetPoint() = *pEnd;
- *GetMark() = *pEnd;
- DeleteMark();
+ *GetPoint() = *pEnd;
+ *GetMark() = *pEnd;
+ DeleteMark();
- aPam.GetBound().nContent.Assign( nullptr, 0 );
- aPam.GetBound( false ).nContent.Assign( nullptr, 0 );
- aPam.DeleteMark();
- pDoc->getIDocumentContentOperations().DelFullPara( aPam );
- }
- }
- else
- {
- pDoc->getIDocumentContentOperations().DeleteRange( aPam );
+ aPam.GetBound().nContent.Assign( nullptr, 0 );
+ aPam.GetBound( false ).nContent.Assign( nullptr, 0 );
+ aPam.DeleteMark();
+ pDoc->getIDocumentContentOperations().DelFullPara( aPam );
}
+ }
+ else
+ {
+ pDoc->getIDocumentContentOperations().DeleteRange( aPam );
+ }
- if( pStt == GetPoint() )
- Exchange();
+ if( pStt == GetPoint() )
+ Exchange();
- DeleteMark();
- }
+ DeleteMark();
}
void SwRangeRedline::MoveFromSection(size_t nMyPos)
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index 18b128769939..b15a22dbe1f9 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -740,19 +740,19 @@ FlatFndBox::FlatFndBox(SwDoc* pDocPtr, const FndBox_& rBoxRef) :
m_nCol(0)
{ // If the array is symmetric
m_bSym = CheckLineSymmetry(rBoxRef);
- if( m_bSym )
- {
- // Determine column/row count
- m_nCols = GetColCount(rBoxRef);
- m_nRows = GetRowCount(rBoxRef);
+ if( !m_bSym )
+ return;
- // Create linear array
- size_t nCount = static_cast<size_t>(m_nRows) * m_nCols;
- m_pArr = std::make_unique<FndBox_ const *[]>(nCount);
- memset(m_pArr.get(), 0, sizeof(const FndBox_*) * nCount);
+ // Determine column/row count
+ m_nCols = GetColCount(rBoxRef);
+ m_nRows = GetRowCount(rBoxRef);
- FillFlat( rBoxRef );
- }
+ // Create linear array
+ size_t nCount = static_cast<size_t>(m_nRows) * m_nCols;
+ m_pArr = std::make_unique<FndBox_ const *[]>(nCount);
+ memset(m_pArr.get(), 0, sizeof(const FndBox_*) * nCount);
+
+ FillFlat( rBoxRef );
}
FlatFndBox::~FlatFndBox()
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index 10b2be028f55..d5857479f6fe 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -1871,33 +1871,32 @@ void SwTOXBaseSection::UpdatePageNum_( SwTextNode* pNd,
}
// The main entries should get their character style
- if (xCharStyleIdx && !xCharStyleIdx->empty() && !GetMainEntryCharStyle().isEmpty())
- {
- // eventually the last index must me appended
- if (xCharStyleIdx->size()&0x01)
- xCharStyleIdx->push_back(aNumStr.getLength());
-
- // search by name
- SwDoc* pDoc = pNd->GetDoc();
- sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( GetMainEntryCharStyle(), SwGetPoolIdFromName::ChrFmt );
- SwCharFormat* pCharFormat = nullptr;
- if(USHRT_MAX != nPoolId)
- pCharFormat = pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool(nPoolId);
- else
- pCharFormat = pDoc->FindCharFormatByName( GetMainEntryCharStyle() );
- if(!pCharFormat)
- pCharFormat = pDoc->MakeCharFormat(GetMainEntryCharStyle(), nullptr);
-
- // find the page numbers in aNumStr and set the character style
- sal_Int32 nOffset = pNd->GetText().getLength() - aNumStr.getLength();
- SwFormatCharFormat aCharFormat(pCharFormat);
- for (size_t j = 0; j < xCharStyleIdx->size(); j += 2)
- {
- sal_Int32 nStartIdx = (*xCharStyleIdx)[j] + nOffset;
- sal_Int32 nEndIdx = (*xCharStyleIdx)[j + 1] + nOffset;
- pNd->InsertItem(aCharFormat, nStartIdx, nEndIdx, SetAttrMode::DONTEXPAND);
- }
+ if (!(xCharStyleIdx && !xCharStyleIdx->empty() && !GetMainEntryCharStyle().isEmpty()))
+ return;
+
+ // eventually the last index must me appended
+ if (xCharStyleIdx->size()&0x01)
+ xCharStyleIdx->push_back(aNumStr.getLength());
+ // search by name
+ SwDoc* pDoc = pNd->GetDoc();
+ sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( GetMainEntryCharStyle(), SwGetPoolIdFromName::ChrFmt );
+ SwCharFormat* pCharFormat = nullptr;
+ if(USHRT_MAX != nPoolId)
+ pCharFormat = pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool(nPoolId);
+ else
+ pCharFormat = pDoc->FindCharFormatByName( GetMainEntryCharStyle() );
+ if(!pCharFormat)
+ pCharFormat = pDoc->MakeCharFormat(GetMainEntryCharStyle(), nullptr);
+
+ // find the page numbers in aNumStr and set the character style
+ sal_Int32 nOffset = pNd->GetText().getLength() - aNumStr.getLength();
+ SwFormatCharFormat aCharFormat(pCharFormat);
+ for (size_t j = 0; j < xCharStyleIdx->size(); j += 2)
+ {
+ sal_Int32 nStartIdx = (*xCharStyleIdx)[j] + nOffset;
+ sal_Int32 nEndIdx = (*xCharStyleIdx)[j + 1] + nOffset;
+ pNd->InsertItem(aCharFormat, nStartIdx, nEndIdx, SetAttrMode::DONTEXPAND);
}
}
diff --git a/sw/source/core/doc/docxforms.cxx b/sw/source/core/doc/docxforms.cxx
index ea827d58d9ad..2a7ee714cece 100644
--- a/sw/source/core/doc/docxforms.cxx
+++ b/sw/source/core/doc/docxforms.cxx
@@ -89,38 +89,38 @@ void SwDoc::initXForms( bool bCreateDefaultModel )
void SwDoc::disposeXForms( )
{
// get XForms models
- if( mxXForms.is() )
+ if( !mxXForms.is() )
+ return;
+
+ // iterate over all models
+ const uno::Sequence<OUString> aNames = mxXForms->getElementNames();
+ for( const OUString& rName : aNames )
{
- // iterate over all models
- const uno::Sequence<OUString> aNames = mxXForms->getElementNames();
- for( const OUString& rName : aNames )
+ Reference< xforms::XModel > xModel(
+ mxXForms->getByName( rName ), UNO_QUERY );
+
+ if( xModel.is() )
{
- Reference< xforms::XModel > xModel(
- mxXForms->getByName( rName ), UNO_QUERY );
+ // ask model for bindings
+ Reference< XIndexAccess > xBindings(
+ xModel->getBindings(), UNO_QUERY );
+
+ // Then release them one by one
+ int nCount = xBindings->getCount();
+ for( int i = nCount-1; i >= 0; i-- )
+ {
+ xModel->getBindings()->remove(xBindings->getByIndex( i ));
+ }
+
+ // ask model for Submissions
+ Reference< XIndexAccess > xSubmissions(
+ xModel->getSubmissions(), UNO_QUERY );
- if( xModel.is() )
+ // Then release them one by one
+ nCount = xSubmissions->getCount();
+ for( int i = nCount-1; i >= 0; i-- )
{
- // ask model for bindings
- Reference< XIndexAccess > xBindings(
- xModel->getBindings(), UNO_QUERY );
-
- // Then release them one by one
- int nCount = xBindings->getCount();
- for( int i = nCount-1; i >= 0; i-- )
- {
- xModel->getBindings()->remove(xBindings->getByIndex( i ));
- }
-
- // ask model for Submissions
- Reference< XIndexAccess > xSubmissions(
- xModel->getSubmissions(), UNO_QUERY );
-
- // Then release them one by one
- nCount = xSubmissions->getCount();
- for( int i = nCount-1; i >= 0; i-- )
- {
- xModel->getSubmissions()->remove(xSubmissions->getByIndex( i ));
- }
+ xModel->getSubmissions()->remove(xSubmissions->getByIndex( i ));
}
}
}
diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx
index d9d22c25f695..83325d73ecd1 100644
--- a/sw/source/core/doc/extinput.cxx
+++ b/sw/source/core/doc/extinput.cxx
@@ -50,160 +50,159 @@ SwExtTextInput::~SwExtTextInput()
if (pDoc->IsInDtor()) { return; /* #i58606# */ }
SwTextNode* pTNd = GetPoint()->nNode.GetNode().GetTextNode();
- if( pTNd )
+ if( !pTNd )
+ return;
+
+ SwIndex& rIdx = GetPoint()->nContent;
+ sal_Int32 nSttCnt = rIdx.GetIndex();
+ sal_Int32 nEndCnt = GetMark()->nContent.GetIndex();
+ if( nEndCnt == nSttCnt )
+ return;
+
+ // Prevent IME edited text being grouped with non-IME edited text.
+ bool bKeepGroupUndo = pDoc->GetIDocumentUndoRedo().DoesGroupUndo();
+ pDoc->GetIDocumentUndoRedo().DoGroupUndo(false);
+ if( nEndCnt < nSttCnt )
{
- SwIndex& rIdx = GetPoint()->nContent;
- sal_Int32 nSttCnt = rIdx.GetIndex();
- sal_Int32 nEndCnt = GetMark()->nContent.GetIndex();
- if( nEndCnt != nSttCnt )
- {
- // Prevent IME edited text being grouped with non-IME edited text.
- bool bKeepGroupUndo = pDoc->GetIDocumentUndoRedo().DoesGroupUndo();
- pDoc->GetIDocumentUndoRedo().DoGroupUndo(false);
- if( nEndCnt < nSttCnt )
- {
- std::swap(nSttCnt, nEndCnt);
- }
+ std::swap(nSttCnt, nEndCnt);
+ }
- // In order to get Undo/Redlining etc. working correctly,
- // we need to go through the Doc interface
+ // In order to get Undo/Redlining etc. working correctly,
+ // we need to go through the Doc interface
+ rIdx = nSttCnt;
+ const OUString sText( pTNd->GetText().copy(nSttCnt, nEndCnt - nSttCnt));
+ if( m_bIsOverwriteCursor && !m_sOverwriteText.isEmpty() )
+ {
+ const sal_Int32 nLen = sText.getLength();
+ const sal_Int32 nOWLen = m_sOverwriteText.getLength();
+ if( nLen > nOWLen )
+ {
+ rIdx += nOWLen;
+ pTNd->EraseText( rIdx, nLen - nOWLen );
rIdx = nSttCnt;
- const OUString sText( pTNd->GetText().copy(nSttCnt, nEndCnt - nSttCnt));
- if( m_bIsOverwriteCursor && !m_sOverwriteText.isEmpty() )
+ pTNd->ReplaceText( rIdx, nOWLen, m_sOverwriteText );
+ if( m_bInsText )
{
- const sal_Int32 nLen = sText.getLength();
- const sal_Int32 nOWLen = m_sOverwriteText.getLength();
- if( nLen > nOWLen )
- {
- rIdx += nOWLen;
- pTNd->EraseText( rIdx, nLen - nOWLen );
- rIdx = nSttCnt;
- pTNd->ReplaceText( rIdx, nOWLen, m_sOverwriteText );
- if( m_bInsText )
- {
- rIdx = nSttCnt;
- pDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::OVERWRITE, nullptr );
- pDoc->getIDocumentContentOperations().Overwrite( *this, sText.copy( 0, nOWLen ) );
- pDoc->getIDocumentContentOperations().InsertString( *this, sText.copy( nOWLen ) );
- pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::OVERWRITE, nullptr );
- }
- }
- else
- {
- pTNd->ReplaceText( rIdx, nLen, m_sOverwriteText.copy( 0, nLen ));
- if( m_bInsText )
- {
- rIdx = nSttCnt;
- pDoc->getIDocumentContentOperations().Overwrite( *this, sText );
- }
- }
+ rIdx = nSttCnt;
+ pDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::OVERWRITE, nullptr );
+ pDoc->getIDocumentContentOperations().Overwrite( *this, sText.copy( 0, nOWLen ) );
+ pDoc->getIDocumentContentOperations().InsertString( *this, sText.copy( nOWLen ) );
+ pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::OVERWRITE, nullptr );
}
- else
+ }
+ else
+ {
+ pTNd->ReplaceText( rIdx, nLen, m_sOverwriteText.copy( 0, nLen ));
+ if( m_bInsText )
{
- pTNd->EraseText( rIdx, nEndCnt - nSttCnt );
-
- if( m_bInsText )
- {
- pDoc->getIDocumentContentOperations().InsertString( *this, sText );
- }
+ rIdx = nSttCnt;
+ pDoc->getIDocumentContentOperations().Overwrite( *this, sText );
}
- pDoc->GetIDocumentUndoRedo().DoGroupUndo(bKeepGroupUndo);
- if (m_eInputLanguage != LANGUAGE_DONTKNOW)
- {
- sal_uInt16 nWhich = RES_CHRATR_LANGUAGE;
- sal_Int16 nScriptType = SvtLanguageOptions::GetI18NScriptTypeOfLanguage(m_eInputLanguage);
- switch(nScriptType)
- {
- case i18n::ScriptType::ASIAN:
- nWhich = RES_CHRATR_CJK_LANGUAGE; break;
- case i18n::ScriptType::COMPLEX:
- nWhich = RES_CHRATR_CTL_LANGUAGE; break;
- }
- // #i41974# Only set language attribute for CJK/CTL scripts.
- if (RES_CHRATR_LANGUAGE != nWhich && pTNd->GetLang( nSttCnt, nEndCnt-nSttCnt, nScriptType) != m_eInputLanguage)
- {
- SvxLanguageItem aLangItem( m_eInputLanguage, nWhich );
- rIdx = nSttCnt;
- GetMark()->nContent = nEndCnt;
- pDoc->getIDocumentContentOperations().InsertPoolItem(*this, aLangItem );
- }
+ }
+ }
+ else
+ {
+ pTNd->EraseText( rIdx, nEndCnt - nSttCnt );
- }
+ if( m_bInsText )
+ {
+ pDoc->getIDocumentContentOperations().InsertString( *this, sText );
}
}
+ pDoc->GetIDocumentUndoRedo().DoGroupUndo(bKeepGroupUndo);
+ if (m_eInputLanguage == LANGUAGE_DONTKNOW)
+ return;
+
+ sal_uInt16 nWhich = RES_CHRATR_LANGUAGE;
+ sal_Int16 nScriptType = SvtLanguageOptions::GetI18NScriptTypeOfLanguage(m_eInputLanguage);
+ switch(nScriptType)
+ {
+ case i18n::ScriptType::ASIAN:
+ nWhich = RES_CHRATR_CJK_LANGUAGE; break;
+ case i18n::ScriptType::COMPLEX:
+ nWhich = RES_CHRATR_CTL_LANGUAGE; break;
+ }
+ // #i41974# Only set language attribute for CJK/CTL scripts.
+ if (RES_CHRATR_LANGUAGE != nWhich && pTNd->GetLang( nSttCnt, nEndCnt-nSttCnt, nScriptType) != m_eInputLanguage)
+ {
+ SvxLanguageItem aLangItem( m_eInputLanguage, nWhich );
+ rIdx = nSttCnt;
+ GetMark()->nContent = nEndCnt;
+ pDoc->getIDocumentContentOperations().InsertPoolItem(*this, aLangItem );
+ }
}
void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData )
{
SwTextNode* pTNd = GetPoint()->nNode.GetNode().GetTextNode();
- if( pTNd )
+ if( !pTNd )
+ return;
+
+ sal_Int32 nSttCnt = GetPoint()->nContent.GetIndex();
+ sal_Int32 nEndCnt = GetMark()->nContent.GetIndex();
+ if( nEndCnt < nSttCnt )
{
- sal_Int32 nSttCnt = GetPoint()->nContent.GetIndex();
- sal_Int32 nEndCnt = GetMark()->nContent.GetIndex();
- if( nEndCnt < nSttCnt )
- {
- std::swap(nSttCnt, nEndCnt);
- }
+ std::swap(nSttCnt, nEndCnt);
+ }
- SwIndex aIdx( pTNd, nSttCnt );
- const OUString& rNewStr = rData.GetText();
+ SwIndex aIdx( pTNd, nSttCnt );
+ const OUString& rNewStr = rData.GetText();
- if( m_bIsOverwriteCursor && !m_sOverwriteText.isEmpty() )
+ if( m_bIsOverwriteCursor && !m_sOverwriteText.isEmpty() )
+ {
+ sal_Int32 nReplace = nEndCnt - nSttCnt;
+ const sal_Int32 nNewLen = rNewStr.getLength();
+ if( nNewLen < nReplace )
+ {
+ // We have to insert some characters from the saved original text
+ nReplace -= nNewLen;
+ aIdx += nNewLen;
+ pTNd->ReplaceText( aIdx, nReplace,
+ m_sOverwriteText.copy( nNewLen, nReplace ));
+ aIdx = nSttCnt;
+ nReplace = nNewLen;
+ }
+ else
{
- sal_Int32 nReplace = nEndCnt - nSttCnt;
- const sal_Int32 nNewLen = rNewStr.getLength();
- if( nNewLen < nReplace )
+ const sal_Int32 nOWLen = m_sOverwriteText.getLength();
+ if( nOWLen < nReplace )
{
- // We have to insert some characters from the saved original text
- nReplace -= nNewLen;
- aIdx += nNewLen;
- pTNd->ReplaceText( aIdx, nReplace,
- m_sOverwriteText.copy( nNewLen, nReplace ));
+ aIdx += nOWLen;
+ pTNd->EraseText( aIdx, nReplace-nOWLen );
aIdx = nSttCnt;
- nReplace = nNewLen;
+ nReplace = nOWLen;
}
else
{
- const sal_Int32 nOWLen = m_sOverwriteText.getLength();
- if( nOWLen < nReplace )
- {
- aIdx += nOWLen;
- pTNd->EraseText( aIdx, nReplace-nOWLen );
- aIdx = nSttCnt;
- nReplace = nOWLen;
- }
- else
- {
- nReplace = std::min(nOWLen, nNewLen);
- }
+ nReplace = std::min(nOWLen, nNewLen);
}
-
- pTNd->ReplaceText( aIdx, nReplace, rNewStr );
- if( !HasMark() )
- SetMark();
- GetMark()->nContent = aIdx;
}
- else
- {
- if( nSttCnt < nEndCnt )
- {
- pTNd->EraseText( aIdx, nEndCnt - nSttCnt );
- }
- pTNd->InsertText( rNewStr, aIdx,
- SwInsertFlags::EMPTYEXPAND );
- if( !HasMark() )
- SetMark();
+ pTNd->ReplaceText( aIdx, nReplace, rNewStr );
+ if( !HasMark() )
+ SetMark();
+ GetMark()->nContent = aIdx;
+ }
+ else
+ {
+ if( nSttCnt < nEndCnt )
+ {
+ pTNd->EraseText( aIdx, nEndCnt - nSttCnt );
}
- GetPoint()->nContent = nSttCnt;
+ pTNd->InsertText( rNewStr, aIdx,
+ SwInsertFlags::EMPTYEXPAND );
+ if( !HasMark() )
+ SetMark();
+ }
- m_aAttrs.clear();
- if( rData.GetTextAttr() )
- {
- const ExtTextInputAttr *pAttrs = rData.GetTextAttr();
- m_aAttrs.insert( m_aAttrs.begin(), pAttrs, pAttrs + rData.GetText().getLength() );
- }
+ GetPoint()->nContent = nSttCnt;
+
+ m_aAttrs.clear();
+ if( rData.GetTextAttr() )
+ {
+ const ExtTextInputAttr *pAttrs = rData.GetTextAttr();
+ m_aAttrs.insert( m_aAttrs.begin(), pAttrs, pAttrs + rData.GetText().getLength() );
}
}
@@ -214,27 +213,27 @@ void SwExtTextInput::SetOverwriteCursor( bool bFlag )
return;
const SwTextNode *const pTNd = GetPoint()->nNode.GetNode().GetTextNode();
- if (pTNd)
- {
- const sal_Int32 nSttCnt = GetPoint()->nContent.GetIndex();
- const sal_Int32 nEndCnt = GetMark()->nContent.GetIndex();
- m_sOverwriteText = pTNd->GetText().copy( std::min(nSttCnt, nEndCnt) );
- if( !m_sOverwriteText.isEmpty() )
- {
- const sal_Int32 nInPos = m_sOverwriteText.indexOf( CH_TXTATR_INWORD );
- const sal_Int32 nBrkPos = m_sOverwriteText.indexOf( CH_TXTATR_BREAKWORD );
+ if (!pTNd)
+ return;
- // Find the first attr found, if any.
- sal_Int32 nPos = std::min(nInPos, nBrkPos);
- if (nPos<0)
- {
- nPos = std::max(nInPos, nBrkPos);
- }
- if (nPos>=0)
- {
- m_sOverwriteText = m_sOverwriteText.copy( 0, nPos );
- }
- }
+ const sal_Int32 nSttCnt = GetPoint()->nContent.GetIndex();
+ const sal_Int32 nEndCnt = GetMark()->nContent.GetIndex();
+ m_sOverwriteText = pTNd->GetText().copy( std::min(nSttCnt, nEndCnt) );
+ if( m_sOverwriteText.isEmpty() )
+ return;
+
+ const sal_Int32 nInPos = m_sOverwriteText.indexOf( CH_TXTATR_INWORD );
+ const sal_Int32 nBrkPos = m_sOverwriteText.indexOf( CH_TXTATR_BREAKWORD );
+
+ // Find the first attr found, if any.
+ sal_Int32 nPos = std::min(nInPos, nBrkPos);
+ if (nPos<0)
+ {
+ nPos = std::max(nInPos, nBrkPos);
+ }
+ if (nPos>=0)
+ {
+ m_sOverwriteText = m_sOverwriteText.copy( 0, nPos );
}
}
diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx
index ab39abf3194f..4ef745fc1926 100644
--- a/sw/source/core/doc/fmtcol.cxx
+++ b/sw/source/core/doc/fmtcol.cxx
@@ -51,22 +51,22 @@ namespace TextFormatCollFunc
}
// #i73790#
- if ( !pTextFormatColl->StayAssignedToListLevelOfOutlineStyle() &&
- pTextFormatColl->IsAssignedToListLevelOfOutlineStyle() )
+ if ( !(!pTextFormatColl->StayAssignedToListLevelOfOutlineStyle() &&
+ pTextFormatColl->IsAssignedToListLevelOfOutlineStyle()) )
+ return;
+
+ if (!pNewNumRuleItem)
{
- if (!pNewNumRuleItem)
- {
- (void)pTextFormatColl->GetItemState(RES_PARATR_NUMRULE, false, reinterpret_cast<const SfxPoolItem**>(&pNewNumRuleItem));
- }
- if (pNewNumRuleItem)
+ (void)pTextFormatColl->GetItemState(RES_PARATR_NUMRULE, false, reinterpret_cast<const SfxPoolItem**>(&pNewNumRuleItem));
+ }
+ if (pNewNumRuleItem)
+ {
+ const OUString& sNumRuleName = pNewNumRuleItem->GetValue();
+ if ( sNumRuleName.isEmpty() ||
+ sNumRuleName != pTextFormatColl->GetDoc()->GetOutlineNumRule()->GetName() )
{
- const OUString& sNumRuleName = pNewNumRuleItem->GetValue();
- if ( sNumRuleName.isEmpty() ||
- sNumRuleName != pTextFormatColl->GetDoc()->GetOutlineNumRule()->GetName() )
- {
- // delete assignment of paragraph style to list level of outline style.
- pTextFormatColl->DeleteAssignmentToListLevelOfOutlineStyle();
- }
+ // delete assignment of paragraph style to list level of outline style.
+ pTextFormatColl->DeleteAssignmentToListLevelOfOutlineStyle();
}
}
}
diff --git a/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx
index e3e642f667ea..ff989ceca612 100644
--- a/sw/source/core/doc/htmltbl.cxx
+++ b/sw/source/core/doc/htmltbl.cxx
@@ -867,179 +867,179 @@ void SwHTMLTableLayout::AutoLayoutPass1()
pConstr = pConstr->GetNext();
}
- if( bFixRelWidths )
+ if( !bFixRelWidths )
+ return;
+
+ if( HasColTags() )
{
- if( HasColTags() )
+ // To adapt the relative widths, in a first step we multiply the
+ // minimum width of all affected cells with the relative width
+ // of the column.
+ // Thus, the width ratio among the columns is correct.
+
+ // Furthermore, a factor is calculated that says by how much the
+ // cell has gotten wider than the minimum width.
+
+ // In the second step the calculated widths are divided by this
+ // factor. Thereby a cell's width is preserved and serves as a
+ // basis for the other cells.
+ // We only change the maximum widths here!
+
+ sal_uLong nAbsMin = 0; // absolute minimum width of all widths with relative width
+ sal_uLong nRel = 0; // sum of all relative widths of all columns
+ for( i=0; i<m_nCols; i++ )
{
- // To adapt the relative widths, in a first step we multiply the
- // minimum width of all affected cells with the relative width
- // of the column.
- // Thus, the width ratio among the columns is correct.
-
- // Furthermore, a factor is calculated that says by how much the
- // cell has gotten wider than the minimum width.
-
- // In the second step the calculated widths are divided by this
- // factor. Thereby a cell's width is preserved and serves as a
- // basis for the other cells.
- // We only change the maximum widths here!
-
- sal_uLong nAbsMin = 0; // absolute minimum width of all widths with relative width
- sal_uLong nRel = 0; // sum of all relative widths of all columns
- for( i=0; i<m_nCols; i++ )
+ SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
+ if( pColumn->IsRelWidthOption() && pColumn->GetWidthOption() )
{
- SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
- if( pColumn->IsRelWidthOption() && pColumn->GetWidthOption() )
- {
- nAbsMin += pColumn->GetMin();
- nRel += pColumn->GetWidthOption();
- }
+ nAbsMin += pColumn->GetMin();
+ nRel += pColumn->GetWidthOption();
}
+ }
- sal_uLong nQuot = ULONG_MAX;
- for( i=0; i<m_nCols; i++ )
+ sal_uLong nQuot = ULONG_MAX;
+ for( i=0; i<m_nCols; i++ )
+ {
+ SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
+ if( pColumn->IsRelWidthOption() )
{
- SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
- if( pColumn->IsRelWidthOption() )
+ m_nMax -= pColumn->GetMax();
+ if( pColumn->GetWidthOption() && pColumn->GetMin() )
{
- m_nMax -= pColumn->GetMax();
- if( pColumn->GetWidthOption() && pColumn->GetMin() )
- {
- pColumn->SetMax( nAbsMin * pColumn->GetWidthOption() );
- sal_uLong nColQuot = pColumn->GetMax() / pColumn->GetMin();
- if( nColQuot<nQuot )
- nQuot = nColQuot;
- }
+ pColumn->SetMax( nAbsMin * pColumn->GetWidthOption() );
+ sal_uLong nColQuot = pColumn->GetMax() / pColumn->GetMin();
+ if( nColQuot<nQuot )
+ nQuot = nColQuot;
}
}
- OSL_ENSURE( 0==nRel || nQuot!=ULONG_MAX,
- "Where did the relative columns go?" );
- for( i=0; i<m_nCols; i++ )
+ }
+ OSL_ENSURE( 0==nRel || nQuot!=ULONG_MAX,
+ "Where did the relative columns go?" );
+ for( i=0; i<m_nCols; i++ )
+ {
+ SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
+ if( pColumn->IsRelWidthOption() )
{
- SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
- if( pColumn->IsRelWidthOption() )
- {
- if( pColumn->GetWidthOption() )
- pColumn->SetMax( pColumn->GetMax() / nQuot );
- else
- pColumn->SetMax( pColumn->GetMin() );
- OSL_ENSURE( pColumn->GetMax() >= pColumn->GetMin(),
- "Maximum column width is lower than the minimum column width" );
- m_nMax += pColumn->GetMax();
- }
+ if( pColumn->GetWidthOption() )
+ pColumn->SetMax( pColumn->GetMax() / nQuot );
+ else
+ pColumn->SetMax( pColumn->GetMin() );
+ OSL_ENSURE( pColumn->GetMax() >= pColumn->GetMin(),
+ "Maximum column width is lower than the minimum column width" );
+ m_nMax += pColumn->GetMax();
}
}
- else
+ }
+ else
+ {
+ sal_uInt16 nRel = 0; // sum of the relative widths of all columns
+ sal_uInt16 nRelCols = 0; // count of the columns with a relative setting
+ sal_uLong nRelMax = 0; // fraction of the maximum of this column
+ for( i=0; i<m_nCols; i++ )
{
- sal_uInt16 nRel = 0; // sum of the relative widths of all columns
- sal_uInt16 nRelCols = 0; // count of the columns with a relative setting
- sal_uLong nRelMax = 0; // fraction of the maximum of this column
- for( i=0; i<m_nCols; i++ )
+ OSL_ENSURE( nRel<=100, "relative width of all columns > 100%" );
+ SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
+ if( pColumn->IsRelWidthOption() && pColumn->GetWidthOption() )
{
- OSL_ENSURE( nRel<=100, "relative width of all columns > 100%" );
- SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
- if( pColumn->IsRelWidthOption() && pColumn->GetWidthOption() )
+ // Make sure that the relative widths don't go above 100%
+ sal_uInt16 nColWidth = pColumn->GetWidthOption();
+ if( nRel+nColWidth > 100 )
{
- // Make sure that the relative widths don't go above 100%
- sal_uInt16 nColWidth = pColumn->GetWidthOption();
- if( nRel+nColWidth > 100 )
- {
- nColWidth = 100 - nRel;
- pColumn->SetWidthOption( nColWidth );
- }
- nRelMax += pColumn->GetMax();
- nRel = nRel + nColWidth;
- nRelCols++;
- }
- else if( !pColumn->GetMin() )
- {
- // The column is empty (so it was solely created by
- // COLSPAN) and therefore must not be assigned a % width.
- nRelCols++;
+ nColWidth = 100 - nRel;
+ pColumn->SetWidthOption( nColWidth );
}
+ nRelMax += pColumn->GetMax();
+ nRel = nRel + nColWidth;
+ nRelCols++;
}
-
- // If there are percentages left we distribute them to the columns
- // that don't have a width setting. Like in Netscape we distribute
- // the remaining percentages according to the ratio of the maximum
- // width of the affected columns.
- // For the maximum widths we also take the fixed-width columns
- // into account. Is that correct?
- sal_uLong nFixMax = 0;
- if( nRel < 100 && nRelCols < m_nCols )
+ else if( !pColumn->GetMin() )
{
- nFixMax = m_nMax - nRelMax;
- SAL_WARN_IF(!nFixMax, "sw.core", "bad fixed width max");
- }
- if (nFixMax)
- {
- sal_uInt16 nRelLeft = 100 - nRel;
- for( i=0; i<m_nCols; i++ )
- {
- SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
- if( !pColumn->IsRelWidthOption() &&
- !pColumn->GetWidthOption() &&
- pColumn->GetMin() )
- {
- // the next column gets the rest
- sal_uInt16 nColWidth =
- static_cast<sal_uInt16>((pColumn->GetMax() * nRelLeft) / nFixMax);
- pColumn->SetWidthOption( nColWidth );
- }
- }
+ // The column is empty (so it was solely created by
+ // COLSPAN) and therefore must not be assigned a % width.
+ nRelCols++;
}
+ }
- // adjust the maximum widths now accordingly
- sal_uLong nQuotMax = ULONG_MAX;
- sal_uLong nOldMax = m_nMax;
- m_nMax = 0;
+ // If there are percentages left we distribute them to the columns
+ // that don't have a width setting. Like in Netscape we distribute
+ // the remaining percentages according to the ratio of the maximum
+ // width of the affected columns.
+ // For the maximum widths we also take the fixed-width columns
+ // into account. Is that correct?
+ sal_uLong nFixMax = 0;
+ if( nRel < 100 && nRelCols < m_nCols )
+ {
+ nFixMax = m_nMax - nRelMax;
+ SAL_WARN_IF(!nFixMax, "sw.core", "bad fixed width max");
+ }
+ if (nFixMax)
+ {
+ sal_uInt16 nRelLeft = 100 - nRel;
for( i=0; i<m_nCols; i++ )
{
- // Columns with a % setting are adapted accordingly.
- // Columns, that
- // - do not have a % setting and are located within a tables
- // with COLS and WIDTH, or
- // - their width is 0%
- // get set to the minimum width.
SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
- if( pColumn->IsRelWidthOption() && pColumn->GetWidthOption() )
+ if( !pColumn->IsRelWidthOption() &&
+ !pColumn->GetWidthOption() &&
+ pColumn->GetMin() )
{
- sal_uLong nNewMax;
- sal_uLong nColQuotMax;
- if( !m_nWidthOption )
- {
- nNewMax = nOldMax * pColumn->GetWidthOption();
- nColQuotMax = nNewMax / pColumn->GetMax();
- }
- else
- {
- nNewMax = m_nMin * pColumn->GetWidthOption();
- nColQuotMax = nNewMax / pColumn->GetMin();
- }
- pColumn->SetMax( nNewMax );
- if( nColQuotMax < nQuotMax )
- nQuotMax = nColQuotMax;
+ // the next column gets the rest
+ sal_uInt16 nColWidth =
+ static_cast<sal_uInt16>((pColumn->GetMax() * nRelLeft) / nFixMax);
+ pColumn->SetWidthOption( nColWidth );
}
- else if( HasColsOption() || m_nWidthOption ||
- (pColumn->IsRelWidthOption() &&
- !pColumn->GetWidthOption()) )
- pColumn->SetMax( pColumn->GetMin() );
}
- // and divide by the quotient
- SAL_WARN_IF(!nQuotMax, "sw.core", "Where did the relative columns go?");
- for (i = 0; i < m_nCols; ++i)
+ }
+
+ // adjust the maximum widths now accordingly
+ sal_uLong nQuotMax = ULONG_MAX;
+ sal_uLong nOldMax = m_nMax;
+ m_nMax = 0;
+ for( i=0; i<m_nCols; i++ )
+ {
+ // Columns with a % setting are adapted accordingly.
+ // Columns, that
+ // - do not have a % setting and are located within a tables
+ // with COLS and WIDTH, or
+ // - their width is 0%
+ // get set to the minimum width.
+ SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
+ if( pColumn->IsRelWidthOption() && pColumn->GetWidthOption() )
{
- SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
- if (pColumn->IsRelWidthOption() && pColumn->GetWidthOption() && nQuotMax)
+ sal_uLong nNewMax;
+ sal_uLong nColQuotMax;
+ if( !m_nWidthOption )
{
- pColumn->SetMax( pColumn->GetMax() / nQuotMax );
- OSL_ENSURE( pColumn->GetMax() >= pColumn->GetMin(),
- "Minimum width is one column bigger than maximum" );
- if( pColumn->GetMax() < pColumn->GetMin() )
- pColumn->SetMax( pColumn->GetMin() );
+ nNewMax = nOldMax * pColumn->GetWidthOption();
+ nColQuotMax = nNewMax / pColumn->GetMax();
}
- m_nMax += pColumn->GetMax();
+ else
+ {
+ nNewMax = m_nMin * pColumn->GetWidthOption();
+ nColQuotMax = nNewMax / pColumn->GetMin();
+ }
+ pColumn->SetMax( nNewMax );
+ if( nColQuotMax < nQuotMax )
+ nQuotMax = nColQuotMax;
}
+ else if( HasColsOption() || m_nWidthOption ||
+ (pColumn->IsRelWidthOption() &&
+ !pColumn->GetWidthOption()) )
+ pColumn->SetMax( pColumn->GetMin() );
+ }
+ // and divide by the quotient
+ SAL_WARN_IF(!nQuotMax, "sw.core", "Where did the relative columns go?");
+ for (i = 0; i < m_nCols; ++i)
+ {
+ SwHTMLTableLayoutColumn *pColumn = GetColumn( i );
+ if (pColumn->IsRelWidthOption() && pColumn->GetWidthOption() && nQuotMax)
+ {
+ pColumn->SetMax( pColumn->GetMax() / nQuotMax );
+ OSL_ENSURE( pColumn->GetMax() >= pColumn->GetMin(),
+ "Minimum width is one column bigger than maximum" );
+ if( pColumn->GetMax() < pColumn->GetMin() )
+ pColumn->SetMax( pColumn->GetMin() );
+ }
+ m_nMax += pColumn->GetMax();
}
}
}
@@ -1455,69 +1455,69 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
// left or right. Here we calculate their width.
m_nInhAbsLeftSpace = 0;
m_nInhAbsRightSpace = 0;
- if( !IsTopTable() && (m_nRelLeftFill>0 || m_nRelRightFill>0 ||
- nAbsTabWidth<nAbsAvail) )
+ if( !(!IsTopTable() && (m_nRelLeftFill>0 || m_nRelRightFill>0 ||
+ nAbsTabWidth<nAbsAvail)) )
+ return;
+
+ // Calculate the width of additional cells we use for
+ // aligning inner tables.
+ sal_uInt16 nAbsDist = static_cast<sal_uInt16>(nAbsAvail-nAbsTabWidth);
+ sal_uInt16 nRelDist = static_cast<sal_uInt16>(nRelAvail-m_nRelTabWidth);
+ sal_uInt16 nParentInhAbsLeftSpace = 0, nParentInhAbsRightSpace = 0;
+
+ // Calculate the size and position of the additional cells.
+ switch( m_eTableAdjust )
{
- // Calculate the width of additional cells we use for
- // aligning inner tables.
- sal_uInt16 nAbsDist = static_cast<sal_uInt16>(nAbsAvail-nAbsTabWidth);
- sal_uInt16 nRelDist = static_cast<sal_uInt16>(nRelAvail-m_nRelTabWidth);
- sal_uInt16 nParentInhAbsLeftSpace = 0, nParentInhAbsRightSpace = 0;
-
- // Calculate the size and position of the additional cells.
- switch( m_eTableAdjust )
+ case SvxAdjust::Right:
+ nAbsLeftFill = nAbsLeftFill + nAbsDist;
+ m_nRelLeftFill = m_nRelLeftFill + nRelDist;
+ nParentInhAbsLeftSpace = nParentInhAbsSpace;
+ break;
+ case SvxAdjust::Center:
{
- case SvxAdjust::Right:
- nAbsLeftFill = nAbsLeftFill + nAbsDist;
- m_nRelLeftFill = m_nRelLeftFill + nRelDist;
- nParentInhAbsLeftSpace = nParentInhAbsSpace;
- break;
- case SvxAdjust::Center:
- {
- sal_uInt16 nAbsLeftDist = nAbsDist / 2;
- nAbsLeftFill = nAbsLeftFill + nAbsLeftDist;
- nAbsRightFill += nAbsDist - nAbsLeftDist;
- sal_uInt16 nRelLeftDist = nRelDist / 2;
- m_nRelLeftFill = m_nRelLeftFill + nRelLeftDist;
- m_nRelRightFill += nRelDist - nRelLeftDist;
- nParentInhAbsLeftSpace = nParentInhAbsSpace / 2;
- nParentInhAbsRightSpace = nParentInhAbsSpace -
- nParentInhAbsLeftSpace;
- }
- break;
- case SvxAdjust::Left:
- default:
- nAbsRightFill = nAbsRightFill + nAbsDist;
- m_nRelRightFill = m_nRelRightFill + nRelDist;
- nParentInhAbsRightSpace = nParentInhAbsSpace;
- break;
+ sal_uInt16 nAbsLeftDist = nAbsDist / 2;
+ nAbsLeftFill = nAbsLeftFill + nAbsLeftDist;
+ nAbsRightFill += nAbsDist - nAbsLeftDist;
+ sal_uInt16 nRelLeftDist = nRelDist / 2;
+ m_nRelLeftFill = m_nRelLeftFill + nRelLeftDist;
+ m_nRelRightFill += nRelDist - nRelLeftDist;
+ nParentInhAbsLeftSpace = nParentInhAbsSpace / 2;
+ nParentInhAbsRightSpace = nParentInhAbsSpace -
+ nParentInhAbsLeftSpace;
}
+ break;
+ case SvxAdjust::Left:
+ default:
+ nAbsRightFill = nAbsRightFill + nAbsDist;
+ m_nRelRightFill = m_nRelRightFill + nRelDist;
+ nParentInhAbsRightSpace = nParentInhAbsSpace;
+ break;
+ }
- // Filler widths are added to the outer columns, if there are no boxes
- // for them after the first pass (nWidth>0) or their width would become
- // too small or if there are COL tags and the filler width corresponds
- // to the border width.
- // In the last case we probably exported the table ourselves.
- if( m_nRelLeftFill &&
- ( m_nWidthSet>0 || nAbsLeftFill<MINLAY+m_nInhLeftBorderWidth ||
- (HasColTags() && nAbsLeftFill < nAbsLeftSpace+nParentInhAbsLeftSpace+20) ) )
- {
- SwHTMLTableLayoutColumn *pColumn = GetColumn( 0 );
- pColumn->SetAbsColWidth( pColumn->GetAbsColWidth()+nAbsLeftFill );
- pColumn->SetRelColWidth( pColumn->GetRelColWidth()+m_nRelLeftFill );
- m_nRelLeftFill = 0;
- m_nInhAbsLeftSpace = nAbsLeftSpace + nParentInhAbsLeftSpace;
- }
- if( m_nRelRightFill &&
- ( m_nWidthSet>0 || nAbsRightFill<MINLAY+m_nInhRightBorderWidth ||
- (HasColTags() && nAbsRightFill < nAbsRightSpace+nParentInhAbsRightSpace+20) ) )
- {
- SwHTMLTableLayoutColumn *pColumn = GetColumn( m_nCols-1 );
- pColumn->SetAbsColWidth( pColumn->GetAbsColWidth()+nAbsRightFill );
- pColumn->SetRelColWidth( pColumn->GetRelColWidth()+m_nRelRightFill );
- m_nRelRightFill = 0;
- m_nInhAbsRightSpace = nAbsRightSpace + nParentInhAbsRightSpace;
- }
+ // Filler widths are added to the outer columns, if there are no boxes
+ // for them after the first pass (nWidth>0) or their width would become
+ // too small or if there are COL tags and the filler width corresponds
+ // to the border width.
+ // In the last case we probably exported the table ourselves.
+ if( m_nRelLeftFill &&
+ ( m_nWidthSet>0 || nAbsLeftFill<MINLAY+m_nInhLeftBorderWidth ||
+ (HasColTags() && nAbsLeftFill < nAbsLeftSpace+nParentInhAbsLeftSpace+20) ) )
+ {
+ SwHTMLTableLayoutColumn *pColumn = GetColumn( 0 );
+ pColumn->SetAbsColWidth( pColumn->GetAbsColWidth()+nAbsLeftFill );
+ pColumn->SetRelColWidth( pColumn->GetRelColWidth()+m_nRelLeftFill );
+ m_nRelLeftFill = 0;
+ m_nInhAbsLeftSpace = nAbsLeftSpace + nParentInhAbsLeftSpace;
+ }
+ if( m_nRelRightFill &&
+ ( m_nWidthSet>0 || nAbsRightFill<MINLAY+m_nInhRightBorderWidth ||
+ (HasColTags() && nAbsRightFill < nAbsRightSpace+nParentInhAbsRightSpace+20) ) )
+ {
+ SwHTMLTableLayoutColumn *pColumn = GetColumn( m_nCols-1 );
+ pColumn->SetAbsColWidth( pColumn->GetAbsColWidth()+nAbsRightFill );
+ pColumn->SetRelColWidth( pColumn->GetRelColWidth()+m_nRelRightFill );
+ m_nRelRightFill = 0;
+ m_nInhAbsRightSpace = nAbsRightSpace + nParentInhAbsRightSpace;
}
}
@@ -1611,60 +1611,59 @@ void SwHTMLTableLayout::SetWidths( bool bCallPass2, sal_uInt16 nAbsAvail,
// whole table.
// We also adapt the table frame format. For nested tables we set the
// filler cell's width instead.
- if( IsTopTable() )
+ if( !IsTopTable() )
+ return;
+
+ SwTwips nCalcTabWidth = 0;
+ for( const SwTableLine *pLine : m_pSwTable->GetTabLines() )
+ lcl_ResizeLine( pLine, &nCalcTabWidth );
+ SAL_WARN_IF( std::abs( m_nRelTabWidth-nCalcTabWidth ) >= COLFUZZY, "sw.core",
+ "Table width is not equal to the row width" );
+
+ // Lock the table format when altering it, or else the box formats
+ // are altered again.
+ // Also, we need to preserve a percent setting if it exists.
+ SwFrameFormat *pFrameFormat = m_pSwTable->GetFrameFormat();
+ const_cast<SwTable *>(m_pSwTable)->LockModify();
+ SwFormatFrameSize aFrameSize( pFrameFormat->GetFrameSize() );
+ aFrameSize.SetWidth( m_nRelTabWidth );
+ bool bRel = m_bUseRelWidth &&
+ text::HoriOrientation::FULL!=pFrameFormat->GetHoriOrient().GetHoriOrient();
+ aFrameSize.SetWidthPercent( static_cast<sal_uInt8>(bRel ? m_nWidthOption : 0) );
+ pFrameFormat->SetFormatAttr( aFrameSize );
+ const_cast<SwTable *>(m_pSwTable)->UnlockModify();
+
+ // If the table is located in a frame, we also need to adapt the
+ // frame's width.
+ if( MayBeInFlyFrame() )
{
- SwTwips nCalcTabWidth = 0;
- for( const SwTableLine *pLine : m_pSwTable->GetTabLines() )
- lcl_ResizeLine( pLine, &nCalcTabWidth );
- SAL_WARN_IF( std::abs( m_nRelTabWidth-nCalcTabWidth ) >= COLFUZZY, "sw.core",
- "Table width is not equal to the row width" );
-
- // Lock the table format when altering it, or else the box formats
- // are altered again.
- // Also, we need to preserve a percent setting if it exists.
- SwFrameFormat *pFrameFormat = m_pSwTable->GetFrameFormat();
- const_cast<SwTable *>(m_pSwTable)->LockModify();
- SwFormatFrameSize aFrameSize( pFrameFormat->GetFrameSize() );
- aFrameSize.SetWidth( m_nRelTabWidth );
- bool bRel = m_bUseRelWidth &&
- text::HoriOrientation::FULL!=pFrameFormat->GetHoriOrient().GetHoriOrient();
- aFrameSize.SetWidthPercent( static_cast<sal_uInt8>(bRel ? m_nWidthOption : 0) );
- pFrameFormat->SetFormatAttr( aFrameSize );
- const_cast<SwTable *>(m_pSwTable)->UnlockModify();
-
- // If the table is located in a frame, we also need to adapt the
- // frame's width.
- if( MayBeInFlyFrame() )
+ SwFrameFormat *pFlyFrameFormat = FindFlyFrameFormat();
+ if( pFlyFrameFormat )
{
- SwFrameFormat *pFlyFrameFormat = FindFlyFrameFormat();
- if( pFlyFrameFormat )
- {
- SwFormatFrameSize aFlyFrameSize( SwFrameSize::Variable, m_nRelTabWidth, MINLAY );
+ SwFormatFrameSize aFlyFrameSize( SwFrameSize::Variable, m_nRelTabWidth, MINLAY );
- if( m_bUseRelWidth )
- {
- // For percentage settings we set the width to the minimum.
- aFlyFrameSize.SetWidth( m_nMin > USHRT_MAX ? USHRT_MAX
- : m_nMin );
- aFlyFrameSize.SetWidthPercent( static_cast<sal_uInt8>(m_nWidthOption) );
- }
- pFlyFrameFormat->SetFormatAttr( aFlyFrameSize );
+ if( m_bUseRelWidth )
+ {
+ // For percentage settings we set the width to the minimum.
+ aFlyFrameSize.SetWidth( m_nMin > USHRT_MAX ? USHRT_MAX
+ : m_nMin );
+ aFlyFrameSize.SetWidthPercent( static_cast<sal_uInt8>(m_nWidthOption) );
}
+ pFlyFrameFormat->SetFormatAttr( aFlyFrameSize );
}
+ }
#ifdef DBG_UTIL
+ {
+ // check if the tables have correct widths
+ SwTwips nSize = m_pSwTable->GetFrameFormat()->GetFrameSize().GetWidth();
+ const SwTableLines& rLines = m_pSwTable->GetTabLines();
+ for (size_t n = 0; n < rLines.size(); ++n)
{
- // check if the tables have correct widths
- SwTwips nSize = m_pSwTable->GetFrameFormat()->GetFrameSize().GetWidth();
- const SwTableLines& rLines = m_pSwTable->GetTabLines();
- for (size_t n = 0; n < rLines.size(); ++n)
- {
- CheckBoxWidth( *rLines[ n ], nSize );
- }
+ CheckBoxWidth( *rLines[ n ], nSize );
}
-#endif
-
}
+#endif
}
void SwHTMLTableLayout::Resize_( sal_uInt16 nAbsAvail, bool bRecalc )
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 19d132d333fa..7e5ca718e7cc 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -183,36 +183,36 @@ static void lcl_ClearArea( const SwFrame &rFrame,
SwRegionRects aRegion( rPtArea, 4 );
aRegion -= rGrfArea;
- if ( !aRegion.empty() )
+ if ( aRegion.empty() )
+ return;
+
+ const SvxBrushItem *pItem;
+ const Color *pCol;
+ SwRect aOrigRect;
+ drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes;
+
+ if ( rFrame.GetBackgroundBrush( aFillAttributes, pItem, pCol, aOrigRect, false, /*bConsiderTextBox=*/false ) )
{
- const SvxBrushItem *pItem;
- const Color *pCol;
- SwRect aOrigRect;
- drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes;
+ SwRegionRects const region(rPtArea);
+ basegfx::utils::B2DClipState aClipState;
+ const bool bDone(::DrawFillAttributes(aFillAttributes, aOrigRect, region, aClipState, rOut));
- if ( rFrame.GetBackgroundBrush( aFillAttributes, pItem, pCol, aOrigRect, false, /*bConsiderTextBox=*/false ) )
+ if(!bDone)
{
- SwRegionRects const region(rPtArea);
- basegfx::utils::B2DClipState aClipState;
- const bool bDone(::DrawFillAttributes(aFillAttributes, aOrigRect, region, aClipState, rOut));
-
- if(!bDone)
+ for( const auto &rRegion : aRegion )
{
- for( const auto &rRegion : aRegion )
- {
- ::DrawGraphic( pItem, &rOut, aOrigRect, rRegion );
- }
+ ::DrawGraphic( pItem, &rOut, aOrigRect, rRegion );
}
}
- else
- {
- rOut.Push( PushFlags::FILLCOLOR|PushFlags::LINECOLOR );
- rOut.SetFillColor( rFrame.getRootFrame()->GetCurrShell()->Imp()->GetRetoucheColor());
- rOut.SetLineColor();
- for( const auto &rRegion : aRegion )
- rOut.DrawRect( rRegion.SVRect() );
- rOut.Pop();
- }
+ }
+ else
+ {
+ rOut.Push( PushFlags::FILLCOLOR|PushFlags::LINECOLOR );
+ rOut.SetFillColor( rFrame.getRootFrame()->GetCurrShell()->Imp()->GetRetoucheColor());
+ rOut.SetLineColor();
+ for( const auto &rRegion : aRegion )
+ rOut.DrawRect( rRegion.SVRect() );
+ rOut.Pop();
}
}
@@ -454,20 +454,20 @@ void SwNoTextFrame::GetGrfArea( SwRect &rRect, SwRect* pOrigRect ) const
rRect.SSize( aVisSz );
// Calculate the whole graphic if needed
- if ( pOrigRect )
- {
- Size aTmpSz( aGrfSz );
- aGrfPt.setX(aGrfPt.getX() + nLeftCrop);
- aTmpSz.AdjustWidth( -(nLeftCrop + nRightCrop) );
- aGrfPt.setY(aGrfPt.getY() + nTopCrop);
- aTmpSz.AdjustHeight( -(nTopCrop + nBottomCrop) );
+ if ( !pOrigRect )
+ return;
- if( MirrorGraph::Dont != nMirror )
- lcl_CalcRect( aGrfPt, aTmpSz, nMirror );
+ Size aTmpSz( aGrfSz );
+ aGrfPt.setX(aGrfPt.getX() + nLeftCrop);
+ aTmpSz.AdjustWidth( -(nLeftCrop + nRightCrop) );
+ aGrfPt.setY(aGrfPt.getY() + nTopCrop);
+ aTmpSz.AdjustHeight( -(nTopCrop + nBottomCrop) );
- pOrigRect->Pos ( aGrfPt );
- pOrigRect->SSize( aTmpSz );
- }
+ if( MirrorGraph::Dont != nMirror )
+ lcl_CalcRect( aGrfPt, aTmpSz, nMirror );
+
+ pOrigRect->Pos ( aGrfPt );
+ pOrigRect->SSize( aTmpSz );
}
/** By returning the surrounding Fly's size which equals the graphic's size */
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 1d2ae4f970d4..2dd071433192 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -102,21 +102,21 @@ const SwNumFormat* SwNumRule::GetNumFormat( sal_uInt16 i ) const
void SwNumRule::SetName( const OUString & rName,
IDocumentListsAccess& rDocListAccess)
{
- if ( msName != rName )
+ if ( msName == rName )
+ return;
+
+ if (mpNumRuleMap)
{
- if (mpNumRuleMap)
- {
- mpNumRuleMap->erase(msName);
- (*mpNumRuleMap)[rName] = this;
+ mpNumRuleMap->erase(msName);
+ (*mpNumRuleMap)[rName] = this;
- if ( !GetDefaultListId().isEmpty() )
- {
- rDocListAccess.trackChangeOfListStyleName( msName, rName );
- }
+ if ( !GetDefaultListId().isEmpty() )
+ {
+ rDocListAccess.trackChangeOfListStyleName( msName, rName );
}
-
- msName = rName;
}
+
+ msName = rName;
}
void SwNumRule::GetTextNodeList( SwNumRule::tTextNodeList& rTextNodeList ) const
@@ -1237,50 +1237,50 @@ namespace numfunc
const uno::Any* pValues = aValues.getConstArray();
OSL_ENSURE( aValues.getLength() == aPropNames.getLength(),
"<SwDefBulletConfig::SwDefBulletConfig()> - GetProperties failed");
- if ( aValues.getLength() == aPropNames.getLength() )
+ if ( aValues.getLength() != aPropNames.getLength() )
+ return;
+
+ for ( int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
{
- for ( int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
+ if ( pValues[nProp].hasValue() )
{
- if ( pValues[nProp].hasValue() )
+ switch ( nProp )
{
- switch ( nProp )
+ case 0:
{
- case 0:
- {
- OUString aStr;
- pValues[nProp] >>= aStr;
- msFontname = aStr;
- mbUserDefinedFontname = true;
- }
- break;
- case 1:
- case 2:
- {
- sal_Int16 nTmp = 0;
- pValues[nProp] >>= nTmp;
- if ( nProp == 1 )
- meFontWeight = static_cast<FontWeight>(nTmp);
- else if ( nProp == 2 )
- meFontItalic = static_cast<FontItalic>(nTmp);
- }
- break;
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- {
- sal_Unicode cChar = sal_Unicode();
- pValues[nProp] >>= cChar;
- mnLevelChars[nProp-3] = cChar;
- }
- break;
+ OUString aStr;
+ pValues[nProp] >>= aStr;
+ msFontname = aStr;
+ mbUserDefinedFontname = true;
+ }
+ break;
+ case 1:
+ case 2:
+ {
+ sal_Int16 nTmp = 0;
+ pValues[nProp] >>= nTmp;
+ if ( nProp == 1 )
+ meFontWeight = static_cast<FontWeight>(nTmp);
+ else if ( nProp == 2 )
+ meFontItalic = static_cast<FontItalic>(nTmp);
+ }
+ break;
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ {
+ sal_Unicode cChar = sal_Unicode();
+ pValues[nProp] >>= cChar;
+ mnLevelChars[nProp-3] = cChar;
}
+ break;
}
}
}
@@ -1404,23 +1404,23 @@ namespace numfunc
const css::uno::Any* pValues = aValues.getConstArray();
OSL_ENSURE( aValues.getLength() == aPropNames.getLength(),
"<SwNumberingUIBehaviorConfig::LoadConfig()> - GetProperties failed");
- if ( aValues.getLength() == aPropNames.getLength() )
+ if ( aValues.getLength() != aPropNames.getLength() )
+ return;
+
+ for ( int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
{
- for ( int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
+ if ( pValues[nProp].hasValue() )
{
- if ( pValues[nProp].hasValue() )
+ switch ( nProp )
{
- switch ( nProp )
+ case 0:
{
- case 0:
- {
- pValues[nProp] >>= mbChangeIndentOnTabAtFirstPosOfFirstListItem;
- }
- break;
- default:
- {
- OSL_FAIL( "<SwNumberingUIBehaviorConfig::LoadConfig()> - unknown configuration property");
- }
+ pValues[nProp] >>= mbChangeIndentOnTabAtFirstPosOfFirstListItem;
+ }
+ break;
+ default:
+ {
+ OSL_FAIL( "<SwNumberingUIBehaviorConfig::LoadConfig()> - unknown configuration property");
}
}
}
diff --git a/sw/source/core/doc/swserv.cxx b/sw/source/core/doc/swserv.cxx
index 95b3982ea860..54e070dc2ade 100644
--- a/sw/source/core/doc/swserv.cxx
+++ b/sw/source/core/doc/swserv.cxx
@@ -107,74 +107,74 @@ bool SwServerObject::GetData( uno::Any & rData,
void SwServerObject::SendDataChanged( const SwPosition& rPos )
{
// Is someone interested in our changes?
- if( HasDataLinks() )
- {
- bool bCall = false;
- const SwStartNode* pNd = nullptr;
- switch( m_eType )
- {
- case BOOKMARK_SERVER:
- if( m_CNTNT_TYPE.pBkmk->IsExpanded() )
- {
- bCall = m_CNTNT_TYPE.pBkmk->GetMarkStart() <= rPos
- && rPos < m_CNTNT_TYPE.pBkmk->GetMarkEnd();
- }
- break;
+ if( !HasDataLinks() )
+ return;
- case TABLE_SERVER: pNd = m_CNTNT_TYPE.pTableNd; break;
- case SECTION_SERVER: pNd = m_CNTNT_TYPE.pSectNd; break;
- case NONE_SERVER: break;
- }
- if( pNd )
- {
- sal_uLong nNd = rPos.nNode.GetIndex();
- bCall = pNd->GetIndex() < nNd && nNd < pNd->EndOfSectionIndex();
- }
-
- if( bCall )
- {
- // Recognize recursions and flag them
- IsLinkInServer( nullptr );
- SvLinkSource::NotifyDataChanged();
- }
- }
-}
-
-void SwServerObject::SendDataChanged( const SwPaM& rRange )
-{
- // Is someone interested in our changes?
- if( HasDataLinks() )
+ bool bCall = false;
+ const SwStartNode* pNd = nullptr;
+ switch( m_eType )
{
- bool bCall = false;
- const SwStartNode* pNd = nullptr;
- const SwPosition* pStt = rRange.Start(), *pEnd = rRange.End();
- switch( m_eType )
- {
case BOOKMARK_SERVER:
- if(m_CNTNT_TYPE.pBkmk->IsExpanded())
+ if( m_CNTNT_TYPE.pBkmk->IsExpanded() )
{
- bCall = *pStt <= m_CNTNT_TYPE.pBkmk->GetMarkEnd()
- && *pEnd > m_CNTNT_TYPE.pBkmk->GetMarkStart();
+ bCall = m_CNTNT_TYPE.pBkmk->GetMarkStart() <= rPos
+ && rPos < m_CNTNT_TYPE.pBkmk->GetMarkEnd();
}
break;
case TABLE_SERVER: pNd = m_CNTNT_TYPE.pTableNd; break;
case SECTION_SERVER: pNd = m_CNTNT_TYPE.pSectNd; break;
case NONE_SERVER: break;
- }
- if( pNd )
- {
- // Is the start area within the node area?
- bCall = pStt->nNode.GetIndex() < pNd->EndOfSectionIndex() &&
- pEnd->nNode.GetIndex() >= pNd->GetIndex();
- }
+ }
+ if( pNd )
+ {
+ sal_uLong nNd = rPos.nNode.GetIndex();
+ bCall = pNd->GetIndex() < nNd && nNd < pNd->EndOfSectionIndex();
+ }
+
+ if( bCall )
+ {
+ // Recognize recursions and flag them
+ IsLinkInServer( nullptr );
+ SvLinkSource::NotifyDataChanged();
+ }
+}
+
+void SwServerObject::SendDataChanged( const SwPaM& rRange )
+{
+ // Is someone interested in our changes?
+ if( !HasDataLinks() )
+ return;
- if( bCall )
+ bool bCall = false;
+ const SwStartNode* pNd = nullptr;
+ const SwPosition* pStt = rRange.Start(), *pEnd = rRange.End();
+ switch( m_eType )
+ {
+ case BOOKMARK_SERVER:
+ if(m_CNTNT_TYPE.pBkmk->IsExpanded())
{
- // Recognize recursions and flag them
- IsLinkInServer( nullptr );
- SvLinkSource::NotifyDataChanged();
+ bCall = *pStt <= m_CNTNT_TYPE.pBkmk->GetMarkEnd()
+ && *pEnd > m_CNTNT_TYPE.pBkmk->GetMarkStart();
}
+ break;
+
+ case TABLE_SERVER: pNd = m_CNTNT_TYPE.pTableNd; break;
+ case SECTION_SERVER: pNd = m_CNTNT_TYPE.pSectNd; break;
+ case NONE_SERVER: break;
+ }
+ if( pNd )
+ {
+ // Is the start area within the node area?
+ bCall = pStt->nNode.GetIndex() < pNd->EndOfSectionIndex() &&
+ pEnd->nNode.GetIndex() >= pNd->GetIndex();
+ }
+
+ if( bCall )
+ {
+ // Recognize recursions and flag them
+ IsLinkInServer( nullptr );
+ SvLinkSource::NotifyDataChanged();
}
}
@@ -289,30 +289,30 @@ SwDataChanged::SwDataChanged( SwDoc* pDc, const SwPosition& rPos )
SwDataChanged::~SwDataChanged()
{
// JP 09.04.96: Only if the Layout is available (thus during input)
- if( m_pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() )
- {
- const ::sfx2::SvLinkSources& rServers = m_pDoc->getIDocumentLinksAdministration().GetLinkManager().GetServers();
+ if( !m_pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() )
+ return;
+
+ const ::sfx2::SvLinkSources& rServers = m_pDoc->getIDocumentLinksAdministration().GetLinkManager().GetServers();
- ::sfx2::SvLinkSources aTemp(rServers);
- for( const auto& rpLinkSrc : aTemp )
+ ::sfx2::SvLinkSources aTemp(rServers);
+ for( const auto& rpLinkSrc : aTemp )
+ {
+ ::sfx2::SvLinkSourceRef refObj( rpLinkSrc );
+ // Anyone else interested in the Object?
+ if( refObj->HasDataLinks() && dynamic_cast<const SwServerObject*>( refObj.get() ) != nullptr)
{
- ::sfx2::SvLinkSourceRef refObj( rpLinkSrc );
- // Anyone else interested in the Object?
- if( refObj->HasDataLinks() && dynamic_cast<const SwServerObject*>( refObj.get() ) != nullptr)
- {
- SwServerObject& rObj = *static_cast<SwServerObject*>( refObj.get() );
- if( m_pPos )
- rObj.SendDataChanged( *m_pPos );
- else
- rObj.SendDataChanged( *m_pPam );
- }
+ SwServerObject& rObj = *static_cast<SwServerObject*>( refObj.get() );
+ if( m_pPos )
+ rObj.SendDataChanged( *m_pPos );
+ else
+ rObj.SendDataChanged( *m_pPam );
+ }
- // We shouldn't have a connection anymore
- if( !refObj->HasDataLinks() )
- {
- // Then remove from the list
- m_pDoc->getIDocumentLinksAdministration().GetLinkManager().RemoveServer( rpLinkSrc );
- }
+ // We shouldn't have a connection anymore
+ if( !refObj->HasDataLinks() )
+ {
+ // Then remove from the list
+ m_pDoc->getIDocumentLinksAdministration().GetLinkManager().RemoveServer( rpLinkSrc );
}
}
}
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index 293e87898cdb..ee25a5173150 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -529,30 +529,30 @@ void SwTableAutoFormat::UpdateFromSet( sal_uInt8 nPos,
pFormat->SetColor( rSet.Get( RES_CHRATR_COLOR ) );
pFormat->SetAdjust( rSet.Get( RES_PARATR_ADJUST ) );
}
- if( SwTableAutoFormatUpdateFlags::Box & eFlags )
- {
- pFormat->SetBox( rSet.Get( RES_BOX ) );
+ if( !(SwTableAutoFormatUpdateFlags::Box & eFlags) )
+ return;
+
+ pFormat->SetBox( rSet.Get( RES_BOX ) );
// FIXME - add attribute IDs for the diagonal line items
// pFormat->SetTLBR( (SvxLineItem&)rSet.Get( RES_... ) );
// pFormat->SetBLTR( (SvxLineItem&)rSet.Get( RES_... ) );
- pFormat->SetBackground( rSet.Get( RES_BACKGROUND ) );
- pFormat->SetTextOrientation(rSet.Get(RES_FRAMEDIR));
- pFormat->SetVerticalAlignment(rSet.Get(RES_VERT_ORIENT));
-
- const SwTableBoxNumFormat* pNumFormatItem;
- const SvNumberformat* pNumFormat = nullptr;
- if( SfxItemState::SET == rSet.GetItemState( RES_BOXATR_FORMAT, true,
- reinterpret_cast<const SfxPoolItem**>(&pNumFormatItem) ) && pNFormatr &&
- nullptr != (pNumFormat = pNFormatr->GetEntry( pNumFormatItem->GetValue() )) )
- pFormat->SetValueFormat( pNumFormat->GetFormatstring(),
- pNumFormat->GetLanguage(),
- ::GetAppLanguage());
- else
- {
- // default
- pFormat->SetValueFormat( OUString(), LANGUAGE_SYSTEM,
- ::GetAppLanguage() );
- }
+ pFormat->SetBackground( rSet.Get( RES_BACKGROUND ) );
+ pFormat->SetTextOrientation(rSet.Get(RES_FRAMEDIR));
+ pFormat->SetVerticalAlignment(rSet.Get(RES_VERT_ORIENT));
+
+ const SwTableBoxNumFormat* pNumFormatItem;
+ const SvNumberformat* pNumFormat = nullptr;
+ if( SfxItemState::SET == rSet.GetItemState( RES_BOXATR_FORMAT, true,
+ reinterpret_cast<const SfxPoolItem**>(&pNumFormatItem) ) && pNFormatr &&
+ nullptr != (pNumFormat = pNFormatr->GetEntry( pNumFormatItem->GetValue() )) )
+ pFormat->SetValueFormat( pNumFormat->GetFormatstring(),
+ pNumFormat->GetLanguage(),
+ ::GetAppLanguage());
+ else
+ {
+ // default
+ pFormat->SetValueFormat( OUString(), LANGUAGE_SYSTEM,
+ ::GetAppLanguage() );
}
// we cannot handle the rest, that's specific to StarCalc
@@ -612,62 +612,62 @@ void SwTableAutoFormat::UpdateToSet(const sal_uInt8 nPos, const bool bSingleRowT
rSet.Put( rChg.GetAdjust() );
}
- if( SwTableAutoFormatUpdateFlags::Box & eFlags )
+ if( !(SwTableAutoFormatUpdateFlags::Box & eFlags) )
+ return;
+
+ if( IsFrame() )
{
- if( IsFrame() )
- {
- SvxBoxItem aAutoFormatBox = rChg.GetBox();
+ SvxBoxItem aAutoFormatBox = rChg.GetBox();
- // No format box is adequate to specify the borders of single column/row tables, so combine first/last.
- if ( bSingleRowTable || bSingleColTable )
- {
- sal_uInt8 nSingleRowOrColumnId = 15; //LAST_ROW_END_COLUMN
- if ( !bSingleRowTable )
- nSingleRowOrColumnId = nPos + 3; //LAST COLUMN (3, 7, 11, 15)
- else if ( !bSingleColTable )
- nSingleRowOrColumnId = nPos + 12; //LAST ROW (12, 13, 14, 15)
-
- assert( nSingleRowOrColumnId < 16 );
- const SvxBoxItem aLastAutoFormatBox( GetBoxFormat(nSingleRowOrColumnId).GetBox() );
- if ( bSingleRowTable )
- aAutoFormatBox.SetLine( aLastAutoFormatBox.GetLine(SvxBoxItemLine::BOTTOM), SvxBoxItemLine::BOTTOM );
- if ( bSingleColTable )
- aAutoFormatBox.SetLine( aLastAutoFormatBox.GetLine(SvxBoxItemLine::RIGHT), SvxBoxItemLine::RIGHT );
- }
+ // No format box is adequate to specify the borders of single column/row tables, so combine first/last.
+ if ( bSingleRowTable || bSingleColTable )
+ {
+ sal_uInt8 nSingleRowOrColumnId = 15; //LAST_ROW_END_COLUMN
+ if ( !bSingleRowTable )
+ nSingleRowOrColumnId = nPos + 3; //LAST COLUMN (3, 7, 11, 15)
+ else if ( !bSingleColTable )
+ nSingleRowOrColumnId = nPos + 12; //LAST ROW (12, 13, 14, 15)
+
+ assert( nSingleRowOrColumnId < 16 );
+ const SvxBoxItem aLastAutoFormatBox( GetBoxFormat(nSingleRowOrColumnId).GetBox() );
+ if ( bSingleRowTable )
+ aAutoFormatBox.SetLine( aLastAutoFormatBox.GetLine(SvxBoxItemLine::BOTTOM), SvxBoxItemLine::BOTTOM );
+ if ( bSingleColTable )
+ aAutoFormatBox.SetLine( aLastAutoFormatBox.GetLine(SvxBoxItemLine::RIGHT), SvxBoxItemLine::RIGHT );
+ }
- rSet.Put( aAutoFormatBox );
+ rSet.Put( aAutoFormatBox );
// FIXME - uncomment the lines to put the diagonal line items
// rSet.Put( rChg.GetTLBR() );
// rSet.Put( rChg.GetBLTR() );
- }
- if( IsBackground() )
- rSet.Put( rChg.GetBackground() );
+ }
+ if( IsBackground() )
+ rSet.Put( rChg.GetBackground() );
- rSet.Put(rChg.GetTextOrientation());
+ rSet.Put(rChg.GetTextOrientation());
- // Do not put a VertAlign when it has default value.
- // It prevents the export of default value by automatic cell-styles export.
- if (rChg.GetVerticalAlignment().GetVertOrient() != GetDefaultBoxFormat().GetVerticalAlignment().GetVertOrient())
- rSet.Put(rChg.GetVerticalAlignment());
+ // Do not put a VertAlign when it has default value.
+ // It prevents the export of default value by automatic cell-styles export.
+ if (rChg.GetVerticalAlignment().GetVertOrient() != GetDefaultBoxFormat().GetVerticalAlignment().GetVertOrient())
+ rSet.Put(rChg.GetVerticalAlignment());
- if( IsValueFormat() && pNFormatr )
- {
- OUString sFormat;
- LanguageType eLng, eSys;
- rChg.GetValueFormat( sFormat, eLng, eSys );
- if( !sFormat.isEmpty() )
- {
- SvNumFormatType nType;
- bool bNew;
- sal_Int32 nCheckPos;
- sal_uInt32 nKey = pNFormatr->GetIndexPuttingAndConverting( sFormat, eLng,
- eSys, nType, bNew, nCheckPos);
- rSet.Put( SwTableBoxNumFormat( nKey ));
- }
- else
- rSet.ClearItem( RES_BOXATR_FORMAT );
- }
+ if( !(IsValueFormat() && pNFormatr) )
+ return;
+
+ OUString sFormat;
+ LanguageType eLng, eSys;
+ rChg.GetValueFormat( sFormat, eLng, eSys );
+ if( !sFormat.isEmpty() )
+ {
+ SvNumFormatType nType;
+ bool bNew;
+ sal_Int32 nCheckPos;
+ sal_uInt32 nKey = pNFormatr->GetIndexPuttingAndConverting( sFormat, eLng,
+ eSys, nType, bNew, nCheckPos);
+ rSet.Put( SwTableBoxNumFormat( nKey ));
}
+ else
+ rSet.ClearItem( RES_BOXATR_FORMAT );
// we cannot handle the rest, that's specific to StarCalc
}
diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx
index cdb75e14755b..d3bc393b906c 100644
--- a/sw/source/core/doc/tblcpy.cxx
+++ b/sw/source/core/doc/tblcpy.cxx
@@ -179,59 +179,59 @@ namespace
LineStructure::size_type nMinSize )
: mnStartCol(USHRT_MAX), mnAddLine(0)
{
- if( !rFndBox.GetLines().empty() )
+ if( rFndBox.GetLines().empty() )
+ return;
+
+ bool bNoSelection = rSelBoxes.size() < 2;
+ FndLines_t &rFndLines = rFndBox.GetLines();
+ maCols.push_front(0);
+ const SwTableLine* pLine = rFndLines.front()->GetLine();
+ const sal_uInt16 nStartLn = rTable.GetTabLines().GetPos( pLine );
+ SwTableLines::size_type nEndLn = nStartLn;
+ if( rFndLines.size() > 1 )
{
- bool bNoSelection = rSelBoxes.size() < 2;
- FndLines_t &rFndLines = rFndBox.GetLines();
- maCols.push_front(0);
- const SwTableLine* pLine = rFndLines.front()->GetLine();
- const sal_uInt16 nStartLn = rTable.GetTabLines().GetPos( pLine );
- SwTableLines::size_type nEndLn = nStartLn;
- if( rFndLines.size() > 1 )
- {
- pLine = rFndLines.back()->GetLine();
- nEndLn = rTable.GetTabLines().GetPos( pLine );
- }
- if( nStartLn < USHRT_MAX && nEndLn < USHRT_MAX )
+ pLine = rFndLines.back()->GetLine();
+ nEndLn = rTable.GetTabLines().GetPos( pLine );
+ }
+ if( nStartLn < USHRT_MAX && nEndLn < USHRT_MAX )
+ {
+ const SwTableLines &rLines = rTable.GetTabLines();
+ if( bNoSelection && nMinSize > nEndLn - nStartLn + 1 )
{
- const SwTableLines &rLines = rTable.GetTabLines();
- if( bNoSelection && nMinSize > nEndLn - nStartLn + 1 )
+ SwTableLines::size_type nNewEndLn = nStartLn + nMinSize - 1;
+ if( nNewEndLn >= rLines.size() )
{
- SwTableLines::size_type nNewEndLn = nStartLn + nMinSize - 1;
- if( nNewEndLn >= rLines.size() )
- {
- mnAddLine = nNewEndLn - rLines.size() + 1;
- nNewEndLn = rLines.size() - 1;
- }
- while( nEndLn < nNewEndLn )
- {
- SwTableLine *pLine2 = rLines[ ++nEndLn ];
- SwTableBox *pTmpBox = pLine2->GetTabBoxes()[0];
- FndLine_ *pInsLine = new FndLine_( pLine2, &rFndBox );
- pInsLine->GetBoxes().insert(pInsLine->GetBoxes().begin(), std::make_unique<FndBox_>(pTmpBox, pInsLine));
- rFndLines.push_back(std::unique_ptr<FndLine_>(pInsLine));
- }
+ mnAddLine = nNewEndLn - rLines.size() + 1;
+ nNewEndLn = rLines.size() - 1;
}
- maLines.resize( nEndLn - nStartLn + 1 );
- const SwSelBoxes* pSelBoxes = &rSelBoxes;
- sal_uInt16 nCnt = 0;
- for( SwTableLines::size_type nLine = nStartLn; nLine <= nEndLn; ++nLine )
+ while( nEndLn < nNewEndLn )
{
- addLine( nCnt, rLines[nLine]->GetTabBoxes(),
- pSelBoxes, rTable.IsNewModel() );
- if( bNoSelection )
- pSelBoxes = nullptr;
+ SwTableLine *pLine2 = rLines[ ++nEndLn ];
+ SwTableBox *pTmpBox = pLine2->GetTabBoxes()[0];
+ FndLine_ *pInsLine = new FndLine_( pLine2, &rFndBox );
+ pInsLine->GetBoxes().insert(pInsLine->GetBoxes().begin(), std::make_unique<FndBox_>(pTmpBox, pInsLine));
+ rFndLines.push_back(std::unique_ptr<FndLine_>(pInsLine));
}
}
- if( bNoSelection && mnStartCol < USHRT_MAX )
+ maLines.resize( nEndLn - nStartLn + 1 );
+ const SwSelBoxes* pSelBoxes = &rSelBoxes;
+ sal_uInt16 nCnt = 0;
+ for( SwTableLines::size_type nLine = nStartLn; nLine <= nEndLn; ++nLine )
{
- sal_uInt16 nIdx = std::min(mnStartCol, static_cast<sal_uInt16>(maLines[0].size()));
- mnStartCol = std::accumulate(maLines[0].begin(), maLines[0].begin() + nIdx, sal_uInt16(0),
- [](sal_uInt16 sum, const BoxSpanInfo& rInfo) { return sum + rInfo.mnColSpan; });
+ addLine( nCnt, rLines[nLine]->GetTabBoxes(),
+ pSelBoxes, rTable.IsNewModel() );
+ if( bNoSelection )
+ pSelBoxes = nullptr;
}
- else
- mnStartCol = USHRT_MAX;
}
+ if( bNoSelection && mnStartCol < USHRT_MAX )
+ {
+ sal_uInt16 nIdx = std::min(mnStartCol, static_cast<sal_uInt16>(maLines[0].size()));
+ mnStartCol = std::accumulate(maLines[0].begin(), maLines[0].begin() + nIdx, sal_uInt16(0),
+ [](sal_uInt16 sum, const BoxSpanInfo& rInfo) { return sum + rInfo.mnColSpan; });
+ }
+ else
+ mnStartCol = USHRT_MAX;
}
void TableStructure::addLine( sal_uInt16 &rLine, const SwTableBoxes& rBoxes,
@@ -325,41 +325,41 @@ namespace
aInfo.mpCopy = nullptr;
aInfo.mpBox = bCovered ? nullptr : pBox;
maLines[nLine].push_back( aInfo );
- if( aInfo.mbSelected )
+ if( !aInfo.mbSelected )
+ return;
+
+ if( rbSelected )
{
- if( rbSelected )
+ while( rpSel != maLines[nLine].end() )
{
- while( rpSel != maLines[nLine].end() )
- {
- rpSel->mbSelected = true;
- ++rpSel;
- }
- }
- else
- {
- rpSel = maLines[nLine].end();
- rbSelected = true;
+ rpSel->mbSelected = true;
+ ++rpSel;
}
- --rpSel;
}
+ else
+ {
+ rpSel = maLines[nLine].end();
+ rbSelected = true;
+ }
+ --rpSel;
}
void TableStructure::moreLines( const SwTable& rTable )
{
- if( mnAddLine )
+ if( !mnAddLine )
+ return;
+
+ const SwTableLines &rLines = rTable.GetTabLines();
+ const sal_uInt16 nLineCount = rLines.size();
+ if( nLineCount < mnAddLine )
+ mnAddLine = nLineCount;
+ sal_uInt16 nLine = static_cast<sal_uInt16>(maLines.size());
+ maLines.resize( nLine + mnAddLine );
+ while( mnAddLine )
{
- const SwTableLines &rLines = rTable.GetTabLines();
- const sal_uInt16 nLineCount = rLines.size();
- if( nLineCount < mnAddLine )
- mnAddLine = nLineCount;
- sal_uInt16 nLine = static_cast<sal_uInt16>(maLines.size());
- maLines.resize( nLine + mnAddLine );
- while( mnAddLine )
- {
- SwTableLine *pLine = rLines[ nLineCount - mnAddLine ];
- addLine( nLine, pLine->GetTabBoxes(), nullptr, rTable.IsNewModel() );
- --mnAddLine;
- }
+ SwTableLine *pLine = rLines[ nLineCount - mnAddLine ];
+ addLine( nLine, pLine->GetTabBoxes(), nullptr, rTable.IsNewModel() );
+ --mnAddLine;
}
}
@@ -580,61 +580,61 @@ static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox,
// heading
SwTextNode *const pTextNd = aSavePos.GetNode().GetTextNode();
- if( pTextNd )
+ if( !pTextNd )
+ return;
+
+ const sal_uInt16 nPoolId = pTextNd->GetTextColl()->GetPoolFormatId();
+ if( bReplaceColl &&
+ (( 1 < rDstTable.GetTabLines().size() &&
+ pLine == rDstTable.GetTabLines().front() )
+ // Is the Table's content still valid?
+ ? RES_POOLCOLL_TABLE == nPoolId
+ : RES_POOLCOLL_TABLE_HDLN == nPoolId ) )
{
- const sal_uInt16 nPoolId = pTextNd->GetTextColl()->GetPoolFormatId();
- if( bReplaceColl &&
- (( 1 < rDstTable.GetTabLines().size() &&
- pLine == rDstTable.GetTabLines().front() )
- // Is the Table's content still valid?
- ? RES_POOLCOLL_TABLE == nPoolId
- : RES_POOLCOLL_TABLE_HDLN == nPoolId ) )
+ SwTextFormatColl* pColl = pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(
+ static_cast<sal_uInt16>(
+ RES_POOLCOLL_TABLE == nPoolId
+ ? RES_POOLCOLL_TABLE_HDLN
+ : RES_POOLCOLL_TABLE ) );
+ if( pColl ) // Apply style
{
- SwTextFormatColl* pColl = pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(
- static_cast<sal_uInt16>(
- RES_POOLCOLL_TABLE == nPoolId
- ? RES_POOLCOLL_TABLE_HDLN
- : RES_POOLCOLL_TABLE ) );
- if( pColl ) // Apply style
- {
- SwPaM aPam( aSavePos );
- aPam.SetMark();
- aPam.Move( fnMoveForward, GoInSection );
- pDoc->SetTextFormatColl( aPam, pColl );
- }
+ SwPaM aPam( aSavePos );
+ aPam.SetMark();
+ aPam.Move( fnMoveForward, GoInSection );
+ pDoc->SetTextFormatColl( aPam, pColl );
}
+ }
- // Delete the current Formula/Format/Value values
- if( SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_FORMAT ) ||
- SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_FORMULA ) ||
- SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_VALUE ) )
- {
- pDstBox->ClaimFrameFormat()->ResetFormatAttr( RES_BOXATR_FORMAT,
- RES_BOXATR_VALUE );
- }
+ // Delete the current Formula/Format/Value values
+ if( SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_FORMAT ) ||
+ SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_FORMULA ) ||
+ SfxItemState::SET == pDstBox->GetFrameFormat()->GetItemState( RES_BOXATR_VALUE ) )
+ {
+ pDstBox->ClaimFrameFormat()->ResetFormatAttr( RES_BOXATR_FORMAT,
+ RES_BOXATR_VALUE );
+ }
- // Copy the TableBoxAttributes - Formula/Format/Value
- if( pCpyBox )
- {
- SfxItemSet aBoxAttrSet( pCpyDoc->GetAttrPool(), svl::Items<RES_BOXATR_FORMAT,
- RES_BOXATR_VALUE>{} );
- aBoxAttrSet.Put( pCpyBox->GetFrameFormat()->GetAttrSet() );
- if( aBoxAttrSet.Count() )
- {
- const SfxPoolItem* pItem;
- SvNumberFormatter* pN = pDoc->GetNumberFormatter( false );
- if( pN && pN->HasMergeFormatTable() && SfxItemState::SET == aBoxAttrSet.
- GetItemState( RES_BOXATR_FORMAT, false, &pItem ) )
- {
- sal_uLong nOldIdx = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
- sal_uLong nNewIdx = pN->GetMergeFormatIndex( nOldIdx );
- if( nNewIdx != nOldIdx )
- aBoxAttrSet.Put( SwTableBoxNumFormat( nNewIdx ));
- }
- pDstBox->ClaimFrameFormat()->SetFormatAttr( aBoxAttrSet );
- }
- }
+ // Copy the TableBoxAttributes - Formula/Format/Value
+ if( !pCpyBox )
+ return;
+
+ SfxItemSet aBoxAttrSet( pCpyDoc->GetAttrPool(), svl::Items<RES_BOXATR_FORMAT,
+ RES_BOXATR_VALUE>{} );
+ aBoxAttrSet.Put( pCpyBox->GetFrameFormat()->GetAttrSet() );
+ if( !aBoxAttrSet.Count() )
+ return;
+
+ const SfxPoolItem* pItem;
+ SvNumberFormatter* pN = pDoc->GetNumberFormatter( false );
+ if( pN && pN->HasMergeFormatTable() && SfxItemState::SET == aBoxAttrSet.
+ GetItemState( RES_BOXATR_FORMAT, false, &pItem ) )
+ {
+ sal_uLong nOldIdx = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
+ sal_uLong nNewIdx = pN->GetMergeFormatIndex( nOldIdx );
+ if( nNewIdx != nOldIdx )
+ aBoxAttrSet.Put( SwTableBoxNumFormat( nNewIdx ));
}
+ pDstBox->ClaimFrameFormat()->SetFormatAttr( aBoxAttrSet );
}
bool SwTable::InsNewTable( const SwTable& rCpyTable, const SwSelBoxes& rSelBoxes,
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index c70697466c36..04142282bebb 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -914,18 +914,18 @@ lcl_SaveUpperLowerBorder( SwTable& rTable, const SwTableBox& rBox,
bChgd = true;
}
}
- if( !bChgd && pPrvBox && pPrvBox->GetSttNd() )
+ if( !(!bChgd && pPrvBox && pPrvBox->GetSttNd()) )
+ return;
+
+ const SvxBoxItem& rPrvBoxItem = pPrvBox->GetFrameFormat()->GetBox();
+ if( !rPrvBoxItem.GetTop() && ( !pNxtBox ||
+ !pNxtBox->GetFrameFormat()->GetBox().GetTop()) )
{
- const SvxBoxItem& rPrvBoxItem = pPrvBox->GetFrameFormat()->GetBox();
- if( !rPrvBoxItem.GetTop() && ( !pNxtBox ||
- !pNxtBox->GetFrameFormat()->GetBox().GetTop()) )
- {
- SvxBoxItem aTmp( rPrvBoxItem );
- aTmp.SetLine( rBoxItem.GetTop() ? rBoxItem.GetTop()
- : rBoxItem.GetBottom(),
- SvxBoxItemLine::BOTTOM );
- rShareFormats.SetAttr( *pPrvBox, aTmp );
- }
+ SvxBoxItem aTmp( rPrvBoxItem );
+ aTmp.SetLine( rBoxItem.GetTop() ? rBoxItem.GetTop()
+ : rBoxItem.GetBottom(),
+ SvxBoxItemLine::BOTTOM );
+ rShareFormats.SetAttr( *pPrvBox, aTmp );
}
}
@@ -1389,28 +1389,28 @@ static void lcl_Merge_MoveBox(FndBox_ & rFndBox, InsULPara *const pULPara)
pBoxes = &pULPara->pInsLine->GetTabBoxes();
// Is there still a level to step down to?
- if (!rFndBox.GetBox()->GetTabLines().empty())
- {
- SwTableBox* pBox = new SwTableBox(
- static_cast<SwTableBoxFormat*>(rFndBox.GetBox()->GetFrameFormat()),
- 0, pULPara->pInsLine );
- InsULPara aPara( *pULPara );
- aPara.pInsBox = pBox;
- for (FndLines_t::iterator it = rFndBox.GetLines().begin() + nStt;
- it != rFndBox.GetLines().begin() + nEnd; ++it )
- {
- lcl_Merge_MoveLine(**it, &aPara);
- }
- if( !pBox->GetTabLines().empty() )
- {
- if( USHRT_MAX == nInsPos )
- nInsPos = pBoxes->size();
- pBoxes->insert( pBoxes->begin() + nInsPos, pBox );
- lcl_CalcWidth( pBox ); // calculate the Box's width
- }
- else
- delete pBox;
+ if (rFndBox.GetBox()->GetTabLines().empty())
+ return;
+
+ SwTableBox* pBox = new SwTableBox(
+ static_cast<SwTableBoxFormat*>(rFndBox.GetBox()->GetFrameFormat()),
+ 0, pULPara->pInsLine );
+ InsULPara aPara( *pULPara );
+ aPara.pInsBox = pBox;
+ for (FndLines_t::iterator it = rFndBox.GetLines().begin() + nStt;
+ it != rFndBox.GetLines().begin() + nEnd; ++it )
+ {
+ lcl_Merge_MoveLine(**it, &aPara);
+ }
+ if( !pBox->GetTabLines().empty() )
+ {
+ if( USHRT_MAX == nInsPos )
+ nInsPos = pBoxes->size();
+ pBoxes->insert( pBoxes->begin() + nInsPos, pBox );
+ lcl_CalcWidth( pBox ); // calculate the Box's width
}
+ else
+ delete pBox;
}
static void lcl_Merge_MoveLine(FndLine_& rFndLine, InsULPara *const pULPara)
@@ -1754,25 +1754,25 @@ static void lcl_CalcNewWidths(const FndLines_t& rFndLines, CpyPara& rPara)
}
// Second step: calculate the new widths for the copied cells
sal_uLong nSelSize = rPara.nMaxRight - rPara.nMinLeft;
- if( nSelSize )
+ if( !nSelSize )
+ return;
+
+ for( size_t nLine = 0; nLine < nLineCount; ++nLine )
{
- for( size_t nLine = 0; nLine < nLineCount; ++nLine )
+ std::vector< sal_uLong > &rWidth = (*rPara.pWidths)[ nLine ];
+ const size_t nCount = rWidth.size();
+ if( nCount > 2 )
{
- std::vector< sal_uLong > &rWidth = (*rPara.pWidths)[ nLine ];
- const size_t nCount = rWidth.size();
- if( nCount > 2 )
+ rWidth[ nCount - 1 ] = rPara.nMaxRight;
+ sal_uLong nLastPos = 0;
+ for( size_t nBox = 0; nBox < nCount; ++nBox )
{
- rWidth[ nCount - 1 ] = rPara.nMaxRight;
- sal_uLong nLastPos = 0;
- for( size_t nBox = 0; nBox < nCount; ++nBox )
- {
- sal_uInt64 nNextPos = rWidth[ nBox ];
- nNextPos -= rPara.nMinLeft;
- nNextPos *= rPara.nNewSize;
- nNextPos /= nSelSize;
- rWidth[ nBox ] = static_cast<sal_uLong>(nNextPos - nLastPos);
- nLastPos = static_cast<sal_uLong>(nNextPos);
- }
+ sal_uInt64 nNextPos = rWidth[ nBox ];
+ nNextPos -= rPara.nMinLeft;
+ nNextPos *= rPara.nNewSize;
+ nNextPos /= nSelSize;
+ rWidth[ nBox ] = static_cast<sal_uLong>(nNextPos - nLastPos);
+ nLastPos = static_cast<sal_uLong>(nNextPos);
}
}
}
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index d80440c916f5..66ba6a7f5717 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -143,34 +143,34 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape)
syncProperty(pShape, RES_FRAMEDIR, 0, uno::makeAny(sal_Int16(eMode)));
const SwFormatAnchor& rAnch = pShape->GetAnchor();
- if ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE && rAnch.GetPageNum() != 0)
- || ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA
- || rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR)
- && rAnch.GetContentAnchor()))
- {
- SfxItemSet aTxFrmSet(pFormat->GetDoc()->GetAttrPool(), aFrameFormatSetRange);
- SwFormatAnchor aNewAnch = pFormat->GetAnchor();
+ if (!((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PAGE && rAnch.GetPageNum() != 0)
+ || ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA
+ || rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR)
+ && rAnch.GetContentAnchor())))
+ return;
- if (pShape->GetAnchor().GetContentAnchor())
- aNewAnch.SetAnchor(pShape->GetAnchor().GetContentAnchor());
- if (pShape->GetAnchor().GetPageNum() > 0)
- aNewAnch.SetPageNum(pShape->GetAnchor().GetPageNum());
-
- aNewAnch.SetType(pShape->GetAnchor().GetAnchorId());
- aTxFrmSet.Put(aNewAnch);
-
- SwFormatVertOrient aVOri(pFormat->GetVertOrient());
- SwFormatHoriOrient aHOri(pFormat->GetHoriOrient());
- aVOri.SetVertOrient(pShape->GetVertOrient().GetVertOrient());
- aHOri.SetHoriOrient(pShape->GetHoriOrient().GetHoriOrient());
- aVOri.SetRelationOrient(pShape->GetVertOrient().GetRelationOrient());
- aHOri.SetRelationOrient(pShape->GetHoriOrient().GetRelationOrient());
- aTxFrmSet.Put(aVOri);
- aTxFrmSet.Put(aHOri);
-
- if (aTxFrmSet.Count())
- pFormat->SetFormatAttr(aTxFrmSet);
- }
+ SfxItemSet aTxFrmSet(pFormat->GetDoc()->GetAttrPool(), aFrameFormatSetRange);
+ SwFormatAnchor aNewAnch = pFormat->GetAnchor();
+
+ if (pShape->GetAnchor().GetContentAnchor())
+ aNewAnch.SetAnchor(pShape->GetAnchor().GetContentAnchor());
+ if (pShape->GetAnchor().GetPageNum() > 0)
+ aNewAnch.SetPageNum(pShape->GetAnchor().GetPageNum());
+
+ aNewAnch.SetType(pShape->GetAnchor().GetAnchorId());
+ aTxFrmSet.Put(aNewAnch);
+
+ SwFormatVertOrient aVOri(pFormat->GetVertOrient());
+ SwFormatHoriOrient aHOri(pFormat->GetHoriOrient());
+ aVOri.SetVertOrient(pShape->GetVertOrient().GetVertOrient());
+ aHOri.SetHoriOrient(pShape->GetHoriOrient().GetHoriOrient());
+ aVOri.SetRelationOrient(pShape->GetVertOrient().GetRelationOrient());
+ aHOri.SetRelationOrient(pShape->GetHoriOrient().GetRelationOrient());
+ aTxFrmSet.Put(aVOri);
+ aTxFrmSet.Put(aHOri);
+
+ if (aTxFrmSet.Count())
+ pFormat->SetFormatAttr(aTxFrmSet);
}
void SwTextBoxHelper::destroy(SwFrameFormat* pShape)
@@ -459,24 +459,25 @@ void SwTextBoxHelper::getProperty(SwFrameFormat const* pShape, sal_uInt16 nWID,
nMemberID &= ~CONVERT_TWIPS;
- if (SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT))
+ SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT);
+ if (!pFormat)
+ return;
+
+ if (nWID != RES_CHAIN)
+ return;
+
+ switch (nMemberID)
{
- if (nWID == RES_CHAIN)
+ case MID_CHAIN_PREVNAME:
+ case MID_CHAIN_NEXTNAME:
{
- switch (nMemberID)
- {
- case MID_CHAIN_PREVNAME:
- case MID_CHAIN_NEXTNAME:
- {
- const SwFormatChain& rChain = pFormat->GetChain();
- rChain.QueryValue(rValue, nMemberID);
- }
- break;
- case MID_CHAIN_NAME:
- rValue <<= pFormat->GetName();
- break;
- }
+ const SwFormatChain& rChain = pFormat->GetChain();
+ rChain.QueryValue(rValue, nMemberID);
}
+ break;
+ case MID_CHAIN_NAME:
+ rValue <<= pFormat->GetName();
+ break;
}
}
@@ -490,186 +491,186 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u
uno::Any aValue(rValue);
nMemberID &= ~CONVERT_TWIPS;
- if (SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT))
+ SwFrameFormat* pFormat = getOtherTextBoxFormat(pShape, RES_DRAWFRMFMT);
+ if (!pFormat)
+ return;
+
+ OUString aPropertyName;
+ bool bAdjustX = false;
+ bool bAdjustY = false;
+ bool bAdjustSize = false;
+ switch (nWID)
{
- OUString aPropertyName;
- bool bAdjustX = false;
- bool bAdjustY = false;
- bool bAdjustSize = false;
- switch (nWID)
+ case RES_HORI_ORIENT:
+ switch (nMemberID)
+ {
+ case MID_HORIORIENT_ORIENT:
+ aPropertyName = UNO_NAME_HORI_ORIENT;
+ break;
+ case MID_HORIORIENT_RELATION:
+ aPropertyName = UNO_NAME_HORI_ORIENT_RELATION;
+ break;
+ case MID_HORIORIENT_POSITION:
+ aPropertyName = UNO_NAME_HORI_ORIENT_POSITION;
+ bAdjustX = true;
+ break;
+ }
+ break;
+ case RES_LR_SPACE:
{
- case RES_HORI_ORIENT:
- switch (nMemberID)
- {
- case MID_HORIORIENT_ORIENT:
- aPropertyName = UNO_NAME_HORI_ORIENT;
- break;
- case MID_HORIORIENT_RELATION:
- aPropertyName = UNO_NAME_HORI_ORIENT_RELATION;
- break;
- case MID_HORIORIENT_POSITION:
- aPropertyName = UNO_NAME_HORI_ORIENT_POSITION;
- bAdjustX = true;
- break;
- }
- break;
- case RES_LR_SPACE:
+ switch (nMemberID)
{
- switch (nMemberID)
- {
- case MID_L_MARGIN:
- aPropertyName = UNO_NAME_LEFT_MARGIN;
- break;
- case MID_R_MARGIN:
- aPropertyName = UNO_NAME_RIGHT_MARGIN;
- break;
- }
- break;
+ case MID_L_MARGIN:
+ aPropertyName = UNO_NAME_LEFT_MARGIN;
+ break;
+ case MID_R_MARGIN:
+ aPropertyName = UNO_NAME_RIGHT_MARGIN;
+ break;
}
- case RES_VERT_ORIENT:
- switch (nMemberID)
- {
- case MID_VERTORIENT_ORIENT:
- aPropertyName = UNO_NAME_VERT_ORIENT;
- break;
- case MID_VERTORIENT_RELATION:
- aPropertyName = UNO_NAME_VERT_ORIENT_RELATION;
- break;
- case MID_VERTORIENT_POSITION:
- aPropertyName = UNO_NAME_VERT_ORIENT_POSITION;
- bAdjustY = true;
- break;
- }
- break;
- case RES_FRM_SIZE:
- switch (nMemberID)
- {
- case MID_FRMSIZE_IS_AUTO_HEIGHT:
- aPropertyName = UNO_NAME_FRAME_ISAUTOMATIC_HEIGHT;
- break;
- case MID_FRMSIZE_REL_HEIGHT_RELATION:
- aPropertyName = UNO_NAME_RELATIVE_HEIGHT_RELATION;
- break;
- case MID_FRMSIZE_REL_WIDTH_RELATION:
- aPropertyName = UNO_NAME_RELATIVE_WIDTH_RELATION;
- break;
- default:
- aPropertyName = UNO_NAME_SIZE;
- bAdjustSize = true;
- break;
- }
- break;
- case RES_ANCHOR:
- switch (nMemberID)
- {
- case MID_ANCHOR_ANCHORTYPE:
- if (aValue.get<text::TextContentAnchorType>()
- == text::TextContentAnchorType_AS_CHARACTER)
- {
- uno::Reference<beans::XPropertySet> const xPropertySet(
- SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat),
- uno::UNO_QUERY);
- xPropertySet->setPropertyValue(
- UNO_NAME_SURROUND, uno::makeAny(text::WrapTextMode_THROUGH));
- return;
- }
- break;
- }
- break;
- case FN_TEXT_RANGE:
+ break;
+ }
+ case RES_VERT_ORIENT:
+ switch (nMemberID)
{
- uno::Reference<text::XTextRange> xRange;
- rValue >>= xRange;
- SwUnoInternalPaM aInternalPaM(*pFormat->GetDoc());
- if (sw::XTextRangeToSwPaM(aInternalPaM, xRange))
- {
- SwFormatAnchor aAnchor(pFormat->GetAnchor());
- aAnchor.SetAnchor(aInternalPaM.Start());
- pFormat->SetFormatAttr(aAnchor);
- }
+ case MID_VERTORIENT_ORIENT:
+ aPropertyName = UNO_NAME_VERT_ORIENT;
+ break;
+ case MID_VERTORIENT_RELATION:
+ aPropertyName = UNO_NAME_VERT_ORIENT_RELATION;
+ break;
+ case MID_VERTORIENT_POSITION:
+ aPropertyName = UNO_NAME_VERT_ORIENT_POSITION;
+ bAdjustY = true;
+ break;
}
break;
- case RES_CHAIN:
- switch (nMemberID)
- {
- case MID_CHAIN_PREVNAME:
- aPropertyName = UNO_NAME_CHAIN_PREV_NAME;
- break;
- case MID_CHAIN_NEXTNAME:
- aPropertyName = UNO_NAME_CHAIN_NEXT_NAME;
- break;
- }
- break;
- case RES_TEXT_VERT_ADJUST:
- aPropertyName = UNO_NAME_TEXT_VERT_ADJUST;
- break;
- case RES_BOX:
- switch (nMemberID)
- {
- case LEFT_BORDER_DISTANCE:
- aPropertyName = UNO_NAME_LEFT_BORDER_DISTANCE;
- break;
- case RIGHT_BORDER_DISTANCE:
- aPropertyName = UNO_NAME_RIGHT_BORDER_DISTANCE;
- break;
- case TOP_BORDER_DISTANCE:
- aPropertyName = UNO_NAME_TOP_BORDER_DISTANCE;
- break;
- case BOTTOM_BORDER_DISTANCE:
- aPropertyName = UNO_NAME_BOTTOM_BORDER_DISTANCE;
- break;
- }
- break;
- case RES_OPAQUE:
- aPropertyName = UNO_NAME_OPAQUE;
- break;
- case RES_FRAMEDIR:
- aPropertyName = UNO_NAME_WRITING_MODE;
- break;
- case RES_WRAP_INFLUENCE_ON_OBJPOS:
- switch (nMemberID)
- {
- case MID_ALLOW_OVERLAP:
- aPropertyName = UNO_NAME_ALLOW_OVERLAP;
- break;
- }
- break;
+ case RES_FRM_SIZE:
+ switch (nMemberID)
+ {
+ case MID_FRMSIZE_IS_AUTO_HEIGHT:
+ aPropertyName = UNO_NAME_FRAME_ISAUTOMATIC_HEIGHT;
+ break;
+ case MID_FRMSIZE_REL_HEIGHT_RELATION:
+ aPropertyName = UNO_NAME_RELATIVE_HEIGHT_RELATION;
+ break;
+ case MID_FRMSIZE_REL_WIDTH_RELATION:
+ aPropertyName = UNO_NAME_RELATIVE_WIDTH_RELATION;
+ break;
+ default:
+ aPropertyName = UNO_NAME_SIZE;
+ bAdjustSize = true;
+ break;
+ }
+ break;
+ case RES_ANCHOR:
+ switch (nMemberID)
+ {
+ case MID_ANCHOR_ANCHORTYPE:
+ if (aValue.get<text::TextContentAnchorType>()
+ == text::TextContentAnchorType_AS_CHARACTER)
+ {
+ uno::Reference<beans::XPropertySet> const xPropertySet(
+ SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat),
+ uno::UNO_QUERY);
+ xPropertySet->setPropertyValue(UNO_NAME_SURROUND,
+ uno::makeAny(text::WrapTextMode_THROUGH));
+ return;
+ }
+ break;
+ }
+ break;
+ case FN_TEXT_RANGE:
+ {
+ uno::Reference<text::XTextRange> xRange;
+ rValue >>= xRange;
+ SwUnoInternalPaM aInternalPaM(*pFormat->GetDoc());
+ if (sw::XTextRangeToSwPaM(aInternalPaM, xRange))
+ {
+ SwFormatAnchor aAnchor(pFormat->GetAnchor());
+ aAnchor.SetAnchor(aInternalPaM.Start());
+ pFormat->SetFormatAttr(aAnchor);
+ }
}
+ break;
+ case RES_CHAIN:
+ switch (nMemberID)
+ {
+ case MID_CHAIN_PREVNAME:
+ aPropertyName = UNO_NAME_CHAIN_PREV_NAME;
+ break;
+ case MID_CHAIN_NEXTNAME:
+ aPropertyName = UNO_NAME_CHAIN_NEXT_NAME;
+ break;
+ }
+ break;
+ case RES_TEXT_VERT_ADJUST:
+ aPropertyName = UNO_NAME_TEXT_VERT_ADJUST;
+ break;
+ case RES_BOX:
+ switch (nMemberID)
+ {
+ case LEFT_BORDER_DISTANCE:
+ aPropertyName = UNO_NAME_LEFT_BORDER_DISTANCE;
+ break;
+ case RIGHT_BORDER_DISTANCE:
+ aPropertyName = UNO_NAME_RIGHT_BORDER_DISTANCE;
+ break;
+ case TOP_BORDER_DISTANCE:
+ aPropertyName = UNO_NAME_TOP_BORDER_DISTANCE;
+ break;
+ case BOTTOM_BORDER_DISTANCE:
+ aPropertyName = UNO_NAME_BOTTOM_BORDER_DISTANCE;
+ break;
+ }
+ break;
+ case RES_OPAQUE:
+ aPropertyName = UNO_NAME_OPAQUE;
+ break;
+ case RES_FRAMEDIR:
+ aPropertyName = UNO_NAME_WRITING_MODE;
+ break;
+ case RES_WRAP_INFLUENCE_ON_OBJPOS:
+ switch (nMemberID)
+ {
+ case MID_ALLOW_OVERLAP:
+ aPropertyName = UNO_NAME_ALLOW_OVERLAP;
+ break;
+ }
+ break;
+ }
- if (!aPropertyName.isEmpty())
+ if (aPropertyName.isEmpty())
+ return;
+
+ // Position/size should be the text position/size, not the shape one as-is.
+ if (bAdjustX || bAdjustY || bAdjustSize)
+ {
+ tools::Rectangle aRect = getTextRectangle(pShape, /*bAbsolute=*/false);
+ if (!aRect.IsEmpty())
{
- // Position/size should be the text position/size, not the shape one as-is.
- if (bAdjustX || bAdjustY || bAdjustSize)
+ if (bAdjustX || bAdjustY)
{
- tools::Rectangle aRect = getTextRectangle(pShape, /*bAbsolute=*/false);
- if (!aRect.IsEmpty())
+ sal_Int32 nValue;
+ if (aValue >>= nValue)
{
- if (bAdjustX || bAdjustY)
- {
- sal_Int32 nValue;
- if (aValue >>= nValue)
- {
- if (bAdjustX)
- nValue += TWIPS_TO_MM(aRect.getX());
- else if (bAdjustY)
- nValue += TWIPS_TO_MM(aRect.getY());
- aValue <<= nValue;
- }
- }
- else if (bAdjustSize)
- {
- awt::Size aSize(TWIPS_TO_MM(aRect.getWidth()),
- TWIPS_TO_MM(aRect.getHeight()));
- aValue <<= aSize;
- }
+ if (bAdjustX)
+ nValue += TWIPS_TO_MM(aRect.getX());
+ else if (bAdjustY)
+ nValue += TWIPS_TO_MM(aRect.getY());
+ aValue <<= nValue;
}
}
-
- uno::Reference<beans::XPropertySet> const xPropertySet(
- SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat), uno::UNO_QUERY);
- xPropertySet->setPropertyValue(aPropertyName, aValue);
+ else if (bAdjustSize)
+ {
+ awt::Size aSize(TWIPS_TO_MM(aRect.getWidth()), TWIPS_TO_MM(aRect.getHeight()));
+ aValue <<= aSize;
+ }
}
}
+
+ uno::Reference<beans::XPropertySet> const xPropertySet(
+ SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat), uno::UNO_QUERY);
+ xPropertySet->setPropertyValue(aPropertyName, aValue);
}
void SwTextBoxHelper::saveLinks(const SwFrameFormats& rFormats,
@@ -719,105 +720,106 @@ void SwTextBoxHelper::restoreLinks(std::set<ZSortFly>& rOld, std::vector<SwFrame
void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& rSet)
{
- if (SwFrameFormat* pFormat = getOtherTextBoxFormat(&rShape, RES_DRAWFRMFMT))
- {
- SfxItemSet aTextBoxSet(pFormat->GetDoc()->GetAttrPool(), aFrameFormatSetRange);
+ SwFrameFormat* pFormat = getOtherTextBoxFormat(&rShape, RES_DRAWFRMFMT);
+ if (!pFormat)
+ return;
- SfxItemIter aIter(rSet);
- const SfxPoolItem* pItem = aIter.GetCurItem();
+ SfxItemSet aTextBoxSet(pFormat->GetDoc()->GetAttrPool(), aFrameFormatSetRange);
- const RndStdIds aAnchId = rShape.GetAnchor().GetAnchorId();
- if ((aAnchId == RndStdIds::FLY_AT_PAGE && rShape.GetAnchor().GetPageNum() != 0)
- || ((aAnchId == RndStdIds::FLY_AT_PARA || aAnchId == RndStdIds::FLY_AT_CHAR)
- && rShape.GetAnchor().GetContentAnchor()))
- {
- SwFormatAnchor aNewAnch = pFormat->GetAnchor();
- if (rShape.GetAnchor().GetContentAnchor())
- aNewAnch.SetAnchor(rShape.GetAnchor().GetContentAnchor());
- if (rShape.GetAnchor().GetPageNum() > 0)
- aNewAnch.SetPageNum(rShape.GetAnchor().GetPageNum());
- aNewAnch.SetType(rShape.GetAnchor().GetAnchorId());
- aTextBoxSet.Put(aNewAnch);
- }
- do
+ SfxItemIter aIter(rSet);
+ const SfxPoolItem* pItem = aIter.GetCurItem();
+
+ const RndStdIds aAnchId = rShape.GetAnchor().GetAnchorId();
+ if ((aAnchId == RndStdIds::FLY_AT_PAGE && rShape.GetAnchor().GetPageNum() != 0)
+ || ((aAnchId == RndStdIds::FLY_AT_PARA || aAnchId == RndStdIds::FLY_AT_CHAR)
+ && rShape.GetAnchor().GetContentAnchor()))
+ {
+ SwFormatAnchor aNewAnch = pFormat->GetAnchor();
+ if (rShape.GetAnchor().GetContentAnchor())
+ aNewAnch.SetAnchor(rShape.GetAnchor().GetContentAnchor());
+ if (rShape.GetAnchor().GetPageNum() > 0)
+ aNewAnch.SetPageNum(rShape.GetAnchor().GetPageNum());
+ aNewAnch.SetType(rShape.GetAnchor().GetAnchorId());
+ aTextBoxSet.Put(aNewAnch);
+ }
+ do
+ {
+ switch (pItem->Which())
{
- switch (pItem->Which())
+ case RES_VERT_ORIENT:
{
- case RES_VERT_ORIENT:
- {
- auto& rOrient = static_cast<const SwFormatVertOrient&>(*pItem);
- SwFormatVertOrient aOrient(rOrient);
+ auto& rOrient = static_cast<const SwFormatVertOrient&>(*pItem);
+ SwFormatVertOrient aOrient(rOrient);
- tools::Rectangle aRect = getTextRectangle(&rShape, /*bAbsolute=*/false);
- if (!aRect.IsEmpty())
- aOrient.SetPos(aOrient.GetPos() + aRect.getY());
+ tools::Rectangle aRect = getTextRectangle(&rShape, /*bAbsolute=*/false);
+ if (!aRect.IsEmpty())
+ aOrient.SetPos(aOrient.GetPos() + aRect.getY());
- if (rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE
- && rShape.GetAnchor().GetPageNum() != 0)
- aOrient.SetRelationOrient(rShape.GetVertOrient().GetRelationOrient());
- aTextBoxSet.Put(aOrient);
+ if (rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE
+ && rShape.GetAnchor().GetPageNum() != 0)
+ aOrient.SetRelationOrient(rShape.GetVertOrient().GetRelationOrient());
+ aTextBoxSet.Put(aOrient);
- // restore height (shrunk for extending beyond the page bottom - tdf#91260)
- SwFormatFrameSize aSize(pFormat->GetFrameSize());
- if (!aRect.IsEmpty())
- {
- aSize.SetHeight(aRect.getHeight());
- aTextBoxSet.Put(aSize);
- }
- }
- break;
- case RES_HORI_ORIENT:
+ // restore height (shrunk for extending beyond the page bottom - tdf#91260)
+ SwFormatFrameSize aSize(pFormat->GetFrameSize());
+ if (!aRect.IsEmpty())
{
- auto& rOrient = static_cast<const SwFormatHoriOrient&>(*pItem);
- SwFormatHoriOrient aOrient(rOrient);
+ aSize.SetHeight(aRect.getHeight());
+ aTextBoxSet.Put(aSize);
+ }
+ }
+ break;
+ case RES_HORI_ORIENT:
+ {
+ auto& rOrient = static_cast<const SwFormatHoriOrient&>(*pItem);
+ SwFormatHoriOrient aOrient(rOrient);
- tools::Rectangle aRect = getTextRectangle(&rShape, /*bAbsolute=*/false);
- if (!aRect.IsEmpty())
- aOrient.SetPos(aOrient.GetPos() + aRect.getX());
+ tools::Rectangle aRect = getTextRectangle(&rShape, /*bAbsolute=*/false);
+ if (!aRect.IsEmpty())
+ aOrient.SetPos(aOrient.GetPos() + aRect.getX());
- if (rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE
- && rShape.GetAnchor().GetPageNum() != 0)
- aOrient.SetRelationOrient(rShape.GetHoriOrient().GetRelationOrient());
- aTextBoxSet.Put(aOrient);
- }
- break;
- case RES_FRM_SIZE:
+ if (rShape.GetAnchor().GetAnchorId() == RndStdIds::FLY_AT_PAGE
+ && rShape.GetAnchor().GetPageNum() != 0)
+ aOrient.SetRelationOrient(rShape.GetHoriOrient().GetRelationOrient());
+ aTextBoxSet.Put(aOrient);
+ }
+ break;
+ case RES_FRM_SIZE:
+ {
+ // In case the shape got resized, then we need to adjust both
+ // the position and the size of the textbox (e.g. larger
+ // rounded edges of a rectangle -> need to push right/down the
+ // textbox).
+ SwFormatVertOrient aVertOrient(rShape.GetVertOrient());
+ SwFormatHoriOrient aHoriOrient(rShape.GetHoriOrient());
+ SwFormatFrameSize aSize(pFormat->GetFrameSize());
+
+ tools::Rectangle aRect = getTextRectangle(&rShape, /*bAbsolute=*/false);
+ if (!aRect.IsEmpty())
{
- // In case the shape got resized, then we need to adjust both
- // the position and the size of the textbox (e.g. larger
- // rounded edges of a rectangle -> need to push right/down the
- // textbox).
- SwFormatVertOrient aVertOrient(rShape.GetVertOrient());
- SwFormatHoriOrient aHoriOrient(rShape.GetHoriOrient());
- SwFormatFrameSize aSize(pFormat->GetFrameSize());
-
- tools::Rectangle aRect = getTextRectangle(&rShape, /*bAbsolute=*/false);
- if (!aRect.IsEmpty())
- {
- aVertOrient.SetPos(aVertOrient.GetPos() + aRect.getY());
- aTextBoxSet.Put(aVertOrient);
+ aVertOrient.SetPos(aVertOrient.GetPos() + aRect.getY());
+ aTextBoxSet.Put(aVertOrient);
- aHoriOrient.SetPos(aHoriOrient.GetPos() + aRect.getX());
- aTextBoxSet.Put(aHoriOrient);
+ aHoriOrient.SetPos(aHoriOrient.GetPos() + aRect.getX());
+ aTextBoxSet.Put(aHoriOrient);
- aSize.SetWidth(aRect.getWidth());
- aSize.SetHeight(aRect.getHeight());
- aTextBoxSet.Put(aSize);
- }
+ aSize.SetWidth(aRect.getWidth());
+ aSize.SetHeight(aRect.getHeight());
+ aTextBoxSet.Put(aSize);
}
- break;
- default:
- SAL_WARN("sw.core", "SwTextBoxHelper::syncFlyFrameAttr: unhandled which-id: "
- << pItem->Which());
- break;
}
+ break;
+ default:
+ SAL_WARN("sw.core", "SwTextBoxHelper::syncFlyFrameAttr: unhandled which-id: "
+ << pItem->Which());
+ break;
+ }
- pItem = aIter.NextItem();
- } while (pItem && (0 != pItem->Which()));
+ pItem = aIter.NextItem();
+ } while (pItem && (0 != pItem->Which()));
- if (aTextBoxSet.Count())
- pFormat->GetDoc()->SetFlyFrameAttr(*pFormat, aTextBoxSet);
- }
+ if (aTextBoxSet.Count())
+ pFormat->GetDoc()->SetFlyFrameAttr(*pFormat, aTextBoxSet);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/visiturl.cxx b/sw/source/core/doc/visiturl.cxx
index 62758c60e83d..a2dc5df93a2d 100644
--- a/sw/source/core/doc/visiturl.cxx
+++ b/sw/source/core/doc/visiturl.cxx
@@ -42,57 +42,57 @@ SwURLStateChanged::~SwURLStateChanged()
void SwURLStateChanged::Notify( SfxBroadcaster& , const SfxHint& rHint )
{
- if( dynamic_cast<const INetURLHistoryHint*>(&rHint) && m_pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() )
- {
- // This URL has been changed:
- const INetURLObject* pIURL = static_cast<const INetURLHistoryHint&>(rHint).GetObject();
- OUString sURL( pIURL->GetMainURL( INetURLObject::DecodeMechanism::NONE ) ), sBkmk;
+ if( !(dynamic_cast<const INetURLHistoryHint*>(&rHint) && m_pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()) )
+ return;
+
+ // This URL has been changed:
+ const INetURLObject* pIURL = static_cast<const INetURLHistoryHint&>(rHint).GetObject();
+ OUString sURL( pIURL->GetMainURL( INetURLObject::DecodeMechanism::NONE ) ), sBkmk;
- SwEditShell* pESh = m_pDoc->GetEditShell();
+ SwEditShell* pESh = m_pDoc->GetEditShell();
- if( m_pDoc->GetDocShell() && m_pDoc->GetDocShell()->GetMedium() &&
- // If this is our Doc, we can also have local jumps!
- m_pDoc->GetDocShell()->GetMedium()->GetName() == sURL )
- sBkmk = "#" + pIURL->GetMark();
+ if( m_pDoc->GetDocShell() && m_pDoc->GetDocShell()->GetMedium() &&
+ // If this is our Doc, we can also have local jumps!
+ m_pDoc->GetDocShell()->GetMedium()->GetName() == sURL )
+ sBkmk = "#" + pIURL->GetMark();
- bool bAction = false, bUnLockView = false;
- for (const SfxPoolItem* pItem : m_pDoc->GetAttrPool().GetItemSurrogates(RES_TXTATR_INETFMT))
+ bool bAction = false, bUnLockView = false;
+ for (const SfxPoolItem* pItem : m_pDoc->GetAttrPool().GetItemSurrogates(RES_TXTATR_INETFMT))
+ {
+ const SwFormatINetFormat* pFormatItem = dynamic_cast<const SwFormatINetFormat*>(pItem);
+ if( pFormatItem != nullptr &&
+ ( pFormatItem->GetValue() == sURL || ( !sBkmk.isEmpty() && pFormatItem->GetValue() == sBkmk )))
{
- const SwFormatINetFormat* pFormatItem = dynamic_cast<const SwFormatINetFormat*>(pItem);
- if( pFormatItem != nullptr &&
- ( pFormatItem->GetValue() == sURL || ( !sBkmk.isEmpty() && pFormatItem->GetValue() == sBkmk )))
+ const SwTextINetFormat* pTextAttr = pFormatItem->GetTextINetFormat();
+ if (pTextAttr != nullptr)
{
- const SwTextINetFormat* pTextAttr = pFormatItem->GetTextINetFormat();
- if (pTextAttr != nullptr)
+ const SwTextNode* pTextNd = pTextAttr->GetpTextNode();
+ if (pTextNd != nullptr)
{
- const SwTextNode* pTextNd = pTextAttr->GetpTextNode();
- if (pTextNd != nullptr)
+ if( !bAction && pESh )
{
- if( !bAction && pESh )
- {
- pESh->StartAllAction();
- bAction = true;
- bUnLockView = !pESh->IsViewLocked();
- pESh->LockView( true );
- }
- const_cast<SwTextINetFormat*>(pTextAttr)->SetVisitedValid(false);
- const SwTextAttr* pAttr = pTextAttr;
- SwUpdateAttr aUpdateAttr(
- pAttr->GetStart(),
- *pAttr->End(),
- RES_FMT_CHG);
-
- const_cast< SwTextNode* >(pTextNd)->ModifyNotification(&aUpdateAttr, &aUpdateAttr);
+ pESh->StartAllAction();
+ bAction = true;
+ bUnLockView = !pESh->IsViewLocked();
+ pESh->LockView( true );
}
+ const_cast<SwTextINetFormat*>(pTextAttr)->SetVisitedValid(false);
+ const SwTextAttr* pAttr = pTextAttr;
+ SwUpdateAttr aUpdateAttr(
+ pAttr->GetStart(),
+ *pAttr->End(),
+ RES_FMT_CHG);
+
+ const_cast< SwTextNode* >(pTextNd)->ModifyNotification(&aUpdateAttr, &aUpdateAttr);
}
}
}
-
- if( bAction )
- pESh->EndAllAction();
- if( bUnLockView )
- pESh->LockView( false );
}
+
+ if( bAction )
+ pESh->EndAllAction();
+ if( bUnLockView )
+ pESh->LockView( false );
}
// Check if the URL has been visited before. Via the Doc, if only one Bookmark is set