summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-12-17 13:13:46 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-12-18 12:49:50 +0100
commit9f3272c06ba87315dd38a090059bfe62b0ecabb7 (patch)
tree4413b913f2decf6f8f39f49dfe1d882d7c0c8755 /sw/source/core
parent19256a9ab68026055849b9ccb4ed93e8a24a3f6c (diff)
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
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/crsr/findattr.cxx73
-rw-r--r--sw/source/core/edit/edfld.cxx8
-rw-r--r--sw/source/core/inc/pamtyp.hxx5
3 files changed, 66 insertions, 20 deletions
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index d50e0c41d496..9d5f2745afda 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -154,12 +154,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;
@@ -170,8 +169,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;
@@ -891,12 +889,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));
@@ -904,8 +904,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
@@ -920,27 +918,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() )
{
@@ -951,7 +995,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
@@ -962,6 +1006,7 @@ bool FindAttrImpl(SwPaM & rSearchPam,
bFound = true;
break;
}
+#endif
}
// if backward search, switch point and mark
diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx
index da0a15e0199e..3311439fd862 100644
--- a/sw/source/core/edit/edfld.cxx
+++ b/sw/source/core/edit/edfld.cxx
@@ -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 )
diff --git a/sw/source/core/inc/pamtyp.hxx b/sw/source/core/inc/pamtyp.hxx
index a0ebf2bea708..b51212b23633 100644
--- a/sw/source/core/inc/pamtyp.hxx
+++ b/sw/source/core/inc/pamtyp.hxx
@@ -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