OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

question on template

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
jelaih
OOo Enthusiast
OOo Enthusiast


Joined: 23 Feb 2005
Posts: 152

PostPosted: Tue Nov 22, 2005 10:44 pm    Post subject: question on template Reply with quote

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... Smile
Back to top
View user's profile Send private message
jelaih
OOo Enthusiast
OOo Enthusiast


Joined: 23 Feb 2005
Posts: 152

PostPosted: Wed Nov 23, 2005 4:50 pm    Post subject: Reply with quote

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... Smile
Back to top
View user's profile Send private message
jelaih
OOo Enthusiast
OOo Enthusiast


Joined: 23 Feb 2005
Posts: 152

PostPosted: Thu Nov 24, 2005 12:32 am    Post subject: Reply with quote

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... Smile
Back to top
View user's profile Send private message
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Thu Nov 24, 2005 4:56 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
jelaih
OOo Enthusiast
OOo Enthusiast


Joined: 23 Feb 2005
Posts: 152

PostPosted: Thu Nov 24, 2005 5:37 pm    Post subject: Reply with quote

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... Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group