| View previous topic :: View next topic |
| Author |
Message |
zap General User

Joined: 28 May 2004 Posts: 40
|
Posted: Thu Jun 24, 2004 2:37 am Post subject: crash when closing hidden doc after accessing text frame |
|
|
Hi,
I wonder if anyone heard about this:
When open a document as hidden from a Template (AsTemplate=True, Hidden=True), then insert some Text, store it to an URL, then close it things work fine. But when I access a textFrame in the document, the entire OO will crash with the close () call.
In code:
| Code: |
doc = docFromTemplate ("template.stw")
doc.textFrames.getByName ("frame")
doc.storeAsURL ("file.sxw")
doc.close () 'OO will crash here without throwing exception
|
where "frame" exists in the template. When I don't do StoreAsURL, it won't crash, but it's uselsess then.
If nobody knows what this is about, should I post a bug-ticket for OO?
thx
zap |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Thu Jun 24, 2004 5:16 am Post subject: |
|
|
You don't provide a complete runnable program that demonstrates the bug. So I tried the following complete example, and have no problem on Win XP, OOo 1.1.2.
| Code: | Sub Main
cFile = "C:\Documents and Settings\dbrewer\Desktop\FrameTemplate.stw"
cUrl = ConvertToURL( cFile )
oDoc = StarDesktop.loadComponentFromURL( cUrl, "_blank", 0,_
Array( _
MakePropertyValue( "AsTemplate", True ),_
MakePropertyValue( "Hidden", True ) ) )
oTextFrame = oDoc.getTextFrames().getByName( "Frame1" )
cFile = "C:\Documents and Settings\dbrewer\Desktop\NewFile.sxd"
cUrl = ConvertToURL( cFile )
oDoc.storeAsUrl( cUrl, Array() )
oDoc.close( True )
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
|
The file FrameTemplate.stw is on the desktop, it has about a dozen blank lines. About line six has a sentence. There is a frame anchored to the middle of the document, with another sentence in the frame. The document was saved as a template FrameTemplate.stw.
Can you run the complete example that I provided here?
If you do submit a but, I would recommend that you provide a fully working example that they will be able to reproduce on a specific type of configuraiton. (i.e. Windows XYZ, and OOo X.Y.Z) _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
zap General User

Joined: 28 May 2004 Posts: 40
|
Posted: Thu Jun 24, 2004 6:56 am Post subject: |
|
|
I am sorry for only providing pseudo-code, the original is very lengthy. Thanks a lot for doing it for me.
Your example crashes my OO, too.
I use a debian sarge box with the standard OO from debian which is Ximian patched. The 1.1.2 build from the OO site works fine though. Since it does not work on another self-build Ximian-patched gentoo-version it's probably related to the patches.
Thanls a lot for your help anyway.
zap |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Thu Jun 24, 2004 10:03 am Post subject: |
|
|
I just noticed a mistake in my example.
When I save the new copy of the file, I give it a suffix of ".sxd". (Hmmm, wonder why I would accidentially do that? ) But this seems harmless.
In fact, you can rename an OOo document to have any OOo document extension, and OOo is not confused. OOo must look at the meta data in the document to determine the type, and ignore the file suffix. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Thu Jun 24, 2004 10:25 am Post subject: |
|
|
Once again I might wanna add, that it probably has nothing to do with your code, but rather with OOo's current framework and/or program core.
It is known that quite an amount of actions - with means of the API - cannot be invoked on a hidden document.
That will hopefully improved in OOo2.0 _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Thu Jun 24, 2004 11:47 am Post subject: |
|
|
| Cybb20 wrote: | Once again I might wanna add, that it probably has nothing to do with your code, but rather with OOo's current framework and/or program core.
It is known that quite an amount of actions - with means of the API - cannot be invoked on a hidden document.
That will hopefully improved in OOo2.0 |
I want to attempt to add some clarification.
The dispatcher does not work on hidden windows.
The API does work on hidden windows. (I don't know of any broken API features on hidden windows.)
(btw, Intercepting dispatches and writing Dispatcher based code is how the Macro Recorder works.)
The API should always be preferred to using the dispatcher. The dispatcher should be used for things that are missing from the API.
Hopefully in OOo 2.0, the API will include more capability that is missing today, making the dispatcher even less necessary.
Making the dispatcher work on hidden windows is possibly counterproductive. (Encourages writing dispatcher code rather than api code.) It may not even be possible, since you dispatch on a Frame, and a hidden document (model) has no Frame. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Thu Jun 24, 2004 10:57 pm Post subject: |
|
|
Danny:
| Quote: |
The API does work on hidden windows. (I don't know of any broken API features on hidden windows.)
|
Nobody can likely prove that. In my understanding there are also methods in the API that cannot be invoked properly.
Anyway I think it's just a general rule always to be reminded that hidden windows in OOo have their weaknesses, when trying to do things/or even simply access things to/of them with any programming language. _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Fri Jun 25, 2004 6:56 am Post subject: |
|
|
| Cybb20 wrote: | | Anyway I think it's just a general rule always to be reminded that hidden windows in OOo have their weaknesses, when trying to do things/or even simply access things to/of them with any programming language. |
Definitely so. Any code you write using hidden windows, should get extra scrutiny and testing. No assumptions of "but it worked on a visible window!".
As for doing document conversions (a popular subject on OOoForum apparently ) I have found no drawbacks to using hidden windows. I have some some other minor operations using windows.
Hey, I just thought of something! Not being able to copy/paste (dispatcher!) on a hidden window is going to cause real problems implementing a "WordArt" type component! I need to create a hidden drawing. Put text onto it. Change it into a Bezier shape of text. Fill with gradient. Then copy/paste back into Writer. Maybe I'll have to make the drawing "invisible" by positioning the window waaaaay off screen? _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
|
|
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
|