diff options
-rw-r--r-- | include/vcl/tabdlg.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.hxx | 4 | ||||
-rw-r--r-- | sd/source/ui/dlg/sddlgfact.hxx | 2 | ||||
-rw-r--r-- | test/source/screenshot_test.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/tabdlg.cxx | 70 |
5 files changed, 64 insertions, 20 deletions
diff --git a/include/vcl/tabdlg.hxx b/include/vcl/tabdlg.hxx index d4edb0e3205e..a3c06017b833 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 ddd95932c1ff..f55e48328041 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 eb7597d6f6e4..5ccb90a2ee49 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 a700b8d928e8..012623a42c8c 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 5706e64c6401..335c00c22244 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; + } } } } |