cui/source/dialogs/hangulhanjadlg.cxx | 2 framework/source/uielement/statusbarmanager.cxx | 5 - include/vcl/event.hxx | 47 +++++++------- sc/source/ui/sidebar/CellLineStyleValueSet.cxx | 2 sd/source/ui/animations/CustomAnimationCreateDialog.cxx | 2 sfx2/source/appl/newhelp.cxx | 4 - sfx2/source/statbar/stbitem.cxx | 2 svtools/source/control/ctrlbox.cxx | 53 ++++++++-------- svtools/source/control/valueset.cxx | 2 svx/source/dialog/svxbmpnumvalueset.cxx | 9 +- svx/source/gallery2/galctrl.cxx | 2 svx/source/sidebar/line/LineWidthValueSet.cxx | 2 svx/source/sidebar/tools/ValueSetWithTextControl.cxx | 2 svx/source/stbctrls/modctrl.cxx | 4 - svx/source/stbctrls/pszctrl.cxx | 4 - svx/source/stbctrls/selctrl.cxx | 2 svx/source/stbctrls/xmlsecctrl.cxx | 4 - svx/source/stbctrls/zoomctrl.cxx | 2 svx/source/stbctrls/zoomsliderctrl.cxx | 2 svx/source/tbxctrls/tbcontrl.cxx | 38 +++++------ sw/source/ui/frmdlg/column.cxx | 2 sw/source/uibase/utlui/viewlayoutctrl.cxx | 4 - vcl/source/control/combobox.cxx | 4 - vcl/source/control/ilstbox.cxx | 4 - vcl/source/control/lstbox.cxx | 8 +- vcl/source/window/status.cxx | 4 - 26 files changed, 111 insertions(+), 105 deletions(-)
New commits: commit 16ed2b5c74ebde8a74284f56689db1662424a078 Author: Jan Holesovsky <ke...@collabora.com> Date: Fri Jun 19 17:52:26 2015 +0200 rendercontext: Fix crash with double-buffering in the Styles combo box. Decouple the actual window from rendercontext in UserDrawEvent. Change-Id: Ic440c4e7f59fcffb7800c578146e8eb528cbb7b4 diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx index db448d2..0d3c96d 100644 --- a/cui/source/dialogs/hangulhanjadlg.cxx +++ b/cui/source/dialogs/hangulhanjadlg.cxx @@ -346,7 +346,7 @@ namespace svx void SuggestionSet::UserDraw( const UserDrawEvent& rUDEvt ) { - OutputDevice* pDev = rUDEvt.GetDevice(); + vcl::RenderContext* pDev = rUDEvt.GetRenderContext(); Rectangle aRect = rUDEvt.GetRect(); sal_uInt16 nItemId = rUDEvt.GetItemId(); diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx index 80e81c0..ce481d3 100644 --- a/framework/source/uielement/statusbarmanager.cxx +++ b/framework/source/uielement/statusbarmanager.cxx @@ -577,10 +577,9 @@ void StatusBarManager::UserDraw( const UserDrawEvent& rUDEvt ) if (( nId > 0 ) && ( it != m_aControllerMap.end() )) { uno::Reference< frame::XStatusbarController > xController( it->second ); - if ( xController.is() && rUDEvt.GetDevice() ) + if (xController.is() && rUDEvt.GetRenderContext()) { - uno::Reference< awt::XGraphics > xGraphics = - rUDEvt.GetDevice()->CreateUnoGraphics(); + uno::Reference< awt::XGraphics > xGraphics = rUDEvt.GetRenderContext()->CreateUnoGraphics(); awt::Rectangle aRect( rUDEvt.GetRect().Left(), rUDEvt.GetRect().Top(), diff --git a/include/vcl/event.hxx b/include/vcl/event.hxx index 9732033..085182a 100644 --- a/include/vcl/event.hxx +++ b/include/vcl/event.hxx @@ -296,45 +296,48 @@ inline HelpEvent::HelpEvent( HelpEventMode nHelpMode ) mbKeyboardActivated = true; } - -// - UserDrawEvent - - - +/// Event to pass information for UserDraw() handling eg. in comboboxes. class VCL_DLLPUBLIC UserDrawEvent { private: - VclPtr<OutputDevice> mpOutDev; + /// Window that owns the user draw. + VclPtr<vcl::Window> mpWindow; + + /// RenderContext to which we should draw - can be a VirtualDevice or anything. + VclPtr<vcl::RenderContext> mpRenderContext; + Rectangle maOutRect; sal_uInt16 mnItemId; sal_uInt16 mnStyle; public: - UserDrawEvent(); - UserDrawEvent( OutputDevice* pOut, - const Rectangle& rOutRect, - sal_uInt16 nId, sal_uInt16 nStyle = 0 ); + UserDrawEvent(); + UserDrawEvent(vcl::Window* pWindow, vcl::RenderContext* pRenderContext, + const Rectangle& rOutRect, sal_uInt16 nId, sal_uInt16 nStyle = 0); - OutputDevice* GetDevice() const { return mpOutDev; } + vcl::Window* GetWindow() const { return mpWindow; } + vcl::RenderContext* GetRenderContext() const { return mpRenderContext; } const Rectangle& GetRect() const { return maOutRect; } - sal_uInt16 GetItemId() const { return mnItemId; } - sal_uInt16 GetStyle() const { return mnStyle; } + sal_uInt16 GetItemId() const { return mnItemId; } + sal_uInt16 GetStyle() const { return mnStyle; } }; inline UserDrawEvent::UserDrawEvent() + : mpWindow(nullptr) + , mpRenderContext(nullptr) + , mnItemId(0) + , mnStyle(0) { - mpOutDev = NULL; - mnItemId = 0; - mnStyle = 0; } -inline UserDrawEvent::UserDrawEvent( OutputDevice* pOut, - const Rectangle& rOutRect, - sal_uInt16 nId, sal_uInt16 nStyle ) : - maOutRect( rOutRect ) +inline UserDrawEvent::UserDrawEvent(vcl::Window* pWindow, vcl::RenderContext* pRenderContext, + const Rectangle& rOutRect, sal_uInt16 nId, sal_uInt16 nStyle) + : mpWindow(pWindow) + , mpRenderContext(pRenderContext) + , maOutRect( rOutRect ) + , mnItemId(nId) + , mnStyle(nStyle) { - mpOutDev = pOut; - mnItemId = nId; - mnStyle = nStyle; } diff --git a/sc/source/ui/sidebar/CellLineStyleValueSet.cxx b/sc/source/ui/sidebar/CellLineStyleValueSet.cxx index b0da0a8..7f3c644 100644 --- a/sc/source/ui/sidebar/CellLineStyleValueSet.cxx +++ b/sc/source/ui/sidebar/CellLineStyleValueSet.cxx @@ -69,7 +69,7 @@ void CellLineStyleValueSet::SetSelItem(sal_uInt16 nSel) void CellLineStyleValueSet::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/sd/source/ui/animations/CustomAnimationCreateDialog.cxx b/sd/source/ui/animations/CustomAnimationCreateDialog.cxx index 333baa7..db86cd5 100644 --- a/sd/source/ui/animations/CustomAnimationCreateDialog.cxx +++ b/sd/source/ui/animations/CustomAnimationCreateDialog.cxx @@ -112,7 +112,7 @@ void CategoryListBox::UserDraw( const UserDrawEvent& rUDEvt ) if( ListBox::GetEntryFlags(nItem) & ListBoxEntryFlags::DisableSelection ) { Rectangle aOutRect( rUDEvt.GetRect() ); - OutputDevice* pDev = rUDEvt.GetDevice(); + vcl::RenderContext* pDev = rUDEvt.GetRenderContext(); // fill the background Color aColor (GetSettings().GetStyleSettings().GetDialogColor()); diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index 70d287e..53d7614 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -503,10 +503,10 @@ void IndexBox_Impl::UserDraw( const UserDrawEvent& rUDEvt ) // indent sub entries Point aPos( rUDEvt.GetRect().TopLeft() ); aPos.X() += 8; - aPos.Y() += ( rUDEvt.GetRect().GetHeight() - rUDEvt.GetDevice()->GetTextHeight() ) / 2; + aPos.Y() += (rUDEvt.GetRect().GetHeight() - rUDEvt.GetRenderContext()->GetTextHeight()) / 2; OUString aEntry( GetEntry( rUDEvt.GetItemId() ) ); sal_Int32 nPos = aEntry.indexOf( ';' ); - rUDEvt.GetDevice()->DrawText( aPos, ( nPos !=-1 ) ? aEntry.copy( nPos + 1 ) : aEntry ); + rUDEvt.GetRenderContext()->DrawText(aPos, (nPos !=-1) ? aEntry.copy(nPos + 1) : aEntry); } else DrawEntry( rUDEvt, false, true, true ); diff --git a/sfx2/source/statbar/stbitem.cxx b/sfx2/source/statbar/stbitem.cxx index c0ded64..f61f060 100644 --- a/sfx2/source/statbar/stbitem.cxx +++ b/sfx2/source/statbar/stbitem.cxx @@ -396,7 +396,7 @@ throw ( ::uno::RuntimeException, std::exception ) if ( pOutDev ) { ::Rectangle aRect = VCLRectangle( rOutputRectangle ); - UserDrawEvent aUserDrawEvent( pOutDev, aRect, pBar->GetCurItemId(), (sal_uInt16)nStyle ); + UserDrawEvent aUserDrawEvent(nullptr, pOutDev, aRect, pBar->GetCurItemId(), static_cast<sal_uInt16>(nStyle)); Paint( aUserDrawEvent ); } } diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index 5414eaf..4de70e4 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -258,11 +258,12 @@ void ColorListBox::UserDraw( const UserDrawEvent& rUDEvt ) const Rectangle aRect(aPos, aImageSize); - rUDEvt.GetDevice()->Push(); - rUDEvt.GetDevice()->SetFillColor( pData->aColor ); - rUDEvt.GetDevice()->SetLineColor( rUDEvt.GetDevice()->GetTextColor() ); - rUDEvt.GetDevice()->DrawRect(aRect); - rUDEvt.GetDevice()->Pop(); + vcl::RenderContext* pRenderContext = rUDEvt.GetRenderContext(); + pRenderContext->Push(); + pRenderContext->SetFillColor(pData->aColor); + pRenderContext->SetLineColor(pRenderContext->GetTextColor()); + pRenderContext->DrawRect(aRect); + pRenderContext->Pop(); const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); @@ -276,7 +277,7 @@ void ColorListBox::UserDraw( const UserDrawEvent& rUDEvt ) if(!aBlendFrame.IsEmpty()) { - rUDEvt.GetDevice()->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); + pRenderContext->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); } } @@ -1125,15 +1126,16 @@ void FontNameBox::UserDraw( const UserDrawEvent& rUDEvt ) nX += IMGOUTERTEXTSPACE; const bool bSymbolFont = isSymbolFont(rInfo); + vcl::RenderContext* pRenderContext = rUDEvt.GetRenderContext(); - Color aTextColor = rUDEvt.GetDevice()->GetTextColor(); - vcl::Font aOldFont( rUDEvt.GetDevice()->GetFont() ); + Color aTextColor = pRenderContext->GetTextColor(); + vcl::Font aOldFont(pRenderContext->GetFont()); Size aSize( aOldFont.GetSize() ); aSize.Height() += EXTRAFONTSIZE; vcl::Font aFont( rInfo ); aFont.SetSize( aSize ); - rUDEvt.GetDevice()->SetFont( aFont ); - rUDEvt.GetDevice()->SetTextColor( aTextColor ); + pRenderContext->SetFont(aFont); + pRenderContext->SetTextColor(aTextColor); bool bUsingCorrectFont = true; Rectangle aTextRect; @@ -1142,29 +1144,29 @@ void FontNameBox::UserDraw( const UserDrawEvent& rUDEvt ) OUString sFontName = rInfo.GetName(); //If it shouldn't or can't draw its own name because it doesn't have the glyphs - if (!canRenderNameOfSelectedFont(*rUDEvt.GetDevice())) + if (!canRenderNameOfSelectedFont(*pRenderContext)) bUsingCorrectFont = false; else { //Make sure it fits in the available height, shrinking the font if necessary - bUsingCorrectFont = shrinkFontToFit(sFontName, nH, aFont, *rUDEvt.GetDevice(), aTextRect) != 0; + bUsingCorrectFont = shrinkFontToFit(sFontName, nH, aFont, *pRenderContext, aTextRect) != 0; } if (!bUsingCorrectFont) { - rUDEvt.GetDevice()->SetFont(aOldFont); - rUDEvt.GetDevice()->GetTextBoundRect(aTextRect, sFontName, 0, 0); + pRenderContext->SetFont(aOldFont); + pRenderContext->GetTextBoundRect(aTextRect, sFontName, 0, 0); } long nTextHeight = aTextRect.GetHeight(); long nDesiredGap = (nH-nTextHeight)/2; long nVertAdjust = nDesiredGap - aTextRect.Top(); Point aPos( nX, aTopLeft.Y() + nVertAdjust ); - rUDEvt.GetDevice()->DrawText( aPos, sFontName ); + pRenderContext->DrawText(aPos, sFontName); long nTextX = aPos.X() + aTextRect.GetWidth() + GAPTOEXTRAPREVIEW; if (!bUsingCorrectFont) - rUDEvt.GetDevice()->SetFont( aFont ); + pRenderContext->SetFont(aFont); OUString sSampleText; @@ -1173,7 +1175,7 @@ void FontNameBox::UserDraw( const UserDrawEvent& rUDEvt ) const bool bNameBeginsWithLatinText = rInfo.GetName()[0] <= 'z'; if (bNameBeginsWithLatinText || !bUsingCorrectFont) - sSampleText = makeShortRepresentativeTextForSelectedFont(*rUDEvt.GetDevice()); + sSampleText = makeShortRepresentativeTextForSelectedFont(*pRenderContext); } //If we're not a symbol font, but could neither render our own name and @@ -1221,7 +1223,7 @@ void FontNameBox::UserDraw( const UserDrawEvent& rUDEvt ) OUString sText = makeShortRepresentativeTextForScript(aScripts[i]); if (!sText.isEmpty()) { - bool bHasSampleTextGlyphs = (-1 == rUDEvt.GetDevice()->HasGlyphs(aFont, sText)); + bool bHasSampleTextGlyphs = (-1 == pRenderContext->HasGlyphs(aFont, sText)); if (bHasSampleTextGlyphs) { sSampleText = sText; @@ -1241,7 +1243,7 @@ void FontNameBox::UserDraw( const UserDrawEvent& rUDEvt ) OUString sText = makeShortMinimalTextForScript(aMinimalScripts[i]); if (!sText.isEmpty()) { - bool bHasSampleTextGlyphs = (-1 == rUDEvt.GetDevice()->HasGlyphs(aFont, sText)); + bool bHasSampleTextGlyphs = (-1 == pRenderContext->HasGlyphs(aFont, sText)); if (bHasSampleTextGlyphs) { sSampleText = sText; @@ -1255,22 +1257,23 @@ void FontNameBox::UserDraw( const UserDrawEvent& rUDEvt ) //render something representative of what it would like to render then //make up some semi-random text that it *can* display if (bSymbolFont || (!bUsingCorrectFont && sSampleText.isEmpty())) - sSampleText = makeShortRepresentativeSymbolTextForSelectedFont(*rUDEvt.GetDevice()); + sSampleText = makeShortRepresentativeSymbolTextForSelectedFont(*pRenderContext); if (!sSampleText.isEmpty()) { - const Size &rItemSize = rUDEvt.GetDevice()->GetOutputSize(); + const Size &rItemSize = rUDEvt.GetWindow()->GetOutputSize(); + //leave a little border at the edge long nSpace = rItemSize.Width() - nTextX - IMGOUTERTEXTSPACE; if (nSpace >= 0) { //Make sure it fits in the available height, and get how wide that would be - long nWidth = shrinkFontToFit(sSampleText, nH, aFont, *rUDEvt.GetDevice(), aTextRect); + long nWidth = shrinkFontToFit(sSampleText, nH, aFont, *pRenderContext, aTextRect); //Chop letters off until it fits in the available width while (nWidth > nSpace || nWidth > MAXPREVIEWWIDTH) { sSampleText = sSampleText.copy(0, sSampleText.getLength()-1); - nWidth = rUDEvt.GetDevice()->GetTextBoundRect(aTextRect, sSampleText, 0, 0) ? + nWidth = pRenderContext->GetTextBoundRect(aTextRect, sSampleText, 0, 0) ? aTextRect.GetWidth() : 0; } @@ -1281,12 +1284,12 @@ void FontNameBox::UserDraw( const UserDrawEvent& rUDEvt ) nDesiredGap = (nH-nTextHeight)/2; nVertAdjust = nDesiredGap - aTextRect.Top(); aPos = Point(nTextX + nSpace - nWidth, aTopLeft.Y() + nVertAdjust); - rUDEvt.GetDevice()->DrawText( aPos, sSampleText ); + pRenderContext->DrawText(aPos, sSampleText); } } } - rUDEvt.GetDevice()->SetFont( aOldFont ); + pRenderContext->SetFont(aOldFont); DrawEntry( rUDEvt, false, false); // draw separator } else diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 2180346..9f9f477 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -299,7 +299,7 @@ void ValueSet::ImplFormatItem(vcl::RenderContext& rRenderContext, ValueSetItem* if (pItem->meType == VALUESETITEM_USERDRAW) { - UserDrawEvent aUDEvt(maVirDev.get(), aRect, pItem->mnId); + UserDrawEvent aUDEvt(this, maVirDev.get(), aRect, pItem->mnId); UserDraw(aUDEvt); } else diff --git a/svx/source/dialog/svxbmpnumvalueset.cxx b/svx/source/dialog/svxbmpnumvalueset.cxx index e392e7a..5c8157d 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 cf03018..e05b8ab 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 db4fe23..c800e68 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 1b47ccd..80bceae 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 5374f36..d22b3a5 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 d4acca7..8cc4d92 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 9fe589a..41f5e69 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 325bb00..0c530b6 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 bbec902..024ee30 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 0bb522c..fcc6e5d 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 cd942a0..d321bb8 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)) diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx index 9039269..266011e 100644 --- a/sw/source/ui/frmdlg/column.cxx +++ b/sw/source/ui/frmdlg/column.cxx @@ -1352,7 +1352,7 @@ void SwColumnPage::SetInSection(bool bSet) void ColumnValueSet::UserDraw(const UserDrawEvent& rUDEvt) { - OutputDevice* pDev = rUDEvt.GetDevice(); + vcl::RenderContext* pDev = rUDEvt.GetRenderContext(); const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); Rectangle aRect = rUDEvt.GetRect(); diff --git a/sw/source/uibase/utlui/viewlayoutctrl.cxx b/sw/source/uibase/utlui/viewlayoutctrl.cxx index 68f2559..2536586 100644 --- a/sw/source/uibase/utlui/viewlayoutctrl.cxx +++ b/sw/source/uibase/utlui/viewlayoutctrl.cxx @@ -111,8 +111,8 @@ void SwViewLayoutControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState void SwViewLayoutControl::Paint( const UserDrawEvent& rUsrEvt ) { - OutputDevice* pDev = rUsrEvt.GetDevice(); - Rectangle aRect = rUsrEvt.GetRect(); + vcl::RenderContext* pDev = rUsrEvt.GetRenderContext(); + Rectangle aRect(rUsrEvt.GetRect()); const Rectangle aControlRect = getControlRect(); diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index f16fd05..19c95e7 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -1254,8 +1254,8 @@ void ComboBox::EnableUserDraw( bool bUserDraw ) void ComboBox::DrawEntry(const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos) { - DBG_ASSERT(rEvt.GetDevice() == mpImplLB->GetMainWindow(), "DrawEntry?!"); - mpImplLB->GetMainWindow()->DrawEntry(*rEvt.GetDevice(), rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos); + DBG_ASSERT(rEvt.GetWindow() == mpImplLB->GetMainWindow(), "DrawEntry?!"); + mpImplLB->GetMainWindow()->DrawEntry(*rEvt.GetRenderContext(), rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos); } void ComboBox::SetSeparatorPos( sal_Int32 n ) diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index 5bdc36b..3259a77 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -1736,7 +1736,7 @@ void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32 nCurr = GetEntryList()->FindEntry(GetEntryList()->GetEntryText(nCurr)); nCurr = sal::static_int_cast<sal_Int32>(nCurr - GetEntryList()->GetMRUCount()); - UserDrawEvent aUDEvt(&rRenderContext, aRect, nPos, nCurr); + UserDrawEvent aUDEvt(this, &rRenderContext, aRect, nPos, nCurr); userDrawSignal(&aUDEvt); mbInUserDraw = false; } @@ -2747,7 +2747,7 @@ void ImplWin::ImplDraw(vcl::RenderContext& rRenderContext, bool bLayout) if ( IsUserDrawEnabled() ) { mbInUserDraw = true; - UserDrawEvent aUDEvt(&rRenderContext, maFocusRect, mnItemPos, 0); + UserDrawEvent aUDEvt(this, &rRenderContext, maFocusRect, mnItemPos, 0); userDrawSignal( &aUDEvt ); mbInUserDraw = false; } diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 2a34959..9b0d5e5 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -1383,10 +1383,10 @@ void ListBox::UserDraw( const UserDrawEvent& ) void ListBox::DrawEntry(const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos) { - if (rEvt.GetDevice() == mpImplLB->GetMainWindow()) - mpImplLB->GetMainWindow()->DrawEntry(*rEvt.GetDevice(), rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos ); - else if (rEvt.GetDevice() == mpImplWin) - mpImplWin->DrawEntry(*rEvt.GetDevice(), bDrawImage, bDrawText, bDrawTextAtImagePos); + if (rEvt.GetWindow() == mpImplLB->GetMainWindow()) + mpImplLB->GetMainWindow()->DrawEntry(*rEvt.GetRenderContext(), rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos ); + else if (rEvt.GetWindow() == mpImplWin) + mpImplWin->DrawEntry(*rEvt.GetRenderContext(), bDrawImage, bDrawText, bDrawTextAtImagePos); } void ListBox::SetUserItemSize( const Size& rSz ) diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index 157925d..e8e2aaf 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -415,14 +415,14 @@ void StatusBar::ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen { mbInUserDraw = true; mpImplData->mpVirDev->EnableRTL( IsRTLEnabled() ); - UserDrawEvent aODEvt(mpImplData->mpVirDev, Rectangle(Point(), aTextRectSize), pItem->mnId); + UserDrawEvent aODEvt(this, mpImplData->mpVirDev, Rectangle(Point(), aTextRectSize), pItem->mnId); UserDraw(aODEvt); mpImplData->mpVirDev->EnableRTL(false); mbInUserDraw = false; } else { - UserDrawEvent aODEvt(&rRenderContext, aTextRect, pItem->mnId); + UserDrawEvent aODEvt(this, &rRenderContext, aTextRect, pItem->mnId); UserDraw(aODEvt); } } commit fab1dbe9a04e8925b35571f3ad6a27b45dcee84e Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri May 22 13:15:14 2015 +0100 Avoid overflowing SetSizePixel computation ...near the end of SetupEntry, which appears to not be needed here Change-Id: Ia273df8a22d26974572d8e9be8de2a27936ee496 diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 5cb5762..cd942a0 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -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, false); + SetupEntry(i, Rectangle(0, 0, RECT_MAX, ITEM_HEIGHT), this, sStyleName, true); Rectangle aTextRectForActualFont; GetTextBoundRect(aTextRectForActualFont, sStyleName); if (AdjustFontForItemHeight(this, aTextRectForActualFont, ITEM_HEIGHT)) commit ee8b32ebbedc2d236fea51c74870efd37476b97b Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri May 22 13:13:33 2015 +0100 Simplify GetSize().Height() -> GetHeight() Change-Id: I8541eb13d82d887ef589a0545d36db88e47932e7 diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 24da648..5cb5762 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -608,7 +608,7 @@ void SvxStyleBox_Impl::SetupEntry(sal_uInt16 nItem, const Rectangle& rRect, Outp { if (nItem == 0 || nItem == GetEntryCount() - 1) { - unsigned int nId = (rRect.getY() / rRect.GetSize().Height()); + unsigned int nId = (rRect.getY() / rRect.GetHeight()); if(nId < MAX_STYLES_ENTRIES && m_pButtons[nId]) m_pButtons[nId]->Hide(); } @@ -735,19 +735,19 @@ void SvxStyleBox_Impl::SetupEntry(sal_uInt16 nItem, const Rectangle& rRect, Outp // handle the push-button if (bIsNotSelected) { - unsigned int nId = (rRect.getY() / rRect.GetSize().Height()); + unsigned int nId = (rRect.getY() / rRect.GetHeight()); if(nId < MAX_STYLES_ENTRIES && m_pButtons[nId]) m_pButtons[nId]->Hide(); } else { - unsigned int nId = (rRect.getY() / rRect.GetSize().Height()); + unsigned int nId = (rRect.getY() / rRect.GetHeight()); if(nId < MAX_STYLES_ENTRIES) { if(m_pButtons[nId] == nullptr) { m_pButtons[nId] = VclPtr<MenuButton>::Create(static_cast<vcl::Window*>(pDevice), WB_FLATBUTTON | WB_NOPOINTERFOCUS); - m_pButtons[nId]->SetSizePixel(Size(BUTTON_WIDTH, rRect.GetSize().Height())); + m_pButtons[nId]->SetSizePixel(Size(BUTTON_WIDTH, rRect.GetHeight())); m_pButtons[nId]->SetPopupMenu(&m_aMenu); } m_pButtons[nId]->SetPosPixel(Point(rRect.GetWidth() - BUTTON_WIDTH, rRect.getY())); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits