/* -*- 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 .
*/
// URLs should always be escaped if (IsFileViewWidget(pControl))
{ // the file view "overrides" the SetHelpId
m_pFileView->set_help_id(sHelpID);
} else
pControl->set_help_id(sHelpID);
}
OUString OControlAccess::getHelpURL(weld::Widget const * pControl) const
{
OUString aHelpId = pControl->get_help_id(); if (IsFileViewWidget(pControl))
{ // the file view "overrides" the SetHelpId
aHelpId = m_pFileView->get_help_id();
}
Any OControlAccess::getControlProperty( std::u16string_view rControlName, const OUString& rControlProperty )
{ // look up the control
sal_Int16 nControlId = -1;
PropFlags nPropertyMask = PropFlags::NONE;
weld::Widget* pControl = implGetControl( rControlName, &nControlId, &nPropertyMask ); // will throw an IllegalArgumentException if the name is not valid
// look up the property
ControlPropertyIterator aPropDesc = ::std::find_if( s_pProperties, s_pPropertiesEnd, ControlPropertyLookup( rControlProperty ) ); if ( aPropDesc == s_pPropertiesEnd ) // it's a completely unknown property throw IllegalArgumentException();
if ( !( nPropertyMask & aPropDesc->nPropertyId ) ) // it's a property which is known, but not allowed for this control throw IllegalArgumentException();
// translate the name into an id auto aFoundRange = ::std::equal_range( s_pControls, s_pControlsEnd, tmpDesc, ControlDescriptionLookup() ); if ( aFoundRange.first != aFoundRange.second )
{ // get the VCL control determined by this id
pControl = m_pFilePickerController->getControl( aFoundRange.first->nControlId );
}
// if not found 'til here, the name is invalid, or we do not have the control in the current mode if ( !pControl ) throw IllegalArgumentException();
// out parameters and outta here if ( _pId )
*_pId = aFoundRange.first->nControlId; if ( _pPropertyMask )
*_pPropertyMask = aFoundRange.first->nPropertyFlags;
return pControl;
}
void OControlAccess::setControlProperty( std::u16string_view rControlName, const OUString& rControlProperty, const css::uno::Any& rValue )
{ // look up the control
sal_Int16 nControlId = -1;
weld::Widget* pControl = implGetControl( rControlName, &nControlId ); // will throw an IllegalArgumentException if the name is not valid
// look up the property
ControlPropertyIterator aPropDesc = ::std::find_if( s_pProperties, s_pPropertiesEnd, ControlPropertyLookup( rControlProperty ) ); if ( aPropDesc == s_pPropertiesEnd ) throw IllegalArgumentException();
// set the property
implSetControlProperty( nControlId, pControl, aPropDesc->nPropertyId, rValue, false );
}
Sequence< OUString > OControlAccess::getSupportedControlProperties( std::u16string_view rControlName )
{
sal_Int16 nControlId = -1;
PropFlags nPropertyMask = PropFlags::NONE;
implGetControl( rControlName, &nControlId, &nPropertyMask ); // will throw an IllegalArgumentException if the name is not valid
// fill in the property names
Sequence< OUString > aProps( s_nPropertyCount );
OUString* pProperty = aProps.getArray();
bool OControlAccess::isControlPropertySupported( std::u16string_view rControlName, const OUString& rControlProperty )
{ // look up the control
sal_Int16 nControlId = -1;
PropFlags nPropertyMask = PropFlags::NONE;
implGetControl( rControlName, &nControlId, &nPropertyMask ); // will throw an IllegalArgumentException if the name is not valid
// look up the property
ControlPropertyIterator aPropDesc = ::std::find_if( s_pProperties, s_pPropertiesEnd, ControlPropertyLookup( rControlProperty ) ); if ( aPropDesc == s_pPropertiesEnd ) // it's a property which is completely unknown returnfalse;
void OControlAccess::setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const Any& rValue )
{
weld::Widget* pControl = m_pFilePickerController->getControl( nControlId );
DBG_ASSERT( pControl, "OControlAccess::SetValue: don't have this control in the current mode!" ); if ( !pControl ) return;
PropFlags nPropertyId = PropFlags::Unknown; if ( ControlActions::SET_HELP_URL == nControlAction )
{
nPropertyId = PropFlags::HelpUrl;
} else
{ switch ( nControlId )
{ case CHECKBOX_AUTOEXTENSION: case CHECKBOX_PASSWORD: case CHECKBOX_FILTEROPTIONS: case CHECKBOX_READONLY: case CHECKBOX_LINK: case CHECKBOX_PREVIEW: case CHECKBOX_SELECTION:
nPropertyId = PropFlags::Checked; break;
case LISTBOX_FILTER:
SAL_WARN( "fpicker.office", "Use the XFilterManager to access the filter listbox" ); break;
case LISTBOX_VERSION: case LISTBOX_TEMPLATE: case LISTBOX_IMAGE_TEMPLATE: case LISTBOX_IMAGE_ANCHOR: if ( ControlActions::SET_SELECT_ITEM == nControlAction )
{
nPropertyId = PropFlags::SelectedItemIndex;
} else
{
weld::ComboBox* pComboBox = dynamic_cast<weld::ComboBox*>(pControl);
assert(pComboBox && "OControlAccess::SetValue: implGetControl returned nonsense!");
implDoListboxAction(pComboBox, nControlAction, rValue);
} break;
}
}
Any OControlAccess::getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) const
{
Any aRet;
weld::Widget* pControl = m_pFilePickerController->getControl( nControlId );
DBG_ASSERT( pControl, "OControlAccess::GetValue: don't have this control in the current mode!" ); if ( pControl )
{
PropFlags nPropertyId = PropFlags::Unknown; if ( ControlActions::SET_HELP_URL == nControlAction )
{
nPropertyId = PropFlags::HelpUrl;
} else
{ switch ( nControlId )
{ case CHECKBOX_AUTOEXTENSION: case CHECKBOX_PASSWORD: case CHECKBOX_GPGENCRYPTION: case CHECKBOX_GPGSIGN: case CHECKBOX_FILTEROPTIONS: case CHECKBOX_READONLY: case CHECKBOX_LINK: case CHECKBOX_PREVIEW: case CHECKBOX_SELECTION:
nPropertyId = PropFlags::Checked; break;
case LISTBOX_FILTER: if ( ControlActions::GET_SELECTED_ITEM == nControlAction )
{
aRet <<= m_pFilePickerController->getCurFilter();
} else
{
SAL_WARN( "fpicker.office", "Use the XFilterManager to access the filter listbox" );
} break;
case LISTBOX_VERSION: case LISTBOX_TEMPLATE: case LISTBOX_IMAGE_TEMPLATE: case LISTBOX_IMAGE_ANCHOR: switch ( nControlAction )
{ case ControlActions::GET_SELECTED_ITEM:
nPropertyId = PropFlags::SelectedItem; break; case ControlActions::GET_SELECTED_ITEM_INDEX:
nPropertyId = PropFlags::SelectedItemIndex; break; case ControlActions::GET_ITEMS:
nPropertyId = PropFlags::ListItems; break; default:
SAL_WARN( "fpicker.office", "OControlAccess::GetValue: invalid control action for the listbox!" ); break;
} break;
}
}
void OControlAccess::setLabel( sal_Int16 nId, const OUString &rLabel )
{
weld::Widget* pControl = m_pFilePickerController->getControl(nId, true); if (weld::Label* pLabel = dynamic_cast<weld::Label*>(pControl))
{
pLabel->set_label(rLabel); return;
} if (weld::Button* pButton = dynamic_cast<weld::Button*>(pControl))
{
pButton->set_label(rLabel); return;
}
assert(false && "OControlAccess::GetValue: don't have this control in the current mode!");
}
OUString OControlAccess::getLabel( sal_Int16 nId ) const
{
weld::Widget* pControl = m_pFilePickerController->getControl(nId, true); if (weld::Label* pLabel = dynamic_cast<weld::Label*>(pControl)) return pLabel->get_label(); if (weld::Button* pButton = dynamic_cast<weld::Button*>(pControl)) return pButton->get_label();
assert(false && "OControlAccess::GetValue: don't have this control in the current mode!"); return OUString();
}
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.