sw: reindent etc. SwContentTree::ExecCommand
Change-Id: Icacc4b235c17d64003652c81ffca7bcc247431e7
This commit is contained in:
@@ -2242,143 +2242,142 @@ void SwContentTree::ExecCommand(const OUString& rCmd, bool bModifier)
|
|||||||
const bool bLeftRight = bLeft || rCmd == "demote";
|
const bool bLeftRight = bLeft || rCmd == "demote";
|
||||||
if (!bUpDown && !bLeftRight)
|
if (!bUpDown && !bLeftRight)
|
||||||
return;
|
return;
|
||||||
if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() &&
|
if (GetWrtShell()->GetView().GetDocShell()->IsReadOnly() ||
|
||||||
(State::ACTIVE == m_eState ||
|
(State::ACTIVE != m_eState &&
|
||||||
(State::CONSTANT == m_eState && m_pActiveShell == GetParentWindow()->GetCreateView()->GetWrtShellPtr())))
|
(State::CONSTANT != m_eState || m_pActiveShell != GetParentWindow()->GetCreateView()->GetWrtShellPtr())))
|
||||||
{
|
{
|
||||||
SwWrtShell* pShell = GetWrtShell();
|
return;
|
||||||
sal_Int8 nActOutlineLevel = m_nOutlineLevel;
|
}
|
||||||
sal_uInt16 nActPos = pShell->GetOutlinePos(nActOutlineLevel);
|
|
||||||
SvTreeListEntry* pFirstEntry = FirstSelected();
|
SwWrtShell *const pShell = GetWrtShell();
|
||||||
if (pFirstEntry && lcl_IsContent(pFirstEntry))
|
sal_Int8 nActOutlineLevel = m_nOutlineLevel;
|
||||||
|
sal_uInt16 nActPos = pShell->GetOutlinePos(nActOutlineLevel);
|
||||||
|
SvTreeListEntry* pFirstEntry = FirstSelected();
|
||||||
|
if (pFirstEntry && lcl_IsContent(pFirstEntry))
|
||||||
|
{
|
||||||
|
assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pFirstEntry->GetUserData())));
|
||||||
|
if ((m_bIsRoot && m_nRootType == ContentTypeId::OUTLINE) ||
|
||||||
|
static_cast<SwContent*>(pFirstEntry->GetUserData())->GetParent()->GetType()
|
||||||
|
== ContentTypeId::OUTLINE)
|
||||||
{
|
{
|
||||||
assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pFirstEntry->GetUserData())));
|
nActPos = static_cast<SwOutlineContent*>(pFirstEntry->GetUserData())->GetPos();
|
||||||
if ( (m_bIsRoot && m_nRootType == ContentTypeId::OUTLINE) ||
|
|
||||||
static_cast<SwContent*>(pFirstEntry->GetUserData())->GetParent()->GetType()
|
|
||||||
== ContentTypeId::OUTLINE)
|
|
||||||
{
|
|
||||||
nActPos = static_cast<SwOutlineContent*>(pFirstEntry->GetUserData())->GetPos();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ( nActPos < USHRT_MAX &&
|
}
|
||||||
( !bUpDown || pShell->IsOutlineMovable( nActPos )) )
|
if (nActPos < USHRT_MAX && (!bUpDown || pShell->IsOutlineMovable(nActPos)))
|
||||||
|
{
|
||||||
|
pShell->StartAllAction();
|
||||||
|
pShell->GotoOutline( nActPos); // If text selection != box selection
|
||||||
|
pShell->Push();
|
||||||
|
pShell->MakeOutlineSel(nActPos, nActPos, bModifier);
|
||||||
|
if (bUpDown)
|
||||||
{
|
{
|
||||||
pShell->StartAllAction();
|
short nDir = bUp ? -1 : 1;
|
||||||
pShell->GotoOutline( nActPos); // If text selection != box selection
|
if (!bModifier && ((nDir == -1 && nActPos > 0) ||
|
||||||
pShell->Push();
|
(nDir == 1 && nActPos < GetEntryCount() - 2)))
|
||||||
pShell->MakeOutlineSel( nActPos, nActPos,
|
|
||||||
bModifier);
|
|
||||||
if (bUpDown)
|
|
||||||
{
|
{
|
||||||
short nDir = bUp ? -1 : 1;
|
pShell->MoveOutlinePara( nDir );
|
||||||
if( !bModifier && ( (nDir == -1 && nActPos > 0) ||
|
// Set cursor back to the current position
|
||||||
(nDir == 1 && nActPos < GetEntryCount() - 2) ) )
|
pShell->GotoOutline( nActPos + nDir);
|
||||||
|
}
|
||||||
|
else if (bModifier && pFirstEntry)
|
||||||
|
{
|
||||||
|
sal_uInt16 nActEndPos = nActPos;
|
||||||
|
SvTreeListEntry* pEntry = pFirstEntry;
|
||||||
|
assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pFirstEntry->GetUserData())));
|
||||||
|
const auto nActLevel = static_cast<SwOutlineContent*>(
|
||||||
|
pFirstEntry->GetUserData())->GetOutlineLevel();
|
||||||
|
pEntry = Next(pEntry);
|
||||||
|
while (pEntry && CTYPE_CNT ==
|
||||||
|
static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId())
|
||||||
{
|
{
|
||||||
pShell->MoveOutlinePara( nDir );
|
assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
|
||||||
// Set cursor back to the current position
|
if (nActLevel >= static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel())
|
||||||
pShell->GotoOutline( nActPos + nDir);
|
break;
|
||||||
}
|
|
||||||
else if(bModifier && pFirstEntry)
|
|
||||||
{
|
|
||||||
sal_uInt16 nActEndPos = nActPos;
|
|
||||||
SvTreeListEntry* pEntry = pFirstEntry;
|
|
||||||
assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pFirstEntry->GetUserData())));
|
|
||||||
const auto nActLevel = static_cast<SwOutlineContent*>(
|
|
||||||
pFirstEntry->GetUserData())->GetOutlineLevel();
|
|
||||||
pEntry = Next(pEntry);
|
pEntry = Next(pEntry);
|
||||||
while( pEntry && CTYPE_CNT ==
|
assert(pEntry == nullptr || dynamic_cast<SwTypeNumber*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
|
||||||
static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId() )
|
nActEndPos++;
|
||||||
|
}
|
||||||
|
if (nDir == 1)
|
||||||
|
{
|
||||||
|
// If the last entry is to be moved we're done
|
||||||
|
if (pEntry && CTYPE_CNT ==
|
||||||
|
static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId())
|
||||||
{
|
{
|
||||||
assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
|
// pEntry now points to the entry following the last
|
||||||
if(nActLevel >= static_cast<SwOutlineContent*>(
|
// selected entry.
|
||||||
pEntry->GetUserData())->GetOutlineLevel())
|
sal_uInt16 nDest = nActEndPos + 1;
|
||||||
break;
|
// here needs to found the next entry after next.
|
||||||
pEntry = Next(pEntry);
|
// The selection must be inserted in front of that.
|
||||||
assert(pEntry == nullptr || dynamic_cast<SwTypeNumber*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
|
while (pEntry)
|
||||||
nActEndPos++;
|
|
||||||
}
|
|
||||||
if(nDir == 1)
|
|
||||||
{
|
|
||||||
// If the last entry is to be moved it is over!
|
|
||||||
if(pEntry && CTYPE_CNT ==
|
|
||||||
static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId())
|
|
||||||
{
|
{
|
||||||
// pEntry now points to the following entry of the last
|
pEntry = Next(pEntry);
|
||||||
// selected entry.
|
|
||||||
sal_uInt16 nDest = nActEndPos + 1;
|
|
||||||
// here needs to found the next record after next.
|
|
||||||
// The selection must be inserted in front of.
|
|
||||||
while(pEntry )
|
|
||||||
{
|
|
||||||
pEntry = Next(pEntry);
|
|
||||||
assert(pEntry == nullptr || dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
|
|
||||||
// nDest++ may only executed if pEntry != 0
|
|
||||||
if(pEntry && nDest++ &&
|
|
||||||
( nActLevel >= static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel()||
|
|
||||||
CTYPE_CNT != static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId()))
|
|
||||||
{
|
|
||||||
nDest--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nDir = nDest - nActEndPos;
|
|
||||||
// If no entry was found which corresponds the condition
|
|
||||||
// of the previously paste, it needs to be pushed slightly less.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
nDir = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sal_uInt16 nDest = nActPos;
|
|
||||||
pEntry = pFirstEntry;
|
|
||||||
while(pEntry && nDest )
|
|
||||||
{
|
|
||||||
nDest--;
|
|
||||||
pEntry = Prev(pEntry);
|
|
||||||
assert(pEntry == nullptr || dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
|
assert(pEntry == nullptr || dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
|
||||||
if(pEntry &&
|
// nDest++ may only executed if pEntry != 0
|
||||||
(nActLevel >= static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel()||
|
if (pEntry && nDest++ &&
|
||||||
|
(nActLevel >= static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel() ||
|
||||||
CTYPE_CNT != static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId()))
|
CTYPE_CNT != static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId()))
|
||||||
{
|
{
|
||||||
|
nDest--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nDir = nDest - nActPos;
|
nDir = nDest - nActEndPos;
|
||||||
|
// If no entry was found that allows insertion before
|
||||||
|
// it, we just move it to the end.
|
||||||
}
|
}
|
||||||
if(nDir)
|
else
|
||||||
|
nDir = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sal_uInt16 nDest = nActPos;
|
||||||
|
pEntry = pFirstEntry;
|
||||||
|
while (pEntry && nDest)
|
||||||
{
|
{
|
||||||
pShell->MoveOutlinePara( nDir );
|
nDest--;
|
||||||
//Set cursor back to the current position
|
pEntry = Prev(pEntry);
|
||||||
pShell->GotoOutline( nActPos + nDir);
|
assert(pEntry == nullptr || dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
|
||||||
|
if (pEntry &&
|
||||||
|
(nActLevel >= static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel() ||
|
||||||
|
CTYPE_CNT != static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId()))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
nDir = nDest - nActPos;
|
||||||
|
}
|
||||||
|
if (nDir)
|
||||||
|
{
|
||||||
|
pShell->MoveOutlinePara( nDir );
|
||||||
|
// Set cursor back to the current position
|
||||||
|
pShell->GotoOutline(nActPos + nDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
if( !pShell->IsProtectedOutlinePara() )
|
{
|
||||||
pShell->OutlineUpDown(bLeft ? -1 : 1);
|
if (!pShell->IsProtectedOutlinePara())
|
||||||
}
|
pShell->OutlineUpDown(bLeft ? -1 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
pShell->ClearMark();
|
pShell->ClearMark();
|
||||||
pShell->Pop(false); // Cursor is now back at the current superscription.
|
pShell->Pop(false); // Cursor is now back at the current heading.
|
||||||
pShell->EndAllAction();
|
pShell->EndAllAction();
|
||||||
if(m_aActiveContentArr[ContentTypeId::OUTLINE])
|
if (m_aActiveContentArr[ContentTypeId::OUTLINE])
|
||||||
m_aActiveContentArr[ContentTypeId::OUTLINE]->Invalidate();
|
m_aActiveContentArr[ContentTypeId::OUTLINE]->Invalidate();
|
||||||
Display(true);
|
Display(true);
|
||||||
if(!m_bIsRoot)
|
if (!m_bIsRoot)
|
||||||
{
|
{
|
||||||
const sal_uInt16 nCurrPos = pShell->GetOutlinePos(MAXLEVEL);
|
const sal_uInt16 nCurrPos = pShell->GetOutlinePos(MAXLEVEL);
|
||||||
SvTreeListEntry* pFirst = First();
|
SvTreeListEntry* pFirst = First();
|
||||||
|
|
||||||
while( nullptr != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst))
|
while (nullptr != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst))
|
||||||
|
{
|
||||||
|
assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pFirst->GetUserData())));
|
||||||
|
if (static_cast<SwOutlineContent*>(pFirst->GetUserData())->GetPos() == nCurrPos)
|
||||||
{
|
{
|
||||||
assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pFirst->GetUserData())));
|
Select(pFirst);
|
||||||
if(static_cast<SwOutlineContent*>(pFirst->GetUserData())->GetPos() == nCurrPos)
|
MakeVisible(pFirst);
|
||||||
{
|
|
||||||
Select(pFirst);
|
|
||||||
MakeVisible(pFirst);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user