Re: [LyX/master] Advaced search: check for toString() before using it. (#12783)

2023-05-18 Thread Richard Kimberly Heck

On 5/18/23 11:02, Kornel Benko wrote:

commit f13808939b9ae6d8d467538d17157a87e8a1a37c
Author: Kornel Benko 
Date:   Thu May 18 18:07:40 2023 +0200

 Advaced search: check for toString() before using it.
 (#12783)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index b8819fd..fed5a74 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -4314,7 +4314,7 @@ docstring Paragraph::asString(pos_type beg, pos_type end, 
int options, const Out
else if (c == META_INSET && (options & AS_STR_INSETS)) {
if (c == META_INSET && (options & AS_STR_PLAINTEXT)) {
LASSERT(runparams != nullptr, return 
docstring());
-   if (runparams->find_effective())
+   if (runparams->find_effective() && 
getInset(i)->hasToString())
getInset(i)->toString(os);
else
getInset(i)->plaintext(os, *runparams);


I know this will be an annoying suggestion after all that work, but what 
about:


if (runparams->find_effective) {
    string str = getInset(i)->toString(os);
    if (str.empty())
        str = getInset(i)->plaintext(os, *runaparms);
}

? Then no need for the new method.

Riki


--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Can I check, if a class component is overridden? Help for #12783

2023-05-18 Thread Kornel Benko
Am Thu, 18 May 2023 10:56:21 -0400
schrieb Richard Kimberly Heck :

> On 5/18/23 10:26, Kornel Benko wrote:
> > Specifically I would like to know if the component toString() in class 
> > Inset is
> > overridden.  
> 
> https://en.cppreference.com/w/cpp/types/is_same
> 
> 
> > To solution for #12783 would be ATM the attached, but I'd like to have it 
> > done for
> > other insets too.  
> 
> Why does this need doing? My sense is that it's almost always a design 
> problem if one needs to know this.
> 
> Riki
> 
> 

While in adv-search, the virtual component toString() results in empty string, 
so
that we do not find the searched string.
We therefore need reasonable output. In 

At the design-time nobody thought about searching probably.
Adding new component in 58 source-files feels weird for this use-case.

Kornel


pgpGTZy_tbTuE.pgp
Description: Digitale Signatur von OpenPGP
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Can I check, if a class component is overridden? Help for #12783

2023-05-18 Thread Richard Kimberly Heck

On 5/18/23 10:26, Kornel Benko wrote:

Specifically I would like to know if the component toString() in class Inset is 
overridden.


https://en.cppreference.com/w/cpp/types/is_same



To solution for #12783 would be ATM the attached, but I'd like to have it done 
for other insets too.


Why does this need doing? My sense is that it's almost always a design 
problem if one needs to know this.


Riki


--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Can I check, if a class component is overridden? Help for #12783

2023-05-18 Thread Kornel Benko

Specifically I would like to know if the component toString() in class Inset is
overridden.

To solution for #12783 would be ATM the attached, but I'd like to have it done 
for
other insets too.

Kornel
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index b8819fdf1b..6ce3ce08ff 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -4312,11 +4312,11 @@ docstring Paragraph::asString(pos_type beg, pos_type end, int options, const Out
 		|| (c == '\n' && (options & AS_STR_NEWLINES)))
 			os.put(c);
 		else if (c == META_INSET && (options & AS_STR_INSETS)) {
 			if (c == META_INSET && (options & AS_STR_PLAINTEXT)) {
 LASSERT(runparams != nullptr, return docstring());
-if (runparams->find_effective())
+if (runparams->find_effective() && !getInset(i)->isTable())
 	getInset(i)->toString(os);
 else
 	getInset(i)->plaintext(os, *runparams);
 			} else if (c == META_INSET && (options & AS_STR_MATHED)
    && getInset(i)->lyxCode() == REF_CODE) {


pgpPIDoXUgwEY.pgp
Description: Digitale Signatur von OpenPGP
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel