Kaydet (Commit) 95e70f71 authored tarafından Julien Nabet's avatar Julien Nabet

Use for-range loops in fpicker

Change-Id: I9bca308889c6e15ce9fcbc82f5c6c5e126b29022
Reviewed-on: https://gerrit.libreoffice.org/51460Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJulien Nabet <serval2412@yahoo.fr>
üst 58337340
...@@ -157,19 +157,19 @@ ControlHelper::~ControlHelper() ...@@ -157,19 +157,19 @@ ControlHelper::~ControlHelper()
[m_pFilterControl setTarget:nil]; [m_pFilterControl setTarget:nil];
} }
for(std::list<NSControl *>::iterator control = m_aActiveControls.begin(); control != m_aActiveControls.end(); ++control) { for (auto const& activeControl : m_aActiveControls)
NSControl* pControl = (*control); {
NSString* sLabelName = m_aMapListLabels[pControl]; NSString* sLabelName = m_aMapListLabels[activeControl];
if (sLabelName != nil) { if (sLabelName != nil) {
[sLabelName release]; [sLabelName release];
} }
if ([pControl class] == [NSPopUpButton class]) { if ([activeControl class] == [NSPopUpButton class]) {
NSTextField* pField = m_aMapListLabelFields[static_cast<NSPopUpButton*>(pControl)]; NSTextField* pField = m_aMapListLabelFields[static_cast<NSPopUpButton*>(activeControl)];
if (pField != nil) { if (pField != nil) {
[pField release]; [pField release];
} }
} }
[pControl release]; [activeControl release];
} }
[pool release]; [pool release];
...@@ -396,38 +396,39 @@ void ControlHelper::createUserPane() ...@@ -396,38 +396,39 @@ void ControlHelper::createUserPane()
int nPopupMaxWidth = 0; int nPopupMaxWidth = 0;
int nPopupLabelMaxWidth = 0; int nPopupLabelMaxWidth = 0;
for (::std::list<NSControl*>::iterator child = m_aActiveControls.begin(); child != m_aActiveControls.end(); child++) { size_t nLoop = 0;
for (auto const& activeControl : m_aActiveControls)
{
SAL_INFO("fpicker.aqua","currentHeight: " << currentHeight); SAL_INFO("fpicker.aqua","currentHeight: " << currentHeight);
NSControl* pControl = *child;
//let the control calculate its size //let the control calculate its size
[pControl sizeToFit]; [activeControl sizeToFit];
NSRect frame = [pControl frame]; NSRect frame = [activeControl frame];
SAL_INFO("fpicker.aqua","frame for control " << [[pControl description] UTF8String] << " is {" << frame.origin.x << ", " << frame.origin.y << ", " << frame.size.width << ", " << frame.size.height << "}"); SAL_INFO("fpicker.aqua","frame for control " << [[activeControl description] UTF8String] << " is {" << frame.origin.x << ", " << frame.origin.y << ", " << frame.size.width << ", " << frame.size.height << "}");
int nControlHeight = frame.size.height; int nControlHeight = frame.size.height;
int nControlWidth = frame.size.width; int nControlWidth = frame.size.width;
// Note: controls are grouped by kind, first all popup menus, then checkboxes // Note: controls are grouped by kind, first all popup menus, then checkboxes
if ([pControl class] == [NSPopUpButton class]) { if ([activeControl class] == [NSPopUpButton class]) {
if (bPopupControlPresent) { if (bPopupControlPresent) {
//this is not the first popup //this is not the first popup
currentHeight += kAquaSpaceBetweenPopupMenus; currentHeight += kAquaSpaceBetweenPopupMenus;
} }
else if (child != m_aActiveControls.begin()){ else if (nLoop)
{
currentHeight += kAquaSpaceBetweenControls; currentHeight += kAquaSpaceBetweenControls;
} }
bPopupControlPresent = true; bPopupControlPresent = true;
// we have to add the label text width // we have to add the label text width
NSString *label = m_aMapListLabels[pControl]; NSString *label = m_aMapListLabels[activeControl];
NSTextField *textField = createLabelWithString(label); NSTextField *textField = createLabelWithString(label);
[textField sizeToFit]; [textField sizeToFit];
m_aMapListLabelFields[static_cast<NSPopUpButton*>(pControl)] = textField; m_aMapListLabelFields[static_cast<NSPopUpButton*>(activeControl)] = textField;
[m_pUserPane addSubview:textField]; [m_pUserPane addSubview:textField];
NSRect tfRect = [textField frame]; NSRect tfRect = [textField frame];
...@@ -444,13 +445,13 @@ void ControlHelper::createUserPane() ...@@ -444,13 +445,13 @@ void ControlHelper::createUserPane()
if (nControlWidth < POPUP_WIDTH_MIN) { if (nControlWidth < POPUP_WIDTH_MIN) {
nControlWidth = POPUP_WIDTH_MIN; nControlWidth = POPUP_WIDTH_MIN;
frame.size.width = nControlWidth; frame.size.width = nControlWidth;
[pControl setFrame:frame]; [activeControl setFrame:frame];
} }
if (nControlWidth > POPUP_WIDTH_MAX) { if (nControlWidth > POPUP_WIDTH_MAX) {
nControlWidth = POPUP_WIDTH_MAX; nControlWidth = POPUP_WIDTH_MAX;
frame.size.width = nControlWidth; frame.size.width = nControlWidth;
[pControl setFrame:frame]; [activeControl setFrame:frame];
} }
//set the max size //set the max size
...@@ -466,8 +467,9 @@ void ControlHelper::createUserPane() ...@@ -466,8 +467,9 @@ void ControlHelper::createUserPane()
nControlHeight -= kAquaSpacePopupMenuFrameBoundsDiffV; nControlHeight -= kAquaSpacePopupMenuFrameBoundsDiffV;
} }
else if ([pControl class] == [NSButton class]) { else if ([activeControl class] == [NSButton class]) {
if (child != m_aActiveControls.begin()){ if (nLoop)
{
currentHeight += kAquaSpaceBetweenControls; currentHeight += kAquaSpaceBetweenControls;
} }
...@@ -486,7 +488,8 @@ void ControlHelper::createUserPane() ...@@ -486,7 +488,8 @@ void ControlHelper::createUserPane()
currentHeight += nControlHeight; currentHeight += nControlHeight;
[m_pUserPane addSubview:pControl]; [m_pUserPane addSubview:activeControl];
++nLoop;
} }
SAL_INFO("fpicker.aqua","height after adding all controls: " << currentHeight); SAL_INFO("fpicker.aqua","height after adding all controls: " << currentHeight);
...@@ -778,18 +781,18 @@ void ControlHelper::layoutControls() ...@@ -778,18 +781,18 @@ void ControlHelper::layoutControls()
int nPopupLabelMaxWidth = 0; int nPopupLabelMaxWidth = 0;
//first loop to determine max sizes //first loop to determine max sizes
for (::std::list<NSControl*>::iterator child = m_aActiveControls.begin(); child != m_aActiveControls.end(); child++) { for (auto const& activeControl : m_aActiveControls)
NSControl* pControl = *child; {
NSRect controlRect = [pControl frame]; NSRect controlRect = [activeControl frame];
int nControlWidth = controlRect.size.width; int nControlWidth = controlRect.size.width;
Class aSubType = [pControl class]; Class aSubType = [activeControl class];
if (aSubType == [NSPopUpButton class]) { if (aSubType == [NSPopUpButton class]) {
if (nPopupMaxWidth < nControlWidth) { if (nPopupMaxWidth < nControlWidth) {
nPopupMaxWidth = nControlWidth; nPopupMaxWidth = nControlWidth;
} }
NSTextField *label = m_aMapListLabelFields[static_cast<NSPopUpButton*>(pControl)]; NSTextField *label = m_aMapListLabelFields[static_cast<NSPopUpButton*>(activeControl)];
NSRect labelFrame = [label frame]; NSRect labelFrame = [label frame];
int nLabelWidth = labelFrame.size.width; int nLabelWidth = labelFrame.size.width;
if (nPopupLabelMaxWidth < nLabelWidth) { if (nPopupLabelMaxWidth < nLabelWidth) {
...@@ -809,32 +812,31 @@ void ControlHelper::layoutControls() ...@@ -809,32 +812,31 @@ void ControlHelper::layoutControls()
int nDistBetweenControls = 0; int nDistBetweenControls = 0;
for (::std::list<NSControl*>::iterator child = m_aActiveControls.begin(); child != m_aActiveControls.end(); child++) { for (auto const& activeControl : m_aActiveControls)
NSControl* pControl = *child; {
//get the control's bounds //get the control's bounds
NSRect controlRect = [pControl frame]; NSRect controlRect = [activeControl frame];
int nControlHeight = controlRect.size.height; int nControlHeight = controlRect.size.height;
int nControlWidth = controlRect.size.width; int nControlWidth = controlRect.size.width;
//subtract the height from the current vertical position, because the control's bounds origin rect will be its lower left hand corner //subtract the height from the current vertical position, because the control's bounds origin rect will be its lower left hand corner
currenttop -= nControlHeight; currenttop -= nControlHeight;
Class aSubType = [pControl class]; Class aSubType = [activeControl class];
//add space between the previous control and this control according to Apple's HIG //add space between the previous control and this control according to Apple's HIG
nDistBetweenControls = getVerticalDistance(previousControl, pControl); nDistBetweenControls = getVerticalDistance(previousControl, activeControl);
SAL_INFO("fpicker.aqua","vertical distance: " << nDistBetweenControls); SAL_INFO("fpicker.aqua","vertical distance: " << nDistBetweenControls);
currenttop -= nDistBetweenControls; currenttop -= nDistBetweenControls;
previousControl = pControl; previousControl = activeControl;
if (aSubType == [NSPopUpButton class]) { if (aSubType == [NSPopUpButton class]) {
//move vertically up some pixels to space the controls between their real (visual) bounds //move vertically up some pixels to space the controls between their real (visual) bounds
currenttop += kAquaSpacePopupMenuFrameBoundsDiffTop;//from top currenttop += kAquaSpacePopupMenuFrameBoundsDiffTop;//from top
//get the corresponding popup label //get the corresponding popup label
NSTextField *label = m_aMapListLabelFields[static_cast<NSPopUpButton*>(pControl)]; NSTextField *label = m_aMapListLabelFields[static_cast<NSPopUpButton*>(activeControl)];
NSRect labelFrame = [label frame]; NSRect labelFrame = [label frame];
int totalWidth = nPopupMaxWidth + labelFrame.size.width + kAquaSpaceBetweenControls - kAquaSpacePopupMenuFrameBoundsDiffLeft - kAquaSpaceLabelFrameBoundsDiffH; int totalWidth = nPopupMaxWidth + labelFrame.size.width + kAquaSpaceBetweenControls - kAquaSpacePopupMenuFrameBoundsDiffLeft - kAquaSpaceLabelFrameBoundsDiffH;
SAL_INFO("fpicker.aqua","totalWidth: " << totalWidth); SAL_INFO("fpicker.aqua","totalWidth: " << totalWidth);
...@@ -850,7 +852,7 @@ void ControlHelper::layoutControls() ...@@ -850,7 +852,7 @@ void ControlHelper::layoutControls()
controlRect.origin.y = currenttop; controlRect.origin.y = currenttop;
controlRect.size.width = nPopupMaxWidth; controlRect.size.width = nPopupMaxWidth;
SAL_INFO("fpicker.aqua","setting popup at: {" << controlRect.origin.x << ", " << controlRect.origin.y << ", " << controlRect.size.width << ", " << controlRect.size.height << "}"); SAL_INFO("fpicker.aqua","setting popup at: {" << controlRect.origin.x << ", " << controlRect.origin.y << ", " << controlRect.size.width << ", " << controlRect.size.height << "}");
[pControl setFrame:controlRect]; [activeControl setFrame:controlRect];
//add some space to place the vertical position right below the popup's visual bounds //add some space to place the vertical position right below the popup's visual bounds
currenttop += kAquaSpacePopupMenuFrameBoundsDiffBottom; currenttop += kAquaSpacePopupMenuFrameBoundsDiffBottom;
...@@ -862,7 +864,7 @@ void ControlHelper::layoutControls() ...@@ -862,7 +864,7 @@ void ControlHelper::layoutControls()
controlRect.origin.x = left; controlRect.origin.x = left;
controlRect.origin.y = currenttop; controlRect.origin.y = currenttop;
controlRect.size.width = nPopupMaxWidth; controlRect.size.width = nPopupMaxWidth;
[pControl setFrame:controlRect]; [activeControl setFrame:controlRect];
SAL_INFO("fpicker.aqua","setting checkbox at: {" << controlRect.origin.x << ", " << controlRect.origin.y << ", " << controlRect.size.width << ", " << controlRect.size.height << "}"); SAL_INFO("fpicker.aqua","setting checkbox at: {" << controlRect.origin.x << ", " << controlRect.origin.y << ", " << controlRect.size.width << ", " << controlRect.size.height << "}");
currenttop += kAquaSpaceSwitchButtonFrameBoundsDiff; currenttop += kAquaSpaceSwitchButtonFrameBoundsDiff;
...@@ -883,8 +885,8 @@ void ControlHelper::createFilterControl() ...@@ -883,8 +885,8 @@ void ControlHelper::createFilterControl()
NSMenu *menu = [m_pFilterControl menu]; NSMenu *menu = [m_pFilterControl menu];
for (NSStringList::iterator iter = m_pFilterHelper->getFilterNames()->begin(); iter != m_pFilterHelper->getFilterNames()->end(); ++iter) { for (auto const& filterName : *m_pFilterHelper->getFilterNames())
NSString *filterName = *iter; {
SAL_INFO("fpicker.aqua","adding filter name: " << [filterName UTF8String]); SAL_INFO("fpicker.aqua","adding filter name: " << [filterName UTF8String]);
if ([filterName isEqualToString:@"-"]) { if ([filterName isEqualToString:@"-"]) {
[menu addItem:[NSMenuItem separatorItem]]; [menu addItem:[NSMenuItem separatorItem]];
......
...@@ -177,38 +177,32 @@ void SvtFilePicker::prepareExecute() ...@@ -177,38 +177,32 @@ void SvtFilePicker::prepareExecute()
{ {
::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() ); ::svt::OControlAccess aAccess( getDialog(), getDialog()->GetView() );
ElementList::iterator aListIter; for (auto const& elem : *m_pElemList)
for ( aListIter = m_pElemList->begin();
aListIter != m_pElemList->end(); ++aListIter )
{ {
ElementEntry_Impl& rEntry = *aListIter; if ( elem.m_bHasValue )
if ( rEntry.m_bHasValue ) aAccess.setValue( elem.m_nElementID, elem.m_nControlAction, elem.m_aValue );
aAccess.setValue( rEntry.m_nElementID, rEntry.m_nControlAction, rEntry.m_aValue ); if ( elem.m_bHasLabel )
if ( rEntry.m_bHasLabel ) aAccess.setLabel( elem.m_nElementID, elem.m_aLabel );
aAccess.setLabel( rEntry.m_nElementID, rEntry.m_aLabel ); if ( elem.m_bHasEnabled )
if ( rEntry.m_bHasEnabled ) aAccess.enableControl( elem.m_nElementID, elem.m_bEnabled );
aAccess.enableControl( rEntry.m_nElementID, rEntry.m_bEnabled );
} }
} }
if ( m_pFilterList && !m_pFilterList->empty() ) if ( m_pFilterList && !m_pFilterList->empty() )
{ {
for ( FilterList::iterator aListIter = m_pFilterList->begin(); for (auto & elem : *m_pFilterList)
aListIter != m_pFilterList->end();
++aListIter
)
{ {
if ( aListIter->hasSubFilters() ) if ( elem.hasSubFilters() )
{ // it's a filter group { // it's a filter group
UnoFilterList aSubFilters; UnoFilterList aSubFilters;
aListIter->getSubFilters( aSubFilters ); elem.getSubFilters( aSubFilters );
getDialog()->AddFilterGroup( aListIter->getTitle(), aSubFilters ); getDialog()->AddFilterGroup( elem.getTitle(), aSubFilters );
} }
else else
// it's a single filter // it's a single filter
getDialog()->AddFilter( aListIter->getTitle(), aListIter->getFilter() ); getDialog()->AddFilter( elem.getTitle(), elem.getFilter() );
} }
} }
...@@ -623,17 +617,14 @@ void SAL_CALL SvtFilePicker::setValue( sal_Int16 nElementID, ...@@ -623,17 +617,14 @@ void SAL_CALL SvtFilePicker::setValue( sal_Int16 nElementID,
m_pElemList.reset( new ElementList ); m_pElemList.reset( new ElementList );
bool bFound = false; bool bFound = false;
ElementList::iterator aListIter;
for ( aListIter = m_pElemList->begin(); for (auto & elem : *m_pElemList)
aListIter != m_pElemList->end(); ++aListIter )
{ {
ElementEntry_Impl& rEntry = *aListIter; if ( ( elem.m_nElementID == nElementID ) &&
if ( ( rEntry.m_nElementID == nElementID ) && ( !elem.m_bHasValue || ( elem.m_nControlAction == nControlAction ) ) )
( !rEntry.m_bHasValue || ( rEntry.m_nControlAction == nControlAction ) ) )
{ {
rEntry.setAction( nControlAction ); elem.setAction( nControlAction );
rEntry.setValue( rValue ); elem.setValue( rValue );
bFound = true; bFound = true;
} }
} }
...@@ -664,16 +655,13 @@ Any SAL_CALL SvtFilePicker::getValue( sal_Int16 nElementID, sal_Int16 nControlAc ...@@ -664,16 +655,13 @@ Any SAL_CALL SvtFilePicker::getValue( sal_Int16 nElementID, sal_Int16 nControlAc
} }
else if ( m_pElemList && !m_pElemList->empty() ) else if ( m_pElemList && !m_pElemList->empty() )
{ {
ElementList::iterator aListIter; for (auto const& elem : *m_pElemList)
for ( aListIter = m_pElemList->begin();
aListIter != m_pElemList->end(); ++aListIter )
{ {
ElementEntry_Impl& rEntry = *aListIter; if ( ( elem.m_nElementID == nElementID ) &&
if ( ( rEntry.m_nElementID == nElementID ) && ( elem.m_bHasValue ) &&
( rEntry.m_bHasValue ) && ( elem.m_nControlAction == nControlAction ) )
( rEntry.m_nControlAction == nControlAction ) )
{ {
aAny = rEntry.m_aValue; aAny = elem.m_aValue;
break; break;
} }
} }
...@@ -699,15 +687,12 @@ void SAL_CALL SvtFilePicker::setLabel( sal_Int16 nLabelID, const OUString& rValu ...@@ -699,15 +687,12 @@ void SAL_CALL SvtFilePicker::setLabel( sal_Int16 nLabelID, const OUString& rValu
m_pElemList.reset( new ElementList ); m_pElemList.reset( new ElementList );
bool bFound = false; bool bFound = false;
ElementList::iterator aListIter;
for ( aListIter = m_pElemList->begin(); for (auto & elem : *m_pElemList)
aListIter != m_pElemList->end(); ++aListIter )
{ {
ElementEntry_Impl& rEntry = *aListIter; if ( elem.m_nElementID == nLabelID )
if ( rEntry.m_nElementID == nLabelID )
{ {
rEntry.setLabel( rValue ); elem.setLabel( rValue );
bFound = true; bFound = true;
} }
} }
...@@ -736,15 +721,12 @@ OUString SAL_CALL SvtFilePicker::getLabel( sal_Int16 nLabelID ) ...@@ -736,15 +721,12 @@ OUString SAL_CALL SvtFilePicker::getLabel( sal_Int16 nLabelID )
} }
else if ( m_pElemList && !m_pElemList->empty() ) else if ( m_pElemList && !m_pElemList->empty() )
{ {
ElementList::iterator aListIter; for (auto const& elem : *m_pElemList)
for ( aListIter = m_pElemList->begin();
aListIter != m_pElemList->end(); ++aListIter )
{ {
ElementEntry_Impl& rEntry = *aListIter; if ( elem.m_nElementID == nLabelID )
if ( rEntry.m_nElementID == nLabelID )
{ {
if ( rEntry.m_bHasLabel ) if ( elem.m_bHasLabel )
aLabel = rEntry.m_aLabel; aLabel = elem.m_aLabel;
break; break;
} }
} }
...@@ -770,15 +752,12 @@ void SAL_CALL SvtFilePicker::enableControl( sal_Int16 nElementID, sal_Bool bEnab ...@@ -770,15 +752,12 @@ void SAL_CALL SvtFilePicker::enableControl( sal_Int16 nElementID, sal_Bool bEnab
m_pElemList.reset( new ElementList ); m_pElemList.reset( new ElementList );
bool bFound = false; bool bFound = false;
ElementList::iterator aListIter;
for ( aListIter = m_pElemList->begin(); for (auto & elem : *m_pElemList)
aListIter != m_pElemList->end(); ++aListIter )
{ {
ElementEntry_Impl& rEntry = *aListIter; if ( elem.m_nElementID == nElementID )
if ( rEntry.m_nElementID == nElementID )
{ {
rEntry.setEnabled( bEnable ); elem.setEnabled( bEnable );
bFound = true; bFound = true;
} }
} }
......
...@@ -329,10 +329,10 @@ void RemoteFilesDialog::dispose() ...@@ -329,10 +329,10 @@ void RemoteFilesDialog::dispose()
Sequence< OUString > placesNamesList( m_aServices.size() ); Sequence< OUString > placesNamesList( m_aServices.size() );
int i = 0; int i = 0;
for( std::vector< ServicePtr >::const_iterator it = m_aServices.begin(); it != m_aServices.end(); ++it ) for (auto const& service : m_aServices)
{ {
placesUrlsList[i] = ( *it )->GetUrl(); placesUrlsList[i] = service->GetUrl();
placesNamesList[i] = ( *it )->GetName(); placesNamesList[i] = service->GetName();
++i; ++i;
} }
......
...@@ -502,10 +502,11 @@ void SvtFileDialog::dispose() ...@@ -502,10 +502,11 @@ void SvtFileDialog::dispose()
Sequence< OUString > placesUrlsList(pImpl->_pPlaces->GetNbEditablePlaces()); Sequence< OUString > placesUrlsList(pImpl->_pPlaces->GetNbEditablePlaces());
Sequence< OUString > placesNamesList(pImpl->_pPlaces->GetNbEditablePlaces()); Sequence< OUString > placesNamesList(pImpl->_pPlaces->GetNbEditablePlaces());
int i(0); int i(0);
for(std::vector<PlacePtr>::const_iterator it = aPlaces.begin(); it != aPlaces.end(); ++it) { for (auto const& place : aPlaces)
if((*it)->IsEditable()) { {
placesUrlsList[i] = (*it)->GetUrl(); if(place->IsEditable()) {
placesNamesList[i] = (*it)->GetName(); placesUrlsList[i] = place->GetUrl();
placesNamesList[i] = place->GetName();
++i; ++i;
} }
} }
......
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