summaryrefslogtreecommitdiff
path: root/svx/source/table
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 /svx/source/table
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 'svx/source/table')
-rw-r--r--svx/source/table/cell.cxx120
-rw-r--r--svx/source/table/cellcursor.cxx23
-rw-r--r--svx/source/table/svdotable.cxx125
-rw-r--r--svx/source/table/tablecolumn.cxx8
-rw-r--r--svx/source/table/tablecontroller.cxx981
-rw-r--r--svx/source/table/tablemodel.cxx74
-rw-r--r--svx/source/table/tablerow.cxx18
-rw-r--r--svx/source/table/tablertfimporter.cxx4
-rw-r--r--svx/source/table/tableundo.cxx54
9 files changed, 705 insertions, 702 deletions
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index cd1973848746..0f733d0c6e5d 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -392,21 +392,31 @@ rtl::Reference< Cell > Cell::create( SdrTableObj& rTableObj )
}
-Cell::Cell( SdrTableObj& rTableObj )
-: SdrText( rTableObj )
-, SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
-, mpPropSet( ImplGetSvxCellPropertySet() )
-, mpProperties( new sdr::properties::CellProperties( rTableObj, this ) )
-, mnCellContentType( CellContentType_EMPTY )
-, mfValue( 0.0 )
-, mnError( 0 )
-, mbMerged( false )
-, mnRowSpan( 1 )
-, mnColSpan( 1 )
-, mxTable( rTableObj.getTable() )
-{
- if( rTableObj.GetModel() )
- SetModel( rTableObj.GetModel() );
+Cell::Cell(
+ SdrTableObj& rTableObj)
+: SdrText(rTableObj)
+ ,SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
+ ,mpPropSet( ImplGetSvxCellPropertySet() )
+ ,mpProperties( new sdr::properties::CellProperties( rTableObj, this ) )
+ ,mnCellContentType( CellContentType_EMPTY )
+ ,mfValue( 0.0 )
+ ,mnError( 0 )
+ ,mbMerged( false )
+ ,mnRowSpan( 1 )
+ ,mnColSpan( 1 )
+ ,mxTable( rTableObj.getTable() )
+{
+ // Caution: Old SetModel() indirectly did a very necessary thing here,
+ // it created a valid SvxTextEditSource which is needed to bind contained
+ // Text to the UNO API and thus to save/load and more. Added version without
+ // model change.
+ // Also done was (not needed, for reference):
+ // SetStyleSheet( nullptr, true );
+ // ForceOutlinerParaObject( OutlinerMode::TextObject );
+ if(nullptr == GetEditSource())
+ {
+ SetEditSource(new SvxTextEditSource(&GetObject(), this));
+ }
}
@@ -440,37 +450,6 @@ void Cell::dispose()
SetOutlinerParaObject( nullptr );
}
-
-void Cell::SetModel(SdrModel* pNewModel)
-{
- SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( GetEditSource() );
- if( (GetModel() != pNewModel) || ( pNewModel && !pTextEditSource) )
- {
- if( mpProperties )
- {
- SfxItemPool* pItemPool = mpProperties->GetObjectItemSet().GetPool();
-
- // test for correct pool in ItemSet; move to new pool if necessary
- if( pNewModel && pItemPool && pItemPool != &pNewModel->GetItemPool())
- mpProperties->MoveToItemPool(pItemPool, &pNewModel->GetItemPool(), pNewModel);
- }
-
- if( pTextEditSource )
- {
- pTextEditSource->ChangeModel( pNewModel );
- }
- else
- {
- SetEditSource( new SvxTextEditSource( &GetObject(), this ) );
- }
-
- SetStyleSheet( nullptr, true );
- SdrText::SetModel( pNewModel );
- ForceOutlinerParaObject( OutlinerMode::TextObject );
- }
-}
-
-
void Cell::merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan )
{
if ((mnColSpan != nColumnSpan) || (mnRowSpan != nRowSpan) || mbMerged)
@@ -537,12 +516,13 @@ void Cell::replaceContentAndFormating( const CellRef& xSourceCell )
{
mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() );
SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell->GetOutlinerParaObject()) );
-
SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() );
- if(rSourceTableObj.GetModel() != rTableObj.GetModel())
+ if(&rSourceTableObj.getSdrModelFromSdrObject() != &rTableObj.getSdrModelFromSdrObject())
{
+ // TTTT should not happen - if, then a clone may be needed
+ // Maybe add a assertion here later
SetStyleSheet( nullptr, true );
}
}
@@ -564,12 +544,13 @@ void Cell::copyFormatFrom( const CellRef& xSourceCell )
if( xSourceCell.is() && mpProperties )
{
mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() );
-
SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() );
- if(rSourceTableObj.GetModel() != rTableObj.GetModel())
+ if(&rSourceTableObj.getSdrModelFromSdrObject() != &rTableObj.getSdrModelFromSdrObject())
{
+ // TTTT should not happen - if, then a clone may be needed
+ // Maybe add a assertion here later
SetStyleSheet( nullptr, true );
}
@@ -812,10 +793,11 @@ void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
void Cell::AddUndo()
{
SdrObject& rObj = GetObject();
- if( rObj.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() )
+
+ if( rObj.IsInserted() && rObj.getSdrModelFromSdrObject().IsUndoEnabled() )
{
CellRef xCell( this );
- GetModel()->AddUndo( new CellUndo( &rObj, xCell ) );
+ rObj.getSdrModelFromSdrObject().AddUndo( new CellUndo( &rObj, xCell ) );
// Undo action for the after-text-edit-ended stack.
SdrTableObj* pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(&rObj);
@@ -1019,7 +1001,7 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any&
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
@@ -1111,7 +1093,7 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any&
}
default:
{
- SfxItemSet aSet( GetModel()->GetItemPool(), {{pMap->nWID, pMap->nWID}});
+ SfxItemSet aSet(GetObject().getSdrModelFromSdrObject().GetItemPool(), {{pMap->nWID, pMap->nWID}});
aSet.Put(mpProperties->GetItem(pMap->nWID));
bool bSpecial = false;
@@ -1131,7 +1113,7 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any&
OUString aApiName;
if( rValue >>= aApiName )
{
- if( SvxShape::SetFillAttribute( pMap->nWID, aApiName, aSet, GetModel() ) )
+ if(SvxShape::SetFillAttribute(pMap->nWID, aApiName, aSet, &GetObject().getSdrModelFromSdrObject()))
bSpecial = true;
}
}
@@ -1148,7 +1130,7 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any&
{
// fetch the default from ItemPool
if(SfxItemPool::IsWhich(pMap->nWID))
- aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
+ aSet.Put(GetObject().getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID));
}
if( aSet.GetItemState( pMap->nWID ) == SfxItemState::SET )
@@ -1158,7 +1140,7 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any&
}
}
- GetModel()->SetChanged();
+ GetObject().getSdrModelFromSdrObject().SetChanged();
mpProperties->SetMergedItemSetAndBroadcast( aSet );
return;
}
@@ -1172,7 +1154,7 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName )
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
@@ -1231,7 +1213,7 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName )
}
default:
{
- SfxItemSet aSet( GetModel()->GetItemPool(), {{pMap->nWID, pMap->nWID}});
+ SfxItemSet aSet(GetObject().getSdrModelFromSdrObject().GetItemPool(), {{pMap->nWID, pMap->nWID}});
aSet.Put(mpProperties->GetItem(pMap->nWID));
Any aAny;
@@ -1241,7 +1223,7 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName )
{
// fetch the default from ItemPool
if(SfxItemPool::IsWhich(pMap->nWID))
- aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
+ aSet.Put(GetObject().getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID));
}
if( aSet.Count() )
@@ -1283,7 +1265,7 @@ void SAL_CALL Cell::setPropertyValues( const Sequence< OUString >& aPropertyName
{
::SolarMutexGuard aSolarGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const sal_Int32 nCount = aPropertyNames.getLength();
@@ -1313,7 +1295,7 @@ Sequence< Any > SAL_CALL Cell::getPropertyValues( const Sequence< OUString >& aP
{
::SolarMutexGuard aSolarGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const sal_Int32 nCount = aPropertyNames.getLength();
@@ -1364,7 +1346,7 @@ PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName )
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
@@ -1467,7 +1449,7 @@ Sequence< PropertyState > SAL_CALL Cell::getPropertyStates( const Sequence< OUSt
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const sal_Int32 nCount = aPropertyName.getLength();
@@ -1497,7 +1479,7 @@ void SAL_CALL Cell::setPropertyToDefault( const OUString& PropertyName )
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
@@ -1527,7 +1509,7 @@ void SAL_CALL Cell::setPropertyToDefault( const OUString& PropertyName )
}
}
- GetModel()->SetChanged();
+ GetObject().getSdrModelFromSdrObject().SetChanged();
return;
}
throw UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this));
@@ -1538,7 +1520,7 @@ Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName )
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
@@ -1565,8 +1547,8 @@ Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName )
{
if( SfxItemPool::IsWhich(pMap->nWID) )
{
- SfxItemSet aSet( GetModel()->GetItemPool(), {{pMap->nWID, pMap->nWID}});
- aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
+ SfxItemSet aSet(GetObject().getSdrModelFromSdrObject().GetItemPool(), {{pMap->nWID, pMap->nWID}});
+ aSet.Put(GetObject().getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID));
return GetAnyForItem( aSet, pMap );
}
}
diff --git a/svx/source/table/cellcursor.cxx b/svx/source/table/cellcursor.cxx
index db68fdb61ab4..b6368837cfc5 100644
--- a/svx/source/table/cellcursor.cxx
+++ b/svx/source/table/cellcursor.cxx
@@ -242,11 +242,11 @@ void SAL_CALL CellCursor::merge( )
if( !mxTable.is() || (mxTable->getSdrTableObj() == nullptr) )
throw DisposedException();
- SdrModel* pModel = mxTable->getSdrTableObj()->GetModel();
- const bool bUndo = pModel && mxTable->getSdrTableObj()->IsInserted() && pModel->IsUndoEnabled();
+ SdrModel& rModel(mxTable->getSdrTableObj()->getSdrModelFromSdrObject());
+ const bool bUndo(mxTable->getSdrTableObj()->IsInserted() && rModel.IsUndoEnabled());
if( bUndo )
- pModel->BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
try
{
@@ -260,10 +260,9 @@ void SAL_CALL CellCursor::merge( )
}
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
}
@@ -503,10 +502,11 @@ void SAL_CALL CellCursor::split( sal_Int32 nColumns, sal_Int32 nRows )
if( !mxTable.is() || (mxTable->getSdrTableObj() == nullptr) )
throw DisposedException();
- SdrModel* pModel = mxTable->getSdrTableObj()->GetModel();
- const bool bUndo = pModel && mxTable->getSdrTableObj()->IsInserted() && pModel->IsUndoEnabled();
+ SdrModel& rModel(mxTable->getSdrTableObj()->getSdrModelFromSdrObject());
+ const bool bUndo(mxTable->getSdrTableObj()->IsInserted() && rModel.IsUndoEnabled());
+
if( bUndo )
- pModel->BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
try
{
@@ -526,10 +526,9 @@ void SAL_CALL CellCursor::split( sal_Int32 nColumns, sal_Int32 nRows )
}
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
}
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index dab61a948e33..f8b23626b281 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -684,7 +684,7 @@ sal_Int32 SdrTableObjImpl::getRowCount() const
void SdrTableObjImpl::LayoutTable( tools::Rectangle& rArea, bool bFitWidth, bool bFitHeight )
{
- if( mpLayouter && mpTableObj->GetModel() )
+ if(mpLayouter)
{
// Optimization: SdrTableObj::SetChanged() can call this very often, repeatedly
// with the same settings, noticeably increasing load time. Skip if already done.
@@ -749,20 +749,20 @@ sdr::contact::ViewContact* SdrTableObj::CreateObjectSpecificViewContact()
return new sdr::contact::ViewContactOfTableObj(*this);
}
-
-SdrTableObj::SdrTableObj(SdrModel* _pModel)
+SdrTableObj::SdrTableObj(SdrModel& rSdrModel)
+: SdrTextObj(rSdrModel)
{
- pModel = _pModel;
init( 1, 1 );
}
-
-SdrTableObj::SdrTableObj(SdrModel* _pModel, const ::tools::Rectangle& rNewRect, sal_Int32 nColumns, sal_Int32 nRows)
-: SdrTextObj( rNewRect )
-, maLogicRect( rNewRect )
+SdrTableObj::SdrTableObj(
+ SdrModel& rSdrModel,
+ const ::tools::Rectangle& rNewRect,
+ sal_Int32 nColumns,
+ sal_Int32 nRows)
+: SdrTextObj(rSdrModel, rNewRect)
+ ,maLogicRect(rNewRect)
{
- pModel = _pModel;
-
if( nColumns <= 0 )
nColumns = 1;
@@ -779,6 +779,16 @@ void SdrTableObj::init( sal_Int32 nColumns, sal_Int32 nRows )
mpImpl = new SdrTableObjImpl;
mpImpl->init( this, nColumns, nRows );
+
+ // Stuff done from old SetModel:
+ if( !maLogicRect.IsEmpty() )
+ {
+ maRect = maLogicRect;
+ mpImpl->LayoutTable( maRect, false, false );
+ }
+
+ // Also init from old SetModel:
+ mpImpl->SetModel(&getSdrModelFromSdrObject());
}
@@ -1349,28 +1359,6 @@ sal_uInt16 SdrTableObj::GetObjIdentifier() const
return static_cast<sal_uInt16>(OBJ_TABLE);
}
-
-void SdrTableObj::SetModel(SdrModel* pNewModel)
-{
- SdrModel* pOldModel = GetModel();
- if( pNewModel != pOldModel )
- {
- SdrTextObj::SetModel(pNewModel);
-
- if( mpImpl.is() )
- {
- mpImpl->SetModel( pNewModel );
-
- if( !maLogicRect.IsEmpty() )
- {
- maRect = maLogicRect;
- mpImpl->LayoutTable( maRect, false, false );
- }
- }
- }
-}
-
-
void SdrTableObj::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText, tools::Rectangle* pAnchorRect, bool /*bLineWidth*/ ) const
{
if( mpImpl.is() )
@@ -1418,9 +1406,9 @@ void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, too
if (pPara)
{
- const bool bHitTest = pModel && (&pModel->GetHitTestOutliner() == &rOutliner);
+ const bool bHitTest(&getSdrModelFromSdrObject().GetHitTestOutliner() == &rOutliner);
+ const SdrTextObj* pTestObj(rOutliner.GetTextObj());
- const SdrTextObj* pTestObj = rOutliner.GetTextObj();
if( !pTestObj || !bHitTest || (pTestObj != this) || (pTestObj->GetOutlinerParaObject() != xCell->GetOutlinerParaObject()) )
{
if( bHitTest ) // #i33696# take back fix #i27510#
@@ -1565,12 +1553,9 @@ void SdrTableObj::TakeTextEditArea( const CellPos& rPos, Size* pPaperMin, Size*
aAnkSiz.AdjustWidth( -1 ); aAnkSiz.AdjustHeight( -1 ); // because GetSize() increments by one
Size aMaxSiz(aAnkSiz.Width(),1000000);
- if (pModel!=nullptr)
- {
- Size aTmpSiz(pModel->GetMaxObjSize());
- if (aTmpSiz.Height()!=0)
- aMaxSiz.setHeight(aTmpSiz.Height() );
- }
+ Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
+ if (aTmpSiz.Height()!=0)
+ aMaxSiz.setHeight(aTmpSiz.Height() );
CellRef xCell( mpImpl->getCell( rPos ) );
SdrTextVertAdjust eVAdj = xCell.is() ? xCell->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_TOP;
@@ -1661,9 +1646,9 @@ OUString SdrTableObj::TakeObjNamePlural() const
}
-SdrTableObj* SdrTableObj::Clone() const
+SdrTableObj* SdrTableObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrTableObj >();
+ return CloneHelper< SdrTableObj >(pTargetModel);
}
SdrTableObj& SdrTableObj::operator=(const SdrTableObj& rObj)
@@ -1724,20 +1709,20 @@ bool SdrTableObj::BegTextEdit(SdrOutliner& rOutl)
mbInEditMode = true;
rOutl.Init( OutlinerMode::TextObject );
- rOutl.SetRefDevice( pModel->GetRefDevice() );
+ rOutl.SetRefDevice(getSdrModelFromSdrObject().GetRefDevice());
- bool bUpdMerk=rOutl.GetUpdateMode();
- if (bUpdMerk) rOutl.SetUpdateMode(false);
- Size aPaperMin;
- Size aPaperMax;
- tools::Rectangle aEditArea;
- TakeTextEditArea(&aPaperMin,&aPaperMax,&aEditArea,nullptr);
+ bool bUpdMerk=rOutl.GetUpdateMode();
+ if (bUpdMerk) rOutl.SetUpdateMode(false);
+ Size aPaperMin;
+ Size aPaperMax;
+ tools::Rectangle aEditArea;
+ TakeTextEditArea(&aPaperMin,&aPaperMax,&aEditArea,nullptr);
- rOutl.SetMinAutoPaperSize(aPaperMin);
- rOutl.SetMaxAutoPaperSize(aPaperMax);
- rOutl.SetPaperSize(aPaperMax);
+ rOutl.SetMinAutoPaperSize(aPaperMin);
+ rOutl.SetMaxAutoPaperSize(aPaperMax);
+ rOutl.SetPaperSize(aPaperMax);
- if (bUpdMerk) rOutl.SetUpdateMode(true);
+ if (bUpdMerk) rOutl.SetUpdateMode(true);
EEControlBits nStat=rOutl.GetControlWord();
nStat |= EEControlBits::AUTOPAGESIZE;
@@ -1758,14 +1743,14 @@ bool SdrTableObj::BegTextEdit(SdrOutliner& rOutl)
void SdrTableObj::EndTextEdit(SdrOutliner& rOutl)
{
- if (GetModel() && GetModel()->IsUndoEnabled() && !mpImpl->maUndos.empty())
+ if (getSdrModelFromSdrObject().IsUndoEnabled() && !mpImpl->maUndos.empty())
{
// These actions should be on the undo stack after text edit.
for (std::unique_ptr<SdrUndoAction>& pAction : mpImpl->maUndos)
- GetModel()->AddUndo(pAction.release());
+ getSdrModelFromSdrObject().AddUndo(pAction.release());
mpImpl->maUndos.clear();
- GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*this));
+ getSdrModelFromSdrObject().AddUndo(getSdrModelFromSdrObject().GetSdrUndoFactory().CreateUndoGeoObject(*this));
}
if(rOutl.IsModified())
@@ -1810,16 +1795,15 @@ void SdrTableObj::NbcSetOutlinerParaObject( OutlinerParaObject* pTextObject)
CellRef xCell( getActiveCell() );
if( xCell.is() )
{
- if( pModel )
+ // Update HitTestOutliner
+ const SdrTextObj* pTestObj(getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
+
+ if(pTestObj && pTestObj->GetOutlinerParaObject() == xCell->GetOutlinerParaObject())
{
- // Update HitTestOutliner
- const SdrTextObj* pTestObj = pModel->GetHitTestOutliner().GetTextObj();
- if( pTestObj && pTestObj->GetOutlinerParaObject() == xCell->GetOutlinerParaObject() )
- pModel->GetHitTestOutliner().SetTextObj( nullptr );
+ getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
}
xCell->SetOutlinerParaObject( pTextObject );
-
SetTextSizeDirty();
NbcAdjustTextFrameWidthAndHeight();
}
@@ -1891,7 +1875,7 @@ bool SdrTableObj::AdjustTextFrameWidthAndHeight()
bool SdrTableObj::AdjustTextFrameWidthAndHeight(tools::Rectangle& rR, bool bHeight, bool bWidth) const
{
- if((pModel == nullptr) || rR.IsEmpty() || !mpImpl.is() || !mpImpl->mxTable.is() )
+ if(rR.IsEmpty() || !mpImpl.is() || !mpImpl->mxTable.is())
return false;
tools::Rectangle aRectangle( rR );
@@ -2203,7 +2187,7 @@ bool SdrTableObj::applySpecialDrag(SdrDragStat& rDrag)
if( pEdgeHdl )
{
- if( GetModel() && IsInserted() )
+ if( IsInserted() )
{
rDrag.SetEndDragChangesAttributes(true);
rDrag.SetEndDragChangesLayout(true);
@@ -2341,12 +2325,21 @@ void SdrTableObj::RestGeoData(const SdrObjGeoData& rGeo)
}
-SdrTableObj* SdrTableObj::CloneRange( const CellPos& rStart, const CellPos& rEnd )
+SdrTableObj* SdrTableObj::CloneRange(
+ const CellPos& rStart,
+ const CellPos& rEnd,
+ SdrModel& rTargetModel)
{
const sal_Int32 nColumns = rEnd.mnCol - rStart.mnCol + 1;
const sal_Int32 nRows = rEnd.mnRow - rStart.mnRow + 1;
- SdrTableObj* pNewTableObj = new SdrTableObj( GetModel(), GetCurrentBoundRect(), nColumns, nRows);
+ SdrTableObj* pNewTableObj(
+ new SdrTableObj(
+ rTargetModel,
+ GetCurrentBoundRect(),
+ nColumns,
+ nRows));
+
pNewTableObj->setTableStyleSettings( getTableStyleSettings() );
pNewTableObj->setTableStyle( getTableStyle() );
diff --git a/svx/source/table/tablecolumn.cxx b/svx/source/table/tablecolumn.cxx
index e6f1c4a77b6b..e4007b3b35cf 100644
--- a/svx/source/table/tablecolumn.cxx
+++ b/svx/source/table/tablecolumn.cxx
@@ -141,10 +141,10 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a
bool bOk = false;
bool bChange = false;
- SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
-
+ SdrModel& rModel(mxTableModel->getSdrTableObj()->getSdrModelFromSdrObject());
TableColumnUndo* pUndo = nullptr;
- if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled() )
+
+ if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && rModel.IsUndoEnabled() )
{
TableColumnRef xThis( this );
pUndo = new TableColumnUndo( xThis );
@@ -214,7 +214,7 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a
{
if( pUndo )
{
- pModel->AddUndo( pUndo );
+ rModel.AddUndo( pUndo );
pUndo = nullptr;
}
mxTableModel->setModified(true);
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index cc0b6de54254..aaf4af78bc8f 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -140,35 +140,44 @@ void SAL_CALL SvxTableControllerModifyListener::disposing( const css::lang::Even
// class SvxTableController
-rtl::Reference< sdr::SelectionController > CreateTableController( SdrObjEditView* pView, const SdrTableObj* pObj, const rtl::Reference< sdr::SelectionController >& xRefController )
+rtl::Reference< sdr::SelectionController > CreateTableController(
+ SdrView& rView,
+ const SdrTableObj& rObj,
+ const rtl::Reference< sdr::SelectionController >& xRefController )
{
- return SvxTableController::create( pView, pObj, xRefController );
+ return SvxTableController::create(rView, rObj, xRefController);
}
-rtl::Reference< sdr::SelectionController > SvxTableController::create( SdrObjEditView* pView, const SdrTableObj* pObj, const rtl::Reference< sdr::SelectionController >& xRefController )
+rtl::Reference< sdr::SelectionController > SvxTableController::create(
+ SdrView& rView,
+ const SdrTableObj& rObj,
+ const rtl::Reference< sdr::SelectionController >& xRefController )
{
if( xRefController.is() )
{
SvxTableController* pController = dynamic_cast< SvxTableController* >( xRefController.get() );
- if( pController && (pController->mxTableObj.get() == pObj) && (pController->mpView == pView) )
+
+ if(pController && (pController->mxTableObj.get() == &rObj) && (&pController->mrView == &rView))
+ {
return xRefController;
+ }
}
- return new SvxTableController( pView, pObj );
+
+ return new SvxTableController(rView, rObj);
}
-SvxTableController::SvxTableController( SdrObjEditView* pView, const SdrTableObj* pObj )
-: mbCellSelectionMode(false)
-, mbLeftButtonDown(false)
-, mpSelectionOverlay(nullptr)
-, mpView( dynamic_cast< SdrView* >( pView ) )
-, mxTableObj( const_cast< SdrTableObj* >( pObj ) )
-, mpModel( nullptr )
-, mnUpdateEvent( nullptr )
+SvxTableController::SvxTableController(
+ SdrView& rView,
+ const SdrTableObj& rObj)
+: mbCellSelectionMode(false)
+ ,mbLeftButtonDown(false)
+ ,mpSelectionOverlay(nullptr)
+ ,mrView(rView)
+ ,mxTableObj(const_cast< SdrTableObj* >(&rObj))
+ ,mnUpdateEvent( nullptr )
{
- mpModel = mxTableObj->GetModel();
-
mxTableObj->getActiveCellPos( maCursorFirstPos );
maCursorLastPos = maCursorFirstPos;
@@ -202,11 +211,14 @@ SvxTableController::~SvxTableController()
bool SvxTableController::onKeyInput(const KeyEvent& rKEvt, vcl::Window* pWindow )
{
- if( !checkTableObject() )
+ if(!checkTableObject())
return false;
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+
// check if we are read only
- if( mpModel && mpModel->IsReadOnly())
+ if( rModel.IsReadOnly())
{
switch( rKEvt.GetKeyCode().GetCode() )
{
@@ -252,7 +264,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
if (comphelper::LibreOfficeKit::isActive() && !pWindow)
{
// Tiled rendering: get the window that has the disabled map mode.
- if (OutputDevice* pOutputDevice = mpView->GetFirstOutputDevice())
+ if (OutputDevice* pOutputDevice = mrView.GetFirstOutputDevice())
{
if (pOutputDevice->GetOutDevType() == OUTDEV_WINDOW)
pWindow = static_cast<vcl::Window*>(pOutputDevice);
@@ -263,7 +275,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
return false;
SdrViewEvent aVEvt;
- if( !rMEvt.IsRight() && mpView->PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN, aVEvt) == SdrHitKind::Handle )
+ if( !rMEvt.IsRight() && mrView.PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN, aVEvt) == SdrHitKind::Handle )
return false;
TableHitKind eHit = mxTableObj->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), maMouseDownPos.mnCol, maMouseDownPos.mnRow);
@@ -284,7 +296,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
{
RemoveSelection();
- SdrHdl* pHdl = mpView->PickHandle(pixelToLogic(rMEvt.GetPosPixel(), pWindow));
+ SdrHdl* pHdl = mrView.PickHandle(pixelToLogic(rMEvt.GetPosPixel(), pWindow));
if( pHdl )
{
@@ -304,7 +316,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
if (comphelper::LibreOfficeKit::isActive() && rMEvt.GetClicks() == 2 && rMEvt.IsLeft() && eHit == TableHitKind::CellTextArea)
{
bool bEmptyOutliner = false;
- if (Outliner* pOutliner = mpView->GetTextEditOutliner())
+ if (Outliner* pOutliner = mrView.GetTextEditOutliner())
{
if (pOutliner->GetParagraphCount() == 1)
{
@@ -318,7 +330,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
StartSelection(maMouseDownPos);
setSelectedCells(maMouseDownPos, maMouseDownPos);
// Update graphic selection, should be hidden now.
- mpView->AdjustMarkHdl();
+ mrView.AdjustMarkHdl();
return true;
}
}
@@ -382,7 +394,7 @@ void SvxTableController::onSelectionHasChanged()
}
else
{
- const SdrMarkList& rMarkList= mpView->GetMarkedObjectList();
+ const SdrMarkList& rMarkList= mrView.GetMarkedObjectList();
if( rMarkList.GetMarkCount() == 1 )
bSelected = mxTableObj.get() == rMarkList.GetMark(0)->GetMarkedSdrObj();
/* fdo#46186 Selecting the table means selecting the entire cells */
@@ -407,12 +419,13 @@ void SvxTableController::onSelectionHasChanged()
void SvxTableController::GetState( SfxItemSet& rSet )
{
- if( !mxTable.is() || !mxTableObj.is() || !mxTableObj->GetModel() )
+ if(!mxTable.is() || !mxTableObj.is())
return;
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
std::unique_ptr<SfxItemSet> xSet;
-
- bool bVertDone = false;
+ bool bVertDone(false);
// Iterate over all requested items in the set.
SfxWhichIter aIter( rSet );
@@ -425,15 +438,11 @@ void SvxTableController::GetState( SfxItemSet& rSet )
case SID_TABLE_VERT_CENTER:
case SID_TABLE_VERT_NONE:
{
- if( !mxTable.is() || !mxTableObj->GetModel() )
- {
- rSet.DisableItem(nWhich);
- }
- else if(!bVertDone)
+ if(!bVertDone)
{
if (!xSet)
{
- xSet.reset(new SfxItemSet( mxTableObj->GetModel()->GetItemPool() ));
+ xSet.reset(new SfxItemSet(rModel.GetItemPool()));
MergeAttrFromSelectedCells(*xSet, false);
}
@@ -505,277 +514,270 @@ void SvxTableController::GetState( SfxItemSet& rSet )
void SvxTableController::onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs )
{
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
- if( !pTableObj )
+ if(!checkTableObject())
return;
- if( mxTable.is() ) try
- {
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ bool bInsertAfter = true;
+ sal_uInt16 nCount = 0;
- bool bInsertAfter = true;
- sal_uInt16 nCount = 0;
- if( pArgs )
+ if( pArgs )
+ {
+ const SfxPoolItem* pItem = nullptr;
+ pArgs->GetItemState(nSId, false, &pItem);
+ if (pItem)
{
- const SfxPoolItem* pItem = nullptr;
- pArgs->GetItemState(nSId, false, &pItem);
- if (pItem)
- {
- nCount = static_cast<const SfxInt16Item*>(pItem)->GetValue();
- if(SfxItemState::SET == pArgs->GetItemState(SID_TABLE_PARAM_INSERT_AFTER, true, &pItem))
- bInsertAfter = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- }
+ nCount = static_cast<const SfxInt16Item*>(pItem)->GetValue();
+ if(SfxItemState::SET == pArgs->GetItemState(SID_TABLE_PARAM_INSERT_AFTER, true, &pItem))
+ bInsertAfter = static_cast<const SfxBoolItem*>(pItem)->GetValue();
}
+ }
- CellPos aStart, aEnd;
- if( hasSelectedCells() )
- {
- getSelectedCells( aStart, aEnd );
- }
- else
+ CellPos aStart, aEnd;
+ if( hasSelectedCells() )
+ {
+ getSelectedCells( aStart, aEnd );
+ }
+ else
+ {
+ if( bInsertAfter )
{
- if( bInsertAfter )
- {
- aStart.mnCol = mxTable->getColumnCount() - 1;
- aStart.mnRow = mxTable->getRowCount() - 1;
- aEnd = aStart;
- }
+ aStart.mnCol = mxTable->getColumnCount() - 1;
+ aStart.mnRow = mxTable->getRowCount() - 1;
+ aEnd = aStart;
}
+ }
- if( pTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ if( rTableObj.IsTextEditActive() )
+ mrView.SdrEndTextEdit(true);
- RemoveSelection();
+ RemoveSelection();
- const OUString sSize( "Size" );
+ const OUString sSize( "Size" );
+ const bool bUndo(rModel.IsUndoEnabled());
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ switch( nSId )
+ {
+ case SID_TABLE_INSERT_COL:
+ {
+ TableModelNotifyGuard aGuard( mxTable.get() );
- switch( nSId )
- {
- case SID_TABLE_INSERT_COL:
+ if( bUndo )
{
- TableModelNotifyGuard aGuard( mxTable.get() );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
+ }
- if( bUndo )
- {
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
- }
+ Reference< XTableColumns > xCols( mxTable->getColumns() );
+ const sal_Int32 nNewColumns = (nCount == 0) ? (aEnd.mnCol - aStart.mnCol + 1) : nCount;
+ const sal_Int32 nNewStartColumn = aEnd.mnCol + (bInsertAfter ? 1 : 0);
+ xCols->insertByIndex( nNewStartColumn, nNewColumns );
- Reference< XTableColumns > xCols( mxTable->getColumns() );
- const sal_Int32 nNewColumns = (nCount == 0) ? (aEnd.mnCol - aStart.mnCol + 1) : nCount;
- const sal_Int32 nNewStartColumn = aEnd.mnCol + (bInsertAfter ? 1 : 0);
- xCols->insertByIndex( nNewStartColumn, nNewColumns );
+ for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
+ {
+ // Resolves fdo#61540
+ // On Insert before, the reference column whose size is going to be
+ // used for newly created column(s) is wrong. As the new columns are
+ // inserted before the reference column, the reference column moved
+ // to the new position by no., of new columns i.e (earlier+newcolumns).
+ Reference< XPropertySet >(xCols->getByIndex(nNewStartColumn+nOffset), UNO_QUERY_THROW )->
+ setPropertyValue( sSize,
+ Reference< XPropertySet >(xCols->getByIndex( bInsertAfter?nNewStartColumn-1:nNewStartColumn+nNewColumns ), UNO_QUERY_THROW )->
+ getPropertyValue( sSize ) );
+ }
- for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
- {
- // Resolves fdo#61540
- // On Insert before, the reference column whose size is going to be
- // used for newly created column(s) is wrong. As the new columns are
- // inserted before the reference column, the reference column moved
- // to the new position by no., of new columns i.e (earlier+newcolumns).
- Reference< XPropertySet >(xCols->getByIndex(nNewStartColumn+nOffset), UNO_QUERY_THROW )->
- setPropertyValue( sSize,
- Reference< XPropertySet >(xCols->getByIndex( bInsertAfter?nNewStartColumn-1:nNewStartColumn+nNewColumns ), UNO_QUERY_THROW )->
- getPropertyValue( sSize ) );
- }
+ // Copy cell properties
+ sal_Int32 nPropSrcCol = (bInsertAfter ? aEnd.mnCol : aStart.mnCol + nNewColumns);
+ sal_Int32 nRowSpan = 0;
+ bool bNewSpan = false;
- // Copy cell properties
- sal_Int32 nPropSrcCol = (bInsertAfter ? aEnd.mnCol : aStart.mnCol + nNewColumns);
- sal_Int32 nRowSpan = 0;
- bool bNewSpan = false;
+ for( sal_Int32 nRow = 0; nRow < mxTable->getRowCount(); ++nRow )
+ {
+ CellRef xSourceCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nPropSrcCol, nRow ).get() ) );
- for( sal_Int32 nRow = 0; nRow < mxTable->getRowCount(); ++nRow )
+ // When we insert new COLUMNs, we want to copy ROW spans.
+ if (xSourceCell.is() && nRowSpan == 0)
{
- CellRef xSourceCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nPropSrcCol, nRow ).get() ) );
+ // we are not in a span yet. Let's find out if the current cell is in a span.
+ sal_Int32 nColSpan = sal_Int32();
+ sal_Int32 nSpanInfoCol = sal_Int32();
- // When we insert new COLUMNs, we want to copy ROW spans.
- if (xSourceCell.is() && nRowSpan == 0)
+ if( xSourceCell->getRowSpan() > 1 )
{
- // we are not in a span yet. Let's find out if the current cell is in a span.
- sal_Int32 nColSpan = sal_Int32();
- sal_Int32 nSpanInfoCol = sal_Int32();
-
- if( xSourceCell->getRowSpan() > 1 )
- {
- // The current cell is the top-left cell in a span.
- // Get the span info and propagate it to the target.
- nRowSpan = xSourceCell->getRowSpan();
- nColSpan = xSourceCell->getColumnSpan();
- nSpanInfoCol = nPropSrcCol;
- }
- else if( xSourceCell->isMerged() )
+ // The current cell is the top-left cell in a span.
+ // Get the span info and propagate it to the target.
+ nRowSpan = xSourceCell->getRowSpan();
+ nColSpan = xSourceCell->getColumnSpan();
+ nSpanInfoCol = nPropSrcCol;
+ }
+ else if( xSourceCell->isMerged() )
+ {
+ // The current cell is a middle cell in a 2D span.
+ // Look for the top-left cell in the span.
+ for( nSpanInfoCol = nPropSrcCol - 1; nSpanInfoCol >= 0; --nSpanInfoCol )
{
- // The current cell is a middle cell in a 2D span.
- // Look for the top-left cell in the span.
- for( nSpanInfoCol = nPropSrcCol - 1; nSpanInfoCol >= 0; --nSpanInfoCol )
+ CellRef xMergeInfoCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nSpanInfoCol, nRow ).get() ) );
+ if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
{
- CellRef xMergeInfoCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nSpanInfoCol, nRow ).get() ) );
- if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
- {
- nRowSpan = xMergeInfoCell->getRowSpan();
- nColSpan = xMergeInfoCell->getColumnSpan();
- break;
- }
+ nRowSpan = xMergeInfoCell->getRowSpan();
+ nColSpan = xMergeInfoCell->getColumnSpan();
+ break;
}
- if( nRowSpan == 1 )
- nRowSpan = 0;
}
-
- // The target columns are outside the span; Start a new span.
- if( nRowSpan > 0 && ( nNewStartColumn < nSpanInfoCol || nSpanInfoCol + nColSpan <= nNewStartColumn ) )
- bNewSpan = true;
+ if( nRowSpan == 1 )
+ nRowSpan = 0;
}
- // Now copy the properties from the source to the targets
- for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
+ // The target columns are outside the span; Start a new span.
+ if( nRowSpan > 0 && ( nNewStartColumn < nSpanInfoCol || nSpanInfoCol + nColSpan <= nNewStartColumn ) )
+ bNewSpan = true;
+ }
+
+ // Now copy the properties from the source to the targets
+ for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
+ {
+ CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nNewStartColumn + nOffset, nRow ).get() ) );
+ if( xTargetCell.is() )
{
- CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nNewStartColumn + nOffset, nRow ).get() ) );
- if( xTargetCell.is() )
+ if( nRowSpan > 0 )
{
- if( nRowSpan > 0 )
- {
- if( bNewSpan )
- xTargetCell->merge( 1, nRowSpan );
- else
- xTargetCell->setMerged();
- }
- xTargetCell->copyFormatFrom( xSourceCell );
+ if( bNewSpan )
+ xTargetCell->merge( 1, nRowSpan );
+ else
+ xTargetCell->setMerged();
}
+ xTargetCell->copyFormatFrom( xSourceCell );
}
+ }
- if( nRowSpan > 0 )
- {
- --nRowSpan;
- bNewSpan = false;
- }
+ if( nRowSpan > 0 )
+ {
+ --nRowSpan;
+ bNewSpan = false;
}
+ }
- if( bUndo )
- mpModel->EndUndo();
+ if( bUndo )
+ rModel.EndUndo();
- aStart.mnCol = nNewStartColumn;
- aStart.mnRow = 0;
- aEnd.mnCol = aStart.mnCol + nNewColumns - 1;
- aEnd.mnRow = mxTable->getRowCount() - 1;
- break;
- }
+ aStart.mnCol = nNewStartColumn;
+ aStart.mnRow = 0;
+ aEnd.mnCol = aStart.mnCol + nNewColumns - 1;
+ aEnd.mnRow = mxTable->getRowCount() - 1;
+ break;
+ }
- case SID_TABLE_INSERT_ROW:
+ case SID_TABLE_INSERT_ROW:
+ {
+ TableModelNotifyGuard aGuard( mxTable.get() );
+
+ if( bUndo )
{
- TableModelNotifyGuard aGuard( mxTable.get() );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_INSROW ) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
+ }
- if( bUndo )
- {
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW ) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
- }
+ Reference< XTableRows > xRows( mxTable->getRows() );
+ const sal_Int32 nNewRows = (nCount == 0) ? (aEnd.mnRow - aStart.mnRow + 1) : nCount;
+ const sal_Int32 nNewRowStart = aEnd.mnRow + (bInsertAfter ? 1 : 0);
+ xRows->insertByIndex( nNewRowStart, nNewRows );
- Reference< XTableRows > xRows( mxTable->getRows() );
- const sal_Int32 nNewRows = (nCount == 0) ? (aEnd.mnRow - aStart.mnRow + 1) : nCount;
- const sal_Int32 nNewRowStart = aEnd.mnRow + (bInsertAfter ? 1 : 0);
- xRows->insertByIndex( nNewRowStart, nNewRows );
+ for( sal_Int32 nOffset = 0; nOffset < nNewRows; nOffset++ )
+ {
+ Reference< XPropertySet >( xRows->getByIndex( aEnd.mnRow + nOffset + 1 ), UNO_QUERY_THROW )->
+ setPropertyValue( sSize,
+ Reference< XPropertySet >( xRows->getByIndex( aStart.mnRow + nOffset ), UNO_QUERY_THROW )->
+ getPropertyValue( sSize ) );
+ }
- for( sal_Int32 nOffset = 0; nOffset < nNewRows; nOffset++ )
- {
- Reference< XPropertySet >( xRows->getByIndex( aEnd.mnRow + nOffset + 1 ), UNO_QUERY_THROW )->
- setPropertyValue( sSize,
- Reference< XPropertySet >( xRows->getByIndex( aStart.mnRow + nOffset ), UNO_QUERY_THROW )->
- getPropertyValue( sSize ) );
- }
+ // Copy the cell properties
+ sal_Int32 nPropSrcRow = (bInsertAfter ? aEnd.mnRow : aStart.mnRow + nNewRows);
+ sal_Int32 nColSpan = 0;
+ bool bNewSpan = false;
- // Copy the cell properties
- sal_Int32 nPropSrcRow = (bInsertAfter ? aEnd.mnRow : aStart.mnRow + nNewRows);
- sal_Int32 nColSpan = 0;
- bool bNewSpan = false;
+ for( sal_Int32 nCol = 0; nCol < mxTable->getColumnCount(); ++nCol )
+ {
+ CellRef xSourceCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nPropSrcRow ).get() ) );
- for( sal_Int32 nCol = 0; nCol < mxTable->getColumnCount(); ++nCol )
- {
- CellRef xSourceCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nPropSrcRow ).get() ) );
+ if (!xSourceCell.is())
+ continue;
- if (!xSourceCell.is())
- continue;
+ // When we insert new ROWs, we want to copy COLUMN spans.
+ if( nColSpan == 0 )
+ {
+ // we are not in a span yet. Let's find out if the current cell is in a span.
+ sal_Int32 nRowSpan = sal_Int32();
+ sal_Int32 nSpanInfoRow = sal_Int32();
- // When we insert new ROWs, we want to copy COLUMN spans.
- if( nColSpan == 0 )
+ if( xSourceCell->getColumnSpan() > 1 )
{
- // we are not in a span yet. Let's find out if the current cell is in a span.
- sal_Int32 nRowSpan = sal_Int32();
- sal_Int32 nSpanInfoRow = sal_Int32();
-
- if( xSourceCell->getColumnSpan() > 1 )
- {
- // The current cell is the top-left cell in a span.
- // Get the span info and propagate it to the target.
- nColSpan = xSourceCell->getColumnSpan();
- nRowSpan = xSourceCell->getRowSpan();
- nSpanInfoRow = nPropSrcRow;
- }
- else if( xSourceCell->isMerged() )
- {
- // The current cell is a middle cell in a 2D span.
- // Look for the top-left cell in the span.
- for( nSpanInfoRow = nPropSrcRow - 1; nSpanInfoRow >= 0; --nSpanInfoRow )
- {
- CellRef xMergeInfoCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nSpanInfoRow ).get() ) );
- if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
- {
- nColSpan = xMergeInfoCell->getColumnSpan();
- nRowSpan = xMergeInfoCell->getRowSpan();
- break;
- }
- }
- if( nColSpan == 1 )
- nColSpan = 0;
- }
-
- // Inserted rows are outside the span; Start a new span.
- if( nColSpan > 0 && ( nNewRowStart < nSpanInfoRow || nSpanInfoRow + nRowSpan <= nNewRowStart ) )
- bNewSpan = true;
+ // The current cell is the top-left cell in a span.
+ // Get the span info and propagate it to the target.
+ nColSpan = xSourceCell->getColumnSpan();
+ nRowSpan = xSourceCell->getRowSpan();
+ nSpanInfoRow = nPropSrcRow;
}
-
- // Now copy the properties from the source to the targets
- for( sal_Int32 nOffset = 0; nOffset < nNewRows; ++nOffset )
+ else if( xSourceCell->isMerged() )
{
- CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nNewRowStart + nOffset ).get() ) );
- if( xTargetCell.is() )
+ // The current cell is a middle cell in a 2D span.
+ // Look for the top-left cell in the span.
+ for( nSpanInfoRow = nPropSrcRow - 1; nSpanInfoRow >= 0; --nSpanInfoRow )
{
- if( nColSpan > 0 )
+ CellRef xMergeInfoCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nSpanInfoRow ).get() ) );
+ if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
{
- if( bNewSpan )
- xTargetCell->merge( nColSpan, 1 );
- else
- xTargetCell->setMerged();
+ nColSpan = xMergeInfoCell->getColumnSpan();
+ nRowSpan = xMergeInfoCell->getRowSpan();
+ break;
}
- xTargetCell->copyFormatFrom( xSourceCell );
}
+ if( nColSpan == 1 )
+ nColSpan = 0;
}
- if( nColSpan > 0 )
+ // Inserted rows are outside the span; Start a new span.
+ if( nColSpan > 0 && ( nNewRowStart < nSpanInfoRow || nSpanInfoRow + nRowSpan <= nNewRowStart ) )
+ bNewSpan = true;
+ }
+
+ // Now copy the properties from the source to the targets
+ for( sal_Int32 nOffset = 0; nOffset < nNewRows; ++nOffset )
+ {
+ CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nNewRowStart + nOffset ).get() ) );
+ if( xTargetCell.is() )
{
- --nColSpan;
- bNewSpan = false;
+ if( nColSpan > 0 )
+ {
+ if( bNewSpan )
+ xTargetCell->merge( nColSpan, 1 );
+ else
+ xTargetCell->setMerged();
+ }
+ xTargetCell->copyFormatFrom( xSourceCell );
}
}
- if( bUndo )
- mpModel->EndUndo();
-
- aStart.mnCol = 0;
- aStart.mnRow = nNewRowStart;
- aEnd.mnCol = mxTable->getColumnCount() - 1;
- aEnd.mnRow = aStart.mnRow + nNewRows - 1;
- break;
- }
+ if( nColSpan > 0 )
+ {
+ --nColSpan;
+ bNewSpan = false;
+ }
}
- StartSelection( aStart );
- UpdateSelection( aEnd );
+ if( bUndo )
+ rModel.EndUndo();
+
+ aStart.mnCol = 0;
+ aStart.mnRow = nNewRowStart;
+ aEnd.mnCol = mxTable->getColumnCount() - 1;
+ aEnd.mnRow = aStart.mnRow + nNewRows - 1;
+ break;
}
- catch( Exception& )
- {
- OSL_FAIL("svx::SvxTableController::onInsert(), exception caught!");
}
+
+ StartSelection( aStart );
+ UpdateSelection( aEnd );
}
@@ -791,7 +793,7 @@ void SvxTableController::onDelete( sal_uInt16 nSId )
getSelectedCells( aStart, aEnd );
if( pTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ mrView.SdrEndTextEdit(true);
RemoveSelection();
@@ -830,7 +832,7 @@ void SvxTableController::onDelete( sal_uInt16 nSId )
}
if( bDeleteTable )
- mpView->DeleteMarkedObj();
+ mrView.DeleteMarkedObj();
else
UpdateTableShape();
}
@@ -886,15 +888,16 @@ namespace
void SvxTableController::onFormatTable( SfxRequest const & rReq )
{
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
- if( !pTableObj )
+ if(!mxTableObj.is())
return;
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
const SfxItemSet* pArgs = rReq.GetArgs();
- if( !pArgs && pTableObj->GetModel() )
+ if(!pArgs)
{
- SfxItemSet aNewAttr( pTableObj->GetModel()->GetItemPool() );
+ SfxItemSet aNewAttr(rModel.GetItemPool());
// merge drawing layer text distance items into SvxBoxItem used by the dialog
SvxBoxItem aBoxItem(mergeDrawinglayerTextDistancesAndSvxBoxItem(aNewAttr));
@@ -907,7 +910,11 @@ void SvxTableController::onFormatTable( SfxRequest const & rReq )
aNewAttr.Put( aBoxInfoItem );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- ScopedVclPtr<SfxAbstractTabDialog> xDlg( pFact ? pFact->CreateSvxFormatCellsDialog( &aNewAttr, pTableObj->GetModel(), pTableObj) : nullptr );
+ ScopedVclPtr<SfxAbstractTabDialog> xDlg( pFact ? pFact->CreateSvxFormatCellsDialog(
+ &aNewAttr,
+ rModel,
+ &rTableObj) : nullptr );
+
// Even Cancel Button is returning positive(101) value,
if (xDlg.get() && xDlg->Execute() == RET_OK)
{
@@ -1026,16 +1033,19 @@ void SvxTableController::Execute( SfxRequest& rReq )
void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
{
- SdrTableObj* pTableObj = mxTableObj.get();
- SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr;
+ if(!checkTableObject())
+ return;
- if( !pTableObj || !pModel || !pArgs || (SfxItemState::SET != pArgs->GetItemState(SID_TABLE_STYLE, false)) )
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+
+ if(!pArgs || (SfxItemState::SET != pArgs->GetItemState(SID_TABLE_STYLE, false)))
return;
const SfxStringItem* pArg = dynamic_cast< const SfxStringItem* >( &pArgs->Get( SID_TABLE_STYLE ) );
if( pArg && mxTable.is() ) try
{
- Reference< XStyleFamiliesSupplier > xSFS( pModel->getUnoModel(), UNO_QUERY_THROW );
+ Reference< XStyleFamiliesSupplier > xSFS( rModel.getUnoModel(), UNO_QUERY_THROW );
Reference< XNameAccess > xFamilyNameAccess( xSFS->getStyleFamilies(), UNO_QUERY_THROW );
const OUString sFamilyName( "table" );
Reference< XNameAccess > xTableFamilyAccess( xFamilyNameAccess->getByName( sFamilyName ), UNO_QUERY_THROW );
@@ -1045,15 +1055,15 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
// found table style with the same name
Reference< XIndexAccess > xNewTableStyle( xTableFamilyAccess->getByName( pArg->GetValue() ), UNO_QUERY_THROW );
- const bool bUndo = pModel->IsUndoEnabled();
+ const bool bUndo = rModel.IsUndoEnabled();
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE) );
- pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ rModel.BegUndo(ImpGetResStr(STR_TABLE_STYLE));
+ rModel.AddUndo(new TableStyleUndo(rTableObj));
}
- pTableObj->setTableStyle( xNewTableStyle );
+ rTableObj.setTableStyle( xNewTableStyle );
const sal_Int32 nRowCount = mxTable->getRowCount();
const sal_Int32 nColCount = mxTable->getColumnCount();
@@ -1098,7 +1108,7 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
}
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
}
}
catch( Exception& )
@@ -1109,14 +1119,13 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
void SvxTableController::SetTableStyleSettings( const SfxItemSet* pArgs )
{
- SdrTableObj* pTableObj = mxTableObj.get();
- SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr;
-
- if( !pTableObj || !pModel )
+ if(!checkTableObject())
return;
- TableStyleSettings aSettings( pTableObj->getTableStyleSettings() );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ TableStyleSettings aSettings(rTableObj.getTableStyleSettings() );
const SfxPoolItem *pPoolItem=nullptr;
if( SfxItemState::SET == pArgs->GetItemState(ID_VAL_USEFIRSTROWSTYLE, false,&pPoolItem) )
@@ -1137,36 +1146,38 @@ void SvxTableController::SetTableStyleSettings( const SfxItemSet* pArgs )
if( SfxItemState::SET == pArgs->GetItemState(ID_VAL_USEBANDINGCOLUMNSTYLE, false,&pPoolItem) )
aSettings.mbUseColumnBanding = static_cast< const SfxBoolItem* >(pPoolItem)->GetValue();
- if( aSettings == pTableObj->getTableStyleSettings() )
+ if( aSettings == rTableObj.getTableStyleSettings() )
return;
- const bool bUndo = pModel->IsUndoEnabled();
+ const bool bUndo(rModel.IsUndoEnabled());
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE_SETTINGS) );
- pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_STYLE_SETTINGS) );
+ rModel.AddUndo(new TableStyleUndo(rTableObj));
}
- pTableObj->setTableStyleSettings( aSettings );
+ rTableObj.setTableStyleSettings( aSettings );
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
}
void SvxTableController::SetVertical( sal_uInt16 nSId )
{
- SdrTableObj* pTableObj = mxTableObj.get();
- if( !mxTable.is() || !pTableObj )
+ if(!checkTableObject())
return;
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+
TableModelNotifyGuard aGuard( mxTable.get() );
+ const bool bUndo(rModel.IsUndoEnabled());
- bool bUndo = mpModel && mpModel->IsUndoEnabled();
if (bUndo)
{
- mpModel->BegUndo(ImpGetResStr(STR_TABLE_NUMFORMAT));
- mpModel->AddUndo(mpModel->GetSdrUndoFactory().CreateUndoAttrObject(*pTableObj));
+ rModel.BegUndo(ImpGetResStr(STR_TABLE_NUMFORMAT));
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoAttrObject(rTableObj));
}
CellPos aStart, aEnd;
@@ -1208,7 +1219,7 @@ void SvxTableController::SetVertical( sal_uInt16 nSId )
UpdateTableShape();
if (bUndo)
- mpModel->EndUndo();
+ rModel.EndUndo();
}
void SvxTableController::MergeMarkedCells()
@@ -1219,7 +1230,7 @@ void SvxTableController::MergeMarkedCells()
if( pTableObj )
{
if( pTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ mrView.SdrEndTextEdit(true);
TableModelNotifyGuard aGuard( mxTable.get() );
MergeRange( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow );
@@ -1228,102 +1239,102 @@ void SvxTableController::MergeMarkedCells()
void SvxTableController::SplitMarkedCells()
{
- if( mxTable.is() )
- {
- CellPos aStart, aEnd;
- getSelectedCells( aStart, aEnd );
+ if(!checkTableObject() || !mxTable.is())
+ return;
- SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- ScopedVclPtr< SvxAbstractSplitTableDialog > xDlg( pFact ? pFact->CreateSvxSplitTableDialog( nullptr, false, 99 ) : nullptr );
- if( xDlg.get() && xDlg->Execute() )
- {
- const sal_Int32 nCount = xDlg->GetCount() - 1;
- if( nCount < 1 )
- return;
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ ScopedVclPtr< SvxAbstractSplitTableDialog > xDlg( pFact ? pFact->CreateSvxSplitTableDialog( nullptr, false, 99 ) : nullptr );
- getSelectedCells( aStart, aEnd );
+ if( xDlg.get() && xDlg->Execute() )
+ {
+ const sal_Int32 nCount = xDlg->GetCount() - 1;
- Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow ) ), UNO_QUERY_THROW );
+ if( nCount < 1 )
+ return;
- const sal_Int32 nRowCount = mxTable->getRowCount();
- const sal_Int32 nColCount = mxTable->getColumnCount();
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow ) ), UNO_QUERY_THROW );
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+ const sal_Int32 nColCount = mxTable->getColumnCount();
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ if( rTableObj.IsTextEditActive() )
+ mrView.SdrEndTextEdit(true);
- SdrTableObj* pTableObj = mxTableObj.get();
- if( pTableObj )
- {
- if( pTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ TableModelNotifyGuard aGuard( mxTable.get() );
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
- TableModelNotifyGuard aGuard( mxTable.get() );
+ if( bUndo )
+ {
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
+ }
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
- if( bUndo )
- {
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
- }
+ if( xDlg->IsHorizontal() )
+ {
+ xRange->split( 0, nCount );
+ }
+ else
+ {
+ xRange->split( nCount, 0 );
+ }
- if( xDlg->IsHorizontal() )
- {
- xRange->split( 0, nCount );
- }
- else
- {
- xRange->split( nCount, 0 );
- }
+ if( bUndo )
+ rModel.EndUndo();
- if( bUndo )
- mpModel->EndUndo();
- }
- aEnd.mnRow += mxTable->getRowCount() - nRowCount;
- aEnd.mnCol += mxTable->getColumnCount() - nColCount;
+ aEnd.mnRow += mxTable->getRowCount() - nRowCount;
+ aEnd.mnCol += mxTable->getColumnCount() - nColCount;
- setSelectedCells( aStart, aEnd );
- }
+ setSelectedCells( aStart, aEnd );
}
}
void SvxTableController::DistributeColumns()
{
- SdrTableObj* pTableObj = mxTableObj.get();
- if( pTableObj )
- {
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
- if( bUndo )
- {
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_COLUMNS) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
- }
+ if(!checkTableObject())
+ return;
- CellPos aStart, aEnd;
- getSelectedCells( aStart, aEnd );
- pTableObj->DistributeColumns( aStart.mnCol, aEnd.mnCol );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
- if( bUndo )
- mpModel->EndUndo();
+ if( bUndo )
+ {
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_COLUMNS) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
}
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ rTableObj.DistributeColumns( aStart.mnCol, aEnd.mnCol );
+
+ if( bUndo )
+ rModel.EndUndo();
}
void SvxTableController::DistributeRows()
{
- SdrTableObj* pTableObj = mxTableObj.get();
- if( pTableObj )
- {
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
- if( bUndo )
- {
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_ROWS) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
- }
+ if(!checkTableObject())
+ return;
- CellPos aStart, aEnd;
- getSelectedCells( aStart, aEnd );
- pTableObj->DistributeRows( aStart.mnRow, aEnd.mnRow );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
- if( bUndo )
- mpModel->EndUndo();
+ if( bUndo )
+ {
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_ROWS) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
}
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ rTableObj.DistributeRows( aStart.mnRow, aEnd.mnRow );
+
+ if( bUndo )
+ rModel.EndUndo();
}
bool SvxTableController::HasMarked()
@@ -1333,12 +1344,15 @@ bool SvxTableController::HasMarked()
bool SvxTableController::DeleteMarked()
{
- if (!HasMarked())
+ if(!checkTableObject() || !HasMarked())
return false;
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
+
if (bUndo)
- mpModel->BegUndo(ImpGetResStr(STR_TABLE_DELETE_CELL_CONTENTS));
+ rModel.BegUndo(ImpGetResStr(STR_TABLE_DELETE_CELL_CONTENTS));
CellPos aStart, aEnd;
getSelectedCells( aStart, aEnd );
@@ -1357,7 +1371,7 @@ bool SvxTableController::DeleteMarked()
}
if (bUndo)
- mpModel->EndUndo();
+ rModel.EndUndo();
UpdateTableShape();
return true;
@@ -1444,8 +1458,7 @@ SvxTableController::TblAction SvxTableController::getKeyboardAction(const KeyEve
{
const bool bMod1 = rKEvt.GetKeyCode().IsMod1(); // ctrl
const bool bMod2 = rKEvt.GetKeyCode().IsMod2(); // Alt
-
- const bool bTextEdit = mpView->IsTextEdit();
+ const bool bTextEdit = mrView.IsTextEdit();
TblAction nAction = TblAction::HandledByView;
@@ -1576,7 +1589,7 @@ SvxTableController::TblAction SvxTableController::getKeyboardAction(const KeyEve
}
bool bTextMove = false;
- OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+ OutlinerView* pOLV = mrView.GetTextEditOutlinerView();
if( pOLV )
{
RemoveSelection();
@@ -1740,7 +1753,7 @@ bool SvxTableController::executeAction(TblAction nAction, bool bSelect, vcl::Win
void SvxTableController::gotoCell(const CellPos& rPos, bool bSelect, vcl::Window* pWindow, TblAction nAction /*= TblAction::NONE */)
{
if( mxTableObj.is() && mxTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ mrView.SdrEndTextEdit(true);
if( bSelect )
{
@@ -1787,22 +1800,29 @@ const CellPos& SvxTableController::getSelectionEnd()
void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow )
{
- if( mxTable.is() ) try
+ if(!checkTableObject() || !mxTable.is())
+ return;
+
+ try
{
Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( nFirstCol, nFirstRow,nLastCol, nLastRow ) ), UNO_QUERY_THROW );
+
if( xRange->isMergeable() )
{
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
+
if( bUndo )
{
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*mxTableObj.get()) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
}
xRange->merge();
if( bUndo )
- mpModel->EndUndo();
+ rModel.EndUndo();
}
}
catch( Exception& )
@@ -1848,16 +1868,20 @@ void SvxTableController::findMergeOrigin( CellPos& rPos )
void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, TblAction nAction /*= TblAction::NONE */)
{
- SdrPageView* pPV = mpView->GetSdrPageView();
+ SdrPageView* pPV(mrView.GetSdrPageView());
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
- if( pTableObj && pTableObj->GetPage() == pPV->GetPage() )
+ if(nullptr == pPV || !checkTableObject())
+ return;
+
+ SdrTableObj& rTableObj(*mxTableObj.get());
+
+ if(rTableObj.GetPage() == pPV->GetPage())
{
bool bEmptyOutliner = false;
- if(!pTableObj->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
+ if(!rTableObj.GetOutlinerParaObject() && mrView.GetTextEditOutliner())
{
- ::Outliner* pOutl = mpView->GetTextEditOutliner();
+ ::Outliner* pOutl = mrView.GetTextEditOutliner();
sal_Int32 nParaCnt = pOutl->GetParagraphCount();
Paragraph* p1stPara = pOutl->GetParagraph( 0 );
@@ -1874,28 +1898,30 @@ void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, Tbl
CellPos aPos( rPos );
findMergeOrigin( aPos );
- if( pTableObj != mpView->GetTextEditObject() || bEmptyOutliner || !pTableObj->IsTextEditActive( aPos ) )
+ if( &rTableObj != mrView.GetTextEditObject() || bEmptyOutliner || !rTableObj.IsTextEditActive( aPos ) )
{
- if( pTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ if( rTableObj.IsTextEditActive() )
+ mrView.SdrEndTextEdit(true);
- pTableObj->setActiveCell( aPos );
+ rTableObj.setActiveCell( aPos );
// create new outliner, owner will be the SdrObjEditView
- SdrOutliner* pOutl = mpModel ? SdrMakeOutliner(OutlinerMode::OutlineObject, *mpModel) : nullptr;
- if (pOutl && pTableObj->IsVerticalWriting())
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ SdrOutliner* pOutl(SdrMakeOutliner(OutlinerMode::OutlineObject, rModel));
+
+ if (pOutl && rTableObj.IsVerticalWriting())
pOutl->SetVertical( true );
- if (mpView->SdrBeginTextEdit(pTableObj, pPV, pWindow, true, pOutl))
+ if (mrView.SdrBeginTextEdit(&rTableObj, pPV, pWindow, true, pOutl))
{
maCursorLastPos = maCursorFirstPos = rPos;
- OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+ OutlinerView* pOLV = mrView.GetTextEditOutlinerView();
// Move cursor to end of text
ESelection aNewSelection;
- const WritingMode eMode = pTableObj->GetWritingMode();
+ const WritingMode eMode = rTableObj.GetWritingMode();
if (((nAction == TblAction::GotoLeftCell) || (nAction == TblAction::GotoRightCell)) && (eMode != WritingMode_TB_RL))
{
const bool bLast = ((nAction == TblAction::GotoLeftCell) && (eMode == WritingMode_LR_TB)) ||
@@ -1913,11 +1939,11 @@ void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, Tbl
void SvxTableController::StopTextEdit()
{
- if(mpView->IsTextEdit())
+ if(mrView.IsTextEdit())
{
- mpView->SdrEndTextEdit();
- mpView->SetCurrentObj(OBJ_TABLE);
- mpView->SetEditMode(SdrViewEditMode::Edit);
+ mrView.SdrEndTextEdit();
+ mrView.SetCurrentObj(OBJ_TABLE);
+ mrView.SetEditMode(SdrViewEditMode::Edit);
}
}
@@ -1971,7 +1997,7 @@ void SvxTableController::getSelectedCells( CellPos& rFirst, CellPos& rLast )
}
while(bExt);
}
- else if( mpView && mpView->IsTextEdit() )
+ else if(mrView.IsTextEdit())
{
rFirst = getSelectionStart();
findMergeOrigin( rFirst );
@@ -2010,7 +2036,7 @@ void SvxTableController::StartSelection( const CellPos& rPos )
StopTextEdit();
mbCellSelectionMode = true;
maCursorLastPos = maCursorFirstPos = rPos;
- mpView->MarkListHasChanged();
+ mrView.MarkListHasChanged();
}
@@ -2025,53 +2051,58 @@ void SvxTableController::setSelectedCells( const CellPos& rStart, const CellPos&
bool SvxTableController::ChangeFontSize(bool bGrow, const FontList* pFontList)
{
- if (mxTable.is())
- {
- if (mpView->IsTextEdit())
- return true;
+ if(!checkTableObject() || !mxTable.is())
+ return false;
- CellPos aStart, aEnd;
- if(hasSelectedCells())
- {
- getSelectedCells(aStart, aEnd);
- }
- else
- {
- aStart.mnRow = 0;
- aStart.mnCol = 0;
- aEnd.mnRow = mxTable->getRowCount() - 1;
- aEnd.mnCol = mxTable->getColumnCount() - 1;
- }
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
- for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++)
+ if (mrView.IsTextEdit())
+ return true;
+
+ CellPos aStart, aEnd;
+
+ if(hasSelectedCells())
+ {
+ getSelectedCells(aStart, aEnd);
+ }
+ else
+ {
+ aStart.mnRow = 0;
+ aStart.mnCol = 0;
+ aEnd.mnRow = mxTable->getRowCount() - 1;
+ aEnd.mnCol = mxTable->getColumnCount() - 1;
+ }
+
+ for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++)
+ {
+ for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++)
{
- for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++)
+ CellRef xCell(dynamic_cast< Cell* >(mxTable->getCellByPosition(nCol, nRow).get()));
+ if (xCell.is())
{
- CellRef xCell(dynamic_cast< Cell* >(mxTable->getCellByPosition(nCol, nRow).get()));
- if (xCell.is())
- {
- if (mpModel && mpModel->IsUndoEnabled())
- xCell->AddUndo();
+ if (rModel.IsUndoEnabled())
+ xCell->AddUndo();
- SfxItemSet aCellSet(xCell->GetItemSet());
- if (EditView::ChangeFontSize(bGrow, aCellSet, pFontList))
- {
- xCell->SetMergedItemSetAndBroadcast(aCellSet, false);
- }
+ SfxItemSet aCellSet(xCell->GetItemSet());
+ if (EditView::ChangeFontSize(bGrow, aCellSet, pFontList))
+ {
+ xCell->SetMergedItemSetAndBroadcast(aCellSet, false);
}
}
}
- UpdateTableShape();
- return true;
}
- return false;
+
+ UpdateTableShape();
+
+ return true;
}
void SvxTableController::UpdateSelection( const CellPos& rPos )
{
maCursorLastPos = rPos;
- mpView->MarkListHasChanged();
+ mrView.MarkListHasChanged();
}
@@ -2099,7 +2130,7 @@ void SvxTableController::RemoveSelection()
if( mbCellSelectionMode )
{
mbCellSelectionMode = false;
- mpView->MarkListHasChanged();
+ mrView.MarkListHasChanged();
}
}
@@ -2136,14 +2167,14 @@ void SvxTableController::updateSelectionOverlay()
aRanges.push_back( a2DRange );
::Color aHighlight( COL_BLUE );
- OutputDevice* pOutDev = mpView->GetFirstOutputDevice();
+ OutputDevice* pOutDev = mrView.GetFirstOutputDevice();
if( pOutDev )
aHighlight = pOutDev->GetSettings().GetStyleSettings().GetHighlightColor();
- const sal_uInt32 nCount = mpView->PaintWindowCount();
+ const sal_uInt32 nCount = mrView.PaintWindowCount();
for( sal_uInt32 nIndex = 0; nIndex < nCount; nIndex++ )
{
- SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(nIndex);
+ SdrPaintWindow* pPaintWindow = mrView.GetPaintWindow(nIndex);
if( pPaintWindow )
{
rtl::Reference < sdr::overlay::OverlayManager > xOverlayManager = pPaintWindow->GetOverlayManager();
@@ -2500,13 +2531,15 @@ void SvxTableController::UpdateTableShape()
void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll)
{
- if( !mxTable.is() )
+ if(!checkTableObject() || !mxTable.is())
return;
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
if( bUndo )
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_NUMFORMAT) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_NUMFORMAT) );
CellPos aStart, aEnd;
getSelectedCells( aStart, aEnd );
@@ -2544,7 +2577,7 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR
UpdateTableShape();
if( bUndo )
- mpModel->EndUndo();
+ rModel.EndUndo();
}
@@ -2554,9 +2587,9 @@ bool SvxTableController::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAtt
{
MergeAttrFromSelectedCells( rTargetSet, bOnlyHardAttr );
- if( mpView->IsTextEdit() )
+ if( mrView.IsTextEdit() )
{
- OutlinerView* pTextEditOutlinerView = mpView->GetTextEditOutlinerView();
+ OutlinerView* pTextEditOutlinerView = mrView.GetTextEditOutlinerView();
if(pTextEditOutlinerView)
{
// FALSE= consider InvalidItems not as the default, but as "holes"
@@ -2575,7 +2608,7 @@ bool SvxTableController::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAtt
bool SvxTableController::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
{
- if( mbCellSelectionMode || mpView->IsTextEdit() )
+ if( mbCellSelectionMode || mrView.IsTextEdit() )
{
SetAttrToSelectedCells( rSet, bReplaceAll );
return true;
@@ -2588,16 +2621,17 @@ bool SvxTableController::GetMarkedObjModel( SdrPage* pNewPage )
{
if( mxTableObj.is() && mbCellSelectionMode && pNewPage ) try
{
- sdr::table::SdrTableObj& rTableObj = *mxTableObj.get();
-
+ sdr::table::SdrTableObj& rTableObj(*mxTableObj.get());
CellPos aStart, aEnd;
- getSelectedCells( aStart, aEnd );
-
- SdrTableObj* pNewTableObj = rTableObj.CloneRange( aStart, aEnd );
-
- pNewTableObj->SetPage( pNewPage );
- pNewTableObj->SetModel( pNewPage->GetModel() );
-
+ getSelectedCells(aStart, aEnd);
+
+ // Clone to new SdrModel
+ SdrTableObj* pNewTableObj(
+ rTableObj.CloneRange(
+ aStart,
+ aEnd,
+ pNewPage->getSdrModelFromSdrPage()));
+ pNewTableObj->SetPage(pNewPage);
pNewPage->InsertObject(pNewTableObj, SAL_MAX_SIZE);
return true;
@@ -2606,13 +2640,14 @@ bool SvxTableController::GetMarkedObjModel( SdrPage* pNewPage )
{
OSL_FAIL( "svx::SvxTableController::GetMarkedObjModel(), exception caught!" );
}
+
return false;
}
bool SvxTableController::PasteObjModel( const SdrModel& rModel )
{
- if( mxTableObj.is() && mpView && (rModel.GetPageCount() >= 1) )
+ if( mxTableObj.is() && (rModel.GetPageCount() >= 1) )
{
const SdrPage* pPastePage = rModel.GetPage(0);
if( pPastePage && pPastePage->GetObjCount() == 1 )
@@ -2647,8 +2682,8 @@ bool SvxTableController::PasteObject( SdrTableObj const * pPasteTableObj )
CellPos aStart, aEnd;
getSelectedCells( aStart, aEnd );
- if( mpView->IsTextEdit() )
- mpView->SdrEndTextEdit(true);
+ if( mrView.IsTextEdit() )
+ mrView.SdrEndTextEdit(true);
sal_Int32 nColumns = mxTable->getColumnCount();
sal_Int32 nRows = mxTable->getRowCount();
@@ -2692,51 +2727,51 @@ bool SvxTableController::TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& /*
bool SvxTableController::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats )
{
- if( mbCellSelectionMode )
+ if(!mbCellSelectionMode)
{
- SdrTextObj* pTableObj = dynamic_cast<SdrTextObj*>( mxTableObj.get() );
- if( !pTableObj )
- return false;
+ return false;
+ }
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if(!checkTableObject())
+ return false;
- if( bUndo )
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_NUMFORMAT) );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
- CellPos aStart, aEnd;
- getSelectedCells( aStart, aEnd );
+ if( bUndo )
+ rModel.BegUndo(ImpGetResStr(STR_TABLE_NUMFORMAT));
- const bool bFrame = (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER ) == SfxItemState::SET) || (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER_INNER ) == SfxItemState::SET);
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ const bool bFrame = (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER ) == SfxItemState::SET) || (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER_INNER ) == SfxItemState::SET);
- for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+ for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+ {
+ for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
{
- for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() )
{
- CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
- if( xCell.is() )
- {
- if (bUndo)
- xCell->AddUndo();
- SdrText* pText = static_cast< SdrText* >( xCell.get() );
- SdrObjEditView::ApplyFormatPaintBrushToText( rFormatSet, *pTableObj, pText, bNoCharacterFormats, bNoParagraphFormats );
- }
+ if (bUndo)
+ xCell->AddUndo();
+ SdrText* pText = static_cast< SdrText* >( xCell.get() );
+ SdrObjEditView::ApplyFormatPaintBrushToText( rFormatSet, rTableObj, pText, bNoCharacterFormats, bNoParagraphFormats );
}
}
+ }
- if( bFrame )
- {
- ApplyBorderAttr( rFormatSet );
- }
-
- UpdateTableShape();
+ if( bFrame )
+ {
+ ApplyBorderAttr( rFormatSet );
+ }
- if( bUndo )
- mpModel->EndUndo();
+ UpdateTableShape();
- return true;
+ if( bUndo )
+ rModel.EndUndo();
- }
- return false;
+ return true;
}
@@ -3077,26 +3112,22 @@ bool SvxTableController::isColumnSelected( sal_Int32 nColumn )
bool SvxTableController::isRowHeader()
{
- SdrTableObj* pTableObj = mxTableObj.get();
- SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr;
-
- if( !pTableObj || !pModel )
+ if(!checkTableObject())
return false;
- TableStyleSettings aSettings( pTableObj->getTableStyleSettings() );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ TableStyleSettings aSettings(rTableObj.getTableStyleSettings());
return aSettings.mbUseFirstRow;
}
bool SvxTableController::isColumnHeader()
{
- SdrTableObj* pTableObj = mxTableObj.get();
- SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr;
-
- if( !pTableObj || !pModel )
+ if(!checkTableObject())
return false;
- TableStyleSettings aSettings( pTableObj->getTableStyleSettings() );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ TableStyleSettings aSettings(rTableObj.getTableStyleSettings());
return aSettings.mbUseFirstColumn;
}
@@ -3125,7 +3156,7 @@ bool SvxTableController::setCursorLogicPosition(const Point& rPosition, bool bPo
// No selection, but rPosition is at an other cell: start table selection.
StartSelection(maMouseDownPos);
// Update graphic selection, should be hidden now.
- mpView->AdjustMarkHdl();
+ mrView.AdjustMarkHdl();
}
}
diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx
index 033af2477a45..812e3de7fe26 100644
--- a/svx/source/table/tablemodel.cxx
+++ b/svx/source/table/tablemodel.cxx
@@ -554,7 +554,7 @@ void TableModel::unlockBroadcasts()
void TableModel::notifyModification()
{
::osl::MutexGuard guard( m_aMutex );
- if( (mnNotifyLock == 0) && mpTableObj && mpTableObj->GetModel() )
+ if( (mnNotifyLock == 0) && mpTableObj )
{
mbNotifyPending = false;
@@ -602,8 +602,7 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
{
try
{
- SdrModel* pModel = mpTableObj->GetModel();
-
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
TableModelNotifyGuard aGuard( this );
nIndex = insert_range<ColumnVector,ColumnVector::iterator,TableColumnRef>( maColumns, nIndex, nCount );
@@ -619,11 +618,12 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
aNewColumns[nOffset] = xNewCol;
}
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
+
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
@@ -638,7 +638,7 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
(*aCellIter++) = getCell( nIndex + nOffset, nRow );
}
- pModel->AddUndo( new InsertColUndo( xThis, nIndex, aNewColumns, aNewCells ) );
+ rModel.AddUndo( new InsertColUndo( xThis, nIndex, aNewColumns, aNewCells ) );
}
const sal_Int32 nRowCount = getRowCountImpl();
@@ -660,11 +660,9 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
}
if( bUndo )
- pModel->EndUndo();
-
- if( pModel )
- pModel->SetChanged();
+ rModel.EndUndo();
+ rModel.SetChanged();
}
catch( Exception& )
{
@@ -691,14 +689,13 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
nCount = nColCount - nIndex;
sal_Int32 nRows = getRowCountImpl();
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
- SdrModel* pModel = mpTableObj->GetModel();
-
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_UNDO_COL_DELETE) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_UNDO_COL_DELETE) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
ColumnVector aRemovedCols( nCount );
@@ -716,7 +713,7 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
(*aCellIter++) = getCell( nIndex + nOffset, nRow );
}
- pModel->AddUndo( new RemoveColUndo( xThis, nIndex, aRemovedCols, aRemovedCells ) );
+ rModel.AddUndo( new RemoveColUndo( xThis, nIndex, aRemovedCols, aRemovedCells ) );
}
// only rows before and inside the removed rows are considered
@@ -769,10 +766,9 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
maRows[nRows]->removeColumns( nIndex, nCount );
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
}
catch( Exception& )
{
@@ -789,8 +785,9 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
{
if( nCount && mpTableObj )
{
- SdrModel* pModel = mpTableObj->GetModel();
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
+
try
{
TableModelNotifyGuard aGuard( this );
@@ -808,10 +805,10 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_INSROW) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
- pModel->AddUndo( new InsertRowUndo( xThis, nIndex, aNewRows ) );
+ rModel.AddUndo( new InsertRowUndo( xThis, nIndex, aNewRows ) );
}
// check if cells merge over new columns
@@ -836,10 +833,9 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
OSL_FAIL("sdr::table::TableModel::insertRows(), exception caught!");
}
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
updateRows();
setModified(true);
@@ -853,8 +849,8 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
if( mpTableObj && nCount && (nIndex >= 0) && (nIndex < nRowCount) )
{
- SdrModel* pModel = mpTableObj->GetModel();
- const bool bUndo = pModel && mpTableObj->IsInserted()&& pModel->IsUndoEnabled();
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
try
{
@@ -866,8 +862,8 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_UNDO_ROW_DELETE) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_UNDO_ROW_DELETE) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
@@ -875,7 +871,7 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset )
aRemovedRows[nOffset] = maRows[nIndex+nOffset];
- pModel->AddUndo( new RemoveRowUndo( xThis, nIndex, aRemovedRows ) );
+ rModel.AddUndo( new RemoveRowUndo( xThis, nIndex, aRemovedRows ) );
}
// only rows before and inside the removed rows are considered
@@ -926,10 +922,9 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
remove_range<RowVector,RowVector::iterator>( maRows, nIndex, nCount );
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
}
catch( Exception& )
{
@@ -1050,10 +1045,11 @@ void TableModel::optimize()
void TableModel::merge( sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan )
{
- SdrModel* pModel = mpTableObj->GetModel();
-
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ if(nullptr == mpTableObj)
+ return;
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
const sal_Int32 nLastRow = nRow + nRowSpan;
const sal_Int32 nLastCol = nCol + nColSpan;
diff --git a/svx/source/table/tablerow.cxx b/svx/source/table/tablerow.cxx
index 43010ad698fe..cf765b47830a 100644
--- a/svx/source/table/tablerow.cxx
+++ b/svx/source/table/tablerow.cxx
@@ -206,14 +206,15 @@ void SAL_CALL TableRow::setName( const OUString& aName )
void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue )
{
- bool bOk = false;
- bool bChange = false;
+ if(!mxTableModel.is() || nullptr == mxTableModel->getSdrTableObj())
+ return;
- TableRowUndo* pUndo = nullptr;
-
- SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
-
- const bool bUndo = mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled();
+ SdrTableObj& rTableObj(*mxTableModel->getSdrTableObj());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ bool bOk(false);
+ bool bChange(false);
+ TableRowUndo* pUndo(nullptr);
+ const bool bUndo(rTableObj.IsInserted() && rModel.IsUndoEnabled());
if( bUndo )
{
@@ -276,6 +277,7 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal
delete pUndo;
throw UnknownPropertyException( OUString::number(nHandle), static_cast<cppu::OWeakObject*>(this));
}
+
if( !bOk )
{
delete pUndo;
@@ -286,7 +288,7 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal
{
if( pUndo )
{
- pModel->AddUndo( pUndo );
+ rModel.AddUndo( pUndo );
pUndo = nullptr;
}
mxTableModel->setModified(true);
diff --git a/svx/source/table/tablertfimporter.cxx b/svx/source/table/tablertfimporter.cxx
index 714e0c62c4ed..b50efb35bc3a 100644
--- a/svx/source/table/tablertfimporter.cxx
+++ b/svx/source/table/tablertfimporter.cxx
@@ -132,8 +132,8 @@ private:
SdrTableRTFParser::SdrTableRTFParser( SdrTableObj& rTableObj )
: mrTableObj( rTableObj )
-, mpOutliner( SdrMakeOutliner( OutlinerMode::TextObject, *rTableObj.GetModel() ) )
-, mrItemPool( rTableObj.GetModel()->GetItemPool() )
+, mpOutliner( SdrMakeOutliner( OutlinerMode::TextObject, rTableObj.getSdrModelFromSdrObject() ) )
+, mrItemPool( rTableObj.getSdrModelFromSdrObject().GetItemPool() )
, mnLastToken( 0 )
, mbNewDef( false )
, mnStartPara( 0 )
diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx
index 9a14948b1dfe..493c895057dc 100644
--- a/svx/source/table/tableundo.cxx
+++ b/svx/source/table/tableundo.cxx
@@ -35,10 +35,10 @@ using namespace ::com::sun::star::table;
namespace sdr { namespace table {
CellUndo::CellUndo( const tools::WeakReference<SdrObject>& xObjRef, const CellRef& xCell )
- : SdrUndoAction( *xCell->GetModel() )
- , mxObjRef( xObjRef )
- , mxCell( xCell )
- , mbUndo( true )
+: SdrUndoAction(xCell->GetObject().getSdrModelFromSdrObject())
+ ,mxObjRef( xObjRef )
+ ,mxCell( xCell )
+ ,mbUndo( true )
{
if( mxCell.is() && mxObjRef.is() )
{
@@ -162,10 +162,10 @@ static void Dispose( RowVector& rRows )
InsertRowUndo::InsertRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aNewRows )
- : SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
- , mxTable( xTable )
- , mnIndex( nIndex )
- , mbUndo( true )
+: SdrUndoAction(xTable->getSdrTableObj()->getSdrModelFromSdrObject())
+ ,mxTable( xTable )
+ ,mnIndex( nIndex )
+ ,mbUndo( true )
{
maRows.swap( aNewRows );
}
@@ -202,10 +202,10 @@ void InsertRowUndo::Redo()
RemoveRowUndo::RemoveRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aRemovedRows )
- : SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
- , mxTable( xTable )
- , mnIndex( nIndex )
- , mbUndo( true )
+: SdrUndoAction(xTable->getSdrTableObj()->getSdrModelFromSdrObject())
+ ,mxTable( xTable )
+ ,mnIndex( nIndex )
+ ,mbUndo( true )
{
maRows.swap( aRemovedRows );
}
@@ -258,10 +258,10 @@ static void Dispose( CellVector& rCells )
InsertColUndo::InsertColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells )
- : SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
- , mxTable( xTable )
- , mnIndex( nIndex )
- , mbUndo( true )
+: SdrUndoAction(xTable->getSdrTableObj()->getSdrModelFromSdrObject())
+ ,mxTable( xTable )
+ ,mnIndex( nIndex )
+ ,mbUndo( true )
{
maColumns.swap( aNewCols );
maCells.swap( aCells );
@@ -302,10 +302,10 @@ void InsertColUndo::Redo()
RemoveColUndo::RemoveColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells )
- : SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
- , mxTable( xTable )
- , mnIndex( nIndex )
- , mbUndo( true )
+: SdrUndoAction(xTable->getSdrTableObj()->getSdrModelFromSdrObject())
+ ,mxTable( xTable )
+ ,mnIndex( nIndex )
+ ,mbUndo( true )
{
maColumns.swap( aNewCols );
maCells.swap( aCells );
@@ -346,9 +346,9 @@ void RemoveColUndo::Redo()
TableColumnUndo::TableColumnUndo( const TableColumnRef& xCol )
- : SdrUndoAction( *xCol->mxTableModel->getSdrTableObj()->GetModel() )
- , mxCol( xCol )
- , mbHasRedoData( false )
+: SdrUndoAction(xCol->mxTableModel->getSdrTableObj()->getSdrModelFromSdrObject())
+ ,mxCol( xCol )
+ ,mbHasRedoData( false )
{
getData( maUndoData );
}
@@ -412,7 +412,7 @@ void TableColumnUndo::getData( Data& rData )
TableRowUndo::TableRowUndo( const TableRowRef& xRow )
- : SdrUndoAction( *xRow->mxTableModel->getSdrTableObj()->GetModel() )
+: SdrUndoAction(xRow->mxTableModel->getSdrTableObj()->getSdrModelFromSdrObject())
, mxRow( xRow )
, mbHasRedoData( false )
{
@@ -475,9 +475,9 @@ void TableRowUndo::getData( Data& rData )
TableStyleUndo::TableStyleUndo( const SdrTableObj& rTableObj )
- : SdrUndoAction( *rTableObj.GetModel() )
- , mxObjRef( const_cast< sdr::table::SdrTableObj*>( &rTableObj ) )
- , mbHasRedoData(false)
+: SdrUndoAction(rTableObj.getSdrModelFromSdrObject())
+ ,mxObjRef( const_cast< sdr::table::SdrTableObj*>( &rTableObj ) )
+ ,mbHasRedoData(false)
{
getData( maUndoData );
}