LibreOffice Module cui (master) 1
eventdlg.cxx
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
21#include <com/sun/star/document/XEventsSupplier.hpp>
22#include <com/sun/star/frame/Desktop.hpp>
23#include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
24#include <com/sun/star/frame/XStorable.hpp>
25
29#include <rtl/ustring.hxx>
30
31#include "eventdlg.hxx"
32#include "macropg_impl.hxx"
33
34#include <cfg.hxx>
35
36using namespace ::com::sun::star;
37
38
41 : SvxMacroTabPage_(pPage, pController, "cui/ui/eventsconfigpage.ui", "EventsConfigPage", rSet)
42 , m_xSaveInListBox(m_xBuilder->weld_combo_box("savein"))
43{
44 mpImpl->xEventLB = m_xBuilder->weld_tree_view("events");
45 mpImpl->xAssignPB = m_xBuilder->weld_button("macro");
46 mpImpl->xDeletePB = m_xBuilder->weld_button("delete");
47 mpImpl->xDeleteAllPB = m_xBuilder->weld_button("deleteall");
48 mpImpl->xAssignComponentPB = m_xBuilder->weld_button("component");
49
50 mpImpl->xEventLB->set_size_request(mpImpl->xEventLB->get_approximate_digit_width() * 70,
51 mpImpl->xEventLB->get_height_rows(20));
52
54
55 m_xSaveInListBox->connect_changed( LINK( this, SvxEventConfigPage,
56 SelectHdl_Impl ) );
57
59 frame::theGlobalEventBroadcaster::get(::comphelper::getProcessComponentContext());
60
61 m_xAppEvents = xSupplier->getEvents();
62 m_xSaveInListBox->append(OUString::boolean(true), utl::ConfigManager::getProductName());
63 m_xSaveInListBox->set_active(0);
64}
65
67{
68 SetFrame( _rxFrame );
70
72
73 SelectHdl_Impl( *m_xSaveInListBox );
74}
75
77{
78}
79
81{
84 if ( !xFrame.is() )
85 return;
86
87 try
88 {
90 if ( !SvxConfigPage::CanConfig( aModuleId ) )
91 return;
92
94 xFrame->getController();
95
96 if ( xController.is() )
97 {
98 xModel = xController->getModel();
99 }
100
101 if ( !xModel.is() )
102 return;
103
104 uno::Reference< document::XEventsSupplier > xSupplier( xModel, uno::UNO_QUERY );
105
106 if ( xSupplier.is() )
107 {
108 m_xDocumentEvents = xSupplier->getEvents();
109 m_xDocumentModifiable.set(xModel, css::uno::UNO_QUERY);
110
111 OUString aTitle = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
112
113 m_xSaveInListBox->append(OUString::boolean(false), aTitle);
114 m_xSaveInListBox->set_active(m_xSaveInListBox->get_count() - 1);
115 }
116 }
117 catch( const uno::Exception& )
118 {
119 DBG_UNHANDLED_EXCEPTION("cui.customize");
120 }
121}
122
124{
125 bool bApp = m_xSaveInListBox->get_active_id().toBoolean();
126
127 if (bApp)
128 {
129 SetReadOnly( false );
131 }
132 else
133 {
134 bool isReadonly = false;
135
136 uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create(
137 ::comphelper::getProcessComponentContext() );
138
140 xFramesSupplier->getActiveFrame();
141
142 if ( xFrame.is() )
143 {
145 xFrame->getController();
146
147 if ( xController.is() )
148 {
150 xController->getModel(), uno::UNO_QUERY );
151 isReadonly = xStorable->isReadonly();
152 }
153 }
154
155 SetReadOnly( isReadonly );
157 }
158}
159
160/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::frame::XFrame > GetFrame() const
void SetFrame(const css::uno::Reference< css::frame::XFrame > &xFrame)
static bool CanConfig(std::u16string_view rModuleId)
Definition: cfg.cxx:165
static OUString GetFrameWithDefaultAndIdentify(css::uno::Reference< css::frame::XFrame > &_inout_rxFrame)
identifies the module in the given frame.
Definition: cfg.cxx:1277
css::uno::Reference< css::container::XNameReplace > m_xAppEvents
Definition: eventdlg.hxx:28
std::unique_ptr< weld::ComboBox > m_xSaveInListBox
Definition: eventdlg.hxx:32
void LateInit(const css::uno::Reference< css::frame::XFrame > &_rxFrame)
Definition: eventdlg.cxx:66
SvxEventConfigPage(const SvxEventConfigPage &)=delete
css::uno::Reference< css::util::XModifiable > m_xDocumentModifiable
Definition: eventdlg.hxx:30
void ImplInitDocument()
Definition: eventdlg.cxx:80
css::uno::Reference< css::container::XNameReplace > m_xDocumentEvents
Definition: eventdlg.hxx:29
virtual ~SvxEventConfigPage() override
Definition: eventdlg.cxx:76
void InitAndSetHandler(const css::uno::Reference< css::container::XNameReplace > &xAppEvents, const css::uno::Reference< css::container::XNameReplace > &xDocEvents, const css::uno::Reference< css::util::XModifiable > &xModifiable)
Definition: macropg.cxx:542
void DisplayAppEvents(bool appEvents)
Definition: macropg.cxx:304
std::unique_ptr< SvxMacroTabPage_Impl > mpImpl
Definition: macropg.hxx:65
void InitResources()
Definition: macropg.cxx:90
static OUString getProductName()
#define DBG_UNHANDLED_EXCEPTION(...)
IMPL_LINK_NOARG(SvxEventConfigPage, SelectHdl_Impl, weld::ComboBox &, void)
Definition: eventdlg.cxx:123
static SfxItemSet & rSet
this is only to let callers know that there is a LateInit which must be called
Definition: eventdlg.hxx:42
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel