summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
Diffstat (limited to 'forms')
-rw-r--r--forms/source/component/FormattedFieldWrapper.cxx44
-rw-r--r--forms/source/component/FormattedFieldWrapper.hxx12
2 files changed, 51 insertions, 5 deletions
diff --git a/forms/source/component/FormattedFieldWrapper.cxx b/forms/source/component/FormattedFieldWrapper.cxx
index 43d81f691f31..f27813278977 100644
--- a/forms/source/component/FormattedFieldWrapper.cxx
+++ b/forms/source/component/FormattedFieldWrapper.cxx
@@ -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: */
diff --git a/forms/source/component/FormattedFieldWrapper.hxx b/forms/source/component/FormattedFieldWrapper.hxx
index b510957eed90..36a8c47aae50 100644
--- a/forms/source/component/FormattedFieldWrapper.hxx
+++ b/forms/source/component/FormattedFieldWrapper.hxx
@@ -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;