Skip to content

Commit

Permalink
[Shared] fixes italic and strike-through being allowed in TextBlock (m…
Browse files Browse the repository at this point in the history
…icrosoft#2935)

* disallows TextBlock to have italic and strikethrough as known properties

* updated ios and android

* updated CMakeLists.txt for android
  • Loading branch information
jwoo-msft authored May 20, 2019
1 parent db48e18 commit 6c21173
Show file tree
Hide file tree
Showing 17 changed files with 358 additions and 25 deletions.
1 change: 1 addition & 0 deletions source/android/adaptivecards/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ add_library( # Sets the name of the library.
../../shared/cpp/ObjectModel/ParseResult.cpp
../../shared/cpp/ObjectModel/ParseUtil.cpp
../../shared/cpp/ObjectModel/RichTextBlock.cpp
../../shared/cpp/ObjectModel/RichTextElementProperties.cpp
../../shared/cpp/ObjectModel/SemanticVersion.cpp
../../shared/cpp/ObjectModel/SharedAdaptiveCard.cpp
../../shared/cpp/ObjectModel/ShowCardAction.cpp
Expand Down
3 changes: 3 additions & 0 deletions source/android/adaptivecards/src/AdaptiveCardObjectModel.i
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ struct tm {
#include "../../../shared/cpp/ObjectModel/Inline.h"
#include "../../../shared/cpp/ObjectModel/RichTextBlock.h"
#include "../../../shared/cpp/ObjectModel/TextRun.h"
#include "../../../shared/cpp/ObjectModel/RichTextElementProperties.h"
%}

%shared_ptr(AdaptiveCards::BackgroundImage)
Expand Down Expand Up @@ -187,6 +188,7 @@ struct tm {
%shared_ptr(AdaptiveCards::RichTextBlockParser)
%shared_ptr(AdaptiveCards::TextRun)
%shared_ptr(AdaptiveCards::TextElementProperties)
%shared_ptr(AdaptiveCards::RichTextElementProperties)

%apply unsigned int& INOUT { unsigned int& };

Expand Down Expand Up @@ -803,3 +805,4 @@ namespace Json {
%include "../../../shared/cpp/ObjectModel/Inline.h"
%include "../../../shared/cpp/ObjectModel/RichTextBlock.h"
%include "../../../shared/cpp/ObjectModel/TextRun.h"
%include "../../../shared/cpp/ObjectModel/RichTextElementProperties.h"
175 changes: 175 additions & 0 deletions source/android/adaptivecards/src/main/cpp/objectmodel_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ namespace Swig {
#include "../../../shared/cpp/ObjectModel/Inline.h"
#include "../../../shared/cpp/ObjectModel/RichTextBlock.h"
#include "../../../shared/cpp/ObjectModel/TextRun.h"
#include "../../../shared/cpp/ObjectModel/RichTextElementProperties.h"

SWIGINTERN std::string Json_Value_getString(Json::Value *self){
Json::StreamWriterBuilder builder;
Expand Down Expand Up @@ -27967,6 +27968,170 @@ SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMod
}


SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_new_1RichTextElementProperties_1_1SWIG_10(JNIEnv *jenv, jclass jcls) {
jlong jresult = 0 ;
AdaptiveCards::RichTextElementProperties *result = 0 ;

(void)jenv;
(void)jcls;
result = (AdaptiveCards::RichTextElementProperties *)new AdaptiveCards::RichTextElementProperties();

*(std::shared_ptr< AdaptiveCards::RichTextElementProperties > **)&jresult = result ? new std::shared_ptr< AdaptiveCards::RichTextElementProperties >(result SWIG_NO_NULL_DELETER_1) : 0;

return jresult;
}


SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_new_1RichTextElementProperties_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
jlong jresult = 0 ;
AdaptiveCards::TextConfig *arg1 = 0 ;
std::string *arg2 = 0 ;
std::string *arg3 = 0 ;
AdaptiveCards::RichTextElementProperties *result = 0 ;

(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(AdaptiveCards::TextConfig **)&jarg1;
if (!arg1) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "AdaptiveCards::TextConfig const & reference is null");
return 0;
}
if(!jarg2) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
return 0;
}
const char *arg2_pstr = (const char *)jenv->GetStringUTFChars(jarg2, 0);
if (!arg2_pstr) return 0;
std::string arg2_str(arg2_pstr);
arg2 = &arg2_str;
jenv->ReleaseStringUTFChars(jarg2, arg2_pstr);
if(!jarg3) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
return 0;
}
const char *arg3_pstr = (const char *)jenv->GetStringUTFChars(jarg3, 0);
if (!arg3_pstr) return 0;
std::string arg3_str(arg3_pstr);
arg3 = &arg3_str;
jenv->ReleaseStringUTFChars(jarg3, arg3_pstr);
result = (AdaptiveCards::RichTextElementProperties *)new AdaptiveCards::RichTextElementProperties((AdaptiveCards::TextConfig const &)*arg1,(std::string const &)*arg2,(std::string const &)*arg3);

*(std::shared_ptr< AdaptiveCards::RichTextElementProperties > **)&jresult = result ? new std::shared_ptr< AdaptiveCards::RichTextElementProperties >(result SWIG_NO_NULL_DELETER_1) : 0;

return jresult;
}


SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_new_1RichTextElementProperties_1_1SWIG_12(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
jlong jresult = 0 ;
AdaptiveCards::RichTextElementProperties *arg1 = 0 ;
AdaptiveCards::RichTextElementProperties *result = 0 ;

(void)jenv;
(void)jcls;
(void)jarg1_;

arg1 = (AdaptiveCards::RichTextElementProperties *)((*(std::shared_ptr< const AdaptiveCards::RichTextElementProperties > **)&jarg1) ? (*(std::shared_ptr< const AdaptiveCards::RichTextElementProperties > **)&jarg1)->get() : 0);
if (!arg1) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "AdaptiveCards::RichTextElementProperties const & reference is null");
return 0;
}
result = (AdaptiveCards::RichTextElementProperties *)new AdaptiveCards::RichTextElementProperties((AdaptiveCards::RichTextElementProperties const &)*arg1);

