Using Liferay 6.1 CE, is there an easy way to create an 'empty' journalarticle based on a known structureId ?
The following code :
ja = JournalArticleLocalServiceUtil.addArticle(
themeDisplay.getUserId(),
themeDisplay.getScopeGroupId(),
0, 0, //classNameId, classPK,
"test-article", //articleId,
false, //autoArticleId,
JournalArticleConstants.VERSION_DEFAULT,
titleMap,
null, //descriptionMap,
content,
"general", // type,
BamboostConstants.SINGLE_CONTENT_STRUCTURE_ID,
null, // templateId,
StringPool.BLANK, //layoutUuid,
1, 1, 1970, 0, 0, // displayDateMonth, displayDateDay, displayDateYear,
// displayDateHour, displayDateMinute,
0, 0, 0, 0, 0, true, // expirationDateMonth, expirationDateDay,
// expirationDateYear, expirationDateHour,
//expirationDateMinute, neverExpire,
0, 0, 0, 0, 0, true, // reviewDateMonth, reviewDateDay, reviewDateYear,
//reviewDateHour, reviewDateMinute, neverReview,
true, // indexable,
false, StringPool.BLANK, null, // smallImage, smallImageURL, smallImageFile,
null, StringPool.BLANK, // images, articleURL,
serviceContext
);
works if content is a valid xml for the given structure, but doesn't if content is null or blank.
Is there is a method that returns the 'minimal' xml for a given structure, but can't find it.
Best regards,
Alain
I don't know of any method to do this , but this xml should suffice
<?xml version="1.0"?>
<root available-locales="en_US" default-locale="en_US">
<static-content language-id="en_US"><![CDATA[ ]]></static-content>
</root>
Related
Can I horizontally flip/reflect a shape item in QML. For example; I have the below shape:
Can I flip/reflect it horizontally to produce:
I know I could edit my QML code to draw the lines differently but it would be much simpler to just use a QML animation or something to flip it if thats possible.
Shape {
id: annotationHLine;
anchors.left: annotationShp.right;
anchors.top: annotationShp.top;
anchors.topMargin: annotationShp.height * 0.5;
ShapePath {
strokeWidth: 2;
strokeColor: "Green";
fillColor: "transparent";
startX: -slant; startY: 0;
PathLine { x: relativeTargetX*0.5; y: 0 }
PathLine { x: relativeTargetX; y: relativeTargetY }
}
}
you can use transform and Scale
transform: Scale{ xScale: -1 }
Yes you can, by simply setting a horizontal mirror transformation matrix to the shape:
transform: Matrix4x4 {
matrix: Qt.matrix4x4(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
}
Edit:
The x position doesn't really change, it is still the same, it is just that the object is now rendered with the transformation. You can compensate for that by stacking a translate on top of the matrix:
transform: [
Matrix4x4 {
matrix: Qt.matrix4x4(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
},
Translate {
x: annotationHLine.width
}
]
Edit 2:
Actually, you can incorporate the translation in the original matrix to simplify things a bit:
transform: Matrix4x4 {
matrix: Qt.matrix4x4( -1, 0, 0, but.width, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)}
}
I'm trying to write a window manager with a wallpaper switcher:
void smoke_change_background(smoke_wm_state_t *config, char *desktop) {
struct smoke_desktop_list_element_t *node = smoke_desktop_list_node(config->tree, desktop);
if (node->background != 0) {
xcb_intern_atom_reply_t *xpmap = xcb_intern_atom_reply(config->connection,
xcb_intern_atom(config->connection,
false,
strlen("_X_ROOTPMAP_ID"),
"_X_ROOTPMAP_ID"),
NULL);
xcb_intern_atom_reply_t *esetr = xcb_intern_atom_reply(config->connection,
xcb_intern_atom(config->connection,
false,
strlen("ESETROOT_PMAP_ID"),
"ESETROOT_PMAP_ID"),
NULL);
xcb_get_property_reply_t *xrepl = xcb_get_property_reply(config->connection,
xcb_get_property(config->connection,
0,
config->screen->root,
xpmap->atom,
XCB_ATOM_PIXMAP,
0,
32),
NULL);
uint32_t *xp = (uint32_t*) xcb_get_property_value(xrepl);
xcb_get_property_reply_t *erepl = xcb_get_property_reply(config->connection,
xcb_get_property(config->connection,
0,
config->screen->root,
esetr->atom,
XCB_ATOM_PIXMAP,
0, 32),
NULL);
uint32_t *ep = (uint32_t*) xcb_get_property_value(erepl);
xcb_change_property(config->connection,
XCB_PROP_MODE_REPLACE,
config->screen->root,
xpmap->atom,
XCB_ATOM_PIXMAP,
32, 1,
(void*) &node->background);
xcb_change_property(config->connection,
XCB_PROP_MODE_REPLACE,
config->screen->root,
esetr->atom,
XCB_ATOM_PIXMAP,
32, 1,
(void*) &node->background);
xcb_free_pixmap(config->connection, *xp);
xcb_free_pixmap(config->connection, *ep);
uint32_t values[1];
values[0] = node->background;
xcb_change_window_attributes(config->connection, config->screen->root, XCB_CW_BACK_PIXMAP, values);
xcb_clear_area(config->connection, false, config->screen->root, 0, 0, 0, 0);
xcb_flush(config->connection);
}
}
This code should change the root's pixmap and it should be displayed in my Xephyr window, but it is not. What's wrong?
i have object in state -
this.state = {
states: {
na: 0, s1a: 0, s2a: 0, s3a: 0, s4a: 0, l1a: 0, l2a: 0, l3a: 0, t1a: 0, t2a: 0, t3a: 0,
nb: 0, s1b: 0, s2b: 0, s3b: 0, s4b: 0, l1b: 0, l2b: 0, l3b: 0, t1b: 0, t2b: 0, t3b: 0
},
and i want to change value of some key i my function -
onInputUpdated(id){
var array = {};
let char = id.slice(-1);
switch(char){
case 'a':
array[id] = this.getY(ReactDOM.findDOMNode(this.refs[id].refs.inp).value);
break;
case 'b':
array[id] = this.getX(ReactDOM.findDOMNode(this.refs[id].refs.inp).value);
break;
}
this.setState({
states: { id : array[id]}
});
but there is no id, id represents string 'na' or others... so how i can do it? any tips pls? btw onIputUpdated(id) is callBack from children..
Firstly, you cant update nested states directly. You will to have to update the whole "states" object. Something like this
let oldStates = this.state.states;
oldStates[id] = array[id];
this.setState({
states: {
...oldStates
}
});
How to adjust the "font" for the following:(solved)
fontSize 40
BOLD
Italicized
Thanks
The following fails:(now works)
CFont *myFont = new CFont();
myFont->CreateFont( 40, 0, 0, 0, FW_HEAVY, true, false,
0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH|FF_MODERN, _T("Courier New") );
CEdit *ed1 = new CEdit();
ed1->Create(WS_VISIBLE | WS_BORDER,CRect(200,100,500,140),this,16);
ed1->SetFont(myFont);
Be sure not to delete myFont as long as your edit control is still around.
Here what i did, and it run for me :
CFont m_Font;
CEdit m_EditBox
CClientDC dc(this);
int nFontSize = 40;
int nHeight = -((dc.GetDeviceCaps(LOGPIXELSY) * nFontSize) / 72);
m_Font.CreateFont(nHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("Courier New"));
// Create edit box
if (m_EditBox.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_WANTRETURN | ES_READONLY, CRect(0, 0, 100, 100), this, 0x102) == FALSE) return FALSE;
// Set font
m_EditBox.SetFont(&m_Font, TRUE);
I have a button on an MFC dialog. How can I make the text bold?
class CYourDialog : CDialog
{
public:
virtual BOOL OnInitDialog(); // override
private:
CButton m_button;
CFont m_font;
};
BOOL CYourDialog::OnInitDialog()
{
__super::OnInitDialog();
CFont* font = m_button.GetFont();
LOGFONT logFont;
font->GetLogFont(&logFont);
logFont.lfWeight = FW_BOLD;
m_font.CreateFontIndirect(&logFont);
m_button.SetFont(&m_font);
return TRUE; // => system will set input focus to the first control item in the dialog box; (0 => you set the focus to a control of your choice)
}
You can create a new CFont and call WM_SETFONT on the button. Something like this:
// note: m_font is a class variable of type CFont
m_font.CreateFont(10, 0, 0, 0, FW_BOLD, 0, 0, 0, 0, 0, 0, 0, 0, "Arial")
GetDlgItem(IDC_BUTTON1)->SendMessage(WM_SETFONT, WPARAM(HFONT(font)), 0);