Files
loongoffice/odk/examples/DevelopersGuide/Text/TextDocuments.java
Release Engineers 810aa6e916 CWS-TOOLING: integrate CWS odfmetadata2
2009-06-22 11:48:36 +0200 mst  r273206 : - connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx:
  + add "include ustrbuf.hxx" to work around warning caused by
    solaris <sys/kstat.h> declaring a global "long l ;"
2009-06-19 14:25:25 +0200 mst  r273159 : - scp2/source/ooo/file_library_ooo.scp:
  + fix MinGW build
2009-06-08 12:52:33 +0200 mst  r272727 : - redland/raptor-1.4.18.patch.mingw, redland/raptor/makefile.mk:
  + disable parsers that do not build on MinGW (thanks for patch by tono)
2009-05-15 17:31:07 +0200 mst  r271957 : fix typos
2009-05-15 17:28:57 +0200 mst  r271956 : #i101965#
- offapi/com/sun/star/text/TextPortion:
  + add missing properties:
    SoftPageBreak, DocumentIndexMark, ReferenceMark, Footnote, TextField
  + fix read-only status of properties: Bookmark, IsStart, IsCollapsed
- offapi/type_reference/{typelibrary_history.txt,types.rdb}:
  + update reference types.rdb
2009-05-07 14:41:38 +0200 mst  r271669 : - sw/inc/{fmtftn.hxx,unocoll.hxx,doc.hxx,editsh.hxx,ftninfo.hxx},
  sw/source/core/layout/{flowfrm.cxx,ftnfrm.cxx},
  sw/source/core/doc/docftn.cxx, sw/source/core/edit/edattr.cxx,
  sw/source/core/txtnode/atrftn.cxx, sw/source/core/unocore/unocoll.cxx,
  sw/source/ui/fldui/fldref.cxx:
  + fix warning ... the hard way
  + also fix signature of SwDoc::SetCurFtn
2009-05-05 19:52:55 +0200 mst  r271556 : - sw/inc/undobj.hxx:
  + make some members const
2009-05-05 19:34:40 +0200 mst  r271555 : - sw/inc/rolbck.hxx, sw/source/core/undo/rolbck.cxx:
  + make some members const
2009-05-05 19:13:14 +0200 mst  r271553 : - sw/inc/{undobj.hxx,rolbck.hxx},
  sw/source/core/undo/{unbkmk.cxx,rolbck.cxx}:
  + fix rebase merge error
  + rename SwHstryBookmark to SwHistoryBookmark
  + clean up SwUndoBookmark
2009-05-05 19:05:53 +0200 mst  r271552 : - sw/source/core/unocore/unoportenum.cxx:
  + fix annoying assertion
2009-05-05 15:34:48 +0200 mst  r271522 : CWS-TOOLING: rebase CWS odfmetadata2 to trunk@271427 (milestone: DEV300:m47)
2009-05-04 12:37:01 +0200 mst  r271444 : trivial
2009-04-22 13:30:37 +0200 mst  r271102 : - sfx2/inc/sfx2/dinfdlg.hxx:
  + trivial change
2009-04-21 16:46:58 +0200 mst  r271043 : - sw/inc/hintids.hxx:
  + introduce some predicates for the various hints, and use them
2009-04-21 16:19:03 +0200 mst  r271041 : - sw/inc/undobj.hxx,
  sw/source/core/doc/{docfly.cxx,docfmt.cxx,docftn.cxx,doctxm.cxx},
  sw/source/core/undo/{unattr.cxx,unins.cxx}:
  + clean up unattr.cxx:
    remove/fix casts, prefix members, use auto_ptr, etc.
2009-04-21 15:34:23 +0200 mst  r271039 : - sw/inc/{rolbck.hxx,undobj.hxx},
  sw/source/core/doc/docfmt.cxx,
  sw/source/core/txtnode/{thints.cxx,txtedt.cxx},
  sw/source/core/undo/{rolbck.cxx,undel.cxx,undobj.cxx,unins.cxx,unmove.cxx,
    unovwr.cxx,unsect.cxx,unspnd.cxx,untbl.cxx,untblk.cxx,unattr.cxx}:
  + clean up SwHistory, SwRegHistory and SwHistoryHint etc.:
    remove/fix casts, prefix members, remove wrong const annotations,
    use auto_ptr, remove unused members, etc.
2009-04-20 19:17:36 +0200 mst  r271013 : - sw/inc/ndhints.hxx,
  sw/source/core/text/{itrtxt.cxx,txtftn.cxx,itratr.cxx,porfly.cxx,
    txtfrm.cxx,txtdrop.cxx,frmform.cxx},
  sw/source/core/txtnode/{ndtxt.cxx,ndhints.cxx,thints.cxx,txtedt.cxx},
  sw/source/core/edit/acorrect.cxx,
  sw/source/core/doc/{docedt.cxx,docfmt.cxx},
  sw/source/filter/html/swhtml.cxx:
  + clean up SwHintsArray and its subclasses: remove/fix casts, prefix members
2009-04-20 18:42:07 +0200 mst  r271007 : - sw/source/core/text/txtio.cxx, sw/source/core/edit/edattr.cxx,
  sw/source/core/undo/rolbck.cxx:
  + remove JP_NEWCORE dead code
2009-04-20 18:38:09 +0200 mst  r271006 : - sw/source/core/unocore/unochart.cxx:
  + silence unxlngi warning (debug=t)
2009-04-20 16:36:13 +0200 mst  r270991 : - sfx2/inc/sfx2/dinfdlg.hxx, sfx2/source/dialog/dinfdlg.cxx,
  sfx2/source/doc/objserv.cxx, sw/source/ui/fldui/flddinf.hxx:
  + trivial cleanups
2009-04-20 15:28:52 +0200 mst  r270990 : - sfx2/inc/sfx2/dinfdlg.hxx, sfx2/source/dialog/dinfdlg.cxx,
  sfx2/source/doc/objserv.cxx:
  + fix bug: replaying a macro with a DocumentInfoItem removes all
    user-defined properties
2009-03-10 15:08:20 +0100 mst  r269273 : - sfx2/source/doc/Metadatable.cxx:
  + add missing SolarMutex guards
2009-03-10 14:46:29 +0100 mst  r269272 : - unoxml/source/rdf/librdf_repository.cxx:
  + never free rdf_world because that would call libxm2 xmlCleanupParser
    (and, to add insult to injury, other libxml2 functions later...)
2009-03-06 19:02:44 +0100 mst  r269041 : argh! undo...
2009-03-06 19:00:58 +0100 mst  r269040 : fix #i99931#
- sw/source/ui/uno/unomod.cxx:
  + SwXViewSettings::_getSingleValue returns uninitialized memory
    for the ZoomType property if the value is PAGE_WIDTH_EXACT
2009-03-06 18:59:28 +0100 mst  r269039 : - sw/inc/ndtxt.hxx, sw/source/core/txtnode/ndtxt.cxx,
  sw/source/core/unocore/unoportenum.cxx:
  + fix some more wntmsci12 warnings...
2009-03-06 18:56:46 +0100 mst  r269038 : - sd/source/ui/slidesorter/model/SlsPageEnumerationProvider.cxx:
  + work around spurious warning on unxsoli4 debug=t
2009-03-05 14:02:01 +0100 mst  r268902 : - sw/inc/txatbase.hxx:
  + back to c-style casts, they also compile on wntmsci12...
2009-03-05 10:23:25 +0100 mst  r268882 : - comphelper/inc/comphelper/processfactory.hxx,
  comphelper/source/processfactory/processfactory.cxx:
  + revert change of return type of comphelper_getProcessComponentContext
    to Reference: does not build on wntmsci12
2009-03-04 19:08:09 +0100 mst  r268861 : - sw/source/core/txtnode/{atrtox.cxx,ndtxt.cxx}:
  + fix initialization
2009-03-04 14:37:30 +0100 mst  r268831 : - solenv/inc/target.mk:
  + fix CLASSPATH so complex tests run (fix by sb)
2009-03-04 14:36:30 +0100 mst  r268830 : - sw/inc/unoobj.hxx,
  sw/source/core/unocore/{unoparagraph.cxx,unoobj.cxx,unoobj2.cxx}:
  + SwXParaFrameEnumeration constructor now takes SwPaM, not SwUnoCrsr
  + move SwParaSelection into unoparagraph.cxx, as it is only used there
  + bugfix: replace SwUnoCrsrs on stack with SwCursors
2009-03-04 14:34:46 +0100 mst  r268829 : - sw/inc/pam.hxx, sw/source/core/crsr/pam.cxx,
  sw/source/core/edit/eddel.cxx, sw/source/core/doc/docredln.cxx,
  sw/source/core/undo/{untbl.cxx,undel.cxx}, sw/source/filter/rtf/swparrtf.cxx:
  + clean up SwPaM: prefix members
  + new constructor SwPosition(SwCntntNode&, xub_StrLen)
  + fix several broken SwPosition and SwPaM constructors
  + SwPam::DeleteMark now actually resets the unused position to default
2009-03-02 12:07:09 +0100 mst  r268646 : - sw/inc/fmtcol.hxx:
  + fix annoying warning (gcc 4)
2009-03-02 12:06:27 +0100 mst  r268645 : - odk/util/check.pl, odk/examples/DevelopersGuide/Text/TextDocuments.java:
  + rename module from FieldMaster to fieldmaster
2009-02-27 19:49:56 +0100 mst  r268614 : - sfx2/inc/sfx2/Metadatable.hxx, sfx2/prj/d.lst,
  sfx2/source/doc/{Metadatable.cxx,makefile.mk},
  sw/inc/{SwMetadatable.hxx,unoobj.hxx,undobj.hxx,ndtxt.hxx},
  sw/source/core/doc/{SwMetadatable.cxx,makefile.mk,docnew.cxx},
  sw/source/core/undo/{untbl.cxx,unins.cxx},
  sw/source/core/unocore/unoparagraph.cxx, sw/source/ui/app/docsh.cxx:
  + move Metadatable implementation from sw to sfx2
2009-02-27 17:58:55 +0100 mst  r268608 : - sw/inc/{SwMetadatable.hxx,undobj.hxx}, sw/source/core/doc/SwMetadatable.cxx,
  sw/source/core/undo/{untbl.cxx,unins.cxx,undel.cxx}:
  + CreateUndo now returns an opaque MetadatableUndo object
2009-02-27 13:15:44 +0100 mst  r268587 : - sw/inc/ndtxt.hxx, sw/source/core/doc/docfmt.cxx,
  sw/source/core/text/{itratr.cxx,porlay.cxx},
  sw/source/core/txtnode/{txtedt.cxx,ndtxt.cxx,thints.cxx}:
  + clean up SwTxtNode: fix casts, prefix members
  + factor out inline function SwTxtNode::TryDeleteSwpHints()
2009-02-27 13:14:30 +0100 mst  r268586 : - svx/inc/svx/emphitem.hxx:
  + fix borken header guard
2009-02-27 13:13:56 +0100 mst  r268585 : - sfx2/source/bastyp/progress.cxx:
  + fix use of compiler specific macro
2009-02-27 11:00:32 +0100 mst  r268564 : - sw/inc/{txatbase.hxx,txtatr.hxx,txtinet.hxx,txtfld.hxx,txtftn.hxx,
    txtflcnt.hxx,txttxmrk.hxx,txtrfmrk.hxx},
  sw/source/core/txtnode/{atrtox.cxx,atrref.cxx,atrflyin.cxx,atrftn.cxx,
    txtatr2.cxx,txatbase.cxx,atrfld.cxx,txtedt.cxx},
  sw/source/core/text/atrstck.cxx, sw/source/core/access/acchyperlink.cxx,
  sw/source/core/doc/visiturl.cxx, sw/source/ui/wrtsh/wrtsh2.cxx:
  + clean up SwTxtAttr and its subclasses: remove/fix casts, prefix members
  + SwTxtINetFmt: remove unused member bColor
- sw/source/core/text/txtfld.cxx:
  + move SwTxtFld methods to atrfld.cxx
2009-02-27 10:58:44 +0100 mst  r268563 : - sfx2/inc/sfx2/sfxbasemodel.hxx:
  + don't privately inherit BaseMutex, ScModelObj wants to access it
2009-02-27 10:58:02 +0100 mst  r268562 : - xmloff/source/core/{RDFaExportHelper.cxx,RDFaImportHelper.cxx}:
  + arrrgh!!! someone thought it would be a good idea to have 2 different
    versions of boost in external! and they're NOT compatible!!!
    insert an ugly fragile hack that maybe works with both...
2009-02-26 17:42:26 +0100 mst  r268544 : - comphelper/inc/comphelper/storagehelper.hxx.
  sfx2/source/doc/DocumentMetadataAccess.cxx:
  +  someone made IsValidZipEntryFileName a static method and didn't tell me
2009-02-26 15:52:56 +0100 mst  r268529 : redland: split up patches
2009-02-26 13:17:56 +0100 mst  r268509 : migration of cws odfmetadata2 from CVS (resync to m42): module sw
#i95863#
- sw/inc/segdefs{,_}.hxx:
  + remove obsolete files
- sw/source/ui/inc/itemdef.hxx:
  + remove itemdef.hxx