*(std::shared_ptr< AdaptiveCards::RichTextElementProperties > **)&jresult = result ? new std::shared_ptr< AdaptiveCards::RichTextElementProperties >(result SWIG_NO_NULL_DELETER_1) : 0;

return jresult;
}


SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_delete_1RichTextElementProperties(JNIEnv *jenv, jclass jcls, jlong jarg1) {
AdaptiveCards::RichTextElementProperties *arg1 = (AdaptiveCards::RichTextElementProperties *) 0 ;
std::shared_ptr< AdaptiveCards::RichTextElementProperties > *smartarg1 = 0 ;

(void)jenv;
(void)jcls;

smartarg1 = *(std::shared_ptr< AdaptiveCards::RichTextElementProperties > **)&jarg1;
arg1 = (AdaptiveCards::RichTextElementProperties *)(smartarg1 ? smartarg1->get() : 0);
(void)arg1; delete smartarg1;
}


SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_RichTextElementProperties_1SerializeToJsonValue(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) {
jlong jresult = 0 ;
AdaptiveCards::RichTextElementProperties *arg1 = (AdaptiveCards::RichTextElementProperties *) 0 ;
Json::Value *arg2 = 0 ;
std::shared_ptr< AdaptiveCards::RichTextElementProperties const > *smartarg1 = 0 ;
Json::Value result;

(void)jenv;
(void)jcls;
(void)jarg1_;
(void)jarg2_;

smartarg1 = *(std::shared_ptr< const AdaptiveCards::RichTextElementProperties > **)&jarg1;
arg1 = (AdaptiveCards::RichTextElementProperties *)(smartarg1 ? smartarg1->get() : 0);
arg2 = *(Json::Value **)&jarg2;
if (!arg2) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Json::Value & reference is null");
return 0;
}
result = ((AdaptiveCards::RichTextElementProperties const *)arg1)->SerializeToJsonValue(*arg2);
*(Json::Value **)&jresult = new Json::Value((const Json::Value &)result);
return jresult;
}


SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_RichTextElementProperties_1Deserialize(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_, jlong jarg3, jobject jarg3_) {
AdaptiveCards::RichTextElementProperties *arg1 = (AdaptiveCards::RichTextElementProperties *) 0 ;
AdaptiveCards::ParseContext *arg2 = 0 ;
Json::Value *arg3 = 0 ;
std::shared_ptr< AdaptiveCards::RichTextElementProperties > *smartarg1 = 0 ;

(void)jenv;
(void)jcls;
(void)jarg1_;
(void)jarg2_;
(void)jarg3_;

smartarg1 = *(std::shared_ptr< AdaptiveCards::RichTextElementProperties > **)&jarg1;
arg1 = (AdaptiveCards::RichTextElementProperties *)(smartarg1 ? smartarg1->get() : 0);

arg2 = (AdaptiveCards::ParseContext *)((*(std::shared_ptr< const AdaptiveCards::ParseContext > **)&jarg2) ? (*(std::shared_ptr< const AdaptiveCards::ParseContext > **)&jarg2)->get() : 0);
if (!arg2) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "AdaptiveCards::ParseContext const & reference is null");
return ;
}
arg3 = *(Json::Value **)&jarg3;
if (!arg3) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Json::Value const & reference is null");
return ;
}
(arg1)->Deserialize((AdaptiveCards::ParseContext const &)*arg2,(Json::Value const &)*arg3);
}


SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_RichTextElementProperties_1PopulateKnownPropertiesSet(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) {
AdaptiveCards::RichTextElementProperties *arg1 = (AdaptiveCards::RichTextElementProperties *) 0 ;
std::unordered_set< std::string > *arg2 = 0 ;
std::shared_ptr< AdaptiveCards::RichTextElementProperties > *smartarg1 = 0 ;

(void)jenv;
(void)jcls;
(void)jarg1_;

smartarg1 = *(std::shared_ptr< AdaptiveCards::RichTextElementProperties > **)&jarg1;
arg1 = (AdaptiveCards::RichTextElementProperties *)(smartarg1 ? smartarg1->get() : 0);
arg2 = *(std::unordered_set< std::string > **)&jarg2;
if (!arg2) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "std::unordered_set< std::string > & reference is null");
return ;
}
(arg1)->PopulateKnownPropertiesSet(*arg2);
}


SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_BaseCardElement_1SWIGSmartPtrUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) {
jlong baseptr = 0;
std::shared_ptr< AdaptiveCards::BaseCardElement > *argp1;
Expand Down Expand Up @@ -28477,6 +28642,16 @@ SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectMod
return baseptr;
}

SWIGEXPORT jlong JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_RichTextElementProperties_1SWIGSmartPtrUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) {
jlong baseptr = 0;
std::shared_ptr< AdaptiveCards::RichTextElementProperties > *argp1;
(void)jenv;
(void)jcls;
argp1 = *(std::shared_ptr< AdaptiveCards::RichTextElementProperties > **)&jarg1;
*(std::shared_ptr< AdaptiveCards::TextElementProperties > **)&baseptr = argp1 ? new std::shared_ptr< AdaptiveCards::TextElementProperties >(*argp1) : 0;
return baseptr;
}

