// Call the AttrChangeNotify on the UI page.
CallChgLnk();
EndAllAction();
}
/** Search inside the cursor selection for full selected sections. * *@returnIfanypartofsectionintheselectionreturn0,ifmorethanonereturnthecount.
*/
sal_uInt16 SwEditShell::GetFullSelectedSectionCount() const
{
sal_uInt16 nRet = 0; for(SwPaM& rPaM : GetCursor()->GetRingContainer())
{
auto [pStart, pEnd] = rPaM.StartEnd(); // SwPosition* const SwContentNode* pCNd; // check the selection, if Start at Node begin and End at Node end if( pStart->GetContentIndex() ||
( nullptr == ( pCNd = pEnd->GetNode().GetContentNode() )) ||
pCNd->Len() != pEnd->GetContentIndex() )
{
nRet = 0; break;
}
// !!! // what about table at start or end ? // There is no selection possible! // What about only a table inside the section ? // There is only a table selection possible!
/** Find the suitable node for a special insert (alt-enter). * *Thisshouldenableinsertingtextbefore/aftersectionsandtables. * *Anodeisfoundif: *1)theinnermosttable/sectionisnotinawrite-protectedarea *2)pCurrentPosisatorjustbeforeanendnode *(oratorjustafterastartnode) *3)thereareonlystart/endnodesbetweenpCurrentPosandtheinnermost *table/section * *Ifasuitablenodeisfound,anSwNode*isreturned;elseitisNULL.
*/ staticconst SwNode* lcl_SpecialInsertNode(const SwPosition* pCurrentPos)
{ const SwNode* pReturn = nullptr;
// the current position
assert(pCurrentPos && "Strange, we have no position!"); const SwNode& rCurrentNode = pCurrentPos->GetNode();
// find innermost section or table. At the end of this scope, // pInnermostNode contains the section/table before/after which we should // insert our empty paragraph, or it will be NULL if none is found. const SwNode* pInnermostNode = nullptr; const SwSection* pSection = nullptr;
{ const SwNode* pTableNode = rCurrentNode.FindTableNode(); const SwNode* pSectionNode = rCurrentNode.FindSectionNode();
// find the table/section which is close if( pTableNode == nullptr )
{ if( pSectionNode == nullptr ) return nullptr;
//special case - ToxSection // - in this case the inner section could be tox header // section but the new node should be before the content section // protection of the tox should not prevent the insertion // only protection outside needs to be checked if( pSection &&
(SectionType::ToxHeader == pSection->GetType() ||
SectionType::ToxContent == pSection->GetType()))
{ if (SectionType::ToxHeader == pSection->GetType())
{ if (const SwSection* pSectionParent = pSection->GetParent())
pInnermostNode = pSectionParent->GetFormat()->GetSectionNode();
}
bCanModify = pInnermostNode && !static_cast<const SwSectionNode*>(pInnermostNode)->IsInProtectSect();
}
// The previous version had a check to skip empty read-only sections. Those // shouldn't occur, so we only need to check whether our pInnermostNode is // inside a protected area.
// Now, pInnermostNode is NULL or the innermost section or table node. if (bCanModify)
{
OSL_ENSURE( pInnermostNode->IsTableNode() ||
pInnermostNode->IsSectionNode(), "wrong node found" );
OSL_ENSURE( ( pInnermostNode->GetIndex() <= rCurrentNode.GetIndex() )&&
( pInnermostNode->EndOfSectionNode()->GetIndex() >=
rCurrentNode.GetIndex() ), "wrong node found" );
// we now need to find the possible start/end positions
// we found a start if // - we're at or just before a start node // - there are only start nodes between the current and pInnermostNode
SwNodeIndex aBegin( pCurrentPos->GetNode() ); if( rCurrentNode.IsContentNode() &&
(pCurrentPos->GetContentIndex() == 0))
--aBegin; while( (aBegin != pInnermostNode->GetIndex()) &&
aBegin.GetNode().IsStartNode() )
--aBegin; bool bStart = ( aBegin == pInnermostNode->GetIndex() );
// we found an end if // - we're at or just before an end node // - there are only end nodes between the current node and // pInnermostNode's end node or // - there are only end nodes between the last table cell merged with // the current cell and pInnermostNode's end node
SwNodeIndex aEnd( pCurrentPos->GetNode() ); if( rCurrentNode.IsContentNode() &&
( pCurrentPos->GetContentIndex() ==
rCurrentNode.GetContentNode()->Len() ) )
{
++aEnd;
/** a node can be special-inserted (alt-Enter) whenever lcl_SpecialInsertNode findsasuitableposition
*/ bool SwEditShell::CanSpecialInsert() const
{ return nullptr != lcl_SpecialInsertNode( GetCursor()->GetPoint() );
}
/** check whether a node can be special-inserted (alt-Enter), and do so. Return whetherinsertionwaspossible.
*/ void SwEditShell::DoSpecialInsert()
{ // get current node
SwPosition* pCursorPos = GetCursor()->GetPoint(); const SwNode* pInsertNode = lcl_SpecialInsertNode( pCursorPos ); if( pInsertNode == nullptr ) return;
StartAllAction();
// adjust insert position to insert before start nodes and after end // nodes
SwNodeIndex aInsertIndex( *pInsertNode,
SwNodeOffset(pInsertNode->IsStartNode() ? -1 : 0) );
SwPosition aInsertPos( aInsertIndex );
// insert a new text node, and set the cursor
GetDoc()->getIDocumentContentOperations().AppendTextNode( aInsertPos );
*pCursorPos = std::move(aInsertPos);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.