/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
namespace pcr
{ using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Exception; using ::com::sun::star::inspection::XPropertyControlContext; using ::com::sun::star::uno::Reference; using ::com::sun::star::inspection::XPropertyControl; using ::com::sun::star::lang::DisposedException; using ::com::sun::star::lang::XComponent; using ::com::sun::star::uno::UNO_QUERY;
const ::rtl::Reference< ::comphelper::AsyncEventNotifier >& SharedNotifier::getNotifier()
{
::osl::MutexGuard aGuard( getMutex() ); if ( !s_pNotifier.is() )
{
s_pNotifier.set( new ::comphelper::AsyncEventNotifier("browserlistbox"));
s_pNotifier->launch(); //TODO: a protocol is missing how to join with the launched // thread before exit(3), to ensure the thread is no longer // relying on any infrastructure while that infrastructure is // being shut down in atexit handlers
} return s_pNotifier;
}
/** implementation for of <type scope="css::inspection">XPropertyControlContext</type> which forwards all events to a non-UNO version of this interface
*/ typedef ::cppu::WeakImplHelper< XPropertyControlContext > PropertyControlContext_Impl_Base; class PropertyControlContext_Impl :public PropertyControlContext_Impl_Base
,public ::comphelper::IEventProcessor
{ public: enum NotificationMode
{
eSynchronously,
eAsynchronously
};
public: /** creates an instance @param _rContextImpl the instance to delegate events to
*/ explicit PropertyControlContext_Impl( OBrowserListBox& _rContextImpl );
/** disposes the context.
When you call this method, all subsequent callbacks to the <type scope="css::inspection">XPropertyControlContext</type> methods will throw a <type scope="css::lang">DisposedException</type>.
*/ void dispose();
/** sets the notification mode, so that notifications received from the controls are forwarded to our OBrowserListBox either synchronously or asynchronously @param _eMode the new notification mode
*/ void setNotificationMode( NotificationMode _eMode );
private: /** processes the given event, i.e. notifies it to our OBrowserListBox @param _rEvent the event no notify @precond our mutex (well, the SolarMutex) is locked
*/ void impl_processEvent_throw( const ::comphelper::AnyEvent& _rEvent );
/** checks whether the instance is already disposed
*/ bool impl_isDisposed_nothrow() const { return m_pContext == nullptr; }
/** notifies the given event originating from the given control @throws DisposedException @param _rxControl @param _eType
*/ void impl_notify_throw( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType );
};
OBrowserListBox::~OBrowserListBox()
{
OSL_ENSURE( !IsModified(), "OBrowserListBox::~OBrowserListBox: still modified - should have been committed before!" );
// doing the commit here, while we, as well as our owner, as well as some other components, // are already "half dead" (means within their dtor) is potentially dangerous. // By definition, CommitModified has to be called (if necessary) before destruction
m_pControlContextImpl->dispose();
m_pControlContextImpl.clear();
void OBrowserListBox::InsertEntry(const OLineDescriptor& rPropertyData, sal_uInt16 _nPos)
{ // create a new line
BrowserLinePointer pBrowserLine = std::make_shared<OBrowserLine>(rPropertyData.sName, m_xLinesPlayground.get(),
m_xSizeGroup.get(), m_pInitialControlParent);
// check that the name is unique for (autoconst& line : m_aLines)
{ if (line.aName == rPropertyData.sName)
{ // already have another line for this name!
assert(false);
}
}
// initialize the entry
ChangeEntry(rPropertyData, nInsertPos);
m_nRowHeight = std::max(m_nRowHeight, pBrowserLine->GetRowHeight() + 6); // 6 is spacing of the "playground" in browserpage.ui
m_xScrolledWindow->vadjustment_set_step_increment(m_nRowHeight);
}
void OBrowserListBox::ShowEntry(sal_uInt16 nPos)
{ if (nPos == 0)
{ // special case the simple entry 0 situation
m_xScrolledWindow->vadjustment_set_value(0); return;
}
// cycle forwards, 'til we've the next control which can grab the focus
++nLine; while ( static_cast< size_t >( nLine ) < m_aLines.size() )
{ if ( m_aLines[nLine].pLine->GrabFocus() ) break;
++nLine;
}
void OBrowserListBox::Clear()
{ for (autoconst& line : m_aLines)
{ // hide the line
line.pLine->Hide(); // reset the listener
lcl_implDisposeControl_nothrow( line.pLine->getControl() );
}
if ( rPropertyData.bReadOnly )
{
rLine.pLine->SetReadOnly( true );
// user controls (i.e. the ones not provided by the usual // XPropertyControlFactory) have no chance to know that they should be read-only, // since XPropertyHandler::describePropertyLine does not transport this // information. // So, we manually switch this to read-only. if ( xControl.is() && ( xControl->getControlType() == PropertyControlType::Unknown ) )
{
weld::Widget* pWindow = rLine.pLine->getControlWindow();
weld::Entry* pControlWindowAsEdit = dynamic_cast<weld::Entry*>(pWindow); if (pControlWindowAsEdit)
pControlWindowAsEdit->set_editable(false); else
pWindow->set_sensitive(false);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.