https://bugs.freedesktop.org/show_bug.cgi?id=56288

          Priority: medium
            Bug ID: 56288
          Assignee: [email protected]
           Summary: typed interface to API
          Severity: enhancement
    Classification: Unclassified
                OS: All
          Reporter: [email protected]
          Hardware: Other
            Status: UNCONFIRMED
           Version: unspecified
         Component: sdk
           Product: LibreOffice

The API is very hard getting used to - a lot of googling, digging, failing.

Why aren't there simple methods like this:

ctx.getActiveDocumentAsSpreadSheet().saveTo/As(..)

This way there might be a chance to implement your idea without even browing
api.libreoffice.org ..
You could use code completion of Java/Scala etc.

All sample code would be a lot more readable.

It took me a couple of hours to ask open office by Java UNO API access whether
a cell is merged - and I failed finding out how many cells got merged.

I'll finally solve my problem by exporting to .html and parsing that.

This is my attempt to get the range of a merged cell - and I failed.
It requires about 10 lines to access the current active sheet - which is way
too much for my personal taste - given that most actions either create a new
document or operate on the current document.


object XHelper {

  def qI[T](b: Object)(implicit m: Manifest[T]): T = {
    UnoRuntime.queryInterface(m.erasure, b).asInstanceOf[T]
  }

//    def qI[T:ClassManifest](b:Object):T = {
//       UnoRuntime.queryInterface(classManifest[T].erasure, b).asInstanceOf[T]
//    }

  // implicit def toXDesktop(o: Object): XDesktop = qI(o)
  implicit def toXDesktop(o: Object): XDesktop = qI[XDesktop](o)
  implicit def toXSpreadsheetDocument(o: Object): XSpreadsheetDocument =
qI[XSpreadsheetDocument](o)
  implicit def toXComponent(o: Object): XComponent = qI[XComponent](o)
}

object Main {


  def main(args: Array[String]): Unit = {
    import XHelper._
    // get the remote office component context
    val xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
    val xMCF: XMultiComponentFactory = xContext.getServiceManager();
    val o:Object = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
xContext)
    val xDesktop: XDesktop = o
    val xSS: XSpreadsheetDocument = xDesktop.getCurrentComponent()
    val xDocModel: XModel = qI[XModel](xSS)
    val xSSModel : XModel =  qI[XModel](xDocModel)
    val xSSController : XController = xSSModel.getCurrentController()
    val xSSView : XSpreadsheetView = qI[XSpreadsheetView](xSSController)

    val as = xSSView.getActiveSheet()
    print(as.getCellByPosition(1,1).getFormula())

    val xSCR : XSheetCellRange = qI[XSheetCellRange](as)

    val xCursor: XSheetCellCursor = as.createCursorByRange(xSCR)
    xCursor.collapseToMergedArea()

    val cra = qI[XCellRangeAddressable](xCursor).getRangeAddress()

    println(cra.EndRow + " " + cra.StartRow)
    println(cra.EndColumn + " " + cra.StartColumn)

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to