1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <sfx2/basedlgs.hxx>
22 #include <sfx2/tabdlg.hxx>
24 #include <com/sun/star/container/XNameReplace.hpp>
25 #include <com/sun/star/util/XModifiable.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <rtl/ustring.hxx>
28 #include <unotools/resmgr.hxx>
30 #include <unordered_map>
33 typedef std::pair
<OUString
, OUString
> EventPair
;
34 typedef std::unordered_map
<OUString
, EventPair
> EventsHash
;
36 struct EventDisplayName
38 const char* pAsciiEventName
;
39 TranslateId pEventResourceID
;
40 EventDisplayName(const char* pAsciiName
, TranslateId pResId
)
41 : pAsciiEventName(pAsciiName
)
42 , pEventResourceID(pResId
)
47 class SvxMacroTabPage_
;
50 class SvxMacroTabPage_Impl
;
53 class SvxMacroTabPage_
: public SfxTabPage
55 DECL_LINK( SelectEvent_Impl
, weld::TreeView
&, void );
56 DECL_LINK( AssignDeleteHdl_Impl
, weld::Button
&, void );
57 DECL_LINK( DoubleClickHdl_Impl
, weld::TreeView
&, bool );
58 DECL_LINK( DeleteAllHdl_Impl
, weld::Button
&, void );
60 void GenericHandler_Impl(const weld::Button
* pBtn
);
61 const EventPair
* LookupEvent(const OUString
& rEventName
);
63 css::uno::Reference
< css::container::XNameReplace
> m_xAppEvents
;
65 std::unique_ptr
<SvxMacroTabPage_Impl
> mpImpl
;
66 css::uno::Reference
< css::container::XNameReplace
> m_xDocEvents
;
67 css::uno::Reference
< css::util::XModifiable
> m_xModifiable
;
68 EventsHash m_appEventsHash
;
69 EventsHash m_docEventsHash
;
70 int m_nAssignedEvents
;
71 bool bDocModified
, bAppEvents
, bInitialized
;
72 std::vector
< EventDisplayName
> aDisplayNames
;
74 SvxMacroTabPage_(weld::Container
* pPage
, weld::DialogController
* pController
, const OUString
& rUIXMLDescription
, const OUString
& rID
, const SfxItemSet
& rItemSet
);
77 static css::uno::Any
GetPropsByName( const OUString
& eventName
, EventsHash
& eventsHash
);
78 static EventPair
GetPairFromAny(const css::uno::Any
& aAny
);
82 virtual ~SvxMacroTabPage_() override
;
85 void InitAndSetHandler( const css::uno::Reference
< css::container::XNameReplace
>& xAppEvents
, const css::uno::Reference
< css::container::XNameReplace
>& xDocEvents
, const css::uno::Reference
< css::util::XModifiable
>& xModifiable
);
86 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
88 virtual void Reset( const SfxItemSet
* ) override
;
90 void DisplayAppEvents( bool appEvents
);
91 void SetReadOnly( bool bSet
);
92 bool IsReadOnly() const override
;
95 class SvxMacroTabPage
: public SvxMacroTabPage_
99 weld::Container
* pPage
, weld::DialogController
* pController
,
100 const css::uno::Reference
< css::frame::XFrame
>& _rxDocumentFrame
,
101 const SfxItemSet
& rSet
,
102 css::uno::Reference
< css::container::XNameReplace
> const & xNameReplace
,
103 sal_uInt16 nSelectedIndex
107 // class SvxMacroAssignDlg --------------------------------------------------
109 typedef WhichRangesContainer (*GetTabPageRanges
)(); // gives international Which-values
111 class SvxMacroAssignSingleTabDialog
: public SfxSingleTabDialogController
114 SvxMacroAssignSingleTabDialog(weld::Window
* pParent
, const SfxItemSet
& rOptionsSet
);
117 DECL_LINK(OKHdl_Impl
, weld::Button
&, void);
120 class SvxMacroAssignDlg
: public SvxMacroAssignSingleTabDialog
124 weld::Window
* pParent
,
125 const css::uno::Reference
< css::frame::XFrame
>& _rxDocumentFrame
,
126 const SfxItemSet
& rSet
,
127 const css::uno::Reference
< css::container::XNameReplace
>& xNameReplace
,
128 sal_uInt16 nSelectedIndex
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */