diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-03-21 12:27:08 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-03-21 12:27:08 +0100 |
commit | 929b785d40c7f7aef334c61476b6d74eaeca79d5 (patch) | |
tree | 569bd45568daf4782cbd2002a17d22198e0f99f7 /wizards/com | |
parent | e8a6c5a27713a2bbc378ca999beb272e7cdd63ef (diff) |
fs34b: #i117472# fix color calculation from style string
Diffstat (limited to 'wizards/com')
7 files changed, 114 insertions, 157 deletions
diff --git a/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java b/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java index e03323c6ebbc..cd9b0771fc4e 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.out); + } + } } diff --git a/wizards/com/sun/star/wizards/form/CallFormWizard.java b/wizards/com/sun/star/wizards/form/CallFormWizard.java index 0538eb5fa1b3..69ae5d0e69ea 100644 --- a/wizards/com/sun/star/wizards/form/CallFormWizard.java +++ b/wizards/com/sun/star/wizards/form/CallFormWizard.java @@ -84,7 +84,7 @@ public class CallFormWizard if (sEvent.compareTo("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 0070fed3ada1..feff3a2ace33 100644 --- a/wizards/com/sun/star/wizards/form/FormDocument.java +++ b/wizards/com/sun/star/wizards/form/FormDocument.java @@ -391,7 +391,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) @@ -415,14 +415,14 @@ public class FormDocument extends TextDocument if (curArrangement == FormWizard.SOGRID) { 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 f75f3e1b84ab..adef74d631cf 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) { @@ -332,7 +336,7 @@ public class FormWizard extends DatabaseObjectWizard setCurrentRoadmapItemID((short) 1); } - public void startFormWizard() + public void start() { try { @@ -456,14 +460,14 @@ public class FormWizard extends DatabaseObjectWizard private void toggleMainFormSteps() { curDBCommandFieldSelection.setModified(true); - boolean benable = curDBCommandFieldSelection.getSelectedFieldNames().length > 0; - enablefromStep(SOSUBFORM_PAGE, benable); - setControlProperty("btnWizardNext", PropertyNames.PROPERTY_ENABLED, new Boolean(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 { @@ -471,7 +475,7 @@ public class FormWizard extends DatabaseObjectWizard setStepEnabled(SOFIELDLINKER_PAGE, false); } } - setControlProperty("btnWizardFinish", PropertyNames.PROPERTY_ENABLED, new Boolean(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 5098a1ffbb74..5a6f42e2c213 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, new Integer(196), new Integer(53), new Short((short) 1), IStyleStep, new Short(curtabindex++), "1", new Integer(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), "SelectedItems", 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 = ""; - int iStyleColor; while (((sPropName.indexOf("}") < 0) && (index < _sDataList.length - 1))) { String scurline = _sDataList[index++]; @@ -343,7 +317,7 @@ public class StyleApplier String[] sPropList = JavaTools.ArrayoutofString(scurline, ":"); String sPropValue = sPropList[1]; sPropValue = sPropValue.trim(); - if (sPropValue.indexOf("#") > 0) + if (sPropValue.indexOf("#") > -1) { sPropValue = JavaTools.replaceSubString(sPropValue, "", ";"); sPropValue = JavaTools.replaceSubString(sPropValue, "", " "); @@ -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", "", ""); - FileAccess.combinePaths(getMSF(), aStylePaths, "/wizard/form/styles"); - - String[][] LayoutFiles = FileAccess.getFolderTitles(getMSF(), null, aStylePaths, ".css"); - + StylesPath = FileAccess.getOfficePath(xMSF, "Config", "", ""); + StylesPath = FileAccess.combinePaths(xMSF, StylesPath, "/wizard/form/styles"); } - catch (com.sun.star.wizards.common.NoValidPathException e) + catch (NoValidPathException e) { - // if there are problems, don't show anything is a little bit hard. - aStylePaths.add("default"); } - return aStylePaths; + return StylesPath; } - private String getStylePath() - { -// TODO: umstellen auf mehrere Pfade - String StylesPath = ""; - try - { - StylesPath = FileAccess.getOfficePath(xMSF, "Config", "", ""); - 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 fe18fd13f6d0..c6f24058e759 100644 --- a/wizards/com/sun/star/wizards/query/CallQueryWizard.java +++ b/wizards/com/sun/star/wizards/query/CallQueryWizard.java @@ -93,7 +93,7 @@ public class CallQueryWizard if (sEvent.compareTo("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 bca4e1a6fa5f..b9d13fa5898d 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,79 +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.out); - } + executeWizardFromCommandLine( i_args, QueryWizard.class.getName() ); } public final XFrame getFrame() @@ -170,7 +96,7 @@ public class QueryWizard extends DatabaseObjectWizard return m_frame; } - public String startQueryWizard() + public String start() { try { @@ -453,7 +379,7 @@ public class QueryWizard extends DatabaseObjectWizard } catch (SQLException e) { - e.printStackTrace(); + e.printStackTrace( System.err ); } } } |