- sw/source/ui/app/[apphdl.cxx,docsh.cxx}, sw/source/ui/misc/glshell.cxx,
  sw/source/ui/shells/*.cxx, sw/source/ui/uiview/*.cxx, sw/source/ui/web/*.cxx:
  + use sfx2/msg.hxx instead of itemdef.hxx
- sw/source/core/edit/eddel.cxx:
  + @ JP: SwEditShell::Replace:
    you're right, deleting the text to be replaced first, and then inserting
    a space, and then replacing that space is unnecessary.
    whew, i'm so happy that we finally answered that question after 11 years.
- sw/inc/edimp.hxx:
  + remove FOREACHCURSOR_START, FOREACHCURSOR_END
- sw/inc/{swcrsr.hxx,unocrsr.hxx,viscrs.hxx},
  sw/source/core/crsr/{crsrsh.cxx,swcrsr.cxx,trvlreg.cxx,trvltbl.cxx,
    unocrsr.cxx,viscrs.cxx},
  sw/source/core/doc/{docbm.cxx,doccorr.cxx},
  sw/source/core/docnode/{ndtbl.cxx,ndtbl1.cxx},
  sw/source/core/edit/editsh.cxx,
  sw/source/core/frmedt/{fefly1.cxx,fetab.cxx,tblsel.cxx},
  sw/source/core/layout/trvlfrm.cxx,
  sw/source/core/unocore/{unochart.cxx,unoobj2.cxx,unoparagraph.cxx,
    unoportenum.cxx,unotbl.cxx},
  sw/source/core/view/vprint.cxx:
  + remove the hideous  virtual operator SwFooCursor*
  + make SwCursor::IsReadOnlyAvailable() virtual
  + make SwUnoCrsr::Clone() virtual
  + refactor SwCursor methods IsSelOver(), LeftRight(), UpDown(), GotoTable():
    replace dynamic_cast<...>(this) with new virtual methods
2009-02-26 13:14:58 +0100 mst  r268508 : migration of cws odfmetadata2 from CVS (resync to m42): module sw
- sw/source/filter/xml/swxml.cxx:
  + XMLReader::Read: load RDF metadata of the ODF document
- sw/source/filter/xml/wrtxml.cxx:
  + SwXMLWriter::_Write: write RDF metadata of the ODF document if ODF >= 1.2
#i90620#: import xml:id in text tables (does not actually work yet)
- sw/source/filter/xml/xmltbli{.hxx,.cxx}:
  + SwXMLTableCellAttrTokens,aTableCellAttrTokenMap: add XML_TOK_TABLE_XMLID
  + SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl:  attribute xml:id
  + SwXMLTableCellContext_Impl::CreateChildContext:  attribute xml:id
  + SwXMLTableColContext_Impl::SwXMLTableColContext_Impl:  attribute xml:id
  + SwXMLTableContext::SwXMLTableContext:  attribute xml:id
fix #i98530#
- sw/inc/unoport.hxx, sw/source/core/unocore/unoport.cxx:
  + SwXTextPortion: make constructor params const&
- sw/source/core/unocore/unoportenum.cxx:
  + refactor to remove some code duplication
  + fix bug: paragraph w/out hints: bookmark before frame gets lost
#i97274# handle invalid tables
- sw/source/core/layout/tabfrm.cxx, sw/source/filter/xml/xmltbli.cxx:
  + SwXMLTableContext::MakeTable():
    check that the table actually contains cells,
    and abort (removing the inserted table nodes) if not
2009-02-26 13:11:48 +0100 mst  r268507 : migration of cws odfmetadata2 from CVS (resync to m42): module sw
refactor SwXTextRange and SwXParagraph
- sw/inc/unoobj.hxx, sw/source/core/unocore/unoobj2.cxx:
  + remove 3 constructors of SwXTextRange
  + new method SwXTextRange::CreateParentXText
  + refactor SwXTextRange::CreateTextRangeFromPosition and
    SwXTextRange::getText
- sw/inc/unoobj.hxx, sw/source/core/unocore/unoparagraph.cxx:
  + SwXParagraph no longer uses a cursor; it registers directly at SwTxtNode
  + replace SwXParagraph::GetCrsr with SwXParagraph::GetTxtNode
- sw/source/core/unocore/unotext.cxx, sw/source/ui/uno/unotxvw.cxx:
  + adapt to new SwXParagraph
#i90620#
- sw/inc/SwMetadatable.hxx,
  sw/source/core/doc/SwMetadatable.cxx:
  + new files: base classes sw::Metadatable and sw::MetadatableMixin;
    also, 2 implementations of IXmlIdRegistry:
    sw::XmlIdRegistryDocument and sw::XmlIdRegistryClipboard
  + setMetadataReference: handle empty stream name as auto-detect
- sw/source/core/doc/makefile.mk:
  + add SwMetadatable
add a XmlIdRegistry to SwDoc
- sw/inc/doc.hxx:
  + SwDoc: add member m_pXmlIdRegistry, method GetXmlIdRegistry()
- sw/source/core/doc/docnew.cxx:
  + initialize XmlIdRegistry in SwDoc::GetXmlIdRegistry, not in constructor,
    because the constructor is not told whether the SwDoc is a clipboard
- sw/inc/docsh.hxx, sw/source/ui/app/docsh.cxx:
  + SwDocShell: override GetXmlIdRegistry()
#i91563#: make the SwTxtNode metadatable
- sw/inc/ndtxt.hxx
  + SwTxtNode inherits sw::Metadatable
- sw/inc/unoobj.hxx, sw/source/core/unocore/unoparagraph.cxx:
  + SwXParagraph inherits sw::MetadatableMixin
#i91563#: handle SwTxtNode's metadata for delete
- sw/source/core/txtnode/ndtxt.cxx:
  + SwTxtNode::SplitCntntNode: handle XmlId
  + SwTxtNode::JoinNext: merge XmlIds
- sw/source/core/doc/docedt.cxx:
  + lcl_GetJoinFlags: document postcondition
  + SwDoc::Delete: remove XmlId only if SwTxtNode _becomes_ empty
#i91563#: handle SwTxtNode's metadata for delete with undo
- sw/inc/undobj.hxx
  + SwUndoDelete: new members m_pMetadataUndoStart, m_pMetadataUndoEnd
- sw/source/core/undo/undel.cxx:
  + SwUndoDelete::SaveCntnt: save XmlIds for start and end SwTxtNode
  + SwUndoDelete::SaveCntnt: remove XmlId only if SwTxtNode _becomes_ empty
  + SwUndoDelete::Undo: restore saved XmlIds for start and end SwTxtNode
- sw/source/core/docnode/ndcopy.cxx:
  + SwTxtNode::MakeCopy: register copy at XmlIdRegistry
#i91563#: handle SwTxtNode's metadata for find/replace with undo
- sw/source/core/undo/unins.cxx:
  + _UnReplaceData: rename members: add prefix m_
  + _UnReplaceData: new members m_pMetadataUndoStart, m_pMetadataUndoEnd
  + _UnReplaceData::_UnReplaceData: save XmlIds for start and end SwTxtNode
  + _UnReplaceData::Undo: restore saved XmlIds for start and end SwTxtNode
#i91563#: handle SwTxtNode's metadata for table-to-text with undo
- sw/source/core/undo/untbl.cxx:
  + SwTblToTxtSave: rename members: add prefix m_
  + SwTblToTxtSave: new members m_pMetadataUndoStart, m_pMetadataUndoEnd
  + SwTblToTxtSave::SwTblToTxtSave: save XmlIds for start and end SwTxtNode
  + SwTblToTxtSave::SwTblToTxtSave, SwNodes::UndoTableToText:
    always store the index of the first SwTxtNode in the cell, instead of
    the index of the first SwTxtNode in case of the first cell in a row,
    and the cell start node in other cases
  + SwNodes::UndoTableToText: restore saved XmlIds for start and end SwTxtNode
- sw/source/core/docnode/ndtbl.cxx:
  + lcl_DelBox: simplify for refactored start index handling in SwTblToTxtSave
2009-02-26 13:02:28 +0100 mst  r268505 : migration of cws odfmetadata2 from CVS (resync to m42): module sd
- sd/source/ui/table/tableobjectbar.cxx,sd/source/ui/view/*.cxx:
  + remove invocations of SFX_DECL_TYPE
- sd/source/ui/slideshow/SlideShowRestarter.cxx,
  sd/source/ui/toolpanel/LayoutMenu.cxx,
  sd/source/ui/unoidl/DrawController.cxx,
  sd/source/ui/view/{ViewShellBase.cxx,ViewTabBar.cxx,frmview.cxx}:
  + fix abuses of comphelper_getProcessComponentContext (missing release)
2009-02-26 13:01:24 +0100 mst  r268504 : migration of cws odfmetadata2 from CVS (resync to m42): module starmath
- starmath/source/document.cxx:
  + don't touch SfxObjectShell's privates
2009-02-26 13:00:37 +0100 mst  r268503 : migration of cws odfmetadata2 from CVS (resync to m42): module sfx2
#i90620#
- sfx2/inc/sfx2/XmlIdRegistry.hxx:
  + new file: interfaces sfx2::IXmlIdRegistry and sfx2::IXmlIdRegistrySupplier
    and a couple of utility functions
- sfx2/inc/sfx2/DocumentMetadataAccess.hxx,
  sfx2/source/doc/DocumentMetadataAccess.cxx:
  + new class sfx2::DocumentMetadataAccess, implements XDocumentMetadataAccess
  + the URI of the DocumentMetadataAccess is now the URI from which the
    document was loaded; for a new document, use a vnd.sun.star.tdoc URI
  + add new function sfx2::createBaseURI()
  + prevent using reserved file names
  + try not to recurse into embedded subdocuments
- sfx2/source/doc/makefile.mk:
  + add DocumentMetadataAccess
- sfx2/util/makefile.mk:
  + link libsfx2 against libxml2 (needed for xmlValidateNCName)
- sfx2/source/doc/makefile.mk:
  + add LIBXML_CFLAGS to CFLAGS
- sfx2/prj/build.lst:
  + add dependence on libxml2
- sfx2/prj/d.lst:
  + add XmlIdRegistry.hxx, DocumentMetadataAccess.hxx
- sfx2/inc/sfx2/objsh.hxx, sfx2/source/doc/objxtor.cxx:
  + make SfxObjectShell's members private
  + new method SfxObjectShell::GetAutoStyleFilterIndex
  + SfxObjectShell inherits sfx2::IXmlIdRegistrySupplier
- sfx2/source/dialog/templdlg.cxx, sfx2/source/doc/sfxbasemodel.cxx:
  + don't touch SfxObjectShell's privates
- sfx2/inc/sfx2/sfxbasemodel.hxx, sfx2/source/doc/sfxbasemodel.cxx:
  + SfxBaseModel inherits BaseMutex instead of IMPL_SfxBaseModel_MutexContainer
  + SfxBaseModel implements additional interface XDocumentMetadataAccess
  + IMPL_SfxBaseModel_DataContainer has new member:
    a sfx2::DocumentMetadataAccess
  + implementation of XDocumentMetadataAccess forwards to
    the sfx2::DocumentMetadataAccess member
- sfx2/qa/complex/DocumentMetadataAccessTest.java,
  sfx2/qa/complex/{tests.sce,makefile.mk},
  sfx2/qa/complex/testdocuments/TESTRDFA.odt:
  + add complex test: DocumentMetadataAccessTest
  + add RDFa test document
#i95863#
- sfx2/inc/sfx2/dinfdlg.hxx, sfx2/source/dialog/dinfdlg.cxx:
  + refactor SfxDocumentItem so it no longer requires a XDocumentInfo
  + move struct CustomProperty to implementation file
  + remove class SfxDocumentUserPage
  + QueryValue,PutValue: remove MID_DOCINFO_FIELD*
- sfx2/source/doc/objserv.cxx:
  + adapt to SfxDocumentItem change
- sfx2/inc/sfx2/sfx.hrc, sfx2/sdi/sfxslots.sdi, sfx2/inc/sfx2/msg.hxx:
  + remove MID_DOCINFO_FIELD*
  + put all invocations of SFX_DECL_TYPE in msg.hxx, and undef SFX_DECL_TYPE
- sfx2/source/doc/objxtor.cxx:
  + fix abuses of comphelper_getProcessComponentContext (missing release)
- sfx2/source/doc/docfile.cxx:
  + SfxMedium::SfxMedium: don't dereference NULL, throw exception instead
- sfx2/source/doc/objstor.cxx:
  + SfxObjectShell::DoLoad: fix bug: DocumentBaseURI is not initialized
2009-02-26 12:58:07 +0100 mst  r268502 : migration of cws odfmetadata2 from CVS (resync to m42): module xmloff
#i90620#: implement RDFa import (interface change)
- xmloff/inc/xmloff/xmlimp.hxx. xmloff/source/core/xmlimp.cxx:
  + make SvXMLImport::GetAbsoluteReference() const
  + add SvXMLImport::GetComponentContext()
  + SvXMLImport::_InitCtor(): add RDFa namespace
  + add SvXMLImport::AddRDFa()
  + SvXMLImport::endDocument() inserts RDFa into document repository
- xmloff/inc/xmloff/xmltoken.hxx, xmloff/source/core/xmltoken.cxx:
  + new tokens for RDFa: XML_ABOUT, XML_DATATYPE
- xmloff/inc/RDFaImportHelper.hxx, xmloff/source/core/RDFaImportHelper.cxx:
  + new class RDFaImportHelper
  + adapt the code to the bleak reality of broken C++ implementations
  + handle empty xhtml:about attributes properly, which are actually
    valid relative URIs
  + work around broken SvXMLImport::GetAbsoluteReference
- xmloff/source/core/makefile.mk:
  + add RDFaImportHelper.cxx
#i90620#: implement RDFa export
- xmloff/inc/xmloff/xmlexp.hxx, xmloff/source/core/xmlexp.cxx:
  + add SvXMLExport::EnsureNamespace(), and a stack of namespace maps
  + add SvXMLExport::GetComponentContext()
  + add SvXMLExport::AddAttributesRDFa()
- xmloff/inc/RDFaExportHelper.hxx, xmloff/source/core/RDFaExportHelper.cxx:
  + new class RDFaExportHelper
  + don't use std::map::data_type, which is actually called
    std::map::mapped_type by libstdc++
- xmloff/source/core/makefile.mk:
  + add RDFaExportHelper.cxx
#i91563#
- xmloff/inc/xmloff/txtimp.hxx, xmloff/source/text/txtimp.cxx:
  + XMLTextPAttrTokens: add RDFa tokens
- xmloff/source/text/txtparai{.hxx,.cxx}:
  + import RDFa for text:p
- xmloff/source/text/txtparae.cxx:
  + export RDFa for text:p
interface change: use XHTML namespace instead of RDFA
- xmloff/inc/xmlnmspe.hxx, xmloff/inc/xmloff/xmltoken.hxx,
  xmloff/source/core/{xmltoken.cxx,xmlimp.cxx,xmlexp.cxx,RDFaExportHelper.cxx},
  xmloff/source/text/txtimp.cxx:
  + use XHTML namespace instead of RDFA
#i91565#, #i91566#: (preliminary) import for text:meta, text:meta-field
- xmloff/source/text/txtparai.cxx:
  + new class XMLMetaImportContextBase with subclasses to import
    text:meta and text:meta-field
- xmloff/source/text/XMLTextMarkImportContext.cxx:
  + change XMLTextMarkImportContext::CreateAndInsertMark to handle marks
    with no name (text:meta)
#i91565#, #i91566#: (preliminary) export for text:meta, text:meta-field
- xmloff/inc/txtflde.hxx, xmloff/source/text/txtflde.cxx:
  + add FIELD_ID_META to FieldIdEnum
  + new method XMLTextFieldExport::ExportMetaField()
  + change XMLTextFieldExport::ExportField{,AutoStyle,Helper}
    to take additional parameter for progress bar
- xmloff/inc/xmloff/txtparae.hxx, xmloff/source/text/txtparae.cxx:
  + make XMLTextParagraphExport::exportTextRangeEnumeration() public
  + new method XMLTextParagraphExport::exportMeta()
#i90620#
- xmloff/inc/xmloff/xmlimp.hxx, xmloff/source/core/xmlimp.cxx,
  xmloff/inc/xmloff/xmlexp.hxx, xmloff/source/core/xmlexp.cxx:
  + rename SvXML{Im,Ex}port::GetStreamPath() to GetStreamName()
  + fix xml:id {im,ex}port for embedded documents and non-packages
  + adapt to API change: XMetadatable
#i90620# GRDDL
- xmloff/inc/xmlnmspe.hxx, xmloff/inc/xmloff/xmltoken.hxx,
  xmloff/source/core/{xmltoken.cxx,xmlexp.cxx}:
  + add GRDDL namespace
  + add token XML_TRANSFORMATION
  + add grddl:transformation attribute to root elements for meta.xml,
    content.xml and styles.xml
2009-02-26 12:54:40 +0100 mst  r268501 : migration of cws odfmetadata2 from CVS (resync to m42): module unoxml
#i90620#
- unoxml/source/rdf/librdf_repository.cxx:
  + librdf_Repository::importGraph: allocate buffer sized length of stream
  + switch from one librdf_world per repository to a single static world
    because redland has global variables with a brain-damaged life-cycle...
  + exportGraph: use new raptor 1.4.18 feature to disable writing
    an xml:base attribute in RDF/XML files
- unoxml/source/rdf/librdf_repository.cxx:
  unoxml/qa/complex/RDFRepositoryTest.java:
  + adapt to predicate is URI change
  + adapt to RDFa API change
  + adapt to API change: RDFa has multiple predicates...
  + adapt to API change: XMetadatable derives from XURI
  + allow xhtml:datatype without xhtml:content
  + adapt to API change: attribute MetadataReference is StringPair
- unoxml/source/rdf/CURI.cxx:
  + add some more URI constants
2009-02-26 12:53:32 +0100 mst  r268500 : migration of cws odfmetadata2 from CVS (resync to m42): module package
- package/inc/ImplValidCharacters.hxx:
  + remove (moved to comphelper)
2009-02-26 12:52:49 +0100 mst  r268499 : migration of cws odfmetadata2 from CVS (resync to m42): module comphelper
- comphelper/inc/comphelper/processfactory.hxx,
  comphelper/source/processfactory/processfactory.cxx:
  + add getProcessComponentContext()
  + change return type of comphelper_getProcessComponentContext to Reference
- comphelper/inc/comphelper/stl_types.hxx:
  + add OUStringBufferAppender
  + add algorithm intersperse
- comphelper/source/misc/string.cxx:
  + rewrite convertCommaSeparated with intersperse and OUStringBufferAppender
- comphelper/inc/comphelper/stlunosequence.hxx:
  + fix bug: begin() on empty sequence != end()
2009-02-26 12:50:47 +0100 mst  r268498 : migration of cws odfmetadata2 from CVS (resync to m42): module offapi
#i96209#
- offapi/com/sun/star/text/fieldmaster/*.idl:
  + rename module from FieldMaster to fieldmaster
- offapi/type_reference/{typelibrary_history.txt,types.rdb}:
  + update reference types.rdb
#i90620#
- offapi/com/sun/star/rdf/{XMetadatable.idl,XDocumentMetadataAccess.idl}:
  + API change: XMetadatable derives from XURI
  + API change: replace XmlId (string) with MetadataReference (StringPair)
- offapi/com/sun/star/rdf/{Statement.idl,XDocumentRepository.idl,
  XNamedGraph.idl,XRepository.idl}:
  + the predicate of a statement is a URI, not a Resource
- offapi/com/sun/star/rdf/XDocumentMetadataAccess.idl:
  + rename: s/Package/Document/
  + remove uuid
  + remove everything related to mapping
  + graph names are now generated from base URI and file names
  + load methods: improve error handling with XInteractionHandler
- offapi/com/sun/star/rdf/XDocumentRepository.idl:
  + change: RDFa permits using multiple predicates in one attribute
  + setStatementRDFa: subject is now XResource, object is now XMetadatable
- offapi/com/sun/star/rdf/URIs.idl:
  + add some more URI constants
- offapi/com/sun/star/rdf:
  + fix @since tags and replace <method> with <member>
2009-02-26 12:47:24 +0100 mst  r268497 : migration of cws odfmetadata2 from CVS (resync to m42): module redland
fix #i93768#
- redland/raptor-1.4.17.patch, redland/raptor/makefile.mk:
  + disable GRDDL parser to prevent call to libxslt
    xsltSetDefaultSecurityPrefs, which breaks xmlhelp
- redland/raptor/makefile.mk, redland/raptor-1.4.17.patch,
  redland/raptor-1.4.18.patch:
  + upgrade raptor to 1.4.18
  + deactivate serializer for RSS/Atom (does not build)
- redland/rasqal/makefile.mk, redland/rasqal-0.9.15.patch,
  redland/rasqal-0.9.16.patch,
  + upgrade rasqal to 0.9.16
- redland/redland/makefile.mk, redland/redland-1.0.7.patch,
  redland/redland-1.0.8.patch:
  + upgrade redland to 1.0.8
- redland/redlandversion.mk:
  + the librasqal SONAME has changed
2009-07-02 09:05:03 +00:00

1799 lines
78 KiB
Java

/*************************************************************************
*
* $RCSfile: TextDocuments.java,v $
*
* $Revision: 1.5 $
*
* last change: $Author: rt $ $Date: 2005-01-31 16:56:34 $
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
*
* Copyright (c) 2003 by Sun Microsystems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Sun Microsystems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*************************************************************************/
import com.sun.star.awt.Point;
import com.sun.star.awt.Size;
import com.sun.star.awt.FontWeight;
import com.sun.star.beans.PropertyState;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.beans.XPropertyState;
import com.sun.star.bridge.XUnoUrlResolver;
import com.sun.star.comp.servicemanager.ServiceManager;
import com.sun.star.connection.XConnector;
import com.sun.star.connection.XConnection;
import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNameContainer;
import com.sun.star.container.XNamed;
import com.sun.star.container.XIndexAccess;
import com.sun.star.container.XIndexReplace;
import com.sun.star.container.XEnumeration;
import com.sun.star.container.XEnumerationAccess;
import com.sun.star.drawing.XShape;
import com.sun.star.drawing.XShapeGrouper;
import com.sun.star.drawing.XShapes;
import com.sun.star.drawing.XDrawPageSupplier;
import com.sun.star.frame.XDesktop;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XModel;
import com.sun.star.frame.XController;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.style.NumberingType;
import com.sun.star.style.XStyle;
import com.sun.star.style.XStyleFamiliesSupplier;
import com.sun.star.table.XCell;
import com.sun.star.text.ControlCharacter;
import com.sun.star.text.ReferenceFieldSource;
import com.sun.star.text.ReferenceFieldPart;
import com.sun.star.text.TextColumn;
import com.sun.star.text.TextContentAnchorType;
import com.sun.star.text.XAutoTextContainer;
import com.sun.star.text.XAutoTextGroup;
import com.sun.star.text.XAutoTextEntry;
import com.sun.star.text.XDependentTextField;
import com.sun.star.text.XDocumentIndex;
import com.sun.star.text.XFootnote;
import com.sun.star.text.XFootnotesSupplier;
import com.sun.star.text.XParagraphCursor;
import com.sun.star.text.XReferenceMarksSupplier;
import com.sun.star.text.XRelativeTextContentInsert;
import com.sun.star.text.XSentenceCursor;
import com.sun.star.text.XSimpleText;
import com.sun.star.text.XText;
import com.sun.star.text.XTextColumns;
import com.sun.star.text.XTextContent;
import com.sun.star.text.XTextCursor;
import com.sun.star.text.XTextDocument;
import com.sun.star.text.XTextField;
import com.sun.star.text.XTextFrame;
import com.sun.star.text.XTextRange;
import com.sun.star.text.XTextSection;
import com.sun.star.text.XTextTable;
import com.sun.star.text.XTextTableCursor;
import com.sun.star.text.XTextTablesSupplier;
import com.sun.star.text.XTextFieldsSupplier;
import com.sun.star.text.XBookmarksSupplier;
import com.sun.star.text.XTextViewCursorSupplier;
import com.sun.star.text.XTextViewCursor;
import com.sun.star.text.XPageCursor;
import com.sun.star.text.XWordCursor;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.uno.XInterface;
import com.sun.star.uno.XNamingService;
import com.sun.star.util.XRefreshable;
import com.sun.star.frame.XStorable;
import com.sun.star.view.XPrintable;
import java.lang.Math;
import java.util.Random;
import java.util.Hashtable;
/*
* TextDocuments.java
*
* Created on 11. April 2002, 08:47
*/
/**
*
* @author Martin Gallwey, Dietrich Schulten
*/
public class TextDocuments {
// adjust these constant to your local printer!
private static String sOutputDir;
private String aPrinterName = "\\\\so-print\\xml3sof";
private XComponentContext mxRemoteContext = null;
private XMultiComponentFactory mxRemoteServiceManager = null;
private XTextDocument mxDoc = null;
private XMultiServiceFactory mxDocFactory = null;
private XMultiServiceFactory mxFactory = null;
private XPropertySet mxDocProps = null;
private XText mxDocText = null;
private XTextCursor mxDocCursor = null;
private XTextContent mxFishSection = null;
private Random maRandom = null;
/** Creates a new instance of TextDocuments */
public TextDocuments() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
TextDocuments textDocuments1 = new TextDocuments();
try {
// output directory for store test;
sOutputDir = args[0];
textDocuments1.runDemo();
}
catch (java.lang.Exception e){
System.out.println(e.getMessage());
e.printStackTrace();
}
finally {
System.exit(0);
}
}
protected void runDemo() throws java.lang.Exception {
storePrintExample(); // depends on printer name
templateExample();
viewCursorExample(); // makes changes to the current document,
// use with care
editingExample();
}
/** Sample for use of templates
* This sample uses the file TextTemplateWithUserFields.odt from the Samples
* folder. The file contains a number of User text fields (Variables - User)
* and a bookmark which we use to fill in various values
*/
protected void templateExample() throws java.lang.Exception {
// create a small hashtable that simulates a rowset
Hashtable recipient = new Hashtable();
recipient.put("Company", "Manatee Books");
recipient.put("Contact", "Rod Martin");
recipient.put("ZIP", "34567");
recipient.put("City", "Fort Lauderdale");
recipient.put("State", "Florida");
// load template with User fields and bookmark
java.io.File sourceFile = new java.io.File("TextTemplateWithUserFields.odt");
StringBuffer sTemplateFileUrl = new StringBuffer("file:///");
sTemplateFileUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
XComponent xTemplateComponent =
newDocComponentFromTemplate( sTemplateFileUrl.toString() );
// get XTextFieldsSupplier, XBookmarksSupplier interfaces
XTextFieldsSupplier xTextFieldsSupplier = (XTextFieldsSupplier)
UnoRuntime.queryInterface(XTextFieldsSupplier.class,
xTemplateComponent);
XBookmarksSupplier xBookmarksSupplier = (XBookmarksSupplier)
UnoRuntime.queryInterface(XBookmarksSupplier.class, xTemplateComponent);
// access the TextFields and the TextFieldMasters collections
XNameAccess xNamedFieldMasters = xTextFieldsSupplier.getTextFieldMasters();
XEnumerationAccess xEnumeratedFields = xTextFieldsSupplier.getTextFields();
// iterate over hashtable and insert values into field masters
java.util.Enumeration keys = recipient.keys();
while(keys.hasMoreElements()) {
// get column name
String key = (String)keys.nextElement();
// access corresponding field master
Object fieldMaster = xNamedFieldMasters.getByName(
"com.sun.star.text.fieldmaster.User." + key);
// query the XPropertySet interface, we need to set the Content property
XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, fieldMaster);
// insert the column value into field master
xPropertySet.setPropertyValue("Content", recipient.get(key));
}
// afterwards we must refresh the textfields collection
XRefreshable xRefreshable = (XRefreshable)UnoRuntime.queryInterface(
XRefreshable.class, xEnumeratedFields);
xRefreshable.refresh();
// accessing the Bookmarks collection of the document
XNameAccess xNamedBookmarks = xBookmarksSupplier.getBookmarks();
// find the bookmark named "Subscription"
Object bookmark = xNamedBookmarks.getByName("Subscription");
// we need its XTextRange which is available from getAnchor(),
// so query for XTextContent
XTextContent xBookmarkContent = (XTextContent)UnoRuntime.queryInterface(
XTextContent.class, bookmark);
// get the anchor of the bookmark (its XTextRange)
XTextRange xBookmarkRange = xBookmarkContent.getAnchor();
// set string at the bookmark position
xBookmarkRange.setString("subscription for the Manatee Journal");
}
/** Sample for document changes, starting at the current view cursor position
* The sample changes the paragraph style and the character style at the
* current view cursor selection Open the sample file ViewCursorExampleFile,
* select some text and run the example.
* The current paragraph will be set to Quotations paragraph style.
* The selected text will be set to Quotation character style.
*/
private void viewCursorExample() throws java.lang.Exception {
// get the remote service manager
mxRemoteServiceManager = this.getRemoteServiceManager();
// get the Desktop service
Object desktop = mxRemoteServiceManager.createInstanceWithContext(
"com.sun.star.frame.Desktop", mxRemoteContext);
// query its XDesktop interface, we need the current component
XDesktop xDesktop = (XDesktop)UnoRuntime.queryInterface(
XDesktop.class, desktop);
// retrieve the current component and access the controller
XComponent xCurrentComponent = xDesktop.getCurrentComponent();
XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class,
xCurrentComponent);
XController xController = xModel.getCurrentController();
// the controller gives us the TextViewCursor
XTextViewCursorSupplier xViewCursorSupplier =
(XTextViewCursorSupplier)UnoRuntime.queryInterface(
XTextViewCursorSupplier.class, xController);
XTextViewCursor xViewCursor = xViewCursorSupplier.getViewCursor();
// query its XPropertySet interface, we want to set character and paragraph
// properties
XPropertySet xCursorPropertySet = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xViewCursor);
// set the appropriate properties for character and paragraph style
xCursorPropertySet.setPropertyValue("CharStyleName", "Quotation");
xCursorPropertySet.setPropertyValue("ParaStyleName", "Quotations");
// print the current page number
XPageCursor xPageCursor = (XPageCursor)UnoRuntime.queryInterface(
XPageCursor.class, xViewCursor);
System.out.println("The current page number is " + xPageCursor.getPage());
// the model cursor is much more powerful, so
// we create a model cursor at the current view cursor position with the
// following steps:
// get the Text service from the TextViewCursor, it is an XTextRange:
XText xDocumentText = xViewCursor.getText();
// create a model cursor from the viewcursor
XTextCursor xModelCursor = xDocumentText.createTextCursorByRange(
xViewCursor.getStart());
// now we could query XWordCursor, XSentenceCursor and XParagraphCursor
// or XDocumentInsertable, XSortable or XContentEnumerationAccess
// and work with the properties of com.sun.star.text.TextCursor
// in this case we just go to the end of the paragraph and add some text.
XParagraphCursor xParagraphCursor = (XParagraphCursor)
UnoRuntime.queryInterface(XParagraphCursor.class, xModelCursor);
// goto the end of the paragraph
xParagraphCursor.gotoEndOfParagraph(false);
xParagraphCursor.setString(" ***** Fin de semana! ******");
}
/** Sample for the various editing facilities described in the
* developer's manual
*/
private void editingExample () throws java.lang.Exception {
// create empty swriter document
XComponent xEmptyWriterComponent = newDocComponent("swriter");
// query its XTextDocument interface to get the text
mxDoc = (XTextDocument)UnoRuntime.queryInterface(
XTextDocument.class, xEmptyWriterComponent);
// get a reference to the body text of the document
mxDocText = mxDoc.getText();
// Get a reference to the document's property set. This contains document
// information like the current word count
mxDocProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, mxDoc );
// Simple text insertion example
BodyTextExample ();
// Example using text ranges to insert strings at the beginning or end
// of a text range
TextRangeExample ();
// Create a document cursor and remember it, it will be used in most
// of the following examples
mxDocCursor = mxDocText.createTextCursor();
// Demonstrate some of the different cursor types (word, sentence)
TextCursorExample ();
// Access the text document's multi service factory, which we will need
// for most of the following examples
mxDocFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(
XMultiServiceFactory.class, mxDoc );
// Examples of text fields, dependant text fields and field masters
TextFieldExample ();
// Example of using an XEnumerationAccess to iterate over paragraphs and
// set properties of each paragraph as we do so
ParagraphExample ();
// Example of creating and manipulating a text frame
TextFrameExample ();
// Example of creating and manipulating a text table, text table rows
// and text table cells get a new random generator
maRandom = new Random();
TextTableExample ();
// Example of creating, inserting and manipulating text sections, as
// well as an example of how to refresh the document
TextSectionExample ();
// Example of creating a text section over a block of text and formatting
// the text section into columns, as well as how to insert an empty
// paragraph using the XRelativeTextContentInsert
TextColumnsExample ();
// Example of creating the NumberingRules service and adjusting
// NumberingTypes and NumberingLevels
NumberingExample ();
// Example of how to use the XStyleFamiliesSupplier interface of the
// document and how to create, insert and apply styles
StylesExample ();
IndexExample ();
// Example of how to create and manipulate reference marks and GetReference
// text fields
ReferenceExample ();
// Example of how to create and insert Footnotes and how to use the
// XFootnotesSupplier interface of the document
FootnoteExample ();
// This method demonstrates how to create shapes from the document factory
// and how to access the draw page of the document using the
// XDrawPageSupplier interface
DrawPageExample ();
mxFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(
XMultiServiceFactory.class, mxRemoteServiceManager);
// This example demonstrates the use of the AutoTextContainer,
// AutoTextGroup and AutoTextEntry services and shows how to create,
// insert and modify auto text blocks
AutoTextExample ();
}
protected void storePrintExample() throws java.lang.Exception {
// get the remote service manager
mxRemoteServiceManager = this.getRemoteServiceManager();
// retrieve the Desktop object, we need its XComponentLoader
Object desktop = mxRemoteServiceManager.createInstanceWithContext(
"com.sun.star.frame.Desktop", mxRemoteContext);
XComponentLoader xComponentLoader = (XComponentLoader)
UnoRuntime.queryInterface(XComponentLoader.class, desktop);
PropertyValue[] loadProps = new PropertyValue[0];
java.io.File sourceFile = new java.io.File("PrintDemo.odt");
StringBuffer sLoadFileUrl = new StringBuffer("file:///");
sLoadFileUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
XComponent xDoc = xComponentLoader.loadComponentFromURL(
sLoadFileUrl.toString(), "_blank", 0, loadProps);
if ( xDoc != null ) {
sourceFile = new java.io.File(sOutputDir);
StringBuffer sStoreFileUrl = new StringBuffer();
sStoreFileUrl.append(sourceFile.toURL().toString());
sStoreFileUrl.append("somepopularfileformat.doc");
storeDocComponent(xDoc, sStoreFileUrl.toString() );
printDocComponent(xDoc);
}
}
private XMultiComponentFactory getRemoteServiceManager()
throws java.lang.Exception
{
if (mxRemoteContext == null && mxRemoteServiceManager == null) {
// get the remote office context. If necessary a new office
// process is started
mxRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
System.out.println("Connected to a running office ...");
mxRemoteServiceManager = mxRemoteContext.getServiceManager();
}
return mxRemoteServiceManager;
}
protected XComponent newDocComponent(String docType)
throws java.lang.Exception
{
String loadUrl = "private:factory/" + docType;
mxRemoteServiceManager = this.getRemoteServiceManager();
Object desktop = mxRemoteServiceManager.createInstanceWithContext(
"com.sun.star.frame.Desktop", mxRemoteContext);
XComponentLoader xComponentLoader = (XComponentLoader)
UnoRuntime.queryInterface(XComponentLoader.class, desktop);
PropertyValue[] loadProps = new PropertyValue[0];
return xComponentLoader.loadComponentFromURL(loadUrl, "_blank",
0, loadProps);
}
/** Load a document as template
*/
protected XComponent newDocComponentFromTemplate(String loadUrl)
throws java.lang.Exception
{
// get the remote service manager
mxRemoteServiceManager = this.getRemoteServiceManager();
// retrieve the Desktop object, we need its XComponentLoader
Object desktop = mxRemoteServiceManager.createInstanceWithContext(
"com.sun.star.frame.Desktop", mxRemoteContext);
XComponentLoader xComponentLoader = (XComponentLoader)
UnoRuntime.queryInterface(XComponentLoader.class, desktop);
// define load properties according to com.sun.star.document.MediaDescriptor
// the boolean property AsTemplate tells the office to create a new document
// from the given file
PropertyValue[] loadProps = new PropertyValue[1];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "AsTemplate";
loadProps[0].Value = new Boolean(true);
// load
return xComponentLoader.loadComponentFromURL(loadUrl, "_blank",
0, loadProps);
}
/** Load a document with arguments (text purposes)
*/
protected void storeDocComponent(XComponent xDoc, String storeUrl)
throws java.lang.Exception
{
XStorable xStorable = (XStorable)UnoRuntime.queryInterface(
XStorable.class, xDoc);
PropertyValue[] storeProps = new PropertyValue[1];
storeProps[0] = new PropertyValue();
storeProps[0].Name = "FilterName";
storeProps[0].Value = "MS Word 97";
System.out.println("... store \"PrintDemo.odt\" to \"" + storeUrl + "\".");
xStorable.storeAsURL(storeUrl, storeProps);
}
protected void printDocComponent(XComponent xDoc) throws java.lang.Exception {
XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(
XPrintable.class, xDoc);
PropertyValue[] printerDesc = new PropertyValue[1];
printerDesc[0] = new PropertyValue();
printerDesc[0].Name = "Name";
printerDesc[0].Value = aPrinterName;
xPrintable.setPrinter(printerDesc);
PropertyValue[] printOpts = new PropertyValue[1];
printOpts[0] = new PropertyValue();
printOpts[0].Name = "Pages";
printOpts[0].Value = "1";
xPrintable.print(printOpts);
}
// Setting the whole text of a document as one string
protected void BodyTextExample ()
{
// Body Text and TextDocument example
try
{
// demonstrate simple text insertion
mxDocText.setString ( "This is the new body text of the document."
+ "\n\nThis is on the second line.\n\n" );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
// Adding a string at the end or the beginning of text
protected void TextRangeExample ()
{
try
{
// Get a text range refering to the beginning of the text document
XTextRange xStart = mxDocText.getStart();
// use setString to insert text at the beginning
xStart.setString ( "This is text inserted at the beginning.\n\n" );
// Get a text range refering to the end of the text document
XTextRange xEnd = mxDocText.getEnd();
// use setString to insert text at the end
xEnd.setString ( "This is text inserted at the end.\n\n" );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
/** moving a text cursor, selecting text and overwriting it
*/
protected void TextCursorExample ()
{
try
{
// First, get the XSentenceCursor interface of our text cursor
XSentenceCursor xSentenceCursor = (XSentenceCursor)
UnoRuntime.queryInterface(XSentenceCursor.class, mxDocCursor );
// Goto the next cursor, without selecting it
xSentenceCursor.gotoNextSentence( false );
// Get the XWordCursor interface of our text cursor
XWordCursor xWordCursor = (XWordCursor) UnoRuntime.queryInterface(
XWordCursor.class, mxDocCursor );
// Skip the first four words of this sentence and select the fifth
xWordCursor.gotoNextWord( false );
xWordCursor.gotoNextWord( false );
xWordCursor.gotoNextWord( false );
xWordCursor.gotoNextWord( false );
xWordCursor.gotoNextWord( true );
// Use the XSimpleText interface to insert a word at the current cursor
// location, over-writing the current selection (the fifth word
// selected above)
mxDocText.insertString ( xWordCursor, "old ", true );
// Access the property set of the cursor, and set the currently
// selected text (which is the string we just inserted) to be bold
XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, mxDocCursor );
xCursorProps.setPropertyValue ( "CharWeight",
new Float(com.sun.star.awt.FontWeight.BOLD) );
// replace the '.' at the end of the sentence with a new string
xSentenceCursor.gotoEndOfSentence( false );
xWordCursor.gotoPreviousWord( true );
mxDocText.insertString (xWordCursor,
", which has been changed with text cursors!",
true);
}
catch ( Exception e )
{
e.printStackTrace();
}
}
/** This method inserts both a date field and a user field containing the
* number '42'
*/
protected void TextFieldExample ()
{
try
{
// Use the text document's factory to create a DateTime text field,
// and access it's XTextField interface
XTextField xDateField = (XTextField) UnoRuntime.queryInterface (
XTextField.class, mxDocFactory.createInstance (
"com.sun.star.text.TextField.DateTime" ) );
// Insert it at the end of the document
mxDocText.insertTextContent ( mxDocText.getEnd(), xDateField, false );
// Use the text document's factory to create a user text field,
// and access it's XDependentTextField interface
XDependentTextField xUserField =
(XDependentTextField) UnoRuntime.queryInterface (
XDependentTextField.class, mxDocFactory.createInstance (
"com.sun.star.text.TextField.User" ) );
// Create a fieldmaster for our newly created User Text field, and
// access it's XPropertySet interface
XPropertySet xMasterPropSet = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, mxDocFactory.createInstance (
"com.sun.star.text.fieldmaster.User" ) );
// Set the name and value of the FieldMaster
xMasterPropSet.setPropertyValue ( "Name", "UserEmperor" );
xMasterPropSet.setPropertyValue ( "Value", new Integer ( 42 ) );
// Attach the field master to the user field
xUserField.attachTextFieldMaster ( xMasterPropSet );
// Move the cursor to the end of the document
mxDocCursor.gotoEnd( false );
// insert a paragraph break using the XSimpleText interface
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
// Insert the user field at the end of the document
mxDocText.insertTextContent ( mxDocText.getEnd(), xUserField, false );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
/** This method demonstrates how to iterate over paragraphs
*/
protected void ParagraphExample ()
{
try
{
// The service 'com.sun.star.text.Text' supports the XEnumerationAccess
// interface to provide an enumeration of the paragraphs contained by
// the text the service refers to.
// Here, we access this interface
XEnumerationAccess xParaAccess = (XEnumerationAccess)
UnoRuntime.queryInterface(XEnumerationAccess.class, mxDocText );
// Call the XEnumerationAccess's only method to access the actual
// Enumeration
XEnumeration xParaEnum = xParaAccess.createEnumeration();
// While there are paragraphs, do things to them
while ( xParaEnum.hasMoreElements() )
{
// Get a reference to the next paragraphs XServiceInfo interface.
// TextTables are also part of this enumeration access, so we ask
// the element if it is a TextTable, if it doesn't support the
// com.sun.star.text.TextTable service, then it is safe to assume
// that it really is a paragraph
XServiceInfo xInfo = (XServiceInfo) UnoRuntime.queryInterface(
XServiceInfo.class, xParaEnum.nextElement() );
if ( !xInfo.supportsService ( "com.sun.star.text.TextTable" ) )
{
// Access the paragraph's property set...the properties in this
// property set are listed in:
// com.sun.star.style.ParagraphProperties
XPropertySet xSet = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xInfo );
// Set the justification to be center justified
xSet.setPropertyValue ( "ParaAdjust",
com.sun.star.style.ParagraphAdjust.CENTER );
}
}
}
catch ( Exception e )
{
e.printStackTrace();
}
}
/** This method returns a random double which isn't too high or too low
*/
protected double getRandomDouble ()
{
return ( ( maRandom.nextInt() % 1000 ) * maRandom.nextDouble () );
}
/** This method sets the text colour of the cell refered to by sCellName to
white and inserts the string sText in it
*/
protected static void insertIntoCell(String sCellName, String sText,
XTextTable xTable)
{
// Access the XText interface of the cell referred to by sCellName
XText xCellText = (XText) UnoRuntime.queryInterface(
XText.class, xTable.getCellByName ( sCellName ) );
// create a text cursor from the cells XText interface
XTextCursor xCellCursor = xCellText.createTextCursor();
// Get the property set of the cell's TextCursor
XPropertySet xCellCursorProps = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xCellCursor );
try
{
// Set the colour of the text to white
xCellCursorProps.setPropertyValue( "CharColor", new Integer(16777215));
}
catch ( Exception e)
{
e.printStackTrace();
}
// Set the text in the cell to sText
xCellText.setString( sText );
}
/** This method shows how to create and insert a text table, as well as insert
text and formulae into the cells of the table
*/
protected void TextTableExample ()
{
try
{
// Create a new table from the document's factory
XTextTable xTable = (XTextTable) UnoRuntime.queryInterface(
XTextTable.class, mxDocFactory .createInstance(
"com.sun.star.text.TextTable" ) );
// Specify that we want the table to have 4 rows and 4 columns
xTable.initialize( 4, 4 );
// Insert the table into the document
mxDocText.insertTextContent( mxDocCursor, xTable, false);
// Get an XIndexAccess of the table rows
XIndexAccess xRows = xTable.getRows();
// Access the property set of the first row (properties listed in
// service description: com.sun.star.text.TextTableRow)
XPropertySet xRow = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xRows.getByIndex ( 0 ) );
// If BackTransparant is false, then the background color is visible
xRow.setPropertyValue( "BackTransparent", new Boolean(false));
// Specify the color of the background to be dark blue
xRow.setPropertyValue( "BackColor", new Integer(6710932));
// Access the property set of the whole table
XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xTable );
// We want visible background colors
xTableProps.setPropertyValue( "BackTransparent", new Boolean(false));
// Set the background colour to light blue
xTableProps.setPropertyValue( "BackColor", new Integer(13421823));
// set the text (and text colour) of all the cells in the first row
// of the table
insertIntoCell( "A1", "First Column", xTable );
insertIntoCell( "B1", "Second Column", xTable );
insertIntoCell( "C1", "Third Column", xTable );
insertIntoCell( "D1", "Results", xTable );
// Insert random numbers into the first this three cells of each
// remaining row
xTable.getCellByName( "A2" ).setValue( getRandomDouble() );
xTable.getCellByName( "B2" ).setValue( getRandomDouble() );
xTable.getCellByName( "C2" ).setValue( getRandomDouble() );
xTable.getCellByName( "A3" ).setValue( getRandomDouble() );
xTable.getCellByName( "B3" ).setValue( getRandomDouble() );
xTable.getCellByName( "C3" ).setValue( getRandomDouble() );
xTable.getCellByName( "A4" ).setValue( getRandomDouble() );
xTable.getCellByName( "B4" ).setValue( getRandomDouble() );
xTable.getCellByName( "C4" ).setValue( getRandomDouble() );
// Set the last cell in each row to be a formula that calculates
// the sum of the first three cells
xTable.getCellByName( "D2" ).setFormula( "sum <A2:C2>" );
xTable.getCellByName( "D3" ).setFormula( "sum <A3:C3>" );
xTable.getCellByName( "D4" ).setFormula( "sum <A4:C4>" );
}
catch (Exception e)
{
e.printStackTrace();
}
}
/** This method shows how to create and manipulate text frames
*/
protected void TextFrameExample ()
{
try
{
// Use the document's factory to create a new text frame and
// immediately access it's XTextFrame interface
XTextFrame xFrame = (XTextFrame) UnoRuntime.queryInterface (
XTextFrame.class, mxDocFactory.createInstance (
"com.sun.star.text.TextFrame" ) );
// Access the XShape interface of the TextFrame
XShape xShape = (XShape)UnoRuntime.queryInterface(XShape.class, xFrame);
// Access the XPropertySet interface of the TextFrame
XPropertySet xFrameProps = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xFrame );
// Set the size of the new Text Frame using the XShape's 'setSize'
// method
Size aSize = new Size();
aSize.Height = 400;
aSize.Width = 15000;
xShape.setSize(aSize);
// Set the AnchorType to
// com.sun.star.text.TextContentAnchorType.AS_CHARACTER
xFrameProps.setPropertyValue( "AnchorType",
TextContentAnchorType.AS_CHARACTER );
// Go to the end of the text document
mxDocCursor.gotoEnd( false );
// Insert a new paragraph
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
// Then insert the new frame
mxDocText.insertTextContent(mxDocCursor, xFrame, false);
// Access the XText interface of the text contained within the frame
XText xFrameText = xFrame.getText();
// Create a TextCursor over the frame's contents
XTextCursor xFrameCursor = xFrameText.createTextCursor();
// Insert some text into the frame
xFrameText.insertString(
xFrameCursor, "The first line in the newly created text frame.",
false );
xFrameText.insertString(
xFrameCursor, "\nThe second line in the new text frame.", false );
// Insert a paragraph break into the document (not the frame)
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
}
catch (Exception e)
{
e.printStackTrace();
}
}
/** This example demonstrates the use of the AutoTextContainer, AutoTextGroup
and AutoTextEntry services and shows how to create, insert and modify
auto text blocks
*/
protected void AutoTextExample ()
{
try
{
// Go to the end of the document
mxDocCursor.gotoEnd( false );
// Insert two paragraphs
mxDocText.insertControlCharacter ( mxDocCursor,
ControlCharacter.PARAGRAPH_BREAK, false );
mxDocText.insertControlCharacter ( mxDocCursor,
ControlCharacter.PARAGRAPH_BREAK, false );
// Position the cursor in the second paragraph
XParagraphCursor xParaCursor = (XParagraphCursor)
UnoRuntime.queryInterface(XParagraphCursor.class, mxDocCursor );
xParaCursor.gotoPreviousParagraph ( false );
// Get an XNameAccess interface to all auto text groups from the
// document factory
XNameAccess xContainer = (XNameAccess) UnoRuntime.queryInterface(
XNameAccess.class, mxFactory.createInstance (
"com.sun.star.text.AutoTextContainer" ) );
// Create a new table at the document factory
XTextTable xTable = (XTextTable) UnoRuntime.queryInterface(
XTextTable.class, mxDocFactory .createInstance(
"com.sun.star.text.TextTable" ) );
// Store the names of all auto text groups in an array of strings
String[] aGroupNames = xContainer.getElementNames();
// Make sure we have at least one group name
if ( aGroupNames.length > 0 )
{
// initialise the table to have a row for every autotext group
// in a single column + one additional row for a header
xTable.initialize( aGroupNames.length+1,1);
// Access the XPropertySet of the table
XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xTable );
// We want a visible background
xTableProps.setPropertyValue( "BackTransparent",
new Boolean(false));
// We want the background to be light blue
xTableProps.setPropertyValue( "BackColor", new Integer(13421823));
// Inser the table into the document
mxDocText.insertTextContent( mxDocCursor, xTable, false);
// Get an XIndexAccess to all table rows
XIndexAccess xRows = xTable.getRows();
// Get the first row in the table
XPropertySet xRow = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xRows.getByIndex ( 0 ) );
// We want the background of the first row to be visible too
xRow.setPropertyValue( "BackTransparent", new Boolean(false));
// And let's make it dark blue
xRow.setPropertyValue( "BackColor", new Integer(6710932));
// Put a description of the table contents into the first cell
insertIntoCell( "A1", "AutoText Groups", xTable);
// Create a table cursor pointing at the second cell in the first
// column
XTextTableCursor xTableCursor = xTable.createCursorByCellName("A2");
// Loop over the group names
for ( int i = 0 ; i < aGroupNames.length ; i ++ )
{
// Get the name of the current cell
String sCellName = xTableCursor.getRangeName ();
// Get the XText interface of the current cell
XText xCellText = (XText) UnoRuntime.queryInterface (
XText.class, xTable.getCellByName ( sCellName ) );
// Set the cell contents of the current cell to be
//the name of the of an autotext group
xCellText.setString ( aGroupNames[i] );
// Access the autotext group with this name
XAutoTextGroup xGroup = (XAutoTextGroup)
UnoRuntime.queryInterface (XAutoTextGroup.class,
xContainer.getByName(aGroupNames[i]));
// Get the titles of each autotext block in this group
String [] aBlockNames = xGroup.getTitles();
// Make sure that the autotext group contains at least one block
if ( aBlockNames.length > 0 )
{
// Split the current cell vertically into two seperate cells
xTableCursor.splitRange ( (short) 1, false );
// Put the cursor in the newly created right hand cell
// and select it
xTableCursor.goRight ( (short) 1, false );
// Split this cell horizontally to make a seperate cell
// for each Autotext block
if ( ( aBlockNames.length -1 ) > 0 )
xTableCursor.splitRange (
(short) (aBlockNames.length - 1), true );
// loop over the block names
for ( int j = 0 ; j < aBlockNames.length ; j ++ )
{
// Get the XText interface of the current cell
xCellText = (XText) UnoRuntime.queryInterface (
XText.class, xTable.getCellByName (
xTableCursor.getRangeName() ) );
// Set the text contents of the current cell to the
// title of an Autotext block
xCellText.setString ( aBlockNames[j] );
// Move the cursor down one cell
xTableCursor.goDown( (short)1, false);
}
}
// Go back to the cell we originally split
xTableCursor.gotoCellByName ( sCellName, false );
// Go down one cell
xTableCursor.goDown( (short)1, false);
}
XAutoTextGroup xGroup;
String [] aBlockNames;
// Add a depth so that we only generate 200 numbers before giving up
// on finding a random autotext group that contains autotext blocks
int nDepth = 0;
do
{
// Generate a random, positive number which is lower than
// the number of autotext groups
int nRandom = Math.abs ( maRandom.nextInt() %
aGroupNames.length );
// Get the autotext group at this name
xGroup = ( XAutoTextGroup ) UnoRuntime.queryInterface (
XAutoTextGroup.class, xContainer.getByName (
aGroupNames[ nRandom ] ) );
// Fill our string array with the names of all the blocks in
// this group
aBlockNames = xGroup.getElementNames();
// increment our depth counter
++nDepth;
}
while ( nDepth < 200 && aBlockNames.length == 0 );
// If we managed to find a group containg blocks...
if ( aBlockNames.length > 0 )
{
// Pick a random block in this group and get it's
// XAutoTextEntry interface
int nRandom = Math.abs ( maRandom.nextInt()
% aBlockNames.length );
XAutoTextEntry xEntry = ( XAutoTextEntry )
UnoRuntime.queryInterface (
XAutoTextEntry.class, xGroup.getByName (
aBlockNames[ nRandom ] ) );
// insert the modified autotext block at the end of the document
xEntry.applyTo ( mxDocCursor );
// Get the titles of all text blocks in this AutoText group
String [] aBlockTitles = xGroup.getTitles();
// Get the XNamed interface of the autotext group
XNamed xGroupNamed = ( XNamed ) UnoRuntime.queryInterface (
XNamed.class, xGroup );
// Output the short cut and title of the random block
//and the name of the group it's from
System.out.println ( "Inserted the Autotext '" +
aBlockTitles[nRandom]
+ "', shortcut '" + aBlockNames[nRandom]
+ "' from group '"
+ xGroupNamed.getName());
}
}
// Go to the end of the document
mxDocCursor.gotoEnd( false );
// Insert new paragraph
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
// Position cursor in new paragraph
xParaCursor.gotoPreviousParagraph ( false );
// Insert a string in the new paragraph
mxDocText.insertString ( mxDocCursor,
"Some text for a new autotext block", false );
// Go to the end of the document
mxDocCursor.gotoEnd( false );
}
catch (Exception e)
{
e.printStackTrace();
}
}
/** This method demonstrates how to insert indexes and index marks
*/
protected void IndexExample ()
{
try
{
// Go to the end of the document
mxDocCursor.gotoEnd( false );
// Insert a new paragraph and position the cursor in it
mxDocText.insertControlCharacter ( mxDocCursor,
ControlCharacter.PARAGRAPH_BREAK, false );
XParagraphCursor xParaCursor = (XParagraphCursor)
UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
xParaCursor.gotoPreviousParagraph ( false );
// Create a new ContentIndexMark and get it's XPropertySet interface
XPropertySet xEntry = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class,
mxDocFactory.createInstance("com.sun.star.text.ContentIndexMark"));
// Set the text to be displayed in the index
xEntry.setPropertyValue(
"AlternativeText", "Big dogs! Falling on my head!");
// The Level property _must_ be set
xEntry.setPropertyValue ( "Level", new Short ( (short) 1 ) );
// Create a ContentIndex and access it's XPropertySet interface
XPropertySet xIndex = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class,
mxDocFactory.createInstance ( "com.sun.star.text.ContentIndex" ) );
// Again, the Level property _must_ be set
xIndex.setPropertyValue ( "Level", new Short ( (short) 10 ) );
// Access the XTextContent interfaces of both the Index and the
// IndexMark
XTextContent xIndexContent = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, xIndex );
XTextContent xEntryContent = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, xEntry );
// Insert both in the document
mxDocText.insertTextContent ( mxDocCursor, xEntryContent, false );
mxDocText.insertTextContent ( mxDocCursor, xIndexContent, false );
// Get the XDocumentIndex interface of the Index
XDocumentIndex xDocIndex = (XDocumentIndex) UnoRuntime.queryInterface(
XDocumentIndex.class, xIndex );
// And call it's update method
xDocIndex.update();
}
catch (Exception e)
{
e.printStackTrace();
}
}
/** This method demonstrates how to create and insert reference marks, and
* GetReference Text Fields
*/
protected void ReferenceExample ()
{
try
{
// Go to the end of the document
mxDocCursor.gotoEnd( false );
// Insert a paragraph break
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
// Get the Paragraph cursor
XParagraphCursor xParaCursor = (XParagraphCursor)
UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
// Move the cursor into the new paragraph
xParaCursor.gotoPreviousParagraph ( false );
// Create a new ReferenceMark and get it's XNamed interface
XNamed xRefMark = (XNamed) UnoRuntime.queryInterface(XNamed.class,
mxDocFactory.createInstance ("com.sun.star.text.ReferenceMark"));
// Set the name to TableHeader
xRefMark.setName ( "TableHeader" );
// Get the TextTablesSupplier interface of the document
XTextTablesSupplier xTableSupplier = ( XTextTablesSupplier )
UnoRuntime.queryInterface(XTextTablesSupplier.class, mxDoc);
// Get an XIndexAccess of TextTables
XIndexAccess xTables = (XIndexAccess)UnoRuntime.queryInterface(
XIndexAccess.class, xTableSupplier.getTextTables());
// We've only inserted one table, so get the first one from index zero
XTextTable xTable = ( XTextTable ) UnoRuntime.queryInterface (
XTextTable.class, xTables.getByIndex( 0 ) );
// Get the first cell from the table
XText xTableText = (XText) UnoRuntime.queryInterface(
XText.class, xTable.getCellByName ( "A1" ) );
// Get a text cursor for the first cell
XTextCursor xTableCursor = xTableText.createTextCursor();
// Get the XTextContent interface of the reference mark so we can
// insert it
XTextContent xContent = ( XTextContent ) UnoRuntime.queryInterface (
XTextContent.class, xRefMark );
// Insert the reference mark into the first cell of the table
xTableText.insertTextContent ( xTableCursor, xContent, false );
// Create a 'GetReference' text field to refer to the reference mark
// we just inserted, and get it's XPropertySet interface
XPropertySet xFieldProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, mxDocFactory.createInstance (
"com.sun.star.text.TextField.GetReference" ) );
// Get the XReferenceMarksSupplier interface of the document
XReferenceMarksSupplier xRefSupplier = ( XReferenceMarksSupplier )
UnoRuntime.queryInterface( XReferenceMarksSupplier.class, mxDoc );
// Get an XNameAccess which refers to all inserted reference marks
XNameAccess xMarks = ( XNameAccess ) UnoRuntime.queryInterface (
XNameAccess.class, xRefSupplier.getReferenceMarks() );
// Put the names of each reference mark into an array of strings
String[] aNames = xMarks.getElementNames();
// Make sure that at least 1 reference mark actually exists
// (well, we just inserted one!)
if ( aNames.length > 0 )
{
// Output the name of the first reference mark ('TableHeader')
System.out.println (
"GetReference text field inserted for ReferenceMark : "
+ aNames[0] );
// Set the SourceName of the GetReference text field to
// 'TableHeader'
xFieldProps.setPropertyValue ( "SourceName", aNames[0] );
// specify that the source is a reference mark (could also be a
// footnote, bookmark or sequence field )
xFieldProps.setPropertyValue ( "ReferenceFieldSource",
new Short(ReferenceFieldSource.REFERENCE_MARK));
// We want the reference displayed as 'above' or 'below'
xFieldProps.setPropertyValue ( "ReferenceFieldPart",
new Short(ReferenceFieldPart.UP_DOWN));
// Get the XTextContent interface of the GetReference text field
XTextContent xRefContent = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, xFieldProps );
// Go to the end of the document
mxDocCursor.gotoEnd( false );
// Make some text to precede the reference
mxDocText.insertString(mxDocText.getEnd(), "The table ", false);
// Insert the text field
mxDocText.insertTextContent(mxDocText.getEnd(), xRefContent, false);
// And some text after the reference..
mxDocText.insertString(mxDocText.getEnd(),
" contains the sum of some random numbers.", false );
// Refresh the document
XRefreshable xRefresh = (XRefreshable) UnoRuntime.queryInterface(
XRefreshable.class, mxDoc );
xRefresh.refresh();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
/** This method demonstrates how to create and insert footnotes, and how to
access the XFootnotesSupplier interface of the document
*/
protected void FootnoteExample ()
{
try
{
// Create a new footnote from the document factory and get it's
// XFootnote interface
XFootnote xFootnote = (XFootnote) UnoRuntime.queryInterface(
XFootnote.class, mxDocFactory.createInstance (
"com.sun.star.text.Footnote" ) );
// Set the label to 'Numbers'
xFootnote.setLabel ( "Numbers" );
// Get the footnotes XTextContent interface so we can...
XTextContent xContent = ( XTextContent ) UnoRuntime.queryInterface (
XTextContent.class, xFootnote );
// ...insert it into the document
mxDocText.insertTextContent ( mxDocCursor, xContent, false );
// Get the XFootnotesSupplier interface of the document
XFootnotesSupplier xFootnoteSupplier = (XFootnotesSupplier)
UnoRuntime.queryInterface(XFootnotesSupplier.class, mxDoc );
// Get an XIndexAccess interface to all footnotes
XIndexAccess xFootnotes = ( XIndexAccess ) UnoRuntime.queryInterface (
XIndexAccess.class, xFootnoteSupplier.getFootnotes() );
// Get the XFootnote interface to the first footnote inserted ('Numbers')
XFootnote xNumbers = ( XFootnote ) UnoRuntime.queryInterface (
XFootnote.class, xFootnotes.getByIndex( 0 ) );
// Get the XSimpleText interface to the Footnote
XSimpleText xSimple = (XSimpleText ) UnoRuntime.queryInterface (
XSimpleText.class, xNumbers );
// Create a text cursor for the foot note text
XTextRange xRange = (XTextRange ) UnoRuntime.queryInterface (
XTextRange.class, xSimple.createTextCursor() );
// And insert the actual text of the footnote.
xSimple.insertString (
xRange, " The numbers were generated by using java.util.Random", false );
}
catch (Exception e)
{
e.printStackTrace();
}
}
/** This method demonstrates how to create and manipulate shapes, and how to
access the draw page of the document to insert shapes
*/
protected void DrawPageExample ()
{
try
{
// Go to the end of the document
mxDocCursor.gotoEnd( false );
// Insert two new paragraphs
mxDocText.insertControlCharacter(mxDocCursor,
ControlCharacter.PARAGRAPH_BREAK, false);
mxDocText.insertControlCharacter(mxDocCursor,
ControlCharacter.PARAGRAPH_BREAK, false);
// Get the XParagraphCursor interface of our document cursor
XParagraphCursor xParaCursor = (XParagraphCursor)
UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
// Position the cursor in the 2nd paragraph
xParaCursor.gotoPreviousParagraph ( false );
// Create a RectangleShape using the document factory
XShape xRect = (XShape) UnoRuntime.queryInterface(
XShape.class, mxDocFactory.createInstance (
"com.sun.star.drawing.RectangleShape" ) );
// Create an EllipseShape using the document factory
XShape xEllipse = (XShape) UnoRuntime.queryInterface(
XShape.class, mxDocFactory.createInstance (
"com.sun.star.drawing.EllipseShape" ) );
// Set the size of both the ellipse and the rectangle
Size aSize = new Size();
aSize.Height = 4000;
aSize.Width = 10000;
xRect.setSize(aSize);
aSize.Height = 3000;
aSize.Width = 6000;
xEllipse.setSize ( aSize );
// Set the position of the Rectangle to the right of the ellipse
Point aPoint = new Point();
aPoint.X = 6100;
aPoint.Y = 0;
xRect.setPosition ( aPoint );
// Get the XPropertySet interfaces of both shapes
XPropertySet xRectProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xRect );
XPropertySet xEllipseProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xEllipse );
// And set the AnchorTypes of both shapes to 'AT_PARAGRAPH'
xRectProps.setPropertyValue ( "AnchorType",
TextContentAnchorType.AT_PARAGRAPH );
xEllipseProps.setPropertyValue ( "AnchorType",
TextContentAnchorType.AT_PARAGRAPH );
// Access the XDrawPageSupplier interface of the document
XDrawPageSupplier xDrawPageSupplier = (XDrawPageSupplier)
UnoRuntime.queryInterface (XDrawPageSupplier.class, mxDoc );
// Get the XShapes interface of the draw page
XShapes xShapes = ( XShapes ) UnoRuntime.queryInterface (
XShapes.class, xDrawPageSupplier.getDrawPage () );
// Add both shapes
xShapes.add ( xEllipse );
xShapes.add ( xRect );
/*
This doesn't work, I am assured that FME and AMA are fixing it.
XShapes xGrouper = (XShapes) UnoRuntime.queryInterface(
XShapes.class, mxDocFactory.createInstance (
"com.sun.star.drawing.GroupShape" ) );
XShape xGrouperShape = (XShape) UnoRuntime.queryInterface(
XShape.class, xGrouper );
xShapes.add ( xGrouperShape );
xGrouper.add ( xRect );
xGrouper.add ( xEllipse );
XShapeGrouper xShapeGrouper = (XShapeGrouper)
UnoRuntime.queryInterface(XShapeGrouper.class, xShapes);
xShapeGrouper.group ( xGrouper );
*/
}
catch (Exception e)
{
e.printStackTrace();
}
}
/** This method demonstrates how to create, insert and apply styles
*/
protected void StylesExample ()
{
try
{
// Go to the end of the document
mxDocCursor.gotoEnd( false );
// Insert two paragraph breaks
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
// Create a new style from the document's factory
XStyle xStyle = (XStyle) UnoRuntime.queryInterface(
XStyle.class, mxDocFactory.createInstance(
"com.sun.star.style.ParagraphStyle" ) );
// Access the XPropertySet interface of the new style
XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xStyle );
// Give the new style a light blue background
xStyleProps.setPropertyValue ( "ParaBackColor", new Integer (13421823));
// Get the StyleFamiliesSupplier interface of the document
XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)
UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, mxDoc);
// Use the StyleFamiliesSupplier interface to get the XNameAccess
// interface of the actual style families
XNameAccess xFamilies = ( XNameAccess ) UnoRuntime.queryInterface (
XNameAccess.class, xSupplier.getStyleFamilies() );
// Access the 'ParagraphStyles' Family
XNameContainer xFamily = (XNameContainer ) UnoRuntime.queryInterface (
XNameContainer.class,
xFamilies.getByName ( "ParagraphStyles" ) );
// Insert the newly created style into the ParagraphStyles family
xFamily.insertByName ( "All-Singing All-Dancing Style", xStyle );
// Get the XParagraphCursor interface of the document cursor
XParagraphCursor xParaCursor = (XParagraphCursor)
UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
// Select the first paragraph inserted
xParaCursor.gotoPreviousParagraph ( false );
xParaCursor.gotoPreviousParagraph ( true );
// Access the property set of the cursor selection
XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, mxDocCursor );
// Set the style of the cursor selection to our newly created style
xCursorProps.setPropertyValue ( "ParaStyleName",
"All-Singing All-Dancing Style" );
// Go back to the end
mxDocCursor.gotoEnd ( false );
// Select the last paragraph in the document
xParaCursor.gotoNextParagraph ( true );
// And reset it's style to 'Standard' (the programmatic name for
// the default style)
xCursorProps.setPropertyValue ( "ParaStyleName", "Standard" );
}
catch (Exception e)
{
e.printStackTrace();
}
}
/** This method demonstrates how to set numbering types and numbering levels
using the com.sun.star.text.NumberingRules service
*/
protected void NumberingExample ()
{
try
{
// Go to the end of the document
mxDocCursor.gotoEnd( false );
// Get the RelativeTextContentInsert interface of the document
XRelativeTextContentInsert xRelative =
(XRelativeTextContentInsert ) UnoRuntime.queryInterface (
XRelativeTextContentInsert.class, mxDocText );
// Use the document's factory to create the NumberingRules service,
// and get it's XIndexAccess interface
XIndexAccess xNum = (XIndexAccess) UnoRuntime.queryInterface(
XIndexAccess.class,
mxDocFactory.createInstance( "com.sun.star.text.NumberingRules" ) );
// Also get the NumberingRule's XIndexReplace interface
XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface(
XIndexReplace.class, xNum );
// Create an array of XPropertySets, one for each of the three
// paragraphs we're about to create
XPropertySet xParas[] = new XPropertySet [ 3 ];
for ( int i = 0 ; i < 3 ; ++ i )
{
// Create a new paragraph
XTextContent xNewPara = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, mxDocFactory.createInstance(
"com.sun.star.text.Paragraph" ) );
// Get the XPropertySet interface of the new paragraph and put
// it in our array
xParas[i] = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xNewPara );
// Insert the new paragraph into the document after the fish
// section. As it is an insert relative to the fish section, the
// first paragraph inserted will be below the next two
xRelative.insertTextContentAfter ( xNewPara, mxFishSection );
// Separate from the above, but also needs to be done three times
// Get the PropertyValue sequence for this numbering level
PropertyValue [] aProps = (PropertyValue [] ) xNum.getByIndex ( i );
// Iterate over the PropertyValue's for this numbering level,
// looking for the 'NumberingType' property
for ( int j = 0 ; j < aProps.length ; ++j )
{
if ( aProps[j].Name.equals ( "NumberingType" ) )
{
// Once we find it, set it's value to a new type,
// dependent on which numbering level we're currently on
switch ( i )
{
case 0 : aProps[j].Value =
new Short(NumberingType.ROMAN_UPPER);
break;
case 1 : aProps[j].Value =
new Short(NumberingType.CHARS_UPPER_LETTER);
break;
case 2 : aProps[j].Value =
new Short(NumberingType.ARABIC);
break;
}
// Put the updated PropertyValue sequence back into the
// NumberingRules service
xReplace.replaceByIndex ( i, aProps );
break;
}
}
}
// Get the XParagraphCursor interface of our text cursro
XParagraphCursor xParaCursor = (XParagraphCursor)
UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
// Go to the end of the document, then select the preceding paragraphs
mxDocCursor.gotoEnd ( false );
xParaCursor.gotoPreviousParagraph ( false );
xParaCursor.gotoPreviousParagraph ( true );
xParaCursor.gotoPreviousParagraph ( true );
// Get the XPropertySet of the cursor's currently selected text
XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, mxDocCursor );
// Set the updated Numbering rules to the cursor's property set
xCursorProps.setPropertyValue ( "NumberingRules", xNum );
mxDocCursor.gotoEnd( false );
// Set the first paragraph that was inserted to a numbering level of
// 2 (thus it will have Arabic style numbering)
xParas[0].setPropertyValue ( "NumberingLevel", new Short((short) 2));
// Set the second paragraph that was inserted to a numbering level of
// 1 (thus it will have 'Chars Upper Letter' style numbering)
xParas[1].setPropertyValue ( "NumberingLevel", new Short((short) 1));
// Set the third paragraph that was inserted to a numbering level of
// 0 (thus it will have 'Chars Upper Letter' style numbering)
xParas[2].setPropertyValue ( "NumberingLevel", new Short((short) 0));
}
catch (Exception e)
{
e.printStackTrace();
}
}
/** This method demonstrates how to create linked and unlinked sections
*/
protected void TextSectionExample ()
{
try
{
// Go to the end of the document
mxDocCursor.gotoEnd( false );
// Insert two paragraph breaks
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, true );
// Create a new TextSection from the document factory and access
// it's XNamed interface
XNamed xChildNamed = (XNamed) UnoRuntime.queryInterface(
XNamed.class, mxDocFactory.createInstance(
"com.sun.star.text.TextSection" ) );
// Set the new sections name to 'Child_Section'
xChildNamed.setName ( "Child_Section" );
// Access the Child_Section's XTextContent interface and insert it
// into the document
XTextContent xChildSection = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, xChildNamed );
mxDocText.insertTextContent ( mxDocCursor, xChildSection, false );
// Access the XParagraphCursor interface of our text cursor
XParagraphCursor xParaCursor = (XParagraphCursor)
UnoRuntime.queryInterface(XParagraphCursor.class, mxDocCursor);
// Go back one paragraph (into Child_Section)
xParaCursor.gotoPreviousParagraph ( false );
// Insert a string into the Child_Section
mxDocText.insertString ( mxDocCursor, "This is a test", false );
// Go to the end of the document
mxDocCursor.gotoEnd( false );
// Go back two paragraphs
xParaCursor.gotoPreviousParagraph ( false );
xParaCursor.gotoPreviousParagraph ( false );
// Go to the end of the document, selecting the two paragraphs
mxDocCursor.gotoEnd ( true );
// Create another text section and access it's XNamed interface
XNamed xParentNamed = (XNamed) UnoRuntime.queryInterface(XNamed.class,
mxDocFactory.createInstance("com.sun.star.text.TextSection"));
// Set this text section's name to Parent_Section
xParentNamed.setName ( "Parent_Section" );
// Access the Parent_Section's XTextContent interface ...
XTextContent xParentSection = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, xParentNamed );
// ...and insert it into the document
mxDocText.insertTextContent ( mxDocCursor, xParentSection, false );
// Go to the end of the document
mxDocCursor.gotoEnd ( false );
// Insert a new paragraph
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
// And select the new pargraph
xParaCursor.gotoPreviousParagraph ( true );
// Create a new Text Section and access it's XNamed interface
XNamed xLinkNamed = (XNamed) UnoRuntime.queryInterface(XNamed.class,
mxDocFactory.createInstance("com.sun.star.text.TextSection"));
// Set the new text section's name to Linked_Section
xLinkNamed.setName ( "Linked_Section" );
// Access the Linked_Section's XTextContent interface
XTextContent xLinkedSection = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, xLinkNamed );
// And insert the Linked_Section into the document
mxDocText.insertTextContent ( mxDocCursor, xLinkedSection, false );
// Access the Linked_Section's XPropertySet interface
XPropertySet xLinkProps = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xLinkNamed );
// Set the linked section to be linked to the Child_Section
xLinkProps.setPropertyValue ( "LinkRegion", "Child_Section" );
// Access the XPropertySet interface of the Child_Section
XPropertySet xChildProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xChildNamed );
// Set the Child_Section's background colour to blue
xChildProps.setPropertyValue( "BackColor", new Integer(13421823));
// Refresh the document, so the linked section matches the Child_Section
XRefreshable xRefresh = (XRefreshable) UnoRuntime.queryInterface(
XRefreshable.class, mxDoc );
xRefresh.refresh();
}
catch (Exception e)
{
e.printStackTrace();
}
}
/** This method demonstrates the XTextColumns interface and how to insert a
blank paragraph using the XRelativeTextContentInsert interface
*/
protected void TextColumnsExample ()
{
try
{
// Go to the end of the doucment
mxDocCursor.gotoEnd( false );
// insert a new paragraph
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
// insert the string 'I am a fish.' 100 times
for ( int i = 0 ; i < 100 ; ++i )
{
mxDocText.insertString ( mxDocCursor, "I am a fish.", false );
}
// insert a paragraph break after the text
mxDocText.insertControlCharacter (
mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
// Get the XParagraphCursor interface of our text cursor
XParagraphCursor xParaCursor = (XParagraphCursor)
UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
// Jump back before all the text we just inserted
xParaCursor.gotoPreviousParagraph ( false );
xParaCursor.gotoPreviousParagraph ( false );
// Insert a string at the beginning of the block of text
mxDocText.insertString ( mxDocCursor, "Fish section begins:", false );
// Then select all of the text
xParaCursor.gotoNextParagraph ( true );
xParaCursor.gotoNextParagraph ( true );
// Create a new text section and get it's XNamed interface
XNamed xSectionNamed = (XNamed) UnoRuntime.queryInterface(XNamed.class,
mxDocFactory.createInstance("com.sun.star.text.TextSection"));
// Set the name of our new section (appropiately) to 'Fish'
xSectionNamed.setName ( "Fish" );
// Create the TextColumns service and get it's XTextColumns interface
XTextColumns xColumns = (XTextColumns) UnoRuntime.queryInterface(
XTextColumns.class,
mxDocFactory.createInstance ( "com.sun.star.text.TextColumns" ) );
// We want three columns
xColumns.setColumnCount ( (short) 3 );
// Get the TextColumns, and make the middle one narrow with a larger
// margin on the left than the right
TextColumn[] aSequence = xColumns.getColumns ();
aSequence[1].Width /= 2;
aSequence[1].LeftMargin = 350;
aSequence[1].RightMargin = 200;
// Set the updated TextColumns back to the XTextColumns
xColumns.setColumns ( aSequence );
// Get the property set interface of our 'Fish' section
XPropertySet xSectionProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xSectionNamed );
// Set the columns to the Text Section
xSectionProps.setPropertyValue ( "TextColumns", xColumns );
// Get the XTextContent interface of our 'Fish' section
mxFishSection = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, xSectionNamed );
// Insert the 'Fish' section over the currently selected text
mxDocText.insertTextContent ( mxDocCursor, mxFishSection, true );
// Get the wonderful XRelativeTextContentInsert interface
XRelativeTextContentInsert xRelative = (XRelativeTextContentInsert )
UnoRuntime.queryInterface (
XRelativeTextContentInsert.class, mxDocText );
// Create a new empty paragraph and get it's XTextContent interface
XTextContent xNewPara = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class,
mxDocFactory.createInstance("com.sun.star.text.Paragraph"));
// Insert the empty paragraph after the fish Text Section
xRelative.insertTextContentAfter ( xNewPara, mxFishSection );
}
catch (Exception e)
{
e.printStackTrace();
}
}
}