예제 #1
0
파일: tools.py 프로젝트: sonnysk76/easydev
    def getSelectedFiles(self, init_folder, multiple, filters):
        """
            init_folder: folder default open
            multiple: True for multiple selected
            filters: Example
            (
                ('XML', '*.xml'),
                ('TXT', '*.txt'),
            )
        """
        if init_folder:
            init_folder = comun.path_to_url(init_folder)
        else:
            init_folder = comun.path_to_url(self.getPath())

        folder = self._create_instance('com.sun.star.ui.dialogs.FilePicker')
        folder.setDisplayDirectory(init_folder)
        folder.setMultiSelectionMode(multiple)
        if filters:
            folder.setCurrentFilter(filters[0][0])
            for f in filters:
                folder.appendFilter(f[0], f[1])

        if folder.execute():
            files = folder.getSelectedFiles()
            if multiple:
                return tuple([comun.path_to_os(f) for f in files])
            else:
                return comun.path_to_os(files[0])
        else:
            return ""
예제 #2
0
    def getSelectedFiles(self, init_folder, multiple, filters):
        """
            init_folder: folder default open
            multiple: True for multiple selected
            filters: Example
            (
                ('XML', '*.xml'),
                ('TXT', '*.txt'),
            )
        """
        if init_folder:
            init_folder = comun.path_to_url(init_folder)
        else:
            init_folder = comun.path_to_url(self.getPath())

        folder = self._create_instance('com.sun.star.ui.dialogs.FilePicker')
        folder.setDisplayDirectory(init_folder)
        folder.setMultiSelectionMode(multiple)
        if filters:
            folder.setCurrentFilter(filters[0][0])
            for f in filters:
                folder.appendFilter(f[0], f[1])

        if folder.execute():
            files = folder.getSelectedFiles()
            if multiple:
                return tuple([comun.path_to_os(f) for f in files])
            else:
                return comun.path_to_os(files[0])
        else:
            return ""
예제 #3
0
 def getFolder(self, init_folder=''):
     if init_folder:
         init_folder = comun.path_to_url(init_folder)
     else:
         init_folder = comun.path_to_url(self.getPath())
     folder = self._create_instance('com.sun.star.ui.dialogs.FolderPicker')
     folder.setDisplayDirectory(init_folder)
     if folder.execute():
         return comun.path_to_os(folder.getDirectory())
     else:
         return ''
예제 #4
0
파일: tools.py 프로젝트: sonnysk76/easydev
 def getFolder(self, init_folder=''):
     if init_folder:
         init_folder = comun.path_to_url(init_folder)
     else:
         init_folder = comun.path_to_url(self.getPath())
     folder = self._create_instance('com.sun.star.ui.dialogs.FolderPicker')
     folder.setDisplayDirectory(init_folder)
     if folder.execute():
         return comun.path_to_os(folder.getDirectory())
     else:
         return ''
예제 #5
0
    def imageAdd(self, data):
        doc = data.Doc
        sheet = comun.get_sheet(doc, data.Sheet)
        properties = comun.to_dict(data.Properties)
        position, size = comun.get_pos_size(data.PosSize)
        draw_page = sheet.getDrawPage()

        if data.Type:
            type_shape = SHAPES.get(data.Type, SRV_DCS)
            image = doc.createInstance(type_shape)
            if type_shape == SRV_DCS:
                pv = comun.set_properties((('Type', data.Type),))
                comun.set_property(image, ('CustomShapeGeometry', pv))
        else:
            path = comun.path_to_url(data.Path)
            image = doc.createInstance(SRV_GOS)
            if data.Link:
                log.info(data.Link)
                image.GraphicURL = path
                log.info(path)
            else:
                gp = self._create_instance(SRV_GP)
                pv = comun.set_properties((('URL', path),))
                image.Graphic = gp.queryGraphic(pv)
        draw_page.add(image)

        if data.Name:
            image.Name = data.Name

        image.setPosition(position)
        image.setSize(size)
        for k, v in properties.items():
            if hasattr(image, k):
                setattr(image, k, v)
        return image
예제 #6
0
 def exportPDF(self, doc, path_save, options):
     """
         Export to PDF
         http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export
     """
     close = False
     if isinstance(doc, str):
         close = True
         doc = self.openDoc(doc, (('Hidden', True),))
     if path_save:
         if comun.isdir(path_save):
             path_save = comun.replace_name_ext(path_save, doc.getURL(), EXT_PDF)
     else:
         path_save = comun.replace_ext(doc.getURL(), EXT_PDF)
     path_save = comun.path_to_url(path_save)
     try:
         filter_name = '{}_pdf_Export'.format(self.getTypeDoc(doc))
         if options:
             filter_data = comun.set_properties(options)
             filter_options = (
                 ('FilterName', filter_name),
                 ('FilterData', filter_data),
             )
         else:
             filter_options = (('FilterName', filter_name),)
         media_descriptor = comun.set_properties(filter_options)
         doc.storeToURL(path_save, media_descriptor)
     except:
         log.error('PDF', exc_info=True)
     if close:
         doc.dispose()
     if comun.exists(path_save):
         return comun.path_to_os(path_save)
     return ''
예제 #7
0
파일: loapp.py 프로젝트: sonnysk76/easydev
 def exportPDF(self, doc, path_save, options):
     """
         Export to PDF
         http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export
     """
     close = False
     if isinstance(doc, str):
         close = True
         doc = self.openDoc(doc, (('Hidden', True), ))
     if path_save:
         if comun.isdir(path_save):
             path_save = comun.replace_name_ext(path_save, doc.getURL(),
                                                EXT_PDF)
     else:
         path_save = comun.replace_ext(doc.getURL(), EXT_PDF)
     path_save = comun.path_to_url(path_save)
     try:
         filter_name = '{}_pdf_Export'.format(self.getTypeDoc(doc))
         if options:
             filter_data = comun.set_properties(options)
             filter_options = (
                 ('FilterName', filter_name),
                 ('FilterData', filter_data),
             )
         else:
             filter_options = (('FilterName', filter_name), )
         media_descriptor = comun.set_properties(filter_options)
         doc.storeToURL(path_save, media_descriptor)
     except:
         log.error('PDF', exc_info=True)
     if close:
         doc.dispose()
     if comun.exists(path_save):
         return comun.path_to_os(path_save)
     return ''
예제 #8
0
    def imageAdd(self, data):
        doc = data.Doc
        sheet = comun.get_sheet(doc, data.Sheet)
        properties = comun.to_dict(data.Properties)
        position, size = comun.get_pos_size(data.PosSize)
        draw_page = sheet.getDrawPage()

        if data.Type:
            type_shape = SHAPES.get(data.Type, SRV_DCS)
            image = doc.createInstance(type_shape)
            if type_shape == SRV_DCS:
                pv = comun.set_properties((('Type', data.Type), ))
                comun.set_property(image, ('CustomShapeGeometry', pv))
        else:
            path = comun.path_to_url(data.Path)
            image = doc.createInstance(SRV_GOS)
            if data.Link:
                log.info(data.Link)
                image.GraphicURL = path
                log.info(path)
            else:
                gp = self._create_instance(SRV_GP)
                pv = comun.set_properties((('URL', path), ))
                image.Graphic = gp.queryGraphic(pv)
        draw_page.add(image)

        if data.Name:
            image.Name = data.Name

        image.setPosition(position)
        image.setSize(size)
        for k, v in properties.items():
            if hasattr(image, k):
                setattr(image, k, v)
        return image
예제 #9
0
 def openDoc(self, path, options):
     """
         Open doc
         http://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1frame_1_1XComponentLoader.html
         http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1document_1_1MediaDescriptor.html
     """
     properties = comun.set_properties(options)
     path_url = comun.path_to_url(path)
     doc = self.desktop.loadComponentFromURL(path_url, '_blank', 0, properties)
     return doc
예제 #10
0
파일: loapp.py 프로젝트: sonnysk76/easydev
 def openDoc(self, path, options):
     """
         Open doc
         http://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1frame_1_1XComponentLoader.html
         http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1document_1_1MediaDescriptor.html
     """
     properties = comun.set_properties(options)
     path_url = comun.path_to_url(path)
     doc = self.desktop.loadComponentFromURL(path_url, '_blank', 0,
                                             properties)
     return doc
예제 #11
0
파일: dialog.py 프로젝트: sonnysk76/easydev
 def createDialog(self, data):
     """
         Create dialog from URL.
         path in OS or URI Specification vnd.sun.star.script
     """
     dp = self._create_instance('com.sun.star.awt.DialogProvider', True)
     if isinstance(data, Macro):
         if not data.Library:
             data.Library = 'Standard'
         data.Location = 'application'
         path = 'vnd.sun.star.script:{}.{}?location={}'.format(
             data.Library, data.Dialog, data.Location)
     elif comun.exists(data):
         path = comun.path_to_url(data)
     return dp.createDialog(path)
예제 #12
0
 def createDialog(self, data):
     """
         Create dialog from URL.
         path in OS or URI Specification vnd.sun.star.script
     """
     dp = self._create_instance('com.sun.star.awt.DialogProvider', True)
     if isinstance(data, Macro):
         if not data.Library:
             data.Library = 'Standard'
         data.Location = 'application'
         path = 'vnd.sun.star.script:{}.{}?location={}'.format(
             data.Library, data.Dialog, data.Location)
     elif comun.exists(data):
         path = comun.path_to_url(data)
     return dp.createDialog(path)
예제 #13
0
 def registerDB(self, name, path):
     self._dbc.registerDatabaseLocation(name, comun.path_to_url(path))
     return True
예제 #14
0
파일: loapp.py 프로젝트: sonnysk76/easydev
 def newDB(self, path):
     dbc = self._create_instance('com.sun.star.sdb.DatabaseContext')
     db = dbc.createInstance()
     db.URL = 'sdbc:embedded:hsqldb'
     db.DatabaseDocument.storeAsURL(comun.path_to_url(path), ())
     return db
예제 #15
0
 def newDB(self, path):
     dbc = self._create_instance('com.sun.star.sdb.DatabaseContext')
     db = dbc.createInstance()
     db.URL = 'sdbc:embedded:hsqldb'
     db.DatabaseDocument.storeAsURL(comun.path_to_url(path), ())
     return db
예제 #16
0
파일: lodb.py 프로젝트: sonnysk76/easydev
 def registerDB(self, name, path):
     self._dbc.registerDatabaseLocation(name, comun.path_to_url(path))
     return True