xref: /trunk/main/cui/source/inc/scriptdlg.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _SCRIPTDLG_HXX
29*cdf0e10cSrcweir #define _SCRIPTDLG_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <memory>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "tools/solar.h"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
36*cdf0e10cSrcweir #include <vcl/dialog.hxx>
37*cdf0e10cSrcweir #include <vcl/button.hxx>
38*cdf0e10cSrcweir #include <vcl/fixed.hxx>
39*cdf0e10cSrcweir #include <vcl/abstdlg.hxx>
40*cdf0e10cSrcweir #include <sfx2/basedlgs.hxx>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/script/browse/XBrowseNode.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include <hash_map>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #define OBJTYPE_BASICMANAGER    1L
49*cdf0e10cSrcweir //#define OBJTYPE_LIB               2L
50*cdf0e10cSrcweir //#define OBJTYPE_MODULE            3L
51*cdf0e10cSrcweir #define OBJTYPE_METHOD          2L
52*cdf0e10cSrcweir //#define OBJTYPE_METHODINOBJ       5L
53*cdf0e10cSrcweir //#define OBJTYPE_OBJECT            6L
54*cdf0e10cSrcweir //#define OBJTYPE_SUBOBJ            7L
55*cdf0e10cSrcweir //#define OBJTYPE_PROPERTY      8L
56*cdf0e10cSrcweir #define OBJTYPE_SCRIPTCONTAINER     3L
57*cdf0e10cSrcweir #define OBJTYPE_SFROOT      4L
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir #define BROWSEMODE_MODULES      0x01
60*cdf0e10cSrcweir #define BROWSEMODE_SUBS         0x02
61*cdf0e10cSrcweir #define BROWSEMODE_OBJS         0x04
62*cdf0e10cSrcweir #define BROWSEMODE_PROPS        0x08
63*cdf0e10cSrcweir #define BROWSEMODE_SUBOBJS      0x10
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir #define INPUTMODE_NEWLIB        1
66*cdf0e10cSrcweir #define INPUTMODE_NEWMACRO      2
67*cdf0e10cSrcweir #define INPUTMODE_RENAME        3
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir typedef ::std::hash_map < ::rtl::OUString, ::rtl::OUString ,
70*cdf0e10cSrcweir     ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > Selection_hash;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir class SFEntry;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir class SFTreeListBox : public SvTreeListBox
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir    friend class SvxScriptOrgDialog;
77*cdf0e10cSrcweir private:
78*cdf0e10cSrcweir     sal_uInt16          nMode;
79*cdf0e10cSrcweir     Image m_hdImage;
80*cdf0e10cSrcweir     Image m_hdImage_hc;
81*cdf0e10cSrcweir     Image m_libImage;
82*cdf0e10cSrcweir     Image m_libImage_hc;
83*cdf0e10cSrcweir     Image m_macImage;
84*cdf0e10cSrcweir     Image m_macImage_hc;
85*cdf0e10cSrcweir     Image m_docImage;
86*cdf0e10cSrcweir     Image m_docImage_hc;
87*cdf0e10cSrcweir     ::rtl::OUString m_sMyMacros;
88*cdf0e10cSrcweir     ::rtl::OUString m_sProdMacros;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >
91*cdf0e10cSrcweir         getLangNodeFromRootNode( ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& root, ::rtl::OUString& language );
92*cdf0e10cSrcweir     void delUserData( SvLBoxEntry* pEntry );
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     ::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 );
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir protected:
97*cdf0e10cSrcweir     void                    ExpandTree( SvLBoxEntry* pRootEntry );
98*cdf0e10cSrcweir     virtual void            RequestingChilds( SvLBoxEntry* pParent );
99*cdf0e10cSrcweir     virtual void            ExpandedHdl();
100*cdf0e10cSrcweir     virtual long            ExpandingHdl();
101*cdf0e10cSrcweir public:
102*cdf0e10cSrcweir     void                    Init( const ::rtl::OUString& language );
103*cdf0e10cSrcweir     void  RequestSubEntries(  SvLBoxEntry* pRootEntry, ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& node,
104*cdf0e10cSrcweir                               ::com::sun::star::uno::Reference< com::sun::star::frame::XModel>& model  );
105*cdf0e10cSrcweir                     SFTreeListBox( Window* pParent, const ResId& rRes );
106*cdf0e10cSrcweir                     ~SFTreeListBox();
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     void            ExpandAllTrees();
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     SvLBoxEntry * insertEntry(String const & rText, sal_uInt16 nBitmap,
113*cdf0e10cSrcweir                               SvLBoxEntry * pParent,
114*cdf0e10cSrcweir                               bool bChildrenOnDemand,
115*cdf0e10cSrcweir                               std::auto_ptr< SFEntry > aUserData,
116*cdf0e10cSrcweir                               ::rtl::OUString factoryURL );
117*cdf0e10cSrcweir     SvLBoxEntry * insertEntry(String const & rText, sal_uInt16 nBitmap,
118*cdf0e10cSrcweir                               SvLBoxEntry * pParent,
119*cdf0e10cSrcweir                               bool bChildrenOnDemand,
120*cdf0e10cSrcweir                               std::auto_ptr< SFEntry > aUserData );
121*cdf0e10cSrcweir     void deleteTree( SvLBoxEntry * pEntry );
122*cdf0e10cSrcweir     void deleteAllTree( );
123*cdf0e10cSrcweir };
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir class InputDialog : public ModalDialog
126*cdf0e10cSrcweir {
127*cdf0e10cSrcweir private:
128*cdf0e10cSrcweir     FixedText       aText;
129*cdf0e10cSrcweir     Edit            aEdit;
130*cdf0e10cSrcweir     OKButton        aOKButton;
131*cdf0e10cSrcweir     CancelButton    aCancelButton;
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir public:
134*cdf0e10cSrcweir     InputDialog( Window * pParent, sal_uInt16 nMode );
135*cdf0e10cSrcweir                 ~InputDialog();
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     String      GetObjectName() const { return aEdit.GetText(); }
138*cdf0e10cSrcweir     void        SetObjectName( const String& rName ) { aEdit.SetText( rName ); aEdit.SetSelection( Selection( 0, rName.Len() ) );}
139*cdf0e10cSrcweir };
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir class SFEntry
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir private:
144*cdf0e10cSrcweir     sal_uInt8           nType;
145*cdf0e10cSrcweir     bool            loaded;
146*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > nodes;
147*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > model;
148*cdf0e10cSrcweir     SFEntry(){}
149*cdf0e10cSrcweir public:
150*cdf0e10cSrcweir                     SFEntry( sal_uInt8 nT )             { nType = nT; loaded=false; }
151*cdf0e10cSrcweir                     SFEntry( sal_uInt8 nT,
152*cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& entryNodes ,
153*cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& entryModel) { nType = nT; nodes = entryNodes; loaded=false; model = entryModel; }
154*cdf0e10cSrcweir                     SFEntry( const SFEntry& r ) { nType = r.nType; nodes = r.nodes; loaded = r.loaded; }
155*cdf0e10cSrcweir     virtual         ~SFEntry() {}
156*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > GetNode() { return nodes ;}
157*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetModel() { return model ;};
158*cdf0e10cSrcweir     sal_uInt8           GetType() const                     { return nType; }
159*cdf0e10cSrcweir     bool            isLoaded() const                    { return loaded; }
160*cdf0e10cSrcweir     void            setLoaded()                         { loaded=true; }
161*cdf0e10cSrcweir };
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir class SvxScriptOrgDialog : public SfxModalDialog
164*cdf0e10cSrcweir {
165*cdf0e10cSrcweir protected:
166*cdf0e10cSrcweir     FixedText               aScriptsTxt;
167*cdf0e10cSrcweir     SFTreeListBox           aScriptsBox;
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     PushButton              aRunButton;
170*cdf0e10cSrcweir     CancelButton            aCloseButton;
171*cdf0e10cSrcweir     PushButton              aCreateButton;
172*cdf0e10cSrcweir     PushButton              aEditButton;
173*cdf0e10cSrcweir     PushButton              aRenameButton;
174*cdf0e10cSrcweir     PushButton              aDelButton;
175*cdf0e10cSrcweir     HelpButton              aHelpButton;
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir     ::rtl::OUString         m_sLanguage;
178*cdf0e10cSrcweir     static Selection_hash   m_lastSelection;
179*cdf0e10cSrcweir     const String m_delErrStr;
180*cdf0e10cSrcweir     const String m_delErrTitleStr;
181*cdf0e10cSrcweir     const String m_delQueryStr;
182*cdf0e10cSrcweir     const String m_delQueryTitleStr;
183*cdf0e10cSrcweir     const String m_createErrStr;
184*cdf0e10cSrcweir     const String m_createDupStr;
185*cdf0e10cSrcweir     const String m_createErrTitleStr;
186*cdf0e10cSrcweir     const String m_renameErrStr;
187*cdf0e10cSrcweir     const String m_renameDupStr;
188*cdf0e10cSrcweir     const String m_renameErrTitleStr;
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     DECL_LINK( MacroSelectHdl, SvTreeListBox * );
191*cdf0e10cSrcweir     DECL_LINK( MacroDoubleClickHdl, SvTreeListBox * );
192*cdf0e10cSrcweir     DECL_LINK( ScriptSelectHdl, SvTreeListBox * );
193*cdf0e10cSrcweir     DECL_LINK( ButtonHdl, Button * );
194*cdf0e10cSrcweir     sal_Bool                getBoolProperty( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xProps, ::rtl::OUString& propName );
195*cdf0e10cSrcweir     void                CheckButtons(  ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& node );
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir     void        createEntry( SvLBoxEntry* pEntry );
198*cdf0e10cSrcweir     void        renameEntry( SvLBoxEntry* pEntry );
199*cdf0e10cSrcweir     void        deleteEntry( SvLBoxEntry* pEntry );
200*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >
201*cdf0e10cSrcweir                 getBrowseNode( SvLBoxEntry* pEntry );
202*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > getModel( SvLBoxEntry* pEntry );
203*cdf0e10cSrcweir     String      getListOfChildren( ::com::sun::star::uno::Reference< com::sun::star::script::browse::XBrowseNode > node, int depth );
204*cdf0e10cSrcweir     void        StoreCurrentSelection();
205*cdf0e10cSrcweir     void        RestorePreviousSelection();
206*cdf0e10cSrcweir     //String                GetInfo( SbxVariable* pVar );
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir public:
209*cdf0e10cSrcweir                     // prob need another arg in the ctor
210*cdf0e10cSrcweir                     // to specify the language or provider
211*cdf0e10cSrcweir                     SvxScriptOrgDialog( Window* pParent, ::rtl::OUString language );
212*cdf0e10cSrcweir                     ~SvxScriptOrgDialog();
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     virtual short   Execute();
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir     //DECL_LINK( ActivatePageHdl, TabControl * );
217*cdf0e10cSrcweir };
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir class SvxScriptErrorDialog : public VclAbstractDialog
220*cdf0e10cSrcweir {
221*cdf0e10cSrcweir private:
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir     ::rtl::OUString m_sMessage;
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir     DECL_LINK( ShowDialog, ::rtl::OUString* );
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir public:
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     SvxScriptErrorDialog(
230*cdf0e10cSrcweir         Window* parent, ::com::sun::star::uno::Any aException );
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     ~SvxScriptErrorDialog();
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir     short           Execute();
235*cdf0e10cSrcweir };
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir #endif // _SCRIPTDLG_HXX
238