[Libreoffice-commits] core.git: 3 commits - sd/inc sd/source
Caolán McNamara
caolanm at redhat.com
Thu Nov 6 08:07:43 PST 2014
sd/inc/sdpage.hxx | 1
sd/source/core/sdpage.cxx | 19 ++++++++
sd/source/ui/dlg/masterlayoutdlg.cxx | 18 +-------
sd/source/ui/inc/DrawViewShell.hxx | 1
sd/source/ui/view/drviewse.cxx | 74 +++++++++++++++++++++++++++--------
5 files changed, 83 insertions(+), 30 deletions(-)
New commits:
commit e36dae401fc8963c9a92cb2c11d9b650b943c6d3
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Nov 6 15:44:27 2014 +0000
implement toggling off removeable master elements with direct delete
i.e. selecting footers/headers/slidenumber/datetime previes placeholders in
master page view and pressing delete will toggle those master elements off.
Change-Id: I91f745703e43cbb4fdd037da4eab7c8f6bf9fbf5
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index f9b0be3..331b62b 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -626,17 +626,53 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
void DrawViewShell::FuDeleteSelectedObjects()
{
- if ( mpDrawView->IsPresObjSelected(false, true, false, true) )
+ bool bConsumed = false;
+
+ //if any placeholders are selected
+ if (mpDrawView->IsPresObjSelected(false, true, false, false))
+ {
+ //If there are placeholders in the list which can be toggled
+ //off in edit->master->master elements then do that here,
+ std::vector<SdrObject*> aPresMarksToRemove;
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ for (size_t i=0; i < rMarkList.GetMarkCount(); ++i)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ SdPage* pPage = (SdPage*)pObj->GetPage();
+ PresObjKind eKind = pPage->GetPresObjKind(pObj);
+ if (eKind == PRESOBJ_FOOTER || eKind == PRESOBJ_HEADER ||
+ eKind == PRESOBJ_DATETIME || eKind == PRESOBJ_SLIDENUMBER)
+ {
+ aPresMarksToRemove.push_back(pObj);
+ }
+ }
+
+ for (SdrObject* pObj : aPresMarksToRemove)
+ {
+ //Unmark object
+ mpDrawView->MarkObj(pObj, mpDrawView->GetSdrPageView(), true);
+ SdPage* pPage = (SdPage*)pObj->GetPage();
+ //remove placeholder from master page
+ pPage->DestroyDefaultPresObj(pPage->GetPresObjKind(pObj));
+ }
+
+ bConsumed = true;
+ }
+
+ // placeholders which cannot be deleted selected
+ if (mpDrawView->IsPresObjSelected(false, true, false, true))
{
::sd::Window* pWindow = GetActiveWindow();
InfoBox(pWindow, SD_RESSTR(STR_ACTION_NOTPOSSIBLE) ).Execute();
+ bConsumed = true;
}
- else
+
+ if (!bConsumed)
{
::vcl::KeyCode aKCode(KEY_DELETE);
KeyEvent aKEvt( 0, aKCode);
- bool bConsumed = mpDrawView && mpDrawView->getSmartTags().KeyInput( aKEvt );
+ bConsumed = mpDrawView && mpDrawView->getSmartTags().KeyInput( aKEvt );
if( !bConsumed && HasCurrentFunction() )
bConsumed = GetCurrentFunction()->KeyInput(aKEvt);
commit ee2d0d06445b44c3a69b9b0cdd1b474063fed521
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Nov 6 15:18:20 2014 +0000
refactor delete code into FuDeleteSelectedObjects
Change-Id: If6929dfae5e284b1201da5505b9c4e5abceedc6d
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index 42fbabe..4110907 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -221,6 +221,7 @@ public:
void FuTemporary(SfxRequest& rReq);
void FuPermanent(SfxRequest& rReq);
void FuSupport(SfxRequest& rReq);
+ void FuDeleteSelectedObjects();
void FuSupportRotate(SfxRequest& rReq);
void FuTable(SfxRequest& rReq);
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 99fd354..f9b0be3 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -624,6 +624,28 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
}
}
+void DrawViewShell::FuDeleteSelectedObjects()
+{
+ if ( mpDrawView->IsPresObjSelected(false, true, false, true) )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, SD_RESSTR(STR_ACTION_NOTPOSSIBLE) ).Execute();
+ }
+ else
+ {
+ ::vcl::KeyCode aKCode(KEY_DELETE);
+ KeyEvent aKEvt( 0, aKCode);
+
+ bool bConsumed = mpDrawView && mpDrawView->getSmartTags().KeyInput( aKEvt );
+
+ if( !bConsumed && HasCurrentFunction() )
+ bConsumed = GetCurrentFunction()->KeyInput(aKEvt);
+
+ if( !bConsumed && mpDrawView )
+ mpDrawView->DeleteMarked();
+ }
+}
+
void DrawViewShell::FuSupport(SfxRequest& rReq)
{
if( rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs())
@@ -871,23 +893,9 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
pOLV->PostKeyEvent(aKEvt);
}
}
- else if ( mpDrawView->IsPresObjSelected(false, true, false, true) )
- {
- ::sd::Window* pWindow = GetActiveWindow();
- InfoBox(pWindow, SD_RESSTR(STR_ACTION_NOTPOSSIBLE) ).Execute();
- }
else
{
- ::vcl::KeyCode aKCode(KEY_DELETE);
- KeyEvent aKEvt( 0, aKCode);
-
- bool bConsumed = mpDrawView && mpDrawView->getSmartTags().KeyInput( aKEvt );
-
- if( !bConsumed && HasCurrentFunction() )
- bConsumed = GetCurrentFunction()->KeyInput(aKEvt);
-
- if( !bConsumed && mpDrawView )
- mpDrawView->DeleteMarked();
+ FuDeleteSelectedObjects();
}
rReq.Ignore ();
}
commit 8ec5b1a267b229aec50c40c6d2acec1ad48da4b1
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Nov 6 14:59:49 2014 +0000
refactor MasterLayoutDialog::remove to SdPage::DestroyDefaultPresObj
Change-Id: If4edb16b2e94396249f3e2ba99381fcd8341d790
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 391b0ef..767cf39 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -176,6 +176,7 @@ public:
void EnsureMasterPageDefaultBackground();
SdrObject* CreatePresObj(PresObjKind eObjKind, bool bVertical, const Rectangle& rRect, bool bInsert=false);
SdrObject* CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert);
+ void DestroyDefaultPresObj(PresObjKind eObjKind);
SdrObject* GetPresObj(PresObjKind eObjKind, int nIndex = 1, bool bFuzzySearch = false );
PresObjKind GetPresObjKind(SdrObject* pObj) const;
OUString GetPresObjText(PresObjKind eObjKind) const;
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 75e41fb..355400b 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -1019,6 +1019,25 @@ SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind, bool bInsert)
}
}
+void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
+{
+ SdrObject* pObject = GetPresObj( eObjKind );
+
+ if( pObject )
+ {
+ SdDrawDocument *pDoc = static_cast<SdDrawDocument*>(pModel);
+
+ const bool bUndo = pDoc->IsUndoEnabled();
+ if( bUndo )
+ pDoc->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject));
+ SdrObjList* pOL = pObject->GetObjList();
+ pOL->RemoveObject(pObject->GetOrdNumDirect());
+
+ if( !bUndo )
+ SdrObject::Free(pObject);
+ }
+}
+
/*************************************************************************
|*
|* return title area
diff --git a/sd/source/ui/dlg/masterlayoutdlg.cxx b/sd/source/ui/dlg/masterlayoutdlg.cxx
index d9e525f..8400372 100644
--- a/sd/source/ui/dlg/masterlayoutdlg.cxx
+++ b/sd/source/ui/dlg/masterlayoutdlg.cxx
@@ -121,26 +121,14 @@ void MasterLayoutDialog::applyChanges()
mpDoc->EndUndo();
}
-void MasterLayoutDialog::create( PresObjKind eKind )
+void MasterLayoutDialog::create(PresObjKind eKind)
{
- mpCurrentPage->CreateDefaultPresObj( eKind, true );
+ mpCurrentPage->CreateDefaultPresObj(eKind, true);
}
void MasterLayoutDialog::remove( PresObjKind eKind )
{
- SdrObject* pObject = mpCurrentPage->GetPresObj( eKind );
-
- if( pObject )
- {
- const bool bUndo = mpDoc->IsUndoEnabled();
- if( bUndo )
- mpDoc->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject));
- SdrObjList* pOL =pObject->GetObjList();
- pOL->RemoveObject(pObject->GetOrdNumDirect());
-
- if( !bUndo )
- SdrObject::Free(pObject);
- }
+ mpCurrentPage->DestroyDefaultPresObj(eKind);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list