Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_CUI_SOURCE_INC_SCRIPTDLG_HXX
21 : #define INCLUDED_CUI_SOURCE_INC_SCRIPTDLG_HXX
22 :
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>
30 :
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>
34 :
35 : #include <unordered_map>
36 :
37 : #define OBJTYPE_METHOD 2L
38 : #define OBJTYPE_SCRIPTCONTAINER 3L
39 : #define OBJTYPE_SFROOT 4L
40 :
41 : #define INPUTMODE_NEWLIB 1
42 : #define INPUTMODE_NEWMACRO 2
43 : #define INPUTMODE_RENAME 3
44 :
45 : typedef std::unordered_map < OUString, OUString,
46 : OUStringHash, std::equal_to< OUString > > Selection_hash;
47 :
48 : class SFEntry;
49 :
50 : class SFTreeListBox : public SvTreeListBox
51 : {
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;
61 :
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 );
65 :
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 );
67 :
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;
81 :
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( );
93 : };
94 :
95 : class CuiInputDialog : public ModalDialog
96 : {
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;
103 :
104 0 : OUString GetObjectName() const { return m_pEdit->GetText(); }
105 0 : void SetObjectName(const OUString& rName)
106 : {
107 0 : m_pEdit->SetText( rName );
108 0 : m_pEdit->SetSelection( Selection( 0, rName.getLength() ) );
109 0 : }
110 : };
111 :
112 : class SFEntry
113 : {
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 0 : SFEntry( sal_uInt8 nT,
123 : const ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode >& entryNodes ,
124 0 : 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 0 : virtual ~SFEntry() {}
127 0 : ::com::sun::star::uno::Reference< ::com::sun::star::script::browse::XBrowseNode > GetNode() { return nodes ;}
128 0 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetModel() { return model ;};
129 : sal_uInt8 GetType() const { return nType; }
130 0 : bool isLoaded() const { return loaded; }
131 0 : void setLoaded() { loaded=true; }
132 : };
133 :
134 : class SvxScriptOrgDialog : public SfxModalDialog
135 : {
136 : protected:
137 : VclPtr<SFTreeListBox> m_pScriptsBox;
138 :
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;
145 :
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;
158 :
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 );
164 :
165 :
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();
175 :
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;
182 :
183 : virtual short Execute() SAL_OVERRIDE;
184 :
185 : };
186 :
187 : class SvxScriptErrorDialog : public VclAbstractDialog
188 : {
189 : private:
190 :
191 : OUString m_sMessage;
192 :
193 : DECL_STATIC_LINK( SvxScriptErrorDialog, ShowDialog, OUString* );
194 :
195 : public:
196 :
197 : SvxScriptErrorDialog(
198 : vcl::Window* parent, ::com::sun::star::uno::Any aException );
199 :
200 : virtual ~SvxScriptErrorDialog();
201 :
202 : short Execute() SAL_OVERRIDE;
203 : };
204 :
205 : #endif // INCLUDED_CUI_SOURCE_INC_SCRIPTDLG_HXX
206 :
207 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|