summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <s.mehrbrodt@gmail.com>2013-05-11 17:56:23 +0200
committerBosdonnat Cedric <cedric.bosdonnat@free.fr>2013-05-13 14:27:55 +0000
commit1c7af341d068e4474774077524ccc15721ea3df3 (patch)
treee522afa122706c780fad8028c57d46dc1bc1cd25
parentf34c31560bb29f90d579a795cd9f7707163c025f (diff)
Related fdo#35546: Simplyfy Code in Photo Album Dialog
Create a method for enabling/disabling the Up/Down/Remove buttons. This also fixes some wrong behavior. Change-Id: Ie40a4f3bb4402b988071b315617404c802b7e92a Reviewed-on: https://gerrit.libreoffice.org/3855 Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr> Tested-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
-rw-r--r--sd/source/ui/dlg/PhotoAlbumDialog.cxx86
-rw-r--r--sd/source/ui/dlg/PhotoAlbumDialog.hxx2
2 files changed, 17 insertions, 71 deletions
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index 2771166e7745..351a9d8171ef 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
@@ -597,19 +597,6 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl)
OSL_FAIL("Could not find config for Create Photo Album function");
}
- if( aFilesArr.getLength() == 1)
- {
- pRemoveBtn->Enable();
- pUpBtn->Disable();
- pDownBtn->Disable();
- }
- else
- {
- pRemoveBtn->Enable();
- pUpBtn->Enable();
- pDownBtn->Enable();
- }
-
for ( sal_Int32 i = 0; i < aFilesArr.getLength(); i++ )
{
// Store full path, show filename only. Use INetURLObject to display spaces in filename correctly
@@ -619,6 +606,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl)
}
}
}
+ EnableDisableButtons();
return 0;
}
@@ -634,12 +622,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, TextHdl)
OUString sStr(SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX));
pImagesLst->SetEntryData(nPos, (void*)new OUString(sStr));
- if(pImagesLst->GetEntryCount() >= 1)
- {
- pRemoveBtn->Enable();
- pUpBtn->Disable();
- pDownBtn->Disable();
- }
+ EnableDisableButtons();
return 0;
}
@@ -669,16 +652,9 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, UpHdl)
pImagesLst->SetEntryData( nActPos, (void*) new OUString(sUpper));
pImagesLst->SelectEntryPos(nActPos - 1);
-
- pDownBtn->Enable();
-
}
- if(pImagesLst->GetSelectEntryPos() == 0)
- {
- pDownBtn->Enable();
- pUpBtn->Disable();
- }
+ EnableDisableButtons();
return 0;
}
@@ -707,16 +683,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, DownHdl)
pImagesLst->SelectEntryPos(nActPos + 1);
}
-
- if(pImagesLst->GetEntry(pImagesLst->GetSelectEntryPos() + 1) != OUString(""))
- {
- pDownBtn->Enable();
- pUpBtn->Enable();
- }
- else
- {
- pDownBtn->Disable();
- }
+ EnableDisableButtons();
return 0;
}
@@ -725,18 +692,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, RemoveHdl)
pImagesLst->RemoveEntry( pImagesLst->GetSelectEntryPos() );
pImg->SetImage(Image());
- if(pImagesLst->GetEntryCount() >= 1)
- {
- pRemoveBtn->Enable();
- pUpBtn->Disable();
- pDownBtn->Disable();
- }
- else
- {
- pRemoveBtn->Disable();
- pUpBtn->Disable();
- pDownBtn->Disable();
- }
+ EnableDisableButtons();
return 0;
}
@@ -744,27 +700,6 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, SelectHdl)
{
OUString* pData = (OUString*) pImagesLst->GetEntryData(pImagesLst->GetSelectEntryPos());
OUString sImgUrl = pData ? OUString(*pData) : "";
- // Some UI functionality: if you select the first/last item in the list,
- // the Up/Down button gets enabled/diabled (meaning: you cannot move up/down the item)
- // disable/enable moving up
- if(pImagesLst->GetSelectEntryPos() == 0)
- {
- pUpBtn->Disable();
- }
- else
- {
- pUpBtn->Enable();
- }
-
- // disable/enable moving down
- if(pImagesLst->GetEntry(pImagesLst->GetSelectEntryPos() + 1) == OUString(""))
- {
- pDownBtn->Disable();
- }
- else
- {
- pDownBtn->Enable();
- }
if (sImgUrl != SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX))
{
@@ -817,7 +752,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, SelectHdl)
{
pImg->SetImage(Image());
}
-
+ EnableDisableButtons();
return 0;
}
@@ -893,6 +828,15 @@ short SdPhotoAlbumDialog::Execute()
return ModalDialog::Execute();
}
+void SdPhotoAlbumDialog::EnableDisableButtons()
+{
+ pRemoveBtn->Enable(pImagesLst->GetSelectEntryCount() > 0);
+ pUpBtn->Enable(pImagesLst->GetSelectEntryCount() > 0 &&
+ pImagesLst->GetSelectEntryPos() != 0);
+ pDownBtn->Enable(pImagesLst->GetSelectEntryCount() > 0 &&
+ pImagesLst->GetSelectEntryPos() < pImagesLst->GetEntryCount()-1);
+}
+
} // end of namespace sd
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.hxx b/sd/source/ui/dlg/PhotoAlbumDialog.hxx
index 9a68ba9cb893..3e751285beb1 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.hxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.hxx
@@ -93,6 +93,8 @@ private:
Reference< graphic::XGraphic> createXGraphicFromUrl(const OUString& sUrl,
Reference< graphic::XGraphicProvider> xProvider);
+ void EnableDisableButtons();
+
enum SlideImageLayout
{
FIT_TO_SLIDE=0,