From bb437029c1e5331bcc3f8fb2fc87837142a52f33 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 12 Nov 2014 09:55:57 +0200 Subject: java: convert fields to local variables where possible found by PMD Change-Id: I05b45382b8fb1b734657ce9421a20e6ef6fbe542 Reviewed-on: https://gerrit.libreoffice.org/12376 Tested-by: LibreOffice gerrit bot Reviewed-by: Noel Grandin --- .../DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java | 5 ++--- odk/examples/DevelopersGuide/Database/OpenQuery.java | 5 ++--- .../OfficeDev/DesktopEnvironment/DocumentView.java | 6 ++---- odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java | 10 ++++------ .../ProfUNO/InterprocessConn/ConnectionAwareClient.java | 4 ++-- .../ScriptSelector/ScriptSelector/ScriptSelector.java | 3 +-- odk/examples/DevelopersGuide/Text/TextDocuments.java | 14 +++++--------- 7 files changed, 18 insertions(+), 29 deletions(-) (limited to 'odk/examples') diff --git a/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java b/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java index 30700ed90faf..48108d8b21d1 100644 --- a/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java +++ b/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java @@ -73,9 +73,9 @@ public class ListenAtCalcRangeInDraw implements XChartDataChangeEventListener Helper aHelper = new Helper( args ); maSheetDoc = aHelper.createSpreadsheetDocument(); - maDrawDoc = aHelper.createDrawingDocument(); + XModel aDrawDoc = aHelper.createDrawingDocument(); CalcHelper aCalcHelper = new CalcHelper( maSheetDoc ); - ChartHelper aChartHelper = new ChartHelper( maDrawDoc ); + ChartHelper aChartHelper = new ChartHelper( aDrawDoc ); XCellRange aRange = aCalcHelper.insertFormulaRange( 3, 30 ); @@ -185,7 +185,6 @@ public class ListenAtCalcRangeInDraw implements XChartDataChangeEventListener // __________ private __________ private XSpreadsheetDocument maSheetDoc; - private XModel maDrawDoc; private XChartDocument maChartDocument; private XChartData maChartData; } diff --git a/odk/examples/DevelopersGuide/Database/OpenQuery.java b/odk/examples/DevelopersGuide/Database/OpenQuery.java index 48e291132691..0aa972aaaf6b 100644 --- a/odk/examples/DevelopersGuide/Database/OpenQuery.java +++ b/odk/examples/DevelopersGuide/Database/OpenQuery.java @@ -47,9 +47,6 @@ import com.sun.star.beans.XPropertySet; public class OpenQuery { - private XComponentContext xContext = null; - private XMultiComponentFactory xMCF = null; - /** * @param args the command line arguments */ @@ -67,6 +64,8 @@ public class OpenQuery { } protected void openQuery() throws com.sun.star.uno.Exception, java.lang.Exception { + XComponentContext xContext = null; + XMultiComponentFactory xMCF = null; try { // get the remote office component context xContext = com.sun.star.comp.helper.Bootstrap.bootstrap(); diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java index 407cfa4f0052..2a3bad305c94 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java +++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java @@ -101,10 +101,8 @@ public class DocumentView extends JFrame private String msName ; - private JButton mbtOpen ; private JButton mbtSave ; private JButton mbtExport ; - private JButton mbtExit ; private boolean mbDead ; @@ -122,10 +120,10 @@ public class DocumentView extends JFrame // create and add command buttons to a panel // it will be a sub panel of later layouted UI - mbtOpen = new JButton("Open ..." ); + JButton mbtOpen = new JButton("Open ..." ); mbtSave = new JButton("Save" ); mbtExport = new JButton("Save as HTML ..."); - mbtExit = new JButton("Exit" ); + JButton mbtExit = new JButton("Exit" ); mbtOpen.setEnabled (true ); mbtSave.setEnabled (false); diff --git a/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java b/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java index f6a8f8c035d8..4a406a0305a5 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java @@ -184,14 +184,14 @@ public class Number_Formats { // get the remote office context. If necessary a new office // process is started - maOfficeContext = com.sun.star.comp.helper.Bootstrap.bootstrap(); + XComponentContext aOfficeContext = com.sun.star.comp.helper.Bootstrap.bootstrap(); System.out.println("Connected to a running office ..."); - maServiceManager = maOfficeContext.getServiceManager(); + XMultiComponentFactory aServiceManager = aOfficeContext.getServiceManager(); // create a new spreadsheet document XComponentLoader aLoader = UnoRuntime.queryInterface( - XComponentLoader.class, maServiceManager.createInstanceWithContext( - "com.sun.star.frame.Desktop", maOfficeContext) ); + XComponentLoader.class, aServiceManager.createInstanceWithContext( + "com.sun.star.frame.Desktop", aOfficeContext) ); maSpreadsheetDoc = UnoRuntime.queryInterface( XSpreadsheetDocument.class, @@ -207,8 +207,6 @@ public class Number_Formats // __________ private members and methods __________ - private XComponentContext maOfficeContext; - private XMultiComponentFactory maServiceManager; private XSpreadsheetDocument maSpreadsheetDoc; private XSpreadsheet maSheet; // the first sheet diff --git a/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java index 2a1d3836517f..35b15635fbf6 100644 --- a/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java +++ b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java @@ -53,7 +53,7 @@ import com.sun.star.bridge.XBridge; public class ConnectionAwareClient extends java.awt.Frame implements ActionListener , com.sun.star.lang.XEventListener { - private Button _btnWriter,_btnCalc; + private Button _btnWriter; private Label _txtLabel; private String _url; @@ -68,7 +68,7 @@ public class ConnectionAwareClient extends java.awt.Frame Panel p1 = new Panel(); _btnWriter = new Button("New writer"); - _btnCalc = new Button("New calc"); + Button _btnCalc = new Button("New calc"); _txtLabel = new Label( "disconnected" ); _btnWriter.addActionListener(this); diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java index a68ba22bcb4b..b117d7f35c86 100644 --- a/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java +++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java @@ -199,7 +199,6 @@ class ScriptSelectorPanel extends JPanel { private XBrowseNode myrootnode = null; public JTextField textField; public JTree tree; - private DefaultTreeModel treeModel; public ScriptSelectorPanel(XBrowseNode root) { @@ -229,7 +228,7 @@ class ScriptSelectorPanel extends JPanel { } }; initNodes(myrootnode, top); - treeModel = new DefaultTreeModel(top); + DefaultTreeModel treeModel = new DefaultTreeModel(top); tree = new JTree(treeModel); tree.setCellRenderer(new ScriptTreeRenderer()); diff --git a/odk/examples/DevelopersGuide/Text/TextDocuments.java b/odk/examples/DevelopersGuide/Text/TextDocuments.java index de5b7c2093cb..d1d09442e6ab 100644 --- a/odk/examples/DevelopersGuide/Text/TextDocuments.java +++ b/odk/examples/DevelopersGuide/Text/TextDocuments.java @@ -117,7 +117,6 @@ public class TextDocuments { private XTextDocument mxDoc = null; private XMultiServiceFactory mxDocFactory = null; private XMultiServiceFactory mxFactory = null; - private XPropertySet mxDocProps = null; private XText mxDocText = null; private XTextCursor mxDocCursor = null; private XTextContent mxFishSection = null; @@ -127,18 +126,16 @@ public class TextDocuments { * @param args the command line arguments */ public static void main(String[] args) { - TextDocuments textDocuments1 = new TextDocuments(); - try { + TextDocuments textDocuments1 = new TextDocuments(); + try { // output directory for store test; sOutputDir = args[0]; textDocuments1.runDemo(); - } - catch (java.lang.Exception e){ + } catch (java.lang.Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); - } - finally { + } finally { System.exit(0); } } @@ -291,8 +288,7 @@ public class TextDocuments { // Get a reference to the document's property set. This contains document // information like the current word count - mxDocProps = UnoRuntime.queryInterface( - XPropertySet.class, mxDoc ); + UnoRuntime.queryInterface(XPropertySet.class, mxDoc ); // Simple text insertion example BodyTextExample (); -- cgit