20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_FAPIHELPER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_FAPIHELPER_HXX
23 #include <com/sun/star/uno/Any.hxx>
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <osl/diagnose.h>
31 namespace lang {
class XMultiServiceFactory; }
38 namespace comphelper {
class IDocPasswordVerifier; }
50 template<
typename Type >
51 static css::uno::Sequence< Type >
55 static OUString
GetServiceName(
const css::uno::Reference< css::uno::XInterface >& xInt );
62 const css::uno::Reference< css::lang::XMultiServiceFactory >&
xFactory,
63 const OUString& rServiceName );
68 const OUString& rServiceName );
71 static css::uno::Reference< css::uno::XInterface >
CreateInstance(
const OUString& rServiceName );
77 const ::std::vector< OUString >* pDefaultPasswords );
80 template<
typename Type >
83 OSL_ENSURE( !rVector.empty(),
"ScfApiHelper::VectorToSequence - vector is empty" );
84 return css::uno::Sequence<Type>(rVector.data(),
static_cast< sal_Int32
>(rVector.size()));
109 explicit ScfPropertySet(
const css::uno::Reference< css::beans::XPropertySet > & xPropSet ) {
Set( xPropSet ); }
111 template<
typename InterfaceType >
112 explicit ScfPropertySet(
const css::uno::Reference< InterfaceType >& xInterface ) {
Set( xInterface ); }
122 void Set( css::uno::Reference< css::beans::XPropertySet >
const & xPropSet );
124 template<
typename InterfaceType >
125 void Set( css::uno::Reference< InterfaceType > xInterface )
126 {
Set( css::uno::Reference< css::beans::XPropertySet >( xInterface, css::uno::UNO_QUERY ) ); }
140 bool HasProperty(
const OUString& rPropName )
const;
144 bool GetAnyProperty( css::uno::Any& rValue,
const OUString& rPropName )
const;
148 template<
typename Type >
150 { css::uno::Any aAny;
return GetAnyProperty( aAny, rPropName ) && (aAny >>= rValue); }
166 void GetProperties( css::uno::Sequence< css::uno::Any >& rValues,
const css::uno::Sequence< OUString >& rPropNames )
const;
171 void SetAnyProperty(
const OUString& rPropName,
const css::uno::Any& rValue );
174 template<
typename Type >
193 void SetProperties(
const css::uno::Sequence< OUString > & rPropNames,
const css::uno::Sequence< css::uno::Any >& rValues );
196 css::uno::Reference< css::beans::XPropertySet >
mxPropSet;
226 template<
typename Type >
241 template<
typename Type >
265 template<
typename Type >
273 template<
typename Type >
281 template<
typename Type >
285 return rPropSetHelper;
288 template<
typename Type >
292 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.
css::uno::Any const & rValue
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