Issue 22746 - Cursor "lost" after .uno:InsertGraphic
Summary: Cursor "lost" after .uno:InsertGraphic
Status: CLOSED FIXED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Linux, all
: P3 Trivial
Target Milestone: ---
Assignee: stephan.wunderlich
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-22 22:30 UTC by em2
Modified: 2013-02-24 21:07 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description em2 2003-11-22 22:30:13 UTC
After dispatching .uno:InsertGraphic to a text document, the cursor
is "lost": it's no longer visible and createTextCursorByRange
will crash when used this way:

  Reference<text::XTextViewCursor> xViewCursor =
xViewCursorSupplier->getViewCursor ();
  Reference<text::XTextRange> xStart = xViewCursor->getStart ();
  Reference<text::XTextCursor> xTextCursor = xText->createTextCursorByRange
(xStart);
Comment 1 ooo 2003-12-10 12:13:20 UTC
forwarding to responsible developer
Comment 2 thomas.lange 2004-04-21 10:13:09 UTC
Need to check:

The following macro results in a runtime exception when some text is selected:

sub Main

oDoc = thiscomponent
oVC = oDOc.getCurrentController.getViewCursor
'msgbox IsNull(oVc)
'msgbox oVc.getString

InsertGrafik
oStart =oVC.getStart
oTC = oDoc.getText.createTextCursorByRange( oStart )

end sub

sub InsertGrafik

rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(3) as new com.sun.star.beans.PropertyValue
args1(0).Name = "FileName"
args1(0).Value = "file:///C:/office-prox-src680_m32-1/share/gallery/apples.gif"
args1(1).Name = "FilterName"
args1(1).Value = "<All formats>"
args1(2).Name = "AsLink"
args1(2).Value = false
args1(3).Name = "Style"
args1(3).Value = "Graphics"

dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args1())


end sub

Comment 3 thomas.lange 2004-09-21 09:18:05 UTC
Set target to OOo 2.0
Comment 4 thomas.lange 2004-10-05 11:45:51 UTC
When running the macro the following code in unoobj2.cxx
SwXTextRange::CreateTextRangeFromPosition will be reached:

:		case SwFlyStartNode:
:		{
:			SwFrmFmt* pFmt;
:			if(0 != (pFmt = pSttNode->GetFlyFmt()))
:			{
:				aRet = new SwXTextRange(*pFmt, *pNewCrsr);
:
:			}
:		}

The pNewCrsr has the attribute bRemainInSection set and thus should not move out
of the section (and in the graphic as it effectively does).

TL->FME: Please have a look. Thanks!


Comment 5 frank.meies 2004-10-06 07:58:22 UTC
FME->TL: I cannot see a problem here. The view cursor will be modified by the
InsertGraphic operation. The only problem according to OS is that the getStart()
call should already throw the exception.
Comment 6 thomas.lange 2004-10-07 11:30:26 UTC
.
Comment 7 thomas.lange 2004-10-07 11:40:35 UTC
Since the view is selecting the graphic after the InsertGrafic call it is not
possible to
create a TextCursor from the ViewCursor (especially since if the grafik is
anchored to the page there is no guessing what the text before or after might be).
If you want to go on with a TextCursor you need to remember it before inserting
the grafic or create a new cursor, but not via passing the view cursor (which is
currently not selecting any text) as argument to the createTextCursorByRange
funcrion.


Fixed in CWS tl03.
Files changed:
- unotxvw.hxx  new revision: 1.7.664.1
- unotxvw.cxx  new revision: 1.48.40.1

I added code to the SwXTextViewCursor to check if there is a text selection when
functions are called that need a working text cursor.
This is the case for all functions from the interfaces
- XLineCursor
- XTextCursor
- XTextRange
- XViewCursor
those functions will now throw a RuntimeException when there is no text selection.

For the example this means the call to xViewCursor->getStart() will now fail.


Comment 8 thomas.lange 2004-11-01 08:57:21 UTC
.
Comment 9 thomas.lange 2004-11-01 08:57:45 UTC
OK in CWS tl03.
Comment 10 thomas.lange 2004-11-01 08:58:05 UTC
.
Comment 11 stephan.wunderlich 2004-11-02 11:26:49 UTC
can't see any changes in tl03 and so will remove it from the cws
Comment 12 stephan.wunderlich 2004-11-02 11:35:42 UTC
back to you to take a second look
Comment 13 thomas.lange 2004-11-25 12:18:35 UTC
TL->MBU: Please have a look.
Comment 14 mbu 2004-11-26 11:57:22 UTC
fix had a bug :-)
SwXTextViewCursor::IsTextSelection in /sw/ui/uno/unotxvw.cxx is now working as
expected...
Comment 15 mbu 2005-01-10 09:38:10 UTC
.
Comment 16 mbu 2005-01-10 10:02:00 UTC
.
Comment 17 stephan.wunderlich 2005-01-11 14:04:14 UTC
to me for verification
Comment 18 stephan.wunderlich 2005-01-13 13:34:35 UTC
sw->mbu: the given macro still throws a runtime exception at oStart
=oVC.getStart ... seems there is still a bug in the fix for the fix ... or do I
miss something ?
Comment 19 mbu 2005-01-13 14:05:50 UTC
as thomas wrote somewhere above "For the example this means the call to
xViewCursor->getStart() will now fail." the runtime exception is the correct
behavior.
see his full explanation for further reference. originally the call to
"createTextCursorByRange
" caused a crash which now has been fixed.
Comment 20 stephan.wunderlich 2005-01-13 14:38:44 UTC
ok in cws_mbu2 => fixed
Comment 21 stephan.wunderlich 2005-01-13 14:39:00 UTC
verified
Comment 22 thomas.lange 2005-01-25 16:23:18 UTC
TL->QA: Please not that #i22746# should still be Ok.
Comment 23 stephan.wunderlich 2005-01-26 16:40:13 UTC
ok in src680_m73 => closed