Hi there, is there any way to apply a page style using uno commands?
I am doing:
function post(msg) {
window.frames[0].postMessage(JSON.stringify(msg), '*');
}
function changePageStyle(pageStyle) {
post({'MessageId': 'Send_UNO_Command',
'Values': {
'Command': '.uno:StyleApply',
'Args': {
Arg0Name: {
type: 'string',
value: 'Template'
},
Arg0Value: {
type: 'string',
value: pageStyle
},
Arg1Name: {
type: 'string',
value: 'Family'
},
Arg1Value: {
type: 'int', // also tried string, integer
value: 8
}
}
}
});
}
function receiveMessage(event) {
// Receive message from Iframe
console.log('ReceiveMessage: ' + event.data);
var msg = JSON.parse(event.data);
if (!msg) {
console.log('NO ReceiveMessage ');
}
}
window.addEventListener("message", receiveMessage, false);
changePageStyle("TemplateLandscape")
… and nothing is happening - the event listener is not fired, no console error. This shows in the log:
kit-00254-00022 2023-10-31 23:21:50.483970 +0000 [ kitbroker_00e ] DBG #18: child_ws: recv [child-0b2 uno .uno:StyleApply {"Arg0Name":{"type":"string","value":"Template"},"Arg0Value":{"type":"string","value":"TemplateLandscape"},"Arg1Name":{"type":"string","value":"Family"},"Arg1Value":{"type":"int","value":8}} | kit/Kit.cpp:2527
I am making assumptions regarding what the uno command arguments should be based on the following working BASIC snippet:
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Template"
args1(0).Value = "Landscape"
args1(1).Name = "Family"
args1(1).Value = 8
dispatcher.executeDispatch(document, ".uno:StyleApply", "", 0, args1())
Thanks