create a new page, using OOoBeanShell/Calc/dividewithspace as a template.
Front page
Search
掲示板
Reload
Help
Browse Log
掲示板の使い方
OOo 掲示板3
OOo 掲示板2
OOo 掲示板
掲示板
雑談掲示板
New
List of pages
Recent changes
Backup
簡単ヘルプ
整形ルール
Start:
*DivideWithSpace [#k89af4c0]
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.frame.XDesktop;
import com.sun.star.frame.XModel;
import drafts.com.sun.star.script.provider.XScriptContext;
import com.sun.star.beans.XPropertySet;
import com.sun.star.beans.PropertyValue;
import com.sun.star.container.XNameContainer;
import com.sun.star.container.XNameAccess;
import com.sun.star.container.XIndexAccess;
import com.sun.star.frame.XController;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.view.XSelectionSupplier;
import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.sheet.XSpreadsheets;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.sheet.XCellRangeAddressable;
import com.sun.star.text.XText;
import com.sun.star.table.XCellRange;
import com.sun.star.table.XCell;
import com.sun.star.sheet.XCellAddressable;
oDoc = XSCRIPTCONTEXT.getDocument();
xSpreadsheetModel = (XModel) UnoRuntime.queryInterface(X...
xController = xSpreadsheetModel.getCurrentController();
xSel = (XSelectionSupplier) UnoRuntime.queryInterface(XS...
Object Selection = xSel.getSelection();
xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(...
String Info = xServiceInfo.getImplementationName();
if (Info.equals("ScCellRangeObj") || Info.equals("ScCell...
xRangeAddr = (XCellRangeAddressable) UnoRuntime.queryIn...
aRangeAddress = xRangeAddr.getRangeAddress();
int nSheet = aRangeAddress.Sheet;
int nRows = aRangeAddress.EndRow - aRangeAddress.StartR...
int nCols = aRangeAddress.EndColumn - aRangeAddress.Sta...
xSelectedRange = (XCellRange) UnoRuntime.queryInterface...
xSheetDoc = (XSpreadsheetDocument) UnoRuntime.queryInte...
xSpreadsheets = xSheetDoc.getSheets();
xSheetIndexAcc = (XIndexAccess) UnoRuntime.queryInterfa...
Object sheet = xSheetIndexAcc.getByIndex(nSheet);
xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface...
for (int i=0; i<=nRows; i++) {
oCell = xSelectedRange.getCellByPosition(0, i);
xCellAddr = (XCellAddressable) UnoRuntime.queryInterfa...
aCellAddr = xCellAddr.getCellAddress();
int nSColumn = aCellAddr.Column;
int nSRow = aCellAddr.Row;
// xCell = (XCell) UnoRuntime.queryInterface(XCell.cla...
xCellText = (XText) UnoRuntime.queryInterface(XText.cl...
sLocString = xCellText.getString();
sPartString = sLocString.split("\\s");
nCell = 0;
for (int j=0; j<sPartString.length; j++) {
if (! sPartString[j].equals("")) {
oPartCell = xSpreadsheet.getCellByPosition(nSColumn ...
xPartCellText = (XText) UnoRuntime.queryInterface(XT...
xPartCellText.setString(sPartString[j]);
nCell++;
}
}
}
}
End:
*DivideWithSpace [#k89af4c0]
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.frame.XDesktop;
import com.sun.star.frame.XModel;
import drafts.com.sun.star.script.provider.XScriptContext;
import com.sun.star.beans.XPropertySet;
import com.sun.star.beans.PropertyValue;
import com.sun.star.container.XNameContainer;
import com.sun.star.container.XNameAccess;
import com.sun.star.container.XIndexAccess;
import com.sun.star.frame.XController;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.view.XSelectionSupplier;
import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.sheet.XSpreadsheets;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.sheet.XCellRangeAddressable;
import com.sun.star.text.XText;
import com.sun.star.table.XCellRange;
import com.sun.star.table.XCell;
import com.sun.star.sheet.XCellAddressable;
oDoc = XSCRIPTCONTEXT.getDocument();
xSpreadsheetModel = (XModel) UnoRuntime.queryInterface(X...
xController = xSpreadsheetModel.getCurrentController();
xSel = (XSelectionSupplier) UnoRuntime.queryInterface(XS...
Object Selection = xSel.getSelection();
xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(...
String Info = xServiceInfo.getImplementationName();
if (Info.equals("ScCellRangeObj") || Info.equals("ScCell...
xRangeAddr = (XCellRangeAddressable) UnoRuntime.queryIn...
aRangeAddress = xRangeAddr.getRangeAddress();
int nSheet = aRangeAddress.Sheet;
int nRows = aRangeAddress.EndRow - aRangeAddress.StartR...
int nCols = aRangeAddress.EndColumn - aRangeAddress.Sta...
xSelectedRange = (XCellRange) UnoRuntime.queryInterface...
xSheetDoc = (XSpreadsheetDocument) UnoRuntime.queryInte...
xSpreadsheets = xSheetDoc.getSheets();
xSheetIndexAcc = (XIndexAccess) UnoRuntime.queryInterfa...
Object sheet = xSheetIndexAcc.getByIndex(nSheet);
xSpreadsheet = (XSpreadsheet) UnoRuntime.queryInterface...
for (int i=0; i<=nRows; i++) {
oCell = xSelectedRange.getCellByPosition(0, i);
xCellAddr = (XCellAddressable) UnoRuntime.queryInterfa...
aCellAddr = xCellAddr.getCellAddress();
int nSColumn = aCellAddr.Column;
int nSRow = aCellAddr.Row;
// xCell = (XCell) UnoRuntime.queryInterface(XCell.cla...
xCellText = (XText) UnoRuntime.queryInterface(XText.cl...
sLocString = xCellText.getString();
sPartString = sLocString.split("\\s");
nCell = 0;
for (int j=0; j<sPartString.length; j++) {
if (! sPartString[j].equals("")) {
oPartCell = xSpreadsheet.getCellByPosition(nSColumn ...
xPartCellText = (XText) UnoRuntime.queryInterface(XT...
xPartCellText.setString(sPartString[j]);
nCell++;
}
}
}
}
Page: