Review Expert Configuration dialog's tree view.

In Expert configuration dialog's tree view didn't work correctly. Now I
followed the old pattern. Additionaly the entries' name are shorter.

Change-Id: Ib7ecd065f02c8f3bbef94daf7f32cb68ab676ee8
Reviewed-on: https://gerrit.libreoffice.org/16411
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Mihály Palenik
2015-06-22 13:38:04 +02:00
committed by Caolán McNamara
parent b5f4275e70
commit eb0c9b43e7
2 changed files with 335 additions and 313 deletions

View File

@@ -55,6 +55,23 @@ struct Prop_Impl
{}
};
struct UserData
{
bool bIsPropertyPath;
OUString sPropertyPath;
Reference<XNameAccess> aXNameAccess;
UserData( OUString rPropertyPath )
: bIsPropertyPath( true )
, sPropertyPath(rPropertyPath)
{}
UserData( Reference<XNameAccess> rXNameAccess )
: bIsPropertyPath( false )
, aXNameAccess( rXNameAccess )
{}
};
VCL_BUILDER_FACTORY_ARGS(CuiCustomMultilineEdit,WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK)
void CuiCustomMultilineEdit::KeyInput( const KeyEvent& rKeyEvent )
@@ -176,7 +193,7 @@ void CuiAboutConfigTabPage::dispose()
ModelessDialog::dispose();
}
void CuiAboutConfigTabPage::InsertEntry(const OUString& rProp, const OUString& rStatus,
void CuiAboutConfigTabPage::InsertEntry(const OUString& rPropertyPath, const OUString& rProp, const OUString& rStatus,
const OUString& rType, const OUString& rValue, SvTreeListEntry *pParentEntry)
{
SvTreeListEntry* pEntry = new SvTreeListEntry;
@@ -185,6 +202,7 @@ void CuiAboutConfigTabPage::InsertEntry(const OUString& rProp, const OUString& r
pEntry->AddItem( new SvLBoxString( pEntry, 0, rStatus));
pEntry->AddItem( new SvLBoxString( pEntry, 0, rType));
pEntry->AddItem( new SvLBoxString( pEntry, 0, rValue));
pEntry->SetUserData( new UserData(rPropertyPath) );
m_pPrefBox->Insert( pEntry, pParentEntry );
@@ -228,43 +246,40 @@ bool CuiAboutConfigTabPage::FillItemSet()
void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAccess, SvTreeListEntry *pParentEntry)
{
OUString sPath = Reference< XHierarchicalName >(
xNameAccess, uno::UNO_QUERY_THROW )->getHierarchicalName();
uno::Sequence< OUString > seqItems = xNameAccess->getElementNames();
for( sal_Int32 i = 0; i < seqItems.getLength(); ++i )
{
Any aNode = xNameAccess->getByName( seqItems[i] );
Reference< XNameAccess > xChildNameAccess;
bool bNotLeaf = false;
Reference< XNameAccess > xNextNameAccess;
try
{
xChildNameAccess = Reference< XNameAccess >(aNode, uno::UNO_QUERY);
OUString sPath = Reference< XHierarchicalName >(
xChildNameAccess, uno::UNO_QUERY_THROW )->getHierarchicalName();
uno::Sequence< OUString > seqChildItems = xChildNameAccess->getElementNames();
bool bIsNotLeaf = false;
for( sal_Int32 l = 0; l < seqChildItems.getLength(); ++l )
xNextNameAccess = Reference< XNameAccess >(aNode, uno::UNO_QUERY);
bNotLeaf = xNextNameAccess.is();
}
catch (const RuntimeException& e)
{
aNode = xChildNameAccess->getByName( seqChildItems[l] );
SAL_WARN( "cui.options", "CuiAboutConfigTabPage: exception " << e.Message);
}
Reference< XNameAccess > xGrandChildNameAccess = Reference< XNameAccess >(aNode, uno::UNO_QUERY);
if(xGrandChildNameAccess.is())
if (bNotLeaf)
{
// not leaf node
if(bIsNotLeaf)
continue;
SvTreeListEntry* pEntry = new SvTreeListEntry;
pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, SvTreeListBox::GetDefaultExpandedNodeImage(),
SvTreeListBox::GetDefaultCollapsedNodeImage(), false));
pEntry->AddItem( new SvLBoxString( pEntry, 0, sPath));
pEntry->AddItem( new SvLBoxString( pEntry, 0, seqItems[i]));
//It is needed, without this the selection line will be truncated.
pEntry->AddItem( new SvLBoxString( pEntry, 0, ""));
pEntry->AddItem( new SvLBoxString( pEntry, 0, ""));
pEntry->AddItem( new SvLBoxString( pEntry, 0, ""));
pEntry->SetUserData( new Reference<XNameAccess>(xChildNameAccess) );
pEntry->SetUserData( new UserData(xNextNameAccess) );
m_pPrefBox->Insert( pEntry, pParentEntry );
bIsNotLeaf = true;
}
else
{
@@ -420,16 +435,19 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
break;
}
InsertEntry( sPath, seqChildItems[l], sType, sValue, pParentEntry);
}
}
}
catch (const RuntimeException& e)
{
SAL_WARN( "cui.options", "CuiAboutConfigTabPage: exception " << e.Message);
}
}
//Short name
int index = 0;
int lineage;
SvTreeListEntry *parentEntry = pParentEntry;
for(lineage = 0; parentEntry != nullptr; ++lineage)
parentEntry = m_pPrefBox->GetParent(parentEntry);
for(int j = 1; j < lineage; ++j)
index = sPath.indexOf("/", index + 1);
InsertEntry(sPath, sPath.copy(index+1), seqItems[i], sType, sValue, pParentEntry);
}
}
m_pPrefBox->SetAlternatingRowColors( true );
}
@@ -531,21 +549,22 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl )
{
SvTreeListEntry* pEntry = m_pPrefBox->FirstSelected();
if(pEntry->GetUserData() != nullptr)
UserData *pUserData = static_cast<UserData*>(pEntry->GetUserData());
if(!pUserData->bIsPropertyPath)
{
//if selection is not node
if(!pEntry->HasChildren())
FillItems( *static_cast<Reference<XNameAccess>*>(pEntry->GetUserData()), pEntry );
FillItems( pUserData->aXNameAccess, pEntry );
}
else
{
//if selection is a node
OUString sPropertyPath = SvTabListBox::GetEntryText( pEntry, 0 );
OUString sPropertyName = SvTabListBox::GetEntryText( pEntry, 1 );
OUString sPropertyType = SvTabListBox::GetEntryText( pEntry, 2 );
OUString sPropertyValue = SvTabListBox::GetEntryText( pEntry, 3 );
boost::shared_ptr< Prop_Impl > pProperty (new Prop_Impl( sPropertyPath, sPropertyName, makeAny( sPropertyValue ) ) );
boost::shared_ptr< Prop_Impl > pProperty (new Prop_Impl( pUserData->sPropertyPath, sPropertyName, makeAny( sPropertyValue ) ) );
bool bSaveChanges = false;
bool bOpenDialog = true;
OUString sDialogValue;
@@ -567,6 +586,7 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl )
pProperty->Value = uno::makeAny( bValue );
bOpenDialog = false;
bSaveChanges = true;
}
else if ( sPropertyType == "void" )
{
@@ -596,6 +616,7 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl )
if( pValueDialog->Execute() == RET_OK )
{
sNewValue = pValueDialog->getValue();
bSaveChanges = true;
if ( sPropertyType == "short")
{
sal_Int16 nShort;
@@ -608,8 +629,7 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl )
throw uno::Exception();
pProperty->Value = uno::makeAny( nShort );
}
else
if( sPropertyType == "long" )
else if( sPropertyType == "long" )
{
sal_Int32 nLong = sNewValue.toInt32();
if( !( nLong==0 && sNewValue.getLength()!=1 ) && nLong < SAL_MAX_INT32 && nLong > SAL_MIN_INT32)
@@ -713,18 +733,21 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl )
else //unknown
throw uno::Exception();
sDialogValue = sNewValue;
}
}
if(bSaveChanges)
{
AddToModifiedVector( pProperty );
//update listbox value.
m_pPrefBox->SetEntryText( sDialogValue, pEntry, 3 );
//update m_prefBoxEntries
SvTreeListEntries::iterator it = std::find_if(m_prefBoxEntries.begin(), m_prefBoxEntries.end(),
[&sPropertyPath, &sPropertyName](SvTreeListEntry &entry) -> bool
[&pUserData, &sPropertyName](SvTreeListEntry &entry) -> bool
{
return static_cast< SvLBoxString* >( entry.GetItem(1) )->GetText().equals( sPropertyPath ) &&
return static_cast< SvLBoxString* >( entry.GetItem(1) )->GetText().equals( pUserData->sPropertyPath ) &&
static_cast< SvLBoxString* >( entry.GetItem(2) )->GetText().equals( sPropertyName );
}
);
@@ -732,7 +755,6 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl )
it->ReplaceItem( new SvLBoxString( &(*it), 0, sDialogValue ), 4 );
}
}
}
catch( uno::Exception& )
{
}

View File

@@ -67,7 +67,7 @@ public:
explicit CuiAboutConfigTabPage(vcl::Window* pParent);
virtual ~CuiAboutConfigTabPage();
virtual void dispose() SAL_OVERRIDE;
void InsertEntry(const OUString& rProp, const OUString& rStatus, const OUString& rType, const OUString& rValue,
void InsertEntry(const OUString &rPropertyPath, const OUString& rProp, const OUString& rStatus, const OUString& rType, const OUString& rValue,
SvTreeListEntry *pParentEntry = nullptr);
void Reset();
void FillItems(const com::sun::star::uno::Reference<com::sun::star::container::XNameAccess>& xNameAccess,