コード例 #1
0
ファイル: test.py プロジェクト: hanya/pyuno3
 def test_createUnoStruct(self):
     from com.sun.star.awt import Rectangle
     rect1 = uno.createUnoStruct("com.sun.star.awt.Rectangle")
     self.assertTrue(isinstance(rect1, Rectangle))
     rect2 = uno.createUnoStruct("com.sun.star.awt.Rectangle", 100, 200, 50, 1)
     self.assertEqual(rect2.X, 100)
     rect3 = uno.createUnoStruct("com.sun.star.awt.Rectangle", rect2)
コード例 #2
0
    def store(self, xMSF, xComponent, StorePath, FilterName):
        try:
            if len(FilterName):
                oStoreProperties = list(range(2))
                oStoreProperties[0] = uno.createUnoStruct(
                    'com.sun.star.beans.PropertyValue')
                oStoreProperties[0].Name = "FilterName"
                oStoreProperties[0].Value = FilterName
                oStoreProperties[1] = uno.createUnoStruct(
                    'com.sun.star.beans.PropertyValue')
                oStoreProperties[1].Name = "InteractionHandler"
                oStoreProperties[1].Value = xMSF.createInstance(
                    "com.sun.star.comp.uui.UUIInteractionHandler")
            else:
                oStoreProperties = list(range(0))

            StorePath = systemPathToFileUrl(StorePath)
            sPath = StorePath[:(StorePath.rfind("/") + 1)]
            sFile = StorePath[(StorePath.rfind("/") + 1):]
            xComponent.storeToURL(absolutize(sPath, sFile),
                                  tuple(oStoreProperties))
            return True
        except ErrorCodeIOException:
            #Throw this exception when trying to save a file
            #which is already opened in Libreoffice
            #TODO: handle it properly
            return True
            pass
        except Exception:
            traceback.print_exc()
            return False
コード例 #3
0
def conditional_format():
    ctx = XSCRIPTCONTEXT.getComponentContext()
    serviceManager = ctx.ServiceManager
    desktop = XSCRIPTCONTEXT.getDesktop()
    doc = desktop.getCurrentComponent()
    sheets = doc.getSheets() #XSpreadSheets
    sheet = sheets.getByIndex(0)

    ### Aquí empieza el ejercicio de traducción del ejemplo de formateado condicional

    xCellRange = sheet.getCellRangeByName("A1:B10");
    xEntries = xCellRange.getPropertyValue("ConditionalFormat");

    cond1 = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
    cond2 = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
    cond3 = uno.createUnoStruct("com.sun.star.beans.PropertyValue")

    cond1.Name = "Operator";
    cond1.Value = uno.getConstantByName("com.sun.star.sheet.ConditionOperator.GREATER")
    cond2.Name = "Formula"
    cond2.Value = "1"
    cond3.Name = "StyleName"
    cond3.Value = "Heading"
    xEntries.addNew((cond1, cond2, cond3))
    xCellRange.setPropertyValue("ConditionalFormat", xEntries); 
コード例 #4
0
 def __init__(self, ctx, manager, parent, tables, enabled, message):
     self._ctx = ctx
     self._window = getContainerWindow(ctx, parent, None, g_extension, 'MergerPage2')
     rectangle = uno.createUnoStruct('com.sun.star.awt.Rectangle', 0, 5, 285, 195)
     tab1, tab2 = self._getTabPages(manager, 'Tab1', rectangle, 1)
     parent = tab1.getPeer()
     handler = Tab1Handler(manager)
     self._tab1 = getContainerWindow(ctx, parent, handler, g_extension, 'MergerTab1')
     self._tab1.setVisible(True)
     parent = tab2.getPeer()
     handler = Tab2Handler(manager)
     self._tab2 = getContainerWindow(ctx, parent, handler, g_extension, 'MergerTab2')
     self._tab2.setVisible(True)
     rectangle = uno.createUnoStruct('com.sun.star.awt.Rectangle', 4, 25, 275, 130)
     data, column = manager.getGridModel(1, rectangle.Width, 2)
     grid = self._createGrid(self._tab1, data, column, 'Grid1', rectangle)
     handler = Grid1Handler(manager)
     grid.addSelectionListener(handler)
     data, column = manager.getGridModel(2, rectangle.Width, 2)
     grid = self._createGrid(self._tab2, data, column, 'Grid1', rectangle)
     handler = Grid2Handler(manager)
     grid.addSelectionListener(handler)
     self._initTables(tables, enabled)
     self.setMessage(message)
     #self._getTable().Model.StringItemList = tables
     print("MergerView.__init__()")
コード例 #5
0
    def loadAsPreview(self, sDefaultTemplate, asTemplate):
        loadValues = list(range(3))
        #      open document in the Preview mode
        loadValues[0] = uno.createUnoStruct(
            'com.sun.star.beans.PropertyValue')
        loadValues[0].Name = "ReadOnly"
        loadValues[0].Value = True
        loadValues[1] = uno.createUnoStruct(
            'com.sun.star.beans.PropertyValue')
        loadValues[1].Name = "AsTemplate"
        if asTemplate:
            loadValues[1].Value = True
        else:
            loadValues[1].Value = False

        loadValues[2] = uno.createUnoStruct(
            'com.sun.star.beans.PropertyValue')
        loadValues[2].Name = "Preview"
        loadValues[2].Value = True

        self.xTextDocument = OfficeDocument.load(
            self.xFrame, sDefaultTemplate, "_self", loadValues)

        self.DocSize = self.getPageSize()

        try:
            self.xTextDocument.CurrentController.ViewSettings.ZoomType = ENTIRE_PAGE
        except Exception:
            traceback.print_exc()
        myFieldHandler = TextFieldHandler(self.xMSF, self.xTextDocument)
        myFieldHandler.updateDocInfoFields()
        return self.xTextDocument
コード例 #6
0
ファイル: core.py プロジェクト: Flatta/LibreOffice-core
      def setUp(self):
         # the testcomponent from the testtools project
         self.tobj = self.ctx.ServiceManager.createInstanceWithContext( 
                                'com.sun.star.test.bridge.CppTestObject' , self.ctx )

         self.tobj.Bool = 1
         self.tobj.Char = 'h'
         self.tobj.Byte = 43
         self.tobj.Short = -42
         self.tobj.UShort = 44
         self.tobj.Long = 42
         self.tobj.ULong = 41
         self.tobj.Hyper = 46
         self.tobj.UHyper = 47
         self.tobj.Float  = 4.3
         self.tobj.Double = 4.2
         self.tobj.Enum = 4
         self.tobj.String = "yabadabadoo"
         self.tobj.Interface = self.ctx
         self.tobj.Any = self.tobj.String
         mystruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData" )
         assign( mystruct, 1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo")
         self.tobj.Struct = mystruct

         self.testElement = uno.createUnoStruct( "test.testtools.bridgetest.TestElement" )
         self.testElement.String = "foo"
         self.testElement2 = uno.createUnoStruct( "test.testtools.bridgetest.TestElement" )
         self.testElement2.String = "42"
         self.tobj.Sequence = (self.testElement,self.testElement2)
コード例 #7
0
    def createNewDocument(self, frame, sDocumentType, preview, readonly):
        loadValues = list(range(2))
        loadValues[0] = uno.createUnoStruct(
            'com.sun.star.beans.PropertyValue')
        loadValues[0].Name = "ReadOnly"
        if readonly:
            loadValues[0].Value = True
        else:
            loadValues[0].Value = False

        loadValues[1] = uno.createUnoStruct(
            'com.sun.star.beans.PropertyValue')
        loadValues[1].Name = "Preview"
        if preview:
            loadValues[1].Value = True
        else:
            loadValues[1].Value = False
        sURL = "private:factory/" + sDocumentType
        xComponent = None
        try:
            xComponent = frame.loadComponentFromURL(
                sURL, "_self", 0, tuple(loadValues))

        except Exception:
            traceback.print_exc()

        return xComponent
コード例 #8
0
    def createNewDocument(self, frame, sDocumentType, preview, readonly):
        loadValues = list(range(2))
        loadValues[0] = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
        loadValues[0].Name = "ReadOnly"
        if readonly:
            loadValues[0].Value = True
        else:
            loadValues[0].Value = False

        loadValues[1] = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
        loadValues[1].Name = "Preview"
        if preview:
            loadValues[1].Value = True
        else:
            loadValues[1].Value = False
        sURL = "private:factory/" + sDocumentType
        xComponent = None
        try:
            xComponent = frame.loadComponentFromURL(systemPathToFileUrl(sURL),
                                                    "_self", 0,
                                                    tuple(loadValues))

        except Exception:
            traceback.print_exc()

        return xComponent
コード例 #9
0
ファイル: core.py プロジェクト: Echo360/LibreOffice-core
      def setUp(self):
         # the testcomponent from the testtools project
         self.tobj = self.ctx.ServiceManager.createInstanceWithContext( 
                                'com.sun.star.test.bridge.CppTestObject' , self.ctx )

         self.tobj.Bool = 1
         self.tobj.Char = 'h'
         self.tobj.Byte = 43
         self.tobj.Short = -42
         self.tobj.UShort = 44
         self.tobj.Long = 42
         self.tobj.ULong = 41
         self.tobj.Hyper = 46
         self.tobj.UHyper = 47
         self.tobj.Float  = 4.3
         self.tobj.Double = 4.2
         self.tobj.Enum = 4
         self.tobj.String = "yabadabadoo"
         self.tobj.Interface = self.ctx
         self.tobj.Any = self.tobj.String
         mystruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData" )
         assign( mystruct, 1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo")
         self.tobj.Struct = mystruct

         self.testElement = uno.createUnoStruct( "test.testtools.bridgetest.TestElement" )
         self.testElement.String = "foo"
         self.testElement2 = uno.createUnoStruct( "test.testtools.bridgetest.TestElement" )
         self.testElement2.String = "42"
         self.tobj.Sequence = (self.testElement,self.testElement2)
コード例 #10
0
ファイル: OfficeDocument.py プロジェクト: rohanKanojia/core
    def store(self, xMSF, xComponent, StorePath, FilterName):
        try:
            if len(FilterName):
                oStoreProperties = list(range(2))
                oStoreProperties[0] = uno.createUnoStruct(
                    'com.sun.star.beans.PropertyValue')
                oStoreProperties[0].Name = "FilterName"
                oStoreProperties[0].Value = FilterName
                oStoreProperties[1] = uno.createUnoStruct(
                    'com.sun.star.beans.PropertyValue')
                oStoreProperties[1].Name = "InteractionHandler"
                oStoreProperties[1].Value = xMSF.createInstance(
                    "com.sun.star.comp.uui.UUIInteractionHandler")
            else:
                oStoreProperties = list(range(0))

            StorePath = systemPathToFileUrl(StorePath)
            sPath = StorePath[:(StorePath.rfind("/") + 1)]
            sFile = StorePath[(StorePath.rfind("/") + 1):]
            xComponent.storeToURL(
                absolutize(sPath, sFile), tuple(oStoreProperties))
            return True
        except ErrorCodeIOException:
            #Throw this exception when trying to save a file
            #which is already opened in Libreoffice
            #TODO: handle it properly
            return True
            pass
        except Exception:
            traceback.print_exc()
            return False
コード例 #11
0
ファイル: wizard.py プロジェクト: prrvchr/DropboxOOo
 def __init__(self, ctx, auto=-1, resize=False, parent=None):
     print("Wizard.__init__() 1")
     self.ctx = ctx
     self._auto = auto
     self._resize = resize
     self._spacer = 5
     self._pages = {}
     self._paths = ()
     self._currentPage = -1
     self._currentPath = -1
     self._firstPage = -1
     self._lastPage = -1
     self._multiPaths = False
     self._controller = None
     self._helpUrl = ''
     print("Wizard.__init__() 2")
     self._stringResource = getStringResource(self.ctx, g_identifier,
                                              g_extension)
     print("Wizard.__init__() 3")
     #self._dialog = getDialog(self.ctx, g_extension, 'Wizard')
     self._dialog = getDialog(self.ctx, g_extension, 'Wizard', self, parent)
     point = uno.createUnoStruct('com.sun.star.awt.Point', 0, 0)
     size = uno.createUnoStruct('com.sun.star.awt.Size', 85, 180)
     print("Wizard.__init__() 4")
     roadmap = self._getRoadmapControl('RoadmapControl1', point, size)
     print("Wizard.__init__() 5")
     roadmap.addItemListener(self)
     self._createPeer(parent)
     self._dialog.toFront()
     print("Wizard.__init__() 6")
コード例 #12
0
ファイル: Provider.py プロジェクト: Vman45/oneDriveOOo
 def getRequestParameter(self, method, data=None):
     parameter = uno.createUnoStruct('com.sun.star.auth.RestRequestParameter')
     parameter.Name = method
     if method == 'getUser':
         parameter.Method = 'GET'
         parameter.Url = '%s/me' % self.BaseUrl
         parameter.Query = '{"select": "%s"}' % g_userfields
     elif method == 'getRoot':
         parameter.Method = 'GET'
         parameter.Url = '%s/me/drive/root' % self.BaseUrl
         parameter.Query = '{"select": "%s"}' % g_drivefields
     elif method == 'getItem':
         parameter.Method = 'GET'
         parameter.Url = '%s/me/drive/items/%s' % (self.BaseUrl, data.getValue('Id'))
         parameter.Query = '{"select": "%s"}' % g_itemfields
     elif method == 'getFolderContent':
         parameter.Method = 'GET'
         parameter.Url = '%s/me/drive/items/%s/children' % (self.BaseUrl, data.getValue('Id'))
         parameter.Query = '{"select": "%s", "top": "%s"}' % (g_itemfields, g_pages)
         token = uno.createUnoStruct('com.sun.star.auth.RestRequestToken')
         token.Type = TOKEN_REDIRECT
         token.Field = '@odata:nextLink'
         enumerator = uno.createUnoStruct('com.sun.star.auth.RestRequestEnumerator')
         enumerator.Field = 'value'
         enumerator.Token = token
         parameter.Enumerator = enumerator
     elif method == 'getDocumentLocation':
         parameter.Method = 'GET'
         parameter.Url = '%s/me/drive/items/%s/content' % (self.BaseUrl, data.getValue('Id'))
         parameter.NoRedirect = True
     elif method == 'getDocumentContent':
         parameter.Method = 'GET'
         parameter.Url = data.getValue('Location')
         parameter.NoAuth = True
     elif method == 'updateTitle':
         parameter.Method = 'PATCH'
         parameter.Url = '%s/me/drive/items/%s' % (self.BaseUrl, data.getValue('Id'))
         parameter.Json = '{"name": "%s"}' % data.getValue('name')
     elif method == 'updateTrashed':
         parameter.Method = 'DELETE'
         parameter.Url = '%s/me/drive/items/%s' % (self.BaseUrl, data.getValue('Id'))
     elif method == 'createNewFolder':
         parameter.Method = 'POST'
         url = '%s/me/drive/items/%s/children' % (self.BaseUrl, data.getValue('ParentId'))
         parameter.Url = url
         rename = '"@microsoft.graph.conflictBehavior": "replace"'
         parameter.Json = '{"name": "%s", "folder": { }, %s}' % (data.getValue('Title'), rename)
     elif method in ('getUploadLocation', 'getNewUploadLocation'):
         parameter.Method = 'POST'
         url, parent, name = self.BaseUrl, data.getValue('ParentId'), data.getValue('Title')
         parameter.Url = '%s/me/drive/items/%s:/%s:/createUploadSession' % (url, parent, name)
         odata = '"@odata.type": "microsoft.graph.driveItemUploadableProperties"'
         onconflict = '"@microsoft.graph.conflictBehavior": "replace"'
         parameter.Json = '{"item": {%s, %s, "name": "%s"}}' % (odata, onconflict, name)
     elif method == 'getUploadStream':
         parameter.Method = 'PUT'
         parameter.Url = data.getValue('uploadUrl')
         parameter.NoAuth = True
     return parameter
コード例 #13
0
def InputBox(msgText, msgTitel, msgDefault, x=None, y=None):
    """
    Parameter: 
    msgText    :  Der Text in der InputBox
    msgTitel   :  Text der Titelleiste
    msgDefault :  Vorgegebener Default-Text
    """
    # Maße der InputBox:
    WIDTH = 600
    HORI_MARGIN = VERT_MARGIN = 8
    BUTTON_WIDTH = 100
    BUTTON_HEIGHT = 26
    HORI_SEP = VERT_SEP = 8
    LABEL_HEIGHT = BUTTON_HEIGHT * 2 + 5
    EDIT_HEIGHT = 24
    HEIGHT = VERT_MARGIN * 2 + LABEL_HEIGHT + VERT_SEP + EDIT_HEIGHT
    
    ctx = uno.getComponentContext()
    def create(name):
        return ctx.getServiceManager().createInstanceWithContext(name, ctx)
    dialog = create("com.sun.star.awt.UnoControlDialog")
    dialog_model = create("com.sun.star.awt.UnoControlDialogModel")
    dialog.setModel(dialog_model)
    dialog.setVisible(False)
    dialog.setTitle(title)
    dialog.setPosSize(0, 0, WIDTH, HEIGHT, SIZE)
    def add(name, type, x_, y_, width_, height_, props):
        model = dialog_model.createInstance("com.sun.star.awt.UnoControl" + type + "Model")
        dialog_model.insertByName(name, model)
        control = dialog.getControl(name)
        control.setPosSize(x_, y_, width_, height_, POSSIZE)
        for key, value in props.items():
            setattr(model, key, value)
    label_width = WIDTH - BUTTON_WIDTH - HORI_SEP - HORI_MARGIN * 2
    add("label", "FixedText", HORI_MARGIN, VERT_MARGIN, label_width, LABEL_HEIGHT, 
        {"Label": str(message), "NoLabel": True})
    add("btn_ok", "Button", HORI_MARGIN + label_width + HORI_SEP, VERT_MARGIN, 
            BUTTON_WIDTH, BUTTON_HEIGHT, {"PushButtonType": OK, "DefaultButton": True})
    add("btn_cancel", "Button", HORI_MARGIN + label_width + HORI_SEP, VERT_MARGIN + BUTTON_HEIGHT + 5, 
            BUTTON_WIDTH, BUTTON_HEIGHT, {"PushButtonType": CANCEL})
    add("edit", "Edit", HORI_MARGIN, LABEL_HEIGHT + VERT_MARGIN + VERT_SEP, 
            WIDTH - HORI_MARGIN * 2, EDIT_HEIGHT, {"Text": str(default)})
    frame = create("com.sun.star.frame.Desktop").getCurrentFrame()
    window = frame.getContainerWindow() if frame else None
    dialog.createPeer(create("com.sun.star.awt.Toolkit"), window)
    if not x is None and not y is None:
        ps = dialog.convertSizeToPixel(uno.createUnoStruct("com.sun.star.awt.Size", x, y), TWIP)
        _x, _y = ps.Width, ps.Height
    elif window:
        ps = window.getPosSize()
        _x = ps.Width / 2 - WIDTH / 2
        _y = ps.Height / 2 - HEIGHT / 2
    dialog.setPosSize(_x, _y, 0, 0, POS)
    edit = dialog.getControl("edit")
    edit.setSelection(uno.createUnoStruct("com.sun.star.awt.Selection", 0, len(str(default))))
    edit.setFocus()
    ret = edit.getModel().Text if dialog.execute() else ""
    dialog.dispose()
    return ret
コード例 #14
0
ファイル: provider.py プロジェクト: prrvchr/gContactOOo
 def getRequestParameter(self, method, data=None):
     parameter = uno.createUnoStruct(
         'com.sun.star.auth.RestRequestParameter')
     parameter.Name = method
     parameter.Url = self.BaseUrl
     if method == 'getUser':
         parameter.Method = 'GET'
         parameter.Url += '/people/me'
         parameter.Query = '{"personFields": "%s"}' % ','.join(data)
     elif method == 'People':
         parameter.Method = 'GET'
         parameter.Url += '/people/me/connections'
         fields = '"personFields": "%s"' % ','.join(data.Fields)
         sources = '"sources": "READ_SOURCE_TYPE_CONTACT"'
         page = '"pageSize": %s' % g_page
         sync = data.PeopleSync
         if sync:
             token = '"syncToken": "%s"' % sync
         else:
             token = '"requestSyncToken": true'
         parameter.Query = '{%s, %s, %s, %s}' % (fields, sources, page,
                                                 token)
         token = uno.createUnoStruct('com.sun.star.auth.RestRequestToken')
         token.Type = TOKEN_QUERY | TOKEN_SYNC
         token.Field = 'nextPageToken'
         token.Value = 'pageToken'
         token.SyncField = 'nextSyncToken'
         enumerator = uno.createUnoStruct(
             'com.sun.star.auth.RestRequestEnumerator')
         enumerator.Field = 'connections'
         enumerator.Token = token
         parameter.Enumerator = enumerator
     elif method == 'Group':
         parameter.Method = 'GET'
         parameter.Url += '/contactGroups'
         page = '"pageSize": %s' % g_page
         query = [page]
         sync = data.GroupSync
         if sync:
             query.append('"syncToken": "%s"' % sync)
         parameter.Query = '{%s}' % ','.join(query)
         token = uno.createUnoStruct('com.sun.star.auth.RestRequestToken')
         token.Type = TOKEN_QUERY | TOKEN_SYNC
         token.Field = 'nextPageToken'
         token.Value = 'pageToken'
         token.SyncField = 'nextSyncToken'
         enumerator = uno.createUnoStruct(
             'com.sun.star.auth.RestRequestEnumerator')
         enumerator.Field = 'contactGroups'
         enumerator.Token = token
         parameter.Enumerator = enumerator
     elif method == 'Connection':
         parameter.Method = 'GET'
         parameter.Url += '/contactGroups:batchGet'
         resources = '","'.join(data.getKeys())
         parameter.Query = '{"resourceNames": ["%s"], "maxMembers": %s}' % (
             resources, g_member)
     return parameter
コード例 #15
0
ファイル: insfw.py プロジェクト: EliseyP/oooInsertFW
def fill_frame(frame, fw_cursor):
    """
    Вставляет во врезку текст из курсора вместе с форматом (цвет и возможно жирность).

    :param frame: врезка
    :param fw_cursor: курсор с первым словом
    :return:
    """

    char_styles = doc.getStyleFamilies().getByName("CharacterStyles")
    # Если есть стиль киноварь, получить значение его цвета.
    # В дальнейшем, если он не красный (в стиле для ч/б печати),
    # будет учитываться "жирность" при вставке текста во врезку.
    kinovar_color = 0
    if char_styles.hasByName(char_style_name):
        kinovar_color = char_styles.getByName(char_style_name).CharColor

    # Очистка текста фрейма, т.к. запись нужна
    # либо в новый, либо в устаревший фрейм
    frame.String = ""

    # временный курсор -> во врезку
    tmp_cursor = frame.createTextCursorByRange(frame.getStart())
    # применить абзацный стиль для содержимого врезки
    tmp_cursor.ParaStyleName = frame_paragaph_style_name

    # Структура для сохранения форматирования
    char_props = (uno.createUnoStruct("com.sun.star.beans.PropertyValue"),
                  uno.createUnoStruct("com.sun.star.beans.PropertyValue"))

    # Получить текст и формат для всех порций текста, и вставить во врезку
    word_enum = fw_cursor.createEnumeration()  # SwXParagraphEnumeration
    while word_enum.hasMoreElements():
        word = word_enum.nextElement()  # SwXParagraph
        part_of_word_enum = word.createEnumeration(
        )  # SwXTextPortionEnumeration
        while part_of_word_enum.hasMoreElements():
            part_of_word = part_of_word_enum.nextElement()  # SwXTextPortion
            # свойства символов порции
            char_props[0].Name = "CharColor"
            char_props[0].Value = part_of_word.CharColor
            char_props[1].Name = "CharWeight"
            # если есть стиль для цветной печати, то жирность не нужна
            if kinovar_color == 0:
                char_props[
                    1].Value = part_of_word.CharWeight  # если нужен bold
            else:
                char_props[1].Value = 100  # выделения цветом достаточно
            # текст порции
            text_of_part_of_word = part_of_word.String

            # Вставка порции текста во врезку с сохранением формата, через tmp_cursor
            frame.insertTextPortion(text_of_part_of_word, char_props,
                                    tmp_cursor)
            tmp_cursor.gotoEndOfWord(False)  # позиция для следующей порции

    return None
コード例 #16
0
ファイル: DialogBox.py プロジェクト: tmtlakmal/EasyTuteLO
def createListBox(ctx,width,height,x,y):
    smgr = ctx.ServiceManager
    Rectangle=uno.createUnoStruct("com.sun.star.awt.Rectangle")
    Rectangle.Width =width
    Rectangle.Height=height
    Rectangle.X=x
    Rectangle.Y=y
    WindowDescriptor = uno.createUnoStruct("com.sun.star.awt.WindowDescriptor") 
    WindowClass = uno.Enum("com.sun.star.awt.WindowClass","MODALTOP") 
    VclWindowPeerAttribute = uno.getConstantByName("com.sun.star.awt.VclWindowPeerAttribute.OK")
コード例 #17
0
ファイル: DialogBox.py プロジェクト: tmtlakmal/EasyTuteLO
def createListBox(ctx, width, height, x, y):
    smgr = ctx.ServiceManager
    Rectangle = uno.createUnoStruct("com.sun.star.awt.Rectangle")
    Rectangle.Width = width
    Rectangle.Height = height
    Rectangle.X = x
    Rectangle.Y = y
    WindowDescriptor = uno.createUnoStruct("com.sun.star.awt.WindowDescriptor")
    WindowClass = uno.Enum("com.sun.star.awt.WindowClass", "MODALTOP")
    VclWindowPeerAttribute = uno.getConstantByName(
        "com.sun.star.awt.VclWindowPeerAttribute.OK")
コード例 #18
0
ファイル: main.py プロジェクト: Vayel/javelot
    def open_document(self, path, hidden=True, read_only=False):
        struct_hidden = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
        struct_hidden.Name = "Hidden"
        struct_hidden.Value = hidden

        struct_read_only = uno.createUnoStruct(
            "com.sun.star.beans.PropertyValue")
        struct_read_only.Name = "ReadOnly"
        struct_read_only.Value = read_only

        return self.desktop.loadComponentFromURL(
            uno.systemPathToFileUrl(path), "_blank", 0,
            tuple([struct_hidden, struct_read_only]))
コード例 #19
0
 def _initPage2(self):
     p = uno.createUnoStruct('com.sun.star.awt.Point', 10, 60)
     s = uno.createUnoStruct('com.sun.star.awt.Size', 115, 115)
     grid1 = self._getGridControl(self._handler._address, 'GridControl1', p,
                                  s, 'Addresses')
     grid1.addSelectionListener(self)
     p.X = 160
     grid2 = self._getGridControl(self._handler._recipient, 'GridControl2',
                                  p, s, 'Recipients')
     grid2.addSelectionListener(self)
     self._handler.addRefreshListener(self)
     self._handler._recipient.execute()
     self._refreshPage2()
コード例 #20
0
ファイル: core.py プロジェクト: Echo360/LibreOffice-core
      def testStruct( self ):
          mystruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData" )
          assign( mystruct, 1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo")
          self.tobj.Struct = mystruct
          aSecondStruct = self.tobj.Struct

          self.failUnless( self.tobj.Struct == mystruct, "struct roundtrip for equality test" )
          self.failUnless( aSecondStruct == mystruct, "struct roundtrip for equality test2" )
          aSecondStruct.Short = 720
          self.failUnless( not aSecondStruct == mystruct , "different structs equality test" )
          self.failUnless( not self.ctx == mystruct , "object is not equal to struct test" )
          self.failUnless( mystruct == self.tobj.transportAny( mystruct ), "struct roundtrip with any test" )
          my2ndstruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData", \
                      1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo",())
          self.failUnless( my2ndstruct == mystruct, "struct non-default ctor test" )                                  
コード例 #21
0
ファイル: core.py プロジェクト: Flatta/LibreOffice-core
      def testStruct( self ):
          mystruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData" )
          assign( mystruct, 1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo")
          self.tobj.Struct = mystruct
          aSecondStruct = self.tobj.Struct

          self.failUnless( self.tobj.Struct == mystruct, "struct roundtrip for equality test" )
          self.failUnless( aSecondStruct == mystruct, "struct roundtrip for equality test2" )
          aSecondStruct.Short = 720
          self.failUnless( not aSecondStruct == mystruct , "different structs equality test" )
          self.failUnless( not self.ctx == mystruct , "object is not equal to struct test" )
          self.failUnless( mystruct == self.tobj.transportAny( mystruct ), "struct roundtrip with any test" )
          my2ndstruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData", \
                      1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo",())
          self.failUnless( my2ndstruct == mystruct, "struct non-default ctor test" )                                  
コード例 #22
0
def run(source, update, pdf):
    fileUrl = uno.systemPathToFileUrl(os.path.realpath(source))
    filepath, ext = os.path.splitext(source)
    fileUrlPDF = uno.systemPathToFileUrl(os.path.realpath(filepath + ".pdf"))

    runner = OORunner(2002)
    desktop, dispatcher = runner.connect()

    print("Loading document")
    struct = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
    struct.Name = 'Hidden'
    struct.Value = True
    document = desktop.loadComponentFromURL(fileUrl, "_default", 0, ([struct]))
    doc = document.getCurrentController()
    #doc = desktop.getCurrentComponent().getCurrentController()

    if update:
        print("Updating Indexes and Saving")
        dispatcher.executeDispatch(doc, ".uno:UpdateAllIndexes", "", 0, ())

        # Saving
        opts = []

        if ext == ".docx":
            struct = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
            struct.Name = "FilterName"
            struct.Value = "MS Word 2007 XML"
            opts.append(struct)

        struct = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
        struct.Name = 'URL'
        struct.Value = fileUrl
        opts.append(struct)

        dispatcher.executeDispatch(doc, ".uno:SaveAs", "", 0, tuple(opts))

    if pdf:
        print("Generating PDF")
        struct = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
        struct.Name = 'URL'
        struct.Value = fileUrlPDF
        struct2 = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
        struct2.Name = "FilterName"
        struct2.Value = "writer_pdf_Export"
        dispatcher.executeDispatch(doc, ".uno:ExportDirectToPDF", "", 0,
                                   tuple([struct, struct2]))

    runner.shutdown()
コード例 #23
0
def getCommandInfo(name, unotype=None, handle=-1):
    command = uno.createUnoStruct('com.sun.star.ucb.CommandInfo')
    command.Name = name
    if unotype:
        command.ArgType = unotype
    command.Handle = handle
    return command
コード例 #24
0
 def createRectangle(self,height,width,xPos,yPos):               #create a rectangle according to the parameters
     Rectangle =uno.createUnoStruct("com.sun.star.awt.Rectangle")
     Rectangle.Width =width
     Rectangle.Height=height
     Rectangle.X=xPos
     Rectangle.Y=yPos
     return Rectangle
コード例 #25
0
ファイル: mailmerge.py プロジェクト: prrvchr/gMailOOo
 def _getPropertyValue(self, nodepath):
     args = []
     arg = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
     arg.Name = "nodepath"
     arg.Value = nodepath
     args.append(arg)
     return tuple(args)
コード例 #26
0
ファイル: Lightproof.py プロジェクト: arnotixe/lp-nor
def proofread( nDocId, TEXT, LOCALE, nStartOfSentencePos, nSuggestedSentenceEndPos, rProperties ):
    global ignore
    aErrs = []
    s = TEXT[nStartOfSentencePos:nSuggestedSentenceEndPos]
    for i in get_rule(LOCALE):
        if i[0] and not str(i[0]) in ignore:
            for m in i[0].finditer(s):
              if not i[3] or eval(i[3]):
                aErr = uno.createUnoStruct( "com.sun.star.linguistic2.SingleProofreadingError" )
                aErr.nErrorStart        = nStartOfSentencePos + m.start(0) # nStartOfSentencePos
                aErr.nErrorLength       = m.end(0) - m.start(0)
                aErr.nErrorType         = PROOFREADING
                aErr.aRuleIdentifier    = str(i[0])
                iscap = (i[4] and m.group(0)[0:1].isupper())
                if i[1][0:1] == "=":
                        aErr.aSuggestions = tuple(cap(eval(i[1][1:]).split("\n"), iscap, LOCALE))
                else:
                        aErr.aSuggestions = tuple(cap(m.expand(i[1]).split("\n"), iscap, LOCALE))
                comment = i[2]
                if comment[0:1] == "=":
                        comment = eval(comment[1:])
                aErr.aShortComment      = comment.split("\n")[0]
                aErr.aFullComment       = comment.split("\n")[-1]
                aErr.aProperties        = ()
                aErrs = aErrs + [aErr]
    return tuple(aErrs)
コード例 #27
0
ファイル: Lightproof.py プロジェクト: arnotixe/lp-nor
    def doProofreading(self, nDocId, rText, rLocale, nStartOfSentencePos, \
        nSuggestedSentenceEndPos, rProperties):
        aRes = uno.createUnoStruct( "com.sun.star.linguistic2.ProofreadingResult" )
        aRes.aDocumentIdentifier = nDocId
        aRes.aText = rText
        aRes.aLocale = rLocale
        aRes.nStartOfSentencePosition = nStartOfSentencePos
        aRes.nStartOfNextSentencePosition = nSuggestedSentenceEndPos
        l = rText[nSuggestedSentenceEndPos:nSuggestedSentenceEndPos+1]
        while l == " ":
            aRes.nStartOfNextSentencePosition = aRes.nStartOfNextSentencePosition + 1
            l = rText[aRes.nStartOfNextSentencePosition:aRes.nStartOfNextSentencePosition+1]
        if aRes.nStartOfNextSentencePosition == nSuggestedSentenceEndPos and l!="":
            aRes.nStartOfNextSentencePosition = nSuggestedSentenceEndPos + 1
        aRes.nBehindEndOfSentencePosition = aRes.nStartOfNextSentencePosition

        try:
            aRes.aErrors = proofread( nDocId, rText, rLocale, \
                nStartOfSentencePos, aRes.nBehindEndOfSentencePosition, rProperties)
        except:
            traceback.print_exc(file=sys.stdout)
            aRes.aErrors = ()
        aRes.aProperties = ()
        aRes.xProofreader = self
        return aRes
コード例 #28
0
ファイル: sheetFunction.py プロジェクト: UBunt14/mpFormulaPy
def getDoubleOf(data):
     '''Simple demo-function duplicating plain cell values 1->2, "A"->"AA"     
     Thanks to the c.s.s.script.ArrayWrapper it works in array context as well. To be called through a 
     StarBasic wrapper.'''     
     # cheap msgbox in scripting context:     
     # raise Exception(repr(data))     
     if hasattr(data[0], '__iter__'):
         # two lists:
         rows = []
         wrapper = uno.createUnoStruct('com.sun.star.script.ArrayWrapper')
         # =A1:B2 passes a one-based array to a Basic function. Let's assume the same here:
         # (Apparently it makes no difference if IsZeroIndex or not)
         wrapper.IsZeroIndex = False
         for row in data:
             column = []
             for val in row:
                 try:
                     column.append(val * 2)
                 except:
                     column.append(None)
             rows.append(tuple(column))
         # returning the mere list of list fails:
         # return tuple(rows)
         # here comes the wrapper into play:
         wrapper.Array = tuple(rows)
         return wrapper 
         
     elif hasattr(data, '__abs__'):
         return data *2
     else:         
        return None 
コード例 #29
0
ファイル: unotools.py プロジェクト: prrvchr/DropboxOOo
def getConfiguration(ctx, nodepath, update=False):
    service = 'com.sun.star.configuration.ConfigurationProvider'
    provider = createService(ctx, service)
    service = 'com.sun.star.configuration.ConfigurationUpdateAccess' if update else \
              'com.sun.star.configuration.ConfigurationAccess'
    arguments = (uno.createUnoStruct('com.sun.star.beans.NamedValue', 'nodepath', nodepath), )
    return provider.createInstanceWithArguments(service, arguments)
コード例 #30
0
ファイル: pyloo.py プロジェクト: ASP96/pyloo
    def add(self, name, value, sheet, column, row, type=0):
        """
        Not implemented yet. FIXME
        Adds a new field (named range) to the collection.

        @type  name: string
        @param name: the new name of the named range.

        @type  value: string
        @param value: the formula expression.

        @type  sheet: int
        @param sheet: the formula expression.

        @type  column: int
        @param column: the formula expression.

        @type  row: int
        @param row: the formula expression.

        @type  type: int
        @param type: a combination of flags that specify the type of a named \
                    range, as defined in NamedRangeFlag. This parameter \
                    will be zero for any common named range.

        @rtype:   bool
        @return:  Operation result
        """
        cell_address = uno.createUnoStruct("com.sun.star.table.CellAddress")
        cell_address.Sheet = sheet
        cell_address.Column = column
        cell_address.Row = row
        if self._oNamedRanges:
            self._oNamedRanges.addNewByName(name, value, cell_address, 0)
        return None
コード例 #31
0
 def createRectangle(self,height,width,xPos,yPos):
     Rectangle =uno.createUnoStruct("com.sun.star.awt.Rectangle")
     Rectangle.Width =width
     Rectangle.Height=height
     Rectangle.X=xPos
     Rectangle.Y=yPos
     return Rectangle
コード例 #32
0
def getPropertyValue(name, value, state=0, handle=-1):
    property = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
    property.Name = name
    property.Handle = handle
    property.Value = value
    property.State = state
    return property
コード例 #33
0
def getConfiguration(ctx, path, update=False, language=None):
    service = 'com.sun.star.configuration.ConfigurationProvider'
    provider = createService(ctx, service)
    service = 'com.sun.star.configuration.Configuration'
    service += 'UpdateAccess' if update else 'Access'
    nodepath = uno.createUnoStruct('com.sun.star.beans.NamedValue')
    nodepath.Name = 'nodepath'
    nodepath.Value = path
    if language is None:
        arguments = (nodepath, )
    else:
        locale = uno.createUnoStruct('com.sun.star.beans.NamedValue')
        locale.Name = 'Locale'
        locale.Value = language
        arguments = (nodepath, locale)
    return provider.createInstanceWithArguments(service, arguments)
コード例 #34
0
ファイル: oauth2dispatch.py プロジェクト: prrvchr/OAuth2OOo
 def dispatchWithNotification(self, url, arguments, listener):
     state, result = self.dispatch(url, arguments)
     notification = uno.createUnoStruct('com.sun.star.frame.DispatchResultEvent')
     notification.Source = self
     notification.State = state
     notification.Result =  result
     listener.dispatchFinished(notification)
コード例 #35
0
    def doProofreading(self, nDocId, rText, rLocale, nStartOfSentencePos, \
        nSuggestedSentenceEndPos, rProperties):
        aRes = uno.createUnoStruct(
            "com.sun.star.linguistic2.ProofreadingResult")
        aRes.aDocumentIdentifier = nDocId
        aRes.aText = rText
        aRes.aLocale = rLocale
        aRes.nStartOfSentencePosition = nStartOfSentencePos
        aRes.nStartOfNextSentencePosition = nSuggestedSentenceEndPos
        l = rText[nSuggestedSentenceEndPos:nSuggestedSentenceEndPos + 1]
        while l == " ":
            aRes.nStartOfNextSentencePosition = aRes.nStartOfNextSentencePosition + 1
            l = rText[aRes.nStartOfNextSentencePosition:aRes.
                      nStartOfNextSentencePosition + 1]
        if aRes.nStartOfNextSentencePosition == nSuggestedSentenceEndPos and l != "":
            aRes.nStartOfNextSentencePosition = nSuggestedSentenceEndPos + 1
        aRes.nBehindEndOfSentencePosition = aRes.nStartOfNextSentencePosition

        try:
            aRes.aErrors = proofread( nDocId, rText, rLocale, \
                nStartOfSentencePos, aRes.nBehindEndOfSentencePosition, rProperties)
        except:
            traceback.print_exc(file=sys.stdout)
            aRes.aErrors = ()
        aRes.aProperties = ()
        aRes.xProofreader = self
        return aRes
コード例 #36
0
def proofread(nDocId, TEXT, LOCALE, nStartOfSentencePos,
              nSuggestedSentenceEndPos, rProperties):
    global ignore
    aErrs = []
    s = TEXT[nStartOfSentencePos:nSuggestedSentenceEndPos]
    for i in get_rule(LOCALE):
        if i[0] and not str(i[0]) in ignore:
            for m in i[0].finditer(s):
                if not i[3] or eval(i[3]):
                    aErr = uno.createUnoStruct(
                        "com.sun.star.linguistic2.SingleProofreadingError")
                    aErr.nErrorStart = nStartOfSentencePos + m.start(
                        0)  # nStartOfSentencePos
                    aErr.nErrorLength = m.end(0) - m.start(0)
                    aErr.nErrorType = PROOFREADING
                    aErr.aRuleIdentifier = str(i[0])
                    iscap = (i[4] and m.group(0)[0:1].isupper())
                    if i[1][0:1] == "=":
                        aErr.aSuggestions = tuple(
                            cap(eval(i[1][1:]).split("\n"), iscap, LOCALE))
                    else:
                        aErr.aSuggestions = tuple(
                            cap(m.expand(i[1]).split("\n"), iscap, LOCALE))
                    comment = i[2]
                    if comment[0:1] == "=":
                        comment = eval(comment[1:])
                    aErr.aShortComment = comment.split("\n")[0]
                    aErr.aFullComment = comment.split("\n")[-1]
                    aErr.aProperties = ()
                    aErrs = aErrs + [aErr]
    return tuple(aErrs)
コード例 #37
0
ファイル: spoolerview.py プロジェクト: prrvchr/smtpMailerOOo
 def refreshLog(self, text, length):
     control = self._getActivityLog()
     selection = uno.createUnoStruct('com.sun.star.awt.Selection')
     selection.Min = length
     selection.Max = length
     control.Text = text
     control.setSelection(selection)
コード例 #38
0
def getContentEvent(source, action, content, id):
    event = uno.createUnoStruct('com.sun.star.ucb.ContentEvent')
    event.Source = source
    event.Action = action
    event.Content = content
    event.Id = id
    return event
コード例 #39
0
ファイル: oauth2tools.py プロジェクト: prrvchr/OAuth2OOo
def checkUrl(ctx, configuration, uuid):
    transformer = ctx.ServiceManager.createInstance(
        'com.sun.star.util.URLTransformer')
    url = uno.createUnoStruct('com.sun.star.util.URL')
    url.Complete = getAuthorizationStr(ctx, configuration, uuid)
    success, url = transformer.parseStrict(url)
    return success
コード例 #40
0
def getPropertySetInfoChangeEvent(source, name, reason, handle=-1):
    event = uno.createUnoStruct(
        'com.sun.star.beans.PropertySetInfoChangeEvent')
    event.Source = source
    event.Name = name
    event.Handle = handle
    event.Reason = reason
コード例 #41
0
 def _setDialogText(self, dialog, url):
     control = dialog.getControl('TextField1')
     length, sequence = getFileSequence(self.ctx, url)
     control.Text = sequence.value.decode('utf-8')
     selection = uno.createUnoStruct('com.sun.star.awt.Selection', length,
                                     length)
     control.setSelection(selection)
コード例 #42
0
def getDriverPropertyInfo(name, value, required=False, choices=()):
    info = uno.createUnoStruct('com.sun.star.sdbc.DriverPropertyInfo')
    info.Name = name
    info.Value = value
    info.IsRequired = required
    info.Choices = choices
    return info
コード例 #43
0
ファイル: ispdbview.py プロジェクト: prrvchr/smtpServerOOo
 def _updateLogger(self):
     length, sequence = getFileSequence(self._ctx, self._url)
     control = self._getLogger()
     control.Text = sequence.value.decode('utf-8')
     selection = uno.createUnoStruct('com.sun.star.awt.Selection', length,
                                     length)
     control.setSelection(selection)
コード例 #44
0
ファイル: core.py プロジェクト: Flatta/LibreOffice-core
 def testInvoke( self ):
     self.failUnless( 5 == uno.invoke( self.tobj , "transportAny" , (uno.Any("byte", 5),) ) )
     self.failUnless( 5 == uno.invoke(
         PythonTransporter(), "transportAny" , (uno.Any( "byte", 5 ),) ) )
     t = uno.getTypeByName( "long" )
     mystruct = uno.createUnoStruct(
         "com.sun.star.beans.PropertyValue", "foo",0,uno.Any(t,2),0 )
     mystruct.Value = uno.Any(t, 1)
コード例 #45
0
ファイル: OfficeDocument.py プロジェクト: rohanKanojia/core
 def attachEventCall(self, xComponent, EventName, EventType, EventURL):
     try:
         oEventProperties = list(range(2))
         oEventProperties[0] = uno.createUnoStruct(
             'com.sun.star.beans.PropertyValue')
         oEventProperties[0].Name = "EventType"
         oEventProperties[0].Value = EventType
         # "Service", "StarBasic"
         oEventProperties[1] = uno.createUnoStruct(
             'com.sun.star.beans.PropertyValue')
         oEventProperties[1].Name = "Script" #"URL";
         oEventProperties[1].Value = EventURL
         uno.invoke(xComponent.Events, "replaceByName",
             (EventName, uno.Any("[]com.sun.star.beans.PropertyValue",
                 tuple(oEventProperties))))
     except Exception:
         traceback.print_exc()
コード例 #46
0
ファイル: OOoBackend.py プロジェクト: greg42/openOfficeMarkup
 def createProps(**args):
    props = []
    for key in args:
       prop = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
       prop.Name = key
       prop.Value = args[key]
       props.append(prop)
    return tuple(props)
コード例 #47
0
ファイル: __init__.py プロジェクト: kikili/MRI
 def create_struct(self, type_name, *args, **kwds):
     _args, _any = self.extract_args(args)
     struct = uno.createUnoStruct(type_name, *_args)
     if "nocode" in kwds: return struct
     entry = self.engine.create(self, type_name, struct)
     entry.code_entry = self.code(
         type=CGType.STRUCT, key=type_name, value_type=entry.type, idl=entry.type, args=args)
     return entry
コード例 #48
0
ファイル: DialogBox.py プロジェクト: tmtlakmal/EasyTuteLO
def createWindow(ctx,parentWin,height,width,positionX,positionY,serviceName):
    smgr = ctx.ServiceManager
    Rectangle =uno.createUnoStruct("com.sun.star.awt.Rectangle")
    Rectangle.Width =width
    Rectangle.Height=height
    Rectangle.X=positionX
    Rectangle.Y=positionY
    WindowDescriptor = uno.createUnoStruct("com.sun.star.awt.WindowDescriptor") 
    WindowClass = uno.Enum("com.sun.star.awt.WindowClass","MODALTOP")
    aDescriptor = WindowDescriptor
    aDescriptor.Type = WindowClass
    aDescriptor.WindowServiceName = serviceName
    aDescriptor.ParentIndex = -1
    aDescriptor.Parent = parentWin
    aDescriptor.Bounds = Rectangle
    tk = aDescriptor.Parent.getToolkit()
    return tk.createWindow(aDescriptor)
コード例 #49
0
 def __init__( self, ctx ):
     p = uno.createUnoStruct( "com.sun.star.beans.PropertyValue" )
     p.Name = "nodepath"
     p.Value = "/org.openoffice.Lightproof_%s/Leaves"%pkg
     self.xConfig = ctx.ServiceManager.createInstance( 'com.sun.star.configuration.ConfigurationProvider' )
     self.node = self.xConfig.createInstanceWithArguments( 'com.sun.star.configuration.ConfigurationUpdateAccess', (p, ) )
     self.service = "org.libreoffice.comp.pyuno.LightproofOptionsEventHandler." + pkg
     self.ImplementationName = self.service
     self.services = (self.service, )
コード例 #50
0
 def breakLinkOfTextSection(self, oTextSection):
     try:
         oSectionLink = \
             uno.createUnoStruct('com.sun.star.text.SectionFileLink')
         oSectionLink.FileURL = ""
         uno.invoke(oTextSection, "setPropertyValues",
             (("FileLink", "LinkRegion"), (oSectionLink, "")))
     except Exception:
         traceback.print_exc()
コード例 #51
0
 def run_infodialog(self, title='', message=''):
   try:
       msgbox = self._toolkit.createMessageBox(self._window,uno.createUnoStruct('com.sun.star.awt.Rectangle'),'infobox',1,title,message)
       msgbox.execute()
       msgbox.dispose()
   except:
       msgbox = self._toolkit.createMessageBox(self._window,'infobox',1,title,message)
       msgbox.execute()
       msgbox.dispose()
コード例 #52
0
 def breakLinkOfTextSection(self, oTextSection):
     try:
         oSectionLink = \
             uno.createUnoStruct('com.sun.star.text.SectionFileLink')
         oSectionLink.FileURL = ""
         oTextSection.FileLink = oSectionLink
         oTextSection.LinkRegion =  ""
     except Exception:
         traceback.print_exc()
コード例 #53
0
ファイル: document.py プロジェクト: pheelixx/konvert
 def set_properties(self, properties):
     for name, value in properties.iteritems():
         if type(value).__name__ == 'dict':
             value = self.__build_properties_recursively(value)
         property = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
         property.Name = name
         property.Value = value
         self.properties.append(property)
         del property
コード例 #54
0
ファイル: DialogBox.py プロジェクト: tmtlakmal/EasyTuteLO
def TestLayout():
    localContext = uno.getComponentContext()
    resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext )
    ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
    smgr = ctx.ServiceManager
    desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
    doc = desktop.getCurrentComponent()
    if not hasattr(doc, "Text"):
        doc = desktop.loadComponentFromURL( "private:factory/swriter","_blank", 0, () )   
    contFrame =doc.getCurrentController().getFrame()
    loutmgr=contFrame.LayoutManager
    a = desktop.getComponents()
    b = a.createEnumeration()
    while b.hasMoreElements(): 
        element = b.nextElement()
        try:
            for prop in element.getPropertySetInfo().getProperties():
                print(prop)
        except Exception :
            print("exempted")
    print(contFrame.getName())
    a1 = contFrame.getContainerWindow()
    print(a1)
    #loutmgr.doLayout()
    #elems = loutmgr.getElements()   
    #for e in elems:  
    #    print(e.getPropertyValue("ResourceURL")) 
    #uiconfmgr = doc.getUIConfigurationManager()
    #wstconf = smgr.createInstanceWithContext( "com.sun.star.ui.WindowStateConfiguration",ctx)
    #print(wstconf)
    #wndw =loutmgr.getDockingAreaAcceptor().getContainerWindow()
    #for a in wndw.getProperties():
    #    print(a)
    uiEl = uno.createUnoStruct("com.sun.star.ui.XUIElement")
    uiEl.Frame = contFrame
    uiEl.ResourceURL = "private:resource/dockingwindow/testdockwindow"
    uiEl.Type =7
    #print(uiEl)
    point = uno.createUnoStruct( "com.sun.star.awt.Point")
    point.X=50
    point.Y=50
    dockingArea = uno.Enum("com.sun.star.ui.DockingArea","DOCKINGAREA_RIGHT")
    loutmgr.dockWindow("private:resource/dockingwindow/testdockwindow",dockingArea,point)
コード例 #55
0
def make_property_array(**kwargs):
    """convert the keyword arguments to a tuple of PropertyValue uno
    structures"""
    array = []
    for name, value in kwargs.iteritems():
        prop = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
        prop.Name = name
        prop.Value = value
        array.append(prop)
    return tuple(array)
コード例 #56
0
ファイル: extensioncore.py プロジェクト: KAMI911/loec
	def box( self, message, kind = 'infobox', buttons = 'OK', title = None ):
		if kind == 'infobox' and buttons != 'OK':
			kind = 'querybox'	# infobox only supports OK
		if title is None: title = self.localize( 'title' )
		toolkit = self.ctx.ServiceManager.createInstance( 'com.sun.star.awt.Toolkit' )
		rectangle = uno.createUnoStruct( 'com.sun.star.awt.Rectangle' )
		msgbox = toolkit.createMessageBox( self.getdesktop().getCurrentFrame().getContainerWindow(), rectangle,
			kind, uno.getConstantByName( 'com.sun.star.awt.MessageBoxButtons.BUTTONS_'+buttons ),
			title, message )
		return msgbox.execute()
コード例 #57
0
ファイル: document.py プロジェクト: pheelixx/konvert
 def __build_properties_recursively(self, properties):
     data = []
     for name, value in properties.iteritems():
         if type(value).__name__ == 'dict':
             value = self.__build_properties_recursively(value)
         property = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
         property.Name = name
         property.Value = value
         data.append(property)
     return uno.Any("[]com.sun.star.beans.PropertyValue", tuple(data))
コード例 #58
0
ファイル: backend.py プロジェクト: hanul93/pyhwp
 def raw_input(self, prompt=''):
     import uno
     arg = uno.createUnoStruct('com.sun.star.beans.NamedValue')
     arg.Name = 'prompt'
     arg.Value = prompt
     args = arg,
     result = self.inp.execute(args)
     if result is None:
         raise EOFError()
     return result