The easiest way to do this is to use Plutext's commercial enterprise edition, from
http://www.plutext.com/m/index.php/productsYou'll find examples there covering both your requirements.
Otherwise, all the low level support you need to do it yourself is available in docx4j. But there may be a learning curve as you come to grips with OLE, assuming you're already comfortable with OpenXML and docx4j.