xref: /aoo42x/main/cui/source/inc/macropg.hxx (revision c4eee24d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _MACROPG_HXX
24 #define _MACROPG_HXX
25 
26 #include <sfx2/basedlgs.hxx>
27 #include <sfx2/tabdlg.hxx>
28 
29 #include <com/sun/star/container/XNameReplace.hpp>
30 #include <com/sun/star/util/XModifiable.hpp>
31 #include <com/sun/star/beans/PropertyValue.hpp>
32 #include <com/sun/star/uno/Reference.hxx>
33 #include <svl/macitem.hxx>
34 #ifndef _LSTBOX_HXX //autogen
35 #include <vcl/lstbox.hxx>
36 #endif
37 #include <rtl/ustring.hxx>
38 
39 #include <hash_map>
40 #include <vector>
41 
42 typedef ::std::hash_map< ::rtl::OUString, ::std::pair< ::rtl::OUString, ::rtl::OUString >, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > EventsHash;
43 
44 struct EventDisplayName
45 {
46     const sal_Char* pAsciiEventName;
47     sal_uInt16          nEventResourceID;
EventDisplayNameEventDisplayName48     EventDisplayName() : pAsciiEventName( NULL ), nEventResourceID(0) { }
EventDisplayNameEventDisplayName49     EventDisplayName( const sal_Char* _pAsciiName, const sal_uInt16 _nResId )
50         : pAsciiEventName( _pAsciiName )
51         , nEventResourceID( _nResId )
52     {
53     }
54 };
55 typedef ::std::vector< EventDisplayName >   EventDisplayNames;
56 
57 class _SvxMacroTabPage;
58 class SvStringsDtor;
59 class SvTabListBox;
60 class Edit;
61 class String;
62 
63 class _HeaderTabListBox;
64 class _SvxMacroTabPage_Impl;
65 
66 
67 class _SvxMacroTabPage : public SfxTabPage
68 {
69 #if _SOLAR__PRIVATE
70 	DECL_STATIC_LINK( _SvxMacroTabPage, SelectEvent_Impl, SvTabListBox * );
71 	DECL_STATIC_LINK( _SvxMacroTabPage, AssignDeleteHdl_Impl, PushButton * );
72 	DECL_STATIC_LINK( _SvxMacroTabPage, DoubleClickHdl_Impl, SvTabListBox * );
73 
74 	static long GenericHandler_Impl( _SvxMacroTabPage* pThis, PushButton* pBtn );
75 
76 #endif
77 protected:
78 	_SvxMacroTabPage_Impl*		mpImpl;
79     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > m_xAppEvents;
80     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > m_xDocEvents;
81     ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifiable > m_xModifiable;
82 	EventsHash m_appEventsHash;
83 	EventsHash m_docEventsHash;
84 	bool bReadOnly, bDocModified, bAppEvents, bInitialized;
85     EventDisplayNames aDisplayNames;
86 
87 								_SvxMacroTabPage( Window* pParent, const ResId& rId, const SfxItemSet& rItemSet );
88 
89 	void						EnableButtons();
90 	::com::sun::star::uno::Any 	GetPropsByName( const ::rtl::OUString& eventName, EventsHash& eventsHash );
91 	::std::pair< ::rtl::OUString, ::rtl::OUString > GetPairFromAny( ::com::sun::star::uno::Any aAny );
92 
93 public:
94 
95 	virtual						~_SvxMacroTabPage();
96     void                        InitResources();
97 
98 	void						InitAndSetHandler( ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > xAppEvents, ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > xDocEvents, ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifiable > xModifiable );
99 	virtual	sal_Bool				FillItemSet( SfxItemSet& rSet );
100 
101 	using SfxTabPage::Reset;
102 	virtual	void				Reset();
103 
104 	void						DisplayAppEvents( bool appEvents);
105 	void						SetReadOnly( sal_Bool bSet );
106 	sal_Bool						IsReadOnly() const;
107 };
108 
109 class SvxMacroTabPage : public _SvxMacroTabPage
110 {
111 public:
112 	SvxMacroTabPage(
113         Window* pParent,
114         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxDocumentFrame,
115         const SfxItemSet& rSet,
116         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > xNameReplace,
117         sal_uInt16 nSelectedIndex
118     );
119 	virtual ~SvxMacroTabPage();
120 };
121 
122 // class SvxMacroAssignDlg --------------------------------------------------
123 
124 typedef sal_uInt16*	(*GetTabPageRanges)(); // liefert internationale Which-Werte
125 
126 class SvxMacroAssignSingleTabDialog : public SfxModalDialog
127 {
128 public:
129 	SvxMacroAssignSingleTabDialog( Window* pParent, const SfxItemSet& rOptionsSet, sal_uInt16 nUniqueId );
130 
131 	virtual             ~SvxMacroAssignSingleTabDialog();
132 
133 	void				SetTabPage( SfxTabPage* pTabPage );
134 	// SfxTabPage*			GetTabPage() const { return pPage; }
135 
136 	// OKButton*			GetOKButton() const { return pOKBtn; }
137 	// CancelButton*		GetCancelButton() const { return pCancelBtn; }
138 
139 private:
140 	SfxViewFrame*       pFrame;
141 
142 	FixedLine*			pFixedLine;
143 
144 	OKButton*			pOKBtn;
145 	CancelButton*		pCancelBtn;
146 	HelpButton*			pHelpBtn;
147 
148 	SfxTabPage*			pPage;
149 	const SfxItemSet*	pOptions;
150 	SfxItemSet*			pOutSet;
151 
152 #if _SOLAR__PRIVATE
153 	DECL_DLLPRIVATE_LINK( OKHdl_Impl, Button * );
154 #endif
155 };
156 
157 
158 class SvxMacroAssignDlg : public SvxMacroAssignSingleTabDialog
159 {
160 public:
161 	SvxMacroAssignDlg(
162         Window* pParent,
163         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxDocumentFrame,
164         const SfxItemSet& rSet,
165         const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace >& xNameReplace,
166         sal_uInt16 nSelectedIndex
167     );
168 	virtual	~SvxMacroAssignDlg();
169 };
170 
171 #endif
172