SWIGEXPORT void JNICALL Java_io_adaptivecards_objectmodel_AdaptiveCardObjectModelJNI_swig_1module_1init(JNIEnv *jenv, jclass jcls) {
int i;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,13 @@ public class AdaptiveCardObjectModelJNI {
public final static native long TextRun_GetSelectAction(long jarg1, TextRun jarg1_);
public final static native void TextRun_SetSelectAction(long jarg1, TextRun jarg1_, long jarg2, BaseActionElement jarg2_);
public final static native long TextRun_dynamic_cast(long jarg1, Inline jarg1_);
public final static native long new_RichTextElementProperties__SWIG_0();
public final static native long new_RichTextElementProperties__SWIG_1(long jarg1, TextConfig jarg1_, String jarg2, String jarg3);
public final static native long new_RichTextElementProperties__SWIG_2(long jarg1, RichTextElementProperties jarg1_);
public final static native void delete_RichTextElementProperties(long jarg1);
public final static native long RichTextElementProperties_SerializeToJsonValue(long jarg1, RichTextElementProperties jarg1_, long jarg2, JsonValue jarg2_);
public final static native void RichTextElementProperties_Deserialize(long jarg1, RichTextElementProperties jarg1_, long jarg2, ParseContext jarg2_, long jarg3, JsonValue jarg3_);
public final static native void RichTextElementProperties_PopulateKnownPropertiesSet(long jarg1, RichTextElementProperties jarg1_, long jarg2);
public final static native long BaseCardElement_SWIGSmartPtrUpcast(long jarg1);
public final static native long BaseActionElement_SWIGSmartPtrUpcast(long jarg1);
public final static native long BaseInputElement_SWIGSmartPtrUpcast(long jarg1);
Expand Down Expand Up @@ -1401,6 +1408,7 @@ public class AdaptiveCardObjectModelJNI {
public final static native long RichTextBlock_SWIGSmartPtrUpcast(long jarg1);
public final static native long RichTextBlockParser_SWIGSmartPtrUpcast(long jarg1);
public final static native long TextRun_SWIGSmartPtrUpcast(long jarg1);
public final static native long RichTextElementProperties_SWIGSmartPtrUpcast(long jarg1);

public static String SwigDirector_BaseElement_GetId(BaseElement jself) {
return jself.GetId();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.0
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */

package io.adaptivecards.objectmodel;

public class RichTextElementProperties extends TextElementProperties {
private transient long swigCPtr;
private transient boolean swigCMemOwnDerived;

protected RichTextElementProperties(long cPtr, boolean cMemoryOwn) {
super(AdaptiveCardObjectModelJNI.RichTextElementProperties_SWIGSmartPtrUpcast(cPtr), true);
swigCMemOwnDerived = cMemoryOwn;
swigCPtr = cPtr;
}

protected static long getCPtr(RichTextElementProperties obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}

protected void swigSetCMemOwn(boolean own) {
swigCMemOwnDerived = own;
super.swigSetCMemOwn(own);
}

protected void finalize() {
delete();
}

public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwnDerived) {
swigCMemOwnDerived = false;
AdaptiveCardObjectModelJNI.delete_RichTextElementProperties(swigCPtr);
}
swigCPtr = 0;
}
super.delete();
}

public RichTextElementProperties() {
this(AdaptiveCardObjectModelJNI.new_RichTextElementProperties__SWIG_0(), true);
}

public RichTextElementProperties(TextConfig arg0, String arg1, String arg2) {
this(AdaptiveCardObjectModelJNI.new_RichTextElementProperties__SWIG_1(TextConfig.getCPtr(arg0), arg0, arg1, arg2), true);
}

public RichTextElementProperties(RichTextElementProperties arg0) {
this(AdaptiveCardObjectModelJNI.new_RichTextElementProperties__SWIG_2(RichTextElementProperties.getCPtr(arg0), arg0), true);
}

public JsonValue SerializeToJsonValue(JsonValue root) {
return new JsonValue(AdaptiveCardObjectModelJNI.RichTextElementProperties_SerializeToJsonValue(swigCPtr, this, JsonValue.getCPtr(root), root), true);
}

public void Deserialize(ParseContext context, JsonValue root) {
AdaptiveCardObjectModelJNI.RichTextElementProperties_Deserialize(swigCPtr, this, ParseContext.getCPtr(context), context, JsonValue.getCPtr(root), root);
}

public void PopulateKnownPropertiesSet(SWIGTYPE_p_std__unordered_setT_std__string_t knownProperties) {
AdaptiveCardObjectModelJNI.RichTextElementProperties_PopulateKnownPropertiesSet(swigCPtr, this, SWIGTYPE_p_std__unordered_setT_std__string_t.getCPtr(knownProperties));
}

}
Loading

0 comments on commit 6c21173

Please sign in to comment.