Skip to content

Commit

Permalink
Make getSdrModelFromUnoModel work with SdrModel&
Browse files Browse the repository at this point in the history
Change-Id: Iea3af7db77ef778db7bbdf2c1b6b1b956fd57fec
Reviewed-on: https://gerrit.libreoffice.org/52592
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
  • Loading branch information
Armin Le Grand authored and Armin Le Grand committed Apr 9, 2018
1 parent aa02205 commit 06d8e62
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 19 deletions.
6 changes: 5 additions & 1 deletion include/svx/unomod.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class SVX_DLLPUBLIC SvxUnoDrawMSFactory : public css::lang::XMultiServiceFactory
{
protected:
/** abstract SdrModel provider */
virtual SdrModel* getSdrModelFromUnoModel() const = 0; //TTTT make reference return
// Every App has a DrwingLayer as internal Tooling, thus ist is
// not too hard to asl a UnoModel to hand back a DrawingLayer Model in the
// form of an SdrModel. Thus, returning a reference and make usages
// safer and easier is justified.
virtual SdrModel& getSdrModelFromUnoModel() const = 0; //TTTT make reference return

public:
SvxUnoDrawMSFactory() throw() {};
Expand Down
2 changes: 1 addition & 1 deletion include/svx/unomodel.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private:

protected:
// SvxUnoDrawMSFactory
virtual SdrModel* getSdrModelFromUnoModel() const override;
virtual SdrModel& getSdrModelFromUnoModel() const override;

public:
SvxUnoDrawingModel( SdrModel* pDoc ) throw();
Expand Down
2 changes: 1 addition & 1 deletion reportdesign/inc/ReportDefinition.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ namespace reportdesign

protected:
/** abstract SdrModel provider */
virtual SdrModel* getSdrModelFromUnoModel() const override;
virtual SdrModel& getSdrModelFromUnoModel() const override;

public:
//TTTT Needed? Or same as above?
Expand Down
5 changes: 3 additions & 2 deletions reportdesign/source/core/api/ReportDefinition.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2020,9 +2020,10 @@ std::shared_ptr<rptui::OReportModel> OReportDefinition::getSdrModel(const uno::R
return pReportModel;
}

SdrModel* OReportDefinition::getSdrModelFromUnoModel() const
SdrModel& OReportDefinition::getSdrModelFromUnoModel() const
{
return m_pImpl->m_pReportModel.get();
OSL_ENSURE(m_pImpl->m_pReportModel.get(), "No SdrModel in ReportDesign, should not happen");
return *m_pImpl->m_pReportModel.get();
}

uno::Reference< uno::XInterface > SAL_CALL OReportDefinition::createInstanceWithArguments( const OUString& aServiceSpecifier, const uno::Sequence< uno::Any >& _aArgs)
Expand Down
2 changes: 1 addition & 1 deletion sc/inc/docuno.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected:
const SfxItemPropertySet& GetPropertySet() const { return aPropSet; }

/** abstract SdrModel provider */
virtual SdrModel* getSdrModelFromUnoModel() const override;
virtual SdrModel& getSdrModelFromUnoModel() const override;

public:
ScModelObj(ScDocShell* pDocSh);
Expand Down
4 changes: 2 additions & 2 deletions sc/source/ui/unoobj/docuno.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ void ScModelObj::CreateAndSet(ScDocShell* pDocSh)
pDocSh->SetBaseModel( new ScModelObj(pDocSh) );
}

SdrModel* ScModelObj::getSdrModelFromUnoModel() const
SdrModel& ScModelObj::getSdrModelFromUnoModel() const
{
ScDocument& rDoc(pDocShell->GetDocument());

Expand All @@ -382,7 +382,7 @@ SdrModel* ScModelObj::getSdrModelFromUnoModel() const
rDoc.InitDrawLayer();
}

return rDoc.GetDrawLayer();
return *rDoc.GetDrawLayer(); // TTTT should be reference
}

ScModelObj::ScModelObj( ScDocShell* pDocSh ) :
Expand Down
2 changes: 1 addition & 1 deletion sd/source/ui/inc/unomodel.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private:

protected:
/** abstract SdrModel provider */
virtual SdrModel* getSdrModelFromUnoModel() const override;
virtual SdrModel& getSdrModelFromUnoModel() const override;

public:
SdXImpressDocument(::sd::DrawDocShell* pShell, bool bClipBoard);
Expand Down
5 changes: 3 additions & 2 deletions sd/source/ui/unoidl/unomodel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2714,9 +2714,10 @@ void SdXImpressDocument::initializeDocument()
}
}

SdrModel* SdXImpressDocument::getSdrModelFromUnoModel() const
SdrModel& SdXImpressDocument::getSdrModelFromUnoModel() const
{
return GetDoc();
OSL_ENSURE(GetDoc(), "No SdrModel in draw/Impress, should not happen");
return *GetDoc(); // TTTT should be reference
}

void SAL_CALL SdXImpressDocument::dispose()
Expand Down
5 changes: 2 additions & 3 deletions svx/source/form/fmdmod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
}
else if ( rServiceSpecifier == "com.sun.star.drawing.ControlShape" )
{
SdrModel* pTargetModel = getSdrModelFromUnoModel();
OSL_ENSURE(pTargetModel, "Got no SdrModel for SdrShape construction (!)");
SdrObject* pObj = new FmFormObj(*pTargetModel);
SdrModel& rTargetModel(getSdrModelFromUnoModel());
SdrObject* pObj = new FmFormObj(rTargetModel);
xRet = static_cast<cppu::OWeakObject*>(static_cast<SvxShape_UnoImplHelper*>(new SvxShapeControl(pObj)));
}

Expand Down
5 changes: 3 additions & 2 deletions svx/source/unodraw/unomod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,10 @@ uno::Sequence< OUString > SvxUnoDrawMSFactory::concatServiceNames( uno::Sequence
return aSeq;
}

SdrModel* SvxUnoDrawingModel::getSdrModelFromUnoModel() const
SdrModel& SvxUnoDrawingModel::getSdrModelFromUnoModel() const
{
return mpDoc;
OSL_ENSURE(mpDoc, "No SdrModel in UnoDrawingModel, should not happen");
return *mpDoc;
}

SvxUnoDrawingModel::SvxUnoDrawingModel(SdrModel* pDoc) throw()
Expand Down
2 changes: 1 addition & 1 deletion sw/inc/unotxdoc.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private:

protected:
/** abstract SdrModel provider */
virtual SdrModel* getSdrModelFromUnoModel() const override;
virtual SdrModel& getSdrModelFromUnoModel() const override;

virtual ~SwXTextDocument() override;
public:
Expand Down
4 changes: 2 additions & 2 deletions sw/source/uibase/uno/unotxdoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,10 @@ SwXTextDocument::SwXTextDocument(SwDocShell* pShell)
{
}

SdrModel* SwXTextDocument::getSdrModelFromUnoModel() const
SdrModel& SwXTextDocument::getSdrModelFromUnoModel() const
{
OSL_ENSURE(pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetOrCreateDrawModel(), "No SdrModel in SwDoc, should not happen");
return pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
return *pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
}

SwXTextDocument::~SwXTextDocument()
Expand Down

0 comments on commit 06d8e62

Please sign in to comment.