/// <summary> /// XSelectionChangeListener call back function. DON'T USE THIS. /// </summary> /// <param name="aEvent">A event.</param> void selectionChanged(unoidl.com.sun.star.lang.EventObject aEvent) { //FIXME: make this dead return; //if (aEvent.Source != null) //{ // System.Diagnostics.Debug.WriteLine("################ SELECTION CHANGE"); // try // { // if (aEvent.Source is XSelectionSupplier) // { // TimeLimitExecutor.ExecuteWithTimeLimit(2000, () => // { // XSelectionSupplier sSupl = aEvent.Source as XSelectionSupplier; // fireSelectionChangedEvent(sSupl, aEvent.Source); // }, "SelectionChendeEventHanlder"); // } // } // catch (Exception e) // { // Logger.Instance.Log(LogPriority.DEBUG, this, "Exception in XSelectionChangeListener.selectionChanged\r\n" + e); // } //} }
/** Creates a unoidl.com.sun.star.table.CellRangeAddress and initializes it with the given range. @param xSheet The XSpreadsheet interface of the spreadsheet. @param aRange The address of the cell range (or a named range). */ public unoidl.com.sun.star.table.CellRangeAddress createCellRangeAddress( unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aRange ) { unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr = (unoidl.com.sun.star.sheet.XCellRangeAddressable) xSheet.getCellRangeByName( aRange ); return xAddr.getRangeAddress(); }
// ________________________________________________________________ // Methods to create cell addresses and range addresses. /** Creates a unoidl.com.sun.star.table.CellAddress and initializes it with the given range. @param xSheet The XSpreadsheet interface of the spreadsheet. @param aCell The address of the cell (or a named cell). */ public unoidl.com.sun.star.table.CellAddress createCellAddress( unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aCell ) { unoidl.com.sun.star.sheet.XCellAddressable xAddr = (unoidl.com.sun.star.sheet.XCellAddressable) xSheet.getCellRangeByName( aCell ).getCellByPosition( 0, 0 ); return xAddr.getCellAddress(); }
void fireWindowMinimizedEvent(unoidl.com.sun.star.lang.EventObject Source) { if (WindowMinimized != null) { try { WindowMinimized.Invoke(this, new EventObjectForwarder(Source)); } catch { } } }
void fireSelectionEvent(unoidl.com.sun.star.lang.EventObject aEvents) { if (SelectionChanged != null) { try { SelectionChanged.Invoke(this, new EventObjectForwarder(aEvents)); } catch { } } }
void fireWindowHiddenEvent(unoidl.com.sun.star.lang.EventObject e) { if (WindowHidden != null) { try { WindowHidden.Invoke(this, new EventObjectForwarder(e)); } catch { } } }
/// <summary> /// Get the Desktop /// </summary> /// <param name="multiservicefactory">A multi service factory</param> /// <returns>Desktop object</returns> public static unoidl.com.sun.star.frame.XDesktop GetDesktop( unoidl.com.sun.star.lang.XMultiServiceFactory multiservicefactory) { try { return (unoidl.com.sun.star.frame.XDesktop)multiservicefactory.createInstance("com.sun.star.frame.Desktop"); } catch(System.Exception ex) { throw; } }
/// <summary> /// Get the MultiServiceFactory /// </summary> /// <param name="componentcontext">A component context</param> /// <returns>MultiServiceFactory object</returns> public static unoidl.com.sun.star.lang.XMultiServiceFactory GetMultiServiceFactory( unoidl.com.sun.star.uno.XComponentContext componentcontext) { try { return (unoidl.com.sun.star.lang.XMultiServiceFactory)componentcontext.getServiceManager(); } catch(System.Exception ex) { throw; } }
public OoEventArgs(unoidl.com.sun.star.lang.EventObject e) { if (e.Source != null) { if (e.Source is uno.Any) { Source = ((uno.Any)e.Source).Value; return; } } Source = e.Source; }
public object createInstanceWithArgumentsAndContext( string ServiceSpecifier, uno.Any[] Arguments, unoidl.com.sun.star.uno.XComponentContext Context) { switch (kind2) { case test_kind.NORMAL: return new Component(Context, Arguments); case test_kind.CREATION_FAILED : return null; case test_kind.TEST_EXCEPTION: throw exception; default: throw new Exception("Factory not properly initialized"); } }
public static XLayer getActiveLayer(unoidl.com.sun.star.frame.XModel xModel) { if (xModel != null) { try { return getActiveLayer(xModel.getCurrentController()); } catch (unoidl.com.sun.star.uno.Exception e) { System.Diagnostics.Debug.WriteLine("Error while getting active layer:\n" + e); } } //Debug.GetAllProperties(bActiveLayer); return null; }
/// <summary> /// Load a given file or create a new blank file /// </summary> /// <param name="aLoader">A ComponentLoader</param> /// <param name="file">The file</param> /// <param name="target">The target frame name</param> /// <returns>The Component object</returns> public static unoidl.com.sun.star.lang.XComponent LoadDocument( unoidl.com.sun.star.frame.XComponentLoader aLoader, string file, string target ) { try { XComponent xComponent = aLoader.loadComponentFromURL( file, target, 0, new unoidl.com.sun.star.beans.PropertyValue[0] ); return xComponent; } catch(System.Exception ex) { throw; } }
/** Draws a colored border around the range and writes the headline in the first cell. @param xSheet The XSpreadsheet interface of the spreadsheet. @param aRange The address of the cell range (or a named range). @param aHeadline The headline text. */ public void prepareRange( unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aRange, String aHeadline ) { unoidl.com.sun.star.beans.XPropertySet xPropSet = null; unoidl.com.sun.star.table.XCellRange xCellRange = null; // draw border xCellRange = xSheet.getCellRangeByName( aRange ); xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange; unoidl.com.sun.star.table.BorderLine aLine = new unoidl.com.sun.star.table.BorderLine(); aLine.Color = 0x99CCFF; aLine.InnerLineWidth = aLine.LineDistance = 0; aLine.OuterLineWidth = 100; unoidl.com.sun.star.table.TableBorder aBorder = new unoidl.com.sun.star.table.TableBorder(); aBorder.TopLine = aBorder.BottomLine = aBorder.LeftLine = aBorder.RightLine = aLine; aBorder.IsTopLineValid = aBorder.IsBottomLineValid = true; aBorder.IsLeftLineValid = aBorder.IsRightLineValid = true; xPropSet.setPropertyValue( "TableBorder", new uno.Any( typeof (unoidl.com.sun.star.table.TableBorder), aBorder ) ); // draw headline unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr = (unoidl.com.sun.star.sheet.XCellRangeAddressable) xCellRange; unoidl.com.sun.star.table.CellRangeAddress aAddr = xAddr.getRangeAddress(); xCellRange = xSheet.getCellRangeByPosition( aAddr.StartColumn, aAddr.StartRow, aAddr.EndColumn, aAddr.StartRow ); xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange; xPropSet.setPropertyValue( "CellBackColor", new uno.Any( (Int32) 0x99CCFF ) ); // write headline unoidl.com.sun.star.table.XCell xCell = xCellRange.getCellByPosition( 0, 0 ); xCell.setFormula( aHeadline ); xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCell; xPropSet.setPropertyValue( "CharColor", new uno.Any( (Int32) 0x003399 ) ); xPropSet.setPropertyValue( "CharWeight", new uno.Any( (Single) unoidl.com.sun.star.awt.FontWeight.BOLD ) ); }
/** Returns the text address of the cell range. @param xCellRange The XSheetCellRange interface of the cell range. @param bWithSheet true = Include sheet name. @return A string containing the cell range address. */ public String getCellRangeAddressString( unoidl.com.sun.star.sheet.XSheetCellRange xCellRange, bool bWithSheet ) { String aStr = ""; if (bWithSheet) { unoidl.com.sun.star.sheet.XSpreadsheet xSheet = xCellRange.getSpreadsheet(); unoidl.com.sun.star.container.XNamed xNamed = (unoidl.com.sun.star.container.XNamed) xSheet; aStr += xNamed.getName() + "."; } unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr = (unoidl.com.sun.star.sheet.XCellRangeAddressable) xCellRange; aStr += getCellRangeAddressString( xAddr.getRangeAddress() ); return aStr; }
/** Returns a list of addresses of all cell ranges contained in the collection. @param xRangesIA The XIndexAccess interface of the collection. @return A string containing the cell range address list. */ public String getCellRangeListString( unoidl.com.sun.star.container.XIndexAccess xRangesIA ) { String aStr = ""; int nCount = xRangesIA.getCount(); for (int nIndex = 0; nIndex < nCount; ++nIndex) { if (nIndex > 0) aStr += " "; uno.Any aRangeObj = xRangesIA.getByIndex( nIndex ); unoidl.com.sun.star.sheet.XSheetCellRange xCellRange = (unoidl.com.sun.star.sheet.XSheetCellRange) aRangeObj.Value; aStr += getCellRangeAddressString( xCellRange, false ); } return aStr; }
/** Returns the text address of the cell range. @param aCellRange The cell range address. @return A string containing the cell range address. */ public String getCellRangeAddressString( unoidl.com.sun.star.table.CellRangeAddress aCellRange ) { return getCellAddressString( aCellRange.StartColumn, aCellRange.StartRow ) + ":" + getCellAddressString( aCellRange.EndColumn, aCellRange.EndRow ); }
/** Writes a date with standard date format into a spreadsheet. @param xSheet The XSpreadsheet interface of the spreadsheet. @param aCellName The address of the cell (or a named range). @param nDay The day of the date. @param nMonth The month of the date. @param nYear The year of the date. */ public void setDate( unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aCellName, int nDay, int nMonth, int nYear ) { // Set the date value. unoidl.com.sun.star.table.XCell xCell = xSheet.getCellRangeByName( aCellName ).getCellByPosition( 0, 0 ); String aDateStr = nMonth + "/" + nDay + "/" + nYear; xCell.setFormula( aDateStr ); // Set standard date format. unoidl.com.sun.star.util.XNumberFormatsSupplier xFormatsSupplier = (unoidl.com.sun.star.util.XNumberFormatsSupplier) getDocument(); unoidl.com.sun.star.util.XNumberFormatTypes xFormatTypes = (unoidl.com.sun.star.util.XNumberFormatTypes) xFormatsSupplier.getNumberFormats(); int nFormat = xFormatTypes.getStandardFormat( unoidl.com.sun.star.util.NumberFormat.DATE, new unoidl.com.sun.star.lang.Locale() ); unoidl.com.sun.star.beans.XPropertySet xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCell; xPropSet.setPropertyValue( "NumberFormat", new uno.Any( (Int32) nFormat ) ); }
/** Activates a scenario. @param xSheet The XSpreadsheet interface of the spreadsheet. @param aScenarioName The name of the scenario. */ private void showScenario( unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aScenarioName ) { // get the scenario set unoidl.com.sun.star.sheet.XScenariosSupplier xScenSupp = (unoidl.com.sun.star.sheet.XScenariosSupplier) xSheet; unoidl.com.sun.star.sheet.XScenarios xScenarios = xScenSupp.getScenarios(); // get the scenario and activate it uno.Any aScenarioObj = xScenarios.getByName( aScenarioName ); unoidl.com.sun.star.sheet.XScenario xScenario = (unoidl.com.sun.star.sheet.XScenario) aScenarioObj.Value; xScenario.apply(); }
/** Inserts a cell range address into a cell range container and prints a message. @param xContainer unoidl.com.sun.star.sheet.XSheetCellRangeContainer interface of the container. @param nSheet Index of sheet of the range. @param nStartCol Index of first column of the range. @param nStartRow Index of first row of the range. @param nEndCol Index of last column of the range. @param nEndRow Index of last row of the range. @param bMerge Determines whether the new range should be merged with the existing ranges. */ private void insertRange( unoidl.com.sun.star.sheet.XSheetCellRangeContainer xContainer, int nSheet, int nStartCol, int nStartRow, int nEndCol, int nEndRow, bool bMerge ) { unoidl.com.sun.star.table.CellRangeAddress aAddress = new unoidl.com.sun.star.table.CellRangeAddress(); aAddress.Sheet = (short)nSheet; aAddress.StartColumn = nStartCol; aAddress.StartRow = nStartRow; aAddress.EndColumn = nEndCol; aAddress.EndRow = nEndRow; xContainer.addRangeAddress( aAddress, bMerge ); Console.WriteLine( "Inserting " + getCellRangeAddressString( aAddress ) + " " + (bMerge ? " with" : "without") + " merge," + " resulting list: " + xContainer.getRangeAddressesAsString() ); }
// Methods to fill values into cells. /** Writes a double value into a spreadsheet. @param xSheet The XSpreadsheet interface of the spreadsheet. @param aCellName The address of the cell (or a named range). @param fValue The value to write into the cell. */ public void setValue( unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aCellName, double fValue ) { xSheet.getCellRangeByName( aCellName ).getCellByPosition( 0, 0 ).setValue( fValue ); }
/** Writes a formula into a spreadsheet. @param xSheet The XSpreadsheet interface of the spreadsheet. @param aCellName The address of the cell (or a named range). @param aFormula The formula to write into the cell. */ public void setFormula( unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aCellName, String aFormula ) { xSheet.getCellRangeByName( aCellName ).getCellByPosition( 0, 0 ).setFormula( aFormula ); }
/// <summary> /// Gets the registered shape observer. /// </summary> /// <param name="comp">The comp.</param> /// <returns></returns> internal OoShapeObserver GetRegisteredShapeObserver(unoidl.com.sun.star.accessibility.XAccessibleComponent comp) { return GetRegisteredShapeObserver(comp as unoidl.com.sun.star.accessibility.XAccessibleContext); }
public void windowShown(unoidl.com.sun.star.lang.EventObject e) { Thread thread = new Thread(delegate() { fireWindowShownEvent(e); }); thread.Start(); }
//happens on child adding, deleting, title changing, name changing // the draw page supplier will be returned not the modified object :-( protected override void modified(unoidl.com.sun.star.lang.EventObject aEvent) { if (aEvent != null && aEvent.Source == PagesSupplier) { //System.Diagnostics.Debug.WriteLine("\t\tModify event happened in DrawPageObserver"); } }
/** Returns the XCellSeries interface of a cell range. @param xSheet The spreadsheet containing the cell range. @param aRange The address of the cell range. @return The XCellSeries interface. */ private unoidl.com.sun.star.sheet.XCellSeries getCellSeries( unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aRange ) { return (unoidl.com.sun.star.sheet.XCellSeries) xSheet.getCellRangeByName( aRange ); }
public void aborted( unoidl.com.sun.star.sheet.RangeSelectionEvent aEvent ) { Monitor.Enter( this ); try { Monitor.Pulse( this ); } finally { Monitor.Exit( this ); } }
/** Inserts a scenario containing one cell range into a sheet and applies the value array. @param xSheet The XSpreadsheet interface of the spreadsheet. @param aRange The range address for the scenario. @param aValueArray The array of cell contents. @param aScenarioName The name of the new scenario. @param aScenarioComment The user comment for the scenario. */ private void insertScenario( unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aRange, uno.Any [][] aValueArray, String aScenarioName, String aScenarioComment ) { // get the cell range with the given address unoidl.com.sun.star.table.XCellRange xCellRange = xSheet.getCellRangeByName( aRange ); // create the range address sequence unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr = (unoidl.com.sun.star.sheet.XCellRangeAddressable) xCellRange; unoidl.com.sun.star.table.CellRangeAddress[] aRangesSeq = new unoidl.com.sun.star.table.CellRangeAddress[1]; aRangesSeq[0] = xAddr.getRangeAddress(); // create the scenario unoidl.com.sun.star.sheet.XScenariosSupplier xScenSupp = (unoidl.com.sun.star.sheet.XScenariosSupplier) xSheet; unoidl.com.sun.star.sheet.XScenarios xScenarios = xScenSupp.getScenarios(); xScenarios.addNewByName( aScenarioName, aRangesSeq, aScenarioComment ); // insert the values into the range unoidl.com.sun.star.sheet.XCellRangeData xData = (unoidl.com.sun.star.sheet.XCellRangeData) xCellRange; xData.setDataArray( aValueArray ); }
public void disposing( unoidl.com.sun.star.lang.EventObject aObj ) { }
public static String homogenMatrix3ToString(unoidl.com.sun.star.drawing.HomogenMatrix3 matrix, bool singeLine=true) { return "[" + matrix.Line1.Column1.ToString() + ", " + matrix.Line1.Column2.ToString() + ", " + matrix.Line1.Column2.ToString() + "]" + (singeLine ? String.Empty : "\r\n") + "[" + matrix.Line2.Column1.ToString() + ", " + matrix.Line2.Column2.ToString() + ", " + matrix.Line2.Column2.ToString() + "]" + (singeLine ? String.Empty : "\r\n") + "[" + matrix.Line3.Column1.ToString() + ", " + matrix.Line3.Column2.ToString() + ", " + matrix.Line3.Column2.ToString() + "]"; }
public void done( unoidl.com.sun.star.sheet.RangeSelectionEvent aEvent ) { aResult = aEvent.RangeDescriptor; Monitor.Enter( this ); try { Monitor.Pulse( this ); } finally { Monitor.Exit( this ); } }