[PATCH] Create Photo Album fix

Gergő Mocsi (via_Code_Review) gerrit at gerrit.libreoffice.org
Wed Apr 17 02:11:06 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3426

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/26/3426/1

Create Photo Album fix

Fixed some pointer issues in CreateHdl function.
Removed the creation of title slide.
Added an enum to access the image layout option from the code.

Change-Id: Ib91fbbf3b068453c8e66b8df1ce32e24c3828bc0
---
M sd/source/ui/app/strings.src
M sd/source/ui/dlg/PhotoAlbumDialog.cxx
M sd/source/ui/dlg/PhotoAlbumDialog.hxx
M sd/source/ui/inc/strings.hrc
4 files changed, 43 insertions(+), 64 deletions(-)



diff --git a/sd/source/ui/app/strings.src b/sd/source/ui/app/strings.src
index a91003d..928e03e 100644
--- a/sd/source/ui/app/strings.src
+++ b/sd/source/ui/app/strings.src
@@ -1268,19 +1268,14 @@
      Text [ en-US ] = "Drag and Drop Slides" ;
 };
 
-String STR_PHOTO_ALBUM_TITLE
-{
-     Text [ en-US ] = "Photo Album" ;
-};
-
-String STR_PHOTO_ALBUM_AUTHOR
-{
-     Text [ en-US ] = "Author:" ;
-};
-
 String STR_PHOTO_ALBUM_EMPTY_WARNING
 {
      Text [ en-US ] = "Please add images to the album." ;
 };
 
+String STR_PHOTO_ALBUM_TEXTBOX
+{
+    Text [ en-US ] = "Text Box";
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index 4beabeb..5d6ba1e 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
@@ -101,33 +101,12 @@
         Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY );
         Reference< lang::XMultiServiceFactory > xShapeFactory( pDoc->getUnoModel(), uno::UNO_QUERY  );
 
-        // Create the title slide
-        const sal_Int32 nSlideCount = pDoc->GetSdPageCount(PK_STANDARD);
-
-        if(nSlideCount == 1)
-        {
-            // we have created an empty presentation (probably)
-            Reference< drawing::XDrawPage > xTitleSlide = appendNewSlide(AUTOLAYOUT_TITLE, xDrawPages);
-
-            SdPage* pFirstSlide = pDoc->GetSdPage( pDoc->GetSdPageCount(PK_STANDARD)-1, PK_STANDARD);
-            SvtUserOptions aUserOptions;
-            SdrObject* pTitleObj = pFirstSlide->GetPresObj(PRESOBJ_TITLE, 0);
-            SvxShapeText* pTitleText = new SvxShapeText(pTitleObj);
-            pTitleText->SetShapeType("com.sun.star.presentation.TitleTextShape");
-            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< graphic::XGraphicProvider> xProvider(graphic::GraphicProvider::create(xContext));
 
         // get the option
-        OUString sOpt = pInsTypeCombo->GetEntry(pInsTypeCombo->GetSelectEntryPos());
-        if ( sOpt == "Fit to slide")
+        sal_uInt16 nOpt = pInsTypeCombo->GetSelectEntryPos();
+        if ( nOpt == FIT_TO_SLIDE )
         {
             OUString sUrl;
 
@@ -184,11 +163,9 @@
                 {
                     appendNewSlide(AUTOLAYOUT_ONLY_TEXT, xDrawPages);
                 }
-                delete pData;
-                pData = NULL;
             }
         }
-        else if( sOpt == "1 image with title" )
+        else if( nOpt == TITLE_ONE_IMAGE )
         {
             OUString sUrl;
 
@@ -196,7 +173,7 @@
             {
                 OUString* pData = (OUString*) pImagesLst->GetEntryData(i);
                 sUrl = *pData;
-                if ( sUrl != "Text Box" )
+                if ( sUrl != SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX) )
                 {
 
                     Reference< drawing::XDrawPage > xSlide = appendNewSlide(AUTOLAYOUT_NONE, xDrawPages);
@@ -227,11 +204,9 @@
                 {
                     appendNewSlide(AUTOLAYOUT_ONLY_TEXT, xDrawPages);
                 }
-                delete pData;
-                pData = NULL;
             }
         }
-        else if( sOpt == "2 images" )
+        else if( nOpt == TWO_IMAGES )
         {
             OUString sUrl1("");
             OUString sUrl2("");
@@ -252,13 +227,15 @@
                     OUString("Height")) >>= aPageSize.Height;
 
                 // grab the left one
-                pData = (OUString*) pImagesLst->GetEntryData(i);
+                void* pD1 = pImagesLst->GetEntryData(i);
+                pData = (OUString*) pD1;
                 sUrl1 = pData ? OUString(*pData) : "";
                 // grab the right one
-                pData = (OUString*) pImagesLst->GetEntryData(i+1);
+                void* pD2 = pImagesLst->GetEntryData(i+1);
+                pData = (OUString*) pD2;
                 sUrl2 = pData ? OUString(*pData) : "";
 
-                if( sUrl1 == "Text Box" ) // create a Text Box
+                if( sUrl1 == SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX) ) // create a Text Box
                 {
                     SdPage* pSlide = pDoc->GetSdPage( pDoc->GetSdPageCount(PK_STANDARD)-1, PK_STANDARD);
                     pSlide->CreatePresObj(PRESOBJ_TEXT, sal_False, Rectangle(Point(100,100), Point(aPageSize.Width/2-100, aPageSize.Height-100)), sal_True);
@@ -300,7 +277,7 @@
                     xSlide->add(xShape);
                 }
 
-                if( sUrl2 == "Text Box" ) // create a Text Box
+                if( sUrl2 == SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX) ) // create a Text Box
                 {
                     SdPage* pSlide = pDoc->GetSdPage( pDoc->GetSdPageCount(PK_STANDARD)-1, PK_STANDARD);
                     pSlide->CreatePresObj(PRESOBJ_TEXT, sal_False, Rectangle(Point(aPageSize.Width/2 + 100,100), Point(aPageSize.Width-100, aPageSize.Height-100)), sal_True);
@@ -340,11 +317,9 @@
                     xShape->setPosition(aPicPos);
                     xSlide->add(xShape);
                 }
-                delete pData;
-                pData = NULL;
             }
         }
-        else if( sOpt == "4 images" )
+        else if( nOpt == FOUR_IMAGES )
         {
             OUString sUrl1("");
             OUString sUrl2("");
@@ -366,22 +341,26 @@
                     OUString("Height")) >>= aPageSize.Height;
 
                 // grab the upper left one
-                pData = (OUString*) pImagesLst->GetEntryData(i);
+                void* pD1 = pImagesLst->GetEntryData(i);
+                pData = (OUString*) pD1;
                 sUrl1 = pData ? OUString(*pData) : "";
 
                 // grab the upper right one
-                pData = (OUString*) pImagesLst->GetEntryData(i+1);
+                void* pD2 = pImagesLst->GetEntryData(i+1);
+                pData = (OUString*) pD2;
                 sUrl2 = pData ? OUString(*pData) : "";
 
                 // grab the lower left one
-                pData = (OUString*) pImagesLst->GetEntryData(i+2);
+                void* pD3 = pImagesLst->GetEntryData(i+2);
+                pData = (OUString*) pD3;
                 sUrl3 = pData ? OUString(*pData) : "";
 
                 // grab the lower right one
-                pData = (OUString*) pImagesLst->GetEntryData(i+3);
+                void* pD4 = pImagesLst->GetEntryData(i+3);
+                pData = (OUString*) pD4;
                 sUrl4 = pData ? OUString(*pData) : "";
 
-                if( sUrl1 == "Text Box" ) // create a Text Box
+                if( sUrl1 == SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX) ) // create a Text Box
                 {
                     SdPage* pSlide = pDoc->GetSdPage( pDoc->GetSdPageCount(PK_STANDARD)-1, PK_STANDARD);
                     pSlide->CreatePresObj(PRESOBJ_TEXT, sal_False, Rectangle(Point(100,100), Point(aPageSize.Width/2-100, aPageSize.Height/2-100)), sal_True);
@@ -423,7 +402,7 @@
                     xSlide->add(xShape);
                 }
 
-                if( sUrl2 == "Text Box" ) // create a Text Box
+                if( sUrl2 == SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX) ) // create a Text Box
                 {
                     SdPage* pSlide = pDoc->GetSdPage( pDoc->GetSdPageCount(PK_STANDARD)-1, PK_STANDARD);
                     pSlide->CreatePresObj(PRESOBJ_TEXT, sal_False, Rectangle(Point(aPageSize.Width/2 + 100,100), Point(aPageSize.Width-100, aPageSize.Height/2-100)), sal_True);
@@ -464,7 +443,7 @@
                     xSlide->add(xShape);
                 }
 
-                if( sUrl3 == "Text Box" ) // create a Text Box
+                if( sUrl3 == SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX) ) // create a Text Box
                 {
                     SdPage* pSlide = pDoc->GetSdPage( pDoc->GetSdPageCount(PK_STANDARD)-1, PK_STANDARD);
                     pSlide->CreatePresObj(PRESOBJ_TEXT, sal_False, Rectangle(Point(100,aPageSize.Height/2-100), Point(aPageSize.Width/2-100, aPageSize.Height-100)), sal_True);
@@ -507,7 +486,7 @@
                     xSlide->add(xShape);
                 }
 
-                if( sUrl4 == "Text Box" ) // create a Text Box
+                if( sUrl4 == SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX) ) // create a Text Box
                 {
                     SdPage* pSlide = pDoc->GetSdPage( pDoc->GetSdPageCount(PK_STANDARD)-1, PK_STANDARD);
                     pSlide->CreatePresObj(PRESOBJ_TEXT, sal_False, Rectangle(Point(aPageSize.Width/2 + 100,aPageSize.Height/2 - 100), Point(aPageSize.Width-100, aPageSize.Height-100)), sal_True);
@@ -547,8 +526,6 @@
                     xShape->setPosition(aPicPos);
                     xSlide->add(xShape);
                 }
-                delete pData;
-                pData = NULL;
             }
         }
         else
@@ -652,11 +629,11 @@
     sal_Int16 nPos;
     sal_Int16 nInsertPos = pImagesLst->GetSelectEntryPos();
     if (nInsertPos < 0)
-        nPos = pImagesLst->InsertEntry( OUString("Text Box"));
+        nPos = pImagesLst->InsertEntry( OUString(SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX)));
     else
-        nPos = pImagesLst->InsertEntry( OUString("Text Box"), nInsertPos);
+        nPos = pImagesLst->InsertEntry( OUString(SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX)), nInsertPos);
 
-    OUString sStr("Text Box");
+    OUString sStr(SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX));
     pImagesLst->SetEntryData(nPos, (void*)new OUString(sStr));
 
     if(pImagesLst->GetEntryCount() >= 1)
@@ -792,7 +769,7 @@
         pDownBtn->Enable();
     }
 
-    if (sImgUrl != "Text Box")
+    if (sImgUrl != SD_RESSTR(STR_PHOTO_ALBUM_TEXTBOX))
     {
         GraphicFilter aCurFilter;
         Graphic aGraphic;
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.hxx b/sd/source/ui/dlg/PhotoAlbumDialog.hxx
index 98eb458..691edd3 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.hxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.hxx
@@ -95,6 +95,14 @@
     Reference< graphic::XGraphic> createXGraphicFromUrl(const OUString& sUrl,
         Reference< graphic::XGraphicProvider> xProvider);
 
+    enum SlideImageLayout
+    {
+        FIT_TO_SLIDE=0,
+        TITLE_ONE_IMAGE,
+        TWO_IMAGES,
+        FOUR_IMAGES
+    };
+
 };
 
 } // end of namespace sd
diff --git a/sd/source/ui/inc/strings.hrc b/sd/source/ui/inc/strings.hrc
index 9281678..19816b9 100644
--- a/sd/source/ui/inc/strings.hrc
+++ b/sd/source/ui/inc/strings.hrc
@@ -415,9 +415,8 @@
 
 #define STR_ACC_DIALOG_DESC                             (RID_APP_START+728)
 
-#define STR_PHOTO_ALBUM_TITLE                           (RID_APP_START+729)
-#define STR_PHOTO_ALBUM_AUTHOR                          (RID_APP_START+730)
-#define STR_PHOTO_ALBUM_EMPTY_WARNING                   (RID_APP_START+731)
+#define STR_PHOTO_ALBUM_EMPTY_WARNING                   (RID_APP_START+729)
+#define STR_PHOTO_ALBUM_TEXTBOX                   (RID_APP_START+730)
 
 /******************************************************************************
 * The ids in glob.hrc start at RID_APP_START+750!

-- 
To view, visit https://gerrit.libreoffice.org/3426
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib91fbbf3b068453c8e66b8df1ce32e24c3828bc0
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Gergő Mocsi <gmocsi91 at gmail.com>



More information about the LibreOffice mailing list