/* -*- 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 . */ #ifndef INCLUDED_CANVAS_PROPERTYSETHELPER_HXX #define INCLUDED_CANVAS_PROPERTYSETHELPER_HXX #include #include #include #include #include #include #include namespace canvas { /** Really simplistic XPropertySet helper for properties. This class provides easy access to properties, referenced via ASCII strings. The name/property modification callbacks pairs are passed into this class via a vector. Each time a property is set or queried, the corresponding getter or setter callback is called. Use this class as a delegate for the corresponding XPropertySet methods, and take care of UNO XInterface and lock handling by yourself. The core responsibility of this class is the name/value mapping for property sets. */ class CANVASTOOLS_DLLPUBLIC PropertySetHelper { public: typedef std::function GetterType; typedef std::function SetterType; struct Callbacks { GetterType getter; SetterType setter; }; typedef tools::ValueMap< Callbacks > MapType; typedef std::vector< MapType::MapEntry > InputMap; class MakeMap : public InputMap { public: MakeMap(const char* name, const GetterType& getter, const SetterType& setter) { MapType::MapEntry aEntry={name, {getter, setter}}; push_back(aEntry); } MakeMap(const char* name, const GetterType& getter) { MapType::MapEntry aEntry={name, {getter, SetterType()}}; push_back(aEntry); } MakeMap& operator()(const char* name, const GetterType& getter, const SetterType& setter) { MapType::MapEntry aEntry={name, {getter, setter}}; push_back(aEntry); return *this; } MakeMap& operator()(const char* name, const GetterType& getter) { MapType::MapEntry aEntry={name, {getter, SetterType()}}; push_back(aEntry); return *this; } }; /** Create helper with zero properties */ PropertySetHelper(); /** Init helper with new name/value map @param rMap Vector of name/function pointers. Each name is offered as a property, and reading/writing to this property is passed on to the given function pointer. */ void initProperties( const InputMap& rMap ); /** Add given properties to helper @param rMap Vector of name/function pointers. Each name is offered as a property, and reading/writing to this property is passed on to the given function pointer. These name/function pairs are added to the already existing ones. */ void addProperties( const InputMap& rMap ); /** Checks whether the given string corresponds to a valid property name. @return true, if the given name maps to a known property. */ bool isPropertyName( const OUString& aPropertyName ) const; // XPropertySet implementation css::uno::Reference< css::beans::XPropertySetInfo > getPropertySetInfo() const; void setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ); css::uno::Any getPropertyValue( const OUString& PropertyName ) const; void addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ); void addVetoableChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener ); private: std::unique_ptr mpMap; InputMap maMapEntries; }; } #endif /* INCLUDED_CANVAS_PROPERTYSETHELPER_HXX */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ labora/lov-6.0.4 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2024-11-08no need to take a copy of the getProcessComponentContext return valueNoel Grandin
2024-05-10loplugin:ostr in sfx2Noel Grandin
2023-12-30move IsFuzzing to comphelperCaolán McNamara
2023-12-10cid#1545789 COPY_INSTEAD_OF_MOVECaolán McNamara
2023-10-15Repurpose loplugin:stringstatic for O[U]String vars that can be constexprStephan Bergmann
2023-04-28survive exporting to pdf without config for fuzzingCaolán McNamara
2022-10-11Deduplicate O(U)StringConcatenationMike Kaganski
2022-08-18Move tools/diagnose_ex.h to comphelper/diagnose_ex.hxxStephan Bergmann
2022-05-04Just use Any ctor instead of makeAny in sfx2Stephan Bergmann
2022-05-01use more string_view in variousNoel Grandin
2021-10-03A more lightweight O[U]StringConcatenationStephan Bergmann
2021-09-22Extend loplugin:stringviewparam to starts/endsWith: sfx2Stephan Bergmann
2021-03-05emplace_back: use perfect forwarding if possibleThorsten Behrens
2021-02-16loplugin:referencecasting in sfx2Noel
2021-02-07Remove unneeded breaksAndrea Gelmini
2021-01-17cppcheck: derefInvalidIteratorRedundantCheck (sfx2/classificationhelper)Julien Nabet
2020-11-24loplugin:stringviewparam extend to comparison operatorsNoel
2020-08-18loplugin:unusedvarsglobalNoel Grandin
2020-05-15use more try_emplaceNoel Grandin
2020-03-12Revert "loplugin:constfields in sfx2"Noel Grandin
2020-01-21tdf#42949 Fix IWYU warnings in sfx2/source/[s-v]*/*cxx and sfx2/qaGabor Kelemen
2019-11-19tdf#97926 Add UNO API for InfobarSamuel Mehrbrodt
2019-10-16loplugin:bufferadd loosen some constraintsNoel Grandin
2019-08-27loplugin:constmethod in sfx2Noel Grandin
2019-08-15loplugin:sequenceloop in sdext..sfx2Noel Grandin
2019-06-17loplugin:logexceptionnicely in sfx2Noel Grandin
2019-03-29tdf#42949 Fix IWYU warnings in include/sfx2/[n-r]*Gabor Kelemen
2019-03-28tdf#42949 Fix IWYU warnings in include/sfx2/[e-M]*Gabor Kelemen
2019-01-28o3tl::make_unique -> std::make_unique in sax...svtools (except sc)Gabor Kelemen
2018-12-10tdf#42949 Fix IWYU warnings in include/vcl/s*Gabor Kelemen
2018-12-07loplugin:singlevalfields extend to all static varsNoel Grandin
2018-11-22improve function-local statics in scripting..svtoolsNoel Grandin
2018-11-18tdf#120703 PVS: V560 A part of conditional expression is always true/falseMike Kaganski
2018-10-09loplugin:constfields in sfx2Noel Grandin
2018-08-29Replace find_if with proper quantifier algorithmsArkadiy Illarionov
2018-07-31Add missing sal/log.hxx headersGabor Kelemen
2018-07-10pass SvStream around by std::unique_ptrNoel Grandin
2018-02-22weld native message dialogsCaolán McNamara
2017-12-27loplugin:passstuffbyref improved return in xmloff,sfx2Noel Grandin
2017-11-27TSCP: don't put a non-existing name into doc. propsTomaž Vajngerl