summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJavier Fernandez <jfernandez@igalia.com>2013-05-03 14:06:48 +0000
committerJavier Fernandez <jfernandez@igalia.com>2013-05-08 09:36:39 +0000
commit3fe37133401faef81b09c9bb59b6e57b61931fe9 (patch)
tree4eb8a4d6982c5ef96ce6c3eb497dd198b7f4479f /wizards
parentb88aeb62eeef1f5b7bbff545550f61ca333001d8 (diff)
PyWebWizard: Fixing bugs and implementation of mising features.
DataAware support for accessing the getter/setters methods. Change-Id: I4b6559b0c819f4db457760d31d4a8cbd664e8fbd
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/ui/event/DataAware.py26
-rw-r--r--wizards/com/sun/star/wizards/ui/event/UnoDataAware.py34
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGDesign.py16
3 files changed, 66 insertions, 10 deletions
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAware.py b/wizards/com/sun/star/wizards/ui/event/DataAware.py
index bc64aa769831..5c8c5aabaae5 100644
--- a/wizards/com/sun/star/wizards/ui/event/DataAware.py
+++ b/wizards/com/sun/star/wizards/ui/event/DataAware.py
@@ -16,6 +16,7 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import traceback
+import uno
from abc import ABCMeta, abstractmethod
from ...common.PropertyNames import PropertyNames
@@ -74,7 +75,10 @@ class DataAware(object):
'''
def updateUI(self):
- data = getattr(self._dataObject, self._field)
+ try:
+ data = getattr(self._dataObject, self._field)
+ except Exception:
+ data = uno.invoke(self._dataObject, "get" + self._field, ())
ui = self.getFromUI()
if data is not ui:
try:
@@ -91,8 +95,8 @@ class DataAware(object):
'''
def setDataObject(self, obj, updateUI):
- if obj is not None and not isinstance(obj, type(self._field)):
- return
+ #if obj is not None and not isinstance(obj, type(self._field)):
+ # return
self._dataObject = obj
@@ -105,14 +109,22 @@ class DataAware(object):
'''
def updateData(self):
+ useUno = False
try:
- data = getattr(self._dataObject, self._field)
+ try:
+ data = getattr(self._dataObject, self._field)
+ except Exception:
+ useUno = True
+ data = uno.invoke(self._dataObject, "get" + self._field, ())
ui = self.getFromUI()
if data is not ui:
- if isinstance(ui,tuple):
+ #if isinstance(ui,tuple):
#Selected Element listbox
- ui = ui[0]
- setattr(self._dataObject, self._field, ui)
+ # ui = ui[0]
+ if useUno:
+ uno.invoke(self._dataObject, "set" + self._field, (ui,))
+ else:
+ setattr(self._dataObject, self._field, ui)
self.enableControls(ui)
except Exception:
traceback.print_exc()
diff --git a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
index 6f1e9b2c4992..ea728b9687f6 100644
--- a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
+++ b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
@@ -43,12 +43,40 @@ class UnoDataAware(DataAware):
def enableControls(self, value):
for i in self.disableObjects:
- i.Model.Enabled = bool(value)
+ i.Model.Enabled = self.getBoolean(value)
def setToUI(self, value):
- if self.isShort:
+ if (isinstance(value, list)):
+ length = len(value)
+ value = tuple(value)
+ elif self.isShort:
value = uno.Any("[]short", (value,))
- setattr(self.unoModel, self.unoPropName, value)
+ if (hasattr(self.unoModel, self.unoPropName)):
+ setattr(self.unoModel, self.unoPropName, value)
+ else:
+ uno.invoke(self.unoModel, "set" + self.unoPropName, (value,))
+
+ # Try to get from an arbitrary object a boolean value.
+ # Null returns Boolean.FALSE;
+ # A Boolean object returns itself.
+ # An Array returns true if it not empty.
+ # An Empty String returns Boolean.FALSE.
+ # everything else returns a Boolean.TRUE.
+ # @param value
+ # @return
+ def getBoolean(self, value):
+ if (value is None):
+ return False
+ elif (isinstance(value, bool)):
+ return bool(value)
+ elif (isinstance(value, list)):
+ return True if (len(value) is not 0) else False
+ elif (value is ""):
+ return False
+ elif (isinstance(value, int)):
+ return True if (value == 0) else False
+ else:
+ return True
def getFromUI(self):
return getattr(self.unoModel, self.unoPropName)
diff --git a/wizards/com/sun/star/wizards/web/data/CGDesign.py b/wizards/com/sun/star/wizards/web/data/CGDesign.py
index a53e40ae00e2..4887bf74982b 100644
--- a/wizards/com/sun/star/wizards/web/data/CGDesign.py
+++ b/wizards/com/sun/star/wizards/web/data/CGDesign.py
@@ -37,3 +37,19 @@ class CGDesign(ConfigGroup):
def createDOM(self, parent):
return XMLHelper.addElement(parent, "design", (0,), (0,))
+
+ def getStyle(self):
+ style = self.root.cp_Styles.getElement(self.cp_Style)
+ return [self.root.cp_Styles.getIndexOf(style)]
+
+ def setStyle(self, newStyle):
+ o = self.root.cp_Styles.getElementAt(newStyle[0])
+ self.cp_Style = self.root.cp_Styles.getKey(o)
+
+ def getLayout(self):
+ layout = self.root.cp_Layouts.getElement(self.cp_Layout)
+ return layout.cp_Index
+
+ def setLayout(self, layoutIndex):
+ layout = self.root.cp_Layouts.getElementAt(layoutIndex)
+ self.cp_Layout = self.root.cp_Layouts.getKey(layout)