本文的目的是介绍织梦CMS后台添加图片style全部都变成stxyle的解决教的详细情况,特别关注织梦图片集如何调用的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解织
本文的目的是介绍织梦CMS后台添加图片style全部都变成stxyle的解决教的详细情况,特别关注织梦图片集如何调用的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解织梦CMS后台添加图片style全部都变成stxyle的解决教的机会,同时也不会遗漏关于$_G['style']['styleimgdir']模板中直接使用扩张图片路径引用文件!、android.text.style.CharacterStyle的实例源码、android.text.style.ParagraphStyle的实例源码、Checkstyle的style的知识。
本文目录一览:- 织梦CMS后台添加图片style全部都变成stxyle的解决教(织梦图片集如何调用)
- $_G['style']['styleimgdir']模板中直接使用扩张图片路径引用文件!
- android.text.style.CharacterStyle的实例源码
- android.text.style.ParagraphStyle的实例源码
- Checkstyle的style
织梦CMS后台添加图片style全部都变成stxyle的解决教(织梦图片集如何调用)
织梦CMS图集自定义字段里面传的图片代码都会变成yle=“width... 在baidu多次寻找无果 在官网论坛也找了N久 都不顶用 自己细节分析
发现会把style替换为st<x>y<x>le,多了两个“<x>”,在代码里面搜索发现是官网为了过滤而设定得
比如
1、给文字添加蓝色属性:保存后会发现文字前面多了yle="color:blue;">,而且原先添加的标题3属性丢失
源代码里面是这样显示的:<h3 x="">yle="color:blue;">织梦58</h3>
正常的源代码需要是这样:<h3>织梦58</h3>
2、给图片添加长宽属性:保存后变成如下效果:
织梦CMS后台添加图片style全部都变成st<x>yle的解决方案
下面就告诉大家解决的办法:
打开/include/datalistcp.class.php文件,在第237行的位置找到如下代码:
$replacement = substr($ra[$i], 0, 2).'<x>'.substr($ra[$i], 2);
将其替换为以下代码:
$replacement = substr($ra[$i], 0, 2).substr($ra[$i], 2);
然后找到/include/filter.helper.php文件,在大概第98行左右的位置找到如下代码:
$replacement = substr($ra[$i], 0, 2).'<x>'.substr($ra[$i], 2);
将其替换为如下代码:
$replacement = substr($ra[$i], 0, 2).substr($ra[$i], 2);
替换完成后覆盖保存即可,然后在后台发布内容就会发现不会自动替换了。
本文章网址:http://www.ppssdd.com/code/10264.html。转载请保留出处,谢谢合作!$_G['style']['styleimgdir']模板中直接使用扩张图片路径引用文件!
styleimgdir选项!
我们在模板中可以直接使用
- $_G[''style''][''styleimgdir'']
总结
以上是小编为你收集整理的$_G[''style''][''styleimgdir'']模板中直接使用扩张图片路径引用文件!全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
android.text.style.CharacterStyle的实例源码
public void invalidateSpannables() { log("invalidating all spannables -- consider everything nullified"); final Spannable spans = getText(); final String text = spans.toString(); // Remove existing spans for (CharacterStyle style : mSpans) { spans.removeSpan(style); } // Loop over the text,looking for new spans for (int i = 0; i < text.length(); i++) { for (SpanComponent component : mComponents) { String equation = component.parse(text.substring(i)); if (equation != null) { MathSpannable span = component.getSpan(equation); spans.setSpan(span,i,i + equation.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); i += equation.length(); break; } } } setSelection(getSelectionStart()); }
/** * Given either a Spannable String or a regular String and a token,apply * the given CharacterStyle to the span between the tokens. * <p> * NOTE: This method was adapted from: * http://www.androidengineer.com/2010/08/easy-method-for-formatting-android.html * <p> * <p> * For example,{@code setSpanBetweenTokens("Hello ##world##!","##",new * ForegroundColorSpan(0xFFFF0000));} will return a CharSequence {@code * "Hello World!"} with {@code world} in red. */ private CharSequence setSpanBetweenTokens(CharSequence text,String token,CharacterStyle... cs) { // Start and end refer to the points where the span will apply int tokenLen = token.length(); int start = text.toString().indexOf(token) + tokenLen; int end = text.toString().indexOf(token,start); if (start > -1 && end > -1) { // copy the spannable string to a mutable spannable string SpannableStringBuilder ssb = new SpannableStringBuilder(text); for (CharacterStyle c : cs) ssb.setSpan(c,start,end,0); text = ssb; } return text; }
void setBold(boolean isBold) { int index = getSelectionIndex(); if (index >= 0 && index < mSections.size()) { mSections.get(index).setBold(isBold); } Editable edit = getEditableText(); int star = getSectionStart(); int end = getSectionEnd(); if (isBold) { edit.setSpan(new StyleSpan(Typeface.BOLD),star,Typeface.BOLD); } else { StyleSpan[] styleSpans = edit.getSpans(star,StyleSpan.class); for (CharacterStyle span : styleSpans) { if (span instanceof StyleSpan && ((StyleSpan) span).getStyle() == Typeface.BOLD) edit.removeSpan(span); } } }
void setItalic(boolean isItalic) { int index = getSelectionIndex(); if (index >= 0 && index < mSections.size()) { mSections.get(index).setItalic(isItalic); } Editable edit = getEditableText(); int star = getSectionStart(); int end = getSectionEnd(); if (isItalic) { edit.setSpan(new StyleSpan(Typeface.ITALIC),Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { StyleSpan[] styleSpans = edit.getSpans(star,StyleSpan.class); for (CharacterStyle span : styleSpans) { if (span instanceof StyleSpan && ((StyleSpan) span).getStyle() == Typeface.ITALIC) edit.removeSpan(span); } } }
void setItalic(boolean isItalic,int index) { if (index >= 0 && index < mSections.size()) { mSections.get(index).setItalic(isItalic); } Editable edit = getEditableText(); int star = getSectionStart(); int end = getSectionEnd(); if (isItalic) { edit.setSpan(new StyleSpan(Typeface.ITALIC),StyleSpan.class); for (CharacterStyle span : styleSpans) { if (span instanceof StyleSpan && ((StyleSpan) span).getStyle() == Typeface.ITALIC) edit.removeSpan(span); } } }
void setBold(boolean isBold,int index) { if (index >= 0 && index < mSections.size()) { mSections.get(index).setBold(isBold); } Editable edit = getEditableText(); int star = getSectionStart(index); int end = getSectionEnd(index); if (star >= end) return; if (isBold) { edit.setSpan(new StyleSpan(Typeface.BOLD),StyleSpan.class); for (CharacterStyle span : styleSpans) { if (span instanceof StyleSpan && ((StyleSpan) span).getStyle() == Typeface.BOLD) edit.removeSpan(span); } } }
public static <A extends CharacterStyle,B extends CharacterStyle> Spannable replaceAll(Spanned original,Class<A> sourceType,SpanConverter<A,B> converter,final ClickSpan.OnClickListener listener) { SpannableString result = new SpannableString(original); A[] spans = result.getSpans(0,result.length(),sourceType); for (A span : spans) { int start = result.getSpanStart(span); int end = result.getSpanEnd(span); int flags = result.getSpanFlags(span); result.removeSpan(span); result.setSpan(converter.convert(span,listener),flags); } return (result); }
/** * 检查当前位置是否命中在spannable上,如果是,返回spannable的start position */ private int findStartPosition(Spannable spannable,int startWidthPosition) { CharacterStyle[] oldSpans = spannable.getSpans(startWidthPosition,spannable.length(),CharacterStyle.class); int position = startWidthPosition; for (CharacterStyle oldSpan : oldSpans) { int spanStart = spannable.getSpanStart(oldSpan); int spanEnd = spannable.getSpanEnd(oldSpan); if (spanStart <= startWidthPosition && spanEnd > startWidthPosition) { position = spanStart; } if (spanStart >= startWidthPosition) { spannable.removeSpan(oldSpan); } } //L.e("call: findStartPosition([spannable,startWidthPosition]) " + startWidthPosition + " -> " + position); return position; }
/** * Given either a Spannable String or a regular String and a token,apply * the given CharacterStyle to the span between the tokens. * <p/> * NOTE: This method was adapted from: * http://www.androidengineer.com/2010/08/easy-method-for-formatting-android.html * <p/> * <p/> * For example,0); text = ssb; } return text; }
/** * Convert a spanned text within a paragraph */ private void withinParagraph(final Spanned text,int start,int end) { // create sorted set of CharacterStyles SortedSet<CharacterStyle> sortedSpans = new TreeSet<>(new Comparator<CharacterStyle>() { @Override public int compare(CharacterStyle s1,CharacterStyle s2) { int start1 = text.getSpanStart(s1); int start2 = text.getSpanStart(s2); if (start1 != start2) return start1 - start2; // span which starts first comes first int end1 = text.getSpanEnd(s1); int end2 = text.getSpanEnd(s2); if (end1 != end2) return end2 - end1; // longer span comes first // if the paragraphs have the same span [start,end] we compare their name // compare the name only because local + anonymous classes have no canonical name return s1.getClass().getName().compareto(s2.getClass().getName()); } }); List<CharacterStyle> spanList = Arrays.asList(text.getSpans(start,CharacterStyle.class)); sortedSpans.addAll(spanList); // process paragraphs/divs convertText(text,sortedSpans); }
private void handleEndTag(CharacterStyle style) { if (style instanceof URLSpan) { mOut.append("</a>"); } else if (style instanceof TypefaceSpan) { mOut.append("</font>"); } else if (style instanceof ForegroundColorSpan) { mOut.append("</font>"); } else if (style instanceof BackgroundColorSpan) { mOut.append("</font>"); } else if (style instanceof AbsoluteSizeSpan) { mOut.append("</font>"); } else if (style instanceof StrikethroughSpan) { mOut.append("</strike>"); } else if (style instanceof SubscriptSpan) { mOut.append("</sub>"); } else if (style instanceof SuperscriptSpan) { mOut.append("</sup>"); } else if (style instanceof Underlinespan) { mOut.append("</u>"); } else if (style instanceof BoldSpan) { mOut.append("</b>"); } else if (style instanceof ItalicSpan) { mOut.append("</i>"); } }
private void init(CharSequence source,int end) { int initial = 20; mSpans = new Object[initial]; mSpanData = new int[initial * 3]; if (source instanceof Spanned) { Spanned sp = (Spanned) source; for (Object span : sp.getSpans(start,Object.class)) { if (span instanceof CharacterStyle || span instanceof ParagraphStyle) { int st = sp.getSpanStart(span); int en = sp.getSpanEnd(span); int fl = sp.getSpanFlags(span); if (st < start) st = start; if (en > end) en = end; setSpan(span,st - start,en - start,fl); } } } }
/** * Convert a spanned text within a paragraph */ private void withinParagraph(final Spanned text,int end) { // create sorted set of CharacterStyles SortedSet<CharacterStyle> sortedSpans = new TreeSet<CharacterStyle>(new Comparator<CharacterStyle>() { @Override public int compare(CharacterStyle s1,sortedSpans); }
/** * {@inheritDoc} * @param s */ @Override public void afterTextChanged(Editable s) { for (CharacterStyle style: mLastStyle) { s.removeSpan(style); } List<MarkdownSyntaxModel> models = MarkdownSyntaxGenerator.SyntaxModelsForString(s.toString()); if (models.size() == 0) { return; } mLastStyle.clear(); for (MarkdownSyntaxModel model : models) { MarkdownSyntaxType type = model.getSyntaxType(); Range range = model.getRange(); // CharacterStyle style = MarkdownSyntaxGenerator.styleFromSyntaxType(type); int low = range.getLower(); int upper = range.getUpper(); // mLastStyle.add(style); // s.setSpan(style,low,upper,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } }
public static SpannableStringBuilder highlight(String text,String target) { SpannableStringBuilder spannable = new SpannableStringBuilder(text); CharacterStyle span = null; for (int i = 0; i < specials.length; i++) { if (target.contains(specials[i])) { target = target.replace(specials[i],"\\" + specials[i]); } } Pattern p = Pattern.compile(target.toLowerCase()); Matcher m = p.matcher(text.toLowerCase()); while (m.find()) { span = new ForegroundColorSpan(Color.rgb(253,113,34));// 需要重复! spannable.setSpan(span,m.start(),m.end(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } return spannable; }
/** * Replace the control codes * * @param m * @param ssb * @param style */ private static void replaceControlCodes(Matcher m,SpannableStringBuilder ssb,CharacterStyle style) { ArrayList<Integer> toremove = new ArrayList<Integer>(); while ( m.find() ) { toremove.add(0,m.start()); // Remove the ending control character unless it's \x0F if( m.group(2) != null && m.group(2) != m.group(3) ) { toremove.add(0,m.end() - 1); } ssb.setSpan(style,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } for( Integer i : toremove ) { ssb.delete(i,i + 1); } }
/** * Convert a spanned text within a paragraph */ private void withinParagraph(final Spanned text,sortedSpans); }
private void handleEndTag(CharacterStyle style) { if (style instanceof URLSpan) { mOut.append("</a>"); } else if (style instanceof TypefaceSpan) { mOut.append("</font>"); } else if (style instanceof ForegroundColorSpan) { mOut.append("</font>"); } else if (style instanceof BackgroundColorSpan) { mOut.append("</font>"); } else if (style instanceof AbsoluteSizeSpan) { mOut.append("</font>"); } else if (style instanceof StrikethroughSpan) { mOut.append("</strike>"); } else if (style instanceof SubscriptSpan) { mOut.append("</sub>"); } else if (style instanceof SuperscriptSpan) { mOut.append("</sup>"); } else if (style instanceof Underlinespan) { mOut.append("</u>"); } else if (style instanceof BoldSpan) { mOut.append("</b>"); } else if (style instanceof ItalicSpan) { mOut.append("</i>"); } }
private void init(CharSequence source,fl); } } } }
@Override public int getSize(@NonNull Rect outRect,@NonNull Paint paint,CharSequence text,@IntRange(from = 0) int start,@IntRange(from = 0) int end,@Nullable Paint.FontMetricsInt fm) { int width = super.getSize(outRect,paint,text,fm); if (styles != null) { for (CharacterStyle style : styles) { if (style instanceof SupportSpan) { width = Math.max(width,((SupportSpan) style).getSize(frame,fm)); } else if (style instanceof ReplacementSpan) { width = Math.max(width,((ReplacementSpan) style).getSize(paint,fm)); } else if (paint instanceof TextPaint) { if (style instanceof MetricAffectingSpan) { ((MetricAffectingSpan) style).updateMeasureState((TextPaint) paint); } } } } frame.right = width; return width; }
@Override public int getSize(@NonNull Paint paint,@Nullable Paint.FontMetricsInt fm) { width = 0; for (CharacterStyle style : styles) { if (style instanceof ReplacementSpan) { width = Math.max(width,fm)); } else if (paint instanceof TextPaint) { if (style instanceof MetricAffectingSpan) { ((MetricAffectingSpan) style).updateMeasureState((TextPaint) paint); } } } if (fm != null) { paint.getFontMetricsInt(fm); } paint.getFontMetricsInt(fontMetricsInt); width = Math.max(width,(int) Math.ceil(paint.measureText(text,end))); frame.right = width; frame.top = fontMetricsInt.top; frame.bottom = fontMetricsInt.bottom; if (bitmap == null) { bitmap = Bitmap.createBitmap(width,frame.bottom - frame.top,Bitmap.Config.ARGB_8888); bitmapCanvas = new Canvas(bitmap); } return width; }
@Override public void draw(@NonNull Canvas canvas,float x,int top,int y,int bottom,@NonNull Paint paint) { // bitmapCanvas.drawColor(Color.GRAY,PorterDuff.Mode.CLEAR); int color = /*paint instanceof TextPaint ? ((TextPaint) paint).bgColor :*/ paint.getColor(); bitmapCanvas.drawColor(color); for (CharacterStyle style : styles) { if (style instanceof ReplacementSpan) { ((ReplacementSpan) style).draw(bitmapCanvas,top,y,bottom,paint); } else if (paint instanceof TextPaint) { style.updateDrawState((TextPaint) paint); } } paint.setXfermode(xfermode); bitmapCanvas.drawText(text,paint); canvas.drawBitmap(bitmap,x,null); }
/** * Convert a spanned text within a paragraph */ private void withinParagraph(final Spanned text,int end) { // create sorted set of CharacterStyles SortedSet<CharacterStyle> sortedSpans = new TreeSet<>((s1,s2) -> { int start1 = text.getSpanStart(s1); int start2 = text.getSpanStart(s2); if (start1 != start2) return start1 - start2; // span which starts first comes first int end1 = text.getSpanEnd(s1); int end2 = text.getSpanEnd(s2); if (end1 != end2) return end2 - end1; // longer span comes first // if the paragraphs have the same span [start,end] we compare their name // compare the name only because local + anonymous classes have no canonical name return s1.getClass().getName().compareto(s2.getClass().getName()); }); List<CharacterStyle> spanList = Arrays.asList(text.getSpans(start,sortedSpans); }
private void handleEndTag(CharacterStyle style) { if (style instanceof URLSpan) { mOut.append("</a>"); } else if (style instanceof TypefaceSpan) { mOut.append("</font>"); } else if (style instanceof ForegroundColorSpan) { mOut.append("</font>"); } else if (style instanceof BackgroundColorSpan) { mOut.append("</font>"); } else if (style instanceof AbsoluteSizeSpan) { mOut.append("</font>"); } else if (style instanceof StrikethroughSpan) { mOut.append("</strike>"); } else if (style instanceof SubscriptSpan) { mOut.append("</sub>"); } else if (style instanceof SuperscriptSpan) { mOut.append("</sup>"); } else if (style instanceof Underlinespan) { mOut.append("</u>"); } else if (style instanceof BoldSpan) { mOut.append("</b>"); } else if (style instanceof ItalicSpan) { mOut.append("</i>"); } }
private void init(CharSequence source,fl); } } } }
private void writeStyles(CharacterStyle styles[],DataOutputStream dos) throws IOException { dos.writeInt(styles.length); for(CharacterStyle characterStyle : styles) { writeSingleCharacterStyle(characterStyle,dos); // if (characterStyle.getUnderlying()!=null) { // CharacterStyle underLying = characterStyle.getUnderlying(); // if (!mWrittenTags.containsKey(underLying)) { // writeSingleCharacterStyle(underLying,dos); // } // int writtenTag = mWrittenTags.get(underLying); // dos.writeInt(-2); // dos.writeInt(writtenTag); // } else { // // } dos.writeInt(0xf00f); // sync mark } dos.writeInt(0xf00e); // sync mark }
public static <A extends CharacterStyle,B extends CharacterStyle> Spannable replaceAll( CharSequence original,B> converter) { SpannableString result = new SpannableString(original); A[] spans = result.getSpans(0,sourceType); for (A span : spans) { int start = result.getSpanStart(span); int end = result.getSpanEnd(span); int flags = result.getSpanFlags(span); result.removeSpan(span); result.setSpan(converter.convert(span),flags); } return (result); }
@CalledByNative private void populateUnderlinesFromSpans(CharSequence text,long underlines) { if (DEBUG_LOGS) { Log.i(TAG,"populateUnderlinesFromSpans: text [%s],underlines [%d]",underlines); } if (!(text instanceof SpannableString)) return; SpannableString spannableString = ((SpannableString) text); CharacterStyle spans[] = spannableString.getSpans(0,text.length(),CharacterStyle.class); for (CharacterStyle span : spans) { if (span instanceof BackgroundColorSpan) { nativeAppendBackgroundColorSpan(underlines,spannableString.getSpanStart(span),spannableString.getSpanEnd(span),((BackgroundColorSpan) span).getBackgroundColor()); } else if (span instanceof Underlinespan) { nativeAppendUnderlinespan(underlines,spannableString.getSpanEnd(span)); } } }
private static void setPreferenceTitleStyle(Preference preference,boolean bold,/*boolean underline,*/ boolean errorColor) { if (preference != null) { CharSequence title = preference.getTitle(); Spannable sbt = new SpannableString(title); Object spansToRemove[] = sbt.getSpans(0,title.length(),Object.class); for (Object span : spansToRemove) { if (span instanceof CharacterStyle) sbt.removeSpan(span); } if (bold/* || underline*/) { //if (bold) sbt.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),sbt.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); /*if (underline) sbt.setSpan(new Underlinespan(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);*/ if (errorColor) sbt.setSpan(new ForegroundColorSpan(Color.RED),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); preference.setTitle(sbt); } else { preference.setTitle(sbt); } } }
private void setTextStyle(TextView textView,boolean errorColor) { if (textView != null) { CharSequence title = textView.getText(); Spannable sbt = new SpannableString(title); Object spansToRemove[] = sbt.getSpans(0,Object.class); for (Object span : spansToRemove) { if (span instanceof CharacterStyle) sbt.removeSpan(span); } if (errorColor) { sbt.setSpan(new ForegroundColorSpan(Color.RED),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(sbt); } else { textView.setText(sbt); } } }
private void setTitleStyle(Preference preference,boolean underline,boolean systemSettings) { if (preference != null) { CharSequence title = preference.getTitle(); if (systemSettings) { String s = title.toString(); if (!s.contains("(S)")) title = TextUtils.concat("(S) ",title); } Spannable sbt = new SpannableString(title); Object spansToRemove[] = sbt.getSpans(0,Object.class); for (Object span : spansToRemove) { if (span instanceof CharacterStyle) sbt.removeSpan(span); } if (bold || underline) { if (bold) sbt.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); if (underline) sbt.setSpan(new Underlinespan(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); preference.setTitle(sbt); } else { preference.setTitle(sbt); } } }
private void setTextStyle(TextView textView,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(sbt); } else { textView.setText(sbt); } } }
/** * Replace the control codes * * @param m * @param ssb * @param style */ private static void replaceControlCodes(Matcher m,CharacterStyle style) { ArrayList<Integer> toremove = new ArrayList<Integer>(); while (m.find()) { toremove.add(0,m.start()); // Remove the ending control character unless it's \x0F if (m.group(2) != null && m.group(2) != m.group(3)) { toremove.add(0,m.end()-1); } ssb.setSpan(style,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } for (Integer i : toremove) { ssb.delete(i,i+1); } }
public static <A extends CharacterStyle,flags); } return (result); }
public static <A extends CharacterStyle,B> converter) { SpannableString result=new SpannableString(original); A[] spans=result.getSpans(0,sourceType); for (A span : spans) { int start=result.getSpanStart(span); int end=result.getSpanEnd(span); int flags=result.getSpanFlags(span); result.removeSpan(span); result.setSpan(converter.convert(span),flags); } return(result); }
android.text.style.ParagraphStyle的实例源码
/** * Create Span for matches in paragraph's. Note that this will highlight the full matched pattern * (including optionals) if no group parameters are given. * * @param editable Text editable * @param pattern The pattern to match * @param creator A ParcelableSpanCreator for ParcelableSpan * @param groupsToMatch (optional) groups to be matched,indexes start at 1. */ protected void createSpanForMatchesP(final Editable editable,final Pattern pattern,final ParagraphStyleCreator creator,int... groupsToMatch) { if (groupsToMatch == null || groupsToMatch.length < 1) { groupsToMatch = new int[]{0}; } int i = 0; for (Matcher m = pattern.matcher(editable); m.find(); i++) { ParagraphStyle span = creator.create(m,i); if (span != null) { for (int g : groupsToMatch) { if (g == 0 || g <= m.groupCount()) { editable.setSpan(span,m.start(g),m.end(g),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } } } }
private void init(CharSequence source,int start,int end) { int initial = 20; mSpans = new Object[initial]; mSpanData = new int[initial * 3]; if (source instanceof Spanned) { Spanned sp = (Spanned) source; for (Object span : sp.getSpans(start,end,Object.class)) { if (span instanceof CharacterStyle || span instanceof ParagraphStyle) { int st = sp.getSpanStart(span); int en = sp.getSpanEnd(span); int fl = sp.getSpanFlags(span); if (st < start) st = start; if (en > end) en = end; setSpan(span,st - start,en - start,fl); } } } }
private void init(CharSequence source,fl); } } } }
@Override /* SpanWatcher */ public void onSpanAdded(Spannable text,Object what,int end) { mTextChanged = true; // we need to keep track of ordered list spans if (what instanceof BulletSpan) { mIsBulletSpanSelected = true; // if text was empty then append zero width char // in order for the bullet to be shown when the span is selected if (text.toString().isEmpty()) { this.append("\u200B"); } } else if (what instanceof NumberSpan) { mIsNumberSpanSelected = true; // if text was empty then append zero width char // in order for the number to be shown when the span is selected if (text.toString().isEmpty()) { this.append("\u200B"); } } if (what instanceof RTSpan && what instanceof ParagraphStyle) { setParagraphsAreUp2Date(false); } }
private void init(CharSequence source,fl); } } } }
private <T extends ParagraphStyle> void clearParagraphSpanType(Editable editable,Class<T> spanType) { ParagraphStyle[] spans = editable.getSpans(0,editable.length(),spanType); for (int n = spans.length; n-- > 0; ) { editable.removeSpan(spans[n]); } }
private static void encodeTextAlignmentByDiv(Context context,StringBuilder out,Spanned text,int option) { int len = text.length(); int next; for (int i = 0; i < len; i = next) { next = text.nextSpanTransition(i,len,ParagraphStyle.class); ParagraphStyle[] styles = text.getSpans(i,next,ParagraphStyle.class); String elements = " "; boolean needDiv = false; for (ParagraphStyle style : styles) { if (style instanceof AlignmentSpan) { Layout.Alignment align = ((AlignmentSpan) style).getAlignment(); needDiv = true; if (align == Layout.Alignment.ALIGN_CENTER) { elements = "align=\"center\" " + elements; } else if (align == Layout.Alignment.ALIGN_OPPOSITE) { elements = "align=\"right\" " + elements; } else { elements = "align=\"left\" " + elements; } } } if (needDiv) { out.append("<div ").append(elements).append(">"); } withindiv(context,out,text,i,option); if (needDiv) { out.append("</div>"); } } }
private static void encodeTextAlignmentByDiv(StringBuilder out,ParagraphStyle.class); ParagraphStyle[] style = text.getSpans(i,ParagraphStyle.class); String elements = " "; boolean needDiv = false; for (int j = 0; j < style.length; j++) { if (style[j] instanceof AlignmentSpan) { Layout.Alignment align = ((AlignmentSpan) style[j]).getAlignment(); needDiv = true; if (align == Layout.Alignment.ALIGN_CENTER) { elements = "align=\"center\" " + elements; } else if (align == Layout.Alignment.ALIGN_OPPOSITE) { elements = "align=\"right\" " + elements; } else { elements = "align=\"left\" " + elements; } } } if (needDiv) { out.append("<div ").append(elements).append(">"); } withindiv(out,option); if (needDiv) { out.append("</div>"); } } }
private Set<SingleParagraphStyle> getParagraphStyles(final Spanned text,Selection selection) { Set<SingleParagraphStyle> styles = new HashSet<>(); for (ParagraphStyle style : text.getSpans(selection.start(),selection.end(),ParagraphStyle.class)) { ParagraphType type = ParagraphType.getInstance(style); if (type != null) { styles.add(new SingleParagraphStyle(type,style)); } } return styles; }
@Override /* SpanWatcher */ public void onSpanAdded(Spannable text,int end) { mTextChanged = true; if (what instanceof RTSpan && what instanceof ParagraphStyle) { setParagraphsAreUp2Date(false); } }
@Override /* SpanWatcher */ public void onSpanChanged(Spannable text,int ostart,int oend,int nstart,int nend) { mTextChanged = true; if (what instanceof RTSpan && what instanceof ParagraphStyle) { setParagraphsAreUp2Date(false); } }
@Override /* SpanWatcher */ public void onSpanRemoved(Spannable text,int end) { mTextChanged = true; if (what instanceof RTSpan && what instanceof ParagraphStyle) { setParagraphsAreUp2Date(false); } }
private Set<SingleParagraphStyle> getParagraphStyles(final Spanned text,Selection selection) { Set<SingleParagraphStyle> styles = new HashSet<SingleParagraphStyle>(); for (ParagraphStyle style : text.getSpans(selection.start(),style)); } } return styles; }
public Spanned convert() { mReader.setContentHandler(this); try { mReader.parse(new InputSource(new StringReader(text))); } catch (SAXException | IOException e) { // We are reading from a string. There should not be IO problems. throw new RuntimeException(e); } // Fix flags and range for paragraph-type markup. Object[] obj = mSpannableStringBuilder.getSpans(0,mSpannableStringBuilder.length(),ParagraphStyle.class); for (Object ob : obj) { int start = mSpannableStringBuilder.getSpanStart(ob); int end = mSpannableStringBuilder.getSpanEnd(ob); // If the last line of the range is blank,back off by one. if (end - 2 >= 0) { if (mSpannableStringBuilder.charat(end - 1) == '\n' && mSpannableStringBuilder.charat(end - 2) == '\n') { end--; } } if (end == start) { mSpannableStringBuilder.removeSpan(ob); } else { mSpannableStringBuilder.setSpan(ob,start,Spannable.SPAN_ParaGRAPH); } } return mSpannableStringBuilder; }
public Spanned convert() { try{ SAXParserFactory saxFactory = SAXParserFactory.newInstance(); SAXParser saxParser = saxFactory.newSAXParser();//利用获取到的对象创建一个解析器 XMLReader xmlReader =saxFactory.newSAXParser().getXMLReader(); //获取一个XMLReader xmlReader.setContentHandler(this); xmlReader.parse(new InputSource(new StringReader(mSource))); }catch (Exception e){ e.printstacktrace(); } // Fix flags and range for paragraph-type markup. Object[] obj = mSpannableStringBuilder.getSpans(0,ParagraphStyle.class); for (int i = 0; i < obj.length; i++) { int start = mSpannableStringBuilder.getSpanStart(obj[i]); int end = mSpannableStringBuilder.getSpanEnd(obj[i]); // If the last line of the range is blank,back off by one. if (end - 2 >= 0) { if (mSpannableStringBuilder.charat(end - 1) == '\n' && mSpannableStringBuilder.charat(end - 2) == '\n') { end--; } } if (end == start) { mSpannableStringBuilder.removeSpan(obj[i]); } else { mSpannableStringBuilder.setSpan(obj[i],Spannable.SPAN_ParaGRAPH); } } return mSpannableStringBuilder; }
private Set<SingleParagraphStyle> getParagraphStyles(final Spanned text,style)); } } return styles; }
@Override /* SpanWatcher */ public void onSpanAdded(Spannable text,int end) { mTextChanged = true; if (what instanceof RTSpan && what instanceof ParagraphStyle) { setParagraphsAreUp2Date(false); } }
@Override /* SpanWatcher */ public void onSpanChanged(Spannable text,int nend) { mTextChanged = true; if (what instanceof RTSpan && what instanceof ParagraphStyle) { setParagraphsAreUp2Date(false); } }
@Override /* SpanWatcher */ public void onSpanRemoved(Spannable text,int end) { mTextChanged = true; if (what instanceof RTSpan && what instanceof ParagraphStyle) { setParagraphsAreUp2Date(false); } }
private static void withinHtml(StringBuilder out,Spanned text) { int len = text.length(); int next; for (int i = 0; i < text.length(); i = next) { next = text.nextSpanTransition(i,ParagraphStyle.class); String elements = " "; boolean needDiv = false; for(int j = 0; j < style.length; j++) { if (style[j] instanceof AlignmentSpan) { Layout.Alignment align = ((AlignmentSpan) style[j]).getAlignment(); needDiv = true; if (align == Layout.Alignment.ALIGN_CENTER) { elements = "align=\"center\" " + elements; } else if (align == Layout.Alignment.ALIGN_OPPOSITE) { elements = "align=\"right\" " + elements; } else { elements = "align=\"left\" " + elements; } } } if (needDiv) { out.append("<div ").append(elements).append(">"); } withindiv(out,next); if (needDiv) { out.append("</div>"); } } }
private static void withinHtml(StringBuilder out,next); if (needDiv) { out.append("</div>"); } } }
public SpannableStringBuilder convert() { mReader.setContentHandler(this); try { mReader.parse(new InputSource(new StringReader(mSource))); } catch (IOException | SAXException e) { // We are reading from a string. There should not be IO problems. throw new RuntimeException(e); } // Fix flags and range for paragraph-type markup. Object[] obj = mSpannableStringBuilder.getSpans(0,ParagraphStyle.class); for (int i = 0; i < obj.length; i++) { int start = mSpannableStringBuilder.getSpanStart(obj[i]); int end = mSpannableStringBuilder.getSpanEnd(obj[i]); // If the last line of the range is blank,back off by one. if (end - 2 >= 0) { if (mSpannableStringBuilder.charat(end - 1) == '\n' && mSpannableStringBuilder.charat(end - 2) == '\n') { end--; } } if (end == start) { mSpannableStringBuilder.removeSpan(obj[i]); } else { mSpannableStringBuilder.setSpan(obj[i],Spannable.SPAN_ParaGRAPH); } } return mSpannableStringBuilder; }
private Set<SingleParagraphStyle> getParagraphStyles(final Spanned text,style)); } } return styles; }
@Override /* SpanWatcher */ public void onSpanChanged(Spannable text,int nend) { mTextChanged = true; if (what instanceof RTSpan && what instanceof ParagraphStyle) { setParagraphsAreUp2Date(false); } }
@Override /* SpanWatcher */ public void onSpanRemoved(Spannable text,int end) { mTextChanged = true; // we need to keep track of ordered list spans if (what instanceof BulletSpan) { mIsBulletSpanSelected = false; } else if (what instanceof NumberSpan) { mIsNumberSpanSelected = false; } if (what instanceof RTSpan && what instanceof ParagraphStyle) { setParagraphsAreUp2Date(false); } }
public Spanned convert() { mReader.setContentHandler(this); try { mReader.parse(new InputSource(new StringReader(mSource))); } catch (IOException | SAXException e) { // We are reading from a string. There should not be IO problems. throw new RuntimeException(e); } // Fix flags and range for paragraph-type markup. Object[] obj = mSpannableStringBuilder.getSpans(0,back off by one. if (end - 2 >= 0 && mSpannableStringBuilder.charat(end - 1) == '\n' && mSpannableStringBuilder.charat(end - 2) == '\n') { end--; } if (end == start) { mSpannableStringBuilder.removeSpan(obj[i]); } else { mSpannableStringBuilder.setSpan(obj[i],Spannable.SPAN_ParaGRAPH); } } return mSpannableStringBuilder; }
/** * serialize Spanned to DataOutputStream * @param dos * @throws IOException */ public void serialize(DataOutputStream dos) throws IOException { CharacterStyle[] styles = mString.getSpans(0,mString.length(),CharacterStyle.class); ParagraphStyle[] paragraphs = mString.getSpans(0,ParagraphStyle.class); dos.writeInt(VERSION); dos.writeInt(getClassNameHash()); dos.writeUTF(mString.toString()); dos.writeInt(0x1030); writeStyles(styles,dos); dos.writeInt(0x1030); writeParagraphs(paragraphs,dos); dos.writeInt(0x1030); }
private void writeParagraphs(ParagraphStyle paragraphStyle[],DataOutputStream dos) throws IOException { dos.writeInt(paragraphStyle.length); for (ParagraphStyle style : paragraphStyle) { writeSingleParagraphStyle(style,dos); dos.writeInt(0xe00e); // sync mark } }
private void writeSingleParagraphStyle(ParagraphStyle style,DataOutputStream dos) throws IOException { Class clazz = style.getClass(); dos.writeInt(mString.getSpanStart(style)); dos.writeInt(mString.getSpanEnd(style)); dos.writeInt(mString.getSpanFlags(style)); if (mCharacterStylesTags.containsKey(clazz.getSimpleName())) { int tag = mCharacterStylesTags.get(clazz.getSimpleName()); if (mCharacterStylesTags.containsKey(clazz.getSimpleName())) { dos.writeInt(tag); } switch (tag) { case 24: // AligmentSpan.Standard AlignmentSpan.Standard as2 = (AlignmentSpan.Standard)style; dos.writeInt(as2.getAlignment().ordinal()); break; case 25: // BulletSpan BulletSpan bs = (BulletSpan)style; dos.writeInt(bs.getLeadingMargin(true)); dos.writeInt(bs.getLeadingMargin(false)); break; case 30: // LeadingMarginSpan.Sandard LeadingMarginSpan.Standard lms = (LeadingMarginSpan.Standard)style; dos.writeInt(lms.getLeadingMargin(true)); dos.writeInt(lms.getLeadingMargin(false)); break; case 34: // QuoteSpan QuoteSpan qs = (QuoteSpan)style; dos.writeInt(qs.getColor()); break; case 36: // TabStopSpan.Standard TabStopSpan.Standard tss = (TabStopSpan.Standard)style; dos.writeInt(tss.getTabStop()); break; default: } } else { write(style,dos); } }
private static void withinHtml(StringBuilder out,ParagraphStyle.class); /*ParagraphStyle[] style = text.getSpans(i,ParagraphStyle.class); String elements = " "; boolean needDiv = false; for (int j = 0; j < style.length; j++) { if (style[j] instanceof AlignmentSpan) { Layout.Alignment align = ((AlignmentSpan) style[j]) .getAlignment(); needDiv = true; if (align == Layout.Alignment.ALIGN_CENTER) { elements = "align=\"center\" " + elements; } else if (align == Layout.Alignment.ALIGN_OPPOSITE) { elements = "align=\"right\" " + elements; } else { elements = "align=\"left\" " + elements; } } } if (needDiv) { out.append("<div " + elements + ">"); }*/ withindiv(out,next); /*if (needDiv) { out.append("</div>"); }*/ } }
private static void withinHtml(StringBuilder out,next); if (needDiv) { out.append("</div>"); } } }
private boolean hasstyleSpan(Spanned spanned) { // Only check against those three classes below,which Could affect text appearance,since // there are other kind of classes won't affect appearance. Class<?>[] styleClasses = { CharacterStyle.class,ParagraphStyle.class,UpdateAppearance.class}; for (Class<?> clazz : styleClasses) { if (spanned.nextSpanTransition(-1,spanned.length(),clazz) < spanned.length()) { return true; } } return false; }
private boolean hasstyleSpan(Spanned spanned) { Class<?>[] styleClasses = { CharacterStyle.class,clazz) < spanned.length()) { return true; } } return false; }
private static void withinHtml(StringBuilder out,Spanned text) { int next; for (int i = 0; i < text.length(); i = next) { next = text.nextSpanTransition(i,text.length(),ParagraphStyle.class); ParagraphStyle[] styles = text.getSpans(i,ParagraphStyle.class); if (styles.length == 2) { if (styles[0] instanceof BulletSpan && styles[1] instanceof QuoteSpan) { // Let a <br> follow the BulletSpan or QuoteSpan end,so next++ withinBulletThenQuote(out,next++); } else if (styles[0] instanceof QuoteSpan && styles[1] instanceof BulletSpan) { withinQuoteThenBullet(out,next++); } else { withinContent(out,next); } } else if (styles.length == 1) { if (styles[0] instanceof BulletSpan) { withinBullet(out,next++); } else if (styles[0] instanceof QuoteSpan) { withinQuote(out,next); } } else { withinContent(out,next); } } }
private static void withinHtml(StringBuilder out,ParagraphStyle.class); String elements = " "; boolean needDiv = false; for(int j = 0; j < style.length; j++) { if (style[j] instanceof AlignmentSpan) { Layout.Alignment align = ((AlignmentSpan) style[j]).getAlignment(); needDiv = true; if (align == Layout.Alignment.ALIGN_CENTER) { elements = "align=\"center\" " + elements; } else if (align == Layout.Alignment.ALIGN_OPPOSITE) { elements = "align=\"right\" " + elements; } else { elements = "align=\"left\" " + elements; } } } if (needDiv) { out.append("<div " + elements + ">"); } withindiv(out,next); if (needDiv) { out.append("</div>"); } } }
private void onSpanAdded(Object span) { if (span instanceof MetricAffectingSpan) { mHasMetricAffectingSpan = true; } if (span instanceof ReplacementSpan) { mHasReplacementSpan = true; } if (span instanceof ParagraphStyle) { mHasParagraphStyle = true; } }
Checkstyle的style
checkstyle是什么?
是代码规范检查,关于各种格式的利弊这里就不说了,但是业内有一些总结的规范利于goole或者阿里有自己的代码规范,就需要用到checkstyle。我个人很讨厌这东西,奈何项目再用,那就研究一下吧。
checkstyle的使用
我们项目是用maven引得包,如下
<dependency>
<groupId>app.myoss.cloud.codestyle</groupId>
<artifactId>code-format-eclipse</artifactId>
<version>2.0.2.RELEASE</version>
<scope>test</scope>
</dependency>
这是一个哥们独立开发的一个jar包。检查的非常详细,详细到什么地图呢,举个例子,http请求只允许使用自己封装的一套。。。 感受一下
<module name="RegexpSinglelineJava">
<property name="format" value="java\.util\.Calendar"/>
<property name="message" value="请使用 Java 8 新的日期 API,比如:java.time.LocalDateTime/java.time.LocalDate !"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="org\.apache\.commons\.lang\.\S+"/>
<property name="message" value="禁止使用 org.apache.commons.lang 旧依赖,请使用 org.apache.commons.lang3 新依赖 !"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="org\.apache\.commons\.logging\.\S+"/>
<property name="message" value="禁止使用 org.apache.commons.logging 输出日志,请使用 org.slf4j.Logger 输出日志 !"/>
<property name="ignoreComments" value="true"/>
</module>
<module name="RegexpSinglelineJava">
<property name="format" value="lombok\.extern\.apachecommons\.CommonsLog"/>
<property name="message" value="禁止使用 lombok.extern.apachecommons.CommonsLog 输出日志,请使用 org.slf4j.Logger 输出日志 !"/>
<property name="ignoreComments" value="true"/>
</module>
推荐网站:https://github.com/checkstyle/checkstyle
关于织梦CMS后台添加图片style全部都变成stxyle的解决教和织梦图片集如何调用的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于$_G['style']['styleimgdir']模板中直接使用扩张图片路径引用文件!、android.text.style.CharacterStyle的实例源码、android.text.style.ParagraphStyle的实例源码、Checkstyle的style的相关信息,请在本站寻找。
本文标签: