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; }
37 namespace 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 );
79 template<
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 >
264 template<
typename Type >
272 template<
typename Type >
280 template<
typename Type >
284 return rPropSetHelper;
287 template<
typename Type >
291 return rPropSetHelper;
Static API helper functions.
ScfPropertySet(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
Constructs a property set wrapper with the passed UNO property set.
void SetProperties(const css::uno::Sequence< OUString > &rPropNames, const css::uno::Sequence< css::uno::Any > &rValues)
Puts the passed properties into the property set.
bool GetBoolProperty(const OUString &rPropName) const
Gets the specified Boolean property from the property set.
css::uno::Any * GetNextAny()
Returns a pointer to the next Any to be written to.
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...
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.
css::uno::Sequence< OUString > maNameSeq
void InitializeWrite()
Must be called before reading or storing property values in the helper.
OUString GetServiceName() const
Returns the service name provided via the XServiceName interface, or an empty string on error...
void ReadFromPropertySet(const ScfPropertySet &rPropSet)
Reads all values from the passed property set.
ScfPropSetHelper & operator<<(ScfPropSetHelper &rPropSetHelper, const Type &rValue)
void WriteToPropertySet(ScfPropertySet &rPropSet) const
Writes all values to the passed property set.
void WriteValue(const Type &rValue)
Writes the next value to the value sequence.
class SAL_NO_VTABLE XPropertySet
void WriteValue(const Color &rColor)
Writes a color value to the value sequence.
static css::uno::Reference< css::lang::XMultiServiceFactory > GetServiceFactory(const SfxObjectShell *pShell)
Returns the multi service factory from a document shell.
css::uno::Sequence< css::uno::Any > maValueSeq
Sequence of property names.
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...
bool GetColorProperty(Color &rColor, const OUString &rPropName) const
Gets the specified color property from the property set.
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.
ScfPropSetHelper(const char *const *ppcPropNames)
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.
css::uno::Reference< css::beans::XMultiPropertySet > mxMultiPropSet
The mandatory property set interface.
ScfPropertySet(const css::uno::Reference< InterfaceType > &xInterface)
Constructs a property set wrapper after querying the XPropertySet interface.
css::uno::Reference< css::beans::XPropertySet > mxPropSet
void SetAnyProperty(const OUString &rPropName, const css::uno::Any &rValue)
Puts the passed Any into the property set.
size_t mnNextIdx
Maps initial order to alphabetical order.
bool Is() const
Returns true, if the contained XPropertySet interface is valid.
A wrapper for a UNO property set.
void SetBoolProperty(const OUString &rPropName, bool bValue)
Puts the passed Boolean value into the property set.
bool GetAnyProperty(css::uno::Any &rValue, const OUString &rPropName) const
Gets the specified property from the property set.
void SetStringProperty(const OUString &rPropName, const OUString &rValue)
Puts the passed string into the property set.
const css::uno::Reference< css::beans::XPropertySet > & GetApiPropertySet() const
Returns the contained XPropertySet interface.
void ReadValue(Type &rValue)
Reads the next value from the value sequence.
ScfPropSetHelper & operator>>(ScfPropSetHelper &rPropSetHelper, Type &rValue)
void SetColorProperty(const OUString &rPropName, const Color &rColor)
Puts the passed color into the property set.
void SetProperty(const OUString &rPropName, const Type &rValue)
Puts the passed value into the property set.
Reference< XSingleServiceFactory > xFactory
bool HasProperty(const OUString &rPropName) const
Returns true, if the property set contains the specified property.
void GetProperties(css::uno::Sequence< css::uno::Any > &rValues, const css::uno::Sequence< OUString > &rPropNames) const
Gets the specified properties from the property set.
ScfInt32Vec maNameOrder
Sequence of property values.
Generic helper class for reading from and writing to property sets.
void Set(css::uno::Reference< css::beans::XPropertySet > const &xPropSet)
Sets the passed UNO property set and releases the old UNO property set.
bool GetProperty(Type &rValue, const OUString &rPropName) const
Gets the specified property from the property set.
ScfPropertySet & operator=(ScfPropertySet const &)=default