Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / cui / source / inc / scriptdlg.hxx
blobbfbe49f59cc20ac83ae073750fbd7ab52b2bf6f1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef _SCRIPTDLG_HXX
21 #define _SCRIPTDLG_HXX
23 #include <memory>
25 #include "tools/solar.h"
27 #include <svtools/treelistbox.hxx>
28 #include <vcl/dialog.hxx>
29 #include <vcl/button.hxx>
30 #include <vcl/fixed.hxx>
31 #include <vcl/abstdlg.hxx>
32 #include <sfx2/basedlgs.hxx>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/script/browse/XBrowseNode.hpp>
36 #include <com/sun/star/frame/XModel.hpp>
38 #include <boost/unordered_map.hpp>
40 #define OBJTYPE_BASICMANAGER 1L
41 #define OBJTYPE_METHOD 2L
42 #define OBJTYPE_SCRIPTCONTAINER 3L
43 #define OBJTYPE_SFROOT 4L
45 #define INPUTMODE_NEWLIB 1
46 #define INPUTMODE_NEWMACRO 2
47 #define INPUTMODE_RENAME 3
49 typedef ::boost::unordered_map < ::rtl::OUString, ::rtl::OUString ,
50 ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > Selection_hash;
52 class SFEntry;
54 class SFTreeListBox : public SvTreeListBox
56 friend class SvxScriptOrgDialog;
57 private:
58 sal_uInt16 nMode;
59 Image m_hdImage;
60 Image m_libImage;
61 Image m_macImage;
62 Image m_docImage;
63 ::rtl::OUString m_sMyMacros;
64 ::rtl::OUString m_sProdMacros;
66 ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >
67 getLangNodeFromRootNode( ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& root, ::rtl::OUString& language );
68 void delUserData( SvTreeListEntry* pEntry );
70 ::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 );
72 protected:
73 void ExpandTree( SvTreeListEntry* pRootEntry );
74 virtual void RequestingChildren( SvTreeListEntry* pParent );
75 virtual void ExpandedHdl();
76 virtual long ExpandingHdl();
77 public:
78 void Init( const ::rtl::OUString& language );
79 void RequestSubEntries( SvTreeListEntry* pRootEntry, ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& node,
80 ::com::sun::star::uno::Reference< com::sun::star::frame::XModel>& model );
81 SFTreeListBox(Window* pParent);
82 ~SFTreeListBox();
84 void ExpandAllTrees();
88 SvTreeListEntry * insertEntry(String const & rText, sal_uInt16 nBitmap,
89 SvTreeListEntry * pParent,
90 bool bChildrenOnDemand,
91 std::auto_ptr< SFEntry > aUserData,
92 ::rtl::OUString factoryURL );
93 SvTreeListEntry * insertEntry(String const & rText, sal_uInt16 nBitmap,
94 SvTreeListEntry * pParent,
95 bool bChildrenOnDemand,
96 std::auto_ptr< SFEntry > aUserData );
97 void deleteTree( SvTreeListEntry * pEntry );
98 void deleteAllTree( );
101 class CuiInputDialog : public ModalDialog
103 private:
104 FixedText aText;
105 Edit aEdit;
106 OKButton aOKButton;
107 CancelButton aCancelButton;
109 public:
110 CuiInputDialog( Window * pParent, sal_uInt16 nMode );
111 ~CuiInputDialog();
113 String GetObjectName() const { return aEdit.GetText(); }
114 void SetObjectName( const String& rName ) { aEdit.SetText( rName ); aEdit.SetSelection( Selection( 0, rName.Len() ) );}
117 class SFEntry
119 private:
120 sal_uInt8 nType;
121 bool loaded;
122 ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > nodes;
123 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > model;
124 SFEntry(){}
125 public:
126 SFEntry( sal_uInt8 nT ) { nType = nT; loaded=false; }
127 SFEntry( sal_uInt8 nT,
128 const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& entryNodes ,
129 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& entryModel) { nType = nT; nodes = entryNodes; loaded=false; model = entryModel; }
130 SFEntry( const SFEntry& r ) { nType = r.nType; nodes = r.nodes; loaded = r.loaded; }
131 virtual ~SFEntry() {}
132 ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > GetNode() { return nodes ;}
133 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetModel() { return model ;};
134 sal_uInt8 GetType() const { return nType; }
135 bool isLoaded() const { return loaded; }
136 void setLoaded() { loaded=true; }
139 class SvxScriptOrgDialog : public SfxModalDialog
141 protected:
142 SFTreeListBox* m_pScriptsBox;
144 PushButton* m_pRunButton;
145 PushButton* m_pCloseButton;
146 PushButton* m_pCreateButton;
147 PushButton* m_pEditButton;
148 PushButton* m_pRenameButton;
149 PushButton* m_pDelButton;
151 ::rtl::OUString m_sLanguage;
152 static Selection_hash m_lastSelection;
153 const String m_delErrStr;
154 const String m_delErrTitleStr;
155 const String m_delQueryStr;
156 const String m_delQueryTitleStr;
157 const String m_createErrStr;
158 const String m_createDupStr;
159 const String m_createErrTitleStr;
160 const String m_renameErrStr;
161 const String m_renameDupStr;
162 const String m_renameErrTitleStr;
164 DECL_LINK( MacroSelectHdl, SvTreeListBox * );
165 DECL_LINK( ScriptSelectHdl, SvTreeListBox * );
166 DECL_LINK( ButtonHdl, Button * );
167 sal_Bool getBoolProperty( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xProps, ::rtl::OUString& propName );
168 void CheckButtons( ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& node );
171 void createEntry( SvTreeListEntry* pEntry );
172 void renameEntry( SvTreeListEntry* pEntry );
173 void deleteEntry( SvTreeListEntry* pEntry );
174 ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >
175 getBrowseNode( SvTreeListEntry* pEntry );
176 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > getModel( SvTreeListEntry* pEntry );
177 String getListOfChildren( ::com::sun::star::uno::Reference< com::sun::star::script::browse::XBrowseNode > node, int depth );
178 void StoreCurrentSelection();
179 void RestorePreviousSelection();
181 public:
182 // prob need another arg in the ctor
183 // to specify the language or provider
184 SvxScriptOrgDialog( Window* pParent, ::rtl::OUString language );
185 ~SvxScriptOrgDialog();
187 virtual short Execute();
191 class SvxScriptErrorDialog : public VclAbstractDialog
193 private:
195 ::rtl::OUString m_sMessage;
197 DECL_LINK( ShowDialog, ::rtl::OUString* );
199 public:
201 SvxScriptErrorDialog(
202 Window* parent, ::com::sun::star::uno::Any aException );
204 ~SvxScriptErrorDialog();
206 short Execute();
209 #endif // _SCRIPTDLG_HXX
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */