1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: scriptdlg.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SCRIPTDLG_HXX
32 #define _SCRIPTDLG_HXX
36 #include "tools/solar.h"
38 #include <svtools/svtreebx.hxx>
39 #include <vcl/dialog.hxx>
40 #include <vcl/button.hxx>
41 #include <vcl/fixed.hxx>
42 #include <vcl/abstdlg.hxx>
43 #include <sfx2/basedlgs.hxx>
45 #include <com/sun/star/beans/XPropertySet.hpp>
46 #include <com/sun/star/script/browse/XBrowseNode.hpp>
47 #include <com/sun/star/frame/XModel.hpp>
51 #define OBJTYPE_BASICMANAGER 1L
52 //#define OBJTYPE_LIB 2L
53 //#define OBJTYPE_MODULE 3L
54 #define OBJTYPE_METHOD 2L
55 //#define OBJTYPE_METHODINOBJ 5L
56 //#define OBJTYPE_OBJECT 6L
57 //#define OBJTYPE_SUBOBJ 7L
58 //#define OBJTYPE_PROPERTY 8L
59 #define OBJTYPE_SCRIPTCONTAINER 3L
60 #define OBJTYPE_SFROOT 4L
62 #define BROWSEMODE_MODULES 0x01
63 #define BROWSEMODE_SUBS 0x02
64 #define BROWSEMODE_OBJS 0x04
65 #define BROWSEMODE_PROPS 0x08
66 #define BROWSEMODE_SUBOBJS 0x10
68 #define INPUTMODE_NEWLIB 1
69 #define INPUTMODE_NEWMACRO 2
70 #define INPUTMODE_RENAME 3
72 typedef ::std::hash_map
< ::rtl::OUString
, ::rtl::OUString
,
73 ::rtl::OUStringHash
, ::std::equal_to
< ::rtl::OUString
> > Selection_hash
;
77 class SFTreeListBox
: public SvTreeListBox
79 friend class SvxScriptOrgDialog
;
90 ::rtl::OUString m_sMyMacros
;
91 ::rtl::OUString m_sProdMacros
;
93 ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>
94 getLangNodeFromRootNode( ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>& root
, ::rtl::OUString
& language
);
95 void delUserData( SvLBoxEntry
* pEntry
);
97 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getDocumentModel( ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xCtx
, ::rtl::OUString
& docName
);
100 void ExpandTree( SvLBoxEntry
* pRootEntry
);
101 virtual void RequestingChilds( SvLBoxEntry
* pParent
);
102 virtual void ExpandedHdl();
103 SvLBoxEntry
* FindEntry( SvLBoxEntry
* pParent
, const String
& rText
, BYTE nType
);
104 virtual long ExpandingHdl();
105 static BOOL
dialogSort1( com::sun::star::uno::Reference
< com::sun::star::script::browse::XBrowseNode
> node1
,
106 com::sun::star::uno::Reference
< com::sun::star::script::browse::XBrowseNode
> node2
);
107 static BOOL
dialogSort2( com::sun::star::uno::Reference
< com::sun::star::script::browse::XBrowseNode
> node1
,
108 com::sun::star::uno::Reference
< com::sun::star::script::browse::XBrowseNode
> node2
);
111 void Init( const ::rtl::OUString
& language
);
112 void RequestSubEntries( SvLBoxEntry
* pRootEntry
, ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>& node
,
113 ::com::sun::star::uno::Reference
< com::sun::star::frame::XModel
>& model
);
114 SFTreeListBox( Window
* pParent
, const ResId
& rRes
);
117 void UpdateEntries();
119 void ExpandAllTrees();
123 SvLBoxEntry
* insertEntry(String
const & rText
, USHORT nBitmap
,
124 SvLBoxEntry
* pParent
,
125 bool bChildrenOnDemand
,
126 std::auto_ptr
< SFEntry
> aUserData
,
127 ::rtl::OUString factoryURL
);
128 SvLBoxEntry
* insertEntry(String
const & rText
, USHORT nBitmap
,
129 SvLBoxEntry
* pParent
,
130 bool bChildrenOnDemand
,
131 std::auto_ptr
< SFEntry
> aUserData
);
132 void deleteTree( SvLBoxEntry
* pEntry
);
133 void deleteAllTree( );
136 class InputDialog
: public ModalDialog
142 CancelButton aCancelButton
;
145 InputDialog( Window
* pParent
, USHORT nMode
);
148 String
GetObjectName() const { return aEdit
.GetText(); }
149 void SetObjectName( const String
& rName
) { aEdit
.SetText( rName
); aEdit
.SetSelection( Selection( 0, rName
.Len() ) );}
157 ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
> nodes
;
158 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> model
;
161 SFEntry( BYTE nT
) { nType
= nT
; loaded
=false; }
163 const ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>& entryNodes
,
164 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& entryModel
) { nType
= nT
; nodes
= entryNodes
; loaded
=false; model
= entryModel
; }
165 SFEntry( const SFEntry
& r
) { nType
= r
.nType
; nodes
= r
.nodes
; loaded
= r
.loaded
; }
166 virtual ~SFEntry() {}
167 ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
> GetNode() { return nodes
;}
168 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> GetModel() { return model
;};
169 BYTE
GetType() const { return nType
; }
170 bool isLoaded() const { return loaded
; }
171 void setLoaded() { loaded
=true; }
174 class SvxScriptOrgDialog
: public SfxModalDialog
177 FixedText aScriptsTxt
;
178 SFTreeListBox aScriptsBox
;
180 PushButton aRunButton
;
181 CancelButton aCloseButton
;
182 PushButton aCreateButton
;
183 PushButton aEditButton
;
184 PushButton aRenameButton
;
185 PushButton aDelButton
;
186 HelpButton aHelpButton
;
188 ::rtl::OUString m_sLanguage
;
189 static Selection_hash m_lastSelection
;
190 const String m_delErrStr
;
191 const String m_delErrTitleStr
;
192 const String m_delQueryStr
;
193 const String m_delQueryTitleStr
;
194 const String m_createErrStr
;
195 const String m_createDupStr
;
196 const String m_createErrTitleStr
;
197 const String m_renameErrStr
;
198 const String m_renameDupStr
;
199 const String m_renameErrTitleStr
;
201 DECL_LINK( MacroSelectHdl
, SvTreeListBox
* );
202 DECL_LINK( MacroDoubleClickHdl
, SvTreeListBox
* );
203 DECL_LINK( ScriptSelectHdl
, SvTreeListBox
* );
204 DECL_LINK( ButtonHdl
, Button
* );
205 BOOL
getBoolProperty( ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& xProps
, ::rtl::OUString
& propName
);
206 void CheckButtons( ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>& node
);
208 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getDocumentModel( ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xCtx
, ::rtl::OUString
& docName
);
210 void createEntry( SvLBoxEntry
* pEntry
);
211 void renameEntry( SvLBoxEntry
* pEntry
);
212 void deleteEntry( SvLBoxEntry
* pEntry
);
213 ::com::sun::star::uno::Reference
< ::com::sun::star::script::browse::XBrowseNode
>
214 getBrowseNode( SvLBoxEntry
* pEntry
);
215 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> getModel( SvLBoxEntry
* pEntry
);
216 void EnableButton( Button
& rButton
, BOOL bEnable
);
217 String
getListOfChildren( ::com::sun::star::uno::Reference
< com::sun::star::script::browse::XBrowseNode
> node
, int depth
);
218 void StoreCurrentSelection();
219 void RestorePreviousSelection();
220 //String GetInfo( SbxVariable* pVar );
223 // prob need another arg in the ctor
224 // to specify the language or provider
225 SvxScriptOrgDialog( Window
* pParent
, ::rtl::OUString language
);
226 ~SvxScriptOrgDialog();
228 virtual short Execute();
230 //DECL_LINK( ActivatePageHdl, TabControl * );
233 class SvxScriptErrorDialog
: public VclAbstractDialog
237 ::rtl::OUString m_sMessage
;
239 DECL_LINK( ShowDialog
, ::rtl::OUString
* );
243 SvxScriptErrorDialog(
244 Window
* parent
, ::com::sun::star::uno::Any aException
);
246 ~SvxScriptErrorDialog();
251 #endif // _SCRIPTDLG_HXX