List Info

Thread: listener issues




listener issues
user name
2007-10-10 07:12:44
Hi,

I am listening to the destruction of fields with
StartListening(
*static_cast<SwPostItField*>(aField->GetFld()) );

Normally this works fine, but when  I select a couple of
fields inside the document and deleting them all together, I
do not recieve a notify event for each one of them, normally
the last one is missing.

Any idea what the problem is?

Regards
Max
Re: listener issues
user name
2007-10-11 03:05:33
Hi Max,

On 10/10/07 14:12, Maximilian Odendahl wrote:
> 
> I am listening to the destruction of fields with
StartListening(
*static_cast<SwPostItField*>(aField->GetFld()) );

I'm not sure if you should listen on the SwPostItField. Are
the 
SwPostItFields actually destructed if you delete them from
the text? Or 
are they still kept in some undo structure? I bet the 
SwPostItField::Ctor is called a couple of times whan
inserting a new 
notes. I discussed this issue with OS and we think you
should better 
listen on the SwTxtFld text attribute (or simply add some
code to 
SwTxtFld::Ctor and SwTxtFld:tor that
registers the note with the notes 
manager).

Hope this helps,

Frank

--
Frank Meies (fme) - OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/Gu
llFOSS

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribesw.openoffice.org
For additional commands, e-mail: dev-helpsw.openoffice.org


Re: listener issues
user name
2007-10-11 07:07:57
Hi Frank,

>or simply add some code to SwTxtFld:tor that
registers the note with the 
>notes manager).

Does sth. like that in general make sense(except the
c-casts) or am I on the 
wrong track here?

SwTxtFld::~SwTxtFld( )
{
    if (Which()==RES_TXTATR_FIELD)
    {
        if ( 
((SwFmtFld&)(GetAttr())).GetFld()->GetTyp()->Which
()==RES_POSTITFLD)
        {
            SwDocShell* aShell = 
static_cast<SwPostItFieldType*>(((SwFmtFld&)GetAtt
r()).GetFld()
                                           
->GetTyp())->GetDoc()->GetDocShell();
            if (aShell)
            {
               
aShell->GetView()->GetPostItMgr()->Delete((SwFmtFld
&)GetAttr());
            }
        }
    }
}

I get an assertion that there is no attribute, but where is
it? Or in other 
words, how can I get my SwFmtFld?
Do I need the check if it is really a RES_TXTATR_FIELD, or
is this always 
the case?

Regards
Max



------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribesw.openoffice.org
For additional commands, e-mail: dev-helpsw.openoffice.org


Re: listener issues
user name
2007-10-11 08:29:55
Hi Max,

On 10/11/07 14:07, Maximilian Odendahl wrote:
> 
> Does sth. like that in general make sense(except the
c-casts) or am I on 
> the wrong track here?
> 
> SwTxtFld::~SwTxtFld( )
> {
>    if (Which()==RES_TXTATR_FIELD)
>    {
>        if ( 
>
((SwFmtFld&)(GetAttr())).GetFld()->GetTyp()->Which
()==RES_POSTITFLD)
>        {
>            SwDocShell* aShell = 
>
static_cast<SwPostItFieldType*>(((SwFmtFld&)GetAtt
r()).GetFld()
>                                            
> ->GetTyp())->GetDoc()->GetDocShell();
>            if (aShell)
>            {
>                
>
aShell->GetView()->GetPostItMgr()->Delete((SwFmtFld
&)GetAttr());
>            }
>        }
>    }
> }
> 
> I get an assertion that there is no attribute, but
where is it? Or in 
> other words, how can I get my SwFmtFld?

Unfortunately, pAttr is already deleted SwTxtNode:estroyAt
tr() by 
calling RemoveFromPool(). Looks like we have to keep it this
way, see 
comment "RemoveFromPool muss immer vorm DTOR Aufruf
erfolgen!!" in 
txatbase.hxx.  It's always harder than expected. I suggest
for now you 
can move this code to "RemoveFromPool", meanwhile
I'll discuss this 
issue with OS.

Regards,

Frank

--
Frank Meies (fme) - OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/Gu
llFOSS

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribesw.openoffice.org
For additional commands, e-mail: dev-helpsw.openoffice.org


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )