bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / inc / scriptdlg.hxx
blob5abe86f4a2ea8b168f84ba1647c8fd7c1479f479
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 INCLUDED_CUI_SOURCE_INC_SCRIPTDLG_HXX
21 #define INCLUDED_CUI_SOURCE_INC_SCRIPTDLG_HXX
23 #include <memory>
24 #include <svtools/treelistbox.hxx>
25 #include <vcl/dialog.hxx>
26 #include <vcl/button.hxx>
27 #include <vcl/fixed.hxx>
28 #include <vcl/abstdlg.hxx>
29 #include <sfx2/basedlgs.hxx>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/script/browse/XBrowseNode.hpp>
33 #include <com/sun/star/frame/XModel.hpp>
35 #include <unordered_map>
37 #define OBJTYPE_METHOD 2L
38 #define OBJTYPE_SCRIPTCONTAINER 3L
39 #define OBJTYPE_SFROOT 4L
41 #define INPUTMODE_NEWLIB 1
42 #define INPUTMODE_NEWMACRO 2
43 #define INPUTMODE_RENAME 3
45 typedef std::unordered_map < OUString, OUString,
46 OUStringHash, std::equal_to< OUString > > Selection_hash;
48 class SFEntry;
50 class SFTreeListBox : public SvTreeListBox
52 friend class SvxScriptOrgDialog;
53 private:
54 sal_uInt16 nMode;
55 Image m_hdImage;
56 Image m_libImage;
57 Image m_macImage;
58 Image m_docImage;
59 OUString m_sMyMacros;
60 OUString m_sProdMacros;
62 static ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >
63 getLangNodeFromRootNode( ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& root, OUString& language );
64 static void delUserData( SvTreeListEntry* pEntry );
66 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getDocumentModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xCtx, OUString& docName );
68 protected:
69 void ExpandTree( SvTreeListEntry* pRootEntry );
70 virtual void RequestingChildren( SvTreeListEntry* pParent ) SAL_OVERRIDE;
71 virtual void ExpandedHdl() SAL_OVERRIDE;
72 virtual bool ExpandingHdl() SAL_OVERRIDE;
73 public:
74 void Init( const OUString& language );
75 void RequestSubEntries( SvTreeListEntry* pRootEntry,
76 ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& node,
77 ::com::sun::star::uno::Reference< com::sun::star::frame::XModel>& model );
78 SFTreeListBox(vcl::Window* pParent);
79 virtual ~SFTreeListBox();
80 virtual void dispose() SAL_OVERRIDE;
82 SvTreeListEntry * insertEntry(OUString const & rText, sal_uInt16 nBitmap,
83 SvTreeListEntry * pParent,
84 bool bChildrenOnDemand,
85 std::unique_ptr< SFEntry > && aUserData,
86 const OUString& factoryURL );
87 SvTreeListEntry * insertEntry(OUString const & rText, sal_uInt16 nBitmap,
88 SvTreeListEntry * pParent,
89 bool bChildrenOnDemand,
90 std::unique_ptr< SFEntry > && aUserData );
91 void deleteTree( SvTreeListEntry * pEntry );
92 void deleteAllTree( );
95 class CuiInputDialog : public ModalDialog
97 private:
98 VclPtr<Edit> m_pEdit;
99 public:
100 CuiInputDialog(vcl::Window * pParent, sal_uInt16 nMode);
101 virtual ~CuiInputDialog();
102 virtual void dispose() SAL_OVERRIDE;
104 OUString GetObjectName() const { return m_pEdit->GetText(); }
105 void SetObjectName(const OUString& rName)
107 m_pEdit->SetText( rName );
108 m_pEdit->SetSelection( Selection( 0, rName.getLength() ) );
112 class SFEntry
114 private:
115 sal_uInt8 nType;
116 bool loaded;
117 ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > nodes;
118 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > model;
119 SFEntry(){}
120 public:
121 SFEntry( sal_uInt8 nT ) { nType = nT; loaded=false; }
122 SFEntry( sal_uInt8 nT,
123 const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& entryNodes ,
124 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& entryModel) { nType = nT; nodes = entryNodes; loaded=false; model = entryModel; }
125 SFEntry( const SFEntry& r ) { nType = r.nType; nodes = r.nodes; loaded = r.loaded; }
126 virtual ~SFEntry() {}
127 ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > GetNode() { return nodes ;}
128 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetModel() { return model ;};
129 sal_uInt8 GetType() const { return nType; }
130 bool isLoaded() const { return loaded; }
131 void setLoaded() { loaded=true; }
134 class SvxScriptOrgDialog : public SfxModalDialog
136 protected:
137 VclPtr<SFTreeListBox> m_pScriptsBox;
139 VclPtr<PushButton> m_pRunButton;
140 VclPtr<CloseButton> m_pCloseButton;
141 VclPtr<PushButton> m_pCreateButton;
142 VclPtr<PushButton> m_pEditButton;
143 VclPtr<PushButton> m_pRenameButton;
144 VclPtr<PushButton> m_pDelButton;
146 OUString m_sLanguage;
147 static Selection_hash m_lastSelection;
148 const OUString m_delErrStr;
149 const OUString m_delErrTitleStr;
150 const OUString m_delQueryStr;
151 const OUString m_delQueryTitleStr;
152 const OUString m_createErrStr;
153 const OUString m_createDupStr;
154 const OUString m_createErrTitleStr;
155 const OUString m_renameErrStr;
156 const OUString m_renameDupStr;
157 const OUString m_renameErrTitleStr;
159 DECL_LINK( MacroSelectHdl, SvTreeListBox * );
160 DECL_LINK( ScriptSelectHdl, SvTreeListBox * );
161 DECL_LINK( ButtonHdl, Button * );
162 static bool getBoolProperty( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xProps, OUString& propName );
163 void CheckButtons( ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& node );
166 void createEntry( SvTreeListEntry* pEntry );
167 void renameEntry( SvTreeListEntry* pEntry );
168 void deleteEntry( SvTreeListEntry* pEntry );
169 static ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >
170 getBrowseNode( SvTreeListEntry* pEntry );
171 static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > getModel( SvTreeListEntry* pEntry );
172 OUString getListOfChildren( ::com::sun::star::uno::Reference< com::sun::star::script::browse::XBrowseNode > node, int depth );
173 void StoreCurrentSelection();
174 void RestorePreviousSelection();
176 public:
177 // prob need another arg in the ctor
178 // to specify the language or provider
179 SvxScriptOrgDialog( vcl::Window* pParent, const OUString& language );
180 virtual ~SvxScriptOrgDialog();
181 virtual void dispose() SAL_OVERRIDE;
183 virtual short Execute() SAL_OVERRIDE;
187 class SvxScriptErrorDialog : public VclAbstractDialog
189 private:
191 OUString m_sMessage;
193 DECL_STATIC_LINK( SvxScriptErrorDialog, ShowDialog, OUString* );
195 public:
197 SvxScriptErrorDialog(
198 vcl::Window* parent, ::com::sun::star::uno::Any aException );
200 virtual ~SvxScriptErrorDialog();
202 short Execute() SAL_OVERRIDE;
205 #endif // INCLUDED_CUI_SOURCE_INC_SCRIPTDLG_HXX
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */