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 class SvxMacroTabPage_
;
38 class SvxMacroTabPage_Impl
;
41 class SvxMacroTabPage_
: public SfxTabPage
43 DECL_LINK( SelectEvent_Impl
, weld::TreeView
&, void );
44 DECL_LINK( AssignDeleteHdl_Impl
, weld::Button
&, void );
45 DECL_LINK( DoubleClickHdl_Impl
, weld::TreeView
&, bool );
46 DECL_LINK( DeleteAllHdl_Impl
, weld::Button
&, void );
48 void GenericHandler_Impl(const weld::Button
* pBtn
);
49 const EventPair
* LookupEvent(const OUString
& rEventName
);
51 css::uno::Reference
< css::container::XNameReplace
> m_xAppEvents
;
53 std::unique_ptr
<SvxMacroTabPage_Impl
> mpImpl
;
54 css::uno::Reference
< css::container::XNameReplace
> m_xDocEvents
;
55 css::uno::Reference
< css::util::XModifiable
> m_xModifiable
;
56 EventsHash m_appEventsHash
;
57 EventsHash m_docEventsHash
;
58 int m_nAssignedEvents
;
59 bool bDocModified
, bAppEvents
, bInitialized
;
61 SvxMacroTabPage_(weld::Container
* pPage
, weld::DialogController
* pController
, const OUString
& rUIXMLDescription
, const OUString
& rID
, const SfxItemSet
& rItemSet
);
64 static css::uno::Any
GetPropsByName( const OUString
& eventName
, EventsHash
& eventsHash
);
65 static EventPair
GetPairFromAny(const css::uno::Any
& aAny
);
69 virtual ~SvxMacroTabPage_() override
;
71 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
);
72 virtual bool FillItemSet( SfxItemSet
* rSet
) override
;
74 virtual void Reset( const SfxItemSet
* ) override
;
76 void DisplayAppEvents( bool appEvents
);
77 void SetReadOnly( bool bSet
);
78 bool IsReadOnly() const override
;
81 class SvxMacroTabPage
: public SvxMacroTabPage_
85 weld::Container
* pPage
, weld::DialogController
* pController
,
86 const css::uno::Reference
< css::frame::XFrame
>& _rxDocumentFrame
,
87 const SfxItemSet
& rSet
,
88 css::uno::Reference
< css::container::XNameReplace
> const & xNameReplace
,
89 sal_uInt16 nSelectedIndex
93 // class SvxMacroAssignDlg --------------------------------------------------
95 typedef const WhichRangesContainer
& (*GetTabPageRanges
)(); // gives international Which-values
97 class SvxMacroAssignSingleTabDialog
: public SfxSingleTabDialogController
100 SvxMacroAssignSingleTabDialog(weld::Window
* pParent
, const SfxItemSet
& rOptionsSet
);
103 DECL_LINK(OKHdl_Impl
, weld::Button
&, void);
106 class SvxMacroAssignDlg
: public SvxMacroAssignSingleTabDialog
110 weld::Window
* pParent
,
111 const css::uno::Reference
< css::frame::XFrame
>& _rxDocumentFrame
,
112 const SfxItemSet
& rSet
,
113 const css::uno::Reference
< css::container::XNameReplace
>& xNameReplace
,
114 sal_uInt16 nSelectedIndex
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */