Expert config edit button implemented.

Value modifying dialog added. Checking if property changed before from a
vector. Not stable but working.

Change-Id: Id2b5ac102007af21ec12635b98f24a11c5befc90
Reviewed-on: https://gerrit.libreoffice.org/5306
Tested-by: Katarina Behrens <bubli@bubli.org>
Tested-by: Thorsten Behrens <tbehrens@suse.com>
Reviewed-by: Thorsten Behrens <tbehrens@suse.com>
This commit is contained in:
Efe Gürkan YALAMAN
2013-08-07 16:32:34 +03:00
committed by Thorsten Behrens
parent 9b56ecd00f
commit a27bc43cb6
4 changed files with 274 additions and 13 deletions

View File

@@ -12,6 +12,7 @@ $(eval $(call gb_UIConfig_UIConfig,cui))
$(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/aboutdialog \
cui/uiconfig/ui/aboutconfigdialog\
cui/uiconfig/ui/aboutconfigvaluedialog \
cui/uiconfig/ui/acorexceptpage \
cui/uiconfig/ui/acoroptionspage \
cui/uiconfig/ui/acorreplacepage \

View File

@@ -18,8 +18,11 @@
#include <com/sun/star/beans/Property.hpp>
#include <com/sun/star/beans/XProperty.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XNameReplace.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
#include <vector>
using namespace svx;
using namespace ::com::sun::star;
@@ -31,6 +34,20 @@ using namespace com::sun::star::container;
#define ITEMID_TYPE 3
#define ITEMID_VALUE 4
struct Prop_Impl
{
OUString Name;
OUString Property;
Any Value;
Prop_Impl( const OUString& sName, const OUString& sProperty, const Any& aValue )
: Name( sName )
, Property( sProperty )
, Value( aValue )
{
}
};
CuiAboutConfigTabPage::CuiAboutConfigTabPage( Window* pParent, const SfxItemSet& rItemSet )
:SfxTabPage( pParent, "AboutConfig", "cui/ui/aboutconfigdialog.ui", rItemSet)
{
@@ -92,8 +109,10 @@ void CuiAboutConfigTabPage::Reset( const SfxItemSet& )
OUString sRootNodePath = "/";
pPrefBox->Clear();
VectorOfModified.clear();
m_pDefaultBtn->Enable(sal_False);
m_pEditBtn->Enable(sal_False);
//m_pEditBtn->Enable(sal_False);
const char* entries[] = {
"/org.openoffice.Office.Common",
@@ -106,10 +125,35 @@ void CuiAboutConfigTabPage::Reset( const SfxItemSet& )
Reference< XNameAccess > xConfigAccess = getConfigAccess( sRootNodePath, sal_False );
FillItems( xConfigAccess, sRootNodePath );
}
}
//Reference< XNameAccess > xConfigAccess = getConfigAccess( sRootNodePath, sal_False );
sal_Bool CuiAboutConfigTabPage::FillItemSet( SfxItemSet& )
{
sal_Bool bModified = sal_False;
Reference< XNameAccess > xUpdateAccess = getConfigAccess( "/", sal_True );
//Reference< XNameReplace > xNameReplace( xUpdateAccess, UNO_QUERY_THROW );
//if( !xNameReplace.is() )
//return bModified;
for( size_t nInd = 0; nInd < VectorOfModified.size(); ++nInd )
{
//beans::NamedValue aNamedValue = VectorOfModified[ nInd ];
Prop_Impl* aNamedValue = VectorOfModified[ nInd ];
xUpdateAccess = getConfigAccess( aNamedValue->Name , sal_True );
Reference< XNameReplace > xNameReplace( xUpdateAccess, UNO_QUERY_THROW );
xNameReplace->replaceByName( aNamedValue->Property, aNamedValue->Value );
bModified = sal_True;
}
Reference< util::XChangesBatch > xChangesBatch( xUpdateAccess, UNO_QUERY_THROW );
xChangesBatch->commitChanges();
return bModified;
//FillItems( xConfigAccess, sRootNodePath );
}
void CuiAboutConfigTabPage::FillItems( Reference< XNameAccess >xNameAccess, OUString sPath)
@@ -221,7 +265,7 @@ void CuiAboutConfigTabPage::FillItems( Reference< XNameAccess >xNameAccess, OUSt
default:
{
sValue = OUString("test");
sValue = OUString("");
}
}
}
@@ -264,6 +308,45 @@ Reference< XNameAccess > CuiAboutConfigTabPage::getConfigAccess( OUString sNodeP
return xNameAccess;
}
//void CuiAboutConfigTabPage::AddToModifiedVector( beans::NamedValue& rProp )
void CuiAboutConfigTabPage::AddToModifiedVector( Prop_Impl* rProp )
{
bool isModifiedBefore = false;
//Check if value modified before
for( size_t nInd = 0; nInd < VectorOfModified.size() ; ++nInd )
{
if( rProp->Name == VectorOfModified[nInd]->Name && rProp->Value == VectorOfModified[nInd]->Value )
{
//property modified before. assing reference to the modified value
//do your changes on this object. They will be saved later.
VectorOfModified[nInd] = rProp;
isModifiedBefore = true;
break;
}
}
if( !isModifiedBefore )
{
VectorOfModified.push_back( rProp );
}
//property is not modified be
}
CuiAboutConfigValueDialog::CuiAboutConfigValueDialog( Window* pWindow, const OUString& rValue )
:ModalDialog( pWindow, "AboutConfigValueDialog", "cui/ui/aboutconfigvaluedialog.ui" )
{
get(m_pBtnOK, "ok");
get(m_pBtnCancel, "cancel");
get(m_pEDValue, "valuebox");
m_pEDValue->SetText( rValue );
}
CuiAboutConfigValueDialog::~CuiAboutConfigValueDialog()
{
}
IMPL_LINK( CuiAboutConfigTabPage, HeaderSelect_Impl, HeaderBar*, pBar )
{
if ( pBar && pBar->GetCurItemId() != ITEMID_TYPE )
@@ -295,18 +378,64 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl )
{
SvTreeListEntry* pEntry = pPrefBox->FirstSelected();
OUString sType = pPrefBox->GetEntryText( pEntry, 2 );
OUString sPropertyPath = pPrefBox->GetEntryText( pEntry, 0 );
OUString sPropertyName = pPrefBox->GetEntryText( pEntry, 1 );
OUString sPropertyType = pPrefBox->GetEntryText( pEntry, 2 );
OUString sPropertyValue = pPrefBox->GetEntryText( pEntry, 3 );
if( sType == OUString("boolean") )
//beans::NamedValue aProperty;
//aProperty.Name = sPropertyPath + OUString("/") + sPropertyName;
Prop_Impl* aProperty = new Prop_Impl( sPropertyPath, sPropertyName, makeAny( sPropertyValue ) );
bool bOpenDialog;
OUString sDialogValue;
OUString sNewValue;
if( sPropertyType == OUString( "boolean" ) )
{
//TODO: this is just cosmetic, take all needed value and handle them properly
OUString sValue = pPrefBox->GetEntryText( pEntry, 3 );
if (sValue == OUString("true"))
pPrefBox->SetEntryText( OUString("false"), pEntry, 3 );
else if(sValue == OUString("false"))
pPrefBox->SetEntryText( OUString("true"), pEntry, 3 );
bool bValue;
if( sPropertyValue == OUString("true") )
{
sDialogValue = OUString("false");
bValue = false;
}
else
{
sDialogValue = OUString("true");
bValue = true;
}
aProperty->Value = uno::makeAny( bValue );
bOpenDialog = false;
}else// if ( sPropertyType == OUString( "string" ) )
{
//TODO: handle void etc.
sDialogValue = sPropertyValue;
bOpenDialog = true;
}
//TODO: add other types
if( bOpenDialog )
{
CuiAboutConfigValueDialog* pValueDialog = new CuiAboutConfigValueDialog(0, sDialogValue);
bool ret = pValueDialog->Execute();
if( ret == RET_OK )
{
sNewValue = pValueDialog->getValue();
//TODO: parse the value according to the type?
aProperty->Value = uno::makeAny( sNewValue );
AddToModifiedVector( aProperty );
sDialogValue = sNewValue;
}
}
pPrefBox->SetEntryText( sDialogValue, pEntry, 3 );
//TODO:update listbox value.
return 0;

View File

@@ -14,12 +14,17 @@
#include <svtools/simptabl.hxx>
#include "optHeaderTabListbox.hxx"
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <vcl/edit.hxx>
#include <vector>
namespace svx
{
class OptHeaderTabListBox;
}
class CuiAboutConfigTabPage;
class CuiAboutConfigValueDialog;
struct Prop_Impl;
class CuiAboutConfigTabPage : public SfxTabPage
{
@@ -28,9 +33,14 @@ private:
PushButton* m_pDefaultBtn;
PushButton* m_pEditBtn;
//std::vector< com::sun::star::beans::NamedValue > VectorOfModified;
std::vector< Prop_Impl* > VectorOfModified;
::svx::OptHeaderTabListBox* pPrefBox;
CuiAboutConfigTabPage( Window* pParent, const SfxItemSet& rItemSet );
~CuiAboutConfigTabPage();
//void AddToModifiedVector( com::sun::star::beans::NamedValue& rProp );
void AddToModifiedVector( Prop_Impl* rProp );
DECL_LINK( HeaderSelect_Impl, HeaderBar * );
DECL_LINK( StandardHdl_Impl, void * );
@@ -41,7 +51,25 @@ public:
void Reset( const SfxItemSet& );
void FillItems( com::sun::star::uno::Reference < com::sun::star::container::XNameAccess > xNameAccess, OUString sPath);
com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > getConfigAccess( OUString sNodePath, sal_Bool bUpdate );
virtual sal_Bool FillItemSet( SfxItemSet& rSet );
};
class CuiAboutConfigValueDialog : public ModalDialog
{
private:
OKButton* m_pBtnOK;
CancelButton* m_pBtnCancel;
VclMultiLineEdit* m_pEDValue;
public:
CuiAboutConfigValueDialog( Window* pWindow, const OUString& rValue );
~CuiAboutConfigValueDialog();
OUString getValue()
{
return m_pEDValue->GetText();
}
};
#endif

View File

@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkDialog" id="AboutConfigValueDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Name</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="layout_style">start</property>
<child>
<object class="GtkButton" id="ok">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Value</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTextView" id="valuebox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="vexpand">True</property>
<property name="wrap_mode">char</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">ok</action-widget>
<action-widget response="0">cancel</action-widget>
</action-widgets>
</object>
</interface>