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 <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
This commit is contained in:
Noel Grandin
2013-04-17 13:51:15 +02:00
committed by Fridrich Strba
parent 391477d40e
commit a79d43dcd7
10 changed files with 168 additions and 192 deletions

View File

@@ -29,7 +29,6 @@ public class EditPageParser extends HTMLEditorKit.ParserCallback
protected String m_sLoginToken = ""; protected String m_sLoginToken = "";
protected String m_sMainURL = ""; protected String m_sMainURL = "";
private int m_nWikiArticleHash = 0;
private boolean m_bHTMLStartFound = false; private boolean m_bHTMLStartFound = false;
private boolean m_bInHead = false; private boolean m_bInHead = false;
@@ -138,7 +137,6 @@ public class EditPageParser extends HTMLEditorKit.ParserCallback
{ {
if ( sName.equalsIgnoreCase( "wpTextbox1" ) ) if ( sName.equalsIgnoreCase( "wpTextbox1" ) )
{ {
m_nWikiArticleHash = t.hashCode();
m_nWikiArticleStart = pos; m_nWikiArticleStart = pos;
} }
} }

View File

@@ -55,8 +55,6 @@ import com.sun.star.uno.XComponentContext;
import com.sun.star.util.XChangesBatch; import com.sun.star.util.XChangesBatch;
import java.net.*; import java.net.*;
import java.io.*; import java.io.*;
import java.util.Hashtable;
import java.util.Random;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.HTMLEditorKit;
@@ -149,11 +147,9 @@ public class Helper
private static final String sHTMLHeader = "<HTML><HEAD><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><TITLE></TITLE></HEAD><BODY>"; private static final String sHTMLHeader = "<HTML><HEAD><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><TITLE></TITLE></HEAD><BODY>";
private static final String sHTMLFooter = "</BODY></HTML>"; private static final String sHTMLFooter = "</BODY></HTML>";
private static Random m_aRandom;
private static MultiThreadedHttpConnectionManager m_aConnectionManager; private static MultiThreadedHttpConnectionManager m_aConnectionManager;
private static HttpClient m_aClient; private static HttpClient m_aClient;
private static boolean m_bAllowConnection = true; private static boolean m_bAllowConnection = true;
private static Hashtable m_aAcceptedUnknownCerts;
private static Boolean m_bShowInBrowser = null; private static Boolean m_bShowInBrowser = null;
@@ -245,7 +241,7 @@ public class Helper
XPropertySet xProps = Helper.GetConfigProps( xContext, "org.openoffice.Office.Custom.WikiExtension/Settings" ); XPropertySet xProps = Helper.GetConfigProps( xContext, "org.openoffice.Office.Custom.WikiExtension/Settings" );
xProps.setPropertyValue( "PreselectShowBrowser", new Boolean( bValue ) ); xProps.setPropertyValue( "PreselectShowBrowser", new Boolean( bValue ) );
XChangesBatch xBatch = ( XChangesBatch ) UnoRuntime.queryInterface( XChangesBatch.class, xProps ); XChangesBatch xBatch = UnoRuntime.queryInterface( XChangesBatch.class, xProps );
if ( xBatch != null ) if ( xBatch != null )
xBatch.commitChanges(); xBatch.commitChanges();
} }
@@ -262,7 +258,7 @@ public class Helper
{ {
XMultiComponentFactory xFactory = xContext.getServiceManager(); XMultiComponentFactory xFactory = xContext.getServiceManager();
if ( xFactory != null ) if ( xFactory != null )
m_xPasswordContainer = (XPasswordContainer)UnoRuntime.queryInterface( m_xPasswordContainer = UnoRuntime.queryInterface(
XPasswordContainer.class, XPasswordContainer.class,
xFactory.createInstanceWithContext( "com.sun.star.task.PasswordContainer", xContext ) ); xFactory.createInstanceWithContext( "com.sun.star.task.PasswordContainer", xContext ) );
} }
@@ -280,7 +276,7 @@ public class Helper
{ {
XMultiComponentFactory xFactory = xContext.getServiceManager(); XMultiComponentFactory xFactory = xContext.getServiceManager();
if ( xFactory != null ) if ( xFactory != null )
m_xInteractionHandler = ( XInteractionHandler )UnoRuntime.queryInterface( m_xInteractionHandler = UnoRuntime.queryInterface(
XInteractionHandler.class, XInteractionHandler.class,
xFactory.createInstanceWithContext( "com.sun.star.task.InteractionHandler", xContext ) ); xFactory.createInstanceWithContext( "com.sun.star.task.InteractionHandler", xContext ) );
} }
@@ -384,8 +380,8 @@ public class Helper
try try
{ {
Object oTempFile = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.io.TempFile", xContext ); Object oTempFile = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.io.TempFile", xContext );
XStream xStream = ( XStream ) UnoRuntime.queryInterface( XStream.class, oTempFile ); XStream xStream = UnoRuntime.queryInterface( XStream.class, oTempFile );
XSeekable xSeekable = ( XSeekable ) UnoRuntime.queryInterface( XSeekable.class, oTempFile ); XSeekable xSeekable = UnoRuntime.queryInterface( XSeekable.class, oTempFile );
if ( xStream != null && xSeekable != null ) if ( xStream != null && xSeekable != null )
{ {
XOutputStream xOutputStream = xStream.getOutputStream(); XOutputStream xOutputStream = xStream.getOutputStream();
@@ -418,13 +414,13 @@ public class Helper
try try
{ {
Object oTempFile = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.io.TempFile", xContext ); 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 ); xPropertySet.setPropertyValue( "RemoveFile", Boolean.FALSE );
sURL = ( String ) xPropertySet.getPropertyValue( "Uri" ); sURL = ( String ) xPropertySet.getPropertyValue( "Uri" );
XInputStream xInputStream = ( XInputStream ) UnoRuntime.queryInterface( XInputStream.class, oTempFile ); XInputStream xInputStream = UnoRuntime.queryInterface( XInputStream.class, oTempFile );
xInputStream.closeInput(); xInputStream.closeInput();
XOutputStream xOutputStream = ( XOutputStream ) UnoRuntime.queryInterface( XOutputStream.class, oTempFile ); XOutputStream xOutputStream = UnoRuntime.queryInterface( XOutputStream.class, oTempFile );
xOutputStream.closeOutput(); xOutputStream.closeOutput();
} catch ( com.sun.star.uno.Exception ex ) } catch ( com.sun.star.uno.Exception ex )
{ {
@@ -454,6 +450,8 @@ public class Helper
sEachLine = aBufReader.readLine(); sEachLine = aBufReader.readLine();
} }
sText = aBuf.toString(); sText = aBuf.toString();
aBufReader.close();
} catch ( Exception e ) } catch ( Exception e )
{ {
e.printStackTrace(); e.printStackTrace();
@@ -489,7 +487,7 @@ public class Helper
throw new com.sun.star.uno.RuntimeException(); throw new com.sun.star.uno.RuntimeException();
Object oModuleManager = xFactory.createInstanceWithContext( "com.sun.star.frame.ModuleManager", xContext ); 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 ) if ( xModuleManager != null )
aDocServiceName = xModuleManager.identify( xModel ); aDocServiceName = xModuleManager.identify( xModel );
} }
@@ -511,7 +509,7 @@ public class Helper
try try
{ {
Object oFilterFactory = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.document.FilterFactory", xContext ); 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 ) if ( xQuery != null )
{ {
NamedValue[] aRequest = new NamedValue[2]; NamedValue[] aRequest = new NamedValue[2];
@@ -562,7 +560,7 @@ public class Helper
{ {
XMultiComponentFactory xFactory = xContext.getServiceManager(); XMultiComponentFactory xFactory = xContext.getServiceManager();
Object oConfigProvider = xFactory.createInstanceWithContext( "com.sun.star.configuration.ConfigurationProvider", xContext ); 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 ) if ( xConfigurationProvider == null )
@@ -592,7 +590,7 @@ public class Helper
protected static XPropertySet GetConfigProps( XComponentContext xContext, String sNodepath ) protected static XPropertySet GetConfigProps( XComponentContext xContext, String sNodepath )
throws com.sun.star.uno.Exception 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 ) if ( xProps == null )
throw new com.sun.star.uno.RuntimeException(); throw new com.sun.star.uno.RuntimeException();
@@ -603,7 +601,7 @@ public class Helper
protected static XNameContainer GetConfigNameContainer( XComponentContext xContext, String sNodepath ) protected static XNameContainer GetConfigNameContainer( XComponentContext xContext, String sNodepath )
throws com.sun.star.uno.Exception 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 ) if ( xContainer == null )
throw new com.sun.star.uno.RuntimeException(); throw new com.sun.star.uno.RuntimeException();
@@ -613,7 +611,7 @@ public class Helper
protected static XNameAccess GetConfigNameAccess( XComponentContext xContext, String sNodepath ) protected static XNameAccess GetConfigNameAccess( XComponentContext xContext, String sNodepath )
throws com.sun.star.uno.Exception 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 ) if ( xNameAccess == null )
throw new com.sun.star.uno.RuntimeException(); throw new com.sun.star.uno.RuntimeException();
@@ -679,7 +677,7 @@ public class Helper
try try
{ {
Object oSystemShell = xContext.getServiceManager().createInstanceWithContext( "com.sun.star.system.SystemShellExecute", xContext ); 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 ) if ( xSystemShell != null )
xSystemShell.execute( sURL, "", SystemShellExecuteFlags.URIS_ONLY ); xSystemShell.execute( sURL, "", SystemShellExecuteFlags.URIS_ONLY );
} }
@@ -701,7 +699,6 @@ public class Helper
SetConfigurationProxy( aHostConfig, xContext ); SetConfigurationProxy( aHostConfig, xContext );
} }
boolean bNoUnknownCertNotification = false;
if ( aHostConfig.getProtocol().getScheme().equals( "https" ) if ( aHostConfig.getProtocol().getScheme().equals( "https" )
&& AllowUnknownCert( xContext, aURI.getHost() ) ) && AllowUnknownCert( xContext, aURI.getHost() ) )
{ {
@@ -855,12 +852,12 @@ public class Helper
private static XControl GetControlFromDialog( XDialog xDialog, String aControlName ) private static XControl GetControlFromDialog( XDialog xDialog, String aControlName )
{ {
XControl xResult = null; XControl xResult = null;
XControlContainer xControlCont = (XControlContainer) UnoRuntime.queryInterface( XControlContainer.class, xDialog ); XControlContainer xControlCont = UnoRuntime.queryInterface( XControlContainer.class, xDialog );
if ( xControlCont != null ) if ( xControlCont != null )
{ {
Object oControl = xControlCont.getControl( aControlName ); Object oControl = xControlCont.getControl( aControlName );
xResult = ( XControl ) UnoRuntime.queryInterface( XControl.class, oControl ); xResult = UnoRuntime.queryInterface( XControl.class, oControl );
} }
return xResult; return xResult;
@@ -870,7 +867,7 @@ public class Helper
{ {
XControl xControl = GetControlFromDialog( xDialog, aControlName ); XControl xControl = GetControlFromDialog( xDialog, aControlName );
if ( xControl != null ) if ( xControl != null )
return ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, xControl.getModel() ); return UnoRuntime.queryInterface( XPropertySet.class, xControl.getModel() );
return null; return null;
} }
@@ -919,7 +916,7 @@ public class Helper
boolean bResult = false; boolean bResult = false;
try try
{ {
XMasterPasswordHandling xMasterHdl = (XMasterPasswordHandling)UnoRuntime.queryInterface( XMasterPasswordHandling.class, GetPasswordContainer( xContext ) ); XMasterPasswordHandling xMasterHdl = UnoRuntime.queryInterface( XMasterPasswordHandling.class, GetPasswordContainer( xContext ) );
if ( xMasterHdl != null ) if ( xMasterHdl != null )
bResult = xMasterHdl.isPersistentStoringAllowed(); 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 ) protected static void ShowError( XComponentContext xContext, XDialog xDialog, int nTitleID, int nErrorID, String sArg, boolean bQuery )
{ {
XWindowPeer xPeer = null; XWindowPeer xPeer = null;
XControl xControl = (XControl)UnoRuntime.queryInterface( XControl.class, xDialog ); XControl xControl = UnoRuntime.queryInterface( XControl.class, xDialog );
if ( xControl != null ) if ( xControl != null )
xPeer = xControl.getPeer(); xPeer = xControl.getPeer();
ShowError( xContext, xPeer, nTitleID, nErrorID, sArg, bQuery ); ShowError( xContext, xPeer, nTitleID, nErrorID, sArg, bQuery );
@@ -946,8 +943,6 @@ public class Helper
if ( xContext != null && nErrorID >= 0 && nErrorID < STRINGS_NUM ) if ( xContext != null && nErrorID >= 0 && nErrorID < STRINGS_NUM )
{ {
boolean bShown = false;
String sError = null; String sError = null;
String sTitle = ""; String sTitle = "";
@@ -975,7 +970,7 @@ public class Helper
{ {
XMultiComponentFactory xFactory = xContext.getServiceManager(); XMultiComponentFactory xFactory = xContext.getServiceManager();
if ( xFactory != null ) if ( xFactory != null )
xMBFactory = (XMessageBoxFactory)UnoRuntime.queryInterface( xMBFactory = UnoRuntime.queryInterface(
XMessageBoxFactory.class, XMessageBoxFactory.class,
xFactory.createInstanceWithContext( "com.sun.star.awt.Toolkit", xContext ) ); xFactory.createInstanceWithContext( "com.sun.star.awt.Toolkit", xContext ) );
@@ -1004,7 +999,6 @@ public class Helper
if ( xMB != null ) if ( xMB != null )
{ {
bResult = MainThreadDialogExecutor.Execute( xContext, xMB ); bResult = MainThreadDialogExecutor.Execute( xContext, xMB );
bShown = true;
} }
} }
} }
@@ -1030,7 +1024,7 @@ public class Helper
XNameAccess xNameAccess = GetConfigNameAccess( xContext, "org.openoffice.Office.Custom.WikiExtension/SpecialData" ); XNameAccess xNameAccess = GetConfigNameAccess( xContext, "org.openoffice.Office.Custom.WikiExtension/SpecialData" );
if ( xNameAccess.hasByName( aURL ) ) 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" ) ) if ( xEntry != null && xEntry.hasByName( "AllowUnknownCertificate" ) )
return AnyConverter.toBoolean( xEntry.getByName( "AllowUnknownCertificate" ) ); return AnyConverter.toBoolean( xEntry.getByName( "AllowUnknownCertificate" ) );
} }
@@ -1050,10 +1044,10 @@ public class Helper
XNameAccess xNameAccess = GetConfigNameAccess( xContext, "org.openoffice.Office.Custom.WikiExtension/SpecialData" ); XNameAccess xNameAccess = GetConfigNameAccess( xContext, "org.openoffice.Office.Custom.WikiExtension/SpecialData" );
if ( xNameAccess.hasByName( aURL ) ) 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 ) 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 ) if ( xArgs != null )
{ {
String[] pNames = xArgs.getElementNames(); String[] pNames = xArgs.getElementNames();
@@ -1062,7 +1056,7 @@ public class Helper
String[][] pResult = new String[pNames.length][2]; String[][] pResult = new String[pNames.length][2];
for ( int nInd = 0; nInd < pNames.length; nInd++ ) 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 ) if ( xArgument == null )
throw new com.sun.star.uno.RuntimeException(); throw new com.sun.star.uno.RuntimeException();
@@ -1112,7 +1106,7 @@ public class Helper
{ {
try try
{ {
XComponent xComp = (XComponent)UnoRuntime.queryInterface( XComponent.class, oObject ); XComponent xComp = UnoRuntime.queryInterface( XComponent.class, oObject );
if ( xComp != null ) if ( xComp != null )
xComp.dispose(); xComp.dispose();
} }

View File

@@ -78,7 +78,7 @@ public class MainThreadDialogExecutor implements XCallback
if ( xFactory == null ) if ( xFactory == null )
throw new com.sun.star.uno.RuntimeException(); throw new com.sun.star.uno.RuntimeException();
XRequestCallback xRequest = (XRequestCallback)UnoRuntime.queryInterface( XRequestCallback xRequest = UnoRuntime.queryInterface(
XRequestCallback.class, XRequestCallback.class,
xFactory.createInstanceWithContext( "com.sun.star.awt.AsyncCallback", xContext ) ); xFactory.createInstanceWithContext( "com.sun.star.awt.AsyncCallback", xContext ) );
if ( xRequest != null ) if ( xRequest != null )

View File

@@ -18,6 +18,12 @@
package com.sun.star.wiki; 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.beans.XPropertySet;
import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNameContainer; 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.UnoRuntime;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
import com.sun.star.util.XChangesBatch; import com.sun.star.util.XChangesBatch;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
public class Settings public class Settings
{ {
private XComponentContext m_xContext; /* Singleton */
private int lastUsedWikiServer = 0;
/* Singelton */
private static Settings m_instance; private static Settings m_instance;
private Vector<Hashtable<String, String>> m_WikiConnections = new Vector<Hashtable<String, String>>(); private XComponentContext m_xContext;
private Vector<Hashtable<String, Object>> m_aWikiDocs = new Vector<Hashtable<String, Object>>(); private int lastUsedWikiServer = 0;
private List<Map<String, String>> m_WikiConnections = new ArrayList<Map<String, String>>();
private List<Map<String, Object>> m_aWikiDocs = new ArrayList<Map<String, Object>>();
private Settings( XComponentContext ctx ) private Settings( XComponentContext ctx )
{ {
@@ -61,13 +62,13 @@ public class Settings
} }
public void addWikiCon ( Hashtable<String, String> wikiCon ) public void addWikiCon ( Map<String, String> wikiCon )
{ {
m_WikiConnections.add( wikiCon ); m_WikiConnections.add( wikiCon );
} }
public Vector<Hashtable<String, String>> getWikiCons() public List<Map<String, String>> getWikiCons()
{ {
return m_WikiConnections; return m_WikiConnections;
} }
@@ -77,17 +78,17 @@ public class Settings
String url = ""; String url = "";
if ( num >=0 && num < m_WikiConnections.size() ) if ( num >=0 && num < m_WikiConnections.size() )
{ {
Hashtable ht = m_WikiConnections.get( num ); Map<String,String> ht = m_WikiConnections.get( num );
url = ( String ) ht.get( "Url" ); url = ht.get( "Url" );
} }
return url; return url;
} }
public void addWikiDoc ( Hashtable<String, Object> aWikiDoc ) public void addWikiDoc ( Map<String, Object> aWikiDoc )
{ {
String sURL = ( String ) aWikiDoc.get( "CompleteUrl" ); String sURL = ( String ) aWikiDoc.get( "CompleteUrl" );
Hashtable aEntry = getDocByCompleteUrl( sURL ); Map<String,Object> aEntry = getDocByCompleteUrl( sURL );
if ( aEntry != null ) if ( aEntry != null )
{ {
@@ -104,7 +105,7 @@ public class Settings
} }
public Vector<Hashtable<String, Object>> getWikiDocs() public List<Map<String, Object>> getWikiDocs()
{ {
return m_aWikiDocs; return m_aWikiDocs;
} }
@@ -112,11 +113,11 @@ public class Settings
public Object[] getWikiDocList( int serverid, int num ) public Object[] getWikiDocList( int serverid, int num )
{ {
String wikiserverurl = getWikiConUrlByNumber( serverid ); String wikiserverurl = getWikiConUrlByNumber( serverid );
Vector<String> theDocs = new Vector<String>(); List<String> theDocs = new ArrayList<String>();
String [] docs = new String[0]; String [] docs = new String[0];
for ( int i=0; i<m_aWikiDocs.size(); i++ ) for ( int i=0; i<m_aWikiDocs.size(); i++ )
{ {
Hashtable ht = m_aWikiDocs.get( i ); Map<String,Object> ht = m_aWikiDocs.get( i );
String docurl = ( String ) ht.get( "Url" ); String docurl = ( String ) ht.get( "Url" );
if ( docurl.equals( wikiserverurl ) ) if ( docurl.equals( wikiserverurl ) )
{ {
@@ -141,19 +142,19 @@ public class Settings
String [] WikiList = new String [m_WikiConnections.size()]; String [] WikiList = new String [m_WikiConnections.size()];
for ( int i=0; i<m_WikiConnections.size(); i++ ) for ( int i=0; i<m_WikiConnections.size(); i++ )
{ {
Hashtable ht = m_WikiConnections.get( i ); Map<String,String> ht = m_WikiConnections.get( i );
WikiList[i] = ( String ) ht.get( "Url" ); WikiList[i] = ht.get( "Url" );
} }
return WikiList; return WikiList;
} }
public Hashtable<String, String> getSettingByUrl( String sUrl ) public Map<String, String> getSettingByUrl( String sUrl )
{ {
Hashtable<String, String> ht = null; Map<String, String> ht = null;
for( int i=0;i<m_WikiConnections.size();i++ ) for( int i=0;i<m_WikiConnections.size();i++ )
{ {
Hashtable<String, String> h1 = m_WikiConnections.get( i ); Map<String, String> h1 = m_WikiConnections.get( i );
String u1 = h1.get( "Url" ); String u1 = h1.get( "Url" );
if ( u1.equals( sUrl ) ) if ( u1.equals( sUrl ) )
{ {
@@ -180,12 +181,12 @@ public class Settings
return ht; return ht;
} }
public Hashtable getDocByCompleteUrl( String curl ) public Map<String,Object> getDocByCompleteUrl( String curl )
{ {
Hashtable ht = null; Map<String,Object> ht = null;
for( int i=0;i<m_aWikiDocs.size();i++ ) for( int i=0;i<m_aWikiDocs.size();i++ )
{ {
Hashtable h1 = m_aWikiDocs.get( i ); Map<String,Object> h1 = m_aWikiDocs.get( i );
String u1 = ( String ) h1.get( "CompleteUrl" ); String u1 = ( String ) h1.get( "CompleteUrl" );
if ( u1.equals( curl ) ) if ( u1.equals( curl ) )
{ {
@@ -198,11 +199,10 @@ public class Settings
public void removeSettingByUrl( String sUrl ) public void removeSettingByUrl( String sUrl )
{ {
Hashtable ht = null;
for( int i=0;i<m_WikiConnections.size();i++ ) for( int i=0;i<m_WikiConnections.size();i++ )
{ {
Hashtable h1 = m_WikiConnections.get( i ); Map<String,String> h1 = m_WikiConnections.get( i );
String u1 = ( String ) h1.get( "Url" ); String u1 = h1.get( "Url" );
if ( u1.equals( sUrl ) ) if ( u1.equals( sUrl ) )
{ {
m_WikiConnections.remove( i ); m_WikiConnections.remove( i );
@@ -228,13 +228,13 @@ public class Settings
for ( int i=0; i< m_WikiConnections.size(); i++ ) for ( int i=0; i< m_WikiConnections.size(); i++ )
{ {
Object oNewConnection = xConnectionFactory.createInstance(); Object oNewConnection = xConnectionFactory.createInstance();
Hashtable ht = m_WikiConnections.get( i ); Map<String,String> ht = m_WikiConnections.get( i );
XNameReplace xNewConn = UnoRuntime.queryInterface( XNameReplace.class, oNewConnection ); XNameReplace xNewConn = UnoRuntime.queryInterface( XNameReplace.class, oNewConnection );
if ( xNewConn != null ) if ( xNewConn != null )
xNewConn.replaceByName( "UserName", ht.get( "Username" ) ); xNewConn.replaceByName( "UserName", ht.get( "Username" ) );
xContainer.insertByName( (String)ht.get( "Url" ), xNewConn ); xContainer.insertByName( ht.get( "Url" ), xNewConn );
} }
// commit changes // commit changes
XChangesBatch xBatch = UnoRuntime.queryInterface( XChangesBatch.class, xContainer ); XChangesBatch xBatch = UnoRuntime.queryInterface( XChangesBatch.class, xContainer );
@@ -251,15 +251,14 @@ public class Settings
XSingleServiceFactory xDocListFactory = UnoRuntime.queryInterface( XSingleServiceFactory.class, xContainer2 ); XSingleServiceFactory xDocListFactory = UnoRuntime.queryInterface( XSingleServiceFactory.class, xContainer2 );
for ( int i=0; i< m_aWikiDocs.size(); i++ ) for ( int i=0; i< m_aWikiDocs.size(); i++ )
{ {
Hashtable ht = m_aWikiDocs.get( i ); Map<String,Object> ht = m_aWikiDocs.get( i );
Object oNewDoc = xDocListFactory.createInstance(); Object oNewDoc = xDocListFactory.createInstance();
XNameReplace xNewDoc = UnoRuntime.queryInterface( XNameReplace.class, oNewDoc ); XNameReplace xNewDoc = UnoRuntime.queryInterface( XNameReplace.class, oNewDoc );
Enumeration e = ht.keys(); for ( Iterator<String> iter = ht.keySet().iterator(); iter.hasNext(); )
while ( e.hasMoreElements() )
{ {
String key = ( String ) e.nextElement(); String key = iter.next();
xNewDoc.replaceByName( key, ht.get( key ) ); xNewDoc.replaceByName( key, ht.get( key ) );
} }
@@ -292,7 +291,7 @@ public class Settings
String [] allCons = xConnectionList.getElementNames(); String [] allCons = xConnectionList.getElementNames();
for ( int i=0; i<allCons.length; i++ ) for ( int i=0; i<allCons.length; i++ )
{ {
Hashtable<String, String> ht = new Hashtable<String, String>(); Map<String, String> ht = new HashMap<String, String>();
ht.put( "Url", allCons[i] ); ht.put( "Url", allCons[i] );
ht.put( "Username", "" ); ht.put( "Username", "" );
ht.put( "Password", "" ); ht.put( "Password", "" );
@@ -322,7 +321,7 @@ public class Settings
{ {
Object oDoc = xRecentDocs.getByName( allDocs[i] ); Object oDoc = xRecentDocs.getByName( allDocs[i] );
XNameAccess xDoc = UnoRuntime.queryInterface( XNameAccess.class, oDoc ); XNameAccess xDoc = UnoRuntime.queryInterface( XNameAccess.class, oDoc );
Hashtable<String, Object> ht = new Hashtable<String, Object>(); Map<String, Object> ht = new HashMap<String, Object>();
ht.put( "Url", xDoc.getByName( "Url" ) ); ht.put( "Url", xDoc.getByName( "Url" ) );
ht.put( "CompleteUrl", xDoc.getByName( "CompleteUrl" ) ); ht.put( "CompleteUrl", xDoc.getByName( "CompleteUrl" ) );
ht.put( "Doc", xDoc.getByName( "Doc" ) ); ht.put( "Doc", xDoc.getByName( "Doc" ) );

View File

@@ -18,13 +18,17 @@
package com.sun.star.wiki; package com.sun.star.wiki;
import java.io.*; import java.io.StringReader;
import java.util.Hashtable; import java.util.Map;
import javax.swing.text.html.*;
import com.sun.star.uno.XComponentContext;
import org.apache.commons.httpclient.*; import javax.swing.text.html.HTMLEditorKit;
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 public class WikiArticle
@@ -34,27 +38,27 @@ public class WikiArticle
private String m_sEditTime = ""; private String m_sEditTime = "";
private String m_sEditToken = ""; private String m_sEditToken = "";
protected String m_sHTMLCode; private String m_sHTMLCode;
private boolean m_bNoArticle = true; private boolean m_bNoArticle = true;
protected String m_sWikiUser; private String m_sWikiUser;
protected String m_sWikiPass; private String m_sWikiPass;
protected String m_sTitle = ""; private String m_sTitle = "";
private URI m_aMainURI; private URI m_aMainURI;
private HostConfiguration m_aHostConfig; private HostConfiguration m_aHostConfig;
/** Creates a new instance of WikiArticle */ /** 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<String,String> wikiSettings, boolean bLogin, WikiPropDialog aPropDialog )
throws java.net.MalformedURLException, com.sun.star.uno.Exception, java.io.IOException, WikiCancelException throws java.net.MalformedURLException, com.sun.star.uno.Exception, java.io.IOException, WikiCancelException
{ {
m_xContext = xContext; m_xContext = xContext;
String sMainUrl = (String) wikiSettings.get("Url"); String sMainUrl = wikiSettings.get("Url");
m_sWikiUser = (String) wikiSettings.get("Username"); m_sWikiUser = wikiSettings.get("Username");
m_sWikiPass = (String) wikiSettings.get("Password"); m_sWikiPass = wikiSettings.get("Password");
m_sTitle = sTitle; m_sTitle = sTitle;
m_aMainURI = new URI( sMainUrl ); m_aMainURI = new URI( sMainUrl );
@@ -77,8 +81,8 @@ public class WikiArticle
if ( MainThreadDialogExecutor.Show( xContext, aDialog ) ) if ( MainThreadDialogExecutor.Show( xContext, aDialog ) )
{ {
m_sWikiUser = (String) wikiSettings.get("Username"); m_sWikiUser = wikiSettings.get("Username");
m_sWikiPass = (String) wikiSettings.get("Password"); m_sWikiPass = wikiSettings.get("Password");
} }
else else
throw new WikiCancelException(); throw new WikiCancelException();

View File

@@ -38,13 +38,12 @@ import com.sun.star.lang.XMultiServiceFactory;
public class WikiDialog implements XDialogEventHandler, XTopWindowListener public class WikiDialog implements XDialogEventHandler, XTopWindowListener
{ {
XComponentContext m_xContext; protected XComponentContext m_xContext;
XControlContainer m_xControlContainer; private XControlContainer m_xControlContainer;
XDialog m_xDialog; protected XDialog m_xDialog;
String[] m_aMethods; private String[] m_aMethods;
boolean m_bAction = false; protected boolean m_bAction = false;
Settings m_aSettings; protected Settings m_aSettings;
protected Thread m_aThread; protected Thread m_aThread;
protected boolean m_bThreadFinished = false; protected boolean m_bThreadFinished = false;
@@ -59,11 +58,11 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener
{ {
Object obj; Object obj;
obj = xMCF.createInstanceWithContext("com.sun.star.awt.DialogProvider2", m_xContext ); 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_xDialog = xDialogProvider.createDialogWithHandler( DialogURL, this );
m_xControlContainer = (XControlContainer)UnoRuntime.queryInterface( XControlContainer.class, m_xDialog ); m_xControlContainer = UnoRuntime.queryInterface( XControlContainer.class, m_xDialog );
XTopWindow xTopWindow = (XTopWindow)UnoRuntime.queryInterface( XTopWindow.class, m_xDialog ); XTopWindow xTopWindow = UnoRuntime.queryInterface( XTopWindow.class, m_xDialog );
if ( xTopWindow != null ) if ( xTopWindow != null )
xTopWindow.addTopWindowListener( this ); xTopWindow.addTopWindowListener( this );
} }
@@ -128,10 +127,10 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener
{ {
if ( xDialog != null && sTitle != null ) if ( xDialog != null && sTitle != null )
{ {
XControl xDialogControl = (XControl)UnoRuntime.queryInterface( XControl.class, xDialog ); XControl xDialogControl = UnoRuntime.queryInterface( XControl.class, xDialog );
if ( xDialogControl != null ) if ( xDialogControl != null )
{ {
XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xDialogControl.getModel() ); XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xDialogControl.getModel() );
if ( xPropSet != null ) if ( xPropSet != null )
xPropSet.setPropertyValue( "Title", sTitle ); xPropSet.setPropertyValue( "Title", sTitle );
} }
@@ -150,7 +149,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener
if ( xControlContainer != null && sControl != null ) if ( xControlContainer != null && sControl != null )
{ {
XControl xControl = xControlContainer.getControl(sControl); XControl xControl = xControlContainer.getControl(sControl);
xPS = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel() ); xPS = UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel() );
} }
if ( xPS == null ) if ( xPS == null )
@@ -168,7 +167,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener
try try
{ {
Object oDialogProvider = xContext.getServiceManager().createInstanceWithContext("com.sun.star.awt.DialogProvider2", xContext ); 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 ) if ( xDialogProvider != null )
xResult = xDialogProvider.createDialog( sURL ); xResult = xDialogProvider.createDialog( sURL );
@@ -178,7 +177,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener
SetTitle( xResult, Helper.GetLocalizedString( xContext, nTitleID ) ); SetTitle( xResult, Helper.GetLocalizedString( xContext, nTitleID ) );
if ( pControls != null && pStringIDs != null && pControls.length == pStringIDs.length ) 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++ ) for ( int nInd = 0; nInd < pControls.length; nInd++ )
GetPropSet( xControlContainer, pControls[nInd] ).setPropertyValue( "Label", new Integer( pStringIDs[nInd] ) ); GetPropSet( xControlContainer, pControls[nInd] ).setPropertyValue( "Label", new Integer( pStringIDs[nInd] ) );
} }
@@ -197,16 +196,16 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener
{ {
try try
{ {
XControl xDialogControl = ( XControl ) UnoRuntime.queryInterface( XControl.class, m_xDialog ); XControl xDialogControl = UnoRuntime.queryInterface( XControl.class, m_xDialog );
XControlModel xDialogModel = null; XControlModel xDialogModel = null;
if ( xDialogControl != null ) if ( xDialogControl != null )
xDialogModel = xDialogControl.getModel(); xDialogModel = xDialogControl.getModel();
XMultiServiceFactory xDialogFactory = ( XMultiServiceFactory ) UnoRuntime.queryInterface( XMultiServiceFactory.class, xDialogModel ); XMultiServiceFactory xDialogFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, xDialogModel );
if ( xDialogFactory != null ) if ( xDialogFactory != null )
{ {
XControlModel xThrobberModel = (XControlModel)UnoRuntime.queryInterface( XControlModel.class, xDialogFactory.createInstance( "com.sun.star.awt.UnoThrobberControlModel" ) ); XControlModel xThrobberModel = UnoRuntime.queryInterface( XControlModel.class, xDialogFactory.createInstance( "com.sun.star.awt.UnoThrobberControlModel" ) );
XPropertySet xThrobberProps = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xThrobberModel ); XPropertySet xThrobberProps = UnoRuntime.queryInterface( XPropertySet.class, xThrobberModel );
if ( xThrobberProps != null ) if ( xThrobberProps != null )
{ {
xThrobberProps.setPropertyValue( "Name", "WikiThrobber" ); xThrobberProps.setPropertyValue( "Name", "WikiThrobber" );
@@ -215,7 +214,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener
xThrobberProps.setPropertyValue( "Height", new Integer( Width ) ); xThrobberProps.setPropertyValue( "Height", new Integer( Width ) );
xThrobberProps.setPropertyValue( "Width", new Integer( Height ) ); 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 ); xDialogContainer.insertByName( "WikiThrobber", xThrobberModel );
} }
} }
@@ -234,7 +233,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener
{ {
try 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 ( xThrobber != null )
{ {
if ( bActive ) if ( bActive )
@@ -256,7 +255,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener
{ {
try 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 ) if ( xWindow != null )
xWindow.setVisible( bVisible ); xWindow.setVisible( bVisible );
} }
@@ -273,7 +272,7 @@ public class WikiDialog implements XDialogEventHandler, XTopWindowListener
{ {
try 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 ) if ( xWindow != null )
xWindow.setFocus(); xWindow.setFocus();
} }

View File

@@ -18,24 +18,27 @@
package com.sun.star.wiki; package com.sun.star.wiki;
import com.sun.star.awt.XDialog; import java.util.HashMap;
import com.sun.star.beans.XPropertySet; import java.util.Map;
import com.sun.star.uno.XComponentContext;
import com.sun.star.lang.EventObject;
import java.util.Hashtable;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.methods.*; 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.lang.EventObject;
import com.sun.star.uno.XComponentContext;
public class WikiEditSettingDialog extends WikiDialog public class WikiEditSettingDialog extends WikiDialog
{ {
private final String sOKMethod = "OK"; private final String sOKMethod = "OK";
String[] Methods = private String[] Methods = {sOKMethod };
{sOKMethod }; private Map<String,String> setting;
private Hashtable setting;
private boolean addMode; private boolean addMode;
private boolean m_bAllowURLChange = true; private boolean m_bAllowURLChange = true;
@@ -43,7 +46,7 @@ public class WikiEditSettingDialog extends WikiDialog
{ {
super( xContext, DialogURL ); super( xContext, DialogURL );
super.setMethods( Methods ); super.setMethods( Methods );
setting = new Hashtable(); setting = new HashMap<String,String>();
addMode = true; addMode = true;
InsertThrobber( 184, 20, 10, 10 ); InsertThrobber( 184, 20, 10, 10 );
@@ -51,7 +54,7 @@ public class WikiEditSettingDialog extends WikiDialog
InitSaveCheckbox( xContext, false ); InitSaveCheckbox( xContext, false );
} }
public WikiEditSettingDialog( XComponentContext xContext, String DialogURL, Hashtable ht, boolean bAllowURLChange ) public WikiEditSettingDialog( XComponentContext xContext, String DialogURL, Map<String,String> ht, boolean bAllowURLChange )
{ {
super( xContext, DialogURL ); super( xContext, DialogURL );
super.setMethods( Methods ); super.setMethods( Methods );
@@ -69,8 +72,8 @@ public class WikiEditSettingDialog extends WikiDialog
if ( Helper.PasswordStoringIsAllowed( m_xContext ) ) if ( Helper.PasswordStoringIsAllowed( m_xContext ) )
{ {
String[] pPasswords = Helper.GetPasswordsForURLAndUser( m_xContext, (String)ht.get( "Url" ), (String)ht.get( "Username" ) ); String[] pPasswords = Helper.GetPasswordsForURLAndUser( m_xContext, ht.get( "Url" ), ht.get( "Username" ) );
bInitSaveCheckBox = ( pPasswords != null && pPasswords.length > 0 && pPasswords[0].equals( (String)ht.get( "Password" ) ) ); 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 // 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 ) if ( bResult && Helper.PasswordStoringIsAllowed( m_xContext )
&& ( (Short)( GetPropSet( "SaveBox" ).getPropertyValue("State") ) ).shortValue() != (short)0 ) && ( (Short)( GetPropSet( "SaveBox" ).getPropertyValue("State") ) ).shortValue() != (short)0 )
{ {
String sURL = (String)setting.get( "Url" ); String sURL = setting.get( "Url" );
String sUserName = (String)setting.get( "Username" ); String sUserName = setting.get( "Username" );
String sPassword = (String)setting.get( "Password" ); String sPassword = setting.get( "Password" );
if ( sURL != null && sURL.length() > 0 && sUserName != null && sUserName.length() > 0 && sPassword != null && sPassword.length() > 0 ) if ( sURL != null && sURL.length() > 0 && sUserName != null && sUserName.length() > 0 && sPassword != null && sPassword.length() > 0 )
{ {

View File

@@ -18,42 +18,38 @@
package com.sun.star.wiki; 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.awt.XWindowPeer;
import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyValue;
import com.sun.star.frame.DispatchDescriptor; import com.sun.star.frame.DispatchDescriptor;
import com.sun.star.frame.XController; import com.sun.star.frame.XController;
import com.sun.star.frame.XDesktop;
import com.sun.star.frame.XDispatch; import com.sun.star.frame.XDispatch;
import com.sun.star.frame.XDispatchProvider; import com.sun.star.frame.XDispatchProvider;
import com.sun.star.frame.XFrame; import com.sun.star.frame.XFrame;
import com.sun.star.frame.XModel; import com.sun.star.frame.XModel;
import com.sun.star.frame.XStatusListener; import com.sun.star.frame.XStatusListener;
import com.sun.star.frame.XStorable; import com.sun.star.frame.XStorable;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XInitialization; import com.sun.star.lang.XInitialization;
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.UnoRuntime;
import com.sun.star.uno.XComponentContext; 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.WeakBase;
import com.sun.star.util.XCloseBroadcaster; 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 public final class WikiEditorImpl extends WeakBase
implements com.sun.star.lang.XServiceInfo, XDispatchProvider, XDispatch, XInitialization 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_implementationName = WikiEditorImpl.class.getName();
private static final String[] m_serviceNames = {"com.sun.star.wiki.WikiEditor" }; 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 // protocol name that this protocol handler handles
public static final String protocolName = "vnd.com.sun.star.wiki:"; public static final String protocolName = "vnd.com.sun.star.wiki:";
private Map m_statusListeners = new HashMap(); private final XComponentContext m_xContext;
private Map<String, com.sun.star.frame.XStatusListener> m_statusListeners = new HashMap<String, com.sun.star.frame.XStatusListener>();
private XComponent xComp;
private String sTempUrl;
private XFrame m_xFrame; private XFrame m_xFrame;
private XModel m_xModel; private XModel m_xModel;
private Settings m_aSettings; private Settings m_aSettings;
private String m_aFilterName; private String m_aFilterName;
public WikiEditorImpl( XComponentContext xContext ) 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; private boolean m_bInitialized;
public synchronized void initialize( Object[] args ) throws com.sun.star.uno.Exception 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 ) if ( args.length > 0 )
{ {
m_bInitialized = true; m_bInitialized = true;
m_xFrame = ( XFrame )UnoRuntime.queryInterface( XFrame.class, args[0] ); m_xFrame = UnoRuntime.queryInterface( XFrame.class, args[0] );
// become close listener // become close listener
XCloseBroadcaster cb = ( XCloseBroadcaster )UnoRuntime.queryInterface( XCloseBroadcaster cb = UnoRuntime.queryInterface( XCloseBroadcaster.class, m_xFrame );
XCloseBroadcaster.class, m_xFrame );
} }
} }
@@ -242,13 +230,10 @@ public final class WikiEditorImpl extends WeakBase
public void callStatusListeners() public void callStatusListeners()
{ {
Set entries = m_statusListeners.entrySet(); for (Iterator<String> iter = m_statusListeners.keySet().iterator(); iter.hasNext(); )
Iterator iter = entries.iterator();
while ( iter.hasNext() )
{ {
Map.Entry entry = ( Map.Entry ) iter.next(); String uristring = iter.next();
String uristring = ( String ) entry.getKey(); XStatusListener listener = m_statusListeners.get(uristring);
XStatusListener listener = ( XStatusListener ) entry.getValue();
callStatusListener( uristring, listener ); callStatusListener( uristring, listener );
} }
} }
@@ -257,7 +242,6 @@ public final class WikiEditorImpl extends WeakBase
{ {
try try
{ {
URI uri = new URI( uristring ); URI uri = new URI( uristring );
// check whether any blogs are live... // check whether any blogs are live...
@@ -300,7 +284,7 @@ public final class WikiEditorImpl extends WeakBase
if ( m_aFilterName == null || m_aFilterName.length() == 0 ) if ( m_aFilterName == null || m_aFilterName.length() == 0 )
{ {
Helper.ShowError( m_xContext, Helper.ShowError( m_xContext,
(XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ),
Helper.DLG_SENDTITLE, Helper.DLG_SENDTITLE,
Helper.NOWIKIFILTER_ERROR, Helper.NOWIKIFILTER_ERROR,
null, null,
@@ -329,7 +313,7 @@ public final class WikiEditorImpl extends WeakBase
} }
} }
public boolean SendArticleImpl( WikiPropDialog aSendDialog, Hashtable aWikiSetting ) public boolean SendArticleImpl( WikiPropDialog aSendDialog, Map<String,String> aWikiSetting )
{ {
boolean bResult = false; boolean bResult = false;
@@ -349,7 +333,7 @@ public final class WikiEditorImpl extends WeakBase
aSendDialog.SetThrobberActive( false ); aSendDialog.SetThrobberActive( false );
bAllowSending = Helper.ShowError( bAllowSending = Helper.ShowError(
m_xContext, m_xContext,
(XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ),
Helper.DLG_SENDTITLE, Helper.DLG_SENDTITLE,
Helper.DLG_WIKIPAGEEXISTS_LABEL1, Helper.DLG_WIKIPAGEEXISTS_LABEL1,
aSendDialog.GetWikiTitle(), aSendDialog.GetWikiTitle(),
@@ -369,7 +353,7 @@ public final class WikiEditorImpl extends WeakBase
sTemp2Url = Helper.CreateTempFile( m_xContext ); 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 ) if ( xStore == null )
throw new com.sun.star.uno.RuntimeException(); 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 ) ) if ( aArticle.setArticle( sWikiCode, aSendDialog.m_sWikiComment, aSendDialog.m_bWikiMinorEdit ) )
{ {
bResult = true; 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() ); Helper.SetDocTitle( m_xModel, aArticle.GetTitle() );
Hashtable aDocInfo = new Hashtable(); Map<String,Object> aDocInfo = new HashMap<String,Object>();
aDocInfo.put( "Doc", aArticle.GetTitle() ); aDocInfo.put( "Doc", aArticle.GetTitle() );
aDocInfo.put( "Url", aArticle.GetMainURL() ); aDocInfo.put( "Url", aArticle.GetMainURL() );
aDocInfo.put( "CompleteUrl", aArticle.GetMainURL() + aArticle.GetTitle() ); aDocInfo.put( "CompleteUrl", aArticle.GetMainURL() + aArticle.GetTitle() );
@@ -392,7 +374,7 @@ public final class WikiEditorImpl extends WeakBase
else else
{ {
Helper.ShowError( m_xContext, Helper.ShowError( m_xContext,
(XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ),
Helper.DLG_SENDTITLE, Helper.DLG_SENDTITLE,
Helper.GENERALSEND_ERROR, Helper.GENERALSEND_ERROR,
null, null,
@@ -410,7 +392,7 @@ public final class WikiEditorImpl extends WeakBase
{ {
// report the error only if sending was not cancelled // report the error only if sending was not cancelled
Helper.ShowError( m_xContext, Helper.ShowError( m_xContext,
(XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ),
Helper.DLG_SENDTITLE, Helper.DLG_SENDTITLE,
Helper.UNKNOWNCERT_ERROR, Helper.UNKNOWNCERT_ERROR,
null, null,
@@ -423,7 +405,7 @@ public final class WikiEditorImpl extends WeakBase
{ {
// report the error only if sending was not cancelled // report the error only if sending was not cancelled
Helper.ShowError( m_xContext, Helper.ShowError( m_xContext,
(XWindowPeer)UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ), UnoRuntime.queryInterface( XWindowPeer.class, m_xFrame.getContainerWindow() ),
Helper.DLG_SENDTITLE, Helper.DLG_SENDTITLE,
Helper.GENERALSEND_ERROR, Helper.GENERALSEND_ERROR,
null, null,

View File

@@ -31,7 +31,7 @@ import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.uno.AnyConverter; import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
import java.util.Hashtable; import java.util.Map;
public final class WikiOptionsEventHandlerImpl extends WeakBase public final class WikiOptionsEventHandlerImpl extends WeakBase
implements XServiceInfo, XContainerWindowEventHandler, XDialogEventHandler implements XServiceInfo, XContainerWindowEventHandler, XDialogEventHandler
@@ -65,7 +65,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
if ( m_xControlContainer != null ) if ( m_xControlContainer != null )
{ {
XControl xControl = m_xControlContainer.getControl(sControl); 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; return xListProps;
} }
@@ -128,7 +128,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
XPropertySet xListProps = GetPropSet( "WikiList" ); XPropertySet xListProps = GetPropSet( "WikiList" );
if ( xListProps != null ) if ( xListProps != null )
{ {
Hashtable ht = null; Map<String,String> ht = null;
try try
{ {
short[] pSel = (short []) xListProps.getPropertyValue( "SelectedItems" ); short[] pSel = (short []) xListProps.getPropertyValue( "SelectedItems" );
@@ -136,7 +136,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
if ( pSel.length > 0 && pItems.length > pSel[0] ) if ( pSel.length > 0 && pItems.length > pSel[0] )
{ {
String selName = pItems[pSel[0]]; String selName = pItems[pSel[0]];
ht = m_aSettings.getSettingByUrl( pItems[pSel[0]] ); ht = m_aSettings.getSettingByUrl( selName );
} }
} }
catch ( Exception ex ) catch ( Exception ex )
@@ -178,7 +178,6 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
{ {
try try
{ {
GetPropSet( "FixedLine1" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_MEDIAWIKIEXTENSION_STRING ) ); GetPropSet( "FixedLine1" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_MEDIAWIKIEXTENSION_STRING ) );
GetPropSet( "AddButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_ADDBUTTON ) ); GetPropSet( "AddButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_ADDBUTTON ) );
GetPropSet( "EditButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_EDITBUTTON ) ); GetPropSet( "EditButton" ).setPropertyValue( "Label", Helper.GetLocalizedString( m_xContext, Helper.DLG_EDITBUTTON ) );
@@ -221,7 +220,7 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
{ {
try try
{ {
String sEvent = (String)AnyConverter.toString( aEventObject ); String sEvent = AnyConverter.toString( aEventObject );
if ( sEvent != null ) if ( sEvent != null )
{ {
if ( sEvent.equals( sOk ) ) if ( sEvent.equals( sOk ) )
@@ -233,9 +232,8 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
{ {
if ( sEvent.equals( sInitialize ) ) if ( sEvent.equals( sInitialize ) )
{ {
m_xDialog = (XDialog)UnoRuntime.queryInterface( XDialog.class, xWindow ); m_xDialog = UnoRuntime.queryInterface( XDialog.class, xWindow );
m_xControlContainer = (XControlContainer)UnoRuntime.queryInterface( m_xControlContainer = UnoRuntime.queryInterface( XControlContainer.class, m_xDialog );
XControlContainer.class, m_xDialog );
m_aSettings = Settings.getSettings( m_xContext ); m_aSettings = Settings.getSettings( m_xContext );
m_aSettings.loadConfiguration(); // throw away all the noncommited changes m_aSettings.loadConfiguration(); // throw away all the noncommited changes
InitStrings(); InitStrings();
@@ -277,8 +275,6 @@ public final class WikiOptionsEventHandlerImpl extends WeakBase
public boolean callHandlerMethod( XDialog xDialog, Object aEventObject, String sMethod ) public boolean callHandlerMethod( XDialog xDialog, Object aEventObject, String sMethod )
throws WrappedTargetException, com.sun.star.uno.RuntimeException throws WrappedTargetException, com.sun.star.uno.RuntimeException
{ {
return true; return true;
} }

View File

@@ -18,25 +18,26 @@
package com.sun.star.wiki; package com.sun.star.wiki;
import java.util.Map;
import com.sun.star.awt.XDialog; import com.sun.star.awt.XDialog;
import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySet;
import com.sun.star.lang.EventObject; import com.sun.star.lang.EventObject;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
import java.util.Hashtable;
public class WikiPropDialog extends WikiDialog{ public class WikiPropDialog extends WikiDialog{
WikiEditorImpl m_aWikiEditor; private WikiEditorImpl m_aWikiEditor;
private final String sSendMethod = "Send"; private final String sSendMethod = "Send";
private final String sWikiListMethod = "WikiListChange"; private final String sWikiListMethod = "WikiListChange";
private final String sArticleTextMethod = "ArticleTextChange"; private final String sArticleTextMethod = "ArticleTextChange";
private final String sAddWikiMethod = "AddWiki"; private final String sAddWikiMethod = "AddWiki";
String[] m_pMethods = {sSendMethod, sWikiListMethod, sArticleTextMethod, sAddWikiMethod}; private String[] m_pMethods = {sSendMethod, sWikiListMethod, sArticleTextMethod, sAddWikiMethod};
private String m_sWikiTitle = ""; private String m_sWikiTitle = "";
protected String m_sWikiEngineURL = ""; private String m_sWikiEngineURL = "";
protected String m_sWikiComment = ""; protected String m_sWikiComment = "";
protected boolean m_bWikiMinorEdit = false; protected boolean m_bWikiMinorEdit = false;
@@ -283,7 +284,7 @@ public class WikiPropDialog extends WikiDialog{
SetThrobberActive( true ); SetThrobberActive( true );
// the following method might show a dialog, should be used in main thread // the following method might show a dialog, should be used in main thread
final Hashtable aWikiSettings = m_aSettings.getSettingByUrl( m_sWikiEngineURL ); final Map<String,String> aWikiSettings = m_aSettings.getSettingByUrl( m_sWikiEngineURL );
if ( Helper.AllowThreadUsage( m_xContext ) ) if ( Helper.AllowThreadUsage( m_xContext ) )
{ {
m_aThread = new Thread( "com.sun.star.thread.WikiEditorSendingThread" ) m_aThread = new Thread( "com.sun.star.thread.WikiEditorSendingThread" )