Method addExportName split in getName and addName
This commit is contained in:
parent
3365665d23
commit
79784f0f7c
9 changed files with 71 additions and 52 deletions
|
@ -109,10 +109,9 @@ public class ExportNameCollection{
|
|||
}
|
||||
}
|
||||
|
||||
public String addToExport(String sName) {
|
||||
// add the name, if it does not exist
|
||||
if (!containsName(sName)) { addName(sName); }
|
||||
return sPrefix + exportNames.get(sName);
|
||||
public String getName(String name) {
|
||||
return sPrefix + exportNames.get(name);
|
||||
|
||||
}
|
||||
|
||||
public boolean containsName(String sName) {
|
||||
|
|
|
@ -328,12 +328,14 @@ public class Converter extends BasicConverter {
|
|||
Integer targetIndex = targets.get(ld.sId);
|
||||
if (targetIndex!=null) {
|
||||
int nTargetIndex = targetIndex.intValue();
|
||||
targetNames.addName(ld.sId);
|
||||
if (nTargetIndex == ld.nIndex) { // same file
|
||||
ld.element.setAttribute("href","#"+targetNames.addToExport(ld.sId));
|
||||
|
||||
ld.element.setAttribute("href","#"+targetNames.getName(ld.sId));
|
||||
}
|
||||
else {
|
||||
ld.element.setAttribute("href",getOutFileName(nTargetIndex,true)
|
||||
+"#"+targetNames.addToExport(ld.sId));
|
||||
ld.element.setAttribute("href",getOutFileName(nTargetIndex,true)
|
||||
+"#"+targetNames.getName(ld.sId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -813,14 +815,16 @@ public class Converter extends BasicConverter {
|
|||
// create a target
|
||||
public Element createTarget(String sId) {
|
||||
Element a = htmlDOM.createElement("a");
|
||||
a.setAttribute("id",targetNames.addToExport(sId));
|
||||
targetNames.addName(sId);
|
||||
a.setAttribute("id",targetNames.getName(sId));
|
||||
targets.put(sId, new Integer(outFileIndex));
|
||||
return a;
|
||||
}
|
||||
|
||||
// put a target id on an existing element
|
||||
public void addTarget(Element node,String sId) {
|
||||
node.setAttribute("id",targetNames.addToExport(sId));
|
||||
targetNames.addName(sId);
|
||||
node.setAttribute("id",targetNames.getName(sId));
|
||||
targets.put(sId, new Integer(outFileIndex));
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,8 @@ public class FrameStyleParser extends StyleWithPropertiesParser {
|
|||
buf.append(getStyleTag());
|
||||
buf.append(".");
|
||||
buf.append(getClassNamePrefix());
|
||||
buf.append(styleNames.addToExport(sDisplayName));
|
||||
styleNames.addName(sDisplayName);
|
||||
buf.append(styleNames.getName(sDisplayName));
|
||||
buf.append(" p {");
|
||||
buf.append(props.toString());
|
||||
buf.append("}");
|
||||
|
|
|
@ -85,7 +85,8 @@ public class HeadingStyleParser extends StyleParser {
|
|||
result.append("h");
|
||||
result.append(i);
|
||||
result.append(".");
|
||||
result.append(styleNames.addToExport(sDisplayName));
|
||||
styleNames.addName(sDisplayName);
|
||||
result.append(styleNames.getName(sDisplayName));
|
||||
result.append(" {");
|
||||
result.append(props.toString());
|
||||
result.append("}");
|
||||
|
@ -107,34 +108,37 @@ public class HeadingStyleParser extends StyleParser {
|
|||
* @param info add style information to this StyleInfo
|
||||
*/
|
||||
public void applyStyle(int nLevel, String sStyleName, StyleInfo info) {
|
||||
StyleWithProperties style = (StyleWithProperties) getStyles().getStyle(sStyleName);
|
||||
if (style!=null) {
|
||||
if (config.multilingual()) { applyLang(style,info); }
|
||||
applyDirection(style,info);
|
||||
if (style.isAutomatic()) {
|
||||
// Apply parent style + hard formatting
|
||||
applyStyle(nLevel, style.getParentName(),info);
|
||||
if (bConvertHard) { getParSc().applyProperties(style,info.props,false); }
|
||||
}
|
||||
else {
|
||||
String sDisplayName = style.getDisplayName();
|
||||
if (styleMap.contains(sDisplayName)) {
|
||||
// Apply attributes as specified in style map from user
|
||||
XhtmlStyleMapItem map = styleMap.get(sDisplayName);
|
||||
info.sTagName = map.sBlockElement;
|
||||
if (!"(none)".equals(map.sBlockCss)) {
|
||||
info.sClass = map.sBlockCss;
|
||||
}
|
||||
}
|
||||
else if (style!=ofr.getHeadingStyle(nLevel)) {
|
||||
// This is not the main style for this level, add class and remember
|
||||
info.sClass = styleNames.addToExport(sDisplayName);
|
||||
if (1<=nLevel && nLevel<=6) {
|
||||
otherLevelStyles.get(nLevel).add(sDisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
StyleWithProperties style = (StyleWithProperties) getStyles().getStyle(sStyleName);
|
||||
if (style != null) {
|
||||
if (config.multilingual()) {
|
||||
applyLang(style, info);
|
||||
}
|
||||
applyDirection(style, info);
|
||||
if (style.isAutomatic()) {
|
||||
// Apply parent style + hard formatting
|
||||
applyStyle(nLevel, style.getParentName(), info);
|
||||
if (bConvertHard) {
|
||||
getParSc().applyProperties(style, info.props, false);
|
||||
}
|
||||
} else {
|
||||
String sDisplayName = style.getDisplayName();
|
||||
if (styleMap.contains(sDisplayName)) {
|
||||
// Apply attributes as specified in style map from user
|
||||
XhtmlStyleMapItem map = styleMap.get(sDisplayName);
|
||||
info.sTagName = map.sBlockElement;
|
||||
if (!"(none)".equals(map.sBlockCss)) {
|
||||
info.sClass = map.sBlockCss;
|
||||
}
|
||||
} else if (style != ofr.getHeadingStyle(nLevel)) {
|
||||
// This is not the main style for this level, add class and remember
|
||||
styleNames.addName(sDisplayName);
|
||||
info.sClass = styleNames.getName(sDisplayName);
|
||||
if (1 <= nLevel && nLevel <= 6) {
|
||||
otherLevelStyles.get(nLevel).add(sDisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Apply an inner style on a heading. The inner style surrounds the text content, excluding the numbering label.
|
||||
|
|
|
@ -78,8 +78,8 @@ public class ListStyleParser extends StyleParser {
|
|||
}
|
||||
}
|
||||
else {
|
||||
info.sClass = "listlevel"+Integer.toString(nLevel)
|
||||
+styleNames.addToExport(sDisplayName);
|
||||
styleNames.addName(sDisplayName);
|
||||
info.sClass = "listlevel"+Integer.toString(nLevel)+styleNames.getName(sDisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,8 @@ public class ListStyleParser extends StyleParser {
|
|||
buf.append(indent);
|
||||
buf.append(".listlevel");
|
||||
buf.append(nLevel);
|
||||
buf.append(styleNames.addToExport(sDisplayName));
|
||||
styleNames.addName(sDisplayName);
|
||||
buf.append(styleNames.getName(sDisplayName));
|
||||
buf.append(" {");
|
||||
buf.append(props.toString());
|
||||
buf.append("}");
|
||||
|
@ -120,7 +121,8 @@ public class ListStyleParser extends StyleParser {
|
|||
buf.append(indent);
|
||||
buf.append(".listlevel");
|
||||
buf.append(nLevel);
|
||||
buf.append(styleNames.addToExport(sDisplayName));
|
||||
styleNames.addName(sDisplayName);
|
||||
buf.append(styleNames.getName(sDisplayName));
|
||||
buf.append(" p {");
|
||||
buf.append(parProps.toString());
|
||||
buf.append("}");
|
||||
|
|
|
@ -123,7 +123,8 @@ public class PageStyleParser extends StyleParser {
|
|||
String sDisplayName = masterPage.getDisplayName();
|
||||
if (ofr.isPresentation()) {
|
||||
// Always generates class name
|
||||
info.sClass="masterpage"+styleNames.addToExport(sDisplayName);
|
||||
styleNames.addName(sDisplayName);
|
||||
info.sClass="masterpage"+styleNames.getName(sDisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +157,8 @@ public class PageStyleParser extends StyleParser {
|
|||
// Then export the results
|
||||
buf.append(indent);
|
||||
buf.append(".masterpage");
|
||||
buf.append(styleNames.addToExport(sDisplayName));
|
||||
styleNames.addName(sDisplayName);
|
||||
buf.append(styleNames.getName(sDisplayName));
|
||||
buf.append(" {");
|
||||
buf.append(info.props.toString());
|
||||
buf.append("}");
|
||||
|
|
|
@ -105,7 +105,8 @@ public class PresentationStyleParser extends FrameStyleParser {
|
|||
if (!props.isEmpty()) {
|
||||
buf.append(indent);
|
||||
buf.append("li.outline");
|
||||
buf.append(styleNames.addToExport(sDisplayName));
|
||||
styleNames.addName(sDisplayName);
|
||||
buf.append(styleNames.getName(sDisplayName));
|
||||
buf.append(" p {");
|
||||
buf.append(props.toString());
|
||||
buf.append("}");
|
||||
|
@ -151,7 +152,9 @@ public class PresentationStyleParser extends FrameStyleParser {
|
|||
public void applyOutlineStyle(int nLevel, StyleInfo info) {
|
||||
if (2<=nLevel && nLevel<=9 && sCurrentOutlineStyle!=null) {
|
||||
if (outlineStyles.containsKey(sCurrentOutlineStyle)) {
|
||||
info.sClass = "outline"+outlineStyleNames.addToExport(outlineStyles.get(sCurrentOutlineStyle)[nLevel]);
|
||||
String name = outlineStyles.get(sCurrentOutlineStyle)[nLevel];
|
||||
outlineStyleNames.addName(name);
|
||||
info.sClass = "outline"+outlineStyleNames.getName(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,8 +84,9 @@ public abstract class StyleWithPropertiesParser extends StyleParser {
|
|||
}
|
||||
else {
|
||||
// Generate class name from display name
|
||||
styleNames.addName(sDisplayName);
|
||||
info.sClass = getClassNamePrefix()
|
||||
+ styleNames.addToExport(sDisplayName);
|
||||
+ styleNames.getName(sDisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +111,8 @@ public abstract class StyleWithPropertiesParser extends StyleParser {
|
|||
buf.append(getStyleTag());
|
||||
buf.append(".");
|
||||
buf.append(getClassNamePrefix());
|
||||
buf.append(styleNames.addToExport(sDisplayName));
|
||||
styleNames.addName(sDisplayName);
|
||||
buf.append(styleNames.getName(sDisplayName));
|
||||
buf.append(" {");
|
||||
buf.append(props.toString());
|
||||
buf.append("}");
|
||||
|
|
|
@ -136,11 +136,13 @@ public class TextStyleParser extends StyleWithPropertiesParser {
|
|||
// This combination is not seen before, but the base style may be known
|
||||
// In that case, use the visited style name as well
|
||||
if (anchorStyleNames.containsName(sStyleName)) {
|
||||
sExportName = anchorStyleNames.addToExport(sStyleName)
|
||||
+anchorVisitedStyleNames.addToExport(sVisitedStyleName);
|
||||
anchorStyleNames.addName(sStyleName);
|
||||
anchorStyleNames.addName(sVisitedStyleName);
|
||||
sExportName = anchorStyleNames.getName(sStyleName)+anchorVisitedStyleNames.getName(sVisitedStyleName);
|
||||
}
|
||||
else {
|
||||
sExportName = anchorStyleNames.addToExport(sStyleName);
|
||||
anchorStyleNames.addName(sStyleName);
|
||||
sExportName = anchorStyleNames.getName(sStyleName);
|
||||
}
|
||||
anchorCombinedStyleNames.put(sName,sExportName);
|
||||
orgAnchorStyleNames.put(sExportName,sStyleName);
|
||||
|
|
Loading…
Add table
Reference in a new issue