diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-06-19 17:52:26 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-08-06 12:23:25 +0200 |
commit | 7ad14fd903c6376760888ebfe9495366b2590555 (patch) | |
tree | 6433810afe78d9c0b20f0f5923a78e01b7576e01 /svx | |
parent | 834615efdf4c23e9e745294ae24c83c2a3d04f72 (diff) |
rendercontext: Fix crash with double-buffering in the Styles combo box.
Decouple the actual window from rendercontext in UserDrawEvent.
Change-Id: Ic440c4e7f59fcffb7800c578146e8eb528cbb7b4
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/dialog/svxbmpnumvalueset.cxx | 9 | ||||
-rw-r--r-- | svx/source/gallery2/galctrl.cxx | 2 | ||||
-rw-r--r-- | svx/source/sidebar/line/LineWidthValueSet.cxx | 2 | ||||
-rw-r--r-- | svx/source/sidebar/tools/ValueSetWithTextControl.cxx | 2 | ||||
-rw-r--r-- | svx/source/stbctrls/modctrl.cxx | 4 | ||||
-rw-r--r-- | svx/source/stbctrls/pszctrl.cxx | 4 | ||||
-rw-r--r-- | svx/source/stbctrls/selctrl.cxx | 2 | ||||
-rw-r--r-- | svx/source/stbctrls/xmlsecctrl.cxx | 4 | ||||
-rw-r--r-- | svx/source/stbctrls/zoomctrl.cxx | 2 | ||||
-rw-r--r-- | svx/source/stbctrls/zoomsliderctrl.cxx | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 30 |
11 files changed, 32 insertions, 31 deletions
diff --git a/svx/source/dialog/svxbmpnumvalueset.cxx b/svx/source/dialog/svxbmpnumvalueset.cxx index e392e7ab0998..5c8157d15e81 100644 --- a/svx/source/dialog/svxbmpnumvalueset.cxx +++ b/svx/source/dialog/svxbmpnumvalueset.cxx @@ -134,7 +134,7 @@ void SvxNumValueSet::UserDraw( const UserDrawEvent& rUDEvt ) 25, 50, 30, 70, 35, 90, // up to here line positions - 05, 10, // character positions + 5, 10, // character positions 10, 30, 15, 50, 20, 70, @@ -145,9 +145,10 @@ void SvxNumValueSet::UserDraw( const UserDrawEvent& rUDEvt ) const Color aBackColor = rStyleSettings.GetFieldColor(); const Color aTextColor = rStyleSettings.GetFieldTextColor(); - OutputDevice* pDev = rUDEvt.GetDevice(); + vcl::RenderContext* pDev = rUDEvt.GetRenderContext(); Rectangle aRect = rUDEvt.GetRect(); - sal_uInt16 nItemId = rUDEvt.GetItemId(); + sal_uInt16 nItemId = rUDEvt.GetItemId(); + long nRectWidth = aRect.GetWidth(); long nRectHeight = aRect.GetHeight(); Size aRectSize(nRectWidth, aRect.GetHeight()); @@ -503,7 +504,7 @@ void SvxBmpNumValueSet::UserDraw(const UserDrawEvent& rUDEvt) SvxNumValueSet::UserDraw(rUDEvt); Rectangle aRect = rUDEvt.GetRect(); - OutputDevice* pDev = rUDEvt.GetDevice(); + vcl::RenderContext* pDev = rUDEvt.GetRenderContext(); sal_uInt16 nItemId = rUDEvt.GetItemId(); Point aBLPos = aRect.TopLeft(); diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx index cf03018d974c..e05b8abd7c15 100644 --- a/svx/source/gallery2/galctrl.cxx +++ b/svx/source/gallery2/galctrl.cxx @@ -355,7 +355,7 @@ void GalleryIconView::UserDraw(const UserDrawEvent& rUDEvt) const Point aPos( ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(), ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top()); - OutputDevice* pDev = rUDEvt.GetDevice(); + OutputDevice* pDev = rUDEvt.GetRenderContext(); if(aBitmapEx.IsTransparent()) { diff --git a/svx/source/sidebar/line/LineWidthValueSet.cxx b/svx/source/sidebar/line/LineWidthValueSet.cxx index db4fe239b835..c800e686f9a0 100644 --- a/svx/source/sidebar/line/LineWidthValueSet.cxx +++ b/svx/source/sidebar/line/LineWidthValueSet.cxx @@ -102,7 +102,7 @@ void LineWidthValueSet::SetCusEnable(bool bEnable) void LineWidthValueSet::UserDraw( const UserDrawEvent& rUDEvt ) { Rectangle aRect = rUDEvt.GetRect(); - OutputDevice* pDev = rUDEvt.GetDevice(); + vcl::RenderContext* pDev = rUDEvt.GetRenderContext(); sal_uInt16 nItemId = rUDEvt.GetItemId(); long nRectHeight = aRect.GetHeight(); diff --git a/svx/source/sidebar/tools/ValueSetWithTextControl.cxx b/svx/source/sidebar/tools/ValueSetWithTextControl.cxx index 1b47ccd5b4ba..80bceaeda362 100644 --- a/svx/source/sidebar/tools/ValueSetWithTextControl.cxx +++ b/svx/source/sidebar/tools/ValueSetWithTextControl.cxx @@ -146,7 +146,7 @@ void ValueSetWithTextControl::ReplaceItemImages( void ValueSetWithTextControl::UserDraw( const UserDrawEvent& rUDEvt ) { const Rectangle aRect = rUDEvt.GetRect(); - OutputDevice* pDev = rUDEvt.GetDevice(); + vcl::RenderContext* pDev = rUDEvt.GetRenderContext(); pDev->Push( PushFlags::ALL ); const sal_uInt16 nItemId = rUDEvt.GetItemId(); diff --git a/svx/source/stbctrls/modctrl.cxx b/svx/source/stbctrls/modctrl.cxx index 5374f369c5f7..d22b3a550e1a 100644 --- a/svx/source/stbctrls/modctrl.cxx +++ b/svx/source/stbctrls/modctrl.cxx @@ -150,8 +150,8 @@ Point centerImage(const Rectangle& rBoundingRect, const Image& rImg) void SvxModifyControl::Paint( const UserDrawEvent& rUsrEvt ) { - OutputDevice* pDev = rUsrEvt.GetDevice(); - Rectangle aRect = rUsrEvt.GetRect(); + vcl::RenderContext* pDev = rUsrEvt.GetRenderContext(); + Rectangle aRect(rUsrEvt.GetRect()); ImplData::ModificationState state = mxImpl->mnModState; Point aPt = centerImage(aRect, mxImpl->maImages[state]); diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx index d4acca719c07..8cc4d9212230 100644 --- a/svx/source/stbctrls/pszctrl.cxx +++ b/svx/source/stbctrls/pszctrl.cxx @@ -351,8 +351,8 @@ void SvxPosSizeStatusBarControl::Command( const CommandEvent& rCEvt ) void SvxPosSizeStatusBarControl::Paint( const UserDrawEvent& rUsrEvt ) { - OutputDevice* pDev = rUsrEvt.GetDevice(); - assert(pDev && "no OutputDevice on UserDrawEvent"); + vcl::RenderContext* pDev = rUsrEvt.GetRenderContext(); + const Rectangle& rRect = rUsrEvt.GetRect(); StatusBar& rBar = GetStatusBar(); Point aItemPos = rBar.GetItemTextPos( GetId() ); diff --git a/svx/source/stbctrls/selctrl.cxx b/svx/source/stbctrls/selctrl.cxx index 9fe589ac85b8..41f5e690ebe0 100644 --- a/svx/source/stbctrls/selctrl.cxx +++ b/svx/source/stbctrls/selctrl.cxx @@ -139,7 +139,7 @@ bool SvxSelectionModeControl::MouseButtonDown( const MouseEvent& rEvt ) void SvxSelectionModeControl::Paint( const UserDrawEvent& rUsrEvt ) { const Rectangle aControlRect = getControlRect(); - OutputDevice* pDev = rUsrEvt.GetDevice(); + vcl::RenderContext* pDev = rUsrEvt.GetRenderContext(); Rectangle aRect = rUsrEvt.GetRect(); Size aImgSize( maImage.GetSizePixel() ); diff --git a/svx/source/stbctrls/xmlsecctrl.cxx b/svx/source/stbctrls/xmlsecctrl.cxx index 325bb00c7f54..0c530b64a3c2 100644 --- a/svx/source/stbctrls/xmlsecctrl.cxx +++ b/svx/source/stbctrls/xmlsecctrl.cxx @@ -142,8 +142,8 @@ void XmlSecStatusBarControl::Command( const CommandEvent& rCEvt ) void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt ) { - OutputDevice* pDev = rUsrEvt.GetDevice(); - DBG_ASSERT( pDev, "-XmlSecStatusBarControl::Paint(): no Output Device... this will lead to nirvana..." ); + vcl::RenderContext* pDev = rUsrEvt.GetRenderContext(); + Rectangle aRect = rUsrEvt.GetRect(); Color aOldLineColor = pDev->GetLineColor(); Color aOldFillColor = pDev->GetFillColor(); diff --git a/svx/source/stbctrls/zoomctrl.cxx b/svx/source/stbctrls/zoomctrl.cxx index bbec9029fd85..024ee30f0524 100644 --- a/svx/source/stbctrls/zoomctrl.cxx +++ b/svx/source/stbctrls/zoomctrl.cxx @@ -186,7 +186,7 @@ SvxZoomPageStatusBarControl::SvxZoomPageStatusBarControl(sal_uInt16 _nSlotId, void SvxZoomPageStatusBarControl::Paint(const UserDrawEvent& rUsrEvt) { - OutputDevice* pDev = rUsrEvt.GetDevice(); + vcl::RenderContext* pDev = rUsrEvt.GetRenderContext(); Rectangle aRect = rUsrEvt.GetRect(); Point aPt = centerImage(aRect, maImage); pDev->DrawImage(aPt, maImage); diff --git a/svx/source/stbctrls/zoomsliderctrl.cxx b/svx/source/stbctrls/zoomsliderctrl.cxx index 0bb522c5d5dc..fcc6e5dd8619 100644 --- a/svx/source/stbctrls/zoomsliderctrl.cxx +++ b/svx/source/stbctrls/zoomsliderctrl.cxx @@ -252,7 +252,7 @@ void SvxZoomSliderControl::Paint( const UserDrawEvent& rUsrEvt ) return; const Rectangle aControlRect = getControlRect(); - OutputDevice* pDev = rUsrEvt.GetDevice(); + vcl::RenderContext* pDev = rUsrEvt.GetRenderContext(); Rectangle aRect = rUsrEvt.GetRect(); Rectangle aSlider = aRect; diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index cd942a04f558..d321bb803df6 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -161,7 +161,7 @@ private: void ReleaseFocus(); static Color TestColorsVisible(const Color &FontCol, const Color &BackCol); static void UserDrawEntry(const UserDrawEvent& rUDEvt, const OUString &rStyleName); - void SetupEntry(sal_uInt16 nItem, const Rectangle& rRect, OutputDevice *pDevice, const OUString &rStyleName, bool bIsNotSelected); + void SetupEntry(vcl::RenderContext& rRenderContext, vcl::Window* pParent, sal_uInt16 nItem, const Rectangle& rRect, const OUString& rStyleName, bool bIsNotSelected); static bool AdjustFontForItemHeight(OutputDevice* pDevice, Rectangle& rTextRect, long nHeight); DECL_LINK( MenuSelectHdl, Menu * ); }; @@ -585,7 +585,7 @@ bool SvxStyleBox_Impl::AdjustFontForItemHeight(OutputDevice* pDevice, Rectangle& void SvxStyleBox_Impl::UserDrawEntry(const UserDrawEvent& rUDEvt, const OUString &rStyleName) { - OutputDevice *pDevice = rUDEvt.GetDevice(); + vcl::RenderContext *pDevice = rUDEvt.GetRenderContext(); // IMG_TXT_DISTANCE in ilstbox.hxx is 6, then 1 is added as // nBorder, and we are adding 1 in order to look better when @@ -604,7 +604,7 @@ void SvxStyleBox_Impl::UserDrawEntry(const UserDrawEvent& rUDEvt, const OUString pDevice->DrawText(aPos, rStyleName); } -void SvxStyleBox_Impl::SetupEntry(sal_uInt16 nItem, const Rectangle& rRect, OutputDevice* pDevice, const OUString& rStyleName, bool bIsNotSelected) +void SvxStyleBox_Impl::SetupEntry(vcl::RenderContext& rRenderContext, vcl::Window* pParent, sal_uInt16 nItem, const Rectangle& rRect, const OUString& rStyleName, bool bIsNotSelected) { if (nItem == 0 || nItem == GetEntryCount() - 1) { @@ -637,7 +637,7 @@ void SvxStyleBox_Impl::SetupEntry(sal_uInt16 nItem, const Rectangle& rRect, Outp if ( pFontItem && pFontHeightItem ) { Size aFontSize( 0, pFontHeightItem->GetHeight() ); - Size aPixelSize( pDevice->LogicToPixel( aFontSize, pShell->GetMapUnit() ) ); + Size aPixelSize(rRenderContext.LogicToPixel(aFontSize, pShell->GetMapUnit())); // setup the font properties SvxFont aFont; @@ -686,11 +686,11 @@ void SvxStyleBox_Impl::SetupEntry(sal_uInt16 nItem, const Rectangle& rRect, Outp aFont.SetEmphasisMark( static_cast< const SvxEmphasisMarkItem* >( pItem )->GetEmphasisMark() ); // setup the device & draw - vcl::Font aOldFont( pDevice->GetFont() ); + vcl::Font aOldFont(rRenderContext.GetFont()); Color aFontCol = COL_AUTO, aBackCol = COL_AUTO; - pDevice->SetFont( aFont ); + rRenderContext.SetFont(aFont); pItem = aItemSet.GetItem( SID_ATTR_CHAR_COLOR ); // text color, when nothing is selected @@ -715,8 +715,8 @@ void SvxStyleBox_Impl::SetupEntry(sal_uInt16 nItem, const Rectangle& rRect, Outp if ( aBackCol != COL_AUTO ) { - pDevice->SetFillColor( aBackCol ); - pDevice->DrawRect(rRect); + rRenderContext.SetFillColor(aBackCol); + rRenderContext.DrawRect(rRect); } } break; @@ -726,11 +726,11 @@ void SvxStyleBox_Impl::SetupEntry(sal_uInt16 nItem, const Rectangle& rRect, Outp // when the font and background color are too similar, adjust the Font-Color if( (aFontCol != COL_AUTO) || (aBackCol != COL_AUTO) ) - aFontCol = TestColorsVisible(aFontCol, (aBackCol != COL_AUTO) ? aBackCol : pDevice->GetBackground().GetColor()); + aFontCol = TestColorsVisible(aFontCol, (aBackCol != COL_AUTO) ? aBackCol : rRenderContext.GetBackground().GetColor()); // set text color if ( aFontCol != COL_AUTO ) - pDevice->SetTextColor( aFontCol ); + rRenderContext.SetTextColor(aFontCol); // handle the push-button if (bIsNotSelected) @@ -744,9 +744,9 @@ void SvxStyleBox_Impl::SetupEntry(sal_uInt16 nItem, const Rectangle& rRect, Outp unsigned int nId = (rRect.getY() / rRect.GetHeight()); if(nId < MAX_STYLES_ENTRIES) { - if(m_pButtons[nId] == nullptr) + if (!m_pButtons[nId] && pParent) { - m_pButtons[nId] = VclPtr<MenuButton>::Create(static_cast<vcl::Window*>(pDevice), WB_FLATBUTTON | WB_NOPOINTERFOCUS); + m_pButtons[nId] = VclPtr<MenuButton>::Create(pParent, WB_FLATBUTTON | WB_NOPOINTERFOCUS); m_pButtons[nId]->SetSizePixel(Size(BUTTON_WIDTH, rRect.GetHeight())); m_pButtons[nId]->SetPopupMenu(&m_aMenu); } @@ -764,13 +764,13 @@ void SvxStyleBox_Impl::UserDraw( const UserDrawEvent& rUDEvt ) sal_uInt16 nItem = rUDEvt.GetItemId(); OUString aStyleName( GetEntry( nItem ) ); - OutputDevice *pDevice = rUDEvt.GetDevice(); + vcl::RenderContext *pDevice = rUDEvt.GetRenderContext(); pDevice->Push(PushFlags::FILLCOLOR | PushFlags::FONT | PushFlags::TEXTCOLOR); const Rectangle& rRect(rUDEvt.GetRect()); bool bIsNotSelected = rUDEvt.GetItemId() != GetSelectEntryPos(); - SetupEntry(nItem, rRect, pDevice, aStyleName, bIsNotSelected); + SetupEntry(*pDevice, rUDEvt.GetWindow(), nItem, rRect, aStyleName, bIsNotSelected); UserDrawEntry(rUDEvt, aStyleName); @@ -800,7 +800,7 @@ void SvxStyleBox_Impl::CalcOptimalExtraUserWidth() OUString sStyleName(GetEntry(i)); Push(PushFlags::FILLCOLOR | PushFlags::FONT | PushFlags::TEXTCOLOR); - SetupEntry(i, Rectangle(0, 0, RECT_MAX, ITEM_HEIGHT), this, sStyleName, true); + SetupEntry(*this /*FIXME rendercontext*/, this, i, Rectangle(0, 0, RECT_MAX, ITEM_HEIGHT), sStyleName, true); Rectangle aTextRectForActualFont; GetTextBoundRect(aTextRectForActualFont, sStyleName); if (AdjustFontForItemHeight(this, aTextRectForActualFont, ITEM_HEIGHT)) |