{***********************************************************************
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
* Redistribution and use in source and binary forms, withor 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 OUTOF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*************************************************************************} unit SampleCode;
procedure TSampleCode.InsertTable(sTableName : String; dbPointer : String); var
oCursor : Variant; begin
{ create a cursor object on the current position in the document }
oCursor := Document.Text.CreateTextCursor();
{ Create for each table a unique database name } if (sTableName = '') then
sTableName := createUniqueTablename(Document);
{ create a new bookmark for the new number }
sBookmarkName := oBookmark.getName();
oBookmark.dispose();
InsertBookmark( oDoc, oTextCursor, sBookmarkName ); end;
{ ' Jump to Bookmark and return for this position the cursor }
function TSampleCode.JumpToBookmark(
oBookmark : Variant) : Variant;
begin
JumpToBookmark := oBookmark.Anchor.Text.createTextCursorByRange(
oBookmark.Anchor ); end;
{ ' Create a Texttable on a Textdocument } function TSampleCode.CreateTextTable(
oDoc : Variant;
oCursor : Variant;
sName : String;
iRow : Integer;
iColumn : Integer) : Variant; var
ret : Variant; begin
ret := oDoc.createInstance( 'com.sun.star.text.TextTable' );
{ ' Returns the Bookmark the Tablename and Cellname } function TSampleCode.GetBookmarkFromAddress(
oDoc : Variant;
sTableName : String;
sCellAddress : String) : Variant; var
sTableAddress : String;
iTableNameLength : Integer;
sBookNames : Variant;
iBookCounter : Integer; begin
sTableAddress := '//' + sTableName + '/%' + sCellAddress;
iTableNameLength := Length( sTableAddress );
sBookNames := oDoc.Bookmarks.getElementNames;
for iBookCounter := VarArrayLowBound(sBookNames, 1) to VarArrayHighBound(sBookNames, 1) do begin If sTableAddress = Copy( sBookNames[iBookCounter], 1, iTableNameLength) then begin
GetBookmarkFromAddress := oDoc.Bookmarks.getByName(sBookNames[iBookCounter]);
exit; end; end; end;
{ ' Returns the Bookmark the Tablename and Cellname } function TSampleCode.GetBookmarkFromDBPointer(
oDoc : Variant;
sBookmarkName : String) : Variant; var
sBookNames : Variant;
iBookCounter : Integer; begin
sBookNames := oDoc.Bookmarks.getElementNames;
for iBookCounter := VarArrayLowBound(sBookNames, 1) to VarArrayHighBound(sBookNames, 1) do begin If Pos(sBookmarkName, sBookNames[iBookCounter]) = (1 + Length(sBookNames[iBookCounter]) - Length(sBookmarkName)) then begin
GetBookmarkFromDBPointer := oDoc.Bookmarks.getByName(sBookNames[iBookCounter]);
exit; end; end; end;
end.
Messung V0.5
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.