11/28/2011
Output Generated SQL for CF Query
[cfdump var="#qryPricing.getMetaData().getExtendedMetaData().sql#"]
11/10/2010
OASIS - Open Document Format for Office - OpenDocument[PDF]
11/06/2010
Programmatically Renaming Styles With a Particular Prefix
'=============================================================================================== 'Author: Victor Sanchez 'Date: November 5, 2010 'Purpose: to rename or replace all styles used in a document with identical styles 'whose names start with the prefix: "statute_ldpc_"...
GET SOURCE CODE HERE...>> '----------------------------------------------------------------------------------------------- Sub Main
GlobalScope.BasicLibraries.LoadLibrary("XrayTool") renameAllUsedStylesToStatuteStyles(ThisComponent) End Sub
'----------------------------------------------------------------------------------------------- Sub renameAllUsedStylesToStatuteStyles(oDoc) Dim mFamilyNames As Variant, mStyleNames As Variant Dim sMsg As String, n%, i% Dim oFamilies As Object, oStyle As Object, oStyles As Object oFamilies = oDoc.StyleFamilies mFamilyNames = oFamilies.getElementNames()
dim tempStyle dim prefix as string prefix = "statute_ldpc_" For n = LBound(mFamilyNames) To UBound(mFamilyNames) if mFamilyNames(n) = "ParagraphStyles" then oStyles = oFamilies.getByName(mFamilyNames(n)) mStyleNames = oStyles.getElementNames() For i = LBound(mStyleNames) To UBound (mStyleNames) tempStyle = oStyles.getByName(mStyleNames(i)) 'If we find user-defined styles that are in use, updated them to be prefixed... if tempStyle.isInUse() AND tempStyle.isUserDefined() AND left(tempStyle.Name, Len("statute")) <> "statute" then
'RENAME TO START WITH "statute_ldpc_" 'msgbox "renaming: " + mStyleNames(i) + " to " + prefix + mStyleNames(i) 'oStyles.getByName(mStyleNames(i)).setName(prefix + mStyleNames(i)) 'Create new properly prefixed style... createNewStyle(oDoc, prefix + tempStyle.Name, tempStyle.Name) 'find all instances of this style in the content, and switch the style to the new one... updateStyleInContent(oDoc, tempStyle.Name, prefix + tempStyle.Name) elseif tempStyle.isInUse() AND tempStyle.isUserDefined() = false then 'If we find OpenOffice standard styles that are in use, we need to create new styles 'whose names are properly prefixed, but that are defined identically to the others... 'Create new properly prefixed style... createNewStyle(oDoc, prefix + tempStyle.Name, tempStyle.Name) 'find all instances of this style in the content, and switch the style to the new one... updateStyleInContent(oDoc, tempStyle.Name, prefix + tempStyle.Name) elseif tempStyle.isInUse() then msgbox tempStyle.Name end if Next i
end if Next n End Sub
'----------------------------------------------------------------------------------------------- sub createNewStyle(oDoc, newStyleName, parentStyle) vFamilies = oDoc.StyleFamilies vStyle = oDoc.createInstance("com.sun.star.style.ParagraphStyle") vStyle.setName(newStyleName) vStyle.setParentStyle(parentStyle) vParaStyles = vFamilies.getByName("ParagraphStyles") 'Insert new paragraph, if it does not exist already by the new name... 'xray vParaStyles if NOT vParaStyles.hasByName(newStyleName) then vParaStyles.insertByName(newStyleName,vStyle) end if
end sub
'----------------------------------------------------------------------------------------------- sub updateStyleInContent(oDoc, oldStyleName, newStyleName) Dim oEnum 'com.sun.star.container.XEnumerationAccess Dim oPar 'Paragraph of some sort Dim nPars As Integer 'Number of paragraphs Dim nTables As Integer 'Number of tables REM ThisComponent refers to the current OOo document REM Text is a property of ThisComponent for a text document REM The getText() object method returns the same thing. REM createEnumeration() is an object method. oEnum = oDoc.Text.createEnumeration() Do While oEnum.hasMoreElements() oPar = oEnum.nextElement() REM The returned paragraph will be a paragraph or a text table If oPar.supportsService("com.sun.star.text.Paragraph") Then 'msgbox oPar.ParaStyleName + ": " + oPar.String() 'If we find any paragraphs having the old stylename, replace it with the new one... if oPar.ParaStyleName = oldStyleName then oPar.ParaStyleName = newStyleName end if else msgbox "NOT PARAGRAPH: " + oPar.String() End If Loop end sub '===============================================================================================
09/14/2010
Available Toolbars in OpenOffice...
http://www.oooforum.org/forum/viewtopic.phtml?t=27935
public static string Algignment = "private:resource/toolbar/alignmentbar"; public static string ArrowShapes = "private:resource/toolbar/arrowshapes"; public static string BasicShapes = "private:resource/toolbar/basicshapes"; public static string CalloutShapes = "private:resource/toolbar/calloutshapes"; public static string ColorBar = "private:resource/toolbar/colorbar"; public static string DrawBar = "private:resource/toolbar/drawbar"; public static string DrawObjectBar = "private:resource/toolbar/drawobjectbar"; public static string ExtrusionObjectBar = "private:resource/toolbar/extrusionobjectbar"; public static string FontWorkObjectBar = "private:resource/toolbar/fontworkobjectbar"; public static string FontworkShapeTypes = "private:resource/toolbar/fontworkshapetypes"; public static string FormatObjectBar = "private:resource/toolbar/formatobjectbar"; public static string FormControlBar = "private:resource/toolbar/formcontrols"; public static string FormdesignBar = "private:resource/toolbar/formdesign"; public static string FormsFilterBar = "private:resource/toolbar/formsfilterbar"; public static string FormsNavigationBar = "private:resource/toolbar/formsnavigationbar"; public static string FormsObjectBar = "private:resource/toolbar/formsobjectbar"; public static string FormtextBar = "private:resource/toolbar/formtextobjectbar"; public static string FullScreenbar = "private:resource/toolbar/fullscreenbar"; public static string GraphicObjectBar = "private:resource/toolbar/graphicobjectbar"; public static string InsertBar = "private:resource/toolbar/insertbar"; public static string InsertCellsBar = "private:resource/toolbar/insertcellsbar"; public static string InsertObjectBar = "private:resource/toolbar/insertobjectbar"; public static string MediaObjectBar = "private:resource/toolbar/mediaobjectbar"; public static string MoreFormControlBar = "private:resource/toolbar/moreformcontrols"; public static string PreviewBar = "private:resource/toolbar/previewbar"; public static string StandardBar = "private:resource/toolbar/standardbar"; public static string StarShapesBar = "private:resource/toolbar/starshapes"; public static string SymbolShapesBar = "private:resource/toolbar/symbolshapes"; public static string TextObjectBar = "private:resource/toolbar/textobjectbar"; public static string ToolBar = "private:resource/toolbar/toolbar"; public static string ViewerBar = "private:resource/toolbar/viewerbar"; public static string MainMenu = "private:resource/menubar/menubar";
09/13/2010
Dynamic Menues in OpenOffice - Call Macro On Document Open
REM ***** BASIC *****
sub DynamicMenuBuilder
dim strMacro, strIcon as string strMacro = "macro:///LDPC.Cleanup.pinkSelectedPara" strIcon = "file:///C:/Users/vsanchez/Desktop/pinkIt.png" AddButtonToToolbar(strMacro, strIcon)
strMacro = "macro:///victor3434.Module1.sayHello" strIcon = "file:///C:/Users/vsanchez/Desktop/openRemoteFile.png" AddButtonToToolbar(strMacro, strIcon) end sub
Sub AddButtonToToolbar(strMacro, strImage) Dim sToolbar$ : sToolbar = "private:resource/toolbar/standardbar" Dim sCmdID$ : sCmdID = strMacro Dim sDocType$ : sDocType = "com.sun.star.text.TextDocument" Dim sSupplier$ Dim oSupplier Dim oModuleCfgMgr Dim oImageMgr Dim oToolbarSettings Dim bHasButton As Boolean Dim nCount As Integer Dim oToolbarButton() Dim nToolbarButtonCount As Integer Dim i%, j% REM Retrieve the module configuration manager from the REM central module configuration manager supplier sSupplier = "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" oSupplier = CreateUnoService(sSupplier) REM Retrieve the module configuration manager with module identifier REM *** See com.sun.star.frame.ModuleManager for more information oModuleCfgMgr = oSupplier.getUIConfigurationManager( sDocType ) oImageMgr = oModuleCfgMgr.getImageManager() oToolbarSettings = oModuleCfgMgr.getSettings( sToolbar, True ) REM Look for our button with the CommandURL property. bHasButton = False nCount = oToolbarSettings.getCount()
For i = 0 To nCount-1 oToolbarButton() = oToolbarSettings.getByIndex( i ) nToolbarButtonCount = ubound(oToolbarButton()) For j = 0 To nToolbarButtonCount If oToolbarButton(j).Name = "CommandURL" Then If oToolbarButton(j).Value = sCmdID Then bHasButton = True End If End If Next Next Dim oImageCmds(0) Dim oImages(0) Dim oImage REM *** Check if image has already been added If Not oImageMgr.hasImage( 0, sCmdID ) OR TRUE Then REM Try to load the image from the file URL oImage = GetImageFromURL(strImage) If Not isNull( oImage ) Then REM *** Insert new image into the Writer image manager oImageCmds(0) = sCmdID oImages(0) = oImage oImageMgr.insertImages( 0, oImageCmds(), oImages() ) End If End If If Not bHasButton Then sString = "Pink IT" oToolbarItem = CreateToolbarItem( sCmdID, strMacro) oToolbarSettings.insertByIndex( nCount, oToolbarItem ) oModuleCfgMgr.replaceSettings( sToolbar, oToolbarSettings ) End If
End Sub
Function GetImageFromURL( URL as String ) as Variant Dim oMediaProperties(0) As New com.sun.star.beans.PropertyValue Dim sProvider$ : sProvider = "com.sun.star.graphic.GraphicProvider" Dim oGraphicProvider REM Create graphic provider instance to load images from files. oGraphicProvider = createUnoService( sProvider ) REM Set URL property so graphic provider is able to load the image oMediaProperties(0).Name = "URL" oMediaProperties(0).Value = URL REM Retrieve the com.sun.star.graphic.XGraphic instance GetImageFromURL = oGraphicProvider.queryGraphic( oMediaProperties() ) End Function
Function CreateToolbarItem( Command$, Label$ ) as Variant Dim aToolbarItem(3) as new com.sun.star.beans.PropertyValue aToolbarItem(0).Name = "CommandURL" aToolbarItem(0).Value = Command aToolbarItem(1).Name = "Label" aToolbarItem(1).Value = Label aToolbarItem(2).Name = "Type" aToolbarItem(2).Value = 0 aToolbarItem(3).Name = "Visible" aToolbarItem(3).Value = true CreateToolbarItem = aToolbarItem() End Function
09/13/2010
Highlight in Pink any paragraph whrere the cursor lies
Function pinkSelectedPara() As Boolean
Dim oDoc as object oDoc = thisComponent Dim oCursor 'Text cursor to check for a collapsed range 'If there is no document, quit... If IsNull(oDoc) Then Exit Function 'Pink paragraph where cursor currently lies.. oCursor = ThisComponent.CurrentController.getViewCursor() oCursor.ParaBackColor = rgb(240,108,152) pinkSelectedPara = true End Function
08/12/2010
OpenOffice and Regular Expressions - Documentation
Click here for a good resource page on REGULAR EXPRESSIONS from OO.org >>
List of Regular Expressions
|
Character
|
Result/Use
|
|
Any character
|
Represents the given character unless otherwise specified.
|
|
.
|
Represents any single character except for a line break or paragraph break. For example, the search term "sh.rt" returns both "shirt" and "short".
|
|
^
|
Only finds the search term if the term is at the beginning of a paragraph. Special objects such as empty fields or character-anchored frames, at the beginning of a paragraph are ignored. Example: "^Peter".
|
|
$
|
Only finds the search term if the term appears at the end of a paragraph. Special objects such as empty fields or character-anchored frames at the end of a paragraph are ignored. Example: "Peter$".
|
|
*
|
Finds zero or more of the characters in front of the "*". For example, "Ab*c" finds "Ac", "Abc", "Abbc", "Abbbc", and so on.
|
|
+
|
Finds one or more of the characters in front of the "+". For example, "AX.+4" finds "AXx4", but not "AX4".
The longest possible string that matches this search pattern in a paragraph is always found. If the paragraph contains the string "AX 4 AX4", the entire passage is highlighted.
|
|
?
|
Finds zero or one of the characters in front of the "?". For example, "Texts?" finds "Text" and "Texts" and "x(ab|c)?y" finds "xy", "xaby", or "xcy".
|
|
|
Search interprets the special character that follows the "" as a normal character and not as a regular expression (except for the combinations n, t, >, and <). For example, "tree." finds "tree.", not "treed" or "trees".
|
|
n
|
Represents a line break that was inserted with the Shift+Enter key combination. To change a line break into a paragraph break, enter n in the Search for and Replace with boxes, and then perform a search and replace.
n in the Search for text box stands for a line break that was inserted with the Shift+Enter key combination.
n in the Replace with text box stands for a paragraph break that can be entered with the Enter or Return key.
|
|
t
|
Represents a tab. You can also use this expression in the Replace with box.
|
|
>
|
Only finds the search term if it appears at the end of a word. For example, "book>" finds "checkbook", but not "bookmark".
|
|
<
|
Only finds the search term if it appears at the beginning of a word. For example, "
|
|
^$
|
Finds an empty paragraph.
|
|
^.
|
Finds the first character of a paragraph.
|
|
& or $0
|
Adds the string that was found by the search criteria in the Search for box to the term in the Replace with box when you make a replacement.
For example, if you enter "window" in the Search for box and "&frame" in the Replace with box, the word "window" is replaced with "windowframe".
You can also enter an "&" in the Replace with box to modify the Attributes or the Format of the string found by the search criteria.
|
|
[abc123]
|
Represents one of the characters that are between the brackets.
|
|
[a-e]
|
Represents any of the characters that are between a and e.
|
|
[a-eh-x]
|
Represents any of the characters that are between a-e and h-x.
|
|
[^a-s]
|
Represents any character that is not between a and s.
|
|
xXXXX
|
Represents a special character based on its four-digit hexadecimal code (XXXX).
The code for the special character depends on the font used. You can view the codes by choosing Insert - Special Character.
|
|
|
|
Finds the terms that occur before or after the "|". For example, "this|that" finds "this" and "that".
|
|
{2}
|
Defines the number of times that the character in front of the opening bracket occurs. For example, "tre{2}" finds "tree".
|
|
{1,2}
|
Defines the number of times that the character in front of the opening bracket can occur. For example, "tre{1,2}" finds both "tree" and "treated".
|
|
{1,}
|
Defines the minimum number of times that the character in front of the opening bracket can occur. For example, "tre{2,}" finds "tree", "treee", and "treeeee".
|
|
( )
|
In the Search for box:
Defines the characters inside the parentheses as a reference. You can then refer to the first reference in the current expression with "1", to the second reference with "2", and so on.
For example, if your text contains the number 13487889 and you search using the regular expression (8)711, "8788" is found.
You can also use () to group terms, for example, "a(bc)?d" finds "ad" or "abcd".
In the Replace with box:
Use $ (dollar) instead of (backslash) to replace references. Use $0 to replace the whole found string.
|
|
[:alpha:]
|
Represents an alphabetic character. Use [:alpha:]+ to find one of them.
|
|
[:digit:]
|
Represents a decimal digit. Use [:digit:]+ to find one of them.
|
|
[:alnum:]
|
Represents an alphanumeric character ([:alpha:] and [:digit:]).
|
|
[:space:]
|
Represents a white space character such as space.
|
|
[:print:]
|
Represents a printable character.
|
|
[:cntrl:]
|
Represents a nonprinting character.
|
|
[:lower:]
|
Represents a lowercase character if Match case is selected in Options.
|
|
[:upper:]
|
Represents an uppercase character if Match case is selected in Options.
|
Examples
You can combine the search terms to form complex searches.
To find three-digit numbers alone in a paragraph
^[:digit:]{3}$
^ means the match has to be at the start of a paragraph,
[:digit:] matches any decimal digit,
{3} means there must be exactly 3 copies of "digit",
$ means the match must end a paragraph.
08/05/2010
Character properties that can be used to Search-and-Replace
Character Properties
Paragraphs contain numerous character-related properties. Like the paragraph-specific properties, these properties are optional and are encapsulated in services. The properties that are primarily related to characters are found the CharacterProperties service (see Table 7).
Table 7: Properties supported by the com. sun. style. CharacterProperties service.
|
Property
|
Description
|
|
CharFontName
|
Specify the name of the font in western text. This may be a comma-separated list of names.
|
|
CharFontStyleName
|
Specify the name of the font style.
|
|
CharFontFamily
|
Specify the name of the font family as specified in com.sun.star.awt.FontFamily constant group.
-
DONTKNOW = 0 - The font family is not known.
-
DECORATIVE = 1 - The font family uses decorative fonts.
-
MODERN = 2 - The font family is a modern font; this is a specific style.
-
ROMAN = 3 - The font family is a Roman font with serifs.
-
SCRIPT = 4 - The font family is a script font.
-
SWISS = 5 - The font family is a Roman font without serifs.
-
SYSTEM = 6 - The font family is a system font.
|
|
CharFontCharSet
|
Specify the text encoding of the font using the com.sun.star.awt.CharSet constant group. The values are self-explanatory: DONTKNOW, ANSI, MAC, IBMPC_437 (IBM PC character set number 437), IBMPC_850, IBMPC_860, IBMPC_86, IBMPC_863, IBMPC_865, SYSTEM, and SYMBOL.
|
|
CharFontPitch
|
Specify the character font pitch using the com.sun.star.awt.FontPitch constant group. The values are self-explanatory: DONTKNOW, FIXED, and VARIABLE.
|
|
CharColor
|
Specify the text color as a Long Integer.
|
|
CharEscapement
|
Specify the Short Integer representing the percentage of raising or lowering for superscript/subscript characters. Negative values lower the characters.
|
|
CharHeight
|
Specify the character height in points as a decimal number.
|
|
CharUnderline
|
Specify the character underline type using the com.sun.star.awt.FontUnderline constant group.
-
NONE = 0 - No underlining.
-
SINGLE = 1 - Single line.
-
DOUBLE = 2 - Double line.
-
DOTTED = 3 - Dotted line.
-
DONTKNOW = 4 - Unknown underlining.
-
DASH = 5 - Dashed line.
-
LONGDASH = 6 - Long dashes.
-
DASHDOT = 7 - Dash and dot sequence.
-
DASHDOTDOT = 8 - Dash, dot, dot sequence.
-
SMALLWAVE = 9 - Small wave.
-
WAVE = 10 - Wave.
-
DOUBLEWAVE = 11 - Double wave.
-
BOLD = 12 - Bold line.
-
BOLDDOTTED = 13 - Bold dots.
-
BOLDDASH = 14 - Bold dashes.
-
BOLDLONGDASH = 15 - Long bold dashes.
-
BOLDDASHDOT = 16 - Dash and dot sequence in bold.
-
BOLDDASHDOTDOT = 17 - Dash, dot, dot sequence in bold.
-
BOLDWAVE = 18 - Bold wave.
|
|
CharWeight
|
Specify the font weight using the com.sun.star.awt.FontWeight constant group.
-
DONTKNOW = 0.000 - Not specified/unknown.
-
THIN = 50.00 - 50% font weight.
-
ULTRALIGHT = 60.00 - 60% font weight.
-
LIGHT = 75.00 - 75% font weight.
-
SEMILIGHT = 90.00 - 90% font weight.
-
NORMAL = 100.00 - normal font weight (100%).
-
SEMIBOLD = 110.00 - 110% font weight.
-
BOLD = 150.00 - 150% font weight.
-
ULTRABOLD = 175.00 - 175% font weight.
-
BLACK = 200.00 - 200% font weight.
|
|
CharPosture
|
Specify the character posture using the com.sun.star.awt.FontSlant enumeration with values:
-
NONE - No slant, regular text.
-
OBLIQUE - Oblique font (slant not designed into the font).
-
ITALIC - Italic font (slant designed into the font).
-
DONTKNOW - Unknown slant.
-
REVERSE_OBLIQUE - Reverse oblique (slant not designed into the font).
-
REVERSE_ITALIC - Reverse italic font (slant designed into the font).
|
|
CharAutoKerning
|
Set to True to use the kerning tables for the current font. Automatic kerning adjusts the spacing between certain pairs of characters to improve readability.
|
|
CharBackColor
|
Specify the text background color as a Long Integer.
|
|
CharBackTransparent
|
If True, the text background color is transparent.
|
|
CharCaseMap
|
Specify how characters should be displayed using the com.sun.star.style.CaseMap constant group. This does not change the actual text-only the way it is displayed.
-
NONE = 0 - No case mapping is performed; this is the most commonly used value.
-
UPPERCASE = 1 - All characters are displayed in uppercase.
-
LOWERCASE = 2 - All characters are displayed in lowercase.
-
TITLE = 3 - The first character of each word is displayed in uppercase.
-
SMALLCAPS = 4 - All characters are displayed in uppercase, but with a smaller font.
|
|
CharCrossedOut
|
If True, the characters have a line through them.
|
|
CharFlash
|
If True, the characters are displayed flashing.
|
|
CharStrikeout
|
Specify character strikeout using the com.sun.star.awt.FontStrikeout constant group:
-
NONE = 0 - Do not strike out characters.
-
SINGLE = 1 - Strike out the characters with a single line.
-
DOUBLE = 2 - Strike out the characters with a double line.
-
DONTKNOW = 3 - The strikeout mode is not specified.
-
BOLD = 4 - Strike out the characters with a bold line.
-
SLASH = 5 - Strike out the characters with slashes.
-
X = 6 - Strike out the characters with X's.
|
|
CharWordMode
|
If True, white spaces (spaces and tabs) ignore the CharStrikeout and CharUnderline properties.
|
|
CharKerning
|
Specify the character kerning value as a Short Integer.
|
|
CharLocale
|
Specify the character locale as a com.star.lang.Locale structure.
|
|
CharKeepTogether
|
If True, OOo tries to keep the character range on the same line. If a break must occur, it occurs before the characters.
|
|
CharNoLineBreak
|
If True, OOo ignores a line break in the character range. If a break must occur, it occurs after the characters so it is possible that they will cross a border.
|
|
CharShadowed
|
If True, the characters are formatted and displayed with a shadow effect.
|
|
CharFontType
|
Specify the fundamental technology of the font using the com.sun.star.awt.FontType constant group.
-
DONTKNOW = 0 - The type of the font is not known.
-
RASTER = 1 - The font is a raster (bitmapped) font.
-
DEVICE = 2 - The font is output-device specific, such as a printer font.
-
SCALABLE = 3 - The font is scalable.
|
|
CharStyleName
|
Specify the name of the font style as a string.
|
|
CharContoured
|
If True, characters are formatted and displayed with a contour (3-D outline) effect.
|
|
CharCombinelsOn
|
If True, text is formatted and displayed using two lines. The CharCombinePrefix string precedes the text in full size, and the CharCombineSuffix follows the text in full size.
|
|
CharCombinePrefix
|
Specify the prefix (usually parentheses) used with the CharCombinelsOn property.
|
|
CharCombineSuffix
|
Specify the suffix (usually parentheses) used with the CharCombinelsOn property.
|
|
CharEmphasize
|
Specify the type and position of emphasis marks in Asian texts using the com.sun.star.text.FontEmphasis constant group:
-
NONE = 0 - No emphasis mark is used.
-
DOT_ABOVE = 1 - A dot is set above (or right from vertical text) the text.
-
CIRCLE_ABOVE = 2 - A circle is set above (or right from vertical text) the text.
-
DISK_ABOVE = 3 - A disk is set above (or right from vertical text) the text.
-
ACCENT_ABOVE = 4 - An accent is set above (or right from vertical text) the text.
-
DOT_BELOW = 11 - A dot is set below (or left from vertical text) the text.
-
CIRCLE_BELOW = 12 - A circle is set below (or left from vertical text) the text.
-
DISK_BELOW = 13 - A disk is set below (or left from vertical text) the text.
-
ACCENT_BELOW = 14 - An accent is set below (or left from vertical text) the text.
|
|
CharRelief
|
Specify the relief value from the com.sun.star.text.FontRelief constant group:
-
NONE = 0 - No relief is used; normal text.
-
EMBOSSED = 1 - Characters look embossed (raised).
-
ENGRAVED = 2 - Characters look engraved (lowered).
|
|
RubyText
|
Specify the text that is set as ruby. "Ruby Text" acts as an annotation and is associated with a "Ruby Base." This is typically used in Asian writing systems, providing a helper for uncommonly used writing characters that are not easily recognizable, especially by children. For example, in Japanese writing, the phonetic Hiragana alphabet is used to pair phonetic "helper" readings (called Furigana or Yomigana in Japanese) with the Chinese character counterpart.
|
|
RubyAdjust
|
Specify the ruby text adjustment using the com.sun.star.text.RubyAdjust enumeration:
-
LEFT - Adjust to the left.
-
CENTER - Adjust to the center.
-
RIGHT - Adjust to the right.
-
BLOCK - Adjust to both borders (stretched).
-
INDENT_BLOCK-Adjust to both borders with a small indent on both sides.
|
|
RubyCharStyleName
|
Specify the name of the character style that is applied to RubyText.
|
|
RubylsAbove
|
If True, the Ruby is printed above the text (right if the text is vertical).
|
|
CharRotation
|
Specify the rotation of a character in degrees as a Short Integer. Not all implementations support all values.
|
|
CharRotationIsFitToLine
|
If True, OOo tries to fit the rotated text to the surrounding line height.
|
|
CharScaleWidth
|
Specify the scaling for superscript and subscript as a percentage using a Short Integer.
|
|
HyperLinkURL
|
Specify the URL of a hyperlink (if set) as a String.
|
|
HyperLinkTarget
|
Specify the name of the target for a hyperlink (if set) as a String.
|
|
HyperLinkName
|
Specify the name of the hyperlink (if set) as a String.
|
|
VisitedCharStyleName
|
Specify the character style for visited hyperlinks as a String.
|
|
UnvisitedCharStyleName
|
Specify the character style name for unvisited hyperlinks as a String.
|
|
CharEscapementHeight
|
Specify the additional height used for subscript or superscript characters as an Integer percent. For subscript characters the value is negative.
|
|
CharNoHyphenation
|
If True, the word cannot be hyphenated at the character.
|
|
CharUnderlineColor
|
Specify the color of the underline as a Long Integer.
|
|
CharUnderlineHasColor
|
If True, the CharUnderlineColor is used for an underline.
|
|
CharStyleNames
|
An array of character style names applied to the text. The order is not necessarily relevant.
|
07/29/2010
Link to OpenOffice API Documentation
07/27/2010
Good Wiki on OOO Search and Replace
07/13/2010
WScript to output to a file, the list of processes running on the system
http://www.rgagnon.com/wshdetails/wsh-0003.html
http://blogs.technet.com/b/heyscriptingguy/archive/2006/06/01/how-can-i-find-the-process-id-associated-with-a-batch-file.aspx
strContent = ""
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & strComputer & "rootcimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_Process")
For Each objItem in colItems If InStr(objItem.CommandLine, ".bat") Or InStr(objItem.CommandLine, ".cmd") Or
InStr(objItem.CommandLine, ".odt") Then Wscript.Echo "Batch file: " & objItem.CommandLine & " | Process ID: " & objItem.ProcessID End If strContent = strContent & Pad(objItem.ProcessID) & " | " & objItem.CommandLine & chr(10) Next
Dim objFileSystem, objOutputFile Dim strOutputFile
' generate a filename base on the script name strOutputFile = "./" & Split(WScript.ScriptName, ".")(0) & ".txt"
Set objFileSystem = CreateObject("Scripting.fileSystemObject") Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)
objOutputFile.WriteLine("Hello world (" & Now & ")") objOutputFile.WriteLine(strContent)
objOutputFile.Close
Set objFileSystem = Nothing
WScript.Quit(0)
Function Pad(number) Pad = Right(1e4 + number, 4) End Function
07/13/2010
Useful CMD commands
List of useful CMD commands...
--Kill a process by name: TaskKill /F /IM Notepad++.exe
-- Kill a process by Process ID: Taskkill /F /PID 22546
--List all running processes: TaskList /FI "status eq running" -- or with one more filter... TaskList /FI "status eq running" /FI "username eq "ldpcvsanchez" -- List processes in 'Verbose' mode... Tasklist /V -- Isolate process by name (Find process for MS Outlook):
tasklist /FI "imagename eq outlook.exe"
-- Isolate process by name (Find process using a wildcard...):
tasklist /FI "imagename eq soffice.*"
-- Isolate process by name (Find process using a wildcard...), and make results Verbose:
tasklist /V /FI "imagename eq soffice.*"
07/12/2010
Link to Microsoft's Scripting Documentation
07/06/2010
Create New Document
Dim args(0)
Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
07/06/2010
Another example using WScript Host to manipulate OpenOffice Writer
Content copied from:
http://udk.openoffice.org/common/man/tutorial/writerdemo.html
Instructions, save the following code as a .vbs file...then run at the comma-line or just double-click on it...
'The service manager is always the starting point 'If there is no office running then an office is started up Set objServiceManager= WScript.CreateObject("com.sun.star.ServiceManager")
'Create the CoreReflection service that is later used to create structs Set objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
'Create the Desktop Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")
'Open a new empty writer document Dim args() Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
'Create a text object Set objText= objDocument.getText
'Create a cursor object Set objCursor= objText.createTextCursor
'Inserting some Text objText.insertString objCursor, "The first line in the newly created text document." & vbLf, false
'Inserting a second line objText.insertString objCursor, "Now we're in the second line", false
'Create instance of a text table with 4 columns and 4 rows Set objTable= objDocument.createInstance( "com.sun.star.text.TextTable") objTable.initialize 4, 4
'Insert the table objText.insertTextContent objCursor, objTable, false
'Get first row Set objRows= objTable.getRows Set objRow= objRows.getByIndex( 0)
'Set the table background color objTable.setPropertyValue "BackTransparent", false objTable.setPropertyValue "BackColor", 13421823
'Set a different background color for the first row objRow.setPropertyValue "BackTransparent", false objRow.setPropertyValue "BackColor", 6710932
'Fill the first table row insertIntoCell "A1","FirstColumn", objTable insertIntoCell "B1","SecondColumn", objTable insertIntoCell "C1","ThirdColumn", objTable insertIntoCell "D1","SUM", objTable
objTable.getCellByName("A2").setValue 22.5 objTable.getCellByName("B2").setValue 5615.3 objTable.getCellByName("C2").setValue -2315.7 objTable.getCellByName("D2").setFormula"sum "
objTable.getCellByName("A3").setValue 21.5 objTable.getCellByName("B3").setValue 615.3 objTable.getCellByName("C3").setValue -315.7 objTable.getCellByName("D3").setFormula "sum "
objTable.getCellByName("A4").setValue 121.5 objTable.getCellByName("B4").setValue -615.3 objTable.getCellByName("C4").setValue 415.7 objTable.getCellByName("D4").setFormula "sum "
'Change the CharColor and add a Shadow objCursor.setPropertyValue "CharColor", 255 objCursor.setPropertyValue "CharShadowed", true
'Create a paragraph break 'The second argument is a com::sun::star::text::ControlCharacter::PARAGRAPH_BREAK constant objText.insertControlCharacter objCursor, 0 , false
'Inserting colored Text. objText.insertString objCursor, " This is a colored Text - blue with shadow" & vbLf, false
'Create a paragraph break ( ControlCharacter::PARAGRAPH_BREAK). objText.insertControlCharacter objCursor, 0, false
'Create a TextFrame. Set objTextFrame= objDocument.createInstance("com.sun.star.text.TextFrame")
'Create a Size struct. Set objSize= createStruct("com.sun.star.awt.Size") objSize.Width= 15000 objSize.Height= 400 objTextFrame.setSize( objSize)
' TextContentAnchorType.AS_CHARACTER = 1 objTextFrame.setPropertyValue "AnchorType", 1
'insert the frame objText.insertTextContent objCursor, objTextFrame, false
'Get the text object of the frame Set objFrameText= objTextFrame.getText
'Create a cursor object Set objFrameTextCursor= objFrameText.createTextCursor
'Inserting some Text objFrameText.insertString objFrameTextCursor, "The first line in the newly created text frame.", _ false objFrameText.insertString objFrameTextCursor, _ vbLf & "With this second line the height of the frame raises.", false
'Create a paragraph break 'The second argument is a com::sun::star::text::ControlCharacter::PARAGRAPH_BREAK constant objFrameText.insertControlCharacter objCursor, 0 , false
'Change the CharColor and add a Shadow objCursor.setPropertyValue "CharColor", 65536 objCursor.setPropertyValue "CharShadowed", false
'Insert another string objText.insertString objCursor, "SHANE'S MOTHER IS HOTTER THAN GUAM!!!", false
On Error Resume Next If Err Then MsgBox "An error occurred" End If
Sub insertIntoCell( strCellName, strText, objTable) Set objCellText= objTable.getCellByName( strCellName) Set objCellCursor= objCellText.createTextCursor objCellCursor.setPropertyValue "CharColor",16777215 objCellText.insertString objCellCursor, strText, false End Sub
Function createStruct( strTypeName) Set classSize= objCoreReflection.forName( strTypeName) Dim aStruct classSize.createObject aStruct Set createStruct= aStruct End Function
07/06/2010
WScript Host to open and alter an OpenOffice Writer Document
Resources:
WSH Examples from Microsoft
http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx
http://user.services.openoffice.org/en/forum/viewtopic.php?f=44&t=14723
'Remember to replace single spaces with %20 sURL = "file:///C:/Documents%20and%20Settings/victor3434/Desktop/helloWorldMacro.odt" sURL_PDF = "file:///C:/Documents%20and%20Settings/victor3434/Desktop/helloWorldMacro.pdf" intPauseMillis = 500
Set oServiceManager = WScript.CreateObject("com.sun.star.ServiceManager") Set oDesktop = oServiceManager.createInstance("com.sun.star.frame.Desktop")
'Open an existing document...
Dim mArgs(0) Set mArgs(0) = MakePropertyValue("Hidden", False) Set oDoc = oDesktop.loadComponentFromURL(sURL, "_blank", 0, mArgs)
'use wshShell to send keys to the OpenOffice Writer document...
set WshShell = WScript.CreateObject("WScript.Shell") WScript.Sleep intPauseMillis WshShell.SendKeys "^a" 'Control + a = select all... WScript.Sleep intPauseMillis WshShell.SendKeys "{RIGHT}" 'Arrow right... WScript.Sleep intPauseMillis WshShell.SendKeys "~" 'ENTER key... WScript.Sleep intPauseMillis WshShell.SendKeys "YEAH BABY!!!" 'Enter literal string... Wscript.Sleep intPauseMillis
'Save the document... oDoc.store()
'Convert to PDF... Dim pdfArgs(0) Set pdfArgs(0) = MakePropertyValue("FilterName", "writer_pdf_Export") Dim oDocPDF oDocPDF = oDoc.storeToURL(sURL_PDF, pdfArgs)
'Close current document... oDoc.close(true)
'Function to create a name/value pair... Function MakePropertyValue(cName, uValue) Dim oStruct Set oStruct = oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") oStruct.Name = cName oStruct.Value = uValue Set MakePropertyValue = oStruct End Function
07/01/2010
Pad Number With Zeroes - Using the Format() method
sub formatThis() dim intNumber as integer intNumber = 9 msgbox Format(intNumber, "0000") end sub
06/30/2010
Open File Choose Dialog
Sub Main
dim fileName as string 'MergeDocumentsInDirectory("C:UsersvsanchezDesktopvictor3434odtstemp") fileName = ChooseAFileName() msgbox "You chose this file: " & fileName End Sub
' Function creates a prompt to allow a user to choose a file.. Function ChooseAFileName() As String Dim vFileDialog 'FilePicker service instance Dim vFileAccess 'SimpleFileAccess service instance Dim iAccept as Integer 'Response to the FilePicker Dim sInitPath as String 'Hold the initial path
'Note: The following services MUST be called in the following order 'or Basic will not remove the FileDialog Service vFileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker") vFileAccess = CreateUnoService("com.sun.star.ucb.SimpleFileAccess") 'Set the initial path here! sInitPath = ConvertToUrl(CurDir) If vFileAccess.Exists(sInitPath) Then vFileDialog.SetDisplayDirectory(sInitPath) End If iAccept = vFileDialog.Execute() 'Run the file chooser dialog If iAccept = 1 Then 'What was the return value? ChooseAFileName = vFileDialog.Files(0) 'Set file name if it was not canceled End If vFileDialog.Dispose() 'Dispose of the dialog
End Function
06/30/2010
Code to iterate through list of currently opened documents in OOo
' Iterates through all currently loaded documents in OOo... Sub IterateThroughAllDocs On Error Resume Next 'Ignore the non-document components Dim vComponents As Object 'All of the components Dim vDocs As Object 'Enumeration of the documents Dim vDoc As Object 'A single document Dim s As String GlobalScope.BasicLibraries.LoadLibrary("Tools")'Contains FileNameOutOfPath vComponents = StarDesktop.getComponents() 'Get all the components vDocs = vComponents.createEnumeration() 'Enumerate them Do While vDocs.hasMoreElements() 'While there are more vDoc = vDocs.nextElement() 'Get the next component s = s & getDocType(vDoc) & " " 'Add the document type s = s & FileNameOutOfPath(vDoc.getURL()) 'Add the file name s = s & CHR$(10) 'Add a new line Loop MsgBox s, 0, "Currently Open Components" End Sub
06/28/2010
OpenOffice API - Info about Services and Interfaces
More information about the available services, and their interfaces, methods and properties can be found in the reference for the OpenOffice.org API
06/28/2010
Success having ColdFusion run OpenOffice macro via command-line using batch file
Here's the problem:
Using OpenOffice.org, you can create or record a macro, or subroutine written in VB to perform some task. In my case, I wanted to read the contents of a series of .odt files and merge them into a single .odt text file. To to this, I put together a macro called MergeDocumentsInDirectory(). An the name suggests, it reads the contents of a directory, and for every .odt text file it finds in it, it combines the contents of each and finishes by generating a merged .odt text file.
At the command-line, this macro can be called into action using the following syntax:
cmd>soffice macro:///Standard.Module1.MergeDocumentsInDirectory()
A convenient way to call the MergeDocumentsInDirectory() macro is to create a simple batch file that you can simply double-click each time you want the macro to run. So far so good. When you double-click, results are as expected, cool!
The next step is to have ColdFusion run the batch file, so we go over to cfQuickDocs to get the proper syntax:
[cfexecute name = "application name" arguments = "command line arguments" outputFile = "output filename" timeout = "timeout interval" variable = "variable name"] ... [/cfexecute>]
In particular, you really only need the 'name', and perhaps the timeout parameter. The name parameter gets the full path to the batch file, while the timeout parameter should be set to a value greater than 2 adn large enough to accomodate the processing time required by the macro. When I put the code together, of course, when I run the coldfusion page with the code in it, nothing happens. The code seems to execute, but the expected output from the macro is missing. Dang it. I tried many different things to no avail, and just as i was thinking there was no solution, I came across a very interesting article from somebody who was having a very similar problem:
http://blog.mxunit.org/2009/10/why-is-cfexecute-hanging.html
So here is what is happening. When coldfusion runs , the command-line requests is made on behalf of the coldfusion user. So for example, say that you have CF configured to run as cfUser. Since cfUser is not likely to be used for anything else, when you use the batch file, there are a number of things that are likely missing, but need to be true for the code to work:
Change the ColdFusion application service to run as a specific user, say cfUser (See below for how to to this)
The path to soffice.exe needs to be a full path OR within the cfUser's account, you must set the PATH variable to include the path to to where soffice.exe resides
The macro to be called needs to be created using the cfUser account, since otherwise, the code is not accessible to coldfusion.
When OpenOffice.org is installed in a machine, even though it may have been made available to all users, each user that opens it will need to go through an initial set of screens that invite you to register and set the user info to be used in document creation...Until this takes place, any attempt to open OpenOffice (which your macro would try to do), will result in a prompt asking for user input, which will result in the illusion that coldfusion is hanging when is used to call the batch file.
The appropriate flags need to be included when the macro is called at the command-line in order to prevent OpenOffice from requesting input when the macro is called. The flag is needed -headless so the batch file should look like this:
cmd>"C:/Program Files/OpenOffice.org 3/program/soffice.exe" -headless macro:///Standard.Module1.MergeDocumentsInDirectory()
Note, if you need coldfusion to run as a different user, here's a good artible describing how it can be done:
http://kb2.adobe.com/cps/172/tn_17279.html
Essentially, it involves opening the 'Services' interface, finding the ColdFusion Application service and manipulating its Properties, changing it to use a specific user and restarting the service.
06/27/2010
Display info about an arbitrary object
Display info about a given object, allows you to know what properties are available and what methods you can call on it...
Example, say you have object vObj, you can display this way:
MsgBox vObj.dbg_methods 'Methods for this object. MsgBox vObj.dbg_supportedInterfaces 'Interfaces for by this objec MsgBox vObj.dbg_properties 'Properties for this object.
06/27/2010
Merging Multiple Text Documents In a Folder - OpenOffice Macro
REM ***** BASIC *****
Sub Main
MergeDocumentsInDirectory()
End Sub
Sub MergeDocumentsInDirectory() Dim DestDirectory As String Dim FileName As String Dim SrcFile As String, DstFile As String Dim oDesktop, oDoc, oCursor, oText Dim argsInsert() Dim args() ' Remove the following comments to do things hidden ' dim args(0) as new com.sun.star.beans.PropertyValue ' args(0).name = "Hidden" ' args(0).value = true ' Which desitnation directory? 'DestDirectory = Trim( GetFolderName() ) DestDirectory = "C:Documents and Settingsvictor3434DesktopLWBodt_docs"
If DestDirectory = "" Then MsgBox "No directory selected, exiting",16,"Merging Documents" Exit Sub End If
' force a trailing backslash. This is okay because using URL notation If Right(DestDirectory,1) <> "/" Then DestDirectory = DestDirectory & "/" End If
oDeskTop = CreateUnoService("com.sun.star.frame.Desktop") ' Read the first file! FileName = Dir(DestDirectory) DstFile = ConvertToURL(DestDirectory & "ResultatFusion.odt") Do While FileName <> "" If lcase( right(FileName,3)) = "odt" Then SrcFile = ConvertToURL(DestDirectory & FileName) If IsNull(oDoc) OR IsEmpty(oDoc) Then FileCopy( SrcFile, DstFile ) oDoc = oDeskTop.Loadcomponentfromurl(DstFile, "_blank", 0, Args()) oText = oDoc.getText oCursor = oText.createTextCursor() Else oCursor.gotoEnd(false) oCursor.BreakType = com.sun.star.style.BreakType.PAGE_BEFORE oCursor.insertDocumentFromUrl(SrcFile, argsInsert()) End If End If FileName = dir() Loop If IsNull(oDoc) OR IsEmpty(oDoc) Then MsgBox "No documents merged!",16,"Merging Documents" Exit Sub End If
' Save the document Dim args2() oDoc.StoreAsURL(DstFile,args2()) If HasUnoInterfaces(oDoc, "com.sun.star.util.XCloseable") Then oDoc.close(true) Else oDoc.dispose End If ' Reload the document! 'oDoc=oDeskTop.Loadcomponentfromurl(DstFile,"_blank",0,Args2()) End Sub
06/27/2010
Iterate through paragraphs of a document
Dim Doc As Object
Dim Enum1 As Object
Dim Enum2 As Object
Dim TextElement As Object
Dim TextPortion As Object
Doc = ThisComponent
Enum1 = Doc.Text.createEnumeration
' loop over all paragraphs
While Enum1.hasMoreElements
TextElement = Enum1.nextElement
If TextElement.supportsService("com.sun.star.text.Paragraph") Then
Enum2 = TextElement.createEnumeration
' loop over all sub-paragraphs
While Enum2.hasMoreElements
TextPortion = Enum2.nextElement
MsgBox "'" & TextPortion.String & "'"
msgbox TextPortion.String
Wend
End If
Wend
06/27/2010
Code needed to export current Text document at PDF
'Export to pdf... Dim args3(0) as new com.sun.star.beans.PropertyValue args3(0).Name = "FilterName" args3(0).Value = "writer_pdf_Export" ThisComponent.storeToURL(DstFilePDF, args3())
06/26/2010
Merging Multiple Text Documents In a Folder - OpenOffice Macro
From: Andrew Pitonyak's Useful Macro Information for OpenOffice
Can use ColdFusion's [cfexecute] tag to execute OpenOffice's macro:
?>soffice "macro:///Standard.Module1.MergeDocumentsInDirectory()"
Note that this assumes that you are either at the same directory where soffice.exe exists, or that you have added it's path to your ENV_PATH variable so that the executable can be accessed.
REM ***** BASIC *****
Sub Main
MergeDocumentsInDirectory()
End Sub
Sub MergeDocumentsInDirectory() Dim DestDirectory As String Dim FileName As String Dim SrcFile As String, DstFile As String Dim oDesktop, oDoc, oCursor, oText Dim argsInsert() Dim args() ' Remove the following comments to do things hidden ' dim args(0) as new com.sun.star.beans.PropertyValue ' args(0).name = "Hidden" ' args(0).value = true ' Which desitnation directory? 'DestDirectory = Trim( GetFolderName() ) DestDirectory = "C:Documents and Settingsvictor3434DesktopLWBodt_docs"
If DestDirectory = "" Then MsgBox "No directory selected, exiting",16,"Merging Documents" Exit Sub End If
' force a trailing backslash. This is okay because using URL notation If Right(DestDirectory,1) <> "/" Then DestDirectory = DestDirectory & "/" End If
oDeskTop = CreateUnoService("com.sun.star.frame.Desktop") ' Read the first file! FileName = Dir(DestDirectory) DstFile = ConvertToURL(DestDirectory & "ResultatFusion.odt") Do While FileName <> "" If lcase( right(FileName,3)) = "odt" Then SrcFile = ConvertToURL(DestDirectory & FileName) If IsNull(oDoc) OR IsEmpty(oDoc) Then FileCopy( SrcFile, DstFile ) oDoc = oDeskTop.Loadcomponentfromurl(DstFile, "_blank", 0, Args()) oText = oDoc.getText oCursor = oText.createTextCursor() Else oCursor.gotoEnd(false) oCursor.BreakType = com.sun.star.style.BreakType.PAGE_BEFORE oCursor.insertDocumentFromUrl(SrcFile, argsInsert()) End If End If FileName = dir() Loop If IsNull(oDoc) OR IsEmpty(oDoc) Then MsgBox "No documents merged!",16,"Merging Documents" Exit Sub End If
' Save the document Dim args2() oDoc.StoreAsURL(DstFile,args2()) If HasUnoInterfaces(oDoc, "com.sun.star.util.XCloseable") Then oDoc.close(true) Else oDoc.dispose End If ' Reload the document! 'oDoc=oDeskTop.Loadcomponentfromurl(DstFile,"_blank",0,Args2()) End Sub
|