1*c4eee24dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*c4eee24dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*c4eee24dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*c4eee24dSAndrew Rist * distributed with this work for additional information 6*c4eee24dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*c4eee24dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*c4eee24dSAndrew Rist * "License"); you may not use this file except in compliance 9*c4eee24dSAndrew Rist * with the License. You may obtain a copy of the License at 10*c4eee24dSAndrew Rist * 11*c4eee24dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*c4eee24dSAndrew Rist * 13*c4eee24dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*c4eee24dSAndrew Rist * software distributed under the License is distributed on an 15*c4eee24dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*c4eee24dSAndrew Rist * KIND, either express or implied. See the License for the 17*c4eee24dSAndrew Rist * specific language governing permissions and limitations 18*c4eee24dSAndrew Rist * under the License. 19*c4eee24dSAndrew Rist * 20*c4eee24dSAndrew Rist *************************************************************/ 21*c4eee24dSAndrew Rist 22*c4eee24dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SCRIPTDLG_HXX 25cdf0e10cSrcweir #define _SCRIPTDLG_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <memory> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "tools/solar.h" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <svtools/svtreebx.hxx> 32cdf0e10cSrcweir #include <vcl/dialog.hxx> 33cdf0e10cSrcweir #include <vcl/button.hxx> 34cdf0e10cSrcweir #include <vcl/fixed.hxx> 35cdf0e10cSrcweir #include <vcl/abstdlg.hxx> 36cdf0e10cSrcweir #include <sfx2/basedlgs.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 39cdf0e10cSrcweir #include <com/sun/star/script/browse/XBrowseNode.hpp> 40cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <hash_map> 43cdf0e10cSrcweir 44cdf0e10cSrcweir #define OBJTYPE_BASICMANAGER 1L 45cdf0e10cSrcweir //#define OBJTYPE_LIB 2L 46cdf0e10cSrcweir //#define OBJTYPE_MODULE 3L 47cdf0e10cSrcweir #define OBJTYPE_METHOD 2L 48cdf0e10cSrcweir //#define OBJTYPE_METHODINOBJ 5L 49cdf0e10cSrcweir //#define OBJTYPE_OBJECT 6L 50cdf0e10cSrcweir //#define OBJTYPE_SUBOBJ 7L 51cdf0e10cSrcweir //#define OBJTYPE_PROPERTY 8L 52cdf0e10cSrcweir #define OBJTYPE_SCRIPTCONTAINER 3L 53cdf0e10cSrcweir #define OBJTYPE_SFROOT 4L 54cdf0e10cSrcweir 55cdf0e10cSrcweir #define BROWSEMODE_MODULES 0x01 56cdf0e10cSrcweir #define BROWSEMODE_SUBS 0x02 57cdf0e10cSrcweir #define BROWSEMODE_OBJS 0x04 58cdf0e10cSrcweir #define BROWSEMODE_PROPS 0x08 59cdf0e10cSrcweir #define BROWSEMODE_SUBOBJS 0x10 60cdf0e10cSrcweir 61cdf0e10cSrcweir #define INPUTMODE_NEWLIB 1 62cdf0e10cSrcweir #define INPUTMODE_NEWMACRO 2 63cdf0e10cSrcweir #define INPUTMODE_RENAME 3 64cdf0e10cSrcweir 65cdf0e10cSrcweir typedef ::std::hash_map < ::rtl::OUString, ::rtl::OUString , 66cdf0e10cSrcweir ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > Selection_hash; 67cdf0e10cSrcweir 68cdf0e10cSrcweir class SFEntry; 69cdf0e10cSrcweir 70cdf0e10cSrcweir class SFTreeListBox : public SvTreeListBox 71cdf0e10cSrcweir { 72cdf0e10cSrcweir friend class SvxScriptOrgDialog; 73cdf0e10cSrcweir private: 74cdf0e10cSrcweir sal_uInt16 nMode; 75cdf0e10cSrcweir Image m_hdImage; 76cdf0e10cSrcweir Image m_hdImage_hc; 77cdf0e10cSrcweir Image m_libImage; 78cdf0e10cSrcweir Image m_libImage_hc; 79cdf0e10cSrcweir Image m_macImage; 80cdf0e10cSrcweir Image m_macImage_hc; 81cdf0e10cSrcweir Image m_docImage; 82cdf0e10cSrcweir Image m_docImage_hc; 83cdf0e10cSrcweir ::rtl::OUString m_sMyMacros; 84cdf0e10cSrcweir ::rtl::OUString m_sProdMacros; 85cdf0e10cSrcweir 86cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > 87cdf0e10cSrcweir getLangNodeFromRootNode( ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& root, ::rtl::OUString& language ); 88cdf0e10cSrcweir void delUserData( SvLBoxEntry* pEntry ); 89cdf0e10cSrcweir 90cdf0e10cSrcweir ::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 ); 91cdf0e10cSrcweir 92cdf0e10cSrcweir protected: 93cdf0e10cSrcweir void ExpandTree( SvLBoxEntry* pRootEntry ); 94cdf0e10cSrcweir virtual void RequestingChilds( SvLBoxEntry* pParent ); 95cdf0e10cSrcweir virtual void ExpandedHdl(); 96cdf0e10cSrcweir virtual long ExpandingHdl(); 97cdf0e10cSrcweir public: 98cdf0e10cSrcweir void Init( const ::rtl::OUString& language ); 99cdf0e10cSrcweir void RequestSubEntries( SvLBoxEntry* pRootEntry, ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& node, 100cdf0e10cSrcweir ::com::sun::star::uno::Reference< com::sun::star::frame::XModel>& model ); 101cdf0e10cSrcweir SFTreeListBox( Window* pParent, const ResId& rRes ); 102cdf0e10cSrcweir ~SFTreeListBox(); 103cdf0e10cSrcweir 104cdf0e10cSrcweir void ExpandAllTrees(); 105cdf0e10cSrcweir 106cdf0e10cSrcweir 107cdf0e10cSrcweir 108cdf0e10cSrcweir SvLBoxEntry * insertEntry(String const & rText, sal_uInt16 nBitmap, 109cdf0e10cSrcweir SvLBoxEntry * pParent, 110cdf0e10cSrcweir bool bChildrenOnDemand, 111cdf0e10cSrcweir std::auto_ptr< SFEntry > aUserData, 112cdf0e10cSrcweir ::rtl::OUString factoryURL ); 113cdf0e10cSrcweir SvLBoxEntry * insertEntry(String const & rText, sal_uInt16 nBitmap, 114cdf0e10cSrcweir SvLBoxEntry * pParent, 115cdf0e10cSrcweir bool bChildrenOnDemand, 116cdf0e10cSrcweir std::auto_ptr< SFEntry > aUserData ); 117cdf0e10cSrcweir void deleteTree( SvLBoxEntry * pEntry ); 118cdf0e10cSrcweir void deleteAllTree( ); 119cdf0e10cSrcweir }; 120cdf0e10cSrcweir 121cdf0e10cSrcweir class InputDialog : public ModalDialog 122cdf0e10cSrcweir { 123cdf0e10cSrcweir private: 124cdf0e10cSrcweir FixedText aText; 125cdf0e10cSrcweir Edit aEdit; 126cdf0e10cSrcweir OKButton aOKButton; 127cdf0e10cSrcweir CancelButton aCancelButton; 128cdf0e10cSrcweir 129cdf0e10cSrcweir public: 130cdf0e10cSrcweir InputDialog( Window * pParent, sal_uInt16 nMode ); 131cdf0e10cSrcweir ~InputDialog(); 132cdf0e10cSrcweir GetObjectName() const133cdf0e10cSrcweir String GetObjectName() const { return aEdit.GetText(); } SetObjectName(const String & rName)134cdf0e10cSrcweir void SetObjectName( const String& rName ) { aEdit.SetText( rName ); aEdit.SetSelection( Selection( 0, rName.Len() ) );} 135cdf0e10cSrcweir }; 136cdf0e10cSrcweir 137cdf0e10cSrcweir class SFEntry 138cdf0e10cSrcweir { 139cdf0e10cSrcweir private: 140cdf0e10cSrcweir sal_uInt8 nType; 141cdf0e10cSrcweir bool loaded; 142cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > nodes; 143cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > model; SFEntry()144cdf0e10cSrcweir SFEntry(){} 145cdf0e10cSrcweir public: SFEntry(sal_uInt8 nT)146cdf0e10cSrcweir SFEntry( sal_uInt8 nT ) { nType = nT; loaded=false; } SFEntry(sal_uInt8 nT,const::com::sun::star::uno::Reference<::com::sun::star::script::browse::XBrowseNode> & entryNodes,const::com::sun::star::uno::Reference<::com::sun::star::frame::XModel> & entryModel)147cdf0e10cSrcweir SFEntry( sal_uInt8 nT, 148cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& entryNodes , 149cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& entryModel) { nType = nT; nodes = entryNodes; loaded=false; model = entryModel; } SFEntry(const SFEntry & r)150cdf0e10cSrcweir SFEntry( const SFEntry& r ) { nType = r.nType; nodes = r.nodes; loaded = r.loaded; } ~SFEntry()151cdf0e10cSrcweir virtual ~SFEntry() {} GetNode()152cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > GetNode() { return nodes ;} GetModel()153cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetModel() { return model ;}; GetType() const154cdf0e10cSrcweir sal_uInt8 GetType() const { return nType; } isLoaded() const155cdf0e10cSrcweir bool isLoaded() const { return loaded; } setLoaded()156cdf0e10cSrcweir void setLoaded() { loaded=true; } 157cdf0e10cSrcweir }; 158cdf0e10cSrcweir 159cdf0e10cSrcweir class SvxScriptOrgDialog : public SfxModalDialog 160cdf0e10cSrcweir { 161cdf0e10cSrcweir protected: 162cdf0e10cSrcweir FixedText aScriptsTxt; 163cdf0e10cSrcweir SFTreeListBox aScriptsBox; 164cdf0e10cSrcweir 165cdf0e10cSrcweir PushButton aRunButton; 166cdf0e10cSrcweir CancelButton aCloseButton; 167cdf0e10cSrcweir PushButton aCreateButton; 168cdf0e10cSrcweir PushButton aEditButton; 169cdf0e10cSrcweir PushButton aRenameButton; 170cdf0e10cSrcweir PushButton aDelButton; 171cdf0e10cSrcweir HelpButton aHelpButton; 172cdf0e10cSrcweir 173cdf0e10cSrcweir ::rtl::OUString m_sLanguage; 174cdf0e10cSrcweir static Selection_hash m_lastSelection; 175cdf0e10cSrcweir const String m_delErrStr; 176cdf0e10cSrcweir const String m_delErrTitleStr; 177cdf0e10cSrcweir const String m_delQueryStr; 178cdf0e10cSrcweir const String m_delQueryTitleStr; 179cdf0e10cSrcweir const String m_createErrStr; 180cdf0e10cSrcweir const String m_createDupStr; 181cdf0e10cSrcweir const String m_createErrTitleStr; 182cdf0e10cSrcweir const String m_renameErrStr; 183cdf0e10cSrcweir const String m_renameDupStr; 184cdf0e10cSrcweir const String m_renameErrTitleStr; 185cdf0e10cSrcweir 186cdf0e10cSrcweir DECL_LINK( MacroSelectHdl, SvTreeListBox * ); 187cdf0e10cSrcweir DECL_LINK( MacroDoubleClickHdl, SvTreeListBox * ); 188cdf0e10cSrcweir DECL_LINK( ScriptSelectHdl, SvTreeListBox * ); 189cdf0e10cSrcweir DECL_LINK( ButtonHdl, Button * ); 190cdf0e10cSrcweir sal_Bool getBoolProperty( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xProps, ::rtl::OUString& propName ); 191cdf0e10cSrcweir void CheckButtons( ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& node ); 192cdf0e10cSrcweir 193cdf0e10cSrcweir void createEntry( SvLBoxEntry* pEntry ); 194cdf0e10cSrcweir void renameEntry( SvLBoxEntry* pEntry ); 195cdf0e10cSrcweir void deleteEntry( SvLBoxEntry* pEntry ); 196cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > 197cdf0e10cSrcweir getBrowseNode( SvLBoxEntry* pEntry ); 198cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > getModel( SvLBoxEntry* pEntry ); 199cdf0e10cSrcweir String getListOfChildren( ::com::sun::star::uno::Reference< com::sun::star::script::browse::XBrowseNode > node, int depth ); 200cdf0e10cSrcweir void StoreCurrentSelection(); 201cdf0e10cSrcweir void RestorePreviousSelection(); 202cdf0e10cSrcweir //String GetInfo( SbxVariable* pVar ); 203cdf0e10cSrcweir 204cdf0e10cSrcweir public: 205cdf0e10cSrcweir // prob need another arg in the ctor 206cdf0e10cSrcweir // to specify the language or provider 207cdf0e10cSrcweir SvxScriptOrgDialog( Window* pParent, ::rtl::OUString language ); 208cdf0e10cSrcweir ~SvxScriptOrgDialog(); 209cdf0e10cSrcweir 210cdf0e10cSrcweir virtual short Execute(); 211cdf0e10cSrcweir 212cdf0e10cSrcweir //DECL_LINK( ActivatePageHdl, TabControl * ); 213cdf0e10cSrcweir }; 214cdf0e10cSrcweir 215cdf0e10cSrcweir class SvxScriptErrorDialog : public VclAbstractDialog 216cdf0e10cSrcweir { 217cdf0e10cSrcweir private: 218cdf0e10cSrcweir 219cdf0e10cSrcweir ::rtl::OUString m_sMessage; 220cdf0e10cSrcweir 221cdf0e10cSrcweir DECL_LINK( ShowDialog, ::rtl::OUString* ); 222cdf0e10cSrcweir 223cdf0e10cSrcweir public: 224cdf0e10cSrcweir 225cdf0e10cSrcweir SvxScriptErrorDialog( 226cdf0e10cSrcweir Window* parent, ::com::sun::star::uno::Any aException ); 227cdf0e10cSrcweir 228cdf0e10cSrcweir ~SvxScriptErrorDialog(); 229cdf0e10cSrcweir 230cdf0e10cSrcweir short Execute(); 231cdf0e10cSrcweir }; 232cdf0e10cSrcweir 233cdf0e10cSrcweir #endif // _SCRIPTDLG_HXX 234