Skip to content

Commit

Permalink
SOSAW080: Derive SdrObjGroup from SdrObjList
Browse files Browse the repository at this point in the history
Also simplify parent/child relationships, get rid
of double data (SdrPage/Parent infos in SdrObjects,
also in SdrObjList). This is all not needed - when a
SdrObject is inserted to a SdrPage, get SdrPage by
traveling over parents (no double info, member as soon
as inserted, ...).
More cleanups/reworks included, will need some more
cleanups, too.

Stabilizing: SetRectsDirty/DefaultStyleSheet

Had to correct the SetRectsDirty stuff for 3D due to
going down the hierarchy while the 2D implementation
goes the other direction -> endless loops. Added special
handling for 3D stuff for now (will be chnaged again when
SnapRect is no longer needed at SdrObject level).
Also had to adapt how the DefaultStyleSheet is set at
incarnated SdrObjects - better: their properties. Since
we now always have a SdrModel, it is possible to correctly
initialize with the correct default StyleSheet from that
SdrModel.
This needs to be done after ForceDefaultAttributes and in a
way that again deletes Items that are set in the StyleSheet.
This leads to an error in CppunitTest_sd_import_tests where
I checked tdf100491 - it is okay and thus I change the control
instance of the imported, XML-dumped file.
The less hard attributes, the better for Styles in general.

Cleanup of comments for last two commits

Corrected SvxShape::getParent()

Needed to get the direct parent, so test for SdrObject
first (to get SdrObjGroup/E3DScene), for SdrPage second

Fixed CppunitTest_sc_subsequent_export_test

Several problems arose. The used SdrCaptionObj was
Cloned, but the clone not inserted to a SdrPage. This
leads to not being able to access a UNO API imlementation
of the SdrPage (SvxPage) on lower levels.
It worked before due to SdrObject having a SdrPage*
additionally to being added to a SdrPage - this is exactly
the main cleanup this change does.
Looked for why it is cloned, could see no reasons. The
SdrCaptionObj exists during all im/export, not difference
to other SdrObjects (that do not get cloned). It is not
changed in any way. It *might* be to suppress a crash that
happened due to UNO API Service emfio/emfio not being
available in the UnitTest scenario. Interestingly it
did not crash with the cloned SdrCaptionObj, but the
Graphic exported was probably wrong.
Fixed by no longer Cloning the SdrCaptionObj and adding
emfio/emfio UNO API Service.

d139f821a5b39535a3e7b9c6261df7e18f8ae8ac
910e7f4bc628a715fda7545dffaf3369d5e76ea0
ca1de01b723051e09ac37d7ec7bba978beea41c5
3a76da1471dfe75e69847f64a6a3519ad21c8c9c

Change-Id: I986586e326b563acebf00d931a7084c6eb09e5f8
Reviewed-on: https://gerrit.libreoffice.org/54689
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 May 25, 2018
1 parent f8edef3 commit 4b49422
Show file tree
Hide file tree
Showing 181 changed files with 1,324 additions and 1,153 deletions.
3 changes: 1 addition & 2 deletions basctl/source/dlged/dlged.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,7 @@ void DlgEditor::CreateDefaultObject()
SdrObject* pObj = SdrObjFactory::MakeNewObject(
*pDlgEdModel,
pDlgEdView->GetCurrentObjInventor(),
pDlgEdView->GetCurrentObjIdentifier(),
pDlgEdPage);
pDlgEdView->GetCurrentObjIdentifier());

