diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-10-29 21:51:19 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-04 12:30:40 -0500 |
commit | 709784cf1d417b4b2df8c5228a4664f697e45a5c (patch) | |
tree | aebf751b13eefee9d0effc31b8119953ab6d459e /svx | |
parent | 2ebf98e8225523186965a2ced928b0623020e41e (diff) |
Apply pimpl to SdrPageWindow.
Change-Id: I54554a229c03ff87096782344a728a49636c1de1
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/sdr/contact/objectcontactofpageview.cxx | 43 | ||||
-rw-r--r-- | svx/source/svdraw/sdrpagewindow.cxx | 122 | ||||
-rw-r--r-- | svx/source/svdraw/svdouno.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdpagv.cxx | 7 | ||||
-rw-r--r-- | svx/source/svdraw/svdpntv.cxx | 6 |
5 files changed, 137 insertions, 43 deletions
diff --git a/svx/source/sdr/contact/objectcontactofpageview.cxx b/svx/source/sdr/contact/objectcontactofpageview.cxx index 390c5bd2d602..460968668fa3 100644 --- a/svx/source/sdr/contact/objectcontactofpageview.cxx +++ b/svx/source/sdr/contact/objectcontactofpageview.cxx @@ -41,6 +41,48 @@ using namespace com::sun::star; +#include <stdio.h> +#include <string> +#include <sys/time.h> + +namespace { + +class stack_printer +{ +public: + explicit stack_printer( const char* msg ) : + msMsg(msg) + { + fprintf(stdout, "%s: --begin\n", msMsg.c_str()); + mfStartTime = getTime(); + } + + ~stack_printer() + { + double fEndTime = getTime(); + fprintf(stdout, "%s: --end (duration: %g sec)\n", msMsg.c_str(), (fEndTime - mfStartTime)); + } + + void printTime( int line ) const + { + double fEndTime = getTime(); + fprintf(stdout, "%s: --(%d) (duration: %g sec)\n", msMsg.c_str(), line, (fEndTime - mfStartTime)); + } + +private: + double getTime() const + { + timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec + tv.tv_usec / 1000000.0; + } + + ::std::string msMsg; + double mfStartTime; +}; + +} + namespace sdr { namespace contact @@ -95,6 +137,7 @@ namespace sdr // From baseclass Timer, the timeout call triggered by the LazyInvalidate mechanism void ObjectContactOfPageView::Timeout() { + stack_printer __stack_printer__( "sdr/contact/ObjectContactOfPageView::Timeout" ); // stop the timer Stop(); diff --git a/svx/source/svdraw/sdrpagewindow.cxx b/svx/source/svdraw/sdrpagewindow.cxx index 87594bac3beb..ca15df072de5 100644 --- a/svx/source/svdraw/sdrpagewindow.cxx +++ b/svx/source/svdraw/sdrpagewindow.cxx @@ -41,11 +41,39 @@ using namespace ::com::sun::star; +struct SdrPageWindow::Impl +{ + // #110094# ObjectContact section + sdr::contact::ObjectContact* mpObjectContact; + + // the SdrPageView this window belongs to + SdrPageView& mrPageView; + + // the PaintWindow to paint on. Here is access to OutDev etc. + // #i72752# change to pointer to allow patcing it in DrawLayer() if necessary + SdrPaintWindow* mpPaintWindow; + SdrPaintWindow* mpOriginalPaintWindow; + + // UNO stuff for xControls + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > mxControlContainer; + + Impl( SdrPageView& rPageView, SdrPaintWindow& rPaintWindow ) : + mpObjectContact(NULL), + mrPageView(rPageView), + mpPaintWindow(&rPaintWindow), + mpOriginalPaintWindow(NULL) + { + } + + ~Impl() + { + } +}; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > SdrPageWindow::GetControlContainer( bool _bCreateIfNecessary ) const { - if ( !mxControlContainer.is() && _bCreateIfNecessary ) + if (!mpImpl->mxControlContainer.is() && _bCreateIfNecessary) { SdrView& rView = GetPageView().GetView(); @@ -53,7 +81,7 @@ using namespace ::com::sun::star; if ( rPaintWindow.OutputToWindow() && !rView.IsPrintPreview() ) { vcl::Window& rWindow = dynamic_cast< vcl::Window& >( rPaintWindow.GetOutputDevice() ); - const_cast< SdrPageWindow* >( this )->mxControlContainer = VCLUnoHelper::CreateControlContainer( &rWindow ); + const_cast< SdrPageWindow* >( this )->mpImpl->mxControlContainer = VCLUnoHelper::CreateControlContainer( &rWindow ); // #100394# xC->setVisible triggers window->Show() and this has // problems when the view is not completely constructed which may @@ -63,7 +91,7 @@ using namespace ::com::sun::star; // UnoControlContainer::setVisible(...) which calls createPeer(...). // This will now be called directly from here. - uno::Reference< awt::XControl > xControl(mxControlContainer, uno::UNO_QUERY); + uno::Reference< awt::XControl > xControl(mpImpl->mxControlContainer, uno::UNO_QUERY); if(xControl.is()) { uno::Reference< uno::XInterface > xContext = xControl->getContext(); @@ -78,9 +106,9 @@ using namespace ::com::sun::star; { // Printer and VirtualDevice, or rather: no OutDev uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); - const_cast< SdrPageWindow* >( this )->mxControlContainer = uno::Reference< awt::XControlContainer >(xFactory->createInstance("com.sun.star.awt.UnoControlContainer"), uno::UNO_QUERY); + const_cast< SdrPageWindow* >( this )->mpImpl->mxControlContainer = uno::Reference< awt::XControlContainer >(xFactory->createInstance("com.sun.star.awt.UnoControlContainer"), uno::UNO_QUERY); uno::Reference< awt::XControlModel > xModel(xFactory->createInstance("com.sun.star.awt.UnoControlContainerModel"), uno::UNO_QUERY); - uno::Reference< awt::XControl > xControl(mxControlContainer, uno::UNO_QUERY); + uno::Reference< awt::XControl > xControl(mpImpl->mxControlContainer, uno::UNO_QUERY); if (xControl.is()) xControl->setModel(xModel); @@ -88,23 +116,20 @@ using namespace ::com::sun::star; Point aPosPix = rOutDev.GetMapMode().GetOrigin(); Size aSizePix = rOutDev.GetOutputSizePixel(); - uno::Reference< awt::XWindow > xContComp(mxControlContainer, uno::UNO_QUERY); + uno::Reference< awt::XWindow > xContComp(mpImpl->mxControlContainer, uno::UNO_QUERY); if( xContComp.is() ) xContComp->setPosSize(aPosPix.X(), aPosPix.Y(), aSizePix.Width(), aSizePix.Height(), awt::PosSize::POSSIZE); } FmFormView* pViewAsFormView = dynamic_cast< FmFormView* >( &rView ); if ( pViewAsFormView ) - pViewAsFormView->InsertControlContainer(mxControlContainer); + pViewAsFormView->InsertControlContainer(mpImpl->mxControlContainer); } - return mxControlContainer; + return mpImpl->mxControlContainer; } -SdrPageWindow::SdrPageWindow(SdrPageView& rPageView, SdrPaintWindow& rPaintWindow) -: mpObjectContact(0L), - mrPageView(rPageView), - mpPaintWindow(&rPaintWindow), - mpOriginalPaintWindow(NULL) +SdrPageWindow::SdrPageWindow(SdrPageView& rPageView, SdrPaintWindow& rPaintWindow) : + mpImpl(new Impl(rPageView, rPaintWindow)) { } @@ -113,19 +138,21 @@ SdrPageWindow::~SdrPageWindow() // #i26631# ResetObjectContact(); - if (mxControlContainer.is()) + if (mpImpl->mxControlContainer.is()) { SdrView& rView = GetPageView().GetView(); // notify derived views FmFormView* pViewAsFormView = dynamic_cast< FmFormView* >( &rView ); if ( pViewAsFormView ) - pViewAsFormView->RemoveControlContainer(mxControlContainer); + pViewAsFormView->RemoveControlContainer(mpImpl->mxControlContainer); // dispose the control container - uno::Reference< lang::XComponent > xComponent(mxControlContainer, uno::UNO_QUERY); + uno::Reference< lang::XComponent > xComponent(mpImpl->mxControlContainer, uno::UNO_QUERY); xComponent->dispose(); } + + delete mpImpl; } // ObjectContact section @@ -134,6 +161,21 @@ sdr::contact::ObjectContact* SdrPageWindow::CreateViewSpecificObjectContact() return new sdr::contact::ObjectContactOfPageView(*this); } +SdrPageView& SdrPageWindow::GetPageView() const +{ + return mpImpl->mrPageView; +} + +SdrPaintWindow& SdrPageWindow::GetPaintWindow() const +{ + return *mpImpl->mpPaintWindow; +} + +const SdrPaintWindow* SdrPageWindow::GetOriginalPaintWindow() const +{ + return mpImpl->mpOriginalPaintWindow; +} + // OVERLAY MANAGER rtl::Reference< ::sdr::overlay::OverlayManager > SdrPageWindow::GetOverlayManager() const { @@ -142,17 +184,17 @@ rtl::Reference< ::sdr::overlay::OverlayManager > SdrPageWindow::GetOverlayManage void SdrPageWindow::patchPaintWindow(SdrPaintWindow& rPaintWindow) { - mpOriginalPaintWindow = mpPaintWindow; - mpPaintWindow = &rPaintWindow; + mpImpl->mpOriginalPaintWindow = mpImpl->mpPaintWindow; + mpImpl->mpPaintWindow = &rPaintWindow; } void SdrPageWindow::unpatchPaintWindow() { - DBG_ASSERT(mpOriginalPaintWindow, "SdrPageWindow::unpatchPaintWindow: paint window not patched!" ); - if ( mpOriginalPaintWindow ) + DBG_ASSERT(mpImpl->mpOriginalPaintWindow, "SdrPageWindow::unpatchPaintWindow: paint window not patched!" ); + if (mpImpl->mpOriginalPaintWindow) { - mpPaintWindow = mpOriginalPaintWindow; - mpOriginalPaintWindow = NULL; + mpImpl->mpPaintWindow = mpImpl->mpOriginalPaintWindow; + mpImpl->mpOriginalPaintWindow = NULL; } } @@ -269,18 +311,18 @@ namespace -void SdrPageWindow::RedrawAll(sdr::contact::ViewObjectContactRedirector* pRedirector) const +void SdrPageWindow::RedrawAll( sdr::contact::ViewObjectContactRedirector* pRedirector ) { // set Redirector GetObjectContact().SetViewObjectContactRedirector(pRedirector); // set PaintingPageView - const SdrView& rView = mrPageView.GetView(); + const SdrView& rView = mpImpl->mrPageView.GetView(); SdrModel& rModel = *((SdrModel*)rView.GetModel()); // get to be processed layers const bool bPrinter(GetPaintWindow().OutputToPrinter()); - SetOfByte aProcessLayers = bPrinter ? mrPageView.GetPrintableLayers() : mrPageView.GetVisibleLayers(); + SetOfByte aProcessLayers = bPrinter ? mpImpl->mrPageView.GetPrintableLayers() : mpImpl->mrPageView.GetVisibleLayers(); // create PaintInfoRec; use Rectangle only temporarily const vcl::Region& rRegion = GetPaintWindow().GetRedrawRegion(); @@ -321,18 +363,18 @@ void SdrPageWindow::RedrawAll(sdr::contact::ViewObjectContactRedirector* pRedire #endif // CLIPPER_TEST } -void SdrPageWindow::RedrawLayer(const SdrLayerID* pId, sdr::contact::ViewObjectContactRedirector* pRedirector) const +void SdrPageWindow::RedrawLayer( const SdrLayerID* pId, sdr::contact::ViewObjectContactRedirector* pRedirector ) { // set redirector GetObjectContact().SetViewObjectContactRedirector(pRedirector); // set PaintingPageView - const SdrView& rView = mrPageView.GetView(); + const SdrView& rView = mpImpl->mrPageView.GetView(); SdrModel& rModel = *((SdrModel*)rView.GetModel()); // get the layers to process const bool bPrinter(GetPaintWindow().OutputToPrinter()); - SetOfByte aProcessLayers = bPrinter ? mrPageView.GetPrintableLayers() : mrPageView.GetVisibleLayers(); + SetOfByte aProcessLayers = bPrinter ? mpImpl->mrPageView.GetPrintableLayers() : mpImpl->mrPageView.GetVisibleLayers(); // is the given layer visible at all? if(aProcessLayers.IsSet(*pId)) @@ -403,28 +445,36 @@ void SdrPageWindow::InvalidatePageWindow(const basegfx::B2DRange& rRange) } // ObjectContact section -sdr::contact::ObjectContact& SdrPageWindow::GetObjectContact() const +const sdr::contact::ObjectContact& SdrPageWindow::GetObjectContact() const { - if(!mpObjectContact) + if (!mpImpl->mpObjectContact) { - ((SdrPageWindow*)this)->mpObjectContact = ((SdrPageWindow*)this)->CreateViewSpecificObjectContact(); + ((SdrPageWindow*)this)->mpImpl->mpObjectContact = ((SdrPageWindow*)this)->CreateViewSpecificObjectContact(); } - return *mpObjectContact; + return *mpImpl->mpObjectContact; +} + +sdr::contact::ObjectContact& SdrPageWindow::GetObjectContact() +{ + if (!mpImpl->mpObjectContact) + mpImpl->mpObjectContact = CreateViewSpecificObjectContact(); + + return *mpImpl->mpObjectContact; } bool SdrPageWindow::HasObjectContact() const { - return ( mpObjectContact != NULL ); + return mpImpl->mpObjectContact != NULL; } // #i26631# void SdrPageWindow::ResetObjectContact() { - if(mpObjectContact) + if (mpImpl->mpObjectContact) { - delete mpObjectContact; - mpObjectContact = 0L; + delete mpImpl->mpObjectContact; + mpImpl->mpObjectContact = 0L; } } diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx index 02ffaaa7d7e9..33c0d67c918f 100644 --- a/svx/source/svdraw/svdouno.cxx +++ b/svx/source/svdraw/svdouno.cxx @@ -127,7 +127,7 @@ namespace for ( sal_uInt32 i = 0; i < pPageView->PageWindowCount(); ++i ) { - const SdrPageWindow* pPageWindow = pPageView->GetPageWindow( i ); + SdrPageWindow* pPageWindow = pPageView->GetPageWindow( i ); DBG_ASSERT( pPageWindow, "lcl_ensureControlVisibility: invalid PageViewWindow!" ); if ( !pPageWindow ) continue; diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx index 08bf1a80e038..67189471eedc 100644 --- a/svx/source/svdraw/svdpagv.cxx +++ b/svx/source/svdraw/svdpagv.cxx @@ -281,7 +281,8 @@ void SdrPageView::PrePaint() } } -void SdrPageView::CompleteRedraw(SdrPaintWindow& rPaintWindow, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector) const +void SdrPageView::CompleteRedraw( + SdrPaintWindow& rPaintWindow, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector ) { if(GetPage()) { @@ -317,13 +318,13 @@ void SdrPageView::setPreparedPageWindow(SdrPageWindow* pKnownTarget) mpPreparedPageWindow = pKnownTarget; } -void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, sdr::contact::ViewObjectContactRedirector* pRedirector, const Rectangle& rRect) const +void SdrPageView::DrawLayer( SdrLayerID nID, OutputDevice* pGivenTarget, sdr::contact::ViewObjectContactRedirector* pRedirector, const Rectangle& rRect ) { if(GetPage()) { if(pGivenTarget) { - const SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget); + SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget); if(pKnownTarget) { diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index 09dcd311d3cc..e633106d2c9d 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -850,7 +850,7 @@ vcl::Region SdrPaintView::OptimizeDrawLayersRegion(OutputDevice* pOut, const vcl -void SdrPaintView::ImpFormLayerDrawing(SdrPaintWindow& rPaintWindow) const +void SdrPaintView::ImpFormLayerDrawing( SdrPaintWindow& rPaintWindow ) { if(mpPageView) { @@ -1201,7 +1201,7 @@ void SdrPaintView::SetAnimationPause( bool bSet ) { for(sal_uInt32 b(0L); b < mpPageView->PageWindowCount(); b++) { - const SdrPageWindow& rPageWindow = *(mpPageView->GetPageWindow(b)); + SdrPageWindow& rPageWindow = *(mpPageView->GetPageWindow(b)); sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact(); sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator(); @@ -1321,7 +1321,7 @@ void SdrPaintView::SetAnimationTimer(sal_uInt32 nTime) // first, reset all timers at all windows to 0L for(sal_uInt32 a(0L); a < mpPageView->PageWindowCount(); a++) { - const SdrPageWindow& rPageWindow = *mpPageView->GetPageWindow(a); + SdrPageWindow& rPageWindow = *mpPageView->GetPageWindow(a); sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact(); sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator(); rAnimator.SetTime(nTime); |