summaryrefslogtreecommitdiff
path: root/unotools/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-10-05 15:00:39 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-10-05 15:19:05 +0200
commit9db74c6133ede2a28af077fd563398176ff0d858 (patch)
tree06161435d835a269c1ed17e590ba73b3653075c6 /unotools/source
parentaed09ee69fb2e5edfb02c4df81ef1adee407c54f (diff)
fdo#46071: Do not hide windows based on nil "Visible" property
This appears to be messy: The /org.openoffice.Office.Views/WindowType configuration group template has both a nilable bool "Visible" property and a UserData/Data string property that encodes various things like geometry---but also visibility---in a string. Now, likely due to the problem that has meanwhile been fixed through f3f79cc9e6c265baf48955d53f7e888205e0b3e0 "Resolves fdo#46074: Fix Partial::contains for paths that go past a leaf node," some registrymodification.xcu files in the wild contain such WindowType entries in "default" state, without a UserData/Data string and with a nil "Visible" property. The way SfxChildWindow::InitializeChildWinFactory_Impl and SvtViewOptions::IsVisible are implemented, they will always lead to an invisible window for such broken registrymodification.xcu data (as IsVisible unhelpfully returns false for a nil value, and InitializeChildWinFactory_Impl uses that value when there is no UserData/Data string). For the Math formula editor window (ID 30378) this means that it can disappear from the UI completely, as there appears to be no UI trigger for the user to show it in case it is hidden. The fix is to introdue SvtViewOptions::HasVisible (which only returns true if the property is not nil) and change InitializeChidlWinFactory_Impl to only use the value of IsVisible() if HasVisible() returns true. This makes the code even more baroque, but this is a rather central, generic piece of code for all sorts of windows, so I do not want to break any other uses by e.g. changing IsVisible to return true for a nil property. Change-Id: Iae40075a7116a8aabd2d25aa9334709522e23d8f
Diffstat (limited to 'unotools/source')
-rw-r--r--unotools/source/config/viewoptions.cxx40
1 files changed, 33 insertions, 7 deletions
diff --git a/unotools/source/config/viewoptions.cxx b/unotools/source/config/viewoptions.cxx
index faf59372bf4f..2b4ffbc3add1 100644
--- a/unotools/source/config/viewoptions.cxx
+++ b/unotools/source/config/viewoptions.cxx
@@ -266,6 +266,8 @@ class SvtViewOptionsBase_Impl
{
//-------------------------------------------------------------------------------------------------------------
public:
+ enum State { STATE_NONE, STATE_FALSE, STATE_TRUE };
+
SvtViewOptionsBase_Impl ( const ::rtl::OUString& sList );
virtual ~SvtViewOptionsBase_Impl ( );
sal_Bool Exists ( const ::rtl::OUString& sName );
@@ -279,7 +281,7 @@ class SvtViewOptionsBase_Impl
sal_Int32 GetPageID ( const ::rtl::OUString& sName );
void SetPageID ( const ::rtl::OUString& sName ,
sal_Int32 nID );
- sal_Bool GetVisible ( const ::rtl::OUString& sName );
+ State GetVisible ( const ::rtl::OUString& sName );
void SetVisible ( const ::rtl::OUString& sName ,
sal_Bool bVisible );
css::uno::Any GetUserItem ( const ::rtl::OUString& sName ,
@@ -682,28 +684,33 @@ void SvtViewOptionsBase_Impl::SetPageID( const ::rtl::OUString& sName ,
}
//*****************************************************************************************************************
-sal_Bool SvtViewOptionsBase_Impl::GetVisible( const ::rtl::OUString& sName )
+SvtViewOptionsBase_Impl::State SvtViewOptionsBase_Impl::GetVisible( const ::rtl::OUString& sName )
{
#ifdef DEBUG_VIEWOPTIONS
++m_nReadCount;
#endif
- sal_Bool bVisible = sal_False;
+ State eState = STATE_NONE;
try
{
css::uno::Reference< css::beans::XPropertySet > xNode(
impl_getSetNode(sName, sal_False),
css::uno::UNO_QUERY);
if (xNode.is())
- xNode->getPropertyValue(PROPERTY_VISIBLE) >>= bVisible;
+ {
+ sal_Bool bVisible = sal_False;
+ if (xNode->getPropertyValue(PROPERTY_VISIBLE) >>= bVisible)
+ {
+ eState = bVisible ? STATE_TRUE : STATE_FALSE;
+ }
+ }
}
catch(const css::uno::Exception& ex)
{
- bVisible = sal_False;
SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex)
}
- return bVisible;
+ return eState;
}
//*****************************************************************************************************************
@@ -1055,7 +1062,7 @@ sal_Bool SvtViewOptions::IsVisible() const
sal_Bool bState = sal_False;
if( m_eViewType == E_WINDOW )
- bState = m_pDataContainer_Windows->GetVisible( m_sViewName );
+ bState = m_pDataContainer_Windows->GetVisible( m_sViewName ) == SvtViewOptionsBase_Impl::STATE_TRUE;
return bState;
}
@@ -1077,6 +1084,25 @@ void SvtViewOptions::SetVisible( sal_Bool bState )
}
//*****************************************************************************************************************
+// public method
+//*****************************************************************************************************************
+bool SvtViewOptions::HasVisible() const
+{
+ // Ready for multithreading
+ ::osl::MutexGuard aGuard( GetOwnStaticMutex() );
+
+ // Safe impossible cases.
+ // These call isn't allowed for dialogs, tab-dialogs or tab-pages!
+ OSL_ENSURE( !(m_eViewType==E_DIALOG||m_eViewType==E_TABDIALOG||m_eViewType==E_TABPAGE), "SvtViewOptions::IsVisible()\nCall not allowed for Dialogs, TabDialogs or TabPages! I do nothing!\n" );
+
+ bool bState = false;
+ if( m_eViewType == E_WINDOW )
+ bState = m_pDataContainer_Windows->GetVisible( m_sViewName ) != SvtViewOptionsBase_Impl::STATE_NONE;
+
+ return bState;
+}
+
+//*****************************************************************************************************************
css::uno::Sequence< css::beans::NamedValue > SvtViewOptions::GetUserData() const
{
// Ready for multithreading