1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
24 #include <sfx2/basedlgs.hxx>
25 #include <vcl/abstdlg.hxx>
26 #include <vcl/weld.hxx>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/script/browse/XBrowseNode.hpp>
30 #include <com/sun/star/frame/XModel.hpp>
31 #include <com/sun/star/uno/XComponentContext.hpp>
33 #include <unordered_map>
35 #define OBJTYPE_METHOD 2L
36 #define OBJTYPE_SCRIPTCONTAINER 3L
37 #define OBJTYPE_SFROOT 4L
39 typedef std::unordered_map
< OUString
, OUString
> Selection_hash
;
43 enum class InputDialogMode
{
49 class CuiInputDialog
: public weld::GenericDialogController
52 std::unique_ptr
<weld::Entry
> m_xEdit
;
54 CuiInputDialog(weld::Window
* pParent
, InputDialogMode nMode
);
55 OUString
GetObjectName() const { return m_xEdit
->get_text(); }
56 void SetObjectName(const OUString
& rName
)
58 m_xEdit
->set_text(rName
);
59 m_xEdit
->select_region(0, -1);
67 css::uno::Reference
< css::script::browse::XBrowseNode
> nodes
;
68 css::uno::Reference
< css::frame::XModel
> model
;
70 SFEntry( const css::uno::Reference
< css::script::browse::XBrowseNode
>& entryNodes
,
71 const css::uno::Reference
< css::frame::XModel
>& entryModel
) { nodes
= entryNodes
; loaded
=false; model
= entryModel
; }
72 SFEntry( const SFEntry
& r
) { nodes
= r
.nodes
; loaded
= r
.loaded
; }
73 const css::uno::Reference
< css::script::browse::XBrowseNode
>& GetNode() const { return nodes
;}
74 const css::uno::Reference
< css::frame::XModel
>& GetModel() const { return model
;};
75 bool isLoaded() const { return loaded
; }
76 void setLoaded() { loaded
=true; }
79 class SvxScriptOrgDialog
: public SfxDialogController
83 static Selection_hash m_lastSelection
;
84 const OUString m_delErrStr
;
85 const OUString m_delErrTitleStr
;
86 const OUString m_delQueryStr
;
87 const OUString m_delQueryTitleStr
;
88 const OUString m_createErrStr
;
89 const OUString m_createDupStr
;
90 const OUString m_createErrTitleStr
;
91 const OUString m_renameErrStr
;
92 const OUString m_renameErrTitleStr
;
93 const OUString m_sMyMacros
;
94 const OUString m_sProdMacros
;
96 std::unique_ptr
<weld::TreeView
> m_xScriptsBox
;
97 std::unique_ptr
<weld::Button
> m_xRunButton
;
98 std::unique_ptr
<weld::Button
> m_xCloseButton
;
99 std::unique_ptr
<weld::Button
> m_xCreateButton
;
100 std::unique_ptr
<weld::Button
> m_xEditButton
;
101 std::unique_ptr
<weld::Button
> m_xRenameButton
;
102 std::unique_ptr
<weld::Button
> m_xDelButton
;
104 DECL_LINK( ScriptSelectHdl
, weld::TreeView
&, void );
105 DECL_LINK( ExpandingHdl
, const weld::TreeIter
&, bool );
106 DECL_LINK( ButtonHdl
, weld::Button
&, void );
107 static bool getBoolProperty( css::uno::Reference
< css::beans::XPropertySet
> const & xProps
, OUString
const & propName
);
108 void CheckButtons( css::uno::Reference
< css::script::browse::XBrowseNode
> const & node
);
110 void createEntry(weld::TreeIter
& rEntry
);
111 void renameEntry(const weld::TreeIter
& rEntry
);
112 void deleteEntry(weld::TreeIter
& rEntry
);
113 css::uno::Reference
<css::script::browse::XBrowseNode
> getBrowseNode(const weld::TreeIter
& rEntry
);
114 css::uno::Reference
<css::frame::XModel
> getModel(const weld::TreeIter
& rEntry
);
115 OUString
getListOfChildren( const css::uno::Reference
< css::script::browse::XBrowseNode
>& node
, int depth
);
116 void StoreCurrentSelection();
117 void RestorePreviousSelection();
119 void Init(const OUString
& language
);
120 void delUserData(const weld::TreeIter
& rIter
);
121 void deleteTree(weld::TreeIter
& rIter
);
122 void deleteAllTree();
123 void insertEntry(OUString
const & rText
, OUString
const & rBitmap
,
124 const weld::TreeIter
* pParent
,
125 bool bChildrenOnDemand
,
126 std::unique_ptr
< SFEntry
> && aUserData
,
127 const OUString
& factoryURL
, bool bSelect
);
128 void insertEntry(OUString
const & rText
, OUString
const & rBitmap
,
129 const weld::TreeIter
* pParent
,
130 bool bChildrenOnDemand
,
131 std::unique_ptr
< SFEntry
> && aUserData
,
134 void RequestSubEntries(const weld::TreeIter
& rRootEntry
,
135 css::uno::Reference
< css::script::browse::XBrowseNode
> const & node
,
136 css::uno::Reference
< css::frame::XModel
>& model
);
138 static css::uno::Reference
< css::script::browse::XBrowseNode
>
139 getLangNodeFromRootNode( css::uno::Reference
< css::script::browse::XBrowseNode
> const & root
, OUString
const & language
);
141 static css::uno::Reference
< css::uno::XInterface
> getDocumentModel( css::uno::Reference
< css::uno::XComponentContext
> const & xCtx
, OUString
const & docName
);
144 // prob need another arg in the ctor
145 // to specify the language or provider
146 SvxScriptOrgDialog(weld::Window
* pParent
, const OUString
& language
);
147 virtual ~SvxScriptOrgDialog() override
;
149 virtual short run() override
;
152 class SvxScriptErrorDialog
: public VclAbstractDialog
158 DECL_STATIC_LINK( SvxScriptErrorDialog
, ShowDialog
, void*, void );
162 SvxScriptErrorDialog( css::uno::Any
const & aException
);
164 virtual ~SvxScriptErrorDialog() override
;
166 short Execute() override
;
169 #endif // INCLUDED_CUI_SOURCE_INC_SCRIPTDLG_HXX
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */