summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de (CIB)>2018-03-01 15:54:32 +0100
committerArmin Le Grand <Armin.Le.Grand@cib.de>2018-04-07 00:28:30 +0200
commitdfefe448c41921f2f1e54d3f69b8b9e89031d055 (patch)
tree1aace31054b5740e2faffcbc5de66a791be27f7d /filter
parenteba4d5b2b76cefde90cb3d6638c736f435023a45 (diff)
SOSAW080: Added first bunch of basic changes to helpers
SOSAW080: Make SdrModel& prerequisite to SdrObjects Added need for SdrModel& in constructors of SdrModel, SdrPage, SdrView and SdrObjList. Builds, not finished. SOSAW080: removed and replaced old SdrModel Removed and replaced GetModel()/SetModel() in all using classes (SdrObject, SdrPage, SdrView), added accessors to new referenced SdrModel, adapted all accessing places. Refactored/Extended ::Clone and ::operator== for these classes to allow cloning objects to a target SdrModel. Adapted places where this is done AFAP. Added quite some comments (tagged with 'TTTT') where possible further work is needed. Builds completely, thus checking in. This does not mean that this change is done yet. SOSAW080: Adapted SdrPage/SdrModel relationship Also needed to work on copy-construction of SdrPage and hierarchy, quite some stuff removed, no copy-constructor anymore, no MigrateItemPool stuff. Builds well, test stuck, will need some cleanup/finetunung SOSAW080: Smaller corrections/includes adapted SOSAW080: Smaller corrections/includes adapted SOSAW080: Debugging/Stabilizing/MakeUnitTestWork SOSAW080: Stabilized for UnitTests, cleanups SOSAW080: Adapted GetObjGraphic to just take a const SdrObject& SOSAW080: Removed ChangeModel from classes Classes SvxTextEditSource and SvxDrawPage (including TextEditSource stuff) do not need change of SdrModel anymore. SOSAW080: Adapted some comments to make more readable SOSAW080: Corrected constructor SOSAW080: getSdrModelFromUnoModel added override marks SOSAW080: Added missing includes SOSAW080: Corrected SdrPage constructor SOSAW080: Corrected some SdrObject::Clone scenarios Especially when cloning to another SdrModel and taking the sdr::properties into account. SOSAW080: Added include for Mac-Build SOSAW080: Added Scale to DefaultProperties If a SdrModel change happens in DefaultProperties copy constructor (used from Clone()), potentially a Scale for the SfxItems has to be done. SOSAW080: Added missing include for MacBuild SOSAW080: Corrected CppunitTest_sc_anchor_test An adaption of a SdrPathObj instantiation was missing, added that. Seems as if that test is no tpart of the usual 'make' scenario, but used/executed in gerrit builds SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Free SdrObjects when SdrModel goes down In an UNO API test problem is that SvxShapes reference SdrShapes, but these are not added to a SdrPage and not 'owned' by the SvxShape. Thus these do not get deleted at all (same in master, memory leak). I extended SvxShape::Notify the case for ModelCleared to also Free the SdrObject when not owner and it's not added to a SdrPage (in that case it gets deleted with deleting the SdrModel) SOSAW080: Solve UNO API calls that move SvxShapes to other Model Due to UNO API tests I got a call to insert an xShape to a xDrawPage which was constructed in another Model, this has now to be done by Cloning the SdrObject to the new SdrModel, getting rid of the old one and getting all the UNO implementation stuff right (referemces SdrObject <-> xShape). 1cb7d573d323e98a89761fe662c10c4a654fdec0 24617494a0ef79f6e33dfcb02782a833a81c6434 763f39094b6a48b529a6952d01468f8776c97679 242b9e228a9a042c3a5bdd38b1ea6600144276d5 242b9e228a9a042c3a5bdd38b1ea6600144276d5 33a6f3f306b70c223171aef796dd5ee041ad14df 6878b33f8b05738a44c0910e40a60a0f0d1d58ed 0a636caf3cb36c2f9c6cd11aa22cb9bc435dc8f2 8c4626274a5cc531dad27f27c0c45d4c528fb2fb 446685a49a6d67aedd01cfbbd5e87b07f97a4d7b c1b5ed3c99bc7219a0061e4ece24ea42afd2889a 22de9a1c8af7c25be5c108671ddc548ba323ed47 4caf6b6fbbe6e8130741d793dffb560fd01d4ed5 488b9601735ec1822433f82f633990063951fe08 c366d60299f239e3df856ddffedb19e743e4be0c c5137ba8c597c7b5f90318df50e87b93a39a28dc f9e646242cf89f6fde1315046952252a2c429779 f830fbc5fadd89d04be5edd2a5abf9b0d4bf0410 1694b54903df784385abaa8452e1201e12344238 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 7b5c241faec7488924e5935ae8b19f785846b5e4 bf097ee7467895823fbd158a2a9543da3b5a5078 Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c Reviewed-on: https://gerrit.libreoffice.org/52526 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/msfilter/escherex.cxx5
-rw-r--r--filter/source/msfilter/msdffimp.cxx86
-rw-r--r--filter/source/msfilter/svdfppt.cxx39
-rw-r--r--filter/source/svg/svgexport.cxx14
4 files changed, 91 insertions, 53 deletions
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 0eb9efe66e86..3b3fc0562bf5 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -3774,10 +3774,9 @@ bool EscherPropertyContainer::CreateBlipPropertiesforOLEControl(const uno::Refer
SdrObject* pShape = GetSdrObjectFromXShape( rXShape );
if ( pShape )
{
- SdrModel* pMod = pShape->GetModel();
- Graphic aGraphic(SdrExchangeView::GetObjGraphic( pMod, pShape));
+ const Graphic aGraphic(SdrExchangeView::GetObjGraphic(*pShape));
+ const GraphicObject aGraphicObject(aGraphic);
- GraphicObject aGraphicObject(aGraphic);
if (!aGraphicObject.GetUniqueID().isEmpty())
{
if ( pGraphicProvider && pPicOutStrm && pShapeBoundRect )
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index ac281e0bfdd1..e958c813068c 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3955,7 +3955,7 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
}
if( !pRet )
{
- pRet = new SdrGrafObj;
+ pRet = new SdrGrafObj(*pSdrModel);
if( bGrfRead )
static_cast<SdrGrafObj*>(pRet)->SetGraphic( aGraf );
@@ -3997,7 +3997,6 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
pRet->SetName( aFileName );
}
}
- pRet->SetModel( pSdrModel ); // required for GraphicLink
pRet->SetLogicRect( rObjData.aBoundRect );
if ( dynamic_cast<const SdrGrafObj* >(pRet) != nullptr )
@@ -4307,7 +4306,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
if ( aObjData.nSpFlags & ShapeFlag::Group )
{
- pRet = new SdrObjGroup;
+ pRet = new SdrObjGroup(*pSdrModel);
/* After CWS aw033 has been integrated, an empty group object
cannot store its resulting bounding rectangle anymore. We have
to return this rectangle via rClientRect now, but only, if
@@ -4337,8 +4336,10 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
basegfx::B2DPolygon aPoly;
aPoly.append(basegfx::B2DPoint(aObjData.aBoundRect.Left(), aObjData.aBoundRect.Top()));
aPoly.append(basegfx::B2DPoint(aObjData.aBoundRect.Right(), aObjData.aBoundRect.Bottom()));
- pRet = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly));
- pRet->SetModel( pSdrModel );
+ pRet = new SdrPathObj(
+ *pSdrModel,
+ OBJ_LINE,
+ basegfx::B2DPolyPolygon(aPoly));
ApplyAttributes( rSt, aSet, aObjData );
pRet->SetMergedItemSet(aSet);
}
@@ -4349,8 +4350,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
ApplyAttributes( rSt, aSet, aObjData );
- pRet = new SdrObjCustomShape();
- pRet->SetModel( pSdrModel );
+ pRet = new SdrObjCustomShape(*pSdrModel);
sal_uInt32 ngtextFStrikethrough = GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 );
bool bIsFontwork = ( ngtextFStrikethrough & 0x4000 ) != 0;
@@ -4471,9 +4471,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
{
SdrOutliner& rOutliner = static_cast<SdrObjCustomShape*>(pRet)->ImpGetDrawOutliner();
bool bOldUpdateMode = rOutliner.GetUpdateMode();
- SdrModel* pModel = pRet->GetModel();
- if ( pModel )
- rOutliner.SetStyleSheetPool( static_cast<SfxStyleSheetPool*>(pModel->GetStyleSheetPool()) );
+ rOutliner.SetStyleSheetPool(static_cast< SfxStyleSheetPool* >(pRet->getSdrModelFromSdrObject().GetStyleSheetPool()));
rOutliner.SetUpdateMode( false );
rOutliner.SetText( *pParaObj );
ScopedVclPtrInstance< VirtualDevice > pVirDev(DeviceFormat::BITMASK);
@@ -4735,7 +4733,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
basegfx::B2DPolyPolygon aPoly( static_cast<SdrObjCustomShape*>(pRet)->GetLineGeometry( true ) );
SdrObject::Free( pRet );
- pRet = new SdrEdgeObj();
+ pRet = new SdrEdgeObj(*pSdrModel);
ApplyAttributes( rSt, aSet, aObjData );
pRet->SetLogicRect( aObjData.aBoundRect );
pRet->SetMergedItemSet(aSet);
@@ -5235,7 +5233,10 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
}
}
- pTextObj = new SdrRectObj(OBJ_TEXT, rTextRect);
+ pTextObj = new SdrRectObj(
+ *pSdrModel,
+ OBJ_TEXT,
+ rTextRect);
pTextImpRec = new SvxMSDffImportRec(*pImpRec);
bDeleteTextImpRec = true;
@@ -5364,7 +5365,6 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
}
pTextObj->SetMergedItemSet(aSet);
- pTextObj->SetModel(pSdrModel);
if (bVerticalText)
pTextObj->SetVerticalWriting(true);
@@ -5397,7 +5397,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
{
if( pTextObj != pObj )
{
- SdrObject* pGroup = new SdrObjGroup;
+ SdrObject* pGroup = new SdrObjGroup(*pSdrModel);
pGroup->GetSubList()->NbcInsertObject( pObj );
pGroup->GetSubList()->NbcInsertObject( pTextObj );
if (pOrgObj == pObj)
@@ -5413,9 +5413,11 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
// simple rectangular objects are ignored by ImportObj() :-(
// this is OK for Draw but not for Calc and Writer
// cause here these objects have a default border
- pObj = new SdrRectObj(rTextRect);
+ pObj = new SdrRectObj(
+ *pSdrModel,
+ rTextRect);
+
pOrgObj = pObj;
- pObj->SetModel( pSdrModel );
SfxItemSet aSet( pSdrModel->GetItemPool() );
ApplyAttributes( rSt, aSet, rObjData );
@@ -6615,9 +6617,19 @@ SdrObject* SvxMSDffManager::ImportOLE( sal_uInt32 nOLEId,
ErrCode nError = ERRCODE_NONE;
uno::Reference < embed::XStorage > xDstStg;
if( GetOLEStorageName( nOLEId, sStorageName, xSrcStg, xDstStg ))
- pRet = CreateSdrOLEFromStorage( sStorageName, xSrcStg, xDstStg,
- rGrf, rBoundRect, rVisArea, pStData, nError,
- nSvxMSDffOLEConvFlags, embed::Aspects::MSOLE_CONTENT, maBaseURL);
+ pRet = CreateSdrOLEFromStorage(
+ *GetModel(),
+ sStorageName,
+ xSrcStg,
+ xDstStg,
+ rGrf,
+ rBoundRect,
+ rVisArea,
+ pStData,
+ nError,
+ nSvxMSDffOLEConvFlags,
+ embed::Aspects::MSOLE_CONTENT,
+ maBaseURL);
return pRet;
}
@@ -7106,17 +7118,18 @@ css::uno::Reference < css::embed::XEmbeddedObject > SvxMSDffManager::CheckForCo
// TODO/MBA: code review and testing!
SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage(
- const OUString& rStorageName,
- tools::SvRef<SotStorage> const & rSrcStorage,
- const uno::Reference < embed::XStorage >& xDestStorage,
- const Graphic& rGrf,
- const tools::Rectangle& rBoundRect,
- const tools::Rectangle& rVisArea,
- SvStream* pDataStrm,
- ErrCode& rError,
- sal_uInt32 nConvertFlags,
- sal_Int64 nRecommendedAspect,
- OUString const& rBaseURL)
+ SdrModel& rSdrModel,
+ const OUString& rStorageName,
+ tools::SvRef<SotStorage> const & rSrcStorage,
+ const uno::Reference < embed::XStorage >& xDestStorage,
+ const Graphic& rGrf,
+ const tools::Rectangle& rBoundRect,
+ const tools::Rectangle& rVisArea,
+ SvStream* pDataStrm,
+ ErrCode& rError,
+ sal_uInt32 nConvertFlags,
+ sal_Int64 nRecommendedAspect,
+ OUString const& rBaseURL)
{
sal_Int64 nAspect = nRecommendedAspect;
SdrOle2Obj* pRet = nullptr;
@@ -7184,7 +7197,12 @@ SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage(
aObj.SetGraphic( rGrf, OUString() );
// TODO/MBA: check setting of PersistName
- pRet = new SdrOle2Obj( aObj, OUString(), rBoundRect);
+ pRet = new SdrOle2Obj(
+ rSdrModel,
+ aObj,
+ OUString(),
+ rBoundRect);
+
// we have the Object, don't create another
bValidStorage = false;
}
@@ -7280,7 +7298,11 @@ SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage(
// TODO/LATER: need MediaType
aObj.SetGraphic( rGrf, OUString() );
- pRet = new SdrOle2Obj( aObj, aDstStgName, rBoundRect);
+ pRet = new SdrOle2Obj(
+ rSdrModel,
+ aObj,
+ aDstStgName,
+ rBoundRect);
}
}
}
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 22d21cb1a74e..5758ca606a1b 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -807,7 +807,10 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
// replacing the object which we will return with a SdrPageObj
SdrObject::Free( pRet );
- pRet = new SdrPageObj( rObjData.aBoundRect, pSdrModel->GetPage( nPageNum - 1 ) );
+ pRet = new SdrPageObj(
+ *pSdrModel,
+ rObjData.aBoundRect,
+ pSdrModel->GetPage(nPageNum - 1));
}
else
{
@@ -1069,8 +1072,9 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
SdrObject::Free( pRet );
pRet = nullptr;
}
- pTObj = new SdrRectObj( eTextKind != OBJ_RECT ? eTextKind : OBJ_TEXT );
- pTObj->SetModel( pSdrModel );
+ pTObj = new SdrRectObj(
+ *pSdrModel,
+ eTextKind != OBJ_RECT ? eTextKind : OBJ_TEXT);
SfxItemSet aSet( pSdrModel->GetItemPool() );
if ( !pRet )
ApplyAttributes( rSt, aSet, rObjData );
@@ -1197,7 +1201,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
}
if ( pRet )
{
- SdrObject* pGroup = new SdrObjGroup;
+ SdrObject* pGroup = new SdrObjGroup(*pSdrModel);
pGroup->GetSubList()->NbcInsertObject( pRet );
pGroup->GetSubList()->NbcInsertObject( pTObj );
pRet = pGroup;
@@ -1880,7 +1884,11 @@ SdrObject* SdrPowerPointImport::ImportOLE( sal_uInt32 nOLEId,
// TODO/LATER: need MediaType for Graphic
aObj.SetGraphic( rGraf, OUString() );
- pRet = new SdrOle2Obj( aObj, aNm, rBoundRect );
+ pRet = new SdrOle2Obj(
+ *pSdrModel,
+ aObj,
+ aNm,
+ rBoundRect);
}
}
if ( !pRet && ( rOe.nType == PPT_PST_ExControl ) )
@@ -1943,7 +1951,11 @@ SdrObject* SdrPowerPointImport::ImportOLE( sal_uInt32 nOLEId,
// TODO/LATER: need MediaType for Graphic
aObj.SetGraphic( aGraphic, OUString() );
- pRet = new SdrOle2Obj( aObj, aNm, rBoundRect );
+ pRet = new SdrOle2Obj(
+ *pSdrModel,
+ aObj,
+ aNm,
+ rBoundRect);
}
}
}
@@ -3062,12 +3074,17 @@ SdrObject* SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage
pSet->Put( XFillStyleItem( drawing::FillStyle_NONE ) );
}
pSet->Put( XLineStyleItem( drawing::LineStyle_NONE ) );
- tools::Rectangle aRect( rPage.GetLeftBorder(), rPage.GetUpperBorder(), rPage.GetWidth()-rPage.GetRightBorder(), rPage.GetHeight()-rPage.GetLowerBorder() );
- pRet = new SdrRectObj( aRect );
- pRet->SetModel( pSdrModel );
+ tools::Rectangle aRect(
+ rPage.GetLeftBorder(),
+ rPage.GetUpperBorder(),
+ rPage.GetWidth() - rPage.GetRightBorder(),
+ rPage.GetHeight() - rPage.GetLowerBorder());
- pRet->SetMergedItemSet(*pSet);
+ pRet = new SdrRectObj(
+ *pSdrModel,
+ aRect);
+ pRet->SetMergedItemSet(*pSet);
pRet->SetMarkProtect( true );
pRet->SetMoveProtect( true );
pRet->SetResizeProtect( true );
@@ -7572,7 +7589,7 @@ SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, const sal_uInt32
if (aRows.empty())
return pRet;
- sdr::table::SdrTableObj* pTable = new sdr::table::SdrTableObj( pSdrModel );
+ sdr::table::SdrTableObj* pTable = new sdr::table::SdrTableObj(*pSdrModel);
pTable->uno_lock();
Reference< XTable > xTable( pTable->getTable() );
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index e923eb92c021..056c1c7fa5c9 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -560,9 +560,9 @@ bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
if( pSvxDrawPage )
{
mpDefaultSdrPage = pSvxDrawPage->GetSdrPage();
- mpSdrModel = mpDefaultSdrPage->GetModel();
+ mpSdrModel = &mpDefaultSdrPage->getSdrModelFromSdrPage();
- if( mpSdrModel )
+ if( mpSdrModel ) // TTTT should be reference
{
SdrOutliner& rOutl = mpSdrModel->GetDrawOutliner();
@@ -921,8 +921,8 @@ void SVGFilter::implGenerateMetaData()
if( pSvxDrawPage )
{
SdrPage* pSdrPage = pSvxDrawPage->GetSdrPage();
- SdrModel* pSdrModel = pSdrPage->GetModel();
- nPageNumberingType = pSdrModel->GetPageNumType();
+ SdrModel& rSdrModel(pSdrPage->getSdrModelFromSdrPage());
+ nPageNumberingType = rSdrModel.GetPageNumType();
// That is used by CalcFieldHdl method.
mVisiblePagePropSet.nPageNumberingType = nPageNumberingType;
@@ -1384,8 +1384,8 @@ void SVGFilter::implGetPagePropSet( const Reference< css::drawing::XDrawPage > &
if( pSvxDrawPage )
{
SdrPage* pSdrPage = pSvxDrawPage->GetSdrPage();
- SdrModel* pSdrModel = pSdrPage->GetModel();
- mVisiblePagePropSet.nPageNumberingType = pSdrModel->GetPageNumType();
+ SdrModel& rSdrModel(pSdrPage->getSdrModelFromSdrPage());
+ mVisiblePagePropSet.nPageNumberingType = rSdrModel.GetPageNumType();
}
}
}
@@ -1931,7 +1931,7 @@ bool SVGFilter::implCreateObjectsFromShape( const Reference< css::drawing::XDraw
if( pObj )
{
- Graphic aGraphic( SdrExchangeView::GetObjGraphic( pObj->GetModel(), pObj ) );
+ const Graphic aGraphic(SdrExchangeView::GetObjGraphic(*pObj));
if( aGraphic.GetType() != GraphicType::NONE )
{