Update easymacro
This commit is contained in:
parent
54b2ed7913
commit
2e7a390a13
79
easymacro.py
79
easymacro.py
|
@ -184,7 +184,6 @@ DIR = {
|
||||||
'images': 'images',
|
'images': 'images',
|
||||||
'locales': 'locales',
|
'locales': 'locales',
|
||||||
}
|
}
|
||||||
DEFAULT_MIME_TYPE = 'png'
|
|
||||||
|
|
||||||
KEY = {
|
KEY = {
|
||||||
'enter': 1280,
|
'enter': 1280,
|
||||||
|
@ -219,6 +218,7 @@ MENUS = {
|
||||||
'show': '.uno:SlideShowMenu',
|
'show': '.uno:SlideShowMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFAULT_MIME_TYPE = 'png'
|
||||||
MIME_TYPE = {
|
MIME_TYPE = {
|
||||||
'png': 'image/png',
|
'png': 'image/png',
|
||||||
'jpg': 'image/jpeg',
|
'jpg': 'image/jpeg',
|
||||||
|
@ -917,54 +917,6 @@ class LOBaseObject(object):
|
||||||
return self._obj
|
return self._obj
|
||||||
|
|
||||||
|
|
||||||
class LOImage(object):
|
|
||||||
TYPE = {
|
|
||||||
'png': 'image/png',
|
|
||||||
'jpg': 'image/jpeg',
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, obj):
|
|
||||||
self._obj = obj
|
|
||||||
|
|
||||||
@property
|
|
||||||
def obj(self):
|
|
||||||
return self._obj
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
return self.obj.Name or 'img'
|
|
||||||
|
|
||||||
@property
|
|
||||||
def mimetype(self):
|
|
||||||
return self.obj.Bitmap.MimeType
|
|
||||||
|
|
||||||
def save(self, path, mimetype=DEFAULT_MIME_TYPE):
|
|
||||||
p = _P(path)
|
|
||||||
if _P.is_dir(path):
|
|
||||||
name = self.name
|
|
||||||
else:
|
|
||||||
path = p.path
|
|
||||||
name = p.name
|
|
||||||
|
|
||||||
path = _P.join(path, f'{name}.{mimetype.lower()}')
|
|
||||||
args = dict(
|
|
||||||
URL = _P.to_url(path),
|
|
||||||
MimeType = self.TYPE[mimetype],
|
|
||||||
)
|
|
||||||
if not _export_image(self.obj, args):
|
|
||||||
path = ''
|
|
||||||
|
|
||||||
# ~ size = len(self.obj.Bitmap.DIB)
|
|
||||||
# ~ data = self.obj.GraphicStream.readBytes((), size)
|
|
||||||
# ~ data = data[-1].value
|
|
||||||
|
|
||||||
# ~ data = self.obj.Bitmap.DIB.value
|
|
||||||
# ~ data = self.obj.Graphic.DIB.value
|
|
||||||
|
|
||||||
# ~ _P.save_bin(path, data)
|
|
||||||
return path
|
|
||||||
|
|
||||||
|
|
||||||
class LODocument(object):
|
class LODocument(object):
|
||||||
FILTERS = {
|
FILTERS = {
|
||||||
'doc': 'MS Word 97',
|
'doc': 'MS Word 97',
|
||||||
|
@ -2422,6 +2374,33 @@ class LOShape(LOBaseObject):
|
||||||
self.obj.Parent.remove(self.obj)
|
self.obj.Parent.remove(self.obj)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def save(self, path: str, mimetype=DEFAULT_MIME_TYPE):
|
||||||
|
if _P.is_dir(path):
|
||||||
|
name = self.name
|
||||||
|
ext = mimetype.lower()
|
||||||
|
else:
|
||||||
|
p = _P(path)
|
||||||
|
path = p.path
|
||||||
|
name = p.name
|
||||||
|
ext = p.ext.lower()
|
||||||
|
|
||||||
|
path = _P.join(path, f'{name}.{ext}')
|
||||||
|
args = dict(
|
||||||
|
URL = _P.to_url(path),
|
||||||
|
MimeType = MIME_TYPE[ext],
|
||||||
|
)
|
||||||
|
if not _export_image(self.obj, args):
|
||||||
|
path = ''
|
||||||
|
return path
|
||||||
|
|
||||||
|
# ~ def save2(self, path: str):
|
||||||
|
# ~ size = len(self.obj.Bitmap.DIB)
|
||||||
|
# ~ data = self.obj.GraphicStream.readBytes((), size)
|
||||||
|
# ~ data = data[-1].value
|
||||||
|
# ~ path = _P.join(path, f'{self.name}.png')
|
||||||
|
# ~ _P.save_bin(path, b'')
|
||||||
|
# ~ return
|
||||||
|
|
||||||
|
|
||||||
class LODrawPage(LOBaseObject):
|
class LODrawPage(LOBaseObject):
|
||||||
|
|
||||||
|
@ -2533,7 +2512,7 @@ class LODrawImpress(LODocument):
|
||||||
|
|
||||||
def paste(self):
|
def paste(self):
|
||||||
call_dispatch(self.frame, '.uno:Paste')
|
call_dispatch(self.frame, '.uno:Paste')
|
||||||
return self.selection
|
return self.current_page[-1]
|
||||||
|
|
||||||
def add(self, type_shape, args={}):
|
def add(self, type_shape, args={}):
|
||||||
return self.current_page.add(type_shape, args)
|
return self.current_page.add(type_shape, args)
|
||||||
|
|
Loading…
Reference in New Issue