Bugzilla – Attachment 153492 Details for
Bug 127017
Copy-Paste doesn't work when Impress is not the focused instance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Script to get instances of LO Impress and LO Calc, then copy a slide in LO Impress
test.py (text/x-python), 2.00 KB, created by
Konstantin Kharlamov
on 2019-08-18 21:30:51 UTC
(
hide
)
Description:
Script to get instances of LO Impress and LO Calc, then copy a slide in LO Impress
Filename:
MIME Type:
Creator:
Konstantin Kharlamov
Created:
2019-08-18 21:30:51 UTC
Size:
2.00 KB
patch
obsolete
>import uno > >def connectToLO(): > # get the uno component context from the PyUNO runtime > localContext = uno.getComponentContext() > resolver = localContext.ServiceManager.createInstanceWithContext( > "com.sun.star.bridge.UnoUrlResolver", localContext ) > # connect to the running office > ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext") > smgr = ctx.ServiceManager > return (smgr, smgr.createInstanceWithContext( "com.sun.star.frame.Desktop", ctx)) > ># courtesy to https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=63966 >def copySlideTo(srcComponent, dstComponent, slide, insert_after, smgr): > srcController = srcComponent.CurrentController > dstController = dstComponent.CurrentController > dispatcher = smgr.createInstance("com.sun.star.frame.DispatchHelper") > srcController.setCurrentPage(slide) > ## begin: a magic to get damn thing copied > dispatcher.executeDispatch(srcController.Frame, ".uno:DiaMode", "", 0, ()) > dispatcher.executeDispatch(srcController.Frame, ".uno:Copy", "", 0, ()) > dispatcher.executeDispatch(srcController.Frame, ".uno:NormalMultiPaneGUI", "", 0, ()) > ## end: a magic to get damn thing copied > dstController.setCurrentPage(dstComponent.DrawPages.getByIndex(insert_after)) > dispatcher.executeDispatch(dstController.Frame, ".uno:Paste", "", 0, ()) > return dstComponent.DrawPages.getByIndex(insert_after+1) > >def getLOInstances(desktop): > loInstances = [c for c in desktop.Components] > assert(len(loInstances) == 2) > CALC_STR = 'ScModelObj' > IMPRESS_STR = 'SdXImpressDocument' > if IMPRESS_STR not in loInstances[0].ImplementationName: > loInstances = [loInstances[1], loInstances[0]] > assert(CALC_STR in loInstances[1].ImplementationName) > return loInstances > >(smgr, desktop) = connectToLO() >(impressApp, spreadsheetApp) = getLOInstances(desktop) >topSlideSample = impressApp.DrawPages.getByIndex(0) >copiedTopSlideSample = copySlideTo(impressApp, impressApp, topSlideSample, 0, smgr)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 127017
: 153492