diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2016-06-15 17:53:52 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2016-08-18 02:39:07 +0200 |
commit | 3fb0839da320bb2256b7a2dcf46363fc25bbfbc9 (patch) | |
tree | 8f31da02adb34e2cc99d49607b956e0b16ee8a96 | |
parent | eab85ed43846c7304980c098522f51de7ff11da8 (diff) |
screenshots: extend default paths where stuff gets written
Change-Id: I1886d832bb9474371ea27d4d36f0446b221246d0
-rw-r--r-- | include/sfx2/tabdlg.hxx | 3 | ||||
-rw-r--r-- | include/vcl/abstdlg.hxx | 7 | ||||
-rw-r--r-- | include/vcl/dialog.hxx | 12 | ||||
-rw-r--r-- | include/vcl/window.hxx | 2 | ||||
-rw-r--r-- | sd/Module_sd.mk | 1 | ||||
-rw-r--r-- | sd/inc/sdabstdlg.hxx | 2 | ||||
-rw-r--r-- | sd/source/filter/html/pubdlg.cxx | 26 | ||||
-rw-r--r-- | sd/source/ui/dlg/sddlgfact.hxx | 22 | ||||
-rw-r--r-- | sd/source/ui/inc/pubdlg.hxx | 4 | ||||
-rw-r--r-- | sfx2/source/dialog/tabdlg.cxx | 50 | ||||
-rw-r--r-- | vcl/source/app/settings.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/abstdlg.cxx | 17 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 44 | ||||
-rw-r--r-- | vcl/source/window/paint.cxx | 11 |
14 files changed, 192 insertions, 11 deletions
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx index b374cddb2fb0..85429068d0a8 100644 --- a/include/sfx2/tabdlg.hxx +++ b/include/sfx2/tabdlg.hxx @@ -203,6 +203,9 @@ public: bool Apply(); virtual FactoryFunction GetUITestFactory() const override; + // Screenshot interface + virtual std::vector<OUString> getAllPageUIXMLDescriptions() const override; + virtual void selectPageByUIXMLDescription(const OUString& rUIXMLDescription) override; }; namespace sfx { class ItemConnectionBase; } diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx index 25b28c7d5510..da45dbe2f13a 100644 --- a/include/vcl/abstdlg.hxx +++ b/include/vcl/abstdlg.hxx @@ -26,13 +26,18 @@ namespace vcl { class Window; } class ResId; class Dialog; +class Bitmap; class VCL_DLLPUBLIC VclAbstractDialog { public: virtual ~VclAbstractDialog(); - virtual short Execute() = 0; + + // Screenshot interface + virtual std::vector<OUString> getAllPageUIXMLDescriptions() const; + virtual void selectPageByUIXMLDescription(const OUString& rUIXMLDescription); + virtual Bitmap createScreenshot() const; }; class VCL_DLLPUBLIC VclAbstractDialog2 diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index 466b3e36d8d8..a1ec41f9825d 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -42,6 +42,7 @@ private: bool mbInExecute; bool mbInClose; bool mbModalMode; + bool mbPaintComplete; InitFlag mnInitFlag; // used for deferred init VclPtr<VclButtonBox> mpActionArea; @@ -93,6 +94,17 @@ public: virtual bool Close() override; + // try to extract content and return as Bitmap. To do that reliably, a Yield-loop + // like in Execute() has to be executed and it is necessary to detect when the + // paint is finished + virtual void PrePaint(vcl::RenderContext& rRenderContext) override; + virtual void PostPaint(vcl::RenderContext& rRenderContext) override; + + // Screenshot interface + virtual std::vector<OUString> getAllPageUIXMLDescriptions() const; + virtual void selectPageByUIXMLDescription(const OUString& rUIXMLDescription); + Bitmap createScreenshot(); + virtual short Execute(); bool IsInExecute() const { return mbInExecute; } diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index ef5135bd1be1..b8211dec0a32 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -804,6 +804,8 @@ public: virtual void KeyUp( const KeyEvent& rKEvt ); virtual void PrePaint(vcl::RenderContext& rRenderContext); virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect); + virtual void PostPaint(vcl::RenderContext& rRenderContext); + using OutputDevice::Erase; void Erase(vcl::RenderContext& rRenderContext); diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk index a6b4f9defb0d..01f23aaabdd9 100644 --- a/sd/Module_sd.mk +++ b/sd/Module_sd.mk @@ -34,6 +34,7 @@ $(eval $(call gb_Module_add_check_targets,sd,\ CppunitTest_sd_export_ooxml2 \ CppunitTest_sd_export_tests \ CppunitTest_sd_filters_test \ + CppunitTest_sd_dialogs_test \ CppunitTest_sd_misc_tests \ CppunitTest_sd_html_export_tests \ )) diff --git a/sd/inc/sdabstdlg.hxx b/sd/inc/sdabstdlg.hxx index 2c4f5b6bfe78..5b7e3b921264 100644 --- a/sd/inc/sdabstdlg.hxx +++ b/sd/inc/sdabstdlg.hxx @@ -150,7 +150,7 @@ class AbstractHeaderFooterDialog : public VclAbstractDialog class SdAbstractDialogFactory { public: - static SdAbstractDialogFactory* Create(); + SD_DLLPUBLIC static SdAbstractDialogFactory* Create(); virtual VclAbstractDialog* CreateBreakDlg(vcl::Window* pWindow, ::sd::DrawView* pDrView, ::sd::DrawDocShell* pShell, sal_uLong nSumActionCount, sal_uLong nObjCount ) = 0; virtual AbstractCopyDlg* CreateCopyDlg(vcl::Window* pWindow, const SfxItemSet& rInAttrs, const rtl::Reference<XColorList> &pColTab, ::sd::View* pView ) = 0; diff --git a/sd/source/filter/html/pubdlg.cxx b/sd/source/filter/html/pubdlg.cxx index a926105d31c6..2b913abdc537 100644 --- a/sd/source/filter/html/pubdlg.cxx +++ b/sd/source/filter/html/pubdlg.cxx @@ -1586,6 +1586,32 @@ bool SdPublishingDlg::Save() return( aMedium.GetError() == 0 ); } +std::vector<OUString> SdPublishingDlg::getAllPageUIXMLDescriptions() const +{ + // this dialog has a hard number of pages + std::vector<OUString> aRetval; + + for (sal_uInt32 a(0); a < 6; a++) + { + aRetval.push_back(OUString::number(a)); + } + + return aRetval; +} + +void SdPublishingDlg::selectPageByUIXMLDescription(const OUString& rUIXMLDescription) +{ + // rUIXMLDescription contains one of the values above, make use of it + const sal_uInt32 nPage(rUIXMLDescription.toUInt32()); + + if (nPage < 6) + { + aAssistentFunc.GotoPage(nPage + 1); + + // does this already call 'ChangePage()'..? Check! + } +} + // SdDesignNameDlg Methods SdDesignNameDlg::SdDesignNameDlg(vcl::Window* pWindow, const OUString& aName) : ModalDialog(pWindow, "NameDesignDialog", "modules/sdraw/ui/namedesign.ui") diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx index c5ec43014349..c9a9352212bf 100644 --- a/sd/source/ui/dlg/sddlgfact.hxx +++ b/sd/source/ui/dlg/sddlgfact.hxx @@ -22,17 +22,23 @@ #include "sdabstdlg.hxx" #include <sfx2/basedlgs.hxx> -#define DECL_ABSTDLG_BASE(Class,DialogClass) \ - ScopedVclPtr<DialogClass> pDlg; \ -public: \ - explicit Class(DialogClass* p) \ - : pDlg(p) \ - { \ - } \ - virtual ~Class(); \ +#define DECL_ABSTDLG_BASE(Class,DialogClass) \ + ScopedVclPtr<DialogClass> pDlg; \ +public: \ + explicit Class(DialogClass* p) \ + : pDlg(p) \ + { \ + } \ + virtual std::vector<OUString> getAllPageUIXMLDescriptions() const override; \ + virtual void selectPageByUIXMLDescription(const OUString& rUIXMLDescription) override; \ + virtual Bitmap createScreenshot() const override; \ + virtual ~Class(); \ virtual short Execute() override ; #define IMPL_ABSTDLG_BASE(Class) \ +std::vector<OUString> Class::getAllPageUIXMLDescriptions() const { return pDlg->getAllPageUIXMLDescriptions(); } \ +void Class::selectPageByUIXMLDescription(const OUString& rUIXMLDescription) { pDlg->selectPageByUIXMLDescription(rUIXMLDescription); } \ +Bitmap Class::createScreenshot() const { return pDlg->createScreenshot();} \ Class::~Class() \ { \ } \ diff --git a/sd/source/ui/inc/pubdlg.hxx b/sd/source/ui/inc/pubdlg.hxx index 894f33d9c9ff..f5156e0ea79b 100644 --- a/sd/source/ui/inc/pubdlg.hxx +++ b/sd/source/ui/inc/pubdlg.hxx @@ -200,6 +200,10 @@ public: virtual void dispose() override; void GetParameterSequence( css::uno::Sequence< css::beans::PropertyValue >& rParams ); + + // Screenshot interface + virtual std::vector<OUString> getAllPageUIXMLDescriptions() const override; + virtual void selectPageByUIXMLDescription(const OUString& rUIXMLDescription) override; }; #endif // INCLUDED_SD_SOURCE_UI_INC_PUBDLG_HXX diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index dd6ccd789950..b8f4041b025e 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -1332,4 +1332,54 @@ FactoryFunction SfxTabDialog::GetUITestFactory() const return SfxTabDialogUIObject::create; } +std::vector<OUString> SfxTabDialog::getAllPageUIXMLDescriptions() const +{ + std::vector<OUString> aRetval; + + for (SfxTabDlgData_Impl::const_iterator it = pImpl->aData.begin(); it != pImpl->aData.end(); ++it) + { + SfxTabPage* pCandidate = GetTabPage((*it)->nId); + + if (!pCandidate) + { + // force SfxTabPage creation + const_cast<SfxTabDialog*>(this)->ShowPage((*it)->nId); + pCandidate = GetTabPage((*it)->nId); + } + + if (pCandidate) + { + // for now, use IDs, later change to UI-Strings + aRetval.push_back(OUString::number((*it)->nId)); + } + } + + return aRetval; +} + +void SfxTabDialog::selectPageByUIXMLDescription(const OUString& rUIXMLDescription) +{ + // for now, use IDs, later change to UI-Strings + const sal_uInt16 nTargetId((sal_uInt16)rUIXMLDescription.toUInt32()); + bool bDone(false); + + for (SfxTabDlgData_Impl::const_iterator it = pImpl->aData.begin(); !bDone && it != pImpl->aData.end(); ++it) + { + SfxTabPage* pCandidate = (*it)->pTabPage; + + if (!pCandidate) + { + // force SfxTabPage creation + const_cast<SfxTabDialog*>(this)->ShowPage((*it)->nId); + pCandidate = GetTabPage((*it)->nId); + } + + if (pCandidate && (*it)->nId == nTargetId) + { + ShowPage(nTargetId); + bDone = true; + } + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 500877a2b559..c57465d04c0e 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -2374,7 +2374,7 @@ ImplMiscData::ImplMiscData() static const char* pEnv = getenv("SAL_DECIMALSEP_ENABLED" ); // set default without UI mbEnableLocalizedDecimalSep = (pEnv != nullptr); // Should we display any windows? - mbPseudoHeadless = getenv("VCL_HIDE_WINDOWS") || comphelper::LibreOfficeKit::isActive(); + mbPseudoHeadless = false; // getenv("VCL_HIDE_WINDOWS") || comphelper::LibreOfficeKit::isActive(); } ImplMiscData::ImplMiscData( const ImplMiscData& rData ) diff --git a/vcl/source/window/abstdlg.cxx b/vcl/source/window/abstdlg.cxx index d12d4d47d451..ebed762f3542 100644 --- a/vcl/source/window/abstdlg.cxx +++ b/vcl/source/window/abstdlg.cxx @@ -57,6 +57,23 @@ VclAbstractDialog::~VclAbstractDialog() { } +std::vector<OUString> VclAbstractDialog::getAllPageUIXMLDescriptions() const +{ + // default has no pages + return std::vector<OUString>(); +} + +void VclAbstractDialog::selectPageByUIXMLDescription(const OUString& /*rUIXMLDescription*/) +{ + // default cannot select a page +} + +Bitmap VclAbstractDialog::createScreenshot() const +{ + // default returns empty bitmap + return Bitmap(); +} + // virtual VclAbstractDialog2::~VclAbstractDialog2() { diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index ec4a3be527ef..837791ef012e 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -351,6 +351,7 @@ void Dialog::ImplInitDialogData() mbInExecute = false; mbInClose = false; mbModalMode = false; + mbPaintComplete = false; mpContentArea.clear(); mpActionArea.clear(); mnMousePositioned = 0; @@ -830,6 +831,49 @@ void Dialog::ImplEndExecuteModal() pSVData->maAppData.mnModalMode--; } +void Dialog::PrePaint(vcl::RenderContext& rRenderContext) +{ + SystemWindow::PrePaint(rRenderContext); + mbPaintComplete = false; +} + +void Dialog::PostPaint(vcl::RenderContext& rRenderContext) +{ + SystemWindow::PostPaint(rRenderContext); + mbPaintComplete = true; +} + +std::vector<OUString> Dialog::getAllPageUIXMLDescriptions() const +{ + // default has no pages + return std::vector<OUString>(); +} + +void Dialog::selectPageByUIXMLDescription(const OUString& /*rUIXMLDescription*/) +{ + // default cannot select anything +} + +Bitmap Dialog::createScreenshot() +{ + // same prerequisites as in Execute() + setDeferredProperties(); + ImplAdjustNWFSizes(); + Show(); + ToTop(); + + // ensure repaint + Invalidate(); + mbPaintComplete = false; + + while (!mbPaintComplete) + { + Application::Yield(); + } + + return GetBitmap(Point(), GetOutputSizePixel()); +} + short Dialog::Execute() { #if HAVE_FEATURE_DESKTOP diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index e927e6a86485..f85582acd7b2 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -600,6 +600,10 @@ void Window::ImplCallPaint(const vcl::Region* pRegion, sal_uInt16 nPaintFlags) Invalidate(InvalidateFlags::NoChildren | InvalidateFlags::NoErase | InvalidateFlags::NoTransparent | InvalidateFlags::NoClipChildren); else if ( pRegion ) Invalidate(*pRegion, InvalidateFlags::NoChildren | InvalidateFlags::NoErase | InvalidateFlags::NoTransparent | InvalidateFlags::NoClipChildren); + + // call PostPaint before returning + PostPaint(*this); + return; } @@ -611,6 +615,9 @@ void Window::ImplCallPaint(const vcl::Region* pRegion, sal_uInt16 nPaintFlags) aHelper.DoPaint(pRegion); else mpWindowImpl->mnPaintFlags = 0; + + // call PostPaint + PostPaint(*this); } void Window::ImplCallOverlapPaint() @@ -1011,6 +1018,10 @@ void Window::PrePaint(vcl::RenderContext& /*rRenderContext*/) { } +void Window::PostPaint(vcl::RenderContext& /*rRenderContext*/) +{ +} + void Window::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect) { CallEventListeners(VCLEVENT_WINDOW_PAINT, const_cast<Rectangle *>(&rRect)); |