Kaydet (Commit) 0408d6f4 authored tarafından Julien Nabet's avatar Julien Nabet

Modernize a bit vcl (part3)

by using for-range loops

Change-Id: Id8f5687510fa55d22873ef159b6399d219643698
Reviewed-on: https://gerrit.libreoffice.org/48811Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJulien Nabet <serval2412@yahoo.fr>
üst c101df21
...@@ -801,12 +801,12 @@ void Printer::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor, ...@@ -801,12 +801,12 @@ void Printer::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor,
RectangleVector aRectangles; RectangleVector aRectangles;
aWorkRgn.GetRegionRectangles(aRectangles); aWorkRgn.GetRegionRectangles(aRectangles);
for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter) for (auto const& rectangle : aRectangles)
{ {
const Point aMapPt(pMapX[aRectIter->Left()], pMapY[aRectIter->Top()]); const Point aMapPt(pMapX[rectangle.Left()], pMapY[rectangle.Top()]);
const Size aMapSz( const Size aMapSz(
pMapX[aRectIter->Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1 pMapX[rectangle.Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1
pMapY[aRectIter->Bottom() + 1] - aMapPt.Y()); // same for Y pMapY[rectangle.Bottom() + 1] - aMapPt.Y()); // same for Y
DrawRect(tools::Rectangle(aMapPt, aMapSz)); DrawRect(tools::Rectangle(aMapPt, aMapSz));
} }
......
...@@ -289,9 +289,9 @@ tools::PolyPolygon vcl::Region::ImplCreatePolyPolygonFromRegionBand() const ...@@ -289,9 +289,9 @@ tools::PolyPolygon vcl::Region::ImplCreatePolyPolygonFromRegionBand() const
RectangleVector aRectangles; RectangleVector aRectangles;
GetRegionRectangles(aRectangles); GetRegionRectangles(aRectangles);
for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter) for (auto const& rectangle : aRectangles)
{ {
aRetval.Insert( tools::Polygon(*aRectIter) ); aRetval.Insert( tools::Polygon(rectangle) );
} }
} }
else else
......
...@@ -236,10 +236,10 @@ void SalGraphics::mirror( vcl::Region& rRgn, const OutputDevice *pOutDev ) const ...@@ -236,10 +236,10 @@ void SalGraphics::mirror( vcl::Region& rRgn, const OutputDevice *pOutDev ) const
rRgn.GetRegionRectangles(aRectangles); rRgn.GetRegionRectangles(aRectangles);
rRgn.SetEmpty(); rRgn.SetEmpty();
for(RectangleVector::iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter) for (auto & rectangle : aRectangles)
{ {
mirror(*aRectIter, pOutDev); mirror(rectangle, pOutDev);
rRgn.Union(*aRectIter); rRgn.Union(rectangle);
} }
//ImplRegionInfo aInfo; //ImplRegionInfo aInfo;
......
...@@ -58,8 +58,8 @@ void DisplayConnectionDispatch::terminate() ...@@ -58,8 +58,8 @@ void DisplayConnectionDispatch::terminate()
MutexGuard aGuard( m_aMutex ); MutexGuard aGuard( m_aMutex );
Any aEvent; Any aEvent;
std::list< css::uno::Reference< XEventHandler > > aLocalList( m_aHandlers ); std::list< css::uno::Reference< XEventHandler > > aLocalList( m_aHandlers );
for( ::std::list< css::uno::Reference< XEventHandler > >::const_iterator it = aLocalList.begin(); it != aLocalList.end(); ++it ) for (auto const& elem : aLocalList)
(*it)->handleEvent( aEvent ); elem->handleEvent( aEvent );
} }
void SAL_CALL DisplayConnectionDispatch::addEventHandler( const Any& /*window*/, const css::uno::Reference< XEventHandler >& handler, sal_Int32 /*eventMask*/ ) void SAL_CALL DisplayConnectionDispatch::addEventHandler( const Any& /*window*/, const css::uno::Reference< XEventHandler >& handler, sal_Int32 /*eventMask*/ )
...@@ -107,8 +107,8 @@ bool DisplayConnectionDispatch::dispatchEvent( void const * pData, int nBytes ) ...@@ -107,8 +107,8 @@ bool DisplayConnectionDispatch::dispatchEvent( void const * pData, int nBytes )
MutexGuard aGuard( m_aMutex ); MutexGuard aGuard( m_aMutex );
handlers = m_aHandlers; handlers = m_aHandlers;
} }
for( ::std::list< css::uno::Reference< XEventHandler > >::const_iterator it = handlers.begin(); it != handlers.end(); ++it ) for (auto const& handle : handlers)
if( (*it)->handleEvent( aEvent ) ) if( handle->handleEvent( aEvent ) )
return true; return true;
return false; return false;
} }
......
...@@ -710,10 +710,10 @@ void OutputDevice::ReMirror( vcl::Region &rRegion ) const ...@@ -710,10 +710,10 @@ void OutputDevice::ReMirror( vcl::Region &rRegion ) const
rRegion.GetRegionRectangles(aRectangles); rRegion.GetRegionRectangles(aRectangles);
vcl::Region aMirroredRegion; vcl::Region aMirroredRegion;
for(RectangleVector::iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter) for (auto & rectangle : aRectangles)
{ {
ReMirror(*aRectIter); ReMirror(rectangle);
aMirroredRegion.Union(*aRectIter); aMirroredRegion.Union(rectangle);
} }
rRegion = aMirroredRegion; rRegion = aMirroredRegion;
......
...@@ -2471,9 +2471,8 @@ bool OutputDevice::GetTextOutlines( basegfx::B2DPolyPolygonVector& rVector, ...@@ -2471,9 +2471,8 @@ bool OutputDevice::GetTextOutlines( basegfx::B2DPolyPolygonVector& rVector,
if( !aMatrix.isIdentity() ) if( !aMatrix.isIdentity() )
{ {
basegfx::B2DPolyPolygonVector::iterator aIt = rVector.begin(); for (auto & elem : rVector)
for(; aIt != rVector.end(); ++aIt ) elem.transform( aMatrix );
(*aIt).transform( aMatrix );
} }
} }
...@@ -2505,9 +2504,8 @@ bool OutputDevice::GetTextOutlines( PolyPolyVector& rResultVector, ...@@ -2505,9 +2504,8 @@ bool OutputDevice::GetTextOutlines( PolyPolyVector& rResultVector,
// convert to a tool polypolygon vector // convert to a tool polypolygon vector
rResultVector.reserve( aB2DPolyPolyVector.size() ); rResultVector.reserve( aB2DPolyPolyVector.size() );
basegfx::B2DPolyPolygonVector::const_iterator aIt = aB2DPolyPolyVector.begin(); for (auto const& elem : aB2DPolyPolyVector)
for(; aIt != aB2DPolyPolyVector.end(); ++aIt ) rResultVector.emplace_back(elem); // #i76339#
rResultVector.emplace_back(*aIt); // #i76339#
return true; return true;
} }
...@@ -2525,10 +2523,9 @@ bool OutputDevice::GetTextOutline( tools::PolyPolygon& rPolyPoly, const OUString ...@@ -2525,10 +2523,9 @@ bool OutputDevice::GetTextOutline( tools::PolyPolygon& rPolyPoly, const OUString
return false; return false;
// convert and merge into a tool polypolygon // convert and merge into a tool polypolygon
basegfx::B2DPolyPolygonVector::const_iterator aIt = aB2DPolyPolyVector.begin(); for (auto const& elem : aB2DPolyPolyVector)
for(; aIt != aB2DPolyPolyVector.end(); ++aIt ) for( unsigned int i = 0; i < elem.count(); ++i )
for( unsigned int i = 0; i < aIt->count(); ++i ) rPolyPoly.Insert(tools::Polygon(elem.getB2DPolygon( i ))); // #i76339#
rPolyPoly.Insert(tools::Polygon((*aIt).getB2DPolygon( i ))); // #i76339#
return true; return true;
} }
......
...@@ -192,14 +192,14 @@ void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask ...@@ -192,14 +192,14 @@ void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask
RectangleVector aRectangles; RectangleVector aRectangles;
aWorkRgn.GetRegionRectangles(aRectangles); aWorkRgn.GetRegionRectangles(aRectangles);
for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter) for (auto const& rectangle : aRectangles)
{ {
const Point aMapPt(pMapX[aRectIter->Left()], pMapY[aRectIter->Top()]); const Point aMapPt(pMapX[rectangle.Left()], pMapY[rectangle.Top()]);
const Size aMapSz( pMapX[aRectIter->Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1 const Size aMapSz( pMapX[rectangle.Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1
pMapY[aRectIter->Bottom() + 1] - aMapPt.Y()); // same for Y pMapY[rectangle.Bottom() + 1] - aMapPt.Y()); // same for Y
Bitmap aBandBmp(aPaint); Bitmap aBandBmp(aPaint);
aBandBmp.Crop(*aRectIter); aBandBmp.Crop(rectangle);
DrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp); DrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp);
} }
......
...@@ -200,9 +200,9 @@ std::vector<KeyEvent> generate_key_events_from_keycode(const OUString& rStr) ...@@ -200,9 +200,9 @@ std::vector<KeyEvent> generate_key_events_from_keycode(const OUString& rStr)
OUString aRemainingText; OUString aRemainingText;
std::vector<OUString> aTokens = comphelper::string::split(rStr, '+'); std::vector<OUString> aTokens = comphelper::string::split(rStr, '+');
for (auto itr = aTokens.begin(), itrEnd = aTokens.end(); itr != itrEnd; ++itr) for (auto const& token : aTokens)
{ {
OUString aToken = itr->trim(); OUString aToken = token.trim();
if (aToken == "CTRL") if (aToken == "CTRL")
{ {
bMod1 = true; bMod1 = true;
...@@ -316,9 +316,9 @@ void WindowUIObject::execute(const OUString& rAction, ...@@ -316,9 +316,9 @@ void WindowUIObject::execute(const OUString& rAction,
bool bHandled = true; bool bHandled = true;
if (rAction == "SET") if (rAction == "SET")
{ {
for (auto itr = rParameters.begin(); itr != rParameters.end(); ++itr) for (auto const& parameter : rParameters)
{ {
std::cout << itr->first; std::cout << parameter.first;
} }
} }
else if (rAction == "TYPE") else if (rAction == "TYPE")
...@@ -328,10 +328,9 @@ void WindowUIObject::execute(const OUString& rAction, ...@@ -328,10 +328,9 @@ void WindowUIObject::execute(const OUString& rAction,
{ {
const OUString& rText = it->second; const OUString& rText = it->second;
auto aKeyEvents = generate_key_events_from_text(rText); auto aKeyEvents = generate_key_events_from_text(rText);
for (auto itr = aKeyEvents.begin(), itrEnd = aKeyEvents.end(); for (auto const& keyEvent : aKeyEvents)
itr != itrEnd; ++itr)
{ {
mxWindow->KeyInput(*itr); mxWindow->KeyInput(keyEvent);
} }
} }
else if (rParameters.find("KEYCODE") != rParameters.end()) else if (rParameters.find("KEYCODE") != rParameters.end())
...@@ -339,10 +338,9 @@ void WindowUIObject::execute(const OUString& rAction, ...@@ -339,10 +338,9 @@ void WindowUIObject::execute(const OUString& rAction,
auto itr = rParameters.find("KEYCODE"); auto itr = rParameters.find("KEYCODE");
const OUString rText = itr->second; const OUString rText = itr->second;
auto aKeyEvents = generate_key_events_from_keycode(rText); auto aKeyEvents = generate_key_events_from_keycode(rText);
for (auto itrKey = aKeyEvents.begin(), itrKeyEnd = aKeyEvents.end(); for (auto const& keyEvent : aKeyEvents)
itrKey != itrKeyEnd; ++itrKey)
{ {
mxWindow->KeyInput(*itrKey); mxWindow->KeyInput(keyEvent);
} }
} }
else else
...@@ -457,9 +455,9 @@ OUString WindowUIObject::dumpState() const ...@@ -457,9 +455,9 @@ OUString WindowUIObject::dumpState() const
OUStringBuffer aStateString = "{\"name\":\"" + mxWindow->get_id() + "\""; OUStringBuffer aStateString = "{\"name\":\"" + mxWindow->get_id() + "\"";
aStateString.append(", \"ImplementationName\":\"").appendAscii(typeid(*mxWindow.get()).name()).append("\""); aStateString.append(", \"ImplementationName\":\"").appendAscii(typeid(*mxWindow.get()).name()).append("\"");
StringMap aState = const_cast<WindowUIObject*>(this)->get_state(); StringMap aState = const_cast<WindowUIObject*>(this)->get_state();
for (auto itr = aState.begin(), itrEnd = aState.end(); itr != itrEnd; ++itr) for (auto const& elem : aState)
{ {
OUString property = ",\"" + itr->first + "\":\"" + escape(itr->second) + "\""; OUString property = ",\"" + elem.first + "\":\"" + escape(elem.second) + "\"";
aStateString.append(property); aStateString.append(property);
} }
...@@ -625,10 +623,9 @@ void EditUIObject::execute(const OUString& rAction, ...@@ -625,10 +623,9 @@ void EditUIObject::execute(const OUString& rAction,
const OUString& rText = it->second; const OUString& rText = it->second;
auto aKeyEvents = generate_key_events_from_text(rText); auto aKeyEvents = generate_key_events_from_text(rText);
for (auto itr = aKeyEvents.begin(), itrEnd = aKeyEvents.end(); for (auto const& keyEvent : aKeyEvents)
itr != itrEnd; ++itr)
{ {
mxEdit->KeyInput(*itr); mxEdit->KeyInput(keyEvent);
} }
} }
else else
......
...@@ -169,10 +169,11 @@ css::uno::Sequence<css::beans::PropertyValue> UIObjectUnoObj::getState() ...@@ -169,10 +169,11 @@ css::uno::Sequence<css::beans::PropertyValue> UIObjectUnoObj::getState()
StringMap aMap = mpObj->get_state(); StringMap aMap = mpObj->get_state();
css::uno::Sequence<css::beans::PropertyValue> aProps(aMap.size()); css::uno::Sequence<css::beans::PropertyValue> aProps(aMap.size());
sal_Int32 i = 0; sal_Int32 i = 0;
for (auto itr = aMap.begin(), itrEnd = aMap.end(); itr != itrEnd; ++itr, ++i) for (auto const& elem : aMap)
{ {
aProps[i].Name = itr->first; aProps[i].Name = elem.first;
aProps[i].Value <<= itr->second; aProps[i].Value <<= elem.second;
++i;
} }
return aProps; return aProps;
...@@ -187,9 +188,10 @@ css::uno::Sequence<OUString> UIObjectUnoObj::getChildren() ...@@ -187,9 +188,10 @@ css::uno::Sequence<OUString> UIObjectUnoObj::getChildren()
css::uno::Sequence<OUString> aRet(aChildren.size()); css::uno::Sequence<OUString> aRet(aChildren.size());
sal_Int32 i = 0; sal_Int32 i = 0;
for (auto itr = aChildren.begin(), itrEnd = aChildren.end(); itr != itrEnd; ++itr, ++i) for (auto const& child : aChildren)
{ {
aRet[i] = *itr; aRet[i] = child;
++i;
} }
return aRet; return aRet;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment