summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2012-07-17 13:57:26 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-07-18 09:29:19 +0100
commitff6c2e7828d4d8901eab80a4a784362286900766 (patch)
tree9e280831bf254b0fca815778e9a3c366deb19f3f /wizards
parentfb92bbcf012c0e98e887f341ee56e94132e856db (diff)
fs34b: #i117472# fix color calculation from style string
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java83
-rw-r--r--wizards/com/sun/star/wizards/form/CallFormWizard.java2
-rw-r--r--wizards/com/sun/star/wizards/form/FormDocument.java8
-rw-r--r--wizards/com/sun/star/wizards/form/FormWizard.java30
-rw-r--r--wizards/com/sun/star/wizards/form/StyleApplier.java80
-rw-r--r--wizards/com/sun/star/wizards/query/CallQueryWizard.java2
-rw-r--r--wizards/com/sun/star/wizards/query/QueryWizard.java91
7 files changed, 120 insertions, 176 deletions
diff --git a/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java b/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java
index e03323c6ebbc..6be3c27da51b 100644
--- a/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java
+++ b/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java
@@ -16,7 +16,10 @@ import com.sun.star.sdbc.SQLException;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.wizards.common.Desktop;
import com.sun.star.wizards.common.NamedValueCollection;
+import com.sun.star.wizards.common.Properties;
import com.sun.star.wizards.ui.WizardDialog;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -73,4 +76,84 @@ public abstract class DatabaseObjectWizard extends WizardDialog
Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, null, ex );
}
}
+
+ protected static void executeWizardFromCommandLine( final String i_args[], final String i_className )
+ {
+ final String settings[] = new String[] { null, null, null };
+ final int IDX_PIPE_NAME = 0;
+ final int IDX_LOCATION = 1;
+ final int IDX_DSN = 2;
+
+ // some simple parsing
+ boolean failure = false;
+ int settingsIndex = -1;
+ for ( int i=0; i<i_args.length; ++i )
+ {
+ if ( settingsIndex >= 0 )
+ {
+ settings[ settingsIndex ] = i_args[i];
+ settingsIndex = -1;
+ continue;
+ }
+
+ if ( i_args[i].equals( "--pipe-name" ) )
+ {
+ settingsIndex = IDX_PIPE_NAME;
+ continue;
+ }
+
+ if ( i_args[i].equals( "--database-location" ) )
+ {
+ settingsIndex = IDX_LOCATION;
+ continue;
+ }
+
+ if ( i_args[i].equals( "--data-source-name" ) )
+ {
+ settingsIndex = IDX_DSN;
+ continue;
+ }
+
+ failure = true;
+ }
+
+ if ( settings[ IDX_PIPE_NAME ] == null )
+ failure = true;
+
+ if ( ( settings[ IDX_DSN ] == null ) && ( settings[ IDX_LOCATION ] == null ) )
+ failure = true;
+
+ if ( failure )
+ {
+ System.err.println( "supported arguments: " );
+ System.err.println( " --pipe-name <name> : specifies the name of the pipe to connect to the running OOo instance" );
+ System.err.println( " --database-location <url> : specifies the URL of the database document to work with" );
+ System.err.println( " --data-source-name <name> : specifies the name of the data source to work with" );
+ return;
+ }
+
+ final String ConnectStr = "uno:pipe,name=" + settings[IDX_PIPE_NAME] + ";urp;StarOffice.ServiceManager";
+ try
+ {
+ final XMultiServiceFactory serviceFactory = Desktop.connect(ConnectStr);
+ if (serviceFactory != null)
+ {
+ PropertyValue[] curproperties = new PropertyValue[1];
+ if ( settings[ IDX_LOCATION ] != null )
+ curproperties[0] = Properties.createProperty( "DatabaseLocation", settings[ IDX_LOCATION ] );
+ else
+ curproperties[0] = Properties.createProperty( "DataSourceName", settings[ IDX_DSN ] );
+
+ final Class wizardClass = Class.forName( i_className );
+ final Constructor ctor = wizardClass.getConstructor( XMultiServiceFactory.class, PropertyValue[].class );
+ final Method invokeMethod = wizardClass.getMethod( "start", new Class[0] );
+ final Object wizardInstance = ctor.newInstance( serviceFactory, curproperties );
+ invokeMethod.invoke( wizardInstance );
+ }
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.err);
+ }
+ }
}
diff --git a/wizards/com/sun/star/wizards/form/CallFormWizard.java b/wizards/com/sun/star/wizards/form/CallFormWizard.java
index 980899745b3c..20eb7c3475b0 100644
--- a/wizards/com/sun/star/wizards/form/CallFormWizard.java
+++ b/wizards/com/sun/star/wizards/form/CallFormWizard.java
@@ -82,7 +82,7 @@ public class CallFormWizard
if (sEvent.compareTo(PropertyNames.START) == 0)
{
FormWizard CurFormWizard = new FormWizard( m_serviceFactory, m_wizardContext );
- CurFormWizard.startFormWizard();
+ CurFormWizard.start();
}
}
catch (Exception exception)
diff --git a/wizards/com/sun/star/wizards/form/FormDocument.java b/wizards/com/sun/star/wizards/form/FormDocument.java
index 10152d083e41..60b27e0ebb14 100644
--- a/wizards/com/sun/star/wizards/form/FormDocument.java
+++ b/wizards/com/sun/star/wizards/form/FormDocument.java
@@ -389,7 +389,7 @@ public class FormDocument extends TextDocument
public void initialize(int _curArrangement, Short _NBorderType)
{
- boolean badaptControlStyles = false;
+ boolean adaptControlStyles = false;
xTextDocument.lockControllers();
curArrangement = _curArrangement;
if (oGridControl != null)
@@ -413,14 +413,14 @@ public class FormDocument extends TextDocument
if (curArrangement == FormWizard.AS_GRID)
{
insertGridControl(_NBorderType);
- badaptControlStyles = true;
+ adaptControlStyles = true;
}
else
{
- badaptControlStyles = !oFormController.areControlsexisting();
+ adaptControlStyles = !oFormController.areControlsexisting();
oFormController.positionControls(_curArrangement, aStartPoint, getAvailableFormSize(), curUIControlArranger.getAlignValue(), _NBorderType);
}
- if (badaptControlStyles)
+ if (adaptControlStyles)
{
curStyleApplier.applyStyle(false, true);
}
diff --git a/wizards/com/sun/star/wizards/form/FormWizard.java b/wizards/com/sun/star/wizards/form/FormWizard.java
index f9d63ad78eab..8356d72205ad 100644
--- a/wizards/com/sun/star/wizards/form/FormWizard.java
+++ b/wizards/com/sun/star/wizards/form/FormWizard.java
@@ -29,7 +29,6 @@ package com.sun.star.wizards.form;
import com.sun.star.awt.XWindowPeer;
import com.sun.star.beans.PropertyValue;
import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lang.XComponent;
import com.sun.star.sdb.application.DatabaseObject;
import com.sun.star.wizards.common.Helper;
import com.sun.star.wizards.common.PropertyNames;
@@ -95,6 +94,11 @@ public class FormWizard extends DatabaseObjectWizard
}
}
+ public static void main(String i_args[])
+ {
+ executeWizardFromCommandLine( i_args, FormWizard.class.getName() );
+ }
+
// @Override
protected void enterStep(int nOldStep, int nNewStep)
{
@@ -334,7 +338,7 @@ public class FormWizard extends DatabaseObjectWizard
setCurrentRoadmapItemID((short) 1);
}
- public void startFormWizard()
+ public void start()
{
try
{
@@ -447,26 +451,24 @@ public class FormWizard extends DatabaseObjectWizard
private boolean toggleSubFormSteps()
{
curSubFormFieldSelection.setModified(true);
- boolean benable = curSubFormFieldSelection.getSelectedFieldNames().length > 0;
- enablefromStep(SOFIELDLINKER_PAGE, benable);
- if (benable)
- {
+ boolean enabled = curSubFormFieldSelection.getSelectedFieldNames().length > 0;
+ enablefromStep(SOFIELDLINKER_PAGE, enabled);
+ if (enabled)
curFieldLinker.enable(!curFormConfiguration.areexistingRelationsdefined());
- }
- return benable;
+ return enabled;
}
private void toggleMainFormSteps()
{
curDBCommandFieldSelection.setModified(true);
- boolean benable = curDBCommandFieldSelection.getSelectedFieldNames().length > 0;
- enablefromStep(SOSUBFORM_PAGE, benable);
- setControlProperty("btnWizardNext", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benable));
- if (benable)
+ boolean enabled = curDBCommandFieldSelection.getSelectedFieldNames().length > 0;
+ enablefromStep(SOSUBFORM_PAGE, enabled);
+ setControlProperty("btnWizardNext", PropertyNames.PROPERTY_ENABLED, enabled);
+ if (enabled)
{
if (curFormConfiguration.hasSubForm())
{
- benable = toggleSubFormSteps();
+ enabled = toggleSubFormSteps();
}
else
{
@@ -474,7 +476,7 @@ public class FormWizard extends DatabaseObjectWizard
setStepEnabled(SOFIELDLINKER_PAGE, false);
}
}
- setControlProperty("btnWizardFinish", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(benable));
+ setControlProperty("btnWizardFinish", PropertyNames.PROPERTY_ENABLED, enabled);
}
}
}
diff --git a/wizards/com/sun/star/wizards/form/StyleApplier.java b/wizards/com/sun/star/wizards/form/StyleApplier.java
index 7e1cfff40f82..c753162abf41 100644
--- a/wizards/com/sun/star/wizards/form/StyleApplier.java
+++ b/wizards/com/sun/star/wizards/form/StyleApplier.java
@@ -36,9 +36,7 @@ import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XInterface;
import com.sun.star.wizards.common.Configuration;
-import com.sun.star.wizards.common.Desktop;
import com.sun.star.wizards.common.FileAccess;
import com.sun.star.wizards.common.Helper;
import com.sun.star.wizards.common.JavaTools;
@@ -49,11 +47,9 @@ import com.sun.star.wizards.document.DatabaseControl;
import com.sun.star.wizards.document.GridControl;
import com.sun.star.wizards.document.TimeStampControl;
import com.sun.star.wizards.text.TextStyleHandler;
-import com.sun.star.wizards.ui.*;
import com.sun.star.wizards.ui.UIConsts;
-import java.util.ArrayList;
-
-// TODO: Style Templates fuer OOo?
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.WizardDialog;
public class StyleApplier
{
@@ -64,23 +60,17 @@ public class StyleApplier
private short curtabindex;
private XRadioButton optNoBorder;
private XRadioButton opt3DLook;
- private XRadioButton optFlat;
private XListBox lstStyles;
- private Desktop.OfficePathRetriever curofficepath;// String[][] sLayoutFiles;
private FormDocument curFormDocument;
private short iOldLayoutPos;
- private int SOLAYOUTLST = 0;
private static final String SCHANGELAYOUT = "changeLayout";
private static final String SCHANGEBORDERTYPE = "changeBorderLayouts";
private String[] StyleNames;
private String[] StyleNodeNames;
private String[] FileNames;
- // private String StylesPath;
private final static int SOBACKGROUNDCOLOR = 0;
private final static int SODBTEXTCOLOR = 1;
private final static int SOLABELTEXTCOLOR = 2;
-// final static int SODBCONTROLBACKGROUNDCOLOR = 3;
- private final static int SOLABELBACKGROUNDCOLOR = 4;
private final static int SOBORDERCOLOR = 5;
private Short IBorderValue = new Short((short) 1);
@@ -101,7 +91,6 @@ public class StyleApplier
String s3DLook = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 30);
String sFlat = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 31);
String sFieldBorder = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 28);
-// XInterface xUcbInterface = (XInterface) _curFormDocument.xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
setStyles();
short[] SelLayoutPos;
SelLayoutPos = new short[]
@@ -149,7 +138,7 @@ public class StyleApplier
UIConsts.INTEGERS[10], "HID:WIZARDS_HID_DLGFORM_CMD3DBORDER", s3DLook, 196, 53, new Short((short) 1), IStyleStep, new Short(curtabindex++), "1", 93
});
- optFlat = CurUnoDialog.insertRadioButton("otpFlat", SCHANGEBORDERTYPE, this,
+ CurUnoDialog.insertRadioButton("otpFlat", SCHANGEBORDERTYPE, this,
new String[]
{
PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, "Tag", PropertyNames.PROPERTY_WIDTH
@@ -175,13 +164,6 @@ public class StyleApplier
// }
}
- /* public void initialize(short _iStyleindex){
- if (_iStyleindex < lstStyles.getItemCount()){
- Helper.setUnoPropertyValue(UnoDialog.getModel(lstStyles), PropertyNames.SELECTED_ITEMS, new short[]{_iStyleindex});
- applyStyle(true, false);
- }
- }
- */
private void setStyles()
{
try
@@ -249,12 +231,6 @@ public class StyleApplier
curFormDocument.unlockallControllers();
}
- /* public void changeLayout(){
- / curFormDocument.xTextDocument.lockControllers();
- applyStyle(true, false);
- curFormDocument.unlockallControllers();
- }
- */
public Short getBorderType()
{
return IBorderValue;
@@ -327,12 +303,10 @@ public class StyleApplier
private int getStyleColor(String[] _sDataList, String _sHeader, String _sPropertyDescription)
{
- int iColor = -1;
int index = JavaTools.FieldInList(_sDataList, _sHeader);
if (index > -1)
{
String sPropName = PropertyNames.EMPTY_STRING;
- int iStyleColor;
while (((sPropName.indexOf("}") < 0) && (index < _sDataList.length - 1)))
{
String scurline = _sDataList[index++];
@@ -356,46 +330,20 @@ public class StyleApplier
return -1;
}
- private XMultiServiceFactory getMSF()
- {
- return xMSF;
- }
-
- private ArrayList<String> getStylePaths()
+ private String getStylePath()
{
- ArrayList<String> aStylePaths = new ArrayList<String>();
+ String StylesPath = "";
try
{
- // TODO: check different languages in header layouts
- aStylePaths = FileAccess.getOfficePaths(getMSF(), "Config", PropertyNames.EMPTY_STRING, PropertyNames.EMPTY_STRING);
- FileAccess.combinePaths(getMSF(), aStylePaths, "/wizard/form/styles");
-
- String[][] LayoutFiles = FileAccess.getFolderTitles(getMSF(), null, aStylePaths, ".css");
-
- }
- catch (com.sun.star.wizards.common.NoValidPathException e)
- {
- // if there are problems, don't show anything is a little bit hard.
- aStylePaths.add("default");
- }
- return aStylePaths;
+ StylesPath = FileAccess.getOfficePath(xMSF, "Config", "", "");
+ StylesPath = FileAccess.combinePaths(xMSF, StylesPath, "/wizard/form/styles");
+ }
+ catch (NoValidPathException e)
+ {
+ }
+ return StylesPath;
}
- private String getStylePath()
- {
-// TODO: umstellen auf mehrere Pfade
- String StylesPath = PropertyNames.EMPTY_STRING;
- try
- {
- StylesPath = FileAccess.getOfficePath(xMSF, "Config", PropertyNames.EMPTY_STRING, PropertyNames.EMPTY_STRING);
- StylesPath = FileAccess.combinePaths(xMSF, StylesPath, "/wizard/form/styles");
- }
- catch (NoValidPathException e)
- {
- }
- return StylesPath;
- }
-
private int[] getStyleColors(String _filename)
{
String sFilePath = getStylePath() + "/" + _filename;
@@ -404,8 +352,6 @@ public class StyleApplier
oStylePropList[SOBACKGROUNDCOLOR] = getStyleColor(sData, ".toctitle {", "background-color:");
oStylePropList[SODBTEXTCOLOR] = getStyleColor(sData, ".doctitle {", "color:");
oStylePropList[SOLABELTEXTCOLOR] = getStyleColor(sData, ".toctitle {", "color:");
-// oStylePropList[SODBCONTROLBACKGROUNDCOLOR] = getStyleColor(sData, "body {", "background-color:");
-// oStylePropList[SOLABELBACKGROUNDCOLOR] = getStyleColor(sData, ".toctitle {", "background-color:");
oStylePropList[SOBORDERCOLOR] = getStyleColor(sData, ".tcolor {", "border-color:");
return oStylePropList;
}
@@ -479,8 +425,6 @@ public class StyleApplier
if (_iStyleColors[SOLABELTEXTCOLOR] > -1)
{
LabelControls[n].xPropertySet.setPropertyValue("TextColor", new Integer(_iStyleColors[SOLABELTEXTCOLOR]));
-// if (_iStyleColors[SOCONTROLBACKGROUNDCOLOR] > -1)
-// LabelControls[n].xPropertySet.setPropertyValue("BackgroundColor", new Integer(_iStyleColors[SOCONTROLBACKGROUNDCOLOR]));
}
}
}
diff --git a/wizards/com/sun/star/wizards/query/CallQueryWizard.java b/wizards/com/sun/star/wizards/query/CallQueryWizard.java
index 1289fb277e72..a314e680ee03 100644
--- a/wizards/com/sun/star/wizards/query/CallQueryWizard.java
+++ b/wizards/com/sun/star/wizards/query/CallQueryWizard.java
@@ -89,7 +89,7 @@ public class CallQueryWizard
if (sEvent.compareTo(PropertyNames.START) == 0)
{
QueryWizard CurQueryWizard = new QueryWizard( m_serviceFactory, m_wizardContext );
- Command = CurQueryWizard.startQueryWizard();
+ Command = CurQueryWizard.start();
}
}
catch (Exception exception)
diff --git a/wizards/com/sun/star/wizards/query/QueryWizard.java b/wizards/com/sun/star/wizards/query/QueryWizard.java
index 0e8c4b3ec30e..9ea57d369432 100644
--- a/wizards/com/sun/star/wizards/query/QueryWizard.java
+++ b/wizards/com/sun/star/wizards/query/QueryWizard.java
@@ -36,10 +36,8 @@ import com.sun.star.sdbc.SQLException;
import com.sun.star.uno.AnyConverter;
import com.sun.star.wizards.ui.UIConsts;
import com.sun.star.uno.UnoRuntime;
-import com.sun.star.wizards.common.Desktop;
import com.sun.star.wizards.common.Helper;
import com.sun.star.wizards.common.JavaTools;
-import com.sun.star.wizards.common.Properties;
import com.sun.star.wizards.common.PropertyNames;
import com.sun.star.wizards.common.Resource;
import com.sun.star.wizards.db.DatabaseObjectWizard;
@@ -90,90 +88,7 @@ public class QueryWizard extends DatabaseObjectWizard
public static void main(String i_args[])
{
- final String settings[] = new String[]
- {
- null, null, null
- };
- final int IDX_PIPE_NAME = 0;
- final int IDX_LOCATION = 1;
- final int IDX_DSN = 2;
-
- // some simple parsing
- boolean failure = false;
- int settingsIndex = -1;
- for (int i = 0; i < i_args.length; ++i)
- {
- if (settingsIndex >= 0)
- {
- settings[ settingsIndex] = i_args[i];
- settingsIndex = -1;
- continue;
- }
-
- if (i_args[i].equals("--pipe-name"))
- {
- settingsIndex = IDX_PIPE_NAME;
- continue;
- }
-
- if (i_args[i].equals("--database-location"))
- {
- settingsIndex = IDX_LOCATION;
- continue;
- }
-
- if (i_args[i].equals("--data-source-name"))
- {
- settingsIndex = IDX_DSN;
- continue;
- }
-
- failure = true;
- }
-
- if (settings[ IDX_PIPE_NAME] == null)
- {
- failure = true;
- }
-
- if ((settings[ IDX_DSN] == null) && (settings[ IDX_LOCATION] == null))
- {
- failure = true;
- }
-
- if (failure)
- {
- System.err.println("supported arguments: ");
- System.err.println(" --pipe-name <name> : specifies the name of the pipe to connect to the running OOo instance");
- System.err.println(" --database-location <url> : specifies the URL of the database document to work with");
- System.err.println(" --data-source-name <name> : specifies the name of the data source to work with");
- return;
- }
-
- final String ConnectStr = "uno:pipe,name=" + settings[IDX_PIPE_NAME] + ";urp;StarOffice.ServiceManager";
- try
- {
- final XMultiServiceFactory serviceFactory = Desktop.connect(ConnectStr);
- if (serviceFactory != null)
- {
- PropertyValue[] curproperties = new PropertyValue[1];
- if (settings[ IDX_LOCATION] != null)
- {
- curproperties[0] = Properties.createProperty("DatabaseLocation", settings[ IDX_LOCATION]);
- }
- else
- {
- curproperties[0] = Properties.createProperty("DataSourceName", settings[ IDX_DSN]);
- }
-
- QueryWizard CurQueryWizard = new QueryWizard(serviceFactory, curproperties);
- CurQueryWizard.startQueryWizard();
- }
- }
- catch (java.lang.Exception jexception)
- {
- jexception.printStackTrace(System.err);
- }
+ executeWizardFromCommandLine( i_args, QueryWizard.class.getName() );
}
public final XFrame getFrame()
@@ -181,7 +96,7 @@ public class QueryWizard extends DatabaseObjectWizard
return m_frame;
}
- public String startQueryWizard()
+ public String start()
{
try
{
@@ -463,7 +378,7 @@ public class QueryWizard extends DatabaseObjectWizard
}
catch (SQLException e)
{
- e.printStackTrace();
+ e.printStackTrace( System.err );
}
}
}