Kaydet (Commit) fa6c0987 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Fix OFormattedFieldWrapper[_ForcedFormatted] instance creation

broken with 5d05f7ed "forms: use constructor
feature for form modules" and follow-up misguided clean up

Change-Id: If9447740e6408472722b81d112cd85349020eabe
üst 2459936c
......@@ -48,6 +48,40 @@ OFormattedFieldWrapper::OFormattedFieldWrapper(const Reference<XComponentContext
{
}
InterfaceRef OFormattedFieldWrapper::createFormattedFieldWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory, bool bActAsFormatted)
{
OFormattedFieldWrapper *pRef = new OFormattedFieldWrapper(_rxFactory);
if (bActAsFormatted)
{
// instantiate an FormattedModel
InterfaceRef xFormattedModel;
// (instantiate it directly ..., as the OFormattedModel isn't
// registered for any service names anymore)
OFormattedModel* pModel = new OFormattedModel(pRef->m_xContext);
query_interface(static_cast<XWeak*>(pModel), xFormattedModel);
pRef->m_xAggregate = Reference<XAggregation> (xFormattedModel, UNO_QUERY);
OSL_ENSURE(pRef->m_xAggregate.is(), "the OFormattedModel didn't have an XAggregation interface !");
// _before_ setting the delegator, give it to the member references
query_interface(xFormattedModel, pRef->m_xFormattedPart);
pRef->m_pEditPart = rtl::Reference< OEditModel >(new OEditModel(pRef->m_xContext));
}
increment(pRef->m_refCount);
if (pRef->m_xAggregate.is())
{ // has to be in it's own block because of the temporary variable created by *this
pRef->m_xAggregate->setDelegator(static_cast<XWeak*>(pRef));
}
InterfaceRef xRef(*pRef);
decrement(pRef->m_refCount);
return xRef;
}
Reference< XCloneable > SAL_CALL OFormattedFieldWrapper::createClone() throw (RuntimeException, std::exception)
{
ensureAggregate();
......@@ -311,14 +345,20 @@ extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
com_sun_star_form_OFormattedFieldWrapper_get_implementation(::com::sun::star::uno::XComponentContext* component,
::com::sun::star::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new frm::OFormattedFieldWrapper(component));
css::uno::Reference<css::uno::XInterface> inst(
OFormattedFieldWrapper::createFormattedFieldWrapper(component, false));
inst->acquire();
return inst.get();
}
extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
com_sun_star_comp_forms_OFormattedFieldWrapper_ForcedFormatted_get_implementation(::com::sun::star::uno::XComponentContext* component,
::com::sun::star::uno::Sequence<css::uno::Any> const &)
{
return cppu::acquire(new frm::OFormattedFieldWrapper(component));
css::uno::Reference<css::uno::XInterface> inst(
OFormattedFieldWrapper::createFormattedFieldWrapper(component, true));
inst->acquire();
return inst.get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -41,9 +41,6 @@ class OFormattedFieldWrapper : public OFormattedFieldWrapper_Base
{
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext;
public:
OFormattedFieldWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory);
protected:
::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate;
......@@ -51,10 +48,19 @@ protected:
// if we act as formatted this is used to write the EditModel part
::com::sun::star::uno::Reference< ::com::sun::star::io::XPersistObject> m_xFormattedPart;
private:
OFormattedFieldWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory);
protected:
virtual ~OFormattedFieldWrapper();
public:
// if we act as formatted, this is the PersistObject interface of our aggregate, used
// to read and write the FormattedModel part
// if bActAsFormatted is false, the state is undetermined until somebody calls
// ::read or does anything which requires a living aggregate
static InterfaceRef createFormattedFieldWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory, bool bActAsFormatted);
// UNO
DECLARE_UNO3_AGG_DEFAULTS(OFormattedFieldWrapper, OWeakAggObject)
virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(const ::com::sun::star::uno::Type& _rType) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment