[Libreoffice-commits] core.git: Branch 'feature/dialog-screenshots' - include/vcl sc/source sd/source test/source vcl/source

Armin Le Grand Armin.Le.Grand at cib.de
Thu Jul 28 15:13:39 UTC 2016


 include/vcl/tabdlg.hxx             |    4 +-
 sc/source/ui/attrdlg/scdlgfact.hxx |    4 +-
 sd/source/ui/dlg/sddlgfact.hxx     |    2 -
 test/source/screenshot_test.cxx    |    4 +-
 vcl/source/window/tabdlg.cxx       |   70 ++++++++++++++++++++++++++++++-------
 5 files changed, 64 insertions(+), 20 deletions(-)

New commits:
commit ab8cf5c023c4564397fd78d8ddfc83528859e278
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Thu Jul 28 17:10:15 2016 +0200

    Changes for clang andUXMLDescription usage
    
    Adapted clang compiler reesults, made TabDialog implementaions
    of ScreenShot API work with real UXMLDescription names, including
    a solution for using multiple tabPages with the same *.ui file
    
    Change-Id: I56df878b3db3bcc18fa2b4713b7ad72d42e8eb30

diff --git a/include/vcl/tabdlg.hxx b/include/vcl/tabdlg.hxx
index d4edb0e..a3c0601 100644
--- a/include/vcl/tabdlg.hxx
+++ b/include/vcl/tabdlg.hxx
@@ -51,8 +51,8 @@ public:
     void                SetViewAlign( WindowAlign eAlign ) { meViewAlign = eAlign; }
 
     // Screenshot interface
-    virtual std::vector<OString> getAllPageUIXMLDescriptions() const;
-    virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription);
+    virtual std::vector<OString> getAllPageUIXMLDescriptions() const override;
+    virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription) override;
 };
 
 #endif // INCLUDED_VCL_TABDLG_HXX
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 19cc0f3..514047b 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -65,10 +65,10 @@ public:                                             \
                      {}                             \
     virtual         ~Class();                       \
     virtual short   Execute() override ;            \
-    std::vector<OString> getAllPageUIXMLDescriptions() const; \
+    std::vector<OString> getAllPageUIXMLDescriptions() const override; \
     bool selectPageByUIXMLDescription(const OString& rUIXMLDescription) override; \
     virtual Bitmap  createScreenshot() const override; \
-    virtual OString GetScreenshotId() const; \
+    virtual OString GetScreenshotId() const override; \
 
 #define DECL_ABSTDLG2_BASE(Class,DialogClass)       \
     ScopedVclPtr<DialogClass> pDlg;                 \
diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx
index 9bb135c..a52bc14 100644
--- a/sd/source/ui/dlg/sddlgfact.hxx
+++ b/sd/source/ui/dlg/sddlgfact.hxx
@@ -32,7 +32,7 @@ public:                                                 \
     virtual std::vector<OString> getAllPageUIXMLDescriptions() const override; \
     virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription) override; \
     virtual Bitmap createScreenshot() const override;   \
-    virtual OString GetScreenshotId() const;   \
+    virtual OString GetScreenshotId() const override;   \
     virtual         ~Class();                           \
     virtual short   Execute() override ;
 
diff --git a/test/source/screenshot_test.cxx b/test/source/screenshot_test.cxx
index a700b8d..012623a 100644
--- a/test/source/screenshot_test.cxx
+++ b/test/source/screenshot_test.cxx
@@ -131,7 +131,7 @@ void ScreenshotTest::dumpDialogToPath(VclAbstractDialog& rDialog)
 
     if (aPageDescriptions.size())
     {
-        for (sal_uInt32 a(0); a < aPageDescriptions.size(); a++)
+        for (size_t a(0); a < aPageDescriptions.size(); a++)
         {
             if (rDialog.selectPageByUIXMLDescription(aPageDescriptions[a]))
             {
@@ -155,7 +155,7 @@ void ScreenshotTest::dumpDialogToPath(Dialog& rDialog)
 
     if (aPageDescriptions.size())
     {
-        for (sal_uInt32 a(0); a < aPageDescriptions.size(); a++)
+        for (size_t a(0); a < aPageDescriptions.size(); a++)
         {
             if (rDialog.selectPageByUIXMLDescription(aPageDescriptions[a]))
             {
diff --git a/vcl/source/window/tabdlg.cxx b/vcl/source/window/tabdlg.cxx
index 5706e64..335c00c 100644
--- a/vcl/source/window/tabdlg.cxx
+++ b/vcl/source/window/tabdlg.cxx
@@ -290,12 +290,32 @@ std::vector<OString> TabDialog::getAllPageUIXMLDescriptions() const
 
                 if (pCandidate)
                 {
-                    // use UIXMLDescription (without '.ui', with '/')
-                    // aRetval.push_back(pCandidate->getUIFile());
+                    OString aNewName(pCandidate->getUIFile());
 
-                    // for now, directly use nPageID since we had a case where
-                    // two TabPages had the same ui file (HeaderFooterDialog)
-                    aRetval.push_back(OString::number(nPageId));
+                    if (!aNewName.isEmpty())
+                    {
+                        // we have to check for double entries, this may happen e.g.
+                        // in the HeaderFooterDialog which has two times the same
+                        // tabPage added. Add the PageID as hint to the name, separated
+                        // by a token (using "|" here). Do not do this for 1st ocurrence,
+                        // that is used for detection and is not necessary.
+                        // Use the UIXMLDescription without trailing '.ui', with one trailing '/'
+                        bool bAlreadyAdded(false);
+
+                        for (auto i = aRetval.begin(); !bAlreadyAdded && i != aRetval.end(); i++)
+                        {
+                            bAlreadyAdded = (*i == aNewName);
+                        }
+
+                        if (bAlreadyAdded)
+                        {
+                            // add the PageId to be able to detect the correct tabPage in
+                            // selectPageByUIXMLDescription below
+                            aNewName = aNewName + "|" + OString::number(nPageId);
+                        }
+
+                        aRetval.push_back(aNewName);
+                    }
                 }
             }
         }
@@ -310,6 +330,19 @@ bool TabDialog::selectPageByUIXMLDescription(const OString& rUIXMLDescription)
 
     if (pTabCtrl)
     {
+        sal_uInt32 nTargetPageId(0);
+        OString aTargetName(rUIXMLDescription);
+        const sal_Int32 nIndexOfSeparator(rUIXMLDescription.indexOf("|"));
+
+        if (-1 != nIndexOfSeparator)
+        {
+            // more than one tabPage with that UXMLDescription is added to this dialog,
+            // see getAllPageUIXMLDescriptions() above. Extract target PageId and
+            // strip the UXMLDescription name for comparison
+            nTargetPageId = rUIXMLDescription.copy(nIndexOfSeparator + 1).toUInt32();
+            aTargetName = rUIXMLDescription.copy(0, nIndexOfSeparator);
+        }
+
         for (sal_uInt16 a(0); a < pTabCtrl->GetPageCount(); a++)
         {
             const sal_uInt16 nPageId(pTabCtrl->GetPageId(a));
@@ -320,15 +353,26 @@ bool TabDialog::selectPageByUIXMLDescription(const OString& rUIXMLDescription)
 
                 if (pCandidate)
                 {
-                    // if (pCandidate->getUIFile() == rUIXMLDescription)
-
-                    // for now, directly work with nPageID, see above. Will need to be
-                    // adapted to the schema later planned to be used in rUIXMLDescription
-                    if (rUIXMLDescription.toUInt32() == nPageId)
+                    if (pCandidate->getUIFile() == aTargetName)
                     {
-                        pTabCtrl->SelectTabPage(nPageId);
-
-                        return true;
+                        if (nTargetPageId)
+                        {
+                            // when multiple versions may exist, name is not sufficient. Also
+                            // check for the given PageId to select the correct tabPage
+                            // for cases where the same TabPage is used more than once
+                            // in a tabDialog (e.g. HeaderFooterDialog)
+                            if (nTargetPageId == nPageId)
+                            {
+                                pTabCtrl->SelectTabPage(nPageId);
+                                return true;
+                            }
+                        }
+                        else
+                        {
+                            // select that tabPage
+                            pTabCtrl->SelectTabPage(nPageId);
+                            return true;
+                        }
                     }
                 }
             }


More information about the Libreoffice-commits mailing list