Difference between revisions of "Documentation/DevGuide/Drawings/Working with Drawing Documents"
m (1 revision(s)) |
m (→Page Handling) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
|NextPage=Documentation/DevGuide/Drawings/Shapes | |NextPage=Documentation/DevGuide/Drawings/Shapes | ||
}} | }} | ||
− | {{DISPLAYTITLE:Working with Drawing Documents}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Drawings/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Working with Drawing Documents}} | ||
=== Document Structure === | === Document Structure === | ||
Line 16: | Line 17: | ||
<!--<idltopic>com.sun.star.drawing.XDrawPages;com.sun.star.drawing.XDrawPageDuplicator</idltopic>--> | <!--<idltopic>com.sun.star.drawing.XDrawPages;com.sun.star.drawing.XDrawPageDuplicator</idltopic>--> | ||
− | Draw and Impress documents supply their pages (slides) through the interface <idl>com.sun.star.drawing.XDrawPagesSupplier</idl>. The method | + | Draw and Impress documents supply their pages (slides) through the interface <idl>com.sun.star.drawing.XDrawPagesSupplier</idl>. The method <idl>com.sun.star.drawing.XDrawPagesSupplier:getDrawPages</idl> returns a container of draw pages with a <idl>com.sun.star.drawing.XDrawPages</idl> interface that is derived from <idl>com.sun.star.container.XIndexAccess</idl>. That is, <code>XDrawPages</code> allows accessing, inserting and removing pages of a drawing document: |
− | + | <syntaxhighlight lang="idl"> | |
type getElementType() | type getElementType() | ||
boolean hasElements() | boolean hasElements() | ||
Line 25: | Line 26: | ||
com::sun::star::drawing::XDrawPage insertNewByIndex(long nIndex) | com::sun::star::drawing::XDrawPage insertNewByIndex(long nIndex) | ||
void remove(com::sun::star::drawing::XDrawPage xPage) | void remove(com::sun::star::drawing::XDrawPage xPage) | ||
− | + | </syntaxhighlight> | |
The example below demonstrates how to access and create draw and master pages. Layers will be described later. | The example below demonstrates how to access and create draw and master pages. Layers will be described later. | ||
− | + | <syntaxhighlight lang="java"> | |
XDrawPagesSupplier xDrawPagesSupplier = (XDrawPagesSupplier)UnoRuntime.queryInterface( | XDrawPagesSupplier xDrawPagesSupplier = (XDrawPagesSupplier)UnoRuntime.queryInterface( | ||
XDrawPagesSupplier.class, xComponent); | XDrawPagesSupplier.class, xComponent); | ||
Line 51: | Line 52: | ||
XDrawPages xMasterPages = xMasterPagesSupplier.getMasterPages(); | XDrawPages xMasterPages = xMasterPagesSupplier.getMasterPages(); | ||
// xMasterPages can now be used in the same manner as xDrawPages is used above | // xMasterPages can now be used in the same manner as xDrawPages is used above | ||
− | + | </syntaxhighlight> | |
Each draw page always has ''one'' master page. The interface <idl>com.sun.star.drawing.XMasterPageTarget</idl> offers methods to get and set the master page that is correlated to a draw page. | Each draw page always has ''one'' master page. The interface <idl>com.sun.star.drawing.XMasterPageTarget</idl> offers methods to get and set the master page that is correlated to a draw page. | ||
− | + | <syntaxhighlight lang="java"> | |
// query for MasterPageTarget | // query for MasterPageTarget | ||
XMasterPageTarget xMasterPageTarget = (XMasterPageTarget)UnoRuntime.queryInterface( | XMasterPageTarget xMasterPageTarget = (XMasterPageTarget)UnoRuntime.queryInterface( | ||
Line 63: | Line 64: | ||
*/ | */ | ||
xMasterPageTarget.setMasterPage(xMasterPage); | xMasterPageTarget.setMasterPage(xMasterPage); | ||
− | + | </syntaxhighlight> | |
− | It is possible to copy pages using the interface | + | It is possible to copy pages using the interface <idl>com.sun.star.drawing.XDrawPageDuplicator</idl> of drawing or presentation documents. |
Methods of <idl>com.sun.star.drawing.XDrawPageDuplicator</idl>: | Methods of <idl>com.sun.star.drawing.XDrawPageDuplicator</idl>: | ||
− | + | <syntaxhighlight lang="idl"> | |
com::sun::star::drawing::XDrawPage duplicate( [in] com::sun::star::drawing::XDrawPage xPage) | com::sun::star::drawing::XDrawPage duplicate( [in] com::sun::star::drawing::XDrawPage xPage) | ||
− | + | </syntaxhighlight> | |
Pass a draw page reference to the method <code>duplicate()</code>. It appends a new draw page at the end of the page list, using the default naming scheme for pages, "slide n". | Pass a draw page reference to the method <code>duplicate()</code>. It appends a new draw page at the end of the page list, using the default naming scheme for pages, "slide n". | ||
Line 105: | Line 106: | ||
{{PDL1}} | {{PDL1}} | ||
− | [[Category: Drawing Documents and Presentation Documents]] | + | |
+ | [[Category:Documentation/Developer's Guide/Drawing Documents and Presentation Documents]] |
Latest revision as of 14:34, 17 May 2022
- Working with Drawing Documents
Document Structure
Draw documents maintain their drawing content on draw pages, master pages and layers. If a new draw document is opened, it contains one slide that corresponds to a com.sun.star.drawing.DrawPage service. Switching to Master View brings up the master page handled by the service com.sun.star.drawing.MasterPage. The Layer View allows access to layers to structure your drawings. These layers can be controlled through com.sun.star.drawing.Layer and com.sun.star.drawing.LayerManager.
Page Handling
Draw and Impress documents supply their pages (slides) through the interface com.sun.star.drawing.XDrawPagesSupplier. The method com.sun.star.drawing.XDrawPagesSupplier:getDrawPages returns a container of draw pages with a com.sun.star.drawing.XDrawPages interface that is derived from com.sun.star.container.XIndexAccess. That is, XDrawPages
allows accessing, inserting and removing pages of a drawing document:
type getElementType() boolean hasElements() long getCount() any getByIndex(long Index) com::sun::star::drawing::XDrawPage insertNewByIndex(long nIndex) void remove(com::sun::star::drawing::XDrawPage xPage)
The example below demonstrates how to access and create draw and master pages. Layers will be described later.
XDrawPagesSupplier xDrawPagesSupplier = (XDrawPagesSupplier)UnoRuntime.queryInterface( XDrawPagesSupplier.class, xComponent); // XDrawPages inherits from com.sun.star.container.XIndexAccess XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages(); // get the page count for standard pagesint nPageCount = xDrawPages.getCount(); // get draw page by index XDrawPage xDrawPage = (XDrawPage)UnoRuntime.queryInterface(XDrawPage .class, xDrawPages.getByIndex(nIndex)); /* create and insert a draw page into the given position, the method returns the newly created page */ XDrawPage xNewDrawPage = xDrawPages.insertNewByIndex(0); // remove the given page xDrawPages.remove( xDrawPage ); /* now repeat the same procedure as described above for the master pages, the main difference is to get the XDrawPages from the XMasterPagesSupplier interface */ XMasterPagesSupplier xMasterPagesSupplier = (XMasterPagesSupplier)UnoRuntime.queryInterface( XMasterPagesSupplier.class, xComponent); XDrawPages xMasterPages = xMasterPagesSupplier.getMasterPages(); // xMasterPages can now be used in the same manner as xDrawPages is used above
Each draw page always has one master page. The interface com.sun.star.drawing.XMasterPageTarget offers methods to get and set the master page that is correlated to a draw page.
// query for MasterPageTarget XMasterPageTarget xMasterPageTarget = (XMasterPageTarget)UnoRuntime.queryInterface( XMasterPageTarget.class, xDrawPage); // now we can get the corresponding master page XDrawPage xMasterPage = xMasterPageTarget.getMasterPage(); /* this method now sets a new master page, it is important to mention that the applied page must be part of the MasterPages */ xMasterPageTarget.setMasterPage(xMasterPage);
It is possible to copy pages using the interface com.sun.star.drawing.XDrawPageDuplicator of drawing or presentation documents.
Methods of com.sun.star.drawing.XDrawPageDuplicator:
com::sun::star::drawing::XDrawPage duplicate( [in] com::sun::star::drawing::XDrawPage xPage)
Pass a draw page reference to the method duplicate()
. It appends a new draw page at the end of the page list, using the default naming scheme for pages, "slide n".
Page Partitioning
All units and dimensions are measured in 1/100th of a millimeter. The coordinates are increasing from left to right, and from top to bottom. The upper-left position of a page is (0, 0).
The page size, margins and orientation can be determined using the following properties of a draw page (generic draw page):
Properties of com.sun.star.drawing.GenericDrawPage | |
---|---|
Height | long - Height of the page.
|
Width | long - Width of the page.
|
BorderBottom | long - Bottom margin of the page.
|
BorderLeft | long - Left margin of the page.
|
BorderRight | long - Right margin of the page.
|
BorderTop | long - Top margin of the page.
|
Orientation | com.sun.star.view.PaperOrientation. Determines if the printer output should be turned by 90??. Possible values are: PORTRAIT and LANDSCAPE .
|
Content on this page is licensed under the Public Documentation License (PDL). |