Kaydet (Commit) 1199902f authored tarafından Michael Stahl's avatar Michael Stahl

sw_redlinehide_4b: adapt FindAttrImpl()

* rename the only user, some UpdateFields() overload, to UpateOneField()
* restrict it to search for non-formatting hints; the FindAttrsImpl()
  should be used for formatting hints instead

Change-Id: I15002610a287fcdcd76777733a277d2ce64904bc
üst 4caef398
......@@ -397,7 +397,7 @@ public:
void Insert2(SwField const &, const bool bForceExpandHints);
void UpdateFields( SwField & ); ///< One single field.
void UpdateOneField(SwField &); ///< One single field.
size_t GetFieldTypeCount(SwFieldIds nResId = SwFieldIds::Unknown) const;
SwFieldType* GetFieldType(size_t nField, SwFieldIds nResId = SwFieldIds::Unknown) const;
......
......@@ -155,12 +155,11 @@ static void lcl_SetAttrPam( SwPaM& rPam, sal_Int32 nStart, const sal_Int32* pEnd
@param rPam ???
@param rCmpItem ???
@param fnMove ???
@param bValue ???
@return Returns <true> if found, <false> otherwise.
*/
static bool lcl_Search( const SwTextNode& rTextNd, SwPaM& rPam,
static bool lcl_SearchAttr( const SwTextNode& rTextNd, SwPaM& rPam,
const SfxPoolItem& rCmpItem,
SwMoveFnCollection const & fnMove, bool bValue )
SwMoveFnCollection const & fnMove)
{
if ( !rTextNd.HasHints() )
return false;
......@@ -171,8 +170,7 @@ static bool lcl_Search( const SwTextNode& rTextNd, SwPaM& rPam,
sal_Int32 nContentPos = rPam.GetPoint()->nContent.GetIndex();
while( nullptr != ( pTextHt=(*fnMove.fnGetHint)(rTextNd.GetSwpHints(),nPos,nContentPos)))
if( pTextHt->Which() == rCmpItem.Which() &&
( !bValue || CmpAttr( pTextHt->GetAttr(), rCmpItem )))
if (pTextHt->Which() == rCmpItem.Which())
{
lcl_SetAttrPam( rPam, pTextHt->GetStart(), pTextHt->End(), bForward );
return true;
......@@ -892,12 +890,14 @@ static bool lcl_Search( const SwContentNode& rCNd, const SfxItemSet& rCmpSet, bo
namespace sw {
bool FindAttrImpl(SwPaM & rSearchPam,
const SfxPoolItem& rAttr, bool bValue, SwMoveFnCollection const & fnMove,
const SwPaM & rRegion, bool bInReadOnly)
const SfxPoolItem& rAttr, SwMoveFnCollection const & fnMove,
const SwPaM & rRegion, bool bInReadOnly,
SwRootFrame const*const pLayout)
{
// determine which attribute is searched:
const sal_uInt16 nWhich = rAttr.Which();
bool bCharAttr = isCHRATR(nWhich) || isTXTATR(nWhich);
assert(isTXTATR(nWhich)); // sw_redlinehide: only works for non-formatting hints such as needed in UpdateFields; use FindAttrsImpl for others
std::unique_ptr<SwPaM> pPam(sw::MakeRegion(fnMove, rRegion));
......@@ -905,8 +905,6 @@ bool FindAttrImpl(SwPaM & rSearchPam,
bool bFirst = true;
const bool bSrchForward = &fnMove == &fnMoveForward;
SwContentNode * pNode;
const SfxPoolItem* pItem;
SwpFormats aFormatArr;
// if at beginning/end then move it out of the node
if( bSrchForward
......@@ -921,27 +919,73 @@ bool FindAttrImpl(SwPaM & rSearchPam,
pPam->GetPoint()->nContent.Assign( pNd, bSrchForward ? 0 : pNd->Len() );
}
while( nullptr != ( pNode = ::GetNode( *pPam, bFirst, fnMove, bInReadOnly ) ) )
while (nullptr != (pNode = ::GetNode(*pPam, bFirst, fnMove, bInReadOnly, pLayout)))
{
if( bCharAttr )
{
if( !pNode->IsTextNode() ) // CharAttr are only in text nodes
continue;
if( pNode->GetTextNode()->HasHints() &&
lcl_Search( *pNode->GetTextNode(), *pPam, rAttr, fnMove, bValue ))
SwTextFrame const*const pFrame(pLayout
? static_cast<SwTextFrame const*>(pNode->getLayoutFrame(pLayout))
: nullptr);
if (pFrame)
{
SwTextNode const* pAttrNode(nullptr);
SwTextAttr const* pAttr(nullptr);
if (bSrchForward)
{
sw::MergedAttrIter iter(*pFrame);
do
{
pAttr = iter.NextAttr(&pAttrNode);
}
while (pAttr
&& (pAttrNode->GetIndex() < pPam->GetPoint()->nNode.GetIndex()
|| (pAttrNode->GetIndex() == pPam->GetPoint()->nNode.GetIndex()
&& pAttr->GetStart() < pPam->GetPoint()->nContent.GetIndex())
|| pAttr->Which() != nWhich));
}
else
{
sw::MergedAttrIterReverse iter(*pFrame);
do
{
pAttr = iter.PrevAttr(&pAttrNode);
}
while (pAttr
&& (pPam->GetPoint()->nNode.GetIndex() < pAttrNode->GetIndex()
|| (pPam->GetPoint()->nNode.GetIndex() == pAttrNode->GetIndex()
&& pPam->GetPoint()->nContent.GetIndex() <= pAttr->GetStart())
|| pAttr->Which() != nWhich));
}
if (pAttr)
{
assert(pAttrNode);
pPam->GetPoint()->nNode = *pAttrNode;
lcl_SetAttrPam(*pPam, pAttr->GetStart(), pAttr->End(), bSrchForward);
bFound = true;
break;
}
}
else if (!pLayout && pNode->GetTextNode()->HasHints() &&
lcl_SearchAttr(*pNode->GetTextNode(), *pPam, rAttr, fnMove))
{
bFound = true;
}
if (bFound)
{
// set to the values of the attribute
rSearchPam.SetMark();
*rSearchPam.GetPoint() = *pPam->GetPoint();
*rSearchPam.GetMark() = *pPam->GetMark();
bFound = true;
break;
}
else if (isTXTATR(nWhich))
continue;
}
#if 0
// no hard attribution, so check if node was asked for this attr before
if( !pNode->HasSwAttrSet() )
{
......@@ -952,7 +996,7 @@ bool FindAttrImpl(SwPaM & rSearchPam,
}
if( SfxItemState::SET == pNode->GetSwAttrSet().GetItemState( nWhich,
true, &pItem ) && ( !bValue || *pItem == rAttr ) )
true, &pItem ))
{
// FORWARD: SPoint at the end, GetMark at the beginning of the node
// BACKWARD: SPoint at the beginning, GetMark at the end of the node
......@@ -963,6 +1007,7 @@ bool FindAttrImpl(SwPaM & rSearchPam,
bFound = true;
break;
}
#endif
}
// if backward search, switch point and mark
......
......@@ -206,7 +206,7 @@ static SwTextField* lcl_FindInputField( SwDoc* pDoc, SwField& rField )
return pTField;
}
void SwEditShell::UpdateFields( SwField &rField )
void SwEditShell::UpdateOneField(SwField &rField)
{
SET_CURR_SHELL( this );
StartAllAction();
......@@ -261,9 +261,9 @@ void SwEditShell::UpdateFields( SwField &rField )
// Search for SwTextField ...
while( bOkay
&& pCurStt->nContent != pCurEnd->nContent
&& (sw::FindAttrImpl(aPam, aFieldHint, false, fnMoveForward, aCurPam, true)
|| sw::FindAttrImpl(aPam, aAnnotationFieldHint, false, fnMoveForward, aCurPam)
|| sw::FindAttrImpl(aPam, aInputFieldHint, false, fnMoveForward, aCurPam)))
&& (sw::FindAttrImpl(aPam, aFieldHint, fnMoveForward, aCurPam, true, GetLayout())
|| sw::FindAttrImpl(aPam, aAnnotationFieldHint, fnMoveForward, aCurPam, false, GetLayout())
|| sw::FindAttrImpl(aPam, aInputFieldHint, fnMoveForward, aCurPam, false, GetLayout())))
{
// if only one PaM has more than one field ...
if( aPam.Start()->nContent != pCurStt->nContent )
......
......@@ -97,9 +97,10 @@ namespace sw {
SwMoveFnCollection const & fnMove,
const SwPaM & rRegion, bool bInReadOnly = false);
bool FindAttrImpl(SwPaM & rSearchPam,
const SfxPoolItem& rAttr, bool bValue,
const SfxPoolItem& rAttr,
SwMoveFnCollection const & fnMove,
const SwPaM & rPam, bool bInReadOnly = false);
const SwPaM & rPam, bool bInReadOnly,
SwRootFrame const* pLayout);
} // namespace sw
......
......@@ -96,7 +96,7 @@ void sw::DropDownFieldDialog::Apply()
static_cast<SwDropDownField*>(m_pDropField->CopyField().release()));
pCopy->SetPar1(sSelect);
m_rSh.SwEditShell::UpdateFields(*pCopy);
m_rSh.SwEditShell::UpdateOneField(*pCopy);
m_rSh.SetUndoNoResetModified();
m_rSh.EndAllAction();
......
......@@ -333,7 +333,7 @@ IMPL_LINK_NOARG(SwFieldEditDlg, AddressHdl, Button*, void)
ScopedVclPtr<SfxAbstractDialog> pDlg(rFact.CreateSwAddressAbstractDlg(this, aSet));
if (RET_OK == pDlg->Execute())
{
pSh->UpdateFields( *pCurField );
pSh->UpdateOneField(*pCurField);
}
}
......
......@@ -133,14 +133,14 @@ void SwFieldInputDlg::Apply()
else if( aTmp != pInpField->GetPar1() )
{
pInpField->SetPar1(aTmp);
rSh.SwEditShell::UpdateFields(*pInpField);
rSh.SwEditShell::UpdateOneField(*pInpField);
bModified = true;
}
}
else if( aTmp != pSetField->GetPar2())
{
pSetField->SetPar2(aTmp);
rSh.SwEditShell::UpdateFields(*pSetField);
rSh.SwEditShell::UpdateOneField(*pSetField);
bModified = true;
}
......
......@@ -1518,7 +1518,7 @@ bool SwFieldMgr::InsertField(
if(bTable)
{
pCurShell->Left(CRSR_SKIP_CHARS, false, 1, false );
pCurShell->UpdateFields(*pField);
pCurShell->UpdateOneField(*pField);
pCurShell->Right(CRSR_SKIP_CHARS, false, 1, false );
}
else if( bPageVar )
......@@ -1690,7 +1690,7 @@ void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat,
}
else {
// mb: #32157
pSh->SwEditShell::UpdateFields(*pTmpField);
pSh->SwEditShell::UpdateOneField(*pTmpField);
GetCurField();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment