예제 #1
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 ''
예제 #2
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
예제 #3
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 ''
예제 #4
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
예제 #5
0
 def conODBC(self, name, user, password):
     dm = self._create_instance('com.sun.star.sdbc.DriverManager')
     pv = comun.set_properties((('user', user), ('password', password)))
     try:
         con = dm.getConnectionWithInfo('sdbc:odbc:{}'.format(name), pv)
         return con
     except Exception as e:
         log.error(str(e))
         return None
예제 #6
0
파일: lodb.py 프로젝트: sonnysk76/easydev
 def conODBC(self, name, user, password):
     dm = self._create_instance('com.sun.star.sdbc.DriverManager')
     pv = comun.set_properties((('user', user), ('password', password)))
     try:
         con = dm.getConnectionWithInfo('sdbc:odbc:{}'.format(name), pv)
         return con
     except Exception as e:
         log.error(str(e))
         return None
예제 #7
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
예제 #8
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