| View previous topic :: View next topic |
| Author |
Message |
jelaih OOo Enthusiast


Joined: 23 Feb 2005 Posts: 152
|
Posted: Tue Nov 22, 2005 10:44 pm Post subject: question on template |
|
|
I have created my own template (with customized styles saved on it) named "normal.stw" and i set it as the default template.
What I am trying to do is
1) I am going to load a "<varying_filename>.doc"
2) I renamed the "<varying_filename>.doc" into "<varying_filename>.sxw" through macro
Problem encountered: ---Some of the styles which I have created in my template were missing in the "<varying_filename>.doc" as well as in the "<varying_filename>.sxw" once I checked F11. I want to retain the styles created in the template. I am I missing something? Thanks _________________ codebits...  |
|
| Back to top |
|
 |
jelaih OOo Enthusiast


Joined: 23 Feb 2005 Posts: 152
|
Posted: Wed Nov 23, 2005 4:50 pm Post subject: |
|
|
here the code:
| Code: |
Sub SavingFileNames
Dim oDoc
Dim sDocURL
Dim sUrl as String
oDoc = ThisComponent
oText = oDoc.Text
If (Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools")) Then
GlobalScope.BasicLibraries.LoadLibrary("Tools")
End If
If (oDoc.hasLocation()) Then
sDocURL = oDoc.getURL()
pSath = DirectoryNameoutofPath(sDocURL, "/")
xName = FileNameoutofPath(sDocURL, "/")
fName = left(xName, 8)
sUrl = pSath & "/" & fname & ".sxw"
oView = ThisComponent.getCurrentController().getViewCursor()
oSelection = oView.getString()
If oSelection = "" Then
document = ThisComponent.CurrentController.Frame
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = pSath & "/" & fname & ".sxw"
args1(1).Name = "Overwrite"
args1(1).Value = "StarOffice XML (Writer)"
oDispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args1())
Else
ClipboardCut( oDoc )
oPRE = StarDesktop.loadComponentFromURL( "private:factory/swriter", "_blank", 0, Array() )
ClipboardPaste( oPRE )
oPRE.storeAsURL(ConvertToURL(sURL), Array( MakePropertyValue( "Overwrite", TRUE ) )
oPRE.close(TRUE)
End If
End If
oDialog1.EndExecute()
End Sub
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
oPropertyValue = createUnoStruct( "com.sun.star.beans.PropertyValue" )
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
Sub ClipboardPaste( oDocumentFrame )
DocumentDispatch( oDocumentFrame, ".uno:Paste" )
End Sub
Sub ClipboardCut( oDocumentFrame )
DocumentDispatch( oDocumentFrame, ".uno:Cut" )
End Sub
|
_________________ codebits...  |
|
| Back to top |
|
 |
jelaih OOo Enthusiast


Joined: 23 Feb 2005 Posts: 152
|
Posted: Thu Nov 24, 2005 12:32 am Post subject: |
|
|
Ok, Here is the scenario. Every document that comes from our clients are created from MS Word. I will be loading that certain "*.doc" in OpenOffice. I have created my own template with styles on it and set it as the default template. Since I set my created template as the default template, i assumed that whenever I load a new text document even through a macro, it will inherit the styles i have in my template. The problem is, with the code above,
not all styles I have created appeared (specifically the numbering style) once I saved is as "*.sxw".
Thanks _________________ codebits...  |
|
| Back to top |
|
 |
probe1 Moderator


Joined: 18 Aug 2004 Posts: 2465 Location: Chonburi Thailand Asia
|
Posted: Thu Nov 24, 2005 4:56 am Post subject: |
|
|
AFAIK there is an issue with saving a numbering style.....
Here all custom paragraph styles exported to *.doc are retained. Changing the *.doc, saving and re-opening in Writer kept those styles. _________________ Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs |
|
| Back to top |
|
 |
jelaih OOo Enthusiast


Joined: 23 Feb 2005 Posts: 152
|
Posted: Thu Nov 24, 2005 5:37 pm Post subject: |
|
|
| Quote: |
AFAIK there is an issue with saving a numbering style.....
|
You mean it's a bug?
Yep, whenever I execute the macro above, the only retained style I have are the paragraph styles. The thing is, there were unknown numbering styles like RTF_NUm 1,RTF_NUm 3, WWW8...etc, on my numbering styles and not the style which I have created. I thought Icould manipulate it through a macro. [/code] _________________ codebits...  |
|
| Back to top |
|
 |
|