Kaydet (Commit) d99f5296 authored tarafından Gergő Mocsi's avatar Gergő Mocsi Kaydeden (comit) Andras Timar

Create Photo Album implementation

UI tweaks: dialog window open in all modes (Normal, Outline, Slide Sorter, ..).
Fixed some pointer issues in function CreateHdl).
Functionality: Title slide gets inserted only when we have one slide in the
presentation (having > 1, I assume that we don't have an empty presentation).

Conflicts:

	sd/source/ui/dlg/PhotoAlbumDialog.cxx

Change-Id: I7eb844bf2382a44481435cfaa8f498e29c56bd69
üst 5acb6ad0
...@@ -102,19 +102,25 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl) ...@@ -102,19 +102,25 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl)
Reference< lang::XMultiServiceFactory > xShapeFactory( pDoc->getUnoModel(), uno::UNO_QUERY ); Reference< lang::XMultiServiceFactory > xShapeFactory( pDoc->getUnoModel(), uno::UNO_QUERY );
// Create the title slide // Create the title slide
Reference< drawing::XDrawPage > xTitleSlide = appendNewSlide(AUTOLAYOUT_TITLE, xDrawPages); const sal_Int32 nSlideCount = pDoc->GetSdPageCount(PK_STANDARD);
SdPage* pFirstSlide = pDoc->GetSdPage( pDoc->GetSdPageCount(PK_STANDARD)-1, PK_STANDARD); if(nSlideCount == 1)
SvtUserOptions aUserOptions; {
SdrObject* pTitleObj = pFirstSlide->GetPresObj(PRESOBJ_TITLE, 0); // we have created an empty presentation (probably)
SvxShapeText* pTitleText = new SvxShapeText(pTitleObj); Reference< drawing::XDrawPage > xTitleSlide = appendNewSlide(AUTOLAYOUT_TITLE, xDrawPages);
pTitleText->SetShapeType("com.sun.star.presentation.TitleTextShape");
pTitleText->setString(SD_RESSTR(STR_PHOTO_ALBUM_TITLE)); SdPage* pFirstSlide = pDoc->GetSdPage( pDoc->GetSdPageCount(PK_STANDARD)-1, PK_STANDARD);
SvtUserOptions aUserOptions;
SdrObject* pTextObj = pFirstSlide->GetPresObj(PRESOBJ_TEXT, 0); SdrObject* pTitleObj = pFirstSlide->GetPresObj(PRESOBJ_TITLE, 0);
SvxShapeText* pTextShape = new SvxShapeText(pTextObj); SvxShapeText* pTitleText = new SvxShapeText(pTitleObj);
pTextShape->SetShapeType("com.sun.star.presentation.TextShape"); pTitleText->SetShapeType("com.sun.star.presentation.TitleTextShape");
pTextShape->setString(SD_RESSTR(STR_PHOTO_ALBUM_AUTHOR) + " " + aUserOptions.GetFullName()); pTitleText->setString(SD_RESSTR(STR_PHOTO_ALBUM_TITLE));
SdrObject* pTextObj = pFirstSlide->GetPresObj(PRESOBJ_TEXT, 0);
SvxShapeText* pTextShape = new SvxShapeText(pTextObj);
pTextShape->SetShapeType("com.sun.star.presentation.TextShape");
pTextShape->setString(SD_RESSTR(STR_PHOTO_ALBUM_AUTHOR) + " " + aUserOptions.GetFullName());
}
Reference< XComponentContext > xContext(::comphelper::getProcessComponentContext()); Reference< XComponentContext > xContext(::comphelper::getProcessComponentContext());
Reference< graphic::XGraphicProvider> xProvider(graphic::GraphicProvider::create(xContext)); Reference< graphic::XGraphicProvider> xProvider(graphic::GraphicProvider::create(xContext));
...@@ -124,10 +130,10 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl) ...@@ -124,10 +130,10 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl)
if ( sOpt == "Fit to slide") if ( sOpt == "Fit to slide")
{ {
OUString sUrl; OUString sUrl;
OUString* pData = NULL;
for( sal_Int16 i = 0; i < pImagesLst->GetEntryCount(); ++i ) for( sal_Int16 i = 0; i < pImagesLst->GetEntryCount(); ++i )
{ {
pData = (OUString*) pImagesLst->GetEntryData(i); OUString* pData = (OUString*) pImagesLst->GetEntryData(i);
sUrl = *pData; sUrl = *pData;
if (sUrl != "Text Box") if (sUrl != "Text Box")
{ {
...@@ -178,16 +184,17 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl) ...@@ -178,16 +184,17 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl)
{ {
appendNewSlide(AUTOLAYOUT_ONLY_TEXT, xDrawPages); appendNewSlide(AUTOLAYOUT_ONLY_TEXT, xDrawPages);
} }
delete pData;
pData = NULL;
} }
delete pData;
} }
else if( sOpt == "1 image with title" ) else if( sOpt == "1 image with title" )
{ {
OUString sUrl; OUString sUrl;
OUString* pData = NULL;
for( sal_Int16 i = 0; i < pImagesLst->GetEntryCount(); ++i ) for( sal_Int16 i = 0; i < pImagesLst->GetEntryCount(); ++i )
{ {
pData = (OUString*) pImagesLst->GetEntryData(i); OUString* pData = (OUString*) pImagesLst->GetEntryData(i);
sUrl = *pData; sUrl = *pData;
if ( sUrl != "Text Box" ) if ( sUrl != "Text Box" )
{ {
...@@ -220,17 +227,19 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl) ...@@ -220,17 +227,19 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl)
{ {
appendNewSlide(AUTOLAYOUT_ONLY_TEXT, xDrawPages); appendNewSlide(AUTOLAYOUT_ONLY_TEXT, xDrawPages);
} }
delete pData;
pData = NULL;
} }
delete pData;
} }
else if( sOpt == "2 images" ) else if( sOpt == "2 images" )
{ {
OUString sUrl1(""); OUString sUrl1("");
OUString sUrl2(""); OUString sUrl2("");
OUString* pData = NULL;
for( sal_Int32 i = 0; i < pImagesLst->GetEntryCount(); i+=2 ) for( sal_Int32 i = 0; i < pImagesLst->GetEntryCount(); i+=2 )
{ {
OUString* pData = NULL;
// create the slide // create the slide
Reference< drawing::XDrawPage > xSlide = appendNewSlide(AUTOLAYOUT_NONE, xDrawPages); Reference< drawing::XDrawPage > xSlide = appendNewSlide(AUTOLAYOUT_NONE, xDrawPages);
Reference< beans::XPropertySet > xSlideProps( xSlide, uno::UNO_QUERY ); Reference< beans::XPropertySet > xSlideProps( xSlide, uno::UNO_QUERY );
...@@ -331,9 +340,9 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl) ...@@ -331,9 +340,9 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl)
xShape->setPosition(aPicPos); xShape->setPosition(aPicPos);
xSlide->add(xShape); xSlide->add(xShape);
} }
delete pData;
pData = NULL;
} }
delete pData;
} }
else if( sOpt == "4 images" ) else if( sOpt == "4 images" )
{ {
...@@ -341,10 +350,10 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl) ...@@ -341,10 +350,10 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl)
OUString sUrl2(""); OUString sUrl2("");
OUString sUrl3(""); OUString sUrl3("");
OUString sUrl4(""); OUString sUrl4("");
OUString* pData = NULL;
for( sal_Int32 i = 0; i < pImagesLst->GetEntryCount(); i+=4 ) for( sal_Int32 i = 0; i < pImagesLst->GetEntryCount(); i+=4 )
{ {
OUString* pData = NULL;
// create the slide // create the slide
Reference< drawing::XDrawPage > xSlide = appendNewSlide(AUTOLAYOUT_NONE, xDrawPages); Reference< drawing::XDrawPage > xSlide = appendNewSlide(AUTOLAYOUT_NONE, xDrawPages);
Reference< beans::XPropertySet > xSlideProps( xSlide, uno::UNO_QUERY ); Reference< beans::XPropertySet > xSlideProps( xSlide, uno::UNO_QUERY );
...@@ -538,8 +547,9 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl) ...@@ -538,8 +547,9 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl)
xShape->setPosition(aPicPos); xShape->setPosition(aPicPos);
xSlide->add(xShape); xSlide->add(xShape);
} }
delete pData;
pData = NULL;
} }
delete pData;
} }
else else
{ {
...@@ -560,9 +570,10 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl) ...@@ -560,9 +570,10 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl)
); );
// Read configuration // Read configuration
OUString sUrl("."); OUString sUrl(".");
Reference< XInterface > xCfg;
try try
{ {
Reference< XInterface > xCfg = ::comphelper::ConfigurationHelper::openConfig( xCfg = ::comphelper::ConfigurationHelper::openConfig(
::comphelper::getProcessComponentContext(), ::comphelper::getProcessComponentContext(),
OUString("/org.openoffice.Office.Impress/"), OUString("/org.openoffice.Office.Impress/"),
::comphelper::ConfigurationHelper::E_READONLY); ::comphelper::ConfigurationHelper::E_READONLY);
...@@ -593,18 +604,18 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl) ...@@ -593,18 +604,18 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl)
// Write out configuration // Write out configuration
try try
{ {
Reference< XInterface > xCfgWriter = ::comphelper::ConfigurationHelper::openConfig( xCfg = ::comphelper::ConfigurationHelper::openConfig(
::comphelper::getProcessComponentContext(), ::comphelper::getProcessComponentContext(),
OUString("/org.openoffice.Office.Impress/"), OUString("/org.openoffice.Office.Impress/"),
::comphelper::ConfigurationHelper::E_STANDARD); ::comphelper::ConfigurationHelper::E_STANDARD);
::comphelper::ConfigurationHelper::writeRelativeKey( ::comphelper::ConfigurationHelper::writeRelativeKey(
xCfgWriter, xCfg,
OUString("Pictures"), OUString("Pictures"),
OUString("Path"), OUString("Path"),
uno::makeAny(sUrl)); uno::makeAny(sUrl));
::comphelper::ConfigurationHelper::flush(xCfgWriter); ::comphelper::ConfigurationHelper::flush(xCfg);
} }
catch(const Exception&) catch(const Exception&)
{ {
...@@ -897,6 +908,7 @@ Reference< graphic::XGraphic> SdPhotoAlbumDialog::createXGraphicFromUrl(const OU ...@@ -897,6 +908,7 @@ Reference< graphic::XGraphic> SdPhotoAlbumDialog::createXGraphicFromUrl(const OU
Reference< graphic::XGraphicProvider> xProvider Reference< graphic::XGraphicProvider> xProvider
) )
{ {
// The same as above, except this returns an XGraphic from the image URL
::comphelper::NamedValueCollection aMediaProperties; ::comphelper::NamedValueCollection aMediaProperties;
aMediaProperties.put( "URL", OUString( sUrl ) ); aMediaProperties.put( "URL", OUString( sUrl ) );
Reference< graphic::XGraphic> xGraphic = Reference< graphic::XGraphic> xGraphic =
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
#include "glob.hrc" #include "glob.hrc"
#include "unmodpg.hxx" #include "unmodpg.hxx"
#include "DrawViewShell.hxx" #include "DrawViewShell.hxx"
#include "sdabstdlg.hxx"
#include <sfx2/request.hxx> #include <sfx2/request.hxx>
#include <sfx2/viewfrm.hxx> #include <sfx2/viewfrm.hxx>
...@@ -263,6 +264,22 @@ void SlotManager::FuTemporary (SfxRequest& rRequest) ...@@ -263,6 +264,22 @@ void SlotManager::FuTemporary (SfxRequest& rRequest)
} }
break; break;
case SID_PHOTOALBUM:
{
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
VclAbstractDialog* pDlg = pFact ? pFact->CreateSdPhotoAlbumDialog(
mrSlideSorter.GetContentWindow().get(),
pDocument) : 0;
if (pDlg)
{
pDlg->Execute();
delete pDlg;
}
rRequest.Done ();
}
break;
default: default:
break; break;
} }
......
...@@ -295,6 +295,23 @@ void OutlineViewShell::FuTemporary(SfxRequest &rReq) ...@@ -295,6 +295,23 @@ void OutlineViewShell::FuTemporary(SfxRequest &rReq)
Cancel(); Cancel();
} }
break; break;
case SID_PHOTOALBUM:
{
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
VclAbstractDialog* pDlg = pFact ? pFact->CreateSdPhotoAlbumDialog(
GetActiveWindow(),
GetDoc()) : 0;
if (pDlg)
{
pDlg->Execute();
delete pDlg;
}
Cancel();
rReq.Ignore ();
}
break;
} }
if(HasCurrentFunction()) if(HasCurrentFunction())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment