From e834354ff3dbf38b1d3834f6980fffaed7b4074c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 21 Feb 2017 16:25:41 +0000 Subject: [PATCH] convert writer changes menu to .ui Change-Id: I30a957f91c3faca5e16a70efce08579ac3368bdf --- sc/source/ui/miscdlgs/acredlin.cxx | 6 +- svx/uiconfig/ui/acceptrejectchangesdialog.ui | 79 ++++- sw/AllLangResTarget_sw.mk | 1 - sw/inc/helpid.h | 9 - sw/source/uibase/inc/misc.hrc | 1 - sw/source/uibase/inc/redlndlg.hxx | 2 +- sw/source/uibase/misc/redlndlg.cxx | 298 +++++++++---------- sw/source/uibase/misc/redlndlg.hrc | 28 -- sw/source/uibase/misc/redlndlg.src | 85 ------ 9 files changed, 215 insertions(+), 294 deletions(-) delete mode 100644 sw/source/uibase/misc/redlndlg.hrc delete mode 100644 sw/source/uibase/misc/redlndlg.src diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx index cf18e2b2e33b..ac5d9b5ad413 100644 --- a/sc/source/ui/miscdlgs/acredlin.cxx +++ b/sc/source/ui/miscdlgs/acredlin.cxx @@ -1679,15 +1679,15 @@ IMPL_LINK_NOARG(ScAcceptChgDlg, CommandHdl, SvSimpleTable*, void) m_xPopup->Deactivate(); } - const sal_uInt16 nSubSortId = m_xPopup->GetItemId("sort"); + const sal_uInt16 nSubSortId = m_xPopup->GetItemId("calcsort"); PopupMenu *pSubMenu = m_xPopup->GetPopupMenu(nSubSortId); - const sal_uInt16 nActionId = pSubMenu->GetItemId("action"); + const sal_uInt16 nActionId = pSubMenu->GetItemId("calcaction"); sal_uInt16 nSortedCol = pTheView->GetSortedCol(); if (nSortedCol != 0xFFFF) pSubMenu->CheckItem(nActionId + nSortedCol); - const sal_uInt16 nEditId = m_xPopup->GetItemId("edit"); + const sal_uInt16 nEditId = m_xPopup->GetItemId("calcedit"); m_xPopup->EnableItem(nEditId, false); diff --git a/svx/uiconfig/ui/acceptrejectchangesdialog.ui b/svx/uiconfig/ui/acceptrejectchangesdialog.ui index af4ddf28a16f..38d6d013994e 100644 --- a/svx/uiconfig/ui/acceptrejectchangesdialog.ui +++ b/svx/uiconfig/ui/acceptrejectchangesdialog.ui @@ -128,14 +128,14 @@ True False - + True False Edit Comment... - + True False Sorting @@ -145,7 +145,7 @@ True False - + True False Action @@ -153,7 +153,7 @@ - + True False Position @@ -161,7 +161,7 @@ - + True False Author @@ -169,7 +169,7 @@ - + True False Date @@ -177,7 +177,7 @@ - + True False Description @@ -189,4 +189,69 @@ + + True + False + + + True + False + Edit Comment... + + + + + True + False + Sort By + True + + + True + False + + + True + False + Action + True + + + + + True + False + Author + True + + + + + True + False + Date + True + + + + + True + False + Comment + True + + + + + True + False + Document Position + True + + + + + + + diff --git a/sw/AllLangResTarget_sw.mk b/sw/AllLangResTarget_sw.mk index 536821e9fb7b..925c5abc2d0e 100644 --- a/sw/AllLangResTarget_sw.mk +++ b/sw/AllLangResTarget_sw.mk @@ -66,7 +66,6 @@ $(eval $(call gb_SrsTarget_add_files,sw/res,\ sw/source/uibase/dialog/regionsw.src \ sw/source/uibase/docvw/docvw.src \ sw/source/uibase/lingu/olmenu.src \ - sw/source/uibase/misc/redlndlg.src \ sw/source/uibase/ribbar/inputwin.src \ sw/source/uibase/ribbar/workctrl.src \ sw/source/uibase/uiview/view.src \ diff --git a/sw/inc/helpid.h b/sw/inc/helpid.h index 3319a904f7c5..2a780a4dbca4 100644 --- a/sw/inc/helpid.h +++ b/sw/inc/helpid.h @@ -58,13 +58,6 @@ #define HID_GLBLTREE_UPD_IDX "SW_HID_GLBLTREE_UPD_IDX" #define HID_GLBLTREE_UPD_LINK "SW_HID_GLBLTREE_UPD_LINK" #define HID_GLBLTREEUPD_ALL "SW_HID_GLBLTREEUPD_ALL" -#define HID_SORT_ACTION "SW_HID_SORT_ACTION" -#define HID_SORT_AUTHOR "SW_HID_SORT_AUTHOR" -#define HID_SORT_DATE "SW_HID_SORT_DATE" -#define HID_SORT_COMMENT "SW_HID_SORT_COMMENT" -#define HID_SW_SORT_POSITION "SW_HID_SW_SORT_POSITION" -#define HID_EDIT_COMMENT "SW_HID_EDIT_COMMENT" - #define HID_GLBLTREE_EDIT_LINK "SW_HID_GLBLTREE_EDIT_LINK" @@ -73,8 +66,6 @@ #define HID_REDLINE_CTRL "SW_HID_REDLINE_CTRL" - - // sw::sidebar::PagePropertyPanel #define HID_SWPAGE_LEFT_MARGIN "HID_SWPAGE_LEFT_MARGIN" #define HID_SWPAGE_RIGHT_MARGIN "HID_SWPAGE_RIGHT_MARGIN" diff --git a/sw/source/uibase/inc/misc.hrc b/sw/source/uibase/inc/misc.hrc index f7a0db9b0f7b..2c29900a3f08 100644 --- a/sw/source/uibase/inc/misc.hrc +++ b/sw/source/uibase/inc/misc.hrc @@ -39,7 +39,6 @@ #define STR_CHANGE_END (RC_MISC_BEGIN + 45) #define STR_SAVE_GLOSSARY (RC_MISC_BEGIN + 46) -#define MN_REDLINE_POPUP (RC_MISC_BEGIN + 61) #define STR_MY_AUTOTEXT (RC_MISC_BEGIN + 64) #define STR_COMMENTS_LABEL (RC_MISC_BEGIN + 65) diff --git a/sw/source/uibase/inc/redlndlg.hxx b/sw/source/uibase/inc/redlndlg.hxx index 328ac4518885..fd5d59442eef 100644 --- a/sw/source/uibase/inc/redlndlg.hxx +++ b/sw/source/uibase/inc/redlndlg.hxx @@ -66,7 +66,7 @@ class SW_DLLPUBLIC SwRedlineAcceptDlg final SwRedlineDataChildArr m_RedlineChildren; SwRedlineDataParentSortArr m_aUsedSeqNo; VclPtr m_aTabPagesCTRL; - ScopedVclPtrInstance m_aPopup; + VclPtr m_xPopup; Timer m_aDeselectTimer; Timer m_aSelectTimer; OUString m_sInserted; diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx index 746ccd9c745d..2d96ad884bdc 100644 --- a/sw/source/uibase/misc/redlndlg.cxx +++ b/sw/source/uibase/misc/redlndlg.cxx @@ -36,7 +36,6 @@ #include #include #include -#include #include // -> #111827# @@ -150,7 +149,7 @@ SwRedlineAcceptDlg::SwRedlineAcceptDlg(vcl::Window *pParent, VclBuilderContainer vcl::Window *pContentArea, bool bAutoFormat) : m_pParentDlg (pParent), m_aTabPagesCTRL (VclPtr::Create(pContentArea, pBuilder)), - m_aPopup (SW_RES(MN_REDLINE_POPUP)), + m_xPopup(pBuilder->get_menu("writermenu")), m_sInserted (SW_RES(STR_REDLINE_INSERTED)), m_sDeleted (SW_RES(STR_REDLINE_DELETED)), m_sFormated (SW_RES(STR_REDLINE_FORMATED)), @@ -1012,166 +1011,147 @@ IMPL_LINK_NOARG(SwRedlineAcceptDlg, CommandHdl, SvSimpleTable*, void) { const CommandEvent aCEvt(m_pTable->GetCommandEvent()); - switch ( aCEvt.GetCommand() ) + if (aCEvt.GetCommand() != CommandEventId::ContextMenu) + return; + + SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr(); + SvTreeListEntry* pEntry = m_pTable->FirstSelected(); + const SwRangeRedline *pRed = nullptr; + + if (pEntry) { - case CommandEventId::ContextMenu: + SvTreeListEntry* pTopEntry = pEntry; + + if (m_pTable->GetParent(pEntry)) + pTopEntry = m_pTable->GetParent(pEntry); + + sal_uInt16 nPos = GetRedlinePos(*pTopEntry); + + // disable commenting for protected areas + if (nPos != USHRT_MAX && (pRed = pSh->GotoRedline(nPos, true)) != nullptr) { - SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr(); - SvTreeListEntry* pEntry = m_pTable->FirstSelected(); - const SwRangeRedline *pRed = nullptr; - - if (pEntry) - { - SvTreeListEntry* pTopEntry = pEntry; - - if (m_pTable->GetParent(pEntry)) - pTopEntry = m_pTable->GetParent(pEntry); - - sal_uInt16 nPos = GetRedlinePos(*pTopEntry); - - // disable commenting for protected areas - if (nPos != USHRT_MAX && (pRed = pSh->GotoRedline(nPos, true)) != nullptr) - { - if( pSh->IsCursorPtAtEnd() ) - pSh->SwapPam(); - pSh->SetInSelect(); - } - } - - m_aPopup->EnableItem( MN_EDIT_COMMENT, pEntry && pRed && - !m_pTable->GetParent(pEntry) && - !m_pTable->NextSelected(pEntry) -//JP 27.9.2001: make no sense if we handle readonly sections -// && pRed->HasReadonlySel() - ); - - m_aPopup->EnableItem( MN_SUB_SORT, m_pTable->First() != nullptr ); - sal_uInt16 nColumn = m_pTable->GetSortedCol(); - if (nColumn == 0xffff) - nColumn = 4; - - PopupMenu *pSubMenu = m_aPopup->GetPopupMenu(MN_SUB_SORT); - if (pSubMenu) - { - for (sal_uInt16 i = MN_SORT_ACTION; i < MN_SORT_ACTION + 5; i++) - pSubMenu->CheckItem(i, false); - - pSubMenu->CheckItem(nColumn + MN_SORT_ACTION); - } - - sal_uInt16 nRet = m_aPopup->Execute(m_pTable, aCEvt.GetMousePosPixel()); - - switch( nRet ) - { - case MN_EDIT_COMMENT: - { - if (pEntry) - { - if (m_pTable->GetParent(pEntry)) - pEntry = m_pTable->GetParent(pEntry); - - sal_uInt16 nPos = GetRedlinePos(*pEntry); - - if (nPos == USHRT_MAX) - break; - - const SwRangeRedline &rRedline = pSh->GetRedline(nPos); - - /* enable again once we have redline comments in the margin - sComment = rRedline.GetComment(); - if ( !sComment.Len() ) - GetActiveView()->GetDocShell()->Broadcast(SwRedlineHint(&rRedline,SWREDLINE_INSERTED)); - const_cast(rRedline).Broadcast(SwRedlineHint(&rRedline,SWREDLINE_FOCUS)); - */ - - OUString sComment = convertLineEnd(rRedline.GetComment(), GetSystemLineEnd()); - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - OSL_ENSURE(pFact, "Dialog creation failed!"); - ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc(); - OSL_ENSURE(fnGetRange, "Dialog creation failed! GetRanges()"); - SfxItemSet aSet( pSh->GetAttrPool(), fnGetRange() ); - - aSet.Put(SvxPostItTextItem(sComment, SID_ATTR_POSTIT_TEXT)); - aSet.Put(SvxPostItAuthorItem(rRedline.GetAuthorString(), SID_ATTR_POSTIT_AUTHOR)); - - aSet.Put(SvxPostItDateItem( GetAppLangDateTimeString( - rRedline.GetRedlineData().GetTimeStamp() ), - SID_ATTR_POSTIT_DATE )); - - ScopedVclPtr pDlg(pFact->CreateSvxPostItDialog( m_pParentDlg, aSet )); - OSL_ENSURE(pDlg, "Dialog creation failed!"); - - pDlg->HideAuthor(); - - sal_uInt16 nResId = 0; - switch( rRedline.GetType() ) - { - case nsRedlineType_t::REDLINE_INSERT: - nResId = STR_REDLINE_INSERTED; - break; - case nsRedlineType_t::REDLINE_DELETE: - nResId = STR_REDLINE_DELETED; - break; - case nsRedlineType_t::REDLINE_FORMAT: - case nsRedlineType_t::REDLINE_PARAGRAPH_FORMAT: - nResId = STR_REDLINE_FORMATED; - break; - case nsRedlineType_t::REDLINE_TABLE: - nResId = STR_REDLINE_TABLECHG; - break; - default:;//prevent warning - } - OUString sTitle(SW_RES(STR_REDLINE_COMMENT)); - if( nResId ) - sTitle += SW_RESSTR( nResId ); - pDlg->SetText(sTitle); - - SwViewShell::SetCareWin(pDlg->GetWindow()); - - if ( pDlg->Execute() == RET_OK ) - { - const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); - OUString sMsg(static_cast(pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue()); - - // insert / change comment - pSh->SetRedlineComment(sMsg); - m_pTable->SetEntryText(sMsg.replace('\n', ' '), pEntry, 3); - } - - pDlg.disposeAndClear(); - SwViewShell::SetCareWin(nullptr); - } - - } - break; - - case MN_SORT_ACTION: - case MN_SORT_AUTHOR: - case MN_SORT_DATE: - case MN_SORT_COMMENT: - case MN_SORT_POSITION: - { - bSortDir = true; - if (nRet - MN_SORT_ACTION == 4 && m_pTable->GetSortedCol() == 0xffff) - break; // we already have it - - nSortMode = nRet - MN_SORT_ACTION; - if (nSortMode == 4) - nSortMode = 0xffff; // unsorted / sorted by position - - if (m_pTable->GetSortedCol() == nSortMode) - bSortDir = !m_pTable->GetSortDirection(); - - SwWait aWait( *::GetActiveView()->GetDocShell(), false ); - m_pTable->SortByCol(nSortMode, bSortDir); - if (nSortMode == 0xffff) - Init(); // newly fill everything - } - break; - } + if( pSh->IsCursorPtAtEnd() ) + pSh->SwapPam(); + pSh->SetInSelect(); } - break; - default: break; + } + + const sal_uInt16 nEditId = m_xPopup->GetItemId("writeredit"); + + m_xPopup->EnableItem(nEditId, pEntry && pRed && + !m_pTable->GetParent(pEntry) && + !m_pTable->NextSelected(pEntry)); + + sal_uInt16 nColumn = m_pTable->GetSortedCol(); + if (nColumn == 0xffff) + nColumn = 4; + + const sal_uInt16 nSubSortId = m_xPopup->GetItemId("writersort"); + m_xPopup->EnableItem(nSubSortId, m_pTable->First() != nullptr); + PopupMenu *pSubMenu = m_xPopup->GetPopupMenu(nSubSortId); + const sal_uInt16 nActionId = pSubMenu->GetItemId("writeraction"); + for (sal_uInt16 i = nActionId; i < nActionId + 5; ++i) + pSubMenu->CheckItem(i, false); + pSubMenu->CheckItem(nActionId + nColumn); + + sal_uInt16 nRet = m_xPopup->Execute(m_pTable, aCEvt.GetMousePosPixel()); + + if (nRet == nEditId) + { + if (pEntry) + { + if (m_pTable->GetParent(pEntry)) + pEntry = m_pTable->GetParent(pEntry); + + sal_uInt16 nPos = GetRedlinePos(*pEntry); + + if (nPos == USHRT_MAX) + return; + + const SwRangeRedline &rRedline = pSh->GetRedline(nPos); + + /* enable again once we have redline comments in the margin + sComment = rRedline.GetComment(); + if ( !sComment.Len() ) + GetActiveView()->GetDocShell()->Broadcast(SwRedlineHint(&rRedline,SWREDLINE_INSERTED)); + const_cast(rRedline).Broadcast(SwRedlineHint(&rRedline,SWREDLINE_FOCUS)); + */ + + OUString sComment = convertLineEnd(rRedline.GetComment(), GetSystemLineEnd()); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "Dialog creation failed!"); + ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc(); + OSL_ENSURE(fnGetRange, "Dialog creation failed! GetRanges()"); + SfxItemSet aSet( pSh->GetAttrPool(), fnGetRange() ); + + aSet.Put(SvxPostItTextItem(sComment, SID_ATTR_POSTIT_TEXT)); + aSet.Put(SvxPostItAuthorItem(rRedline.GetAuthorString(), SID_ATTR_POSTIT_AUTHOR)); + + aSet.Put(SvxPostItDateItem( GetAppLangDateTimeString( + rRedline.GetRedlineData().GetTimeStamp() ), + SID_ATTR_POSTIT_DATE )); + + ScopedVclPtr pDlg(pFact->CreateSvxPostItDialog( m_pParentDlg, aSet )); + OSL_ENSURE(pDlg, "Dialog creation failed!"); + + pDlg->HideAuthor(); + + sal_uInt16 nResId = 0; + switch( rRedline.GetType() ) + { + case nsRedlineType_t::REDLINE_INSERT: + nResId = STR_REDLINE_INSERTED; + break; + case nsRedlineType_t::REDLINE_DELETE: + nResId = STR_REDLINE_DELETED; + break; + case nsRedlineType_t::REDLINE_FORMAT: + case nsRedlineType_t::REDLINE_PARAGRAPH_FORMAT: + nResId = STR_REDLINE_FORMATED; + break; + case nsRedlineType_t::REDLINE_TABLE: + nResId = STR_REDLINE_TABLECHG; + break; + default:;//prevent warning + } + OUString sTitle(SW_RES(STR_REDLINE_COMMENT)); + if( nResId ) + sTitle += SW_RESSTR( nResId ); + pDlg->SetText(sTitle); + + SwViewShell::SetCareWin(pDlg->GetWindow()); + + if ( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + OUString sMsg(static_cast(pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue()); + + // insert / change comment + pSh->SetRedlineComment(sMsg); + m_pTable->SetEntryText(sMsg.replace('\n', ' '), pEntry, 3); + } + + pDlg.disposeAndClear(); + SwViewShell::SetCareWin(nullptr); + } + } + else if (nRet) + { + bSortDir = true; + if (nRet - nActionId == 4 && m_pTable->GetSortedCol() == 0xffff) + return; // we already have it + + nSortMode = nRet - nActionId; + if (nSortMode == 4) + nSortMode = 0xffff; // unsorted / sorted by position + + if (m_pTable->GetSortedCol() == nSortMode) + bSortDir = !m_pTable->GetSortDirection(); + + SwWait aWait( *::GetActiveView()->GetDocShell(), false ); + m_pTable->SortByCol(nSortMode, bSortDir); + if (nSortMode == 0xffff) + Init(); // newly fill everything } } diff --git a/sw/source/uibase/misc/redlndlg.hrc b/sw/source/uibase/misc/redlndlg.hrc deleted file mode 100644 index e3d0464faca6..000000000000 --- a/sw/source/uibase/misc/redlndlg.hrc +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#define MN_EDIT_COMMENT 1 -#define MN_SUB_SORT 2 -#define MN_SORT_ACTION 3 -#define MN_SORT_AUTHOR 4 -#define MN_SORT_DATE 5 -#define MN_SORT_COMMENT 6 -#define MN_SORT_POSITION 7 - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/misc/redlndlg.src b/sw/source/uibase/misc/redlndlg.src deleted file mode 100644 index e3b9aadb3a0f..000000000000 --- a/sw/source/uibase/misc/redlndlg.src +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -/* StarView resource file */ - -#include "redlndlg.hrc" -#include "misc.hrc" -#include "helpid.h" - -Menu MN_REDLINE_POPUP -{ - ItemList = - { - MenuItem - { - Identifier = MN_EDIT_COMMENT ; - HelpID = HID_EDIT_COMMENT ; - Text [ en-US ] = "Edit Comment..." ; - }; - MenuItem - { - Identifier = MN_SUB_SORT ; - RadioCheck = TRUE ; - SubMenu = Menu - { - ItemList = - { - MenuItem - { - Identifier = MN_SORT_ACTION ; - HelpID = HID_SORT_ACTION ; - RadioCheck = TRUE ; - Text [ en-US ] = "Action" ; - }; - MenuItem - { - Identifier = MN_SORT_AUTHOR ; - HelpID = HID_SORT_AUTHOR ; - RadioCheck = TRUE ; - Text [ en-US ] = "Author" ; - }; - MenuItem - { - Identifier = MN_SORT_DATE ; - HelpID = HID_SORT_DATE ; - RadioCheck = TRUE ; - Text [ en-US ] = "Date" ; - }; - MenuItem - { - Identifier = MN_SORT_COMMENT ; - HelpID = HID_SORT_COMMENT ; - RadioCheck = TRUE ; - Text [ en-US ] = "Comment" ; - }; - MenuItem - { - Identifier = MN_SORT_POSITION ; - HelpID = HID_SW_SORT_POSITION ; - RadioCheck = TRUE ; - Text [ en-US ] = "Document position" ; - }; - }; - }; - Text [ en-US ] = "Sort By" ; - }; - }; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */