/* -*- 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 .
*/
using ::com::sun::star::lang::DisposedException; using ::com::sun::star::lang::NullPointerException; using ::com::sun::star::inspection::XPropertyHandler; using ::com::sun::star::uno::Reference; using ::com::sun::star::inspection::XObjectInspectorUI; using ::com::sun::star::inspection::XPropertyControl; using ::com::sun::star::inspection::XPropertyControlObserver;
void CachedInspectorUI::checkDisposed() const
{ if (m_bDisposed) throw DisposedException();
}
namespace
{ void lcl_markStringKeyPositiveOrNegative( const OUString& _rKeyName, StringBag& _rPositives, StringBag& _rNegatives, bool _bMarkPositive )
{ if ( _bMarkPositive )
{
_rPositives.insert( _rKeyName ); // if the same key has been remember as in the "negative" list before, clear this information, since it's overruled
_rNegatives.erase( _rKeyName );
} else
_rNegatives.insert( _rKeyName );
}
}
aShownProperties.insert( _rPropertyName ); // if the same category has been hidden before, clear this information, since it's overruled
aHiddenProperties.erase( _rPropertyName );
void SAL_CALL CachedInspectorUI::registerControlObserver( const Reference< XPropertyControlObserver >& Observer )
{
OSL_FAIL( "CachedInspectorUI::registerControlObserver: not expected to be called!" ); // CachedInspectorUI is used as context for the controls, and we don't expect them to // register listeners themself
m_rMaster.getDelegatorUI()->registerControlObserver( Observer );
}
void SAL_CALL CachedInspectorUI::revokeControlObserver( const Reference< XPropertyControlObserver >& Observer )
{
OSL_FAIL( "CachedInspectorUI::revokeControlObserver: not expected to be called!" ); // CachedInspectorUI is used as context for the controls, and we don't expect them to // register listeners themself
m_rMaster.getDelegatorUI()->revokeControlObserver( Observer );
}
// an STL-compatible structure which collects strings from a CachedInspectorUI instances struct StringBagCollector
{ private:
StringBag& m_rBag;
CachedInspectorUI::FGetStringBag m_pGetter;
// an STL-compatible structure which cleans a certain string bag in a CachedInspectorUI instances struct StringBagClearer
{ private:
CachedInspectorUI::FGetStringBag m_pGetter;
// a typedef for a ->XObjectInspectorUI member function taking a string typedefvoid ( SAL_CALL XObjectInspectorUI::*FPropertyUISetter )( const OUString& );
// an STL-compatible struct which calls a certain member method (taking a string) at a // given ->XObjectInspectorUI instance struct PropertyUIOperator
{ private:
Reference< XObjectInspectorUI > m_xUpdater;
FPropertyUISetter m_pSetter;
// an interface which encapsulates access to a single aspect of the ->XObjectInspectorUI, // where this aspect is given by a string key, and has a boolean value. class IStringKeyBooleanUIUpdate
{ public: virtualvoid updateUIForKey( const OUString& _rKey, bool _bFlag ) const = 0;
virtual ~IStringKeyBooleanUIUpdate() { }
};
// FPropertyUIFlagSetter
/** an implementation of the ->IStringKeyBooleanUIUpdate interface which, for a fixed ->XObjectInspectorUI instance and a fixed UI element (->PropertyLineElement), updates this element for a given property with a given boolean flag (->XObjectInspectorUI::enablePropertyUIElements)
*/ class EnablePropertyUIElement : public IStringKeyBooleanUIUpdate
{ private:
Reference< XObjectInspectorUI > m_xUIUpdate;
sal_Int16 m_nElement;
// a ->XObjectInspectorUI method taking a string and a boolean typedefvoid ( SAL_CALL XObjectInspectorUI::*FPropertyUIFlagSetter )( const OUString&, sal_Bool );
// an implementation of the ->IStringKeyBooleanUIUpdate interface which calls // an arbitrary ->XObjectInspectorUI method taking a string and a boolean flag class DefaultStringKeyBooleanUIUpdate : public IStringKeyBooleanUIUpdate
{ private:
Reference< XObjectInspectorUI > m_xUIUpdate;
FPropertyUIFlagSetter m_pSetter;
// an STL-compatible structure which applies a ->IStringKeyBooleanUIUpdate::updateUIForKey // operation with a fixed boolean value, for a given string value struct BooleanUIAspectUpdate
{ private: const IStringKeyBooleanUIUpdate& m_rUpdater; bool m_bFlag;
void lcl_fireUIStateFlag( const IStringKeyBooleanUIUpdate& _rUIUpdate, const ImplMapHandlerToUI& _rHandlerUIs,
CachedInspectorUI::FGetStringBag _pGetPositives,
CachedInspectorUI::FGetStringBag _pGetNegatives
)
{ // all strings which are in the "positive" list of one handler
StringBag aAllPositives;
StringBagCollector::collectAll( aAllPositives, _rHandlerUIs, _pGetPositives );
// all strings which are in the "negative" list of one handler
StringBag aAllNegatives;
StringBagCollector::collectAll( aAllNegatives, _rHandlerUIs, _pGetNegatives );
// propagate the "negative" flags to the delegator UI
BooleanUIAspectUpdate::forEach( aAllNegatives, _rUIUpdate, false );
// propagate the "positive" flags to the delegator UI, for all elements where _no_ // "negative" flag exists
StringBagComplement::subtract( aAllPositives, aAllNegatives );
BooleanUIAspectUpdate::forEach( aAllPositives, _rUIUpdate, true );
// the "positive" request can be cleared no, only negative requests // (such as "disable a property" or "hide a category") need to be preserved for the next round
StringBagClearer::clearAll( _rHandlerUIs, _pGetPositives );
}
}
void ComposedPropertyUIUpdate::impl_fireRebuildPropertyUI_throw()
{ // collect all properties for which a rebuild request has been made
StringBag aAllRebuilt;
StringBagCollector::collectAll( aAllRebuilt, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getRebuiltProperties );
// rebuild all those properties
PropertyUIOperator::forEach( aAllRebuilt, m_xDelegatorUI, &XObjectInspectorUI::rebuildPropertyUI );
// clear the "properties to rebuild" at all handlers, since the request has been fulfilled now.
StringBagClearer::clearAll( m_pCollectedUIs->aHandlers, &CachedInspectorUI::getRebuiltProperties );
}
void ComposedPropertyUIUpdate::impl_fireShowHidePropertyUI_throw()
{ // all properties which have been shown by at least one handler
StringBag aAllShown;
StringBagCollector::collectAll( aAllShown, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getShownProperties ); // all properties which have been hidden by at least one handler
StringBag aAllHidden;
StringBagCollector::collectAll( aAllHidden, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getHiddenProperties );
// hide properties as necessary
PropertyUIOperator::forEach( aAllHidden, m_xDelegatorUI, &XObjectInspectorUI::hidePropertyUI );
// for those properties which are hidden, ignore all "show" requests which other handlers might have had
StringBagComplement::subtract( aAllShown, aAllHidden );
// show properties
PropertyUIOperator::forEach( aAllShown, m_xDelegatorUI, &XObjectInspectorUI::showPropertyUI );
}
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 ist noch experimentell.