34#include <sfx2/strings.hrc>
35#include <svx/svxids.hrc>
38#include <com/sun/star/beans/XPropertySet.hpp>
39#include <com/sun/star/embed/StorageFactory.hpp>
40#include <com/sun/star/embed/XTransactedObject.hpp>
41#include <com/sun/star/embed/ElementModes.hpp>
42#include <com/sun/star/form/XReset.hpp>
43#include <com/sun/star/frame/Desktop.hpp>
44#include <com/sun/star/frame/XController.hpp>
45#include <com/sun/star/frame/XModel.hpp>
46#include <com/sun/star/frame/ModuleManager.hpp>
47#include <com/sun/star/frame/theUICommandDescription.hpp>
48#include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
49#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
50#include <com/sun/star/ui/UIConfigurationManager.hpp>
51#include <com/sun/star/ui/XUIConfigurationManager.hpp>
52#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
55#include <com/sun/star/util/SearchFlags.hpp>
56#include <com/sun/star/util/SearchAlgorithms2.hpp>
64#include <config_features.h>
66#include <com/sun/star/frame/LayoutManager.hpp>
814 sal_uInt16 nCode1 = aCode1.
GetCode();
825 TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(
i));
831 if (nCode1 == nCode2 && nMod1 == nMod2)
833 m_xEntriesBox->select(
i);
834 m_xEntriesBox->scroll_to_row(
i);
847 :
SfxTabPage(pPage, pController,
"cui/ui/accelconfigpage.ui",
"AccelConfigPage", &aSet)
848#
if HAVE_FEATURE_SCRIPTING
851 , aLoadAccelConfigStr(
CuiResId(RID_CUISTR_LOADACCELCONFIG))
852 , aSaveAccelConfigStr(
CuiResId(RID_CUISTR_SAVEACCELCONFIG))
853 , aFilterAllStr(
SfxResId(STR_SFX_FILTERNAME_ALL))
854 , aFilterCfgStr(
CuiResId(RID_CUISTR_FILTERNAME_CFG))
855 , m_bStylesInfoInitialized(false)
856 , m_aUpdateDataTimer(
"SfxAcceleratorConfigPage UpdateDataTimer")
857 , m_aFillGroupIdle(
"SfxAcceleratorConfigPage m_aFillGroupIdle")
858 , m_xEntriesBox(m_xBuilder->weld_tree_view(
"shortcuts"))
859 , m_xOfficeButton(m_xBuilder->weld_radio_button(
"office"))
860 , m_xModuleButton(m_xBuilder->weld_radio_button(
"module"))
861 , m_xChangeButton(m_xBuilder->weld_button(
"change"))
862 , m_xRemoveButton(m_xBuilder->weld_button(
"delete"))
865 , m_xKeyBox(m_xBuilder->weld_tree_view(
"keys"))
866 , m_xSearchEdit(m_xBuilder->weld_entry(
"searchEntry"))
867 , m_xLoadButton(m_xBuilder->weld_button(
"load"))
868 , m_xSaveButton(m_xBuilder->weld_button(
"save"))
869 , m_xResetButton(m_xBuilder->weld_button(
"reset"))
904 if (nTmp > nMaxWidth)
908 auto nNewTab = nMaxWidth + 5;
911 std::vector<int> aWidths{ nNewTab };
918 |= (util::SearchFlags::REG_NOT_BEGINOFLINE | util::SearchFlags::REG_NOT_ENDOFLINE);
963 m_xFrame = xDesktop->getActiveFrame();
980 ui::theModuleUIConfigurationManagerSupplier::get(
m_xContext));
983 m_xModule = xUICfgManager->getShortCutManager();
985 catch (
const uno::RuntimeException&)
989 catch (
const uno::Exception&)
1020 OUString sKey = aKey.
GetName();
1032 sal_Int32 c2 = lKeys.getLength();
1035 for (i2 = 0; i2 < c2; ++i2)
1037 const awt::KeyEvent& aAWTKey = lKeys[i2];
1038 OUString sCommand = xAccMgr->getCommandByKeyEvent(aAWTKey);
1057 for (i3 = 0; i3 < c3; ++i3)
1085 awt::KeyEvent aAWTKey;
1095 if (!sCommand.isEmpty())
1096 xAccMgr->setKeyEvent(aAWTKey, sCommand);
1098 xAccMgr->removeKeyEvent(aAWTKey);
1100 catch (
const uno::RuntimeException&)
1104 catch (
const uno::Exception&)
1114 SelectHdl(m_xGroupLBox->get_widget());
1119 m_aUpdateDataTimer.Start();
1124 if (m_aUpdateDataTimer.IsActive())
1126 m_aUpdateDataTimer.Stop();
1127 m_aUpdateDataTimer.Invoke();
1134 StartFileDialog(StartFileDialogType::Open, aLoadAccelConfigStr);
1139 StartFileDialog(StartFileDialogType::SaveAs, aSaveAccelConfigStr);
1148 m_xEntriesBox->freeze();
1151 m_xEntriesBox->thaw();
1152 m_xEntriesBox->select(0);
1153 SelectHdl(*m_xEntriesBox);
1158 int nPos = m_xEntriesBox->get_selected_index();
1162 TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(
nPos));
1163 OUString sNewCommand = m_xFunctionBox->GetCurCommand();
1164 OUString sLabel = m_xFunctionBox->GetCurLabel();
1165 if (sLabel.isEmpty())
1166 sLabel = GetLabel4Command(sNewCommand);
1169 m_xEntriesBox->set_text(
nPos, sLabel, 1);
1171 SelectHdl(m_xFunctionBox->get_widget());
1177 int nPos = m_xEntriesBox->get_selected_index();
1181 TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(
nPos));
1184 m_xEntriesBox->set_text(
nPos, OUString(), 1);
1187 SelectHdl(m_xFunctionBox->get_widget());
1192 if (&rListBox == m_xEntriesBox.get())
1194 TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_selected_id());
1196 OUString sPossibleNewCommand = m_xFunctionBox->GetCurCommand();
1198 m_xRemoveButton->set_sensitive(
false);
1199 m_xChangeButton->set_sensitive(
false);
1204 m_xRemoveButton->set_sensitive(
true);
1205 m_xChangeButton->set_sensitive(pEntry->
m_sCommand != sPossibleNewCommand);
1208 else if (&rListBox == &m_xGroupLBox->get_widget())
1210 m_xGroupLBox->GroupSelected();
1213 m_xFunctionBox->freeze();
1215 OUString aSearchTerm(m_xSearchEdit->get_text());
1216 int nMatchFound = applySearchFilter(aSearchTerm);
1218 m_xFunctionBox->thaw();
1219 if (nMatchFound != -1)
1221 m_xFunctionBox->select(nMatchFound);
1222 SelectHdl(m_xFunctionBox->get_widget());
1227 m_xChangeButton->set_sensitive(
false);
1230 else if (&rListBox == &m_xFunctionBox->get_widget())
1232 m_xRemoveButton->set_sensitive(
false);
1233 m_xChangeButton->set_sensitive(
false);
1236 TAccInfo* pEntry = weld::fromId<TAccInfo*>(m_xEntriesBox->get_selected_id());
1239 OUString sPossibleNewCommand = m_xFunctionBox->GetCurCommand();
1244 m_xRemoveButton->set_sensitive(
true);
1245 m_xChangeButton->set_sensitive(pEntry->
m_sCommand != sPossibleNewCommand
1246 && !sPossibleNewCommand.isEmpty());
1251 if (!sPossibleNewCommand.isEmpty())
1253 for (
int i = 0,
nCount = m_xEntriesBox->n_children();
i <
nCount; ++
i)
1255 TAccInfo* pUserData = weld::fromId<TAccInfo*>(m_xEntriesBox->get_id(
i));
1256 if (pUserData && pUserData->
m_sCommand == sPossibleNewCommand)
1268 TAccInfo* pU2 = weld::fromId<TAccInfo*>(m_xKeyBox->get_selected_id());
1270 nP2 = MapKeyCodeToPos(pU2->
m_aKey);
1273 m_xEntriesBox->select(nP2);
1274 m_xEntriesBox->scroll_to_row(nP2);
1275 SelectHdl(*m_xEntriesBox);
1284 if (m_xOfficeButton->get_active())
1286 else if (m_xModuleButton->get_active())
1290 if (m_xAct.is() && (xOld == m_xAct))
1293 m_xEntriesBox->freeze();
1296 m_xEntriesBox->thaw();
1301 if (m_xEntriesBox->n_children())
1302 m_xEntriesBox->select(0);
1304 m_aFillGroupIdle.Start();
1314 SelectHdl(rTreeView);
1323 sCfgName = m_pFileDlg->GetPath();
1325 if (sCfgName.isEmpty())
1340 uno::Any(css::embed::ElementModes::READ) };
1342 xRootStorage.set(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY_THROW);
1348 = ui::UIConfigurationManager::create(
m_xContext);
1349 xCfgMgr2->setStorage(xUIConfig);
1350 xCfgMgr.set(xCfgMgr2, uno::UNO_QUERY_THROW);
1357 uno::UNO_SET_THROW);
1359 m_xEntriesBox->freeze();
1362 m_xEntriesBox->thaw();
1363 if (m_xEntriesBox->n_children())
1365 m_xEntriesBox->select(0);
1366 SelectHdl(m_xFunctionBox->get_widget());
1372 if (xRootStorage.is())
1375 xComponent.set(xCfgMgr, uno::UNO_QUERY);
1376 if (xComponent.is())
1377 xComponent->dispose();
1378 xRootStorage->dispose();
1381 catch (
const uno::RuntimeException&)
1385 catch (
const uno::Exception&)
1396 sCfgName = m_pFileDlg->GetPath();
1398 if (sCfgName.isEmpty())
1411 xRootStorage.set(xStorageFactory->createInstanceWithArguments(lArgs), uno::UNO_QUERY_THROW);
1415 uno::UNO_SET_THROW);
1422 xUIConfigProps->setPropertyValue(
1426 = ui::UIConfigurationManager::create(
m_xContext);
1427 xCfgMgr->setStorage(xUIConfig);
1434 uno::UNO_SET_THROW);
1435 Apply(xTargetAccMgr);
1439 uno::UNO_QUERY_THROW);
1444 if (xRootStorage.is())
1451 if (xRootStorage.is())
1455 xRootStorage->dispose();
1458 catch (
const uno::RuntimeException&)
1462 catch (
const uno::Exception&)
1469 bool bSave =
nType == StartFileDialogType::SaveAs;
1470 short nDialogType = bSave ? ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
1471 : ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
1484 m_pFileDlg->StartExecuteModal(aDlgClosedLink);
1493 css::uno::Reference<css::beans::XPropertySet> xFrameProps(
m_xFrame,
1494 css::uno::UNO_QUERY_THROW);
1495 css::uno::Reference<css::frame::XLayoutManager> xLayoutManager;
1496 xFrameProps->getPropertyValue(
"LayoutManager") >>= xLayoutManager;
1497 css::uno::Reference<css::beans::XPropertySet> xLayoutProps(xLayoutManager,
1498 css::uno::UNO_QUERY_THROW);
1499 xLayoutProps->setPropertyValue(
"RefreshContextToolbarToolTip", css::uno::Any(
true));
1501 catch (
const uno::RuntimeException&)
1505 catch (
const uno::Exception&)
1537#if HAVE_FEATURE_SCRIPTING
1538 if (
const SfxMacroInfoItem* pMacroItem =
rSet->
GetItemIfSet(SID_MACROINFO))
1540 m_pMacroInfoItem = pMacroItem;
1557 if (nCode1 == nCode2)
1572 if (xModuleConf.is())
1576 if (!sLabel.isEmpty())
1580 catch (
const uno::RuntimeException&)
1584 catch (
const uno::Exception&)
1605 if (rSearchTerm.isEmpty())
1615 sal_Int32 aStartPos = 0;
1616 sal_Int32 aEndPos =
aStr.getLength();
Reference< XComponentContext > m_xContext
constexpr OUStringLiteral MEDIATYPE_PROPNAME
constexpr OUStringLiteral FOLDERNAME_UICONFIG
const sal_uInt16 KEYCODE_ARRAY[]
IMPL_LINK_NOARG(SfxAcceleratorConfigPage, ImplUpdateDataHdl, Timer *, void)
IMPL_LINK(SfxAcceleratorConfigPage, KeyInputHdl, const KeyEvent &, rKey, bool)
select the entry, which match the current key input ... excepting keys, which are used for the dialog...
const sal_uInt16 KEYCODE_ARRAY_SIZE
css::uno::Reference< css::lang::XComponent > m_xFrame
constexpr OUStringLiteral sMediaType
static size_t GetReservedKeyCodeCount()
static const vcl::KeyCode * GetReservedKeyCode(size_t i)
css::uno::Reference< css::frame::XFrame > m_xFrame
std::unique_ptr< weld::RadioButton > m_xOfficeButton
css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription
bool m_bStylesInfoInitialized
virtual bool FillItemSet(SfxItemSet *) override
std::unique_ptr< weld::Button > m_xResetButton
std::unique_ptr< weld::Button > m_xLoadButton
std::unique_ptr< sfx2::FileDialogHelper > m_pFileDlg
std::unique_ptr< weld::Button > m_xSaveButton
std::unique_ptr< weld::Entry > m_xSearchEdit
sal_Int32 MapKeyCodeToPos(const vcl::KeyCode &rCode) const
int applySearchFilter(OUString const &rSearchTerm)
void StartFileDialog(StartFileDialogType nType, const OUString &rTitle)
void Init(const css::uno::Reference< css::ui::XAcceleratorConfiguration > &pAccMgr)
std::unique_ptr< weld::TreeView > m_xEntriesBox
void Apply(const css::uno::Reference< css::ui::XAcceleratorConfiguration > &pAccMgr)
std::unique_ptr< weld::TreeView > m_xKeyBox
css::uno::Reference< css::uno::XComponentContext > m_xContext
i18nutil::SearchOptions2 m_options
virtual ~SfxAcceleratorConfigPage() override
std::unique_ptr< weld::RadioButton > m_xModuleButton
SfxStylesInfo_Impl m_aStylesInfo
SfxAcceleratorConfigPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rItemSet)
std::unique_ptr< CuiConfigFunctionListBox > m_xFunctionBox
std::unique_ptr< weld::Button > m_xChangeButton
virtual void Reset(const SfxItemSet *) override
css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xAct
OUString GetLabel4Command(const OUString &rCommand)
css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobal
OUString m_sModuleLongName
std::unique_ptr< CuiConfigGroupListBox > m_xGroupLBox
std::unique_ptr< weld::Button > m_xRemoveButton
css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModule
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
css::uno::Reference< css::frame::XFrame > GetFrame() const
weld::Window * GetFrameWeld() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetPriority(TaskPriority ePriority)
void SetTimeout(sal_uInt64 nTimeoutMs)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
static vcl::KeyCode st_AWTKey2VCLKey(const css::awt::KeyEvent &aKey)
static css::awt::KeyEvent st_VCLKey2AWTKey(const vcl::KeyCode &aKey)
bool SearchForward(const OUString &rStr, sal_Int32 *pStart, sal_Int32 *pEnd, css::util::SearchResult *pRes=nullptr)
sal_uInt16 GetCode() const
sal_uInt16 GetModifier() const
OUString CuiResId(TranslateId aKey)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
virtual OUString GetName() const override
constexpr OUStringLiteral FILEDIALOG_FILTER_ALL
constexpr sal_uInt16 KEY_X
constexpr sal_uInt16 KEY_M
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_0
constexpr sal_uInt16 KEY_Q
constexpr sal_uInt16 KEY_SEMICOLON
constexpr sal_uInt16 KEY_R
constexpr sal_uInt16 KEY_F2
constexpr sal_uInt16 KEY_6
constexpr sal_uInt16 KEY_CONTEXTMENU
constexpr sal_uInt16 KEY_8
constexpr sal_uInt16 KEY_F3
constexpr sal_uInt16 KEY_MOD2
constexpr sal_uInt16 KEY_N
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_FIND
constexpr sal_uInt16 KEY_MOD1
constexpr sal_uInt16 KEY_I
constexpr sal_uInt16 KEY_CUT
constexpr sal_uInt16 KEY_K
constexpr sal_uInt16 KEY_BRACKETRIGHT
constexpr sal_uInt16 KEY_HOME
constexpr sal_uInt16 KEY_T
constexpr sal_uInt16 KEY_F15
constexpr sal_uInt16 KEY_7
constexpr sal_uInt16 KEY_1
constexpr sal_uInt16 KEY_ADD
constexpr sal_uInt16 KEY_V
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_F4
constexpr sal_uInt16 KEY_F5
constexpr sal_uInt16 KEY_PAGEDOWN
constexpr sal_uInt16 KEY_EQUAL
constexpr sal_uInt16 KEY_TAB
constexpr sal_uInt16 KEY_COMMA
constexpr sal_uInt16 KEY_J
constexpr sal_uInt16 KEY_B
constexpr sal_uInt16 KEY_4
constexpr sal_uInt16 KEY_POINT
constexpr sal_uInt16 KEY_F6
constexpr sal_uInt16 KEY_U
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_PASTE
constexpr sal_uInt16 KEY_F10
constexpr sal_uInt16 KEY_COLON
constexpr sal_uInt16 KEY_F9
constexpr sal_uInt16 KEY_5
constexpr sal_uInt16 KEY_F7
constexpr sal_uInt16 KEY_COPY
constexpr sal_uInt16 KEY_F1
constexpr sal_uInt16 KEY_MENU
constexpr sal_uInt16 KEY_9
constexpr sal_uInt16 KEY_BRACKETLEFT
constexpr sal_uInt16 KEY_PROPERTIES
constexpr sal_uInt16 KEY_FRONT
constexpr sal_uInt16 KEY_O
constexpr sal_uInt16 KEY_Z
constexpr sal_uInt16 KEY_S
constexpr sal_uInt16 KEY_3
constexpr sal_uInt16 KEY_MOD3
constexpr sal_uInt16 KEY_QUOTERIGHT
constexpr sal_uInt16 KEY_A
constexpr sal_uInt16 KEY_REPEAT
constexpr sal_uInt16 KEY_Y
constexpr sal_uInt16 KEY_UNDO
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_F13
constexpr sal_uInt16 KEY_F
constexpr sal_uInt16 KEY_D
constexpr sal_uInt16 KEY_H
constexpr sal_uInt16 KEY_G
constexpr sal_uInt16 KEY_OPEN
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEY_L
constexpr sal_uInt16 KEY_F8
constexpr sal_uInt16 KEY_F12
constexpr sal_uInt16 KEY_TILDE
constexpr sal_uInt16 KEY_DOWN
constexpr sal_uInt16 KEY_SPACE
constexpr sal_uInt16 KEY_PAGEUP
constexpr sal_uInt16 KEY_F11
constexpr sal_uInt16 KEY_E
constexpr sal_uInt16 KEY_QUOTELEFT
constexpr sal_uInt16 KEY_C
constexpr sal_uInt16 KEY_HELP
constexpr sal_uInt16 KEY_2
constexpr sal_uInt16 KEY_W
constexpr sal_uInt16 KEY_P
constexpr sal_uInt16 KEY_SUBTRACT
constexpr sal_uInt16 KEY_DIVIDE
constexpr sal_uInt16 KEY_F16
constexpr sal_uInt16 KEY_SHIFT
constexpr sal_uInt16 KEY_F14
constexpr sal_uInt16 KEY_RIGHTCURLYBRACKET
constexpr sal_uInt16 KEY_INSERT
constexpr sal_uInt16 KEY_BACKSPACE
constexpr sal_uInt16 KEY_END
constexpr sal_uInt16 KEY_MULTIPLY
#define LINK(Instance, Class, Member)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
Reference< XComponentContext > getProcessComponentContext()
OUString toId(const void *pValue)
SFX2_DLLPUBLIC OUString SfxResId(TranslateId aId)
void init(const OUString &rModuleName, const css::uno::Reference< css::frame::XModel > &xModel)
static bool parseStyleCommand(SfxStyleInfo_Impl &aStyle)
void getLabel4Style(SfxStyleInfo_Impl &aStyle)
bool isConfigured() const
TransliterationFlags transliterateFlags
Reference< XController > xController
Reference< XModel > xModel
#define EDIT_UPDATEDATA_TIMEOUT