[Libreoffice-commits] core.git: 2 commits - include/vcl sd/source vcl/source
Caolán McNamara
caolanm at redhat.com
Tue May 13 12:31:46 PDT 2014
include/vcl/window.hxx | 4
sd/source/ui/accessibility/accessibility.src | 2
vcl/source/window/window.cxx | 297 ++++++++++++++++-----------
3 files changed, 182 insertions(+), 121 deletions(-)
New commits:
commit e1f0d790832098a7f8b323ab04809b6b55ade3d9
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue May 13 14:03:51 2014 +0100
Sub Title -> Subtitle
Change-Id: I1a0bcf7548699845752ac3cf49232655c2fb4fc0
diff --git a/sd/source/ui/accessibility/accessibility.src b/sd/source/ui/accessibility/accessibility.src
index 0d22039..6d2572f 100644
--- a/sd/source/ui/accessibility/accessibility.src
+++ b/sd/source/ui/accessibility/accessibility.src
@@ -210,7 +210,7 @@ String SID_SD_A11Y_P_OUTLINER_N_STYLE
String SID_SD_A11Y_P_SUBTITLE_N_STYLE
{
- Text [ en-US ] = "Sub Title";
+ Text [ en-US ] = "Subtitle";
};
String SID_SD_A11Y_P_PAGE_N_STYLE
commit c1c152f0e47407b2b327839e8b31601ea7423ddf
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon May 12 21:41:35 2014 +0100
coverity#1213522 Uncaught exception
and a gadzillion more
refactor to avoid slicing catch and rethrow
Change-Id: I5c05d1c151b81ff481eff8cd7544db9838143c71
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 2fd43a1..b24e933 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -316,6 +316,7 @@ const char* ImplDbgCheckWindow( const void* pObj );
class Dialog;
class WindowImpl;
+class PaintHelper;
class VclBuilder;
class VclSizeGroup;
@@ -343,6 +344,7 @@ class VCL_DLLPUBLIC Window : public OutputDevice, public Resource
friend class SystemChildWindow;
friend class ImplBorderWindow;
friend class VclBuilder;
+ friend class PaintHelper;
// TODO: improve missing functionality
// only required because of SetFloatingMode()
@@ -480,6 +482,8 @@ protected:
SAL_DLLPRIVATE WindowResHeader ImplLoadResHeader( const ResId& rResId );
SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
+ SAL_DLLPRIVATE void PushPaintHelper(PaintHelper *pHelper);
+ SAL_DLLPRIVATE void PopPaintHelper(PaintHelper *pHelper);
private:
SAL_DLLPRIVATE void ImplInitWindowData( WindowType nType );
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index d958287..2291b7f 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -1914,162 +1914,219 @@ void Window::ImplCalcOverlapRegion( const Rectangle& rSourceRect, Region& rRegio
}
}
-void Window::ImplCallPaint( const Region* pRegion, sal_uInt16 nPaintFlags )
+class PaintHelper
{
- Exception aException;
- bool bExceptionCaught(false);
-
- // call PrePaint. PrePaint may add to the invalidate region as well as
- // other parameters used below.
- PrePaint();
-
- mpWindowImpl->mbPaintFrame = false;
+private:
+ Window* m_pWindow;
+ Region* m_pChildRegion;
+ Rectangle m_aSelectionRect;
+ Rectangle m_aPaintRect;
+ Region m_aPaintRegion;
+ sal_uInt16 m_nPaintFlags;
+ bool m_bPop;
+ bool m_bRestoreCursor;
+public:
+ PaintHelper(Window *pWindow, sal_uInt16 nPaintFlags);
+ void SetPop()
+ {
+ m_bPop = true;
+ }
+ void SetPaintRect(const Rectangle& rRect)
+ {
+ m_aPaintRect = rRect;
+ }
+ void SetSelectionRect(const Rectangle& rRect)
+ {
+ m_aSelectionRect = rRect;
+ }
+ void SetRestoreCursor(bool bRestoreCursor)
+ {
+ m_bRestoreCursor = bRestoreCursor;
+ }
+ bool GetRestoreCursor() const
+ {
+ return m_bRestoreCursor;
+ }
+ sal_uInt16 GetPaintFlags() const
+ {
+ return m_nPaintFlags;
+ }
+ Region& GetPaintRegion()
+ {
+ return m_aPaintRegion;
+ }
+ void DoPaint(const Region* pRegion);
+ ~PaintHelper();
+};
- if ( nPaintFlags & IMPL_PAINT_PAINTALLCHILDREN )
- mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINT | IMPL_PAINT_PAINTALLCHILDREN | (nPaintFlags & IMPL_PAINT_PAINTALL);
- if ( nPaintFlags & IMPL_PAINT_PAINTCHILDREN )
- mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTCHILDREN;
- if ( nPaintFlags & IMPL_PAINT_ERASE )
- mpWindowImpl->mnPaintFlags |= IMPL_PAINT_ERASE;
- if ( nPaintFlags & IMPL_PAINT_CHECKRTL )
- mpWindowImpl->mnPaintFlags |= IMPL_PAINT_CHECKRTL;
- if ( !mpWindowImpl->mpFirstChild )
- mpWindowImpl->mnPaintFlags &= ~IMPL_PAINT_PAINTALLCHILDREN;
+PaintHelper::PaintHelper(Window *pWindow, sal_uInt16 nPaintFlags)
+ : m_pWindow(pWindow)
+ , m_pChildRegion(NULL)
+ , m_nPaintFlags(nPaintFlags)
+ , m_bPop(false)
+ , m_bRestoreCursor(false)
+{
+}
- if ( mpWindowImpl->mbPaintDisabled )
+void PaintHelper::DoPaint(const Region* pRegion)
+{
+ WindowImpl* pWindowImpl = m_pWindow->ImplGetWindowImpl();
+ Region* pWinChildClipRegion = m_pWindow->ImplGetWinChildClipRegion();
+ if ( pWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
+ pWindowImpl->maInvalidateRegion = *pWinChildClipRegion;
+ else
{
- if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
- Invalidate( INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN );
- else if ( pRegion )
- Invalidate( *pRegion, INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN );
- return;
- }
+ if ( pRegion )
+ pWindowImpl->maInvalidateRegion.Union( *pRegion );
- nPaintFlags = mpWindowImpl->mnPaintFlags & ~(IMPL_PAINT_PAINT);
+ if( pWindowImpl->mpWinData && pWindowImpl->mbTrackVisible )
+ /* #98602# need to repaint all children within the
+ * tracking rectangle, so the following invert
+ * operation takes places without traces of the previous
+ * one.
+ */
+ pWindowImpl->maInvalidateRegion.Union( *pWindowImpl->mpWinData->mpTrackRect );
- Region* pChildRegion = NULL;
- Rectangle aSelectionRect;
- if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINT )
+ if ( pWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDREN )
+ m_pChildRegion = new Region( pWindowImpl->maInvalidateRegion );
+ pWindowImpl->maInvalidateRegion.Intersect( *pWinChildClipRegion );
+ }
+ pWindowImpl->mnPaintFlags = 0;
+ if ( !pWindowImpl->maInvalidateRegion.IsEmpty() )
{
- Region* pWinChildClipRegion = ImplGetWinChildClipRegion();
- if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
- mpWindowImpl->maInvalidateRegion = *pWinChildClipRegion;
- else
- {
- if ( pRegion )
- mpWindowImpl->maInvalidateRegion.Union( *pRegion );
+ m_pWindow->PushPaintHelper(this);
+ m_pWindow->Paint(m_aPaintRect);
+ }
+}
- if( mpWindowImpl->mpWinData && mpWindowImpl->mbTrackVisible )
- /* #98602# need to repaint all children within the
- * tracking rectangle, so the following invert
- * operation takes places without traces of the previous
- * one.
- */
- mpWindowImpl->maInvalidateRegion.Union( *mpWindowImpl->mpWinData->mpTrackRect );
+void Window::PushPaintHelper(PaintHelper *pHelper)
+{
+ pHelper->SetPop();
- if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDREN )
- pChildRegion = new Region( mpWindowImpl->maInvalidateRegion );
- mpWindowImpl->maInvalidateRegion.Intersect( *pWinChildClipRegion );
- }
- mpWindowImpl->mnPaintFlags = 0;
- if ( !mpWindowImpl->maInvalidateRegion.IsEmpty() )
- {
- bool bRestoreCursor = false;
- if ( mpWindowImpl->mpCursor )
- bRestoreCursor = mpWindowImpl->mpCursor->ImplSuspend();
+ if ( mpWindowImpl->mpCursor )
+ pHelper->SetRestoreCursor(mpWindowImpl->mpCursor->ImplSuspend());
- mbInitClipRegion = true;
- mpWindowImpl->mbInPaint = true;
+ mbInitClipRegion = true;
+ mpWindowImpl->mbInPaint = true;
- // restore Paint-Region
- Region aPaintRegion( mpWindowImpl->maInvalidateRegion );
- Rectangle aPaintRect = aPaintRegion.GetBoundRect();
+ // restore Paint-Region
+ Region &rPaintRegion = pHelper->GetPaintRegion();
+ rPaintRegion = mpWindowImpl->maInvalidateRegion;
+ Rectangle aPaintRect = rPaintRegion.GetBoundRect();
- // - RTL - re-mirror paint rect and region at this window
- if( ImplIsAntiparallel() )
- {
- const OutputDevice *pOutDev = GetOutDev();
- pOutDev->ReMirror( aPaintRect );
- pOutDev->ReMirror( aPaintRegion );
- }
- aPaintRect = ImplDevicePixelToLogic( aPaintRect);
- mpWindowImpl->mpPaintRegion = &aPaintRegion;
- mpWindowImpl->maInvalidateRegion.SetEmpty();
+ // - RTL - re-mirror paint rect and region at this window
+ if( ImplIsAntiparallel() )
+ {
+ const OutputDevice *pOutDev = GetOutDev();
+ pOutDev->ReMirror( aPaintRect );
+ pOutDev->ReMirror( rPaintRegion );
+ }
+ aPaintRect = ImplDevicePixelToLogic( aPaintRect);
+ mpWindowImpl->mpPaintRegion = &rPaintRegion;
+ mpWindowImpl->maInvalidateRegion.SetEmpty();
- if ( (nPaintFlags & IMPL_PAINT_ERASE) && IsBackground() )
- {
- if ( IsClipRegion() )
- {
- Region aOldRegion = GetClipRegion();
- SetClipRegion();
- Erase();
- SetClipRegion( aOldRegion );
- }
- else
- Erase();
- }
+ if ( (pHelper->GetPaintFlags() & IMPL_PAINT_ERASE) && IsBackground() )
+ {
+ if ( IsClipRegion() )
+ {
+ Region aOldRegion = GetClipRegion();
+ SetClipRegion();
+ Erase();
+ SetClipRegion( aOldRegion );
+ }
+ else
+ Erase();
+ }
- // #98943# trigger drawing of toolbox selection after all childern are painted
- if( mpWindowImpl->mbDrawSelectionBackground )
- aSelectionRect = aPaintRect;
+ // #98943# trigger drawing of toolbox selection after all childern are painted
+ if( mpWindowImpl->mbDrawSelectionBackground )
+ pHelper->SetSelectionRect(aPaintRect);
+ pHelper->SetPaintRect(aPaintRect);
+}
- // Paint can throw exceptions; to not have a situation where
- // mpWindowImpl->mbInPaint keeps to be on true (and other
- // settings, too) better catch here to avoid to go completely out of
- // this method without executing the after-paint stuff
- try
- {
- Paint( aPaintRect );
- }
- catch(Exception& rException)
- {
- aException = rException;
- bExceptionCaught = true;
- }
+void Window::PopPaintHelper(PaintHelper *pHelper)
+{
+ if ( mpWindowImpl->mpWinData )
+ {
+ if ( mpWindowImpl->mbFocusVisible )
+ ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) );
+ }
+ mpWindowImpl->mbInPaint = false;
+ mbInitClipRegion = true;
+ mpWindowImpl->mpPaintRegion = NULL;
+ if ( mpWindowImpl->mpCursor )
+ mpWindowImpl->mpCursor->ImplResume(pHelper->GetRestoreCursor());
+}
- if ( mpWindowImpl->mpWinData )
- {
- if ( mpWindowImpl->mbFocusVisible )
- ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) );
- }
- mpWindowImpl->mbInPaint = false;
- mbInitClipRegion = true;
- mpWindowImpl->mpPaintRegion = NULL;
- if ( mpWindowImpl->mpCursor )
- mpWindowImpl->mpCursor->ImplResume( bRestoreCursor );
- }
+PaintHelper::~PaintHelper()
+{
+ WindowImpl* pWindowImpl = m_pWindow->ImplGetWindowImpl();
+ if (m_bPop)
+ {
+ m_pWindow->PopPaintHelper(this);
}
- else
- mpWindowImpl->mnPaintFlags = 0;
- if ( nPaintFlags & (IMPL_PAINT_PAINTALLCHILDREN | IMPL_PAINT_PAINTCHILDREN) )
+ if ( m_nPaintFlags & (IMPL_PAINT_PAINTALLCHILDREN | IMPL_PAINT_PAINTCHILDREN) )
{
// Paint from the bottom child window and frontward.
- Window* pTempWindow = mpWindowImpl->mpLastChild;
+ Window* pTempWindow = pWindowImpl->mpLastChild;
while ( pTempWindow )
{
if ( pTempWindow->mpWindowImpl->mbVisible )
- pTempWindow->ImplCallPaint( pChildRegion, nPaintFlags );
+ pTempWindow->ImplCallPaint( m_pChildRegion, m_nPaintFlags );
pTempWindow = pTempWindow->mpWindowImpl->mpPrev;
}
}
- if ( mpWindowImpl->mpWinData && mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & SHOWTRACK_WINDOW) )
+ if ( pWindowImpl->mpWinData && pWindowImpl->mbTrackVisible && (pWindowImpl->mpWinData->mnTrackFlags & SHOWTRACK_WINDOW) )
/* #98602# need to invert the tracking rect AFTER
* the children have painted
*/
- InvertTracking( *(mpWindowImpl->mpWinData->mpTrackRect), mpWindowImpl->mpWinData->mnTrackFlags );
+ m_pWindow->InvertTracking( *(pWindowImpl->mpWinData->mpTrackRect), pWindowImpl->mpWinData->mnTrackFlags );
// #98943# draw toolbox selection
- if( !aSelectionRect.IsEmpty() )
- DrawSelectionBackground( aSelectionRect, 3, false, true, false );
+ if( !m_aSelectionRect.IsEmpty() )
+ m_pWindow->DrawSelectionBackground( m_aSelectionRect, 3, false, true, false );
+
+ delete m_pChildRegion;
+}
- delete pChildRegion;
+void Window::ImplCallPaint( const Region* pRegion, sal_uInt16 nPaintFlags )
+{
+ // call PrePaint. PrePaint may add to the invalidate region as well as
+ // other parameters used below.
+ PrePaint();
+
+ mpWindowImpl->mbPaintFrame = false;
- if(bExceptionCaught)
+ if ( nPaintFlags & IMPL_PAINT_PAINTALLCHILDREN )
+ mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINT | IMPL_PAINT_PAINTALLCHILDREN | (nPaintFlags & IMPL_PAINT_PAINTALL);
+ if ( nPaintFlags & IMPL_PAINT_PAINTCHILDREN )
+ mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTCHILDREN;
+ if ( nPaintFlags & IMPL_PAINT_ERASE )
+ mpWindowImpl->mnPaintFlags |= IMPL_PAINT_ERASE;
+ if ( nPaintFlags & IMPL_PAINT_CHECKRTL )
+ mpWindowImpl->mnPaintFlags |= IMPL_PAINT_CHECKRTL;
+ if ( !mpWindowImpl->mpFirstChild )
+ mpWindowImpl->mnPaintFlags &= ~IMPL_PAINT_PAINTALLCHILDREN;
+
+ if ( mpWindowImpl->mbPaintDisabled )
{
- throw(aException);
+ if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
+ Invalidate( INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN );
+ else if ( pRegion )
+ Invalidate( *pRegion, INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN );
+ return;
}
+
+ nPaintFlags = mpWindowImpl->mnPaintFlags & ~(IMPL_PAINT_PAINT);
+
+ PaintHelper aHelper(this, nPaintFlags);
+
+ if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINT )
+ aHelper.DoPaint(pRegion);
+ else
+ mpWindowImpl->mnPaintFlags = 0;
}
void Window::ImplCallOverlapPaint()
More information about the Libreoffice-commits
mailing list