if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj))
{
Expand Down
4 changes: 2 additions & 2 deletions basctl/source/dlged/dlgedobj.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ bool DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
void DlgEdObj::SetDefaults()
{
// set parent form
pDlgEdForm = static_cast<DlgEdPage*>(GetPage())->GetDlgEdForm();
pDlgEdForm = static_cast<DlgEdPage*>(getSdrPageFromSdrObject())->GetDlgEdForm();

if ( pDlgEdForm )
{
Expand Down Expand Up @@ -1379,7 +1379,7 @@ void DlgEdForm::PositionAndSizeChange( const beans::PropertyChangeEvent& evt )

void DlgEdForm::UpdateStep()
{
SdrPage* pSdrPage = GetPage();
SdrPage* pSdrPage = getSdrPageFromSdrObject();

if ( pSdrPage )
{
Expand Down
2 changes: 1 addition & 1 deletion basctl/source/dlged/propbrw.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Sequence< Reference< XInterface > >
std::unique_ptr<SdrObjListIter> pGroupIterator;
if (pCurrent->IsGroupObject())
{
pGroupIterator.reset(new SdrObjListIter(*pCurrent->GetSubList()));
pGroupIterator.reset(new SdrObjListIter(pCurrent->GetSubList()));
pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr;
}

Expand Down
4 changes: 1 addition & 3 deletions chart2/source/controller/main/ChartController_Tools.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void ChartController::impl_PasteShapes( SdrModel* pModel )
for ( sal_uInt16 i = 0; i < nCount; ++i )
{
const SdrPage* pPage = pModel->GetPage( i );
SdrObjListIter aIter( *pPage, SdrIterMode::DeepNoGroups );
SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
while ( aIter.IsMore() )
{
SdrObject* pObj(aIter.Next());
Expand All @@ -402,8 +402,6 @@ void ChartController::impl_PasteShapes( SdrModel* pModel )

if ( pNewObj )
{
pNewObj->SetPage( pDestPage );

// set position
Reference< drawing::XShape > xShape( pNewObj->getUnoShape(), uno::UNO_QUERY );
if ( xShape.is() )
Expand Down
2 changes: 1 addition & 1 deletion chart2/source/controller/main/ChartTransferable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ bool ChartTransferable::WriteObject( tools::SvRef<SotStorageStream>& rxOStm, voi
for ( sal_uInt16 i = 0; i < nCount; ++i )
{
const SdrPage* pPage = pMarkedObjModel->GetPage( i );
SdrObjListIter aIter( *pPage, SdrIterMode::DeepNoGroups );
SdrObjListIter aIter( pPage, SdrIterMode::DeepNoGroups );
while ( aIter.IsMore() )
{
SdrObject* pObj = aIter.Next();
Expand Down
3 changes: 1 addition & 2 deletions chart2/source/controller/main/DrawCommandDispatch.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
pObj = SdrObjFactory::MakeNewObject(
pDrawModelWrapper->getSdrModel(),
pDrawViewWrapper->GetCurrentObjInventor(),
pDrawViewWrapper->GetCurrentObjIdentifier(),
pPage);
pDrawViewWrapper->GetCurrentObjIdentifier());

if ( pObj )
{
Expand Down
10 changes: 5 additions & 5 deletions chart2/source/controller/main/SelectionHelper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ bool SelectionHelper::findNamedParent( SdrObject*& pInOutObject
SdrObjList* pObjList = pObj->getParentOfSdrObject();
if( !pObjList )
return false;
SdrObject* pOwner = pObjList->GetOwnerObj();
SdrObject* pOwner = pObjList->getSdrObjectFromSdrObjList();
if( !pOwner )
return false;
pObj = pOwner;
Expand Down Expand Up @@ -483,7 +483,7 @@ SdrObject* SelectionHelper::getMarkHandlesObject( SdrObject* pObj )
SdrObjList* pSubList = pObj->GetSubList();
if(pSubList)
{
SdrObjListIter aIterator(*pSubList, SdrIterMode::Flat);
SdrObjListIter aIterator(pSubList, SdrIterMode::Flat);
while (aIterator.IsMore())
{
SdrObject* pMarkHandles = SelectionHelper::getMarkHandlesObject( aIterator.Next() );
Expand All @@ -508,7 +508,7 @@ SdrObject* SelectionHelper::getObjectToMark()
SdrObjList* pSubList = pObj->GetSubList();
if(pSubList)
{
SdrObjListIter aIterator(*pSubList, SdrIterMode::Flat);
SdrObjListIter aIterator(pSubList, SdrIterMode::Flat);
while (aIterator.IsMore())
{
SdrObject* pMarkHandles = SelectionHelper::getMarkHandlesObject( aIterator.Next() );
Expand Down Expand Up @@ -539,7 +539,7 @@ E3dScene* SelectionHelper::getSceneToRotate( SdrObject* pObj )
SdrObjList* pSubList = pObj->GetSubList();
if(pSubList)
{
SdrObjListIter aIterator(*pSubList, SdrIterMode::DeepWithGroups);
SdrObjListIter aIterator(pSubList, SdrIterMode::DeepWithGroups);
while( aIterator.IsMore() && !pRotateable )
{
SdrObject* pSubObj = aIterator.Next();
Expand Down Expand Up @@ -628,7 +628,7 @@ bool SelectionHelper::getMarkHandles( SdrHdlList& rHdlList )
return false;
}

SdrObjListIter aIterator(*pSubList, SdrIterMode::Flat);
SdrObjListIter aIterator(pSubList, SdrIterMode::Flat);

while (aIterator.IsMore())
{
Expand Down
2 changes: 1 addition & 1 deletion filter/source/msfilter/eschesdo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ ImplEESdrObject::ImplEESdrObject( ImplEESdrWriter& rEx,
mbEmptyPresObj( false ),
mbOOXML(bOOXML)
{
SdrPage* pPage = rObj.GetPage();
SdrPage* pPage = rObj.getSdrPageFromSdrObject();
DBG_ASSERT( pPage, "ImplEESdrObject::ImplEESdrObject: no SdrPage" );
if( pPage && rEx.ImplInitPage( *pPage ) )
{
Expand Down
2 changes: 1 addition & 1 deletion filter/source/msfilter/svdfppt.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7570,7 +7570,7 @@ SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, const sal_uInt32
std::set< sal_Int32 > aRows;
std::set< sal_Int32 > aColumns;

SdrObjListIter aGroupIter( *pSubList, SdrIterMode::DeepNoGroups, false );
SdrObjListIter aGroupIter( pSubList, SdrIterMode::DeepNoGroups, false );
while( aGroupIter.IsMore() )
{
const SdrObject* pObj( aGroupIter.Next() );
Expand Down
16 changes: 13 additions & 3 deletions include/svx/scene3d.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ protected:
public:
E3dScene(SdrModel& rSdrModel);

// derived from SdrObjList
virtual SdrPage* getSdrPageFromSdrObjList() const override;
virtual SdrObject* getSdrObjectFromSdrObjList() const override;
virtual SdrModel& getSdrModelFromSdrObjList() const override;

// derived from SdrObject
virtual SdrObjList* getChildrenOfSdrObject() const override;

virtual void SetBoundRectDirty() override;

// access to cleanup of depth mapper
Expand Down Expand Up @@ -180,10 +188,12 @@ public:
virtual SdrObject* RemoveObject(size_t nObjNum) override;

// needed for group functionality
virtual void SetRectsDirty(bool bNotMyself = false) override;
virtual void SetRectsDirty(bool bNotMyself = false, bool bRecursive = true) override;
virtual void NbcSetLayer(SdrLayerID nLayer) override;
virtual void setParentOfSdrObject(SdrObjList* pNewObjList) override;
virtual void SetPage(SdrPage* pNewPage) override;

// react on model/page change
virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;

virtual SdrObjList* GetSubList() const override;
void Insert3DObj(E3dObject* p3DObj);
void Remove3DObj(E3dObject const * p3DObj);
Expand Down
2 changes: 2 additions & 0 deletions include/svx/sdr/properties/properties.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ namespace sdr
SdrObject& mrObject;

protected:
// apply the correct SfyStyleSheet from SdrObject's SdrModel
virtual void applyDefaultStyleSheetFromSdrModel();

// create a new object specific itemset with object specific ranges.
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& pPool) = 0;
Expand Down
34 changes: 15 additions & 19 deletions include/svx/svditer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

class SdrObjList;
class SdrObject;
class SdrPage;
class SdrMarkList;

// SdrObjListIter methods:
Expand All @@ -37,41 +38,36 @@ enum class SdrIterMode { Flat, DeepWithGroups, DeepNoGroups };

class SVX_DLLPUBLIC SdrObjListIter
{
std::vector<SdrObject*> maObjList;
sal_uInt32 mnIndex;
bool mbReverse;
std::vector< const SdrObject* > maObjList;
size_t mnIndex;
bool mbReverse;
bool mbUseZOrder;

void ImpProcessObjectList(const SdrObjList& rObjList, SdrIterMode eMode, bool bUseZOrder);
void ImpProcessObjectList(const SdrObjList& rSdrObjList, SdrIterMode eMode);
void ImpProcessMarkList(const SdrMarkList& rMarkList, SdrIterMode eMode);
void ImpProcessObj(SdrObject* pObj, SdrIterMode eMode, bool bUseZOrder);
void ImpProcessObj(const SdrObject& rSdrObject, SdrIterMode eMode);

public:
explicit SdrObjListIter(const SdrObjList& rObjList, SdrIterMode eMode = SdrIterMode::DeepNoGroups, bool bReverse = false);
/** This variant lets the user choose the order in which to travel over
the objects.
@param bUseZOrder
When <TRUE/> then the z-order defines the order of iteration.
Otherwise the navigation position as returned by
SdrObject::GetNavigationPosition() is used.
*/
SdrObjListIter(const SdrObjList& rObjList, bool bUseZOrder, SdrIterMode eMode);
explicit SdrObjListIter(const SdrObjList* pObjList, SdrIterMode eMode = SdrIterMode::DeepNoGroups, bool bReverse = false);
explicit SdrObjListIter(const SdrObjList* pObjList, bool bUseZOrder, SdrIterMode eMode = SdrIterMode::DeepNoGroups, bool bReverse = false);

/* SJ: the following function can now be used with every
SdrObject and is no longer limited to group objects */
explicit SdrObjListIter(const SdrObject& rObj, SdrIterMode eMode = SdrIterMode::DeepNoGroups);
explicit SdrObjListIter(const SdrObject& rSdrObject, SdrIterMode eMode = SdrIterMode::DeepNoGroups, bool bReverse = false);
explicit SdrObjListIter(const SdrPage* pSdrPage, SdrIterMode eMode = SdrIterMode::DeepNoGroups, bool bReverse = false);

/** Iterates over a list of marked objects received from the SdrMarkView. */
/** Iterates over a list of marked objects received from the SdrMarkView. TTTT used in sc */
explicit SdrObjListIter(const SdrMarkList& rMarkList, SdrIterMode eMode = SdrIterMode::DeepNoGroups);

void Reset() { mnIndex = (mbReverse ? maObjList.size() : 0L); }
bool IsMore() const { return (mbReverse ? mnIndex != 0 : ( mnIndex < maObjList.size())); }
SdrObject* Next()
{
sal_uInt32 idx = (mbReverse ? --mnIndex : mnIndex++);
return idx < maObjList.size() ? maObjList[idx] : nullptr;
const size_t idx(mbReverse ? --mnIndex : mnIndex++);
return (idx < maObjList.size()) ? const_cast< SdrObject* >(maObjList[idx]) : nullptr;
}

sal_uInt32 Count() { return maObjList.size(); }
size_t Count() { return maObjList.size(); }
};

#endif // INCLUDED_SVX_SVDITER_HXX
Expand Down
3 changes: 2 additions & 1 deletion include/svx/svdoashp.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ public:

virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;

virtual void SetPage( SdrPage* pNewPage ) override;
// react on model/page change
virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;

virtual SdrObjGeoData *NewGeoData() const override;
virtual void SaveGeoData(SdrObjGeoData &rGeo) const override;
Expand Down
27 changes: 16 additions & 11 deletions include/svx/svdobj.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,20 @@ public:
// A SdrObject always needs a SdrModel for lifetime (Pool, ...)
SdrObject(SdrModel& rSdrModel);

// SdrModel access on SdrObject level
SdrModel& getSdrModelFromSdrObject() const { return mrSdrModelFromSdrObject; }
// SdrModel/SdrPage access on SdrObject level
virtual SdrPage* getSdrPageFromSdrObject() const;
SdrModel& getSdrModelFromSdrObject() const;
SdrObjList* getParentOfSdrObject() const;
virtual SdrObjList* getChildrenOfSdrObject() const;

private:
// only allow SetParentAtSdrObjectFromSdrObjList to call setParentOfSdrObject
friend void SetParentAtSdrObjectFromSdrObjList(SdrObject& rSdrObject, SdrObjList* pNew);
SVX_DLLPRIVATE void setParentOfSdrObject(SdrObjList* pNew);

public:
// react on model/page change
virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage);

void AddObjectUser(sdr::ObjectUser& rNewUser);
void RemoveObjectUser(sdr::ObjectUser& rOldUser);
Expand Down Expand Up @@ -372,7 +384,7 @@ public:
///
/// This is needed for instance for NbcMove, because usually one moves SnapRect and aOutRect
/// at the same time to avoid recomputation.
virtual void SetRectsDirty(bool bNotMyself = false);
virtual void SetRectsDirty(bool bNotMyself = false, bool bRecursive = true);

// frees the SdrObject pointed to by the argument
// In case the object has an SvxShape, which has the ownership of the object, it
Expand All @@ -382,11 +394,6 @@ public:
// this method is only for access from Property objects
virtual void SetBoundRectDirty();

virtual void setParentOfSdrObject(SdrObjList* pNewObjList);
SdrObjList* getParentOfSdrObject() const { return mpParentOfSdrObject;}

virtual void SetPage(SdrPage* pNewPage);
SdrPage* GetPage() const { return pPage;}
SfxItemPool & GetObjectItemPool() const;

void AddListener(SfxListener& rListener);
Expand Down Expand Up @@ -906,9 +913,8 @@ public:
const css::uno::WeakReference< css::uno::XInterface >& getWeakUnoShape() const { return maWeakUnoShape; }

protected:
tools::Rectangle aOutRect; // surrounding rectangle for Paint (incl. LineWdt, ...)
tools::Rectangle aOutRect; // surrounding rectangle for Paint (incl. LineWdt, ...)
Point aAnchor; // anchor position (Writer)
SdrPage* pPage;
SdrObjUserCall* pUserCall;
std::unique_ptr<SdrObjPlusData>
pPlusData; // Broadcaster, UserData, connectors, ... (this is the Bitsack)
Expand Down Expand Up @@ -1071,7 +1077,6 @@ public:
SdrModel& rSdrModel,
SdrInventor nInventor,
sal_uInt16 nObjIdentifier,
SdrPage* pPage = nullptr,
const tools::Rectangle* pSnapRect = nullptr);

static void InsertMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> const & rLink);
Expand Down
3 changes: 3 additions & 0 deletions include/svx/svdoedge.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ protected:
public:
SdrEdgeObj(SdrModel& rSdrModel);

// react on model/page change
virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;

SdrObjConnection& GetConnection(bool bTail1) { return *(bTail1 ? &aCon1 : &aCon2); }
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual sal_uInt16 GetObjIdentifier() const override;
Expand Down
3 changes: 2 additions & 1 deletion include/svx/svdograf.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ public:

bool HasGDIMetaFile() const;

virtual void SetPage(SdrPage* pNewPage) override;
// react on model/page change
virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;

bool isEmbeddedVectorGraphicData() const;
GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() const;
Expand Down
17 changes: 13 additions & 4 deletions include/svx/svdogrp.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
class SfxItemSet;

// SdrObjGroup
class SVX_DLLPUBLIC SdrObjGroup final : public SdrObject
class SVX_DLLPUBLIC SdrObjGroup final : public SdrObject, public SdrObjList
{
private:
virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override;

SdrObjList maSdrObjList; // sub list (children)
Point aRefPoint; // Reference point inside the object group

private:
Expand All @@ -45,13 +44,23 @@ private:
public:
SdrObjGroup(SdrModel& rSdrModel);

// derived from SdrObjList
virtual SdrPage* getSdrPageFromSdrObjList() const override;
virtual SdrObject* getSdrObjectFromSdrObjList() const override;
virtual SdrModel& getSdrModelFromSdrObjList() const override;

// derived from SdrObject
virtual SdrObjList* getChildrenOfSdrObject() const override;

virtual void SetBoundRectDirty() override;
virtual sal_uInt16 GetObjIdentifier() const override;
virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual SdrLayerID GetLayer() const override;
virtual void NbcSetLayer(SdrLayerID nLayer) override;
virtual void setParentOfSdrObject(SdrObjList* pNewObjList) override;
virtual void SetPage(SdrPage* pNewPage) override;

// react on model/page change
virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;

virtual SdrObjList* GetSubList() const override;

virtual const tools::Rectangle& GetCurrentBoundRect() const override;
Expand Down
3 changes: 2 additions & 1 deletion include/svx/svdoole2.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ public:

void AbandonObject();

virtual void SetPage(SdrPage* pNewPage) override;
// react on model/page change
virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;

/** Change the IsClosedObj attribute
Expand Down
4 changes: 3 additions & 1 deletion include/svx/svdotext.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,9 @@ public:
SdrTextAniKind GetTextAniKind() const;
SdrTextAniDirection GetTextAniDirection() const;

virtual void SetPage(SdrPage* pNewPage) override;
// react on model/page change
virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;

virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
virtual sal_uInt16 GetObjIdentifier() const override;

Expand Down
Loading

0 comments on commit 4b49422

Please sign in to comment.