LibreOffice Module cui (master) 1
scriptdlg.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <memory>
23#include <sfx2/basedlgs.hxx>
24#include <vcl/weld.hxx>
25
26#include <com/sun/star/beans/XPropertySet.hpp>
27#include <com/sun/star/script/browse/XBrowseNode.hpp>
28#include <com/sun/star/frame/XModel.hpp>
29#include <com/sun/star/uno/XComponentContext.hpp>
30
31#include <unordered_map>
32
33#define OBJTYPE_METHOD 2L
34#define OBJTYPE_SCRIPTCONTAINER 3L
35#define OBJTYPE_SFROOT 4L
36
37typedef std::unordered_map < OUString, OUString > Selection_hash;
38
39class SFEntry;
40
41enum class InputDialogMode {
42 NEWLIB = 1,
43 NEWMACRO = 2,
44 RENAME = 3,
45};
46
48{
49private:
50 std::unique_ptr<weld::Entry> m_xEdit;
51public:
53 OUString GetObjectName() const { return m_xEdit->get_text(); }
54 void SetObjectName(const OUString& rName)
55 {
56 m_xEdit->set_text(rName);
57 m_xEdit->select_region(0, -1);
58 }
59};
60
61class SFEntry final
62{
63private:
64 bool loaded;
65 css::uno::Reference< css::script::browse::XBrowseNode > nodes;
66 css::uno::Reference< css::frame::XModel > model;
67public:
68 SFEntry( const css::uno::Reference< css::script::browse::XBrowseNode >& entryNodes ,
69 const css::uno::Reference< css::frame::XModel >& entryModel) { nodes = entryNodes; loaded=false; model = entryModel; }
70 SFEntry( const SFEntry& r ) { nodes = r.nodes; loaded = r.loaded; }
71 const css::uno::Reference< css::script::browse::XBrowseNode >& GetNode() const { return nodes ;}
72 const css::uno::Reference< css::frame::XModel >& GetModel() const { return model ;};
73 bool isLoaded() const { return loaded; }
74 void setLoaded() { loaded=true; }
75};
76
78{
80 OUString m_sLanguage;
82 const OUString m_delErrStr;
83 const OUString m_delErrTitleStr;
84 const OUString m_delQueryStr;
85 const OUString m_delQueryTitleStr;
86 const OUString m_createErrStr;
87 const OUString m_createDupStr;
88 const OUString m_createErrTitleStr;
89 const OUString m_renameErrStr;
90 const OUString m_renameErrTitleStr;
91 const OUString m_sMyMacros;
92 const OUString m_sProdMacros;
93
94 std::unique_ptr<weld::TreeView> m_xScriptsBox;
95 std::unique_ptr<weld::TreeIter> m_xScratchIter;
96 std::unique_ptr<weld::Button> m_xRunButton;
97 std::unique_ptr<weld::Button> m_xCloseButton;
98 std::unique_ptr<weld::Button> m_xCreateButton;
99 std::unique_ptr<weld::Button> m_xEditButton;
100 std::unique_ptr<weld::Button> m_xRenameButton;
101 std::unique_ptr<weld::Button> m_xDelButton;
102
103 DECL_LINK( ScriptSelectHdl, weld::TreeView&, void );
104 DECL_LINK( ExpandingHdl, const weld::TreeIter&, bool );
105 DECL_LINK( ButtonHdl, weld::Button&, void );
106 static bool getBoolProperty( css::uno::Reference< css::beans::XPropertySet > const & xProps, OUString const & propName );
107 void CheckButtons( css::uno::Reference< css::script::browse::XBrowseNode > const & node );
108
109 void createEntry(const weld::TreeIter& rEntry);
110 void renameEntry(const weld::TreeIter& rEntry);
111 void deleteEntry(const weld::TreeIter& rEntry);
112 css::uno::Reference<css::script::browse::XBrowseNode> getBrowseNode(const weld::TreeIter& rEntry);
113 css::uno::Reference<css::frame::XModel> getModel(const weld::TreeIter& rEntry);
114 OUString getListOfChildren( const css::uno::Reference< css::script::browse::XBrowseNode >& node, int depth );
117
118 void Init(std::u16string_view language);
119 void delUserData(const weld::TreeIter& rIter);
120 void deleteTree(const weld::TreeIter& rIter);
121 void deleteAllTree();
122 void insertEntry(OUString const & rText, OUString const & rBitmap,
123 const weld::TreeIter* pParent,
124 bool bChildrenOnDemand,
125 std::unique_ptr< SFEntry > && aUserData,
126 std::u16string_view factoryURL, bool bSelect);
127 void insertEntry(OUString const & rText, OUString const & rBitmap,
128 const weld::TreeIter* pParent,
129 bool bChildrenOnDemand,
130 std::unique_ptr< SFEntry > && aUserData,
131 bool bSelect);
132
133 void RequestSubEntries(const weld::TreeIter& rRootEntry,
134 css::uno::Reference< css::script::browse::XBrowseNode > const & node,
135 css::uno::Reference< css::frame::XModel>& model);
136
137 static css::uno::Reference< css::script::browse::XBrowseNode >
138 getLangNodeFromRootNode( css::uno::Reference< css::script::browse::XBrowseNode > const & root, std::u16string_view language );
139
140 static css::uno::Reference< css::uno::XInterface > getDocumentModel( css::uno::Reference< css::uno::XComponentContext > const & xCtx, std::u16string_view docName );
141
142public:
143 // prob need another arg in the ctor
144 // to specify the language or provider
145 SvxScriptOrgDialog(weld::Window* pParent, OUString language);
146 virtual ~SvxScriptOrgDialog() override;
147
148 virtual short run() override;
149};
150
152{
153private:
154 struct DialogData {
156 OUString sMessage;
157 };
158
159 DECL_STATIC_LINK( SvxScriptErrorDialog, ShowDialog, void*, void );
160
161public:
162
163 static void ShowAsyncErrorDialog( weld::Window* pParent, css::uno::Any const & aException );
164};
165
166/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Entry > m_xEdit
Definition: scriptdlg.hxx:50
OUString GetObjectName() const
Definition: scriptdlg.hxx:53
CuiInputDialog(weld::Window *pParent, InputDialogMode nMode)
Definition: scriptdlg.cxx:341
void SetObjectName(const OUString &rName)
Definition: scriptdlg.hxx:54
css::uno::Reference< css::script::browse::XBrowseNode > nodes
Definition: scriptdlg.hxx:65
SFEntry(const css::uno::Reference< css::script::browse::XBrowseNode > &entryNodes, const css::uno::Reference< css::frame::XModel > &entryModel)
Definition: scriptdlg.hxx:68
const css::uno::Reference< css::script::browse::XBrowseNode > & GetNode() const
Definition: scriptdlg.hxx:71
void setLoaded()
Definition: scriptdlg.hxx:74
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: scriptdlg.hxx:72
css::uno::Reference< css::frame::XModel > model
Definition: scriptdlg.hxx:66
SFEntry(const SFEntry &r)
Definition: scriptdlg.hxx:70
bool loaded
Definition: scriptdlg.hxx:64
bool isLoaded() const
Definition: scriptdlg.hxx:73
DECL_STATIC_LINK(SvxScriptErrorDialog, ShowDialog, void *, void)
static void ShowAsyncErrorDialog(weld::Window *pParent, css::uno::Any const &aException)
Definition: scriptdlg.cxx:1297
void delUserData(const weld::TreeIter &rIter)
Definition: scriptdlg.cxx:65
void deleteTree(const weld::TreeIter &rIter)
Definition: scriptdlg.cxx:79
static css::uno::Reference< css::script::browse::XBrowseNode > getLangNodeFromRootNode(css::uno::Reference< css::script::browse::XBrowseNode > const &root, std::u16string_view language)
Definition: scriptdlg.cxx:230
const OUString m_delErrTitleStr
Definition: scriptdlg.hxx:83
css::uno::Reference< css::frame::XModel > getModel(const weld::TreeIter &rEntry)
Definition: scriptdlg.cxx:686
const OUString m_sMyMacros
Definition: scriptdlg.hxx:91
std::unique_ptr< weld::TreeIter > m_xScratchIter
Definition: scriptdlg.hxx:95
std::unique_ptr< weld::Button > m_xDelButton
Definition: scriptdlg.hxx:101
const OUString m_delQueryStr
Definition: scriptdlg.hxx:84
void insertEntry(OUString const &rText, OUString const &rBitmap, const weld::TreeIter *pParent, bool bChildrenOnDemand, std::unique_ptr< SFEntry > &&aUserData, std::u16string_view factoryURL, bool bSelect)
Definition: scriptdlg.cxx:295
virtual short run() override
Definition: scriptdlg.cxx:426
DECL_LINK(ExpandingHdl, const weld::TreeIter &, bool)
static css::uno::Reference< css::uno::XInterface > getDocumentModel(css::uno::Reference< css::uno::XComponentContext > const &xCtx, std::u16string_view docName)
Definition: scriptdlg.cxx:203
void deleteEntry(const weld::TreeIter &rEntry)
Definition: scriptdlg.cxx:925
std::unique_ptr< weld::Button > m_xRenameButton
Definition: scriptdlg.hxx:100
DECL_LINK(ScriptSelectHdl, weld::TreeView &, void)
std::unique_ptr< weld::TreeView > m_xScriptsBox
Definition: scriptdlg.hxx:94
SvxScriptOrgDialog(weld::Window *pParent, OUString language)
Definition: scriptdlg.cxx:369
const OUString m_createDupStr
Definition: scriptdlg.hxx:87
const OUString m_renameErrStr
Definition: scriptdlg.hxx:89
const OUString m_renameErrTitleStr
Definition: scriptdlg.hxx:90
void CheckButtons(css::uno::Reference< css::script::browse::XBrowseNode > const &node)
Definition: scriptdlg.cxx:445
virtual ~SvxScriptOrgDialog() override
Definition: scriptdlg.cxx:421
OUString getListOfChildren(const css::uno::Reference< css::script::browse::XBrowseNode > &node, int depth)
Definition: scriptdlg.cxx:987
void Init(std::u16string_view language)
Definition: scriptdlg.cxx:119
void renameEntry(const weld::TreeIter &rEntry)
Definition: scriptdlg.cxx:869
const OUString m_createErrTitleStr
Definition: scriptdlg.hxx:88
std::unique_ptr< weld::Button > m_xCloseButton
Definition: scriptdlg.hxx:97
const OUString m_delErrStr
Definition: scriptdlg.hxx:82
weld::Window * m_pParent
Definition: scriptdlg.hxx:79
void RequestSubEntries(const weld::TreeIter &rRootEntry, css::uno::Reference< css::script::browse::XBrowseNode > const &node, css::uno::Reference< css::frame::XModel > &model)
Definition: scriptdlg.cxx:263
std::unique_ptr< weld::Button > m_xEditButton
Definition: scriptdlg.hxx:99
const OUString m_createErrStr
Definition: scriptdlg.hxx:86
css::uno::Reference< css::script::browse::XBrowseNode > getBrowseNode(const weld::TreeIter &rEntry)
Definition: scriptdlg.cxx:675
static bool getBoolProperty(css::uno::Reference< css::beans::XPropertySet > const &xProps, OUString const &propName)
Definition: scriptdlg.cxx:972
OUString m_sLanguage
Definition: scriptdlg.hxx:80
const OUString m_sProdMacros
Definition: scriptdlg.hxx:92
const OUString m_delQueryTitleStr
Definition: scriptdlg.hxx:85
void StoreCurrentSelection()
Definition: scriptdlg.cxx:1018
std::unique_ptr< weld::Button > m_xCreateButton
Definition: scriptdlg.hxx:98
static Selection_hash m_lastSelection
Definition: scriptdlg.hxx:81
DECL_LINK(ButtonHdl, weld::Button &, void)
std::unique_ptr< weld::Button > m_xRunButton
Definition: scriptdlg.hxx:96
void createEntry(const weld::TreeIter &rEntry)
Definition: scriptdlg.cxx:697
void RestorePreviousSelection()
Definition: scriptdlg.cxx:1037
RENAME
std::unordered_map< OUString, OUString > Selection_hash
Definition: scriptdlg.hxx:37
InputDialogMode
Definition: scriptdlg.hxx:41