22#include <com/sun/star/uno/Any.hxx>
23#include <com/sun/star/uno/Reference.hxx>
24#include <com/sun/star/uno/Sequence.hxx>
25#include <osl/diagnose.h>
30 namespace lang {
class XMultiServiceFactory; }
37namespace comphelper {
class IDocPasswordVerifier; }
49 template<
typename Type >
50 static css::uno::Sequence< Type >
54 static OUString
GetServiceName(
const css::uno::Reference< css::uno::XInterface >& xInt );
61 const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory,
62 const OUString& rServiceName );
67 const OUString& rServiceName );
70 static css::uno::Reference< css::uno::XInterface >
CreateInstance(
const OUString& rServiceName );
76 const ::std::vector< OUString >* pDefaultPasswords );
79template<
typename Type >
82 OSL_ENSURE( !rVector.empty(),
"ScfApiHelper::VectorToSequence - vector is empty" );
83 return css::uno::Sequence<Type>(rVector.data(),
static_cast< sal_Int32
>(rVector.size()));
108 explicit ScfPropertySet(
const css::uno::Reference< css::beans::XPropertySet > & xPropSet ) {
Set( xPropSet ); }
110 template<
typename InterfaceType >
111 explicit ScfPropertySet(
const css::uno::Reference< InterfaceType >& xInterface ) {
Set( xInterface ); }
121 void Set( css::uno::Reference< css::beans::XPropertySet >
const & xPropSet );
123 template<
typename InterfaceType >
124 void Set( css::uno::Reference< InterfaceType > xInterface )
125 {
Set( css::uno::Reference< css::beans::XPropertySet >( xInterface, css::uno::UNO_QUERY ) ); }
139 bool HasProperty(
const OUString& rPropName )
const;
143 bool GetAnyProperty( css::uno::Any& rValue,
const OUString& rPropName )
const;
147 template<
typename Type >
149 { css::uno::Any aAny;
return GetAnyProperty( aAny, rPropName ) && (aAny >>= rValue); }
165 void GetProperties( css::uno::Sequence< css::uno::Any >& rValues,
const css::uno::Sequence< OUString >& rPropNames )
const;
170 void SetAnyProperty(
const OUString& rPropName,
const css::uno::Any& rValue );
173 template<
typename Type >
192 void SetProperties(
const css::uno::Sequence< OUString > & rPropNames,
const css::uno::Sequence< css::uno::Any >& rValues );
195 css::uno::Reference< css::beans::XPropertySet >
mxPropSet;
225 template<
typename Type >
240 template<
typename Type >
264template<
typename Type >
272template<
typename Type >
280template<
typename Type >
284 return rPropSetHelper;
287template<
typename Type >
291 return rPropSetHelper;
Static API helper functions.
static OUString GetServiceName(const css::uno::Reference< css::uno::XInterface > &xInt)
Returns the service name provided via the XServiceName interface, or an empty string on error.
static css::uno::Reference< css::lang::XMultiServiceFactory > GetServiceFactory(const SfxObjectShell *pShell)
Returns the multi service factory from a document shell.
static css::uno::Sequence< Type > VectorToSequence(const ::std::vector< Type > &rVector)
Converts a non-empty vector into a UNO sequence containing elements of the same type.
static css::uno::Sequence< css::beans::NamedValue > QueryEncryptionDataForMedium(SfxMedium &rMedium, ::comphelper::IDocPasswordVerifier &rVerifier, const ::std::vector< OUString > *pDefaultPasswords)
Opens a password dialog and returns the encryption data.
static css::uno::Reference< css::uno::XInterface > CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory > &xFactory, const OUString &rServiceName)
Creates an instance from the passed service name, using the passed service factory.
Generic helper class for reading from and writing to property sets.
css::uno::Sequence< css::uno::Any > maValueSeq
Sequence of property names.
css::uno::Sequence< OUString > maNameSeq
size_t mnNextIdx
Maps initial order to alphabetical order.
void WriteValue(const Type &rValue)
Writes the next value to the value sequence.
void WriteValue(const Color &rColor)
Writes a color value to the value sequence.
void WriteValue(const css::uno::Any &rAny)
Writes an Any to the value sequence.
void ReadValue(css::uno::Any &rAny)
Reads an Any from the value sequence.
ScfPropSetHelper(const char *const *ppcPropNames)
void ReadValue(Type &rValue)
Reads the next value from the value sequence.
ScfInt32Vec maNameOrder
Sequence of property values.
void ReadFromPropertySet(const ScfPropertySet &rPropSet)
Reads all values from the passed property set.
void WriteToPropertySet(ScfPropertySet &rPropSet) const
Writes all values to the passed property set.
void InitializeWrite()
Must be called before reading or storing property values in the helper.
css::uno::Any * GetNextAny()
Returns a pointer to the next Any to be written to.
A wrapper for a UNO property set.
const css::uno::Reference< css::beans::XPropertySet > & GetApiPropertySet() const
Returns the contained XPropertySet interface.
void SetProperty(const OUString &rPropName, const Type &rValue)
Puts the passed value into the property set.
css::uno::Reference< css::beans::XPropertySet > mxPropSet
void GetProperties(css::uno::Sequence< css::uno::Any > &rValues, const css::uno::Sequence< OUString > &rPropNames) const
Gets the specified properties from the property set.
void Set(css::uno::Reference< css::beans::XPropertySet > const &xPropSet)
Sets the passed UNO property set and releases the old UNO property set.
bool GetBoolProperty(const OUString &rPropName) const
Gets the specified Boolean property from the property set.
void SetColorProperty(const OUString &rPropName, const Color &rColor)
Puts the passed color into the property set.
void SetStringProperty(const OUString &rPropName, const OUString &rValue)
Puts the passed string into the property set.
ScfPropertySet(const css::uno::Reference< InterfaceType > &xInterface)
Constructs a property set wrapper after querying the XPropertySet interface.
void SetBoolProperty(const OUString &rPropName, bool bValue)
Puts the passed Boolean value into the property set.
bool GetProperty(Type &rValue, const OUString &rPropName) const
Gets the specified property from the property set.
ScfPropertySet(ScfPropertySet &&)=default
ScfPropertySet(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
Constructs a property set wrapper with the passed UNO property set.
css::uno::Reference< css::beans::XMultiPropertySet > mxMultiPropSet
The mandatory property set interface.
OUString GetServiceName() const
Returns the service name provided via the XServiceName interface, or an empty string on error.
bool GetAnyProperty(css::uno::Any &rValue, const OUString &rPropName) const
Gets the specified property from the property set.
OUString GetStringProperty(const OUString &rPropName) const
Gets the specified Boolean property from the property set.
void Set(css::uno::Reference< InterfaceType > xInterface)
Queries the passed interface for an XPropertySet and releases the old UNO property set.
ScfPropertySet & operator=(ScfPropertySet const &)=default
bool GetColorProperty(Color &rColor, const OUString &rPropName) const
Gets the specified color property from the property set.
bool HasProperty(const OUString &rPropName) const
Returns true, if the property set contains the specified property.
void SetProperties(const css::uno::Sequence< OUString > &rPropNames, const css::uno::Sequence< css::uno::Any > &rValues)
Puts the passed properties into the property set.
void SetAnyProperty(const OUString &rPropName, const css::uno::Any &rValue)
Puts the passed Any into the property set.
bool Is() const
Returns true, if the contained XPropertySet interface is valid.
ScfPropertySet(ScfPropertySet const &)=default
ScfPropSetHelper & operator>>(ScfPropSetHelper &rPropSetHelper, Type &rValue)
ScfPropSetHelper & operator<<(ScfPropSetHelper &rPropSetHelper, const Type &rValue)
class SAL_NO_VTABLE XPropertySet