From a79d43dcd7989ee927de1b8c69ebc2981cc7166e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 17 Apr 2013 13:51:15 +0200 Subject: Java cleanup in mediawiki extension - remove unnecessary casts - convert Hashtable->Map and Vector->ArrayList - remove dead fields Change-Id: Id85abee74857325a113133bf61474b962256489c Reviewed-on: https://gerrit.libreoffice.org/3430 Reviewed-by: Fridrich Strba Tested-by: Fridrich Strba --- .../src/com/sun/star/wiki/EditPageParser.java | 2 - swext/mediawiki/src/com/sun/star/wiki/Helper.java | 62 ++++++++---------- .../sun/star/wiki/MainThreadDialogExecutor.java | 2 +- .../mediawiki/src/com/sun/star/wiki/Settings.java | 75 +++++++++++----------- .../src/com/sun/star/wiki/WikiArticle.java | 36 ++++++----- .../src/com/sun/star/wiki/WikiDialog.java | 45 +++++++------ .../com/sun/star/wiki/WikiEditSettingDialog.java | 35 +++++----- .../src/com/sun/star/wiki/WikiEditorImpl.java | 72 ++++++++------------- .../sun/star/wiki/WikiOptionsEventHandlerImpl.java | 18 ++---- .../src/com/sun/star/wiki/WikiPropDialog.java | 11 ++-- 10 files changed, 167 insertions(+), 191 deletions(-) (limited to 'swext') diff --git a/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java b/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java index 39677101dc6c..7500be6e9b7f 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java +++ b/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java @@ -29,7 +29,6 @@ public class EditPageParser extends HTMLEditorKit.ParserCallback protected String m_sLoginToken = ""; protected String m_sMainURL = ""; - private int m_nWikiArticleHash = 0; private boolean m_bHTMLStartFound = false; private boolean m_bInHead = false; @@ -138,7 +137,6 @@ public class EditPageParser extends HTMLEditorKit.ParserCallback { if ( sName.equalsIgnoreCase( "wpTextbox1" ) ) { - m_nWikiArticleHash = t.hashCode(); m_nWikiArticleStart = pos; } } diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java index 9601579aa798..345be2c785ab 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/Helper.java +++ b/swext/mediawiki/src/com/sun/star/wiki/Helper.java @@ -55,8 +55,6 @@ import com.sun.star.uno.XComponentContext; import com.sun.star.util.XChangesBatch; import java.net.*; import java.io.*; -import java.util.Hashtable; -import java.util.Random; import javax.net.ssl.SSLException; import javax.swing.text.html.HTMLEditorKit; @@ -149,11 +147,9 @@ public class Helper private static final String sHTMLHeader = ""; private static final String sHTMLFooter = ""; - private static Random m_aRandom; private static MultiThreadedHttpConnectionManager m_aConnectionManager; private static HttpClient m_aClient; private static boolean m_bAllowConnection = true; - private static Hashtable m_aAcceptedUnknownCerts; private static Boolean m_bShowInBrowser = null; @@ -245,7 +241,7 @@ public class Helper XPropertySet xProps = Helper.GetConfigProps( xContext, "org.openoffice.Office.Custom.WikiExtension/Settings" ); xProps.setPropertyValue( "PreselectShowBrowser", new Boolean( bValue ) ); - XChangesBatch xBatch = ( XChangesBatch ) UnoRuntime.queryInterface( XChangesBatch.class, xProps ); + XChangesBatch xBatch = UnoRuntime.queryInterface( XChangesBatch.class, xProps ); if ( xBatch != null ) xBatch.commitChanges(); } @@ -262,7 +258,7 @@ public class Helper { XMultiComponentFactory xFactory = xContext.getServiceManager(); if ( xFactory != null ) - m_xPasswordContainer = (XPasswordContainer)UnoRuntime.queryInterface( + m_xPasswordContainer = UnoRuntime.queryInterface( XPasswordContainer.class, xFactory.createInstanceWithContext( "com.sun.star.task.PasswordContainer", xContext ) ); } @@ -280,7 +276,7 @@ public class Helper { XMultiComponentFactory xFactory = xContext.getServiceManager(); if ( xFactory != null ) - m_xInteractionHandler = ( XInteractionHandler )UnoRuntime.queryInterface( + m_xInteractionHandler = UnoRuntime.queryInterface( XInteractionHandler.class, xFactory.createInstanceWithContext( "com.sun.star.task.InteractionHandler", xContext ) ); } @@ -384,8 +380,8 @@ public class Helper try { Object oTempFile = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.io.TempFile", xContext ); - XStream xStream = ( XStream ) UnoRuntime.queryInterface( XStream.class, oTempFile ); - XSeekable xSeekable = ( XSeekable ) UnoRuntime.queryInterface( XSeekable.class, oTempFile ); + XStream xStream = UnoRuntime.queryInterface( XStream.class, oTempFile ); + XSeekable xSeekable = UnoRuntime.queryInterface( XSeekable.class, oTempFile ); if ( xStream != null && xSeekable != null ) { XOutputStream xOutputStream = xStream.getOutputStream(); @@ -418,13 +414,13 @@ public class Helper try { Object oTempFile = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.io.TempFile", xContext ); - XPropertySet xPropertySet = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, oTempFile ); + XPropertySet xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oTempFile ); xPropertySet.setPropertyValue( "RemoveFile", Boolean.FALSE ); sURL = ( String ) xPropertySet.getPropertyValue( "Uri" ); - XInputStream xInputStream = ( XInputStream ) UnoRuntime.queryInterface( XInputStream.class, oTempFile ); + XInputStream xInputStream = UnoRuntime.queryInterface( XInputStream.class, oTempFile ); xInputStream.closeInput(); - XOutputStream xOutputStream = ( XOutputStream ) UnoRuntime.queryInterface( XOutputStream.class, oTempFile ); + XOutputStream xOutputStream = UnoRuntime.queryInterface( XOutputStream.class, oTempFile ); xOutputStream.closeOutput(); } catch ( com.sun.star.uno.Exception ex ) { @@ -454,6 +450,8 @@ public class Helper sEachLine = aBufReader.readLine(); } sText = aBuf.toString(); + + aBufReader.close(); } catch ( Exception e ) { e.printStackTrace(); @@ -489,7 +487,7 @@ public class Helper throw new com.sun.star.uno.RuntimeException(); Object oModuleManager = xFactory.createInstanceWithContext( "com.sun.star.frame.ModuleManager", xContext ); - XModuleManager xModuleManager = ( XModuleManager ) UnoRuntime.queryInterface( XModuleManager.class, oModuleManager ); + XModuleManager xModuleManager = UnoRuntime.queryInterface( XModuleManager.class, oModuleManager ); if ( xModuleManager != null ) aDocServiceName = xModuleManager.identify( xModel ); } @@ -511,7 +509,7 @@ public class Helper try { Object oFilterFactory = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.document.FilterFactory", xContext ); - XContainerQuery xQuery = ( XContainerQuery )UnoRuntime.queryInterface( XContainerQuery.class, oFilterFactory ); + XContainerQuery xQuery = UnoRuntime.queryInterface( XContainerQuery.class, oFilterFactory ); if ( xQuery != null ) { NamedValue[] aRequest = new NamedValue[2]; @@ -562,7 +560,7 @@ public class Helper { XMultiComponentFactory xFactory = xContext.getServiceManager(); Object oConfigProvider = xFactory.createInstanceWithContext( "com.sun.star.configuration.ConfigurationProvider", xContext ); - xConfigurationProvider = ( XMultiServiceFactory ) UnoRuntime.queryInterface( XMultiServiceFactory.class, oConfigProvider ); + xConfigurationProvider = UnoRuntime.queryInterface( XMultiServiceFactory.class, oConfigProvider ); } if ( xConfigurationProvider == null ) @@ -592,7 +590,7 @@ public class Helper protected static XPropertySet GetConfigProps( XComponentContext xContext, String sNodepath ) throws com.sun.star.uno.Exception { - XPropertySet xProps = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, GetConfig( xContext, sNodepath, true ) ); + XPropertySet xProps = UnoRuntime.queryInterface( XPropertySet.class, GetConfig( xContext, sNodepath, true ) ); if ( xProps == null ) throw new com.sun.star.uno.RuntimeException(); @@ -603,7 +601,7 @@ public class Helper protected static XNameContainer GetConfigNameContainer( XComponentContext xContext, String sNodepath ) throws com.sun.star.uno.Exception { - XNameContainer xContainer = ( XNameContainer ) UnoRuntime.queryInterface( XNameContainer.class, GetConfig( xContext, sNodepath, true ) ); + XNameContainer xContainer = UnoRuntime.queryInterface( XNameContainer.class, GetConfig( xContext, sNodepath, true ) ); if ( xContainer == null ) throw new com.sun.star.uno.RuntimeException(); @@ -613,7 +611,7 @@ public class Helper protected static XNameAccess GetConfigNameAccess( XComponentContext xContext, String sNodepath ) throws com.sun.star.uno.Exception { - XNameAccess xNameAccess = ( XNameAccess ) UnoRuntime.queryInterface( XNameAccess.class, GetConfig( xContext, sNodepath, false ) ); + XNameAccess xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, GetConfig( xContext, sNodepath, false ) ); if ( xNameAccess == null ) throw new com.sun.star.uno.RuntimeException(); @@ -679,7 +677,7 @@ public class Helper try { Object oSystemShell = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.system.SystemShellExecute", xContext ); - XSystemShellExecute xSystemShell = (XSystemShellExecute)UnoRuntime.queryInterface( XSystemShellExecute.class, oSystemShell ); + XSystemShellExecute xSystemShell = UnoRuntime.queryInterface( XSystemShellExecute.class, oSystemShell ); if ( xSystemShell != null ) xSystemShell.execute( sURL, "", SystemShellExecuteFlags.URIS_ONLY ); } @@ -701,7 +699,6 @@ public class Helper SetConfigurationProxy( aHostConfig, xContext ); } - boolean bNoUnknownCertNotification = false; if ( aHostConfig.getProtocol().getScheme().equals( "https" ) && AllowUnknownCert( xContext, aURI.getHost() ) ) { @@ -855,12 +852,12 @@ public class Helper private static XControl GetControlFromDialog( XDialog xDialog, String aControlName ) { XControl xResult = null; - XControlContainer xControlCont = (XControlContainer) UnoRuntime.queryInterface( XControlContainer.class, xDialog ); + XControlContainer xControlCont = UnoRuntime.queryInterface( XControlContainer.class, xDialog ); if ( xControlCont != null ) { Object oControl = xControlCont.getControl( aControlName ); - xResult = ( XControl ) UnoRuntime.queryInterface( XControl.class, oControl ); + xResult = UnoRuntime.queryInterface( XControl.class, oControl ); } return xResult; @@ -870,7 +867,7 @@ public class Helper { XControl xControl = GetControlFromDialog( xDialog, aControlName ); if ( xControl != null ) - return ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, xControl.getModel() ); + return UnoRuntime.queryInterface( XPropertySet.class, xControl.getModel() ); return null; } @@ -919,7 +916,7 @@ public class Helper boolean bResult = false; try { - XMasterPasswordHandling xMasterHdl = (XMasterPasswordHandling)UnoRuntime.queryInterface( XMasterPasswordHandling.class, GetPasswordContainer( xContext ) ); + XMasterPasswordHandling xMasterHdl = UnoRuntime.queryInterface( XMasterPasswordHandling.class, GetPasswordContainer( xContext ) ); if ( xMasterHdl != null ) bResult = xMasterHdl.isPersistentStoringAllowed(); } @@ -934,7 +931,7 @@ public class Helper protected static void ShowError( XComponentContext xContext, XDialog xDialog, int nTitleID, int nErrorID, String sArg, boolean bQuery ) { XWindowPeer xPeer = null; - XControl xControl = (XControl)UnoRuntime.queryInterface( XControl.class, xDialog ); + XControl xControl = UnoRuntime.queryInterface( XControl.class, xDialog ); if ( xControl != null ) xPeer = xControl.getPeer(); ShowError( xContext, xPeer, nTitleID, nErrorID, sArg, bQuery ); @@ -946,8 +943,6 @@ public class Helper if ( xContext != null && nErrorID >= 0 && nErrorID < STRINGS_NUM ) { - boolean bShown = false; - String sError = null; String sTitle = ""; @@ -975,7 +970,7 @@ public class Helper { XMultiComponentFactory xFactory = xContext.getServiceManager(); if ( xFactory != null ) - xMBFactory = (XMessageBoxFactory)UnoRuntime.queryInterface( + xMBFactory = UnoRuntime.queryInterface( XMessageBoxFactory.class, xFactory.createInstanceWithContext( "com.sun.star.awt.Toolkit", xContext ) ); @@ -1004,7 +999,6 @@ public class Helper if ( xMB != null ) { bResult = MainThreadDialogExecutor.Execute( xContext, xMB ); - bShown = true; } } } @@ -1030,7 +1024,7 @@ public class Helper XNameAccess xNameAccess = GetConfigNameAccess( xContext, "org.openoffice.Office.Custom.WikiExtension/SpecialData" ); if ( xNameAccess.hasByName( aURL ) ) { - XNameAccess xEntry = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, xNameAccess.getByName( aURL ) ); + XNameAccess xEntry = UnoRuntime.queryInterface( XNameAccess.class, xNameAccess.getByName( aURL ) ); if ( xEntry != null && xEntry.hasByName( "AllowUnknownCertificate" ) ) return AnyConverter.toBoolean( xEntry.getByName( "AllowUnknownCertificate" ) ); } @@ -1050,10 +1044,10 @@ public class Helper XNameAccess xNameAccess = GetConfigNameAccess( xContext, "org.openoffice.Office.Custom.WikiExtension/SpecialData" ); if ( xNameAccess.hasByName( aURL ) ) { - XNameAccess xEntry = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, xNameAccess.getByName( aURL ) ); + XNameAccess xEntry = UnoRuntime.queryInterface( XNameAccess.class, xNameAccess.getByName( aURL ) ); if ( xEntry != null ) { - XNameAccess xArgs = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, xEntry.getByName( "AdditionalLoginArguments" ) ); + XNameAccess xArgs = UnoRuntime.queryInterface( XNameAccess.class, xEntry.getByName( "AdditionalLoginArguments" ) ); if ( xArgs != null ) { String[] pNames = xArgs.getElementNames(); @@ -1062,7 +1056,7 @@ public class Helper String[][] pResult = new String[pNames.length][2]; for ( int nInd = 0; nInd < pNames.length; nInd++ ) { - XNameAccess xArgument = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, xArgs.getByName( pNames[nInd] ) ); + XNameAccess xArgument = UnoRuntime.queryInterface( XNameAccess.class, xArgs.getByName( pNames[nInd] ) ); if ( xArgument == null ) throw new com.sun.star.uno.RuntimeException(); @@ -1112,7 +1106,7 @@ public class Helper { try { - XComponent xComp = (XComponent)UnoRuntime.queryInterface( XComponent.class, oObject ); + XComponent xComp = UnoRuntime.queryInterface( XComponent.class, oObject ); if ( xComp != null ) xComp.dispose(); } diff --git a/swext/mediawiki/src/com/sun/star/wiki/MainThreadDialogExecutor.java b/swext/mediawiki/src/com/sun/star/wiki/MainThreadDialogExecutor.java index 643b238e1b15..b0dfb38f51ee 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/MainThreadDialogExecutor.java +++ b/swext/mediawiki/src/com/sun/star/wiki/MainThreadDialogExecutor.java @@ -78,7 +78,7 @@ public class MainThreadDialogExecutor implements XCallback if ( xFactory == null ) throw new com.sun.star.uno.RuntimeException(); - XRequestCallback xRequest = (XRequestCallback)UnoRuntime.queryInterface( + XRequestCallback xRequest = UnoRuntime.queryInterface( XRequestCallback.class, xFactory.createInstanceWithContext( "com.sun.star.awt.AsyncCallback", xContext ) ); if ( xRequest != null ) diff --git a/swext/mediawiki/src/com/sun/star/wiki/Settings.java b/swext/mediawiki/src/com/sun/star/wiki/Settings.java index 87cc378b88ad..f18ff8f7ed48 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/Settings.java +++ b/swext/mediawiki/src/com/sun/star/wiki/Settings.java @@ -18,6 +18,12 @@ package com.sun.star.wiki; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import com.sun.star.beans.XPropertySet; import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; @@ -27,23 +33,18 @@ import com.sun.star.uno.AnyConverter; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.util.XChangesBatch; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; public class Settings { - private XComponentContext m_xContext; - private int lastUsedWikiServer = 0; - - - /* Singelton */ + /* Singleton */ private static Settings m_instance; - private Vector> m_WikiConnections = new Vector>(); - private Vector> m_aWikiDocs = new Vector>(); + private XComponentContext m_xContext; + private int lastUsedWikiServer = 0; + private List> m_WikiConnections = new ArrayList>(); + private List> m_aWikiDocs = new ArrayList>(); private Settings( XComponentContext ctx ) { @@ -61,13 +62,13 @@ public class Settings } - public void addWikiCon ( Hashtable wikiCon ) + public void addWikiCon ( Map wikiCon ) { m_WikiConnections.add( wikiCon ); } - public Vector> getWikiCons() + public List> getWikiCons() { return m_WikiConnections; } @@ -77,17 +78,17 @@ public class Settings String url = ""; if ( num >=0 && num < m_WikiConnections.size() ) { - Hashtable ht = m_WikiConnections.get( num ); - url = ( String ) ht.get( "Url" ); + Map ht = m_WikiConnections.get( num ); + url = ht.get( "Url" ); } return url; } - public void addWikiDoc ( Hashtable aWikiDoc ) + public void addWikiDoc ( Map aWikiDoc ) { String sURL = ( String ) aWikiDoc.get( "CompleteUrl" ); - Hashtable aEntry = getDocByCompleteUrl( sURL ); + Map aEntry = getDocByCompleteUrl( sURL ); if ( aEntry != null ) { @@ -104,7 +105,7 @@ public class Settings } - public Vector> getWikiDocs() + public List> getWikiDocs() { return m_aWikiDocs; } @@ -112,11 +113,11 @@ public class Settings public Object[] getWikiDocList( int serverid, int num ) { String wikiserverurl = getWikiConUrlByNumber( serverid ); - Vector theDocs = new Vector(); + List theDocs = new ArrayList(); String [] docs = new String[0]; for ( int i=0; i ht = m_aWikiDocs.get( i ); String docurl = ( String ) ht.get( "Url" ); if ( docurl.equals( wikiserverurl ) ) { @@ -141,19 +142,19 @@ public class Settings String [] WikiList = new String [m_WikiConnections.size()]; for ( int i=0; i ht = m_WikiConnections.get( i ); + WikiList[i] = ht.get( "Url" ); } return WikiList; } - public Hashtable getSettingByUrl( String sUrl ) + public Map getSettingByUrl( String sUrl ) { - Hashtable ht = null; + Map ht = null; for( int i=0;i h1 = m_WikiConnections.get( i ); + Map h1 = m_WikiConnections.get( i ); String u1 = h1.get( "Url" ); if ( u1.equals( sUrl ) ) { @@ -180,12 +181,12 @@ public class Settings return ht; } - public Hashtable getDocByCompleteUrl( String curl ) + public Map getDocByCompleteUrl( String curl ) { - Hashtable ht = null; + Map ht = null; for( int i=0;i h1 = m_aWikiDocs.get( i ); String u1 = ( String ) h1.get( "CompleteUrl" ); if ( u1.equals( curl ) ) { @@ -198,11 +199,10 @@ public class Settings public void removeSettingByUrl( String sUrl ) { - Hashtable ht = null; for( int i=0;i h1 = m_WikiConnections.get( i ); + String u1 = h1.get( "Url" ); if ( u1.equals( sUrl ) ) { m_WikiConnections.remove( i ); @@ -228,13 +228,13 @@ public class Settings for ( int i=0; i< m_WikiConnections.size(); i++ ) { Object oNewConnection = xConnectionFactory.createInstance(); - Hashtable ht = m_WikiConnections.get( i ); + Map ht = m_WikiConnections.get( i ); XNameReplace xNewConn = UnoRuntime.queryInterface( XNameReplace.class, oNewConnection ); if ( xNewConn != null ) xNewConn.replaceByName( "UserName", ht.get( "Username" ) ); - xContainer.insertByName( (String)ht.get( "Url" ), xNewConn ); + xContainer.insertByName( ht.get( "Url" ), xNewConn ); } // commit changes XChangesBatch xBatch = UnoRuntime.queryInterface( XChangesBatch.class, xContainer ); @@ -251,15 +251,14 @@ public class Settings XSingleServiceFactory xDocListFactory = UnoRuntime.queryInterface( XSingleServiceFactory.class, xContainer2 ); for ( int i=0; i< m_aWikiDocs.size(); i++ ) { - Hashtable ht = m_aWikiDocs.get( i ); + Map ht = m_aWikiDocs.get( i ); Object oNewDoc = xDocListFactory.createInstance(); XNameReplace xNewDoc = UnoRuntime.queryInterface( XNameReplace.class, oNewDoc ); - Enumeration e = ht.keys(); - while ( e.hasMoreElements() ) + for ( Iterator iter = ht.keySet().iterator(); iter.hasNext(); ) { - String key = ( String ) e.nextElement(); + String key = iter.next(); xNewDoc.replaceByName( key, ht.get( key ) ); } @@ -292,7 +291,7 @@ public class Settings String [] allCons = xConnectionList.getElementNames(); for ( int i=0; i ht = new Hashtable(); + Map ht = new HashMap(); ht.put( "Url", allCons[i] ); ht.put( "Username", "" ); ht.put( "Password", "" ); @@ -322,7 +321,7 @@ public class Settings { Object oDoc = xRecentDocs.getByName( allDocs[i] ); XNameAccess xDoc = UnoRuntime.queryInterface( XNameAccess.class, oDoc ); - Hashtable ht = new Hashtable(); + Map ht = new HashMap(); ht.put( "Url", xDoc.getByName( "Url" ) ); ht.put( "CompleteUrl", xDoc.getByName( "CompleteUrl" ) ); ht.put( "Doc", xDoc.getByName( "Doc" ) ); diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java index 7cdafebd5abc..1495404cf92b 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java @@ -18,13 +18,17 @@ package com.sun.star.wiki; -import java.io.*; -import java.util.Hashtable; -import javax.swing.text.html.*; -import com.sun.star.uno.XComponentContext; +import java.io.StringReader; +import java.util.Map; + +import javax.swing.text.html.HTMLEditorKit; -import org.apache.commons.httpclient.*; -import org.apache.commons.httpclient.methods.*; +import org.apache.commons.httpclient.HostConfiguration; +import org.apache.commons.httpclient.URI; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.methods.PostMethod; + +import com.sun.star.uno.XComponentContext; public class WikiArticle @@ -34,27 +38,27 @@ public class WikiArticle private String m_sEditTime = ""; private String m_sEditToken = ""; - protected String m_sHTMLCode; + private String m_sHTMLCode; private boolean m_bNoArticle = true; - protected String m_sWikiUser; - protected String m_sWikiPass; + private String m_sWikiUser; + private String m_sWikiPass; - protected String m_sTitle = ""; + private String m_sTitle = ""; private URI m_aMainURI; private HostConfiguration m_aHostConfig; /** Creates a new instance of WikiArticle */ - public WikiArticle( XComponentContext xContext, String sTitle, Hashtable wikiSettings, boolean bLogin, WikiPropDialog aPropDialog ) + public WikiArticle( XComponentContext xContext, String sTitle, Map wikiSettings, boolean bLogin, WikiPropDialog aPropDialog ) throws java.net.MalformedURLException, com.sun.star.uno.Exception, java.io.IOException, WikiCancelException { m_xContext = xContext; - String sMainUrl = (String) wikiSettings.get("Url"); - m_sWikiUser = (String) wikiSettings.get("Username"); - m_sWikiPass = (String) wikiSettings.get("Password"); + String sMainUrl = wikiSettings.get("Url"); + m_sWikiUser = wikiSettings.get("Username"); + m_sWikiPass = wikiSettings.get("Password"); m_sTitle = sTitle; m_aMainURI = new URI( sMainUrl ); @@ -77,8 +81,8 @@ public class WikiArticle if ( MainThreadDialogExecutor.Show( xContext, aDialog ) ) { - m_sWikiUser = (String) wikiSettings.get("Username"); - m_sWikiPass = (String) wikiSettings.get("Password"); + m_sWikiUser = wikiSettings.get("Username"); + m_sWikiPass = wikiSettings.get("Password"); } else throw new WikiCancelException(); diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java b/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java index e65c4fbcd1c9..5a1dc4ff447f 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiDialog.java @@ -38,13 +38,12 @@ import com.sun.star.lang.XMultiServiceFactory; public class WikiDialog implements XDialogEventHandler, XTopWindowListener { - XComponentContext m_xContext; - XControlContainer m_xControlContainer; - XDialog m_xDialog; - String[] m_aMethods; - boolean m_bAction = false; - Settings m_aSettings; - + protected XComponentContext m_xContext; + private XControlContainer m_xControlContainer; + protected XDialog m_xDialog; + private String[] m_aMethods; + protected boolean m_bAction = false; + protected Settings m_aSettings; protected Thread m_aThread; protected boolean m_bThreadFinished = false; @@ -59,11 +58,11 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener { Object obj; obj = xMCF.createInstanceWithContext("com.sun.star.awt.DialogProvider2", m_xContext ); - XDialogProvider2 xDialogProvider = (XDialogProvider2) UnoRuntime.queryInterface( XDialogProvider2.class, obj ); + XDialogProvider2 xDialogProvider = UnoRuntime.queryInterface( XDialogProvider2.class, obj ); m_xDialog = xDialogProvider.createDialogWithHandler( DialogURL, this ); - m_xControlContainer = (XControlContainer)UnoRuntime.queryInterface( XControlContainer.class, m_xDialog ); - XTopWindow xTopWindow = (XTopWindow)UnoRuntime.queryInterface( XTopWindow.class, m_xDialog ); + m_xControlContainer = UnoRuntime.queryInterface( XControlContainer.class, m_xDialog ); + XTopWindow xTopWindow = UnoRuntime.queryInterface( XTopWindow.class, m_xDialog ); if ( xTopWindow != null ) xTopWindow.addTopWindowListener( this ); } @@ -128,10 +127,10 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener { if ( xDialog != null && sTitle != null ) { - XControl xDialogControl = (XControl)UnoRuntime.queryInterface( XControl.class, xDialog ); + XControl xDialogControl = UnoRuntime.queryInterface( XControl.class, xDialog ); if ( xDialogControl != null ) { - XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xDialogControl.getModel() ); + XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xDialogControl.getModel() ); if ( xPropSet != null ) xPropSet.setPropertyValue( "Title", sTitle ); } @@ -150,7 +149,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener if ( xControlContainer != null && sControl != null ) { XControl xControl = xControlContainer.getControl(sControl); - xPS = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel() ); + xPS = UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel() ); } if ( xPS == null ) @@ -168,7 +167,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener try { Object oDialogProvider = xContext.getServiceManager().createInstanceWithContext("com.sun.star.awt.DialogProvider2", xContext ); - XDialogProvider2 xDialogProvider = (XDialogProvider2) UnoRuntime.queryInterface( XDialogProvider2.class, oDialogProvider ); + XDialogProvider2 xDialogProvider = UnoRuntime.queryInterface( XDialogProvider2.class, oDialogProvider ); if ( xDialogProvider != null ) xResult = xDialogProvider.createDialog( sURL ); @@ -178,7 +177,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener SetTitle( xResult, Helper.GetLocalizedString( xContext, nTitleID ) ); if ( pControls != null && pStringIDs != null && pControls.length == pStringIDs.length ) { - XControlContainer xControlContainer = (XControlContainer)UnoRuntime.queryInterface( XControlContainer.class, xResult ); + XControlContainer xControlContainer = UnoRuntime.queryInterface( XControlContainer.class, xResult ); for ( int nInd = 0; nInd < pControls.length; nInd++ ) GetPropSet( xControlContainer, pControls[nInd] ).setPropertyValue( "Label", new Integer( pStringIDs[nInd] ) ); } @@ -197,16 +196,16 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener { try { - XControl xDialogControl = ( XControl ) UnoRuntime.queryInterface( XControl.class, m_xDialog ); + XControl xDialogControl = UnoRuntime.queryInterface( XControl.class, m_xDialog ); XControlModel xDialogModel = null; if ( xDialogControl != null ) xDialogModel = xDialogControl.getModel(); - XMultiServiceFactory xDialogFactory = ( XMultiServiceFactory ) UnoRuntime.queryInterface( XMultiServiceFactory.class, xDialogModel ); + XMultiServiceFactory xDialogFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, xDialogModel ); if ( xDialogFactory != null ) { - XControlModel xThrobberModel = (XControlModel)UnoRuntime.queryInterface( XControlModel.class, xDialogFactory.createInstance( "com.sun.star.awt.UnoThrobberControlModel" ) ); - XPropertySet xThrobberProps = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xThrobberModel ); + XControlModel xThrobberModel = UnoRuntime.queryInterface( XControlModel.class, xDialogFactory.createInstance( "com.sun.star.awt.UnoThrobberControlModel" ) ); + XPropertySet xThrobberProps = UnoRuntime.queryInterface( XPropertySet.class, xThrobberModel ); if ( xThrobberProps != null ) { xThrobberProps.setPropertyValue( "Name", "WikiThrobber" ); @@ -215,7 +214,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener xThrobberProps.setPropertyValue( "Height", new Integer( Width ) ); xThrobberProps.setPropertyValue( "Width", new Integer( Height ) ); - XNameContainer xDialogContainer = (XNameContainer)UnoRuntime.queryInterface( XNameContainer.class, xDialogModel ); + XNameContainer xDialogContainer = UnoRuntime.queryInterface( XNameContainer.class, xDialogModel ); xDialogContainer.insertByName( "WikiThrobber", xThrobberModel ); } } @@ -234,7 +233,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener { try { - XThrobber xThrobber = (XThrobber)UnoRuntime.queryInterface( XThrobber.class, m_xControlContainer.getControl( "WikiThrobber" ) ); + XThrobber xThrobber = UnoRuntime.queryInterface( XThrobber.class, m_xControlContainer.getControl( "WikiThrobber" ) ); if ( xThrobber != null ) { if ( bActive ) @@ -256,7 +255,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener { try { - XWindow xWindow = (XWindow)UnoRuntime.queryInterface( XWindow.class, m_xControlContainer.getControl( "WikiThrobber" ) ); + XWindow xWindow = UnoRuntime.queryInterface( XWindow.class, m_xControlContainer.getControl( "WikiThrobber" ) ); if ( xWindow != null ) xWindow.setVisible( bVisible ); } @@ -273,7 +272,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener { try { - XWindow xWindow = (XWindow)UnoRuntime.queryInterface( XWindow.class, m_xControlContainer.getControl( aControl ) ); + XWindow xWindow = UnoRuntime.queryInterface( XWindow.class, m_xControlContainer.getControl( aControl ) ); if ( xWindow != null ) xWindow.setFocus(); } diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java b/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java index 182400d4f948..592b7489b341 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java @@ -18,24 +18,27 @@ package com.sun.star.wiki; +import java.util.HashMap; +import java.util.Map; + +import javax.net.ssl.SSLException; + +import org.apache.commons.httpclient.HostConfiguration; +import org.apache.commons.httpclient.URI; +import org.apache.commons.httpclient.methods.GetMethod; + import com.sun.star.awt.XDialog; import com.sun.star.beans.XPropertySet; -import com.sun.star.uno.XComponentContext; import com.sun.star.lang.EventObject; -import java.util.Hashtable; -import javax.net.ssl.SSLException; - -import org.apache.commons.httpclient.*; -import org.apache.commons.httpclient.methods.*; +import com.sun.star.uno.XComponentContext; public class WikiEditSettingDialog extends WikiDialog { private final String sOKMethod = "OK"; - String[] Methods = - {sOKMethod }; - private Hashtable setting; + private String[] Methods = {sOKMethod }; + private Map setting; private boolean addMode; private boolean m_bAllowURLChange = true; @@ -43,7 +46,7 @@ public class WikiEditSettingDialog extends WikiDialog { super( xContext, DialogURL ); super.setMethods( Methods ); - setting = new Hashtable(); + setting = new HashMap(); addMode = true; InsertThrobber( 184, 20, 10, 10 ); @@ -51,7 +54,7 @@ public class WikiEditSettingDialog extends WikiDialog InitSaveCheckbox( xContext, false ); } - public WikiEditSettingDialog( XComponentContext xContext, String DialogURL, Hashtable ht, boolean bAllowURLChange ) + public WikiEditSettingDialog( XComponentContext xContext, String DialogURL, Map ht, boolean bAllowURLChange ) { super( xContext, DialogURL ); super.setMethods( Methods ); @@ -69,8 +72,8 @@ public class WikiEditSettingDialog extends WikiDialog if ( Helper.PasswordStoringIsAllowed( m_xContext ) ) { - String[] pPasswords = Helper.GetPasswordsForURLAndUser( m_xContext, (String)ht.get( "Url" ), (String)ht.get( "Username" ) ); - bInitSaveCheckBox = ( pPasswords != null && pPasswords.length > 0 && pPasswords[0].equals( (String)ht.get( "Password" ) ) ); + String[] pPasswords = Helper.GetPasswordsForURLAndUser( m_xContext, ht.get( "Url" ), ht.get( "Username" ) ); + bInitSaveCheckBox = ( pPasswords != null && pPasswords.length > 0 && pPasswords[0].equals( ht.get( "Password" ) ) ); } // the password should be entered by the user or the Cancel should be pressed @@ -100,9 +103,9 @@ public class WikiEditSettingDialog extends WikiDialog if ( bResult && Helper.PasswordStoringIsAllowed( m_xContext ) && ( (Short)( GetPropSet( "SaveBox" ).getPropertyValue("State") ) ).shortValue() != (short)0 ) { - String sURL = (String)setting.get( "Url" ); - String sUserName = (String)setting.get( "Username" ); - String sPassword = (String)setting.get( "Password" ); + String sURL = setting.get( "Url" ); + String sUserName = setting.get( "Username" ); + String sPassword = setting.get( "Password" ); if ( sURL != null && sURL.length() > 0 && sUserName != null && sUserName.length() > 0 && sPassword != null && sPassword.length() > 0 ) { diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiEditorImpl.java b/swext/mediawiki/src/com/sun/star/wiki/WikiEditorImpl.java index 0b37a657cca8..ff9f85aaa0bb 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiEditorImpl.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiEditorImpl.java @@ -18,42 +18,38 @@ package com.sun.star.wiki; +import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import javax.net.ssl.SSLException; + import com.sun.star.awt.XWindowPeer; import com.sun.star.beans.PropertyValue; import com.sun.star.frame.DispatchDescriptor; import com.sun.star.frame.XController; -import com.sun.star.frame.XDesktop; import com.sun.star.frame.XDispatch; import com.sun.star.frame.XDispatchProvider; import com.sun.star.frame.XFrame; import com.sun.star.frame.XModel; import com.sun.star.frame.XStatusListener; import com.sun.star.frame.XStorable; -import com.sun.star.lang.XComponent; import com.sun.star.lang.XInitialization; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XComponentContext; -import com.sun.star.lib.uno.helper.Factory; import com.sun.star.lang.XSingleComponentFactory; +import com.sun.star.lib.uno.helper.Factory; import com.sun.star.lib.uno.helper.WeakBase; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; import com.sun.star.util.XCloseBroadcaster; -import com.sun.star.view.XSelectionSupplier; -import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import javax.net.ssl.SSLException; public final class WikiEditorImpl extends WeakBase implements com.sun.star.lang.XServiceInfo, XDispatchProvider, XDispatch, XInitialization { - private final XComponentContext m_xContext; private static final String m_implementationName = WikiEditorImpl.class.getName(); private static final String[] m_serviceNames = {"com.sun.star.wiki.WikiEditor" }; @@ -63,16 +59,11 @@ public final class WikiEditorImpl extends WeakBase // protocol name that this protocol handler handles public static final String protocolName = "vnd.com.sun.star.wiki:"; - private Map m_statusListeners = new HashMap(); - - - private XComponent xComp; - private String sTempUrl; - + private final XComponentContext m_xContext; + private Map m_statusListeners = new HashMap(); private XFrame m_xFrame; private XModel m_xModel; private Settings m_aSettings; - private String m_aFilterName; public WikiEditorImpl( XComponentContext xContext ) @@ -119,8 +110,6 @@ public final class WikiEditorImpl extends WeakBase } - private XSelectionSupplier m_sel; - private XController m_ctrl; private boolean m_bInitialized; public synchronized void initialize( Object[] args ) throws com.sun.star.uno.Exception { @@ -131,10 +120,9 @@ public final class WikiEditorImpl extends WeakBase if ( args.length > 0 ) { m_bInitialized = true; - m_xFrame = ( XFrame )UnoRuntime.queryInterface( XFrame.class, args[0] ); + m_xFrame = UnoRuntime.queryInterface( XFrame.class, args[0] ); // become close listener - XCloseBroadcaster cb = ( XCloseBroadcaster )UnoRuntime.queryInterface( - XCloseBroadcaster.class, m_xFrame ); + XCloseBroadcaster cb = UnoRuntime.queryInterface( XCloseBroadcaster.class, m_xFrame ); } } @@ -242,13 +230,10 @@ public final class WikiEditorImpl extends WeakBase public void callStatusListeners() { - Set entries = m_statusListeners.entrySet(); - Iterator iter = entries.iterator(); - while ( iter.hasNext() ) + for (Iterator iter = m_statusListeners.keySet().iterator(); iter.hasNext(); ) { - Map.Entry entry = ( Map.Entry ) iter.next(); - String uristring = ( String ) entry.getKey(); - XStatusListener listener = ( XStatusListener ) entry.getValue(); + String uristring = iter.next(); + XStatusListener listener = m_statusListeners.get(uristring); callStatusListener( uristring, listener ); } } @@ -257,7 +242,6 @@ public final class WikiEditorImpl extends WeakBase { try { - URI uri = new URI( uristring ); // check whether any blogs are live... @@ -300,7 +284,7 @@ public final class WikiEditorImpl extends WeakBase if ( m_aFilterName == null || m_aFilterName.length() == 0 ) { Helper.ShowError( m_xContext, - (XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), + UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), Helper.DLG_SENDTITLE, Helper.NOWIKIFILTER_ERROR, null, @@ -329,7 +313,7 @@ public final class WikiEditorImpl extends WeakBase } } - public boolean SendArticleImpl( WikiPropDialog aSendDialog, Hashtable aWikiSetting ) + public boolean SendArticleImpl( WikiPropDialog aSendDialog, Map aWikiSetting ) { boolean bResult = false; @@ -349,7 +333,7 @@ public final class WikiEditorImpl extends WeakBase aSendDialog.SetThrobberActive( false ); bAllowSending = Helper.ShowError( m_xContext, - (XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), + UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), Helper.DLG_SENDTITLE, Helper.DLG_WIKIPAGEEXISTS_LABEL1, aSendDialog.GetWikiTitle(), @@ -369,7 +353,7 @@ public final class WikiEditorImpl extends WeakBase sTemp2Url = Helper.CreateTempFile( m_xContext ); - XStorable xStore = ( com.sun.star.frame.XStorable )UnoRuntime.queryInterface ( XStorable.class, m_xModel ); + XStorable xStore = UnoRuntime.queryInterface ( XStorable.class, m_xModel ); if ( xStore == null ) throw new com.sun.star.uno.RuntimeException(); @@ -379,10 +363,8 @@ public final class WikiEditorImpl extends WeakBase if ( aArticle.setArticle( sWikiCode, aSendDialog.m_sWikiComment, aSendDialog.m_bWikiMinorEdit ) ) { bResult = true; - Object desktop = m_xContext.getServiceManager().createInstanceWithContext( "com.sun.star.frame.Desktop", m_xContext ); - XDesktop xDesktop = ( XDesktop ) UnoRuntime.queryInterface( com.sun.star.frame.XDesktop.class, desktop ); Helper.SetDocTitle( m_xModel, aArticle.GetTitle() ); - Hashtable aDocInfo = new Hashtable(); + Map aDocInfo = new HashMap(); aDocInfo.put( "Doc", aArticle.GetTitle() ); aDocInfo.put( "Url", aArticle.GetMainURL() ); aDocInfo.put( "CompleteUrl", aArticle.GetMainURL() + aArticle.GetTitle() ); @@ -392,7 +374,7 @@ public final class WikiEditorImpl extends WeakBase else { Helper.ShowError( m_xContext, - (XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), + UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), Helper.DLG_SENDTITLE, Helper.GENERALSEND_ERROR, null, @@ -410,7 +392,7 @@ public final class WikiEditorImpl extends WeakBase { // report the error only if sending was not cancelled Helper.ShowError( m_xContext, - (XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), + UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), Helper.DLG_SENDTITLE, Helper.UNKNOWNCERT_ERROR, null, @@ -423,7 +405,7 @@ public final class WikiEditorImpl extends WeakBase { // report the error only if sending was not cancelled Helper.ShowError( m_xContext, - (XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), + UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), Helper.DLG_SENDTITLE, Helper.GENERALSEND_ERROR, null, diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java b/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java index 7d2bec8910e7..b16be39f65a7 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiOptionsEventHandlerImpl.java @@ -31,7 +31,7 @@ import com.sun.star.lib.uno.helper.WeakBase; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; -import java.util.Hashtable; +import java.util.Map; public final class WikiOptionsEventHandlerImpl extends WeakBase implements XServiceInfo, XContainerWindowEventHandler, XDialogEventHandler @@ -65,7 +65,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase if ( m_xControlContainer != null ) { XControl xControl = m_xControlContainer.getControl(sControl); - XPropertySet xListProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel() ); + XPropertySet xListProps = UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel() ); return xListProps; } @@ -128,7 +128,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase XPropertySet xListProps = GetPropSet( "WikiList" ); if ( xListProps != null ) { - Hashtable ht = null; + Map ht = null; try { short[] pSel = (short []) xListProps.getPropertyValue( "SelectedItems" ); @@ -136,7 +136,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase if ( pSel.length > 0 && pItems.length > pSel[0] ) { String selName = pItems[pSel[0]]; - ht = m_aSettings.getSettingByUrl( pItems[pSel[0]] ); + ht = m_aSettings.getSettingByUrl( selName ); } } catch ( Exception ex ) @@ -178,7 +178,6 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase { try { - GetPropSet( "FixedLine1" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_MEDIAWIKIEXTENSION_STRING ) ); GetPropSet( "AddButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_ADDBUTTON ) ); GetPropSet( "EditButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_EDITBUTTON ) ); @@ -221,7 +220,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase { try { - String sEvent = (String)AnyConverter.toString( aEventObject ); + String sEvent = AnyConverter.toString( aEventObject ); if ( sEvent != null ) { if ( sEvent.equals( sOk ) ) @@ -233,9 +232,8 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase { if ( sEvent.equals( sInitialize ) ) { - m_xDialog = (XDialog)UnoRuntime.queryInterface( XDialog.class, xWindow ); - m_xControlContainer = (XControlContainer)UnoRuntime.queryInterface( - XControlContainer.class, m_xDialog ); + m_xDialog = UnoRuntime.queryInterface( XDialog.class, xWindow ); + m_xControlContainer = UnoRuntime.queryInterface( XControlContainer.class, m_xDialog ); m_aSettings = Settings.getSettings( m_xContext ); m_aSettings.loadConfiguration(); // throw away all the noncommited changes InitStrings(); @@ -277,8 +275,6 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase public boolean callHandlerMethod( XDialog xDialog, Object aEventObject, String sMethod ) throws WrappedTargetException, com.sun.star.uno.RuntimeException { - - return true; } diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java b/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java index adec27e2da17..c184fcf478d5 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java @@ -18,25 +18,26 @@ package com.sun.star.wiki; +import java.util.Map; + import com.sun.star.awt.XDialog; import com.sun.star.beans.XPropertySet; import com.sun.star.lang.EventObject; import com.sun.star.uno.XComponentContext; -import java.util.Hashtable; public class WikiPropDialog extends WikiDialog{ - WikiEditorImpl m_aWikiEditor; + private WikiEditorImpl m_aWikiEditor; private final String sSendMethod = "Send"; private final String sWikiListMethod = "WikiListChange"; private final String sArticleTextMethod = "ArticleTextChange"; private final String sAddWikiMethod = "AddWiki"; - String[] m_pMethods = {sSendMethod, sWikiListMethod, sArticleTextMethod, sAddWikiMethod}; + private String[] m_pMethods = {sSendMethod, sWikiListMethod, sArticleTextMethod, sAddWikiMethod}; private String m_sWikiTitle = ""; - protected String m_sWikiEngineURL = ""; + private String m_sWikiEngineURL = ""; protected String m_sWikiComment = ""; protected boolean m_bWikiMinorEdit = false; @@ -283,7 +284,7 @@ public class WikiPropDialog extends WikiDialog{ SetThrobberActive( true ); // the following method might show a dialog, should be used in main thread - final Hashtable aWikiSettings = m_aSettings.getSettingByUrl( m_sWikiEngineURL ); + final Map aWikiSettings = m_aSettings.getSettingByUrl( m_sWikiEngineURL ); if ( Helper.AllowThreadUsage( m_xContext ) ) { m_aThread = new Thread( "com.sun.star.thread.WikiEditorSendingThread" ) -- cgit