bump product version to 7.6.3.2-android
[LibreOffice.git] / cui / source / customize / eventdlg.cxx
blob755fd16b416a7f21a74cc0fccfa7e12d01211a7f
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 #include <comphelper/diagnose_ex.hxx>
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>
26 #include <comphelper/processfactory.hxx>
27 #include <comphelper/documentinfo.hxx>
28 #include <unotools/configmgr.hxx>
29 #include <rtl/ustring.hxx>
31 #include "eventdlg.hxx"
32 #include "macropg_impl.hxx"
34 #include <cfg.hxx>
36 using namespace ::com::sun::star;
39 SvxEventConfigPage::SvxEventConfigPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet,
40 SvxEventConfigPage::EarlyInit)
41 : SvxMacroTabPage_(pPage, pController, "cui/ui/eventsconfigpage.ui", "EventsConfigPage", rSet)
42 , m_xSaveInListBox(m_xBuilder->weld_combo_box("savein"))
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");
50 mpImpl->xEventLB->set_size_request(mpImpl->xEventLB->get_approximate_digit_width() * 70,
51 mpImpl->xEventLB->get_height_rows(20));
53 InitResources();
55 m_xSaveInListBox->connect_changed( LINK( this, SvxEventConfigPage,
56 SelectHdl_Impl ) );
58 uno::Reference< frame::XGlobalEventBroadcaster > xSupplier =
59 frame::theGlobalEventBroadcaster::get(::comphelper::getProcessComponentContext());
61 m_xAppEvents = xSupplier->getEvents();
62 m_xSaveInListBox->append(OUString::boolean(true), utl::ConfigManager::getProductName());
63 m_xSaveInListBox->set_active(0);
66 void SvxEventConfigPage::LateInit( const uno::Reference< frame::XFrame >& _rxFrame )
68 SetFrame( _rxFrame );
69 ImplInitDocument();
71 InitAndSetHandler( m_xAppEvents, m_xDocumentEvents, m_xDocumentModifiable );
73 SelectHdl_Impl( *m_xSaveInListBox );
76 SvxEventConfigPage::~SvxEventConfigPage()
80 void SvxEventConfigPage::ImplInitDocument()
82 uno::Reference< frame::XFrame > xFrame( GetFrame() );
83 OUString aModuleId = SvxConfigPage::GetFrameWithDefaultAndIdentify( xFrame );
84 if ( !xFrame.is() )
85 return;
87 try
89 uno::Reference< frame::XModel > xModel;
90 if ( !SvxConfigPage::CanConfig( aModuleId ) )
91 return;
93 uno::Reference< frame::XController > xController =
94 xFrame->getController();
96 if ( xController.is() )
98 xModel = xController->getModel();
101 if ( !xModel.is() )
102 return;
104 uno::Reference< document::XEventsSupplier > xSupplier( xModel, uno::UNO_QUERY );
106 if ( xSupplier.is() )
108 m_xDocumentEvents = xSupplier->getEvents();
109 m_xDocumentModifiable.set(xModel, css::uno::UNO_QUERY);
111 OUString aTitle = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
113 m_xSaveInListBox->append(OUString::boolean(false), aTitle);
114 m_xSaveInListBox->set_active(m_xSaveInListBox->get_count() - 1);
117 catch( const uno::Exception& )
119 DBG_UNHANDLED_EXCEPTION("cui.customize");
123 IMPL_LINK_NOARG( SvxEventConfigPage, SelectHdl_Impl, weld::ComboBox&, void )
125 bool bApp = m_xSaveInListBox->get_active_id().toBoolean();
127 if (bApp)
129 SetReadOnly( false );
130 SvxMacroTabPage_::DisplayAppEvents( true );
132 else
134 bool isReadonly = false;
136 uno::Reference< frame::XDesktop2 > xFramesSupplier = frame::Desktop::create(
137 ::comphelper::getProcessComponentContext() );
139 uno::Reference< frame::XFrame > xFrame =
140 xFramesSupplier->getActiveFrame();
142 if ( xFrame.is() )
144 uno::Reference< frame::XController > xController =
145 xFrame->getController();
147 if ( xController.is() )
149 uno::Reference< frame::XStorable > xStorable(
150 xController->getModel(), uno::UNO_QUERY );
151 isReadonly = xStorable->isReadonly();
155 SetReadOnly( isReadonly );
156 SvxMacroTabPage_::DisplayAppEvents( false );
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */