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