impress211: #i110990# Fixed remaining problems with display ids and indices.
Conflicts:
sd/source/ui/dlg/present.cxx
diff --git a/sd/source/ui/dlg/present.cxx b/sd/source/ui/dlg/present.cxx
index dbe57f0..1fcc07a 100755
--- a/sd/source/ui/dlg/present.cxx
+++ b/sd/source/ui/dlg/present.cxx
@@ -214,8 +214,9 @@ void SdStartPresentationDlg::InitMonitorSettings()
{
}
sal_Int32 nSelected (nPrimaryIndex);
const sal_Int32 nDefaultValue (
sal_Int32 nSelectedIndex (-1);
sal_Int32 nDefaultExternalIndex (-1);
const sal_Int32 nDefaultSelectedDisplay (
( ( const SfxInt32Item& ) rOutAttrs.Get( ATTR_PRESENT_DISPLAY ) ).GetValue());
const String sPlaceHolder( RTL_CONSTASCII_USTRINGPARAM( "%1" ) );
for( sal_Int32 nDisplay = 0; nDisplay < mnMonitors; nDisplay++ )
@@ -229,25 +230,33 @@ void SdStartPresentationDlg::InitMonitorSettings()
const sal_uInt32 nEntryIndex (maLBMonitor.GetEntryCount()-1);
maLBMonitor.SetEntryData(nEntryIndex, (void*)nDisplay);
// Remember to select the default display.
if (nDefaultValue == nDisplay)
nSelected = nEntryIndex;
// Remember the index of the default selection.
if (nDefaultSelectedDisplay == nDisplay)
nSelectedIndex = nEntryIndex;
// Remember index of the default display.
if (nDisplay == nExternalIndex)
nDefaultExternalIndex = nEntryIndex;
}
if( !bUnifiedDisplay )
{
maLBMonitor.InsertEntry( msAllMonitors );
const sal_uInt32 nEntryIndex (maLBMonitor.GetEntryCount()-1);
maLBMonitor.SetEntryData(nEntryIndex, (void*)-1);
if (nDefaultValue == -1)
nSelected = nEntryIndex;
if (nDefaultSelectedDisplay == -1)
nSelectedIndex = nEntryIndex;
}
if( nSelected <= 0 )
nSelected = nExternalIndex;
else
nSelected--;
if (nSelectedIndex < 0)
{
if (nExternalIndex < 0)
nSelectedIndex = 0;
else
nSelectedIndex = nDefaultExternalIndex;
}
maLBMonitor.SelectEntryPos( (sal_uInt16)nSelected );
maLBMonitor.SelectEntryPos((sal_uInt16)nSelectedIndex);
}
}
catch( Exception& )
diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx
index 3b4ca7d..6c9cc7d 100644
--- a/sd/source/ui/slideshow/slideshow.cxx
+++ b/sd/source/ui/slideshow/slideshow.cxx
@@ -110,6 +110,25 @@ namespace {
private:
::boost::shared_ptr<SlideShowRestarter> mpRestarter;
};
/** Return the default display id (or -1 when that can not be
determined.)
*/
sal_Int32 GetExternalDisplay (void)
{
try
{
Reference< XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
Reference< XPropertySet > xMonProps(xFactory->createInstance( "com.sun.star.awt.DisplayAccess" ), UNO_QUERY_THROW );
sal_Int32 nPrimaryIndex (-1);
if (xMonProps->getPropertyValue( "ExternalDisplay" ) >>= nPrimaryIndex)
return nPrimaryIndex;
}
catch( Exception& )
{
}
return -1;
}
}
@@ -561,6 +580,14 @@ void SAL_CALL SlideShow::setPropertyValue( const OUString& aPropertyName, const
sal_Int32 nDisplay = 0;
if( aValue >>= nDisplay )
{
// Convert value to true display id.
if (nDisplay == 0)
nDisplay = GetExternalDisplay();
else if (nDisplay < 0)
nDisplay = -1;
else
--nDisplay;
bIllegalArgument = false;
SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
@@ -645,7 +672,14 @@ Any SAL_CALL SlideShow::getPropertyValue( const OUString& PropertyName ) throw(U
case ATTR_PRESENT_DISPLAY:
{
SdOptions* pOptions = SD_MOD()->GetSdOptions(DOCUMENT_TYPE_IMPRESS);
return Any( pOptions->GetDisplay() );
const sal_Int32 nDisplay (pOptions->GetDisplay());
// Convert true display id to the previously used schema.
if (nDisplay == GetExternalDisplay())
return Any(sal_Int32(0));
else if (nDisplay < 0)
return Any(sal_Int32(-1));
else
return Any(nDisplay+1);
}
default: