diff options
Diffstat (limited to 'sw/source/uibase/utlui/content.cxx')
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 262 |
1 files changed, 133 insertions, 129 deletions
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 48a21a981099..cb3c75d29566 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -766,8 +766,9 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged) } -SwContentTree::SwContentTree(vcl::Window* pParent, const ResId& rResId) - : SvTreeListBox(pParent, rResId) +SwContentTree::SwContentTree(vcl::Window* pParent, SwNavigationPI* pDialog) + : SvTreeListBox(pParent) + , m_xDialog(pDialog) , m_sSpace(OUString(" ")) , m_sRemoveIdx(SW_RES(STR_REMOVE_INDEX)) , m_sUpdateIdx(SW_RES(STR_UPDATE)) @@ -833,9 +834,15 @@ void SwContentTree::dispose() bIsInDrag = false; m_aUpdTimer.Stop(); SetActiveShell(nullptr); + m_xDialog.clear(); SvTreeListBox::dispose(); } +Size SwContentTree::GetOptimalSize() const +{ + return LogicToPixel(Size(110, 112), MapUnit::MapAppFont); +} + OUString SwContentTree::GetEntryAltText( SvTreeListEntry* pEntry ) const { if( pEntry == nullptr) @@ -1564,11 +1571,11 @@ void SwContentTree::Display( bool bActive ) m_bIsLastReadOnly = bReadOnly; bool bDisable = pShell == nullptr || bReadOnly; SwNavigationPI* pNavi = GetParentWindow(); - pNavi->m_aContentToolBox->EnableItem(FN_ITEM_UP , !bDisable); - pNavi->m_aContentToolBox->EnableItem(FN_ITEM_DOWN, !bDisable); - pNavi->m_aContentToolBox->EnableItem(FN_ITEM_LEFT, !bDisable); - pNavi->m_aContentToolBox->EnableItem(FN_ITEM_RIGHT, !bDisable); - pNavi->m_aContentToolBox->EnableItem(FN_SELECT_SET_AUTO_BOOKMARK, !bDisable); + pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("up"), !bDisable); + pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("down"), !bDisable); + pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("promote"), !bDisable); + pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("demote"), !bDisable); + pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("reminder"), !bDisable); } if(pShell) { @@ -1890,7 +1897,8 @@ void SwContentTree::ToggleToRoot() } } m_pConfig->SetRootType( m_nRootType ); - GetParentWindow()->m_aContentToolBox->CheckItem(FN_SHOW_ROOT, m_bIsRoot); + VclPtr<SwNavHelpToolBox> xBox = GetParentWindow()->m_aContentToolBox; + xBox->CheckItem(xBox->GetItemId("root"), m_bIsRoot); } bool SwContentTree::HasContentChanged() @@ -2218,147 +2226,143 @@ void SwContentTree::Notify(SfxBroadcaster & rBC, SfxHint const& rHint) } } -void SwContentTree::ExecCommand(sal_uInt16 nCmd, bool bModifier) +void SwContentTree::ExecCommand(const OUString& rCmd, bool bModifier) { - bool bMove = false; - switch( nCmd ) + const bool bUp = rCmd == "up"; + const bool bUpDown = bUp || rCmd == "up"; + const bool bLeft = rCmd == "promote"; + const bool bLeftRight = bLeft || rCmd == "demote"; + if (!bUpDown && !bLeftRight) + return; + if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() && + (m_bIsActive || + (m_bIsConstant && m_pActiveShell == GetParentWindow()->GetCreateView()->GetWrtShellPtr()))) { - case FN_ITEM_DOWN: - case FN_ITEM_UP: - bMove = true; - SAL_FALLTHROUGH; - case FN_ITEM_LEFT: - case FN_ITEM_RIGHT: - if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() && - (m_bIsActive || - (m_bIsConstant && m_pActiveShell == GetParentWindow()->GetCreateView()->GetWrtShellPtr()))) + SwWrtShell* pShell = GetWrtShell(); + sal_Int8 nActOutlineLevel = m_nOutlineLevel; + sal_uInt16 nActPos = pShell->GetOutlinePos(nActOutlineLevel); + SvTreeListEntry* pFirstEntry = FirstSelected(); + if (pFirstEntry && lcl_IsContent(pFirstEntry)) { - SwWrtShell* pShell = GetWrtShell(); - sal_Int8 nActOutlineLevel = m_nOutlineLevel; - sal_uInt16 nActPos = pShell->GetOutlinePos(nActOutlineLevel); - SvTreeListEntry* pFirstEntry = FirstSelected(); - if (pFirstEntry && lcl_IsContent(pFirstEntry)) - { - if ( (m_bIsRoot && m_nRootType == ContentTypeId::OUTLINE) || - static_cast<SwContent*>(pFirstEntry->GetUserData())->GetParent()->GetType() - == ContentTypeId::OUTLINE) - { - 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 && - ( !bMove || 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(); - pShell->GotoOutline( nActPos); // If text selection != box selection - pShell->Push(); - pShell->MakeOutlineSel( nActPos, nActPos, - bModifier); - if( bMove ) + short nDir = bUp ? -1 : 1; + if( !bModifier && ( (nDir == -1 && nActPos > 0) || + (nDir == 1 && nActPos < GetEntryCount() - 2) ) ) { - short nDir = nCmd == FN_ITEM_UP ? -1 : 1; - if( !bModifier && ( (nDir == -1 && nActPos > 0) || - (nDir == 1 && nActPos < GetEntryCount() - 2) ) ) + pShell->MoveOutlinePara( nDir ); + // Set cursor back to the current position + pShell->GotoOutline( nActPos + nDir); + } + else if(bModifier && pFirstEntry) + { + sal_uInt16 nActEndPos = nActPos; + SvTreeListEntry* pEntry = pFirstEntry; + 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 ); - // Set cursor back to the current position - pShell->GotoOutline( nActPos + nDir); + if(nActLevel >= static_cast<SwOutlineContent*>( + pEntry->GetUserData())->GetOutlineLevel()) + break; + pEntry = Next(pEntry); + nActEndPos++; } - else if(bModifier && pFirstEntry) + if(nDir == 1) { - sal_uInt16 nActEndPos = nActPos; - SvTreeListEntry* pEntry = pFirstEntry; - const auto nActLevel = static_cast<SwOutlineContent*>( - pFirstEntry->GetUserData())->GetOutlineLevel(); - pEntry = Next(pEntry); - while( pEntry && CTYPE_CNT == - static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId() ) + // If the last entry is to be moved it is over! + if(pEntry && CTYPE_CNT == + static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId()) { - if(nActLevel >= static_cast<SwOutlineContent*>( - pEntry->GetUserData())->GetOutlineLevel()) - break; - pEntry = Next(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 + // 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 now points to the following entry of the last - // 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); + // 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())) { - pEntry = Next(pEntry); - // 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; - } + 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; + 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 ) { - sal_uInt16 nDest = nActPos; - pEntry = pFirstEntry; - while(pEntry && nDest ) + nDest--; + pEntry = Prev(pEntry); + if(pEntry && + (nActLevel >= static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel()|| + CTYPE_CNT != static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId())) { - nDest--; - pEntry = Prev(pEntry); - if(pEntry && - (nActLevel >= static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel()|| - CTYPE_CNT != static_cast<SwTypeNumber*>(pEntry->GetUserData())->GetTypeId())) - { - break; - } + break; } - nDir = nDest - nActPos; - } - if(nDir) - { - pShell->MoveOutlinePara( nDir ); - //Set cursor back to the current position - pShell->GotoOutline( nActPos + nDir); } + nDir = nDest - nActPos; + } + if(nDir) + { + pShell->MoveOutlinePara( nDir ); + //Set cursor back to the current position + pShell->GotoOutline( nActPos + nDir); } } - else - { - if( !pShell->IsProtectedOutlinePara() ) - pShell->OutlineUpDown( nCmd == FN_ITEM_LEFT ? -1 : 1 ); - } + } + else + { + if( !pShell->IsProtectedOutlinePara() ) + pShell->OutlineUpDown(bLeft ? -1 : 1); + } - pShell->ClearMark(); - pShell->Pop(false); // Cursor is now back at the current superscription. - pShell->EndAllAction(); - if(m_aActiveContentArr[ContentTypeId::OUTLINE]) - m_aActiveContentArr[ContentTypeId::OUTLINE]->Invalidate(); - Display(true); - if(!m_bIsRoot) - { - const sal_uInt16 nCurrPos = pShell->GetOutlinePos(MAXLEVEL); - SvTreeListEntry* pFirst = First(); + pShell->ClearMark(); + pShell->Pop(false); // Cursor is now back at the current superscription. + pShell->EndAllAction(); + if(m_aActiveContentArr[ContentTypeId::OUTLINE]) + m_aActiveContentArr[ContentTypeId::OUTLINE]->Invalidate(); + Display(true); + if(!m_bIsRoot) + { + const sal_uInt16 nCurrPos = pShell->GetOutlinePos(MAXLEVEL); + SvTreeListEntry* pFirst = First(); - while( nullptr != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst)) + while( nullptr != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst)) + { + if(static_cast<SwOutlineContent*>(pFirst->GetUserData())->GetPos() == nCurrPos) { - if(static_cast<SwOutlineContent*>(pFirst->GetUserData())->GetPos() == nCurrPos) - { - Select(pFirst); - MakeVisible(pFirst); - } + Select(pFirst); + MakeVisible(pFirst); } } } @@ -2995,10 +2999,10 @@ bool SwContentTree::Select( SvTreeListEntry* pEntry, bool bSelect ) } } SwNavigationPI* pNavi = GetParentWindow(); - pNavi->m_aContentToolBox->EnableItem(FN_ITEM_UP , bEnable); - pNavi->m_aContentToolBox->EnableItem(FN_ITEM_DOWN, bEnable); - pNavi->m_aContentToolBox->EnableItem(FN_ITEM_LEFT, bEnable); - pNavi->m_aContentToolBox->EnableItem(FN_ITEM_RIGHT,bEnable); + pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("up"), bEnable); + pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("down"), bEnable); + pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("promote"), bEnable); + pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("demote"), bEnable); return SvTreeListBox::Select(pEntry, bSelect); } @@ -3441,7 +3445,7 @@ void SwContentTree::DataChanged(const DataChangedEvent& rDCEvt) SwNavigationPI* SwContentTree::GetParentWindow() { - return static_cast<SwNavigationPI*>(Window::GetParent()); + return m_xDialog; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |